summaryrefslogtreecommitdiff
path: root/util/libreboot-utils/lib/state.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/libreboot-utils/lib/state.c')
-rw-r--r--util/libreboot-utils/lib/state.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/util/libreboot-utils/lib/state.c b/util/libreboot-utils/lib/state.c
index a3cd5b1f..f0be5656 100644
--- a/util/libreboot-utils/lib/state.c
+++ b/util/libreboot-utils/lib/state.c
@@ -22,6 +22,12 @@
struct xstate *
xstart(int argc, char *argv[])
{
+#if defined(PATH_LEN) && \
+ ((PATH_LEN) >= 256)
+ static size_t maxlen = PATH_LEN;
+#else
+ static size_t maxlen = 4096;
+#endif
static int first_run = 1;
static char *dir = NULL;
static char *base = NULL;
@@ -77,9 +83,6 @@ xstart(int argc, char *argv[])
/* .f */
{0},
- /* .argv0 (for our getprogname implementation) */
- NULL,
-
/* ->i (index to cmd[]) */
0,
@@ -103,7 +106,6 @@ xstart(int argc, char *argv[])
us.f.buf = us.f.real_buf;
- us.argv0 = argv[0];
us.f.fname = argv[1];
us.f.tmp_fd = -1;
@@ -117,8 +119,7 @@ xstart(int argc, char *argv[])
err_exit(errno, "xstart: don't know CWD of %s",
us.f.fname);
- if ((us.f.base = strdup(base)) == NULL)
- err_exit(errno, "strdup base");
+ sdup(base, maxlen, &us.f.base);
us.f.dirfd = fs_open(dir,
O_RDONLY | O_DIRECTORY);
@@ -132,9 +133,7 @@ xstart(int argc, char *argv[])
&tmpdir, &tmpbase_local, 0) < 0)
err_exit(errno, "tmp basename");
- us.f.tmpbase = strdup(tmpbase_local);
- if (us.f.tmpbase == NULL)
- err_exit(errno, "strdup tmpbase");
+ sdup(tmpbase_local, maxlen, &us.f.tmpbase);
free_and_set_null(&tmpdir);