mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 09:40:51 +01:00
safer file name copies
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@990 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
5a042c79ec
commit
98ebe15f45
@ -123,7 +123,8 @@ static off_t get_offset_stdio(STDIOSTREAMFILE *streamFile) {
|
||||
}
|
||||
|
||||
static void get_name_stdio(STDIOSTREAMFILE *streamfile,char *buffer,size_t length) {
|
||||
strcpy(buffer,streamfile->name);
|
||||
strncpy(buffer,streamfile->name,length);
|
||||
buffer[length-1]='\0';
|
||||
}
|
||||
|
||||
#ifdef PROFILE_STREAMFILE
|
||||
@ -190,7 +191,8 @@ static STREAMFILE * open_stdio_streamfile_buffer_by_FILE(FILE *infile,const char
|
||||
streamfile->buffersize = buffersize;
|
||||
streamfile->buffer = buffer;
|
||||
|
||||
strcpy(streamfile->name,filename);
|
||||
strncpy(streamfile->name,filename,sizeof(streamfile->name));
|
||||
streamfile->name[sizeof(streamfile->name)-1] = '\0';
|
||||
|
||||
return &streamfile->sf;
|
||||
}
|
||||
|
12
unix/vfs.c
12
unix/vfs.c
@ -65,12 +65,14 @@ static size_t get_offset_vfs(VFSSTREAMFILE *streamfile)
|
||||
|
||||
static void get_name_vfs(VFSSTREAMFILE *streamfile,char *buffer,size_t length)
|
||||
{
|
||||
strcpy(buffer,streamfile->name);
|
||||
strncpy(buffer,streamfile->name,length);
|
||||
buffer[length-1]='\0';
|
||||
}
|
||||
|
||||
static void get_realname_vfs(VFSSTREAMFILE *streamfile,char *buffer,size_t length)
|
||||
{
|
||||
strcpy(buffer,streamfile->realname);
|
||||
strncpy(buffer,streamfile->realname,length);
|
||||
buffer[length-1]='\0';
|
||||
}
|
||||
|
||||
static STREAMFILE *open_vfs_by_VFSFILE(VFSFile *file,const char *path);
|
||||
@ -119,10 +121,12 @@ static STREAMFILE *open_vfs_by_VFSFILE(VFSFile *file,const char *path)
|
||||
|
||||
streamfile->vfsFile = file;
|
||||
streamfile->offset = 0;
|
||||
strcpy(streamfile->name,path);
|
||||
strncpy(streamfile->name,path,sizeof(streamfile->name));
|
||||
streamfile->name[sizeof(streamfile->name)-1] = '\0';
|
||||
{
|
||||
gchar* realname = g_filename_from_uri(path,NULL,NULL);
|
||||
strcpy(streamfile->realname,realname);
|
||||
strncpy(streamfile->realname,realname,sizeof(streamfile->realname));
|
||||
streamfile->realname[sizeof(streamfile->realname)-1] = '\0';
|
||||
g_free(realname);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user