Re: [hackers][sbase][PATCH] Activate the "else if" branch

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Wed, 16 Dec 2015 09:28:29 +0100

On Tue, Dec 15, 2015 at 07:54:28PM +0100, Silvan Jegen wrote:
> We checked the same condition in the "if" branch so it was never true
> in the "else if" one. Removing this condition makes the "else if"
> branch viable.

I'm sorry, but you are wrong here. Setjmp saves the current state
of the program, and it allows that a deeper call to longjmp restores
the state. When setjmp is called directly it returns always 0,
but when it returns dur to a call to longjmp it returns a value
passed as parameter to longjmp (in our case 1). It is a kind of
try {} catch{} ala C.

> dowrite("ed.hup", 1);
> - } else if (home && !setjmp(savesp)) {
> + } else if (home) {
> n = snprintf(fname,

If you remove the setjmp in the else if branch, then any call
to error (which calls to longjmp) will resume the execution in
the if branch, making a new execution of the else if branch,
which in some cases will produce an infinite loop.


Regards,
Received on Wed Dec 16 2015 - 09:28:29 CET

This archive was generated by hypermail 2.3.0 : Wed Dec 16 2015 - 09:36:14 CET