daemon: plug memory leak on overlong path
Release the strbuf containing the interpolated path after copying it to a stack buffer and before erroring out if it's too long. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e9d7761bb9
commit
999bba3e0b
2
daemon.c
2
daemon.c
@ -232,13 +232,13 @@ static const char *path_ok(const char *directory, struct hostinfo *hi)
|
|||||||
|
|
||||||
rlen = strlcpy(interp_path, expanded_path.buf,
|
rlen = strlcpy(interp_path, expanded_path.buf,
|
||||||
sizeof(interp_path));
|
sizeof(interp_path));
|
||||||
|
strbuf_release(&expanded_path);
|
||||||
if (rlen >= sizeof(interp_path)) {
|
if (rlen >= sizeof(interp_path)) {
|
||||||
logerror("interpolated path too large: %s",
|
logerror("interpolated path too large: %s",
|
||||||
interp_path);
|
interp_path);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf_release(&expanded_path);
|
|
||||||
loginfo("Interpolated dir '%s'", interp_path);
|
loginfo("Interpolated dir '%s'", interp_path);
|
||||||
|
|
||||||
dir = interp_path;
|
dir = interp_path;
|
||||||
|
Loading…
Reference in New Issue
Block a user