[FFmpeg-devel] [PATCH v6 4/4] lavf/utils: Normalize AVPacket.data to native endian

Michael Niedermayer michael at niedermayer.cc
Fri Mar 4 03:49:32 CET 2016


On Fri, Mar 04, 2016 at 03:41:23AM +0100, Mats Peterson wrote:
> On 03/04/2016 03:30 AM, Michael Niedermayer wrote:
> >>
> >>-    if (!*palette && ret == CONTAINS_PAL)
> >>-        *palette = pkt->data + pkt->size - AVPALETTE_SIZE;
> >>+    if (!*palette && ret == CONTAINS_PAL) {
> >>+        uint8_t *pkt_pal = pkt->data + pkt->size - AVPALETTE_SIZE;
> >>+        int i;
> >>+        for (i = 0; i < AVPALETTE_COUNT; i++) {
> >>+            uint8_t *p8 = pkt_pal + 4*i;
> >
> >>+            uint32_t *p32 = (uint32_t *)p8;
> >
> >undefined behavior, violating alignment requirements, and possibly
> >aliassing violation
> >
> 
> Really? It works just fine, so please elaborate.

you cant cast arbitrary pointers to uint32_t

uint32_t can have platform specific alignment requirements that are
stricter than what a random 4 uint8_t have.
pkt->size does not need to be a multiple of 4 so even if pkt->data
would be aligned enough p8 doesnt have to be


> 
> >
> >>+            *p32 = AV_RL32(p8);
> >
> >corrupting potenially shared or read only input packet
> >
> >[...]
> 
> That one I do understand.
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160304/68366abd/attachment.sig>


More information about the ffmpeg-devel mailing list