changeset 321:3e6d0c26e37b

2003-11-30 Brian Masney <masneyb@gftp.org> * lib/sshv2.c - cleaned up some of the code. Added a temporary fix for an upload crash that is happening on FreeBSD.
author masneyb
date Mon, 01 Dec 2003 01:21:14 +0000
parents 853981bbd4d7
children eaf943274fdb
files ChangeLog lib/sshv2.c
diffstat 2 files changed, 24 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Nov 30 19:35:24 2003 +0000
+++ b/ChangeLog	Mon Dec 01 01:21:14 2003 +0000
@@ -1,4 +1,7 @@
 2003-11-30 Brian Masney <masneyb@gftp.org>
+	* lib/sshv2.c - cleaned up some of the code. Added a temporary fix for
+	an upload crash that is happening on FreeBSD. 
+
 	* src/gtk/transfer.c - shows status information in title bar. (patch
 	from Jamil Geor <jamil_geor@yahoo.co.nz>, cleaned up by me some)
 
@@ -1776,7 +1779,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.175 2003/11/30 19:35:16 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.176 2003/12/01 01:21:13 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/sshv2.c	Sun Nov 30 19:35:24 2003 +0000
+++ b/lib/sshv2.c	Mon Dec 01 01:21:14 2003 +0000
@@ -564,7 +564,7 @@
 
 static int
 sshv2_send_command (gftp_request * request, char type, char *command, 
-                    gint32 len)
+                    size_t len)
 {
   char buf[34000];
   gint32 clen;
@@ -1883,7 +1883,7 @@
 {
   sshv2_params * params;
   sshv2_message message;
-  char *tempstr;
+  char *tempstr, *path;
   size_t stlen;
   gint32 num;
   int ret;
@@ -1904,11 +1904,11 @@
     }
   else
     {
-      stlen = strlen (file) + strlen (request->directory) + 1;
+      path = gftp_build_path (request->directory, file, NULL);
+      stlen = strlen (path);
       tempstr = g_malloc (stlen + 16);
-      strcpy (tempstr + 8, request->directory);
-      strcat (tempstr + 8, "/");
-      strcat (tempstr + 8, file);
+      strcpy (tempstr + 8, path);
+      g_free (path);
     }
 
   num = htonl (params->id++);
@@ -1920,7 +1920,8 @@
   num = htonl (SSH_FXF_READ);
   memcpy (tempstr + 8 + stlen, &num, 4);
 
-  memset (tempstr + 12 + stlen, 0, 4);
+  num = 0;
+  memcpy (tempstr + 12 + stlen, &num, 4);
   
   if (sshv2_send_command (request, SSH_FXP_OPEN, tempstr, stlen + 16) < 0)
     {
@@ -1973,7 +1974,7 @@
 {
   sshv2_params * params;
   sshv2_message message;
-  char *tempstr;
+  char *tempstr, *path;
   size_t stlen;
   gint32 num;
   int ret;
@@ -1994,11 +1995,11 @@
     }
   else
     {
-      stlen = strlen (file) + strlen (request->directory) + 1;
+      path = gftp_build_path (request->directory, file, NULL);
+      stlen = strlen (path);
       tempstr = g_malloc (stlen + 16);
-      strcpy (tempstr + 8, request->directory);
-      strcat (tempstr + 8, "/");
-      strcat (tempstr + 8, file);
+      strcpy (tempstr + 8, path);
+      g_free (path);
     }
 
   num = htonl (params->id++);
@@ -2013,7 +2014,8 @@
     num = htonl (SSH_FXF_WRITE | SSH_FXF_CREAT | SSH_FXF_TRUNC);
   memcpy (tempstr + 8 + stlen, &num, 4);
 
-  memset (tempstr + 12 + stlen, 0, 4);
+  num = 0;
+  memcpy (tempstr + 12 + stlen, &num, 4);
   
   if (sshv2_send_command (request, SSH_FXP_OPEN, tempstr, stlen + 16) < 0)
     {
@@ -2052,7 +2054,7 @@
     }
 
   memset (params->handle, 0, 4);
-  memcpy (params->handle + 4, message.buffer+ 4, message.length - 5);
+  memcpy (params->handle + 4, message.buffer + 4, message.length - 5);
   params->handle_len = message.length - 1;
   sshv2_message_free (&message);
 
@@ -2151,8 +2153,9 @@
 {
   sshv2_params * params;
   sshv2_message message;
-  char tempstr[32768];
+  static char tempstr[32768]; /* FIXME - temporary fix for FreeBSD */
   gint32 num;
+  size_t len;
   int ret;
 
 #ifdef G_HAVE_GINT64
@@ -2169,7 +2172,6 @@
 
   params = request->protocol_data;
 
-  num = htonl (params->handle_len);
   memcpy (tempstr, params->handle, params->handle_len);
 
   num = htonl (params->id++);
@@ -2188,7 +2190,8 @@
   memcpy (tempstr + params->handle_len + 8, &num, 4);
   memcpy (tempstr + params->handle_len + 12, buf, size);
   
-  if (sshv2_send_command (request, SSH_FXP_WRITE, tempstr, params->handle_len + size + 12) < 0)
+  len = params->handle_len + size + 12;
+  if (sshv2_send_command (request, SSH_FXP_WRITE, tempstr, len) < 0)
     {
       g_free (tempstr);
       return (GFTP_ERETRYABLE);