Menu

#9 Keydata::loadFile -- segfault when keys arg is NULL

Common_Libraries
closed
Library (32)
5
2005-10-20
2005-10-17
No

<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>

Discussion

  • David Sugar

    David Sugar - 2005-10-18
    • labels: --> Library
    • assigned_to: nobody --> dyfet
     
  • David Sugar

    David Sugar - 2005-10-18

    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.

     
  • Scott Bailey

    Scott Bailey - 2005-10-18

    Patch file with suggested changes.

     
  • Scott Bailey

    Scott Bailey - 2005-10-18

    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.

     
  • David Sugar

    David Sugar - 2005-10-20
    • status: open --> closed
     

Log in to post a comment.