Hi!

Now that you've added strnul(3) and use it in some places, you may want
to also replace another set of strlen(3) uses by strnul(3):

        diff --git i/lib/file-has-acl.c w/lib/file-has-acl.c
        index 26d3e358de7a..3269d7f71b7e 100644
        --- i/lib/file-has-acl.c
        +++ w/lib/file-has-acl.c
        @@ -145,7 +145,7 @@ aclinfo_has_xattr (struct aclinfo const *ai, char 
const *xattr)
           if (0 < ai->size)
             {
               char const *blim = ai->buf + ai->size;
        -      for (char const *b = ai->buf; b < blim; b += strlen (b) + 1)
        +      for (char const *b = ai->buf; b < blim; b = strnul (b) + 1)
                 for (char const *a = xattr; *a == *b; a++, b++)
                   if (!*a)
                     return true;
        diff --git i/lib/getopt.c w/lib/getopt.c
        index 406a406b9bfa..9df03cf5e9bc 100644
        --- i/lib/getopt.c
        +++ w/lib/getopt.c
        @@ -302,7 +302,7 @@ process_long_option (int argc, char **argv, const 
char *optstring,
                        }
                    }
                  free (ambig_malloced);
        -         d->__nextchar += strlen (d->__nextchar);
        +         d->__nextchar = strnul (d->__nextchar);
                  d->optind++;
                  d->optopt = 0;
                  return '?';
        diff --git i/lib/inet_ntop.c w/lib/inet_ntop.c
        index 599ca4fb723a..dff25c5f6d33 100644
        --- i/lib/inet_ntop.c
        +++ w/lib/inet_ntop.c
        @@ -225,7 +225,7 @@ inet_ntop6 (const unsigned char *src, char *dst, 
socklen_t size)
                 {
                   if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
                     return (NULL);
        -          tp += strlen (tp);
        +          tp = strnul (tp);
                   break;
                 }
               {
        diff --git i/lib/time_rz.c w/lib/time_rz.c
        index 811240e6da16..0e8ea47e7916 100644
        --- i/lib/time_rz.c
        +++ w/lib/time_rz.c
        @@ -146,7 +146,7 @@ save_abbr (timezone_t tz, struct tm *tm)
                       break;
                     }
         
        -          zone_copy += strlen (zone_copy) + 1;
        +          zone_copy = strnul (zone_copy) + 1;
                   if (!*zone_copy && tz->next)
                     {
                       tz = tz->next;
        diff --git i/tests/test-savedir.c w/tests/test-savedir.c
        index 95abc7833bb9..c95408c52fad 100644
        --- i/tests/test-savedir.c
        +++ w/tests/test-savedir.c
        @@ -44,7 +44,7 @@ test_savedir_sort_none (void)
           memset (seen, 0, sizeof seen);
         
           /* Scan through the file names.  */
        -  for (char *namep = name_space; *namep != '\0'; namep += strlen 
(namep) + 1)
        +  for (char *namep = name_space; *namep != '\0'; namep = strnul 
(namep) + 1)
             {
               int index = *namep - 'a';
               ASSERT (strlen (namep) == 1);
        @@ -68,7 +68,7 @@ test_savedir_sort_name (void)
         
           /* Check that files "a" to "z" appear in order.  */
           for (char *namep = name_space; *namep != '\0';
        -       namep += strlen (namep) + 1, i += 1)
        +       namep = strnul (namep) + 1, i += 1)
             {
               ASSERT (strlen (namep) == 1);
               ASSERT (*namep - 'a' == i);


Cheers,
Alex

-- 
<https://www.alejandro-colomar.es>

Attachment: signature.asc
Description: PGP signature

Reply via email to