Segment fault

Jouni Malinen jkmaline at cc.hut.fi
Thu May 8 23:16:27 EDT 2003


On Fri, May 09, 2003 at 11:39:04AM +0900, ?vBXXZcX0-? wrote:

>         if (!oserv || nserv->shared_secret_len != oserv->shared_secret_len ||
>             memcmp(nserv->shared_secret, oserv->shared_secret, nserv->shared_secret_len) != 0) {
> 	...
> 	}
> 
> in case oserv is NULL the "!oserv condition" make it TRUE and "oserv->shared_secret_len" is not exist in memory
> but, the condition try to access oserv->XXX  member event though oserv is NULL. So, segment fault generated..


Eh.. What kind of C compiler are you using? Are you saying that it has
short-circuiting disabled? If oserv == NULL, that if statement only
evaluates !oserv and does not evaluate others parts, i.e., it does not
dereference oserv as NULL pointer. If your compiler evaluates other
parts, e.g. prints 'foo' with 'if (1 || printf("foo")) {}', you will
surely find much more problems since short-circuiting is used a lot in
many C programs..


-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the HostAP mailing list