Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/usr.sbin/eeprom Pull up following revision(s) (requested ...
details: https://anonhg.NetBSD.org/src/rev/450a2603d5d0
branches: netbsd-6
changeset: 776478:450a2603d5d0
user: bouyer <bouyer%NetBSD.org@localhost>
date: Sun Oct 20 13:25:02 2013 +0000
description:
Pull up following revision(s) (requested by dholland in ticket #964):
usr.sbin/eeprom/eehandlers.c: revision 1.16
PR/47528: Izumi Tsutsui: eeprom(8) dumps core after 64 bit time_t changes
diffstat:
usr.sbin/eeprom/eehandlers.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diffs (57 lines):
diff -r 797e2be356a8 -r 450a2603d5d0 usr.sbin/eeprom/eehandlers.c
--- a/usr.sbin/eeprom/eehandlers.c Sun Oct 20 13:16:57 2013 +0000
+++ b/usr.sbin/eeprom/eehandlers.c Sun Oct 20 13:25:02 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: eehandlers.c,v 1.15 2009/04/30 07:45:28 nakayama Exp $ */
+/* $NetBSD: eehandlers.c,v 1.15.8.1 2013/10/20 13:25:02 bouyer Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
#include <time.h>
#include <unistd.h>
#include <util.h>
+#include <sys/inttypes.h>
#include <machine/eeprom.h>
#ifdef __sparc__
@@ -140,6 +141,7 @@
struct keytabent *ktent;
char *arg;
{
+ uint32_t hwtime;
time_t t;
char *cp, *cp2;
@@ -154,18 +156,26 @@
} else
if ((t = parsedate(arg, NULL, NULL)) == (time_t)(-1))
BARF(ktent);
+ hwtime = (uint32_t)t; /* XXX 32 bit time_t on hardware */
+ if (hwtime != t)
+ warnx("time overflow");
- if (doio(ktent, (u_char *)&t, sizeof(t), IO_WRITE))
+ if (doio(ktent, (u_char *)&hwtime, sizeof(hwtime), IO_WRITE))
FAILEDWRITE(ktent);
- } else
- if (doio(ktent, (u_char *)&t, sizeof(t), IO_READ))
+ } else {
+ if (doio(ktent, (u_char *)&hwtime, sizeof(hwtime), IO_READ))
FAILEDREAD(ktent);
+ t = (time_t)hwtime; /* XXX 32 bit time_t on hardware */
+ }
cp = ctime(&t);
- if ((cp2 = strrchr(cp, '\n')) != NULL)
+ if (cp != NULL && (cp2 = strrchr(cp, '\n')) != NULL)
*cp2 = '\0';
- printf("%s=%ld (%s)\n", ktent->kt_keyword, (long)t, cp);
+ printf("%s=%" PRId64, ktent->kt_keyword, (int64_t)t);
+ if (cp != NULL)
+ printf(" (%s)", cp);
+ printf("\n");
}
void
Home |
Main Index |
Thread Index |
Old Index