Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/mlp.c
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2013-10-22 01:53:48 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2013-10-22 01:58:03 +0400
commitd6b56793d84490e78c91afcb3af96071094b7292 (patch)
tree3eed1eb854cf72f6a66f54ddf05f525f94f6c6ef /src/mlp.c
parente8f18c403cdafd012cc90df172ad9f7d6d07b2ab (diff)
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.
Diffstat (limited to 'src/mlp.c')
-rw-r--r--src/mlp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/mlp.c b/src/mlp.c
index 73b1d315..56040bd7 100644
--- a/src/mlp.c
+++ b/src/mlp.c
@@ -67,9 +67,10 @@ static inline float tansig_approx(float x)
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)
{