Skip to content

Commit 70ff373

Browse files
committed
[itvSem] add fread semantics
1 parent ac8e0c4 commit 70ff373

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/semantics/itvSem.ml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,22 @@ let rec model_strchr mode spec node pid (lvo, exps) (mem, global) =
646646
(mem, global)
647647
| _, _ -> (mem, global)
648648

649+
let model_fread mode spec pid (lvo, exps) (mem, global) =
650+
match exps with
651+
| buf :: _ :: cnt :: _ -> (
652+
let size_itv = eval ~spec pid cnt mem in
653+
let arr = eval ~spec pid buf mem in
654+
let locs = Val.all_locs arr in
655+
let mem = update Weak spec global locs size_itv mem in
656+
match lvo with
657+
| Some lv ->
658+
let mem =
659+
update mode spec global (eval_lv ~spec pid lv mem) arr mem
660+
in
661+
(mem, global)
662+
| _ -> (mem, global))
663+
| _ -> (mem, global)
664+
649665
let model_memset mode spec pid (lvo, exps) (mem, global) =
650666
match exps with
651667
| buf :: v :: _ -> (
@@ -926,6 +942,7 @@ let scaffolded_functions mode spec node pid (lvo, f, exps) (mem, global) =
926942
| "strchr" | "strrchr" ->
927943
model_strchr mode spec node pid (lvo, exps) (mem, global)
928944
| "memset" -> model_memset mode spec pid (lvo, exps) (mem, global)
945+
| "fread" -> model_fread mode spec pid (lvo, exps) (mem, global)
929946
| s when List.mem s mem_alloc_libs ->
930947
model_alloc_one mode spec pid lvo f (mem, global)
931948
| _ when ApiSem.ApiMap.mem f.vname ApiSem.api_map ->

0 commit comments

Comments
 (0)