Browse Source

initd: fix off-by-one error in mkdev.c

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>
Daniel Golle 2 years ago
parent
commit
8eb1d783cc
1 changed files with 1 additions and 1 deletions
  1. 1 1
      initd/mkdev.c

+ 1 - 1
initd/mkdev.c

@@ -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;