check for write and close errors, from wiz
This commit is contained in:
parent
4783843fdc
commit
c73d854002
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: utmpx.c,v 1.11 2002/09/26 17:08:42 wiz Exp $ */
|
/* $NetBSD: utmpx.c,v 1.12 2002/09/28 01:34:36 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
__RCSID("$NetBSD: utmpx.c,v 1.11 2002/09/26 17:08:42 wiz Exp $");
|
__RCSID("$NetBSD: utmpx.c,v 1.12 2002/09/28 01:34:36 christos Exp $");
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -297,10 +297,13 @@ updwtmpx(const char *file, const struct utmpx *utx)
|
||||||
(void)memset(&ut, 0, sizeof(ut));
|
(void)memset(&ut, 0, sizeof(ut));
|
||||||
ut.ut_type = SIGNATURE;
|
ut.ut_type = SIGNATURE;
|
||||||
(void)memcpy(ut.ut_user, vers, sizeof(vers));
|
(void)memcpy(ut.ut_user, vers, sizeof(vers));
|
||||||
(void)write(fd, &ut, sizeof(ut));
|
if ((write(fd, &ut, sizeof(ut)) == -1)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
(void)write(fd, utx, sizeof(*utx));
|
if (write(fd, utx, sizeof(*utx)) == -1)
|
||||||
(void)close(fd);
|
return -1;
|
||||||
|
if (close(fd) == -1)
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue