1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-15 01:34:03 +00:00

Do not leak trimmed string when expanding, found by ossfuzz.

This commit is contained in:
nicm
2026-04-02 09:35:46 +00:00
parent 3c769161d8
commit 4245707926
2 changed files with 5 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: format-draw.c,v 1.30 2025/12/04 20:49:57 nicm Exp $ */
/* $OpenBSD: format-draw.c,v 1.31 2026/04/02 09:35:46 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1116,7 +1116,7 @@ format_width(const char *expanded)
/*
* Trim on the left, taking #[] into account. Note, we copy the whole set of
* unescaped #s, but only add their escaped size to width. This is because the
* format_draw function will actually do the escaping when it runs
* format_draw function will actually do the escaping.
*/
char *
format_trim_left(const char *expanded, u_int limit)

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: format.c,v 1.351 2026/04/02 09:28:22 nicm Exp $ */
/* $OpenBSD: format.c,v 1.352 2026/04/02 09:35:46 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -5325,6 +5325,7 @@ done:
if (marker != NULL && strcmp(new, value) != 0) {
free(value);
xasprintf(&value, "%s%s", new, marker);
free(new);
} else {
free(value);
value = new;
@@ -5335,6 +5336,7 @@ done:
if (marker != NULL && strcmp(new, value) != 0) {
free(value);
xasprintf(&value, "%s%s", marker, new);
free(new);
} else {
free(value);
value = new;