[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
coreutils posixtm int bugfix/cleanup
From: |
Paul Eggert |
Subject: |
coreutils posixtm int bugfix/cleanup |
Date: |
Mon, 02 Aug 2004 13:36:05 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
This fixes a bug where posix_time_parse would go into an infinite loop
or worse when given a string longer than UINT_MAX.
2004-08-02 Paul Eggert <address@hidden>
* posixtm.c (posix_time_parse): Don't assume that the length of
the string being parsed is <= UINT_MAX.
Index: lib/posixtm.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/posixtm.c,v
retrieving revision 1.16
diff -p -u -r1.16 posixtm.c
--- lib/posixtm.c 10 Sep 2003 09:07:17 -0000 1.16
+++ lib/posixtm.c 2 Aug 2004 20:33:42 -0000
@@ -1,5 +1,7 @@
/* Parse dates for touch and date.
- Copyright (C) 1989, 1990, 1991, 1998, 2000-2003 Free Software Foundation
Inc.
+
+ Copyright (C) 1989, 1990, 1991, 1998, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -45,7 +47,7 @@
POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
ISDIGIT_LOCALE unless it's important to use the locale's definition
of `digit' even when the host does not conform to POSIX. */
-#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
+#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
time_t mktime ();
@@ -113,7 +115,7 @@ posix_time_parse (struct tm *tm, const c
const char *dot = NULL;
int pair[6];
int *p;
- unsigned int i;
+ size_t i;
size_t s_len = strlen (s);
size_t len = (((syntax_bits & PDS_SECONDS) && (dot = strchr (s, '.')))
@@ -304,7 +306,7 @@ main (void)
{
printf ("%-15s %2u ", time_str, syntax_bits);
if (posixtime (&t, time_str, syntax_bits))
- printf ("%12ld %s", (long) t, ctime (&t));
+ printf ("%12ld %s", (long int) t, ctime (&t));
else
printf ("%12s %s", "*", "*\n");
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- coreutils posixtm int bugfix/cleanup,
Paul Eggert <=