aboutsummaryrefslogtreecommitdiffstats
path: root/package/uhttpd/src/uhttpd.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-05-03 17:19:18 +0000
committerJo-Philipp Wich <jow@openwrt.org>2016-03-20 20:05:13 +0100
commitbcd8d530d10127ce0be796fe7ef42944c47d4485 (patch)
tree492755de150d19a234532e846c1d30d6a39e7031 /package/uhttpd/src/uhttpd.c
parent2bfb1e012abca1dbb3797bc5e72e2af3ee741dec (diff)
downloadupstream-bcd8d530d10127ce0be796fe7ef42944c47d4485.tar.gz
upstream-bcd8d530d10127ce0be796fe7ef42944c47d4485.tar.bz2
upstream-bcd8d530d10127ce0be796fe7ef42944c47d4485.zip
Fixed: [PATCH 2/3] uhttpd URL-codec enhancements.
My apologies, the 2nd of those patches had a syntax error -- that's what I get for making a last-minute edit, even to the comments, without testing! :-p Here is the corrected patch. -- David From d259cff104d2084455476b82e92a3a27524f4263 Mon Sep 17 00:00:00 2001 From: David Favro <openwrt@meta-dynamic.com> Date: Fri, 27 Apr 2012 14:17:52 -0400 Subject: [PATCH] uhttpd URL-codec enhancements. * uh_urlencode() and uh_urldecode() now return an error condition for buffer-overflow and malformed-encoding rather than normal return with corrupt or truncated data. As HTTP request processing is currently implemented, this causes a 404 HTTP status returned to the client, while 400 is more appropriate. * Exposed urlencode() to Lua. * Lua's uhttpd.urlencode() and .urldecode() now raise an error condition for buffer-overflow and malformed-encoding rather than normal return with incorrect data. SVN-Revision: 31570
Diffstat (limited to 'package/uhttpd/src/uhttpd.c')
-rw-r--r--package/uhttpd/src/uhttpd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/package/uhttpd/src/uhttpd.c b/package/uhttpd/src/uhttpd.c
index 9b9608628d..5d66e23a50 100644
--- a/package/uhttpd/src/uhttpd.c
+++ b/package/uhttpd/src/uhttpd.c
@@ -948,9 +948,10 @@ int main (int argc, char **argv)
for (opt = 0; optarg[opt]; opt++)
if (optarg[opt] == '+')
optarg[opt] = ' ';
-
- memset(port, 0, strlen(optarg)+1);
- uh_urldecode(port, strlen(optarg), optarg, strlen(optarg));
+ /* opt now contains strlen(optarg) -- no need to re-scan */
+ memset(port, 0, opt+1);
+ if (uh_urldecode(port, opt, optarg, opt) < 0)
+ fprintf( stderr, "uhttpd: invalid encoding\n" );
printf("%s", port);
free(port);