URL:
<http://gna.org/bugs/?20443>
Summary: fc_utf8_validate_rep_len(): "end" might be used
uninitialized
Project: Freeciv
Submitted by: cazfi
Submitted on: Sat 19 Jan 2013 11:27:39 AM EET
Category: general
Severity: 3 - Normal
Priority: 5 - Normal
Status: Ready For Test
Assigned to: None
Originator Email:
Open/Closed: Open
Release:
Discussion Lock: Any
Operating System: None
Planned Release: 2.3.4, 2.4.0, 2.5.0
_______________________________________________________
Details:
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.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Sat 19 Jan 2013 11:27:39 AM EET Name: NullUtf8StrlcpyFix.patch Size:
407B By: cazfi
<http://gna.org/bugs/download.php?file_id=16972>
_______________________________________________________
Reply to this item at:
<http://gna.org/bugs/?20443>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev