From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5502 invoked by alias); 26 Jun 2009 12:18:15 -0000 Received: (qmail 5494 invoked by uid 22791); 26 Jun 2009 12:18:14 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp-vbr3.xs4all.nl (HELO smtp-vbr3.xs4all.nl) (194.109.24.23) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Jun 2009 12:18:06 +0000 Received: from [192.168.1.66] (cust.7.108.adsl.cistron.nl [82.95.157.21]) by smtp-vbr3.xs4all.nl (8.13.8/8.13.8) with ESMTP id n5QCI2AH040143; Fri, 26 Jun 2009 14:18:02 +0200 (CEST) (envelope-from rutger@cs.vu.nl) Message-ID: <4A44BE0B.3050108@cs.vu.nl> Date: Fri, 26 Jun 2009 12:18:00 -0000 From: Rutger Hofman User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Chris Holgate CC: ecos-devel@ecos.sourceware.org Subject: Re: Should we add compiler warnings to diag_sprintf & diag_vsprintf ? References: <4A44B683.5060602@zynaptic.com> <4A44BC4E.5030508@cs.vu.nl> In-Reply-To: <4A44BC4E.5030508@cs.vu.nl> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact ecos-devel-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-devel-owner@ecos.sourceware.org X-SW-Source: 2009-06/txt/msg00039.txt.bz2 Rutger Hofman wrote: > Chris Holgate wrote: >> I've just had to add support for diag_vsnprintf to diag.h as part of >> writing some logging code. We all know that sprintf, vsprintf and their >> evil unchecked spawn are the source of lots of buffer overflow bugs - >> so while I'm prepping a patch for this change is it worth adding >> compiler warning attributes to diag_sprintf and diag_vsprintf to help >> 'discourage' their use? > > That would collide with -Werror -- an option I happen to like a lot. > Besides, my guess is that the vsnprintf functions will be called through > some printf-style variadic function, and the compiler can verify > arguments there. Ach, I misunderstood. You want to discourage diag_sprintf and diag_vsprintf in favour of diag_vsnprintf. I fully agree here. Rutger