{
uint8 byte;
+ if (stream_get_left(s) < 1)
+ return false;
+
stream_read_uint8(s, byte);
if (byte & 0x80)
{
+ if (stream_get_left(s) < 1)
+ return false;
+
byte &= ~(0x80);
*length = (byte << 8);
stream_read_uint8(s, byte);
boolean per_read_choice(STREAM* s, uint8* choice)
{
+ if (stream_get_left(s) < 1)
+ return false;
+
stream_read_uint8(s, *choice);
return true;
}
boolean per_read_selection(STREAM* s, uint8* selection)
{
+ if (stream_get_left(s) < 1)
+ return false;
+
stream_read_uint8(s, *selection);
return true;
}
boolean per_read_number_of_sets(STREAM* s, uint8* number)
{
+ if (stream_get_left(s) < 1)
+ return false;
+
stream_read_uint8(s, *number);
return true;
}
boolean per_read_padding(STREAM* s, int length)
{
- stream_seek(s, length);
+ if (stream_get_left(s) < length)
+ return false;
+ stream_seek(s, length);
return true;
}
{
uint16 length;
- per_read_length(s, &length);
+ if (!per_read_length(s, &length))
+ return false;
+
+ if (stream_get_left(s) < length)
+ return false;
if (length == 1)
stream_read_uint8(s, *integer);
boolean per_read_integer16(STREAM* s, uint16* integer, uint16 min)
{
+ if (stream_get_left(s) < 2)
+ return false;
+
stream_read_uint16_be(s, *integer);
if (*integer + min > 0xFFFF)
boolean per_read_enumerated(STREAM* s, uint8* enumerated, uint8 count)
{
+ if (stream_get_left(s) < 1)
+ return false;
+
stream_read_uint8(s, *enumerated);
/* check that enumerated value falls within expected range */
uint16 length;
uint8 a_oid[6];
-
- per_read_length(s, &length); /* length */
+ if (!per_read_length(s, &length))
+ return false;
if (length != 5)
return false;
+ if (stream_get_left(s) < length)
+ return false;
+
stream_read_uint8(s, t12); /* first two tuples */
a_oid[0] = (t12 >> 4);
a_oid[1] = (t12 & 0x0F);
uint16 mlength;
uint8* a_oct_str;
- per_read_length(s, &mlength);
+ if (!per_read_length(s, &mlength))
+ return false;
if (mlength + min != length)
return false;
+ if (stream_get_left(s) < length)
+ return false;
+
a_oct_str = s->p;
stream_seek(s, length);
int length;
uint16 mlength;
- per_read_length(s, &mlength);
+ if (!per_read_length(s, &mlength))
+ return false;
length = (mlength + min + 1) / 2;
- stream_seek(s, length);
+ if (stream_get_left(s) < length)
+ return false;
+ stream_seek(s, length);
return true;
}