libc: stdio: Fix NULL pointer dereference in ungetc(). If 'stream' was NULL, 'stream->fs_oflags' was evaluated. From Juha Niskanen
This commit is contained in:
parent
af6d9e2684
commit
c39725b398
@ -94,10 +94,17 @@ int ungetc(int c, FAR FILE *stream)
|
|||||||
int nungotten;
|
int nungotten;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Verify that a non-NULL stream was provided */
|
||||||
|
|
||||||
|
if (!stream)
|
||||||
|
{
|
||||||
|
set_errno(EBADF);
|
||||||
|
return EOF;
|
||||||
|
}
|
||||||
|
|
||||||
/* Stream must be open for read access */
|
/* Stream must be open for read access */
|
||||||
|
|
||||||
if ((stream && stream->fs_fd < 0) ||
|
if ((stream->fs_fd < 0) || ((stream->fs_oflags & O_RDOK) == 0))
|
||||||
((stream->fs_oflags & O_RDOK) == 0))
|
|
||||||
{
|
{
|
||||||
set_errno(EBADF);
|
set_errno(EBADF);
|
||||||
return EOF;
|
return EOF;
|
||||||
|
Loading…
Reference in New Issue
Block a user