Hi,
On Fri, Nov 30, Dr. Werner Fink wrote:
Maybe some more checks are required as if n != 4 this could be that one of the variables are not used and therefore not initialized.
Before sscanf() this could be a `memset(language, 0, sizeof(language));' or more simple a `*language = 0;' depending on the type of language. Also the code
if (n != 4 || isempty(description)) { free(description); description = NULL; }
could become
if (n != 4 || isempty(description)) { if (description) free(description); description = NULL; }
as well as the line
esyslog("dbloms: "%X" "%02X" "%7s" "%s"", Stream, Type, language, description);
may look like
esyslog("dbloms: "%X" "%02X" "%7s" "%s"", Stream, Type, language, description ? description : "");
may code looks like:
--snip-- bool tComponent::FromString(const char *s) { unsigned int Stream, Type; description = NULL; int n = sscanf(s, "%X %02X %7s %as[^\n]", &Stream, &Type, language, &description); // 7 = MAXLANGCODE2 - 1 esyslog("dbloms: "%X" "%02X" "%7s" "%s"", Stream, Type, language, description ? description : "");
if (n != 4 || isempty(description)) { if (description) free(description); description = NULL; } stream = Stream; type = Type; return n >= 3; } --snip--
and I get a core dump like:
--snip-- vdrservernew:/usr/src/vdr-1.7.32# gdb --core /tmp/core /usr/local/bin/vdr GNU gdb (GDB) 7.5 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-unknown-linux-gnu". For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /usr/local/bin/vdr...done. [New LWP 2829] [New LWP 2830] [New LWP 2828] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/libthread_db.so.1". Core was generated by `/usr/local/bin/vdr --config=/etc/vdr --epgfile=/tmp/epg.data --grab=/dev/shm --'. Program terminated with signal 11, Segmentation fault. #0 0x0000799a5fbbe3b3 in strnlen () from /lib/libc.so.0.9.32 (gdb) bt #0 0x0000799a5fbbe3b3 in strnlen () from /lib/libc.so.0.9.32 #1 0x0000799a5fbb7f56 in ?? () from /lib/libc.so.0.9.32 #2 0x0000799a5fbb55dc in vsnprintf () from /lib/libc.so.0.9.32 #3 0x0000799a5fbacc29 in vsyslog () from /lib/libc.so.0.9.32 #4 0x000000000052e570 in syslog_with_tid (priority=3, format=0x551b18 "dbloms: "%X" "%02X" "%7s" "%s"") at tools.c:40 #5 0x00000000004a1bbd in tComponent::FromString (this=0x22a24b0, s=<optimized out>) at epg.c:37 #6 0x00000000004a4197 in SetComponent (s=<optimized out>, Index=0, this=0x22ad550) at epg.c:85 #7 cEvent::Parse (this=<optimized out>, s=<optimized out>) at epg.c:499 #8 0x00000000004e9f76 in cRecordingInfo::Read (this=0x22a50e0, f=f@entry=0x22a1f00) at recording.c:468 #9 0x00000000004eb5b3 in cRecording::cRecording (this=0x22a2210, FileName=0x22a0fdc "Sex_and_the_City_2/2012-11-19.20.10.27-0.rec") at recording.c:723 #10 0x00000000004ecf81 in cRecordings::ScanVideoDir (this=0x7fe900 <Recordings>, DirName=0x229aca0 "/remote/vdr/Sex_and_the_City_2", Foreground=false, LinkLevel=0) at recording.c:1165 #11 0x00000000004ed3fc in cRecordings::ScanVideoDir (this=0x7fe900 <Recordings>, DirName=0x2285390 "/remote/vdr", Foreground=false, LinkLevel=0) at recording.c:1180 #12 0x0000000000526a1e in cThread::StartThread (Thread=0x7fe920 <Recordings+32>) at thread.c:262 #13 0x0000799a614e2406 in start_thread () from /lib/libpthread.so.0.9.32 #14 0x0000799a614da885 in clone () from /lib/libpthread.so.0.9.32 #15 0x0000000000000000 in ?? () (gdb) --snip--