mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
If handed a file pointer we can't write to, set errno properly to EBADF
in order to get SUSv2 conformant behavior in higher level calls like fputs() and puts(). Reviewed by: bde
This commit is contained in:
parent
0a5df651a6
commit
1b629e865e
1 changed files with 4 additions and 1 deletions
|
|
@ -40,6 +40,7 @@ static char sccsid[] = "@(#)fvwrite.c 8.1 (Berkeley) 6/4/93";
|
|||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -67,8 +68,10 @@ __sfvwrite(fp, uio)
|
|||
if ((len = uio->uio_resid) == 0)
|
||||
return (0);
|
||||
/* make sure we can write */
|
||||
if (cantwrite(fp))
|
||||
if (cantwrite(fp)) {
|
||||
errno = EBADF;
|
||||
return (EOF);
|
||||
}
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n))
|
||||
|
|
|
|||
Loading…
Reference in a new issue