On Sun, Nov 18, 2012 at 06:21:46AM +0000, Eitan Adler wrote:
> Author: eadler
> Date: Sun Nov 18 06:21:45 2012
> New Revision: 243210
> URL: http://svnweb.freebsd.org/changeset/base/243210
> 
> Log:
>   MFC r243074:
>       Add a missing check for fread
>   
>   Approved by:        cperciva (implicit)
> 
> Modified:
>   stable/9/usr.sbin/ndiscvt/ndiscvt.c
> Directory Properties:
>   stable/9/usr.sbin/ndiscvt/   (props changed)
> 
> Modified: stable/9/usr.sbin/ndiscvt/ndiscvt.c
> ==============================================================================
> --- stable/9/usr.sbin/ndiscvt/ndiscvt.c       Sun Nov 18 05:19:08 2012        
> (r243209)
> +++ stable/9/usr.sbin/ndiscvt/ndiscvt.c       Sun Nov 18 06:21:45 2012        
> (r243210)
> @@ -325,6 +325,8 @@ main(int argc, char *argv[])
>       rewind (fp);
>       img = calloc(fsize, 1);
>       n = fread (img, fsize, 1, fp);
> +     if (n == 0)
> +             err(1, "reading .SYS file '%s' failed", sysfile);
>  
AFAIR fread(3) can return 0 both for error and EOF. In the later case, errno
is meaningless. Is the short read case fatal ?

Attachment: pgpHA792t0oqw.pgp
Description: PGP signature



Reply via email to