From: Sage Weil Date: Sat, 5 May 2012 17:01:44 +0000 (-0700) Subject: safe_io: int -> ssize_t X-Git-Tag: v0.47~38 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3509b039a28d41c7ae1b3d482d67a27f8e5739e8;p=ceph.git safe_io: int -> ssize_t int is 32-bit on 64-bit archs, but ssize_t is 64-bits. This fixes overflow when reading large (>2GB) extends. Fixes: #2275 Signed-off-by: Sage Weil --- diff --git a/src/common/safe_io.c b/src/common/safe_io.c index 8ad05a3687e..a7be648ebf4 100644 --- a/src/common/safe_io.c +++ b/src/common/safe_io.c @@ -21,7 +21,7 @@ ssize_t safe_read(int fd, void *buf, size_t count) { - int r; + ssize_t r; size_t cnt = 0; while (cnt < count) { @@ -43,7 +43,7 @@ ssize_t safe_read(int fd, void *buf, size_t count) ssize_t safe_read_exact(int fd, void *buf, size_t count) { - int ret = safe_read(fd, buf, count); + ssize_t ret = safe_read(fd, buf, count); if (ret < 0) return ret; if ((size_t)ret != count) @@ -53,7 +53,7 @@ ssize_t safe_read_exact(int fd, void *buf, size_t count) ssize_t safe_write(int fd, const void *buf, size_t count) { - int r; + ssize_t r; while (count > 0) { r = write(fd, buf, count); @@ -70,7 +70,7 @@ ssize_t safe_write(int fd, const void *buf, size_t count) ssize_t safe_pread(int fd, void *buf, size_t count, off_t offset) { - int r; + ssize_t r; size_t cnt = 0; char *b = (char*)buf; @@ -93,7 +93,7 @@ ssize_t safe_pread(int fd, void *buf, size_t count, off_t offset) ssize_t safe_pread_exact(int fd, void *buf, size_t count, off_t offset) { - int ret = safe_pread(fd, buf, count, offset); + ssize_t ret = safe_pread(fd, buf, count, offset); if (ret < 0) return ret; if ((size_t)ret != count) @@ -103,7 +103,7 @@ ssize_t safe_pread_exact(int fd, void *buf, size_t count, off_t offset) ssize_t safe_pwrite(int fd, const void *buf, size_t count, off_t offset) { - int r; + ssize_t r; while (count > 0) { r = pwrite(fd, buf, count, offset);