initd: fix off-by-one error in mkdev.c
authorDaniel Golle <daniel@makrotopia.org>
Mon, 30 Aug 2021 21:20:30 +0000 (22:20 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 30 Aug 2021 21:22:16 +0000 (22:22 +0100)
Actually make sure buffer is 0-terminated intead of writing the 0-byte
out of bounds.

Coverity CID: 1330087 Readlink used insecurely
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
initd/mkdev.c

index 44101aa12df5e5a102b626d2eb41f1a10a40e2ad..1c9c97ab8e0560e11fd5c56efc2d09c2244aae9d 100644 (file)
@@ -86,7 +86,7 @@ static void find_devs(bool block)
                if (len <= 0)
                        continue;
 
-               buf[len] = 0;
+               buf[sizeof(buf) - 1] = '\0';
                if (!find_pattern(buf))
                        continue;