You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/analyses/base.ml
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2680,9 +2680,11 @@ struct
2680
2680
if get_bool "sem.malloc.fail"
2681
2681
thenAD.join addr AD.null_ptr (* calloc can fail and return NULL *)
2682
2682
else addr in
2683
+
let ik =Cilfacade.ptrdiff_ikind ()in
2684
+
let blobsize =ID.mul (ID.cast_to ik @@ eval_int (Analyses.ask_of_ctx ctx) gs st size) (ID.cast_to ik @@ eval_int (Analyses.ask_of_ctx ctx) gs st n) in
2683
2685
(* the memory that was allocated by calloc is set to bottom, but we keep track that it originated from calloc, so when bottom is read from memory allocated by calloc it is turned to zero *)
Copy file name to clipboardExpand all lines: src/cdomains/valueDomain.ml
+17-2Lines changed: 17 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -335,7 +335,7 @@ struct
335
335
let one_addr =letopenAddrinfunction
336
336
(* only allow conversion of float pointers if source and target type are the same *)
337
337
|Addr ({ vtype = TFloat(fkind, _); _}, _) asxwhen (match t withTFloat (fkind', _) when fkind = fkind' -> true|_ -> false) -> x
338
-
(* do not allow conversion from/to float pointers*)
338
+
(* do not allow conversion from/to float pointers*)
339
339
|Addr ({ vtype = TFloat(_); _}, _) -> UnknownPtr
340
340
|_when (match t withTFloat_ ->true|_ -> false) ->UnknownPtr
341
341
|Addr ({ vtype = TVoid_; _}asv, offs) whennot (Cilfacade.isCharType t) -> (* we had no information about the type (e.g. malloc), so we add it; ignore for casts to char* since they're special conversions (N1570 6.3.2.3.7) *)
@@ -914,7 +914,22 @@ struct
914
914
begin
915
915
let l', o' = shift_one_over l o in
916
916
let x = zero_init_calloced_memory orig x t in
917
-
mu (`Blob (join x (do_update_offset ask x offs value exp l' o' v t), s, orig))
917
+
(* Strong update of scalar variable is possible if the variable is unique and size of written value matches size of blob being written to. *)
918
+
let do_strong_update =
919
+
beginmatch v with
920
+
| (Var var, _) ->
921
+
let blob_size_opt =ID.to_int s in
922
+
not@@ ask.f (Q.IsMultiple var)
923
+
&¬@@Cil.isVoidType t (* Size of value is known *)
924
+
&&Option.is_some blob_size_opt (* Size of blob is known *)
0 commit comments