Fix a crash because of a NULL pointer dereference in parse.y

Before:
/etc/bgpd.conf:85: macro 'UNDEFINED' not defined
Segmentation fault

After:
/etc/bgpd.conf:85: macro 'UNDEFINED' not defined
/etc/bgpd.conf:85: syntax error

-- 
:wq Claudio

Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.428
diff -u -p -r1.428 parse.y
--- parse.y     2 Jun 2022 11:12:47 -0000       1.428
+++ parse.y     9 Jun 2022 17:03:08 -0000
@@ -3248,8 +3248,10 @@ expand_macro(void)
                break;
        }
        val = symget(buf);
-       if (val == NULL)
+       if (val == NULL) {
                yyerror("macro '%s' not defined", buf);
+               return (ERROR);
+       }
        p = val + strlen(val) - 1;
        lungetc(DONE_EXPAND);
        while (p >= val) {

Reply via email to