init: don't read NULL pointers
authorAlan Cox <alan@linux.intel.com>
Fri, 21 Oct 2016 16:51:53 +0000 (17:51 +0100)
committerAlan Cox <alan@linux.intel.com>
Fri, 21 Oct 2016 16:51:53 +0000 (17:51 +0100)
Needed for the 68K port as it causes a trap

Applications/util/init.c

index d989488..e2282fd 100644 (file)
@@ -630,7 +630,6 @@ static int envn;
 static void envset(const char *a, const char *b)
 {
        int al = strlen(a);
-       static char hptr[5];
        /* May unalign the memory pool but we don't care by this point */
        char *tp = sbrk(al + strlen(b) + 2);
        if (tp == (char *) -1) {
@@ -688,6 +687,9 @@ const char *bauds[] = {
 static int baudmatch(const char *p)
 {
        const char **str = bauds;
+       if (p == NULL)
+               return B9600;
+
        int i;
        for(i = 1; i < 15; i++) {
                if (strcmp(p, *str++) == 0)