From e097eb5483b00631ef49353a22a73c2c48939d95 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 21 Apr 2026 06:39:50 +0100 Subject: lbutils: don't use stack memory for path strings Signed-off-by: Leah Rowe --- util/libreboot-utils/lib/string.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'util/libreboot-utils/lib/string.c') diff --git a/util/libreboot-utils/lib/string.c b/util/libreboot-utils/lib/string.c index 99864b82..7388cf35 100644 --- a/util/libreboot-utils/lib/string.c +++ b/util/libreboot-utils/lib/string.c @@ -270,6 +270,27 @@ out: return *rval; } +int +dup_pair(char **dir, const char *d, + char **base, const char *b) +{ + char *dtmp = NULL; + char *btmp = NULL; + + if (d && sdup(d, PATH_MAX, &dtmp) == NULL) + return -1; + + if (b && sdup(b, PATH_MAX, &btmp) == NULL) { + free(dtmp); + return -1; + } + + *dir = dtmp; + *base = btmp; + + return 0; +} + /* strict word-based strdup */ char * sdup(const char *s, -- cgit v1.2.1