[Freeciv-Dev] (PR#40415) [Patch] Fix incorrect use of strlen in strncmp

2008-08-06 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40415 

Commited to S2_2 (r15097) and trunk (r15098).


---
もう疲れた。寝る。
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40415) [Patch] Fix incorrect use of strlen in strncmp

2008-08-03 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40415 

 [EMAIL PROTECTED] - Sun Aug 03 21:13:54 2008]:
 
 Good catch.  But why need strncmp at all?  The string is always
 null-terminated, is it not?  Then strcmp will work just fine.

True, it is very unlikely that both pcity-name and
packet-name would have no terminating nulls, and even
if both did not, then at worst it would result in
strcmp reading past the end of the memory for those
struct fields, possibly past the end of the memory for
'pcity' or 'packet' if there are no null bytes before
the end (incredibly unlikely). So while the danger is
rather minor, using strncmp at least does not assume
that programmers will always remember to null-terminate
those strings (or that this condition could not arise
by some other freak of nature).


---
弁護士なら、なんとか証拠を見つけますよ。

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev