tree-wide: use memmem_safe()
Let's be paranoid and do something useful if we operate with empty haystack/needle. This doesn't actually fix anything, as the places as far as I can see check for non-emptyness already beforehand, but I will sleep safer at night, if we don't even allow the trap to be fallen in, ever, even if the code is changed sooner or later.
This commit is contained in:
+1
-1
@@ -163,7 +163,7 @@ static int get_file_version(int fd, char **v) {
|
||||
if (!s)
|
||||
goto finish;
|
||||
|
||||
e = memmem(s, st.st_size - (s - buf), " ####", 5);
|
||||
e = memmem_safe(s, st.st_size - (s - buf), " ####", 5);
|
||||
if (!e || e - s < 3) {
|
||||
r = log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Malformed version string.");
|
||||
goto finish;
|
||||
|
||||
Reference in New Issue
Block a user