X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fos_crypto%2Fmd5_sha1%2Fmd5_sha1_op.c;h=b3471f4b3f5ff16fe453a83e42d244768db92508;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hp=d38e542ad479cea36b9b455584a370132e48632f;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/os_crypto/md5_sha1/md5_sha1_op.c b/src/os_crypto/md5_sha1/md5_sha1_op.c index d38e542..b3471f4 100755 --- a/src/os_crypto/md5_sha1/md5_sha1_op.c +++ b/src/os_crypto/md5_sha1/md5_sha1_op.c @@ -1,11 +1,12 @@ -/* @(#) $Id: md5_sha1_op.c,v 1.3 2009/06/24 17:06:28 dcid Exp $ */ +/* @(#) $Id: ./src/os_crypto/md5_sha1/md5_sha1_op.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 3) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation */ @@ -16,10 +17,11 @@ #include "../md5/md5.h" #include "../sha1/sha.h" +#include "headers/defs.h" + - -int OS_MD5_SHA1_File(char * fname, char *md5output, char *sha1output) +int OS_MD5_SHA1_File(char *fname, char *prefilter_cmd, char *md5output, char *sha1output) { int n; FILE *fp; @@ -27,19 +29,30 @@ int OS_MD5_SHA1_File(char * fname, char *md5output, char *sha1output) unsigned char sha1_digest[SHA_DIGEST_LENGTH]; unsigned char md5_digest[16]; + char cmd[OS_MAXSTR]; + SHA_CTX sha1_ctx; MD5_CTX md5_ctx; - + /* Clearing the memory. */ md5output[0] = '\0'; sha1output[0] = '\0'; buf[2048 +1] = '\0'; - fp = fopen(fname,"r"); - if(!fp) - return(-1); - + /* Use prefilter_cmd if set */ + if (prefilter_cmd == NULL) { + fp = fopen(fname,"r"); + if(!fp) + return(-1); + } else { + strncpy(cmd, prefilter_cmd, sizeof(cmd) - 1); + strcat(cmd, " "); + strncat(cmd, fname, sizeof(cmd) - strlen(cmd) - 1); + fp = popen(cmd, "r"); + if(!fp) + return(-1); + } /* Initializing both hashes */ MD5Init(&md5_ctx); @@ -74,7 +87,11 @@ int OS_MD5_SHA1_File(char * fname, char *md5output, char *sha1output) /* Closing it */ - fclose(fp); + if (prefilter_cmd == NULL) { + fclose(fp); + } else { + pclose(fp); + } return(0); }