mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-25 13:29:03 +02:00
lib/mkhtemp: rename suffix to template
suffix is a gnu term, for its mktemp version. it goes after the template. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -79,8 +79,8 @@ new_tmp_common(int *fd, char **path, int type,
|
||||
#endif
|
||||
struct stat st;
|
||||
|
||||
const char *suffix;
|
||||
size_t suffix_len;
|
||||
const char *templatestr;
|
||||
size_t templatestr_len;
|
||||
|
||||
size_t dirlen;
|
||||
size_t destlen;
|
||||
@@ -144,17 +144,17 @@ new_tmp_common(int *fd, char **path, int type,
|
||||
goto err;
|
||||
|
||||
if (template != NULL)
|
||||
suffix = template;
|
||||
templatestr = template;
|
||||
else
|
||||
suffix = "tmp.XXXXXXXXXX";
|
||||
templatestr = "tmp.XXXXXXXXXX";
|
||||
|
||||
if (slen(suffix, maxlen, &suffix_len) < 0)
|
||||
if (slen(templatestr, maxlen, &templatestr_len) < 0)
|
||||
goto err;
|
||||
|
||||
/* sizeof adds an extra byte, useful
|
||||
* because we also want '.' or '/'
|
||||
*/
|
||||
destlen = dirlen + 1 + suffix_len;
|
||||
destlen = dirlen + 1 + templatestr_len;
|
||||
if (destlen > maxlen - 1) {
|
||||
errno = EOVERFLOW;
|
||||
goto err;
|
||||
@@ -168,7 +168,7 @@ new_tmp_common(int *fd, char **path, int type,
|
||||
|
||||
memcpy(dest, tmpdir, dirlen);
|
||||
*(dest + dirlen) = '/';
|
||||
memcpy(dest + dirlen + 1, suffix, suffix_len);
|
||||
memcpy(dest + dirlen + 1, templatestr, templatestr_len);
|
||||
*(dest + destlen) = '\0';
|
||||
|
||||
fname = dest + dirlen + 1;
|
||||
@@ -622,7 +622,7 @@ mkhtemp(int *fd,
|
||||
if((fname_copy = malloc(fname_len + 1)) == NULL)
|
||||
goto err;
|
||||
|
||||
/* fname_copy = suffix region only; p points to trailing XXXXXX */
|
||||
/* fname_copy = templatestr region only; p points to trailing XXXXXX */
|
||||
memcpy(fname_copy,
|
||||
template + len - fname_len,
|
||||
fname_len + 1);
|
||||
|
||||
Reference in New Issue
Block a user