Open maska989 opened 1 year ago
This happens because the parser for scanf
, fscanf
, vscanf
and vfscanf
loads only one line of the file using getline
: https://github.com/phoenix-rtos/libphoenix/blob/ffca1e635e8146d77b5694077f5283cb88f0154b/stdio/scanf.c#L665
Problem occurs only in cases when brackets are used with scanf operating on files (fscanf/vfscanf).
In the progress of creating tests for square bracket format there couple of possibilities for interrupting this read, but there was found a difference between our system and host generic in placing
\n
in the text.After a deeper investigation scanf, found that fscanf and vfscanf read
\n
as the end of the file.Code to reproduction:
int main(void) { FILE *fd; char buff[12] = "abc\nabc"; char exp[12] = { 0 }; char c1, c2, c3, c4, c5, c6, c7; int sz;
}