tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: varargs bug in libedit



On Tue, Nov 03, 2015 at 12:26:01AM +0000, Christos Zoulas wrote:
> In article <20151102223523.GD50561%spindle.one-eyed-alien.net@localhost>,
> Brooks Davis  <brooks%freebsd.org@localhost> wrote:
> >I've commmitted the following to FreeBSD's copy of libedit.  It fixes a
> >bug in varargs handling in el_get().  It's harmless for most
> >architectures, but our CHERI architecture turns it into a failure.
> 
> This looks wrong. To set let's say EL_SIGNAL you do:
> 
> 	el_set(el, EL_SIGNAL, 1);
> 
> but how do you get the current setting of EL_SIGNAL if you pass an int?
> You need:
> 
> 	int x;
> 	el_get(el, EL_SIGNAL, &x);
> 
> Something else is wrong...

The documentation for EL_SIGNAL is:

  EL_SIGNAL, int flag
	 If flag is non-zero, editline will install its own signal
	 handler for the following signals when reading command input:
	 SIGCONT, SIGHUP, SIGINT, SIGQUIT, SIGSTOP, SIGTERM, SIGTSTP,
	 and SIGWINCH.  Otherwise, the current signal handlers will be
	 used.

It provides no way to retrieve the previous value.  el_wget does read
the value as an int so if you passed &x it wouldn't work in any
sensible way.

As you say, this isn't a good API, but it's what's documented and
implemented.

-- Brooks

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index