OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: Patch to handle empty sed expressions

From: Otto Moerbeek (ottodrijf.net)
Date: Tue Jan 02 2007 - 15:00:44 CST


On Mon, 1 Jan 2007, Matthew R. Dempsky wrote:

> Some packages (e.g., binutils 2.17) want to issue sed commands like
>
> s,^.*/,,;s,^,avr-,;;s/$//
>
> but OpenBSD's sed doesn't handle empty expressions as in this. The
> patch below adds support for this.
>
> (It also eliminates a useless null pointer check: p is checked for
> nullity when it is set a few lines above the hunk, and p is also
> dereferenced later without null checks.)

A dangerous statement in the presense of labels....

This looks correct to me. SU even specifies the empty command.

BTW, tech or bugs is better place to send diffs to.

        -Otto

>
> Index: src/usr.bin/sed/compile.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/sed/compile.c,v
> retrieving revision 1.22
> diff -p -u -r1.22 compile.c
> --- src/usr.bin/sed/compile.c 9 Oct 2006 00:23:56 -0000 1.22
> +++ src/usr.bin/sed/compile.c 2 Jan 2007 04:28:29 -0000
> -161,8 +161,12 compile_stream(struct s_command **link)
> }
>
> semicolon: EATSPACE();
> - if (p && (*p == '#' || *p == '\0'))
> + if (*p == '#' || *p == '\0')
> continue;
> + if (*p == ';') {
> + p++;
> + goto semicolon;
> + }
> *link = cmd = xmalloc(sizeof(struct s_command));
> link = &cmd->next;
> cmd->nonsel = cmd->inrange = 0;