summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-10-04 13:32:50 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-10-04 13:32:50 +0000
commit11e8b161916078d13ad2ee5bc8636ae7fe56bab4 (patch)
treec00f7c34866ef0258857e918a6d1eb0080e218b5 /src
parent6db5c5e913e996ef21c1f3746819384377622848 (diff)
downloadzabbix-11e8b161916078d13ad2ee5bc8636ae7fe56bab4.tar.gz
zabbix-11e8b161916078d13ad2ee5bc8636ae7fe56bab4.tar.xz
zabbix-11e8b161916078d13ad2ee5bc8636ae7fe56bab4.zip
- fixed crash of zabbix_sender (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@2100 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/libs/zbxcommon/base64.c2
-rw-r--r--src/libs/zbxcommon/comms.c5
-rw-r--r--src/libs/zbxdbhigh/host.c2
-rw-r--r--src/zabbix_sender/zabbix_sender.c13
-rw-r--r--src/zabbix_server/trapper/autoregister.c4
5 files changed, 14 insertions, 12 deletions
diff --git a/src/libs/zbxcommon/base64.c b/src/libs/zbxcommon/base64.c
index 5fc2381b..bc26cf8e 100644
--- a/src/libs/zbxcommon/base64.c
+++ b/src/libs/zbxcommon/base64.c
@@ -112,7 +112,7 @@ void str_base64_encode(char *p_str, char *p_b64str, int in_size)
unsigned char from1=0,from2=0,from3=0;
unsigned char to1=0,to2=0,to3=0,to4=0;
char *p_b64init = p_b64str;
-
+
if ( 0 == in_size )
{
return;
diff --git a/src/libs/zbxcommon/comms.c b/src/libs/zbxcommon/comms.c
index 837386cb..086e49ba 100644
--- a/src/libs/zbxcommon/comms.c
+++ b/src/libs/zbxcommon/comms.c
@@ -17,7 +17,10 @@ int comms_create_request(char *host, char *key, char *data, char *lastlogsize, c
str_base64_encode(host, host_b64, strlen(host));
str_base64_encode(key, key_b64, strlen(key));
str_base64_encode(data, data_b64, strlen(data));
- str_base64_encode(lastlogsize, lastlogsize_b64, strlen(lastlogsize));
+ if(lastlogsize[0]!=0)
+ {
+ str_base64_encode(lastlogsize, lastlogsize_b64, strlen(lastlogsize));
+ }
if(lastlogsize[0]==0)
{
diff --git a/src/libs/zbxdbhigh/host.c b/src/libs/zbxdbhigh/host.c
index 42cf6d07..de0ddb3b 100644
--- a/src/libs/zbxdbhigh/host.c
+++ b/src/libs/zbxdbhigh/host.c
@@ -56,7 +56,7 @@ int DBhost_exists(char *server)
char sql[MAX_STRING_LEN];
int ret = SUCCEED;
- snprintf(sql,sizeof(sql)-1,"select hostid from hosts order where host='%s'", server);
+ snprintf(sql,sizeof(sql)-1,"select hostid from hosts where host='%s'", server);
result = DBselect(sql);
if(DBnum_rows(result) == 0)
diff --git a/src/zabbix_sender/zabbix_sender.c b/src/zabbix_sender/zabbix_sender.c
index c8a26eed..b8edd269 100644
--- a/src/zabbix_sender/zabbix_sender.c
+++ b/src/zabbix_sender/zabbix_sender.c
@@ -54,14 +54,11 @@ void signal_handler( int sig )
exit( FAIL );
}
-static int send_value(char *server,int port,char *hostname, char *key,char *value)
+static int send_value(char *server,int port,char *hostname, char *key,char *value, char *lastlogsize)
{
int i,s;
char tosend[MAX_STRING_LEN];
char result[MAX_STRING_LEN];
- char hostname_b64[3*MAX_STRING_LEN];
- char key_b64[3*MAX_STRING_LEN];
- char value_b64[3*MAX_STRING_LEN];
struct hostent *hp;
struct sockaddr_in myaddr_in;
@@ -69,6 +66,8 @@ static int send_value(char *server,int port,char *hostname, char *key,char *valu
/* struct linger ling;*/
+/* printf("In send_value(%s,%d,%s,%s,%s)\n", server, port, hostname, key, value);*/
+
servaddr_in.sin_family=AF_INET;
hp=gethostbyname(server);
@@ -106,7 +105,7 @@ static int send_value(char *server,int port,char *hostname, char *key,char *valu
/* Send <req><host>SERVER_B64</host><key>KEY_B64</key><data>VALUE_B64</data></req> */
- comms_create_request(hostname, key, value, tosend,sizeof(tosend)-1);
+ comms_create_request(hostname, key, value, lastlogsize, tosend, sizeof(tosend)-1);
// snprintf(tosend,sizeof(tosend)-1,"%s:%s\n",shortname,value);
// snprintf(tosend,sizeof(tosend)-1,"<req><host>%s</host><key>%s</key><data>%s</data></req>",hostname_b64,key_b64,value_b64);
@@ -166,7 +165,7 @@ int main(int argc, char **argv)
alarm(SENDER_TIMEOUT);
- ret = send_value(argv[1],port,argv[3],argv[4],argv[5]);
+ ret = send_value(argv[1],port,argv[3],argv[4],argv[5],"0");
alarm(0);
}
@@ -187,7 +186,7 @@ int main(int argc, char **argv)
strscpy(key,s);
s=(char *)strtok(NULL," ");
strscpy(value,s);
- ret = send_value(zabbix_server,atoi(port_str),server,key,value);
+ ret = send_value(zabbix_server,atoi(port_str),server,key,value,"0");
alarm(0);
}
diff --git a/src/zabbix_server/trapper/autoregister.c b/src/zabbix_server/trapper/autoregister.c
index 989dea75..a8231138 100644
--- a/src/zabbix_server/trapper/autoregister.c
+++ b/src/zabbix_server/trapper/autoregister.c
@@ -55,13 +55,13 @@ int autoregister(char *server)
return FAIL;
}
- snprintf(sql,sizeof(sql)-1,"select id,pattern,hostid from functions order by priority");
+ snprintf(sql,sizeof(sql)-1,"select id,pattern,hostid from autoreg order by priority");
result = DBselect(sql);
for(i=0;i<DBnum_rows(result);i++)
{
- pattern=DBget_field(result,i,0);
+ pattern=DBget_field(result,i,1);
hostid=atoi(DBget_field(result,i,2));
if(zbx_regexp_match(server, pattern, &len) != 0)