From: Zbigniew Jędrzejewski-Szmek Date: Wed, 3 Apr 2013 20:58:16 +0000 (-0400) Subject: sd-id128: check that the kernel is feeding us proper data X-Git-Tag: v201~54 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=54c7d1f454801d3053b99c16b2a371934deb0219 sd-id128: check that the kernel is feeding us proper data The characters are already checked, so we show that we don't trust the kernel. Make sure we don't overrun the buffer too. --- diff --git a/src/libsystemd-id128/sd-id128.c b/src/libsystemd-id128/sd-id128.c index 4286ae7d1..68c498714 100644 --- a/src/libsystemd-id128/sd-id128.c +++ b/src/libsystemd-id128/sd-id128.c @@ -170,6 +170,9 @@ _public_ int sd_id128_get_boot(sd_id128_t *ret) { for (j = 0, p = buf; j < 16; j++) { int a, b; + if (p >= buf + k) + return -EIO; + if (*p == '-') p++;