Commit fabb8ff6 authored by Natanael Copa's avatar Natanael Copa

main/zabbix: security fix (CVE-2013-5743)

https://support.zabbix.com/browse/ZBX-7091
ref #2271
parent e7849caa
......@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=zabbix
pkgver=2.0.8
pkgrel=2
pkgrel=3
pkgdesc="Enterprise-class open source distributed monitoring"
url="http://www.zabbix.com"
arch="all"
......@@ -27,6 +27,7 @@ source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
zabbix-server.initd
zabbix-agentd.initd
zabbix-proxy.initd
ZBX-7091-2.0.8.patch
"
_builddir="$srcdir"/$pkgname-$pkgver
......@@ -50,7 +51,7 @@ build() {
# set default configure flags
_configure="--prefix=/usr \
--sysconfdir=/etc/zabbix \
--mandir=/usr/share/man \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--enable-server \
--enable-agent \
......@@ -175,7 +176,8 @@ b80eca2e260cc9e563f4b7a1b30bb158 res_send.patch
5f7b1815a309d8dade4a1d15d5048742 automake.patch
d823c2ab6c2bbdd0ebd3511fac4a83b4 zabbix-server.initd
1a5c718bcf815fcf659e14fb0b576a1a zabbix-agentd.initd
a99978139481e69434f78fc3e8c53441 zabbix-proxy.initd"
a99978139481e69434f78fc3e8c53441 zabbix-proxy.initd
69f7a0d3b7747bcad5f4928a0e9c4786 ZBX-7091-2.0.8.patch"
sha256sums="c4b94960de0a1d0b20604a08503e9715c15845409368162c1e321040b8e4519a zabbix-2.0.8.tar.gz
3b09a8fdc38216d859022c5966c36f0bcb6984974208cf4c69c17129649efdf5 zabbix_server.conf
3ae307895c9a7189e29c4ebf7479ce08d4c3bbe1a7f0a3554828170dac417bab zabbix_trapper.conf
......@@ -186,7 +188,8 @@ sha256sums="c4b94960de0a1d0b20604a08503e9715c15845409368162c1e321040b8e4519a za
4cd7ab9c6fa95aacab0c1f7b77bad18e9b500feca70b16c866a581775b4ad611 automake.patch
f4e18cca40cd7299140aec3077cf39429487860094d7f5d88d76d8e040dca9b8 zabbix-server.initd
4f93c4868726a3e8fed12a030cfce8911f105217a59187d6b3e1565d8d3e76b5 zabbix-agentd.initd
60a01c08df054a0c1bcfb71e378544b4c4e489e6a6779d96383387ed34ddc0b0 zabbix-proxy.initd"
60a01c08df054a0c1bcfb71e378544b4c4e489e6a6779d96383387ed34ddc0b0 zabbix-proxy.initd
ae8f91f846f8a84d926c0bfe81ad6c4f8203a28efeb0b040b6fef32cfc0022fa ZBX-7091-2.0.8.patch"
sha512sums="5a65c7fcce33d98a0f441798ca83f16bb6ed31b8a1b025f39c4003a0906c148ed5ff9db41aec591f053083b6bacd3ea1a1c8b96c007c44da092bfa179693e403 zabbix-2.0.8.tar.gz
3170d56a61871e6efadf705c19f864fdecf9420c4263f2a1129245b3b55bd730d1ba5a6a26ea866fc7842c86f7745e51ea28878bb9e9267ed9176499cb75e8bb zabbix_server.conf
cd08d907838de646f65316950e8c71deae25be1701e0cc22e5fd2f636c21ef2365a537d247277bafb694cae8c5dbd22eb725c1647797ad3e4ac4b3df2084ef07 zabbix_trapper.conf
......@@ -197,4 +200,5 @@ a2d8d52bacd353363c22f89ca26deffdec722144dab4899987ef4b8479d0b0722007bf3e97f75403
7aa59336e92d83eddff4bc18038820cfc25dc50f45327a2c0a6aa0e360fa742c9724d25e84152e3a14193c88ea5d6e66fdb99f2900c0bf8199cb2adf9e143415 automake.patch
af0853d8c5a8b33399b87e7958a7ffd692fe18005dcc43af5f58e0fdf6bbee3dd66ec77a3840ae5e526a4c445b04425071f6796d726ff923aba9d3a78ca3c022 zabbix-server.initd
3ef0fe0c1c94f2f01a0c335a45ee0f3c0cd4b125d96b5eefa869a17efb352087a5dd18ef8e87c35e6816b6fb705b829f0a25452e7285637d3595ff4c103b7c21 zabbix-agentd.initd
b305ea06641c6a331273f065a4a85fac92c45e107a30e85cb41be4ea36e2efbf5442c69cc6605ea3734a851808f7abba20042058d4b07832d858cdb63e98d405 zabbix-proxy.initd"
b305ea06641c6a331273f065a4a85fac92c45e107a30e85cb41be4ea36e2efbf5442c69cc6605ea3734a851808f7abba20042058d4b07832d858cdb63e98d405 zabbix-proxy.initd
cd960187bf234b14fd612ff3b4357ce5b1b094a9498e58a735309136b04a7f5076a8ff251edf47ede7d663d3d0fbd1e36c9c99e647dab598f4bedc634e17e24a ZBX-7091-2.0.8.patch"
Index: frontends/php/api/classes/CGraphItem.php
===================================================================
--- ./frontends/php/api/classes/CGraphItem.php (revision 38884)
+++ ./frontends/php/api/classes/CGraphItem.php (working copy)
@@ -119,7 +119,7 @@
// type
if (!is_null($options['type'] )) {
- $sqlParts['where'][] = 'gi.type='.$options['type'];
+ $sqlParts['where'][] = 'gi.type='.zbx_dbstr($options['type']);
}
// output
@@ -254,8 +254,8 @@
$dbRes = DBselect(
'SELECT gi.gitemid'.
' FROM graphs_items gi'.
- ' WHERE gi.itemid='.$gitemData['itemid'].
- ' AND gi.graphid='.$gitemData['graphid']
+ ' WHERE gi.itemid='.zbx_dbstr($gitemData['itemid']).
+ ' AND gi.graphid='.zbx_dbstr($gitemData['graphid'])
);
while ($gitem = DBfetch($dbRes)) {
$gitemids[$gitem['gitemid']] = $gitem['gitemid'];
Index: frontends/php/api/classes/CEvent.php
===================================================================
--- ./frontends/php/api/classes/CEvent.php (revision 38884)
+++ ./frontends/php/api/classes/CEvent.php (working copy)
@@ -232,12 +232,12 @@
// object
if (!is_null($options['object'])) {
- $sqlParts['where']['o'] = 'e.object='.$options['object'];
+ $sqlParts['where']['o'] = 'e.object='.zbx_dbstr($options['object']);
}
// source
if (!is_null($options['source'])) {
- $sqlParts['where'][] = 'e.source='.$options['source'];
+ $sqlParts['where'][] = 'e.source='.zbx_dbstr($options['source']);
}
// acknowledged
@@ -255,22 +255,22 @@
// time_from
if (!is_null($options['time_from'])) {
- $sqlParts['where'][] = 'e.clock>='.$options['time_from'];
+ $sqlParts['where'][] = 'e.clock>='.zbx_dbstr($options['time_from']);
}
// time_till
if (!is_null($options['time_till'])) {
- $sqlParts['where'][] = 'e.clock<='.$options['time_till'];
+ $sqlParts['where'][] = 'e.clock<='.zbx_dbstr($options['time_till']);
}
// eventid_from
if (!is_null($options['eventid_from'])) {
- $sqlParts['where'][] = 'e.eventid>='.$options['eventid_from'];
+ $sqlParts['where'][] = 'e.eventid>='.zbx_dbstr($options['eventid_from']);
}
// eventid_till
if (!is_null($options['eventid_till'])) {
- $sqlParts['where'][] = 'e.eventid<='.$options['eventid_till'];
+ $sqlParts['where'][] = 'e.eventid<='.zbx_dbstr($options['eventid_till']);
}
// value
Index: frontends/php/api/classes/CGraphPrototype.php
===================================================================
--- ./frontends/php/api/classes/CGraphPrototype.php (revision 38884)
+++ ./frontends/php/api/classes/CGraphPrototype.php (working copy)
@@ -227,7 +227,7 @@
// type
if (!is_null($options['type'] )) {
- $sqlParts['where'][] = 'g.type='.$options['type'];
+ $sqlParts['where'][] = 'g.type='.zbx_dbstr($options['type']);
}
// templated
Index: frontends/php/api/classes/CItemGeneral.php
===================================================================
--- ./frontends/php/api/classes/CItemGeneral.php (revision 38884)
+++ ./frontends/php/api/classes/CItemGeneral.php (working copy)
@@ -707,7 +707,7 @@
$sqlWhere = array();
foreach ($itemKeysByHostId as $hostId => $keys) {
- $sqlWhere[] = '(i.hostid='.$hostId.' AND '.dbConditionString('i.key_', $keys).')';
+ $sqlWhere[] = '(i.hostid='.zbx_dbstr($hostId).' AND '.dbConditionString('i.key_', $keys).')';
}
if ($sqlWhere) {
Index: frontends/php/api/classes/CHistory.php
===================================================================
--- ./frontends/php/api/classes/CHistory.php (revision 38884)
+++ ./frontends/php/api/classes/CHistory.php (working copy)
@@ -169,13 +169,13 @@
// time_from
if (!is_null($options['time_from'])) {
$sqlParts['select']['clock'] = 'h.clock';
- $sqlParts['where']['clock_from'] = 'h.clock>='.$options['time_from'];
+ $sqlParts['where']['clock_from'] = 'h.clock>='.zbx_dbstr($options['time_from']);
}
// time_till
if (!is_null($options['time_till'])) {
$sqlParts['select']['clock'] = 'h.clock';
- $sqlParts['where']['clock_till'] = 'h.clock<='.$options['time_till'];
+ $sqlParts['where']['clock_till'] = 'h.clock<='.zbx_dbstr($options['time_till']);
}
// filter
Index: frontends/php/api/classes/CTrigger.php
===================================================================
--- ./frontends/php/api/classes/CTrigger.php (revision 38884)
+++ ./frontends/php/api/classes/CTrigger.php (working copy)
@@ -321,12 +321,12 @@
// lastChangeSince
if (!is_null($options['lastChangeSince'])) {
- $sqlParts['where']['lastchangesince'] = 't.lastchange>'.$options['lastChangeSince'];
+ $sqlParts['where']['lastchangesince'] = 't.lastchange>'.zbx_dbstr($options['lastChangeSince']);
}
// lastChangeTill
if (!is_null($options['lastChangeTill'])) {
- $sqlParts['where']['lastchangetill'] = 't.lastchange<'.$options['lastChangeTill'];
+ $sqlParts['where']['lastchangetill'] = 't.lastchange<'.zbx_dbstr($options['lastChangeTill']);
}
// withUnacknowledgedEvents
@@ -466,7 +466,7 @@
// min_severity
if (!is_null($options['min_severity'])) {
- $sqlParts['where'][] = 't.priority>='.$options['min_severity'];
+ $sqlParts['where'][] = 't.priority>='.zbx_dbstr($options['min_severity']);
}
// output
Index: frontends/php/api/classes/CScript.php
===================================================================
--- ./frontends/php/api/classes/CScript.php (revision 38884)
+++ ./frontends/php/api/classes/CScript.php (working copy)
@@ -114,7 +114,7 @@
$sqlParts['from']['hosts_groups'] = 'hosts_groups hg';
$sqlParts['where'][] = 'hg.groupid=r.id';
$sqlParts['where'][] = 'r.groupid=ug.usrgrpid';
- $sqlParts['where'][] = 'ug.userid='.$userid;
+ $sqlParts['where'][] = 'ug.userid='.zbx_dbstr($userid);
$sqlParts['where'][] = '(hg.groupid=s.groupid OR s.groupid IS NULL)';
$sqlParts['where'][] = '(ug.usrgrpid=s.usrgrpid OR s.usrgrpid IS NULL)';
}
@@ -265,7 +265,7 @@
'SELECT s.scriptid'.
' FROM scripts s'.
' WHERE '.DBin_node('s.scriptid').
- ' AND s.name='.$script['name']
+ ' AND s.name='.zbx_dbstr($script['name'])
);
while ($script = DBfetch($dbScripts)) {
$scriptids[$script['scriptid']] = $script['scriptid'];
Index: frontends/php/api/classes/CTemplate.php
===================================================================
--- ./frontends/php/api/classes/CTemplate.php (revision 38884)
+++ ./frontends/php/api/classes/CTemplate.php (working copy)
@@ -1021,7 +1021,7 @@
foreach ($template['groups'] as $group) {
$hostgroupid = get_dbid('hosts_groups', 'hostgroupid');
- $result = DBexecute("INSERT INTO hosts_groups (hostgroupid, hostid, groupid) VALUES ($hostgroupid, $templateid, {$group['groupid']})");
+ $result = DBexecute('INSERT INTO hosts_groups (hostgroupid,hostid,groupid) VALUES ('.zbx_dbstr($hostgroupid).','.zbx_dbstr($templateid).','.zbx_dbstr($group['groupid']).')');
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
}
Index: frontends/php/api/classes/CHostGeneral.php
===================================================================
--- ./frontends/php/api/classes/CHostGeneral.php (revision 38884)
+++ ./frontends/php/api/classes/CHostGeneral.php (working copy)
@@ -261,7 +261,7 @@
continue;
}
- $values = array(get_dbid('hosts_templates', 'hosttemplateid'), $targetid, $templateid);
+ $values = array(get_dbid('hosts_templates', 'hosttemplateid'), zbx_dbstr($targetid), zbx_dbstr($templateid));
$sql = 'INSERT INTO hosts_templates VALUES ('.implode(', ', $values).')';
$result = DBexecute($sql);
Index: frontends/php/api/classes/CUser.php
===================================================================
--- ./frontends/php/api/classes/CUser.php (revision 38884)
+++ ./frontends/php/api/classes/CUser.php (working copy)
@@ -507,7 +507,8 @@
$usrgrps = zbx_objectValues($user['usrgrps'], 'usrgrpid');
foreach ($usrgrps as $groupid) {
$usersGroupdId = get_dbid('users_groups', 'id');
- $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.$usersGroupdId.','.$groupid.','.$userid.')';
+ $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.zbx_dbstr($usersGroupdId).','.zbx_dbstr($groupid).','.zbx_dbstr($userid).')';
+
if (!DBexecute($sql)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
}
@@ -516,8 +517,8 @@
foreach ($user['user_medias'] as $mediaData) {
$mediaid = get_dbid('media', 'mediaid');
$sql = 'INSERT INTO media (mediaid,userid,mediatypeid,sendto,active,severity,period)'.
- ' VALUES ('.$mediaid.','.$userid.','.$mediaData['mediatypeid'].','.
- zbx_dbstr($mediaData['sendto']).','.$mediaData['active'].','.$mediaData['severity'].','.
+ ' VALUES ('.zbx_dbstr($mediaid).','.zbx_dbstr($userid).','.zbx_dbstr($mediaData['mediatypeid']).','.
+ zbx_dbstr($mediaData['sendto']).','.zbx_dbstr($mediaData['active']).','.zbx_dbstr($mediaData['severity']).','.
zbx_dbstr($mediaData['period']).')';
if (!DBexecute($sql)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
@@ -577,10 +578,10 @@
$newUsrgrpids = zbx_objectValues($user['usrgrps'], 'usrgrpid');
// deleting all relations with groups, but not touching those, where user still must be after update
- DBexecute('DELETE FROM users_groups WHERE userid='.$user['userid'].' AND '.dbConditionInt('usrgrpid', $newUsrgrpids, true));
+ DBexecute('DELETE FROM users_groups WHERE userid='.zbx_dbstr($user['userid']).' AND '.dbConditionInt('usrgrpid', $newUsrgrpids, true));
// getting the list of groups user is currently in
- $dbGroupsUserIn = DBSelect('SELECT usrgrpid FROM users_groups WHERE userid='.$user['userid']);
+ $dbGroupsUserIn = DBSelect('SELECT usrgrpid FROM users_groups WHERE userid='.zbx_dbstr($user['userid']));
$groupsUserIn = array();
while ($grp = DBfetch($dbGroupsUserIn)) {
$groupsUserIn[$grp['usrgrpid']] = $grp['usrgrpid'];
@@ -598,7 +599,7 @@
}
$usersGroupdId = get_dbid('users_groups', 'id');
- $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.$usersGroupdId.','.$groupid.','.$user['userid'].')';
+ $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.zbx_dbstr($usersGroupdId).','.zbx_dbstr($groupid).','.zbx_dbstr($user['userid']).')';
if (!DBexecute($sql)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
@@ -696,8 +697,8 @@
$mediaid = get_dbid('media', 'mediaid');
$sql = 'INSERT INTO media (mediaid,userid,mediatypeid,sendto,active,severity,period)'.
- ' VALUES ('.$mediaid.','.$user['userid'].','.$media['mediatypeid'].','.
- zbx_dbstr($media['sendto']).','.$media['active'].','.$media['severity'].','.
+ ' VALUES ('.zbx_dbstr($mediaid).','.zbx_dbstr($user['userid']).','.zbx_dbstr($media['mediatypeid']).','.
+ zbx_dbstr($media['sendto']).','.zbx_dbstr($media['active']).','.zbx_dbstr($media['severity']).','.
zbx_dbstr($media['period']).')';
if (!DBexecute($sql)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
@@ -796,12 +797,12 @@
$result = DBexecute(
'UPDATE media'.
- ' SET mediatypeid='.$media['mediatypeid'].','.
+ ' SET mediatypeid='.zbx_dbstr($media['mediatypeid']).','.
' sendto='.zbx_dbstr($media['sendto']).','.
- ' active='.$media['active'].','.
- ' severity='.$media['severity'].','.
+ ' active='.zbx_dbstr($media['active']).','.
+ ' severity='.zbx_dbstr($media['severity']).','.
' period='.zbx_dbstr($media['period']).
- ' WHERE mediaid='.$media['mediaid']
+ ' WHERE mediaid='.zbx_dbstr($media['mediaid'])
);
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot update user media.'));
@@ -927,7 +928,7 @@
$dbAccess = DBfetch(DBselect(
'SELECT MAX(g.gui_access) AS gui_access'.
' FROM usrgrp g,users_groups ug'.
- ' WHERE ug.userid='.$userInfo['userid'].
+ ' WHERE ug.userid='.zbx_dbstr($userInfo['userid']).
' AND g.usrgrpid=ug.usrgrpid'
));
if (!zbx_empty($dbAccess['gui_access'])) {
@@ -968,7 +969,7 @@
DBexecute(
'UPDATE users'.
- ' SET attempt_failed='.$userInfo['attempt_failed'].','.
+ ' SET attempt_failed='.zbx_dbstr($userInfo['attempt_failed']).','.
' attempt_clock='.time().','.
' attempt_ip='.zbx_dbstr($ip).
' WHERE userid='.$userInfo['userid']
@@ -980,7 +981,7 @@
// start session
$sessionid = md5(time().$password.$name.rand(0, 10000000));
- DBexecute('INSERT INTO sessions (sessionid,userid,lastaccess,status) VALUES ('.zbx_dbstr($sessionid).','.$userInfo['userid'].','.time().','.ZBX_SESSION_ACTIVE.')');
+ DBexecute('INSERT INTO sessions (sessionid,userid,lastaccess,status) VALUES ('.zbx_dbstr($sessionid).','.zbx_dbstr($userInfo['userid']).','.time().','.ZBX_SESSION_ACTIVE.')');
add_audit(AUDIT_ACTION_LOGIN, AUDIT_RESOURCE_USER, _s('Correct login "%s".', $name));
@@ -990,7 +991,7 @@
$userData['userid'] = $userInfo['userid'];
if ($userInfo['attempt_failed']) {
- DBexecute('UPDATE users SET attempt_failed=0 WHERE userid='.$userInfo['userid']);
+ DBexecute('UPDATE users SET attempt_failed=0 WHERE userid='.zbx_dbstr($userInfo['userid']));
}
CWebUser::$data = self::$userData = $userData;
@@ -1035,16 +1036,16 @@
}
if ($userInfo['autologout'] > 0) {
- DBexecute('DELETE FROM sessions WHERE userid='.$userInfo['userid'].' AND lastaccess<'.(time() - $userInfo['autologout']));
+ DBexecute('DELETE FROM sessions WHERE userid='.zbx_dbstr($userInfo['userid']).' AND lastaccess<'.(time() - $userInfo['autologout']));
}
- DBexecute('UPDATE sessions SET lastaccess='.time().' WHERE userid='.$userInfo['userid'].' AND sessionid='.zbx_dbstr($sessionid));
+ DBexecute('UPDATE sessions SET lastaccess='.time().' WHERE userid='.zbx_dbstr($userInfo['userid']).' AND sessionid='.zbx_dbstr($sessionid));
}
$dbAccess = DBfetch(DBselect(
'SELECT MAX(g.gui_access) AS gui_access'.
' FROM usrgrp g,users_groups ug'.
- ' WHERE ug.userid='.$userInfo['userid'].
+ ' WHERE ug.userid='.zbx_dbstr($userInfo['userid']).
' AND g.usrgrpid=ug.usrgrpid'
));
if (!zbx_empty($dbAccess['gui_access'])) {
@@ -1070,13 +1071,13 @@
'SELECT u.userid,u.alias,u.name,u.surname,u.url,u.autologin,u.autologout,u.lang,u.refresh,u.type,'.
' u.theme,u.attempt_failed,u.attempt_ip,u.attempt_clock,u.rows_per_page'.
' FROM users u'.
- ' WHERE u.userid='.$userid
+ ' WHERE u.userid='.zbx_dbstr($userid)
));
$userData['debug_mode'] = (bool) DBfetch(DBselect(
'SELECT ug.userid'.
' FROM usrgrp g,users_groups ug'.
- ' WHERE ug.userid='.$userid.
+ ' WHERE ug.userid='.zbx_dbstr($userid).
' AND g.usrgrpid=ug.usrgrpid'.
' AND g.debug_mode='.GROUP_DEBUG_MODE_ENABLED
));
Index: frontends/php/api/classes/CImage.php
===================================================================
--- ./frontends/php/api/classes/CImage.php (revision 38884)
+++ ./frontends/php/api/classes/CImage.php (working copy)
@@ -314,9 +314,9 @@
$imageid = get_dbid('images', 'imageid');
$values = array(
- 'imageid' => $imageid,
+ 'imageid' => zbx_dbstr($imageid),
'name' => zbx_dbstr($image['name']),
- 'imagetype' => $image['imagetype'],
+ 'imagetype' => zbx_dbstr($image['imagetype'])
);
switch ($DB['TYPE']) {
@@ -423,7 +423,7 @@
$values = array();
if (isset($image['name'])) $values['name'] = zbx_dbstr($image['name']);
- if (isset($image['imagetype'])) $values['imagetype'] = $image['imagetype'];
+ if (isset($image['imagetype'])) $values['imagetype'] = zbx_dbstr($image['imagetype']);
if (isset($image['image'])) {
// decode BASE64
@@ -443,7 +443,7 @@
$values['image'] = zbx_dbstr($image['image']);
break;
case ZBX_DB_ORACLE:
- $sql = 'SELECT image FROM images WHERE imageid = '.$image['imageid'].' FOR UPDATE';
+ $sql = 'SELECT image FROM images WHERE imageid = '.zbx_dbstr($image['imageid']).' FOR UPDATE';
if (!$stmt = oci_parse($DB['DB'], $sql)) {
$e = oci_error($DB['DB']);
@@ -464,7 +464,7 @@
$row['IMAGE']->free();
break;
case ZBX_DB_DB2:
- $stmt = db2_prepare($DB['DB'], 'UPDATE images SET image=? WHERE imageid='.$image['imageid']);
+ $stmt = db2_prepare($DB['DB'], 'UPDATE images SET image=? WHERE imageid='.zbx_dbstr($image['imageid']));
if (!$stmt) {
self::exception(ZBX_API_ERROR_PARAMETERS, db2_conn_errormsg($DB['DB']));
@@ -486,7 +486,7 @@
foreach ($values as $field => $value) {
$sqlUpd[] = $field.'='.$value;
}
- $sql = 'UPDATE images SET '.implode(', ', $sqlUpd).' WHERE imageid='.$image['imageid'];
+ $sql = 'UPDATE images SET '.implode(', ', $sqlUpd).' WHERE imageid='.zbx_dbstr($image['imageid']);
$result = DBexecute($sql);
if (!$result) {
Index: frontends/php/api/classes/CMapElement.php
===================================================================
--- ./frontends/php/api/classes/CMapElement.php (revision 38884)
+++ ./frontends/php/api/classes/CMapElement.php (working copy)
@@ -586,7 +586,7 @@
$sql = 'SELECT elementid, elementtype '.
' FROM sysmaps_elements '.
- ' WHERE sysmapid='.$elementid .
+ ' WHERE sysmapid='.zbx_dbstr($elementid) .
' AND elementtype='.SYSMAP_ELEMENT_TYPE_MAP;
$dbElements = DBselect($sql);
Index: frontends/php/api/classes/CTriggerPrototype.php
===================================================================
--- ./frontends/php/api/classes/CTriggerPrototype.php (revision 38884)
+++ ./frontends/php/api/classes/CTriggerPrototype.php (working copy)
@@ -423,7 +423,7 @@
// min_severity
if (!is_null($options['min_severity'])) {
- $sqlParts['where'][] = 't.priority>='.$options['min_severity'];
+ $sqlParts['where'][] = 't.priority>='.zbx_dbstr($options['min_severity']);
}
// output
Index: frontends/php/api/classes/CUserGroup.php
===================================================================
--- ./frontends/php/api/classes/CUserGroup.php (revision 38884)
+++ ./frontends/php/api/classes/CUserGroup.php (working copy)
@@ -144,7 +144,7 @@
// status
if (!is_null($options['status'])) {
- $sqlParts['where'][] = 'g.users_status='.$options['status'];
+ $sqlParts['where'][] = 'g.users_status='.zbx_dbstr($options['status']);
}
// with_gui_access
Index: frontends/php/api/classes/CGraph.php
===================================================================
--- ./frontends/php/api/classes/CGraph.php (revision 38884)
+++ ./frontends/php/api/classes/CGraph.php (working copy)
@@ -209,7 +209,7 @@
// type
if (!is_null($options['type'])) {
- $sqlParts['where'][] = 'g.type='.$options['type'];
+ $sqlParts['where'][] = 'g.type='.zbx_dbstr($options['type']);
}
// templated
Index: frontends/php/api/classes/CApplication.php
===================================================================
--- ./frontends/php/api/classes/CApplication.php (revision 38884)
+++ ./frontends/php/api/classes/CApplication.php (working copy)
@@ -719,7 +719,7 @@
DB::insert('items_applications', $appsInsert);
foreach ($itemids as $inum => $itemid) {
- $dbChilds = DBselect('SELECT i.itemid,i.hostid FROM items i WHERE i.templateid='.$itemid);
+ $dbChilds = DBselect('SELECT i.itemid,i.hostid FROM items i WHERE i.templateid='.zbx_dbstr($itemid));
while ($child = DBfetch($dbChilds)) {
$dbApps = DBselect(
'SELECT a1.applicationid'.
Index: frontends/php/api/classes/CAlert.php
===================================================================
--- ./frontends/php/api/classes/CAlert.php (revision 38884)
+++ ./frontends/php/api/classes/CAlert.php (working copy)
@@ -237,12 +237,12 @@
// time_from
if (!is_null($options['time_from'])) {
- $sqlParts['where'][] = 'a.clock>'.$options['time_from'];
+ $sqlParts['where'][] = 'a.clock>'.zbx_dbstr($options['time_from']);
}
// time_till
if (!is_null($options['time_till'])) {
- $sqlParts['where'][] = 'a.clock<'.$options['time_till'];
+ $sqlParts['where'][] = 'a.clock<'.zbx_dbstr($options['time_till']);
}
// output
Index: frontends/php/api/classes/CWebCheck.php
===================================================================
--- ./frontends/php/api/classes/CWebCheck.php (revision 38884)
+++ ./frontends/php/api/classes/CWebCheck.php (working copy)
@@ -347,7 +347,7 @@
$dbCheckItems = DBselect(
'SELECT i.itemid,hi.type'.
' FROM items i,httptestitem hi'.
- ' WHERE hi.httptestid='.$httpTest['httptestid'].
+ ' WHERE hi.httptestid='.zbx_dbstr($httpTest['httptestid']).
' AND hi.itemid=i.itemid'
);
while ($checkitem = DBfetch($dbCheckItems)) {
@@ -696,7 +696,7 @@
$sql = 'SELECT h.httpstepid,h.name'.
' FROM httpstep h'.
- ' WHERE h.httptestid='.$httpTest['httptestid'].
+ ' WHERE h.httptestid='.zbx_dbstr($httpTest['httptestid']).
' AND '.dbConditionString('h.name', $webstepsNames);
if ($httpstepData = DBfetch(DBselect($sql))) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Step "%s" already exists.', $httpstepData['name']));
@@ -820,7 +820,7 @@
$dbStepItems = DBselect(
'SELECT i.itemid,hi.type'.
' FROM items i,httpstepitem hi'.
- ' WHERE hi.httpstepid='.$webstep['webstepid'].
+ ' WHERE hi.httpstepid='.zbx_dbstr($webstep['webstepid']).
' AND hi.itemid=i.itemid'
);
while ($stepitem = DBfetch($dbStepItems)) {
Index: frontends/php/api/classes/CTemplateScreen.php
===================================================================
--- ./frontends/php/api/classes/CTemplateScreen.php (revision 38884)
+++ ./frontends/php/api/classes/CTemplateScreen.php (working copy)
@@ -618,7 +618,7 @@
'SELECT src.itemid as srcid,dest.itemid as destid'.
' FROM items dest,items src'.
' WHERE dest.key_=src.key_'.
- ' AND dest.hostid='.$templateId.
+ ' AND dest.hostid='.zbx_dbstr($templateId).
' AND '.dbConditionInt('src.itemid', $resourceItemIds)
);
while ($dbItem = DBfetch($dbItems)) {
@@ -633,7 +633,7 @@
' WHERE dest.name=src.name'.
' AND destgi.graphid=dest.graphid'.
' AND destgi.itemid=desti.itemid'.
- ' AND desti.hostid='.$templateId.
+ ' AND desti.hostid='.zbx_dbstr($templateId).
' AND '.dbConditionInt('src.graphid', $resourceGraphIds)
);
while ($dbItem = DBfetch($dbItems)) {
Index: frontends/php/include/items.inc.php
===================================================================
--- ./frontends/php/include/items.inc.php (revision 38884)
+++ ./frontends/php/include/items.inc.php (working copy)
@@ -224,7 +224,7 @@
while ($item = DBfetch($db_items)) {
$old_status = $item['status'];
if ($status != $old_status) {
- $result &= DBexecute('UPDATE items SET status='.$status.
+ $result &= DBexecute('UPDATE items SET status='.zbx_dbstr($status).
($status != ITEM_STATUS_NOTSUPPORTED ? ",error=''" : '').
' WHERE itemid='.$item['itemid']);
if ($result) {
@@ -420,7 +420,7 @@
}
function get_item_by_itemid($itemid) {
- $db_items = DBfetch(DBselect('SELECT i.* FROM items i WHERE i.itemid='.$itemid));
+ $db_items = DBfetch(DBselect('SELECT i.* FROM items i WHERE i.itemid='.zbx_dbstr($itemid)));
if ($db_items) {
return $db_items;
}
@@ -436,7 +436,7 @@
'i.formula,i.trends,i.logtimefmt,i.valuemapid,i.delay_flex,i.params,i.ipmi_sensor,i.templateid,'.
'i.authtype,i.username,i.password,i.publickey,i.privatekey,i.flags,i.filter,i.description,i.inventory_link'.
' FROM items i'.
- ' WHERE i.itemid='.$itemid));
+ ' WHERE i.itemid='.zbx_dbstr($itemid)));
if ($row) {
return $row;
}
@@ -469,7 +469,7 @@
$db_items = DBselect(
'SELECT src.*'.
' FROM items src,items dest'.
- ' WHERE dest.itemid='.$itemid.
+ ' WHERE dest.itemid='.zbx_dbstr($itemid).
' AND src.key_=dest.key_'.
' AND '.dbConditionInt('src.hostid', $dest_hostids)
);
@@ -838,7 +838,7 @@
'SELECT a1.applicationid'.
' FROM applications a1,applications a2'.
' WHERE a1.name=a2.name'.
- ' AND a1.hostid='.$hostid.
+ ' AND a1.hostid='.zbx_dbstr($hostid).
' AND '.dbConditionInt('a2.applicationid', $applications)
);
while ($app = DBfetch($db_apps)) {
@@ -986,9 +986,9 @@
if ($last == 0) {
$sql = 'SELECT value'.
' FROM '.$table.
- ' WHERE itemid='.$db_item['itemid'].
- ' AND clock='.$clock.
- ' AND ns='.$ns;
+ ' WHERE itemid='.zbx_dbstr($db_item['itemid']).
+ ' AND clock='.zbx_dbstr($clock).
+ ' AND ns='.zbx_dbstr($ns);
if (null != ($row = DBfetch(DBselect($sql, 1)))) {
$value = $row['value'];
}
@@ -1000,17 +1000,17 @@
$sql = 'SELECT DISTINCT clock'.
' FROM '.$table.
- ' WHERE itemid='.$db_item['itemid'].
- ' AND clock='.$clock.
- ' AND ns<'.$ns;
+ ' WHERE itemid='.zbx_dbstr($db_item['itemid']).
+ ' AND clock='.zbx_dbstr($clock).
+ ' AND ns<'.zbx_dbstr($ns);
if (null != ($row = DBfetch(DBselect($sql)))) {
$max_clock = $row['clock'];
}
if ($max_clock == 0) {
$sql = 'SELECT MAX(clock) AS clock'.
' FROM '.$table.
- ' WHERE itemid='.$db_item['itemid'].
- ' AND clock<'.$clock;
+ ' WHERE itemid='.zbx_dbstr($db_item['itemid']).
+ ' AND clock<'.zbx_dbstr($clock);
if (null != ($row = DBfetch(DBselect($sql)))) {
$max_clock = $row['clock'];
}
@@ -1022,15 +1022,15 @@
if ($clock == $max_clock) {
$sql = 'SELECT value'.
' FROM '.$table.
- ' WHERE itemid='.$db_item['itemid'].
- ' AND clock='.$clock.
- ' AND ns<'.$ns;
+ ' WHERE itemid='.zbx_dbstr($db_item['itemid']).
+ ' AND clock='.zbx_dbstr($clock).
+ ' AND ns<'.zbx_dbstr($ns);
}
else {
$sql = 'SELECT value'.
' FROM '.$table.
- ' WHERE itemid='.$db_item['itemid'].
- ' AND clock='.$max_clock.
+ ' WHERE itemid='.zbx_dbstr($db_item['itemid']).
+ ' AND clock='.zbx_dbstr($max_clock).
' ORDER BY itemid,clock desc,ns desc';
}
@@ -1039,9 +1039,9 @@
}
}
else {
- $row = DBfetch(DBselect('SELECT MAX(clock) AS clock FROM '.$table.' WHERE itemid='.$db_item['itemid']));
+ $row = DBfetch(DBselect('SELECT MAX(clock) AS clock FROM '.$table.' WHERE itemid='.zbx_dbstr($db_item['itemid'])));
if (!empty($row['clock'])) {
- $row = DBfetch(DBselect('SELECT value FROM '.$table.' WHERE itemid='.$db_item['itemid'].' AND clock='.$row['clock'].' ORDER BY ns DESC', 1));
+ $row = DBfetch(DBselect('SELECT value FROM '.$table.' WHERE itemid='.zbx_dbstr($db_item['itemid']).' AND clock='.zbx_dbstr($row['clock']).' ORDER BY ns DESC', 1));
if (!empty($row['value'])) {
$value = $row['value'];
}
Index: frontends/php/include/services.inc.php
===================================================================
--- ./frontends/php/include/services.inc.php (revision 38884)
+++ ./frontends/php/include/services.inc.php (working copy)
@@ -42,7 +42,7 @@
$result = DBselect(
'SELECT s.status'.
' FROM services s,services_links l'.
- ' WHERE l.serviceupid='.$serviceid.
+ ' WHERE l.serviceupid='.zbx_dbstr($serviceid).
' AND s.serviceid=l.servicedownid'.
' ORDER BY s.status'.$sort_order
);
@@ -77,7 +77,7 @@
$result = DBselect(
'SELECT sl.servicedownid'.
' FROM services_links sl'.
- ' WHERE sl.serviceupid='.$serviceid.
+ ' WHERE sl.serviceupid='.zbx_dbstr($serviceid).
($soft ? '' : ' AND sl.soft=0')