r23972: Fix a bug in pwrite error detection in tdb_expand_file():
authorMichael Adam <obnox@samba.org>
Thu, 19 Jul 2007 13:46:26 +0000 (13:46 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:28:50 +0000 (12:28 -0500)
The proper error condition is (ret == -1) instead of
(ret != number_of_byte_told_to_write).

Michael
(This used to be commit e3af95f0983e9f92c10a80ee4f15a0cd718a4728)

source3/lib/tdb/common/io.c

index cc66b85b3384d3620f3523e201e9d0b6818a44ac..ea925f38953c7a1cc2b55580b4b96b6416818831 100644 (file)
@@ -234,13 +234,13 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
        while (addition) {
                int n = addition>sizeof(buf)?sizeof(buf):addition;
                int ret = pwrite(tdb->fd, buf, n, size);
-               if (ret != n) {
+               if (ret == -1) {
                        TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write of %d failed (%s)\n", 
                                   n, strerror(errno)));
                        return -1;
                }
-               addition -= n;
-               size += n;
+               addition -= ret;
+               size += ret;
        }
        return 0;
 }