Skip to content

Commit 549f939

Browse files
committed
path BUGFIX do not allow fractions as position
1 parent 87409e0 commit 549f939

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/path.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ ly_path_check_predicate(const struct ly_ctx *ctx, const struct lysc_node *cur_no
5555
struct ly_set *set = NULL;
5656
uint32_t i;
5757
const char *name;
58+
char *start, *end;
5859
size_t name_len;
5960

6061
if (cur_node) {
@@ -152,10 +153,11 @@ ly_path_check_predicate(const struct ly_ctx *ctx, const struct lysc_node *cur_no
152153
} else if ((pred == LY_PATH_PRED_SIMPLE) && !lyxp_next_token(NULL, exp, tok_idx, LYXP_TOKEN_NUMBER)) {
153154
/* Number */
154155

155-
/* check for index 0 */
156-
if (!atoi(exp->expr + exp->tok_pos[*tok_idx - 1])) {
156+
/* check for index 0 or fractions */
157+
start = exp->expr + exp->tok_pos[*tok_idx - 1];
158+
if (!strtol(start, &end, 10) || (end - start != exp->tok_len[*tok_idx - 1])) {
157159
LOGVAL(ctx, NULL, LYVE_XPATH, "Invalid positional predicate \"%.*s\".", (int)exp->tok_len[*tok_idx - 1],
158-
exp->expr + exp->tok_pos[*tok_idx - 1]);
160+
start);
159161
goto token_error;
160162
}
161163

0 commit comments

Comments
 (0)