From: <no...@so...> - 2007-07-28 12:30:05
|
Update of /cvsroot/ijbswa/current In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv13707 Modified Files: gateway.c ChangeLog Log Message: Modified patch from Song Weijia (#1762559) to fix socks requests on big-endian platforms. Index: gateway.c =================================================================== RCS file: /cvsroot/ijbswa/current/gateway.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- gateway.c 14 May 2007 10:23:48 -0000 1.20 +++ gateway.c 28 Jul 2007 12:30:03 -0000 1.21 @@ -34,6 +34,10 @@ * * Revisions : * $Log$ + * Revision 1.21 2007/07/28 12:30:03 fabiankeil + * Modified patch from Song Weijia (#1762559) to + * fix socks requests on big-endian platforms. + * * Revision 1.20 2007/05/14 10:23:48 fabiankeil * - Use strlcpy() instead of strcpy(). * - Use the same buffer for socks requests and socks responses. @@ -185,6 +189,7 @@ unsigned char dstport[2]; /* destination port */ unsigned char dstip[4]; /* destination address */ char userid; /* first byte of userid */ + char padding[3]; /* make sure sizeof(struct socks_op) is endian-independent. */ /* more bytes of the userid follow, terminated by a NULL */ }; @@ -317,7 +322,7 @@ strlcpy(&(c->userid), socks_userid, sizeof(buf) - sizeof(struct socks_op)); - csiz = sizeof(*c) + sizeof(socks_userid) - 1; + csiz = sizeof(*c) + sizeof(socks_userid) - sizeof(c->userid) - sizeof(c->padding); switch (fwd->type) { @@ -348,11 +353,12 @@ * size of socks_op, plus the length of the userid plus * its \0 byte (which we don't have to add because the * first byte of the userid is counted twice as it's also - * part of sock_op), plus the length of the target_host + * part of sock_op) minus the padding bytes (which are part + * of the userid as well), plus the length of the target_host * (which is stored csiz bytes after the beginning of the buffer), * plus another \0 byte. */ - assert(n == sizeof(struct socks_op) + strlen(&(c->userid)) + strlen(buf + csiz) + 1); + assert(n == sizeof(struct socks_op) + strlen(&(c->userid)) - sizeof(c->padding) + strlen(buf + csiz) + 1); csiz = n; } break; Index: ChangeLog =================================================================== RCS file: /cvsroot/ijbswa/current/ChangeLog,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- ChangeLog 21 Jul 2007 11:53:40 -0000 1.58 +++ ChangeLog 28 Jul 2007 12:30:04 -0000 1.59 @@ -114,6 +114,7 @@ - Don't ignore applying filters if the server didn't specify a Content-Type. Bug reported by Amuro Namie. - Allow to rewrite the request destination behind the client's back. +- Fix socks requests on big-endian platforms. Patch provided by Song Weijia. - Minor code clean-ups, filter and action file updates. (Some of them reported by Davide Alberani, Markus Elfring and Adam Piggott) |