summaryrefslogtreecommitdiff
path: root/saveutil.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2007-11-26 13:21:18 -0800
committerAlan Coopersmith <alan.coopersmith@sun.com>2007-11-26 13:21:18 -0800
commit6f4560e2ad81736127d2d3544415a05d41e8a2a7 (patch)
tree6c53b2585d1081cf9296c09cd22acee1e9ac9a4f /saveutil.c
parentfab9dcb15024996ac3a4f94d65ba73f484820534 (diff)
Use snprintf, strdup & remove instead of sprintf, malloc/strcpy & unlink
Diffstat (limited to 'saveutil.c')
-rw-r--r--saveutil.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/saveutil.c b/saveutil.c
index 0e81785..cd020dd 100644
--- a/saveutil.c
+++ b/saveutil.c
@@ -47,9 +47,8 @@ set_session_save_file_name(char *session_name)
p = ".";
}
- strcpy (session_save_file, p);
- strcat (session_save_file, "/.XSM-");
- strcat (session_save_file, session_name);
+ snprintf (session_save_file, sizeof(session_save_file),
+ "%s/.XSM-%s", p, session_name);
}
@@ -314,8 +313,8 @@ WriteSave(char *sm_id)
{
char msg[256];
- sprintf (msg, "%s: Error creating session save file %s",
- Argv[0], session_save_file);
+ snprintf (msg, sizeof(msg), "%s: Error creating session save file %s",
+ Argv[0], session_save_file);
add_log_text (msg);
perror (msg);
}
@@ -426,7 +425,7 @@ DeleteSession(char *session_name)
dir = ".";
}
- sprintf (filename, "%s/.XSM-%s", dir, session_name);
+ snprintf (filename, sizeof(filename), "%s/.XSM-%s", dir, session_name);
f = fopen(filename, "r");
if(!f) {
@@ -510,7 +509,7 @@ DeleteSession(char *session_name)
if (buf)
free (buf);
- return ((unlink (filename) == -1) ? 0 : 1);
+ return ((remove (filename) == -1) ? 0 : 1);
}