Fix comparison of integers of different signs
authorAngelo G. Del Regno <kholk11@gmail.com>
Sun, 4 Jun 2017 09:02:07 +0000 (11:02 +0200)
committerNikolaus Rath <Nikolaus@rath.org>
Mon, 5 Jun 2017 15:25:14 +0000 (11:25 -0400)
Some variables of different size and sign were getting compared
without any safe casting.
The build system also throws warnings at this and, being this
library used for filesystems, it's really important to ensure
stability.

lib/fuse.c
lib/fuse_lowlevel.c

index 2ab5b552e4c14e4e8b404cb69d574b2dce2ef76c..d7a7c82b5fbd803d802b1fc70a0e391857ce281f 100644 (file)
@@ -1719,7 +1719,7 @@ int fuse_fs_read_buf(struct fuse_fs *fs, const char *path,
                                (unsigned long long) fi->fh,
                                fuse_buf_size(*bufp),
                                (unsigned long long) off);
-               if (res >= 0 && fuse_buf_size(*bufp) > (int) size)
+               if (res >= 0 && fuse_buf_size(*bufp) > size)
                        fprintf(stderr, "fuse: read too many bytes\n");
 
                if (res < 0)
index 1ece58c9436992d551006c3f48fba514f7e4183c..c3724a639b995e9e92ae4669b3b0726f7c65130b 100644 (file)
@@ -2399,12 +2399,12 @@ static const char *opname(enum fuse_opcode opcode)
 static int fuse_ll_copy_from_pipe(struct fuse_bufvec *dst,
                                  struct fuse_bufvec *src)
 {
-       int res = fuse_buf_copy(dst, src, 0);
+       ssize_t res = fuse_buf_copy(dst, src, 0);
        if (res < 0) {
                fprintf(stderr, "fuse: copy from pipe: %s\n", strerror(-res));
                return res;
        }
-       if (res < fuse_buf_size(dst)) {
+       if ((size_t)res < fuse_buf_size(dst)) {
                fprintf(stderr, "fuse: copy from pipe: short read\n");
                return -1;
        }
@@ -2940,7 +2940,7 @@ retry:
                goto out_free;
        }
 
-       if (ret == bufsize) {
+       if ((size_t)ret == bufsize) {
                free(buf);
                bufsize *= 4;
                goto retry;