I found that there is a possible segfaults problem in the function agcep, which is defined in _agcep.c. The problem will happen when agcep are called multiple times with different stage values.
A quick illustration of the problem:
line #101
eg[m] = d[stage * m - 1];
When agcep are called multiple times with difference stage values, this line may cause segfault, since memory will not be re-allocated when the larger value is specified to stage (e.g, stage = 1 for the first call and stage = 2 for the second call).
My fix:
line #89 ~ 96
- size = m;
+ size = m * stage;
}
- if (m > size) {
+ if (m * stage > size) {
free(eg);
eg = dgetmem(2 * (m + 1) + m * stage);
ep = eg + m + 1;
d = ep + m + 1;
- size = m;
+ size = m * stage;
I think this will fix the problem, though the function agcep is never used in the agcep command which algorithm is written in agcep.c as a separate (duplicate?) program and the problem doesn't appear for most users.
I hope you can take a look at the code and my fix as well.
I found the same issue in _amcep.c.
Line #86 ~ 100
This should fix the problem.
I also found the same problem in _acep.c (perhaps in others, I guess). I think this would be a serious problem for embedded programs that link with SPTK internally.
Hi,
Thank you for using SPTK and your kindly report.
I'll check them.
Keiichiro
Hi,
Thank you for your report.
It was fixed.
http://sp-tk.cvs.sourceforge.net/viewvc/sp-tk/SPTK/src/bin/agcep/_agcep.c?r1=1.18&r2=1.19
Hi, this doesn't seem to be fixed entirely. I've quickly looked into the SPTK-3.10 and there was still this kind of bug, at least in _amcep.c, _acep.c and _fftcep.c. Please consider the following pathces:
_amcep.c
_acep.c
_fftcep.c
Thank you very much. It was fixed.