You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* Read the result */char*res=malloc(256);
size_tlen=read(pipefd[0], res, 256);
/* Trim the newline */len--;
res[len] =0;
close(pipefd[0]);
if (str_has_prefix(res, "inode/")) {
free(res);
returnNULL;
}
returnres;
If xdg-mime doesn't print anything (len == 0), len-- will cause len to underflow and the next line will try to set res[18446744073709551615] to 0. res will then be returned
pointing to uninitialised memory, resulting in either another buffer
overflow or the mime type being filled with junk (which will prevent
it from being pasted by most programs).
The text was updated successfully, but these errors were encountered:
Indeed, I suppose this could be made more robust, thanks. We should also be reading in a loop rather than once, and checking that the byte we're trimming is indeed a newline.
If xdg-mime doesn't print anything (
len == 0
),len--
will causelen
to underflow and the next line will try to setres[18446744073709551615]
to 0.res
will then be returnedpointing to uninitialised memory, resulting in either another buffer
overflow or the mime type being filled with junk (which will prevent
it from being pasted by most programs).
The text was updated successfully, but these errors were encountered: