Revision: 556
          http://vde.svn.sourceforge.net/vde/?rev=556&view=rev
Author:   danielel
Date:     2013-03-07 20:18:59 +0000 (Thu, 07 Mar 2013)
Log Message:
-----------
Closes sourceforge #3603894, #3603897.

Modified Paths:
--------------
    trunk/vde-2/src/lib/libvdeplug.c
    trunk/vde-2/src/vde_cryptcab/vde_cryptcab_client.c

Modified: trunk/vde-2/src/lib/libvdeplug.c
===================================================================
--- trunk/vde-2/src/lib/libvdeplug.c    2013-03-04 17:56:00 UTC (rev 555)
+++ trunk/vde-2/src/lib/libvdeplug.c    2013-03-07 20:18:59 UTC (rev 556)
@@ -586,8 +586,12 @@
                errno=err;
        }
 cleanup:
-       if (std_sockname) free(std_sockname);
-       if (real_sockname) free(real_sockname);
+  {
+    int err=errno;
+       if (std_sockname) free(std_sockname);
+       if (real_sockname) free(real_sockname);
+    errno = err;
+  }
        return conn;
 }
 

Modified: trunk/vde-2/src/vde_cryptcab/vde_cryptcab_client.c
===================================================================
--- trunk/vde-2/src/vde_cryptcab/vde_cryptcab_client.c  2013-03-04 17:56:00 UTC 
(rev 555)
+++ trunk/vde-2/src/vde_cryptcab/vde_cryptcab_client.c  2013-03-07 20:18:59 UTC 
(rev 556)
@@ -20,6 +20,7 @@
 static struct timeval last_out_time;
 static enum e_enc_type enc_type = ENC_SSH;
 static char *scp_extra_options = NULL;
+static char keyname[] = "/tmp/vde_XXXXXX.key";
 
 static void send_keepalive(struct peer *p){
        if (!keepalives)
@@ -73,10 +74,9 @@
 static struct peer
 *generate_key (struct peer *ret)
 {
-       int i, fd=-1, od=-1;
+       int fd=-1, od=-1;
        unsigned char key[16];
        unsigned char iv[8];
-       unsigned char c;
        char *path;
        char random[]="/dev/urandom";
        if (pre_shared){
@@ -87,6 +87,7 @@
                vc_printlog(2,"Generating Blowfish key...");    
        }
 
+
        if ( ((fd = open (path, O_RDONLY)) == -1)||
                         ((read (fd, key, 16)) == -1) ||
                         ((read (fd, iv, 8)) == -1) )
@@ -96,25 +97,20 @@
                goto failure;
        }
        
-       memset(ret,0, sizeof(struct peer));     
-
-       for(i=0; i<FILENAMESIZE-1;i++){
-               if (read(fd,&c,1) < 0) {
-                       perror("could not read filename ");
-                       goto failure;
-               }
-               c=(c%25);
-               //fprintf(stderr,"c=%u\n",c);
-               ret->id[i]=(char)('a' + c);
-       }
-       ret->id[FILENAMESIZE-1]='\0';
-       
        close (fd);
        
-       if ((od = 
open("/tmp/.blowfish.key",O_CREAT|O_WRONLY|O_TRUNC|O_EXCL,0600)) == -1){
-               perror ("blowfish.key creat error");
+  memset(keyname + strlen(keyname) - 10, 'X', 6);
+  od = mkostemps(keyname, 4, O_RDWR | O_CREAT | O_TRUNC);
+       if (od < 0){
+               perror ("blowfish.key mktemp error");
                goto failure;
        }
+       memset(ret,0, sizeof(struct peer));
+
+  strncpy(ret->id,
+          keyname + strlen("/tmp/"), 
+          strlen(keyname) - strlen("/tmp/") - strlen(".key"));
+
        memcpy(ret->key,key,16);
        memcpy(ret->iv,iv,8);
        if (write(od,key,16) < 0 || write(od,iv,8) < 0) {
@@ -139,7 +135,7 @@
  * OpenSSH secure copy.
  */
 static struct peer *generate_and_xmit(struct peer *ret){
-       char command[PATH_MAX];
+       char source[PATH_MAX], dest[PATH_MAX];
        struct hostent *target;
 
        ret=generate_key(ret);
@@ -159,16 +155,22 @@
        ret->in_a.sin_port = htons(remoteport);
        ret->in_a.sin_addr.s_addr=((struct in_addr *)(target->h_addr))->s_addr;
        if(!pre_shared){                
-               char *cmd[]={"scp",NULL,"/tmp/.blowfish.key",NULL,0};
+               char *cmd[]={"scp",NULL, NULL, NULL,0};
                pid_t pid;
                int status;
+    int cmd_idx = 1;
                vc_printlog(2,"Sending key over ssh channel:");
-               cmd[1]=scp_extra_options?scp_extra_options:"";
+    if (scp_extra_options)
+      cmd[cmd_idx++] = scp_extra_options;
                if(remoteusr)
-                       
snprintf(command,PATH_MAX,"%s@%s:/tmp/.%s.key",remoteusr, remotehost, ret->id);
+                       snprintf(dest,PATH_MAX,"%s@%s:/tmp/.%s.key",remoteusr, 
remotehost, ret->id);
                else
-                       snprintf(command,PATH_MAX,"%s:/tmp/.%s.key", 
remotehost, ret->id);
+                       snprintf(dest,PATH_MAX,"%s:/tmp/.%s.key", remotehost, 
ret->id);
+    snprintf(source, PATH_MAX, "/tmp/%s.key", ret->id);
+    cmd[cmd_idx++] = source;
+    cmd[cmd_idx++] = dest;
 
+
                if ((pid=fork()) == 0) {
                        dup2(1,2);
                        execvp(cmd[0],cmd);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
vde-users mailing list
vde-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vde-users

Reply via email to