httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@hyperreal.org
Subject cvs commit: apache-1.3/src/support ab.c
Date Sun, 08 Aug 1999 11:45:21 GMT
dirkx       99/08/08 04:45:20

  Modified:    src/ap   Makefile.tmpl ap_sha1.c
               src/include ap.h ap_sha1.h httpd.h
               src/main http_protocol.c util.c
               src/modules/proxy proxy_ftp.c
               src/support ab.c
  Log:
  Collating various peoples patches on base64, md5 and sha1
  which sanitize the uuencoding used in various places a
  little bit; and getting rid of all the warnings.
  
  What is left now is moving ap_sha1.h and ap_md5.h into
  ap.h OR #including them there and modularizing the ap.h
  file. Secondly it might be nice to swap the base64-ish
  encoding used in apache's its own MD5 passwords to the
  uu-encoded one to get rid of those routines. But that
  would break compatibility betwen the 1.x series.
  
  Let's hope this is all for now.
  
   Modified Files:
   	ap/Makefile.tmpl ap/ap_checkpass.c ap/ap_md5c.c ap/ap_sha1.c
   	include/ap.h include/ap_sha1.h include/httpd.h
   	main/http_protocol.c main/util.c modules/proxy/proxy_ftp.c
   	support/ab.c
  
  Revision  Changes    Path
  1.34      +1 -1      apache-1.3/src/ap/Makefile.tmpl
  
  Index: Makefile.tmpl
  ===================================================================
  RCS file: /x3/home/cvs/apache-1.3/src/ap/Makefile.tmpl,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Makefile.tmpl	1999/08/02 10:13:44	1.33
  +++ Makefile.tmpl	1999/08/08 11:45:15	1.34
  @@ -6,7 +6,7 @@
   LIB=libap.a
   
   OBJS=ap_cpystrn.o ap_execve.o ap_fnmatch.o ap_getpass.o ap_md5c.o ap_signal.o \
  -     ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o
  +     ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o ap_base64.o
   
   .c.o:
   	$(CC) -c $(INCLUDES) $(CFLAGS) $<
  
  
  
  1.4       +85 -102   apache-1.3/src/ap/ap_sha1.c
  
  Index: ap_sha1.c
  ===================================================================
  RCS file: /x3/home/cvs/apache-1.3/src/ap/ap_sha1.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ap_sha1.c	1999/08/05 20:04:01	1.3
  +++ ap_sha1.c	1999/08/08 11:45:15	1.4
  @@ -6,7 +6,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -70,10 +70,10 @@
    *     will always generate the same hash, making it easier
    *     to break since the search space is smaller.
    *
  - * See also the documentation in support/SHA1 as to hints on how to 
  + * See also the documentation in support/SHA1 as to hints on how to
    * migrate an existing netscape installation and other supplied utitlites.
    *
  - * This software also makes use of the following components: 
  + * This software also makes use of the following components:
    *
    * NIST Secure Hash Algorithm
    *  	heavily modified by Uwe Hollerbach uh@alumni.caltech edu
  @@ -86,15 +86,15 @@
    *
    * Metamail's copyright is:
    * 	Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
  - * 	Permission to use, copy, modify, and distribute this material 
  - *	for any purpose and without fee is hereby granted, provided 
  - *	that the above copyright notice and this permission notice 
  - *	appear in all copies, and that the name of Bellcore not be 
  - *	used in advertising or publicity pertaining to this 
  - *	material without the specific, prior written permission 
  - *	of an authorized representative of Bellcore.  BELLCORE 
  - *	MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
  - *	OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
  + * 	Permission to use, copy, modify, and distribute this material
  + *	for any purpose and without fee is hereby granted, provided
  + *	that the above copyright notice and this permission notice
  + *	appear in all copies, and that the name of Bellcore not be
  + *	used in advertising or publicity pertaining to this
  + *	material without the specific, prior written permission
  + *	of an authorized representative of Bellcore.  BELLCORE
  + *	MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
  + *	OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS",
    *	WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
    */
   
  @@ -133,30 +133,13 @@
       temp = ROT32(A,5) + f##n(B,C,D) + E + W[i] + CONST##n;	\
       E = D; D = C; C = ROT32(B,30); B = A; A = temp
   
  -typedef unsigned char AP_BYTE;     /* an 8-bit quantity */
  -typedef unsigned long AP_LONG;     /* a 32-bit quantity */
  - 
   #define SHA_BLOCKSIZE           64
   #define SHA_DIGESTSIZE          20
  - 
  -typedef struct {
  -    AP_LONG digest[5];             /* message digest */
  -    AP_LONG count_lo, count_hi;    /* 64-bit bit count */
  -    AP_LONG data[16];              /* SHA data buffer */
  -    int local;                  /* unprocessed amount in data */
  -} SHA_INFO;
  -
  -static void sha_init(SHA_INFO *);
  -static void sha_update(SHA_INFO *, const AP_BYTE *, int);
  -static void sha_final(SHA_INFO *);
  -static void sha_raw_swap(SHA_INFO *);
  -static void output64chunk(unsigned char, unsigned char, unsigned char,
  -			  int, unsigned char **);
  -static void encode_mime64(unsigned char *, unsigned char *, int);
  -void sha1_base64(char *, int, char *);
   
  +typedef unsigned char AP_BYTE;
  +
   /* do SHA transformation */
  -static void sha_transform(SHA_INFO *sha_info)
  +static void sha_transform(AP_SHA1_CTX *sha_info)
   {
       int i;
       AP_LONG temp, A, B, C, D, E, W[80];
  @@ -236,7 +219,7 @@
       int i;
       AP_BYTE ct[4], *cp;
   
  -    if (isLittleEndian()) {    /* do the swap only if it is little endian */
  +    if (isLittleEndian()) {	/* do the swap only if it is little endian */
   	count /= sizeof(AP_LONG);
   	cp = (AP_BYTE *) buffer;
   	for (i = 0; i < count; ++i) {
  @@ -255,7 +238,7 @@
   
   /* initialize the SHA digest */
   
  -static void sha_init(SHA_INFO *sha_info)
  +API_EXPORT(void) ap_SHA1Init(AP_SHA1_CTX *sha_info)
   {
       sha_info->digest[0] = 0x67452301L;
       sha_info->digest[1] = 0xefcdab89L;
  @@ -269,7 +252,9 @@
   
   /* update the SHA digest */
   
  -static void sha_update(SHA_INFO *sha_info, const AP_BYTE *buffer, int count)
  +API_EXPORT(void) ap_SHA1Update_binary(AP_SHA1_CTX *sha_info,
  +				      const unsigned char *buffer,
  +				      unsigned int count)
   {
       int i;
   
  @@ -306,12 +291,55 @@
       sha_info->local = count;
   }
   
  +API_EXPORT(void) ap_SHA1Update(AP_SHA1_CTX *sha_info, const char *buf,
  +			       unsigned int count)
  +{
  +#ifdef CHARSET_EBCDIC
  +    int i;
  +    const AP_BYTE *buffer = (const AP_BYTE *) buf;
  +
  +    if ((sha_info->count_lo + ((LONG) count << 3)) < sha_info->count_lo)
{
  +	++sha_info->count_hi;
  +    }
  +    sha_info->count_lo += (LONG) count << 3;
  +    sha_info->count_hi += (LONG) count >> 29;
  +    if (sha_info->local) {
  +	i = SHA_BLOCKSIZE - sha_info->local;
  +	if (i > count) {
  +	    i = count;
  +	}
  +	ebcdic2ascii_strictly(((AP_BYTE *) sha_info->data) + sha_info->local, ubuf, i);
  +	count -= i;
  +	buffer += i;
  +	sha_info->local += i;
  +	if (sha_info->local == SHA_BLOCKSIZE) {
  +	    maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE);
  +	    sha_transform(sha_info);
  +	}
  +	else {
  +	    return;
  +	}
  +    }
  +    while (count >= SHA_BLOCKSIZE) {
  +	ebcdic2ascii_strictly(sha_info->data, buffer, SHA_BLOCKSIZE);
  +	buffer += SHA_BLOCKSIZE;
  +	count -= SHA_BLOCKSIZE;
  +	maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE);
  +	sha_transform(sha_info);
  +    }
  +    ebcdic2ascii_strictly(sha_info->data, buffer, count);
  +    sha_info->local = count;
  +#else
  +    ap_SHA1Update_binary(sha_info, (const unsigned char *) buf, count);
  +#endif
  +}
  +
   /* finish computing the SHA digest */
   
  -static void sha_final(SHA_INFO *sha_info)
  +API_EXPORT(void) ap_SHA1Final(unsigned char digest[20], AP_SHA1_CTX *sha_info)
   {
  -    int count;
  -    AP_LONG lo_bit_count, hi_bit_count;
  +    int count, i, j;
  +    AP_LONG lo_bit_count, hi_bit_count, k;
   
       lo_bit_count = sha_info->count_lo;
       hi_bit_count = sha_info->count_hi;
  @@ -331,66 +359,17 @@
       sha_info->data[14] = hi_bit_count;
       sha_info->data[15] = lo_bit_count;
       sha_transform(sha_info);
  -}
  -
  -/*
  -   internally implemented as an array of longs, need to swap if 
  -   you're going to access the memory in the raw, instead of looping
  -   through with arrays of longs.
  -*/
   
  -static void sha_raw_swap(SHA_INFO *sha_info)
  -{
  -    int i;
  -
  -    for (i = 0; i < 5; ++i) {
  -	maybe_byte_reverse((AP_LONG *) &sha_info->digest[i], 4);
  +    for (i = 0, j = 0; j < SHA_DIGESTSIZE; i++) {
  +	k = sha_info->digest[i];
  +	digest[j++] = (unsigned char) ((k >> 24) & 0xff);
  +	digest[j++] = (unsigned char) ((k >> 16) & 0xff);
  +	digest[j++] = (unsigned char) ((k >> 8) & 0xff);
  +	digest[j++] = (unsigned char) (k & 0xff);
       }
   }
   
  -static char basis_64[] =
  -  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
   
  -static void output64chunk(unsigned char c1, unsigned char c2, unsigned char c3,
  -			  int pads, unsigned char **outfile)
  -{
  -    *(*outfile)++ = basis_64[c1>>2];
  -
  -    *(*outfile)++ = basis_64[((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)];
  -    if (pads == 2) {
  -	*(*outfile)++ = '=';
  -	*(*outfile)++ = '=';
  -    }
  -    else if (pads) {
  -	*(*outfile)++ =  basis_64[((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)];
  -	*(*outfile)++ = '=';
  -    }
  -    else {
  -	*(*outfile)++ = basis_64[((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)];
  -	*(*outfile)++ = basis_64[c3 & 0x3F];
  -    }
  -}
  -
  -static void encode_mime64(unsigned char *in, unsigned char *out, int length)
  -{
  -    int diff, ct = 0;
  -
  -    while ((diff = length - ct)) {
  -	if ( diff >= 3 ) {
  -	    diff = 3;
  -	    output64chunk(in[ct], in[ct+1], in[ct+2], 0, &out);
  -	}
  -	else if (diff == 2) {
  -	    output64chunk(in[ct], in[ct+1], 0, 1, &out);
  -	}
  -	else if (diff == 1) {
  -	    output64chunk(in[ct], 0, 0, 2, &out);
  -	}
  -	ct += diff;
  -    }
  -    *out++ = 0;
  -}
  -
   /* {SHA} is the prefix used for base64 encoded sha1 in
    * ldap data interchange format.
    */
  @@ -398,23 +377,27 @@
   
   API_EXPORT(void) ap_sha1_base64(const char *clear, int len, char *out)
   {
  -    SHA_INFO context;
  +    int l;
  +    AP_SHA1_CTX context;
  +    AP_BYTE digest[SHA_DIGESTSIZE];
   
       if (!strncmp(clear, sha1_id, strlen(sha1_id))) {
   	clear += strlen(sha1_id);
       }
  -
  -    sha_init(&context);
  -    sha_update(&context, clear, len);
  -    sha_final(&context);
   
  -    sha_raw_swap(&context);
  +    ap_SHA1Init(&context);
  +    ap_SHA1Update(&context, clear, len);
  +    ap_SHA1Final(digest, &context);
   
       /* private marker. */
       strcpy(out, sha1_id);
   
       /* SHA1 hash is always 20 chars */
  -    encode_mime64((char *)context.digest, out+strlen(sha1_id), 20);
  -    /* output of MIME Base 64 encoded SHA1 is always
  -     * 28 characters + strlen(sha1_id) */
  +    l = ap_uuencode_binary(out + strlen(sha1_id), digest, sizeof(digest));
  +    out[l + strlen(sha1_id)] = '\0';
  +
  +    /*
  +     * output of MIME Base 64 encoded SHA1 is always 28 characters +
  +     * strlen(sha1_id)
  +     */
   }
  
  
  
  1.23      +24 -0     apache-1.3/src/include/ap.h
  
  Index: ap.h
  ===================================================================
  RCS file: /x3/home/cvs/apache-1.3/src/include/ap.h,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- ap.h	1999/08/02 20:50:14	1.22
  +++ ap.h	1999/08/08 11:45:16	1.23
  @@ -159,6 +159,30 @@
   			    __attribute__((format(printf,3,4)));
   API_EXPORT(int) ap_vsnprintf(char *buf, size_t len, const char *format,
   			     va_list ap);
  +/* Simple BASE64 encode/decode functions.
  + * 
  + * As we might encode binary strings, hence we require the length of
  + * the incoming plain source. And return the length of what we decoded.
  + *
  + * The decoding function takes any non valid char (i.e. whitespace, \0
  + * or anything non A-Z,0-9 etc as terminal.
  + * 
  + * plain strings/binary sequences are not assumed '\0' terminated. Encoded
  + * strings are neither. But propably should.
  + *
  + */
  +API_EXPORT(int) ap_uuencode_len(int len);
  +API_EXPORT(int) ap_uuencode(char * coded_dst, const char *plain_src,int len_plain_src);
  +API_EXPORT(int) ap_uuencode_binary(char * coded_dst, const unsigned char *plain_src,int
len_plain_src);
  +
  +API_EXPORT(int) ap_uudecode_len(const char * coded_src);
  +API_EXPORT(int) ap_uudecode(char * plain_dst, const char *coded_src);
  +API_EXPORT(int) ap_uudecode_binary(unsigned char * plain_dst, const char *coded_src);
  +
  +/* Password validation, as used in AuthType Basic which is able to cope
  + * (based on the prexix) with the SHA1, Apache's internal MD5 and (depending
  + * on your platform either plain or crypt(3) passwords.
  + */
   API_EXPORT(char *) ap_validate_password(const char *passwd, const char *hash);
   
   #ifdef __cplusplus
  
  
  
  1.4       +17 -1     apache-1.3/src/include/ap_sha1.h
  
  Index: ap_sha1.h
  ===================================================================
  RCS file: /x3/home/cvs/apache-1.3/src/include/ap_sha1.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ap_sha1.h	1999/08/05 20:04:03	1.3
  +++ ap_sha1.h	1999/08/08 11:45:16	1.4
  @@ -84,11 +84,27 @@
   extern "C" {
   #endif
   
  +typedef unsigned long AP_LONG;     /* a 32-bit quantity */
  +
  +typedef struct {
  +    AP_LONG digest[5];             /* message digest */
  +    AP_LONG count_lo, count_hi;    /* 64-bit bit count */
  +    AP_LONG data[16];              /* SHA data buffer */
  +    int local;                     /* unprocessed amount in data */
  +} AP_SHA1_CTX;
  +
   extern const char *sha1_id;	/* passwd prefix marker for SHA1 */
   API_EXPORT(void) ap_sha1_base64(const char *clear, int len, char *out);
  +API_EXPORT(void) ap_SHA1Init(AP_SHA1_CTX *context);
  +API_EXPORT(void) ap_SHA1Update(AP_SHA1_CTX *context, const char *input,
  +			       unsigned int inputLen);
  +API_EXPORT(void) ap_SHA1Update_binary(AP_SHA1_CTX *context,
  +				      const unsigned char *input,
  +				      unsigned int inputLen);
  +API_EXPORT(void) ap_SHA1Final(unsigned char digest[20], AP_SHA1_CTX *context);
   
   #ifdef __cplusplus
   }
   #endif
   
  -#endif	/* !APACHE_MD5_H */
  +#endif	/* !APACHE_SHA1_H */
  
  
  
  1.289     +2 -2      apache-1.3/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /x3/home/cvs/apache-1.3/src/include/httpd.h,v
  retrieving revision 1.288
  retrieving revision 1.289
  diff -u -r1.288 -r1.289
  --- httpd.h	1999/07/29 22:58:23	1.288
  +++ httpd.h	1999/08/08 11:45:16	1.289
  @@ -990,8 +990,8 @@
   API_EXPORT(int) ap_is_matchexp(const char *str);
   API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp);
   API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp);
  -API_EXPORT(char *) ap_uudecode(pool *, const char *);
  -API_EXPORT(char *) ap_uuencode(pool *p, char *string); 
  +API_EXPORT(char *) ap_puudecode(pool *, const char *);
  +API_EXPORT(char *) ap_puuencode(pool *p, char *string); 
   #ifdef OS2
   void os2pathname(char *path);
   char *ap_double_quotes(pool *p, char *str);
  
  
  
  1.276     +7 -1      apache-1.3/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /x3/home/cvs/apache-1.3/src/main/http_protocol.c,v
  retrieving revision 1.275
  retrieving revision 1.276
  diff -u -r1.275 -r1.276
  --- http_protocol.c	1999/07/31 03:30:18	1.275
  +++ http_protocol.c	1999/08/08 11:45:18	1.276
  @@ -1151,7 +1151,13 @@
           return AUTH_REQUIRED;
       }
   
  -    t = ap_uudecode(r->pool, auth_line);
  +    /* CHARSET_EBCDIC Issue's here ?!? Compare with 32/9 instead
  +     * as we are operating on an octed stream ?
  +     */
  +    while (*auth_line== ' ' || *auth_line== '\t')
  +        auth_line++;
  +
  +    t = ap_puudecode(r->pool, auth_line);
       /* Note that this allocation has to be made from r->connection->pool
        * because it has the lifetime of the connection.  The other allocations
        * are temporary and can be tossed away any time.
  
  
  
  1.169     +18 -154   apache-1.3/src/main/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /x3/home/cvs/apache-1.3/src/main/util.c,v
  retrieving revision 1.168
  retrieving revision 1.169
  diff -u -r1.168 -r1.169
  --- util.c	1999/08/02 10:45:32	1.168
  +++ util.c	1999/08/08 11:45:18	1.169
  @@ -1957,167 +1957,31 @@
       return server_hostname;
   }
   
  -/* aaaack but it's fast and const should make it shared text page. */
  -static const unsigned char pr2six[256] =
  +/* simple 'pool' alloc()ing glue to ap_base64.c
  + */
  +API_EXPORT(char *) ap_puudecode(pool *p, const char *bufcoded)
   {
  -    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  -    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  -    64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, 52, 53, 54,
  -    55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3,
  -    4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
  -    22, 23, 24, 25, 64, 64, 64, 64, 64, 64, 26, 27, 28, 29, 30, 31, 32,
  -    33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
  -    50, 51, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  -    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  -    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  -    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  -    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  -    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  -    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  -    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
  -};
  +    char *decoded;
  +    int l;
   
  -API_EXPORT(char *) ap_uudecode(pool *p, const char *bufcoded)
  -{
  -    int nbytesdecoded;
  -    register const unsigned char *bufin;
  -    register char *bufplain;
  -    register unsigned char *bufout;
  -    register int nprbytes;
  -
  -    /* Strip leading whitespace. */
  -
  -    while (*bufcoded == ' ' || *bufcoded == '\t')
  -	bufcoded++;
  -
  -    /* Figure out how many characters are in the input buffer.
  -     * Allocate this many from the per-transaction pool for the result.
  -     */
  -#ifndef CHARSET_EBCDIC
  -    bufin = (const unsigned char *) bufcoded;
  -    while (pr2six[*(bufin++)] <= 63);
  -    nprbytes = (bufin - (const unsigned char *) bufcoded) - 1;
  -    nbytesdecoded = ((nprbytes + 3) / 4) * 3;
  -
  -    bufplain = ap_palloc(p, nbytesdecoded + 1);
  -    bufout = (unsigned char *) bufplain;
  -
  -    bufin = (const unsigned char *) bufcoded;
  -
  -    while (nprbytes > 4) {
  -	*(bufout++) =
  -	    (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
  -	*(bufout++) =
  -	    (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
  -	*(bufout++) =
  -	    (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
  -	bufin += 4;
  -	nprbytes -= 4;
  -    }
  -
  -    /* Note: (nprbytes == 1) would be an error, so just ingore that case */
  -    if (nprbytes > 1) {
  -	*(bufout++) =
  -	    (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
  -    }
  -    if (nprbytes > 2) {
  -	*(bufout++) =
  -	    (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
  -    }
  -    if (nprbytes > 3) {
  -        *(bufout++) =
  -            (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
  -    }
  -#else /*CHARSET_EBCDIC*/
  -    bufin = (const unsigned char *) bufcoded;
  -    while (pr2six[os_toascii[(unsigned char)*(bufin++)]] <= 63);
  -    nprbytes = (bufin - (const unsigned char *) bufcoded) - 1;
  -    nbytesdecoded = ((nprbytes + 3) / 4) * 3;
  +    decoded = (char *) ap_palloc(p, 1+ap_uudecode_len(bufcoded));
  +    l = ap_uudecode(decoded,bufcoded);
  +    decoded[l]='\0'; /* make binary sequence into string */
   
  -    bufplain = ap_palloc(p, nbytesdecoded + 1);
  -    bufout = (unsigned char *) bufplain;
  -
  -    bufin = (const unsigned char *) bufcoded;
  -
  -    while (nprbytes > 4) {
  -	*(bufout++) = os_toebcdic[
  -	    (unsigned char) (pr2six[os_toascii[*bufin]] << 2 | pr2six[os_toascii[bufin[1]]]
>> 4)];
  -	*(bufout++) = os_toebcdic[
  -	    (unsigned char) (pr2six[os_toascii[bufin[1]]] << 4 | pr2six[os_toascii[bufin[2]]]
>> 2)];
  -	*(bufout++) = os_toebcdic[
  -	    (unsigned char) (pr2six[os_toascii[bufin[2]]] << 6 | pr2six[os_toascii[bufin[3]]])];
  -	bufin += 4;
  -	nprbytes -= 4;
  -    }
  -
  -    /* Note: (nprbytes == 1) would be an error, so just ingore that case */
  -    if (nprbytes > 1) {
  -	*(bufout++) = os_toebcdic[
  -	    (unsigned char) (pr2six[os_toascii[*bufin]] << 2 | pr2six[os_toascii[bufin[1]]]
>> 4)];
  -    }
  -    if (nprbytes > 2) {
  -	*(bufout++) = os_toebcdic[
  -	    (unsigned char) (pr2six[os_toascii[bufin[1]]] << 4 | pr2six[os_toascii[bufin[2]]]
>> 2)];
  -    }
  -    if (nprbytes > 3) {
  -        *(bufout++) = os_toebcdic[
  -            (unsigned char) (pr2six[os_toascii[bufin[2]]] << 6 | pr2six[os_toascii[bufin[3]]])];
  -    }
  -#endif /*CHARSET_EBCDIC*/
  -
  -    nbytesdecoded -= (4 - nprbytes) & 3;
  -    bufplain[nbytesdecoded] = '\0';
  -
  -    return bufplain;
  +    return decoded;
   }
   
  -static const char basis_64[] = 
  -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 
  - 
  -API_EXPORT(char *) ap_uuencode(pool *a, char *string) 
  +API_EXPORT(char *) ap_puuencode(pool *p, char *string) 
   { 
  -    int i, len = strlen(string); 
  -    char *p; 
  -    char *encoded = (char *) ap_palloc(a, ((len+2) / 3 * 4) + 1); 
  - 
  -    p = encoded; 
  -#ifndef CHARSET_EBCDIC
  -    for (i = 0; i < len-2; i += 3) { 
  -        *p++ = basis_64[(string[i] >> 2) & 0x3F]; 
  -        *p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] &
0xF0) >> 4)]; 
  -        *p++ = basis_64[((string[i + 1] & 0xF) << 2) | ((int) (string[i + 2]
& 0xC0) >> 6)]; 
  -        *p++ = basis_64[string[i + 2] & 0x3F]; 
  -    } 
  -    if (i < len) {
  -        *p++ = basis_64[(string[i] >> 2) & 0x3F]; 
  -       *p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] &
0xF0) >> 4)]; 
  -       if (i == (len-2))
  -           *p++ = basis_64[((string[i + 1] & 0xF) << 2)]; 
  -       else
  -           *p++ = '='; 
  -       *p++ = '='; 
  -    }
  -#else /*CHARSET_EBCDIC*/
  -    for (i = 0; i < len-2; i += 3) { 
  -        *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; 
  -        *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | ((int) (os_toascii[string[i
+ 1]] & 0xF0) >> 4)]; 
  -        *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2) | ((int) (os_toascii[string[i
+ 2]] & 0xC0) >> 6)]; 
  -        *p++ = basis_64[os_toascii[string[i + 2]] & 0x3F]; 
  -    } 
  -    if (i < len) {
  -        *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; 
  -       *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | ((int) (os_toascii[string[i
+ 1]] & 0xF0) >> 4)]; 
  -       if (i == (len-2))
  -           *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2)]; 
  -       else
  -           *p++ = '='; 
  -       *p++ = '='; 
  -    }
  -#endif /*CHARSET_EBCDIC*/
  +    char *encoded;
  +    int l = strlen(string);
  +
  +    encoded = (char *) ap_palloc(p, 1+ap_uuencode_len(l));
  +    l=ap_uuencode(encoded,string,l);
  +    encoded[l]='\0'; /* make binary sequence into string */
   
  -    *p = '\0'; 
  -    return encoded; 
  -} 
  +    return encoded;
  +}
   
   #ifdef OS2
   void os2pathname(char *path)
  
  
  
  1.77      +1 -1      apache-1.3/src/modules/proxy/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /x3/home/cvs/apache-1.3/src/modules/proxy/proxy_ftp.c,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- proxy_ftp.c	1999/06/05 15:48:11	1.76
  +++ proxy_ftp.c	1999/08/08 11:45:19	1.77
  @@ -510,7 +510,7 @@
        */
       if ((password = ap_table_get(r->headers_in, "Authorization")) != NULL
   	&& strcasecmp(ap_getword(r->pool, &password, ' '), "Basic") == 0
  -	&& (password = ap_uudecode(r->pool, password))[0] != ':') {
  +	&& (password = ap_puudecode(r->pool, password))[0] != ':') {
   	/* Note that this allocation has to be made from r->connection->pool
   	 * because it has the lifetime of the connection.  The other allocations
   	 * are temporary and can be tossed away any time.
  
  
  
  1.27      +19 -57    apache-1.3/src/support/ab.c
  
  Index: ab.c
  ===================================================================
  RCS file: /x3/home/cvs/apache-1.3/src/support/ab.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ab.c	1999/07/19 07:19:43	1.26
  +++ ab.c	1999/08/08 11:45:20	1.27
  @@ -123,6 +123,7 @@
   #define ap_select       select
   #else				/* (!)NO_APACHE_INCLUDES */
   #include "ap_config.h"
  +#include "ap_base64.h"
   #ifdef CHARSET_EBCDIC
   #include "ebcdic.h"
   #endif
  @@ -238,56 +239,6 @@
       exit(errno);
   }
   
  -/* -- simple uuencode, lifted from main/util.c which
  - *    needed the pool, so duplicated here with normal
  - *    malloc.
  - */
  -static const char basis_64[] =
  -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  -
  -static char *uuencode(char *string)
  -{
  -    int i, len = strlen(string);
  -    char *p;
  -    char *encoded = (char *) malloc((len + 2) / 3 * 4 + 1);
  -    p = encoded;
  -#ifndef CHARSET_EBCDIC
  -    for (i = 0; i < len-2; i += 3) {
  -        *p++ = basis_64[(string[i] >> 2) & 0x3F];
  -        *p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] &
0xF0) >> 4)];
  -        *p++ = basis_64[((string[i + 1] & 0xF) << 2) | ((int) (string[i + 2]
& 0xC0) >> 6)];
  -        *p++ = basis_64[string[i + 2] & 0x3F];
  -    }
  -    if (i < len) {
  -        *p++ = basis_64[(string[i] >> 2) & 0x3F];
  -        *p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] &
