]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: an int is not 1 byte
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 12 Dec 2013 19:56:35 +0000 (13:56 -0600)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 12 Dec 2013 19:56:35 +0000 (13:56 -0600)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc_usernsexec.c

index a58b944e48a7f900fe9c68a6888fe63d74b699ec..98e4fa24bac36ddc62c3632c382671e14a588434 100644 (file)
@@ -349,6 +349,7 @@ int main(int argc, char *argv[])
        int ret;
        int pid;
        char *default_args[] = {"/bin/sh", NULL};
+       char buf[1];
        int pipe1[2],  // child tells parent it has unshared
            pipe2[2];  // parent tells child it is mapped and may proceed
 
@@ -398,16 +399,16 @@ int main(int argc, char *argv[])
                        perror("unshare");
                        return 1;
                }
-               ret = 1;
-               if (write(pipe1[1], &ret, 1) < 1) {
+               buf[0] = '1';
+               if (write(pipe1[1], buf, 1) < 1) {
                        perror("write pipe");
                        exit(1);
                }
-               if (read(pipe2[0], &ret, 1) < 1) {
+               if (read(pipe2[0], buf, 1) < 1) {
                        perror("read pipe");
                        exit(1);
                }
-               if (ret != 1) {
+               if (buf[0] != '1') {
                        fprintf(stderr, "parent had an error, child exiting\n");
                        exit(1);
                }
@@ -419,17 +420,17 @@ int main(int argc, char *argv[])
 
        close(pipe1[1]);
        close(pipe2[0]);
-       if (read(pipe1[0], &ret, 1) < 1) {
+       if (read(pipe1[0], buf, 1) < 1) {
                perror("read pipe");
                exit(1);
        }
 
-       ret = 1;
+       buf[0] = 1;
        if (map_child_uids(pid, active_map)) {
                fprintf(stderr, "error mapping child\n");
                ret = 0;
        }
-       if (write(pipe2[1], &ret, 1) < 0) {
+       if (write(pipe2[1], buf, 1) < 0) {
                perror("write to pipe");
                exit(1);
        }