Debian Codegraph @

debian/patches/klatt-garbage

raw
1 commit 7e304a41295fa6b4458f759e8ac70f86b61b26e5
2 Author: Samuel Thibault <[email protected]>
3 Date: Sun Dec 15 23:44:10 2024 +0100
4
5 klatt: Fix out-of-bound access
6
7 klatt should watch for wdata->mix_wavefile_max like others do already.
8
9 Probably we should actually be scaling the wave according to
10 speed.wav_factor rather than backwarding by 3/4, but for now let's at least
11 fix the garbage introduced in the klatt case (which was also getting noticed
12 on big-endian archs where the garbage is different).
13
14 diff --git a/src/libespeak-ng/klatt.c b/src/libespeak-ng/klatt.c
15 index dfadcfd9..db389199 100644
16 --- a/src/libespeak-ng/klatt.c
17 +++ b/src/libespeak-ng/klatt.c
18 @@ -380,16 +380,19 @@ static int parwave(klatt_frame_ptr frame, WGEN_DATA *wdata)
19 if (wdata->mix_wavefile_ix < wdata->n_mix_wavefile) {
20 if (wdata->mix_wave_scale == 0) {
21 // a 16 bit sample
22 - c = wdata->mix_wavefile[wdata->mix_wavefile_ix+1];
23 - sample = wdata->mix_wavefile[wdata->mix_wavefile_ix] + (c * 256);
24 + c = wdata->mix_wavefile[wdata->mix_wavefile_ix+wdata->mix_wavefile_offset+1];
25 + sample = wdata->mix_wavefile[wdata->mix_wavefile_ix+wdata->mix_wavefile_offset] + (c * 256);
26 wdata->mix_wavefile_ix += 2;
27 } else {
28 // a 8 bit sample, scaled
29 - sample = (signed char)wdata->mix_wavefile[wdata->mix_wavefile_ix++] * wdata->mix_wave_scale;
30 + sample = (signed char)wdata->mix_wavefile[wdata->mix_wavefile_offset+wdata->mix_wavefile_ix++] * wdata->mix_wave_scale;
31 }
32 int z2 = sample * wdata->amplitude_v / 1024;
33 z2 = (z2 * wdata->mix_wave_amp)/40;
34 temp += z2;
35 +
36 + if ((wdata->mix_wavefile_ix + wdata->mix_wavefile_offset) >= wdata->mix_wavefile_max) // reached the end of available WAV data
37 + wdata->mix_wavefile_offset -= (wdata->mix_wavefile_max*3)/4;
38 }
39
40 if (kt_globals.fadein < 64) {
41 diff --git a/tests/klatt.test b/tests/klatt.test
42 index 280de7bf..c0849f23 100755
43 --- a/tests/klatt.test
44 +++ b/tests/klatt.test
45 @@ -4,8 +4,8 @@
46 # and run needed checks before
47 is_hash
48 # call actual test functions
49 -test_wav en+klatt "8155a2249db8f6fe5f3b1d4fd00c35d09ceb6c82" "The quick brown fox jumps over the lazy dog"
50 -test_wav en+klatt2 "90559a2ff9973c3ccf1eb7e71579fedfedbd3c67" "The quick brown fox jumps over the lazy dog"
51 -test_wav en+klatt3 "a636bc97d68fbec753c7cecc718b539c87627095" "The quick brown fox jumps over the lazy dog"
52 -test_wav en+klatt4 "653e243019c9462c7a9a90f4b03326d45b45f41c" "The quick brown fox jumps over the lazy dog"
53 -test_wav en+klatt5 "6665329b413244b9846533ce207f0ee3d6e55094" "The quick brown fox jumps over the lazy dog"
54 +test_wav en+klatt "696213dbbceecf20c3f80d771aab5757e05181c0" "The quick brown fox jumps over the lazy dog"
55 +test_wav en+klatt2 "e55bf0a5cd96d648177f743557c67a791da03f7b" "The quick brown fox jumps over the lazy dog"
56 +test_wav en+klatt3 "9ed890d032b1bed4a4ef1e3380b68133d0342429" "The quick brown fox jumps over the lazy dog"
57 +test_wav en+klatt4 "77243123d96113ab747200c5312e4945af4e16f3" "The quick brown fox jumps over the lazy dog"
58 +test_wav en+klatt5 "6426725d6c5a9053862a5251ff9c1e0a58c29e9b" "The quick brown fox jumps over the lazy dog"