From patchwork Sat Aug 18 17:21:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segev Finer X-Patchwork-Id: 959235 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="B2FxoqtI"; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41t6MP2hWZz9rvt for ; Sun, 19 Aug 2018 03:22:23 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 52CFC10087; Sat, 18 Aug 2018 19:22:19 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by helium.openadk.org (Postfix) with ESMTPS id 79BBB10087 for ; Sat, 18 Aug 2018 19:22:16 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id o18-v6so10107127wmc.0 for ; Sat, 18 Aug 2018 10:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=X9Ff49s+ffOb736Jrunzgs9y96eucAgZGHFsQFHhN6Y=; b=B2FxoqtIngKdKm3Q4T92sk1EvyR0tWibnfJPovP0UVPJjbtcm7PDdi60GCNzqppKZ7 pMoGczPVZ5mI1tPzyDxgbRH599NQPk084c9fWCt+xQDcezpuc1FO4ENWckIIWW2PBK1E nJJz6IA+Q3qvQKiq+WGqBYqVVIsp/0TMcBv7STMgvSSB8i6dIypKsJf1dTza2xHBoL8P xw1Tmho6YoGZlbjZkOj9v9ZYYcMuIUv57oEE5HvGlH7F4TCp6eKyejlfgiiNAxedM5zL ubhX2wGAoEnMy4sutWS7ugn+iZAbfMCN7lNKgf9sKs2frakLp698G9/xqpHGPF2H2uur hJTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=X9Ff49s+ffOb736Jrunzgs9y96eucAgZGHFsQFHhN6Y=; b=R+0kaxkjKo45XXu2h4dH2BwxJIdhGvHgjQ4U6EHjbwUBSIHw2BC6UmrnBQMPBr4kd/ IvyUxKaD9xoFg0R6iUyTIoyXlXY9g2ZDS4oNChSzqfoqyO129AOrxv9+bknbL8NGdqLl 3EmtKliaag+i+MN0gDPeBZsgpDDBCSL5qQmA1Mp3E8g2OqSsSHxRo5Dv/z4cT05NcCqA QWltqblzp1QtyPPGgsjjgxGZxQINkFODzZbl5YIbtuoqD0IXwnZ9Wn1t2PYOMxfGIpbe zcvBXjih0sWh1ONIf+FIIUrFhMH76AjaXhhJwQPRFfX28bCz/gcnkDrG3/do+nBkNWdy xYDg== X-Gm-Message-State: AOUpUlHp8l12yiECqDVpWyNtERxl14+0B4EsAg8nzxoMXWVp+xdmsglo 9eu6l/Hhf4dfGPWyWdRtlVeucZeRN1o= X-Google-Smtp-Source: AA+uWPzRr7/35rGU7vKG8FcSKgaKLO4Mhmn0+GVlZh0rJJHhGw6QICaqOst8NlfLgpekmBQP6PPtLg== X-Received: by 2002:a1c:e409:: with SMTP id b9-v6mr20555078wmh.34.1534612935289; Sat, 18 Aug 2018 10:22:15 -0700 (PDT) Received: from localhost.localdomain (bzq-109-67-224-163.red.bezeqint.net. [109.67.224.163]) by smtp.gmail.com with ESMTPSA id 200-v6sm13544509wmv.6.2018.08.18.10.22.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 18 Aug 2018 10:22:14 -0700 (PDT) From: Segev Finer To: devel@uclibc-ng.org Date: Sat, 18 Aug 2018 20:21:08 +0300 Message-Id: <20180818172108.18416-1-segev208@gmail.com> X-Mailer: git-send-email 2.18.0 Subject: [uclibc-ng-devel] [PATCH] wordexp: Fix the usage of the internal _itoa function X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" 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 --- libc/misc/wordexp/wordexp.c | 18 +++++++++--------- 1 file 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, - ¶m_length[20])); + param_length)); if (free_value) { assert(value != NULL); free(value);