0xF0) >> 4)];
  -        if (i == (len-2))
  -           *p++ = basis_64[((string[i + 1] & 0xF) << 2)];
  -        else
  -           *p++ = '=';
  -        *p++ = '=';
  -    }
  -#else /*CHARSET_EBCDIC*/
  -    for (i = 0; i < len-2; i += 3) {
  -        *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F];
  -        *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | ((int) (os_toascii[string[i
+ 1]] & 0xF0) >> 4)];
  -        *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2) | ((int) (os_toascii[string[i
+ 2]] & 0xC0) >> 6)];
  -        *p++ = basis_64[os_toascii[string[i + 2]] & 0x3F];
  -    }
  -    if (i < len) {
  -       *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F];
  -       *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | ((int) (os_toascii[string[i
+ 1]] & 0xF0) >> 4)];
  -       if (i == (len-2))
  -           *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2)];
  -       else
  -           *p++ = '=';
  -       *p++ = '=';
  -    }
  -#endif /*CHARSET_EBCDIC*/
  -    *p = '\0';
  -    return encoded;
  -}
  -
   /* --------------------------------------------------------- */
   
   /* write out request to a connection - assumes we can write
  @@ -1021,7 +972,8 @@
   /* sort out command-line args and call test */
   int main(int argc, char **argv)
   {
  -    int c, r;
  +    int c, r,l;
  +    char tmp[1024];
   
       /* table defaults  */
       tablestring = "";
  @@ -1064,25 +1016,35 @@
   	case 'T':
   	    strcpy(content_type, optarg);
   	    break;
  -	case 'C':
  +	case 'C': 
   	    strncat(cookie, "Cookie: ", sizeof(cookie));
   	    strncat(cookie, optarg, sizeof(cookie));
   	    strncat(cookie, "\r\n", sizeof(cookie));
   	    break;
  -	case 'A':
  -	    /*
  -	     * assume username passwd already to be in colon separated form.
  +	case 'A': 
  +	    /* assume username passwd already to be in colon separated form. Ready
  +	     * to be uu-encoded.
   	     */
  +	    while(isspace(*optarg))
  +		optarg++;
  +	    l=ap_uuencode(tmp,optarg,strlen(optarg));
  +	    tmp[l]='\0';
  +
   	    strncat(auth, "Authorization: basic ", sizeof(auth));
  -	    strncat(auth, uuencode(optarg), sizeof(auth));
  +	    strncat(auth, tmp, sizeof(auth));
   	    strncat(auth, "\r\n", sizeof(auth));
   	    break;
   	case 'P':
   	    /*
   	     * assume username passwd already to be in colon separated form.
   	     */
  +	    while(isspace(*optarg))
  +		optarg++;
  +	    l=ap_uuencode(tmp,optarg,strlen(optarg));
  +	    tmp[l]='\0';
  +
   	    strncat(auth, "Proxy-Authorization: basic ", sizeof(auth));
  -	    strncat(auth, uuencode(optarg), sizeof(auth));
  +	    strncat(auth, tmp, sizeof(auth));
   	    strncat(auth, "\r\n", sizeof(auth));
   	    break;
   	case 'H':
  
  
  

Mime
View raw message