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>
René Scharfe committed
Dec 18, 2021 at 10:47 UTC
999bba3e0bbb2e81a3e1b2bdb5846479d1e663ad
1 file changed
+1
-1
daemon.c
+1
-1
@@ -232,13 +232,13 @@ static const char *path_ok(const char *directory, struct hostinfo *hi)
232
233
rlen = strlcpy(interp_path, expanded_path.buf,
234
sizeof(interp_path));
235
+ strbuf_release(&expanded_path);
236
if (rlen >= sizeof(interp_path)) {
237
logerror("interpolated path too large: %s",
238
interp_path);
239
return NULL;
240
}
241
241
- strbuf_release(&expanded_path);
242
loginfo("Interpolated dir '%s'", interp_path);
243
244
dir = interp_path;