#9 Suggested fixes to strcmp and strstr usage

closed
Interface (7)
5
2014-08-17
2009-01-04
No

in libircclient.c line 622;

else if \( \!strccmp \(params\[0\], session->nick\) \)

This needs to be strcasecmp; nicks and channels are case preserving but case insensitive.

Discussion

  • Nathan Ollerenshaw

    Actually, I have a bunch of suggested fixes in this area. I'll supply a patch and you can review & merge if acceptable.

     
  • George Yunaev

    George Yunaev - 2009-01-04

    Sure. BTW, wanna join as a maintainer?

     
  • Nathan Ollerenshaw

    • summary: strcmp needs to be strcasecmp --> Suggested fixes to strcmp and strstr usage
     
  • Nathan Ollerenshaw

    the attached patch does the following;

    in libirc_process_incoming_data(), use size_t for process_length. A length < 0 isn't valid; and size_t should really be used for all lengths as a matter of consistency.

    Added char *buf_end which points to buf + process_length, giving us a way to limit the strncmp() calls.

    Replaced all usage of strcmp() with strncmp().
    Replaced the problematic strcmp() in the nickname comparison on line 622 with strncasecmp() (is this available on every OS? or is it a BSD thing?)

    It also includes the fix for the ACTION target clobbering issue.

    You can add me as maintainer if you like; but I probably won't be very active. You also may not agree with my fixes :)

     
  • George Yunaev

    George Yunaev - 2009-01-04

    Generally it's ok. I'd replace strncasecmp by your own function as it's not portable enough. Should be easy to do so.

    I've added you as a developer. The library is generally stable, so bugfixes are quite rare. I do not use personally this library anymore, and therefore not adding the features. Feel free to discuss/add new ones. For coding, I would ask the code to support Unix/Win32 which shouldn't be a problem.

     
  • Nathan Ollerenshaw

    Fixed in revision 82.

    Added

    \#define strncasecmp            \_strnicmp
    

    to portable.c which should make it work on Windows.

     
  • Nathan Ollerenshaw

    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks