summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/ssh-ed25519.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2014-02-23 20:03:43 +0000
committerDamien Miller <djm@cvs.openbsd.org>2014-02-23 20:03:43 +0000
commit8b8081cac8c4edd66b1cc6be38774663270ca114 (patch)
treeaf963605fe86c1bdf63d33748f9b1ba8d56fdfdb /usr.bin/ssh/ssh-ed25519.c
parentc8eb6863e3718563ca617baa9f28ed5f19c1bda7 (diff)
check for unsigned overflow; not reachable in OpenSSH but others might
copy our code...
Diffstat (limited to 'usr.bin/ssh/ssh-ed25519.c')
-rw-r--r--usr.bin/ssh/ssh-ed25519.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/ssh/ssh-ed25519.c b/usr.bin/ssh/ssh-ed25519.c
index ece438c7ccc..7c3593b9f17 100644
--- a/usr.bin/ssh/ssh-ed25519.c
+++ b/usr.bin/ssh/ssh-ed25519.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-ed25519.c,v 1.2 2014/02/02 03:44:31 djm Exp $ */
+/* $OpenBSD: ssh-ed25519.c,v 1.3 2014/02/23 20:03:42 djm Exp $ */
/*
* Copyright (c) 2013 Markus Friedl <markus@openbsd.org>
*
@@ -19,6 +19,7 @@
#include "crypto_api.h"
+#include <limits.h>
#include <string.h>
#include <stdarg.h>
@@ -43,6 +44,11 @@ ssh_ed25519_sign(const Key *key, u_char **sigp, u_int *lenp,
error("%s: no ED25519 key", __func__);
return -1;
}
+
+ if (datalen >= UINT_MAX - crypto_sign_ed25519_BYTES) {
+ error("%s: datalen %u too long", __func__, datalen);
+ return -1;
+ }
smlen = slen = datalen + crypto_sign_ed25519_BYTES;
sig = xmalloc(slen);