[opensuse-programming] Next issue: libmodplug
Hi, Sorry for the noise on this otherwise sooo quiet mailinglist. I have a package that fails building (own obs). the issue is not really of packaging nature (it works up to 11.0) but is actually a code issue. The build log says: I: Statement is overflowing a buffer E: libmodplug bufferoverflow load_pat.cpp:1321 Which ends up to be in this loop: for(t=1; t<of->m_nInstruments; t++) { // xmms modplug doesn't use slot zero if( (of->Headers[t] = new INSTRUMENTHEADER) == NULL ) return FALSE; memset(of->Headers[t], 0, sizeof(INSTRUMENTHEADER)); PATinst(of->Headers[t], t, pat_smptogm(t)); } from the buildlog, I think the 'most' interesting part would be g++ -DHAVE_CONFIG_H -I. -I. -I. -Ilibmodplug -march=i586 -mtune=i686 -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasy nchronous-unwind-tables -fPIC -march=i586 -mtune=i686 -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwin d-tables -fno-exceptions -Wall -ffast-math -D_REENTRANT -MT load_pat.lo -MD -MP -MF .deps/load_pat.Tpo -c load_pat.cpp -o load_pat.o load_pat.cpp: In function 'void pat_init_patnames()': load_pat.cpp:367: warning: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result load_pat.cpp:390: warning: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result load_pat.cpp: In function 'void pat_read_layerheader(FILE*, LayerHeader*)': load_pat.cpp:435: warning: ignoring return value of 'size_t fread(void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result load_pat.cpp: In function 'void pat_read_waveheader(FILE*, WaveHeader*, int)': load_pat.cpp:465: warning: ignoring return value of 'size_t fread(void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result load_pat.cpp:473: warning: ignoring return value of 'size_t fread(void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result load_pat.cpp:487: warning: ignoring return value of 'size_t fread(void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result load_pat.cpp: In function 'void pat_readpat(int, char*, int)': load_pat.cpp:649: warning: ignoring return value of 'size_t fread(void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result In function 'char* strncpy(char*, const char*, size_t)', inlined from 'void PATinst(INSTRUMENTHEADER*, int, int)' at load_pat.cpp:1147, inlined from 'BOOL PAT_Load_Instruments(void*)' at load_pat.cpp:1321: /usr/include/bits/string3.h:122: warning: call to char* __builtin___strncpy_chk(char*, const char*, unsigned int, unsigned int) will always overflow destinat ion buffer Any ideas on how I can fix that one? (Sorry... I do some coding.. but I'm pretty much at my beginnings with this... and this at my high age) Thanks for giving any pointers possible or, if needed, I can provide more information if this helps. Dominique -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
* Dominique Leuenberger (Dominique.Leuenberger@TMF-Group.com) [20081219 14:47]:
Which ends up to be in this loop:
for(t=1; t<of->m_nInstruments; t++) { // xmms modplug doesn't use slot zero if( (of->Headers[t] = new INSTRUMENTHEADER) == NULL ) return FALSE; memset(of->Headers[t], 0, sizeof(INSTRUMENTHEADER)); PATinst(of->Headers[t], t, pat_smptogm(t)); }
I'd try memset(of->Headers[t], 0, sizeof(of->Headers[t]); Philipp -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
>>> On 12/19/2008 at 3:13 PM, Philipp Thomaswrote: > * Dominique Leuenberger (Dominique.Leuenberger@TMF-Group.com) [20081219 > 14:47]: > >> Which ends up to be in this loop: >> >> for(t=1; t m_nInstruments; t++) { // xmms modplug doesn't use slot > zero >> if( (of->Headers[t] = new INSTRUMENTHEADER) == NULL ) return > FALSE; >> memset(of->Headers[t], 0, sizeof(INSTRUMENTHEADER)); >> PATinst(of->Headers[t], t, pat_smptogm(t)); >> } >> > > I'd try > > memset(of->Headers[t], 0, sizeof(of->Headers[t]); > > Philipp Can you explain this? Creating the patch is one thing; but I atually prefer also understanding the background. And I did not specify in my mail that the line failing is the one with PATinst(), just in case that makes a difference. Of course only if you have time for such things... Dominique -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
Philipp Thomas wrote:
* Dominique Leuenberger (Dominique.Leuenberger@TMF-Group.com) [20081219 14:47]:
Which ends up to be in this loop:
for(t=1; t<of->m_nInstruments; t++) { // xmms modplug doesn't use slot zero if( (of->Headers[t] = new INSTRUMENTHEADER) == NULL ) return FALSE; memset(of->Headers[t], 0, sizeof(INSTRUMENTHEADER)); PATinst(of->Headers[t], t, pat_smptogm(t)); }
I'd try
memset(of->Headers[t], 0, sizeof(of->Headers[t]);
Philipp
Actually the memset line looks correct. The above won't work because of->Headers[t] is a pointer, the size of which is going to be 4bytes on most platforms, as you can tell from it being assigned from the new command. That is probably not what the author intended. If you look at the output in the original posting you see: ########## In function 'char* strncpy(char*, const char*, size_t)', inlined from 'void PATinst(INSTRUMENTHEADER*, int, int)' at load_pat.cpp:1147, inlined from 'BOOL PAT_Load_Instruments(void*)' at load_pat.cpp:1321: /usr/include/bits/string3.h:122: warning: call to char* __builtin___strncpy_chk(char*, const char*, unsigned int, unsigned int) will always overflow destinat ion buffer ########### This looks to me like the overflow is happening somewhere in the code of PATinst(of->Headers[t], t, pat_smptogm(t)); which we can't see from his posting. -- kr -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
On 12/19/2008 at 3:32 PM, "K.R. Foley"
wrote: ########## In function 'char* strncpy(char*, const char*, size_t)', inlined from 'void PATinst(INSTRUMENTHEADER*, int, int)' at load_pat.cpp:1147, inlined from 'BOOL PAT_Load_Instruments(void*)' at load_pat.cpp:1321: /usr/include/bits/string3.h:122: warning: call to char* __builtin___strncpy_chk(char*, const char*, unsigned int, unsigned int) will always overflow destinat ion buffer ########### This looks to me like the overflow is happening somewhere in the code of PATinst(of->Headers[t], t, pat_smptogm(t));
which we can't see from his posting.
Thanks... I 'interpret' that giving the function PATinst might sched some more light on the case, so here it is... (sorry, it's long) #ifdef NEWMIKMOD static void PATinst(UNIMOD *of, INSTRUMENT *d, int smp, int gm) #else static void PATinst(INSTRUMENTHEADER *d, int smp, int gm) #endif { WaveHeader hw; char s[32]; memset(s,0,32); if( pat_readpat_attr(gm-1, &hw, 0) ) { pat_setpat_inst(&hw, d, smp); } else { hw.modes = PAT_16BIT|PAT_ENVELOPE|PAT_SUSTAIN|PAT_LOOP; hw.start_loop = 0; hw.end_loop = 30000; hw.wave_size = 30000; // envelope rates and offsets pinched from timidity's acpiano.pat sample no 1 hw.envelope_rate[0] = 0x3f; hw.envelope_rate[1] = 0x3f; hw.envelope_rate[2] = 0x3f; hw.envelope_rate[3] = 0x08|(3<<6); hw.envelope_rate[4] = 0x3f; hw.envelope_rate[5] = 0x3f; hw.envelope_offset[0] = 246; hw.envelope_offset[1] = 246; hw.envelope_offset[2] = 246; hw.envelope_offset[3] = 0; hw.envelope_offset[4] = 0; hw.envelope_offset[5] = 0; strncpy(hw.reserved, midipat[gm-1], 36); pat_setpat_inst(&hw, d, smp); } if( hw.reserved[0] ) strncpy(s, hw.reserved, 32); else strncpy(s, midipat[gm-1], 32); #ifdef NEWMIKMOD d->insname = DupStr(of->allochandle, s,28); #else s[31] = '\0'; memset(d->name, 0, 32); strcpy((char *)d->name, s); strncpy(s, midipat[gm-1], 12); s[11] = '\0'; memset(d->filename, 0, 12); strcpy((char *)d->filename, s); #endif } Dominique -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
* Dominique Leuenberger (Dominique.Leuenberger@TMF-Group.com) [20081219 15:39]:
Thanks... I 'interpret' that giving the function PATinst might sched some more light on the case, so here it is...
Please just give the URL to that package so that we can check the sources ourselves. Just posting the function doesn't suffice as additional definitions (probably from headers) are missing. Philipp -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
* Dominique Leuenberger (Dominique.Leuenberger@TMF-Group.com) [20081219 14:47]:
Hi,
I have a package that fails building (own obs).
Full URL please so that I can check the code myself. Philipp -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
>>> On 12/19/2008 at 3:43 PM, Philipp Thomaswrote: > * Dominique Leuenberger (Dominique.Leuenberger@TMF-Group.com) [20081219 > 14:47]: >> Hi, > >> I have a package that fails building (own obs). > > Full URL please so that I can check the code myself. Philipp OBS is on a private net, but the package to be build is libmodplug 0.8.4 http://sourceforge.net/projects/modplug-xmms/ Dominique -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
participants (3)
-
Dominique Leuenberger
-
K.R. Foley
-
Philipp Thomas