Skip to content

Commit 999bba3

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e9d7761 commit 999bba3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

daemon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,13 @@ static const char *path_ok(const char *directory, struct hostinfo *hi)
232232

233233
rlen = strlcpy(interp_path, expanded_path.buf,
234234
sizeof(interp_path));
235+
strbuf_release(&expanded_path);
235236
if (rlen >= sizeof(interp_path)) {
236237
logerror("interpolated path too large: %s",
237238
interp_path);
238239
return NULL;
239240
}
240241

241-
strbuf_release(&expanded_path);
242242
loginfo("Interpolated dir '%s'", interp_path);
243243

244244
dir = interp_path;

0 commit comments

Comments
 (0)