basic: util - fix errorhandling in unhexmem()
authorTom Gundersen <teg@jklm.no>
Sat, 11 Jul 2015 17:14:52 +0000 (19:14 +0200)
committerTom Gundersen <teg@jklm.no>
Sun, 12 Jul 2015 17:11:34 +0000 (19:11 +0200)
commit30494563f235b21c6583f7476b8ee35e9f5f8048
treee4f934efd5005b004d7b2768776b5aab244e8734
parent39fced01623e148d847010c6ee7fcfc552234018
basic: util - fix errorhandling in unhexmem()

We were ignoring failures from unhexchar, which meant that invalid
hex characters were being turned into garbage rather than the string
rejected.

Fix this by making unhexmem return an error code, also change the API
slightly, to return the size of the returned memory, reflecting the
fact that the memory is a binary blob,and not a string.

For convenience, still append a trailing NULL byte to the returned
memory (not included in the returned size), allowing callers to
treat it as a string without doing a second copy.
src/basic/util.c
src/basic/util.h
src/libsystemd-network/sd-dhcp-lease.c
src/libsystemd/sd-bus/bus-socket.c
src/test/test-util.c