This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] avoid double Nul termination
- From: Thorsten Kukuk <kukuk at suse dot de>
- To: libc-alpha at sources dot redhat dot com
- Date: Fri, 10 Jun 2005 16:00:05 +0200
- Subject: [PATCH] avoid double Nul termination
Hi,
As result of Bug #962 I double checked the code and remove the
assert statements, the string is always Nul terminated in our yp_match
implementation. I still don't understand why malloc_usable_size
returns the wrong value, but this patch is save and only removes the
duplicate Nul termination:
2005-06-10 Thorsten Kukuk <kukuk@suse.de>
[BZ #962]
* nis/nss_nis/nis-netgrp.c (_nss_nis_setnetgrent): Remove
double Nul termination.
--- nis/nss_nis/nis-netgrp.c 14 Aug 2004 04:20:34 -0000 1.12
+++ nis/nss_nis/nis-netgrp.c 10 Jun 2005 13:44:14 -0000
@@ -71,14 +71,8 @@
&netgrp->data, &len));
if (status == NSS_STATUS_SUCCESS)
{
- /* Our implementation of yp_match already allocates a buffer
- which is one byte larger than the value in LEN specifies
- and the last byte is filled with NUL. So we can simply
- use that buffer. */
- assert (len > 0);
- assert (malloc_usable_size (netgrp->data) >= len + 1);
- assert (netgrp->data[len] == '\0');
-
+ /* Our implementation of yp_match makes sure the data is Nul
+ terminated, we don't need to do it again. */
netgrp->data_size = len;
netgrp->cursor = netgrp->data;
}
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de
SUSE LINUX Products GmbH Maxfeldstr. 5 D-90409 Nuernberg
--------------------------------------------------------------------
Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B