head 1.7; access; symbols OPENPKG_E1_MP_HEAD:1.7 OPENPKG_E1_MP:1.7 OPENPKG_E1_MP_2_STABLE:1.7 OPENPKG_E1_FP:1.7 OPENPKG_2_STABLE_MP:1.7 OPENPKG_2_STABLE_20061018:1.7 OPENPKG_2_STABLE_20060622:1.7 OPENPKG_2_STABLE:1.7.0.2 OPENPKG_2_STABLE_BP:1.7 OPENPKG_2_5_RELEASE:1.6 OPENPKG_2_5_SOLID:1.6.0.4 OPENPKG_2_5_SOLID_BP:1.6 OPENPKG_2_4_RELEASE:1.6 OPENPKG_2_4_SOLID:1.6.0.2 OPENPKG_2_4_SOLID_BP:1.6 OPENPKG_CW_FP:1.5 OPENPKG_2_3_RELEASE:1.5 OPENPKG_2_3_SOLID:1.5.0.2 OPENPKG_2_3_SOLID_BP:1.5 OPENPKG_2_2_RELEASE:1.4 OPENPKG_2_2_SOLID:1.4.0.6 OPENPKG_2_2_SOLID_BP:1.4 OPENPKG_2_1_RELEASE:1.4 OPENPKG_2_1_SOLID:1.4.0.4 OPENPKG_2_1_SOLID_BP:1.4 OPENPKG_2_0_RELEASE:1.4 OPENPKG_2_0_SOLID:1.4.0.2 OPENPKG_2_0_SOLID_BP:1.4 OPENPKG_1_3_RELEASE:1.1.4.2 OPENPKG_1_3_SOLID:1.1.4.2.0.2 OPENPKG_1_3_SOLID_BP:1.1.4.2 OPENPKG_1_STABLE_MP:1.1 OPENPKG_1_2_RELEASE:1.1 OPENPKG_1_2_SOLID:1.1.0.6 OPENPKG_1_2_SOLID_BP:1.1 OPENPKG_1_STABLE:1.1.0.4 OPENPKG_1_STABLE_BP:1.1 OPENPKG_1_1_RELEASE:1.1 OPENPKG_1_1_SOLID:1.1.0.2 OPENPKG_1_1_SOLID_BP:1.1; locks; strict; comment @# @; 1.7 date 2006.03.21.08.49.07; author rse; state Exp; branches; next 1.6; commitid s8IHpqF1DuBrJ1qr; 1.6 date 2005.04.28.11.05.58; author tho; state Exp; branches; next 1.5; 1.5 date 2005.02.06.13.21.46; author rse; state Exp; branches; next 1.4; 1.4 date 2003.10.01.16.04.12; author thl; state Exp; branches; next 1.3; 1.3 date 2003.09.18.20.42.39; author thl; state Exp; branches; next 1.2; 1.2 date 2003.09.18.19.26.48; author thl; state Exp; branches; next 1.1; 1.1 date 2001.12.28.11.30.48; author rse; state Exp; branches 1.1.2.1 1.1.4.1 1.1.6.1; next ; 1.1.2.1 date 2003.03.14.10.02.09; author mlelstv; state Exp; branches; next ; 1.1.4.1 date 2003.03.14.09.55.36; author mlelstv; state Exp; branches; next 1.1.4.2; 1.1.4.2 date 2003.07.24.20.45.13; author rse; state Exp; branches 1.1.4.2.2.1; next ; 1.1.4.2.2.1 date 2003.10.02.12.21.14; author thl; state Exp; branches; next ; 1.1.6.1 date 2003.03.14.10.08.10; author mlelstv; state Exp; branches; next ; desc @@ 1.7 log @upgrading package: qpopper 4.0.8 -> 4.0.9 @ text @Index: popper/Makefile.in --- popper/Makefile.in.orig 2006-03-09 23:32:37 +0100 +++ popper/Makefile.in 2006-03-21 09:44:34 +0100 @@@@ -192,11 +192,10 @@@@ popper: ${OBJS} mangler_library common_library ${CC} ${OBJS} -o popper ${mmangle_dir}/libmangle.a \ -I${common_srcdir} ${common_dir}/libcommon.a \ - ${LIBS} ${LDFLAGS} + ${LDFLAGS} ${LIBS} popauth: ${POPAUTHOBJS} - ${CC} -o popauth ${POPAUTHOBJS} ${NETWORK_LIBS} ${DBM_LIBS} \ - ${common_dir}/libcommon.a + ${CC} -o popauth ${POPAUTHOBJS} ${common_dir}/libcommon.a ${LDFLAGS} ${NETWORK_LIBS} ${DBM_LIBS} ${LIBS} poppassd: common_library cd ${password_dir} && ${MAKE} all Index: popper/main.c --- popper/main.c.orig 2006-03-09 23:32:37 +0100 +++ popper/main.c 2006-03-21 09:44:34 +0100 @@@@ -277,12 +277,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; @@@@ -307,46 +301,35 @@@@ ptr = argv [ 1 ]; if ( argc >= 2 && ( *ptr == ':' || isdigit ( (int) *ptr ) ) ) { - int j = 0; - 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 ) - j = atoi ( ptr ); - - if ( a == BAD_ADDR || j == 0 || j > USHRT_MAX ) + if ( addr == BAD_ADDR || port == 0 || port > USHRT_MAX ) err_dump ( HERE, "invalid address and/or port: \"%s\"", argv[1] ); - n = j; - port = htons ( n ); - addr = a; - /* * Since we consumed the first specified parameter, * create our own argv that omits it, to pass on to @@@@ -363,6 +346,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 @@@@ -559,6 +544,22 @@@@ #endif /* not _DEBUG */ +#ifdef PIDFILE + /* + * Write PID file. -- RSE + */ + { + pid_t pid; + FILE *fp; + + pid = getpid(); + if ((fp = fopen(PIDFILE, "w")) == NULL) + err_dump(HERE, "Can't write pidfile '%s'", PIDFILE); + fprintf(fp, "%ld\n", (long)pid); + fclose(fp); + } +#endif + /* * Set up the socket on which we listen */ @@@@ -596,17 +597,9 @@@@ rslt = bind ( sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr) ); if ( rslt < 0 ) { - if ( errno == EADDRINUSE ) - { - fprintf ( stderr, "%s:%d in use\n", - inet_ntoa ( serv_addr.sin_addr ), - ntohs ( serv_addr.sin_port ) ); - return 1; - } - else - err_dump ( HERE, "Can't bind local address %s:%d", - inet_ntoa ( serv_addr.sin_addr ), - ntohs ( serv_addr.sin_port ) ); + err_dump ( HERE, "Can't bind local address %s:%d", + inet_ntoa ( serv_addr.sin_addr ), + ntohs ( serv_addr.sin_port ) ); } TRACE ( trace_file, POP_DEBUG, HERE, Index: popper/pop_dropcopy.c --- popper/pop_dropcopy.c.orig 2006-03-09 23:32:37 +0100 +++ popper/pop_dropcopy.c 2006-03-21 09:44:34 +0100 @@@@ -1232,6 +1232,10 @@@@ return pop_msg ( p, POP_FAILURE, HERE, "[SYS/TEMP] Unable to get temp drop name" ); + /* + * OpenPKG: enforce usage of "spool-dir" configuration option + */ +#if 0 if ( stat ( p->temp_drop, &mybuf ) == -1 || mybuf.st_size <= 0 ) { if ( genpath ( p, p->temp_drop, @@@@ -1240,6 +1244,7 @@@@ return pop_msg ( p, POP_FAILURE, HERE, "[SYS/TEMP] Unable to get temp drop name" ); } +#endif } else { /* @ 1.6 log @upgrading package: qpopper 4.0.5 -> 4.0.7 @ text @d2 2 a3 2 --- popper/Makefile.in.orig 2005-04-26 05:14:37 +0200 +++ popper/Makefile.in 2005-04-28 12:41:52 +0200 d19 2 a20 2 --- popper/main.c.orig 2005-04-26 05:14:37 +0200 +++ popper/main.c 2005-04-28 12:41:52 +0200 d159 2 a160 2 --- popper/pop_dropcopy.c.orig 2005-04-26 05:14:39 +0200 +++ popper/pop_dropcopy.c 2005-04-28 12:41:52 +0200 @ 1.5 log @fix building @ text @d1 17 d19 3 a21 3 --- popper/main.c.orig 2003-01-02 03:39:02.000000000 +0100 +++ popper/main.c 2003-09-18 22:04:57.000000000 +0200 @@@@ -226,12 +226,6 @@@@ d34 1 a34 1 @@@@ -256,43 +250,34 @@@@ d38 1 d57 13 a69 13 + 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; d76 5 a80 5 + 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 */ d82 5 a86 5 + if (cpIp != NULL ) + addr = inet_addr(cpIp); + if (cpPort != NULL ) + port = atoi(cpPort); + free(cpDup); d92 1 a92 1 - n = atoi ( ptr ); d94 1 a94 1 - if ( a == BAD_ADDR || n == 0 || n > USHRT_MAX ) d97 2 a98 1 - d101 1 a101 1 d104 2 a105 1 @@@@ -310,6 +295,8 @@@@ d114 1 a114 1 @@@@ -477,6 +464,22 @@@@ d137 1 a137 1 @@@@ -510,17 +513,9 @@@@ d158 4 a161 4 Index: pop_dropcopy.c --- popper/pop_dropcopy.c.orig 2003-01-02 03:39:02.000000000 +0100 +++ popper/pop_dropcopy.c 2003-10-01 17:33:31.000000000 +0200 @@@@ -1231,6 +1231,10 @@@@ d172 1 a172 1 @@@@ -1239,6 +1243,7 @@@@ a179 17 Index: popper/Makefile.in --- popper/Makefile.in.orig 2003-03-13 03:06:36 +0100 +++ popper/Makefile.in 2005-02-06 14:19:48 +0100 @@@@ -185,11 +185,10 @@@@ popper: ${OBJS} mangler_library common_library ${CC} ${OBJS} -o popper ${mmangle_dir}/libmangle.a \ -I${common_srcdir} ${common_dir}/libcommon.a \ - ${LIBS} ${LDFLAGS} + ${LDFLAGS} ${LIBS} popauth: ${POPAUTHOBJS} - ${CC} -o popauth ${POPAUTHOBJS} ${NETWORK_LIBS} ${DBM_LIBS} \ - ${common_dir}/libcommon.a + ${CC} -o popauth ${POPAUTHOBJS} ${common_dir}/libcommon.a ${LDFLAGS} ${NETWORK_LIBS} ${DBM_LIBS} ${LIBS} poppassd: common_library cd ${password_dir} && ${MAKE} all @ 1.4 log @permissions @ text @d160 17 @ 1.3 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) @ text @d138 22 @ 1.2 log @remove useless error printing in case of EADDRINUSE @ text @d3 92 a94 2 +++ popper/main.c 2003-09-18 21:13:57.000000000 +0200 @@@@ -477,6 +477,22 @@@@ d117 1 a117 1 @@@@ -510,17 +526,9 @@@@ @ 1.1 log @- add patch for creating pid file - better handle pid file - use fakesyslog for logging @ text @d1 4 a4 3 --- popper/main.c.orig Wed Apr 4 02:23:26 2001 +++ popper/main.c Fri Dec 28 11:18:39 2001 @@@@ -472,6 +472,22 @@@@ d27 21 @ 1.1.6.1 log @MFS: SA-2003.018 @ text @a25 148 --- common/snprintf.c-orig Thu Mar 13 17:43:37 2003 +++ common/snprintf.c Thu Mar 13 21:10:59 2003 @@@@ -1,5 +1,5 @@@@ /* - * Copyright (c) 2002 QUALCOMM Incorporated. All rights reserved. + * Copyright (c) 2003 QUALCOMM Incorporated. All rights reserved. * See License.txt file for terms and conditions for modification and * redistribution. * @@@@ -7,6 +7,10 @@@@ * * Revisions: * + * 03/11/03 [rcg] + * - Buffer now always returned null-terminated. + * - Return value now always -1 when we run out of room. + * * 01/05/01 [rcg] * - Added Qstrlen, as a safe strlen. * @@@@ -73,7 +77,8 @@@@ -# define BUFSIZE 1024 +enum { BUFSIZE = 1024 }; +enum { NO_SIZE = 2147483647 }; #ifndef MIN # define MIN(A,B) ( ( (A) < (B) ) ? (A) : (B) ) @@@@ -135,7 +140,7 @@@@ * tokens. */ *f = NULL; /* Pointer into frmToken */ STATES nState = IN_FORM; - size_t nSize = n-1; + size_t nSize = n-1; /* Maximum chars we'll handle */ size_t width = 0; /* If we have a width minimum */ BOOL bWidth = FALSE; /* TRUE if width specified */ size_t limit = 0; /* If we have a length limiter */ @@@@ -185,8 +190,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } *f++ = *p; *f = '\0'; @@@@ -208,8 +215,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } *f++ = *p; *f = '\0'; @@@@ -227,8 +236,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } *f++ = *p; *f = '\0'; @@@@ -246,8 +257,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } /* * Get the string pointer. If NULL, or if the maximum length @@@@ -264,8 +277,10 @@@@ /* * Make sure we have room if limit is unspecified. */ - if ( bLimit == FALSE && s_len >= nSize ) - return -1; + if ( bLimit == FALSE && s_len >= nSize ) { + *s = '\0'; + return -1; + } /* * Handle minimum width @@@@ -313,8 +328,10 @@@@ f += strlen ( f ); /* on some systems sprintf doesn't return length of added chars */ } - else + else { + *s = '\0'; return -1; + } break; case '0': @@@@ -364,9 +381,24 @@@@ } /* We're still inside a format */ } /* for loop */ - if ( nSize ) + /* + * If we haven't run out of room, copy last character of + * format string (which is usually the terminating null). + * If we have run out of room, just make sure the buffer + * is null-terminated. + */ + if ( nSize > 0 ) *s++ = *p; - return ( (n-1) - nSize ); + else + *s = '\0'; + + /* + * Return chars put in buffer (or -1 if we ran out of room) + */ + if ( nSize == 0 && *p != '\0' ) + return -1; + else + return ( (n-1) - nSize ); } @@@@ -390,7 +422,7 @@@@ va_list ap; /* Pointer into stack to extract * parameters */ va_start ( ap, format ); - rslt = Qvsnprintf ( s, 2147483647, format, ap ); + rslt = Qvsnprintf ( s, NO_SIZE, format, ap ); va_end ( ap ); return rslt; } @ 1.1.2.1 log @MFS: SA-2003.018 @ text @a25 148 --- common/snprintf.c-orig Thu Mar 13 17:43:37 2003 +++ common/snprintf.c Thu Mar 13 21:10:59 2003 @@@@ -1,5 +1,5 @@@@ /* - * Copyright (c) 2002 QUALCOMM Incorporated. All rights reserved. + * Copyright (c) 2003 QUALCOMM Incorporated. All rights reserved. * See License.txt file for terms and conditions for modification and * redistribution. * @@@@ -7,6 +7,10 @@@@ * * Revisions: * + * 03/11/03 [rcg] + * - Buffer now always returned null-terminated. + * - Return value now always -1 when we run out of room. + * * 01/05/01 [rcg] * - Added Qstrlen, as a safe strlen. * @@@@ -73,7 +77,8 @@@@ -# define BUFSIZE 1024 +enum { BUFSIZE = 1024 }; +enum { NO_SIZE = 2147483647 }; #ifndef MIN # define MIN(A,B) ( ( (A) < (B) ) ? (A) : (B) ) @@@@ -135,7 +140,7 @@@@ * tokens. */ *f = NULL; /* Pointer into frmToken */ STATES nState = IN_FORM; - size_t nSize = n-1; + size_t nSize = n-1; /* Maximum chars we'll handle */ size_t width = 0; /* If we have a width minimum */ BOOL bWidth = FALSE; /* TRUE if width specified */ size_t limit = 0; /* If we have a length limiter */ @@@@ -185,8 +190,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } *f++ = *p; *f = '\0'; @@@@ -208,8 +215,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } *f++ = *p; *f = '\0'; @@@@ -227,8 +236,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } *f++ = *p; *f = '\0'; @@@@ -246,8 +257,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } /* * Get the string pointer. If NULL, or if the maximum length @@@@ -264,8 +277,10 @@@@ /* * Make sure we have room if limit is unspecified. */ - if ( bLimit == FALSE && s_len >= nSize ) - return -1; + if ( bLimit == FALSE && s_len >= nSize ) { + *s = '\0'; + return -1; + } /* * Handle minimum width @@@@ -313,8 +328,10 @@@@ f += strlen ( f ); /* on some systems sprintf doesn't return length of added chars */ } - else + else { + *s = '\0'; return -1; + } break; case '0': @@@@ -364,9 +381,24 @@@@ } /* We're still inside a format */ } /* for loop */ - if ( nSize ) + /* + * If we haven't run out of room, copy last character of + * format string (which is usually the terminating null). + * If we have run out of room, just make sure the buffer + * is null-terminated. + */ + if ( nSize > 0 ) *s++ = *p; - return ( (n-1) - nSize ); + else + *s = '\0'; + + /* + * Return chars put in buffer (or -1 if we ran out of room) + */ + if ( nSize == 0 && *p != '\0' ) + return -1; + else + return ( (n-1) - nSize ); } @@@@ -390,7 +422,7 @@@@ va_list ap; /* Pointer into stack to extract * parameters */ va_start ( ap, format ); - rslt = Qvsnprintf ( s, 2147483647, format, ap ); + rslt = Qvsnprintf ( s, NO_SIZE, format, ap ); va_end ( ap ); return rslt; } @ 1.1.4.1 log @SA-2003.018 @ text @a25 148 --- common/snprintf.c-orig Thu Mar 13 17:43:37 2003 +++ common/snprintf.c Thu Mar 13 21:10:59 2003 @@@@ -1,5 +1,5 @@@@ /* - * Copyright (c) 2002 QUALCOMM Incorporated. All rights reserved. + * Copyright (c) 2003 QUALCOMM Incorporated. All rights reserved. * See License.txt file for terms and conditions for modification and * redistribution. * @@@@ -7,6 +7,10 @@@@ * * Revisions: * + * 03/11/03 [rcg] + * - Buffer now always returned null-terminated. + * - Return value now always -1 when we run out of room. + * * 01/05/01 [rcg] * - Added Qstrlen, as a safe strlen. * @@@@ -73,7 +77,8 @@@@ -# define BUFSIZE 1024 +enum { BUFSIZE = 1024 }; +enum { NO_SIZE = 2147483647 }; #ifndef MIN # define MIN(A,B) ( ( (A) < (B) ) ? (A) : (B) ) @@@@ -135,7 +140,7 @@@@ * tokens. */ *f = NULL; /* Pointer into frmToken */ STATES nState = IN_FORM; - size_t nSize = n-1; + size_t nSize = n-1; /* Maximum chars we'll handle */ size_t width = 0; /* If we have a width minimum */ BOOL bWidth = FALSE; /* TRUE if width specified */ size_t limit = 0; /* If we have a length limiter */ @@@@ -185,8 +190,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } *f++ = *p; *f = '\0'; @@@@ -208,8 +215,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } *f++ = *p; *f = '\0'; @@@@ -227,8 +236,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } *f++ = *p; *f = '\0'; @@@@ -246,8 +257,10 @@@@ if ( bWidth || bLimit ) if ( MAX ( width, limit ) > MIN ( BUFSIZE, nSize ) - ) + ) { + *s = '\0'; return -1; + } /* * Get the string pointer. If NULL, or if the maximum length @@@@ -264,8 +277,10 @@@@ /* * Make sure we have room if limit is unspecified. */ - if ( bLimit == FALSE && s_len >= nSize ) - return -1; + if ( bLimit == FALSE && s_len >= nSize ) { + *s = '\0'; + return -1; + } /* * Handle minimum width @@@@ -313,8 +328,10 @@@@ f += strlen ( f ); /* on some systems sprintf doesn't return length of added chars */ } - else + else { + *s = '\0'; return -1; + } break; case '0': @@@@ -364,9 +381,24 @@@@ } /* We're still inside a format */ } /* for loop */ - if ( nSize ) + /* + * If we haven't run out of room, copy last character of + * format string (which is usually the terminating null). + * If we have run out of room, just make sure the buffer + * is null-terminated. + */ + if ( nSize > 0 ) *s++ = *p; - return ( (n-1) - nSize ); + else + *s = '\0'; + + /* + * Return chars put in buffer (or -1 if we ran out of room) + */ + if ( nSize == 0 && *p != '\0' ) + return -1; + else + return ( (n-1) - nSize ); } @@@@ -390,7 +422,7 @@@@ va_list ap; /* Pointer into stack to extract * parameters */ va_start ( ap, format ); - rslt = Qvsnprintf ( s, 2147483647, format, ap ); + rslt = Qvsnprintf ( s, NO_SIZE, format, ap ); va_end ( ap ); return rslt; } @ 1.1.4.2 log @mass Merge-From-CURRENT (MFC) in preparation for OpenPKG 1.3 [class BASE only] @ text @d26 148 @ 1.1.4.2.2.1 log @MFC: permissions; fix bug where hton(3) was called twice; rewrite addr/port parsing @ text @d1 3 a3 94 Index: popper/main.c --- popper/main.c.orig 2003-01-02 03:39:02.000000000 +0100 +++ 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 @@@@ a25 43 @@@@ -510,17 +513,9 @@@@ rslt = bind ( sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr) ); if ( rslt < 0 ) { - if ( errno == EADDRINUSE ) - { - fprintf ( stderr, "%s:%d in use\n", - inet_ntoa ( serv_addr.sin_addr ), - ntohs ( serv_addr.sin_port ) ); - return 1; - } - else - err_dump ( HERE, "Can't bind local address %s:%d", - inet_ntoa ( serv_addr.sin_addr ), - ntohs ( serv_addr.sin_port ) ); + err_dump ( HERE, "Can't bind local address %s:%d", + inet_ntoa ( serv_addr.sin_addr ), + ntohs ( serv_addr.sin_port ) ); } TRACE ( trace_file, POP_DEBUG, HERE, Index: pop_dropcopy.c --- popper/pop_dropcopy.c.orig 2003-01-02 03:39:02.000000000 +0100 +++ popper/pop_dropcopy.c 2003-10-01 17:33:31.000000000 +0200 @@@@ -1231,6 +1231,10 @@@@ return pop_msg ( p, POP_FAILURE, HERE, "[SYS/TEMP] Unable to get temp drop name" ); + /* + * OpenPKG: enforce usage of "spool-dir" configuration option + */ +#if 0 if ( stat ( p->temp_drop, &mybuf ) == -1 || mybuf.st_size <= 0 ) { if ( genpath ( p, p->temp_drop, @@@@ -1239,6 +1243,7 @@@@ return pop_msg ( p, POP_FAILURE, HERE, "[SYS/TEMP] Unable to get temp drop name" ); } +#endif } else { /* @