[llvm] r216268 - [Support] Fix the overflow bug in ULEB128 decoding.

Alex L arphaman at gmail.com
Fri Aug 22 11:16:53 PDT 2014


I took a quick look at DebugInfo/DataExtractor, and the getULEB128 there is
correct (it has the uint64_t conversion).
But the question is why is the LEB128 decoding code is duplicated?


2014-08-22 11:04 GMT-07:00 David Blaikie <dblaikie at gmail.com>:

> So this scares me a bit - not because this fix isn't right (it looks
> right to me) but because this isn't the only code that does (U)LEB
> conversions. I think there's a couple of copies in debug info code...
>
> Could you check for them? Or I can try to dredge them up & take a glance.
>
> On Fri, Aug 22, 2014 at 9:29 AM, Alex Lorenz <arphaman at gmail.com> wrote:
> > Author: arphaman
> > Date: Fri Aug 22 11:29:45 2014
> > New Revision: 216268
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=216268&view=rev
> > Log:
> > [Support] Fix the overflow bug in ULEB128 decoding.
> >
> > Differential Revision: http://reviews.llvm.org/D5029
> >
> > Modified:
> >     llvm/trunk/include/llvm/Support/LEB128.h
> >     llvm/trunk/unittests/Support/LEB128Test.cpp
> >
> > Modified: llvm/trunk/include/llvm/Support/LEB128.h
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LEB128.h?rev=216268&r1=216267&r2=216268&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/include/llvm/Support/LEB128.h (original)
> > +++ llvm/trunk/include/llvm/Support/LEB128.h Fri Aug 22 11:29:45 2014
> > @@ -82,7 +82,7 @@ inline uint64_t decodeULEB128(const uint
> >    uint64_t Value = 0;
> >    unsigned Shift = 0;
> >    do {
> > -    Value += (*p & 0x7f) << Shift;
> > +    Value += uint64_t(*p & 0x7f) << Shift;
> >      Shift += 7;
> >    } while (*p++ >= 128);
> >    if (n)
> >
> > Modified: llvm/trunk/unittests/Support/LEB128Test.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/LEB128Test.cpp?rev=216268&r1=216267&r2=216268&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/unittests/Support/LEB128Test.cpp (original)
> > +++ llvm/trunk/unittests/Support/LEB128Test.cpp Fri Aug 22 11:29:45 2014
> > @@ -106,6 +106,7 @@ TEST(LEB128Test, DecodeULEB128) {
> >    EXPECT_DECODE_ULEB128_EQ(0xffu, "\xff\x01");
> >    EXPECT_DECODE_ULEB128_EQ(0x100u, "\x80\x02");
> >    EXPECT_DECODE_ULEB128_EQ(0x101u, "\x81\x02");
> > +  EXPECT_DECODE_ULEB128_EQ(4294975616ULL, "\x80\xc1\x80\x80\x10");
> >
> >    // Decode ULEB128 with extra padding bytes
> >    EXPECT_DECODE_ULEB128_EQ(0u, "\x80\x00");
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140822/e28fb92b/attachment.html>


More information about the llvm-commits mailing list