* [PATCH] Minor nit in nis_leaf_of_r
@ 2005-08-15 12:05 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2005-08-15 12:05 UTC (permalink / raw)
To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers
Hi!
Recent change in nis_subr.c:
@@ -39,22 +39,13 @@ nis_leaf_of_r (const_nis_name name, char
while (name[i] != '.' && name[i] != '\0')
i++;
- if (i > buflen - 1)
+ if (__builtin_expect (i > buflen - 1, 0))
{
__set_errno (ERANGE);
return NULL;
}
- if (i > 0)
- {
- if ((size_t)i >= buflen)
- {
- __set_errno (ERANGE);
- return NULL;
- }
-
- *((char *) __mempcpy (buffer, name, i)) = '\0';
- }
+ *((char *) __mempcpy (buffer, name, i)) = '\0';
return buffer;
}
together with removing unnecessary code and no longer forgetting
to zero-terminate in i == 0 case also no longer handles
buflen == 0 gracefully. i >= buflen test should behave the same
as the current i > buflen - 1, except for buflen == 0.
2005-08-15 Jakub Jelinek <jakub@redhat.com>
* nis/nis_subr.c (nis_leaf_of_r): Handle buflen == 0 correctly.
--- libc/nis/nis_subr.c.jj 2005-08-08 09:14:54.000000000 +0200
+++ libc/nis/nis_subr.c 2005-08-15 13:59:06.000000000 +0200
@@ -39,7 +39,7 @@ nis_leaf_of_r (const_nis_name name, char
while (name[i] != '.' && name[i] != '\0')
i++;
- if (__builtin_expect (i > buflen - 1, 0))
+ if (__builtin_expect (i >= buflen, 0))
{
__set_errno (ERANGE);
return NULL;
Jakub
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-08-15 12:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-15 12:05 [PATCH] Minor nit in nis_leaf_of_r Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).