From: <ew...@us...> - 2007-08-06 21:03:50
|
Revision: 2510 http://selinux.svn.sourceforge.net/selinux/?rev=2510&view=rev Author: ewalsh Date: 2007-08-06 14:03:48 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Author: Eamon Walsh Email: ew...@ty... Subject: libselinux Patch to prevent segfault from un-initialized print statement Date: Fri, 03 Aug 2007 17:12:07 -0400 Please use the following instead, this is a result of the new labeling interface having its own logging callback. I tried to use the value of the function pointer to decide compatibility mode; this introduces a separate flag variable. Signed-off-by: Eamon Walsh <ew...@ty...> Acked-by: Stephen Smalley <sd...@ty...> Modified Paths: -------------- trunk/libselinux/src/label_internal.h trunk/libselinux/src/matchpathcon.c Modified: trunk/libselinux/src/label_internal.h =================================================================== --- trunk/libselinux/src/label_internal.h 2007-08-02 20:52:45 UTC (rev 2509) +++ trunk/libselinux/src/label_internal.h 2007-08-06 21:03:48 UTC (rev 2510) @@ -58,10 +58,11 @@ /* * Compatibility support */ +extern int myprintf_compat; extern void __attribute__ ((format(printf, 1, 2))) (*myprintf) (const char *fmt,...); -#define COMPAT_LOG(type, fmt...) if (myprintf) \ +#define COMPAT_LOG(type, fmt...) if (myprintf_compat) \ myprintf(fmt); \ else \ selinux_log(type, fmt); Modified: trunk/libselinux/src/matchpathcon.c =================================================================== --- trunk/libselinux/src/matchpathcon.c 2007-08-02 20:52:45 UTC (rev 2509) +++ trunk/libselinux/src/matchpathcon.c 2007-08-06 21:03:48 UTC (rev 2510) @@ -65,14 +65,13 @@ #ifdef __GNUC__ __attribute__ ((format(printf, 1, 2))) #endif - (*myprintf) (const char *fmt,...); + (*myprintf) (const char *fmt,...) = &default_printf; +int myprintf_compat = 0; void set_matchpathcon_printf(void (*f) (const char *fmt, ...)) { - if (f) - myprintf = f; - else - myprintf = &default_printf; + myprintf = f ? f : &default_printf; + myprintf_compat = 1; } static int (*myinvalidcon) (const char *p, unsigned l, char *c) = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |