fix strncat misuse

The third argument of strncat() tells how much data to append from
src, not the total size of the buffer.

Change uses of strncat() to strlcat(), which has the buffer overflow
protection behavior intended by the original author.

This fixes the following compiler warning:

In function 'strncat',
    inlined from 'print_type' at system/core/toolbox/lsof.c:76:12:
bionic/libc/include/string.h:142:5: warning: call to __builtin___strncat_chk might overflow destination buffer [enabled by default]

Change-Id: Id69edc641de3cb87d1867a409cd57b04b12f90a7
diff --git a/toolbox/lsof.c b/toolbox/lsof.c
index 376a642..113c120 100644
--- a/toolbox/lsof.c
+++ b/toolbox/lsof.c
@@ -54,7 +54,7 @@
     ssize_t parent_length;
 };
 
-void print_header()
+static void print_header()
 {
     printf("%-9s %5s %10s %4s %9s %18s %9s %10s %s\n",
             "COMMAND",
@@ -68,12 +68,12 @@
             "NAME");
 }
 
-void print_type(char *type, struct pid_info_t* info)
+static void print_type(char *type, struct pid_info_t* info)
 {
     static ssize_t link_dest_size;
     static char link_dest[PATH_MAX];
 
-    strncat(info->path, type, sizeof(info->path));
+    strlcat(info->path, type, sizeof(info->path));
     if ((link_dest_size = readlink(info->path, link_dest, sizeof(link_dest)-1)) < 0) {
         if (errno == ENOENT)
             goto out;
@@ -96,7 +96,7 @@
 }
 
 // Prints out all file that have been memory mapped
-void print_maps(struct pid_info_t* info)
+static void print_maps(struct pid_info_t* info)
 {
     FILE *maps;
     char buffer[PATH_MAX + 100];
@@ -107,7 +107,7 @@
     long int inode;
     char file[PATH_MAX];
 
-    strncat(info->path, "maps", sizeof(info->path));
+    strlcat(info->path, "maps", sizeof(info->path));
 
     maps = fopen(info->path, "r");
     if (!maps)
@@ -131,10 +131,10 @@
 }
 
 // Prints out all open file descriptors
-void print_fds(struct pid_info_t* info)
+static void print_fds(struct pid_info_t* info)
 {
     static char* fd_path = "fd/";
-    strncat(info->path, fd_path, sizeof(info->path));
+    strlcat(info->path, fd_path, sizeof(info->path));
 
     int previous_length = info->parent_length;
     info->parent_length += strlen(fd_path);
@@ -163,7 +163,7 @@
     info->path[info->parent_length] = '\0';
 }
 
-void lsof_dumpinfo(pid_t pid)
+static void lsof_dumpinfo(pid_t pid)
 {
     int fd;
     struct pid_info_t info;
@@ -187,7 +187,7 @@
     }
 
     // Read the command line information; each argument is terminated with NULL.
-    strncat(info.path, "cmdline", sizeof(info.path));
+    strlcat(info.path, "cmdline", sizeof(info.path));
     fd = open(info.path, O_RDONLY);
     if (fd < 0) {
         fprintf(stderr, "Couldn't read %s\n", info.path);