From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3179C1F601 for ; Sat, 3 Sep 2022 11:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662204021; bh=BeYhccpMLW+fTjUqoaPDg3sGMGIMl2qfSqNmU1tMzVI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OjsMakYB5niwH5DaGceZYW9Q6CdgfbghQ6u9izQGwSY69sxDmnpLAPCIp/Yk85LNM /jIH5s0r0XE7ENJom0RjfWzElbhA1FrwkqONRJUT/qvkuSOELR3DI+S2qPEP3kbWsq xel7PqupOE3dMBqoNR57Gx1G15fmdGkI6E/wI4dQ= From: Eric Wong To: mwrap-public@80x24.org Subject: [PATCH 2/2] paranoid safety fix to clamp pathnames to PATH_MAX Date: Sat, 3 Sep 2022 11:20:20 +0000 Message-Id: <20220903112020.2317141-3-e@80x24.org> In-Reply-To: <20220903112020.2317141-1-e@80x24.org> References: <20220903112020.2317141-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: While I doubt Ruby (nor Perl) would store pathnames longer than PATH_MAX by default, it's possible `eval' users to specify whatever path (and line number) they wish to use. Likely was the case with `# line $FILE' directives in Perl5 which prompted this clamping. --- ext/mwrap/mwrap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/mwrap/mwrap.c b/ext/mwrap/mwrap.c index 90f560e..08761d6 100644 --- a/ext/mwrap/mwrap.c +++ b/ext/mwrap/mwrap.c @@ -470,6 +470,8 @@ static struct src_loc *update_stats_rcu_lock(size_t size, uintptr_t caller) /* avoid vsnprintf or anything which could call malloc here: */ len = strlen(ptr); + if (len > PATH_MAX) + len = PATH_MAX; k = (void *)kbuf; k->total = size; dst = mempcpy(k->k, ptr, len);