Skip to content

Commit 282df68

Browse files
committed
CHC: Close POs that refer to argv[0]
We already had some logic to deal with this but not for all pointer cases. I copy/pasted that logic over to the cases where the current version of CHC complains for a simple hello world program that passes argv[0] to printf. There's still an open issue where there's a precondition for 'initialized(*argv)' that I have not addressed
1 parent c443f5e commit 282df68

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

CodeHawk/CHC/cchpre/cCHCheckValid.ml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,11 @@ let check_ppo_validity
15101510
| _ -> ()
15111511
end
15121512

1513+
| PPtrUpperBound (_, _, e, _) when is_program_name e ->
1514+
make
1515+
("validity of pointer to program name is guaranteed by the "
1516+
^ "operating system")
1517+
15131518
| PPtrUpperBound (_, _, e, _) when is_null_pointer e ->
15141519
make ("not-null of first argument is checked separately")
15151520

@@ -2062,6 +2067,11 @@ let check_ppo_validity
20622067
| PInitialized (Mem e, NoOffset) when is_constant_string e ->
20632068
make ("constant string is guaranteed to have at least one character")
20642069

2070+
| PInitializedRange (e, _) when is_program_name e ->
2071+
make
2072+
("validity of pointer to program name is guaranteed by the "
2073+
^ "operating system")
2074+
20652075
| PInitializedRange (e, _) when is_null_pointer e ->
20662076
make "null pointer does have any range, so this is trivially valid"
20672077

@@ -2150,6 +2160,11 @@ let check_ppo_validity
21502160
| PNullTerminated (Const (CWStr _))
21512161
| PNullTerminated (CastE (_, Const (CWStr _))) -> make "wide string literal"
21522162

2163+
| PNullTerminated e when is_program_name e ->
2164+
make
2165+
("validity of pointer to program name is guaranteed by the "
2166+
^ "operating system")
2167+
21532168
| PNullTerminated e when is_null_pointer e ->
21542169
make "null pointer is not subject to null-termination"
21552170

0 commit comments

Comments
 (0)