Path arguments to *_open functions should be const, but we were mangling

them.

Submitted by:	write-protected text segment in BTX
This commit is contained in:
Mike Smith 1998-09-18 22:58:01 +00:00
parent 0532933e60
commit 4ce36a791b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=39468
9 changed files with 54 additions and 74 deletions

View File

@ -43,7 +43,7 @@
#include "stand.h"
static int cd9660_open(char *path, struct open_file *f);
static int cd9660_open(const char *path, struct open_file *f);
static int cd9660_close(struct open_file *f);
static int cd9660_read(struct open_file *f, void *buf, size_t size, size_t *resid);
static int cd9660_write(struct open_file *f, void *buf, size_t size, size_t *resid);
@ -91,7 +91,7 @@ isonum_732(p)
static int
pnmatch(path, pp)
char *path;
const char *path;
struct ptable_ent *pp;
{
char *cp;
@ -110,7 +110,7 @@ pnmatch(path, pp)
static int
dirmatch(path, dp)
char *path;
const char *path;
struct iso_directory_record *dp;
{
char *cp;
@ -148,7 +148,7 @@ dirmatch(path, dp)
static int
cd9660_open(path, f)
char *path;
const char *path;
struct open_file *f;
{
struct file *fp = 0;

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: zipfs.c,v 1.1.1.1 1998/08/20 08:19:55 msmith Exp $
*
*/
@ -43,7 +43,7 @@ struct z_file
};
static int zf_fill(struct z_file *z);
static int zf_open(char *path, struct open_file *f);
static int zf_open(const char *path, struct open_file *f);
static int zf_close(struct open_file *f);
static int zf_read(struct open_file *f, void *buf, size_t size, size_t *resid);
static off_t zf_seek(struct open_file *f, off_t offset, int where);
@ -157,7 +157,7 @@ check_header(struct z_file *zf)
}
static int
zf_open(char *fname, struct open_file *f)
zf_open(const char *fname, struct open_file *f)
{
static char *zfname;
int rawfd;

View File

@ -43,7 +43,6 @@
#include "stand.h"
#include "net.h"
#include "netif.h"
#include "nfs.h"
#include "rpc.h"
#define NFS_DEBUGxx
@ -102,7 +101,7 @@ struct nfs_iodesc {
* XXX interactions with tftp? See nfswrapper.c for a confusing
* issue.
*/
int nfs_open(char *path, struct open_file *f);
int nfs_open(const char *path, struct open_file *f);
static int nfs_close(struct open_file *f);
static int nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid);
static int nfs_write(struct open_file *f, void *buf, size_t size, size_t *resid);
@ -180,7 +179,7 @@ nfs_getrootfh(d, path, fhp)
int
nfs_lookupfh(d, name, newfd)
struct nfs_iodesc *d;
char *name;
const char *name;
struct nfs_iodesc *newfd;
{
register int len, rlen;
@ -353,8 +352,8 @@ nfs_readdata(d, off, addr, len)
* return zero or error number
*/
int
nfs_open(path, f)
char *path;
nfs_open(upath, f)
const char *upath;
struct open_file *f;
{
static struct nfs_iodesc nfs_root_node;
@ -370,6 +369,7 @@ nfs_open(path, f)
int nlinks = 0;
#endif
int error;
char *path;
#ifdef NFS_DEBUG
if (debug)
@ -400,7 +400,11 @@ nfs_open(path, f)
currfd = &nfs_root_node;
newfd = 0;
cp = path;
cp = path = strdup(upath);
if (path == NULL) {
error = ENOMEM;
goto out;
}
while (*cp) {
/*
* Remove extra separators
@ -496,13 +500,15 @@ nfs_open(path, f)
out:
if (newfd)
free(newfd);
if (path)
free(path);
#else
/* allocate file system specific data structure */
currfd = malloc(sizeof(*currfd));
currfd->iodesc = desc;
currfd->off = 0;
error = nfs_lookupfh(&nfs_root_node, path, currfd);
error = nfs_lookupfh(&nfs_root_node, upath, currfd);
#endif
if (!error) {
f->f_fsdata = (void *)currfd;

View File

@ -1,37 +0,0 @@
/* $NetBSD: nfs.h,v 1.5 1996/07/10 18:32:33 cgd Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
extern int nfs_open(char *path, struct open_file *f); /* XXX for nfswrapper */

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: pager.c,v 1.1.1.1 1998/08/20 08:19:55 msmith Exp $
*/
/*
* Simple paged-output and paged-viewing functions
@ -127,7 +127,7 @@ pager_output(const char *cp)
* Display from (fd).
*/
int
pager_file(char *fname)
pager_file(const char *fname)
{
char buf[80];
size_t hmuch;

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: stand.h,v 1.1.1.1 1998/08/20 08:19:55 msmith Exp $
* $Id: stand.h,v 1.2 1998/08/24 02:54:33 bde Exp $
* From $NetBSD: stand.h,v 1.22 1997/06/26 19:17:40 drochner Exp $
*/
@ -97,8 +97,8 @@ struct open_file;
* filesystems that they require.
*/
struct fs_ops {
char *fs_name;
int (*fo_open)(char *path, struct open_file *f);
const char *fs_name;
int (*fo_open)(const char *path, struct open_file *f);
int (*fo_close)(struct open_file *f);
int (*fo_read)(struct open_file *f, void *buf,
size_t size, size_t *resid);
@ -129,7 +129,7 @@ extern struct fs_ops dosfs_fsops;
* Device switch
*/
struct devsw {
char dv_name[8];
const char dv_name[8];
int dv_type; /* opaque type constant, arch-dependant */
int (*dv_init)(void); /* early probe call */
int (*dv_strategy)(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize);
@ -188,7 +188,7 @@ extern void ngets(char *, int);
#define gets(x) ngets((x), 0)
extern int fgetstr(char *buf, int size, int fd);
extern char *strerror(int);
extern const char *strerror(int);
extern int open(const char *, int);
#define O_RDONLY 0x0
@ -214,7 +214,7 @@ extern int getopt(int, char * const [], const char *);
extern void pager_open(void);
extern void pager_close(void);
extern int pager_output(const char *lines);
extern int pager_file(char *fname);
extern int pager_file(const char *fname);
/* environment.c */
#define EV_DYNAMIC (1<<0) /* value was dynamically allocated, free if changed/unset */
@ -280,16 +280,13 @@ extern int nodev(void);
extern int noioctl(struct open_file *, u_long, void *);
extern void nullsys(void);
extern int null_open(char *path, struct open_file *f);
extern int null_open(const char *path, struct open_file *f);
extern int null_close(struct open_file *f);
extern ssize_t null_read(struct open_file *f, void *buf, size_t size, size_t *resid);
extern ssize_t null_write(struct open_file *f, void *buf, size_t size, size_t *resid);
extern off_t null_seek(struct open_file *f, off_t offset, int where);
extern int null_stat(struct open_file *f, struct stat *sb);
/* stuff should be in bootstrap (undocumented) */
extern int getfile(char *prompt, int mode);
/*
* Machine dependent functions and data, must be provided or stubbed by
* the consumer

View File

@ -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);
}

View File

@ -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);

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: zipfs.c,v 1.1.1.1 1998/08/20 08:19:55 msmith Exp $
*
*/
@ -43,7 +43,7 @@ struct z_file
};
static int zf_fill(struct z_file *z);
static int zf_open(char *path, struct open_file *f);
static int zf_open(const char *path, struct open_file *f);
static int zf_close(struct open_file *f);
static int zf_read(struct open_file *f, void *buf, size_t size, size_t *resid);
static off_t zf_seek(struct open_file *f, off_t offset, int where);
@ -157,7 +157,7 @@ check_header(struct z_file *zf)
}
static int
zf_open(char *fname, struct open_file *f)
zf_open(const char *fname, struct open_file *f)
{
static char *zfname;
int rawfd;