Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valgrind: unicode_utf8_trim #608

Closed
ennorehling opened this issue Nov 20, 2016 · 7 comments
Closed

valgrind: unicode_utf8_trim #608

ennorehling opened this issue Nov 20, 2016 · 7 comments
Assignees
Labels
Milestone

Comments

@ennorehling
Copy link
Member

Conditional jump or move depends on uninitialised value(s)
at 0x4F5D5A: unicode_utf8_trim (unicode.c:39)
by 0x4DA8BF: read_ship (save.c:1589)
by 0x4DAE75: read_game (save.c:1707)
by 0x4DA255: readgame (save.c:1500)
by 0x423CDF: eressea_read_game (bind_eressea.c:22)
by 0x4208E4: tolua_eressea_eressea_read_game00 (eressea.pkg.c:70)
by 0x4E3C471: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.2.so.0.0.0)
by 0x4E479B6: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.2.so.0.0.0)
by 0x4E3C6B8: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.2.so.0.0.0)
by 0x4E38860: lua_callk (in /usr/lib/x86_64-linux-gnu/liblua5.2.so.0.0.0)
by 0x4E4B9B7: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.2.so.0.0.0)
by 0x4E3C471: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.2.so.0.0.0)

@ennorehling ennorehling added this to the version-3-10 milestone Nov 20, 2016
@ennorehling ennorehling self-assigned this Nov 20, 2016
@ennorehling
Copy link
Member Author

Das Schiff hat einen Fehler im Namen, da sind zwei aufeinander folgende bytes -61 und 0, was mal ein ü war, aber der Name wurde wohl irgendwie zerstört? Jedenfalls liest der Code jetzt über die terminierende 0 weg, weil das Byte davor das UTF8 Fortsetzungsbit gesetzt hat. Das ist z.B. so bei Schiff Nummer 3476(dec), in Datenfile 961.

@ennorehling
Copy link
Member Author

ennorehling commented Nov 20, 2016

I suspect that unicode_utf8_to_ucs4 does not handle zero bytes correctly. Or any badly formed UTF8, for that matter.

@ennorehling
Copy link
Member Author

Der String im Datenfile ist 127 Zeichen lang: "Das stolze Drachenschiff wurde Ragna von ihrer Mutter geschenkt. Seitdem kreuzt es über die Meere und hat bisher jeden Sturm "

@ennorehling
Copy link
Member Author

Das klingt beinahe, als wäre der von einem Tool (falsch) beschnitten worden.

@ennorehling
Copy link
Member Author

Oh, spannend. Das scheint ganz anders zu sein. Das zero-byte gehört da wohl nicht hin. Im alten Code, der die Bytefolge einfach behalten hat, kommt folgendes im CR raus:

00000000  22 44 61 73 20 73 74 6f  6c 7a 65 20 44 72 61 63  |"Das stolze Drac|
00000010  68 65 6e 73 63 68 69 66  66 20 77 75 72 64 65 20  |henschiff wurde |
00000020  52 61 67 6e 61 20 76 6f  6e 20 69 68 72 65 72 20  |Ragna von ihrer |
00000030  4d 75 74 74 65 72 20 67  65 73 63 68 65 6e 6b 74  |Mutter geschenkt|
00000040  2e 20 53 65 69 74 64 65  6d 20 6b 72 65 75 7a 74  |. Seitdem kreuzt|
00000050  20 65 73 20 c3 bc 62 65  72 20 64 69 65 20 4d 65  | es ..ber die Me|
00000060  65 72 65 20 75 6e 64 20  68 61 74 20 62 69 73 68  |ere und hat bish|
00000070  65 72 20 6a 65 64 65 6e  20 53 74 75 72 6d 20 c3  |er jeden Sturm .|
00000080  22 3b 42 65 73 63 68 72  0a                       |";Beschr.|

Die beiden kaputten Bytes hier sind also c3 bc.

@ennorehling
Copy link
Member Author

Gehört der Partei "The Cult of the Sahuagin"

@ennorehling
Copy link
Member Author

Das Byte C3 am Ende des Strings ist falsch. Danach müsste eigentlich noch ein weiteres Byte kommen. Tut es aber nicht, und unicode_utf8_to_ucs4 liest statt dessen den nul-Terminator, den bin_r_str_buf ans Ende gesetzt hat, obwohl der String eigentlich zu Ende ist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant