@@ -232,11 +232,14 @@ char *fgets(char *str, int size, FILE *stream)
232
232
__CPROVER_bool error = __VERIFIER_nondet___CPROVER_bool ();
233
233
234
234
(void )size ;
235
- #if !defined(__linux__ ) || defined(__GLIBC__ )
236
- (void )* stream ;
237
- #else
238
- (void )* (char * )stream ;
239
- #endif
235
+ if (stream != stdin )
236
+ {
237
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
238
+ (void )* stream ;
239
+ #else
240
+ (void )* (char * )stream ;
241
+ #endif
242
+ }
240
243
241
244
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
242
245
__CPROVER_assert (__CPROVER_get_must (stream , "open" ),
@@ -290,11 +293,14 @@ inline size_t fread(
290
293
size_t bytes = nread * size ;
291
294
__CPROVER_assume (nread <=nitems );
292
295
293
- #if !defined(__linux__ ) || defined(__GLIBC__ )
294
- (void )* stream ;
295
- #else
296
- (void )* (char * )stream ;
297
- #endif
296
+ if (stream != stdin )
297
+ {
298
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
299
+ (void )* stream ;
300
+ #else
301
+ (void )* (char * )stream ;
302
+ #endif
303
+ }
298
304
299
305
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
300
306
__CPROVER_assert (__CPROVER_get_must (stream , "open" ),
@@ -325,11 +331,14 @@ inline int feof(FILE *stream)
325
331
__CPROVER_HIDE :;
326
332
int return_value = __VERIFIER_nondet_int ();
327
333
328
- #if !defined(__linux__ ) || defined(__GLIBC__ )
329
- (void )* stream ;
330
- #else
331
- (void )* (char * )stream ;
332
- #endif
334
+ if (stream != stdin )
335
+ {
336
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
337
+ (void )* stream ;
338
+ #else
339
+ (void )* (char * )stream ;
340
+ #endif
341
+ }
333
342
334
343
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
335
344
__CPROVER_assert (__CPROVER_get_must (stream , "open" ),
@@ -354,11 +363,14 @@ inline int ferror(FILE *stream)
354
363
__CPROVER_HIDE :;
355
364
int return_value = __VERIFIER_nondet_int ();
356
365
357
- #if !defined(__linux__ ) || defined(__GLIBC__ )
358
- (void )* stream ;
359
- #else
360
- (void )* (char * )stream ;
361
- #endif
366
+ if (stream != stdin )
367
+ {
368
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
369
+ (void )* stream ;
370
+ #else
371
+ (void )* (char * )stream ;
372
+ #endif
373
+ }
362
374
363
375
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
364
376
__CPROVER_assert (__CPROVER_get_must (stream , "open" ),
@@ -379,8 +391,15 @@ int __VERIFIER_nondet_int();
379
391
380
392
inline int fileno (FILE * stream )
381
393
{
382
- // just return nondet
383
- __CPROVER_HIDE :;
394
+ // just return nondet
395
+ __CPROVER_HIDE :;
396
+ if (stream == stdin )
397
+ return 0 ;
398
+ else if (stream == stdout )
399
+ return 1 ;
400
+ else if (stream == stderr )
401
+ return 2 ;
402
+
384
403
int return_value = __VERIFIER_nondet_int ();
385
404
386
405
#if !defined(__linux__ ) || defined(__GLIBC__ )
@@ -416,11 +435,14 @@ inline int fputs(const char *s, FILE *stream)
416
435
#endif
417
436
(void )* s ;
418
437
419
- #if !defined(__linux__ ) || defined(__GLIBC__ )
420
- (void )* stream ;
421
- #else
422
- (void )* (char * )stream ;
423
- #endif
438
+ if (stream != stdout && stream != stderr )
439
+ {
440
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
441
+ (void )* stream ;
442
+ #else
443
+ (void )* (char * )stream ;
444
+ #endif
445
+ }
424
446
425
447
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
426
448
__CPROVER_assert (__CPROVER_get_must (stream , "open" ),
@@ -470,11 +492,14 @@ inline int fpurge(FILE *stream)
470
492
__CPROVER_HIDE :;
471
493
int return_value = __VERIFIER_nondet_int ();
472
494
473
- #if !defined(__linux__ ) || defined(__GLIBC__ )
474
- (void )* stream ;
475
- #else
476
- (void )* (char * )stream ;
477
- #endif
495
+ if (stream != stdin && stream != stdout && stream != stderr )
496
+ {
497
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
498
+ (void )* stream ;
499
+ #else
500
+ (void )* (char * )stream ;
501
+ #endif
502
+ }
478
503
479
504
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
480
505
__CPROVER_assert (__CPROVER_get_must (stream , "open" ),
@@ -497,11 +522,16 @@ inline int fgetc(FILE *stream)
497
522
{
498
523
__CPROVER_HIDE :;
499
524
int return_value = __VERIFIER_nondet_int ();
500
- #if !defined(__linux__ ) || defined(__GLIBC__ )
501
- (void )* stream ;
502
- #else
503
- (void )* (char * )stream ;
504
- #endif
525
+
526
+ if (stream != stdin )
527
+ {
528
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
529
+ (void )* stream ;
530
+ #else
531
+ (void )* (char * )stream ;
532
+ #endif
533
+ }
534
+
505
535
// it's a byte or EOF (-1)
506
536
__CPROVER_assume (return_value >=-1 && return_value <=255 );
507
537
@@ -529,11 +559,14 @@ inline int getc(FILE *stream)
529
559
__CPROVER_HIDE :;
530
560
int return_value = __VERIFIER_nondet_int ();
531
561
532
- #if !defined(__linux__ ) || defined(__GLIBC__ )
533
- (void )* stream ;
534
- #else
535
- (void )* (char * )stream ;
536
- #endif
562
+ if (stream != stdin )
563
+ {
564
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
565
+ (void )* stream ;
566
+ #else
567
+ (void )* (char * )stream ;
568
+ #endif
569
+ }
537
570
538
571
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
539
572
__CPROVER_assert (__CPROVER_get_must (stream , "open" ),
@@ -581,11 +614,14 @@ inline int getw(FILE *stream)
581
614
__CPROVER_HIDE :;
582
615
int return_value = __VERIFIER_nondet_int ();
583
616
584
- #if !defined(__linux__ ) || defined(__GLIBC__ )
585
- (void )* stream ;
586
- #else
587
- (void )* (char * )stream ;
588
- #endif
617
+ if (stream != stdin )
618
+ {
619
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
620
+ (void )* stream ;
621
+ #else
622
+ (void )* (char * )stream ;
623
+ #endif
624
+ }
589
625
590
626
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
591
627
__CPROVER_assert (__CPROVER_get_must (stream , "open" ),
@@ -698,11 +734,14 @@ size_t fwrite(
698
734
(void )* (char * )ptr ;
699
735
(void )size ;
700
736
701
- #if !defined(__linux__ ) || defined(__GLIBC__ )
702
- (void )* stream ;
703
- #else
704
- (void )* (char * )stream ;
705
- #endif
737
+ if (stream != stdout && stream != stderr )
738
+ {
739
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
740
+ (void )* stream ;
741
+ #else
742
+ (void )* (char * )stream ;
743
+ #endif
744
+ }
706
745
707
746
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
708
747
__CPROVER_assert (__CPROVER_get_must (stream , "open" ),
@@ -821,11 +860,16 @@ inline int vfscanf(FILE *restrict stream, const char *restrict format, va_list a
821
860
{
822
861
__CPROVER_HIDE :;
823
862
int result = __VERIFIER_nondet_int ();
824
- #if !defined(__linux__ ) || defined(__GLIBC__ )
825
- (void )* stream ;
826
- #else
827
- (void )* (char * )stream ;
828
- #endif
863
+
864
+ if (stream != stdin )
865
+ {
866
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
867
+ (void )* stream ;
868
+ #else
869
+ (void )* (char * )stream ;
870
+ #endif
871
+ }
872
+
829
873
(void )* format ;
830
874
(void )arg ;
831
875
@@ -921,11 +965,15 @@ inline int vfprintf(FILE *stream, const char *restrict format, va_list arg)
921
965
922
966
int result = __VERIFIER_nondet_int ();
923
967
924
- #if !defined(__linux__ ) || defined(__GLIBC__ )
925
- (void )* stream ;
926
- #else
927
- (void )* (char * )stream ;
928
- #endif
968
+ if (stream != stdout && stream != stderr )
969
+ {
970
+ #if !defined(__linux__ ) || defined(__GLIBC__ )
971
+ (void )* stream ;
972
+ #else
973
+ (void )* (char * )stream ;
974
+ #endif
975
+ }
976
+
929
977
(void )* format ;
930
978
(void )arg ;
931
979
0 commit comments