Opened 5 weeks ago

#2434 new defect

Out of bounds read in vobsub_queue_reseek.

Reported by: wififreedom Owned by: beastd
Priority: normal Component: undetermined
Version: unspecified Severity: blocker
Keywords: Cc:
Blocked By: Blocking:
Reproduced by developer: no Analyzed by developer: no

Description

Detected while analyzing ​​https://trac.mplayerhq.hu/ticket/2432

Out of bounds read detected with valgrind.

mplayer svn revision r38688.

How to reproduce:

+ valgrind /home/user/repos/svn/mplayer/mplayer -really-quiet -vo jpeg -vobsub sub-0 -vobsubid 0 subtest.mp4
==523839== Memcheck, a memory error detector
==523839== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==523839== Using Valgrind-3.26.0 and LibVEX; rerun with -h for copyright info
==523839== Command: /home/user/repos/svn/mplayer/mplayer -really-quiet -vo jpeg -vobsub sub-0 -vobsubid 0 subtest.mp4
...
==523839== Invalid read of size 4
==523839==    at 0x428DD54: vobsub_queue_reseek (vobsub.c:1092)
==523839==    by 0x428FF41: vobsub_get_packet (vobsub.c:1124)
==523839==    by 0x41C5181: update_subtitles (mpcommon.c:222)
==523839==    by 0x4177502: generate_video_frame (mplayer.c:1805)
==523839==    by 0x4177502: update_video (mplayer.c:2525)
==523839==    by 0x416BAA3: main (mplayer.c:3820)
==523839==  Address 0x832bd00 is 0 bytes after a block of size 32 alloc'd
==523839==    at 0x703C858: malloc (vg_replace_malloc.c:447)
==523839==    by 0x428DFC9: packet_queue_ensure (vobsub.c:545)
==523839==    by 0x428EB88: packet_queue_grow (vobsub.c:559)
==523839==    by 0x428EB88: vobsub_add_timestamp (vobsub.c:662)
==523839==    by 0x428EB88: vobsub_parse_timestamp (vobsub.c:705)
==523839==    by 0x428EB88: vobsub_parse_one_line (vobsub.c:810)
==523839==    by 0x428EB88: vobsub_open (vobsub.c:928)
==523839==    by 0x4175B36: add_vob_subtitle (mplayer.c:1116)
==523839==    by 0x4169742: main (mplayer.c:3228)
==523839== 
==523839== 
==523839== HEAP SUMMARY:
==523839==     in use at exit: 50,603 bytes in 64 blocks
==523839==   total heap usage: 7,349 allocs, 7,285 frees, 11,619,682 bytes allocated
==523839== 
==523839== LEAK SUMMARY:
==523839==    definitely lost: 3 bytes in 1 blocks
==523839==    indirectly lost: 0 bytes in 0 blocks
==523839==      possibly lost: 0 bytes in 0 blocks
==523839==    still reachable: 50,600 bytes in 63 blocks
==523839==         suppressed: 0 bytes in 0 blocks
==523839== Rerun with --leak-check=full to see details of leaked memory
==523839== 
==523839== For lists of detected and suppressed errors, rerun with: -s
==523839== ERROR SUMMARY: 199 errors from 3 contexts (suppressed: 0 from 0)
  • first call to vobsub_queue_reseek leaves queue->current_index = 1, queue->packets_size = 1, queue->packets_reserve = 1.
  • second call to vobsub_queue_reseek accesses packet at queue->current_index = 1 (past the end) without first checking if queue->current_index < queue->packets_size.

I will attach the script and small C program that produced this.

Attachments (2)

subtest.c​ (5.5 KB ) - added by wififreedom 5 weeks ago.
C program to generate the .sub and .idx files
run.sh​ (588 bytes ) - added by wififreedom 5 weeks ago.
Script to build the C program and run valgrind with the test output.

Download all attachments as: .zip

Change History (2)

by wififreedom, 5 weeks ago

Attachment: subtest.c​ added

C program to generate the .sub and .idx files

by wififreedom, 5 weeks ago

Attachment: run.sh​ added

Script to build the C program and run valgrind with the test output.

Note: See TracTickets for help on using tickets.