From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113432 invoked by alias); 28 Sep 2015 16:19:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 113422 invoked by uid 89); 28 Sep 2015 16:19:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f47.google.com Received: from mail-la0-f47.google.com (HELO mail-la0-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 28 Sep 2015 16:19:33 +0000 Received: by laclj5 with SMTP id lj5so72347818lac.3 for ; Mon, 28 Sep 2015 09:19:30 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.205.231 with SMTP id lj7mr5905202lbc.57.1443457170224; Mon, 28 Sep 2015 09:19:30 -0700 (PDT) Received: by 10.25.160.73 with HTTP; Mon, 28 Sep 2015 09:19:30 -0700 (PDT) In-Reply-To: <20150928161514.GZ1847@tucnak.redhat.com> References: <20150928161013.GC25312@msticlxl57.ims.intel.com> <20150928161514.GZ1847@tucnak.redhat.com> Date: Mon, 28 Sep 2015 16:50:00 -0000 Message-ID: Subject: Re: [PATCH][committed] Fix PR67652: wrong sizeof calculation in liboffloadmic From: Andrew Pinski To: Jakub Jelinek Cc: Ilya Verbin , GCC Patches , Kirill Yukhin Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg02132.txt.bz2 On Mon, Sep 28, 2015 at 9:15 AM, Jakub Jelinek wrote: > On Mon, Sep 28, 2015 at 07:10:13PM +0300, Ilya Verbin wrote: >> Committed to trunk as obvious. >> >> PR other/67652 >> * runtime/offload_engine.cpp (Engine::init_process): Fix sizeof. >> >> diff --git a/liboffloadmic/runtime/offload_engine.cpp b/liboffloadmic/runtime/offload_engine.cpp >> index 16b440d..00b673a 100644 >> --- a/liboffloadmic/runtime/offload_engine.cpp >> +++ b/liboffloadmic/runtime/offload_engine.cpp >> @@ -173,7 +173,7 @@ void Engine::init_process(void) >> // use putenv instead of setenv as Windows has no setenv. >> // Note: putenv requires its argument can't be freed or modified. >> // So no free after call to putenv or elsewhere. >> - char * env_var = (char*) malloc(sizeof("COI_DMA_CHANNEL_COUNT=2" + 1)); >> + char * env_var = (char*) malloc(sizeof("COI_DMA_CHANNEL_COUNT=2")); >> sprintf(env_var, "COI_DMA_CHANNEL_COUNT=2"); >> putenv(env_var); > > Missing error handling if malloc returns NULL? Also why not just use strdup here? instead of malloc/sizeof/sprintf ? Thanks, Andrew Pinski > > Jakub