@@ -109,8 +109,11 @@ bool receiveJspr(jsprResponse_t * response, const char * expectedTarget)
109109 targetStart = & jsprRxBuffer [JSPR_RESULT_CODE_LENGTH + 1 ];
110110 targetEnd = strchr (targetStart , ' ' );
111111 targetLength = targetEnd - targetStart ;
112- memcpy (response -> target , targetStart , targetLength );
113- response -> target [targetLength ] = '\0' ;
112+ if (targetLength < JSPR_MAX_TARGET_LENGTH )
113+ {
114+ memcpy (response -> target , targetStart , targetLength );
115+ response -> target [targetLength ] = '\0' ;
116+ }
114117
115118 if (expectedTarget != NULL )
116119 {
@@ -125,8 +128,11 @@ bool receiveJspr(jsprResponse_t * response, const char * expectedTarget)
125128
126129 jsonStart = strchr (targetStart , '{' );
127130 response -> jsonSize = strchr (targetStart , '\0' ) - jsonStart ;
128- strncpy (response -> json , jsonStart , response -> jsonSize );
129- response -> json [response -> jsonSize ] = '\0' ;
131+ if (response -> jsonSize < JSPR_MAX_JSON_LENGTH )
132+ {
133+ strncpy (response -> json , jsonStart , response -> jsonSize );
134+ response -> json [response -> jsonSize ] = '\0' ;
135+ }
130136 reading = false;
131137 gotResponse = true;
132138 received = true;
0 commit comments