Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12599 Discussions

NIOS Library bug in scan functions

RProesel
Novice
658 Views

The scan functions contain a bug that affects time zone routines, but could affect other routines as well.  The bug is in both the PRO and STD versions of NIOS software versions 19 and above.

This bug does not appear to be in the publicly available versions of NEWLIB, just the Intel implementation.

The bug can be exposed with the following code:

char result[11];
int n;

sscanf ("ABC+XYZ", "%10[^+]%n", result, &n);
printf("Result string = '%s', Number of characters consumed = %d\n", &result, n);

The code above will return incorrect results:

Result string = 'ABC', Number of characters consumed = 6

The result string is correct but the number of characters consumed should be 3 not 6.

The file with the bug is vfscanf.c and it can be found in the following location which is dependent on the version of software installed:

C:\intelFPGA_pro\22.2\nios2eds\bin\gnu\src\newlib-4.1.0\newlib\libc\stdio\vfscanf.c

Around line 1196, this sequence of code can be found:

#ifdef _WANT_IO_POSIX_EXTENSIONS
shrink_m_ptr (char, p_p, n + 1, p_siz);
#endif
nassigned++;
nread += n;
}
nread += n; <<<<==== REMOVE THIS LINE
break;

case CT_STRING:
/* like CCL, but zero-length string OK, & no NOSKIP */
if (width == 0)
width = SIZE_MAX;


The line indicated in the code fragment should be removed. After editing the vscanf.c file, you will need to rebuild the library which can be done by cleaning the BSP project then building it again.

 

0 Kudos
6 Replies
KellyJialin_Goh
Employee
634 Views

Hi,

Thank you for notifying us the issue. We will look into it and get back to you.

Thank you.


Regards,

Kelly




0 Kudos
KellyJialin_Goh
Employee
558 Views

Hi,

We are currently still looking into the issue that you have raised.

Thank you.


Regards,

Kelly Jialin, GOH


0 Kudos
KellyJialin_Goh
Employee
523 Views

Hi,

Is it possible we close this case first while the engineering team continue with their investigation?


Regards,

Kelly Jialin, GOH


0 Kudos
KellyJialin_Goh
Employee
512 Views

Hi,

Any updates on your side?


Regards,

Kelly


0 Kudos
KellyJialin_Goh
Employee
503 Views

Hi,

As we do not receive any response from you on the previous reply that we have provided. Please login to ‘https://supporttickets.intel.com’, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.


p/s: If any answer from the community or Intel Support are helpful, please feel free to give best answer or rate 9/10 survey.

Thank you.

Regards,

Kelly Jialin. GOH


0 Kudos
RProesel
Novice
487 Views

I don't understand why you would want to close this issue when it hasn't been addressed by Intel.  Transitioning it to community support will not help since the community does not provide the library to itself.  Since Intel distributes the library, only Intel can fix it for everyone.  For myself, I already patched the libraries but that doesn't help everyone else.

 

If you feel you must close this case, go ahead.

 

0 Kudos
Reply