[llvm] r220567 - [Object] Fix MachO's getUuid to return a pointer into the object instead of a dangling ArrayRef.
Alexey Samsonov
vonosmas at gmail.com
Fri Oct 24 11:07:56 PDT 2014
Thanks for fixing this!
On Fri, Oct 24, 2014 at 8:52 AM, Benjamin Kramer <benny.kra at googlemail.com>
wrote:
> Author: d0k
> Date: Fri Oct 24 10:52:05 2014
> New Revision: 220567
>
> URL: http://llvm.org/viewvc/llvm-project?rev=220567&view=rev
> Log:
> [Object] Fix MachO's getUuid to return a pointer into the object instead
> of a dangling ArrayRef.
>
> This works because uuid's are always little endian so it's not swapped.
> Fixes use-after-return reported by asan.
>
> Modified:
> llvm/trunk/lib/Object/MachOObjectFile.cpp
>
> Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=220567&r1=220566&r2=220567&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/MachOObjectFile.cpp Fri Oct 24 10:52:05 2014
> @@ -2460,8 +2460,9 @@ ArrayRef<uint8_t> MachOObjectFile::getDy
> ArrayRef<uint8_t> MachOObjectFile::getUuid() const {
> if (!UuidLoadCmd)
> return ArrayRef<uint8_t>();
> - MachO::uuid_command Uuid = getStruct<MachO::uuid_command>(this,
> UuidLoadCmd);
> - return ArrayRef<uint8_t>(Uuid.uuid, 16);
> + // Returning a pointer is fine as uuid doesn't need endian swapping.
> + const char *Ptr = UuidLoadCmd + offsetof(MachO::uuid_command, uuid);
> + return ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(Ptr), 16);
> }
>
> StringRef MachOObjectFile::getStringTableData() const {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141024/545cd6c3/attachment.html>
More information about the llvm-commits
mailing list