Skip to content

Commit c221e84

Browse files
committed
xpath BUGFIX forbid xpaths longer than 65k characters
Fixes #616
1 parent d1c5d93 commit c221e84

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/xpath.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <ctype.h>
2121
#include <stdio.h>
2222
#include <stdlib.h>
23+
#include <stdint.h>
2324
#include <string.h>
2425
#include <assert.h>
2526
#include <limits.h>
@@ -2506,6 +2507,11 @@ lyxp_parse_expr(struct ly_ctx *ctx, const char *expr)
25062507
enum lyxp_token tok_type;
25072508
int prev_function_check = 0;
25082509

2510+
if (strlen(expr) > UINT16_MAX) {
2511+
LOGERR(ctx, LY_EINVAL, "XPath expression cannot be longer than %ud characters.", UINT16_MAX);
2512+
return NULL;
2513+
}
2514+
25092515
/* init lyxp_expr structure */
25102516
ret = calloc(1, sizeof *ret);
25112517
LY_CHECK_ERR_GOTO(!ret, LOGMEM(ctx), error);

0 commit comments

Comments
 (0)