Re: [Nagios-devel] [patch] Fix compiler warnings

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] [patch] Fix compiler warnings

Post by Guest »

Hi,

Stephen Gran wrote:
> diff --git a/cgi/cmd.c b/cgi/cmd.c
> index df5fc72..2a37a08 100644
> --- a/cgi/cmd.c
> +++ b/cgi/cmd.c
> @@ -1891,6 +1891,26 @@ void commit_command_data(int cmd){
> return;
> }
>
> +static int cmd_submit(int id){
> + char cmd[MAX_EXTERNAL_COMMAND_LENGTH];
> + const char *command;
> + int len;
> +
> + command = extcmd_get_name(id);
> + /*
> + * We disallow sending 'CHANGE' commands from the cgi's
> + * until we do proper session handling to prevent cross-site
> + * request forgery
> + */
> + if (!command || (strlen(command)> 6&& !memcmp("CHANGE", command, 6)))
> + return ERROR;
> +
> + len = snprintf(cmd, sizeof(cmd) - 1, "[%lu] %s;", time(NULL), command);
> + if (len + return ERROR;
> +
> + return write_command_to_file(cmd);
> + }
>
> __attribute__((format(printf, 2, 3)))
> static int cmd_submitf(int id, const char *fmt, ...){
> @@ -1925,7 +1945,6 @@ static int cmd_submitf(int id, const char *fmt, ...){
>
> /* commits a command for processing */
> int commit_command(int cmd){
> - char command_buffer[MAX_INPUT_BUFFER];
> time_t current_time;
> time_t scheduled_time;
> time_t notification_time;
> @@ -1980,7 +1999,7 @@ int commit_command(int cmd){
> case CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS:
> case CMD_START_OBSESSING_OVER_HOST_CHECKS:
> case CMD_STOP_OBSESSING_OVER_HOST_CHECKS:
> - result = cmd_submitf(cmd,"");
> + result = cmd_submit(cmd);
> break;
>
> /** simple host commands **/
>

Instead of adding another function doing pretty much the same, but
without any variable arguments on the function call, you might have a
look at Andreas Ericsson's patch by checking fmt for NULL, and replacing
the string literal by NULL.

http://git.op5.org/git/?p=nagios.git;a= ... acbba27e3a

It's nicely resolved and keeps the upstream clean for other NULL'ed
arguments.

Kind regards,
Michael

--
DI (FH) Michael Friedrich

Vienna University Computer Center
Universitaetsstrasse 7 A-1010 Vienna, Austria

email: [email protected]
phone: +43 1 4277 14359
fax: +43 1 4277 14279
web: http://www.univie.ac.at/zid

Icinga Core& IDOUtils Developer
http://www.icinga.org






This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked