stty: fix bb_common_bufsiz1 use in NOEXEC
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 6 Aug 2017 18:55:56 +0000 (20:55 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 6 Aug 2017 18:55:56 +0000 (20:55 +0200)
function                                             old     new   delta
stty_main                                           1211    1221     +10
do_display                                           379     370      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
NOFORK_NOEXEC.lst
coreutils/stty.c
debianutils/start_stop_daemon.c

index 02e2ba956277826f7bdd3c6b7ffb88b02a8e86e3..fb76fcf63e025118db3da651569ba970988d2c6a 100644 (file)
@@ -327,7 +327,7 @@ softlimit - noexec. spawner
 sort - noexec. runner
 split - runner
 ssl_client - longterm
-start-stop-daemon
+start-stop-daemon - not noexec: uses bb_common_bufsiz1
 stat - nofork candidate(needs fewer allocs)
 strings - runner
 stty - noexec. nofork candidate: has no allocs or opens except xmove_fd(xopen("-F DEVICE"),STDIN). tcsetattr(STDIN) is not a problem: it would work the same across processes sharing this fd
index d09f0e4531c3d09a4bbe52d69fff20b85cdf1e75..2292fa5eeb57404ec429a94227916935c323cca5 100644 (file)
@@ -782,12 +782,12 @@ struct globals {
        unsigned max_col;
        /* Current position, to know when to wrap */
        unsigned current_col;
-       char buf[10];
 } FIX_ALIASING;
 #define G (*(struct globals*)bb_common_bufsiz1)
 #define INIT_G() do { \
        G.device_name = bb_msg_standard_input; \
        G.max_col = 80; \
+       G.current_col = 0; /* we are noexec, must clear */ \
 } while (0)
 
 static void set_speed_or_die(enum speed_setting type, const char *arg,
@@ -1018,6 +1018,8 @@ static void do_display(const struct termios *mode, int all)
 
        for (i = 0; i != CIDX_min; ++i) {
                char ch;
+               char buf10[10];
+
                /* If swtch is the same as susp, don't print both */
 #if VSWTCH == VSUSP
                if (i == CIDX_swtch)
@@ -1033,10 +1035,10 @@ static void do_display(const struct termios *mode, int all)
 #endif
                ch = mode->c_cc[control_info[i].offset];
                if (ch == _POSIX_VDISABLE)
-                       strcpy(G.buf, "<undef>");
+                       strcpy(buf10, "<undef>");
                else
-                       visible(ch, G.buf, 0);
-               wrapf("%s = %s;", nth_string(control_name, i), G.buf);
+                       visible(ch, buf10, 0);
+               wrapf("%s = %s;", nth_string(control_name, i), buf10);
        }
 #if VEOF == VMIN
        if ((mode->c_lflag & ICANON) == 0)
index 07c104baad230e41b3fba7b67285d65887baa20f..9effdc80b3dc683f98e821340956e85d77fcb87d 100644 (file)
@@ -79,6 +79,7 @@ Misc options:
 //config:      -N|--nicelevel N
 
 //applet:IF_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, BB_DIR_SBIN, BB_SUID_DROP, start_stop_daemon))
+/* not NOEXEC: uses bb_common_bufsiz1 */
 
 //kbuild:lib-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o
 
@@ -409,11 +410,11 @@ static const char start_stop_daemon_longopts[] ALIGN1 =
        "quiet\0"        No_argument       "q"
        "test\0"         No_argument       "t"
        "make-pidfile\0" No_argument       "m"
-#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
+# if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
        "oknodo\0"       No_argument       "o"
        "verbose\0"      No_argument       "v"
        "nicelevel\0"    Required_argument "N"
-#endif
+# endif
        "startas\0"      Required_argument "a"
        "name\0"         Required_argument "n"
        "signal\0"       Required_argument "s"
@@ -421,9 +422,9 @@ static const char start_stop_daemon_longopts[] ALIGN1 =
        "chuid\0"        Required_argument "c"
        "exec\0"         Required_argument "x"
        "pidfile\0"      Required_argument "p"
-#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
+# if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
        "retry\0"        Required_argument "R"
-#endif
+# endif
        ;
 #endif