Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: segfault in strftime
- X-seq: zsh-users 14901
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: segfault in strftime
- Date: Fri, 26 Feb 2010 17:21:30 +0100
- In-reply-to: <20100226151712.05fbe555@news01>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <A73C7D9C-66C5-4BFA-8FB3-8560FE65B529@xxxxxxxxxxx> <20100226125256.GC13766@xxxxxxxxxxxxxxxxxxx> <20100226150748.GE13766@xxxxxxxxxxxxxxxxxxx> <20100226151712.05fbe555@news01>
On 2010-02-26 15:17:12 +0000, Peter Stephenson wrote:
> I hope we don't need to handle the case sizeof(time_t) >
> sizeof(unsigned long). It's certainly not typical.
The problem would be more a signed time_t that cannot represent
ULONG_MAX: (time_t)ULONG_MAX would have an implementation-defined
behavior, e.g. process killed by a signal. And time_t is typically
defined as a long int!
Wouldn't it be better to test only errno != 0 ?
> Index: Src/Modules/datetime.c
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Src/Modules/datetime.c,v
> retrieving revision 1.19
> diff -p -u -r1.19 datetime.c
> --- Src/Modules/datetime.c 26 Feb 2010 14:25:05 -0000 1.19
> +++ Src/Modules/datetime.c 26 Feb 2010 15:15:12 -0000
> @@ -111,8 +111,9 @@ bin_strftime(char *nam, char **argv, Opt
> if (OPT_ISSET(ops, 'r'))
> return reverse_strftime(nam, argv, scalar, OPT_ISSET(ops, 'q'));
>
> + errno = 0;
> secs = (time_t)strtoul(argv[1], &endptr, 10);
> - if (secs == (time_t)ULONG_MAX) {
> + if (secs == (time_t)ULONG_MAX && errno != 0) {
> zwarnnam(nam, "%s: %e", argv[1], errno);
> return 1;
> } else if (*endptr != '\0') {
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author