diff options
author | Petri Hintukainen <phintuka@users.sourceforge.net> | 2014-04-20 16:17:32 +0300 |
---|---|---|
committer | Petri Hintukainen <phintuka@users.sourceforge.net> | 2014-04-20 16:17:32 +0300 |
commit | 83ce6f21569add50bea9d69ac6d1118997641de3 (patch) | |
tree | 10b555ac46097a6ff8302e37ff260bda53afce05 /src | |
parent | 97a52da44fc0f360f61e1c0f0ea6256622776ffd (diff) | |
download | xine-lib-83ce6f21569add50bea9d69ac6d1118997641de3.tar.gz xine-lib-83ce6f21569add50bea9d69ac6d1118997641de3.tar.bz2 |
Fix aliasing in demuxers
Diffstat (limited to 'src')
-rw-r--r-- | src/demuxers/Makefile.am | 3 | ||||
-rw-r--r-- | src/demuxers/demux_asf.c | 20 | ||||
-rw-r--r-- | src/demuxers/demux_smjpeg.c | 6 | ||||
-rw-r--r-- | src/demuxers/ebml.c | 20 |
4 files changed, 26 insertions, 23 deletions
diff --git a/src/demuxers/Makefile.am b/src/demuxers/Makefile.am index 1f7948fdb..7e8193852 100644 --- a/src/demuxers/Makefile.am +++ b/src/demuxers/Makefile.am @@ -88,7 +88,6 @@ xineplug_dmx_qt_la_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CPPFLAGS) # is safe given same compiler options xineplug_dmx_asf_la_SOURCES = demux_asf.c asfheader.c xineplug_dmx_asf_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(LTLIBICONV) -xineplug_dmx_asf_la_CFLAGS = $(AM_CFLAGS) -fno-strict-aliasing xineplug_dmx_fli_la_SOURCES = demux_fli.c xineplug_dmx_fli_la_LIBADD = $(XINE_LIB) @@ -114,7 +113,6 @@ xineplug_dmx_games_la_SOURCES = group_games.c demux_eawve.c \ demux_vqa.c demux_wc3movie.c demux_str.c \ demux_film.c demux_smjpeg.c demux_4xm.c \ demux_vmd.c -xineplug_dmx_games_la_CFLAGS = $(AM_CFLAGS) -fno-strict-aliasing xineplug_dmx_games_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) xineplug_dmx_audio_la_SOURCES = group_audio.c demux_aud.c demux_aiff.c \ @@ -144,7 +142,6 @@ xineplug_dmx_nsv_la_LIBADD = $(XINE_LIB) xineplug_dmx_matroska_la_SOURCES = demux_matroska.c demux_matroska-chapters.c ebml.c xineplug_dmx_matroska_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(ZLIB_LIBS) -xineplug_dmx_matroska_la_CFLAGS = $(AM_CFLAGS) -fno-strict-aliasing xineplug_dmx_matroska_la_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CPPFLAGS) xineplug_dmx_iff_la_SOURCES = demux_iff.c diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c index 683c5c5c1..4ecd148e7 100644 --- a/src/demuxers/demux_asf.c +++ b/src/demuxers/demux_asf.c @@ -929,8 +929,11 @@ static int asf_parse_packet_align(demux_asf_t *this) { static int asf_parse_packet_ecd(demux_asf_t *this, uint32_t *p_hdr_size) { uint8_t ecd_flags; - uint8_t buf[16]; int invalid_packet; + union { + uint8_t u8[16]; + GUID guid; + } buf; do { ecd_flags = get_byte(this); *p_hdr_size = 1; @@ -952,7 +955,7 @@ static int asf_parse_packet_ecd(demux_asf_t *this, uint32_t *p_hdr_size) { if (ecd_present && !ecd_opaque && !ecd_len_type) { int read_size; - read_size = this->input->read (this->input, buf, ecd_len); + read_size = this->input->read (this->input, buf.u8, ecd_len); if (read_size != ecd_len) { this->status = DEMUX_FINISHED; return 1; @@ -960,19 +963,18 @@ static int asf_parse_packet_ecd(demux_asf_t *this, uint32_t *p_hdr_size) { *p_hdr_size += read_size; } else { - GUID *guid = (GUID *)buf; /* check if it's a new stream */ - buf[0] = ecd_flags; - if (this->input->read (this->input, buf + 1, 15) != 15) { + buf.u8[0] = ecd_flags; + if (this->input->read (this->input, buf.u8 + 1, 15) != 15) { this->status = DEMUX_FINISHED; return 1; } *p_hdr_size += 15; - guid->Data1 = _X_LE_32(buf); - guid->Data2 = _X_LE_16(buf + 4); - guid->Data3 = _X_LE_16(buf + 6); - if (get_guid_id(this, guid) == GUID_ASF_HEADER) { + buf.guid.Data1 = _X_LE_32(buf.u8); + buf.guid.Data2 = _X_LE_16(buf.u8 + 4); + buf.guid.Data3 = _X_LE_16(buf.u8 + 6); + if (get_guid_id(this, &buf.guid) == GUID_ASF_HEADER) { lprintf("new asf header detected\n"); _x_demux_control_end(this->stream, 0); if (demux_asf_send_headers_common(this)) diff --git a/src/demuxers/demux_smjpeg.c b/src/demuxers/demux_smjpeg.c index a932952bb..e6c44d141 100644 --- a/src/demuxers/demux_smjpeg.c +++ b/src/demuxers/demux_smjpeg.c @@ -95,7 +95,7 @@ static int open_smjpeg_file(demux_smjpeg_t *this) { unsigned int chunk_tag; unsigned char signature[8]; unsigned char header_chunk[SMJPEG_HEADER_CHUNK_MAX_SIZE]; - unsigned int audio_codec = 0; + uint32_t audio_codec = 0; static const uint8_t SMJPEG_SIGNATURE[8] = { 0x00, 0x0A, 'S', 'M', 'J', 'P', 'E', 'G' }; @@ -139,7 +139,7 @@ static int open_smjpeg_file(demux_smjpeg_t *this) { this->bih.biWidth = _X_BE_16(&header_chunk[8]); this->bih.biHeight = _X_BE_16(&header_chunk[10]); - this->bih.biCompression = *(uint32_t *)&header_chunk[12]; + memcpy(&this->bih.biCompression, &header_chunk[12], sizeof(uint32_t)); this->video_type = _x_fourcc_to_buf_video(this->bih.biCompression); if (!this->video_type) _x_report_video_fourcc (this->stream->xine, LOG_MODULE, this->bih.biCompression); @@ -160,7 +160,7 @@ static int open_smjpeg_file(demux_smjpeg_t *this) { audio_codec = be2me_32(APCM_TAG); this->audio_type = BUF_AUDIO_SMJPEG_IMA; } else { - audio_codec = *(uint32_t *)&header_chunk[8]; + memcpy(&audio_codec, &header_chunk[8], sizeof(uint32_t)); this->audio_type = _x_formattag_to_buf_audio(audio_codec); if (!this->audio_type) _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, audio_codec); diff --git a/src/demuxers/ebml.c b/src/demuxers/ebml.c index aabdea362..268f5e2e6 100644 --- a/src/demuxers/ebml.c +++ b/src/demuxers/ebml.c @@ -283,15 +283,19 @@ int ebml_read_float (ebml_parser_t *ebml, ebml_elem_t *elem, double *num) { } if (size == 4) { - float f; - - *((uint32_t *) &f) = _X_BE_32(data); - *num = f; + union { + float f; + uint32_t u32; + } tmp; + tmp.u32 = _X_BE_32(data); + *num = tmp.f; } else { - double d; - - *((uint64_t *) &d) = _X_BE_64(data); - *num = d; + union { + double d; + uint64_t u64; + } tmp; + tmp.u64 = _X_BE_64(data); + *num = tmp.d; } return 1; } |