Avoid implicit conversions

Found by running under pedantic UBSAN:

    ../bubblewrap.c:968:21: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'uid_t' (aka 'unsigned int') changed the value to 4294967295 (32-bit, unsigned)
    ../bubblewrap.c:1210:28: runtime error: implicit conversion from type 'int' of value -41 (32-bit, signed) to type 'unsigned int' changed the value to 4294967255 (32-bit, unsigned)
    ../bubblewrap.c:1215:28: runtime error: implicit conversion from type 'int' of value -41 (32-bit, signed) to type 'unsigned int' changed the value to 4294967255 (32-bit, unsigned)

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
Christian Göttsche
2023-02-28 21:22:46 +01:00
parent 2ae2ec3542
commit 15ef38c4e3

View File

@@ -965,7 +965,7 @@ write_uid_gid_map (uid_t sandbox_uid,
cleanup_free char *gid_map = NULL;
cleanup_free char *dir = NULL;
cleanup_fd int dir_fd = -1;
uid_t old_fsuid = -1;
uid_t old_fsuid = (uid_t)-1;
if (pid == -1)
dir = xstrdup ("self");
@@ -1207,12 +1207,12 @@ setup_newroot (bool unshare_pid,
* inaccessible by that group. */
if (op->perms >= 0 &&
(op->perms & 0070) == 0)
parent_mode &= ~0050;
parent_mode &= ~0050U;
/* The same, but for users other than the owner and group. */
if (op->perms >= 0 &&
(op->perms & 0007) == 0)
parent_mode &= ~0005;
parent_mode &= ~0005U;
dest = get_newroot_path (op->dest);
if (mkdir_with_parents (dest, parent_mode, FALSE) != 0)