Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve output for NullByte #1405

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/cdomain/value/cdomains/arrayDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1012,9 +1012,9 @@ struct
let (+.) = Z.add

(* (Must Null Set, May Null Set, Array Size) *)
include Lattice.Prod (Nulls) (Idx)
include Lattice.Prod (Nulls) (struct include Idx let name () = "length" end)

let name () = "arrays containing null bytes"
let name () = "ArrayNullBytes"
type idx = Idx.t
type value = Val.t

Expand Down Expand Up @@ -1815,6 +1815,17 @@ struct
else
f_get

let delegate_if_no_nullbytes (a, n) ffull fa =
if get_bool "ana.base.arrays.nullbytes" then
ffull (a, n)
else
fa a

let show x = delegate_if_no_nullbytes x show A.show
let printXml f x = delegate_if_no_nullbytes x (printXml f) (A.printXml f)
let to_yojson x = delegate_if_no_nullbytes x to_yojson A.to_yojson
let pretty () x = delegate_if_no_nullbytes x (pretty ()) (A.pretty ())

let construct a n =
if get_bool "ana.base.arrays.nullbytes" then
(a, n ())
Expand Down
4 changes: 4 additions & 0 deletions src/cdomain/value/cdomains/nullByteSet.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module MustSet = struct
module M = SetDomain.Reverse (SetDomain.ToppedSet (IntOps.BigIntOps) (struct let topname = "All Null" end))
include M

let name () = "MustNullBytes"

let compute_set len =
List.init (Z.to_int len) Z.of_int
|> of_list
Expand Down Expand Up @@ -48,6 +50,8 @@ module MaySet = struct
module M = SetDomain.ToppedSet (IntOps.BigIntOps) (struct let topname = "All Null" end)
include M

let name () = "MayNullBytes"

let elements ?max_size may_nulls_set =
if M.is_top may_nulls_set then
match max_size with
Expand Down
Loading