diff options
-rw-r--r-- | libbb/xfuncs_printf.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 05aa07ce8..a70683241 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -541,13 +541,11 @@ int FAST_FUNC bb_xioctl(int fd, unsigned request, void *argp) | |||
541 | 541 | ||
542 | char* FAST_FUNC xmalloc_ttyname(int fd) | 542 | char* FAST_FUNC xmalloc_ttyname(int fd) |
543 | { | 543 | { |
544 | char *buf = xzalloc(128); | 544 | char buf[128]; |
545 | int r = ttyname_r(fd, buf, 127); | 545 | int r = ttyname_r(fd, buf, sizeof(buf) - 1); |
546 | if (r) { | 546 | if (r) |
547 | free(buf); | 547 | return NULL; |
548 | buf = NULL; | 548 | return xstrdup(buf); |
549 | } | ||
550 | return buf; | ||
551 | } | 549 | } |
552 | 550 | ||
553 | void FAST_FUNC generate_uuid(uint8_t *buf) | 551 | void FAST_FUNC generate_uuid(uint8_t *buf) |