diff mbox series

[FFmpeg-devel,3/4] avformat/mxfdec: Use ff_data_to_hex() for data->hex conversion

Message ID DB6PR0101MB22142FB98E323BB72FE32EAC8FAB9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 6b5e3590c761aaf8e1ccceee8eadd8d49cf9c0af
Headers show
Series [FFmpeg-devel,1/4] avformat/mxf: Use AVUUID for uids | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt June 13, 2022, 11:24 p.m. UTC
In this case it also stops pretending that the length of
the output string is somehow checked (which is currently
being done by using snprintf that is called with the amount
of space needed instead of the amount of space actually available).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/mxfdec.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 392066b65a..77bde7c3fe 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -2120,22 +2120,13 @@  static int mxf_is_intra_only(MXFDescriptor *descriptor)
 
 static int mxf_umid_to_str(UID ul, UID uid, char **str)
 {
-    int i;
     char *p;
     p = *str = av_mallocz(sizeof(UID) * 4 + 2 + 1);
     if (!p)
         return AVERROR(ENOMEM);
     snprintf(p, 2 + 1, "0x");
-    p += 2;
-    for (i = 0; i < sizeof(UID); i++) {
-        snprintf(p, 2 + 1, "%.2X", ul[i]);
-        p += 2;
-
-    }
-    for (i = 0; i < sizeof(UID); i++) {
-        snprintf(p, 2 + 1, "%.2X", uid[i]);
-        p += 2;
-    }
+    ff_data_to_hex(p + 2, ul, sizeof(UID), 0);
+    ff_data_to_hex(p + 2 + 2 * sizeof(UID), uid, sizeof(UID), 0);
     return 0;
 }