aboutsummaryrefslogtreecommitdiffstats
path: root/epan/filesystem.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2008-02-03 15:38:20 +0000
committerStig Bjørlykke <stig@bjorlykke.org>2008-02-03 15:38:20 +0000
commit47d744b59da83744623bea39c006eb7e2ec02de9 (patch)
tree17d9ec1526a37c793ee3d7cbd031091d1867dd7f /epan/filesystem.c
parente59b5d6b8a963263b0c2dcf163e07b4318737d71 (diff)
More rewrite of prohibited APIs (sprintf, strcpy, strcat).
svn path=/trunk/; revision=24258
Diffstat (limited to 'epan/filesystem.c')
-rw-r--r--epan/filesystem.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/epan/filesystem.c b/epan/filesystem.c
index 7ad214e9a2..9194226aef 100644
--- a/epan/filesystem.c
+++ b/epan/filesystem.c
@@ -386,10 +386,7 @@ init_progfile_dir(const char *arg0
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 {
@@ -411,8 +408,8 @@ init_progfile_dir(const char *arg0
+ 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!
@@ -1140,9 +1137,7 @@ get_persdatafile_dir(void)
/* 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", 3devicedocumentpath, U3_MY_CAPTURES);
persdatafile_dir = szPath;
return szPath;
@@ -1192,10 +1187,7 @@ get_home_dir(void)
* 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.