*** /home/njh/src/clamav-devel/./libclamav/htmlnorm.c 2006-10-09 17:00:07.000000000 +0100 --- ./libclamav/htmlnorm.c 2006-10-09 17:32:30.000000000 +0100 *************** *** 495,501 **** if (fd_tmp < 0) { return FALSE; } ! stream_in = fdopen(fd_tmp, "r"); if (!stream_in) { close(fd_tmp); return FALSE; --- 495,501 ---- if (fd_tmp < 0) { return FALSE; } ! stream_in = fdopen(fd_tmp, "rb"); if (!stream_in) { close(fd_tmp); return FALSE; *************** *** 537,543 **** } snprintf(filename, 1024, "%s/comment.html", dirname); ! file_buff_o1->fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR); if (!file_buff_o1->fd) { cli_dbgmsg("open failed: %s\n", filename); free(file_buff_o1); --- 537,543 ---- } snprintf(filename, 1024, "%s/comment.html", dirname); ! file_buff_o1->fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IWUSR|S_IRUSR); if (!file_buff_o1->fd) { cli_dbgmsg("open failed: %s\n", filename); free(file_buff_o1); *************** *** 548,554 **** } snprintf(filename, 1024, "%s/nocomment.html", dirname); ! file_buff_o2->fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR); if (!file_buff_o2->fd) { cli_dbgmsg("open failed: %s\n", filename); close(file_buff_o1->fd); --- 548,554 ---- } snprintf(filename, 1024, "%s/nocomment.html", dirname); ! file_buff_o2->fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IWUSR|S_IRUSR); if (!file_buff_o2->fd) { cli_dbgmsg("open failed: %s\n", filename); close(file_buff_o1->fd); *************** *** 560,566 **** } snprintf(filename, 1024, "%s/script.html", dirname); ! file_buff_script->fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR); if (!file_buff_script->fd) { cli_dbgmsg("open failed: %s\n", filename); close(file_buff_o1->fd); --- 560,566 ---- } snprintf(filename, 1024, "%s/script.html", dirname); ! file_buff_script->fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IWUSR|S_IRUSR); if (!file_buff_script->fd) { cli_dbgmsg("open failed: %s\n", filename); close(file_buff_o1->fd); *************** *** 1273,1279 **** snprintf(filename, 1024, "%s/rfc2397", dirname); tmp_file = cli_gentemp(filename); cli_dbgmsg("RFC2397 data file: %s\n", tmp_file); ! file_tmp_o1->fd = open(tmp_file, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR); free(tmp_file); if (!file_tmp_o1->fd) { cli_dbgmsg("open failed: %s\n", filename); --- 1273,1279 ---- snprintf(filename, 1024, "%s/rfc2397", dirname); tmp_file = cli_gentemp(filename); cli_dbgmsg("RFC2397 data file: %s\n", tmp_file); ! file_tmp_o1->fd = open(tmp_file, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IWUSR|S_IRUSR); free(tmp_file); if (!file_tmp_o1->fd) { cli_dbgmsg("open failed: %s\n", filename); *************** *** 1475,1488 **** if (fd_tmp < 0) { return FALSE; } ! stream_in = fdopen(fd_tmp, "r"); if (!stream_in) { close(fd_tmp); return FALSE; } snprintf(filename, 1024, "%s/screnc.html", dirname); ! file_buff.fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR); file_buff.length = 0; if (!file_buff.fd) { --- 1475,1488 ---- if (fd_tmp < 0) { return FALSE; } ! stream_in = fdopen(fd_tmp, "rb"); if (!stream_in) { close(fd_tmp); return FALSE; } snprintf(filename, 1024, "%s/screnc.html", dirname); ! file_buff.fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IWUSR|S_IRUSR); file_buff.length = 0; if (!file_buff.fd) { *** /home/njh/src/clamav-devel/./libclamav/readdb.c 2006-10-09 17:00:07.000000000 +0100 --- ./libclamav/readdb.c 2006-10-09 20:28:22.000000000 +0100 *************** *** 1284,1290 **** struct stat sb; int ret; - if(stat(path, &sb) == -1) { cli_errmsg("cl_loaddbdir(): Can't get status of %s\n", path); return CL_EIO; --- 1284,1289 ---- *** /home/njh/src/clamav-devel/./libclamav/blob.c 2006-10-08 13:22:52.000000000 +0100 --- ./libclamav/blob.c 2006-09-27 11:30:16.000000000 +0100 *************** *** 16,22 **** * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #if HAVE_CONFIG_H #include "clamav-config.h" --- 16,22 ---- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #if HAVE_CONFIG_H #include "clamav-config.h" *************** *** 440,446 **** cli_dbgmsg("fileblobSetFilename: _mktemp_s(%s)\n", fullname); if(_mktemp_s(fullname, strlen(fullname) + 1) != 0) { char *name; ! /* _mktemp_s only allows 26 files */ cli_dbgmsg("fileblobSetFilename: _mktemp_s(%s) failed: %s\n", fullname, strerror(errno)); name = cli_gentemp(dir); --- 440,446 ---- cli_dbgmsg("fileblobSetFilename: _mktemp_s(%s)\n", fullname); if(_mktemp_s(fullname, strlen(fullname) + 1) != 0) { char *name; ! /* _mktemp_s only allows 26 files */ cli_dbgmsg("fileblobSetFilename: _mktemp_s(%s) failed: %s\n", fullname, strerror(errno)); name = cli_gentemp(dir); *** /home/njh/src/clamav-devel/./libclamav/others.c 2006-09-23 13:37:39.000000000 +0100 --- ./libclamav/others.c 2006-10-09 21:14:22.000000000 +0100 *************** *** 384,390 **** --- 384,394 ---- return NULL; } + #if defined(_MSC_VER) && defined(_DEBUG) + alloc = _realloc_dbg(ptr, size, _NORMAL_BLOCK, __FILE__, __LINE__); + #else alloc = realloc(ptr, size); + #endif if(!alloc) { cli_errmsg("cli_realloc(): Can't re-allocate memory to %u byte.\n", size); *** /home/njh/src/clamav-devel/./libclamav/unrar/unrar.c 2006-09-26 10:11:01.000000000 +0100 --- ./libclamav/unrar/unrar.c 2006-10-09 17:34:56.000000000 +0100 *************** *** 1470,1476 **** metadata_tail->encrypted = TRUE; } else /*if (file_header->unpack_size)*/ { snprintf(filename, 1024, "%s/%lu.ura", dirname, file_count); ! ofd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0600); if (ofd < 0) { free(file_header->filename); free(file_header); --- 1470,1476 ---- metadata_tail->encrypted = TRUE; } else /*if (file_header->unpack_size)*/ { snprintf(filename, 1024, "%s/%lu.ura", dirname, file_count); ! ofd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600); if (ofd < 0) { free(file_header->filename); free(file_header); *** /home/njh/src/clamav-devel/./libclamav/binhex.c 2006-10-08 13:25:05.000000000 +0100 --- ./libclamav/binhex.c 2006-08-11 21:05:12.000000000 +0100 *************** *** 18,25 **** * * Change History: * $Log: patches,v $ * Revision 1.13 2006/10/10 21:26:41 njh * Sync with CVS * ! * Revision 1.22 2006/07/31 09:19:52 njh ! * Use MAP_PRIVATE * * Revision 1.21 2006/07/01 16:17:35 njh * Added destroy flag --- 18,25 ---- * * Change History: * $Log: patches,v $ * Revision 1.13 2006/10/10 21:26:41 njh * Sync with CVS * ! * Revision 1.1 2006/08/11 20:05:13 njh ! * First Draft * * Revision 1.21 2006/07/01 16:17:35 njh * Added destroy flag *************** *** 82,88 **** * First draft of binhex.c * */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #include "clamav.h" --- 82,88 ---- * First draft of binhex.c * */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #include "clamav.h" *************** *** 197,203 **** cli_errmsg("No binhex line found\n"); return CL_EFORMAT; } ! /* similar to binhexMessage */ messageSetEncoding(m, "x-binhex"); --- 197,203 ---- cli_errmsg("No binhex line found\n"); return CL_EFORMAT; } ! /* similar to binhexMessage */ messageSetEncoding(m, "x-binhex"); *** /home/njh/src/clamav-devel/./libclamav/line.h 2006-04-09 20:59:27.000000000 +0100 --- ./libclamav/line.h 2006-08-11 21:05:12.000000000 +0100 *************** *** 17,22 **** --- 17,25 ---- * MA 02110-1301, USA. * * $Log: patches,v $ * Revision 1.13 2006/10/10 21:26:41 njh * Sync with CVS * + * Revision 1.1 2006/08/11 20:05:13 njh + * First Draft + * * Revision 1.5 2006/04/09 19:59:27 kojm * update GPL headers with new address for FSF * *** /home/njh/src/clamav-devel/./libclamav/text.h 2006-07-01 17:17:35.000000000 +0100 --- ./libclamav/text.h 2006-08-11 21:05:12.000000000 +0100 *************** *** 17,22 **** --- 17,25 ---- * MA 02110-1301, USA. * * $Log: patches,v $ * Revision 1.13 2006/10/10 21:26:41 njh * Sync with CVS * + * Revision 1.1 2006/08/11 20:05:13 njh + * First Draft + * * Revision 1.9 2006/07/01 16:17:35 njh * Added destroy flag * *** /home/njh/src/clamav-devel/./libclamav/is_tar.h 2005-03-22 21:26:25.000000000 +0000 --- ./libclamav/is_tar.h 2006-08-11 21:05:12.000000000 +0100 *************** *** 5,11 **** * * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu. * ! * $Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $ # checkin only */ /* --- 5,11 ---- * * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu. * ! * $Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $ # checkin only */ /* *** /home/njh/src/clamav-devel/./libclamav/is_tar.c 2006-06-17 22:00:44.000000000 +0100 --- ./libclamav/is_tar.c 2006-08-11 21:05:12.000000000 +0100 *************** *** 5,11 **** * Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu). * * @(#)list.c 1.18 9/23/86 Public Domain - gnu ! * $Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $ * * Comments changed and some code/comments reformatted * for file command by Ian Darwin. --- 5,11 ---- * Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu). * * @(#)list.c 1.18 9/23/86 Public Domain - gnu ! * $Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $ * * Comments changed and some code/comments reformatted * for file command by Ian Darwin. *** /home/njh/src/clamav-devel/./libclamav/scanners.c 2006-10-09 17:48:45.000000000 +0100 --- ./libclamav/scanners.c 2006-07-31 20:42:08.000000000 +0100 *************** *** 38,43 **** --- 38,44 ---- #include #endif + #if HAVE_MMAP #if HAVE_SYS_MMAN_H #include *************** *** 48,57 **** #include - #ifndef O_BINARY - #define O_BINARY 0 - #endif - extern short cli_leavetemps_flag; #include "clamav.h" --- 49,54 ---- *************** *** 73,79 **** #include "untar.h" #include "special.h" #include "binhex.h" - #include "js.h" /* #include "uuencode.h" */ #include "tnef.h" #include "pst.h" --- 70,75 ---- *************** *** 1143,1169 **** return ret; } - #ifdef CL_EXPERIMENTAL - if(ret == CL_CLEAN) { - char *t = cli_gentemp(NULL); - if(mkdir(t, 0700)) { - cli_dbgmsg("ScanHTML -> Can't create temporary directory %s\n", t); - free(t); - if(!cli_leavetemps_flag) - cli_rmdirs(tempname); - free(tempname); - return CL_ETMPDIR; - } - - lseek(desc, 0L, SEEK_SET); - ret = cli_scanjs(t, desc); - if(ret == CL_CLEAN) - ret = cli_scandir(t, ctx); - if(!cli_leavetemps_flag) - cli_rmdirs(t); - } - #endif - if (ret == CL_CLEAN) { snprintf(fullname, 1024, "%s/rfc2397", tempname); ret = cli_scandir(fullname, ctx); --- 1139,1144 ---- *** /home/njh/src/clamav-devel/./libclamav/untar.c 2006-08-20 20:42:02.000000000 +0100 --- ./libclamav/untar.c 2006-08-20 20:47:28.000000000 +0100 *************** *** 22,27 **** --- 22,30 ---- * * Change History: * $Log: patches,v $ * Revision 1.13 2006/10/10 21:26:41 njh * Sync with CVS * + * Revision 1.2 2006/08/20 19:47:28 njh + * Fix error return + * * Revision 1.31 2006/08/20 19:42:02 njh * Fix error return * *************** *** 116,122 **** * First draft * */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #include #include --- 119,125 ---- * First draft * */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #include #include *** /home/njh/src/clamav-devel/./libclamav/untar.h 2006-04-09 20:59:28.000000000 +0100 --- ./libclamav/untar.h 2006-08-11 21:05:12.000000000 +0100 *************** *** 18,23 **** --- 18,26 ---- * * Change History: * $Log: patches,v $ * Revision 1.13 2006/10/10 21:26:41 njh * Sync with CVS * + * Revision 1.1 2006/08/11 20:05:13 njh + * First Draft + * * Revision 1.4 2006/04/09 19:59:28 kojm * update GPL headers with new address for FSF * *** /home/njh/src/clamav-devel/./libclamav/pst.c 2006-09-16 21:22:21.000000000 +0100 --- ./libclamav/pst.c 2006-08-29 08:44:40.000000000 +0100 *************** *** 36,42 **** * TODO: Remove the vcard handling * FIXME: The code does little error checking of OOM scenarios */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #if HAVE_CONFIG_H #include "clamav-config.h" /* must come first */ --- 36,42 ---- * TODO: Remove the vcard handling * FIXME: The code does little error checking of OOM scenarios */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #if HAVE_CONFIG_H #include "clamav-config.h" /* must come first */ *************** *** 57,64 **** #include "cltypes.h" #include "others.h" ! #if defined(C_SOLARIS) || defined(C_WINDOWS) || defined(_HPUX_SOURCE) ! typedef uint16_t u_int16_t; /* should be in cltypes.h */ typedef uint32_t u_int32_t; #endif --- 57,64 ---- #include "cltypes.h" #include "others.h" ! #if defined(C_SOLARIS) || defined(C_WINDOWS) /* should be in cltypes.h */ ! typedef uint16_t u_int16_t; typedef uint32_t u_int32_t; #endif *************** *** 1193,1199 **** struct _pst_table_ptr_struct table, table2; pst_desc desc_rec; pst_desc_ll *d_ptr=NULL, *d_par=NULL; ! int32_t i = 0, prev_id=-1; char *buf = NULL, *bptr; struct _pst_d_ptr_ll { --- 1193,1199 ---- struct _pst_table_ptr_struct table, table2; pst_desc desc_rec; pst_desc_ll *d_ptr=NULL, *d_par=NULL; ! int32_t i = 0, y, prev_id=-1; char *buf = NULL, *bptr; struct _pst_d_ptr_ll { *************** *** 1514,1519 **** --- 1514,1520 ---- return -1; } + y = 0; while(table.start != 0 /*&& y < 0x1F && table.start < end_val*/) { if (table2.start <= table.start) { *************** *** 2070,2076 **** } int32_t _pst_process(pst_num_array *list , pst_item *item) { ! int32_t x; int32_t next = 0; pst_item_attach *attach; pst_item_extra_field *ef; --- 2071,2077 ---- } int32_t _pst_process(pst_num_array *list , pst_item *item) { ! int32_t x, t; int32_t next = 0; pst_item_attach *attach; pst_item_extra_field *ef; *************** *** 2125,2130 **** --- 2126,2132 ---- MALLOC_EMAIL(item); memcpy(&(item->email->importance), list->items[x]->data, sizeof(item->email->importance)); LE32_CPU(item->email->importance); + t = item->email->importance; // INC_CHECK_X(); break; case 0x001A: // PR_MESSAGE_CLASS Ascii type of messages - NOT FOLDERS *************** *** 2175,2180 **** --- 2177,2183 ---- MALLOC_EMAIL(item); memcpy(&(item->email->priority), list->items[x]->data, sizeof(item->email->priority)); LE32_CPU(item->email->priority); + t = item->email->priority; // INC_CHECK_X(); break; case 0x0029:// PR_READ_RECEIPT_REQUESTED *************** *** 2209,2214 **** --- 2212,2218 ---- MALLOC_EMAIL(item); memcpy(&(item->email->orig_sensitivity), list->items[x]->data, sizeof(item->email->orig_sensitivity)); LE32_CPU(item->email->orig_sensitivity); + t = item->email->orig_sensitivity; // INC_CHECK_X(); break; case 0x0036: // PR_SENSITIVITY *************** *** 2221,2226 **** --- 2225,2231 ---- MALLOC_EMAIL(item); memcpy(&(item->email->sensitivity), list->items[x]->data, sizeof(item->email->sensitivity)); LE32_CPU(item->email->sensitivity); + t = item->email->sensitivity; // INC_CHECK_X(); break; case 0x0037: // PR_SUBJECT raw subject *************** *** 2849,2854 **** --- 2854,2860 ---- MOVE_NEXT(attach); memcpy(&(attach->method), list->items[x]->data, sizeof(attach->method)); LE32_CPU(attach->method); + t = attach->method; //INC_CHECK_X(); break; case 0x370B: // PR_RENDERING_POSITION *** /home/njh/src/clamav-devel/./libclamav/regex_list.c 2006-10-08 21:42:25.000000000 +0100 --- ./libclamav/regex_list.c 2006-10-09 11:33:08.000000000 +0100 *************** *** 713,718 **** --- 713,723 ---- static int cli_iswctype(const char c,const enum wctype_t type) { + if(c & 0x80) { + cli_dbgmsg("iswctype top bit is set\n"); + return 0; + } + switch(type) { case ALNUM: return isalnum(c); *************** *** 738,747 **** return isprint(c); case XDIGIT: return isxdigit(c); ! default: { ! cli_warnmsg("Unknown char class in iswctype\n"); ! return 0; ! } } } --- 743,751 ---- return isprint(c); case XDIGIT: return isxdigit(c); ! default: ! cli_warnmsg("Unknown char class in iswctype\n"); ! return 0; } } *** /home/njh/src/clamav-devel/./libclamav/line.c 2006-04-09 20:59:27.000000000 +0100 --- ./libclamav/line.c 2006-08-11 21:05:12.000000000 +0100 *************** *** 17,22 **** --- 17,25 ---- * MA 02110-1301, USA. * * $Log: patches,v $ * Revision 1.13 2006/10/10 21:26:41 njh * Sync with CVS * + * Revision 1.1 2006/08/11 20:05:13 njh + * First Draft + * * Revision 1.10 2006/04/09 19:59:27 kojm * update GPL headers with new address for FSF * *************** *** 49,55 **** * */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #if HAVE_CONFIG_H #include "clamav-config.h" --- 52,58 ---- * */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #if HAVE_CONFIG_H #include "clamav-config.h" *** /home/njh/src/clamav-devel/./libclamav/binhex.h 2006-04-09 20:59:27.000000000 +0100 --- ./libclamav/binhex.h 2006-08-11 21:05:12.000000000 +0100 *************** *** 18,23 **** --- 18,26 ---- * * Change History: * $Log: patches,v $ * Revision 1.13 2006/10/10 21:26:41 njh * Sync with CVS * + * Revision 1.1 2006/08/11 20:05:13 njh + * First Draft + * * Revision 1.4 2006/04/09 19:59:27 kojm * update GPL headers with new address for FSF * *** /home/njh/src/clamav-devel/./libclamav/chmunpack.c 2006-10-09 17:00:07.000000000 +0100 --- ./libclamav/chmunpack.c 2006-10-09 17:31:12.000000000 +0100 *************** *** 829,835 **** if (mf_in.desc < 0) { return FALSE; } ! mf_in.fh = fdopen(mf_in.desc, "r"); if (!mf_in.fh) { close(mf_in.desc); return FALSE; --- 829,835 ---- if (mf_in.desc < 0) { return FALSE; } ! mf_in.fh = fdopen(mf_in.desc, "rb"); if (!mf_in.fh) { close(mf_in.desc); return FALSE; *************** *** 844,850 **** fclose(mf_in.fh); return FALSE; } ! mf_out.fh = fdopen(mf_out.desc, "w"); if (!mf_out.fh) { cli_dbgmsg("fdopen failed\n", filename); free(mf_in.name); --- 844,850 ---- fclose(mf_in.fh); return FALSE; } ! mf_out.fh = fdopen(mf_out.desc, "wb"); if (!mf_out.fh) { cli_dbgmsg("fdopen failed\n", filename); free(mf_in.name); *** /home/njh/src/clamav-devel/./libclamav/pdf.c 2006-10-08 13:24:32.000000000 +0100 --- ./libclamav/pdf.c 2006-09-17 15:50:58.000000000 +0100 *************** *** 15,21 **** * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #if HAVE_CONFIG_H #include "clamav-config.h" --- 15,21 ---- * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! static char const rcsid[] = "$Id: patches,v 1.13 2006/10/10 21:26:41 njh Exp $"; #if HAVE_CONFIG_H #include "clamav-config.h" *************** *** 178,184 **** char *md5digest; size_t length, objlen, streamlen; char fullname[NAME_MAX + 1]; ! if(q == xrefstart) break; if(memcmp(q, "xref", 4) == 0) --- 178,184 ---- char *md5digest; size_t length, objlen, streamlen; char fullname[NAME_MAX + 1]; ! if(q == xrefstart) break; if(memcmp(q, "xref", 4) == 0) *************** *** 297,303 **** } } else fout = open(fullname, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_BINARY, 0600); ! #else mktemp(fullname); fout = open(fullname, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_BINARY, 0600); #endif --- 297,303 ---- } } else fout = open(fullname, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_BINARY, 0600); ! #else mktemp(fullname); fout = open(fullname, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_BINARY, 0600); #endif *** /home/njh/src/clamav-devel/./clamscan/treewalk.h 2006-06-08 21:00:50.000000000 +0100 --- ./clamscan/treewalk.h 2006-07-26 14:36:44.000000000 +0100 *************** *** 20,26 **** --- 20,29 ---- #ifndef __TREEWALK_H #define __TREEWALK_H + #ifndef C_WINDOWS #include + #endif + #include #include "options.h" *** /home/njh/src/clamav-devel/./clamscan/others.c 2006-04-09 20:59:26.000000000 +0100 --- ./clamscan/others.c 2006-07-26 15:03:16.000000000 +0100 *************** *** 29,41 **** --- 29,47 ---- #include #include #include + #ifdef HAVE_UNISTD_H #include + #endif #include + #ifndef C_WINDOWS #include + #endif #include #include + #ifndef C_WINDOWS #include #include + #endif #include #include #include *************** *** 73,78 **** --- 79,92 ---- } } + #ifdef C_WINDOWS + /* FIXME: Handle users correctly */ + int + checkaccess(const char *path, const char *username, int mode) + { + return _access(path, mode); + } + #else int checkaccess(const char *path, const char *username, int mode) { struct passwd *user; *************** *** 117,122 **** --- 131,137 ---- return ret; } + #endif int match_regex(const char *filename, const char *pattern) { *** /home/njh/src/clamav-devel/./clamscan/treewalk.c 2006-10-09 10:09:17.000000000 +0100 --- ./clamscan/treewalk.c 2006-10-09 21:23:06.000000000 +0100 *************** *** 24,35 **** --- 24,39 ---- #include #include #include + #ifdef HAVE_UNISTD_H #include + #endif #include #include + #ifndef C_WINDOWS #include #include #include + #endif #include #include "shared.h" *************** *** 97,103 **** if((dd = opendir(dirname)) != NULL) { while((dent = readdir(dd))) { ! #ifndef C_INTERIX if(dent->d_ino) #endif { --- 101,107 ---- if((dd = opendir(dirname)) != NULL) { while((dent = readdir(dd))) { ! #if (!defined(C_INTERIX)) && (!defined(C_WINDOWS)) && (!defined(C_CYGWIN)) if(dent->d_ino) #endif { *************** *** 136,141 **** --- 140,152 ---- } + #ifdef C_WINDOWS + int + clamav_rmdirs(const char *dir) + { + return rmdirs(dir); + } + #else int clamav_rmdirs(const char *dir) { #ifndef C_CYGWIN *************** *** 184,189 **** --- 195,201 ---- } } + #endif int fixperms(const char *dirname) { *************** *** 195,201 **** if((dd = opendir(dirname)) != NULL) { while((dent = readdir(dd))) { ! #ifndef C_INTERIX if(dent->d_ino) #endif { --- 207,213 ---- if((dd = opendir(dirname)) != NULL) { while((dent = readdir(dd))) { ! #if (!defined(C_INTERIX)) && (!defined(C_WINDOWS)) && (!defined(C_CYGWIN)) if(dent->d_ino) #endif { *************** *** 241,247 **** if((dd = opendir(dirname)) != NULL) { while((dent = readdir(dd))) { ! #ifndef C_INTERIX if(dent->d_ino) #endif { --- 253,259 ---- if((dd = opendir(dirname)) != NULL) { while((dent = readdir(dd))) { ! #if (!defined(C_INTERIX)) && (!defined(C_WINDOWS)) && (!defined(C_CYGWIN)) if(dent->d_ino) #endif { *** /home/njh/src/clamav-devel/./clamscan/manager.c 2006-09-15 13:27:22.000000000 +0100 --- ./clamscan/manager.c 2006-10-10 09:21:58.000000000 +0100 *************** *** 30,40 **** --- 30,48 ---- #include #include #include + #ifdef C_WINDOWS + #include + #else #include #include + #endif + #ifdef HAVE_INITGROUPS #include + #endif #include + #ifdef HAVE_UNISTD_H #include + #endif #include #include #include *************** *** 57,62 **** --- 65,75 ---- dev_t procdev; #endif + #ifdef C_WINDOWS + #undef P_tmpdir + + #define P_tmpdir "C:\\WINDOWS\\TEMP" + #endif int scanmanager(const struct optstruct *opt) { *************** *** 69,77 **** struct stat sb; char *fullpath = NULL, cwd[1024]; - /* njh@bandsman.co.uk: BeOS */ ! #if !defined(C_CYGWIN) && !defined(C_OS2) && !defined(C_BEOS) if(!geteuid()) { if((user = getpwnam(UNPUSER)) == NULL) { logg("^Can't get information about user "UNPUSER"\n"); --- 82,89 ---- struct stat sb; char *fullpath = NULL, cwd[1024]; /* njh@bandsman.co.uk: BeOS */ ! #if !defined(C_CYGWIN) && !defined(C_OS2) && !defined(C_BEOS) && !defined(C_WINDOWS) if(!geteuid()) { if((user = getpwnam(UNPUSER)) == NULL) { logg("^Can't get information about user "UNPUSER"\n"); *************** *** 360,371 **** --- 372,385 ---- return 0; } + #ifndef C_WINDOWS if(geteuid()) if(checkaccess(filename, NULL, R_OK) != 1) { if(!printinfected) logg("%s: Access denied\n", filename); return 0; } + #endif claminfo.files++; *************** *** 476,482 **** tmpdir = getenv("TMPDIR"); if(tmpdir == NULL) ! #ifdef P_tmpdir tmpdir = P_tmpdir; #else tmpdir = "/tmp"; --- 490,496 ---- tmpdir = getenv("TMPDIR"); if(tmpdir == NULL) ! #ifdef P_tmpdir tmpdir = P_tmpdir; #else tmpdir = "/tmp"; *************** *** 495,501 **** exit(63); /* critical */ } ! #ifndef C_OS2 if(user) chown(gendir, user->pw_uid, user->pw_gid); #endif --- 509,516 ---- exit(63); /* critical */ } ! #if (!defined(C_OS2)) && (!defined(C_WINDOWS)) ! /* FIXME: do the correct native windows way */ if(user) chown(gendir, user->pw_uid, user->pw_gid); #endif *************** *** 674,680 **** tmpdir = getenv("TMPDIR"); if(tmpdir == NULL) ! #ifdef P_tmpdir tmpdir = P_tmpdir; #else tmpdir = "/tmp"; --- 689,695 ---- tmpdir = getenv("TMPDIR"); if(tmpdir == NULL) ! #ifdef P_tmpdir tmpdir = P_tmpdir; #else tmpdir = "/tmp"; *************** *** 710,716 **** fixperms(gendir); ! #ifndef C_OS2 if(user) { chown(gendir, user->pw_uid, user->pw_gid); chown(tmpfile, user->pw_uid, user->pw_gid); --- 725,731 ---- fixperms(gendir); ! #if (!defined(C_OS2)) && (!defined(C_WINDOWS)) if(user) { chown(gendir, user->pw_uid, user->pw_gid); chown(tmpfile, user->pw_uid, user->pw_gid); *************** *** 753,759 **** logg("*Scanning %s\n", filename); ! if((fd = open(filename, O_RDONLY)) == -1) { logg("^Can't open file %s\n", filename); return 54; } --- 768,774 ---- logg("*Scanning %s\n", filename); ! if((fd = open(filename, O_RDONLY|O_BINARY)) == -1) { logg("^Can't open file %s\n", filename); return 54; } *************** *** 788,794 **** tmpdir = getenv("TMPDIR"); if(tmpdir == NULL) ! #ifdef P_tmpdir tmpdir = P_tmpdir; #else tmpdir = "/tmp"; --- 803,809 ---- tmpdir = getenv("TMPDIR"); if(tmpdir == NULL) ! #ifdef P_tmpdir tmpdir = P_tmpdir; #else tmpdir = "/tmp"; *************** *** 806,811 **** --- 821,833 ---- return 63; } + #ifdef C_WINDOWS + if(setmode(fileno(stdin), O_BINARY) < 0) { + logg("^Can't set binary mode on stdin\n"); + return 63; + } + #endif + while((ret = fread(buff, 1, FILEBUFF, stdin))) fwrite(buff, 1, ret, fs); *************** *** 840,845 **** --- 862,875 ---- * 0 -> OK */ + #ifdef C_WINDOWS + int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struct passwd *user, const struct optstruct *opt) + { + /* TODO: use spamvp(P_WAIT, prog, args); */ + cli_errmsg("clamav_unpack is not supported under Windows yet\n"); + return -1; + } + #else int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struct passwd *user, const struct optstruct *opt) { pid_t pid; *************** *** 870,876 **** case -1: return -1; case 0: ! #ifndef C_CYGWIN if(!geteuid() && user) { #ifdef HAVE_SETGROUPS --- 900,906 ---- case -1: return -1; case 0: ! #if (!defined(C_CYGWIN)) && (!defined(C_WINDOWS)) if(!geteuid() && user) { #ifdef HAVE_SETGROUPS *************** *** 946,958 **** return 0; } void move_infected(const char *filename, const struct optstruct *opt) { char *movedir, *movefilename, *tmp, numext[4 + 1]; struct stat fstat, mfstat; int n, len, movefilename_size; ! struct utimbuf ubuf; if(!(movedir = opt_arg(opt, "move"))) { --- 976,989 ---- return 0; } + #endif void move_infected(const char *filename, const struct optstruct *opt) { char *movedir, *movefilename, *tmp, numext[4 + 1]; struct stat fstat, mfstat; int n, len, movefilename_size; ! struct _utimbuf ubuf; if(!(movedir = opt_arg(opt, "move"))) { *************** *** 1030,1036 **** } chmod(movefilename, fstat.st_mode); ! #ifndef C_OS2 chown(movefilename, fstat.st_uid, fstat.st_gid); #endif --- 1061,1067 ---- } chmod(movefilename, fstat.st_mode); ! #if (!defined(C_OS2)) && (!defined(C_WINDOWS)) chown(movefilename, fstat.st_uid, fstat.st_gid); #endif *** /home/njh/src/clamav-devel/./clamscan/clamscan.c 2006-09-15 13:27:22.000000000 +0100 --- ./clamscan/clamscan.c 2006-10-10 09:50:04.000000000 +0100 *************** *** 24,32 **** --- 24,39 ---- #include #include #include + #ifdef HAVE_UNISTD_H #include + #endif + #ifdef C_WINDOWS + #include + #else #include + #endif #include + #include #include "clamscan_opt.h" #include "others.h" *************** *** 53,62 **** int ds, dms, ret; double mb; struct timeval t1, t2; struct timezone tz; struct optstruct *opt; const char *pt; ! opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, NULL); if(!opt) { --- 60,77 ---- int ds, dms, ret; double mb; struct timeval t1, t2; + #ifndef C_WINDOWS struct timezone tz; + #endif struct optstruct *opt; const char *pt; ! ! #if defined(C_WINDOWS) && defined(CL_THREAD_SAFE) ! if(!pthread_win32_process_attach_np()) { ! mprintf("!Can't start the win32 pthreads layer\n"); ! return 1; ! } ! #endif opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, NULL); if(!opt) { *************** *** 174,184 **** memset(&claminfo, 0, sizeof(struct s_info)); gettimeofday(&t1, &tz); ret = scanmanager(opt); if(!opt_check(opt, "disable-summary") && !opt_check(opt, "no-summary")) { ! gettimeofday(&t2, &tz); ds = t2.tv_sec - t1.tv_sec; dms = t2.tv_usec - t1.tv_usec; ds -= (dms < 0) ? (1):(0); --- 189,210 ---- memset(&claminfo, 0, sizeof(struct s_info)); + #ifdef C_WINDOWS + _set_fmode(_O_BINARY); + + gettimeofday(&t1, NULL); + #else gettimeofday(&t1, &tz); + #endif + ret = scanmanager(opt); if(!opt_check(opt, "disable-summary") && !opt_check(opt, "no-summary")) { ! #ifdef C_WINDOWS ! gettimeofday(&t2, NULL); ! #else ! gettimeofday(&t2, &tz); ! #endif ds = t2.tv_sec - t1.tv_sec; dms = t2.tv_usec - t1.tv_usec; ds -= (dms < 0) ? (1):(0); *************** *** 204,209 **** --- 230,243 ---- } opt_free(opt); + + #if defined(C_WINDOWS) && defined(CL_THREAD_SAFE) + if(!pthread_win32_process_detach_np()) { + mprintf("!Can't stop the win32 pthreads layer\n"); + return 1; + } + #endif + return ret; } *** /home/njh/src/clamav-devel/./clamscan/manager.h 2006-05-15 19:30:18.000000000 +0100 --- ./clamscan/manager.h 2006-10-10 10:12:40.000000000 +0100 *************** *** 21,27 **** --- 21,29 ---- #define __MANAGER_H #include + #ifndef C_WINDOWS #include + #endif #include "options.h" int scanmanager(const struct optstruct *opt); *************** *** 42,45 **** --- 44,52 ---- void move_infected(const char *filename, const struct optstruct *opt); + #ifdef _DEBUG + /* breaks mspack/qtmd.c :-( */ + #define free(p) _free_dbg(p, _NORMAL_BLOCK) + #endif + #endif *** /home/njh/src/clamav-devel/./shared/network.c 2006-09-27 17:24:10.000000000 +0100 --- ./shared/network.c 2006-08-01 17:57:24.000000000 +0100 *************** *** 78,84 **** if(gethostbyname_r(hostname, &hp, (struct hostent_data *)buf) < 0) return h_errno; #else ! /* Single thread the code e.g. VS2005 */ struct hostent *hp2; #ifdef CL_THREAD_SAFE static pthread_mutex_t hostent_mutex = PTHREAD_MUTEX_INITIALIZER; --- 78,84 ---- if(gethostbyname_r(hostname, &hp, (struct hostent_data *)buf) < 0) return h_errno; #else ! /* Single thread the code */ struct hostent *hp2; #ifdef CL_THREAD_SAFE static pthread_mutex_t hostent_mutex = PTHREAD_MUTEX_INITIALIZER; *** /home/njh/src/clamav-devel/./shared/getopt.c 2004-03-29 01:00:58.000000000 +0100 --- ./shared/getopt.c 2006-07-26 15:49:38.000000000 +0100 *************** *** 41,47 **** --- 41,49 ---- #include + #ifndef C_WINDOWS int strncmp(const char *s1, const char *s2, size_t n); + #endif /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C *** /home/njh/src/clamav-devel/./shared/cdiff.c 2006-10-07 16:31:11.000000000 +0100 --- ./shared/cdiff.c 2006-10-09 19:39:06.000000000 +0100 *************** *** 27,33 **** --- 27,35 ---- #include #include #include + #ifdef HAVE_UNISTD_H #include + #endif #include "shared/memory.h" #include "shared/misc.h" *************** *** 356,362 **** if(del || xchg) { ! if(!(fh = fopen(ctx->open_db, "r"))) { logg("!cdiff_cmd_close: Can't open file %s for reading\n", ctx->open_db); return -1; } --- 358,364 ---- if(del || xchg) { ! if(!(fh = fopen(ctx->open_db, "rb"))) { logg("!cdiff_cmd_close: Can't open file %s for reading\n", ctx->open_db); return -1; } *************** *** 367,373 **** return -1; } ! if(!(tmpfh = fopen(tmp, "w"))) { logg("!cdiff_cmd_close: Can't open file %s for writing\n", tmp); fclose(fh); free(tmp); --- 369,375 ---- return -1; } ! if(!(tmpfh = fopen(tmp, "wb"))) { logg("!cdiff_cmd_close: Can't open file %s for writing\n", tmp); fclose(fh); free(tmp); *************** *** 452,458 **** if(add) { ! if(!(fh = fopen(ctx->open_db, "a"))) { logg("!cdiff_cmd_close: Can't open file %s for appending\n", ctx->open_db); return -1; } --- 454,460 ---- if(add) { ! if(!(fh = fopen(ctx->open_db, "ab"))) { logg("!cdiff_cmd_close: Can't open file %s for appending\n", ctx->open_db); return -1; } *************** *** 523,529 **** return -1; } ! if(!(src = fopen(srcdb, "r"))) { logg("!cdiff_cmd_move: Can't open %s for reading\n", srcdb); free(start_str); free(end_str); --- 525,531 ---- return -1; } ! if(!(src = fopen(srcdb, "rb"))) { logg("!cdiff_cmd_move: Can't open %s for reading\n", srcdb); free(start_str); free(end_str); *************** *** 540,546 **** return -1; } ! if(!(dst = fopen(dstdb, "a"))) { logg("!cdiff_cmd_move: Can't open %s for appending\n", dstdb); free(start_str); free(end_str); --- 542,548 ---- return -1; } ! if(!(dst = fopen(dstdb, "ab"))) { logg("!cdiff_cmd_move: Can't open %s for appending\n", dstdb); free(start_str); free(end_str); *************** *** 561,567 **** return -1; } ! if(!(tmp = fopen(tmpdb, "w"))) { logg("!cdiff_cmd_move: Can't open file %s for writing\n", tmpdb); free(start_str); free(end_str); --- 563,569 ---- return -1; } ! if(!(tmp = fopen(tmpdb, "wb"))) { logg("!cdiff_cmd_move: Can't open file %s for writing\n", tmpdb); free(start_str); free(end_str); *************** *** 724,730 **** return -1; } ! if(!(fh = fdopen(desc, "r"))) { logg("!cdiff_apply: fdopen() failed for descriptor %d\n", desc); close(desc); return -1; --- 726,732 ---- return -1; } ! if(!(fh = fdopen(desc, "rb"))) { logg("!cdiff_apply: fdopen() failed for descriptor %d\n", desc); close(desc); return -1; *** /home/njh/src/clamav-devel/./shared/network.h 2006-04-09 20:59:28.000000000 +0100 --- ./shared/network.h 2006-07-31 14:59:30.000000000 +0100 *************** *** 21,28 **** --- 21,33 ---- #ifndef __NETWORK_H #define __NETWORK_H + #ifdef HAVE_SYS_TYPES_H #include + #endif + + #ifndef C_WINDOWS #include + #endif int r_gethostbyname(const char *hostname, struct hostent *hp, char *buf, size_t len); *** /home/njh/src/clamav-devel/./shared/output.c 2006-08-31 09:03:18.000000000 +0100 --- ./shared/output.c 2006-08-31 09:23:58.000000000 +0100 *************** *** 16,21 **** --- 16,26 ---- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + #ifdef _MSC_VER + #include + #include + #endif + #if HAVE_CONFIG_H #include "clamav-config.h" *************** *** 30,42 **** --- 35,51 ---- #include #include #include + #ifdef HAVE_UNISTD_H #include + #endif #include #include #include #include + #ifndef C_WINDOWS #include #include + #endif #if HAVE_SYS_TYPES_H #include #endif *************** *** 122,128 **** --- 131,139 ---- int logg(const char *str, ...) { va_list args, argscpy, argsout; + #ifdef F_WRLCK struct flock fl; + #endif char *pt, *timestr, vbuff[1025]; time_t currtime; struct stat sb; *************** *** 140,146 **** if(logg_file) { if(!logg_fd) { old_umask = umask(0037); ! if((logg_fd = fopen(logg_file, "a")) == NULL) { umask(old_umask); #ifdef CL_THREAD_SAFE pthread_mutex_unlock(&logg_mutex); --- 151,157 ---- if(logg_file) { if(!logg_fd) { old_umask = umask(0037); ! if((logg_fd = fopen(logg_file, "at")) == NULL) { umask(old_umask); #ifdef CL_THREAD_SAFE pthread_mutex_unlock(&logg_mutex); *************** *** 149,154 **** --- 160,166 ---- return -1; } else umask(old_umask); + #ifdef F_WRLCK if(logg_lock) { memset(&fl, 0, sizeof(fl)); fl.l_type = F_WRLCK; *************** *** 159,164 **** --- 171,177 ---- return -1; } } + #endif } if(logg_size) { *** /home/njh/src/clamav-devel/./shared/misc.c 2006-09-27 13:08:01.000000000 +0100 --- ./shared/misc.c 2006-09-17 16:55:56.000000000 +0100 *************** *** 37,52 **** #include #include ! #include "shared/cfgparser.h" ! #include "shared/memory.h" ! #include "shared/output.h" ! #include "libclamav/clamav.h" ! #include "libclamav/cvd.h" ! ! #ifndef O_BINARY ! #define O_BINARY 0 ! #endif char *freshdbdir(void) --- 37,48 ---- #include #include ! #include "clamav.h" ! #include "cfgparser.h" ! #include "memory.h" ! #include "output.h" ! #include "../libclamav/cvd.h" char *freshdbdir(void) *** /home/njh/src/clamav-devel/./shared/cfgparser.c 2006-10-10 08:17:06.000000000 +0100 --- ./shared/cfgparser.c 2006-10-10 09:25:36.000000000 +0100 *************** *** 139,145 **** } } ! if((fs = fopen(cfgfile, "r")) == NULL) { /* do not print error message here! */ freecfg(copt); return NULL; --- 139,145 ---- } } ! if((fs = fopen(cfgfile, "rb")) == NULL) { /* do not print error message here! */ freecfg(copt); return NULL; *** /home/njh/src/clamav-devel/./shared/memory.c 2006-04-09 20:59:28.000000000 +0100 --- ./shared/memory.c 2006-10-10 10:09:58.000000000 +0100 *************** *** 19,31 **** --- 19,41 ---- #include #include + #ifdef HAVE_UNISTD_H #include + #endif + + #if defined(_MSC_VER) && defined(_DEBUG) + #include + #endif void *mmalloc(size_t size) { void *alloc; + #if defined(_MSC_VER) && defined(_DEBUG) + alloc = _malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__); + #else alloc = malloc(size); + #endif if(!alloc) { fprintf(stderr, "CRITICAL: Can't allocate memory (%ld bytes).\n", (long int) size); *************** *** 38,44 **** --- 48,58 ---- { void *alloc; + #if defined(_MSC_VER) && defined(_DEBUG) + alloc = _calloc_dbg(nmemb, size, _NORMAL_BLOCK, __FILE__, __LINE__); + #else alloc = calloc(nmemb, size); + #endif if(!alloc) { fprintf(stderr, "CRITICAL: Can't allocate memory (%ld bytes).\n", (long int) nmemb * size); *** /home/njh/src/clamav-devel/./shared/memory.h 2006-04-09 20:59:28.000000000 +0100 --- ./shared/memory.h 2006-10-10 10:16:24.000000000 +0100 *************** *** 25,28 **** --- 25,33 ---- void *mmalloc(size_t size); void *mcalloc(size_t nmemb, size_t size); + #ifdef _DEBUG + #include + #define free(p) _free_dbg(p, _NORMAL_BLOCK) + #endif + #endif *** /home/njh/src/clamav-devel/./freshclam/manager.c 2006-09-15 13:11:55.000000000 +0100 --- ./freshclam/manager.c 2006-09-17 11:23:36.000000000 +0100 *************** *** 20,25 **** --- 20,29 ---- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + #ifdef _MSC_VER + #include + #include + #endif #if HAVE_CONFIG_H #include "clamav-config.h" *************** *** 27,40 **** --- 31,50 ---- #include #include + #ifdef HAVE_UNISTD_H #include + #endif #include #include + #ifndef C_WINDOWS #include #include + #endif #include + #ifndef C_WINDOWS #include #include + #endif #include #include #include *************** *** 63,68 **** --- 73,82 ---- #define O_BINARY 0 #endif + #ifndef C_WINDOWS + #define closesocket(s) close(s) + #endif + static int wwwconnect(const char *server, const char *proxy, int pport, char *ip, const char *localip, int ctimeout) { *************** *** 143,149 **** --- 157,165 ---- else port = 8080; + #ifndef C_WINDOWS endservent(); + #endif #else port = 8080; #endif *************** *** 178,184 **** break; } logg("^Can't get information about %s: %s\n", hostpt, herr); ! close(socketfd); return -1; } --- 194,200 ---- break; } logg("^Can't get information about %s: %s\n", hostpt, herr); ! closesocket(socketfd); return -1; } *************** *** 208,214 **** } } ! close(socketfd); return -2; } --- 224,230 ---- } } ! closesocket(socketfd); return -2; } *************** *** 362,370 **** if(!ip[0]) strcpy(ip, ipaddr); ! if(write(sd, cmd, strlen(cmd)) < 0) { logg("!remote_cvdhead: write failed\n"); ! close(sd); return NULL; } --- 378,386 ---- if(!ip[0]) strcpy(ip, ipaddr); ! if(send(sd, cmd, strlen(cmd), 0) < 0) { logg("!remote_cvdhead: write failed\n"); ! closesocket(sd); return NULL; } *************** *** 380,386 **** if(cnt <= 0) break; } ! close(sd); if(bread == -1) { logg("!remote_cvdhead: Error while reading CVD header from %s\n", hostname); --- 396,402 ---- if(cnt <= 0) break; } ! closesocket(sd); if(bread == -1) { logg("!remote_cvdhead: Error while reading CVD header from %s\n", hostname); *************** *** 498,504 **** if(!ip[0]) strcpy(ip, ipaddr); ! if(write(sd, cmd, strlen(cmd)) < 0) { logg("!getfile: Can't write to socket\n"); return 52; } --- 514,520 ---- if(!ip[0]) strcpy(ip, ipaddr); ! if(send(sd, cmd, strlen(cmd), 0) < 0) { logg("!getfile: Can't write to socket\n"); return 52; } *************** *** 536,542 **** /* check whether the resource actually existed or not */ if((strstr(buffer, "HTTP/1.1 404")) != NULL || (strstr(buffer, "HTTP/1.0 404")) != NULL) { logg("!getfile: %s not found on remote server\n", srcfile); ! close(sd); return 58; } --- 552,558 ---- /* check whether the resource actually existed or not */ if((strstr(buffer, "HTTP/1.1 404")) != NULL || (strstr(buffer, "HTTP/1.0 404")) != NULL) { logg("!getfile: %s not found on remote server\n", srcfile); ! closesocket(sd); return 58; } *************** *** 565,571 **** getcwd(currdir, sizeof(currdir)); logg("!getfile: Can't create new file %s in %s\n", destfile, currdir); logg("Hint: The database directory must be writable for UID %d or GID %d\n", getuid(), getgid()); ! close(sd); return 57; } --- 581,587 ---- getcwd(currdir, sizeof(currdir)); logg("!getfile: Can't create new file %s in %s\n", destfile, currdir); logg("Hint: The database directory must be writable for UID %d or GID %d\n", getuid(), getgid()); ! closesocket(sd); return 57; } *************** *** 578,584 **** logg("getfile: Can't write %d bytes to %s\n", bread, destfile); unlink(destfile); close(fd); ! close(sd); return 57; /* FIXME */ } --- 594,600 ---- logg("getfile: Can't write %d bytes to %s\n", bread, destfile); unlink(destfile); close(fd); ! closesocket(sd); return 57; /* FIXME */ } *************** *** 595,601 **** fflush(stdout); } } ! close(sd); close(fd); if(totalsize > 0) --- 611,617 ---- fflush(stdout); } } ! closesocket(sd); close(fd); if(totalsize > 0) *************** *** 722,728 **** return ret; } ! if((fd = open(tempname, O_RDONLY)) == -1) { logg("!getpatch: Can't open %s for reading\n", tempname); unlink(tempname); free(tempname); --- 738,744 ---- return ret; } ! if((fd = open(tempname, O_RDONLY|O_BINARY)) == -1) { logg("!getpatch: Can't open %s for reading\n", tempname); unlink(tempname); free(tempname); *************** *** 971,979 **** char ipaddr[16], *dnsreply = NULL, *pt, *localip = NULL, *newver = NULL; const char *arg = NULL; struct cfgstruct *cpt; - #ifdef HAVE_RESOLV_H const char *dnsdbinfo; - #endif time(&currtime); logg("ClamAV update process started at %s", ctime(&currtime)); --- 987,993 ---- *************** *** 983,989 **** logg("See the FAQ at http://www.clamav.net/faq.html for an explanation.\n"); #endif - #ifdef HAVE_RESOLV_H dnsdbinfo = cfgopt(copt, "DNSDatabaseInfo")->strarg; if(opt_check(opt, "no-dns")) { --- 997,1002 ---- *************** *** 1042,1052 **** } } ! if(!dnsreply) { logg("^Invalid DNS reply. Falling back to HTTP mode.\n"); } } - #endif /* HAVE_RESOLV_H */ if(opt_check(opt, "local-address")) { localip = opt_arg(opt, "local-address"); --- 1055,1064 ---- } } ! if((!dnsreply) && (!ttl)) { logg("^Invalid DNS reply. Falling back to HTTP mode.\n"); } } if(opt_check(opt, "local-address")) { localip = opt_arg(opt, "local-address"); *** /home/njh/src/clamav-devel/./freshclam/execute.c 2006-08-31 08:38:17.000000000 +0100 --- ./freshclam/execute.c 2006-10-06 23:03:52.000000000 +0100 *************** *** 1,5 **** /* ! * By Per Jessen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by --- 1,5 ---- /* ! * By Per Jessen with changes by the ClamAV team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by *************** *** 23,31 **** --- 23,36 ---- #include #include + #ifdef HAVE_UNISTD_H #include + #endif #include #include + #ifdef C_WINDOWS + #include + #endif #include "shared/output.h" *************** *** 35,40 **** --- 40,55 ---- void execute( const char *type, const char *text ) { + #ifdef C_WINDOWS + if(active_children < MAX_CHILDREN) { + if(spawnlp(P_DETACH, text, text, NULL) == -1) { + logg("^%s: couldn't execute \"%s\".\n", type, text); + return; + } + active_children++; /* FIXME: this is never reduced */ + } else + logg("^%s: already %d processes active.\n", type, active_children); + #else pid_t pid; if ( active_children + #endif #if HAVE_CONFIG_H #include "clamav-config.h" *************** *** 24,37 **** #include #include #include #include #include #include #include #include ! #include #include #include #include #include --- 27,46 ---- #include #include + #ifdef HAVE_UNISTD_H #include + #endif #include #include + #ifndef C_WINDOWS #include #include + #endif #include ! /*#include /* in nonblock.h */ ! #ifndef C_WINDOWS #include + #endif #include #include #include *************** *** 40,45 **** --- 49,64 ---- #include "shared/output.h" + #if (!defined(EALREADY)) && (defined(WSAEALREADY)) + #define EALREADY WSAEALREADY + #endif + #if (!defined(EINPROGRESS)) && (defined(WSAEINPROGRESS)) + #define EINPROGRESS WSAEINPROGRESS + #endif + #if (!defined(EISCONN)) && (defined(WSAEISCONN)) + #define EISCONN WSAEISCONN + #endif + #ifdef SO_ERROR #ifndef timercmp *************** *** 229,234 **** --- 248,254 ---- static long nonblock_fcntl(int sock) { + #ifdef F_GETFL long fcntl_flags; /* Save fcntl() flags */ fcntl_flags = fcntl(sock, F_GETFL, 0); *************** *** 242,257 **** --- 262,282 ---- } return fcntl_flags; + #else + return 0; + #endif } static void restore_fcntl(int sock, long fcntl_flags) { + #ifdef F_SETFL if (fcntl_flags != -1) { if (fcntl(sock, F_SETFL, fcntl_flags)) { logg("restore_fcntl: restoring: fcntl(%d, F_SETFL): errno=%d: %s\n", sock, errno, strerror(errno)); } } + #endif } /* *** /home/njh/src/clamav-devel/./freshclam/nonblock.h 2006-09-04 09:24:02.000000000 +0100 --- ./freshclam/nonblock.h 2006-09-04 09:35:10.000000000 +0100 *************** *** 24,30 **** --- 24,32 ---- #endif #include + #ifndef C_WINDOWS #include + #endif /* wait_connect(): wrapper for connect(), with explicit 'secs' timeout *** /home/njh/src/clamav-devel/./freshclam/notify.c 2006-08-31 08:53:35.000000000 +0100 --- ./freshclam/notify.c 2006-08-31 09:26:34.000000000 +0100 *************** *** 16,21 **** --- 16,26 ---- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + #ifdef _MSC_VER + #include + #include + #endif + #if HAVE_CONFIG_H #include "clamav-config.h" *************** *** 24,45 **** --- 29,60 ---- #ifdef BUILD_CLAMD #include + #ifdef HAVE_UNISTD_H #include + #endif #include + #ifndef C_WINDOWS #include #include #include #include #include + #endif #include #include "shared/cfgparser.h" #include "shared/output.h" + #ifndef C_WINDOWS + #define closesocket(s) close(s) + #endif + int notify(const char *cfgfile) { char buff[20]; + #ifndef C_WINDOWS struct sockaddr_un server; + #endif struct sockaddr_in server2; struct hostent *he; struct cfgstruct *copt, *cpt; *************** *** 52,57 **** --- 67,73 ---- return 1; } + #ifndef C_WINDOWS if((cpt = cfgopt(copt, "LocalSocket"))->enabled) { socktype = "UNIX"; server.sun_family = AF_UNIX; *************** *** 64,76 **** } if(connect(sockd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) { ! close(sockd); logg("^Clamd was NOT notified: Can't connect to clamd through %s\n", cpt->strarg); perror("connect()"); return 1; } ! } else if((cpt = cfgopt(copt, "TCPSocket"))->enabled) { socktype = "TCP"; #ifdef PF_INET --- 80,94 ---- } if(connect(sockd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) { ! closesocket(sockd); logg("^Clamd was NOT notified: Can't connect to clamd through %s\n", cpt->strarg); perror("connect()"); return 1; } ! } else ! #endif ! if((cpt = cfgopt(copt, "TCPSocket"))->enabled) { socktype = "TCP"; #ifdef PF_INET *************** *** 98,104 **** if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) { ! close(sockd); logg("^Clamd was NOT notified: Can't connect to clamd on %s:%d\n", inet_ntoa(server2.sin_addr), ntohs(server2.sin_port)); perror("connect()"); --- 116,122 ---- if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) { ! closesocket(sockd); logg("^Clamd was NOT notified: Can't connect to clamd on %s:%d\n", inet_ntoa(server2.sin_addr), ntohs(server2.sin_port)); perror("connect()"); *************** *** 110,132 **** return 1; } ! if(write(sockd, "RELOAD", 6) < 0) { logg("^Clamd was NOT notified: Could not write to %s socket\n", socktype); perror("write()"); ! close(sockd); return 1; } /* TODO: Handle timeout */ memset(buff, 0, sizeof(buff)); ! if((bread = read(sockd, buff, sizeof(buff))) > 0) if(!strstr(buff, "RELOADING")) { logg("^Clamd was NOT notified: Unknown answer from clamd: '%s'\n", buff); ! close(sockd); return 1; } ! close(sockd); logg("Clamd successfully notified about the update.\n"); return 0; } --- 128,150 ---- return 1; } ! if(send(sockd, "RELOAD", 6, 0) < 0) { logg("^Clamd was NOT notified: Could not write to %s socket\n", socktype); perror("write()"); ! closesocket(sockd); return 1; } /* TODO: Handle timeout */ memset(buff, 0, sizeof(buff)); ! if((bread = recv(sockd, buff, sizeof(buff), 0)) > 0) if(!strstr(buff, "RELOADING")) { logg("^Clamd was NOT notified: Unknown answer from clamd: '%s'\n", buff); ! closesocket(sockd); return 1; } ! closesocket(sockd); logg("Clamd successfully notified about the update.\n"); return 0; } *** /home/njh/src/clamav-devel/./clamd/clamd.c 2006-09-15 13:30:20.000000000 +0100 --- ./clamd/clamd.c 2006-09-15 13:29:56.000000000 +0100 *************** *** 16,22 **** * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ ! #ifdef _MSC_VER #include #endif --- 16,22 ---- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ ! #ifdef _MSC_VER #include #endif *** /home/njh/src/clamav-devel/./clamd/localserver.c 2006-09-13 18:50:46.000000000 +0100 --- ./clamd/localserver.c 2006-09-13 20:15:20.000000000 +0100 *************** *** 24,32 **** --- 24,36 ---- #include #include #include + #ifndef C_WINDOWS #include + #endif #include + #ifndef C_WINDOWS #include + #endif #include #include "libclamav/clamav.h" *** /home/njh/src/clamav-devel/./clamdscan/clamdscan.c 2006-05-15 19:30:18.000000000 +0100 --- ./clamdscan/clamdscan.c 2006-08-04 11:37:50.000000000 +0100 *************** *** 16,21 **** --- 16,26 ---- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + + #ifdef _MSC_VER + #include + #include + #endif #if HAVE_CONFIG_H #include "clamav-config.h" *************** *** 24,31 **** --- 29,44 ---- #include #include #include + #ifdef HAVE_UNISTD_H #include + #endif + #ifdef C_WINDOWS + #ifdef CL_THREAD_SAFE + #include + #endif + #else #include + #endif #include #include *************** *** 49,62 **** { int ds, dms, ret, infected; struct timeval t1, t2; struct timezone tz; time_t starttime; struct optstruct *opt; char *clamdscan_accepted[] = { "help", "version", "verbose", "quiet", "stdout", "log", "move", "remove", "config-file", "no-summary", "disable-summary", NULL }; ! opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, clamdscan_accepted); if(!opt) { --- 62,83 ---- { int ds, dms, ret, infected; struct timeval t1, t2; + #ifndef C_WINDOWS struct timezone tz; + #endif time_t starttime; struct optstruct *opt; char *clamdscan_accepted[] = { "help", "version", "verbose", "quiet", "stdout", "log", "move", "remove", "config-file", "no-summary", "disable-summary", NULL }; ! ! #ifdef C_WINDOWS ! if(!pthread_win32_process_attach_np()) { ! mprintf("!Can't start the win32 pthreads layer\n"); ! return 1; ! } ! #endif opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, clamdscan_accepted); if(!opt) { *************** *** 105,117 **** time(&starttime); /* ctime() does \n, but I need it once more */ ! gettimeofday(&t1, &tz); ret = client(opt, &infected); /* TODO: Implement STATUS in clamd */ if(!opt_check(opt, "disable-summary") && !opt_check(opt, "no-summary")) { gettimeofday(&t2, &tz); ds = t2.tv_sec - t1.tv_sec; dms = t2.tv_usec - t1.tv_usec; ds -= (dms < 0) ? (1):(0); --- 126,146 ---- time(&starttime); /* ctime() does \n, but I need it once more */ ! #ifdef C_WINDOWS ! gettimeofday(&t1, NULL); ! #else ! gettimeofday(&t1, &tz); ! #endif ret = client(opt, &infected); /* TODO: Implement STATUS in clamd */ if(!opt_check(opt, "disable-summary") && !opt_check(opt, "no-summary")) { + #ifdef C_WINDOWS + gettimeofday(&t2, NULL); + #else gettimeofday(&t2, &tz); + #endif ds = t2.tv_sec - t1.tv_sec; dms = t2.tv_usec - t1.tv_usec; ds -= (dms < 0) ? (1):(0); *************** *** 128,133 **** --- 157,171 ---- } opt_free(opt); + + #ifdef C_WINDOWS + WSACleanup(); + if(!pthread_win32_process_detach_np()) { + mprintf("!Can't stop the win32 pthreads layer\n"); + return 1; + } + #endif + exit(ret); } *** /home/njh/src/clamav-devel/./clamdscan/client.c 2006-09-12 09:09:03.000000000 +0100 --- ./clamdscan/client.c 2006-09-12 10:37:54.000000000 +0100 *************** *** 16,37 **** --- 16,44 ---- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ + #ifdef _MSC_VER + #include + #endif #if HAVE_CONFIG_H #include "clamav-config.h" #endif #include + #ifdef HAVE_UNISTD_H #include + #endif #include #include #include + #ifndef C_WINDOWS #include #include #include #include #include #include + #endif #include #ifdef HAVE_SYS_UIO_H *************** *** 54,65 **** --- 61,140 ---- # define SOCKET_INET AF_INET #endif + #ifndef C_WINDOWS + #define closesocket(s) close(s) + #endif + /* #define ENABLE_FD_PASSING FIXME: Doesn't work yet */ void move_infected(const char *filename, const struct optstruct *opt); int notremoved = 0, notmoved = 0; static int hwaccel = 0; + #ifdef C_WINDOWS + static int get_a_line(int sockd, char *buf, size_t len); + + static int + dsresult(int sockd, const struct optstruct *opt) + { + char buff[BUFSIZ], *pt; + int infected = 0, waserror = 0; + + while(get_a_line(sockd, buff, sizeof(buff))) { + if(strstr(buff, "FOUND\n")) { + infected++; + logg("%s", buff); + if(opt_check(opt, "move")) { + /* filename: Virus FOUND */ + if((pt = strrchr(buff, ':'))) { + *pt = 0; + move_infected(buff, opt); + } else + mprintf("@Broken data format. File not moved.\n"); + } else if(opt_check(opt, "remove")) { + if(!(pt = strrchr(buff, ':'))) + mprintf("@Broken data format. File not removed.\n"); + else { + *pt = 0; + if(unlink(buff)) { + mprintf("%s: Can't remove.\n", buff); + logg("%s: Can't remove.\n", buff); + notremoved++; + } else { + mprintf("%s: Removed.\n", buff); + logg("%s: Removed.\n", buff); + } + } + } + } + + if(strstr(buff, "ERROR\n")) { + logg("%s", buff); + waserror = 1; + } + } + + return infected ? infected : (waserror ? -1 : 0); + } + + static int + get_a_line(int sockd, char *buf, size_t len) + { + char *ptr; + + for(ptr = buf; ptr < &buf[len]; ptr++) { + /* FIXME: very inefficient to call recv so many times */ + if(recv(sockd, ptr, sizeof(char), 0) <= 0) + return 0; + if(*ptr == '\n') { + *++ptr = '\0'; + return 1; + } + } + return 1; + } + + #else static int dsresult(int sockd, const struct optstruct *opt) { int infected = 0, waserror = 0; *************** *** 67,76 **** FILE *fd; ! #ifndef C_OS2 if((fd = fdopen(dup(sockd), "r")) == NULL) { ! #else /* FIXME: accoriding to YD OS/2 does not support dup() for sockets */ ! if((fd = fdopen(sockd, "r")) == NULL) { #endif logg("^Can't open descriptor for reading.\n"); return -1; --- 142,151 ---- FILE *fd; ! #ifndef (C_OS2) if((fd = fdopen(dup(sockd), "r")) == NULL) { ! #else /* FIXME: according to YD OS/2 does not support dup() for sockets */ ! if((fd = fdopen(sockd, "rb")) == NULL) { #endif logg("^Can't open descriptor for reading.\n"); return -1; *************** *** 118,123 **** --- 193,199 ---- return infected ? infected : (waserror ? -1 : 0); } + #endif /* C_WINDOWS */ static int dsfile(int sockd, const char *scantype, const char *filename, const struct optstruct *opt) { *************** *** 128,134 **** scancmd = mcalloc(strlen(filename) + 20, sizeof(char)); sprintf(scancmd, "%s %s", scantype, filename); ! if(write(sockd, scancmd, strlen(scancmd)) <= 0) { logg("^Can't write to the socket.\n"); free(scancmd); return -1; --- 204,210 ---- scancmd = mcalloc(strlen(filename) + 20, sizeof(char)); sprintf(scancmd, "%s %s", scantype, filename); ! if(send(sockd, scancmd, strlen(scancmd), 0) <= 0) { logg("^Can't write to the socket.\n"); free(scancmd); return -1; *************** *** 202,208 **** char buff[4096], *pt; ! if(write(sockd, "STREAM", 6) <= 0) { logg("^Can't write to the socket.\n"); return 2; } --- 278,284 ---- char buff[4096], *pt; ! if(send(sockd, "STREAM", 6, 0) <= 0) { logg("^Can't write to the socket.\n"); return 2; } *************** *** 312,318 **** --- 388,396 ---- static int dconnect(const struct optstruct *opt) { + #ifndef C_WINDOWS struct sockaddr_un server; + #endif struct sockaddr_in server2; struct hostent *he; struct cfgstruct *copt, *cpt; *************** *** 328,341 **** return -1; } memset((char *) &server, 0, sizeof(server)); memset((char *) &server2, 0, sizeof(server2)); /* Set default address to connect to */ server2.sin_addr.s_addr = inet_addr("127.0.0.1"); - if((cpt = cfgopt(copt, "LocalSocket"))->enabled) { server.sun_family = AF_UNIX; strncpy(server.sun_path, cpt->strarg, sizeof(server.sun_path)); --- 406,424 ---- return -1; } + #ifndef C_WINDOWS memset((char *) &server, 0, sizeof(server)); + #endif memset((char *) &server2, 0, sizeof(server2)); /* Set default address to connect to */ server2.sin_addr.s_addr = inet_addr("127.0.0.1"); + if((cpt = cfgopt(copt, "LocalSocket"))->enabled) { + #ifdef C_WINDOWS + logg("^LocalSocket is not supported under Windows"); + #else server.sun_family = AF_UNIX; strncpy(server.sun_path, cpt->strarg, sizeof(server.sun_path)); *************** *** 353,360 **** --- 436,452 ---- freecfg(copt); return -1; } + #endif } else if((cpt = cfgopt(copt, "TCPSocket"))->enabled) { + #ifdef C_WINDOWS + WSADATA wsaData; + + if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) { + logg("!Error at WSAStartup(): %d\n", WSAGetLastError()); + return -1; + } + #endif if((sockd = socket(SOCKET_INET, SOCK_STREAM, 0)) < 0) { perror("socket()"); *************** *** 368,374 **** if((cpt = cfgopt(copt, "TCPAddr"))->enabled) { if ((he = gethostbyname(cpt->strarg)) == 0) { ! close(sockd); perror("gethostbyname()"); logg("^Can't lookup clamd hostname.\n"); freecfg(copt); --- 460,466 ---- if((cpt = cfgopt(copt, "TCPAddr"))->enabled) { if ((he = gethostbyname(cpt->strarg)) == 0) { ! closesocket(sockd); perror("gethostbyname()"); logg("^Can't lookup clamd hostname.\n"); freecfg(copt); *************** *** 378,384 **** } if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) { ! close(sockd); perror("connect()"); logg("^Can't connect to clamd.\n"); freecfg(copt); --- 470,476 ---- } if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) { ! closesocket(sockd); perror("connect()"); logg("^Can't connect to clamd.\n"); freecfg(copt); *************** *** 433,439 **** else errors++; ! close(sockd); #if defined(ENABLE_FD_PASSING) && defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN) } else if(!strcmp(opt->filename, "-")) { /* scan data from stdin */ --- 525,531 ---- else errors++; ! closesocket(sockd); #if defined(ENABLE_FD_PASSING) && defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) && !defined(C_CYGWIN) } else if(!strcmp(opt->filename, "-")) { /* scan data from stdin */ *************** *** 494,500 **** else errors++; ! close(sockd); break; default: --- 586,592 ---- else errors++; ! closesocket(sockd); break; default: *************** *** 515,521 **** --- 607,615 ---- char *movedir, *movefilename, *tmp, numext[4 + 1]; struct stat fstat, mfstat; int n, len, movefilename_size; + #ifndef C_WINDOWS struct utimbuf ubuf; + #endif if(!(movedir = opt_arg(opt, "move"))) { *************** *** 600,608 **** --- 694,704 ---- chmod(movefilename, fstat.st_mode); chown(movefilename, fstat.st_uid, fstat.st_gid); + #ifndef C_WINDOWS ubuf.actime = fstat.st_atime; ubuf.modtime = fstat.st_mtime; utime(movefilename, &ubuf); + #endif if(unlink(filename)) { logg("^cannot unlink '%s': %s\n", filename, strerror(errno)); *** /home/njh/src/clamav-devel/./clamconf/clamconf.c 2006-09-15 13:38:59.000000000 +0100 --- ./clamconf/clamconf.c 2006-09-15 13:38:42.000000000 +0100 *************** *** 26,32 **** --- 26,34 ---- #include #include #include + #ifdef HAVE_UNISTD_H #include + #endif #include "cfgparser.h" #define _GNU_SOURCE *** /home/njh/src/clamav-devel/./sigtool/sigtool.c 2006-09-27 11:29:31.000000000 +0100 --- ./sigtool/sigtool.c 2006-09-13 17:48:54.000000000 +0100 *************** *** 270,276 **** int i; struct stat sb; char file[32], *md5; ! char *extlist[] = { "db", "fp", "hdb", "mdb", "ndb", "pdb", "rmd", "zmd", "sdb", NULL }; snprintf(file, sizeof(file), "%s.info", db); --- 270,276 ---- int i; struct stat sb; char file[32], *md5; ! char *extlist[] = { "db", "fp", "hdb", "ndb", "rmd", "zmd", "sdb", NULL }; snprintf(file, sizeof(file), "%s.info", db); *************** *** 345,353 **** if(stat("main.db", &foo) == -1 && stat("daily.db", &foo) == -1 && stat("main.hdb", &foo) == -1 && stat("daily.hdb", &foo) == -1 && - stat("main.mdb", &foo) == -1 && stat("daily.mdb", &foo) == -1 && stat("main.ndb", &foo) == -1 && stat("daily.ndb", &foo) == -1 && - stat("main.pdb", &foo) == -1 && stat("daily.pdb", &foo) == -1 && stat("main.sdb", &foo) == -1 && stat("daily.sdb", &foo) == -1 && stat("main.zmd", &foo) == -1 && stat("daily.zmd", &foo) == -1 && stat("main.rmd", &foo) == -1 && stat("daily.rmd", &foo) == -1) --- 345,351 ---- *************** *** 368,374 **** } else { lines = countlines("main.db") + countlines("daily.db") + countlines("main.hdb") + countlines("daily.hdb") + - countlines("main.mdb") + countlines("daily.mdb") + countlines("main.ndb") + countlines("daily.ndb") + countlines("main.sdb") + countlines("daily.sdb") + countlines("main.zmd") + countlines("daily.zmd") + --- 366,371 ---- *************** *** 484,493 **** "main.ndb", "daily.ndb", "main.sdb", "daily.sdb", "main.zmd", "daily.zmd", "main.rmd", "daily.rmd", "main.fp", ! "daily.fp", "main.mdb", "daily.mdb", ! "daily.info", "main.info", "main.wdb", ! "daily.wdb", "main.pdb", "daily.pdb", ! NULL }; args[2] = tarfile; if(!opt_check(opt, "debug")) { if((dn = open("/dev/null", O_WRONLY)) == -1) { --- 481,487 ---- "main.ndb", "daily.ndb", "main.sdb", "daily.sdb", "main.zmd", "daily.zmd", "main.rmd", "daily.rmd", "main.fp", ! "daily.fp", "daily.info", "main.info", NULL }; args[2] = tarfile; if(!opt_check(opt, "debug")) { if((dn = open("/dev/null", O_WRONLY)) == -1) { *************** *** 818,824 **** if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..") && (cli_strbcasestr(dent->d_name, ".db") || cli_strbcasestr(dent->d_name, ".hdb") || - cli_strbcasestr(dent->d_name, ".mdb") || cli_strbcasestr(dent->d_name, ".ndb") || cli_strbcasestr(dent->d_name, ".sdb") || cli_strbcasestr(dent->d_name, ".zmd") || --- 812,817 ---- *************** *** 946,952 **** mprintf("%s\n", start); } ! } else if(cli_strbcasestr(filename, ".hdb") || cli_strbcasestr(filename, ".mdb")) { /* hash database */ while(fgets(buffer, FILEBUFF, fd)) { line++; --- 939,945 ---- mprintf("%s\n", start); } ! } else if(cli_strbcasestr(filename, ".hdb")) { /* hash database */ while(fgets(buffer, FILEBUFF, fd)) { line++; *** /home/njh/src/clamav-devel/./sigtool/vba.c 2006-04-09 20:59:28.000000000 +0100 --- ./sigtool/vba.c 2006-08-04 13:32:54.000000000 +0100 *************** *** 17,30 **** --- 17,38 ---- * MA 02110-1301, USA. */ + #if HAVE_CONFIG_H + #include "clamav-config.h" + #endif + #include #include #include + #ifdef HAVE_UNISTD_H #include + #endif #include #include #include + #ifndef C_WINDOWS #include + #endif #include #include *************** *** 963,969 **** --- 971,981 ---- if ((dd = opendir (dirname)) != NULL) { while ((dent = readdir (dd))) { + #if (!defined(C_CYGWIN)) && (!defined(C_WINDOWS)) if (dent->d_ino) { + #else + { + #endif if (strcmp (dent->d_name, ".") && strcmp (dent->d_name, "..")) { /* build the full name */ fname = (char *) cli_calloc (strlen (dirname) + strlen (dent->d_name) + 2, sizeof (char)); *************** *** 1120,1126 **** --- 1132,1142 ---- if ((dd = opendir (dirname)) != NULL) { while ((dent = readdir (dd))) { + #if (!defined(C_CYGWIN)) && (!defined(C_WINDOWS)) if (dent->d_ino) { + #else + { + #endif if (strcmp (dent->d_name, ".") && strcmp (dent->d_name, "..")) { /* build the full name */ fname = calloc (strlen (dirname) + strlen (dent->d_name) + 2, sizeof (char));