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. Tested by: pav
This commit is contained in:
parent
3d63e35206
commit
342a207e3d
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=216281
@ -8,7 +8,7 @@
|
||||
|
||||
PORTNAME= policykit
|
||||
PORTVERSION= 0.8
|
||||
PORTREVISION= 2
|
||||
PORTREVISION= 3
|
||||
CATEGORIES= sysutils gnome
|
||||
MASTER_SITES= http://hal.freedesktop.org/releases/
|
||||
DISTNAME= PolicyKit-${PORTVERSION}
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- src/kit/kit-string.c.orig 2008-04-08 15:44:50.000000000 -0400
|
||||
+++ src/kit/kit-string.c 2008-04-22 01:00:49.000000000 -0400
|
||||
@@ -113,6 +113,28 @@ out:
|
||||
+++ src/kit/kit-string.c 2008-07-03 18:17:57.000000000 -0400
|
||||
@@ -113,6 +113,33 @@ out:
|
||||
|
||||
#else
|
||||
|
||||
@ -14,13 +14,18 @@
|
||||
+ 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;
|
||||
+}
|
||||
|
Loading…
Reference in New Issue
Block a user