reduce stack usage
authorFelix Fietkau <nbd@openwrt.org>
Thu, 20 Oct 2011 21:10:01 +0000 (23:10 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 20 Oct 2011 21:10:01 +0000 (23:10 +0200)
main.c
proto-shell.c
system-linux.c

diff --git a/main.c b/main.c
index f180c30..3f16cd5 100644 (file)
--- a/main.c
+++ b/main.c
@@ -98,7 +98,7 @@ retry:
 
        cur = buf;
        buf = proc->log_buf;
 
        cur = buf;
        buf = proc->log_buf;
-       while ((cur = memchr(cur, '\n', len))) {
+       while (len > 0 && (cur = memchr(cur, '\n', len))) {
                *cur = 0;
 
                if (!proc->log_overflow)
                *cur = 0;
 
                if (!proc->log_overflow)
index c2a6d00..3b5311c 100644 (file)
@@ -332,8 +332,8 @@ out:
 static int
 proto_shell_run_command(struct proto_shell_state *state, struct blob_attr **tb)
 {
 static int
 proto_shell_run_command(struct proto_shell_state *state, struct blob_attr **tb)
 {
-       char *argv[64];
-       char *env[32];
+       static char *argv[64];
+       static char *env[32];
 
        if (!tb[NOTIFY_COMMAND])
                goto error;
 
        if (!tb[NOTIFY_COMMAND])
                goto error;
index 44332a2..8b9189d 100644 (file)
@@ -101,7 +101,7 @@ static void system_set_sysctl(const char *path, const char *val)
 
 static void system_set_dev_sysctl(const char *path, const char *device, const char *val)
 {
 
 static void system_set_dev_sysctl(const char *path, const char *device, const char *val)
 {
-       char buf[256];
+       static char buf[256];
 
        snprintf(buf, sizeof(buf), path, val);
        system_set_sysctl(buf, val);
 
        snprintf(buf, sizeof(buf), path, val);
        system_set_sysctl(buf, val);
@@ -367,7 +367,7 @@ out:
  */
 void system_if_clear_state(struct device *dev)
 {
  */
 void system_if_clear_state(struct device *dev)
 {
-       char buf[256];
+       static char buf[256];
        char *bridge;
 
        if (dev->external)
        char *bridge;
 
        if (dev->external)