From a6cc7f06cf3807a0e0590697e1f14e6ab9055271 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Wed, 21 Feb 2018 13:49:41 -0600 Subject: rc.c: remove PATH_MAX references --- src/rc/rc.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/rc/rc.c b/src/rc/rc.c index 110591e4..1f462c66 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -336,26 +336,26 @@ set_krunlevel(const char *level) return true; } -static size_t -get_krunlevel(char *buffer, int buffer_len) +static char *get_krunlevel(void) { + char *buffer = NULL; FILE *fp; size_t i = 0; if (!exists(RC_KRUNLEVEL)) - return 0; + return NULL; if (!(fp = fopen(RC_KRUNLEVEL, "r"))) { eerror("fopen `%s': %s", RC_KRUNLEVEL, strerror(errno)); - return 0; + return NULL; } - if (fgets(buffer, buffer_len, fp)) { + if (getline(&buffer, &i, fp) != -1) { i = strlen(buffer); if (buffer[i - 1] == '\n') buffer[i - 1] = 0; } fclose(fp); - return i; + return buffer; } static void @@ -743,7 +743,7 @@ int main(int argc, char **argv) RC_STRING *service; bool going_down = false; int depoptions = RC_DEP_STRICT | RC_DEP_TRACE; - char krunlevel [PATH_MAX]; + char *krunlevel = NULL; char pidstr[10]; int opt; bool parallel; @@ -892,7 +892,8 @@ int main(int argc, char **argv) (strcmp(newlevel, RC_LEVEL_SYSINIT) != 0 && strcmp(newlevel, getenv("RC_BOOTLEVEL")) != 0)) { - if (get_krunlevel(krunlevel, sizeof(krunlevel))) { + krunlevel = get_krunlevel(); + if (krunlevel) { newlevel = krunlevel; set_krunlevel(NULL); } -- cgit v1.2.3