Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
8b67274c
Commit
8b67274c
authored
7 years ago
by
Alexander Alashkin
Committed by
Cesanta Bot
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mg_get_http_var retval
PUBLISHED_FROM=257deff5ea20302627e77a0f29cf2359276a41d4
parent
af22fb7a
master
dev
6.11
6.10
6.9
6.8
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
mg_get_http_var.md
docs/c-api/http_server.h/mg_get_http_var.md
+2
-1
mongoose.c
mongoose.c
+10
-2
mongoose.h
mongoose.h
+2
-1
No files found.
docs/c-api/http_server.h/mg_get_http_var.md
View file @
8b67274c
...
...
@@ -12,5 +12,6 @@ Fetches a HTTP form variable.
Fetches a variable
`name`
from a
`buf`
into a buffer specified by
`dst`
,
`dst_len`
. The destination is always zero-terminated. Returns the length of
a fetched variable. If not found, 0 is returned.
`buf`
must be valid
url-encoded buffer. If destination is too small,
`-1`
is returned.
url-encoded buffer. If destination is too small or an error occured,
negative number is returned.
This diff is collapsed.
Click to expand it.
mongoose.c
View file @
8b67274c
...
...
@@ -6492,6 +6492,13 @@ int mg_get_http_var(const struct mg_str *buf, const char *name, char *dst,
size_t
name_len
;
int
len
;
/*
* According to the documentation function returns negative
* value in case of error. For debug purposes it returns:
* -1 - src is wrong (NUUL)
* -2 - dst is wrong (NULL)
* -3 - failed to decode url or dst is to small
*/
if
(
dst
==
NULL
||
dst_len
==
0
)
{
len
=
-
2
;
}
else
if
(
buf
->
p
==
NULL
||
name
==
NULL
||
buf
->
len
==
0
)
{
...
...
@@ -6500,7 +6507,7 @@ int mg_get_http_var(const struct mg_str *buf, const char *name, char *dst,
}
else
{
name_len
=
strlen
(
name
);
e
=
buf
->
p
+
buf
->
len
;
len
=
-
1
;
len
=
0
;
dst
[
0
]
=
'\0'
;
for
(
p
=
buf
->
p
;
p
+
name_len
<
e
;
p
++
)
{
...
...
@@ -6512,8 +6519,9 @@ int mg_get_http_var(const struct mg_str *buf, const char *name, char *dst,
s
=
e
;
}
len
=
mg_url_decode
(
p
,
(
size_t
)(
s
-
p
),
dst
,
dst_len
,
1
);
/* -1 means: failed to decode or dst is too small */
if
(
len
==
-
1
)
{
len
=
-
2
;
len
=
-
3
;
}
break
;
}
...
...
This diff is collapsed.
Click to expand it.
mongoose.h
View file @
8b67274c
...
...
@@ -4516,7 +4516,8 @@ size_t mg_parse_multipart(const char *buf, size_t buf_len, char *var_name,
* Fetches a variable `name` from a `buf` into a buffer specified by `dst`,
* `dst_len`. The destination is always zero-terminated. Returns the length of
* a fetched variable. If not found, 0 is returned. `buf` must be valid
* url-encoded buffer. If destination is too small, `-1` is returned.
* url-encoded buffer. If destination is too small or an error occured,
* negative number is returned.
*/
int
mg_get_http_var
(
const
struct
mg_str
*
buf
,
const
char
*
name
,
char
*
dst
,
size_t
dst_len
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment