aboutsummaryrefslogtreecommitdiffstats
path: root/tempfile.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 /tempfile.c
parente59b5d6b8a963263b0c2dcf163e07b4318737d71 (diff)
More rewrite of prohibited APIs (sprintf, strcpy, strcat).
svn path=/trunk/; revision=24258
Diffstat (limited to 'tempfile.c')
-rw-r--r--tempfile.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/tempfile.c b/tempfile.c
index 61495281ce..af922b6d41 100644
--- a/tempfile.c
+++ b/tempfile.c
@@ -57,9 +57,7 @@ setup_tmpdir(const char *dir)
return dir;
}
else {
- newdir = g_malloc(len + 2);
- strcpy(newdir, dir);
- strcat(newdir, G_DIR_SEPARATOR_S);
+ newdir = g_strdup_printf("%s%s", dir, G_DIR_SEPARATOR_S);
return newdir;
}
}
@@ -72,17 +70,14 @@ try_tempfile(char *namebuf, int namebuflen, const char *dir, const char *pfx)
int old_umask;
int tmp_fd;
+ g_snprintf(namebuf, namebuflen, "%s%s%s", dir, pfx, suffix);
if (namebuflen < namelen) {
- /* Stick in a truncated name, so that if this error is
+ /* Stick with the truncated name, so that if this error is
reported with the file name, you at least get
something. */
- g_snprintf(namebuf, namebuflen, "%s%s%s", dir, pfx, suffix);
errno = ENAMETOOLONG;
return -1;
}
- strcpy(namebuf, dir);
- strcat(namebuf, pfx);
- strcat(namebuf, suffix);
/* The Single UNIX Specification doesn't say that "mkstemp()"
creates the temporary file with mode rw-------, so we