span_log(&s->logging, SPAN_LOG_FLOW, "Partial page OK - committing block %d, %d frames\n", s->ecm_block, s->ecm_frames);
for (i = 0; i < s->ecm_frames; i++)
{
- if (t4_rx_put(&s->t4.rx, s->ecm_data[i], s->ecm_len[i]))
+ if (t4_rx_put(&s->t4.rx, s->ecm_data[i], s->ecm_len[i]) != T4_DECODE_MORE_DATA)
{
/* This is the end of the document */
break;
break;
case T30_STATE_F_DOC_NON_ECM:
/* Document transfer */
- if (t4_rx_put_bit(&s->t4.rx, bit) == T4_DECODE_OK)
+ if (t4_rx_put_bit(&s->t4.rx, bit) != T4_DECODE_MORE_DATA)
{
/* That is the end of the document */
set_state(s, T30_STATE_F_POST_DOC_NON_ECM);
break;
case T30_STATE_F_DOC_NON_ECM:
/* Document transfer */
- if (t4_rx_put(&s->t4.rx, buf, len))
+ if (t4_rx_put(&s->t4.rx, buf, len) != T4_DECODE_MORE_DATA)
{
/* That is the end of the document */
set_state(s, T30_STATE_F_POST_DOC_NON_ECM);
#endif
{
span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. Fixed bytes do not contain expected values.\n");
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
}
/* P - Number of bit planes */
if (s->buffer[2] < s->min_bit_planes || s->buffer[2] > s->max_bit_planes)
{
span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. %d bit planes. Should be %d to %d.\n", s->buffer[2], s->min_bit_planes, s->max_bit_planes);
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
}
s->bit_planes = s->buffer[2];
if (s->xd == 0 || (s->max_xd && s->xd > s->max_xd))
{
span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. Width is %" PRIu32 "\n", s->xd);
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
}
/* YD - Vertical image size at layer D */
if (s->yd == 0 || (s->max_yd && s->yd > s->max_yd))
{
span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. Length is %" PRIu32 "\n", s->yd);
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
}
/* L0 - Rows per stripe, at the lowest resolution */
if (s->l0 == 0)
{
span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. L0 is %" PRIu32 "\n", s->l0);
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
}
/* MX - Maximum horizontal offset allowed for AT pixel */
if (s->mx > 127)
{
span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. MX is %d\n", s->mx);
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
}
/* Options byte */
if ((s->options & 0x97))
{
span_log(&s->logging, SPAN_LOG_FLOW, "BIH invalid. Options are 0x%X\n", s->options);
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
}
span_log(&s->logging, SPAN_LOG_FLOW, "BIH is OK. Image is %" PRIu32 "x%" PRIu32 " pixels\n", s->xd, s->yd);
{
if (s->y >= s->yd)
return T4_DECODE_OK;
+ if (s->end_of_data > 0)
+ return T4_DECODE_INVALID_DATA;
/* This is the end of image condition */
s->end_of_data = 1;
}
the commonest thing for us to hit here. */
decode_pscd(s, s->buffer, 2);
s->buf_len = 0;
-
if (s->interrupt)
return T4_DECODE_INTERRUPT;
break;
continue;
s->buf_needed = 2;
s->buf_len = 0;
-
if (s->at_moves >= T85_ATMOVES_MAX)
+ {
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
+ }
s->at_row[s->at_moves] = pack_32(&s->buffer[2]);
s->at_tx[s->at_moves] = s->buffer[6];
if (s->at_tx[s->at_moves] > s->mx
||
s->buffer[7] != 0)
{
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
}
s->at_moves++;
continue;
s->buf_needed = 2;
s->buf_len = 0;
-
if (!(s->options & T85_VLENGTH))
+ {
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
+ }
s->options &= ~T85_VLENGTH;
y = pack_32(&s->buffer[2]);
/* An update to the image length is not allowed to stretch it. */
if (y > s->yd)
+ {
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
+ }
s->yd = y;
break;
case T82_SDNORM:
y = pack_32(&s->buffer[4]);
/* An update to the image length is not allowed to stretch it. */
if (y > s->yd)
+ {
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
+ }
/* Things look OK, so accept this new length, and proceed. */
s->yd = y;
/* Now process the T82_SDNORM or T82_SDRST */
break;
default:
s->buf_len = 0;
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
}
}
/* We should only have stopped processing PSCD if
we ran out of data, or hit a T82_ESC */
if (cnt < len && data[cnt] != T82_ESC)
+ {
+ s->end_of_data = 2;
return T4_DECODE_INVALID_DATA;
+ }
}
}
-
return T4_DECODE_MORE_DATA;
}
/*- End of function --------------------------------------------------------*/