[systemd-devel] [PATCH] shared: fix utf16_to_utf8() on big endian machines

Martin Pitt martin.pitt at ubuntu.com
Tue Feb 17 21:54:46 PST 2015


Hello all,

219 shows a test failure in test-utf8 on big-endian machines (on
Debian: powerpc, s390, mips):

Assertion 'streq(a, utf8)' failed at src/test/test-utf8.c:103, function test_utf16_to_utf8(). Aborting.

gdb shows that indeed the converted string is utter bogus. a is the
converted string, utf8 the expected outcome:

| Program received signal SIGABRT, Aborted.
| 0x20319c48 in raise () from /lib/powerpc-linux-gnu/libc.so.6
| (gdb) f 3
| #3  0x204befbc in test_utf16_to_utf8 () at src/test/test-utf8.c:103
| 103             assert_se(streq(a, utf8));
| (gdb) p a
| $1 = 0x204eb068 "\346\204\200\303\230\346\210\200\303\234\346\214\200\307\230\343\237\234"
| (gdb) p utf8
| $2 = "abc\360\220\220\267"

Patch against master attached, tested on both little-endian (unchanged
behaviour/code) and big-endian machine.

CC'ing Tom for reviewing, as that was introduced in
http://cgit.freedesktop.org/systemd/systemd/commit/?id=04166cb7d and
he might still have the UTF-16 stuff in his head :-)

Thanks,

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-shared-fix-utf16_to_utf8-on-big-endian-machines.patch
Type: text/x-diff
Size: 1364 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150218/a693f994/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150218/a693f994/attachment.sig>


More information about the systemd-devel mailing list