{"action":"created","issue":{"url":"https://api.github.com/repos/bas-t/descrambler/issues/8","repository_url":"https://api.github.com/repos/bas-t/descrambler","labels_url":"https://api.github.com/repos/bas-t/descrambler/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/bas-t/descrambler/issues/8/comments","events_url":"https://api.github.com/repos/bas-t/descrambler/issues/8/events","html_url":"https://github.com/bas-t/descrambler/issues/8","id":184948238,"number":8,"title":"segfault in plugin_getsid","user":{"login":"HSchill","id":23040016,"avatar_url":"https://avatars.githubusercontent.com/u/23040016?v=3","gravatar_id":"","url":"https://api.github.com/users/HSchill","html_url":"https://github.com/HSchill","followers_url":"https://api.github.com/users/HSchill/followers","following_url":"https://api.github.com/users/HSchill/following{/other_user}","gists_url":"https://api.github.com/users/HSchill/gists{/gist_id}","starred_url":"https://api.github.com/users/HSchill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HSchill/subscriptions","organizations_url":"https://api.github.com/users/HSchill/orgs","repos_url":"https://api.github.com/users/HSchill/repos","events_url":"https://api.github.com/users/HSchill/events{/privacy}","received_events_url":"https://api.github.com/users/HSchill/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-24T20:38:11Z","updated_at":"2016-10-24T21:35:44Z","closed_at":null,"body":"Hi \r\nI had two segfaults in plugin_getsid.c but both hade same root cause.\r\n NULL pointer usage  In function static int start(char *dmxdev... ) \r\n After macro \"ll_find_elem(filt, ... \" \r\n\r\nThere will be segfaults in function read_pmt()  or when using filt->  3 rows further down.\r\n          if(ret < 0) {\r\n              filt->parse_err++;\r\n\r\nThis simple patch solves the problem:\r\n```\r\ndiff --git a/src/plugin_getsid.c b/src/plugin_getsid.c\r\nindex f157c02..9cd1e02 100644\r\n--- a/src/plugin_getsid.c\r\n+++ b/src/plugin_getsid.c\r\n@@ -597,6 +597,8 @@ static int start(char *dmxdev, struct sid_data *sid_data, int timeout) {\r\n           struct filter *filt;\r\n           dprintf3(\"Read %d bytes\\n\", size);\r\n           ll_find_elem(filt, pat.dmx_filter_ll, fd, pollfd[i].fd, struct filter);\r\n+         if (!filt)\r\n+           goto exit;\r\n           int ret = read_pmt(pes, filt, sid_data, size);\r\n           if(ret < 0) {\r\n              filt->parse_err++;\r\n\r\n```\r\nHere is a back trace of a core dump.\r\n\r\n```\r\nThread 31 \"ffdecsawrapper\" received signal SIGSEGV, Segmentation fault.\r\n[Switching to Thread 0x7ffff7ead700 (LWP 14536)]\r\n0x0000000000470329 in start (dmxdev=0x7ffff7eace00 \"/dev/dvb/adapter3/demux0\", sid_data=0x7b0730, timeout=200) at src/plugin_getsid.c:602\r\n602                  filt->parse_err++;\r\n(gdb) \r\n(gdb) bt full\r\n#0  0x0000000000470329 in start (dmxdev=0x7ffff7eace00 \"/dev/dvb/adapter3/demux0\", sid_data=0x7b0730, timeout=200) at src/plugin_getsid.c:602\r\n        filt = 0x0\r\n        ret = -1\r\n        count = 45\r\n        num_filters = 45\r\n        found = 13\r\n        pes = \"G\\004)\\324Ma\\315ո\\222\\267L\\255\\a\\r)\\322\\033\\001\\225\\021쒊\\202.-\\303\\377\\065\\233\\032\\203\\310\\002\\222&\\335\\357#\\375\\221l\\022\\363\\061\\274\\065\\316զ\\275PL\\340\\341\\062\\371\\003\\240\\006 \\301x\\343s\\224\\313\\\\\\355\\266'(\\037b\\310}\\177\\201\\366q\\372e\\366k\\225\\233\\206\\210\\365\\201\\211\\b\\232\\357_\\307\\303Bߔ\\255\\066\\277F?\\247\\021\\207Z\\254\\260f\\317\\342b'\\254<\\331>\\271\\177\\242\\275h\\023\\323\\337\\357\\346\\222N\\320\\004`\\037\\240\\371l\\301,)S\\004\\241A`\\032\\000I\\000U\\025\\274\\276\\361)8:K\\252\\202\\373\\032ǭ\\311\\342uʖ\\017fR\\261WR\\204\\376\\335\\035yR\\367\\v\\247\\322G\\004)\\325\\343Z\\257\\200d\\270\\236I\\353\\307\\037\\017\\304\\365^\"...\r\n        pfd = {fd = 7, events = 1, revents = 1}\r\n        pollfd = {{fd = 5, events = 5, revents = 1}, {fd = 5, events = 5, revents = 1}, {fd = 5, events = 5, revents = 1}, {fd = 5, events = 5, revents = 1}, {fd = 5, events = 5, revents = 1}, {fd = 5, events = 5, revents = 1}, {fd = 5, events = 1, \r\n            revents = 1}, {fd = 69, events = 1, revents = 0}, {fd = 70, events = 1, revents = 0}, {fd = 71, events = 1, revents = 0}, {fd = 72, events = 1, revents = 0}, {fd = 73, events = 1, revents = 0}, {fd = 74, events = 1, revents = 0}, {fd = 75, \r\n            events = 1, revents = 0}, {fd = 76, events = 1, revents = 0}, {fd = 77, events = 1, revents = 0}, {fd = 78, events = 1, revents = 0}, {fd = 79, events = 1, revents = 0}, {fd = 80, events = 1, revents = 0}, {fd = 81, events = 1, revents = 0}, {\r\n            fd = 82, events = 1, revents = 0}, {fd = 83, events = 1, revents = 0}, {fd = 84, events = 1, revents = 0}, {fd = 85, events = 1, revents = 0}, {fd = 86, events = 1, revents = 0}, {fd = 87, events = 1, revents = 0}, {fd = 88, events = 1, \r\n            revents = 0}, {fd = 89, events = 1, revents = 0}, {fd = 90, events = 1, revents = 0}, {fd = 91, events = 1, revents = 0}, {fd = 92, events = 1, revents = 0}, {fd = 93, events = 1, revents = 0}}\r\n        pollretries = {5 <repeats 32 times>}\r\n        pat_restart = 0\r\n        done = 1\r\n        size = 940\r\n        i = 0\r\n        ret = 0\r\n        pat = {patfd = 7, version = 8, last_section = 0 '\\000', section_seen = \"\\001\\000\\000\\000\", has_nit = 16, dmx_filter_ll = {next = 0x7fffa4009fe0, prev = 0x7fffb80008c0, priority = 4294967295}}\r\n        lptr = 0x7ffff7eabb98\r\n#1  0x0000000000470822 in read_sid (arg=0x7b0730) at src/plugin_getsid.c:710\r\n        sid_data = 0x7b0730\r\n        sid_ll = 0x0\r\n        dmxcmd = 0x7fffbc1e8f00\r\n        dmxdev = \"/dev/dvb/adapter3/demux0\", '\\000' <repeats 231 times>\r\n        ret = 0\r\n#2  0x00007ffff75456fa in start_thread (arg=0x7ffff7ead700) at pthread_create.c:333\r\n        __res = <optimized out>\r\n        pd = 0x7ffff7ead700\r\n        now = <optimized out>\r\n        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140737352750848, -6612622759983783371, 0, 140737488342575, 140737352751552, 0, 6612640462249452085, 6612638894808293941}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, \r\n              cleanup = 0x0, canceltype = 0}}}\r\n        not_first_call = <optimized out>\r\n        pagesize_m1 = <optimized out>\r\n        sp = <optimized out>\r\n        freesize = <optimized out>\r\n        __PRETTY_FUNCTION__ = \"start_thread\"\r\n#3  0x00007ffff69dab5d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/bas-t/descrambler/issues/comments/255873271","html_url":"https://github.com/bas-t/descrambler/issues/8#issuecomment-255873271","issue_url":"https://api.github.com/repos/bas-t/descrambler/issues/8","id":255873271,"user":{"login":"bas-t","id":778694,"avatar_url":"https://avatars.githubusercontent.com/u/778694?v=3","gravatar_id":"","url":"https://api.github.com/users/bas-t","html_url":"https://github.com/bas-t","followers_url":"https://api.github.com/users/bas-t/followers","following_url":"https://api.github.com/users/bas-t/following{/other_user}","gists_url":"https://api.github.com/users/bas-t/gists{/gist_id}","starred_url":"https://api.github.com/users/bas-t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bas-t/subscriptions","organizations_url":"https://api.github.com/users/bas-t/orgs","repos_url":"https://api.github.com/users/bas-t/repos","events_url":"https://api.github.com/users/bas-t/events{/privacy}","received_events_url":"https://api.github.com/users/bas-t/received_events","type":"User","site_admin":false},"created_at":"2016-10-24T21:35:43Z","updated_at":"2016-10-24T21:35:43Z","body":"Can you please elaborate some more, I've never seen those segfaults.\r\nLike OS, kernel version and so on.\r\nHow to reproduce?"}}
{"actor":{"display_login":"bas-t"}}