Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 50881 invoked from network); 1 Sep 2009 17:12:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Sep 2009 17:12:58 -0000 Received: (qmail 94231 invoked by uid 500); 1 Sep 2009 17:12:57 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 94113 invoked by uid 500); 1 Sep 2009 17:12:57 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 94104 invoked by uid 99); 1 Sep 2009 17:12:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Sep 2009 17:12:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Sep 2009 17:12:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7C8BD23888E4; Tue, 1 Sep 2009 17:12:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r810128 - /commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c Date: Tue, 01 Sep 2009 17:12:33 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090901171233.7C8BD23888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mturk Date: Tue Sep 1 17:12:33 2009 New Revision: 810128 URL: http://svn.apache.org/viewvc?rev=810128&view=rev Log: Guard against temp path overflows Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c?rev=810128&r1=810127&r2=810128&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c Tue Sep 1 17:12:33 2009 @@ -71,13 +71,19 @@ if (tmpath) { if (strlcpy(name, tmpath, TMP_PATH_MAX) >= TMP_PATH_MAX) { - ACR_THROW_IO_IF_ERR(ACR_ENODIR); + ACR_THROW_IO_IF_ERR(ACR_E2BIG); return -1; } strlcat(name, "/", PATH_MAX); } strlcat(name, prefix, PATH_MAX); - strlcat(name, "XXXXXX", PATH_MAX); + if (strlcat(name, "XXXXXX", PATH_MAX) >= PATH_MAX) { + /* Truncation occurred. We dont have enough space + * to create temp file template + */ + ACR_THROW_IO_IF_ERR(ACR_E2BIG); + return -1; + } fd = mkstemp(name); if (fd < 0) { @@ -123,12 +129,12 @@ for (;;) { if (tmpath) { if (strlcpy(name, tmpath, TMP_PATH_MAX) >= TMP_PATH_MAX) { - ACR_THROW_IO_IF_ERR(ACR_ENODIR); + ACR_THROW_IO_IF_ERR(ACR_E2BIG); return NULL; } - strlcat(name, "/", PATH_MAX); + strlcat(name, "/", PATH_MAX); } - strlcat(name, prefix, PATH_MAX); + strlcat(name, prefix, PATH_MAX); if (strlcat(name, "XXXXXX", PATH_MAX) >= PATH_MAX) { /* Truncation occurred. We dont have enough space * to create temp file template