]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't crash when passing a NULL message to __astman_get_header.
authorSean Bright <sean@malleable.com>
Tue, 18 Sep 2012 20:12:41 +0000 (20:12 +0000)
committerSean Bright <sean@malleable.com>
Tue, 18 Sep 2012 20:12:41 +0000 (20:12 +0000)
Before this commit, __astman_get_header would blindly dereference the passed in
'struct message *' to traverse the header list.  There are cases, however, such
as '*CLI> sip qualify peer foo' where the message pointer is NULL, so we need
to check for that.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@373131 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/manager.c

index ce21d74df1dc8e976aa4a42d2e4031b036db34cb..ed0bacd6175dd6fd27eb66e895eafdd93137a548 100644 (file)
@@ -1790,6 +1790,10 @@ static const char *__astman_get_header(const struct message *m, char *var, int m
        int x, l = strlen(var);
        const char *result = "";
 
+       if (!m) {
+               return result;
+       }
+
        for (x = 0; x < m->hdrcount; x++) {
                const char *h = m->headers[x];
                if (!strncasecmp(var, h, l) && h[l] == ':') {