diff --git a/sftpcommon.c b/sftpcommon.c index 4912899b..43b65755 100644 --- a/sftpcommon.c +++ b/sftpcommon.c @@ -85,6 +85,12 @@ bool BinarySource_get_fxp_attrs(BinarySource *src, struct fxp_attrs *attrs) if (attrs->flags & SSH_FILEXFER_ATTR_EXTENDED) { unsigned long count = get_uint32(src); while (count--) { + if (get_err(src)) { + /* Truncated packet. Don't waste time looking for + * attributes that aren't there. Caller should spot + * the truncation. */ + break; + } /* * We should try to analyse these, if we ever find one * we recognise.