diff options
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r-- | ssh-keygen.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c index 60261c210..7dc10808c 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-keygen.c,v 1.179 2010/02/26 20:29:54 djm Exp $ */ | 1 | /* $OpenBSD: ssh-keygen.c,v 1.180 2010/03/02 23:20:57 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -1243,13 +1243,29 @@ parse_absolute_time(const char *s) | |||
1243 | { | 1243 | { |
1244 | struct tm tm; | 1244 | struct tm tm; |
1245 | time_t tt; | 1245 | time_t tt; |
1246 | char buf[32], *fmt; | ||
1246 | 1247 | ||
1247 | if (strlen(s) != 8 && strlen(s) != 14) | 1248 | /* |
1249 | * POSIX strptime says "The application shall ensure that there | ||
1250 | * is white-space or other non-alphanumeric characters between | ||
1251 | * any two conversion specifications" so arrange things this way. | ||
1252 | */ | ||
1253 | switch (strlen(s)) { | ||
1254 | case 8: | ||
1255 | fmt = "%Y/%m/%d"; | ||
1256 | snprintf(buf, sizeof(buf), "%.4s/%.2s/%.2s", s, s + 4, s + 6); | ||
1257 | break; | ||
1258 | case 14: | ||
1259 | fmt = "%Y/%m/%d %H:%M:%S"; | ||
1260 | snprintf(buf, sizeof(buf), "%.4s/%.2s/%.2s %.2s:%.2s:%.2s", | ||
1261 | s, s + 4, s + 6, s + 8, s + 10, s + 12); | ||
1262 | break; | ||
1263 | default: | ||
1248 | fatal("Invalid certificate time format %s", s); | 1264 | fatal("Invalid certificate time format %s", s); |
1265 | } | ||
1249 | 1266 | ||
1250 | bzero(&tm, sizeof(tm)); | 1267 | bzero(&tm, sizeof(tm)); |
1251 | if (strptime(s, | 1268 | if (strptime(buf, fmt, &tm) == NULL) |
1252 | strlen(s) == 8 ? "%Y%m%d" : "%Y%m%d%H%M%S", &tm) == NULL) | ||
1253 | fatal("Invalid certificate time %s", s); | 1269 | fatal("Invalid certificate time %s", s); |
1254 | if ((tt = mktime(&tm)) < 0) | 1270 | if ((tt = mktime(&tm)) < 0) |
1255 | fatal("Certificate time %s cannot be represented", s); | 1271 | fatal("Certificate time %s cannot be represented", s); |