From nobody Wed Nov 18 07:40:28 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jTtmr6X15z6yxVF for ; Wed, 18 Nov 2026 07:40:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTtmr44MLz4HSh for ; Wed, 18 Nov 2026 07:40:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794987628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tyYywDdqSQt/ptOnuXM8vyOfbN2I/b7FnubOqzlAXEg=; b=GgZqxAjeDsQavVb9q4zevOsdSdspLXAlH66atpkJo59gHTLybvIoQ6trzo791PMhvyXzQ7 87okXgy6LZXuOU7Q5hZHdFNcOEm0J5HX8aNfvTERopoZlBGzonc+g5dq3VahUWXOTHCL4v BCtQC7+AefuIvidieIvuafVDRf1Qy2p2fRSQ9nVvJ4ebEu4qDlPXKXQunEjiguwC1jdU+f 5ea4R5y8y9aq9t+8cYohP/pyY+vRBa9jY0L/hv8A0Z/q6b/ZnIpJvfEPmLpgdON0Kb7IVF am0eiYhQPHSbuiNnytSCQLudwbC5sIDrQz9snzEkq6ISbQ1+uk7rJYcDLIhoxw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794987628; b=ggsdiQOQljA16EZKUXfk+jz8U9dHpdFAknqKhPYyMXquUky8VO9EKMbENWxx4Le7R9JTs5 SKX1+KA/NvTpa6D2SwaoBUxJPup5pcn2pcgX13upNh5AKyxhhwMHZXS9YhOiMN5QLe3VE/ W4Hwb/aQr2KxslDVv4ejTXWv67S9/ndO9RluKMBDLVxXJBFY00ZlkqxjlqXWIqvKWJTEfe KOvODHGDY7XkAxtJgbiegUYhcCMv6X2tBTHYrDM12aZu9n7/5TbDXT95CkyaRRdXqgRXdz 2qnNWJTFWQ/wdz8VIZBhFzbFIbz/wMtQhnJ1heU9bBZ1/bAzvinDrhZtjEJvDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794987628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tyYywDdqSQt/ptOnuXM8vyOfbN2I/b7FnubOqzlAXEg=; b=uodJMPCZC+3hVcdBEtNao88W7UmFKyYGzXCjKRoQsmvEIQvlRfP0NYf2CeyJEJzlIMqFfe Paxb7DEpyBAReokpSlhDuaNH9RW62WKpKLdqXeZ/dsgigwJaWFb6GeEmZCUu5N5VoU3fpo 8dfWpdpiqbY8JngEM8BcDpESgdlE65WwnoHlHOCqriJZxyYJY1hEJWvixGkvsVLi5fNhpZ c+2I9bxpNJK/8eFeCenMuoYjZs3Fd5gP1afB8O0jVGzOpTFBp8F/DKPWFpViSjsoa8vnwW NFJhiMnprug7HytioStasGVDwg788vSWRW/q4otooAlhC2HQz+ELmzNn7+lulw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTtmr39XZz1JrT for ; Wed, 18 Nov 2026 07:40:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 14f81 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 18 Nov 2026 07:40:28 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 05e79d2c0f76 - main - soelim: fix path and whitespace handling List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 05e79d2c0f765f1004517acb3e1f7e890b56d8c7 Auto-Submitted: auto-generated Date: Wed, 18 Nov 2026 07:40:28 +0000 Message-Id: <6afd566c.14f81.31249c83@gitrepo.freebsd.org> The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=05e79d2c0f765f1004517acb3e1f7e890b56d8c7 commit 05e79d2c0f765f1004517acb3e1f7e890b56d8c7 Author: Baptiste Daroussin AuthorDate: 2026-11-18 06:17:11 +0000 Commit: Baptiste Daroussin CommitDate: 2026-11-18 07:40:21 +0000 soelim: fix path and whitespace handling Reject truncated path Skip all white space following the file name --- usr.bin/soelim/soelim.c | 32 ++++++++++++++++++-------------- usr.bin/soelim/tests/soelim_test.sh | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/usr.bin/soelim/soelim.c b/usr.bin/soelim/soelim.c index fe363b9e8827..ad22901b1f7a 100644 --- a/usr.bin/soelim/soelim.c +++ b/usr.bin/soelim/soelim.c @@ -58,6 +58,7 @@ soelim_fopen(const char *name) FILE *f; char path[PATH_MAX]; size_t i; + int len; if (strcmp(name, "-") == 0) return (stdin); @@ -71,8 +72,10 @@ soelim_fopen(const char *name) } for (i = 0; i < includes->sl_cur; i++) { - snprintf(path, sizeof(path), "%s/%s", includes->sl_str[i], - name); + len = snprintf(path, sizeof(path), "%s/%s", + includes->sl_str[i], name); + if (len < 0 || (size_t)len >= sizeof(path)) + continue; if ((f = fopen(path, "r")) != NULL) return (f); } @@ -86,9 +89,8 @@ static int soelim_file(FILE *f, const char *name, int flag) { char *line = NULL; - char *walk, *cp; + char *walk, *cp, *end; size_t linecap = 0; - ssize_t linelen; int ret; if (f == NULL) @@ -96,30 +98,32 @@ soelim_file(FILE *f, const char *name, int flag) include_depth++; ret = 0; - while ((linelen = getline(&line, &linecap, f)) > 0) { + while (getline(&line, &linecap, f) > 0) { if (strncmp(line, ".so", 3) != 0) { - printf("%s", line); + fputs(line, stdout); continue; } walk = line + 3; - if (!isspace(*walk) && ((flag & C_OPTION) == 0)) { - printf("%s", line); + if (!isspace((unsigned char)*walk) && + ((flag & C_OPTION) == 0)) { + fputs(line, stdout); continue; } - while (isspace(*walk)) + while (isspace((unsigned char)*walk)) walk++; cp = walk; - while (*cp != '\0' && !isspace(*cp)) + while (*cp != '\0' && !isspace((unsigned char)*cp)) cp++; - *cp = 0; - if (cp < line + linelen) + end = cp; + while (isspace((unsigned char)*cp)) cp++; + *end = '\0'; if (*walk == '\0') { - printf("%s", line); + fputs(line, stdout); continue; } if (include_depth >= MAX_INCLUDE_DEPTH) { @@ -132,7 +136,7 @@ soelim_file(FILE *f, const char *name, int flag) break; } if (*cp != '\0') - printf("%s", cp); + fputs(cp, stdout); } include_depth--; diff --git a/usr.bin/soelim/tests/soelim_test.sh b/usr.bin/soelim/tests/soelim_test.sh index bf126d35260b..b768717aaa28 100755 --- a/usr.bin/soelim/tests/soelim_test.sh +++ b/usr.bin/soelim/tests/soelim_test.sh @@ -136,9 +136,27 @@ errors_body() soelim self } +atf_test_case whitespace +whitespace_head() +{ + atf_set "descr" "white space after the file name" +} + +whitespace_body() +{ + printf 'included\n' > inc + printf '.so inc \nnext\n' > trailing + atf_check \ + -o inline:"included\nnext\n" \ + -e empty \ + -s exit:0 \ + soelim trailing +} + atf_init_test_cases() { atf_add_test_case stdin atf_add_test_case files atf_add_test_case errors + atf_add_test_case whitespace }