Fix potential segfault at checking server password when debugging enabled
authorfatbob313 <martin@fatbob.nu>
Wed, 3 Nov 2010 08:29:05 +0000 (08:29 +0000)
committerfatbob313 <martin@fatbob.nu>
Wed, 3 Nov 2010 08:29:05 +0000 (08:29 +0000)
src/messagehandler.c

index d20ccba1504cb08f598ced4eadd4299767cf1904..4111d4980d0ba9b3dedccffab90d224cc77208c7 100644 (file)
@@ -104,11 +104,14 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        }                               
                }
                if (strlen(getStrConf(PASSPHRASE)) > 0) {
-                       if (!msg->payload.authenticate->password || strncmp(getStrConf(PASSPHRASE), msg->payload.authenticate->password, MAX_TEXT) != 0) {
+                       if (!msg->payload.authenticate->password ||
+                               (msg->payload.authenticate->password &&
+                                strncmp(getStrConf(PASSPHRASE), msg->payload.authenticate->password, MAX_TEXT) != 0)) {
                                char buf[64];
                                sprintf(buf, "Wrong server password");
                                sendServerReject(client, buf, MUMBLE_PROTO__REJECT__REJECT_TYPE__WrongServerPW);
-                               Log_debug("Wrong server password: %s", msg->payload.authenticate->password);
+                               Log_debug("Wrong server password: '%s'", msg->payload.authenticate->password != NULL ?
+                                                 msg->payload.authenticate->password : "(null)");
                                goto disconnect;
                        }
                }