Mailing List Archive



Back to the month index Back to the list index

Matthias Suencksen (msuencks@TechFak.Uni-Bielefeld.DE)
Mon, 14 Apr 1997 13:06:48 +0200


Message-Id: <33520FC8.1CC0DC58@techfak.uni-bielefeld.de>
Date: Mon, 14 Apr 1997 13:06:48 +0200
From: Matthias Suencksen <msuencks@TechFak.Uni-Bielefeld.DE>
Subject: [mSQL] CGI parameter lenght limit (& patch)

I just wondered about the length limits of CGI variables und values.

>From w-3msql.c I see:

variables 30 bytes
values 5 Kbytes

My question is:
Is it enough to change these values if I want *more* or
do I have to change other source files, too?

As the violaton of these limits makes w3-msql die, please
enjoy the following patch (to Beta 6) which lets w3-msql
produce an error message in that case.

I tested it by setting the limits to 7 bytes
in w3-msql.c. I apologize if I break anything with it!

regards

Matthias Suencksen

--- w3-msql.c Mon Apr 7 13:25:46 1997
+++ w3-msql.c.new Mon Apr 14 12:58:49 1997
@@ -137,7 +137,10 @@
         char *query;
         int source;
 {
- char *cp1,
+ char *current_limit;
+ char error_msg[64];
+
+ char *cp1,
                 *cp2,
                 var[30],
                 val[5 * 1024];
@@ -154,12 +157,15 @@
         bzero(var,sizeof(var));
         bzero(val,sizeof(val));
         *cp2++ = '$';
+ current_limit=var+sizeof(var);
+
         while(*cp1)
         {
                 if (*cp1 == '=')
                 {
                         cp1++;
                         cp2 = val;
+ current_limit=val+sizeof(val);
                         continue;
                 }
                 if (*cp1 == '&')
@@ -193,9 +199,25 @@
                         cp1++;
                         cp2 = var;
                         *cp2++ = '$';
+ current_limit=var+sizeof(var) ;
                         continue;
                 }
- *cp2++ = *cp1++;
+ *cp2++ = *cp1++;
+
+ if (cp2>current_limit)
+ {
+ if (current_limit==(var+sizeof(var)))
+ {
+ sprintf(error_msg, "symbolname exceeds %d bytes", sizeof(val));
+ runError(error_msg);
+ }
+ else
+ {
+ sprintf(error_msg, "value for %s exceeds %d bytes", strdup(var), sizeof(var));
+ runError(error_msg);
+ }
+ exit(0);
+ }
         }
         sym = symGetSymbol(var);
         if (sym)

--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com. Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!