diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2023-02-28 21:22:46 +0100 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2023-02-28 21:53:45 +0100 |
commit | 15ef38c4e3af506e7f35b9372cf9f657e9861701 (patch) | |
tree | 88e33af0bdf054640819c96aa81348394cbf642f | |
parent | 2ae2ec35424a84d3f6baaa114f36d9a2a88962bc (diff) | |
download | bubblewrap-15ef38c4e3af506e7f35b9372cf9f657e9861701.tar.gz |
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>
-rw-r--r-- | bubblewrap.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bubblewrap.c b/bubblewrap.c index 97f12af..712b07f 100644 --- a/bubblewrap.c +++ b/bubblewrap.c @@ -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) |