PDA

View Full Version : zabbix_trapperd not handling key values correctly for W32 Keys


darveesh
17-06-2005, 18:32
in the process() function in zabbix_trapperd.c the server:key:value string is extracted by calling strtok repeatedly by using the : character as the delimiter.

However, i think, this causes a bug when the receiving Windows keys since the keys often have the char : in the them. Example:

host1:diskfree[c:]:83536330752.000000

or

host1:cksum[c:\\autoexec.bat]:4294967295.000000


I am running 1.0. Can i get a patch for this?

Thanks.

darveesh
21-06-2005, 00:45
Here is what I did and seems to be working now...


int process(int sockfd,char *s)
{
char *p,*k;
char *server,*key,*value_string;

int ret=SUCCEED;

for( p=s+strlen(s)-1; p>s && ( *p=='\r' || *p =='\n' || *p == ' ' ); --\
p );
p[1]=0;

/* Change */
p=strchr(s, ':');
if (p == NULL)
{
return FAIL;
}
p[0]=0;
server=s;

k=strchr(p+1, ']');
if (k == NULL)
{
// Process normally - nothing special about the key
key=(char *)strtok(p+1,":");
if(NULL == key)
{
return FAIL;
}

value_string=(char *)strtok(NULL,":");
if(NULL == value_string)
{
return FAIL;
}
}
else
{
k[1]=0;
key=p+1;
value_string = k + (2 * sizeof(char));
}
/* End Change */
ret=process_data(sockfd,server,key,value_string);

return ret;
}