mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-08 16:11:18 +00:00
Inspect POST buffer in mg_get_var() only if first call of get_var() returns -1
In mg_get_var() the first call of get_var() inspects the variables of the query string. If the requested variable is found but the destination buffer is too small to hold the variable, return -2 right away. If it's not found, make the second call of get_var() to inspect the POST buffer.
This commit is contained in:
1 parent
8a2aa72571
commit
eacd3f35e0
1 file changed
+1
-1
+1
-1
@@ -5043,7 +5043,7 @@ int mg_get_var(const struct mg_connection *conn, const char *name,
|
|||||||
char *dst, size_t dst_len) {
|
char *dst, size_t dst_len) {
|
||||||
int len = get_var(conn->query_string, conn->query_string == NULL ? 0 :
|
int len = get_var(conn->query_string, conn->query_string == NULL ? 0 :
|
||||||
strlen(conn->query_string), name, dst, dst_len);
|
strlen(conn->query_string), name, dst, dst_len);
|
||||||
if (len < 0) {
|
if (len == -1) {
|
||||||
len = get_var(conn->content, conn->content_len, name, dst, dst_len);
|
len = get_var(conn->content, conn->content_len, name, dst, dst_len);
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
|
|||||||
Reference in new issue
Block a user