]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Trivial fix to check for NULL pointer prior to strncmp
authorVMware, Inc <>
Tue, 13 Mar 2012 20:08:37 +0000 (13:08 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Wed, 14 Mar 2012 16:04:59 +0000 (09:04 -0700)
The MSG_MAGICAL() macro needs to check for a NULL pointer
prior to calling strncmp on it.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/include/msgid.h

index 59503d1b8764ed48fee5f29d23fa44925fb5389d..4355c3365c555a8c2b4d897c52286cdaaf697279 100644 (file)
@@ -39,7 +39,8 @@
 
 
 // the X hides MSG_MAGIC so it won't appear in the object file
-#define MSG_MAGICAL(s) (strncmp(s, MSG_MAGIC"X", MSG_MAGIC_LEN) == 0)
+#define MSG_MAGICAL(s) \
+   (s != NULL && strncmp(s, MSG_MAGIC"X", MSG_MAGIC_LEN) == 0)
 
 // Start after MSG_MAGIC so it won't appear in the object file either.
 #define MSG_HAS_BUTTONID(s) \