Keydata::loadFile -- segfault when keys arg is NULL
GNU Telephony Services and Applications
Brought to you by:
dyfet
<code>
version: commoncpp2-1.3.20
file: keydata.cpp
functon: Keydata::loadFile
platform: solaris 10 x86
The following code snipet causes segfault when keys is NULL
if(seek)
setString(seek, sizeof(seek), keys);
else
seek[0] = 0;
Potential workaround: change "if (seek)" to "if
(keys)"; however, note that keydata is not loaded from
the head of the file (as I suspect it should be) with
this fix.
(Given time, I will submit a patch, but don't hold your
breath.)
</code>
Logged In: YES
user_id=217
I think that was actually supposed to be if(keys) since it is true always
otherwise.
Generally there is an automatic cfgFile->seekg(0); further down, so it always
restarts it scan from head.
Perhaps the while loop; while(stricmp(seek, find))
Should also become while(keys && stricmp(seek, find))
As this assures the while look the exists if keys was originally passed as
NULL.
Patch file with suggested changes.
Logged In: YES
user_id=72684
Yes, the suggested changes correct the defect.
Note, for those of you foolishly holding your breath, I did
indeed upload a patch.