Use rstrlcpy() for printFileInfo() username + group fields
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 17 Apr 2008 14:39:08 +0000 (17:39 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 17 Apr 2008 14:39:08 +0000 (17:39 +0300)
- just avoids having to manually ensure zero-termination

lib/query.c

index d642c80..f118aba 100644 (file)
@@ -50,11 +50,8 @@ static void printFileInfo(const char * name,
        if (tm) nowtm = *tm;    /* structure assignment */
     }
 
-    strncpy(ownerfield, owner, sizeof(ownerfield));
-    ownerfield[sizeof(ownerfield)-1] = '\0';
-
-    strncpy(groupfield, group, sizeof(groupfield));
-    groupfield[sizeof(groupfield)-1] = '\0';
+    rstrlcpy(ownerfield, owner, sizeof(ownerfield));
+    rstrlcpy(groupfield, group, sizeof(groupfield));
 
     /* this is normally right */
     sprintf(sizefield, "%12u", size);