#88 wput passive mode IP octect swapping fix

0.6.1
open
nobody
5
2010-04-23
2010-04-23
No

Found the previous bug from "wput pasive mode fail on NSLU2 (armv5tel) - ID: 2914745" while looking for a solution. Below is a patch which wastested on arm/ppc/i386 devices.

-Brian T

--- ftplib.c (revision 1602)
+++ ftplib.c (revision 1710)
@@ -1001,16 +1001,44 @@
* and puts their decimal values in a comma-seperated string like
* (192,168,1,1,42,5). this function parses the garbage */
void parse_passive_string(char * msg, unsigned int * ip, unsigned short int * port) {
+ typedef union myipaddr {
+ unsigned int full;
+ unsigned char parts[4];
+ } Tmyipaddr;
+ Tmyipaddr myaddr;
char * start = strchr(msg, '(') + 1;
char * curtok;
char temp[6];
int i = 0;
curtok = strtok(start, ",");
do
temp[i++] = atoi(curtok);
while( (curtok = strtok(NULL, ",") ));

+ myaddr.parts[0] = temp[2];
+ myaddr.parts[1] = temp[3];
+ myaddr.parts[2] = temp[0];
+ myaddr.parts[3] = temp[1];

/* TODO USS do we have an endian problem here for the ip-adress */
- *ip = *(unsigned int *) temp;
+ /* *ip = *(unsigned int *) temp; */
+ *ip = myaddr.full;
+
*port = ntohs(*(unsigned short *) (temp+4));
}
+

Discussion

  • Brian  Tuchten

    Brian Tuchten - 2010-04-23
    • summary: wput passive mode IP octect swalling fix --> wput passive mode IP octect swapping fix
     
  • Brian  Tuchten

    Brian Tuchten - 2010-04-23

    Fix subject line typo

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks