"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ip2name_exec.c" between
sarg-2.3.11.tar.gz and sarg-2.4.0.tar.gz

About: SARG ia a Squid Analysis Report Generator.

ip2name_exec.c  (sarg-2.3.11):ip2name_exec.c  (sarg-2.4.0)
/* /*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
* 1998, 2013 * 1998, 2015
* *
* SARG donations: * SARG donations:
* please look at http://sarg.sourceforge.net/donations.php * please look at http://sarg.sourceforge.net/donations.php
* Support: * Support:
* http://sourceforge.net/projects/sarg/forums/forum/363374 * http://sourceforge.net/projects/sarg/forums/forum/363374
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
skipping to change at line 61 skipping to change at line 61
\param name The name of the module as invoked by the user in the configuration \param name The name of the module as invoked by the user in the configuration
file. file.
\param param The parameters passed to the module. \param param The parameters passed to the module.
*/ */
static void ip2name_execconfig(const char *name,const char *param) static void ip2name_execconfig(const char *name,const char *param)
{ {
int len; int len;
len=strlen(param); len=strlen(param);
if (len>=sizeof(ExecCmd)) { if (len>=sizeof(ExecCmd)) {
debuga(_("Command to execute to resolve the IP addresses is too l ong (maximum is %d bytes)\n"),(int)sizeof(ExecCmd)); debuga(__FILE__,__LINE__,_("Command to execute to resolve the IP addresses is too long (maximum is %d bytes)\n"),(int)sizeof(ExecCmd));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strcpy(ExecCmd,param); strcpy(ExecCmd,param);
} }
/*! /*!
Run an external process to get the name of a computer. Run an external process to get the name of a computer.
\param ip The ip address. \param ip The ip address.
\param ip_len The number of bytes in the IP address. \param ip_len The number of bytes in the IP address.
skipping to change at line 86 skipping to change at line 86
{ {
char cmd[CMD_BUFFER_SIZE]; char cmd[CMD_BUFFER_SIZE];
int i; int i;
int j; int j;
int len; int len;
FILE *cmd_in; FILE *cmd_in;
char buffer[512]; char buffer[512];
size_t nread; size_t nread;
if (ExecCmd[0]=='\0') { if (ExecCmd[0]=='\0') {
debuga(_("No command to run to resolve an IP address. Please conf igure it in sarg.conf\n")); debuga(__FILE__,__LINE__,_("No command to run to resolve an IP ad dress. Please configure it in sarg.conf\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
j=0; j=0;
len=strlen(ip); len=strlen(ip);
for (i=0 ; i<sizeof(ExecCmd) && ExecCmd[i] ; i++) { for (i=0 ; i<sizeof(ExecCmd) && ExecCmd[i] ; i++) {
if (ExecCmd[i]=='%' && strncmp(ExecCmd+i+1,"IP",2)==0) { if (ExecCmd[i]=='%' && strncmp(ExecCmd+i+1,"IP",2)==0) {
if (j+len>=sizeof(cmd)) { if (j+len>=sizeof(cmd)) {
debuga(_("IP address \"%s\" too long for the comm and to run\n"),ip); debuga(__FILE__,__LINE__,_("IP address \"%s\" too long for the command to run\n"),ip);
return(INRC_Error); return(INRC_Error);
} }
strcpy(cmd+j,ip); strcpy(cmd+j,ip);
j+=len; j+=len;
i+=2; i+=2;
} else { } else {
if (j>=sizeof(cmd)) { if (j>=sizeof(cmd)) {
debuga(_("IP address \"%.*s\" too long for the co mmand to run\n"),ip_len,ip); debuga(__FILE__,__LINE__,_("IP address \"%s\" too long for the command to run\n"),ip);
return(INRC_Error); return(INRC_Error);
} }
cmd[j++]=ExecCmd[i]; cmd[j++]=ExecCmd[i];
} }
} }
cmd[j]='\0'; cmd[j]='\0';
cmd_in=popen(cmd,"r"); cmd_in=popen(cmd,"r");
if (!cmd_in) { if (!cmd_in) {
debuga(_("Cannot run command %s\n"),cmd); debuga(__FILE__,__LINE__,_("Cannot run command %s\n"),cmd);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
nread=fread(buffer,1,sizeof(buffer),cmd_in); nread=fread(buffer,1,sizeof(buffer),cmd_in);
if (pclose(cmd_in)==-1) { if (pclose(cmd_in)==-1) {
debuga(_("Command failed: %s\n"),cmd); debuga(__FILE__,__LINE__,_("Command failed: %s\n"),cmd);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (nread==0) return(INRC_NotFound); if (nread==0) return(INRC_NotFound);
safe_strcpy(ip,buffer,ip_len); safe_strcpy(ip,buffer,ip_len);
return(INRC_Found); return(INRC_Found);
} }
 End of changes. 7 change blocks. 
7 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)