httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@gonzo.ben.algroup.co.uk>
Subject Re: rprintf lives
Date Thu, 16 May 1996 16:05:47 GMT
Randy Terbush wrote:
> 
> I took a stab at reimplementing rprintf() in hopes to eliminate some
> of the incompatibility with older modules. Here's a patch relative
> to current source.  If this does not get shot down, could someone
> please commit it?

The reason rprintf has not been implemented in this way is the security risk
associated with the fixed length buffer. In the old scheme of things it
translated to an fprintf, which has no such problem. This is why there was all
the talk of nabbing someone's printf code to incorporate.

Cheers,

Ben.

> 
> 
> *** http_protocol.h.orig	Thu May 16 11:18:01 1996
> --- http_protocol.h	Thu May 16 11:06:10 1996
> ***************
> *** 104,112 ****
>    * definitions of the macros would get a whole lot hairier.
>    */
>        
> - #if 0
>   long rprintf (request_rec *r, char *s, ...);     
> - #endif
>   int rputc (int c, request_rec *r);     
>   extern int rputs(const char *str, request_rec *r);
>   extern int rvputs(request_rec *r, ...);
> --- 104,110 ----
> *** http_protocol.c.orig	Thu May 16 10:24:47 1996
> --- http_protocol.c	Thu May 16 11:20:31 1996
> ***************
> *** 776,781 ****
> --- 776,808 ----
>       return k;
>   }
>   
> + long
> + rprintf (request_rec *r, char *fmt, ...)
> + {
> +     va_list args;
> +     int i, retval;
> +     char buf[MAX_STRING_LEN];
> +     BUFF *fb = r->connection->client;
> +     
> +     if (r->connection->aborted) return EOF;
> +     
> +     va_start (args, fmt);
> +     retval = vsnprintf (buf, MAX_STRING_LEN, fmt, args);
> +     
> +     if (retval > 0)
> +     {
> + 	i = bwrite(fb, buf, retval);
> + 	if (i != retval)
> + 	{
> + 	    va_end(args);
> + 	    return -1;
> + 	}
> +     }
> +     va_end (args);
> + 
> +     return (retval);
> + }
> + 
>   void send_error_response (request_rec *r, int recursive_error)
>   {
>       conn_rec *c = r->connection;
> 
> 
> 

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant and    Fax:   +44 (181) 994 6472
Technical Director          Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.

Mime
View raw message