From owner-svn-src-head@freebsd.org Thu Jun 15 17:49:12 2017 Return-Path: Delivered-To: svn-src-head@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 181F8D8EE9A; Thu, 15 Jun 2017 17:49:12 +0000 (UTC) (envelope-from delphij@gmail.com) Received: from mail-io0-x233.google.com (mail-io0-x233.google.com [IPv6:2607:f8b0:4001:c06::233]) (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 D56F97DA51; Thu, 15 Jun 2017 17:49:11 +0000 (UTC) (envelope-from delphij@gmail.com) Received: by mail-io0-x233.google.com with SMTP id t87so16482311ioe.0; Thu, 15 Jun 2017 10:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=uwIrZN3aL1EfliP4o/JSkCTFNIKRfn5Ijtm7p402nAE=; b=TbDZmgLIZj2Iv03qr88NGjcLK7YXXWRn4SQea6pJxbobl0CgDUgeyb5T4QpmjvsbNY wQi8eQblMu83sTzwlQMJc/HxOJPI4OJ1gDSJB46mFQIumDZ6GF66wgdcHmPRkzvq5wZW vtixgjLZIl8Aoe6PUKpXYDI9Um2ZJVfznDdhaitvanbA8rTZh8RJJSYblIIb93JFiccI P0PtIGbnHx79qNWJNN+zF1ZZX4RBqzTyeBNtAStCkpKaRBamR0LkZBafxOytNiCg1OzK U8vxtWZxTUj6D5BhtJGVGnEFn7+u6TtXftoQ0CL3iUzlClH1ISTlCB1SiOW9ZPcCkySJ +aHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=uwIrZN3aL1EfliP4o/JSkCTFNIKRfn5Ijtm7p402nAE=; b=iwo4XUs4+WvT+WzON5/xdZbSSm+lxyn05Qa5hLPR2FA7Ll6U6RtydYyBFoxAolfBl2 yBnl6RPteX01BAv6XlGAEdedxll0PvAFR7kAyEWt3aW2rvToT7WSuHnpJs9Lotg9cLVu vL6BO+pbVns/UKcyQM2kJZug6LRt6KaJL4iI5VVeYYHSva+hh7hr9ieIuAQ/JLT/0ANe bWMLUbhVwC4Q8+oEkmHVyHGA2cH0piNALDDZnWiFjBVsoESBG05G2ckAO0M1zabcOIAN KsJ4Ti4uRMIPt53vJlbkOGBzyma4KvTgxDi5EgCqynA/MOTa2/9GsLs3DzbSUo4tF54B /1hA== X-Gm-Message-State: AKS2vOz4boWGM+Se7bdYlGzx8b+a3opky7ZMxRaUqSXgPcqGaTegBtML TdCWVTESr0J8E9/ihCDVd8yZtmk+6SJYq5U= X-Received: by 10.107.174.211 with SMTP id n80mr7173831ioo.54.1497548950997; Thu, 15 Jun 2017 10:49:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.33.199 with HTTP; Thu, 15 Jun 2017 10:49:10 -0700 (PDT) In-Reply-To: <201706131235.v5DCZ1aR077437@repo.freebsd.org> References: <201706131235.v5DCZ1aR077437@repo.freebsd.org> From: Xin LI Date: Thu, 15 Jun 2017 10:49:10 -0700 Message-ID: Subject: Re: svn commit: r319897 - head/usr.bin/yes To: Pietro Cerutti , cognet@freebsd.org Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jun 2017 17:49:12 -0000 Hi, On Tue, Jun 13, 2017 at 5:35 AM, Pietro Cerutti wrote: [...] > Modified: head/usr.bin/yes/yes.c > ============================================================================== > --- head/usr.bin/yes/yes.c Tue Jun 13 12:07:18 2017 (r319896) > +++ head/usr.bin/yes/yes.c Tue Jun 13 12:35:01 2017 (r319897) > @@ -44,20 +44,42 @@ static const char rcsid[] = "$FreeBSD$"; > int > main(int argc, char **argv) > { [...] > + { > + exp = argv[1]; > + explen = strlen(exp) + 1; > + exp[explen - 1] = '\n'; > + } I think this effectively replaces the terminating NUL character with '\n', but in this context it seems to be Okay because later code is treating argv[1] as a block of memory instead of NUL-termated string. Could you please add comment here, so future readers would not have to scratch their head and figure this out again and again? By the way, in r319904, the following was introduced: if (explen <= sizeof(buf)) { Why do we bother to copy the buffer when the size is exactly the same (and we could use it directly), in other words, why not explen < sizeof(buf)? Cheers,