comparison aac.c @ 7871:8277c41b7160 libavcodec

Validate pulse position and error out if an invalid position is encountered. Patch by Alex Converse (alex converse gmail com)
author superdump
date Tue, 16 Sep 2008 15:59:43 +0000
parents f75806078d46
children fdd3e68dcf94
comparison
equal deleted inserted replaced
7870:08ef30f08a01 7871:8277c41b7160
592 } 592 }
593 593
594 /** 594 /**
595 * Decode pulse data; reference: table 4.7. 595 * Decode pulse data; reference: table 4.7.
596 */ 596 */
597 static void decode_pulses(Pulse * pulse, GetBitContext * gb, const uint16_t * swb_offset) { 597 static int decode_pulses(Pulse * pulse, GetBitContext * gb, const uint16_t * swb_offset, int num_swb) {
598 int i; 598 int i, pulse_swb;
599 pulse->num_pulse = get_bits(gb, 2) + 1; 599 pulse->num_pulse = get_bits(gb, 2) + 1;
600 pulse->pos[0] = swb_offset[get_bits(gb, 6)]; 600 pulse_swb = get_bits(gb, 6);
601 if (pulse_swb >= num_swb)
602 return -1;
603 pulse->pos[0] = swb_offset[pulse_swb];
601 pulse->pos[0] += get_bits(gb, 5); 604 pulse->pos[0] += get_bits(gb, 5);
605 if (pulse->pos[0] > 1023)
606 return -1;
602 pulse->amp[0] = get_bits(gb, 4); 607 pulse->amp[0] = get_bits(gb, 4);
603 for (i = 1; i < pulse->num_pulse; i++) { 608 for (i = 1; i < pulse->num_pulse; i++) {
604 pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i-1]; 609 pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i-1];
610 if (pulse->pos[i] > 1023)
611 return -1;
605 pulse->amp[i] = get_bits(gb, 4); 612 pulse->amp[i] = get_bits(gb, 4);
606 } 613 }
614 return 0;
607 } 615 }
608 616
609 /** 617 /**
610 * Decode Temporal Noise Shaping data; reference: table 4.48. 618 * Decode Temporal Noise Shaping data; reference: table 4.48.
611 * 619 *
809 if ((pulse_present = get_bits1(gb))) { 817 if ((pulse_present = get_bits1(gb))) {
810 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { 818 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
811 av_log(ac->avccontext, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n"); 819 av_log(ac->avccontext, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n");
812 return -1; 820 return -1;
813 } 821 }
814 decode_pulses(&pulse, gb, ics->swb_offset); 822 if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) {
823 av_log(ac->avccontext, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n");
824 return -1;
825 }
815 } 826 }
816 if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics)) 827 if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
817 return -1; 828 return -1;
818 if (get_bits1(gb)) { 829 if (get_bits1(gb)) {
819 av_log_missing_feature(ac->avccontext, "SSR", 1); 830 av_log_missing_feature(ac->avccontext, "SSR", 1);