aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/bb_askpass.c6
-rw-r--r--libbb/human_readable.c9
2 files changed, 3 insertions, 12 deletions
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c
index 1927ba9e9..c2580b9eb 100644
--- a/libbb/bb_askpass.c
+++ b/libbb/bb_askpass.c
@@ -1,7 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * Ask for a password 3 * Ask for a password
4 * I use a static buffer in this function. Plan accordingly.
5 * 4 *
6 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
7 * 6 *
@@ -23,8 +22,8 @@ char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt)
23{ 22{
24 /* Was static char[BIGNUM] */ 23 /* Was static char[BIGNUM] */
25 enum { sizeof_passwd = 128 }; 24 enum { sizeof_passwd = 128 };
26 static char *passwd;
27 25
26 char *passwd;
28 char *ret; 27 char *ret;
29 int i; 28 int i;
30 struct sigaction sa, oldsa; 29 struct sigaction sa, oldsa;
@@ -62,8 +61,7 @@ char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt)
62 alarm(timeout); 61 alarm(timeout);
63 } 62 }
64 63
65 if (!passwd) 64 passwd = auto_string(xmalloc(sizeof_passwd));
66 passwd = xmalloc(sizeof_passwd);
67 ret = passwd; 65 ret = passwd;
68 i = 0; 66 i = 0;
69 while (1) { 67 while (1) {
diff --git a/libbb/human_readable.c b/libbb/human_readable.c
index 0b2eb777e..5c7fc076f 100644
--- a/libbb/human_readable.c
+++ b/libbb/human_readable.c
@@ -37,8 +37,6 @@ const char* FAST_FUNC make_human_readable_str(unsigned long long val,
37 '\0', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' 37 '\0', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'
38 }; 38 };
39 39
40 static char *str;
41
42 unsigned frac; /* 0..9 - the fractional digit */ 40 unsigned frac; /* 0..9 - the fractional digit */
43 const char *u; 41 const char *u;
44 const char *fmt; 42 const char *fmt;
@@ -81,12 +79,7 @@ const char* FAST_FUNC make_human_readable_str(unsigned long long val,
81#endif 79#endif
82 } 80 }
83 81
84 if (!str) { 82 return auto_string(xasprintf(fmt, val, frac, *u));
85 /* sufficient for any width of val */
86 str = xmalloc(sizeof(val)*3 + 2 + 3);
87 }
88 sprintf(str, fmt, val, frac, *u);
89 return str;
90} 83}
91 84
92 85