@@ -67,13 +67,12 @@ static really_inline int32_t parse_text(
67
67
{ { { "", 0 }, code }, 0, false, false, { 0, NULL }, check_generic_rr, parse_unknown_rdata }
68
68
69
69
#if _WIN32
70
- // FIXME: actually, for all the check functions, an int32_t will more than suffice
70
+ // FIXME: check functions can be simplified as int32_t is wide enough to
71
+ // represent errors and the maximum length of rdata.
71
72
#include <basetsd.h>
72
73
typedef SSIZE_T ssize_t ;
73
74
#endif
74
75
75
- // FIXME: check functions can be simplified as int32_t is wide enough to
76
- // represent errors and the maximum length of rdata.
77
76
nonnull ((1 ,2 ,3 ,4 ))
78
77
static really_inline ssize_t check_bytes (
79
78
parser_t * parser ,
@@ -170,15 +169,15 @@ static really_inline ssize_t check_nsec(
170
169
const size_t length )
171
170
{
172
171
size_t count = 0 ;
173
- size_t last_window = 0 ;
172
+ int32_t last_window = -1 ;
174
173
175
174
while ((count + 2 ) < length ) {
176
- const size_t window = (size_t )data [0 ];
175
+ const int32_t window = (int32_t )data [0 ];
177
176
const size_t blocks = (size_t )data [1 ];
178
- if (window < last_window || ! window != ! last_window )
177
+ if (window <= last_window )
179
178
SYNTAX_ERROR (parser , "Invalid %s in %s, windows are out-of-order" ,
180
179
NAME (field ), NAME (type ));
181
- if (blocks > 32 )
180
+ if (! blocks || blocks > 32 )
182
181
SYNTAX_ERROR (parser , "Invalid %s in %s, blocks are out-of-bounds" ,
183
182
NAME (field ), NAME (type ));
184
183
count += 2 + blocks ;
0 commit comments