ps: work around libc bug: printf("%.*s\n", MAX_INT, buffer)
authorDenis Vlasenko <vda.linux@googlemail.com>
Wed, 28 Mar 2007 21:57:12 +0000 (21:57 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Wed, 28 Mar 2007 21:57:12 +0000 (21:57 -0000)
libbb/xfuncs.c
procps/ps.c

index e1632a4b64013a315d3dbbbaf86a475b45fbb207..68ad3dec4066bda4c27a192803475f1188485f1c 100644 (file)
@@ -253,9 +253,9 @@ void smart_ulltoa5(unsigned long long ul, char buf[5])
        buf[4] = '\0';
 }
 
-// Convert unsigned integer to ascii, writing into supplied buffer.  A
-// truncated result is always null terminated (unless buflen is 0), and
-// contains the first few digits of the result ala strncpy.
+// Convert unsigned integer to ascii, writing into supplied buffer.
+// A truncated result contains the first few digits of the result ala strncpy.
+// Returns a pointer past last generated digit, does _not_ store NUL.
 void BUG_sizeof_unsigned_not_4(void);
 char *utoa_to_buf(unsigned n, char *buf, unsigned buflen)
 {
index c1cb64397e4a17c339dfcbc521272a493130d15a..2be0b36055d5dc51ab6ef613650c7bb46532842f 100644 (file)
@@ -262,7 +262,9 @@ int ps_main(int argc, char **argv)
                parse_o(default_o);
        post_process();
 
-       terminal_width = INT_MAX;
+       /* Was INT_MAX, but some libc's go belly up with printf("%.*s")
+        * and such large widths */
+       terminal_width = 30000;
        if (isatty(1)) {
                get_terminal_width_height(1, &terminal_width, NULL);
                terminal_width--;