summaryrefslogtreecommitdiff
path: root/libc/misc
diff options
context:
space:
mode:
authorSegev Finer <segev208@gmail.com>2018-08-18 20:21:08 +0300
committerWaldemar Brodkorb <wbrodkorb@conet.de>2018-09-21 03:42:08 +0200
commitf664078e0fcd5988ef0acc124b1f52d2ce7be03c (patch)
tree98a2d87e6a06ae14021c5ded1838a408557a9c8b /libc/misc
parent85baf42330a75ffa55e75625b80e743780dcccbf (diff)
wordexp: Fix the usage of the internal _itoa function
The original from glibc received the end of the buffer and worked backwards. Ours needs the beginning of the buffer. Signed-off-by: Segev Finer <segev208@gmail.com>
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/wordexp/wordexp.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libc/misc/wordexp/wordexp.c b/libc/misc/wordexp/wordexp.c
index fb635fe91..285e81e87 100644
--- a/libc/misc/wordexp/wordexp.c
+++ b/libc/misc/wordexp/wordexp.c
@@ -491,10 +491,10 @@ parse_squote(char **word, size_t * word_length, size_t * max_length,
#ifdef __WORDEXP_FULL
static int eval_expr(char *expr, long int *result);
-static char *_itoa(unsigned long long int value, char *buflim)
+static char *_itoa(unsigned long long int value, char *buf)
{
- sprintf(buflim, "%llu", value);
- return buflim;
+ sprintf(buf, "%llu", value);
+ return buf;
}
/* Functions to evaluate an arithmetic expression */
@@ -692,7 +692,7 @@ parse_arith(char **word, size_t * word_length, size_t * max_length,
result[20] = '\0';
*word = w_addstr(*word, word_length, max_length,
- _itoa(convertme, &result[20]));
+ _itoa(convertme, result));
free(expr);
return *word ? 0 : WRDE_NOSPACE;
}
@@ -717,7 +717,7 @@ parse_arith(char **word, size_t * word_length, size_t * max_length,
result[20] = '\0';
*word = w_addstr(*word, word_length, max_length,
- _itoa(numresult, &result[20]));
+ _itoa(numresult, result));
free(expr);
return *word ? 0 : WRDE_NOSPACE;
}
@@ -1313,7 +1313,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
if (seen_hash) {
/* $# expands to the number of positional parameters */
buffer[20] = '\0';
- value = _itoa(__libc_argc - 1, &buffer[20]);
+ value = _itoa(__libc_argc - 1, buffer);
seen_hash = 0;
} else {
/* Just $ on its own */
@@ -1338,13 +1338,13 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
/* Is it `$$'? */
if (*env == '$') {
buffer[20] = '\0';
- value = _itoa(getpid(), &buffer[20]);
+ value = _itoa(getpid(), buffer);
}
/* Is it `${#*}' or `${#@}'? */
else if ((*env == '*' || *env == '@') && seen_hash) {
buffer[20] = '\0';
value = _itoa(__libc_argc > 0 ? __libc_argc - 1 : 0,
- &buffer[20]);
+ buffer);
*word = w_addstr(*word, word_length, max_length, value);
free(env);
free(pattern);
@@ -1770,7 +1770,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
param_length[20] = '\0';
*word = w_addstr(*word, word_length, max_length,
_itoa(value ? strlen(value) : 0,
- &param_length[20]));
+ param_length));
if (free_value) {
assert(value != NULL);
free(value);