Message ID | AM7PR03MB66609FAEE5128E3BA3F57C0F8F569@AM7PR03MB6660.eurprd03.prod.outlook.com |
---|---|
State | Accepted |
Commit | ca168635494276bb7f2f686de07747e7f493e30c |
Headers | show |
Series | [FFmpeg-devel,01/25] avformat/matroskaenc: Fix potential overflow | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_aarch64_jetson | success | Make finished |
andriy/make_fate_aarch64_jetson | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
On 1/16/2022 7:49 PM, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavformat/matroskaenc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c > index 41b2df7dbf..1dde12a7d9 100644 > --- a/libavformat/matroskaenc.c > +++ b/libavformat/matroskaenc.c > @@ -286,7 +286,7 @@ static void put_ebml_uint(AVIOContext *pb, uint32_t elementid, uint64_t val) > static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val) > { > int i, bytes = 1; > - uint64_t tmp = 2*(val < 0 ? val^-1 : val); > + uint64_t tmp = 2 * (uint64_t)(val < 0 ? val^-1 : val); nit: 2ULL is shorter. > > while (tmp >>= 8) > bytes++;
James Almer: > > > On 1/16/2022 7:49 PM, Andreas Rheinhardt wrote: >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> >> --- >> libavformat/matroskaenc.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c >> index 41b2df7dbf..1dde12a7d9 100644 >> --- a/libavformat/matroskaenc.c >> +++ b/libavformat/matroskaenc.c >> @@ -286,7 +286,7 @@ static void put_ebml_uint(AVIOContext *pb, >> uint32_t elementid, uint64_t val) >> static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, >> int64_t val) >> { >> int i, bytes = 1; >> - uint64_t tmp = 2*(val < 0 ? val^-1 : val); >> + uint64_t tmp = 2 * (uint64_t)(val < 0 ? val^-1 : val); > > nit: 2ULL is shorter. > This is correct, but the above is more natural; after all, it is (val < 0 ? val^-1 : val) that is reinterpreted as uint64_t. - Andreas
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavformat/matroskaenc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c > index 41b2df7dbf..1dde12a7d9 100644 > --- a/libavformat/matroskaenc.c > +++ b/libavformat/matroskaenc.c > @@ -286,7 +286,7 @@ static void put_ebml_uint(AVIOContext *pb, uint32_t elementid, uint64_t val) > static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val) > { > int i, bytes = 1; > - uint64_t tmp = 2*(val < 0 ? val^-1 : val); > + uint64_t tmp = 2 * (uint64_t)(val < 0 ? val^-1 : val); > > while (tmp >>= 8) > bytes++; > Will apply this patchset tomorrow unless there are objections. - Andreas
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 41b2df7dbf..1dde12a7d9 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -286,7 +286,7 @@ static void put_ebml_uint(AVIOContext *pb, uint32_t elementid, uint64_t val) static void put_ebml_sint(AVIOContext *pb, uint32_t elementid, int64_t val) { int i, bytes = 1; - uint64_t tmp = 2*(val < 0 ? val^-1 : val); + uint64_t tmp = 2 * (uint64_t)(val < 0 ? val^-1 : val); while (tmp >>= 8) bytes++;
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavformat/matroskaenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)