Module Name: src Committed By: bouyer Date: Sun Oct 20 13:25:02 UTC 2013
Modified Files: src/usr.sbin/eeprom [netbsd-6]: eehandlers.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.15.8.1 src/usr.sbin/eeprom/eehandlers.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/eeprom/eehandlers.c diff -u src/usr.sbin/eeprom/eehandlers.c:1.15 src/usr.sbin/eeprom/eehandlers.c:1.15.8.1 --- src/usr.sbin/eeprom/eehandlers.c:1.15 Thu Apr 30 07:45:28 2009 +++ src/usr.sbin/eeprom/eehandlers.c Sun Oct 20 13:25:02 2013 @@ -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 @@ ee_hwupdate(ktent, arg) struct keytabent *ktent; char *arg; { + uint32_t hwtime; time_t t; char *cp, *cp2; @@ -154,18 +156,26 @@ ee_hwupdate(ktent, arg) } 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