mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Fix #19063: Add check in utility macro
This commit is contained in:
@@ -1111,6 +1111,9 @@ tor_digest256_is_zero(const char *digest)
|
||||
/* Were there unexpected unconverted characters? */ \
|
||||
if (!next && *endptr) \
|
||||
goto err; \
|
||||
/* Illogical (max, min) inputs? */ \
|
||||
if (max < min) \
|
||||
goto err; \
|
||||
/* Is r within limits? */ \
|
||||
if (r < min || r > max) \
|
||||
goto err; \
|
||||
|
||||
@@ -1501,6 +1501,11 @@ test_util_strmisc(void *arg)
|
||||
tt_int_op(-50L,OP_EQ, tor_parse_long("-50 plus garbage",10,-100,100,&i,&cp));
|
||||
tt_int_op(1,OP_EQ, i);
|
||||
tt_str_op(cp,OP_EQ, " plus garbage");
|
||||
/* Illogical min max */
|
||||
tt_int_op(0L,OP_EQ, tor_parse_long("10",10,50,4,&i,NULL));
|
||||
tt_int_op(0,OP_EQ, i);
|
||||
tt_int_op(0L,OP_EQ, tor_parse_long("-50",10,100,-100,&i,NULL));
|
||||
tt_int_op(0,OP_EQ, i);
|
||||
/* Out of bounds */
|
||||
tt_int_op(0L,OP_EQ, tor_parse_long("10",10,50,100,&i,NULL));
|
||||
tt_int_op(0,OP_EQ, i);
|
||||
|
||||
Reference in New Issue
Block a user