[xiph-commits] r12765 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Thu Mar 15 16:32:40 PDT 2007
Author: jm
Date: 2007-03-15 16:32:36 -0700 (Thu, 15 Mar 2007)
New Revision: 12765
Modified:
trunk/speex/libspeex/filters.c
trunk/speex/libspeex/filters.h
trunk/speex/libspeex/nb_celp.c
Log:
Doing some sanity checking (just in case) on the propagated long-term
prediction
Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c 2007-03-15 13:13:25 UTC (rev 12764)
+++ trunk/speex/libspeex/filters.c 2007-03-15 23:32:36 UTC (rev 12765)
@@ -62,6 +62,24 @@
}
}
+void sanitize_values32(spx_word32_t *vec, spx_word32_t min_val, spx_word32_t max_val, int len)
+{
+ int i;
+ for (i=0;i<len;i++)
+ {
+ /* It's important we do the test that way so we can catch NaNs, which are neither greater nor smaller */
+ if (!(vec[i]>=min_val && vec[i] <= max_val))
+ {
+ if (vec[i] < min_val)
+ vec[i] = min_val;
+ else if (vec[i] > max_val)
+ vec[i] = max_val;
+ else /* Has to be NaN */
+ vec[i] = 0;
+ }
+ }
+}
+
void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem)
{
int i;
Modified: trunk/speex/libspeex/filters.h
===================================================================
--- trunk/speex/libspeex/filters.h 2007-03-15 13:13:25 UTC (rev 12764)
+++ trunk/speex/libspeex/filters.h 2007-03-15 23:32:36 UTC (rev 12765)
@@ -67,6 +67,7 @@
/* Apply bandwidth expansion on LPC coef */
void bw_lpc(spx_word16_t , const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order);
+void sanitize_values32(spx_word32_t *vec, spx_word32_t min_val, spx_word32_t max_val, int len);
void syn_percep_zero16(const spx_word16_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack);
Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c 2007-03-15 13:13:25 UTC (rev 12764)
+++ trunk/speex/libspeex/nb_celp.c 2007-03-15 23:32:36 UTC (rev 12765)
@@ -1526,7 +1526,11 @@
#ifdef EPIC_48K
}
#endif
-
+ /* Ensuring that things aren't blowing up as would happen if e.g. an encoder is
+ crafting packets to make us produce NaNs and slow down the decoder (vague DoS threat).
+ We can probably be even more aggressive and limit to 15000 or so. */
+ sanitize_values32(exc32, NEG32(QCONST32(32000,SIG_SHIFT-1)), QCONST32(32000,SIG_SHIFT-1), st->subframeSize);
+
tmp = gain_3tap_to_1tap(pitch_gain);
pitch_average += tmp;
More information about the commits
mailing list