diff options
author | msmith <msmith@FreeBSD.org> | 1998-09-18 22:58:01 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 1998-09-18 22:58:01 +0000 |
commit | 3b7700ffefbf84bddf6433f318b4f2d440ab544d (patch) | |
tree | be8d7f6697a189dd3af5c56e280e7937bcdf9ab5 /lib/libstand/ufs.c | |
parent | 01f9752c5500adf97fd320a4547b366297e6b6d9 (diff) | |
download | FreeBSD-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/ufs.c')
-rw-r--r-- | lib/libstand/ufs.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libstand/ufs.c b/lib/libstand/ufs.c index 2a2c56a..1c7fd90 100644 --- a/lib/libstand/ufs.c +++ b/lib/libstand/ufs.c @@ -74,7 +74,7 @@ #include "stand.h" #include "string.h" -static int ufs_open(char *path, struct open_file *f); +static int ufs_open(const char *path, struct open_file *f); static int ufs_close(struct open_file *f); static int ufs_read(struct open_file *f, void *buf, size_t size, size_t *resid); static off_t ufs_seek(struct open_file *f, off_t offset, int where); @@ -387,8 +387,8 @@ search_directory(name, f, inumber_p) * Open a file. */ static int -ufs_open(path, f) - char *path; +ufs_open(upath, f) + const char *upath; struct open_file *f; { register char *cp, *ncp; @@ -401,6 +401,7 @@ ufs_open(path, f) int nlinks = 0; char namebuf[MAXPATHLEN+1]; char *buf = NULL; + char *path = NULL; /* allocate file system specific data structure */ fp = malloc(sizeof(struct file)); @@ -443,7 +444,11 @@ ufs_open(path, f) if ((rc = read_inode(inumber, f)) != 0) goto out; - cp = path; + cp = path = strdup(upath); + if (path == NULL) { + rc = ENOMEM; + goto out; + } while (*cp) { /* @@ -562,6 +567,8 @@ ufs_open(path, f) out: if (buf) free(buf); + if (path) + free(path); if (rc) { if (fp->f_buf) free(fp->f_buf); |