File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ bool needsEncode(char c) {
2424void encode (const char * src, uint16_t len, String& dest) {
2525 if (!len) len = strlen (src);
2626 dest.reserve (len);
27- while (*src) {
27+ const char * end = src + len;
28+ while (src < end) {
2829 char c = *src++;
2930 if (needsEncode (c)) {
3031 dest += ' %' ;
@@ -56,14 +57,15 @@ static uint8_t _decodeNibble(char c) {
5657void decode (const char * src, uint16_t len, String& dest) {
5758 if (!len) len = strlen (src);
5859 dest.reserve (len);
59- while (*src) {
60+ const char * end = src + len;
61+ while (src < end) {
6062 char c = *src++;
6163 if (c != ' %' ) {
6264 dest += (c == ' +' ) ? ' ' : c;
6365 } else {
6466 char c1 = *src++;
6567 char c2 = *src++;
66- if (!c1 || !c2) return ;
68+ if (!c1 || !c2 || src >= end ) return ;
6769 dest += char (_decodeNibble (c2) | (_decodeNibble (c1) << 4 ));
6870 }
6971 }
You can’t perform that action at this time.
0 commit comments