summaryrefslogtreecommitdiffstats
path: root/lib/libstand/tftp.c
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1998-09-18 22:58:01 +0000
committermsmith <msmith@FreeBSD.org>1998-09-18 22:58:01 +0000
commit3b7700ffefbf84bddf6433f318b4f2d440ab544d (patch)
treebe8d7f6697a189dd3af5c56e280e7937bcdf9ab5 /lib/libstand/tftp.c
parent01f9752c5500adf97fd320a4547b366297e6b6d9 (diff)
downloadFreeBSD-src-3b7700ffefbf84bddf6433f318b4f2d440ab544d.zip
FreeBSD-src-3b7700ffefbf84bddf6433f318b4f2d440ab544d.tar.gz
Path arguments to *_open functions should be const, but we were mangling
them. Submitted by: write-protected text segment in BTX
Diffstat (limited to 'lib/libstand/tftp.c')
-rw-r--r--lib/libstand/tftp.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libstand/tftp.c b/lib/libstand/tftp.c
index db796b3..a6695e9 100644
--- a/lib/libstand/tftp.c
+++ b/lib/libstand/tftp.c
@@ -58,7 +58,7 @@
#include "tftp.h"
-static int tftp_open(char *path, struct open_file *f);
+static int tftp_open(const char *path, struct open_file *f);
static int tftp_close(struct open_file *f);
static int tftp_read(struct open_file *f, void *buf, size_t size, size_t *resid);
static int tftp_write(struct open_file *f, void *buf, size_t size, size_t *resid);
@@ -236,7 +236,7 @@ tftp_getnextblock(h)
static int
tftp_open(path, f)
- char *path;
+ const char *path;
struct open_file *f;
{
struct tftp_handle *tftpfile;
@@ -250,11 +250,16 @@ tftp_open(path, f)
tftpfile->iodesc = io = socktodesc(*(int *) (f->f_devdata));
io->destip = servip;
tftpfile->off = 0;
- tftpfile->path = path; /* XXXXXXX we hope it's static */
+ tftpfile->path = strdup(path);
+ if (tftpfile->path == NULL) {
+ free(tftpfile);
+ return(ENOMEM);
+ }
res = tftp_makereq(tftpfile, path);
if (res) {
+ free(tftpfile->path);
free(tftpfile);
return (res);
}
@@ -345,8 +350,10 @@ tftp_close(f)
/* let it time out ... */
- if (tftpfile)
+ if (tftpfile) {
+ free(tftpfile->path);
free(tftpfile);
+ }
return (0);
}
OpenPOWER on IntegriCloud