diff options
author | Jonathan Lebon <jonathan@jlebon.com> | 2021-10-26 15:14:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-26 15:14:21 -0400 |
commit | b7efd16cc5e1555ca4aca42fa17a6f0565b7c647 (patch) | |
tree | ae5bae0bb54ac82c614b420785f1781dfb94080d | |
parent | 6e0165020a34edd593dbcac695f3e4d709197a5a (diff) | |
parent | ca84da679a170fcb1b2ab59a59ec45e014530996 (diff) | |
download | ostree-b7efd16cc5e1555ca4aca42fa17a6f0565b7c647.tar.gz |
Merge pull request #2472 from lucab/ups/prepare-root-checked-printf
-rw-r--r-- | src/switchroot/ostree-prepare-root.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 46283f3f..aa7d5a4e 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -132,7 +132,8 @@ resolve_deploy_path (const char * root_mountpoint) if (!ostree_target) errx (EXIT_FAILURE, "No OSTree target; expected ostree=/ostree/boot.N/..."); - snprintf (destpath, sizeof(destpath), "%s/%s", root_mountpoint, ostree_target); + if (snprintf (destpath, sizeof(destpath), "%s/%s", root_mountpoint, ostree_target) < 0) + err (EXIT_FAILURE, "failed to assemble ostree target path"); if (lstat (destpath, &stbuf) < 0) err (EXIT_FAILURE, "Couldn't find specified OSTree root '%s'", destpath); if (!S_ISLNK (stbuf.st_mode)) @@ -284,12 +285,14 @@ main(int argc, char *argv[]) char srcpath[PATH_MAX]; /* If /boot is on the same partition, use a bind mount to make it visible * at /boot inside the deployment. */ - snprintf (srcpath, sizeof(srcpath), "%s/boot/loader", root_mountpoint); + if (snprintf (srcpath, sizeof(srcpath), "%s/boot/loader", root_mountpoint) < 0) + err (EXIT_FAILURE, "failed to assemble /boot/loader path"); if (lstat (srcpath, &stbuf) == 0 && S_ISLNK (stbuf.st_mode)) { if (lstat ("boot", &stbuf) == 0 && S_ISDIR (stbuf.st_mode)) { - snprintf (srcpath, sizeof(srcpath), "%s/boot", root_mountpoint); + if (snprintf (srcpath, sizeof(srcpath), "%s/boot", root_mountpoint) < 0) + err (EXIT_FAILURE, "failed to assemble /boot path"); if (mount (srcpath, "boot", NULL, MS_BIND | MS_SILENT, NULL) < 0) err (EXIT_FAILURE, "failed to bind mount %s to boot", srcpath); } |