fill_db_untrusted: follow untrusted data down the call tree
[smatch.git] / check_memset.c
blob245a58f4b20671819fb9d45b7425445e295b624c
1 /*
2 * sparse/check_memset.c
4 * Copyright (C) 2011 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include "smatch.h"
12 static int my_id;
14 static void match_memset(const char *fn, struct expression *expr, void *data)
16 struct expression *arg_expr;
17 long long val;
19 arg_expr = get_argument_from_call_expr(expr->args, 2);
21 if (arg_expr->type != EXPR_VALUE)
22 return;
23 if (!get_value(arg_expr, &val))
24 return;
25 if (val != 0)
26 return;
27 sm_msg("error: calling memset(x, y, 0);");
30 void check_memset(int id)
32 my_id = id;
33 add_function_hook("memset", &match_memset, NULL);
34 add_function_hook("__builtin_memset", &match_memset, NULL);