add support for UNLINK command

git-svn: trunk@2342
remotes/push_mirror/metadata
Tomasz Kojm 19 years ago
parent 85820f9719
commit df64f2f71f
  1. 4
      clamav-devel/ChangeLog
  2. 38
      clamav-devel/shared/cdiff.c

@ -1,3 +1,7 @@
Sat Oct 7 17:13:40 CEST 2006 (tk)
----------------------------------
* shared/cdiff.c: add support for UNLINK command
Sat Oct 7 12:47:32 CEST 2006 (tk)
----------------------------------
* libclamav: make the experimental anti-phishing code more thread safe,

@ -63,6 +63,7 @@ static int cdiff_cmd_del(const char *cmdstr, struct cdiff_ctx *ctx);
static int cdiff_cmd_xchg(const char *cmdstr, struct cdiff_ctx *ctx);
static int cdiff_cmd_close(const char *cmdstr, struct cdiff_ctx *ctx);
static int cdiff_cmd_move(const char *cmdstr, struct cdiff_ctx *ctx);
static int cdiff_cmd_unlink(const char *cmdstr, struct cdiff_ctx *ctx);
static struct cdiff_cmd commands[] = {
/* OPEN db_name */
@ -83,6 +84,9 @@ static struct cdiff_cmd commands[] = {
/* MOVE src_db dst_db start_line first_16b end_line first_16b */
{ "MOVE", 6, &cdiff_cmd_move },
/* UNLINK db_name */
{ "UNLINK", 1, &cdiff_cmd_unlink },
{ NULL, 0, NULL }
};
@ -671,6 +675,40 @@ static int cdiff_cmd_move(const char *cmdstr, struct cdiff_ctx *ctx)
return 0;
}
static int cdiff_cmd_unlink(const char *cmdstr, struct cdiff_ctx *ctx)
{
char *db;
unsigned int i;
if(ctx->open_db) {
logg("!cdiff_cmd_unlink: Database %s is still open\n", ctx->open_db);
return -1;
}
if(!(db = cdiff_token(cmdstr, 1, 1))) {
logg("!cdiff_cmd_unlink: Can't get first argument\n");
return -1;
}
for(i = 0; i < strlen(db); i++) {
if((db[i] != '.' && !isalnum(db[i])) || strchr("/\\", db[i])) {
logg("!cdiff_cmd_unlink: Forbidden characters found in database name\n");
free(db);
return -1;
}
}
if(unlink(db) == -1) {
logg("!cdiff_cmd_unlink: Can't unlink %s\n", db);
free(db);
return -1;
}
free(db);
return 0;
}
int cdiff_apply(int fd)
{
struct cdiff_ctx ctx;

Loading…
Cancel
Save