httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grega...@apache.org
Subject cvs commit: httpd-2.0/server protocol.c
Date Thu, 07 Mar 2002 22:08:46 GMT
gregames    02/03/07 14:08:46

  Modified:    include  http_protocol.h
               server   protocol.c
  Log:
  ap_rgetline: fix folding and partial line handling on ebcdic boxes.  The
  normal case worked OK, but due to the recursion and multiple exit points,
  input bytes could go thru charset translation multiple times or not at all.
  
  Suggested by: Justin Erenkrantz
  
  Revision  Changes    Path
  1.69      +18 -2     httpd-2.0/include/http_protocol.h
  
  Index: http_protocol.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/http_protocol.h,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- http_protocol.h	24 Jan 2002 23:59:51 -0000	1.68
  +++ http_protocol.h	7 Mar 2002 22:08:46 -0000	1.69
  @@ -541,6 +541,14 @@
   
   /**
    * Get the next line of input for the request
  + *
  + * Note: on ASCII boxes, ap_rgetline is a macro which simply calls 
  + *       ap_rgetline_core to get the line of input.
  + * 
  + *       on EBCDIC boxes, ap_rgetline is a wrapper function which
  + *       translates ASCII protocol lines to the local EBCDIC code page
  + *       after getting the line of input.
  + *       
    * @param s Pointer to the pointer to the buffer into which the line
    *          should be read; if *s==NULL, a buffer of the necessary size
    *          to hold the data will be allocated from the request pool
  @@ -552,9 +560,17 @@
    *         APR_ENOSPC, if the line is too big to fit in the buffer
    *         Other errors where appropriate
    */
  -AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n, apr_size_t *read,
  +#if APR_CHARSET_EBCDIC
  +AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n, 
  +                                     apr_size_t *read,
                                        request_rec *r, int fold);
  -
  +#else /* ASCII box */
  +#define ap_rgetline(s, n, read, r, fold) \
  +        ap_rgetline_core((s), (n), (read), (r), (fold))
  +#endif
  +AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, 
  +                                          apr_size_t *read,
  +                                          request_rec *r, int fold);
   /**
    * Get the method number associated with the given string, assumed to
    * contain an HTTP method.  Returns M_INVALID if not recognized.
  
  
  
  1.89      +29 -8     httpd-2.0/server/protocol.c
  
  Index: protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/protocol.c,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- protocol.c	7 Mar 2002 02:09:30 -0000	1.88
  +++ protocol.c	7 Mar 2002 22:08:46 -0000	1.89
  @@ -187,7 +187,7 @@
    * caused by MIME folding (or broken clients) if fold != 0, and place it
    * in the buffer s, of size n bytes, without the ending newline.
    *
  - * If s is NULL, ap_rgetline will allocate necessary memory from r->pool.
  + * If s is NULL, ap_rgetline_core will allocate necessary memory from r->pool.
    *
    * Returns APR_SUCCESS if there are no problems and sets *read to be
    * the full length of s.
  @@ -204,9 +204,9 @@
    *        If no LF is detected on the last line due to a dropped connection 
    *        or a full buffer, that's considered an error.
    */
  -AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n, 
  -                                     apr_size_t *read, request_rec *r, 
  -                                     int fold)
  +AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, 
  +                                          apr_size_t *read, request_rec *r, 
  +                                          int fold)
   {
       apr_status_t rv;
       apr_bucket_brigade *b;
  @@ -323,7 +323,7 @@
   
               next_size = n - bytes_handled;
   
  -            rv = ap_rgetline(&tmp, next_size, &next_len, r, fold);
  +            rv = ap_rgetline_core(&tmp, next_size, &next_len, r, fold);
   
               if (rv != APR_SUCCESS) {
                   return rv;
  @@ -456,7 +456,7 @@
   
                   next_size = n - bytes_handled;
   
  -                rv = ap_rgetline(&tmp, next_size, &next_len, r, fold);
  +                rv = ap_rgetline_core(&tmp, next_size, &next_len, r, fold);
   
                   if (rv != APR_SUCCESS) {
                       return rv;
  @@ -483,11 +483,32 @@
           }
       }
   
  -    /* FIXME: Can we optimize this at all by placing it a different layer? */
  -    ap_xlate_proto_from_ascii(*s, bytes_handled);
       *read = bytes_handled;
       return APR_SUCCESS;
   }
  + 
  +#if APR_CHARSET_EBCDIC
  +AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n,
  +                                     apr_size_t *read, request_rec *r,
  +                                     int fold)
  +{
  +    /* on ASCII boxes, ap_rgetline is a macro which simply invokes 
  +     * ap_rgetline_core with the same parms
  +     *
  +     * on EBCDIC boxes, each complete http protocol input line needs to be
  +     * translated into the code page used by the compiler.  Since 
  +     * ap_rgetline_core uses recursion, we do the translation in a wrapper
  +     * function to insure that each input character gets translated only once.
  +     */
  +    apr_status_t rv;
  +
  +    rv = ap_rgetline_core(s, n, read, r, fold);
  +    if (rv == APR_SUCCESS) {
  +        ap_xlate_proto_from_ascii(*s, *read);
  +    }
  +    return rv;
  +}
  +#endif
   
   AP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int fold)
   {
  
  
  

Mime
View raw message