cvs commit: apachen/src/modules/standard mod_info.c

1998-01-02 Thread dgaudet
dgaudet 98/01/02 15:44:46

  Modified:.STATUS
   src  CHANGES
   src/modules/standard mod_info.c
  Log:
  - make mod_info_html_cmd_string() thread safe
  
  - fix minor buffer overrun in mod_info_html_cmd_string() (it would only
  hammer a \0 up to 5 bytes past the end of the buffer... nothing big)
  
  - mod_info_load_config() switched to use getword_conf() just like the real
  config parsing routines
  
  - replace a bunch of ap_snprintf()/rputs() pairs with rprintf() for more
  efficiency
  
  Reviewed by:  Brian Behlendorf
  
  Revision  ChangesPath
  1.45  +1 -4  apachen/STATUS
  
  Index: STATUS
  ===
  RCS file: /export/home/cvs/apachen/STATUS,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- STATUS1998/01/02 17:03:16 1.44
  +++ STATUS1998/01/02 23:44:42 1.45
  @@ -63,6 +63,7 @@
   * Jim's [PATCH] ap_cpystrn() function (replace strncpy) Take II
   * Dean's [PATCH] 1.3: "DoS" attack
   * Paul/Ben's [PATCH] 1.3: spaces in NT spawn* arguments
  +* Dean's [PATCH] mod_info minor cleanups (take 2)
   
   Available Patches:
   
  @@ -79,10 +80,6 @@
   * Dean's [PATCH] mod_status cleanups
<[EMAIL PROTECTED]>
Status: Dean +1, Jim +1
  -
  -* Dean's [PATCH] mod_info minor cleanups (take 2)
  - <[EMAIL PROTECTED]>
  - Status: Dean +1, Brian +1
   
   * Martin's [PATCH] 36kB: Make apache compile & run on an EBCDIC mainframe
<[EMAIL PROTECTED]>
  
  
  
  1.554 +3 -0  apachen/src/CHANGES
  
  Index: CHANGES
  ===
  RCS file: /export/home/cvs/apachen/src/CHANGES,v
  retrieving revision 1.553
  retrieving revision 1.554
  diff -u -r1.553 -r1.554
  --- CHANGES   1997/12/30 19:03:16 1.553
  +++ CHANGES   1998/01/02 23:44:43 1.554
  @@ -1,5 +1,8 @@
   Changes with Apache 1.3b4
   
  +  *) A few cleanups in mod_info to make it thread-safe, and remove an
  + off-by-5 bug that could hammer \0 on the stack. [Dean Gaudet]
  +
 *) no2slash() was O(n^2) in the length of the input.  Make it O(n).
