svn commit: samba r23972 - in branches: SAMBA_3_2/source/lib/tdb/common SAMBA_3_2_0/source/lib/tdb/common SAMBA_4_0/source/lib/tdb/common

obnox at samba.org obnox at samba.org
Thu Jul 19 13:46:29 GMT 2007


Author: obnox
Date: 2007-07-19 13:46:26 +0000 (Thu, 19 Jul 2007)
New Revision: 23972

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23972

Log:
Fix a bug in pwrite error detection in tdb_expand_file():
The proper error condition is (ret == -1) instead of
(ret != number_of_byte_told_to_write).

Michael


Modified:
   branches/SAMBA_3_2/source/lib/tdb/common/io.c
   branches/SAMBA_3_2_0/source/lib/tdb/common/io.c
   branches/SAMBA_4_0/source/lib/tdb/common/io.c


Changeset:
Modified: branches/SAMBA_3_2/source/lib/tdb/common/io.c
===================================================================
--- branches/SAMBA_3_2/source/lib/tdb/common/io.c	2007-07-19 13:37:49 UTC (rev 23971)
+++ branches/SAMBA_3_2/source/lib/tdb/common/io.c	2007-07-19 13:46:26 UTC (rev 23972)
@@ -234,13 +234,13 @@
 	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;
 }

Modified: branches/SAMBA_3_2_0/source/lib/tdb/common/io.c
===================================================================
--- branches/SAMBA_3_2_0/source/lib/tdb/common/io.c	2007-07-19 13:37:49 UTC (rev 23971)
+++ branches/SAMBA_3_2_0/source/lib/tdb/common/io.c	2007-07-19 13:46:26 UTC (rev 23972)
@@ -234,13 +234,13 @@
 	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;
 }

Modified: branches/SAMBA_4_0/source/lib/tdb/common/io.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/io.c	2007-07-19 13:37:49 UTC (rev 23971)
+++ branches/SAMBA_4_0/source/lib/tdb/common/io.c	2007-07-19 13:46:26 UTC (rev 23972)
@@ -234,13 +234,13 @@
 	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;
 }



More information about the samba-cvs mailing list