[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#589328: Short write in nstx_tuntap.c



Package: nstx 
Version: 1.1-beta6-6
Severity: normal
Tags: patch
Justification: Policy 9.3.2
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu maverick ubuntu-patch

Hello, 

In ubuntu we applied the attached patch and we think you're interested
to apply it too. The purpose of this patch is to fix ignoring the return
value of a possible short write in nstx_tuntap.c. Thanks. 

## fix-return-values.dpatch by  <sistpoty@ubuntu.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

--- nstx-1.1-beta6~/nstx_tuntap.c	2009-10-10 13:57:50.000000000 +0200
+++ nstx-1.1-beta6/nstx_tuntap.c	2009-10-10 13:58:17.000000000 +0200
@@ -266,7 +266,21 @@
 sendtun(const char *data, size_t len)
 {
 //   printf("Sent len %d, csum %d\n", len, checksum(data, len));
-   write(tfd, data, len);
+
+	size_t count;
+	ssize_t ret;
+
+	for (count = 0; count < len; count += ret) {
+		ret = write(tfd, data + count, len - count);
+
+		if (ret < 0) {
+			if (errno == EINTR) {
+				ret = 0;
+				continue;
+			}
+			return;
+		}
+	}
 }
 
 void

Reply to: