* vfs.c (mc_def_getlocalcopy): Preserve existing extension.
Этот коммит содержится в:
родитель
7f923cc9c0
Коммит
b1dbe77c5b
@ -1,5 +1,7 @@
|
|||||||
2002-08-15 Pavel Roskin <proski@gnu.org>
|
2002-08-15 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* vfs.c (mc_def_getlocalcopy): Preserve existing extension.
|
||||||
|
|
||||||
* direntry.c (vfs_s_getlocalcopy): Fix potentially dangerous
|
* direntry.c (vfs_s_getlocalcopy): Fix potentially dangerous
|
||||||
strcpy().
|
strcpy().
|
||||||
|
|
||||||
|
15
vfs/vfs.c
15
vfs/vfs.c
@ -1090,12 +1090,25 @@ mc_def_getlocalcopy (vfs *vfs, char *filename)
|
|||||||
int fdin, fdout, i;
|
int fdin, fdout, i;
|
||||||
char buffer[8192];
|
char buffer[8192];
|
||||||
struct stat mystat;
|
struct stat mystat;
|
||||||
|
char *ext = NULL;
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
fdin = mc_open (filename, O_RDONLY);
|
fdin = mc_open (filename, O_RDONLY);
|
||||||
if (fdin == -1)
|
if (fdin == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
fdout = mc_mkstemps (&tmp, "mclocalcopy", NULL);
|
/* Try to preserve existing extension */
|
||||||
|
for (ptr = filename + strlen(filename) - 1; ptr >= filename; ptr--) {
|
||||||
|
if (*ptr == '.') {
|
||||||
|
ext = ptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isalnum((unsigned char) *ptr))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fdout = mc_mkstemps (&tmp, "mclocalcopy", ext);
|
||||||
if (fdout == -1)
|
if (fdout == -1)
|
||||||
goto fail;
|
goto fail;
|
||||||
while ((i = mc_read (fdin, buffer, sizeof (buffer))) > 0){
|
while ((i = mc_read (fdin, buffer, sizeof (buffer))) > 0){
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user