Skip to content

Commit bbdab58

Browse files
committed
Merge branch 'code/hygiene'
* code/hygiene: hygiene, try and limit length of input to gperf'd __strpdt_special()
2 parents 2ebdf04 + 3f38fb1 commit bbdab58

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/dt-io.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,17 @@ serror(const char *fmt, ...)
7171

7272
#include "strpdt-special.c"
7373

74+
static inline __attribute__((const, pure)) size_t
75+
min_z(size_t z1, size_t z2)
76+
{
77+
return z1 <= z2 ? z1 : z2;
78+
}
79+
7480
dt_strpdt_special_t
7581
dt_io_strpdt_special(const char *str)
7682
{
77-
size_t len = strlen(str);
7883
const struct dt_strpdt_special_s *res;
84+
size_t len = min_z(strlen(str), 16U);
7985

8086
if (UNLIKELY((res = __strpdt_special(str, len)) != NULL)) {
8187
return res->e;

0 commit comments

Comments
 (0)