return g_strdup_printf("getcwd failed: %s\n",
strerror(errno));
}
- path = g_malloc(strlen(curdir) + 1 + strlen(arg0) + 1);
- strcpy(path, curdir);
- strcat(path, "/");
- strcat(path, arg0);
+ path = g_strdup_printf("%s/%s", curdir, arg0);
g_free(curdir);
prog_pathname = path;
} else {
+ strlen(arg0) + 1);
memcpy(path, path_start, path_component_len);
path[path_component_len] = '\0';
- strcat(path, "/");
- strcat(path, arg0);
+ strncat(path, "/", 2);
+ strncat(path, arg0, strlen(arg0) + 1);
if (access(path, X_OK) == 0) {
/*
* Found it!
g_free (persconfprofile);
}
- if (profilename && strlen(profilename) > 0) {
+ if (profilename && strlen(profilename) > 0 &&
+ strcmp(profilename, DEFAULT_PROFILE) != 0) {
persconfprofile = g_strdup (profilename);
} else {
/* Default Profile */
g_free (persconffile_profile_dir);
}
- if (profilename) {
- persconffile_profile_dir = g_strdup_printf ("%s%s%s", get_profiles_dir (), G_DIR_SEPARATOR_S,
- profilename);
+ if (profilename && strlen(profilename) > 0 &&
+ strcmp(profilename, DEFAULT_PROFILE) != 0) {
+ persconffile_profile_dir = g_strdup_printf ("%s%s%s", get_profiles_dir (),
+ G_DIR_SEPARATOR_S, profilename);
} else {
persconffile_profile_dir = g_strdup_printf (get_persconffile_dir_no_profile ());
}
if ((dir = eth_dir_open(directory, 0, NULL)) != NULL) {
while ((file = eth_dir_read_name(dir)) != NULL) {
- filename = g_strdup_printf ("%s%s%s", directory, G_DIR_SEPARATOR_S, eth_dir_get_name(file));
+ filename = g_strdup_printf ("%s%s%s", directory, G_DIR_SEPARATOR_S,
+ eth_dir_get_name(file));
if (test_for_directory(filename) != EISDIR) {
ret = eth_remove(filename);
#if 0
/* the "My Captures" sub-directory is created (if it doesn't exist)
by u3util.exe when the U3 Wireshark is first run */
- szPath = g_malloc(strlen(u3devicedocumentpath) + strlen(U3_MY_CAPTURES) + 1);
- strcpy(szPath, u3devicedocumentpath);
- strcat(szPath, U3_MY_CAPTURES);
+ szPath = g_strdup_printf("%s%s", u3devicedocumentpath, U3_MY_CAPTURES);
persdatafile_dir = szPath;
return szPath;
* This is cached, so we don't need to worry about
* allocating multiple ones of them.
*/
- homestring =
- g_malloc(strlen(homedrive) + strlen(homepath) + 1);
- strcpy(homestring, homedrive);
- strcat(homestring, homepath);
+ homestring = g_strdup_printf("%s%s", homedrive, homepath);
/*
* Trim off any trailing slash or backslash.