File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ uint8_t Packet::writeTo(uint8_t dest[]) const {
5757 memcpy (&dest[i], &transport_codes[1 ], 2 ); i += 2 ;
5858 }
5959 dest[i++] = path_len;
60- memcpy (&dest[i], path, path_len); i += path_len ;
60+ i += writePath (&dest[i], path, path_len);
6161 memcpy (&dest[i], payload, payload_len); i += payload_len;
6262 return i;
6363}
@@ -72,8 +72,11 @@ bool Packet::readFrom(const uint8_t src[], uint8_t len) {
7272 transport_codes[0 ] = transport_codes[1 ] = 0 ;
7373 }
7474 path_len = src[i++];
75- if (path_len > sizeof (path)) return false ; // bad encoding
76- memcpy (path, &src[i], path_len); i += path_len;
75+ if (!isValidPathLen (path_len)) return false ; // bad encoding
76+
77+ uint8_t bl = getPathByteLen ();
78+ memcpy (path, &src[i], bl); i += bl;
79+
7780 if (i >= len) return false ; // bad encoding
7881 payload_len = len - i;
7982 if (payload_len > sizeof (payload)) return false ; // bad encoding
You can’t perform that action at this time.
0 commit comments