diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-04-21 06:39:50 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-04-21 06:39:50 +0100 |
| commit | e097eb5483b00631ef49353a22a73c2c48939d95 (patch) | |
| tree | b0446d36f711dd1b439f67571b38b13e17663f01 /util/libreboot-utils/lib/string.c | |
| parent | 7faf014a84e89f442f1ce35f5d0305074e77b85d (diff) | |
lbutils: don't use stack memory for path strings
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils/lib/string.c')
| -rw-r--r-- | util/libreboot-utils/lib/string.c | 21 |
1 files changed, 21 insertions, 0 deletions
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, |
