Summary:ASTERISK-05121: [patch] ast_strlen_zero on a null string causes segfault.
Reporter:Anthony Minessale (anthm)Labels:
Date Opened:2005-09-21 12:36:42Date Closed:2011-06-07 14:00:37
Versions:Frequency of
Environment:Attachments:( 0) strlenzero.diff
Description:This may be up for debate but I get the impression that most people expect ast_strlen_zero() on a null string to return true rather than to segfault the box. if it is intended to crash may i recommend an assert(s != NULL) so we know why it's crashing all over the place.

Comments:By: Tilghman Lesher (tilghman) 2005-09-21 16:38:03

What code is not already checking for a NULLable condition before calling ast_strlen_zero?

For that matter, strlen(3) (which this function is replacing) also doesn't test for non-NULL and will segfault if passed a NULL pointer.

By: Anthony Minessale (anthm) 2005-09-21 19:26:55

cdr.c does in like every function and currently causes a crash for some poor souls which is how I discovered.

Like I said, it can be a philosophical debate.  That is why I say at least put an assert in it so you can see where it crashes right away.  Though, since it *is* a new function it may be nice to have it be true for NULL , let the world decide.

By: Tilghman Lesher (tilghman) 2005-09-21 23:18:04

None of the functions in cdr.c would cause a crash from ast_strlen_zero.  The only way that I could see a crash occurring is if cdr itself was NULL, in which case the dereferencing of the NULL value would cause a crash, not the usage of the ast_strlen_zero function.

The other possibility for a crash occurring is the usage of Intel's C compiler or another compiler which evaluates conditions right to left, instead of left to right, the way gcc does.  However, this would not be a problem unique to cdr.c; that issue would crop up all over the place.

Do you have a backtrace to upload?

By: Anthony Minessale (anthm) 2005-09-22 09:27:17

I dont want to fight about someone elses bug. Let it crash I'm sofa anyway.