mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-16 00:00:07 +01:00
lws_hdr_copy: protect against garbage
This commit is contained in:
parent
793d8bfa13
commit
6ef69ad82e
1 changed files with 6 additions and 2 deletions
|
@ -570,11 +570,15 @@ LWS_VISIBLE int lws_hdr_copy(struct lws *wsi, char *dst, int len,
|
|||
return 0;
|
||||
|
||||
do {
|
||||
strcpy(dst,
|
||||
&wsi->u.hdr.ah->data[wsi->u.hdr.ah->frags[n].offset]);
|
||||
if (wsi->u.hdr.ah->frags[n].len >= len)
|
||||
return -1;
|
||||
strncpy(dst, &wsi->u.hdr.ah->data[wsi->u.hdr.ah->frags[n].offset],
|
||||
wsi->u.hdr.ah->frags[n].len);
|
||||
dst += wsi->u.hdr.ah->frags[n].len;
|
||||
len -= wsi->u.hdr.ah->frags[n].len;
|
||||
n = wsi->u.hdr.ah->frags[n].nfrag;
|
||||
} while (n);
|
||||
*dst = '\0';
|
||||
|
||||
return toklen;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue