[OPEN-ILS-DEV] PATCH: osrf_system.c (segfault)
Mike Rylander
mrylander at gmail.com
Mon May 28 10:22:54 EDT 2007
This, and a follow-up patch, are covered by a parallel effort
discussed later. (Just following up on the thread/patch.)
--miker
On 5/15/07, Scott McKellar <mck9 at swbell.net> wrote:
> 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/
>
>
--
Mike Rylander
More information about the Open-ils-dev
mailing list