[llvm] r237650 - [BitcodeReader] Error out if we read an invalid function argument type

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon May 25 20:52:06 PDT 2015


Thanks for all the testing of the error conditions. It is really helpful
when refactoring.
On May 18, 2015 9:26 PM, "Filipe Cabecinhas" <me at filcab.net> wrote:

> Author: filcab
> Date: Mon May 18 20:21:06 2015
> New Revision: 237650
>
> URL: http://llvm.org/viewvc/llvm-project?rev=237650&view=rev
> Log:
> [BitcodeReader] Error out if we read an invalid function argument type
>
> Bug found with AFL fuzz.
>
> Added:
>     llvm/trunk/test/Bitcode/Inputs/invalid-function-argument-type.bc
> Modified:
>     llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
>     llvm/trunk/test/Bitcode/invalid.test
>
> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=237650&r1=237649&r2=237650&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon May 18 20:21:06
> 2015
> @@ -1402,8 +1402,11 @@ std::error_code BitcodeReader::ParseType
>          return Error("Invalid record");
>        SmallVector<Type*, 8> ArgTys;
>        for (unsigned i = 2, e = Record.size(); i != e; ++i) {
> -        if (Type *T = getTypeByID(Record[i]))
> +        if (Type *T = getTypeByID(Record[i])) {
> +          if (!FunctionType::isValidArgumentType(T))
> +            return Error("Invalid function argument type");
>            ArgTys.push_back(T);
> +        }
>          else
>            break;
>        }
>
> Added: llvm/trunk/test/Bitcode/Inputs/invalid-function-argument-type.bc
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/Inputs/invalid-function-argument-type.bc?rev=237650&view=auto
>
> ==============================================================================
> Binary files
> llvm/trunk/test/Bitcode/Inputs/invalid-function-argument-type.bc (added)
> and llvm/trunk/test/Bitcode/Inputs/invalid-function-argument-type.bc Mon
> May 18 20:21:06 2015 differ
>
> Modified: llvm/trunk/test/Bitcode/invalid.test
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/invalid.test?rev=237650&r1=237649&r2=237650&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Bitcode/invalid.test (original)
> +++ llvm/trunk/test/Bitcode/invalid.test Mon May 18 20:21:06 2015
> @@ -152,3 +152,8 @@ RUN: not llvm-dis -disable-output %p/Inp
>  RUN:   FileCheck --check-prefix=INVALID-CODELENWIDTH %s
>
>  INVALID-CODELENWIDTH: Malformed block
> +
> +RUN: not llvm-dis -disable-output
> %p/Inputs/invalid-function-argument-type.bc 2>&1 | \
> +RUN:   FileCheck --check-prefix=INVALID-ARGUMENT-TYPE %s
> +
> +INVALID-ARGUMENT-TYPE: Invalid function argument type
>
>
> _______________________________________________
> 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/20150525/bc44c9db/attachment.html>


More information about the llvm-commits mailing list