OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Thomas Lotterer
Root: /e/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-src Date: 18-Sep-2003 22:42:40
Branch: HEAD Handle: 2003091821423900
Modified files:
openpkg-src/qpopper qpopper.patch
Log:
fix bug where hton(3) was called twice; rewrite addr/port parsing to
match manpage and accept all parseable combinations resulting from
[IP][:][PORT] (including empty and colon-only, but IPPORT w/o colon is
not parseable)
Summary:
Revision Changes Path
1.3 +93 -3 openpkg-src/qpopper/qpopper.patch
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-src/qpopper/qpopper.patch
============================================================================
$ cvs diff -u -r1.2 -r1.3 qpopper.patch
--- openpkg-src/qpopper/qpopper.patch 18 Sep 2003 19:26:48 -0000 1.2
+++ openpkg-src/qpopper/qpopper.patch 18 Sep 2003 20:42:39 -0000 1.3
@@ -1,7 +1,97 @@
Index: popper/main.c
--- popper/main.c.orig 2003-01-02 03:39:02.000000000 +0100
-+++ popper/main.c 2003-09-18 21:13:57.000000000 +0200
-@@ -477,6 +477,22 @@
++++ popper/main.c 2003-09-18 22:04:57.000000000 +0200
+@@ -226,12 +226,6 @@
+ err_out = msg_out = fopen ( "/dev/null", "w+" ); /* until we get set up */
+
+ /*
+- * Ensure default port & address is in network order
+- */
+- addr = htonl ( addr );
+- port = htons ( port );
+-
+- /*
+ * Set defaults for Qargc and Qargv
+ */
+ Qargc = argc;
+@@ -256,43 +250,34 @@
+ ptr = argv [ 1 ];
+ if ( argc >= 2 && ( *ptr == ':' || isdigit ( (int) *ptr ) ) )
+ {
+- unsigned long a = addr;
+- unsigned short n = port;
+- char b [ 25 ] = "";
+- char *q = b;
+-
+- /*
+- * We might have an ip address first
+- */
+- if ( strchr ( ptr, '.' ) != NULL )
+- while ( *ptr == '.' || isdigit ( (int) *ptr ) )
+- *q++ = *ptr++;
+-
+- if ( *b != '\0' )
+- {
+- a = inet_addr ( b );
+- ptr = strchr ( ptr, ':' );
+- if ( ptr != NULL )
+- ptr++;
++ char *cpIp = NULL;
++ char *cpPort = NULL;
++ char *cpDup;
++ char *cp;
++
++ if ((cpDup = strdup(ptr)) == NULL)
++ err_dump ( HERE, "unable to allocate memory to examine first argument"
);
++ if ((cp = strchr(cpDup, ':')) != NULL) {
++ *cp++ = '\0'; /* a colon means both ip and port are given, split them
*/
++ if (*cpDup != '\0') /* do not accept empty strings */
++ cpIp = cpDup;
++ if (*cp != '\0') /* do not accept empty strings */
++ cpPort = cp;
+ }
+- else
+- {
+- ptr = argv [ 1 ];
+- if ( *ptr == ':' )
+- ptr++;
++ else {
++ if (strchr (ptr, '.') != NULL)
++ cpIp = cpDup; /* no colon but a dot means a ip is given */
++ else
++ cpPort = cpDup; /* no colon and no dot means a port is given */
+ }
++ if (cpIp != NULL )
++ addr = inet_addr(cpIp);
++ if (cpPort != NULL )
++ port = atoi(cpPort);
++ free(cpDup);
+
+- /*
+- * We might have a port number
+- */
+- if ( ptr != NULL )
+- n = atoi ( ptr );
+-
+- if ( a == BAD_ADDR || n == 0 || n > USHRT_MAX )
++ if ( addr == BAD_ADDR || port == 0 || port > USHRT_MAX )
+ err_dump ( HERE, "invalid address and/or port: \"%s\"", argv[1] );
+-
+- port = htons ( n );
+- addr = a;
+
+ /*
+ * Since we consumed the first specified parameter,
+@@ -310,6 +295,8 @@
+ Qargv [ rslt - 1 ] = argv [ rslt ];
+ Qargc = argc - 1;
+ }
++ /* Ensure address remains and default port becomes network byte order */
++ port = htons ( port );
+
+ /*
+ * Open the log
+@@ -477,6 +464,22 @@
#endif /* not _DEBUG */
@@ -24,7 +114,7 @@
/*
* Set up the socket on which we listen
*/
-@@ -510,17 +526,9 @@
+@@ -510,17 +513,9 @@
rslt = bind ( sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr) );
if ( rslt < 0 )
{
@@ .
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List [EMAIL PROTECTED]