projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- add fortify to lintian
[ossec-hids.git]
/
src
/
analysisd
/
decoders
/
hostinfo.c
diff --git
a/src/analysisd/decoders/hostinfo.c
b/src/analysisd/decoders/hostinfo.c
index
dccee36
..
fa7c414
100755
(executable)
--- a/
src/analysisd/decoders/hostinfo.c
+++ b/
src/analysisd/decoders/hostinfo.c
@@
-1,11
+1,12
@@
-/* @(#) $Id: hostinfo.c,v 1.14 2009/06/24 17:06:23 dcid Exp $ */
+/* @(#) $Id: ./src/analysisd/decoders/hostinfo.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
/* 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
*/
* Foundation
*/
@@
-94,7
+95,7
@@
void HostinfoInit()
/* Opening HOSTINFO_FILE */
snprintf(_hi_buf,OS_SIZE_1024, "%s", HOSTINFO_FILE);
/* Opening HOSTINFO_FILE */
snprintf(_hi_buf,OS_SIZE_1024, "%s", HOSTINFO_FILE);
-
+
/* r+ to read and write. Do not truncate */
_hi_fp = fopen(_hi_buf,"r+");
/* r+ to read and write. Do not truncate */
_hi_fp = fopen(_hi_buf,"r+");
@@
-114,7
+115,7
@@
void HostinfoInit()
return;
}
return;
}
-
+
/* clearing the buffer */
memset(_hi_buf, '\0', OS_MAXSTR +1);
/* clearing the buffer */
memset(_hi_buf, '\0', OS_MAXSTR +1);
@@
-147,7
+148,7
@@
int DecodeHostinfo(Eventinfo *lf)
{
int changed = 0;
int bf_size;
{
int changed = 0;
int bf_size;
-
+
char *ip;
char *portss;
char *tmpstr;
char *ip;
char *portss;
char *tmpstr;
@@
-156,7
+157,7
@@
int DecodeHostinfo(Eventinfo *lf)
char opened[OS_MAXSTR + 1];
FILE *fp;
char opened[OS_MAXSTR + 1];
FILE *fp;
-
+
/* Checking maximum number of errors */
if(hi_err > 30)
{
/* Checking maximum number of errors */
if(hi_err > 30)
{
@@
-164,7
+165,7
@@
int DecodeHostinfo(Eventinfo *lf)
"Ignoring it.", ARGV0);
return(0);
}
"Ignoring it.", ARGV0);
return(0);
}
-
+
/* Zeroing buffers */
buffer[OS_MAXSTR] = '\0';
/* Zeroing buffers */
buffer[OS_MAXSTR] = '\0';
@@
-181,8
+182,8
@@
int DecodeHostinfo(Eventinfo *lf)
/* Copying log to buffer */
strncpy(buffer,lf->log, OS_MAXSTR);
/* Copying log to buffer */
strncpy(buffer,lf->log, OS_MAXSTR);
-
-
+
+
/* Getting ip */
tmpstr = __go_after(buffer, HOST_HOST);
if(!tmpstr)
/* Getting ip */
tmpstr = __go_after(buffer, HOST_HOST);
if(!tmpstr)
@@
-193,7
+194,7
@@
int DecodeHostinfo(Eventinfo *lf)
return(0);
}
return(0);
}
-
+
/* Setting ip */
ip = tmpstr;
tmpstr = strchr(tmpstr, ',');
/* Setting ip */
ip = tmpstr;
tmpstr = strchr(tmpstr, ',');
@@
-216,8
+217,8
@@
int DecodeHostinfo(Eventinfo *lf)
*tmpstr = '\0';
}
bf_size = strlen(ip);
*tmpstr = '\0';
}
bf_size = strlen(ip);
-
-
+
+
/* Reads the file and search for a possible
* entry
*/
/* Reads the file and search for a possible
* entry
*/
@@
-232,13
+233,13
@@
int DecodeHostinfo(Eventinfo *lf)
/* Removing new line */
tmpstr = strchr(_hi_buf, '\n');
if(tmpstr)
/* Removing new line */
tmpstr = strchr(_hi_buf, '\n');
if(tmpstr)
- *tmpstr = '\0';
+ *tmpstr = '\0';
/* Checking for ip */
if(strncmp(ip, _hi_buf, bf_size) == 0)
{
/* Checking for ip */
if(strncmp(ip, _hi_buf, bf_size) == 0)
{
- /* Cannot use strncmp to avoid errors with crafted files */
+ /* Cannot use strncmp to avoid errors with crafted files */
if(strcmp(portss, _hi_buf + bf_size) == 0)
{
return(0);
if(strcmp(portss, _hi_buf + bf_size) == 0)
{
return(0);
@@
-252,9
+253,9
@@
int DecodeHostinfo(Eventinfo *lf)
changed = 1;
}
}
changed = 1;
}
}
- }
+ }
+
-
/* Adding the new entry at the end of the file */
fseek(fp, 0, SEEK_END);
fprintf(fp,"%s%s\n", ip, portss);
/* Adding the new entry at the end of the file */
fseek(fp, 0, SEEK_END);
fprintf(fp,"%s%s\n", ip, portss);
@@
-263,7
+264,7
@@
int DecodeHostinfo(Eventinfo *lf)
/* Setting decoder */
lf->decoder_info = hostinfo_dec;
/* Setting decoder */
lf->decoder_info = hostinfo_dec;
-
+
/* Setting comment */
if(changed == 1)
{
/* Setting comment */
if(changed == 1)
{
@@
-274,7
+275,7
@@
int DecodeHostinfo(Eventinfo *lf)
{
hostinfo_dec->id = id_new;
}
{
hostinfo_dec->id = id_new;
}
-
+
return(1);
}
return(1);
}