summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Pankov <yuri.pankov@nexenta.com>2012-09-05 09:50:52 -0500
committerYuri Pankov <yuri.pankov@nexenta.com>2012-09-05 09:50:52 -0500
commit69fcd3d47071ff9cff1003e67c4973786fb01cac (patch)
tree7df676c63a2478a68b503b6681951d1d70cfa7e9
parentabe85dc5696f519c0c45fb0dded9fdb0df03376f (diff)
downloadillumos-joyent-69fcd3d47071ff9cff1003e67c4973786fb01cac.tar.gz
3140 fmdump -t/-T incorrectly parses date/time
Reviewed by: Jason King <jason.brian.king@gmail.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r--usr/src/cmd/fm/fmdump/common/fmdump.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/usr/src/cmd/fm/fmdump/common/fmdump.c b/usr/src/cmd/fm/fmdump/common/fmdump.c
index c4168f961a..dc22eff7df 100644
--- a/usr/src/cmd/fm/fmdump/common/fmdump.c
+++ b/usr/src/cmd/fm/fmdump/common/fmdump.c
@@ -18,8 +18,10 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
#include <alloca.h>
@@ -262,35 +264,27 @@ gettimeopt(const char *arg)
/*
* First try a variety of strptime() calls. If these all fail, we'll
* try parsing an integer followed by one of our suffix[] strings.
- * NOTE: any form using %y must appear *before* the equivalent %Y form;
- * otherwise %Y will accept the two year digits but infer century zero.
- * Any form ending in %y must additionally check isdigit(*p) to ensure
- * that it does not inadvertently match 2 digits of a 4-digit year.
- *
- * Beware: Any strptime() sequence containing consecutive %x sequences
- * may fall victim to SCCS expanding it as a keyword! If this happens
- * we use separate string constant that ANSI C will concatenate.
*/
- if ((p = strptime(arg, "%m/%d/%y" "%t" "%H:%M:%S", &tm)) == NULL &&
- (p = strptime(arg, "%m/%d/%Y" "%t" "%H:%M:%S", &tm)) == NULL &&
- (p = strptime(arg, "%m/%d/%y" "%t" "%H:%M", &tm)) == NULL &&
- (p = strptime(arg, "%m/%d/%Y" "%t" "%H:%M", &tm)) == NULL &&
- ((p = strptime(arg, "%m/%d/%y", &tm)) == NULL || isdigit(*p)) &&
+ if ((p = strptime(arg, "%m/%d/%Y %H:%M:%S", &tm)) == NULL &&
+ (p = strptime(arg, "%m/%d/%y %H:%M:%S", &tm)) == NULL &&
+ (p = strptime(arg, "%m/%d/%Y %H:%M", &tm)) == NULL &&
+ (p = strptime(arg, "%m/%d/%y %H:%M", &tm)) == NULL &&
(p = strptime(arg, "%m/%d/%Y", &tm)) == NULL &&
- (p = strptime(arg, "%y-%m-%dT%H:%M:%S", &tm)) == NULL &&
+ (p = strptime(arg, "%m/%d/%y", &tm)) == NULL &&
(p = strptime(arg, "%Y-%m-%dT%H:%M:%S", &tm)) == NULL &&
- (p = strptime(arg, "%y-%m-%dT%H:%M", &tm)) == NULL &&
+ (p = strptime(arg, "%y-%m-%dT%H:%M:%S", &tm)) == NULL &&
(p = strptime(arg, "%Y-%m-%dT%H:%M", &tm)) == NULL &&
- (p = strptime(arg, "%y-%m-%d", &tm)) == NULL &&
+ (p = strptime(arg, "%y-%m-%dT%H:%M", &tm)) == NULL &&
(p = strptime(arg, "%Y-%m-%d", &tm)) == NULL &&
- (p = strptime(arg, "%d%b%y" "%t" "%H:%M:%S", &tm)) == NULL &&
- (p = strptime(arg, "%d%b%Y" "%t" "%H:%M:%S", &tm)) == NULL &&
- (p = strptime(arg, "%d%b%y" "%t" "%H:%M", &tm)) == NULL &&
- (p = strptime(arg, "%d%b%Y" "%t" "%H:%M", &tm)) == NULL &&
- ((p = strptime(arg, "%d%b%y", &tm)) == NULL || isdigit(*p)) &&
+ (p = strptime(arg, "%y-%m-%d", &tm)) == NULL &&
+ (p = strptime(arg, "%d%b%Y %H:%M:%S", &tm)) == NULL &&
+ (p = strptime(arg, "%d%b%y %H:%M:%S", &tm)) == NULL &&
+ (p = strptime(arg, "%d%b%Y %H:%M", &tm)) == NULL &&
+ (p = strptime(arg, "%d%b%y %H:%M", &tm)) == NULL &&
(p = strptime(arg, "%d%b%Y", &tm)) == NULL &&
- (p = strptime(arg, "%b%t%d" "%t" "%H:%M:%S", &tm)) == NULL &&
- (p = strptime(arg, "%b%t%d" "%t" "%H:%M:%S", &tm)) == NULL &&
+ (p = strptime(arg, "%d%b%y", &tm)) == NULL &&
+ (p = strptime(arg, "%b %d %H:%M:%S", &tm)) == NULL &&
+ (p = strptime(arg, "%b %d %H:%M:%S", &tm)) == NULL &&
(p = strptime(arg, "%H:%M:%S", &tm)) == NULL &&
(p = strptime(arg, "%H:%M", &tm)) == NULL) {