[OPEN-ILS-DEV] PATCH: osrf_system.c (segfault)
Scott McKellar
mck9 at swbell.net
Tue May 15 01:01:48 EDT 2007
In osrf_system_bootstrap_client_resc() we read a configuration file
and grab various bits and pieces from it.
If the file is empty, however, we get a segmentation fault from
the following line:
char* domain = strdup(osrfStringArrayGetString( arr, 0 ));
We populated the string array with all the domains in the configuration
file, and then picked the first one. But if the configuration file
is empty, then there are no domains. The string array is empty, so
osrfStringArrayGetString() returns NULL, which we then try to strdup.
Oops.
The same thing probably happens if the configuration file is not
empty but doesn't have a domain. I haven't tried that scenario.
This patch is minimal. If osrfStringArrayGetString() returns NULL,
I strdup an empty string instead. The rest of the function doesn't
seem to notice. In the case of srfsh I get some error messages but
then I get to the srfsh# prompt in the usual way. I can do a
"set pretty_print true" and so forth, but some other operations
would presumably fail.
An alternative response would be to return -1 immediately (after
releasing allocated resources, of course). Then the calling function
can recognize that there's an error and refuse to continue. I can
prepare a patch that does that, if you prefer. Your call.
Scott McKellar
http://home.swbell.net/mck9/aargh/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: osrf_system_c_1.patch
Type: text/x-patch
Size: 900 bytes
Desc: 792189815-osrf_system_c_1.patch
Url : http://list.georgialibraries.org/pipermail/open-ils-dev/attachments/20070514/649d6b8f/osrf_system_c_1.bin
More information about the Open-ils-dev
mailing list