]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
In the Windows version of tun_finalize, on errors that would
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Wed, 16 Jul 2008 22:37:09 +0000 (22:37 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Wed, 16 Jul 2008 22:37:09 +0000 (22:37 +0000)
return -1, set buf->len to 0 rather than -1.  While downstream
code is set up to consider the buffer invalidated if its length
is <= 0, this change makes the code cleaner and safer.

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3061 e7ae566f-a301-0410-adde-c780ea21d3b5

tun.c

diff --git a/tun.c b/tun.c
index c1494d9548158d87e6d79626471d1725deee1191..bc3466bd4e5b90f677e4719dddec37a75b2f9bad 100644 (file)
--- a/tun.c
+++ b/tun.c
@@ -2033,7 +2033,12 @@ tun_finalize (
     }
 
   if (buf)
-    buf->len = ret;
+    {
+      if (ret < 0)
+       buf->len = 0;
+      else
+       buf->len = ret;
+    }
   return ret;
 }