public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] off by one error in nis-publickey
@ 2005-10-28 12:56 Thorsten Kukuk
  2005-10-28 22:45 ` Ulrich Drepper
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Kukuk @ 2005-10-28 12:56 UTC (permalink / raw)
  To: libc-hacker


Hi,

there is a off by one error in nis-publickey:

2005-10-28  Thorsten Kukuk  <kukuk@suse.de>

	* nis/nss_nis/nis-publickey.c(_nss_nis_getpublickey): fix off
	by one error.

--- nis/nss_nis/nis-publickey.c	26 Aug 2002 06:20:04 -0000	1.13
+++ nis/nss_nis/nis-publickey.c	28 Oct 2005 12:53:02 -0000
@@ -120,7 +120,7 @@
 
       ++p;
       strncpy (buf, p, 2 * (HEXKEYBYTES + 1));
-      buf[2 * (HEXKEYBYTES + 1)] = '\0';
+      buf[2 * HEXKEYBYTES + 1] = '\0';
       if (!xdecrypt (buf, passwd))
 	return NSS_STATUS_SUCCESS;
 

-- 
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] off by one error in nis-publickey
  2005-10-28 12:56 [PATCH] off by one error in nis-publickey Thorsten Kukuk
@ 2005-10-28 22:45 ` Ulrich Drepper
  2005-10-30 14:48   ` Thorsten Kukuk
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Drepper @ 2005-10-28 22:45 UTC (permalink / raw)
  To: Thorsten Kukuk; +Cc: libc-hacker

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]

Thorsten Kukuk wrote:
> there is a off by one error in nis-publickey:

While this is correct for the current definition of the array the
question is why is the array and the strncpy not defined as 2 *
HEXKEYBYTES + 1.

The memcmp starts at HEXKEYBYTES and continues for KEYCHECKSUMSIZE.  In
fact, the array should be HEXKEYBYTES + KEYCHECKSUMSIZE in size (no NUL
byte needed).  So, why doesn't it do it like this?

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] off by one error in nis-publickey
  2005-10-28 22:45 ` Ulrich Drepper
@ 2005-10-30 14:48   ` Thorsten Kukuk
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Kukuk @ 2005-10-30 14:48 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: libc-hacker

On Fri, Oct 28, Ulrich Drepper wrote:

> Thorsten Kukuk wrote:
> > there is a off by one error in nis-publickey:
> 
> While this is correct for the current definition of the array the
> question is why is the array and the strncpy not defined as 2 *
> HEXKEYBYTES + 1.
> 
> The memcmp starts at HEXKEYBYTES and continues for KEYCHECKSUMSIZE.  In
> fact, the array should be HEXKEYBYTES + KEYCHECKSUMSIZE in size (no NUL
> byte needed).  So, why doesn't it do it like this?

Because you ignores the data you get from the entry, the xdecrypt() 
call and the fact, that the NIS definition is very unclear about the
NUL byte and different implementations handle that different.

  Thorsten

-- 
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-10-30 14:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-28 12:56 [PATCH] off by one error in nis-publickey Thorsten Kukuk
2005-10-28 22:45 ` Ulrich Drepper
2005-10-30 14:48   ` Thorsten Kukuk

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).