Skip to content
Snippets Groups Projects
Commit fed928ad authored by Colin Walters's avatar Colin Walters
Browse files

Merge branch 'wip/smcv/issue5' into 'master'

fdio: Avoid relying on VLAs or gcc-specific constant folding

Closes #5

See merge request GNOME/libglnx!63
parents 5544bfdd cd4b7b53
No related branches found
No related tags found
1 merge request!777Update libglnx to 2025-01-06
...@@ -321,6 +321,8 @@ glnx_open_anonymous_tmpfile (int flags, ...@@ -321,6 +321,8 @@ glnx_open_anonymous_tmpfile (int flags,
error); error);
} }
static const char proc_self_fd_slash[] = "/proc/self/fd/";
/* Use this after calling glnx_open_tmpfile_linkable_at() to give /* Use this after calling glnx_open_tmpfile_linkable_at() to give
* the file its final name (link into place). * the file its final name (link into place).
*/ */
...@@ -367,8 +369,8 @@ glnx_link_tmpfile_at (GLnxTmpfile *tmpf, ...@@ -367,8 +369,8 @@ glnx_link_tmpfile_at (GLnxTmpfile *tmpf,
else else
{ {
/* This case we have O_TMPFILE, so our reference to it is via /proc/self/fd */ /* This case we have O_TMPFILE, so our reference to it is via /proc/self/fd */
char proc_fd_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(tmpf->fd) + 1]; char proc_fd_path[sizeof (proc_self_fd_slash) + DECIMAL_STR_MAX(tmpf->fd)];
snprintf (proc_fd_path, sizeof (proc_fd_path), "/proc/self/fd/%i", tmpf->fd); snprintf (proc_fd_path, sizeof (proc_fd_path), "%s%i", proc_self_fd_slash, tmpf->fd);
if (replace) if (replace)
{ {
...@@ -455,8 +457,8 @@ glnx_tmpfile_reopen_rdonly (GLnxTmpfile *tmpf, ...@@ -455,8 +457,8 @@ glnx_tmpfile_reopen_rdonly (GLnxTmpfile *tmpf,
else else
{ {
/* This case we have O_TMPFILE, so our reference to it is via /proc/self/fd */ /* This case we have O_TMPFILE, so our reference to it is via /proc/self/fd */
char proc_fd_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(tmpf->fd) + 1]; char proc_fd_path[sizeof (proc_self_fd_slash) + DECIMAL_STR_MAX(tmpf->fd)];
snprintf (proc_fd_path, sizeof (proc_fd_path), "/proc/self/fd/%i", tmpf->fd); snprintf (proc_fd_path, sizeof (proc_fd_path), "%s%i", proc_self_fd_slash, tmpf->fd);
if (!glnx_openat_rdonly (AT_FDCWD, proc_fd_path, TRUE, &rdonly_fd, error)) if (!glnx_openat_rdonly (AT_FDCWD, proc_fd_path, TRUE, &rdonly_fd, error))
return FALSE; return FALSE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment