pkgsrc/security/policykit/patches/patch-aj
jmcneill 617b5b4c10 From FreeBSD:
Fix a problem with PK's strndup() implementation assuming all strings
passed to it would be NUL-terminated.  This is known to fix crashes with
polkit-gnome-authorization and clock-applet.
2008-11-23 22:28:23 +00:00

29 lines
838 B
Text

$NetBSD: patch-aj,v 1.1 2008/11/23 22:28:23 jmcneill Exp $
--- src/kit/kit-string.c.orig 2008-05-30 17:24:44.000000000 -0400
+++ src/kit/kit-string.c 2008-07-24 01:21:34.000000000 -0400
@@ -123,13 +123,18 @@ static char
if ( !s )
return NULL;
- if ( strlen(s) > n )
- nAvail = n + 1;
- else
- nAvail = strlen(s) + 1;
- p = malloc ( nAvail );
+ if (memchr(s, '\0', n) != NULL) {
+ nAvail = strlen(s);
+ if ( nAvail > n )
+ nAvail = n;
+ } else {
+ nAvail = n;
+ }
+ p = malloc ( nAvail + 1 );
+ if (p == NULL)
+ return NULL;
memcpy ( p, s, nAvail );
- p[nAvail - 1] = '\0';
+ p[nAvail] = '\0';
return p;
}