Fix regression in command line parsing
[project/procd.git] / utils / utils.c
index 5e67310..e782e44 100644 (file)
@@ -129,8 +129,8 @@ blobmsg_list_equal(struct blobmsg_list *l1, struct blobmsg_list *l2)
 
 char* get_cmdline_val(const char* name, char* out, int len)
 {
-       char pattern[COMMAND_LINE_SIZE + 1];
-       char line[COMMAND_LINE_SIZE + 1];
+       char pattern[CMDLINE_SIZE + 1];
+       char line[CMDLINE_SIZE + 1];
        char *res = NULL, *tty;
        int r, fd;
        regex_t pat_cmdline;
@@ -140,7 +140,7 @@ char* get_cmdline_val(const char* name, char* out, int len)
        if (fd < 0)
                return NULL;
 
-       r = read(fd, line, COMMAND_LINE_SIZE);
+       r = read(fd, line, CMDLINE_SIZE);
        if ( r <= 0 ) {
                close(fd);
                return NULL;
@@ -149,16 +149,16 @@ char* get_cmdline_val(const char* name, char* out, int len)
        close(fd);
 
        sprintf( pattern, "%s=([^ \n]*)", name);
-    regcomp(&pat_cmdline, pattern, REG_EXTENDED);
-    if (!regexec(&pat_cmdline, line, 2, matches, 0)) {
-       line[matches[1].rm_eo] = '\0';
+       regcomp(&pat_cmdline, pattern, REG_EXTENDED);
+       if (!regexec(&pat_cmdline, line, 2, matches, 0)) {
+               line[matches[1].rm_eo] = '\0';
                tty = (line + matches[1].rm_so);
                strncpy(out, tty, len);
                tty[len-1] = '\0';
                res = out;
        }
 
-    regfree(&pat_cmdline);
+       regfree(&pat_cmdline);
 
        return res;
 }