diff options
author | Christian Ruppert <idl0r@gentoo.org> | 2011-12-30 01:44:15 +0100 |
---|---|---|
committer | Christian Ruppert <idl0r@gentoo.org> | 2011-12-30 16:03:24 +0100 |
commit | 0d6ae379f43fdab9516e6ed949ba9563972c0c65 (patch) | |
tree | f57ca896ac1c0d7a6ad5ce4dc50f1d7b043c54e0 /src/rc | |
parent | 2471d741f7d12382ba22a9efac0418293c7a74d5 (diff) |
Compare stricter in proc_getent
The new proc_getent compares stricter so that e.g. "ro" doesn't match
root=/dev/sdaN anymore.
So it has to be either "ro" or "ro=".
Diffstat (limited to 'src/rc')
-rw-r--r-- | src/rc/rc.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/rc/rc.c b/src/rc/rc.c index ad16f7d2..05c99faf 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -173,7 +173,7 @@ proc_getent(const char *ent) { FILE *fp; char *proc, *p, *value = NULL; - size_t i; + size_t i, len; if (!exists("/proc/cmdline")) return NULL; @@ -187,16 +187,25 @@ proc_getent(const char *ent) i = 0; if (rc_getline(&proc, &i, fp) == -1 || proc == NULL) eerror("rc_getline: %s", strerror(errno)); - if (*proc && (p = strstr(proc, ent))) { - i = p - proc; - if (i == '\0' || proc[i - 1] == ' ') { - p += strlen(ent); - if (*p == '=') - p++; - value = xstrdup(strsep(&p, " ")); + + if(proc != NULL) { + len = strlen(ent); + + while((p = strsep(&proc, " "))) { + if(strncmp(ent, p, len) == 0 && (p[len] == '\0' || p[len] == ' ' || p[len] == '=')) { + p += len; + + if (*p == '=') + p++; + + value = xstrdup(p); + } } - } else + } + + if(!value) errno = ENOENT; + fclose(fp); free(proc); |