[PATCH libgpg-error] gpgrt-config: escape expr(1) operands

Roman Bogorodskiy bogorodskiy at gmail.com
Thu Jan 17 05:12:36 CET 2019


  NIIBE Yutaka wrote:

> Roman Bogorodskiy <bogorodskiy at gmail.com> wrote:
> > With FreeBSD's expr(1), gpgrt-config prints the following:
> [...]
> > This happens because FreeBSD expr(1) makes no lexical distinction
> > between arguments which may be operators and arguments which
> > may be operands. [1]
> >
> > To fix that, parenthesize values that could start with "-", as
> > suggested in the man page.
> 
> Thank you.
> 
> > --- a/src/gpgrt-config
> > +++ b/src/gpgrt-config
> > @@ -404,7 +404,7 @@ sysroot () {
> >  	    _result="$_result${_result:+ }$_opt"
> >  	    shift
> >  	    _result="$_result $PKG_CONFIG_SYSROOT_DIR$1"
> > -	elif expr "$1" : "^$_opt" >/dev/null; then
> > +	elif expr "\( $1 \)" : "^$_opt" >/dev/null; then
> 
> Here, the expression is to match string of $1 against $_opt.  IIUC,
> while this fix indeed escapes $1, I'm afraid it changes the semantics.
> 
> I fix it in a different way, by adding "x" to the expression.  I also
> fix another portability problem of expr.

Hi,

For some reason, it looks like this change was not included to 1.34,
which is strange, because I can see the commit[1] in the repo.

If I do something like that, I can see the old bits are still there:

$ curl -s https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.34.tar.bz2 | tar Ojxf - libgpg-error-1.34/src/gpgrt-config |egrep -n 'expr ("\$1|match)'
451:    elif expr "$1" : "^$_opt" >/dev/null; then
452:        _result="$_result${_result:+ }$_opt$PKG_CONFIG_SYSROOT_DIR$(expr "$1" : "^$_opt\(.*\)")"
571:elif expr match "$module_list" "=\|!=\|<\|>\|<=\|>=" >/dev/null; then
$

Am I missing something?

1: https://github.com/gpg/libgpg-error/commit/1d71dbb

Roman Bogorodskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: not available
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20190117/827d1d9e/attachment.sig>


More information about the Gnupg-devel mailing list