From 0af6fe92d82c4bce6606f79b2fe8394d8a151b24 Mon Sep 17 00:00:00 2001 From: djm Date: Fri, 31 Mar 2023 04:00:37 +0000 Subject: [PATCH] don't attempt to decode a ridiculous number of attributes; harmless because of bounds elsewhere, but better to be explicit --- usr.bin/ssh/sftp-common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/ssh/sftp-common.c b/usr.bin/ssh/sftp-common.c index 82d6fd1dcb5..985db5182eb 100644 --- a/usr.bin/ssh/sftp-common.c +++ b/usr.bin/ssh/sftp-common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-common.c,v 1.33 2022/09/19 10:41:58 djm Exp $ */ +/* $OpenBSD: sftp-common.c,v 1.34 2023/03/31 04:00:37 djm Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * Copyright (c) 2001 Damien Miller. All rights reserved. @@ -132,6 +132,8 @@ decode_attrib(struct sshbuf *b, Attrib *a) if ((r = sshbuf_get_u32(b, &count)) != 0) return r; + if (count > 0x100000) + return SSH_ERR_INVALID_FORMAT; for (i = 0; i < count; i++) { if ((r = sshbuf_get_cstring(b, &type, NULL)) != 0 || (r = sshbuf_get_string(b, &data, &dlen)) != 0) -- 2.20.1