Ignore:
Timestamp:
11/15/06 13:29:00 (17 years ago)
Author:
r2d
Message:
  • added CRC check in libmpcdec
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/branches/r2d/libmpcdec/streaminfo.c

    r126 r138  
    3939#include <stdio.h>
    4040#include "internal.h"
     41
     42unsigned long crc32(unsigned char *buf, int len);
    4143
    4244mpc_uint32_t mpc_bits_read(mpc_bits_reader * r, const unsigned int nb_bits);
     
    139141/// Reads streaminfo from SV8 header.
    140142mpc_status
    141 streaminfo_read_header_sv8(mpc_streaminfo* si, const mpc_bits_reader * r_in)
    142 {
    143         mpc_uint32_t CRC;
     143streaminfo_read_header_sv8(mpc_streaminfo* si, const mpc_bits_reader * r_in,
     144                                                   mpc_size_t block_size)
     145{
     146        mpc_uint32_t CRC, CRC_tmp;
    144147        mpc_bits_reader r = *r_in;
    145148
    146         // FIXME : add CRC check
    147149        CRC = mpc_bits_read(&r, 32);
     150        CRC_tmp = crc32(r.buff + 1 - (r.count >> 3), block_size - 4);
     151        if (CRC != CRC_tmp)
     152                return MPC_STATUS_FILE;
     153
    148154        si->stream_version = mpc_bits_read(&r, 8);
    149155        mpc_bits_get_size(&r, &si->samples);
Note: See TracChangeset for help on using the changeset viewer.