about summary refs log tree commit diff
path: root/instrumentation/cmplog-routines-pass.cc
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2021-10-18 00:21:33 +0200
committervanhauser-thc <vh@thc.org>2021-10-18 00:21:33 +0200
commit9c278df0385afb03a078e25e27a4763512d8831a (patch)
tree56864a2078d41392c068a7d91a59c1e151690ef8 /instrumentation/cmplog-routines-pass.cc
parent4b4244bcf6cad5fdc897edef6ea810647a54ca9f (diff)
downloadafl++-9c278df0385afb03a078e25e27a4763512d8831a.tar.gz
try fix
Diffstat (limited to 'instrumentation/cmplog-routines-pass.cc')
-rw-r--r--instrumentation/cmplog-routines-pass.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/instrumentation/cmplog-routines-pass.cc b/instrumentation/cmplog-routines-pass.cc
index 50ced5d8..854492b1 100644
--- a/instrumentation/cmplog-routines-pass.cc
+++ b/instrumentation/cmplog-routines-pass.cc
@@ -94,7 +94,7 @@ bool CmpLogRoutines::hookRtns(Module &M) {
   Type *VoidTy = Type::getVoidTy(C);
   // PointerType *VoidPtrTy = PointerType::get(VoidTy, 0);
   IntegerType *Int8Ty = IntegerType::getInt8Ty(C);
-  IntegerType *Int32Ty = IntegerType::getInt32Ty(C);
+  IntegerType *Int64Ty = IntegerType::getInt64Ty(C);
   PointerType *i8PtrTy = PointerType::get(Int8Ty, 0);
 
 #if LLVM_VERSION_MAJOR < 9
@@ -192,7 +192,7 @@ bool CmpLogRoutines::hookRtns(Module &M) {
   FunctionCallee
 #endif
       c5 = M.getOrInsertFunction("__cmplog_rtn_hook_n", VoidTy, i8PtrTy,
-                                 i8PtrTy, Int32Ty
+                                 i8PtrTy, Int64Ty
 #if LLVM_VERSION_MAJOR < 5
                                  ,
                                  NULL
@@ -210,7 +210,7 @@ bool CmpLogRoutines::hookRtns(Module &M) {
   FunctionCallee
 #endif
       c6 = M.getOrInsertFunction("__cmplog_rtn_hook_strn", VoidTy, i8PtrTy,
-                                 i8PtrTy, Int32Ty
+                                 i8PtrTy, Int64Ty
 #if LLVM_VERSION_MAJOR < 5
                                  ,
                                  NULL
@@ -282,6 +282,15 @@ bool CmpLogRoutines::hookRtns(Module &M) {
                            FT->getParamType(0) == FT->getParamType(1) &&
                            FT->getParamType(0)->isPointerTy() &&
                            FT->getParamType(2)->isIntegerTy();
+          if (isPtrRtnN) {
+            auto intTyOp = dyn_cast<IntegerType>(callInst->getArgOperand(2)->getType());
+            if (intTyOp) {
+              if (intTyOp->getBitWidth() != 32 && intTyOp->getBitWidth() != 64) {
+                isPtrRtnN = false;
+              }
+            }
+          }
+
 
           bool isMemcmp =
               (!FuncName.compare("memcmp") || !FuncName.compare("bcmp") ||
@@ -469,7 +478,7 @@ bool CmpLogRoutines::hookRtns(Module &M) {
     std::vector<Value *> args;
     Value *              v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
     Value *              v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
-    Value *              v3Pcasted = IRB.CreateTruncOrBitCast(v3P, Int32Ty);
+    Value *              v3Pcasted = IRB.CreateTruncOrBitCast(v3P, Int64Ty);
     args.push_back(v1Pcasted);
     args.push_back(v2Pcasted);
     args.push_back(v3Pcasted);
@@ -524,7 +533,7 @@ bool CmpLogRoutines::hookRtns(Module &M) {
     std::vector<Value *> args;
     Value *              v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy);
     Value *              v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy);
-    Value *              v3Pcasted = IRB.CreateTruncOrBitCast(v3P, Int32Ty);
+    Value *              v3Pcasted = IRB.CreateTruncOrBitCast(v3P, Int64Ty);
     args.push_back(v1Pcasted);
     args.push_back(v2Pcasted);
     args.push_back(v3Pcasted);