mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-27 07:44:29 +02:00
upstream: Change convtime() from returning long to returning int.
On platforms where sizeof(int) != sizeof(long), convtime could accept values >MAX_INT which subsequently truncate when stored in an int during config parsing. bz#3250, ok djm@ OpenBSD-Commit-ID: 8fc932683d6b4660d52f50911d62bd6639c5db31
This commit is contained in:
parent
7a57adb8b0
commit
6d30673fed
10
misc.c
10
misc.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: misc.c,v 1.157 2020/12/22 00:12:22 djm Exp $ */
|
/* $OpenBSD: misc.c,v 1.158 2021/01/11 02:12:57 dtucker Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||||
* Copyright (c) 2005-2020 Damien Miller. All rights reserved.
|
* Copyright (c) 2005-2020 Damien Miller. All rights reserved.
|
||||||
@ -543,7 +543,7 @@ a2tun(const char *s, int *remote)
|
|||||||
*
|
*
|
||||||
* Return -1 if time string is invalid.
|
* Return -1 if time string is invalid.
|
||||||
*/
|
*/
|
||||||
long
|
int
|
||||||
convtime(const char *s)
|
convtime(const char *s)
|
||||||
{
|
{
|
||||||
long total, secs, multiplier;
|
long total, secs, multiplier;
|
||||||
@ -560,7 +560,7 @@ convtime(const char *s)
|
|||||||
while (*p) {
|
while (*p) {
|
||||||
secs = strtol(p, &endp, 10);
|
secs = strtol(p, &endp, 10);
|
||||||
if (p == endp ||
|
if (p == endp ||
|
||||||
(errno == ERANGE && (secs == LONG_MIN || secs == LONG_MAX)) ||
|
(errno == ERANGE && (secs == INT_MIN || secs == INT_MAX)) ||
|
||||||
secs < 0)
|
secs < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -591,10 +591,10 @@ convtime(const char *s)
|
|||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (secs >= LONG_MAX / multiplier)
|
if (secs >= INT_MAX / multiplier)
|
||||||
return -1;
|
return -1;
|
||||||
secs *= multiplier;
|
secs *= multiplier;
|
||||||
if (total >= LONG_MAX - secs)
|
if (total >= INT_MAX - secs)
|
||||||
return -1;
|
return -1;
|
||||||
total += secs;
|
total += secs;
|
||||||
if (total < 0)
|
if (total < 0)
|
||||||
|
4
misc.h
4
misc.h
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: misc.h,v 1.91 2020/12/22 00:12:22 djm Exp $ */
|
/* $OpenBSD: misc.h,v 1.92 2021/01/11 02:12:57 dtucker Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
@ -67,7 +67,7 @@ char *colon(char *);
|
|||||||
int parse_user_host_path(const char *, char **, char **, char **);
|
int parse_user_host_path(const char *, char **, char **, char **);
|
||||||
int parse_user_host_port(const char *, char **, char **, int *);
|
int parse_user_host_port(const char *, char **, char **, int *);
|
||||||
int parse_uri(const char *, const char *, char **, char **, int *, char **);
|
int parse_uri(const char *, const char *, char **, char **, int *, char **);
|
||||||
long convtime(const char *);
|
int convtime(const char *);
|
||||||
const char *fmt_timeframe(time_t t);
|
const char *fmt_timeframe(time_t t);
|
||||||
char *tilde_expand_filename(const char *, uid_t);
|
char *tilde_expand_filename(const char *, uid_t);
|
||||||
|
|
||||||
|
10
ssh-add.c
10
ssh-add.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: ssh-add.c,v 1.158 2020/10/18 11:32:02 djm Exp $ */
|
/* $OpenBSD: ssh-add.c,v 1.159 2021/01/11 02:12:58 dtucker Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
@ -91,7 +91,7 @@ static char *default_files[] = {
|
|||||||
static int fingerprint_hash = SSH_FP_HASH_DEFAULT;
|
static int fingerprint_hash = SSH_FP_HASH_DEFAULT;
|
||||||
|
|
||||||
/* Default lifetime (0 == forever) */
|
/* Default lifetime (0 == forever) */
|
||||||
static long lifetime = 0;
|
static int lifetime = 0;
|
||||||
|
|
||||||
/* User has to confirm key use */
|
/* User has to confirm key use */
|
||||||
static int confirm = 0;
|
static int confirm = 0;
|
||||||
@ -372,7 +372,7 @@ add_file(int agent_fd, const char *filename, int key_only, int qflag,
|
|||||||
filename, comment);
|
filename, comment);
|
||||||
if (lifetime != 0) {
|
if (lifetime != 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Lifetime set to %ld seconds\n", lifetime);
|
"Lifetime set to %d seconds\n", lifetime);
|
||||||
}
|
}
|
||||||
if (confirm != 0) {
|
if (confirm != 0) {
|
||||||
fprintf(stderr, "The user must confirm "
|
fprintf(stderr, "The user must confirm "
|
||||||
@ -427,7 +427,7 @@ add_file(int agent_fd, const char *filename, int key_only, int qflag,
|
|||||||
fprintf(stderr, "Certificate added: %s (%s)\n", certpath,
|
fprintf(stderr, "Certificate added: %s (%s)\n", certpath,
|
||||||
private->cert->key_id);
|
private->cert->key_id);
|
||||||
if (lifetime != 0) {
|
if (lifetime != 0) {
|
||||||
fprintf(stderr, "Lifetime set to %ld seconds\n",
|
fprintf(stderr, "Lifetime set to %d seconds\n",
|
||||||
lifetime);
|
lifetime);
|
||||||
}
|
}
|
||||||
if (confirm != 0) {
|
if (confirm != 0) {
|
||||||
@ -610,7 +610,7 @@ load_resident_keys(int agent_fd, const char *skprovider, int qflag)
|
|||||||
sshkey_type(keys[i]), fp);
|
sshkey_type(keys[i]), fp);
|
||||||
if (lifetime != 0) {
|
if (lifetime != 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Lifetime set to %ld seconds\n", lifetime);
|
"Lifetime set to %d seconds\n", lifetime);
|
||||||
}
|
}
|
||||||
if (confirm != 0) {
|
if (confirm != 0) {
|
||||||
fprintf(stderr, "The user must confirm "
|
fprintf(stderr, "The user must confirm "
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: ssh-agent.c,v 1.267 2020/11/08 22:37:24 djm Exp $ */
|
/* $OpenBSD: ssh-agent.c,v 1.268 2021/01/11 02:12:58 dtucker Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
@ -164,7 +164,7 @@ u_char lock_salt[LOCK_SALT_SIZE];
|
|||||||
extern char *__progname;
|
extern char *__progname;
|
||||||
|
|
||||||
/* Default lifetime in seconds (0 == forever) */
|
/* Default lifetime in seconds (0 == forever) */
|
||||||
static long lifetime = 0;
|
static int lifetime = 0;
|
||||||
|
|
||||||
static int fingerprint_hash = SSH_FP_HASH_DEFAULT;
|
static int fingerprint_hash = SSH_FP_HASH_DEFAULT;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user