upstream: fix memory leak in process_read() path; Spotted by James

Robinson in GHPR363; ok markus@

OpenBSD-Commit-ID: cdc2d98e6478b7e7f3a36976845adae3820429d8
This commit is contained in:
djm@openbsd.org 2023-03-07 05:37:26 +00:00 committed by Damien Miller
parent c5e6e89083
commit 3f9231c2e1
No known key found for this signature in database

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sftp-server.c,v 1.145 2022/11/09 09:04:12 dtucker Exp $ */ /* $OpenBSD: sftp-server.c,v 1.146 2023/03/07 05:37:26 djm Exp $ */
/* /*
* Copyright (c) 2000-2004 Markus Friedl. All rights reserved. * Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
* *
@ -819,7 +819,7 @@ process_read(u_int32_t id)
} }
if (len > buflen) { if (len > buflen) {
debug3_f("allocate %zu => %u", buflen, len); debug3_f("allocate %zu => %u", buflen, len);
if ((buf = realloc(NULL, len)) == NULL) if ((buf = realloc(buf, len)) == NULL)
fatal_f("realloc failed"); fatal_f("realloc failed");
buflen = len; buflen = len;
} }