From a31f895e9a7ac1aec1a7d188a52f04f0544879e2 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Wed, 20 Feb 2013 01:01:40 +0000 Subject: [PATCH] gets: lock file before performing read --- functions/stdio/gets.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/stdio/gets.c b/functions/stdio/gets.c index 83a261e..798df76 100644 --- a/functions/stdio/gets.c +++ b/functions/stdio/gets.c @@ -14,13 +14,16 @@ char * gets( char * s ) { + _PDCLIB_flockfile( stdin ); if ( _PDCLIB_prepread( stdin ) == EOF ) { + _PDCLIB_funlockfile( stdin ); return NULL; } char * dest = s; dest += _PDCLIB_getchars( dest, SIZE_MAX, '\n', stdin ); + _PDCLIB_funlockfile( stdin ); if(*(dest - 1) == '\n') { *(--dest) = '\0'; -- 2.40.0