Use the somewhat misnamed proxy_write() function to write the CSD script
authorAdam Piątyszek <ediap@users.sourceforge.net>
Fri, 12 Feb 2010 14:26:19 +0000 (15:26 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 22 Feb 2010 13:58:24 +0000 (13:58 +0000)
Signed-off-by: Adam Piątyszek <ediap@users.sourceforge.net>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
http.c

diff --git a/http.c b/http.c
index 4bc4360..1b50f0f 100644 (file)
--- a/http.c
+++ b/http.c
@@ -40,6 +40,8 @@
 
 #include "openconnect.h"
 
+static int proxy_write(int fd, unsigned char *buf, size_t len);
+
 #define MAX_BUF_LEN 131072
 /*
  * We didn't really want to have to do this for ourselves -- one might have
@@ -344,7 +346,7 @@ static int fetch_config(struct openconnect_info *vpninfo, char *fu, char *bu,
 static int run_csd_script(struct openconnect_info *vpninfo, char *buf, int buflen)
 {
        char fname[16];
-       int fd;
+       int fd, ret;
 
        if (!vpninfo->uid_csd_given) {
                vpninfo->progress(vpninfo, PRG_ERR, "Error: You are trying to "
@@ -366,7 +368,13 @@ static int run_csd_script(struct openconnect_info *vpninfo, char *buf, int bufle
                                  strerror(errno));
                return err;
        }
-       write(fd, buf, buflen);
+
+       ret = proxy_write(fd, (void *)buf, buflen);
+       if (ret) {
+               vpninfo->progress(vpninfo, PRG_ERR, "Failed to write temporary CSD script file: %s\n",
+                                 strerror(ret));
+               return ret;
+       }
        fchmod(fd, 0755);
        close(fd);