From owner-svn-src-projects@freebsd.org Sun Feb 21 21:51:06 2016 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B09D1AB0A87 for ; Sun, 21 Feb 2016 21:51:06 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5D5E219EE; Sun, 21 Feb 2016 21:51:06 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: by mail-wm0-x231.google.com with SMTP id b205so132641923wmb.1; Sun, 21 Feb 2016 13:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=TAoTHFFK83YxMNozzPtP32Lyx5KKEJEGoNf/i53f5Eo=; b=u8MUE9hqy4abMqL6s7kUfQBTzKGWNLfdrvtuhFY+anev4ynBmnfjc61rbUp1BHllTW Mvkh2vtUYS+j9QlUyCw9JXj/g/38MbynJfmjnvVtDmBFVBtUYYwqe2bfQTIFZ92214jT vzwa2owaWBqyvw9du3Mx2e/f9Wt5nnJYN50oR8/LkIkLPA4cQqGs71egU5SA4QP+aRR/ xJkUQWTu4/Ju9ZpnAqI8i5eNrtfByI7ReZpWenUAUllG1ZdNPKvkuVWPGM5/ZUh6UyVq DRgwjpLVaxe0aiTEOjbBRWhAov5Nce/pas58uOcg1n2Dq86mnqhVLButAo66rgL7L6Bk 2vKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=TAoTHFFK83YxMNozzPtP32Lyx5KKEJEGoNf/i53f5Eo=; b=LIbv8BpVgRzVMDeB9ZB40t/Cf00eVK1hE3jHdxNJolRXXVFOnKrcwTEdggAo6Nmwg7 ZtRvcTDawzqJUb11bVoxEwCrzPp8uEMK5Na3BHz+Q2BArm3zIsj7DyaBoBp+4nDx6NCf 80ViUpHPgozoxUMfllY9Hat1jcR4DXduXayQaRcLehN+MMIm9yGwaV6jFbNZzPus4Riz znbDRruc9cPoHxzxiMFKMq+5wFBb20xYOmlLzwAyv/mxkS+2QQsj+RyBL/a7X2WjlFqI 0p8Yeb7wzNSdT0AiCC3KxIoDiiWwH9Sg3Jots8t9bkS4rqaZANiYbGdOHmFbVG980a0I ULFA== X-Gm-Message-State: AG10YOQryKVHPB7RtFJ7DYHWfgtHtLbXvOS3QuCLyr/l8c9k8J/mkZd4rd1nC47kzR0A5Kwa1e24qtdbwXmUGA== MIME-Version: 1.0 X-Received: by 10.28.88.81 with SMTP id m78mr9172395wmb.58.1456091463955; Sun, 21 Feb 2016 13:51:03 -0800 (PST) Received: by 10.27.170.11 with HTTP; Sun, 21 Feb 2016 13:51:03 -0800 (PST) In-Reply-To: <1456066063.1294.40.camel@freebsd.org> References: <201602191637.u1JGb6lm055074@repo.freebsd.org> <1456066063.1294.40.camel@freebsd.org> Date: Sun, 21 Feb 2016 15:51:03 -0600 Message-ID: Subject: Re: svn commit: r295812 - projects/mips64-clang/sys/mips/rmi From: Benjamin Kaduk To: Ian Lepore Cc: Sean Bruno , "src-committers@freebsd.org" , svn-src-projects@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Feb 2016 21:51:06 -0000 On Sun, Feb 21, 2016 at 8:47 AM, Ian Lepore wrote: > On Fri, 2016-02-19 at 16:37 +0000, Sean Bruno wrote: > > Author: sbruno > > Date: Fri Feb 19 16:37:06 2016 > > New Revision: 295812 > > URL: https://svnweb.freebsd.org/changeset/base/295812 > > > > Log: > > Change a static const string to a #define as the strcpy() throws a > > warn/error with clang. > > > > /home/sbruno/mips64-clang/sys/mips/rmi/xls_ehci.c:133:25: error: > > format string is not a string literal (potentially insecure) > > [-Werror,-Wformat-security] > > sprintf(sc->sc_vendor, xlr_vendor_desc); > > > > Modified: > > projects/mips64-clang/sys/mips/rmi/xls_ehci.c > > > > Modified: projects/mips64-clang/sys/mips/rmi/xls_ehci.c > > ===================================================================== > > ========= > > --- projects/mips64-clang/sys/mips/rmi/xls_ehci.c Fri Feb 19 > > 15:53:08 2016 (r295811) > > +++ projects/mips64-clang/sys/mips/rmi/xls_ehci.c Fri Feb 19 > > 16:37:06 2016 (r295812) > > @@ -73,7 +73,7 @@ static device_attach_t ehci_xls_attach; > > static device_detach_t ehci_xls_detach; > > > > static const char *xlr_usb_dev_desc = "RMI XLR USB 2.0 controller"; > > -static const char *xlr_vendor_desc = "RMI Corp"; > > +#define XLR_VENDOR_DESC "RMI Corp"; > > > > static int > > ehci_xls_probe(device_t self) > > @@ -130,7 +130,7 @@ ehci_xls_attach(device_t self) > > device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); > > device_set_desc(sc->sc_bus.bdev, xlr_usb_dev_desc); > > > > - sprintf(sc->sc_vendor, xlr_vendor_desc); > > + sprintf(sc->sc_vendor, XLR_VENDOR_DESC); > > > > err = bus_setup_intr(self, sc->sc_irq_res, > > INTR_TYPE_BIO | INTR_MPSAFE, NULL, > > > > Bah. The compiler should understand that a static const char* is > equivelent to a string literal for the purposes of this warning. > > Is it? The compiler would need to check that nothing else in the file writes to xlr_vendor_desc before making that conclusion; on the other hand, if it was char const * const, then that alone would suffice. > That said, a sprintf() is just a strange spelling of strlcpy() here. > Almost. sprintf() is not as good about length checking as strlcpy(), which is a much better option here, as you note. -Ben > > -- Ian > > _______________________________________________ > svn-src-projects@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-projects > To unsubscribe, send any mail to "svn-src-projects-unsubscribe@freebsd.org > " >