Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
CodeQL: g_assert result of g_build_path calls
  • Loading branch information
kg committed Mar 12, 2024
commit 32e7bc1b693ee3339749f24995e4e6f496262241
1 change: 1 addition & 0 deletions src/mono/mono/eglib/gfile-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **gerror)
}

t = g_build_filename (g_get_tmp_dir (), tmpl, (const char*)NULL);
g_assert (t);

#ifdef HOST_WASI
g_critical ("g_file_open_tmp is not implemented for WASI");
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/metadata/appdomain.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ try_load_from (MonoAssembly **assembly,

*assembly = NULL;
fullpath = g_build_filename (path1, path2, path3, path4, (const char*)NULL);
g_assert (fullpath);

found = g_file_test (fullpath, G_FILE_TEST_IS_REGULAR);

Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/metadata/assembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ load_in_path (const char *basename, const char** search_path, const MonoAssembly

for (i = 0; search_path [i]; ++i) {
fullpath = g_build_filename (search_path [i], basename, (const char*)NULL);
g_assert (fullpath);
result = mono_assembly_request_open (fullpath, req, status);
g_free (fullpath);
if (result)
Expand Down Expand Up @@ -1407,6 +1408,7 @@ absolute_dir (const gchar *filename)

cwd = g_get_current_dir ();
mixed = g_build_filename (cwd, filename, (const char*)NULL);
g_assert (mixed);
parts = g_strsplit (mixed, G_DIR_SEPARATOR_S, 0);
g_free (mixed);
g_free (cwd);
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -4564,6 +4564,7 @@ ves_icall_System_Reflection_RuntimeAssembly_GetInfo (MonoQCallAssemblyHandle ass
else
absolute = g_build_filename (assembly->basedir, filename, (const char*)NULL);

g_assert (absolute);
mono_icall_make_platform_path (absolute);

const gchar *prepend = mono_icall_get_file_path_prefix (absolute);
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/metadata/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,7 @@ mono_image_load_file_for_image_checked (MonoImage *image, uint32_t fileidx, Mono
fname = mono_metadata_string_heap (image, fname_id);
base_dir = g_path_get_dirname (image->name);
name = g_build_filename (base_dir, fname, (const char*)NULL);
g_assert (name);
res = mono_image_open (name, NULL);
if (!res)
goto done;
Expand Down
4 changes: 3 additions & 1 deletion src/mono/mono/metadata/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -4243,6 +4243,8 @@ prepare_run_main (MonoMethod *method, int argc, char *argv[])
basename,
(const char*)NULL);

g_assert (fullpath);

utf8_fullpath = utf8_from_external (fullpath);
if(utf8_fullpath == NULL) {
/* Printing the arg text will cause glib to
Expand Down Expand Up @@ -5355,7 +5357,7 @@ MonoObjectHandle
mono_object_new_handle (MonoClass *klass, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;

if (MONO_CLASS_IS_IMPORT(klass)) {
mono_error_set_not_supported (error, "Built-in COM interop is not supported on Mono.");
return MONO_HANDLE_NEW (MonoObject, NULL);
Expand Down
12 changes: 10 additions & 2 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -5508,10 +5508,10 @@ MONO_RESTORE_WARNING
if (decoded_args->named_args_info [j].field && !strcmp (decoded_args->named_args_info [j].field->name, "EntryPoint")) {
named = (const char *)decoded_args->named_args[j]->value.primitive;
slen = mono_metadata_decode_value (named, &named);

int prefix_len = (int)strlen (acfg->user_symbol_prefix);
g_assert (prefix_len < 2);

export_name = (char *)g_malloc (prefix_len + slen + 1);
if (prefix_len == 1)
export_name[0] = *acfg->user_symbol_prefix;
Expand Down Expand Up @@ -11566,6 +11566,9 @@ emit_exception_info (MonoAotCompile *acfg)
char *aot_file = g_strdup_printf("%s%s", image_basename, SEQ_POINT_AOT_EXT);
char *aot_file_path = g_build_filename (dir, aot_file, (const char*)NULL);

g_assert (dir);
g_assert (aot_file_path);

if (g_ensure_directory_exists (aot_file_path) == FALSE) {
fprintf (stderr, "AOT : failed to create msym directory: %s\n", aot_file_path);
exit (1);
Expand Down Expand Up @@ -15348,6 +15351,8 @@ set_paths (MonoAotCompile *acfg)
acfg->asm_fname = g_strdup_printf ("%s.s", acfg->tmpbasename);
acfg->llvm_sfile = g_strdup_printf ("%s-llvm.s", acfg->tmpbasename);

g_assert (acfg->tmpbasename);

if (acfg->aot_opts.static_link)
acfg->llvm_ofile = g_strdup (acfg->aot_opts.llvm_outfile);
else
Expand Down Expand Up @@ -15380,6 +15385,8 @@ set_paths (MonoAotCompile *acfg)
} else {
acfg->tmpbasename = g_build_filename (acfg->aot_opts.temp_path, "temp", (const char*)NULL);
acfg->asm_fname = g_strdup_printf ("%s.s", acfg->tmpbasename);

g_assert (acfg->tmpbasename);
}
}
}
Expand Down Expand Up @@ -15624,6 +15631,7 @@ compile_assemblies_in_child (MonoAotOptions *aot_opts, MonoAssembly **assemblies

#ifdef HOST_WIN32
response_fname = g_build_filename (aot_opts->temp_path, "temp.rsp", (const char*)NULL);
g_assert (response_fname);
response = fopen (response_fname, "w");
g_assert (response);
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/utils/mono-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ mono_path_canonicalize (const char *path)
} else {
gchar *tmpdir = g_get_current_dir ();
abspath = g_build_filename (tmpdir, path, (const char*)NULL);
g_assert (abspath);
g_free (tmpdir);
}

Expand Down Expand Up @@ -128,6 +129,7 @@ resolve_symlink (const char *path)
if (!g_path_is_absolute (buffer)) {
dir = g_path_get_dirname (p);
concat = g_build_filename (dir, buffer, (const char*)NULL);
g_assert (concat);
g_free (dir);
} else {
concat = g_strdup (buffer);
Expand Down