aboutsummaryrefslogtreecommitdiff
path: root/src/rc
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-06-21 12:20:53 +0100
committerRoy Marples <roy@marples.name>2009-06-21 12:20:53 +0100
commit6abeec74301d8406ebbbd653b9fe9a0e234c09bf (patch)
treeab7484086cf6198ffe0422e48888f463381d7d2f /src/rc
parentfbb78022f973361a60861cf4b99dda91ccfc1aa5 (diff)
Use rc_getline instead of assuming a fixed kernel cmdline length.
This is now requires as COMMAND_LINE_SIZE isn't exposed by kernel headers anymore. Fixes #177.
Diffstat (limited to 'src/rc')
-rw-r--r--src/rc/rc.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 915dc181..3d8628e8 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -43,10 +43,6 @@ const char rc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
#include <sys/utsname.h>
#include <sys/wait.h>
-#ifdef __linux__
-# include <asm/setup.h> /* for COMMAND_LINE_SIZE */
-#endif
-
#include <errno.h>
#include <dirent.h>
#include <ctype.h>
@@ -177,10 +173,8 @@ static char *
proc_getent(const char *ent)
{
FILE *fp;
- char proc[COMMAND_LINE_SIZE];
- char *p;
- char *value = NULL;
- int i;
+ char *proc, *p, *value = NULL;
+ size_t i;
if (!exists("/proc/cmdline"))
return NULL;
@@ -190,11 +184,11 @@ proc_getent(const char *ent)
return NULL;
}
- memset(proc, 0, sizeof(proc));
- p = fgets(proc, sizeof(proc), fp);
- if (p == NULL)
- eerror("fgets: %s", strerror(errno));
- else if (*proc && (p = strstr(proc, ent))) {
+ proc = NULL;
+ 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);
@@ -205,6 +199,7 @@ proc_getent(const char *ent)
} else
errno = ENOENT;
fclose(fp);
+ free(proc);
return value;
}