Closed magicalfox007 closed 2 years ago
I never seen that for a YANG file, that parser is fairly static. Also, seems like a very old version. could be a version mis-match of some sort. Line 1 in a (formatted) yang file is also very early, usually just "module clixon-config{\n". One far-fetched explanation would be some escape character in the file, or possible mis-handling of \r from DOS newline formatting.
It turns out to be size-end problem. As below is code from clixon-4.2.0/lib/clixon_yang.c
yang_stmt* yang_parse_file(int fd,
const char* name,
yang_stmt* ysp)
{
char* buf = NULL;
int i;
int c; // type of c is int
int len;
yang_stmt* ymod = NULL;
int ret;
len = BUFLEN; /* any number is fine */
if ((buf = malloc(len)) == NULL)
{
perror("pt_file malloc");
return NULL;
}
memset(buf, 0, len);
i = 0; /* position in buf */
while (1) /* read the whole file */
{
if ((ret = read(fd, &c, 1)) < 0) // use c to get char
{
clicon_err(OE_XML, errno, "read");
break;
}
if (ret == 0)
{
break; /* eof */
}
if (len == i)
{
if ((buf = realloc(buf, 2 * len)) == NULL)
{
clicon_err(OE_XML, errno, "realloc");
goto done;
}
memset(buf + len, 0, len);
len *= 2;
}
buf[i++] = (char)(c & 0xff); // buf may fail to get correct value
} /* read a line */
In latest vesion,int i has been modified to char i
Does this mean this error only occurs in 4.2.0 and has been fixed in later versions, and there is a workaround by the type change patch? If so, can you please close this issue.
This error only occurs in 4.2.0 or other versions which includes "int c" statement in function "yang_parse_file". (e.g. still exists in 4.3.0) It has been fixed in latest version.
Anybody met this error when starting clixon_backend ?
developing based on clixon-4.2.0