mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-24 14:05:05 +00:00
Backport from xs.
This commit is contained in:
parent
0337c71cf4
commit
aa82e14bc7
3 changed files with 5 additions and 4 deletions
3
xs.h
3
xs.h
|
@ -914,7 +914,8 @@ void *xs_memmem(const char *haystack, int h_size, const char *needle, int n_size
|
||||||
char *p, *r = NULL;
|
char *p, *r = NULL;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
while (!r && h_size - offset > n_size && (p = strchr(haystack + offset, *needle))) {
|
while (!r && h_size - offset > n_size &&
|
||||||
|
(p = memchr(haystack + offset, *needle, h_size - offset))) {
|
||||||
if (memcmp(p, needle, n_size) == 0)
|
if (memcmp(p, needle, n_size) == 0)
|
||||||
r = p;
|
r = p;
|
||||||
else
|
else
|
||||||
|
|
|
@ -131,13 +131,13 @@ d_char *_xs_multipart_form_data(char *payload, int p_size, char *header)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find the start of the part content */
|
/* find the start of the part content */
|
||||||
if ((p = xs_memmem(p, p_size - offset, "\r\n\r\n", 4)) == NULL)
|
if ((p = xs_memmem(p, p_size - (p - payload), "\r\n\r\n", 4)) == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
p += 4;
|
p += 4;
|
||||||
|
|
||||||
/* find the next boundary */
|
/* find the next boundary */
|
||||||
if ((q = xs_memmem(p, p_size - offset, boundary, bsz)) == NULL)
|
if ((q = xs_memmem(p, p_size - (p - payload), boundary, bsz)) == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
po = p - payload;
|
po = p - payload;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
/* 3aa82bc4fc310ec95194602bed88a9767e100350 */
|
/* d5a6108812a499a389030a1402ce49f282b4a818 */
|
||||||
|
|
Loading…
Reference in a new issue