171 if (!is_array(left))
172 return;
173 array = get_array_base(left);
174 name = get_array_name(array);
175 if (!name)
176 return;
177
178 if (expr->op != '=') {
179 rl = alloc_whole_rl(get_type(expr->right));
180 rl = cast_rl(type, rl);
181 } else {
182 get_absolute_rl(expr->right, &rl);
183 rl = cast_rl(type, rl);
184 orig_rl = get_saved_rl(type, name);
185 rl = rl_union(orig_rl, rl);
186 }
187
188 update_cache(name, is_file_local(array), rl);
189 }
190
191 void register_array_values(int id)
192 {
193 my_id = id;
194
195 add_hook(&match_assign, ASSIGNMENT_HOOK);
196 add_hook(&match_assign, GLOBAL_ASSIGNMENT_HOOK);
197 }
|
171 if (!is_array(left))
172 return;
173 array = get_array_base(left);
174 name = get_array_name(array);
175 if (!name)
176 return;
177
178 if (expr->op != '=') {
179 rl = alloc_whole_rl(get_type(expr->right));
180 rl = cast_rl(type, rl);
181 } else {
182 get_absolute_rl(expr->right, &rl);
183 rl = cast_rl(type, rl);
184 orig_rl = get_saved_rl(type, name);
185 rl = rl_union(orig_rl, rl);
186 }
187
188 update_cache(name, is_file_local(array), rl);
189 }
190
191 static void mark_strings_unknown(const char *fn, struct expression *expr, void *_arg)
192 {
193 struct expression *dest;
194 struct symbol *type;
195 int arg = PTR_INT(_arg);
196 char *name;
197
198 dest = get_argument_from_call_expr(expr->args, arg);
199 if (!dest)
200 return;
201 name = get_array_name(dest);
202 if (!name)
203 return;
204 type = get_type(dest);
205 if (type_is_ptr(type))
206 type = get_real_base_type(type);
207 update_cache(name, is_file_local(dest), alloc_whole_rl(type));
208 }
209
210 void register_array_values(int id)
211 {
212 my_id = id;
213
214 add_hook(&match_assign, ASSIGNMENT_HOOK);
215 add_hook(&match_assign, GLOBAL_ASSIGNMENT_HOOK);
216
217 add_function_hook("sprintf", &mark_strings_unknown, INT_PTR(0));
218 add_function_hook("snprintf", &mark_strings_unknown, INT_PTR(0));
219
220 add_function_hook("strcpy", &mark_strings_unknown, INT_PTR(0));
221 add_function_hook("strncpy", &mark_strings_unknown, INT_PTR(0));
222 add_function_hook("strlcpy", &mark_strings_unknown, INT_PTR(0));
223 add_function_hook("strscpy", &mark_strings_unknown, INT_PTR(0));
224 }
|