Skip to content

Commit

Permalink
dnp3: regenerate object decoding code
Browse files Browse the repository at this point in the history
Ticket: OISF#4558
So as to avoid intra-structure overflow
  • Loading branch information
catenacyber authored and victorjulien committed Aug 23, 2021
1 parent 126a7dc commit 44bd316
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app-layer-dnp3-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -7153,6 +7153,9 @@ static int DNP3DecodeObjectG70V4(const uint8_t **buf, uint32_t *len,
if (!DNP3ReadUint8(buf, len, &object->status_code)) {
goto error;
}
if (prefix - (offset - *len) >= 255) {
goto error;
}
object->optional_text_len = prefix - (offset - *len);
if (object->optional_text_len > 0) {
if (*len < object->optional_text_len) {
Expand Down Expand Up @@ -7217,6 +7220,9 @@ static int DNP3DecodeObjectG70V5(const uint8_t **buf, uint32_t *len,
if (!DNP3ReadUint32(buf, len, &object->block_number)) {
goto error;
}
if (prefix - (offset - *len) >= 255) {
goto error;
}
object->file_data_len = prefix - (offset - *len);
if (object->file_data_len > 0) {
if (*len < object->file_data_len) {
Expand Down Expand Up @@ -7284,6 +7290,9 @@ static int DNP3DecodeObjectG70V6(const uint8_t **buf, uint32_t *len,
if (!DNP3ReadUint8(buf, len, &object->status_code)) {
goto error;
}
if (prefix - (offset - *len) >= 255) {
goto error;
}
object->optional_text_len = prefix - (offset - *len);
if (object->optional_text_len > 0) {
if (*len < object->optional_text_len) {
Expand Down Expand Up @@ -7413,6 +7422,9 @@ static int DNP3DecodeObjectG70V8(const uint8_t **buf, uint32_t *len,

offset = *len;

if (prefix - (offset - *len) >= 65535) {
goto error;
}
object->file_specification_len = prefix - (offset - *len);
if (object->file_specification_len > 0) {
if (*len < object->file_specification_len) {
Expand Down Expand Up @@ -8158,6 +8170,9 @@ static int DNP3DecodeObjectG120V7(const uint8_t **buf, uint32_t *len,
if (!DNP3ReadUint48(buf, len, &object->time_of_error)) {
goto error;
}
if (prefix - (offset - *len) >= 65535) {
goto error;
}
object->error_text_len = prefix - (offset - *len);
if (object->error_text_len > 0) {
if (*len < object->error_text_len) {
Expand Down

0 comments on commit 44bd316

Please sign in to comment.