diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-13 16:18:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-13 16:18:43 +0200 |
commit | f0d7ac9e81aeb2715ce7a48ec3c4e5fd10c98526 (patch) | |
tree | 8a877857852220fd983397e8459fca197d38f3b7 | |
parent | 1593d4c052fc0795e6fe31917edcb1ecbe5ee192 (diff) | |
parent | c33371fadbcd933318c34963e9e161209c492da6 (diff) | |
download | podman-f0d7ac9e81aeb2715ce7a48ec3c4e5fd10c98526.tar.gz podman-f0d7ac9e81aeb2715ce7a48ec3c4e5fd10c98526.tar.bz2 podman-f0d7ac9e81aeb2715ce7a48ec3c4e5fd10c98526.zip |
Merge pull request #5797 from giuseppe/use-snprintf
rootless: use snprintf
-rw-r--r-- | pkg/rootless/rootless_linux.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/rootless/rootless_linux.c b/pkg/rootless/rootless_linux.c index 6643bfbbf..da52a7217 100644 --- a/pkg/rootless/rootless_linux.c +++ b/pkg/rootless/rootless_linux.c @@ -288,6 +288,7 @@ static void __attribute__((constructor)) init() char *cwd = getcwd (NULL, 0); char uid_fmt[16]; char gid_fmt[16]; + size_t len; if (cwd == NULL) { @@ -295,13 +296,13 @@ static void __attribute__((constructor)) init() _exit (EXIT_FAILURE); } - if (strlen (xdg_runtime_dir) >= PATH_MAX - strlen (suffix)) + len = snprintf (path, PATH_MAX, "%s%s", xdg_runtime_dir, suffix); + if (len >= PATH_MAX) { fprintf (stderr, "invalid value for XDG_RUNTIME_DIR: %s", strerror (ENAMETOOLONG)); exit (EXIT_FAILURE); } - sprintf (path, "%s%s", xdg_runtime_dir, suffix); fd = open (path, O_RDONLY); if (fd < 0) { |