More restrictive about which characters can be used in filename on DOS based systems

git-svn: trunk@432
remotes/push_mirror/metadata
Nigel Horne 22 years ago
parent 6fd6dd3774
commit 79015e8197
  1. 36
      clamav-devel/libclamav/blob.c

@ -16,6 +16,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *
* $Log: blob.c,v $ * $Log: blob.c,v $
* Revision 1.8 2004/03/23 10:58:52 nigelhorne
* More restrictive about which characters can be used in filename on DOS based systems
*
* Revision 1.7 2004/02/15 08:45:53 nigelhorne * Revision 1.7 2004/02/15 08:45:53 nigelhorne
* Avoid scanning the same file twice * Avoid scanning the same file twice
* *
@ -23,7 +26,7 @@
* Change LOG to Log * Change LOG to Log
* *
*/ */
static char const rcsid[] = "$Id: blob.c,v 1.7 2004/02/15 08:45:53 nigelhorne Exp $"; static char const rcsid[] = "$Id: blob.c,v 1.8 2004/03/23 10:58:52 nigelhorne Exp $";
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
#include "clamav-config.h" #include "clamav-config.h"
@ -33,11 +36,6 @@ static char const rcsid[] = "$Id: blob.c,v 1.7 2004/02/15 08:45:53 nigelhorne Ex
#include <string.h> #include <string.h>
#if C_DARWIN #if C_DARWIN
#include <sys/types.h> #include <sys/types.h>
#include <sys/malloc.h>
#else
#ifdef HAVE_MALLOC_H /* tk: FreeBSD-CURRENT doesn't support malloc.h */
#include <malloc.h>
#endif
#endif #endif
#include "mbox.h" #include "mbox.h"
#include "blob.h" #include "blob.h"
@ -54,7 +52,8 @@ blobCreate(void)
{ {
#ifdef CL_DEBUG #ifdef CL_DEBUG
blob *b = (blob *)cli_calloc(1, sizeof(blob)); blob *b = (blob *)cli_calloc(1, sizeof(blob));
b->magic = BLOB; if(b)
b->magic = BLOB;
cli_dbgmsg("blobCreate\n"); cli_dbgmsg("blobCreate\n");
return b; return b;
#else #else
@ -109,16 +108,15 @@ blobSetFilename(blob *b, const char *filename)
free(b->name); free(b->name);
b->name = strdup(filename); b->name = strdup(filename);
assert(b->name != NULL); if(b->name)
for(ptr = b->name; *ptr; ptr++) {
for(ptr = b->name; *ptr; ptr++) { #if defined(MSDOS) || defined(C_CYGWIN) || defined(WIN32)
#ifdef MSDOS if(strchr("*?<>|\"+=,;: ", *ptr))
if((*ptr == '/') || (*ptr == '\\'))
#else #else
if(*ptr == '/') if(*ptr == '/')
#endif #endif
*ptr = '_'; *ptr = '_';
} }
cli_dbgmsg("blobSetFilename: %s\n", filename); cli_dbgmsg("blobSetFilename: %s\n", filename);
} }
@ -159,10 +157,10 @@ blobAddData(blob *b, const unsigned char *data, size_t len)
b->data = cli_realloc(b->data, b->size); b->data = cli_realloc(b->data, b->size);
} }
assert(b->data != NULL); if(b->data) {
memcpy(&b->data[b->len], data, len);
memcpy(&b->data[b->len], data, len); b->len += len;
b->len += len; }
} }
unsigned char * unsigned char *

Loading…
Cancel
Save