On Sat, May 11, 2019 at 2:40 PM Waldemar Kozaczuk <jwkozac...@gmail.com>
wrote:

> Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
> ---
>  libc/stdio/fopen.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libc/stdio/fopen.c b/libc/stdio/fopen.c
> index 83452407..c6053c21 100644
> --- a/libc/stdio/fopen.c
> +++ b/libc/stdio/fopen.c
> @@ -10,6 +10,11 @@ FILE *fopen(const char *restrict filename, const char
> *restrict mode)
>         int fd;
>         int flags;
>
> +       if (filename == NULL) {
> +               errno = EFAULT;
> +               return 0;
> +       }
>

I'm curious why you wanted to do this change, for two reasons:

1. Is there a real program which calls fopen() on a null pointer and expect
it to fail with EFAULT instead of crashing?

2. Since fopen() just calls the open() system call, shouldn't we do this
change in open()'s implementation?

Because fopen.c really came from Musl, I wouldn't want to do changes in it
which aren't necessary.


> +
>         /* Check for valid initial mode character */
>         if (!strchr("rwa", *mode)) {
>                 errno = EINVAL;
> --
> 2.20.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osv-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/osv-dev/20190511114024.4928-1-jwkozaczuk%40gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CANEVyjvWTi3zz8NPVXY9RuBZkFLfhzLCfygHRK0Hs9cYvpFeJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to