git: 03d8ac948b1a - main - heimdal: Pass the correct pointer to realloc when growing a string buffer
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 02 Feb 2026 17:18:31 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=03d8ac948b1ad9c419b294c3129b7da58d818363
commit 03d8ac948b1ad9c419b294c3129b7da58d818363
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-02-02 17:18:11 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-02-02 17:18:11 +0000
heimdal: Pass the correct pointer to realloc when growing a string buffer
The realloc in my_fgetln was trying to grow the pointer to the string
buffer, not the string buffer itself.
In function 'my_fgetln',
inlined from 'mit_prop_dump' at crypto/heimdal/kdc/mit_dump.c:156:19:
crypto/heimdal/kdc/mit_dump.c:119:13: error: 'realloc' called on unallocated object 'line' [-Werror=free-nonheap-object]
119 | n = realloc(buf, *sz + (*sz >> 1));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
crypto/heimdal/kdc/mit_dump.c: In function 'mit_prop_dump':
crypto/heimdal/kdc/mit_dump.c:139:11: note: declared here
139 | char *line = NULL;
| ^~~~
Reviewed by: rmacklem, cy
Fixes: a93e1b731ae4 ("heimdal-kadmin: Add support for the -f dump option")
Differential Revision: https://reviews.freebsd.org/D54933
---
crypto/heimdal/kdc/mit_dump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crypto/heimdal/kdc/mit_dump.c b/crypto/heimdal/kdc/mit_dump.c
index 4397d1ad897d..d790b145af11 100644
--- a/crypto/heimdal/kdc/mit_dump.c
+++ b/crypto/heimdal/kdc/mit_dump.c
@@ -116,7 +116,7 @@ my_fgetln(FILE *f, char **buf, size_t *sz, size_t *len)
return 0;
}
*len += strlen(&(*buf)[*len]); /* *len should be == *sz */
- n = realloc(buf, *sz + (*sz >> 1));
+ n = realloc(*buf, *sz + (*sz >> 1));
if (!n) {
free(*buf);
*buf = NULL;