From 33438037e00ec750bff020578b1a5b6f75f60555 Mon Sep 17 00:00:00 2001
From: Adam Majer <amajer@suse.de>
Date: Fri, 17 Aug 2018 14:41:02 +0800
Subject: [PATCH] fix CVE-2018-8882

https://bugzilla.nasm.us/show_bug.cgi?id=3392445

Upstream-Status: Submitted [https://bugzilla.nasm.us/show_bug.cgi?id=3392445]
CVE: CVE-2018-8882
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 asm/float.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/asm/float.c b/asm/float.c
index dcf69fea..2965d3db 100644
--- a/asm/float.c
+++ b/asm/float.c
@@ -608,6 +608,8 @@ static void ieee_shr(fp_limb *mant, int i)
         if (offs)
             for (j = MANT_LIMBS-1; j >= offs; j--)
                 mant[j] = mant[j-offs];
+    } else if (MANT_LIMBS-1-offs < 0) {
+        j = MANT_LIMBS-1;
     } else {
         n = mant[MANT_LIMBS-1-offs] >> sr;
         for (j = MANT_LIMBS-1; j > offs; j--) {
-- 
2.17.1

