seek on the underlying file descriptor and not FILE*.

Avoids problems on OpenBSD with cvd unpacking.


git-svn: trunk@3239
remotes/push_mirror/metadata
Török Edvin 18 years ago
parent 53be1a9dca
commit 2782c74315
  1. 5
      ChangeLog
  2. 22
      libclamav/cvd.c

@ -1,3 +1,8 @@
Sat Sep 22 18:14:49 EEST 2007 (edwin)
-------------------------------------
* libclamav/cvd.c: seek on the underlying file descriptor and not FILE*.
Avoids problems on OpenBSD with cvd unpacking.
Fri Sep 21 18:40:56 EEST 2007 (edwin) Fri Sep 21 18:40:56 EEST 2007 (edwin)
------------------------------------- -------------------------------------
* configure, configure.in: add comment on origin of testcases. * configure, configure.in: add comment on origin of testcases.

@ -365,7 +365,7 @@ int cli_cvdload(FILE *fs, struct cl_engine **engine, unsigned int *signo, short
struct cl_cvd cvd; struct cl_cvd cvd;
int ret; int ret;
time_t s_time; time_t s_time;
int cfd;
cli_dbgmsg("in cli_cvdload()\n"); cli_dbgmsg("in cli_cvdload()\n");
@ -391,11 +391,6 @@ int cli_cvdload(FILE *fs, struct cl_engine **engine, unsigned int *signo, short
cli_warnmsg("***********************************************************\n"); cli_warnmsg("***********************************************************\n");
} }
if(fseek(fs, 512, SEEK_SET) == -1) {
cli_errmsg("cli_cvdload(): fseek(fs, 512, SEEK_SET) failed\n");
return CL_EIO;
}
dir = cli_gentemp(NULL); dir = cli_gentemp(NULL);
if(mkdir(dir, 0700)) { if(mkdir(dir, 0700)) {
cli_errmsg("cli_cvdload(): Can't create temporary directory %s\n", dir); cli_errmsg("cli_cvdload(): Can't create temporary directory %s\n", dir);
@ -403,7 +398,20 @@ int cli_cvdload(FILE *fs, struct cl_engine **engine, unsigned int *signo, short
return CL_ETMPDIR; return CL_ETMPDIR;
} }
if(cli_untgz(fileno(fs), dir)) { cfd = fileno(fs);
/* use only operations on file descriptors, and not on the FILE* from here on
* if we seek the FILE*, the underlying descriptor may not seek as expected
* (for example on OpenBSD, cygwin, etc.).
* So seek the descriptor directly.
*/
if(lseek(cfd, 512, SEEK_SET) == -1) {
cli_errmsg("cli_cvdload(): lseek(fs, 512, SEEK_SET) failed\n");
return CL_EIO;
}
if(cli_untgz(cfd, dir)) {
cli_errmsg("cli_cvdload(): Can't unpack CVD file.\n"); cli_errmsg("cli_cvdload(): Can't unpack CVD file.\n");
free(dir); free(dir);
return CL_ECVDEXTR; return CL_ECVDEXTR;

Loading…
Cancel
Save