From: <gps...@li...> - 2011-12-11 13:02:23
|
Bugs item #3457119, was opened at 2011-12-11 03:31 Message generated for change (Comment added) made by hbowman You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=770280&aid=3457119&group_id=148048 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: source code Group: gpsdrive-2.11 Status: Open Resolution: None Priority: 5 Private: No Submitted By: dcb (dcb314) Assigned to: Nobody/Anonymous (nobody) Summary: friendsd.c: 2 * bad strncpy Initial Comment: I just tried to compile gpsdrive-2.11 with compiler flag -D_FORTIFY_SOURCE=2. It noticed 1. In function 'strncpy', inlined from 'dg_echo' at /home/dcb/rpmbuild/BUILD/gpsdrive-2.11/src/friendsd.c:229:16: /usr/include/bits/string3.h:121:3: warning: call to __builtin___strncpy_chk will always overflow destination buffer [enabled by default] The source code is strncpy ((list + i)->txt, mesg, MAXMESG - 1); Suggest new code strncpy ((list + i)->txt, mesg, 1024); 2. In function 'strncpy', inlined from 'dg_echo' at /home/dcb/rpmbuild/BUILD/gpsdrive-2.11/src/friendsd.c:245:15: /usr/include/bits/string3.h:121:3: warning: call to __builtin___strncpy_chk will always overflow destination buffer [enabled by default] Source code is strncpy ((list + i)->txt, mesg, MAXMESG - 1); Suggest new code strncpy ((list + i)->txt, mesg, 1024); ---------------------------------------------------------------------- >Comment By: Hamish B (hbowman) Date: 2011-12-11 05:02 Message: how about this solution: Index: src/friendsd.c =================================================================== --- src/friendsd.c (revision 2597) +++ src/friendsd.c (working copy) @@ -170,7 +170,7 @@ struct { char id[31]; - char txt[1024]; + char txt[MAXMESG]; long int times; } *list; ?, Hamish ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=770280&aid=3457119&group_id=148048 |