[ZBX-9677] C preprocessor directives should not be used in macro arguments Created: 2015 Jul 02 Updated: 2017 May 30 Resolved: 2015 Nov 06 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Agent (G), Proxy (P), Server (S) |
Affects Version/s: | 2.5.0 |
Fix Version/s: | 2.0.16rc1, 2.2.11rc1, 2.4.7rc1, 3.0.0alpha2 |
Type: | Incident report | Priority: | Trivial |
Reporter: | Andris Mednis | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | compilation | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Description |
In file src/zabbix_server/escalator/escalator.c there is a function execute_commands() with code: result = DBselect( "select distinct h.hostid,h.host,o.type,o.scriptid,o.execute_on,o.port" ",o.authtype,o.username,o.password,o.publickey,o.privatekey,o.command" #ifdef HAVE_OPENIPMI ",h.ipmi_authtype,h.ipmi_privilege,h.ipmi_username,h.ipmi_password" #endif " from opcommand o,opcommand_grp og,hosts_groups hg,hosts h" " where o.operationid=og.operationid" " and og.groupid=hg.groupid" " and hg.hostid=h.hostid" " and o.operationid=" ZBX_FS_UI64 " and h.status=%d" " union " "select distinct h.hostid,h.host,o.type,o.scriptid,o.execute_on,o.port" ",o.authtype,o.username,o.password,o.publickey,o.privatekey,o.command" #ifdef HAVE_OPENIPMI ",h.ipmi_authtype,h.ipmi_privilege,h.ipmi_username,h.ipmi_password" #endif " from opcommand o,opcommand_hst oh,hosts h" " where o.operationid=oh.operationid" " and oh.hostid=h.hostid" " and o.operationid=" ZBX_FS_UI64 " and h.status=%d" " union " "select distinct 0,null,o.type,o.scriptid,o.execute_on,o.port" ",o.authtype,o.username,o.password,o.publickey,o.privatekey,o.command" #ifdef HAVE_OPENIPMI ",0,2,null,null" #endif " from opcommand o,opcommand_hst oh" " where o.operationid=oh.operationid" " and o.operationid=" ZBX_FS_UI64 " and oh.hostid is null", operationid, HOST_STATUS_MONITORED, operationid, HOST_STATUS_MONITORED, operationid); DBselect() is defined as macro. escalator.c: In function ‘execute_commands’: escalator.c:469:1: warning: embedding a directive within macro arguments is not portable #ifdef HAVE_OPENIPMI escalator.c:471:1: warning: embedding a directive within macro arguments is not portable #endif escalator.c:481:1: warning: embedding a directive within macro arguments is not portable #ifdef HAVE_OPENIPMI escalator.c:483:1: warning: embedding a directive within macro arguments is not portable #endif escalator.c:492:1: warning: embedding a directive within macro arguments is not portable #ifdef HAVE_OPENIPMI escalator.c:494:1: warning: embedding a directive within macro arguments is not portable #endif |
Comments |
Comment by Aleksandrs Saveljevs [ 2015 Jul 02 ] |
According to http://stackoverflow.com/questions/28343501/is-it-legal-to-use-the-line-directive-in-a-macro-argument the consequences are undefined:
|
Comment by Aleksandrs Saveljevs [ 2015 Jul 02 ] |
(1) Let's also document it in the coding guidelines at https://www.zabbix.org/wiki/C_coding_guidelines . asaveljevs Documented at https://www.zabbix.org/wiki/C_coding_guidelines#Macros . RESOLVED. sasha Great! CLOSED |
Comment by Igors Homjakovs (Inactive) [ 2015 Jul 07 ] |
Fixed in svn://svn.zabbix.com/branches/dev/ZBX-9677 |
Comment by Andris Zeila [ 2015 Jul 29 ] |
(2) The resulting sql looks correct. Just a small comment - we should use zbx_strcpy_alloc() rather than zbx_snprintf_alloc() when simply concatenating strings. igorsh RESOLVED in r54605. wiper CLOSED |
Comment by Andris Zeila [ 2015 Jul 30 ] |
Successfully tested |
Comment by Alexander Vladishev [ 2015 Aug 30 ] |
Fixed in:
|
Comment by richlv [ 2015 Sep 04 ] |
(3) typo in the changelog entry : ecalator.s <richlv> should be fixed in r55388. asaveljevs "escalator.s" is an Assembly file, not a C file. REOPENED sasha RESOLVED in r55464,r55465 asaveljevs CLOSED |
Comment by richlv [ 2015 Sep 04 ] |
subissues still open : |