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://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54c7d1f454801d3053b99c16b2a371934deb0219;p=thirdparty%2Fsystemd.git 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 4286ae7d146..68c4987149d 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++;