From 470bb82342126937ca6d08109737248a6c7b9ee5 Mon Sep 17 00:00:00 2001 From: eck Date: Tue, 24 Apr 1990 09:30:15 +0000 Subject: [PATCH] garbage is allowed in the f[re]open mode string --- lang/cem/libcc.ansi/stdio/fopen.c | 8 +++++--- lang/cem/libcc.ansi/stdio/freopen.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lang/cem/libcc.ansi/stdio/fopen.c b/lang/cem/libcc.ansi/stdio/fopen.c index bc2e1ed6b..af11acd57 100644 --- a/lang/cem/libcc.ansi/stdio/fopen.c +++ b/lang/cem/libcc.ansi/stdio/fopen.c @@ -73,14 +73,16 @@ fopen(const char *name, const char *mode) while (*mode) { switch(*mode++) { case 'b': - break; + continue; case '+': rwmode = O_RDWR; flags |= _IOREAD | _IOWRITE; - break; + continue; + /* The sequence may be followed by additional characters */ default: - return (FILE *)NULL; + break; } + break; } /* Perform a creat() when the file should be truncated or when diff --git a/lang/cem/libcc.ansi/stdio/freopen.c b/lang/cem/libcc.ansi/stdio/freopen.c index 41887f861..32965362c 100644 --- a/lang/cem/libcc.ansi/stdio/freopen.c +++ b/lang/cem/libcc.ansi/stdio/freopen.c @@ -56,14 +56,16 @@ freopen(const char *name, const char *mode, FILE *stream) while (*mode) { switch(*mode++) { case 'b': - break; + continue; case '+': rwmode = O_RDWR; flags |= _IOREAD | _IOWRITE; - break; + continue; + /* The sequence may be followed by aditional characters */ default: - return (FILE *)NULL; + break; } + break; } if ((rwflags & O_TRUNC) -- 2.34.1