avformat/mxfdec: Use ff_data_to_hex() for data->hex conversion

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).

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
release/5.1
Andreas Rheinhardt 3 years ago
parent 8823900b14
commit 6b5e3590c7
  1. 13
      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) static int mxf_umid_to_str(UID ul, UID uid, char **str)
{ {
int i;
char *p; char *p;
p = *str = av_mallocz(sizeof(UID) * 4 + 2 + 1); p = *str = av_mallocz(sizeof(UID) * 4 + 2 + 1);
if (!p) if (!p)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
snprintf(p, 2 + 1, "0x"); snprintf(p, 2 + 1, "0x");
p += 2; ff_data_to_hex(p + 2, ul, sizeof(UID), 0);
for (i = 0; i < sizeof(UID); i++) { ff_data_to_hex(p + 2 + 2 * sizeof(UID), uid, sizeof(UID), 0);
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;
}
return 0; return 0;
} }

Loading…
Cancel
Save