File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ static cam_obj_t *cam_obj = NULL;
4646static const uint8_t JPEG_SOI_MARKER [] = {0xFF , 0xD8 , 0xFF }; /* SOI = FF D8 FF */
4747#define JPEG_SOI_MARKER_LEN (3)
4848static const uint16_t JPEG_EOI_MARKER = 0xD9FF ; /* EOI = FF D9 */
49+ #define JPEG_EOI_MARKER_LEN (2)
4950
5051static int cam_verify_jpeg_soi (const uint8_t * inbuf , uint32_t length )
5152{
@@ -66,10 +67,14 @@ static int cam_verify_jpeg_soi(const uint8_t *inbuf, uint32_t length)
6667
6768static int cam_verify_jpeg_eoi (const uint8_t * inbuf , uint32_t length )
6869{
70+ if (length < JPEG_EOI_MARKER_LEN ) {
71+ return -1 ;
72+ }
73+
6974 int offset = -1 ;
70- uint8_t * dptr = (uint8_t * )inbuf + length - 2 ;
75+ uint8_t * dptr = (uint8_t * )inbuf + length - JPEG_EOI_MARKER_LEN ;
7176 while (dptr > inbuf ) {
72- if (memcmp (dptr , & JPEG_EOI_MARKER , 2 ) == 0 ) {
77+ if (memcmp (dptr , & JPEG_EOI_MARKER , JPEG_EOI_MARKER_LEN ) == 0 ) {
7378 offset = dptr - inbuf ;
7479 //ESP_LOGW(TAG, "EOI: %d", length - (offset + 2));
7580 return offset ;
You can’t perform that action at this time.
0 commit comments