[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ossec-dev] [Bug 62] New: [PATCH] Problems with wrong format



http://www.ossec.net/bugs/show_bug.cgi?id=62

           Summary: [PATCH] Problems with wrong format
           Product: OSSEC
           Version: UI-0.3
          Platform: PC
               URL: http://www.ossec.net/main/ossec-v13-released#comment-2
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: ossec core
        AssignedTo: ossec-dev@xxxxxxxxx
        ReportedBy: php-coder@xxxxxxxxxxxx


Hello!

Normally ossec compiles without any warnings, but if we turn on one of special
GCC feature which helps to us find problems with wrong format, then GCC
complains about some code.

1) Enable format checks:

[c0der@rock ~]$ gendiff ossec-hids-1.3 .orig
--- ossec-hids-1.3/src/headers/debug_op.h.orig  2007-08-29 19:27:05 +0700
+++ ossec-hids-1.3/src/headers/debug_op.h       2007-08-29 19:40:31 +0700
@@ -26,19 +26,23 @@

 #define __DEBUG_H

-void debug1(const char *msg,...);
+#ifndef __GNUC__
+#define __attribute__(x)
+#endif
+
+void debug1(const char *msg,...) __attribute__((format(printf, 1, 2)));

-void debug2(const char *msg,...);
+void debug2(const char *msg,...) __attribute__((format(printf, 1, 2)));

-void merror(const char *msg,...);
+void merror(const char *msg,...) __attribute__((format(printf, 1, 2)));

-void verbose(const char *msg,...);
+void verbose(const char *msg,...) __attribute__((format(printf, 1, 2)));

-void print_out(const char *msg,...);
+void print_out(const char *msg,...) __attribute__((format(printf, 1, 2)));

-void log2file(const char * msg,... );
+void log2file(const char *msg,... ) __attribute__((format(printf, 1, 2)));

-void ErrorExit(const char *msg,...);
+void ErrorExit(const char *msg,...) __attribute__((format(printf, 1, 2)));


 /* Use these three functions to set when you

2) Try to build project (I remove all blank lines from output):

[c0der@rock ~/ossec-hids-1.3/src]$ LANG=C make -s all
 *** Making zlib (by Jean-loup Gailly and Mark Adler)  *** 
 *** Making os_xml *** 
 *** Making os_regex *** 
 *** Making os_net *** 
 *** Making os_crypto *** 
sec.c: In function 'ReadSecMSG':
sec.c:595: warning: format '%s' expects type 'char *', but argument 3 has type
'struct os_ip *'
sec.c:626: warning: format '%s' expects type 'char *', but argument 3 has type
'struct os_ip *'
sec.c:700: warning: format '%s' expects type 'char *', but argument 3 has type
'struct os_ip *'
sec.c:741: warning: format '%d' expects type 'int', but argument 4 has type
'time_t'
 *** Making shared *** 
help.c: In function 'help':
help.c:29: warning: zero-length printf format string
help.c:34: warning: zero-length printf format string
help.c:45: warning: zero-length printf format string
help.c: In function 'print_version':
help.c:51: warning: zero-length printf format string
help.c:53: warning: zero-length printf format string
 *** Making config *** 
active-response.c: In function 'ReadActiveResponses':
active-response.c:191: warning: too few arguments for format
 *** Making os_maild *** 
../config/active-response.c: In function 'ReadActiveResponses':
../config/active-response.c:191: warning: too few arguments for format
 *** Making os_execd *** 
 *** Making analysisd *** 
pf_decoder.c: In function 'PF_Decoder_Init':
pf_decoder.c:23: warning: too few arguments for format
symantecws_decoder.c: In function 'SymantecWS_Decoder_Init':
symantecws_decoder.c:22: warning: too few arguments for format
decode-xml.c: In function 'ReadDecodeXML':
decode-xml.c:790: warning: format '%d' expects type 'int', but argument 4 has
type 'char *'
rules.c: In function 'Rules_OP_ReadRules':
rules.c:246: warning: format '%s' expects type 'char *', but argument 2 has
type 'int'
rules.c:246: warning: too few arguments for format
rules.c:890: warning: format '%s' expects type 'char *', but argument 2 has
type 'int'
rules.c:890: warning: too few arguments for format
rules.c: In function 'printRuleinfo':
rules.c:1704: warning: too many arguments for format
../config/active-response.c: In function 'ReadActiveResponses':
../config/active-response.c:191: warning: too few arguments for format
 *** Making logcollector *** 
../config/active-response.c: In function 'ReadActiveResponses':
../config/active-response.c:191: warning: too few arguments for format
 *** Making remoted *** 
main.c: In function 'main':
main.c:84: warning: too few arguments for format
manager.c: In function 'read_controlmsg':
manager.c:363: warning: format '%s' expects type 'char *', but argument 3 has
type 'struct os_ip *'
manager.c:410: warning: format '%s' expects type 'char *', but argument 3 has
type 'struct os_ip *'
manager.c:422: warning: format '%s' expects type 'char *', but argument 3 has
type 'struct os_ip *'
secure.c: In function 'HandleSecure':
secure.c:67: warning: too many arguments for format
secure.c:189: warning: too few arguments for format
../config/active-response.c: In function 'ReadActiveResponses':
../config/active-response.c:191: warning: too few arguments for format
 *** Making client-agent *** 
notify.c: In function 'getsharedfiles':
notify.c:55: warning: too few arguments for format
../config/active-response.c: In function 'ReadActiveResponses':
../config/active-response.c:191: warning: too few arguments for format
 *** Making addagent *** 
main.c: In function 'main':
main.c:78: warning: too few arguments for format
manage_keys.c: In function 'k_extract':
manage_keys.c:158: warning: too few arguments for format
 *** Making util *** 
../addagent/manage_keys.c: In function 'k_extract':
../addagent/manage_keys.c:158: warning: too few arguments for format
syscheck_update.c: In function 'main':
syscheck_update.c:59: warning: too few arguments for format
clear_stats.c: In function 'main':
clear_stats.c:62: warning: too few arguments for format
list_agents.c: In function 'main':
list_agents.c:61: warning: too few arguments for format
 *** Making rootcheck *** 
common_rcl.c: In function 'rkcl_get_entry':
common_rcl.c:333: warning: too few arguments for format
common_rcl.c:534: warning: too few arguments for format
 *** Making syscheckd *** 
run_check.c: In function 'start_daemon':
run_check.c:209: warning: too few arguments for format
../config/active-response.c: In function 'ReadActiveResponses':
../config/active-response.c:191: warning: too few arguments for format
 *** Making monitord *** 
[c0der@rock ~/ossec-hids-1.3/src]$

These warnings cause to segfault in some cases (for example, see to URL where
user evilghost notify about crashing because exist error with wrong format).

Yesterday I made the patch which fixes most of these warnings (except in help.c
file). Patch will be attached.

Please test my patch and apply if needed.


-- 
Configure bugmail: http://www.ossec.net/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


OSSEC home | Main Index | Thread Index


OSSEC project: www.ossec.net.
Mailling list information: http://www.ossec.net/en/mailing_lists.html.