Skip to content

Commit 6980afa

Browse files
committed
parser BUGFIX long identityref default value buffer overflow
STRING_OVERFLOW (CWE-120)
1 parent f6d684a commit 6980afa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/parser.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,10 @@ make_canonical(struct ly_ctx *ctx, int type, const char **value, void *data1, vo
10211021
module_name = (const char *)data1;
10221022
/* identity must always have a prefix */
10231023
if (!strchr(*value, ':')) {
1024+
LY_CHECK_ERR_RETURN(strlen(module_name) + 1 + strlen(*value) > buf_len, LOGBUF(*value), -1);
10241025
sprintf(buf, "%s:%s", module_name, *value);
10251026
} else {
1027+
LY_CHECK_ERR_RETURN(strlen(*value) > buf_len, LOGBUF(*value), -1);
10261028
strcpy(buf, *value);
10271029
}
10281030
break;

0 commit comments

Comments
 (0)