bugFreeciv - Bugs: bug #20443, fc_utf8_validate_rep_len():...

 
 
Show feedback again

bug #20443: fc_utf8_validate_rep_len(): "end" might be used uninitialized

Submitted by:  Marko Lindqvist <cazfi>
Submitted on:  Sat Jan 19 09:27:39 2013  
 
Category: generalSeverity: 3 - Normal
Priority: 5 - NormalStatus: Fixed
Assigned to: Marko Lindqvist <cazfi>Open/Closed: Closed
Release: Operating System: None
Planned Release: 2.3.4, 2.4.0, 2.5.0Contains string changes: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon Jan 21 09:26:27 2013, SVN revision 22173:

Assert against NULL parameter string in fc_utf8_validate_rep_len().
This fixes compiler warning about how variable "end" might be used
uninitialized if string is NULL.

See gna bug #20443

(Browse SVN revision 22173)

Marko Lindqvist <cazfi>
Project AdministratorIn charge of this item.
Mon Jan 21 09:26:23 2013, SVN revision 22172:

Assert against NULL parameter string in fc_utf8_validate_rep_len().
This fixes compiler warning about how variable "end" might be used
uninitialized if string is NULL.

See gna bug #20443

(Browse SVN revision 22172)

Marko Lindqvist <cazfi>
Project AdministratorIn charge of this item.
Mon Jan 21 09:25:38 2013, SVN revision 22171:

Assert against NULL parameter string in fc_utf8_validate_rep_len().
This fixes compiler warning about how variable "end" might be used
uninitialized if string is NULL.

See gna bug #20443

(Browse SVN revision 22171)

Marko Lindqvist <cazfi>
Project AdministratorIn charge of this item.
Sat Jan 19 09:27:39 2013, original submission:

When compiling with optimization level -O3 (and related inlining):

../../../src.patched/utility/fc_utf8.c: In function 'fc_utf8_validate_rep_len':
../../../src.patched/utility/fc_utf8.c:150:17: error: 'end' may be used uninitialized in this function [-Werror=maybe-uninitialized]
../../../src.patched/utility/fc_utf8.c:132:15: note: 'end' was declared here

Before line 150 fc_utf8_validate_len(...,&end) always gets called and is supposed to set "end". But it has one way of returning without touching "end":
fc_assert_ret_val(NULL != utf8_string, FALSE);

NULL is not valid input for fc_utf8_validate_rep_len() (it would crash on strlen()), but compiler does not know that and sees that NULL parameter to fc_utf8_validate_rep_len() would be passed to fc_utf8_validate_len() causing fc_assert_ret_val() there to return without touching "end" which is then used regardless.

Attached patch simply asserts against NULL in fc_utf8_validate_rep_len() too, so compiler knows it will never be used deeper in the function.

Marko Lindqvist <cazfi>
Project AdministratorIn charge of this item.

 

(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #16972:  NullUtf8StrlcpyFix.patch added by cazfi (407B - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by cazfi (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Error: not logged in

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Jan 21 09:26:47 2013cazfiStatusReady For Test=>Fixed
      Assigned toNone=>cazfi
      Open/ClosedOpen=>Closed
    Sat Jan 19 09:27:39 2013cazfiAttached File-=>Added NullUtf8StrlcpyFix.patch, #16972
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup