Skip to content

Commit

Permalink
dhcp4: set underflow in dnssearch when EOF unexpected
Browse files Browse the repository at this point in the history
  • Loading branch information
wipawel committed Jul 1, 2015
1 parent fd2d23f commit e6bb6f3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dhcp4/protocol.c
Expand Up @@ -1137,8 +1137,10 @@ ni_dhcp4_decode_dnssearch(ni_buffer_t *optbuf, ni_string_array_t *list, const ch
char label[64];
int length;

if ((length = ni_buffer_getc(bp)) == EOF)
if ((length = ni_buffer_getc(bp)) == EOF) {
bp->underflow = 1;
goto failure; /* unexpected EOF */
}

if (length == 0)
break; /* end of this name */
Expand All @@ -1158,8 +1160,10 @@ ni_dhcp4_decode_dnssearch(ni_buffer_t *optbuf, ni_string_array_t *list, const ch
case 0xC0:
/* Pointer */
pointer = (length & 0x3F) << 8;
if ((length = ni_buffer_getc(bp)) == EOF)
if ((length = ni_buffer_getc(bp)) == EOF) {
bp->underflow = 1;
goto failure;
}

pointer |= length;
if (pointer >= pos)
Expand Down

0 comments on commit e6bb6f3

Please sign in to comment.