|
|
@@ -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 @@ Index: popper/main.c
|
|
|
/*
|
|
|
* 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 )
|
|
|
{
|