changeset 13802:d239c320157d

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>
author Yuri Pankov <yuri.pankov@nexenta.com>
date Wed, 05 Sep 2012 09:50:52 -0500
parents c6c92fa2b3ad
children b5e49d71ff0e
files usr/src/cmd/fm/fmdump/common/fmdump.c
diffstat 1 files changed, 17 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/fm/fmdump/common/fmdump.c	Wed Sep 05 10:31:48 2012 +0000
+++ b/usr/src/cmd/fm/fmdump/common/fmdump.c	Wed Sep 05 09:50:52 2012 -0500
@@ -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 @@
 	/*
 	 * 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, "%m/%d/%y", &tm)) == NULL &&
+	    (p = strptime(arg, "%Y-%m-%dT%H:%M:%S", &tm)) == NULL &&
 	    (p = strptime(arg, "%y-%m-%dT%H:%M:%S", &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", &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-%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) {