From patchwork Wed Aug 26 06:42:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 510736 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 06BD714028E for ; Wed, 26 Aug 2015 16:42:21 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=sX+4/SVq; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=u4UT4OHNP/ZWPQ2lr0ODQnWw4hUzTBZRMUwk3EDVcA1k1INVw4+OY Ju1FePyl2QDfMW9+ngEIvSsaRxN6flveNKjCICJiMRSE4/tDP9ZVLu6T8ZAcKWB7 T3M4TqMPSCDkmQLwa0uPxYfpzXgDv4/vHeAA4GSZnd8uBFKR24n4uM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=Xh5faHV8ZQ/YZYS/3Lo+5OomBjg=; b=sX+4/SVqVFrTuTjErG+Vhw3+pU7D M0M4CUTuIW5uSiBQ+KfH/gtT8G3heNIdO8tgbSJI/p+uztv1UYxJKKsb6f5X5ihY eIzPQK+Xs6SO5wyY1Md9mhN4U0Sjh31nrZwWJxrcAkV8ojUGaIPuGX7tcCOckw2w nmaoodrQOJ6AHqE= Received: (qmail 73831 invoked by alias); 26 Aug 2015 06:42:16 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 73817 invoked by uid 89); 26 Aug 2015 06:42:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: zimbra.cs.ucla.edu From: Paul Eggert To: libc-alpha@sourceware.org Cc: Paul Eggert Subject: [PATCH] Fix broken overflow check in posix_fallocate Date: Tue, 25 Aug 2015 23:42:01 -0700 Message-Id: <1440571321-20287-1-git-send-email-eggert@cs.ucla.edu> * sysdeps/posix/posix_fallocate.c (posix_fallocate): * sysdeps/posix/posix_fallocate64.c (__posix_fallocate64_l64): Fix parenthesization typo. --- ChangeLog | 5 +++++ sysdeps/posix/posix_fallocate.c | 2 +- sysdeps/posix/posix_fallocate64.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd6d027..458b850 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2015-08-25 Paul Eggert + Fix broken overflow check in posix_fallocate + * sysdeps/posix/posix_fallocate.c (posix_fallocate): + * sysdeps/posix/posix_fallocate64.c (__posix_fallocate64_l64): + Fix parenthesization typo. + Fix memory leak in printf_positional * stdio-common/vfprintf.c (printf_positional): Free temporary data allocated via malloc. diff --git a/sysdeps/posix/posix_fallocate.c b/sysdeps/posix/posix_fallocate.c index e7fe201..d0479a6 100644 --- a/sysdeps/posix/posix_fallocate.c +++ b/sysdeps/posix/posix_fallocate.c @@ -37,7 +37,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len) /* Perform overflow check. The outer cast relies on a GCC extension. */ - if ((__off_t) ((uint64_t) offset) + ((uint64_t) len) < 0) + if ((__off_t) ((uint64_t) offset + (uint64_t) len) < 0) return EFBIG; /* pwrite below will not do the right thing in O_APPEND mode. */ diff --git a/sysdeps/posix/posix_fallocate64.c b/sysdeps/posix/posix_fallocate64.c index ee32679..fb2dac6 100644 --- a/sysdeps/posix/posix_fallocate64.c +++ b/sysdeps/posix/posix_fallocate64.c @@ -37,7 +37,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) /* Perform overflow check. The outer cast relies on a GCC extension. */ - if ((__off64_t) ((uint64_t) offset) + ((uint64_t) len) < 0) + if ((__off64_t) ((uint64_t) offset + (uint64_t) len) < 0) return EFBIG; /* pwrite64 below will not do the right thing in O_APPEND mode. */