libselinux Patch to prevent segfault from un-initialized print statement
src/matchpathcon.c +1 -1
@@ -65,7 +65,7 @@#ifdef __GNUC__ __attribute__ ((format(printf, 1, 2)))#endif - (*myprintf) (const char *fmt,...); + (*myprintf) (const char *fmt,...) = &default_printf;void set_matchpathcon_printf (void (*f) (const char *fmt, ...)) {
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.
How did you find this bug? Was it from running an old setfiles using a new libselinux?
---
label_internal.h | 3 ++- matchpathcon.c | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
src/matchpathcon.c +0 -0
@@ -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;
src/label_internal.h +0 -0
@@ -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);
Signature · 8 lines
Eamon Walsh <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 8 lines · Eamon Walsh
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.
How did you find this bug? Was it from running an old setfiles using a new libselinux?
No I believe the Anaconda team found this by using some chroot environments. Don't remember the exact cause. As long as it is initialized.
Quoted 40 lines
Signed-off-by Eamon Walsh <[email protected]>---
label_internal.h | 3 ++- matchpathcon.c | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-)Index:
libselinux/src/matchpathcon.c
===================================================================src/matchpathcon.c (working copy) renamed from src/matchpathcon.c (revision 2508) +4
-5@@ -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;Index:
libselinux/src/label_internal.h
===================================================================src/label_internal.h (working copy) renamed from src/label_internal.h (revision 2508) +0
-0@@ -58,10 +58,11 @@ /* * Compatibility support
src/label_internal.h (working copy) line 68
Quoted 10 lines
src/label_internal.h (working copy) renamed from src/label_internal.h (revision 2508) +2
-1*/ +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);
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.