From 82effc97f9f2d1c258ea50cb11b130753b8ba805 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 1 Jan 2015 16:59:35 -0600 Subject: Switch a lot of strncpy() calls to xstrncpy(). --- toys/pending/netstat.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'toys/pending/netstat.c') diff --git a/toys/pending/netstat.c b/toys/pending/netstat.c index 59355638..fbb9eb12 100644 --- a/toys/pending/netstat.c +++ b/toys/pending/netstat.c @@ -76,15 +76,6 @@ static const char *get_basename(char *name) if (c) return c + 1; return name; } -/* - * copy string from src to dest -> only number of bytes. - */ -static char *safe_strncpy(char *dst, char *src, size_t size) -{ - if(!size) return dst; - dst[--size] = '\0'; - return strncpy(dst, src, size); -} /* * locate character in string. @@ -410,7 +401,7 @@ static void add2list(long inode, char *progname) } PID_LIST *new = (PID_LIST *)xzalloc(sizeof(PID_LIST)); new->inode = inode; - safe_strncpy(new->name, progname, PROGNAME_LEN-1); + xstrncpy(new->name, progname, PROGNAME_LEN); new->next = pid_list; pid_list = new; } -- cgit v1.2.3