perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: modperl-2.0/xs/APR/Bucket APR__Bucket.h
Date Fri, 21 May 2004 18:35:23 GMT
stas        2004/05/21 11:35:23

  Modified:    xs/APR/Bucket APR__Bucket.h
  Log:
  - read now returns data and throws exceptions
  - make sure that the offset/len are in boundary
  
  Revision  Changes    Path
  1.7       +30 -23    modperl-2.0/xs/APR/Bucket/APR__Bucket.h
  
  Index: APR__Bucket.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/APR/Bucket/APR__Bucket.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- APR__Bucket.h	4 Mar 2004 06:01:09 -0000	1.6
  +++ APR__Bucket.h	21 May 2004 18:35:23 -0000	1.7
  @@ -18,40 +18,47 @@
   static apr_bucket *mpxs_APR__Bucket_new(pTHX_ SV *classname, SV *sv,
                                           int offset, int len)
   {
  -    if (!len) {
  -        (void)SvPV(sv, len);
  -    }
   
  -    return modperl_bucket_sv_create(aTHX_ sv, offset, len);
  -}
  +    int full_len;
  +    (void)SvPV(sv, full_len);
   
  -/* this is just so C::Scan will pickup the prototype */
  -static MP_INLINE apr_status_t modperl_bucket_read(apr_bucket *bucket,
  -                                                  const char **str,
  -                                                  apr_size_t *len,
  -                                                  apr_read_type_e block)
  -{
  -    return apr_bucket_read(bucket, str, len, block);
  +    if (len) {
  +        if (len > full_len - offset) {
  +            Perl_croak(aTHX_ "APR::Bucket::new: the length argument can't be"
  +                       " bigger than the total buffer length minus offset");
  +        }
  +    }
  +    else {
  +        len = full_len - offset;
  +    }
  +    
  +    return modperl_bucket_sv_create(aTHX_ sv, offset, len);
   }
   
  -static MP_INLINE apr_status_t mpxs_modperl_bucket_read(pTHX_
  -                                                       apr_bucket *bucket,
  -                                                       SV *buffer,
  -                                                       apr_read_type_e block)
  +static MP_INLINE SV *mpxs_APR__Bucket_read(pTHX_
  +                                           apr_bucket *bucket,
  +                                           apr_read_type_e block)
   {
  -    int rc;
  +    SV *buf;
       apr_size_t len;
       const char *str;
  +    apr_status_t rc = apr_bucket_read(bucket, &str, &len, block);
  +    
  +    if (rc == APR_EOF) {
  +        return newSVpvn("", 0);
  +    }
   
  -    rc = modperl_bucket_read(bucket, &str, &len, block);
  -
  -    if ((rc != APR_SUCCESS) && (rc != APR_EOF)) {
  -        /* XXX: croak ? */
  +    if (rc != APR_SUCCESS) {
  +        modperl_croak(aTHX_ rc, "APR::Bucket::read");  
       }
   
  -    sv_setpvn(buffer, str, len);
  +    buf = newSVpvn(str, len);
   
  -    return rc;
  +    /* XXX: must be on, but utf8::decode fails to parse it as UTF-8
  +     * flag in 5.8.4 if the input is utf8 */
  +    //SvTAINTED_on(buf);
  +    
  +    return buf;
   }
   
   static MP_INLINE int mpxs_APR__Bucket_is_eos(apr_bucket *bucket)
  
  
  

Mime
View raw message