config/powerpc-nvram: Fix nvram line parsing
authorJeremy Kerr <jk@ozlabs.org>
Tue, 2 Jul 2013 02:47:35 +0000 (10:47 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 2 Jul 2013 03:44:20 +0000 (11:44 +0800)
We have a couple of issues with the nvram output parser; lines aren't
being broken up correctly.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/pb-config/storage-powerpc-nvram.c

index 96d279c4041dc65d7a950e883d3342575de16bb2..4b1647955996dcc17633caca9c7c655285ebd9d2 100644 (file)
@@ -78,9 +78,16 @@ static int parse_nvram_params(struct powerpc_nvram_storage *nv,
                return -1;
        }
 
-       for (pos = buf + i; pos < buf + len; pos += paramlen) {
+       for (pos = buf + i; pos < buf + len; pos += paramlen + 1) {
                unsigned int namelen;
                struct param *param;
+               char *newline;
+
+               newline = strchr(pos, '\n');
+               if (!newline)
+                       break;
+
+               *newline = '\0';
 
                paramlen = strlen(pos);
 
@@ -89,7 +96,9 @@ static int parse_nvram_params(struct powerpc_nvram_storage *nv,
                if (!value)
                        continue;
 
-               namelen = name - value;
+               namelen = value - name;
+               if (namelen == 0)
+                       continue;
 
                if (!param_is_known(name, namelen))
                        continue;