Commit Graph

8 Commits

Author SHA1 Message Date
Christian Göttsche
88004f880a Drop unnecessary cast to same type
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2023-02-28 21:53:48 +01:00
Christian Göttsche
2ae2ec3542 Enable and resolve sign comparisson warnings
Comparisson of different signedness can result in unexpected results due
to implicit conversions.

    ../network.c:81:34: warning: comparison of integer expressions of different signedness: ‘__u32’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]
       81 |           if (rheader->nlmsg_seq != seq_nr)
          |                                  ^~
    ../network.c:83:34: warning: comparison of integer expressions of different signedness: ‘__u32’ {aka ‘unsigned int’} and ‘__pid_t’ {aka ‘int’} [-Wsign-compare]
      83 |           if (rheader->nlmsg_pid != getpid ())
          |                                  ^~

    ../bind-mount.c:268:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
      268 |       assert (i < n_lines);
          |                 ^
    ../bind-mount.c:309:13: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
      309 |   assert (i == n_lines);
          |             ^~
    ../bind-mount.c:318:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
      318 |   for (i = 0; i < n_lines; i++)
          |                 ^
    ../bind-mount.c:321:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
      321 |   for (i = 0; i < n_lines; i++)
          |                 ^

    ../utils.c:818:19: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘ssize_t’ {aka ‘long int’} [-Wsign-compare]
      818 |   while (size - 2 < n);
          |                   ^

    ../bubblewrap.c:489:13: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
      489 |   assert (j < sizeof(dont_close)/sizeof(*dont_close));
          |             ^
    ../bubblewrap.c:994:25: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uid_t’ {aka ‘unsigned int’} [-Wsign-compare]
      994 |       if (setfsuid (-1) != real_uid)
          |                         ^~
    ../bubblewrap.c:1042:61: warning: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
     1042 |       if (write (privileged_op_socket, buffer, buffer_size) != buffer_size)
          |                                                             ^~
    ../bubblewrap.c:1232:25: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
     1232 |           for (i = 0; i < N_ELEMENTS (cover_proc_dirs); i++)
          |                         ^
    ../bubblewrap.c:1260:25: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
     1260 |           for (i = 0; i < N_ELEMENTS (devnodes); i++)
          |                         ^
    ../bubblewrap.c:1272:25: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
     1272 |           for (i = 0; i < N_ELEMENTS (stdionodes); i++)
          |                         ^
    ../bubblewrap.c: In function ‘read_priv_sec_op’:
    ../bubblewrap.c:1556:15: warning: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘long int’} and ‘long unsigned int’ [-Wsign-compare]
     1556 |   if (rec_len < sizeof (PrivSepOp))
          |               ^
    ../bubblewrap.c:1626:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
     1626 |   if (*total_parsed_argc_p > MAX_ARGS)
          |                            ^
    ../bubblewrap.c:1681:40: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
     1681 |               if (*total_parsed_argc_p > MAX_ARGS)
          |                                        ^
    ../bubblewrap.c:2265:31: warning: comparison of integer expressions of different signedness: ‘uid_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]
     2265 |           if (opt_sandbox_uid != -1)
          |                               ^~
    ../bubblewrap.c:2285:31: warning: comparison of integer expressions of different signedness: ‘gid_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]
     2285 |           if (opt_sandbox_gid != -1)
          |                               ^~
    ../bubblewrap.c:2678:23: warning: comparison of integer expressions of different signedness: ‘uid_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]
     2678 |   if (opt_sandbox_uid == -1)
          |                       ^~
    ../bubblewrap.c:2680:23: warning: comparison of integer expressions of different signedness: ‘gid_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]
     2680 |   if (opt_sandbox_gid == -1)
          |                       ^~

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2023-02-28 21:53:19 +01:00
Simon McVittie
a6c90c516b Add SPDX-License-Identifier for files that already specify license
This is a step towards REUSE compliance. Third-party files that we do
not otherwise edit (git.mk, m4/attributes.m4) are excluded here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-31 12:32:40 +01:00
Colin Walters
e605e2d255 Be more informative if loopback setup fails
We're seeing loopback setup fail in Fedora infrastructure for rpm-ostree
composes: https://pagure.io/releng/issue/6602

This should help debug.  Tested with strace fault injection:

```
$ strace -o strace.log -f -e fault=bind:error=EPERM bwrap --unshare-net --bind / / true
loopback: Failed to bind NETLINK_ROUTE socket: Operation not permitted
$
```

Closes: #166
Approved by: alexlarsson
2017-01-26 08:42:36 +00:00
Alexander Larsson
d69ab9202b Ran uncruftify.sh
Closes: #67
Approved by: cgwalters
2016-05-13 12:21:08 +00:00
Alexander Larsson
8613206fba Fix (and standardize) error checks in network setup
Now we always return -1 on error, and 0 on OK.
Also, fixes the incorrect check in rtnl_do_request().
2016-03-02 12:51:28 +01:00
Alexander Larsson
92712d8cd5 Rename to bubblewrap 2016-02-17 11:54:21 +01:00
Alexander Larsson
5556d20fd5 Split out network functions to separate file 2016-02-16 09:41:01 +01:00