shithub: opus

Download patch

ref: d6b56793d84490e78c91afcb3af96071094b7292
parent: e8f18c403cdafd012cc90df172ad9f7d6d07b2ab
author: Jean-Marc Valin <[email protected]>
date: Mon Oct 21 13:53:48 EDT 2013

Fixes a potential crash when encoding NaNs

This fixes tansig_approx() to avoid crashing when the input is NaN.
The problem could only be triggered when calling the float API with
a float build at a complexity of 7 or more (i.e. analysis called).
Since the crash was due to an out-of-bound read (typically the index
is INT_MIN), it's unlikely to be exploitable in any other way than
causing a crash.

--- a/src/mlp.c
+++ b/src/mlp.c
@@ -67,9 +67,10 @@
 	int i;
 	float y, dy;
 	float sign=1;
-    if (x>=8)
+	/* Tests are reversed to catch NaNs */
+    if (!(x<8))
         return 1;
-    if (x<=-8)
+    if (!(x>-8))
         return -1;
 	if (x<0)
 	{