Use rstrlcpy() for various parseForFoo() functions in build
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 17 Apr 2008 15:13:52 +0000 (18:13 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 17 Apr 2008 15:13:52 +0000 (18:13 +0300)
- just avoids manual termination, no new fixes here..

build/files.c

index 56e62cd..0d80529 100644 (file)
@@ -319,8 +319,7 @@ static rpmRC parseForVerify(const char * buf, FileList fl)
 
     /* Localize. Erase parsed string */
     q = alloca((pe-p) + 1);
-    strncpy(q, p, pe-p);
-    q[pe-p] = '\0';
+    rstrlcpy(q, p, pe-p);
     while (p <= pe)
        *p++ = ' ';
 
@@ -400,8 +399,7 @@ static rpmRC parseForDev(const char * buf, FileList fl)
 
     /* Localize. Erase parsed string */
     q = alloca((pe-p) + 1);
-    strncpy(q, p, pe-p);
-    q[pe-p] = '\0';
+    rstrlcpy(q, p, pe-p);
     while (p <= pe)
        *p++ = ' ';
 
@@ -514,8 +512,7 @@ static int parseForAttr(const char * buf, FileList fl)
 
     /* Localize. Erase parsed string */
     q = alloca((pe-p) + 1);
-    strncpy(q, p, pe-p);
-    q[pe-p] = '\0';
+    rstrlcpy(q, p, pe-p);
     while (p <= pe)
        *p++ = ' ';
 
@@ -624,8 +621,7 @@ static rpmRC parseForConfig(const char * buf, FileList fl)
 
     /* Localize. Erase parsed string. */
     q = alloca((pe-p) + 1);
-    strncpy(q, p, pe-p);
-    q[pe-p] = '\0';
+    rstrlcpy(q, p, pe-p);
     while (p <= pe)
        *p++ = ' ';
 
@@ -694,8 +690,7 @@ static int parseForLang(const char * buf, FileList fl)
 
     /* Localize. Erase parsed string. */
     q = alloca((pe-p) + 1);
-    strncpy(q, p, pe-p);
-    q[pe-p] = '\0';
+    rstrlcpy(q, p, pe-p);
     while (p <= pe)
        *p++ = ' ';
 
@@ -735,8 +730,7 @@ static int parseForLang(const char * buf, FileList fl)
        fl->currentLangs = xrealloc(fl->currentLangs,
                                (fl->nLangs + 1) * sizeof(*fl->currentLangs));
        newp = xmalloc( np+1 );
-       strncpy(newp, p, np);
-       newp[np] = '\0';
+       rstrlcpy(newp, p, np);
        fl->currentLangs[fl->nLangs++] = newp;
        if (*pe == ',') pe++;   /* skip , if present */
     }