From aff25ad5f0747c1c52b272ff9189a693223d6aeb Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 28 Nov 2018 13:39:04 +0300 Subject: [PATCH] nul_terminator: export the is_nul_terminated() function The NUL terminated stuff is still very preliminary but it can help solve some false positives so I've started to use it. Signed-off-by: Dan Carpenter --- smatch.h | 3 +++ smatch_nul_terminator.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/smatch.h b/smatch.h index cc816491..f9e633f5 100644 --- a/smatch.h +++ b/smatch.h @@ -1152,6 +1152,9 @@ unsigned long get_max_memory(void); /* check_is_nospec.c */ bool is_nospec(struct expression *expr); +/* smatch_nul_terminator.c */ +bool is_nul_terminated(struct expression *expr); + static inline int type_bits(struct symbol *type) { if (!type) diff --git a/smatch_nul_terminator.c b/smatch_nul_terminator.c index 4d401afd..845c7566 100644 --- a/smatch_nul_terminator.c +++ b/smatch_nul_terminator.c @@ -240,6 +240,13 @@ free: free_string(name); } +bool is_nul_terminated(struct expression *expr) +{ + if (get_terminated_state(expr) == &terminated) + return 1; + return 0; +} + void register_nul_terminator(int id) { my_id = id; -- 2.11.4.GIT