From owner-svn-src-stable@freebsd.org Wed Sep 5 12:06:24 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C995FEE384; Wed, 5 Sep 2018 12:06:24 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 171D97E33A; Wed, 5 Sep 2018 12:06:23 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w85C66TO025934 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 5 Sep 2018 15:06:09 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w85C66TO025934 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w85C66Sd025933; Wed, 5 Sep 2018 15:06:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 5 Sep 2018 15:06:06 +0300 From: Konstantin Belousov To: Mark Johnston Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r338462 - in stable/11: sys/kern usr.bin/sed usr.bin/sed/tests Message-ID: <20180905120606.GA3161@kib.kiev.ua> References: <201809050030.w850UZaF031642@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201809050030.w850UZaF031642@repo.freebsd.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 12:06:24 -0000 On Wed, Sep 05, 2018 at 12:30:35AM +0000, Mark Johnston wrote: > Author: markj > Date: Wed Sep 5 00:30:34 2018 > New Revision: 338462 > URL: https://svnweb.freebsd.org/changeset/base/338462 > > Log: > MFC r338375: > sed: Fix -i option behavior with 'q' command. > > PR: 230507 > > Modified: > stable/11/sys/kern/imgact_elf.c ^^^^ This part is not relevant. > stable/11/usr.bin/sed/extern.h > stable/11/usr.bin/sed/main.c > stable/11/usr.bin/sed/process.c > stable/11/usr.bin/sed/tests/sed2_test.sh > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/sys/kern/imgact_elf.c > ============================================================================== > --- stable/11/sys/kern/imgact_elf.c Tue Sep 4 19:28:46 2018 (r338461) > +++ stable/11/sys/kern/imgact_elf.c Wed Sep 5 00:30:34 2018 (r338462) > @@ -839,7 +839,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i > break; > case PT_INTERP: > /* Path to interpreter */ > - if (phdr[i].p_filesz > MAXPATHLEN) { > + if (phdr[i].p_filesz < 2 || > + phdr[i].p_filesz > MAXPATHLEN) { > uprintf("Invalid PT_INTERP\n"); > error = ENOEXEC; > goto ret; > @@ -870,6 +871,11 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i > } else { > interp = __DECONST(char *, imgp->image_header) + > phdr[i].p_offset; > + if (interp[interp_name_len - 1] != '\0') { > + uprintf("Invalid PT_INTERP\n"); > + error = ENOEXEC; > + goto ret; > + } > } > break; > case PT_GNU_STACK: > > Modified: stable/11/usr.bin/sed/extern.h > ============================================================================== > --- stable/11/usr.bin/sed/extern.h Tue Sep 4 19:28:46 2018 (r338461) > +++ stable/11/usr.bin/sed/extern.h Wed Sep 5 00:30:34 2018 (r338462) > @@ -44,6 +44,8 @@ extern int aflag, eflag, nflag; > extern const char *fname, *outfname; > extern FILE *infile, *outfile; > extern int rflags; /* regex flags to use */ > +extern const char *inplace; > +extern int quit; > > void cfclose(struct s_command *, struct s_command *); > void compile(void); > > Modified: stable/11/usr.bin/sed/main.c > ============================================================================== > --- stable/11/usr.bin/sed/main.c Tue Sep 4 19:28:46 2018 (r338461) > +++ stable/11/usr.bin/sed/main.c Wed Sep 5 00:30:34 2018 (r338462) > @@ -101,6 +101,7 @@ FILE *outfile; /* Current output file */ > > int aflag, eflag, nflag; > int rflags = 0; > +int quit = 0; > static int rval; /* Exit status */ > > static int ispan; /* Whether inplace editing spans across files */ > @@ -114,7 +115,7 @@ const char *fname; /* File name. */ > const char *outfname; /* Output file name */ > static char oldfname[PATH_MAX]; /* Old file name (for in-place editing) */ > static char tmpfname[PATH_MAX]; /* Temporary file name (for in-place editing) */ > -static const char *inplace; /* Inplace edit file extension. */ > +const char *inplace; /* Inplace edit file extension. */ > u_long linenum; > > static void add_compunit(enum e_cut, char *); > @@ -334,7 +335,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) > } > > for (;;) { > - if (infile != NULL && (c = getc(infile)) != EOF) { > + if (infile != NULL && (c = getc(infile)) != EOF && !quit) { > (void)ungetc(c, infile); > break; > } > > Modified: stable/11/usr.bin/sed/process.c > ============================================================================== > --- stable/11/usr.bin/sed/process.c Tue Sep 4 19:28:46 2018 (r338461) > +++ stable/11/usr.bin/sed/process.c Wed Sep 5 00:30:34 2018 (r338462) > @@ -207,10 +207,14 @@ redirect: > } > break; > case 'q': > - if (!nflag && !pd) > - OUT(); > - flush_appends(); > - exit(0); > + if (inplace == NULL) { > + if (!nflag && !pd) > + OUT(); > + flush_appends(); > + exit(0); > + } > + quit = 1; > + break; > case 'r': > if (appendx >= appendnum) > if ((appends = realloc(appends, > > Modified: stable/11/usr.bin/sed/tests/sed2_test.sh > ============================================================================== > --- stable/11/usr.bin/sed/tests/sed2_test.sh Tue Sep 4 19:28:46 2018 (r338461) > +++ stable/11/usr.bin/sed/tests/sed2_test.sh Wed Sep 5 00:30:34 2018 (r338462) > @@ -38,6 +38,7 @@ inplace_hardlink_src_body() > atf_check ln a b > atf_check sed -i '' -e 's,foo,bar,g' b > atf_check -o 'inline:bar\n' -s exit:0 cat b > + atf_check -s not-exit:0 stat -q '.!'* > } > > atf_test_case inplace_symlink_src > @@ -50,10 +51,27 @@ inplace_symlink_src_body() > echo foo > a > atf_check ln -s a b > atf_check -e not-empty -s not-exit:0 sed -i '' -e 's,foo,bar,g' b > + atf_check -s not-exit:0 stat -q '.!'* > } > > +atf_test_case inplace_command_q > +inplace_command_q_head() > +{ > + atf_set "descr" "Verify -i works correctly with the 'q' command" > +} > +inplace_command_q_body() > +{ > + printf '1\n2\n3\n' > a > + atf_check -o 'inline:1\n2\n' sed '2q' a > + atf_check sed -i.bak '2q' a > + atf_check -o 'inline:1\n2\n' cat a > + atf_check -o 'inline:1\n2\n3\n' cat a.bak > + atf_check -s not-exit:0 stat -q '.!'* > +} > + > atf_init_test_cases() > { > + atf_add_test_case inplace_command_q > atf_add_test_case inplace_hardlink_src > atf_add_test_case inplace_symlink_src > }