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;
46
46
static const uint8_t JPEG_SOI_MARKER [] = {0xFF , 0xD8 , 0xFF }; /* SOI = FF D8 FF */
47
47
#define JPEG_SOI_MARKER_LEN (3)
48
48
static const uint16_t JPEG_EOI_MARKER = 0xD9FF ; /* EOI = FF D9 */
49
+ #define JPEG_EOI_MARKER_LEN (2)
49
50
50
51
static int cam_verify_jpeg_soi (const uint8_t * inbuf , uint32_t length )
51
52
{
@@ -66,10 +67,14 @@ static int cam_verify_jpeg_soi(const uint8_t *inbuf, uint32_t length)
66
67
67
68
static int cam_verify_jpeg_eoi (const uint8_t * inbuf , uint32_t length )
68
69
{
70
+ if (length < JPEG_EOI_MARKER_LEN ) {
71
+ return -1 ;
72
+ }
73
+
69
74
int offset = -1 ;
70
- uint8_t * dptr = (uint8_t * )inbuf + length - 2 ;
75
+ uint8_t * dptr = (uint8_t * )inbuf + length - JPEG_EOI_MARKER_LEN ;
71
76
while (dptr > inbuf ) {
72
- if (memcmp (dptr , & JPEG_EOI_MARKER , 2 ) == 0 ) {
77
+ if (memcmp (dptr , & JPEG_EOI_MARKER , JPEG_EOI_MARKER_LEN ) == 0 ) {
73
78
offset = dptr - inbuf ;
74
79
//ESP_LOGW(TAG, "EOI: %d", length - (offset + 2));
75
80
return offset ;
You can’t perform that action at this time.
0 commit comments