[Dean Gaudet]
   
  
  
  
  1.32  +66 -105   apachen/src/modules/standard/mod_info.c
  
  Index: mod_info.c
  ===
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_info.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- mod_info.c1997/10/26 20:20:05 1.31
  +++ mod_info.c1998/01/02 23:44:45 1.32
  @@ -119,27 +119,27 @@
   return new;
   }
   
  -static char *mod_info_html_cmd_string(char *string)
  +static char *mod_info_html_cmd_string(const char *string, char *buf, size_t 
buf_len)
   {
  -char *s, *t;
  -static char ret[256];   /* What is the max size of a command? */
  -char *end_ret;
  +const char *s;
  +char *t;
  +char *end_buf;
   
  -ret[0] = '\0';
   s = string;
  -t = ret;
  -end_ret = t + sizeof(ret);
  -while ((*s) && ((t - ret) < sizeof(ret))) {
  +t = buf;
  +/* keep space for \0 byte */
  +end_buf = buf + buf_len - 1;
  +while ((*s) && (t < end_buf)) {
   if (*s == '<') {
  -strncpy(t, "<", end_ret - t);
  +strncpy(t, "<", end_buf - t);
   t += 4;
   }
   else if (*s == '>') {
  -strncpy(t, ">", end_ret - t);
  +strncpy(t, ">", end_buf - t);
   t += 4;
   }
   else if (*s == '&') {
  -strncpy(t, "&", end_ret - t);
  +strncpy(t, "&", end_buf - t);
   t += 5;
   }
   else {
  @@ -147,25 +147,33 @@
   }
   s++;
   }
  -*t = '\0';
  -return (ret);
  +/* oops, overflowed... don't overwrite */
  +if (t > end_buf) {
  + *end_buf = '\0';
  +}
  +else {
  + *t = '\0';
  +}
  +return (buf);
   }
   
  -static info_cfg_lines *mod_info_load_config(pool *p, char *filename,
  +static info_cfg_lines *mod_info_load_config(pool *p, const char *filename,
   request_rec *r)
   {
   char s[MAX_STRING_LEN];
   configfile_t *fp;
  -info_cfg_lines *new, *ret = NULL, *prev = NULL;
  -char *t, *tt, o, *msg;
  +info_cfg_lines *new, *ret, *prev;
  +const char *t;
   
   fp = pcfg_openfile(p, filename);
   if (!fp) {
  -msg = pstrcat(r->pool, "mod_info: couldn't open config file ",
  -  filename, NULL);
  -aplog_error(APLOG_MARK, APLOG_WARNING, r->server, msg);
  +aplog_error(APLOG_MARK, APLOG_WARNING, r->server, 
  + "mod_info: couldn't open config file %s",
  + filename);
   return NULL;
   }
  +ret = NULL;
  +prev = NULL;

cvs commit: apachen/src/modules/standard mod_info.c

1997-09-15 Thread Rodent of Unusual Size
coar97/09/15 04:57:06

  Modified:src  INDENT
   src/modules/example mod_example.c
   src/modules/standard mod_info.c
  Log:
GNU indent run across a couple of modules.  {Whew!}
  
  Revision  ChangesPath
  1.14  +3 -3  apachen/src/INDENT
  
  Index: INDENT
  ===
  RCS file: /export/home/cvs/apachen/src/INDENT,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- INDENT1997/09/14 22:49:48 1.13
  +++ INDENT1997/09/15 11:57:03 1.14
  @@ -47,7 +47,7 @@
  util_snprintf.c   DONE by Randy
   
   ./modules/example:
  -   mod_example.c RESERVED by Ken
  +   mod_example.c DONE by Ken
   
   ./modules/proxy:
  mod_proxy.c
  @@ -78,14 +78,14 @@
  mod_headers.c
  mod_imap.c
  mod_include.c
  -   mod_info.cRESERVED by Ken
  +   mod_info.cDONE by Ken
  mod_log_agent.c
  mod_log_config.c  RESERVED by Ken
  mod_log_referer.c
  mod_mime.c
  mod_mime.h
  mod_mime_magic.c
  -   mod_negotiation.c
  +   mod_negotiation.c RESERVED by Ken
  mod_rewrite.c
  mod_rewrite.h
  mod_setenvif.cRESERVED by Ken
  
  
  
  1.19  +79 -78apachen/src/modules/example/mod_example.c
  
  Index: mod_example.c
  ===
  RCS file: /export/home/cvs/apachen/src/modules/example/mod_example.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- mod_example.c 1997/09/01 02:53:48 1.18
  +++ mod_example.c 1997/09/15 11:57:05 1.19
  @@ -90,17 +90,18 @@
* are handed a record that applies to the current location by implication or
* inheritance, and modifying it will change the rules for other locations.
*/
  -typedef struct example_config {
  -int cmode;  /* Environment to which record applies (directory,  
*/
  -/* server, or combination). 
*/
  +typedef struct excfg {
  +int cmode;  /* Environment to which record applies 
(directory,
  + * server, or combination).
  + */
   #define CONFIG_MODE_SERVER 1
   #define CONFIG_MODE_DIRECTORY 2
  -#define CONFIG_MODE_COMBO 3  /* Shouldn't ever happen.  
*/
  -int local;  /* Boolean: was "Example" directive declared here?  
*/
  -int congenital; /* Boolean: did we inherit an "Example"?
*/
  -char *trace;/* Pointer to trace string. 
*/
  -char *loc;  /* Location to which this record applies.   
*/
  -} example_config;
  +#define CONFIG_MODE_COMBO 3 /* Shouldn't ever happen. */
  +int local;  /* Boolean: "Example" directive declared 
here? */
  +int congenital; /* Boolean: did we inherit an "Example"? */
  +char *trace;/* Pointer to trace string. */
  +char *loc;  /* Location to which this record applies. */
  +} excfg;
   
   /*
* Let's set up a module-local static cell to point to the accreting callback
  @@ -144,7 +145,7 @@
*
* static const char *handle_NO_ARGS(cmd_parms *cmd, void *mconfig);
*/
  - 
  +
   /*
* Command handler for a RAW_ARGS directive.  The "args" argument is the text
* of the commandline following the directive itself.
  @@ -246,31 +247,28 @@
   /*
* Locate our directory configuration record for the current request.
*/
  -static example_config *our_dconfig(request_rec *r)
  +static excfg *our_dconfig(request_rec *r)
   {
   
  -return (example_config *) get_module_config(r->per_dir_config,
  -&example_module);
  +return (excfg *) get_module_config(r->per_dir_config, &example_module);
   }
   
   /*
* Locate our server configuration record for the specified server.
*/
  -static example_config *our_sconfig(server_rec *s)
  +static excfg *our_sconfig(server_rec *s)
   {
   
  -return (example_config *) get_module_config(s->module_config,
  -&example_module);
  +return (excfg *) get_module_config(s->module_config, &example_module);
   }
   
   /*
* Likewise for our configuration record for the specified request.
*/
  -static example_config *our_rconfig(request_rec *r)
  +static excfg *our_rconfig(request_rec *r)
   {
   
  -return (example_config *) get_module_config(r->request_config,
  -&example_module);
  +return (excfg *) get_module_config(r->request_config, &example_module);
   }
   
   /*
  @@ -313,7 +311,7 @@
   
   #define TRACE_NOTE "example-trace"
   
  -static void trace_add(server_rec *s, requ

cvs commit: apachen/src/modules/standard mod_info.c

1997-09-12 Thread Rodent of Unusual Size
coar97/09/12 11:53:31

  Modified:src/modules/standard mod_info.c
  Log:
Add the missing request phases, add the configuration phases,
change "commands" to "directives"..
  
  Revision  ChangesPath
  1.28  +130 -82   apachen/src/modules/standard/mod_info.c
  
  Index: mod_info.c
  ===
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_info.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- mod_info.c1997/09/01 01:36:45 1.27
  +++ mod_info.c1997/09/12 18:53:30 1.28
  @@ -381,89 +381,137 @@
}
rputs("",r);
for(modp = top_module; modp; modp = modp->next) {
  - if(!r->args || !strcasecmp(modp->name,r->args)) {   
  - ap_snprintf(buf, sizeof(buf), "Module Name: %s\n",modp->name,modp->name);
  - rputs(buf,r);
  - rputs("Content-types 
affected:",r);
  - hand = modp->handlers;
  - if(hand) {
  - while(hand) {
  - if(hand->content_type) {
  - ap_snprintf(buf, 
sizeof(buf), " %s\n",hand->content_type); 
  - rputs(buf,r);
  - } else break;
  - hand++;
  - if(hand && hand->content_type) 
rputs(",",r);
  - }
  - } else {
  - rputs(" none",r);
  - }
  - rputs("Module Groups: 
\n",r);
  - if(modp->translate_handler) {
  - rputs("Translate Handler\n",r);
  - comma=1;
  - }
  - if(modp->check_user_id) {
  - if(comma) rputs(", ",r);
  - rputs("User ID Checking\n",r);
  - comma=1;
  - }
  - if(modp->auth_checker) {
  - if(comma) rputs(", ",r);
  - rputs("Authentication 
Checking\n",r);
  - comma=1;
  - }
  - if(modp->access_checker) {
  - if(comma) rputs(", ",r);
  - rputs("Access Checking\n",r);
  - comma=1;
  - }
  - if(modp->type_checker) {
  - if(comma) rputs(", ",r);
  - rputs("Type Checking\n",r);
  - comma=1;
  - }
  - if(modp->fixer_upper) {
  - if(comma) rputs(", ",r);
  - rputs("Header Fixer\n",r);
  - comma=1;
  - }
  - if(modp->logger) {
  - if(comma) rputs(", ",r);
  - rputs("Logging\n",r);
  - comma=1;
  - }
  - if(!comma) rputs(" none",r);
  - comma=0;
  - rputs("Module Configuration 
Commands: ",r);
  - cmd = modp->cmds;
  - if(cmd) {
  - while(cmd) {
  - if(cmd->name) {
  - ap_snprintf(buf, 
sizeof(buf), "%s - ",mod_info_html_cmd_string(cmd->name));  
  - rputs(buf,r);
  - if(cmd->errmsg) 
rputs(cmd->errmsg,r);
  - rputs("\n",r);
  - } else break;
  - cmd++;
  - }
  - rputs("Current 
Configuration:\n",r);
  - 
mod_info_module_cmds(r,mod_info_cfg_httpd,modp->cmds,"httpd.conf"); 
  - 
mod_info_module_cmds(r,mod_info_c

cvs commit: apachen/src/modules/standard mod_info.c

1997-08-31 Thread Randy Terbush
randy   97/08/31 18:36:47

  Modified:src/modules/standard mod_info.c
  Log:
  Convert log_*() to aplog_error().
  
  Revision  ChangesPath
  1.27  +1 -1  apachen/src/modules/standard/mod_info.c
  
  Index: mod_info.c
  ===
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_info.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- mod_info.c1997/08/31 13:30:52 1.26
  +++ mod_info.c1997/09/01 01:36:45 1.27
  @@ -163,7 +163,7 @@
filename,
NULL
);
  - log_error (msg, r->server);
  + aplog_error(APLOG_MARK, APLOG_ERR, r->server, msg);
return NULL;
}
while(!cfg_getline(s,MAX_STRING_LEN,fp)) {
  
  
  


cvs commit: apachen/src/modules/standard mod_info.c

1997-08-31 Thread Rodent of Unusual Size
coar97/08/31 06:30:53

  Modified:src/modules/example mod_example.c
   src/modules/standard mod_info.c
  Log:
Add the server build time to some other useful places.
  
  Revision  ChangesPath
  1.15  +6 -1  apachen/src/modules/example/mod_example.c
  
  Index: mod_example.c
  ===
  RCS file: /export/home/cvs/apachen/src/modules/example/mod_example.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- mod_example.c 1997/08/18 13:12:05 1.14
  +++ mod_example.c 1997/08/31 13:30:51 1.15
  @@ -548,6 +548,11 @@
   rputs ("  mod_example Module Content-Handler Output\n", 
r);
   rputs ("  \n", r);
   rputs ("  \n", r);
  +rprintf (r, "  Apache HTTP Server version: \"%s\"\n", SERVER_VERSION);
  +rputs ("  \n", r);
  +rprintf (r, "  Server built: \"%s\"\n", SERVER_BUILT);
  +rputs ("  \n", r);;
  +rputs ("  \n", r);
   rputs ("  The format for the callback trace is:\n", r);
   rputs ("  \n", r);
   rputs ("  \n", r);
  @@ -1190,5 +1195,5 @@
   example_hparser,/* [2] header parser */
   example_child_init, /* process initializer */
   example_child_exit,  /* process exit/cleanup */
  -example_post_readreq /* ? */
  +example_post_readreq /* [?] post read_request handling */
   };
  
  
  
  1.26  +2 -0  apachen/src/modules/standard/mod_info.c
  
  Index: mod_info.c
  ===
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_info.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- mod_info.c1997/08/18 13:12:13 1.25
  +++ mod_info.c1997/08/31 13:30:52 1.26
  @@ -350,6 +350,8 @@
if(!r->args || !strcasecmp(r->args,"server")) { 
ap_snprintf(buf, sizeof(buf), "Server Version: %s\n",SERVER_VERSION);
rputs(buf,r);
  + ap_snprintf(buf, sizeof(buf), "Server 
Built: %s\n",SERVER_BUILT);
  + rputs(buf,r);
ap_snprintf(buf, sizeof(buf), "API 
Version: %d\n",MODULE_MAGIC_NUMBER);
rputs(buf,r);
ap_snprintf(buf, sizeof(buf), "Run 
Mode: %s\n",standalone?"standalone":"inetd");