prompt
stringclasses 1
value | completions
listlengths 1
63.8k
| labels
listlengths 1
63.8k
| source
stringclasses 1
value | other_info
stringlengths 2.06k
101k
| index
int64 0
6.83k
|
|---|---|---|---|---|---|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class taxController extends expController {\n public $basemodel_name = 'taxclass';",
"\n protected $add_permissions = array(\n 'manage_zones' => 'Manages Zones',\n 'edit_zone' => 'Add/Edit Zone',\n 'update_zone' => 'Update Zone',\n 'delete_zone' => 'Delete Zone'\n );",
"\n static function displayname() {\n return gt(\"e-Commerce Tax Class Manager\");\n }",
" static function description() {\n return gt(\"Manage tax classes for your e-Commerce store\");\n }",
"// static function canImportData() {\n// return true;\n// }\n//\n// static function canExportData() {\n// return true;\n// }",
" // tax rates",
" function manage() {\n expHistory::set('manageable', $this->params);\n $taxes = taxController::getTaxRates();\n assign_to_template(array(\n 'taxes' => $taxes\n ));\n }",
" static function getTaxRates() {\n global $db;",
" $sql = \"\n SELECT\n \" . $db->prefix . \"tax_rate.id,\n \" . $db->prefix . \"tax_zone.`name` AS zonename,\n \" . $db->prefix . \"tax_rate.rate as rate,\n \" . $db->prefix . \"tax_rate.shipping_taxed as shipping_taxed,\n \" . $db->prefix . \"tax_rate.origin_tax as origin_tax,\n \" . $db->prefix . \"tax_rate.inactive as inactive,\n \" . $db->prefix . \"tax_class.`name` AS classname,\n \" . $db->prefix . \"geo_country.`name` as country,\n \" . $db->prefix . \"geo_region.`name` as state\n FROM \" . $db->prefix . \"tax_class\n INNER JOIN \" . $db->prefix . \"tax_rate ON \" . $db->prefix . \"tax_class.id = \" . $db->prefix . \"tax_rate.class_id\n INNER JOIN \" . $db->prefix . \"tax_zone ON \" . $db->prefix . \"tax_rate.zone_id = \" . $db->prefix . \"tax_zone.id\n INNER JOIN \" . $db->prefix . \"tax_geo ON \" . $db->prefix . \"tax_geo.zone_id = \" . $db->prefix . \"tax_zone.id\n LEFT JOIN \" . $db->prefix . \"geo_country ON \" . $db->prefix . \"tax_geo.country_id = \" . $db->prefix . \"geo_country.id\n LEFT JOIN \" . $db->prefix . \"geo_region ON \" . $db->prefix . \"tax_geo.region_id = \" . $db->prefix . \"geo_region.id\n \";",
" return $db->selectObjectsBySql($sql);\n }",
" function edit() {\n global $db;",
" $record = '';\n if (!empty($this->params['id'])) {\n //Get the data from the 3 tables\n $tax_rate = $db->selectObject('tax_rate', 'id =' . $this->params['id']);\n $tax_class = $db->selectObject('tax_class', 'id =' . $tax_rate->class_id);\n// $tax_geo = $db->selectObject('tax_geo', 'zone_id =' . $tax_rate->zone_id);\n //Store it in a single object all the data needed\n $record = new stdClass();\n $record->id = $tax_rate->id;\n $record->class_id = $tax_rate->class_id;\n $record->classname = $tax_class->name;\n $record->rate = $tax_rate->rate;\n $record->shipping_taxed = $tax_rate->shipping_taxed;\n $record->origin_tax = $tax_rate->origin_tax;\n $record->inactive = $tax_rate->inactive;\n $record->zone = $tax_rate->zone_id;\n// $record->state = $tax_geo->region_id;\n// $record->country = $tax_geo->country_id;\n }",
" //Get the tax_zone\n $records = $db->selectObjects('tax_zone');\n $zones = array();\n foreach ($records as $item) {\n $zones[$item->id] = $item->name;\n }",
" $records = $db->selectObjects('tax_class');\n $classes = array();\n foreach ($records as $item) {\n $classes[$item->id] = $item->name;\n }",
" assign_to_template(array(\n 'classes' => $classes,\n 'zones' => $zones,\n 'record' => $record\n ));\n }",
" function update() {\n global $db;",
"// if (isset($this->params['address_country_id'])) {\n// $this->params['country'] = $this->params['address_country_id'];\n// unset($this->params['address_country_id']);\n// }\n// if (isset($this->params['address_region_id'])) {\n// $this->params['state'] = $this->params['address_region_id'];\n// unset($this->params['address_region_id']);\n// }",
" if (empty($this->params['id'])) {\n // Add data in tax class\n// $tax_class = new stdClass();\n// $tax_class->name = $this->params['name'];\n// $class_id = $db->insertObject($tax_class, 'tax_class');",
" // Add data in the tax rate\n $tax_rate = new stdClass();\n $tax_rate->zone_id = $this->params['zone'];\n $tax_rate->class_id = $this->params['class'];\n $tax_rate->rate = $this->params['rate'];\n $tax_rate->shipping_taxed = $this->params['shipping_taxed'];\n $tax_rate->origin_tax = $this->params['origin_tax'];\n $tax_rate->inactive = $this->params['inactive'];\n $db->insertObject($tax_rate, 'tax_rate');",
" // Add data in the tax geo\n// $tax_geo = new stdClass();\n// $tax_geo->zone_id = $this->params['zone'];\n// $tax_geo->country_id = $this->params['country'];\n// $tax_geo->region_id = $this->params['state'];\n// $db->insertObject($tax_geo, 'tax_geo');\n } else {\n // Update the Tax class table\n// $tax_class = $db->selectObject('tax_class', 'id =' . $this->params['id']);\n// $tax_class->name = $this->params['name'];\n// $db->updateObject($tax_class, 'tax_class');",
" // Update the Tax rate table\n $tax_rate = $db->selectObject('tax_rate', 'id =' . $this->params['id']);\n// $zone_id = $tax_rate->zone_id;\n $tax_rate->zone_id = $this->params['zone'];\n $tax_rate->class_id = $this->params['class'];\n $tax_rate->rate = $this->params['rate'];\n $tax_rate->shipping_taxed = $this->params['shipping_taxed'] == 1;\n $tax_rate->origin_tax = $this->params['origin_tax'] == 1;\n $tax_rate->inactive = $this->params['inactive'] == 1;\n $db->updateObject($tax_rate, 'tax_rate');",
" // Update the Tax geo table\n// $tax_geo = $db->selectObject('tax_geo', 'zone_id =' . $zone_id);\n// $tax_geo->zone_id = $this->params['zone'];\n// $tax_geo->country_id = $this->params['country'];\n// $tax_geo->region_id = $this->params['state'];\n// $db->updateObject($tax_geo, 'tax_geo');\n }",
" expHistory::returnTo('manageable');\n }",
" /**\n * Delete tax rate\n */\n function delete() {\n global $db;",
" if (empty($this->params['id'])) return false;\n// $zone = $db->selectObject('tax_zone', 'id =' . $this->params['id']);",
" //Get the data from the text rate to get the zone id\n// $rate = $db->selectObject('tax_rate', 'class_id=' . $this->params['id']);",
" //Delete record in tax rate\n $db->delete('tax_rate', 'class_id =' . $this->params['id']);",
" //Delete record in tax geo\n// $db->delete('tax_geo', 'zone_id =' . $rate->zone_id);",
" //Finally delete the record in tax class\n// $db->delete('tax_class', 'id =' . $this->params['id']);",
" expHistory::returnTo('manageable');\n }",
" // tax classes",
" function manage_classes() {\n global $db;",
" $back = expHistory::getLast('manageable');\n expHistory::set('manageable', $this->params);\n $classes = $db->selectObjects('tax_class');",
" assign_to_template(array(\n 'classes' => $classes,\n 'back' => $back\n ));\n }",
" /**\n * Edit tax class\n */\n function edit_class() {\n global $db;",
" if (isset($this->params['id'])) {\n $class = $db->selectObject('tax_class', 'id =' . $this->params['id']);",
" assign_to_template(array(\n 'class' => $class\n ));\n }\n }",
" /**\n * Update tax class\n */\n function update_class() {\n global $db;",
" if (empty($this->params['id'])) {\n // Add data in tax class\n $obj = new stdClass();\n $obj->name = $this->params['name'];\n $db->insertObject($obj, 'tax_class');\n } else {\n // Update the Tax class table\n $class = $db->selectObject('tax_class', 'id =' . $this->params['id']);\n $class->name = $this->params['name'];\n $db->updateObject($class, 'tax_class');\n }",
" expHistory::returnTo('manageable');\n }",
" /**\n * Delete tax class along with assoc. tax rates\n */\n function delete_class() {\n global $db;",
" if (empty($this->params['id'])) return false;\n $db->delete('tax_rate', 'class_id =' . $this->params['id']);\n $db->delete('tax_class', 'id =' . $this->params['id']);",
" expHistory::returnTo('manageable');\n }",
" // tax zones",
" function manage_zones() {\n global $db;",
" $back = expHistory::getLast('manageable');\n expHistory::set('manageable', $this->params);\n// $zones = $db->selectObjects('tax_zone', null, 'name');\n $zones = taxController::getTaxZones();",
" assign_to_template(array(\n 'zones' => $zones,\n 'back' => $back\n ));\n }",
" static function getTaxZones() {\n global $db;",
" $sql = \"\n SELECT\n \" . $db->prefix . \"tax_zone.id,\n \" . $db->prefix . \"tax_zone.`name` AS name,\n \" . $db->prefix . \"geo_country.`name` as country,\n \" . $db->prefix . \"geo_region.`name` as state\n FROM \" . $db->prefix . \"tax_zone\n INNER JOIN \" . $db->prefix . \"tax_geo ON \" . $db->prefix . \"tax_geo.zone_id = \" . $db->prefix . \"tax_zone.id\n LEFT JOIN \" . $db->prefix . \"geo_country ON \" . $db->prefix . \"tax_geo.country_id = \" . $db->prefix . \"geo_country.id\n LEFT JOIN \" . $db->prefix . \"geo_region ON \" . $db->prefix . \"tax_geo.region_id = \" . $db->prefix . \"geo_region.id\n \";",
" return $db->selectObjectsBySql($sql);\n }",
" /**\n * Edit tax zone and tax geo\n */\n function edit_zone() {\n global $db;",
" if (isset($this->params['id'])) {\n $zone = $db->selectObject('tax_zone', 'id =' . $this->params['id']);",
" $tax_geo = $db->selectObject('tax_geo', 'zone_id =' . $zone->id);\n //Store it in a single object all the data needed\n $zone->state = $tax_geo->region_id;\n $zone->country = $tax_geo->country_id;",
" assign_to_template(array(\n 'zone' => $zone\n ));\n }\n }",
" /**\n * Update tax zone and assoc. tax geo\n */\n function update_zone() {\n global $db;",
" if (isset($this->params['address_country_id'])) {\n $this->params['country'] = $this->params['address_country_id'];\n unset($this->params['address_country_id']);\n }\n if (isset($this->params['address_region_id'])) {\n $this->params['state'] = $this->params['address_region_id'];\n unset($this->params['address_region_id']);\n }",
" if (empty($this->params['id'])) {\n // Add data in tax zone\n $obj = new stdClass();\n $obj->name = $this->params['name'];\n $zone_id = $db->insertObject($obj, 'tax_zone');",
" // Add data in the tax geo\n $tax_geo = new stdClass();\n $tax_geo->zone_id = $zone_id;\n $tax_geo->country_id = $this->params['country'];\n $tax_geo->region_id = $this->params['state'];\n $db->insertObject($tax_geo, 'tax_geo');\n } else {\n // Update the Tax zone table\n $zone = $db->selectObject('tax_zone', 'id =' . $this->params['id']);\n $zone->name = $this->params['name'];\n $db->updateObject($zone, 'tax_zone');",
" // Update the Tax geo table\n $tax_geo = $db->selectObject('tax_geo', 'zone_id =' . $zone->id);\n// $tax_geo->zone_id = $this->params['id'];\n $tax_geo->country_id = $this->params['country'];\n $tax_geo->region_id = $this->params['state'];\n $db->updateObject($tax_geo, 'tax_geo');\n }",
" expHistory::returnTo('manageable');\n }",
" /**\n * Delete tax zone alone with assoc. tax classes & tax rates\n */\n function delete_zone() {\n global $db;",
" if (empty($this->params['id'])) return false;\n $db->delete('tax_geo', 'zone_id =' . $this->params['id']);\n $rates = $db->selectObjects('tax_rate', 'zone_id =' . $this->params['id']);\n foreach ($rates as $rate) {\n $db->delete('tax_class', 'id =' . $rate->id);\n }\n $db->delete('tax_rate', 'zone_id =' . $this->params['id']);\n $db->delete('tax_zone', 'id =' . $this->params['id']);",
" expHistory::returnTo('manageable');\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class taxController extends expController {\n public $basemodel_name = 'taxclass';",
"",
"\n static function displayname() {\n return gt(\"e-Commerce Tax Class Manager\");\n }",
" static function description() {\n return gt(\"Manage tax classes for your e-Commerce store\");\n }",
"// static function canImportData() {\n// return true;\n// }\n//\n// static function canExportData() {\n// return true;\n// }",
" // tax rates",
" function manage() {\n expHistory::set('manageable', $this->params);\n $taxes = taxController::getTaxRates();\n assign_to_template(array(\n 'taxes' => $taxes\n ));\n }",
" static function getTaxRates() {\n global $db;",
" $sql = \"\n SELECT\n \" . $db->prefix . \"tax_rate.id,\n \" . $db->prefix . \"tax_zone.`name` AS zonename,\n \" . $db->prefix . \"tax_rate.rate as rate,\n \" . $db->prefix . \"tax_rate.shipping_taxed as shipping_taxed,\n \" . $db->prefix . \"tax_rate.origin_tax as origin_tax,\n \" . $db->prefix . \"tax_rate.inactive as inactive,\n \" . $db->prefix . \"tax_class.`name` AS classname,\n \" . $db->prefix . \"geo_country.`name` as country,\n \" . $db->prefix . \"geo_region.`name` as state\n FROM \" . $db->prefix . \"tax_class\n INNER JOIN \" . $db->prefix . \"tax_rate ON \" . $db->prefix . \"tax_class.id = \" . $db->prefix . \"tax_rate.class_id\n INNER JOIN \" . $db->prefix . \"tax_zone ON \" . $db->prefix . \"tax_rate.zone_id = \" . $db->prefix . \"tax_zone.id\n INNER JOIN \" . $db->prefix . \"tax_geo ON \" . $db->prefix . \"tax_geo.zone_id = \" . $db->prefix . \"tax_zone.id\n LEFT JOIN \" . $db->prefix . \"geo_country ON \" . $db->prefix . \"tax_geo.country_id = \" . $db->prefix . \"geo_country.id\n LEFT JOIN \" . $db->prefix . \"geo_region ON \" . $db->prefix . \"tax_geo.region_id = \" . $db->prefix . \"geo_region.id\n \";",
" return $db->selectObjectsBySql($sql);\n }",
" function edit() {\n global $db;",
" $record = '';\n if (!empty($this->params['id'])) {\n //Get the data from the 3 tables\n $tax_rate = $db->selectObject('tax_rate', 'id =' . $this->params['id']);\n $tax_class = $db->selectObject('tax_class', 'id =' . $tax_rate->class_id);\n// $tax_geo = $db->selectObject('tax_geo', 'zone_id =' . $tax_rate->zone_id);\n //Store it in a single object all the data needed\n $record = new stdClass();\n $record->id = $tax_rate->id;\n $record->class_id = $tax_rate->class_id;\n $record->classname = $tax_class->name;\n $record->rate = $tax_rate->rate;\n $record->shipping_taxed = $tax_rate->shipping_taxed;\n $record->origin_tax = $tax_rate->origin_tax;\n $record->inactive = $tax_rate->inactive;\n $record->zone = $tax_rate->zone_id;\n// $record->state = $tax_geo->region_id;\n// $record->country = $tax_geo->country_id;\n }",
" //Get the tax_zone\n $records = $db->selectObjects('tax_zone');\n $zones = array();\n foreach ($records as $item) {\n $zones[$item->id] = $item->name;\n }",
" $records = $db->selectObjects('tax_class');\n $classes = array();\n foreach ($records as $item) {\n $classes[$item->id] = $item->name;\n }",
" assign_to_template(array(\n 'classes' => $classes,\n 'zones' => $zones,\n 'record' => $record\n ));\n }",
" function update() {\n global $db;",
"// if (isset($this->params['address_country_id'])) {\n// $this->params['country'] = $this->params['address_country_id'];\n// unset($this->params['address_country_id']);\n// }\n// if (isset($this->params['address_region_id'])) {\n// $this->params['state'] = $this->params['address_region_id'];\n// unset($this->params['address_region_id']);\n// }",
" if (empty($this->params['id'])) {\n // Add data in tax class\n// $tax_class = new stdClass();\n// $tax_class->name = $this->params['name'];\n// $class_id = $db->insertObject($tax_class, 'tax_class');",
" // Add data in the tax rate\n $tax_rate = new stdClass();\n $tax_rate->zone_id = $this->params['zone'];\n $tax_rate->class_id = $this->params['class'];\n $tax_rate->rate = $this->params['rate'];\n $tax_rate->shipping_taxed = $this->params['shipping_taxed'];\n $tax_rate->origin_tax = $this->params['origin_tax'];\n $tax_rate->inactive = $this->params['inactive'];\n $db->insertObject($tax_rate, 'tax_rate');",
" // Add data in the tax geo\n// $tax_geo = new stdClass();\n// $tax_geo->zone_id = $this->params['zone'];\n// $tax_geo->country_id = $this->params['country'];\n// $tax_geo->region_id = $this->params['state'];\n// $db->insertObject($tax_geo, 'tax_geo');\n } else {\n // Update the Tax class table\n// $tax_class = $db->selectObject('tax_class', 'id =' . $this->params['id']);\n// $tax_class->name = $this->params['name'];\n// $db->updateObject($tax_class, 'tax_class');",
" // Update the Tax rate table\n $tax_rate = $db->selectObject('tax_rate', 'id =' . $this->params['id']);\n// $zone_id = $tax_rate->zone_id;\n $tax_rate->zone_id = $this->params['zone'];\n $tax_rate->class_id = $this->params['class'];\n $tax_rate->rate = $this->params['rate'];\n $tax_rate->shipping_taxed = $this->params['shipping_taxed'] == 1;\n $tax_rate->origin_tax = $this->params['origin_tax'] == 1;\n $tax_rate->inactive = $this->params['inactive'] == 1;\n $db->updateObject($tax_rate, 'tax_rate');",
" // Update the Tax geo table\n// $tax_geo = $db->selectObject('tax_geo', 'zone_id =' . $zone_id);\n// $tax_geo->zone_id = $this->params['zone'];\n// $tax_geo->country_id = $this->params['country'];\n// $tax_geo->region_id = $this->params['state'];\n// $db->updateObject($tax_geo, 'tax_geo');\n }",
" expHistory::returnTo('manageable');\n }",
" /**\n * Delete tax rate\n */\n function delete() {\n global $db;",
" if (empty($this->params['id'])) return false;\n// $zone = $db->selectObject('tax_zone', 'id =' . $this->params['id']);",
" //Get the data from the text rate to get the zone id\n// $rate = $db->selectObject('tax_rate', 'class_id=' . $this->params['id']);",
" //Delete record in tax rate\n $db->delete('tax_rate', 'class_id =' . $this->params['id']);",
" //Delete record in tax geo\n// $db->delete('tax_geo', 'zone_id =' . $rate->zone_id);",
" //Finally delete the record in tax class\n// $db->delete('tax_class', 'id =' . $this->params['id']);",
" expHistory::returnTo('manageable');\n }",
" // tax classes",
" function manage_classes() {\n global $db;",
" $back = expHistory::getLast('manageable');\n expHistory::set('manageable', $this->params);\n $classes = $db->selectObjects('tax_class');",
" assign_to_template(array(\n 'classes' => $classes,\n 'back' => $back\n ));\n }",
" /**\n * Edit tax class\n */\n function edit_class() {\n global $db;",
" if (isset($this->params['id'])) {\n $class = $db->selectObject('tax_class', 'id =' . $this->params['id']);",
" assign_to_template(array(\n 'class' => $class\n ));\n }\n }",
" /**\n * Update tax class\n */\n function update_class() {\n global $db;",
" if (empty($this->params['id'])) {\n // Add data in tax class\n $obj = new stdClass();\n $obj->name = $this->params['name'];\n $db->insertObject($obj, 'tax_class');\n } else {\n // Update the Tax class table\n $class = $db->selectObject('tax_class', 'id =' . $this->params['id']);\n $class->name = $this->params['name'];\n $db->updateObject($class, 'tax_class');\n }",
" expHistory::returnTo('manageable');\n }",
" /**\n * Delete tax class along with assoc. tax rates\n */\n function delete_class() {\n global $db;",
" if (empty($this->params['id'])) return false;\n $db->delete('tax_rate', 'class_id =' . $this->params['id']);\n $db->delete('tax_class', 'id =' . $this->params['id']);",
" expHistory::returnTo('manageable');\n }",
" // tax zones",
" function manage_zones() {\n global $db;",
" $back = expHistory::getLast('manageable');\n expHistory::set('manageable', $this->params);\n// $zones = $db->selectObjects('tax_zone', null, 'name');\n $zones = taxController::getTaxZones();",
" assign_to_template(array(\n 'zones' => $zones,\n 'back' => $back\n ));\n }",
" static function getTaxZones() {\n global $db;",
" $sql = \"\n SELECT\n \" . $db->prefix . \"tax_zone.id,\n \" . $db->prefix . \"tax_zone.`name` AS name,\n \" . $db->prefix . \"geo_country.`name` as country,\n \" . $db->prefix . \"geo_region.`name` as state\n FROM \" . $db->prefix . \"tax_zone\n INNER JOIN \" . $db->prefix . \"tax_geo ON \" . $db->prefix . \"tax_geo.zone_id = \" . $db->prefix . \"tax_zone.id\n LEFT JOIN \" . $db->prefix . \"geo_country ON \" . $db->prefix . \"tax_geo.country_id = \" . $db->prefix . \"geo_country.id\n LEFT JOIN \" . $db->prefix . \"geo_region ON \" . $db->prefix . \"tax_geo.region_id = \" . $db->prefix . \"geo_region.id\n \";",
" return $db->selectObjectsBySql($sql);\n }",
" /**\n * Edit tax zone and tax geo\n */\n function edit_zone() {\n global $db;",
" if (isset($this->params['id'])) {\n $zone = $db->selectObject('tax_zone', 'id =' . $this->params['id']);",
" $tax_geo = $db->selectObject('tax_geo', 'zone_id =' . $zone->id);\n //Store it in a single object all the data needed\n $zone->state = $tax_geo->region_id;\n $zone->country = $tax_geo->country_id;",
" assign_to_template(array(\n 'zone' => $zone\n ));\n }\n }",
" /**\n * Update tax zone and assoc. tax geo\n */\n function update_zone() {\n global $db;",
" if (isset($this->params['address_country_id'])) {\n $this->params['country'] = $this->params['address_country_id'];\n unset($this->params['address_country_id']);\n }\n if (isset($this->params['address_region_id'])) {\n $this->params['state'] = $this->params['address_region_id'];\n unset($this->params['address_region_id']);\n }",
" if (empty($this->params['id'])) {\n // Add data in tax zone\n $obj = new stdClass();\n $obj->name = $this->params['name'];\n $zone_id = $db->insertObject($obj, 'tax_zone');",
" // Add data in the tax geo\n $tax_geo = new stdClass();\n $tax_geo->zone_id = $zone_id;\n $tax_geo->country_id = $this->params['country'];\n $tax_geo->region_id = $this->params['state'];\n $db->insertObject($tax_geo, 'tax_geo');\n } else {\n // Update the Tax zone table\n $zone = $db->selectObject('tax_zone', 'id =' . $this->params['id']);\n $zone->name = $this->params['name'];\n $db->updateObject($zone, 'tax_zone');",
" // Update the Tax geo table\n $tax_geo = $db->selectObject('tax_geo', 'zone_id =' . $zone->id);\n// $tax_geo->zone_id = $this->params['id'];\n $tax_geo->country_id = $this->params['country'];\n $tax_geo->region_id = $this->params['state'];\n $db->updateObject($tax_geo, 'tax_geo');\n }",
" expHistory::returnTo('manageable');\n }",
" /**\n * Delete tax zone alone with assoc. tax classes & tax rates\n */\n function delete_zone() {\n global $db;",
" if (empty($this->params['id'])) return false;\n $db->delete('tax_geo', 'zone_id =' . $this->params['id']);\n $rates = $db->selectObjects('tax_rate', 'zone_id =' . $this->params['id']);\n foreach ($rates as $rate) {\n $db->delete('tax_class', 'id =' . $rate->id);\n }\n $db->delete('tax_rate', 'zone_id =' . $this->params['id']);\n $db->delete('tax_zone', 'id =' . $this->params['id']);",
" expHistory::returnTo('manageable');\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Models\n * @package Modules\n */",
"class donation extends product {\n public $table = 'product';\n //public $has_and_belongs_to_many = array('storeCategory');",
" public $product_name = 'Online Donation';\n public $product_type = 'donation';\n public $requiresShipping = false;\n public $requiresBilling = true;\n public $isQuantityAdjustable = false;",
" protected $attachable_item_types = array(\n// 'content_expCats'=>'expCat',\n// 'content_expComments'=>'expComment',\n// 'content_expDefinableFields'=> 'expDefinableField',\n 'content_expFiles' => 'expFile',\n// 'content_expRatings'=>'expRating',\n// 'content_expSimpleNote'=>'expSimpleNote',\n// 'content_expTags'=>'expTag',\n );",
" public function hasOptions() {\n return false;\n }",
" public function hasUserInputFields() {\n return true;\n }",
" public function __construct($params = array(), $get_assoc = true, $get_attached = true) {\n parent::__construct($params, $get_assoc, $get_attached);\n//\t\t$this->price = '';\n $this->price = $this->base_price;\n }",
" public function find($range = 'all', $where = null, $order = null, $limit = null, $limitstart = 0, $get_assoc = true, $get_attached = true, $except = array(), $cascade_except = false) {\n global $db;",
" if (is_numeric($range)) {\n $where = 'id=' . intval($range); // If we hit this then we are expecting just a simple id\n $range = 'first';\n }",
" $sql = \"product_type='donation'\";\n if (!empty($where)) $sql .= $where;",
" $sql .= empty($order) ? '' : ' ORDER BY ' . $order;",
"\n if (strcasecmp($range, 'all') == 0) {",
" $sql .= empty($limit) ? '' : ' LIMIT ' . $limitstart . ',' . $limit;",
" return $db->selectExpObjects($this->tablename, $sql, $this->classname);\n } elseif (strcasecmp($range, 'first') == 0) {\n $sql .= ' LIMIT 0,1';\n $records = $db->selectExpObjects($this->tablename, $sql, $this->classname);\n return empty($records) ? null : $records[0];\n } elseif (strcasecmp($range, 'bytitle') == 0) {\n $records = $db->selectExpObjects($this->tablename, \"title='\" . $where . \"' OR sef_url='\" . $where . \"'\", $this->classname);\n return empty($records) ? null : $records[0];\n } elseif (strcasecmp($range, 'count') == 0) {\n return $db->countObjects($this->tablename, $sql);\n } elseif (strcasecmp($range, 'in') == 0) {\n if (!is_array($where)) return array();\n foreach ($where as $id) $records[] = new $this->classname($id);\n return $records;\n } elseif (strcasecmp($range, 'bytag') == 0) {\n $sql = 'SELECT DISTINCT m.id FROM ' . $db->prefix . $this->table . ' m ';\n $sql .= 'JOIN ' . $db->prefix . 'content_expTags ct ';\n $sql .= 'ON m.id = ct.content_id WHERE ct.exptags_id=' . $where . \" AND ct.content_type='\" . $this->classname . \"'\";\n $tag_assocs = $db->selectObjectsBySql($sql);\n $records = array();\n foreach ($tag_assocs as $assoc) {\n $records[] = new $this->classname($assoc->id);\n }\n return $records;\n }\n }",
" public function cartSummary($item) {\n $view = new controllertemplate($this, $this->getForm('cartSummary'));\n $view->assign('product', $this);\n $view->assign('item', $item);",
" // grab all the registrants\n// $message = expUnserialize($item->extra_data);\n// $view->assign('message', $message);",
" return $view->render();\n }",
" function getPrice($orderitem = null) {\n return 1;\n }",
" function addToCart($params, $orderid = null) {\n if (empty($params['quick']) && empty($params['options_shown'])) { //get user input if needed\n $this->displayForm('addToCart', $params);\n return false;\n }",
" $item = new orderitem($params);\n if (empty($params['dollar_amount'])) $params['dollar_amount'] = $this->price;\n $item->products_price = expUtil::currency_to_float($params['dollar_amount']);",
" $product = new product($params['product_id']);\n//\t $item->products_name = $params['dollar_amount'].' '.$this->product_name.' to '.$product->title;\n $item->products_name = $this->product_name . ' to ' . $product->title;",
" // we need to unset the orderitem's ID to force a new entry..other wise we will overwrite any\n // other giftcards in the cart already\n $item->id = null;\n $item->quantity = $this->getDefaultQuantity();\n $item->save();\n return true;\n }",
" public function getSEFURL() {\n if (!empty($this->sef_url)) return $this->sef_url;\n $parent = new product($this->parent_id, false, false);\n return $parent->sef_url;\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Models\n * @package Modules\n */",
"class donation extends product {\n public $table = 'product';\n //public $has_and_belongs_to_many = array('storeCategory');",
" public $product_name = 'Online Donation';\n public $product_type = 'donation';\n public $requiresShipping = false;\n public $requiresBilling = true;\n public $isQuantityAdjustable = false;",
" protected $attachable_item_types = array(\n// 'content_expCats'=>'expCat',\n// 'content_expComments'=>'expComment',\n// 'content_expDefinableFields'=> 'expDefinableField',\n 'content_expFiles' => 'expFile',\n// 'content_expRatings'=>'expRating',\n// 'content_expSimpleNote'=>'expSimpleNote',\n// 'content_expTags'=>'expTag',\n );",
" public function hasOptions() {\n return false;\n }",
" public function hasUserInputFields() {\n return true;\n }",
" public function __construct($params = array(), $get_assoc = true, $get_attached = true) {\n parent::__construct($params, $get_assoc, $get_attached);\n//\t\t$this->price = '';\n $this->price = $this->base_price;\n }",
" public function find($range = 'all', $where = null, $order = null, $limit = null, $limitstart = 0, $get_assoc = true, $get_attached = true, $except = array(), $cascade_except = false) {\n global $db;",
" if (is_numeric($range)) {\n $where = 'id=' . intval($range); // If we hit this then we are expecting just a simple id\n $range = 'first';\n }",
" $sql = \"product_type='donation'\";\n if (!empty($where)) $sql .= $where;",
" $sql .= empty($order) ? '' : ' ORDER BY ' . expString::escape($order);",
"\n if (strcasecmp($range, 'all') == 0) {",
" $sql .= empty($limit) ? '' : ' LIMIT ' . intval($limitstart) . ',' . intval($limit);",
" return $db->selectExpObjects($this->tablename, $sql, $this->classname);\n } elseif (strcasecmp($range, 'first') == 0) {\n $sql .= ' LIMIT 0,1';\n $records = $db->selectExpObjects($this->tablename, $sql, $this->classname);\n return empty($records) ? null : $records[0];\n } elseif (strcasecmp($range, 'bytitle') == 0) {\n $records = $db->selectExpObjects($this->tablename, \"title='\" . $where . \"' OR sef_url='\" . $where . \"'\", $this->classname);\n return empty($records) ? null : $records[0];\n } elseif (strcasecmp($range, 'count') == 0) {\n return $db->countObjects($this->tablename, $sql);\n } elseif (strcasecmp($range, 'in') == 0) {\n if (!is_array($where)) return array();\n foreach ($where as $id) $records[] = new $this->classname($id);\n return $records;\n } elseif (strcasecmp($range, 'bytag') == 0) {\n $sql = 'SELECT DISTINCT m.id FROM ' . $db->prefix . $this->table . ' m ';\n $sql .= 'JOIN ' . $db->prefix . 'content_expTags ct ';\n $sql .= 'ON m.id = ct.content_id WHERE ct.exptags_id=' . $where . \" AND ct.content_type='\" . $this->classname . \"'\";\n $tag_assocs = $db->selectObjectsBySql($sql);\n $records = array();\n foreach ($tag_assocs as $assoc) {\n $records[] = new $this->classname($assoc->id);\n }\n return $records;\n }\n }",
" public function cartSummary($item) {\n $view = new controllertemplate($this, $this->getForm('cartSummary'));\n $view->assign('product', $this);\n $view->assign('item', $item);",
" // grab all the registrants\n// $message = expUnserialize($item->extra_data);\n// $view->assign('message', $message);",
" return $view->render();\n }",
" function getPrice($orderitem = null) {\n return 1;\n }",
" function addToCart($params, $orderid = null) {\n if (empty($params['quick']) && empty($params['options_shown'])) { //get user input if needed\n $this->displayForm('addToCart', $params);\n return false;\n }",
" $item = new orderitem($params);\n if (empty($params['dollar_amount'])) $params['dollar_amount'] = $this->price;\n $item->products_price = expUtil::currency_to_float($params['dollar_amount']);",
" $product = new product($params['product_id']);\n//\t $item->products_name = $params['dollar_amount'].' '.$this->product_name.' to '.$product->title;\n $item->products_name = $this->product_name . ' to ' . $product->title;",
" // we need to unset the orderitem's ID to force a new entry..other wise we will overwrite any\n // other giftcards in the cart already\n $item->id = null;\n $item->quantity = $this->getDefaultQuantity();\n $item->save();\n return true;\n }",
" public function getSEFURL() {\n if (!empty($this->sef_url)) return $this->sef_url;\n $parent = new product($this->parent_id, false, false);\n return $parent->sef_url;\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\r\n\r\n##################################################\r\n#\r\n# Copyright (c) 2004-2016 OIC Group, Inc.\r\n#\r\n# This file is part of Exponent\r\n#\r\n# Exponent is free software; you can redistribute\r\n# it and/or modify it under the terms of the GNU\r\n# General Public License as published by the Free\r\n# Software Foundation; either version 2 of the\r\n# License, or (at your option) any later version.\r\n#\r\n# GPL: http://www.gnu.org/licenses/gpl.txt\r\n#\r\n##################################################\r\n\r\n/**\r\n * @subpackage Controllers\r\n * @package Modules\r\n */\r\n\r\nclass eventController extends expController {\r\n// public $basemodel_name = 'event';\r\n public $useractions = array(\r\n 'showall' => 'Show Calendar',\r\n );\r\n// public $codequality = 'beta';\r\n\r\n public $remove_configs = array(\r\n 'comments',\r\n 'ealerts',\r\n// 'facebook',\r\n 'files',\r\n 'pagination',\r\n 'rss',\r\n// 'twitter',\r\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)\r\n\r\n static function displayname() {\r\n return \"Events\";\r\n }\r\n\r\n static function description() {\r\n return \"Manage events and schedules, and optionally publish them.\";\r\n }\r\n\r\n static function author() {\r\n return \"Dave Leffler\";\r\n }\r\n\r\n static function isSearchable() {\r\n return true;\r\n }\r\n\r\n function searchName() {\r\n return gt(\"Calendar Event\");\r\n }\r\n\r\n function searchCategory() {\r\n return gt('Event');\r\n }\r\n\r\n /**\r\n * can this module import data?\r\n *\r\n * @return bool\r\n */\r\n public static function canImportData() {\r\n return true;\r\n }\r\n\r\n function showall() {\r\n global $user;\r\n\r\n expHistory::set('viewable', $this->params);\r\n $locsql = $this->aggregateWhereClause();\r\n $time = (isset($this->params['time']) ? $this->params['time'] : time());\r\n assign_to_template(array(\r\n 'time' => $time,\r\n 'daynames' => event::dayNames(),\r\n ));\r\n\r\n $regcolor = !empty($this->config['registrations_color']) ? $this->config['registrations_color'] : null;\r\n\r\n $ed = new eventdate();\r\n $viewtype = 'default';\r\n $viewrange = 'all';\r\n $view = !empty($this->params['view']) ? $this->params['view'] : 'showall';\r\n switch ($view) {\r\n case 'showall_Administration':\r\n $viewtype = \"administration\";\r\n break;\r\n case 'showall_Past Events':\r\n $viewrange = \"past\";\r\n break;\r\n case 'showall_Monthly Summary':\r\n case 'showall_Mini-Calendar':\r\n case 'minical':\r\n $viewtype = \"minical\";\r\n break;\r\n case 'showall_Monthly List':\r\n case 'showall_List':\r\n case 'monthlist':\r\n $viewtype = \"byday\";\r\n $viewrange = \"month\";\r\n break;\r\n case 'showall_Week':\r\n case 'week':\r\n $viewtype = \"byday\";\r\n $viewrange = \"week\";\r\n break;\r\n case 'showall_Day':\r\n case 'day':\r\n $viewtype = \"byday\";\r\n $viewrange = \"day\";\r\n break;\r\n case 'showall_announcement':\r\n case 'showall_Upcoming Events':\r\n case 'showall_Upcoming Events - Headlines':\r\n $viewrange = \"upcoming\";\r\n break;\r\n case 'showall':\r\n case 'month':\r\n $viewtype = \"monthly\";\r\n break;\r\n default :\r\n $view_params = explode('_',$view);\r\n if (!empty($view_params[1])) $viewtype = $view_params[1];\r\n if (!empty($view_params[2])) $viewrange = $view_params[2];\r\n } // end switch $view\r\n\r\n switch ($viewtype) {\r\n case \"minical\":\r\n $monthly = expDateTime::monthlyDaysTimestamp($time);\r\n $info = getdate($time);\r\n $timefirst = mktime(0, 0, 0, $info['mon'], 1, $info['year']);\r\n $now = getdate(time());\r\n $currentday = $now['mday'];\r\n $endofmonth = date('t', $time);\r\n foreach ($monthly as $weekNum => $week) {\r\n foreach ($week as $dayNum => $day) {\r\n if ($dayNum == $now['mday']) {\r\n $currentweek = $weekNum;\r\n }\r\n if ($dayNum <= $endofmonth) {\r\n// $monthly[$weekNum][$dayNum]['number'] = ($monthly[$weekNum][$dayNum]['ts'] != -1) ? $db->countObjects(\"eventdate\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($day['ts']) . \" AND date <= \" . expDateTime::endOfDayTimestamp($day['ts'])) : -1;\r\n $monthly[$weekNum][$dayNum]['number'] = ($monthly[$weekNum][$dayNum]['ts'] != -1) ? $ed->find(\"count\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($day['ts']) . \" AND date <= \" . expDateTime::endOfDayTimestamp($day['ts'])) : -1;\r\n }\r\n }\r\n }\r\n $prevmonth = mktime(0, 0, 0, date(\"m\", $timefirst) - 1, date(\"d\", $timefirst) + 10, date(\"Y\", $timefirst));\r\n $nextmonth = mktime(0, 0, 0, date(\"m\", $timefirst) + 1, date(\"d\", $timefirst) + 10, date(\"Y\", $timefirst));\r\n assign_to_template(array(\r\n \"monthly\" => $monthly,\r\n \"currentweek\" => $currentweek,\r\n \"currentday\" => $currentday,\r\n \"now\" => $timefirst,\r\n \"prevmonth\" => $prevmonth,\r\n \"thismonth\" => $timefirst,\r\n \"nextmonth\" => $nextmonth,\r\n ));\r\n break; // end switch $viewtype minicalendar\r\n case \"byday\": //note aggregates events by groups of days\r\n // Remember this is the code for weekly view and monthly listview\r\n // Test your fixes on both views\r\n // \t\t$startperiod = 0;\r\n //\t\t\t$totaldays = 0;\r\n switch ($viewrange) {\r\n case \"day\":\r\n $startperiod = expDateTime::startOfDayTimestamp($time);\r\n $totaldays = 1;\r\n $next = expDateTime::endOfDayTimestamp($startperiod);\r\n if (!empty($this->config['starttype'])) $startperiod = $time;\r\n $this->params['time'] = $time;\r\n assign_to_template(array(\r\n \"prev_timestamp3\" => strtotime('-3 days', $startperiod),\r\n \"prev_timestamp2\" => strtotime('-2 days', $startperiod),\r\n \"prev_timestamp\" => strtotime('-1 days', $startperiod),\r\n \"next_timestamp\" => strtotime('+1 days', $startperiod),\r\n \"next_timestamp2\" => strtotime('+2 days', $startperiod),\r\n \"next_timestamp3\" => strtotime('+3 days', $startperiod),\r\n 'params' => $this->params\r\n ));\r\n break;\r\n case \"week\":\r\n $startperiod = expDateTime::startOfWeekTimestamp($time);\r\n $totaldays = 7;\r\n $next = strtotime('+7 days', $startperiod);\r\n// $next = expDateTime::endOfWeekTimestamp($startperiod);\r\n if (!empty($this->config['starttype'])) $startperiod = $time;\r\n $this->params['time'] = $time;\r\n assign_to_template(array(\r\n \"prev_timestamp3\" => strtotime('-21 days', $startperiod),\r\n \"prev_timestamp2\" => strtotime('-14 days', $startperiod),\r\n \"prev_timestamp\" => strtotime('-7 days', $startperiod),\r\n \"next_timestamp\" => $next,\r\n \"next_timestamp2\" => strtotime('+14 days', $startperiod),\r\n \"next_timestamp3\" => strtotime('+21 days', $startperiod),\r\n 'params' => $this->params\r\n ));\r\n break;\r\n case \"twoweek\":\r\n $startperiod = expDateTime::startOfWeekTimestamp($time);\r\n $totaldays = 14;\r\n $next = strtotime('+14 days', $startperiod);\r\n if (!empty($this->config['starttype'])) $startperiod = $time;\r\n assign_to_template(array(\r\n \"prev_timestamp3\" => strtotime('-42 days', $startperiod),\r\n \"prev_timestamp2\" => strtotime('-28 days', $startperiod),\r\n \"prev_timestamp\" => strtotime('-14 days', $startperiod),\r\n \"next_timestamp\" => $next,\r\n \"next_timestamp2\" => strtotime('+28 days', $startperiod),\r\n \"next_timestamp3\" => strtotime('+42 days', $startperiod),\r\n ));\r\n break;\r\n case \"month\":\r\n default: // range = month\r\n $startperiod = expDateTime::startOfMonthTimestamp($time);\r\n $totaldays = date('t', $time);\r\n $next = strtotime('+1 months', $startperiod);\r\n// $next = expDateTime::endOfMonthTimestamp($startperiod);\r\n $this->params['time'] = $time;\r\n assign_to_template(array(\r\n \"prev_timestamp3\" => strtotime('-3 months', $startperiod),\r\n \"prev_timestamp2\" => strtotime('-2 months', $startperiod),\r\n \"prev_timestamp\" => strtotime('-1 months', $startperiod),\r\n \"next_timestamp\" => $next,\r\n \"next_timestamp2\" => strtotime('+2 months', $startperiod),\r\n \"next_timestamp3\" => strtotime('+3 months', $startperiod),\r\n 'params' => $this->params\r\n ));\r\n break;\r\n } // end switch $viewrange\r\n\r\n // $days = array();\r\n // added per Ignacio\r\n //\t\t\t$endofmonth = date('t', $time);\r\n $extitems = $this->getExternalEvents($startperiod, $next);\r\n if (!empty($this->config['aggregate_registrations'])) \r\n $regitems = eventregistrationController::getRegEventsForDates($startperiod, $next, $regcolor);\r\n for ($i = 1; $i <= $totaldays; $i++) {\r\n // $info = getdate($time);\r\n // switch ($viewrange) {\r\n // case \"week\":\r\n // $start = mktime(0,0,0,$info['mon'],$i,$info['year']); //FIXME this can't be right?\r\n // break;\r\n // case \"twoweek\":\r\n //// $start = mktime(0,0,0,$info['mon'],$info['mday']+($i-1),$info['year']); //FIXME this can't be right?\r\n // \t\t $start = $startperiod + ($i*86400);\r\n // break;\r\n // default: // range = month\r\n // $start = mktime(0,0,0,$info['mon'],$i,$info['year']);\r\n // }\r\n $start = expDateTime::startOfDayTimestamp($startperiod + ($i * 86400) - 86400);\r\n $edates = $ed->find(\"all\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($start) . \" AND date <= \" . expDateTime::endOfDayTimestamp($start));\r\n// $days[$start] = $this->getEventsForDates($edates, true, isset($this->config['only_featured']) ? true : false);\r\n $days[$start] = $this->event->getEventsForDates($edates, true, isset($this->config['only_featured']) ? true : false);\r\n // for ($j = 0; $j < count($days[$start]); $j++) {\r\n // $thisloc = expCore::makeLocation($this->loc->mod,$this->loc->src,$days[$start][$j]->id);\r\n // $days[$start][$j]->permissions = array(\r\n // \"manage\"=>(expPermissions::check(\"manage\",$thisloc) || expPermissions::check(\"manage\",$this->loc)),\r\n // \"edit\"=>(expPermissions::check(\"edit\",$thisloc) || expPermissions::check(\"edit\",$this->loc)),\r\n // \"delete\"=>(expPermissions::check(\"delete\",$thisloc) || expPermissions::check(\"delete\",$this->loc))\r\n // );\r\n // }\r\n if (!empty($extitems[$start]))\r\n $days[$start] = array_merge($extitems[$start], $days[$start]);\r\n if (!empty($regitems[$start]))\r\n $days[$start] = array_merge($regitems[$start], $days[$start]);\r\n $days[$start] = expSorter::sort(array('array' => $days[$start], 'sortby' => 'eventstart', 'order' => 'ASC'));\r\n }\r\n assign_to_template(array(\r\n \"time\" => $startperiod,\r\n 'days' => $days,\r\n \"now\" => $startperiod,\r\n ));\r\n break; // end switch $viewtype byday\r\n case \"monthly\": //note this is a simply array of events for the requested month\r\n // build a month array of weeks with an array of days\r\n // $monthly = array();\r\n // $counts = array();\r\n $info = getdate($time);\r\n $nowinfo = getdate(time());\r\n if ($info['mon'] != $nowinfo['mon']) $nowinfo['mday'] = -10;\r\n // Grab non-day numbers only (before end of month)\r\n// $week = 0;\r\n $currentweek = -1;\r\n $timefirst = mktime(0, 0, 0, $info['mon'], 1, $info['year']);\r\n $week = (int)date('W',$timefirst);\r\n if ($week >= 52 && $info['mon'] == 1) $week = 1;\r\n $infofirst = getdate($timefirst);\r\n $monthly[$week] = array(); // initialize for non days\r\n $counts[$week] = array();\r\n if (($infofirst['wday'] == 0) && (DISPLAY_START_OF_WEEK == 1)) {\r\n for ($i = -6; $i < (1 - DISPLAY_START_OF_WEEK); $i++) {\r\n $monthly[$week][$i] = array();\r\n $counts[$week][$i] = -1;\r\n }\r\n $weekday = $infofirst['wday'] + 7; // day number in grid. if 7+, switch weeks\r\n } else {\r\n for ($i = 1 - $infofirst['wday']; $i < (1 - DISPLAY_START_OF_WEEK); $i++) {\r\n $monthly[$week][$i] = array();\r\n $counts[$week][$i] = -1;\r\n }\r\n $weekday = $infofirst['wday']; // day number in grid. if 7+, switch weeks\r\n }\r\n // Grab day counts\r\n $endofmonth = date('t', $time);\r\n $extitems = $this->getExternalEvents($timefirst, expDateTime::endOfMonthTimestamp($timefirst));\r\n if (!empty($this->config['aggregate_registrations'])) \r\n $regitems = eventregistrationController::getRegEventsForDates($timefirst, expDateTime::endOfMonthTimestamp($timefirst), $regcolor);\r\n for ($i = 1; $i <= $endofmonth; $i++) {\r\n $start = mktime(0, 0, 0, $info['mon'], $i, $info['year']);\r\n if ($i == $nowinfo['mday']) $currentweek = $week;\r\n $dates = $ed->find(\"all\", $locsql . \" AND (date >= \" . expDateTime::startOfDayTimestamp($start) . \" AND date <= \" . expDateTime::endOfDayTimestamp($start) . \")\");\r\n// $monthly[$week][$i] = $this->getEventsForDates($dates, true, isset($this->config['only_featured']) ? true : false);\r\n $monthly[$week][$i] = $this->event->getEventsForDates($dates, true, isset($this->config['only_featured']) ? true : false);\r\n if (!empty($extitems[$start]))\r\n $monthly[$week][$i] = array_merge($extitems[$start], $monthly[$week][$i]);\r\n if (!empty($regitems[$start]))\r\n $monthly[$week][$i] = array_merge($regitems[$start], $monthly[$week][$i]);\r\n $monthly[$week][$i] = expSorter::sort(array('array' => $monthly[$week][$i], 'sortby' => 'eventstart', 'order' => 'ASC'));\r\n $counts[$week][$i] = count($monthly[$week][$i]);\r\n if ($weekday >= (6 + DISPLAY_START_OF_WEEK)) {\r\n $week++;\r\n $monthly[$week] = array(); // allocate an array for the next week\r\n $counts[$week] = array();\r\n $weekday = DISPLAY_START_OF_WEEK;\r\n } else $weekday++;\r\n }\r\n // Grab non-day numbers only (after end of month)\r\n for ($i = 1; $weekday && $i < (8 + DISPLAY_START_OF_WEEK - $weekday); $i++) {\r\n $monthly[$week][$i + $endofmonth] = array();\r\n $counts[$week][$i + $endofmonth] = -1;\r\n }\r\n $this->params['time'] = $time;\r\n assign_to_template(array(\r\n \"currentweek\" => $currentweek,\r\n \"monthly\" => $monthly,\r\n \"counts\" => $counts,\r\n \"prevmonth3\" => strtotime('-3 months', $timefirst),\r\n \"prevmonth2\" => strtotime('-2 months', $timefirst),\r\n \"prevmonth\" => strtotime('-1 months', $timefirst),\r\n \"nextmonth\" => strtotime('+1 months', $timefirst),\r\n \"nextmonth2\" => strtotime('+2 months', $timefirst),\r\n \"nextmonth3\" => strtotime('+3 months', $timefirst),\r\n \"now\" => $timefirst,\r\n \"today\" => expDateTime::startOfDayTimestamp(time()),\r\n 'params' => $this->params\r\n ));\r\n break; // end switch $viewtype monthly\r\n case \"administration\": //note a simple list of all upcoming events, except no external nor registration events\r\n // Check perms and return if cant view\r\n if (!$user) return;\r\n $continue = (expPermissions::check(\"manage\", $this->loc) ||\r\n expPermissions::check(\"create\", $this->loc) ||\r\n expPermissions::check(\"edit\", $this->loc) ||\r\n expPermissions::check(\"delete\", $this->loc)\r\n ) ? 1 : 0;\r\n $dates = $ed->find(\"all\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp(time()));\r\n// $items = $this->getEventsForDates($dates);\r\n $items = $this->event->getEventsForDates($dates);\r\n // if (!$continue) {\r\n // foreach ($items as $i) {\r\n // $iloc = expCore::makeLocation($this->loc->mod,$this->loc->src,$i->id);\r\n // if (expPermissions::check(\"edit\",$iloc) ||\r\n // expPermissions::check(\"delete\",$iloc) ||\r\n // expPermissions::check(\"manage\",$iloc)\r\n // ) {\r\n // $continue = true;\r\n // }\r\n // }\r\n // }\r\n if (!$continue) return;\r\n // for ($i = 0; $i < count($items); $i++) {\r\n // $thisloc = expCore::makeLocation($this->loc->mod,$this->loc->src,$items[$i]->id);\r\n // //\t\t\t\tif ($user && $items[$i]->poster == $user->id) $canviewapproval = 1;\r\n // $items[$i]->permissions = array(\r\n // \"manage\"=>(expPermissions::check(\"manage\",$thisloc) || expPermissions::check(\"manage\",$this->loc)),\r\n // \"edit\"=>(expPermissions::check(\"edit\",$thisloc) || expPermissions::check(\"edit\",$this->loc)),\r\n // \"delete\"=>(expPermissions::check(\"delete\",$thisloc) || expPermissions::check(\"delete\",$this->loc))\r\n // );\r\n // }\r\n $items = expSorter::sort(array('array' => $items, 'sortby' => 'eventstart', 'order' => 'ASC'));\r\n assign_to_template(array(\r\n 'items' => $items,\r\n ));\r\n break; // end switch $viewtype administration\r\n case \"default\": //note a simple list of events based on $viewrange\r\n default;\r\n // $items = null;\r\n // $dates = null;\r\n $day = expDateTime::startOfDayTimestamp(time());\r\n $sort_asc = true; // For the getEventsForDates call\r\n // $moreevents = false;\r\n switch ($viewrange) {\r\n case \"upcoming\": // events in the future\r\n if (!empty($this->config['enable_ical']) && !empty($this->config['rss_limit']) && $this->config['rss_limit'] > 0) {\r\n $eventlimit = \" AND date <= \" . ($day + ($this->config['rss_limit'] * 86400));\r\n } else {\r\n $eventlimit = \"\";\r\n }\r\n $dates = $ed->find(\"all\", $locsql . \" AND date >= \" . $day . $eventlimit . \" ORDER BY date ASC \");\r\n $begin = $day;\r\n $end = null;\r\n //\t\t\t\t\t$moreevents = count($dates) < $db->countObjects(\"eventdate\",$locsql.\" AND date >= $day\");\r\n break;\r\n case \"past\": // events in the past\r\n $dates = $ed->find(\"all\", $locsql . \" AND date < $day ORDER BY date DESC \");\r\n //\t\t\t\t\t$moreevents = count($dates) < $db->countObjects(\"eventdate\",$locsql.\" AND date < $day\");\r\n $sort_asc = false;\r\n $begin = null;\r\n $end = $day;\r\n break;\r\n case \"today\": // events occuring today\r\n $dates = $ed->find(\"all\", $locsql . \" AND (date >= \" . expDateTime::startOfDayTimestamp($day) . \" AND date <= \" . expDateTime::endOfDayTimestamp($day) . \")\");\r\n $begin = $day;\r\n $end = expDateTime::endOfDayTimestamp($day);\r\n break;\r\n case \"day\": // events for a specific day (same as byday day?)\r\n $dates = $ed->find(\"all\", $locsql . \" AND (date >= \" . expDateTime::startOfDayTimestamp($time) . \" AND date <= \" . expDateTime::endOfDayTimestamp($time) . \")\");\r\n $begin = expDateTime::startOfDayTimestamp($time);\r\n $end = expDateTime::endOfDayTimestamp($time);\r\n break;\r\n case \"next\": // future events\r\n $dates = array($ed->find(\"all\", $locsql . \" AND date >= $time\"));\r\n $begin = expDateTime::startOfDayTimestamp($time);\r\n $end = null;\r\n break;\r\n case \"month\": // events for a specific month (same as monthly?)\r\n// $dates = $ed->find(\"all\", $locsql . \" AND (date >= \" . expDateTime::startOfMonthTimestamp(time()) . \" AND date <= \" . expDateTime::endOfMonthTimestamp(time()) . \")\");\r\n $dates = $ed->find(\"all\", $locsql . \" AND (date >= \" . expDateTime::startOfMonthTimestamp($time) . \" AND date <= \" . expDateTime::endOfMonthTimestamp($time) . \")\");\r\n $begin = expDateTime::startOfMonthTimestamp($time);\r\n $end = expDateTime::endOfMonthTimestamp($time);\r\n break;\r\n case \"all\": // all events\r\n default;\r\n $dates = $ed->find(\"all\", $locsql);\r\n $begin = null;\r\n $end = null;\r\n }\r\n// $items = $this->getEventsForDates($dates, $sort_asc, isset($this->config['only_featured']) ? true : false, true);\r\n $items = $this->event->getEventsForDates($dates, $sort_asc, isset($this->config['only_featured']) ? true : false, true);\r\n if ($viewrange != 'past') {\r\n $extitems = $this->getExternalEvents($begin, $end);\r\n // we need to flatten these down to simple array of events\r\n $extitem = array();\r\n foreach ($extitems as $days) {\r\n foreach ($days as $event) {\r\n if (empty($event->eventdate->date) || ($viewrange == 'upcoming' && $event->eventdate->date < time()))\r\n break;\r\n if (empty($event->eventstart))\r\n $event->eventstart = $event->eventdate->date;\r\n $extitem[] = $event;\r\n }\r\n }\r\n $items = array_merge($items, $extitem);\r\n \r\n if (!empty($this->config['aggregate_registrations']))\r\n $regitems = eventregistrationController::getRegEventsForDates($begin, $end, $regcolor);\r\n // we need to flatten these down to simple array of events\r\n $regitem = array();\r\n if (!empty($regitems)) foreach ($regitems as $days) {\r\n foreach ($days as $value) {\r\n $regitem[] = $value;\r\n }\r\n }\r\n $items = array_merge($items, $regitem);\r\n\r\n // remove today's events that have already ended\r\n if ($viewtype == 'default' && $viewrange == 'upcoming') {\r\n foreach ($items as $key=>$item) {\r\n if (!$item->is_allday && $item->eventend < time()) {\r\n //fixme we've left events ending earlier in the day, but already cancelled out tomorrow's event\r\n unset($items[$key]);\r\n } else {\r\n break; // they are chronological so we can end\r\n }\r\n }\r\n }\r\n }\r\n $items = expSorter::sort(array('array' => $items, 'sortby' => 'eventstart', 'order' => 'ASC'));\r\n // Upcoming events can be configured to show a specific number of events.\r\n // The previous call gets all events in the future from today\r\n // If configured, cut the array to the configured number of events\r\n //\t\t\tif ($template->viewconfig['num_events']) {\r\n //\t\t\t\tswitch ($viewrange) {\r\n //\t\t\t\t\tcase \"upcoming\":\r\n //\t\t\t\t\tcase \"past\":\r\n //\t\t\t\t\t\t$moreevents = $template->viewconfig['num_events'] < count($items);\r\n //\t\t\t\t\t\tbreak;\r\n //\t\t\t\t}\r\n //\t\t\t\t$items = array_slice($items, 0, $template->viewconfig['num_events']);\r\n //\t\t\t}\r\n // for ($i = 0; $i < count($items); $i++) {\r\n // $thisloc = expCore::makeLocation($this->loc->mod,$this->loc->src,$items[$i]->id);\r\n // $items[$i]->permissions = array(\r\n // 'manage'=>(expPermissions::check('manage',$thisloc) || expPermissions::check('manage',$this->loc)),\r\n // 'edit'=>(expPermissions::check('edit',$thisloc) || expPermissions::check('edit',$this->loc)),\r\n // 'delete'=>(expPermissions::check('delete',$thisloc) || expPermissions::check('delete',$this->loc))\r\n // );\r\n // }\r\n assign_to_template(array(\r\n 'items' => $items,\r\n \"now\" => $day,\r\n ));\r\n }\r\n }\r\n\r\n /**\r\n * default view for individual item\r\n */\r\n function show() {\r\n expHistory::set('viewable', $this->params);\r\n if (!empty($this->params['date_id'])) { // specific event instance\r\n $eventdate = new eventdate($this->params['date_id']);\r\n $eventdate->event = new event($eventdate->event_id);\r\n } else { // we'll default to the first event of this series\r\n $event = new event($this->params['id']);\r\n $eventdate = new eventdate($event->eventdate[0]->id);\r\n }\r\n if (empty($eventdate->id))\r\n redirect_to(array('controller'=>'notfound','action'=>'page_not_found','title'=>'event'));\r\n\r\n if (!empty($eventdate->event->feedback_form) && $eventdate->event->feedback_form != 'Disallow Feedback') {\r\n assign_to_template(array(\r\n 'feedback_form' => $eventdate->event->feedback_form,\r\n ));\r\n }\r\n\r\n assign_to_template(array(\r\n 'event' => $eventdate,\r\n ));\r\n }\r\n\r\n function edit() {\r\n global $template;\r\n\r\n parent::edit();\r\n $allforms = array();\r\n $allforms[\"\"] = gt('Disallow Feedback');\r\n // calculate which event date is the one being edited\r\n $event_key = 0;\r\n foreach ($template->tpl->tpl_vars['record']->value->eventdate as $key=>$d) {\r\n \t if ($d->id == $this->params['date_id']) $event_key = $key;\r\n \t}\r\n\r\n assign_to_template(array(\r\n 'allforms' => array_merge($allforms, expTemplate::buildNameList(\"forms\", \"event/email\", \"tpl\", \"[!_]*\")),\r\n 'checked_date' => !empty($this->params['date_id']) ? $this->params['date_id'] : null,\r\n 'event_key' => $event_key,\r\n ));\r\n }\r\n\r\n /**\r\n * Delete a recurring event by asking for which event dates to delete\r\n *\r\n */\r\n function delete_recurring() {\r\n $item = $this->event->find('first', 'id=' . $this->params['id']);\r\n if ($item->is_recurring == 1) { // need to give user options\r\n expHistory::set('editable', $this->params);\r\n assign_to_template(array(\r\n 'checked_date' => $this->params['date_id'],\r\n 'event' => $item,\r\n ));\r\n } else { // Process a regular delete\r\n $item->delete();\r\n }\r\n }\r\n\r\n /**\r\n * Delete selected event dates for a recurring event and event if all event dates deleted\r\n *\r\n */\r\n function delete_selected() {\r\n $item = $this->event->find('first', 'id=' . $this->params['id']);\r\n if ($item && $item->is_recurring == 1) {\r\n $event_remaining = false;\r\n $eventdates = $item->eventdate[0]->find('all', 'event_id=' . $item->id);\r\n foreach ($eventdates as $ed) {\r\n if (array_key_exists($ed->id, $this->params['dates'])) {\r\n $ed->delete();\r\n } else {\r\n $event_remaining = true;\r\n }\r\n }\r\n if (!$event_remaining) {\r\n $item->delete(); // model will also ensure we delete all event dates\r\n }\r\n expHistory::back();\r\n } else {\r\n notfoundController::handle_not_found();\r\n }\r\n }\r\n\r\n function delete_all_past() {\r\n $locsql = $this->aggregateWhereClause();\r\n $ed = new eventdate();\r\n $dates = $ed->find(\"all\", $locsql . \" AND date < \" . strtotime('-1 months', time()));\r\n foreach ($dates as $date) {\r\n $date->delete(); // event automatically deleted if all assoc eventdates are deleted\r\n }\r\n expHistory::back();\r\n }\r\n\r\n /**\r\n \t * get the metainfo for this module\r\n \t * @return array\r\n \t */\r\n \tfunction metainfo() {\r\n global $router;\r\n\r\n $action = $router->params['action'];\r\n $metainfo = array('title' => '', 'keywords' => '', 'description' => '', 'canonical'=> '', 'noindex' => false, 'nofollow' => false);\r\n // look for event date_id which expController::metainfo won't detect\r\n// if (!empty($router->params['action']) && $router->params['action'] == 'show' && !isset($router->params['id']) && isset($router->params['date_id'])) {\r\n switch ($action) {\r\n case 'show':\r\n if (!isset($router->params['id']) && isset($router->params['date_id'])) {\r\n // look up the record.\r\n $object = new eventdate((int)$router->params['date_id']);\r\n // set the meta info\r\n if (!empty($object)) {\r\n if (!empty($object->event->body)) {\r\n $desc = str_replace('\"',\"'\",expString::summarize($object->event->body,'html','para'));\r\n } else {\r\n $desc = SITE_DESCRIPTION;\r\n }\r\n if (!empty($object->expTag)) {\r\n $keyw = '';\r\n foreach ($object->expTag as $tag) {\r\n if (!empty($keyw)) $keyw .= ', ';\r\n $keyw .= $tag->title;\r\n }\r\n } else {\r\n $keyw = SITE_KEYWORDS;\r\n }\r\n $metainfo['title'] = empty($object->event->meta_title) ? $object->event->title : $object->event->meta_title;\r\n $metainfo['keywords'] = empty($object->event->meta_keywords) ? $keyw : $object->event->meta_keywords;\r\n $metainfo['description'] = empty($object->event->meta_description) ? $desc : $object->event->meta_description;\r\n $metainfo['canonical'] = empty($object->event->canonical) ? $router->plainPath() : $object->event->canonical;\r\n $metainfo['noindex'] = empty($object->event->meta_noindex) ? false : $object->event->meta_noindex;\r\n $metainfo['nofollow'] = empty($object->event->meta_nofollow) ? false : $object->event->meta_nofollow;\r\n return $metainfo;\r\n break;\r\n }\r\n }\r\n default:\r\n return parent::metainfo();\r\n }\r\n }\r\n\r\n /**\r\n * function to build a string to pull in all events within requested date range\r\n */\r\n function build_daterange_sql($timestamp, $endtimestamp=null, $field='date', $multiday=false) {\r\n if (empty($endtimestamp)) {\r\n $date_sql = \"((\".$field.\" >= \" . expDateTime::startOfDayTimestamp($timestamp) . \" AND \".$field.\" <= \" . expDateTime::endOfDayTimestamp($timestamp) . \")\";\r\n } else {\r\n $date_sql = \"((\".$field.\" >= \" . expDateTime::startOfDayTimestamp($timestamp) . \" AND \".$field.\" <= \" . expDateTime::endOfDayTimestamp($endtimestamp) . \")\";\r\n }\r\n if ($multiday)\r\n $date_sql .= \" OR (\" . expDateTime::startOfDayTimestamp($timestamp) . \" BETWEEN \".$field.\" AND dateFinished)\";\r\n $date_sql .= \")\";\r\n return $date_sql;\r\n }\r\n\r\n function send_feedback() {\r\n $success = false;\r\n if (isset($this->params['id'])) {\r\n $ed = new eventdate($this->params['id']);\r\n// $email_addrs = array();\r\n if ($ed->event->feedback_email != '') {\r\n $msgtemplate = expTemplate::get_template_for_action($this, 'email/_' . $this->params['formname'], $this->loc);\r\n $msgtemplate->assign('params', $this->params);\r\n $msgtemplate->assign('event', $ed);\r\n $email_addrs = explode(',', $ed->event->feedback_email);\r\n //This is an easy way to remove duplicates\r\n $email_addrs = array_flip(array_flip($email_addrs));\r\n $email_addrs = array_map('trim', $email_addrs);\r\n $mail = new expMail();\r\n $success += $mail->quickSend(array(\r\n \"text_message\" => $msgtemplate->render(),\r\n 'to' => $email_addrs,\r\n 'from' => !empty($this->params['email']) ? $this->params['email'] : trim(SMTP_FROMADDRESS),\r\n 'subject' => $this->params['subject'],\r\n ));\r\n }\r\n }\r\n\r\n if ($success) {\r\n flashAndFlow('message', gt('Your feedback was successfully sent.'));\r\n } else {\r\n flashAndFlow('error', gt('We could not send your feedback. Please contact your administrator.'));\r\n }\r\n }\r\n\r\n function ical() {\r\n if (isset($this->params['date_id']) || isset($this->params['title']) || isset($this->params['src'])) {\r\n $cfg = new expConfig();\r\n $configs = $cfg->find('all', \"location_data LIKE '%event%'\"); // get all event module configs\r\n foreach ($configs as $config) {\r\n $loc = expUnserialize($config->location_data);\r\n if (!empty($this->params['title'])) {\r\n if ($this->params['title'] == $config->config['feed_sef_url']) {\r\n $this->config = $config->config;\r\n break;\r\n }\r\n } elseif (!empty($this->params['src'])) {\r\n if ($this->params['src'] == $loc->src) {\r\n $this->config = $config->config;\r\n break;\r\n }\r\n }\r\n }\r\n $this->loc = $loc;\r\n\r\n if ($this->config['enable_ical']) {\r\n $ed = new eventdate();\r\n if (isset($this->params['date_id'])) { // get single specific event only\r\n// $dates = array($db->selectObject(\"eventdate\",\"id=\".$this->params['date_id']));\r\n $dates = $ed->find('first', \"id=\" . $this->params['date_id']);\r\n $Filename = \"Event-\" . $this->params['date_id'];\r\n } else {\r\n $locsql = $this->aggregateWhereClause();\r\n\r\n $day = expDateTime::startOfDayTimestamp(time());\r\n if (!empty($this->config['enable_ical']) && isset($this->config['rss_limit']) && ($this->config['rss_limit'] > 0)) {\r\n $rsslimit = \" AND date <= \" . ($day + ($this->config['rss_limit'] * 86400));\r\n } else {\r\n $rsslimit = \"\";\r\n }\r\n\r\n if (isset($this->params['time'])) {\r\n $time = $this->params['time']; // get current month's events\r\n// $dates = $db->selectObjects(\"eventdate\",$locsql.\" AND (date >= \".expDateTime::startOfMonthTimestamp($time).\" AND date <= \".expDateTime::endOfMonthTimestamp($time).\")\");\r\n $dates = $ed->find('all', $locsql . \" AND (date >= \" . expDateTime::startOfMonthTimestamp($time) . \" AND date <= \" . expDateTime::endOfMonthTimestamp($time) . \")\");\r\n } else {\r\n $time = date('U', strtotime(\"midnight -1 month\", time())); // previous month also\r\n// $dates = $db->selectObjects(\"eventdate\",$locsql.\" AND date >= \".expDateTime::startOfDayTimestamp($time).$rsslimit);\r\n $dates = $ed->find('all', $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($time) . $rsslimit);\r\n }\r\n //\t\t\t$title = $db->selectValue('container', 'title', \"internal='\".serialize($loc).\"'\");\r\n $title = $this->config['feed_title'];\r\n $Filename = preg_replace('/\\s+/', '', $title); // without whitespace\r\n }\r\n\r\n if (!function_exists(\"quoted_printable_encode\")) { // function added in php v5.3.0\r\n function quoted_printable_encode($input, $line_max = 75) {\r\n $hex = array('0', '1', '2', '3', '4', '5', '6', '7',\r\n '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');\r\n $lines = preg_split(\"/(?:\\r\\n|\\r|\\n)/\", $input);\r\n $linebreak = \"=0D=0A=\\r\\n\";\r\n /* the linebreak also counts as characters in the mime_qp_long_line\r\n * rule of spam-assassin */\r\n $line_max = $line_max - strlen($linebreak);\r\n $escape = \"=\";\r\n $output = \"\";\r\n $cur_conv_line = \"\";\r\n $length = 0;\r\n $whitespace_pos = 0;\r\n $addtl_chars = 0;\r\n\r\n // iterate lines\r\n for ($j = 0, $jMax = count($lines); $j < $jMax; $j++) {\r\n $line = $lines[$j];\r\n $linlen = strlen($line);\r\n\r\n // iterate chars\r\n for ($i = 0; $i < $linlen; $i++) {\r\n $c = substr($line, $i, 1);\r\n $dec = ord($c);\r\n\r\n $length++;\r\n\r\n if ($dec == 32) {\r\n // space occurring at end of line, need to encode\r\n if (($i == ($linlen - 1))) {\r\n $c = \"=20\";\r\n $length += 2;\r\n }\r\n\r\n $addtl_chars = 0;\r\n $whitespace_pos = $i;\r\n } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) {\r\n $h2 = floor($dec / 16);\r\n $h1 = floor($dec % 16);\r\n $c = $escape . $hex[\"$h2\"] . $hex[\"$h1\"];\r\n $length += 2;\r\n $addtl_chars += 2;\r\n }\r\n\r\n // length for wordwrap exceeded, get a newline into the text\r\n if ($length >= $line_max) {\r\n $cur_conv_line .= $c;\r\n\r\n // read only up to the whitespace for the current line\r\n $whitesp_diff = $i - $whitespace_pos + $addtl_chars;\r\n\r\n /* the text after the whitespace will have to be read\r\n * again ( + any additional characters that came into\r\n * existence as a result of the encoding process after the whitespace)\r\n *\r\n * Also, do not start at 0, if there was *no* whitespace in\r\n * the whole line */\r\n if (($i + $addtl_chars) > $whitesp_diff) {\r\n $output .= substr($cur_conv_line, 0, (strlen($cur_conv_line) -\r\n $whitesp_diff)) . $linebreak;\r\n $i = $i - $whitesp_diff + $addtl_chars;\r\n } else {\r\n $output .= $cur_conv_line . $linebreak;\r\n }\r\n\r\n $cur_conv_line = \"\";\r\n $length = 0;\r\n $whitespace_pos = 0;\r\n } else {\r\n // length for wordwrap not reached, continue reading\r\n $cur_conv_line .= $c;\r\n }\r\n } // end of for\r\n\r\n $length = 0;\r\n $whitespace_pos = 0;\r\n $output .= $cur_conv_line;\r\n $cur_conv_line = \"\";\r\n\r\n if ($j <= count($lines) - 1) {\r\n $output .= $linebreak;\r\n }\r\n } // end for\r\n\r\n return trim($output);\r\n } // end quoted_printable_encode\r\n }\r\n\r\n $tz = DISPLAY_DEFAULT_TIMEZONE;\r\n $msg = \"BEGIN:VCALENDAR\\n\";\r\n $msg .= \"VERSION:2.0\\n\"; // version for iCalendar files vs vCalendar files\r\n $msg .= \"CALSCALE:GREGORIAN\\n\";\r\n $msg .= \"METHOD: PUBLISH\\n\";\r\n $msg .= \"PRODID:<-//ExponentCMS//EN>\\n\";\r\n if (isset($this->config['rss_cachetime']) && ($this->config['rss_cachetime'] > 0)) {\r\n $msg .= \"X-PUBLISHED-TTL:PT\" . $this->config['rss_cachetime'] . \"M\\n\";\r\n }\r\n $msg .= \"X-WR-CALNAME:$Filename\\n\";\r\n\r\n// $items = $this->getEventsForDates($dates);\r\n $items = $this->event->getEventsForDates($dates);\r\n\r\n for ($i = 0, $iMax = count($items); $i < $iMax; $i++) {\r\n\r\n // Convert events stored in local time to GMT\r\n $eventstart = new DateTime(date('r', $items[$i]->eventstart), new DateTimeZone($tz));\r\n $eventstart->setTimezone(new DateTimeZone('GMT'));\r\n $eventend = new DateTime(date('r', $items[$i]->eventend), new DateTimeZone($tz));\r\n $eventend->setTimezone(new DateTimeZone('GMT'));\r\n if ($items[$i]->is_allday) {\r\n $dtstart = \"DTSTART;VALUE=DATE:\" . date(\"Ymd\", $items[$i]->eventstart) . \"\\n\";\r\n $dtend = \"DTEND;VALUE=DATE:\" . date(\"Ymd\", strtotime(\"midnight +1 day\", $items[$i]->eventstart)) . \"\\n\";\r\n } else {\r\n $dtstart = \"DTSTART;VALUE=DATE-TIME:\" . $eventstart->format(\"Ymd\\THi00\") . \"Z\\n\";\r\n if ($items[$i]->eventend) {\r\n $dtend = \"DTEND;VALUE=DATE-TIME:\" . $eventend->format(\"Ymd\\THi00\") . \"Z\\n\";\r\n } else {\r\n $dtend = \"DTEND;VALUE=DATE-TIME:\" . $eventstart->format(\"Ymd\\THi00\") . \"Z\\n\";\r\n }\r\n }\r\n\r\n $body = trim(strip_tags(str_replace(array(\"<br />\", \"<br>\", \"br/>\", \"</p>\"), \"\\n\", $items[$i]->body)));\r\n if ($items[$i]->is_cancelled) $body = gt('This Event Has Been Cancelled') . ' - ' . $body;\r\n $body = str_replace(array(\"\\r\"), \"\", $body);\r\n $body = str_replace(array(\" \"), \" \", $body);\r\n $body = expString::convertSmartQuotes($body);\r\n if (!isset($this->params['style'])) {\r\n // it's going to Outlook so remove all formatting from body text\r\n $body = quoted_printable_encode($body);\r\n } elseif ($this->params['style'] == \"g\") {\r\n // It's going to Google (doesn't like quoted-printable, but likes html breaks)\r\n $body = str_replace(array(\"\\n\"), \"<br />\", $body);\r\n } else {\r\n // It's going elsewhere (doesn't like quoted-printable)\r\n $body = str_replace(array(\"\\n\"), \" -- \", $body);\r\n }\r\n $title = $items[$i]->title;\r\n\r\n $msg .= \"BEGIN:VEVENT\\n\";\r\n $msg .= $dtstart . $dtend;\r\n $msg .= \"UID:\" . $items[$i]->date_id . \"\\n\";\r\n $msg .= \"DTSTAMP:\" . date(\"Ymd\\THis\", time()) . \"Z\\n\";\r\n if ($title) {\r\n $msg .= \"SUMMARY:$title\\n\";\r\n }\r\n if ($body) {\r\n $msg .= \"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:\" . $body . \"\\n\";\r\n }\r\n //\tif($link_url) { $msg .= \"URL: $link_url\\n\";}\r\n if (!empty($this->config['usecategories'])) {\r\n if (!empty($items[$i]->expCat[0]->title)) {\r\n $msg .= \"CATEGORIES:\".$items[$i]->expCat[0]->title.\"\\n\";\r\n } else {\r\n $msg .= \"CATEGORIES:\".$this->config['uncat'].\"\\n\";\r\n }\r\n }\r\n $msg .= \"END:VEVENT\\n\";\r\n }\r\n $msg .= \"END:VCALENDAR\";\r\n\r\n // Kick it out as a file download\r\n ob_end_clean();\r\n\r\n //\t$mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octet-stream;' : \"text/x-vCalendar\";\r\n //\t$mime_type = \"text/x-vCalendar\";\r\n $mime_type = 'text/Calendar';\r\n header('Content-Type: ' . $mime_type);\r\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\r\n header('Content-length: ' . strlen($msg));\r\n header('Content-Transfer-Encoding: binary');\r\n header('Content-Encoding:');\r\n //\theader(\"Content-Disposition: inline; filename=\".$Filename.\".ics\");\r\n header('Content-Disposition: attachment; filename=\"' . $Filename . '.ics\"');\r\n // IE need specific headers\r\n //\tif (EXPONENT_USER_BROWSER == 'IE') {\r\n header('Cache-Control: no-cache, must-revalidate');\r\n header('Pragma: public');\r\n header('Vary: User-Agent');\r\n //\t} else {\r\n header('Pragma: no-cache');\r\n //\t}\r\n echo $msg;\r\n exit();\r\n } else {\r\n notfoundController::handle_not_found();\r\n }\r\n } else {\r\n notfoundController::handle_not_found();\r\n }\r\n }\r\n\r\n function send_reminders() {\r\n if (isset($this->params['title']) || isset($this->params['src'])) {\r\n $cfg = new expConfig();\r\n $configs = $cfg->find('all', \"location_data LIKE '%event%'\"); // get all event module configs\r\n foreach ($configs as $config) {\r\n $loc = expUnserialize($config->location_data);\r\n if (!empty($this->params['title'])) {\r\n if ($this->params['title'] == $config->config['feed_sef_url']) {\r\n $this->config = $config->config;\r\n break;\r\n }\r\n } elseif (!empty($this->params['src'])) {\r\n if ($this->params['src'] == $loc->src) {\r\n $this->config = $config->config;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (empty($this->config['reminder_active'])) {\r\n notfoundController::handle_not_found();\r\n return;\r\n }\r\n if (!empty($this->config['reminder_code']) && (empty($this->params['code']) || ($this->params['code'] != $this->config['reminder_code']))) {\r\n notfoundController::handle_not_authorized();\r\n return;\r\n }\r\n\r\n $this->loc = $loc;\r\n $locsql = $this->aggregateWhereClause();\r\n\r\n $view = (isset($this->params['view']) ? $this->params['view'] : '');\r\n if ($view == \"\") {\r\n $view = \"send_reminders\"; // default reminder view\r\n }\r\n\r\n// $template = expTemplate::get_template_for_action($this, $view, $this->loc);\r\n global $template;\r\n\r\n $title = $this->config['feed_title'];\r\n $template->assign('moduletitle', $title);\r\n\r\n $time = (isset($this->params['time']) ? $this->params['time'] : time());\r\n $time = (int)$time;\r\n\r\n $template->assign(\"time\", $time);\r\n\r\n $startperiod = expDateTime::startOfDayTimestamp($time);\r\n if (!empty($this->params['days'])) {\r\n $totaldays = $this->params['days'];\r\n } else {\r\n $totaldays = 7; // default 7 days of events\r\n }\r\n\r\n $count = 0;\r\n $info = getdate($startperiod);\r\n for ($i = 0; $i < $totaldays; $i++) {\r\n $start = mktime(0, 0, 0, $info['mon'], $info['mday'] + $i, $info['year']);\r\n $ed = new eventdate();\r\n $edates = $ed->find('all', $locsql . \" AND (date >= \" . expDateTime::startOfDayTimestamp($start) . \" AND date <= \" . expDateTime::endOfDayTimestamp($start) . \")\");\r\n $days[$start] = array();\r\n// $days[$start] = $this->getEventsForDates($edates);\r\n $days[$start] = $this->event->getEventsForDates($edates);\r\n for ($j = 0, $jMax = count($days[$start]); $j < $jMax; $j++) {\r\n $thisloc = expCore::makeLocation($loc->mod, $loc->src, $days[$start][$j]->id);\r\n $days[$start][$j]->permissions = array(\r\n \"manage\" => (expPermissions::check(\"manage\", $thisloc) || expPermissions::check(\"manage\", $loc)),\r\n \"edit\" => (expPermissions::check(\"edit\", $thisloc) || expPermissions::check(\"edit\", $loc)),\r\n \"delete\" => (expPermissions::check(\"delete\", $thisloc) || expPermissions::check(\"delete\", $loc))\r\n );\r\n }\r\n $counts[$start] = count($days[$start]);\r\n $count += count($days[$start]);\r\n $days[$start] = expSorter::sort(array('array' => $days[$start], 'sortby' => 'eventstart', 'order' => 'ASC'));\r\n }\r\n $template->assign(\"days\", $days);\r\n $template->assign(\"counts\", $counts);\r\n $template->assign(\"start\", $startperiod);\r\n $template->assign(\"totaldays\", $totaldays);\r\n\r\n if ($count == 0) {\r\n flash('error',gt('No Events to Send!'));\r\n echo show_msg_queue('error');\r\n return;\r\n }\r\n\r\n if (bs3())\r\n $css = file_get_contents(BASE . \"external/bootstrap3/css/bootstrap.css\");\r\n elseif (bs2())\r\n $css = file_get_contents(BASE . \"external/bootstrap/css/bootstrap.css\");\r\n else\r\n $css = file_get_contents(BASE . \"framework/modules/events/assets/css/calendar.css\");\r\n $template->assign(\"css\", $css);\r\n $template->assign(\"config\", $this->config);\r\n $template->assign(\"src\", $loc->src);\r\n\r\n // format and send email\r\n $subject = $this->config['email_title_reminder'] . \" - $title\";\r\n $from_addr = $this->config['email_address_reminder'];\r\n $headers = array(\r\n \"From\" => $from = $this->config['email_from_reminder'],\r\n \"Reply-to\" => $reply = $this->config['email_reply_reminder']\r\n );\r\n\r\n // set up the html message\r\n $template->assign(\"showdetail\", !empty($this->config['email_showdetail']));\r\n $htmlmsg = $template->render();\r\n\r\n // now the same thing for the text message\r\n $msg = preg_replace('/(<script[^>]*>.+?<\\/script>|<style[^>]*>.+?<\\/style>)/s', '', $htmlmsg); // remove any script or style blocks\r\n $msg = trim(strip_tags(str_replace(array(\"<br />\", \"<br>\", \"br/>\"), \"\\n\", $msg)));\r\n\r\n // Saved. do notifs\r\n $emails = array();\r\n if (!empty($this->config['user_list'])) foreach ($this->config['user_list'] as $c) {\r\n $u = user::getUserById($c);\r\n $emails[$u->email] = trim(user::getUserAttribution($u->id));\r\n }\r\n if (!empty($this->config['group_list'])) foreach ($this->config['group_list'] as $c) {\r\n $grpusers = group::getUsersInGroup($c);\r\n foreach ($grpusers as $u) {\r\n $emails[$u->email] = trim(user::getUserAttribution($u->id));\r\n }\r\n }\r\n if (!empty($this->config['address_list'])) foreach ($this->config['address_list'] as $c) {\r\n $emails[] = $c;\r\n }\r\n if (empty($emails)) {\r\n flash('error',gt('No One to Send Reminders to!'));\r\n echo show_msg_queue('error');\r\n return;\r\n }\r\n\r\n $emails = array_flip(array_flip($emails));\r\n $emails = array_map('trim', $emails);\r\n// $headers = array(\r\n// \"MIME-Version\" => \"1.0\",\r\n// \"Content-type\" => \"text/html; charset=\" . LANG_CHARSET\r\n// );\r\n $mail = new expMail();\r\n $mail->quickSend(array(\r\n// 'headers' => $headers,\r\n 'html_message' => $htmlmsg,\r\n \"text_message\" => $msg,\r\n 'to' => $emails,\r\n 'from' => array(trim($this->config['email_address_reminder']) => $this->config['email_from_reminder']),\r\n 'subject' => $subject,\r\n ));\r\n\r\n flash('message',gt('The following reminder was sent via email'));\r\n echo show_msg_queue();\r\n// echo($htmlmsg);\r\n } else {\r\n flash('error',gt('No Calendar Selected!'));\r\n echo show_msg_queue('error');\r\n }\r\n }\r\n\r\n /** @deprecated moved to event model\r\n * @param $edates\r\n * @param bool $sort_asc\r\n * @param bool $featuredonly\r\n * @param bool $condense\r\n * @return array\r\n */\r\n function getEventsForDates($edates, $sort_asc = true, $featuredonly = false, $condense = false) {\r\n global $eventid;\r\n\r\n $events = array();\r\n $featuresql = \"\";\r\n if ($featuredonly) $featuresql = \" AND is_featured=1\";\r\n foreach ($edates as $edate) {\r\n $evs = $this->event->find('all', \"id=\" . $edate->event_id . $featuresql);\r\n foreach ($evs as $key=>$event) {\r\n if ($condense) {\r\n $eventid = $event->id;\r\n $multiday_event = array_filter($events, create_function('$event', 'global $eventid; return $event->id === $eventid;'));\r\n if (!empty($multiday_event)) {\r\n unset($evs[$key]);\r\n continue;\r\n }\r\n }\r\n $evs[$key]->eventstart += $edate->date;\r\n $evs[$key]->eventend += $edate->date;\r\n $evs[$key]->date_id = $edate->id;\r\n if (!empty($event->expCat)) {\r\n $catcolor = empty($event->expCat[0]->color) ? null : trim($event->expCat[0]->color);\r\n// if (substr($catcolor,0,1)=='#') $catcolor = '\" style=\"color:'.$catcolor.';';\r\n $evs[$key]->color = $catcolor;\r\n }\r\n }\r\n if (count($events) < 500) { // magic number to not crash loop?\r\n $events = array_merge($events, $evs);\r\n } else {\r\n// $evs[$key]->title = gt('Too many events to list').', '.(count($edates)-count($events)).' '.gt('not displayed!');\r\n// $events = array_merge($events, $evs);\r\n flash('notice',gt('Too many events to list').', '.(count($edates)-count($events)).' '.gt('not displayed!'));\r\n break; // keep from breaking system by too much data\r\n }\r\n }\r\n $events = expSorter::sort(array('array' => $events, 'sortby' => 'eventstart', 'order' => $sort_asc ? 'ASC' : 'DESC'));\r\n return $events;\r\n }\r\n\r\n function getExternalEvents($startdate, $enddate, $multiday = false) {\r\n global $db;\r\n\r\n $extevents = array();\r\n $dy = 0; // index of events array\r\n if (!empty($this->config['pull_gcal'])) foreach ($this->config['pull_gcal'] as $key=>$extgcalurl) {\r\n// $dy = count($extevents); // index of events array\r\n $cache_hit = false;\r\n $gcal_cname = str_replace(array(\"/\",\":\",\"&\",\"?\"),\"_\",$extgcalurl);\r\n $cache_fname = BASE.'tmp/cache/'.$gcal_cname.\".cache\";\r\n if (file_exists($cache_fname)) {\r\n $cache = unserialize(file_get_contents($cache_fname));\r\n if ($startdate >= $cache['start_date'] || $startdate >= $cache['first_date']) {\r\n $events = $db->selectObjects('event_cache','feed=\"'.$extgcalurl.'\" AND ' . self::build_daterange_sql($startdate,$enddate,'eventdate',true));\r\n foreach ($events as $event) {\r\n if ($multiday) {\r\n $extevents[$event->eventdate][$dy] = $event;\r\n $extevents[$event->eventdate][$dy]->feedkey = $key;\r\n $extevents[$event->eventdate][$dy]->location_data = 'gcalevent' . $key;\r\n $extevents[$event->eventdate][$dy]->color = !empty($this->config['pull_gcal_color'][$key]) ? $this->config['pull_gcal_color'][$key] : null;\r\n if ($event->is_allday) {\r\n $extevents[$event->eventdate][$dy]->eventstart = $event->eventdate;\r\n }\r\n $dy++;\r\n } else {\r\n $endit = !empty($event->dateFinished) ? $event->dateFinished : $event->eventdate;\r\n// for ($i = $startdate; $i < $enddate; $i += 86400) {\r\n for ($i = $event->eventdate; $i <= $endit; $i += 86400) {\r\n if ((!empty($event->dateFinished) && $i > $event->dateFinished) || (empty($event->dateFinished) && $i > $event->eventdate)) {\r\n break;\r\n } else {\r\n $extevents[$i][$dy] = clone($event);\r\n $extevents[$i][$dy]->eventdate = (int)$i;\r\n $extevents[$i][$dy]->eventstart = ($event->eventstart - $event->eventdate);\r\n $extevents[$i][$dy]->eventend = ($event->eventend - (!empty($event->dateFinished)?$event->dateFinished:$event->eventdate));\r\n $extevents[$i][$dy]->eventstart = ($extevents[$i][$dy]->eventstart) + $i;\r\n $extevents[$i][$dy]->eventend = ($extevents[$i][$dy]->eventend) + $i;\r\n $extevents[$i][$dy]->feedkey = $key;\r\n $extevents[$i][$dy]->location_data = 'gcalevent' . $key;\r\n $extevents[$i][$dy]->color = !empty($this->config['pull_gcal_color'][$key]) ? $this->config['pull_gcal_color'][$key] : null;\r\n $dy++;\r\n }\r\n }\r\n }\r\n }\r\n $cache_hit = true;\r\n }\r\n }\r\n if (!$cache_hit) { // pull in the external events\r\n foreach ($this->get_gcal_events($extgcalurl, $startdate, $enddate, $dy, $key, $multiday) as $date=>$events) {\r\n foreach ($events as $event) {\r\n $extevents[$date][] = $event;\r\n }\r\n }\r\n }\r\n }\r\n if (!empty($this->config['pull_ical'])) foreach ($this->config['pull_ical'] as $key=>$exticalurl) {\r\n// $dy = count($extevents); // index of events array\r\n $cache_hit = false;\r\n $ical_cname = str_replace(array(\"/\",\":\",\"&\",\"?\"),\"_\",$exticalurl);\r\n $cache_fname = BASE.'tmp/cache/'.$ical_cname.\".cache\";\r\n if (file_exists($cache_fname)) {\r\n $cache = unserialize(file_get_contents($cache_fname));\r\n if ($startdate >= $cache['start_date'] || $startdate >= $cache['first_date']) {\r\n $events = $db->selectObjects('event_cache','feed=\"'.$exticalurl.'\" AND ' . self::build_daterange_sql($startdate,$enddate,'eventdate',true));\r\n foreach ($events as $event) {\r\n $extevents[$event->eventdate][$dy] = $event;\r\n $extevents[$event->eventdate][$dy]->location_data = 'icalevent' . $key;\r\n $extevents[$event->eventdate][$dy]->color = !empty($this->config['pull_ical_color'][$key]) ? $this->config['pull_ical_color'][$key] : null;\r\n $dy++;\r\n }\r\n $cache_hit = true;\r\n }\r\n }\r\n if (!$cache_hit) { // pull in the external events\r\n foreach ($this->get_ical_events($exticalurl, $startdate, $enddate, $dy, $key, $multiday) as $date=>$events) {\r\n foreach ($events as $event) {\r\n $extevents[$date][] = $event;\r\n }\r\n }\r\n }\r\n }\r\n return $extevents;\r\n }\r\n\r\n public function get_gcal_events($extgcalurl, $startdate, $enddate=null, &$dy=0, $key=0, $multiday=false) {\r\n $extevents = array();\r\n if (!empty($startdate)) $begin = date(\"Y-m-d\\Th:i:sP\", expDateTime::startOfDayTimestamp($startdate));\r\n if (!empty($enddate)) $end = date(\"Y-m-d\\Th:i:sP\", expDateTime::endOfDayTimestamp($enddate));\r\n else $end = date(\"Y-m-d\\Th:i:sP\", (expDateTime::endOfDayTimestamp($startdate + ((3600*24)*30))));\r\n\r\n if (substr($extgcalurl, -5) == 'basic') {\r\n $extgcalurl = substr($extgcalurl, 0, - 5) . 'full';\r\n }\r\n $feed = $extgcalurl . \"?orderby=starttime&singleevents=true\";\r\n if (!empty($startdate)) $feed .= \"&start-min=\" . $begin;\r\n if (!empty($enddate)) $feed .= \"&start-max=\" . $end;\r\n\r\n // XML method\r\n// $s = simplexml_load_file($feed);\r\n// foreach ($s->entry as $item) {\r\n// $gd = $item->children('http://schemas.google.com/g/2005');\r\n// if (!empty($gd->when)) {\r\n// $dtstart = $gd->when->attributes()->startTime;\r\n// } elseif (!empty($gd->recurrence)){\r\n// $dtstart = $gd->recurrence->when->attributes()->startTime;\r\n// } else {\r\n// $dtstart = $item->attributes()->When;\r\n// }\r\n// //FIXME must convert $dtstart timezone\r\n// $eventdate = expDateTime::startOfDayTimestamp(strtotime($dtstart));\r\n// $ourtzoffsets = (int)(date('O',$eventdate)) * 36;\r\n// $theirtzoffset = -((int)(substr($dtstart,-5,2)) * 3600);\r\n// $tzoffset = $ourtzoffsets - $theirtzoffset;\r\n// $extevents[$eventdate][$dy] = new stdClass();\r\n// $extevents[$eventdate][$dy]->eventdate = $eventdate;\r\n// $extevents[$eventdate][$dy]->eventstart += strtotime($dtstart) + $tzoffset;\r\n// if (!empty($gd->when)) {\r\n// $dtend = $gd->when->attributes()->endTime;\r\n// } elseif (!empty($gd->recurrence)) {\r\n// $dtend = $gd->recurrence->when->attributes()->endTime;\r\n// }\r\n// //FIXME must convert $dtend timezone\r\n// if (!empty($dtend)) $extevents[$eventdate][$dy]->eventend += strtotime($dtend) + $tzoffset;\r\n// // dtstart required, one occurrence, (orig. start date)\r\n// $extevents[$eventdate][$dy]->title = $item->title;\r\n// $extevents[$eventdate][$dy]->body = $item->content;\r\n // End XML method\r\n\r\n // DOM method\r\n $doc = new DOMDocument();\r\n $doc->load($feed);\r\n $entries = $doc->getElementsByTagName(\"entry\");\r\n foreach ($entries as $item) {\r\n $times = $item->getElementsByTagName(\"when\");\r\n $dtstart = $times->item(0)->getAttributeNode(\"startTime\")->value;\r\n $eventdate = expDateTime::startOfDayTimestamp(strtotime($dtstart));\r\n $extevents[$eventdate][$dy] = new stdClass();\r\n $extevents[$eventdate][$dy]->eventdate = $eventdate;\r\n $dtend = @$times->item(0)->getAttributeNode(\"endTime\")->value;\r\n $ourtzoffsets = (int)date('O',$eventdate) * 36;\r\n $theirtzoffset = -((int)substr($dtstart,-5,2) * 3600);\r\n $tzoffset = $ourtzoffsets - $theirtzoffset;\r\n if (strlen($dtstart) > 10) {\r\n $extevents[$eventdate][$dy]->eventstart = ((int)substr($dtstart, 11, 2) * 3600) + ((int)substr($dtstart, 14, 2) * 60) + $tzoffset;\r\n// if (date(\"I\", $eventdate)) $extevents[$eventdate][$dy]->eventstart += 3600;\r\n $extevents[$eventdate][$dy]->eventend = ((int)substr($dtend, 11, 2) * 3600) + ((int)substr($dtend, 14, 2) * 60) + $tzoffset;\r\n// if (date(\"I\", $eventdate)) $extevents[$eventdate][$dy]->eventend += 3600;\r\n } else {\r\n $extevents[$eventdate][$dy]->eventstart = null;\r\n $extevents[$eventdate][$dy]->is_allday = 1;\r\n }\r\n $extevents[$eventdate][$dy]->eventstart += $eventdate;\r\n $extevents[$eventdate][$dy]->eventend += $eventdate;\r\n if (empty($dtend)) $extevents[$eventdate][$dy]->eventend = $extevents[$eventdate][$dy]->eventstart;\r\n\r\n $titles = $item->getElementsByTagName(\"title\");\r\n $extevents[$eventdate][$dy]->title = $titles->item(0)->nodeValue;\r\n $contents = $item->getElementsByTagName(\"content\");\r\n $extevents[$eventdate][$dy]->body = $contents->item(0)->nodeValue;\r\n // End DOM method\r\n\r\n// $extevents[$eventdate][$dy]->location_data = serialize(expCore::makeLocation('extevent',$extcal->id));\r\n $extevents[$eventdate][$dy]->location_data = 'gcalevent' . $key;\r\n $extevents[$eventdate][$dy]->color = !empty($this->config['pull_gcal_color'][$key]) ? $this->config['pull_gcal_color'][$key] : null;\r\n $dy++;\r\n }\r\n return $extevents;\r\n }\r\n\r\n public function get_ical_events($exticalurl, $startdate=null, $enddate=null, &$dy=0, $key=0, $multiday=false) {\r\n $extevents = array();\r\n// require_once BASE . 'external/iCalcreator.class.php';\r\n require_once BASE . 'external/iCalcreator-2.22/iCalcreator.php';\r\n $v = new vcalendar(); // initiate new CALENDAR\r\n if (stripos($exticalurl, 'http') === 0) {\r\n $v->setConfig('url', $exticalurl);\r\n } else {\r\n $v->setConfig('directory', dirname($exticalurl));\r\n $v->setConfig('filename', basename($exticalurl));\r\n }\r\n $v->parse();\r\n if ($startdate === null) {\r\n $startYear = false;\r\n $startMonth = false;\r\n $startDay = false;\r\n } else {\r\n $startYear = date('Y', $startdate);\r\n $startMonth = date('n', $startdate);\r\n $startDay = date('j', $startdate);\r\n }\r\n if ($enddate === null) {\r\n $endYear = $startYear+1;\r\n $endMonth = $startMonth;\r\n $endDay = $startDay;\r\n } else {\r\n $endYear = date('Y', $enddate);\r\n $endMonth = date('n', $enddate);\r\n $endDay = date('j', $enddate);\r\n }\r\n // get all events within period split out recurring events as single events per each day\r\n $eventArray = $v->selectComponents($startYear, $startMonth, $startDay, $endYear, $endMonth, $endDay, 'vevent');\r\n // Set the timezone to GMT\r\n @date_default_timezone_set('GMT');\r\n $tzarray = getTimezonesAsDateArrays($v);\r\n // Set the default timezone\r\n @date_default_timezone_set(DISPLAY_DEFAULT_TIMEZONE);\r\n if (!empty($eventArray)) foreach ($eventArray as $year => $yearArray) {\r\n if (!empty($yearArray)) foreach ($yearArray as $month => $monthArray) {\r\n if (!empty($monthArray)) foreach ($monthArray as $day => $dailyEventsArray) {\r\n if (!empty($dailyEventsArray)) foreach ($dailyEventsArray as $vevent) {\r\n // process each event\r\n $yesterday = false;\r\n $currdate = $vevent->getProperty('x-current-dtstart');\r\n $thisday = explode('-', $currdate[1]);\r\n $thisday2 = substr($thisday[2], 0, 2);\r\n // if member of a recurrence set,\r\n // returns array( 'x-current-dtstart', <DATE>)\r\n // <DATE> = (string) date(\"Y-m-d [H:i:s][timezone/UTC offset]\")\r\n $dtstart = $vevent->getProperty('dtstart', false, true);\r\n $dtend = $vevent->getProperty('dtend', false, true);\r\n if (empty($dtend))\r\n $dtend = $dtstart;\r\n\r\n // calculate the cumulative timezone offset in seconds to convert to local/system time\r\n $tzoffsets = array();\r\n $date_tzoffset = 0;\r\n if (!empty($tzarray)) {\r\n// $ourtzoffsets = -(iCalUtilityFunctions::_tz2offset(date('O',time())));\r\n $ourtzoffsets = -(iCalUtilityFunctions::_tz2offset(date('O',self::_date2timestamp($dtstart['value']))));\r\n // Set the timezone to GMT\r\n @date_default_timezone_set('GMT');\r\n if (!empty($dtstart['params']['TZID'])) $tzoffsets = getTzOffsetForDate($tzarray, $dtstart['params']['TZID'], $dtstart['value']);\r\n // Set the default timezone\r\n @date_default_timezone_set(DISPLAY_DEFAULT_TIMEZONE);\r\n if (isset($tzoffsets['offsetSec'])) $date_tzoffset = $ourtzoffsets + $tzoffsets['offsetSec'];\r\n }\r\n if (empty($tzoffsets)) {\r\n $date_tzoffset = -(iCalUtilityFunctions::_tz2offset(date('O',self::_date2timestamp($dtstart['value']))));\r\n }\r\n //FIXME we must have the real timezone offset for the date by this point\r\n\r\n //FIXME this is for the google ical feed which is bad!\r\n if ($dtstart['value']['day'] != (int)$thisday2 && (isset($dtstart['value']['day']) && isset($dtend['value']['hour']))&&\r\n !((int)$dtstart['value']['hour'] == 0 && (int)$dtstart['value']['min'] == 0 && (int)$dtstart['value']['sec'] == 0\r\n && (int)$dtend['value']['hour'] == 0 && (int)$dtend['value']['min'] == 0 && (int)$dtend['value']['sec'] == 0\r\n && ((((int)$dtstart['value']['day'] - (int)$dtend['value']['day']) == -1) || (((int)$dtstart['value']['month'] - (int)$dtend['value']['month']) == -1) || (((int)$dtstart['value']['month'] - (int)$dtend['value']['month']) == -11)))) {\r\n $dtst = strtotime($currdate[1]);\r\n $dtst1 = iCalUtilityFunctions::_timestamp2date($dtst);\r\n $dtstart['value']['year'] = $dtst1['year'];\r\n $dtstart['value']['month'] = $dtst1['month'];\r\n $dtstart['value']['day'] = $dtst1['day'];\r\n $currenddate = $vevent->getProperty('x-current-dtend');\r\n $dtet = strtotime($currenddate[1]);\r\n $dtet1 = iCalUtilityFunctions::_timestamp2date($dtet);\r\n $dtend['value']['year'] = $dtet1['year'];\r\n $dtend['value']['month'] = $dtet1['month'];\r\n $dtend['value']['day'] = $dtet1['day'];\r\n// $date_tzoffset = 0;\r\n }\r\n\r\n if (!empty($dtstart['value']['hour']) && !((int)$dtstart['value']['hour'] == 0 && (int)$dtstart['value']['min'] == 0 && (int)$dtstart['value']['sec'] == 0\r\n && (int)$dtend['value']['hour'] == 0 && (int)$dtend['value']['min'] == 0 && (int)$dtend['value']['sec'] == 0\r\n && ((((int)$dtstart['value']['day'] - (int)$dtend['value']['day']) == -1) || (((int)$dtstart['value']['month'] - (int)$dtend['value']['month']) == -1) || (((int)$dtstart['value']['month'] - (int)$dtend['value']['month']) == -11)))) {\r\n $eventdate = expDateTime::startOfDayTimestamp(self::_date2timestamp($dtstart['value']) - $date_tzoffset);\r\n// $eventend = expDateTime::startOfDayTimestamp(self::_date2timestamp($dtend['value']) - $date_tzoffset);\r\n $extevents[$eventdate][$dy] = new stdClass();\r\n $extevents[$eventdate][$dy]->eventdate = new stdClass();\r\n $extevents[$eventdate][$dy]->eventdate->date = $eventdate;\r\n// if ((int)($dtstart['value']['hour']) == 0 && (int)($dtstart['value']['min']) == 0 && (int)($dtstart['value']['sec']) == 0\r\n// && (int)($dtend['value']['hour']) == 0 && (int)($dtend['value']['min']) == 0 && (int)($dtend['value']['sec']) == 0\r\n// && ((((int)($dtstart['value']['day']) - (int)($dtend['value']['day'])) == -1) || (((int)($dtstart['value']['month']) - (int)($dtend['value']['month'])) == -1) || (((int)($dtstart['value']['month']) - (int)($dtend['value']['month'])) == -11))) {\r\n//// if ($dtstart['value']['day'] != (int)($thisday2)) {\r\n// if (date('d',$eventdate) != $thisday2) {\r\n//// if (date('d',$eventdate) != date('d',$eventend)) {\r\n// $yesterday = true;\r\n// } else {\r\n// $extevents[$eventdate][$dy]->eventstart = null;\r\n// $extevents[$eventdate][$dy]->is_allday = 1;\r\n// }\r\n// } else {\r\n if (date('d',$eventdate) != $thisday2) {\r\n// if (date('d',$eventdate) != date('d',$eventend)) {\r\n $yesterday = true;\r\n } else {\r\n $extevents[$eventdate][$dy]->eventstart = ($dtstart['value']['hour'] * 3600) + ($dtstart['value']['min'] * 60) - $date_tzoffset;\r\n// if (date(\"I\", $eventdate)) $extevents[$eventdate][$dy]->eventstart += 3600; // adjust for daylight savings time\r\n }\r\n// }\r\n } else {\r\n // this is an all day event\r\n $eventdate = expDateTime::startOfDayTimestamp(self::_date2timestamp($dtstart['value']));\r\n// $eventend = expDateTime::startOfDayTimestamp(self::_date2timestamp($dtend['value']));\r\n $extevents[$eventdate][$dy] = new stdClass();\r\n $extevents[$eventdate][$dy]->eventdate = new stdClass();\r\n $extevents[$eventdate][$dy]->eventdate->date = $eventdate;\r\n// if ($dtstart['value']['day'] != (int)($thisday2)) {\r\n if (date('d',$eventdate) != $thisday2) {\r\n// if (date('d',$eventdate) != date('d',$eventend)) {\r\n $yesterday = true;\r\n } else {\r\n $extevents[$eventdate][$dy]->eventstart = null;\r\n $extevents[$eventdate][$dy]->is_allday = 1;\r\n }\r\n }\r\n\r\n // set the end time if needed\r\n if (!$yesterday && isset($dtend['value']['hour']) && empty($extevents[$eventdate][$dy]->is_allday)) {\r\n// if ($dtend['value']['day'] != (int)($thisday2)) {\r\n// if ((date('d',$eventend) != $thisday2)) {\r\n// $yesterday = true;\r\n// } else {\r\n $extevents[$eventdate][$dy]->eventend = ($dtend['value']['hour'] * 3600) + ($dtend['value']['min'] * 60) - $date_tzoffset;\r\n// if (date(\"I\", $eventdate)) $extevents[$eventdate][$dy]->eventend += 3600; // adjust for daylight savings time\r\n// }\r\n }\r\n\r\n // convert the start and end times to a full date\r\n if (isset($extevents[$eventdate][$dy]->eventstart) && $extevents[$eventdate][$dy]->eventstart != null)\r\n $extevents[$eventdate][$dy]->eventstart += $eventdate;\r\n if (isset($extevents[$eventdate][$dy]->eventend))\r\n $extevents[$eventdate][$dy]->eventend += $eventdate;\r\n\r\n // dtstart required, one occurrence, (orig. start date)\r\n $extevents[$eventdate][$dy]->title = $vevent->getProperty('summary');\r\n $body = $vevent->getProperty('description');\r\n // convert end of lines\r\n $body = nl2br(str_replace(\"\\\\n\",\" <br>\\n\",$body));\r\n $body = str_replace(\"\\n\",\" <br>\\n\",$body);\r\n $body = str_replace(array('==0A','=0A','=C2=A0'),\" <br>\\n\",$body);\r\n $extevents[$eventdate][$dy]->body = $body;\r\n $extevents[$eventdate][$dy]->location_data = 'icalevent' . $key;\r\n $extevents[$eventdate][$dy]->color = !empty($this->config['pull_ical_color'][$key]) ? $this->config['pull_ical_color'][$key] : null;\r\n if (!$yesterday && $eventdate >= $startdate) {\r\n $dy++;\r\n } else {\r\n unset($extevents[$eventdate][$dy]);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return $extevents;\r\n }\r\n\r\n public static function _date2timestamp( $datetime, $wtz=null ) {\r\n if( !isset( $datetime['hour'] )) $datetime['hour'] = 0;\r\n if( !isset( $datetime['min'] )) $datetime['min'] = 0;\r\n if( !isset( $datetime['sec'] )) $datetime['sec'] = 0;\r\n if( empty( $wtz ) && ( !isset( $datetime['tz'] ) || empty( $datetime['tz'] )))\r\n return mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year'] );\r\n $output = $offset = 0;\r\n if( empty( $wtz )) {\r\n if( iCalUtilityFunctions::_isOffset( $datetime['tz'] )) {\r\n $offset = iCalUtilityFunctions::_tz2offset( $datetime['tz'] ) * -1;\r\n $wtz = 'UTC';\r\n }\r\n else\r\n $wtz = $datetime['tz'];\r\n }\r\n if(( 'Z' == $wtz ) || ( 'GMT' == strtoupper( $wtz )))\r\n $wtz = 'UTC';\r\n try {\r\n $strdate = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['min'], $datetime['sec'] );\r\n $d = new DateTime( $strdate, new DateTimeZone( $wtz ));\r\n if( 0 != $offset ) // adjust for offset\r\n $d->modify( $offset.' seconds' );\r\n $output = $d->format( 'U' );\r\n unset( $d );\r\n }\r\n catch( Exception $e ) {\r\n $output = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year'] );\r\n }\r\n return $output;\r\n }\r\n\r\n /**\r\n * build/update the external event cache\r\n *\r\n */\r\n public function build_cache() {\r\n global $db;\r\n\r\n // get our requested config\r\n $cfg = new expConfig();\r\n $configs = $cfg->find('all', \"location_data LIKE '%event%'\"); // get all event module configs\r\n foreach ($configs as $config) {\r\n $loc = expUnserialize($config->location_data);\r\n if (!empty($this->params['title'])) {\r\n if ($this->params['title'] == $config->config['feed_sef_url']) {\r\n $this->config = $config->config;\r\n break;\r\n }\r\n } elseif (!empty($this->params['src'])) {\r\n if ($this->params['src'] == $loc->src) {\r\n $this->config = $config->config;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n // next loop through our config pull urls\r\n\r\n // google xml pull\r\n if (!empty($this->config['pull_gcal'])) foreach ($this->config['pull_gcal'] as $key=>$extgcalurl) {\r\n $start = expDateTime::startOfMonthTimestamp(time());\r\n $gcal_cname = str_replace(array(\"/\",\":\",\"&\",\"?\"),\"_\",$extgcalurl);\r\n $cache_fname = BASE.'tmp/cache/'.$gcal_cname.\".cache\";\r\n $db->delete('event_cache', \"feed='\" . $extgcalurl . \"' AND eventdate > \" . $start); // replace future events\r\n // loop through 12 months, 1 month at a time\r\n for ($i=1; $i < 13; $i++) {\r\n $end = expDateTime::endOfMonthTimestamp($start);\r\n $tmp = 0;\r\n $extevents = $this->get_gcal_events($extgcalurl, $start, $end, $tmp, 0, true);\r\n// $extevents = $this->get_gcal_events($extgcalurl, null, null, 0, 0, 0, true);\r\n foreach ($extevents as $day) {\r\n foreach ($day as $extevent) {\r\n $event_cache = new stdClass();\r\n $event_cache->feed = $extgcalurl;\r\n $event_cache->event_id = $extevent->event_id;\r\n $event_cache->title = $extevent->title;\r\n $event_cache->body = $extevent->body;\r\n $event_cache->eventdate = $extevent->eventdate->date;\r\n if (isset($extevent->dateFinished) && $extevent->dateFinished != -68400)\r\n $event_cache->dateFinished = $extevent->dateFinished;\r\n if (isset($extevent->eventstart))\r\n $event_cache->eventstart = $extevent->eventstart;\r\n if (isset($extevent->eventend))\r\n $event_cache->eventend = $extevent->eventend;\r\n if (isset($extevent->is_allday))\r\n $event_cache->is_allday = $extevent->is_allday;\r\n $found = false;\r\n if ($extevent->eventdate->date < $start) // prevent duplicating events crossing month boundaries\r\n $found = $db->selectObject('event_cache','feed=\"'.$extgcalurl.'\" AND event_id=\"'.$event_cache->event_id.'\" AND eventdate='.$event_cache->eventdate);\r\n if (!$found)\r\n $db->insertObject($event_cache,'event_cache');\r\n }\r\n }\r\n $start = expDateTime::startOfMonthTimestamp($end + 1024);\r\n }\r\n $cache_contents = serialize(array('start_date'=>$start,'first_date'=>(int)$db->selectValue('event_cache','eventdate','feed=\"'.$extgcalurl.'\" ORDER BY eventdate'),'refresh_date'=>time()));\r\n file_put_contents($cache_fname, $cache_contents);\r\n }\r\n\r\n // ical pull\r\n $start = expDateTime::startOfMonthTimestamp(time());\r\n if (!empty($this->config['pull_ical'])) foreach ($this->config['pull_ical'] as $key=>$exticalurl) {\r\n $ical_cname = str_replace(array(\"/\",\":\",\"&\",\"?\"),\"_\",$exticalurl);\r\n $cache_fname = BASE.'tmp/cache/'.$ical_cname.\".cache\";\r\n $db->delete('event_cache', \"feed='\" . $exticalurl . \"' AND eventdate > \" . $start);\r\n // get 1 years worth of events\r\n $extevents = $this->get_ical_events($exticalurl, $start);\r\n foreach ($extevents as $day) {\r\n foreach ($day as $extevent) {\r\n $event_cache = new stdClass();\r\n $event_cache->feed = $exticalurl;\r\n $event_cache->title = $extevent->title;\r\n $event_cache->body = $extevent->body;\r\n $event_cache->eventdate = $extevent->eventdate->date;\r\n if (isset($extevent->dateFinished))\r\n $event_cache->dateFinished = $extevent->dateFinished;\r\n $event_cache->eventstart = $extevent->eventstart;\r\n if (isset($extevent->eventend))\r\n $event_cache->eventend = $extevent->eventend;\r\n if (isset($extevent->is_allday))\r\n $event_cache->is_allday = $extevent->is_allday;\r\n $db->insertObject($event_cache, 'event_cache');\r\n }\r\n }\r\n $cache_contents = serialize(array('start_date'=>$start,'first_date'=>(int)$db->selectValue('event_cache','eventdate','feed=\"'.$exticalurl.'\" ORDER BY eventdate'),'refresh_date'=>time()));\r\n file_put_contents($cache_fname, $cache_contents);\r\n }\r\n flash('message', gt('External Calendar Event cache updated'));\r\n echo show_msg_queue();\r\n }\r\n\r\n function import() {\r\n $pullable_modules = expModules::listInstalledControllers($this->baseclassname);\r\n $modules = new expPaginator(array(\r\n 'records' => $pullable_modules,\r\n 'controller' => $this->loc->mod,\r\n 'action' => $this->params['action'],\r\n 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\r\n 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\r\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\r\n 'columns' => array(\r\n gt('Title') => 'title',\r\n gt('Page') => 'section'\r\n ),\r\n ));\r\n\r\n assign_to_template(array(\r\n 'modules' => $modules,\r\n ));\r\n }\r\n\r\n function import_select()\r\n {\r\n if (empty($this->params['import_aggregate'])) {\r\n expValidator::setErrorField('import_aggregate[]');\r\n expValidator::failAndReturnToForm(gt('You must select a module.'), $this->params);\r\n }\r\n $extevents = array();\r\n unset(\r\n $this->params['begin'],\r\n $this->params['end']\r\n ); // always use date value\r\n $begin = yuidatetimecontrol::parseData('begin', $this->params);\r\n $end = yuidatetimecontrol::parseData('end', $this->params);\r\n if ($this->params['file_type'] == 'file') {\r\n //Get the temp directory to put the uploaded file\r\n $directory = \"tmp\";\r\n\r\n //Get the file save it to the temp directory\r\n if (!empty($_FILES[\"import_file\"]) && $_FILES[\"import_file\"][\"error\"] == UPLOAD_ERR_OK) {\r\n $file = expFile::fileUpload(\r\n \"import_file\",\r\n false,\r\n false,\r\n time() . \"_\" . $_FILES['import_file']['name'],\r\n $directory . '/'\r\n );\r\n if ($file === null) {\r\n switch ($_FILES[\"import_file\"][\"error\"]) {\r\n case UPLOAD_ERR_INI_SIZE:\r\n case UPLOAD_ERR_FORM_SIZE:\r\n $this->params['_formError'] = gt(\r\n 'The file you attempted to upload is too large. Contact your system administrator if this is a problem.'\r\n );\r\n break;\r\n case UPLOAD_ERR_PARTIAL:\r\n $this->params['_formError'] = gt('The file was only partially uploaded.');\r\n break;\r\n case UPLOAD_ERR_NO_FILE:\r\n $this->params['_formError'] = gt('No file was uploaded.');\r\n break;\r\n default:\r\n $this->params['_formError'] = gt(\r\n 'A strange internal error has occurred. Please contact the Exponent Developers.'\r\n );\r\n break;\r\n }\r\n expSession::set(\"last_POST\", $this->params);\r\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\r\n exit(\"\");\r\n } else {\r\n $extevents = $this->get_ical_events($directory . \"/\" . $file->filename, $begin, $end);\r\n }\r\n } else {\r\n expValidator::setErrorField('import_file');\r\n expValidator::failAndReturnToForm(gt('File failed to upload.'), $this->params); // file upload error\r\n }\r\n } else {\r\n if (empty($this->params['ext_feed'])) {\r\n expValidator::setErrorField('ext_feed');\r\n expValidator::failAndReturnToForm(gt('You must enter a feed url.'), $this->params);\r\n }\r\n $extevents = $this->get_ical_events($this->params['ext_feed'], $begin, $end);\r\n }\r\n\r\n $src = $this->params['import_aggregate'][0];\r\n $count = 0;\r\n foreach ($extevents as $day) {\r\n foreach ($day as $extevent) {\r\n $event = array();\r\n $event['title'] = $extevent->title;\r\n $event['body'] = $extevent->body;\r\n $event['eventdate'] = $extevent->eventdate->date;\r\n $event['eventstart'] = $extevent->eventstart;\r\n $event['eventstart'] -= $event['eventdate'];\r\n if (isset($extevent->eventend))\r\n $event['eventend'] = $extevent->eventend;\r\n else\r\n $event['eventend'] = $extevent->eventstart;\r\n $event['eventend'] -= $event['eventdate'];\r\n if (isset($extevent->is_allday))\r\n $event['is_allday'] = $extevent->is_allday;\r\n $event['module'] = 'event';\r\n $event['src'] = $src;\r\n $item = new event(); // create new populated record to auto-set things\r\n $item->update($event);\r\n $count++;\r\n }\r\n }\r\n\r\n unlink($directory . \"/\" . $file->filename);\r\n\r\n // update search index\r\n $this->addContentToSearch();\r\n\r\n flashAndFlow('message', $count . ' ' . gt('events were imported.'));\r\n }\r\n\r\n /** @deprecated\r\n * function to build a control requested via ajax\r\n * we the html just like the control smarty function\r\n * @deprecated\r\n */\r\n public function buildControl() {\r\n $control = new colorcontrol();\r\n if (!empty($this->params['value'])) $control->value = $this->params['value'];\r\n if ($this->params['value'][0] != '#') $this->params['value'] = '#' . $this->params['value'];\r\n $control->default = $this->params['value'];\r\n if (!empty($this->params['hide'])) $control->hide = $this->params['hide'];\r\n if (isset($this->params['flip'])) $control->flip = $this->params['flip'];\r\n $this->params['name'] = !empty($this->params['name']) ? $this->params['name'] : '';\r\n $control->name = $this->params['name'];\r\n $this->params['id'] = !empty($this->params['id']) ? $this->params['id'] : '';\r\n $control->id = isset($this->params['id']) && $this->params['id'] != \"\" ? $this->params['id'] : \"\";\r\n //echo $control->id;\r\n if (empty($control->id)) $control->id = $this->params['name'];\r\n if (empty($control->name)) $control->name = $this->params['id'];\r\n\r\n // attempt to translate the label\r\n if (!empty($this->params['label'])) {\r\n $this->params['label'] = gt($this->params['label']);\r\n } else {\r\n $this->params['label'] = null;\r\n }\r\n echo $control->toHTML($this->params['label'], $this->params['name']);\r\n// $ar = new expAjaxReply(200, gt('The control was created'), json_encode(array('data'=>$code)));\r\n// $ar->send();\r\n }\r\n\r\n}\r\n\r",
"?>"
] |
[
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class eventController extends expController {\n// public $basemodel_name = 'event';\n public $useractions = array(\n 'showall' => 'Show Calendar',\n );\n// protected $manage_permissions = array(\n// 'import' => 'Import Calendar',\n// );\n public $remove_configs = array(\n 'comments',\n 'ealerts',\n// 'facebook',\n 'files',\n 'pagination',\n 'rss',\n// 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" static function displayname() {\n return \"Events\";\n }",
" static function description() {\n return \"Manage events and schedules, and optionally publish them.\";\n }",
" static function author() {\n return \"Dave Leffler\";\n }",
" static function isSearchable() {\n return true;\n }",
" function searchName() {\n return gt(\"Calendar Event\");\n }",
" function searchCategory() {\n return gt('Event');\n }",
" /**\n * can this module import data?\n *\n * @return bool\n */\n public static function canImportData() {\n return true;\n }",
" function showall() {\n global $user;",
" expHistory::set('viewable', $this->params);\n $locsql = $this->aggregateWhereClause();\n $time = (isset($this->params['time']) ? intval($this->params['time']) : time());\n assign_to_template(array(\n 'time' => $time,\n 'daynames' => event::dayNames(),\n ));",
" $regcolor = !empty($this->config['registrations_color']) ? $this->config['registrations_color'] : null;",
" $ed = new eventdate();\n $viewtype = 'default';\n $viewrange = 'all';\n $view = !empty($this->params['view']) ? $this->params['view'] : 'showall';\n switch ($view) {\n case 'showall_Administration':\n $viewtype = \"administration\";\n break;\n case 'showall_Past Events':\n $viewrange = \"past\";\n break;\n case 'showall_Monthly Summary':\n case 'showall_Mini-Calendar':\n case 'minical':\n $viewtype = \"minical\";\n break;\n case 'showall_Monthly List':\n case 'showall_List':\n case 'monthlist':\n $viewtype = \"byday\";\n $viewrange = \"month\";\n break;\n case 'showall_Week':\n case 'week':\n $viewtype = \"byday\";\n $viewrange = \"week\";\n break;\n case 'showall_Day':\n case 'day':\n $viewtype = \"byday\";\n $viewrange = \"day\";\n break;\n case 'showall_announcement':\n case 'showall_Upcoming Events':\n case 'showall_Upcoming Events - Headlines':\n $viewrange = \"upcoming\";\n break;\n case 'showall':\n case 'month':\n $viewtype = \"monthly\";\n break;\n default :\n $view_params = explode('_',$view);\n if (!empty($view_params[1])) $viewtype = $view_params[1];\n if (!empty($view_params[2])) $viewrange = $view_params[2];\n } // end switch $view",
" switch ($viewtype) {\n case \"minical\":\n $monthly = expDateTime::monthlyDaysTimestamp($time);\n $info = getdate($time);\n $timefirst = mktime(0, 0, 0, $info['mon'], 1, $info['year']);\n $now = getdate(time());\n $currentday = $now['mday'];\n $endofmonth = date('t', $time);\n foreach ($monthly as $weekNum => $week) {\n foreach ($week as $dayNum => $day) {\n if ($dayNum == $now['mday']) {\n $currentweek = $weekNum;\n }\n if ($dayNum <= $endofmonth) {\n// $monthly[$weekNum][$dayNum]['number'] = ($monthly[$weekNum][$dayNum]['ts'] != -1) ? $db->countObjects(\"eventdate\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($day['ts']) . \" AND date <= \" . expDateTime::endOfDayTimestamp($day['ts'])) : -1;\n $monthly[$weekNum][$dayNum]['number'] = ($monthly[$weekNum][$dayNum]['ts'] != -1) ? $ed->find(\"count\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($day['ts']) . \" AND date <= \" . expDateTime::endOfDayTimestamp($day['ts'])) : -1;\n }\n }\n }\n $prevmonth = mktime(0, 0, 0, date(\"m\", $timefirst) - 1, date(\"d\", $timefirst) + 10, date(\"Y\", $timefirst));\n $nextmonth = mktime(0, 0, 0, date(\"m\", $timefirst) + 1, date(\"d\", $timefirst) + 10, date(\"Y\", $timefirst));\n assign_to_template(array(\n \"monthly\" => $monthly,\n \"currentweek\" => $currentweek,\n \"currentday\" => $currentday,\n \"now\" => $timefirst,\n \"prevmonth\" => $prevmonth,\n \"thismonth\" => $timefirst,\n \"nextmonth\" => $nextmonth,\n ));\n break; // end switch $viewtype minicalendar\n case \"byday\": //note aggregates events by groups of days\n // Remember this is the code for weekly view and monthly listview\n // Test your fixes on both views\n // \t\t$startperiod = 0;\n //\t\t\t$totaldays = 0;\n switch ($viewrange) {\n case \"day\":\n $startperiod = expDateTime::startOfDayTimestamp($time);\n $totaldays = 1;\n $next = expDateTime::endOfDayTimestamp($startperiod);\n if (!empty($this->config['starttype'])) $startperiod = $time;\n $this->params['time'] = $time;\n assign_to_template(array(\n \"prev_timestamp3\" => strtotime('-3 days', $startperiod),\n \"prev_timestamp2\" => strtotime('-2 days', $startperiod),\n \"prev_timestamp\" => strtotime('-1 days', $startperiod),\n \"next_timestamp\" => strtotime('+1 days', $startperiod),\n \"next_timestamp2\" => strtotime('+2 days', $startperiod),\n \"next_timestamp3\" => strtotime('+3 days', $startperiod),\n 'params' => $this->params\n ));\n break;\n case \"week\":\n $startperiod = expDateTime::startOfWeekTimestamp($time);\n $totaldays = 7;\n $next = strtotime('+7 days', $startperiod);\n// $next = expDateTime::endOfWeekTimestamp($startperiod);\n if (!empty($this->config['starttype'])) $startperiod = $time;\n $this->params['time'] = $time;\n assign_to_template(array(\n \"prev_timestamp3\" => strtotime('-21 days', $startperiod),\n \"prev_timestamp2\" => strtotime('-14 days', $startperiod),\n \"prev_timestamp\" => strtotime('-7 days', $startperiod),\n \"next_timestamp\" => $next,\n \"next_timestamp2\" => strtotime('+14 days', $startperiod),\n \"next_timestamp3\" => strtotime('+21 days', $startperiod),\n 'params' => $this->params\n ));\n break;\n case \"twoweek\":\n $startperiod = expDateTime::startOfWeekTimestamp($time);\n $totaldays = 14;\n $next = strtotime('+14 days', $startperiod);\n if (!empty($this->config['starttype'])) $startperiod = $time;\n assign_to_template(array(\n \"prev_timestamp3\" => strtotime('-42 days', $startperiod),\n \"prev_timestamp2\" => strtotime('-28 days', $startperiod),\n \"prev_timestamp\" => strtotime('-14 days', $startperiod),\n \"next_timestamp\" => $next,\n \"next_timestamp2\" => strtotime('+28 days', $startperiod),\n \"next_timestamp3\" => strtotime('+42 days', $startperiod),\n ));\n break;\n case \"month\":\n default: // range = month\n $startperiod = expDateTime::startOfMonthTimestamp($time);\n $totaldays = date('t', $time);\n $next = strtotime('+1 months', $startperiod);\n// $next = expDateTime::endOfMonthTimestamp($startperiod);\n $this->params['time'] = $time;\n assign_to_template(array(\n \"prev_timestamp3\" => strtotime('-3 months', $startperiod),\n \"prev_timestamp2\" => strtotime('-2 months', $startperiod),\n \"prev_timestamp\" => strtotime('-1 months', $startperiod),\n \"next_timestamp\" => $next,\n \"next_timestamp2\" => strtotime('+2 months', $startperiod),\n \"next_timestamp3\" => strtotime('+3 months', $startperiod),\n 'params' => $this->params\n ));\n break;\n } // end switch $viewrange",
" // $days = array();\n // added per Ignacio\n //\t\t\t$endofmonth = date('t', $time);\n $extitems = $this->getExternalEvents($startperiod, $next);\n if (!empty($this->config['aggregate_registrations']))\n $regitems = eventregistrationController::getRegEventsForDates($startperiod, $next, $regcolor);\n for ($i = 1; $i <= $totaldays; $i++) {\n // $info = getdate($time);\n // switch ($viewrange) {\n // case \"week\":\n // $start = mktime(0,0,0,$info['mon'],$i,$info['year']); //FIXME this can't be right?\n // break;\n // case \"twoweek\":\n //// $start = mktime(0,0,0,$info['mon'],$info['mday']+($i-1),$info['year']); //FIXME this can't be right?\n // \t\t $start = $startperiod + ($i*86400);\n // break;\n // default: // range = month\n // $start = mktime(0,0,0,$info['mon'],$i,$info['year']);\n // }\n $start = expDateTime::startOfDayTimestamp($startperiod + ($i * 86400) - 86400);\n $edates = $ed->find(\"all\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($start) . \" AND date <= \" . expDateTime::endOfDayTimestamp($start));\n// $days[$start] = $this->getEventsForDates($edates, true, isset($this->config['only_featured']) ? true : false);\n $days[$start] = $this->event->getEventsForDates($edates, true, isset($this->config['only_featured']) ? true : false);\n // for ($j = 0; $j < count($days[$start]); $j++) {\n // $thisloc = expCore::makeLocation($this->loc->mod,$this->loc->src,$days[$start][$j]->id);\n // $days[$start][$j]->permissions = array(\n // \"manage\"=>(expPermissions::check(\"manage\",$thisloc) || expPermissions::check(\"manage\",$this->loc)),\n // \"edit\"=>(expPermissions::check(\"edit\",$thisloc) || expPermissions::check(\"edit\",$this->loc)),\n // \"delete\"=>(expPermissions::check(\"delete\",$thisloc) || expPermissions::check(\"delete\",$this->loc))\n // );\n // }\n if (!empty($extitems[$start]))\n $days[$start] = array_merge($extitems[$start], $days[$start]);\n if (!empty($regitems[$start]))\n $days[$start] = array_merge($regitems[$start], $days[$start]);\n $days[$start] = expSorter::sort(array('array' => $days[$start], 'sortby' => 'eventstart', 'order' => 'ASC'));\n }\n assign_to_template(array(\n \"time\" => $startperiod,\n 'days' => $days,\n \"now\" => $startperiod,\n ));\n break; // end switch $viewtype byday\n case \"monthly\": //note this is a simply array of events for the requested month\n // build a month array of weeks with an array of days\n // $monthly = array();\n // $counts = array();\n $info = getdate($time);\n $nowinfo = getdate(time());\n if ($info['mon'] != $nowinfo['mon']) $nowinfo['mday'] = -10;\n // Grab non-day numbers only (before end of month)\n// $week = 0;\n $currentweek = -1;\n $timefirst = mktime(0, 0, 0, $info['mon'], 1, $info['year']);\n $week = (int)date('W',$timefirst);\n if ($week >= 52 && $info['mon'] == 1) $week = 1;\n $infofirst = getdate($timefirst);\n $monthly[$week] = array(); // initialize for non days\n $counts[$week] = array();\n if (($infofirst['wday'] == 0) && (DISPLAY_START_OF_WEEK == 1)) {\n for ($i = -6; $i < (1 - DISPLAY_START_OF_WEEK); $i++) {\n $monthly[$week][$i] = array();\n $counts[$week][$i] = -1;\n }\n $weekday = $infofirst['wday'] + 7; // day number in grid. if 7+, switch weeks\n } else {\n for ($i = 1 - $infofirst['wday']; $i < (1 - DISPLAY_START_OF_WEEK); $i++) {\n $monthly[$week][$i] = array();\n $counts[$week][$i] = -1;\n }\n $weekday = $infofirst['wday']; // day number in grid. if 7+, switch weeks\n }\n // Grab day counts\n $endofmonth = date('t', $time);\n $extitems = $this->getExternalEvents($timefirst, expDateTime::endOfMonthTimestamp($timefirst));\n if (!empty($this->config['aggregate_registrations']))\n $regitems = eventregistrationController::getRegEventsForDates($timefirst, expDateTime::endOfMonthTimestamp($timefirst), $regcolor);\n for ($i = 1; $i <= $endofmonth; $i++) {\n $start = mktime(0, 0, 0, $info['mon'], $i, $info['year']);\n if ($i == $nowinfo['mday']) $currentweek = $week;\n $dates = $ed->find(\"all\", $locsql . \" AND (date >= \" . expDateTime::startOfDayTimestamp($start) . \" AND date <= \" . expDateTime::endOfDayTimestamp($start) . \")\");\n// $monthly[$week][$i] = $this->getEventsForDates($dates, true, isset($this->config['only_featured']) ? true : false);\n $monthly[$week][$i] = $this->event->getEventsForDates($dates, true, isset($this->config['only_featured']) ? true : false);\n if (!empty($extitems[$start]))\n $monthly[$week][$i] = array_merge($extitems[$start], $monthly[$week][$i]);\n if (!empty($regitems[$start]))\n $monthly[$week][$i] = array_merge($regitems[$start], $monthly[$week][$i]);\n $monthly[$week][$i] = expSorter::sort(array('array' => $monthly[$week][$i], 'sortby' => 'eventstart', 'order' => 'ASC'));\n $counts[$week][$i] = count($monthly[$week][$i]);\n if ($weekday >= (6 + DISPLAY_START_OF_WEEK)) {\n $week++;\n $monthly[$week] = array(); // allocate an array for the next week\n $counts[$week] = array();\n $weekday = DISPLAY_START_OF_WEEK;\n } else $weekday++;\n }\n // Grab non-day numbers only (after end of month)\n for ($i = 1; $weekday && $i < (8 + DISPLAY_START_OF_WEEK - $weekday); $i++) {\n $monthly[$week][$i + $endofmonth] = array();\n $counts[$week][$i + $endofmonth] = -1;\n }\n $this->params['time'] = $time;\n assign_to_template(array(\n \"currentweek\" => $currentweek,\n \"monthly\" => $monthly,\n \"counts\" => $counts,\n \"prevmonth3\" => strtotime('-3 months', $timefirst),\n \"prevmonth2\" => strtotime('-2 months', $timefirst),\n \"prevmonth\" => strtotime('-1 months', $timefirst),\n \"nextmonth\" => strtotime('+1 months', $timefirst),\n \"nextmonth2\" => strtotime('+2 months', $timefirst),\n \"nextmonth3\" => strtotime('+3 months', $timefirst),\n \"now\" => $timefirst,\n \"today\" => expDateTime::startOfDayTimestamp(time()),\n 'params' => $this->params\n ));\n break; // end switch $viewtype monthly\n case \"administration\": //note a simple list of all upcoming events, except no external nor registration events\n // Check perms and return if cant view\n if (!$user) return;\n $continue = (expPermissions::check(\"manage\", $this->loc) ||\n expPermissions::check(\"create\", $this->loc) ||\n expPermissions::check(\"edit\", $this->loc) ||\n expPermissions::check(\"delete\", $this->loc)\n ) ? 1 : 0;\n $dates = $ed->find(\"all\", $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp(time()));\n// $items = $this->getEventsForDates($dates);\n $items = $this->event->getEventsForDates($dates);\n // if (!$continue) {\n // foreach ($items as $i) {\n // $iloc = expCore::makeLocation($this->loc->mod,$this->loc->src,$i->id);\n // if (expPermissions::check(\"edit\",$iloc) ||\n // expPermissions::check(\"delete\",$iloc) ||\n // expPermissions::check(\"manage\",$iloc)\n // ) {\n // $continue = true;\n // }\n // }\n // }\n if (!$continue) return;\n // for ($i = 0; $i < count($items); $i++) {\n // $thisloc = expCore::makeLocation($this->loc->mod,$this->loc->src,$items[$i]->id);\n // //\t\t\t\tif ($user && $items[$i]->poster == $user->id) $canviewapproval = 1;\n // $items[$i]->permissions = array(\n // \"manage\"=>(expPermissions::check(\"manage\",$thisloc) || expPermissions::check(\"manage\",$this->loc)),\n // \"edit\"=>(expPermissions::check(\"edit\",$thisloc) || expPermissions::check(\"edit\",$this->loc)),\n // \"delete\"=>(expPermissions::check(\"delete\",$thisloc) || expPermissions::check(\"delete\",$this->loc))\n // );\n // }\n $items = expSorter::sort(array('array' => $items, 'sortby' => 'eventstart', 'order' => 'ASC'));\n assign_to_template(array(\n 'items' => $items,\n ));\n break; // end switch $viewtype administration\n case \"default\": //note a simple list of events based on $viewrange\n default;\n // $items = null;\n // $dates = null;\n $day = expDateTime::startOfDayTimestamp(time());\n $sort_asc = true; // For the getEventsForDates call\n // $moreevents = false;\n switch ($viewrange) {\n case \"upcoming\": // events in the future\n if (!empty($this->config['enable_ical']) && !empty($this->config['rss_limit']) && $this->config['rss_limit'] > 0) {\n $eventlimit = \" AND date <= \" . ($day + ($this->config['rss_limit'] * 86400));\n } else {\n $eventlimit = \"\";\n }\n $dates = $ed->find(\"all\", $locsql . \" AND date >= \" . $day . $eventlimit . \" ORDER BY date ASC \");\n $begin = $day;\n $end = null;\n //\t\t\t\t\t$moreevents = count($dates) < $db->countObjects(\"eventdate\",$locsql.\" AND date >= $day\");\n break;\n case \"past\": // events in the past\n $dates = $ed->find(\"all\", $locsql . \" AND date < $day ORDER BY date DESC \");\n //\t\t\t\t\t$moreevents = count($dates) < $db->countObjects(\"eventdate\",$locsql.\" AND date < $day\");\n $sort_asc = false;\n $begin = null;\n $end = $day;\n break;\n case \"today\": // events occuring today\n $dates = $ed->find(\"all\", $locsql . \" AND (date >= \" . expDateTime::startOfDayTimestamp($day) . \" AND date <= \" . expDateTime::endOfDayTimestamp($day) . \")\");\n $begin = $day;\n $end = expDateTime::endOfDayTimestamp($day);\n break;\n case \"day\": // events for a specific day (same as byday day?)\n $dates = $ed->find(\"all\", $locsql . \" AND (date >= \" . expDateTime::startOfDayTimestamp($time) . \" AND date <= \" . expDateTime::endOfDayTimestamp($time) . \")\");\n $begin = expDateTime::startOfDayTimestamp($time);\n $end = expDateTime::endOfDayTimestamp($time);\n break;\n case \"next\": // future events\n $dates = array($ed->find(\"all\", $locsql . \" AND date >= $time\"));\n $begin = expDateTime::startOfDayTimestamp($time);\n $end = null;\n break;\n case \"month\": // events for a specific month (same as monthly?)\n// $dates = $ed->find(\"all\", $locsql . \" AND (date >= \" . expDateTime::startOfMonthTimestamp(time()) . \" AND date <= \" . expDateTime::endOfMonthTimestamp(time()) . \")\");\n $dates = $ed->find(\"all\", $locsql . \" AND (date >= \" . expDateTime::startOfMonthTimestamp($time) . \" AND date <= \" . expDateTime::endOfMonthTimestamp($time) . \")\");\n $begin = expDateTime::startOfMonthTimestamp($time);\n $end = expDateTime::endOfMonthTimestamp($time);\n break;\n case \"all\": // all events\n default;\n $dates = $ed->find(\"all\", $locsql);\n $begin = null;\n $end = null;\n }\n// $items = $this->getEventsForDates($dates, $sort_asc, isset($this->config['only_featured']) ? true : false, true);\n $items = $this->event->getEventsForDates($dates, $sort_asc, isset($this->config['only_featured']) ? true : false, true);\n if ($viewrange != 'past') {\n $extitems = $this->getExternalEvents($begin, $end);\n // we need to flatten these down to simple array of events\n $extitem = array();\n foreach ($extitems as $days) {\n foreach ($days as $event) {\n if (empty($event->eventdate->date) || ($viewrange == 'upcoming' && $event->eventdate->date < time()))\n break;\n if (empty($event->eventstart))\n $event->eventstart = $event->eventdate->date;\n $extitem[] = $event;\n }\n }\n $items = array_merge($items, $extitem);",
" if (!empty($this->config['aggregate_registrations']))\n $regitems = eventregistrationController::getRegEventsForDates($begin, $end, $regcolor);\n // we need to flatten these down to simple array of events\n $regitem = array();\n if (!empty($regitems)) foreach ($regitems as $days) {\n foreach ($days as $value) {\n $regitem[] = $value;\n }\n }\n $items = array_merge($items, $regitem);",
" // remove today's events that have already ended\n if ($viewtype == 'default' && $viewrange == 'upcoming') {\n foreach ($items as $key=>$item) {\n if (!$item->is_allday && $item->eventend < time()) {\n //fixme we've left events ending earlier in the day, but already cancelled out tomorrow's event\n unset($items[$key]);\n } else {\n break; // they are chronological so we can end\n }\n }\n }\n }\n $items = expSorter::sort(array('array' => $items, 'sortby' => 'eventstart', 'order' => 'ASC'));\n // Upcoming events can be configured to show a specific number of events.\n // The previous call gets all events in the future from today\n // If configured, cut the array to the configured number of events\n //\t\t\tif ($template->viewconfig['num_events']) {\n //\t\t\t\tswitch ($viewrange) {\n //\t\t\t\t\tcase \"upcoming\":\n //\t\t\t\t\tcase \"past\":\n //\t\t\t\t\t\t$moreevents = $template->viewconfig['num_events'] < count($items);\n //\t\t\t\t\t\tbreak;\n //\t\t\t\t}\n //\t\t\t\t$items = array_slice($items, 0, $template->viewconfig['num_events']);\n //\t\t\t}\n // for ($i = 0; $i < count($items); $i++) {\n // $thisloc = expCore::makeLocation($this->loc->mod,$this->loc->src,$items[$i]->id);\n // $items[$i]->permissions = array(\n // 'manage'=>(expPermissions::check('manage',$thisloc) || expPermissions::check('manage',$this->loc)),\n // 'edit'=>(expPermissions::check('edit',$thisloc) || expPermissions::check('edit',$this->loc)),\n // 'delete'=>(expPermissions::check('delete',$thisloc) || expPermissions::check('delete',$this->loc))\n // );\n // }\n assign_to_template(array(\n 'items' => $items,\n \"now\" => $day,\n ));\n }\n }",
" /**\n * default view for individual item\n */\n function show() {\n expHistory::set('viewable', $this->params);\n if (!empty($this->params['date_id'])) { // specific event instance\n $eventdate = new eventdate($this->params['date_id']);\n $eventdate->event = new event($eventdate->event_id);\n } else { // we'll default to the first event of this series\n $event = new event($this->params['id']);\n $eventdate = new eventdate($event->eventdate[0]->id);\n }\n if (empty($eventdate->id))\n redirect_to(array('controller'=>'notfound','action'=>'page_not_found','title'=>'event'));",
" if (!empty($eventdate->event->feedback_form) && $eventdate->event->feedback_form != 'Disallow Feedback') {\n assign_to_template(array(\n 'feedback_form' => $eventdate->event->feedback_form,\n ));\n }",
" assign_to_template(array(\n 'event' => $eventdate,\n ));\n }",
" function edit() {\n global $template;",
" parent::edit();\n $allforms = array();\n $allforms[\"\"] = gt('Disallow Feedback');\n // calculate which event date is the one being edited\n $event_key = 0;\n foreach ($template->tpl->tpl_vars['record']->value->eventdate as $key=>$d) {\n \t if ($d->id == $this->params['date_id']) $event_key = $key;\n \t}",
" assign_to_template(array(\n 'allforms' => array_merge($allforms, expTemplate::buildNameList(\"forms\", \"event/email\", \"tpl\", \"[!_]*\")),\n 'checked_date' => !empty($this->params['date_id']) ? $this->params['date_id'] : null,\n 'event_key' => $event_key,\n ));\n }",
" /**\n * Delete a recurring event by asking for which event dates to delete\n *\n */\n function delete_recurring() {\n $item = $this->event->find('first', 'id=' . $this->params['id']);\n if ($item->is_recurring == 1) { // need to give user options\n expHistory::set('editable', $this->params);\n assign_to_template(array(\n 'checked_date' => $this->params['date_id'],\n 'event' => $item,\n ));\n } else { // Process a regular delete\n $item->delete();\n }\n }",
" /**\n * Delete selected event dates for a recurring event and event if all event dates deleted\n *\n */\n function delete_selected() {\n $item = $this->event->find('first', 'id=' . $this->params['id']);\n if ($item && $item->is_recurring == 1) {\n $event_remaining = false;\n $eventdates = $item->eventdate[0]->find('all', 'event_id=' . $item->id);\n foreach ($eventdates as $ed) {\n if (array_key_exists($ed->id, $this->params['dates'])) {\n $ed->delete();\n } else {\n $event_remaining = true;\n }\n }\n if (!$event_remaining) {\n $item->delete(); // model will also ensure we delete all event dates\n }\n expHistory::back();\n } else {\n notfoundController::handle_not_found();\n }\n }",
" function delete_all_past() {\n $locsql = $this->aggregateWhereClause();\n $ed = new eventdate();\n $dates = $ed->find(\"all\", $locsql . \" AND date < \" . strtotime('-1 months', time()));\n foreach ($dates as $date) {\n $date->delete(); // event automatically deleted if all assoc eventdates are deleted\n }\n expHistory::back();\n }",
" /**\n \t * get the metainfo for this module\n \t * @return array\n \t */\n \tfunction metainfo() {\n global $router;",
" $action = $router->params['action'];\n $metainfo = array('title' => '', 'keywords' => '', 'description' => '', 'canonical'=> '', 'noindex' => false, 'nofollow' => false);\n // look for event date_id which expController::metainfo won't detect\n// if (!empty($router->params['action']) && $router->params['action'] == 'show' && !isset($router->params['id']) && isset($router->params['date_id'])) {\n switch ($action) {\n case 'show':\n if (!isset($router->params['id']) && isset($router->params['date_id'])) {\n // look up the record.\n $object = new eventdate((int)$router->params['date_id']);\n // set the meta info\n if (!empty($object)) {\n if (!empty($object->event->body)) {\n $desc = str_replace('\"',\"'\",expString::summarize($object->event->body,'html','para'));\n } else {\n $desc = SITE_DESCRIPTION;\n }\n if (!empty($object->expTag)) {\n $keyw = '';\n foreach ($object->expTag as $tag) {\n if (!empty($keyw)) $keyw .= ', ';\n $keyw .= $tag->title;\n }\n } else {\n $keyw = SITE_KEYWORDS;\n }\n $metainfo['title'] = empty($object->event->meta_title) ? $object->event->title : $object->event->meta_title;\n $metainfo['keywords'] = empty($object->event->meta_keywords) ? $keyw : $object->event->meta_keywords;\n $metainfo['description'] = empty($object->event->meta_description) ? $desc : $object->event->meta_description;\n $metainfo['canonical'] = empty($object->event->canonical) ? $router->plainPath() : $object->event->canonical;\n $metainfo['noindex'] = empty($object->event->meta_noindex) ? false : $object->event->meta_noindex;\n $metainfo['nofollow'] = empty($object->event->meta_nofollow) ? false : $object->event->meta_nofollow;\n return $metainfo;\n break;\n }\n }\n default:\n return parent::metainfo();\n }\n }",
" /**\n * function to build a string to pull in all events within requested date range\n */\n function build_daterange_sql($timestamp, $endtimestamp=null, $field='date', $multiday=false) {\n if (empty($endtimestamp)) {\n $date_sql = \"((\".$field.\" >= \" . expDateTime::startOfDayTimestamp($timestamp) . \" AND \".$field.\" <= \" . expDateTime::endOfDayTimestamp($timestamp) . \")\";\n } else {\n $date_sql = \"((\".$field.\" >= \" . expDateTime::startOfDayTimestamp($timestamp) . \" AND \".$field.\" <= \" . expDateTime::endOfDayTimestamp($endtimestamp) . \")\";\n }\n if ($multiday)\n $date_sql .= \" OR (\" . expDateTime::startOfDayTimestamp($timestamp) . \" BETWEEN \".$field.\" AND dateFinished)\";\n $date_sql .= \")\";\n return $date_sql;\n }",
" function send_feedback() {\n $success = false;\n if (isset($this->params['id'])) {\n $ed = new eventdate($this->params['id']);\n// $email_addrs = array();\n if ($ed->event->feedback_email != '') {\n $msgtemplate = expTemplate::get_template_for_action($this, 'email/_' . expString::escape($this->params['formname']), $this->loc);\n $msgtemplate->assign('params', $this->params);\n $msgtemplate->assign('event', $ed);\n $email_addrs = explode(',', $ed->event->feedback_email);\n //This is an easy way to remove duplicates\n $email_addrs = array_flip(array_flip($email_addrs));\n $email_addrs = array_map('trim', $email_addrs);\n $mail = new expMail();\n $success += $mail->quickSend(array(\n \"text_message\" => $msgtemplate->render(),\n 'to' => $email_addrs,\n 'from' => !empty($this->params['email']) ? $this->params['email'] : trim(SMTP_FROMADDRESS),\n 'subject' => $this->params['subject'],\n ));\n }\n }",
" if ($success) {\n flashAndFlow('message', gt('Your feedback was successfully sent.'));\n } else {\n flashAndFlow('error', gt('We could not send your feedback. Please contact your administrator.'));\n }\n }",
" function ical() {\n if (isset($this->params['date_id']) || isset($this->params['title']) || isset($this->params['src'])) {\n $cfg = new expConfig();\n $configs = $cfg->find('all', \"location_data LIKE '%event%'\"); // get all event module configs\n foreach ($configs as $config) {\n $loc = expUnserialize($config->location_data);\n if (!empty($this->params['title'])) {\n if ($this->params['title'] == $config->config['feed_sef_url']) {\n $this->config = $config->config;\n break;\n }\n } elseif (!empty($this->params['src'])) {\n if ($this->params['src'] == $loc->src) {\n $this->config = $config->config;\n break;\n }\n }\n }\n $this->loc = $loc;",
" if ($this->config['enable_ical']) {\n $ed = new eventdate();\n if (isset($this->params['date_id'])) { // get single specific event only\n// $dates = array($db->selectObject(\"eventdate\",\"id=\".$this->params['date_id']));\n $dates = $ed->find('first', \"id=\" . $this->params['date_id']);\n $Filename = \"Event-\" . $this->params['date_id'];\n } else {\n $locsql = $this->aggregateWhereClause();",
" $day = expDateTime::startOfDayTimestamp(time());\n if (!empty($this->config['enable_ical']) && isset($this->config['rss_limit']) && ($this->config['rss_limit'] > 0)) {\n $rsslimit = \" AND date <= \" . ($day + ($this->config['rss_limit'] * 86400));\n } else {\n $rsslimit = \"\";\n }",
" if (isset($this->params['time'])) {\n $time = intval($this->params['time']); // get current month's events\n// $dates = $db->selectObjects(\"eventdate\",$locsql.\" AND (date >= \".expDateTime::startOfMonthTimestamp($time).\" AND date <= \".expDateTime::endOfMonthTimestamp($time).\")\");\n $dates = $ed->find('all', $locsql . \" AND (date >= \" . expDateTime::startOfMonthTimestamp($time) . \" AND date <= \" . expDateTime::endOfMonthTimestamp($time) . \")\");\n } else {\n $time = date('U', strtotime(\"midnight -1 month\", time())); // previous month also\n// $dates = $db->selectObjects(\"eventdate\",$locsql.\" AND date >= \".expDateTime::startOfDayTimestamp($time).$rsslimit);\n $dates = $ed->find('all', $locsql . \" AND date >= \" . expDateTime::startOfDayTimestamp($time) . $rsslimit);\n }\n //\t\t\t$title = $db->selectValue('container', 'title', \"internal='\".serialize($loc).\"'\");\n $title = $this->config['feed_title'];\n $Filename = preg_replace('/\\s+/', '', $title); // without whitespace\n }",
" if (!function_exists(\"quoted_printable_encode\")) { // function added in php v5.3.0\n function quoted_printable_encode($input, $line_max = 75) {\n $hex = array('0', '1', '2', '3', '4', '5', '6', '7',\n '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');\n $lines = preg_split(\"/(?:\\r\\n|\\r|\\n)/\", $input);\n $linebreak = \"=0D=0A=\\r\\n\";\n /* the linebreak also counts as characters in the mime_qp_long_line\n * rule of spam-assassin */\n $line_max = $line_max - strlen($linebreak);\n $escape = \"=\";\n $output = \"\";\n $cur_conv_line = \"\";\n $length = 0;\n $whitespace_pos = 0;\n $addtl_chars = 0;",
" // iterate lines\n for ($j = 0, $jMax = count($lines); $j < $jMax; $j++) {\n $line = $lines[$j];\n $linlen = strlen($line);",
" // iterate chars\n for ($i = 0; $i < $linlen; $i++) {\n $c = substr($line, $i, 1);\n $dec = ord($c);",
" $length++;",
" if ($dec == 32) {\n // space occurring at end of line, need to encode\n if (($i == ($linlen - 1))) {\n $c = \"=20\";\n $length += 2;\n }",
" $addtl_chars = 0;\n $whitespace_pos = $i;\n } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) {\n $h2 = floor($dec / 16);\n $h1 = floor($dec % 16);\n $c = $escape . $hex[\"$h2\"] . $hex[\"$h1\"];\n $length += 2;\n $addtl_chars += 2;\n }",
" // length for wordwrap exceeded, get a newline into the text\n if ($length >= $line_max) {\n $cur_conv_line .= $c;",
" // read only up to the whitespace for the current line\n $whitesp_diff = $i - $whitespace_pos + $addtl_chars;",
" /* the text after the whitespace will have to be read\n * again ( + any additional characters that came into\n * existence as a result of the encoding process after the whitespace)\n *\n * Also, do not start at 0, if there was *no* whitespace in\n * the whole line */\n if (($i + $addtl_chars) > $whitesp_diff) {\n $output .= substr($cur_conv_line, 0, (strlen($cur_conv_line) -\n $whitesp_diff)) . $linebreak;\n $i = $i - $whitesp_diff + $addtl_chars;\n } else {\n $output .= $cur_conv_line . $linebreak;\n }",
" $cur_conv_line = \"\";\n $length = 0;\n $whitespace_pos = 0;\n } else {\n // length for wordwrap not reached, continue reading\n $cur_conv_line .= $c;\n }\n } // end of for",
" $length = 0;\n $whitespace_pos = 0;\n $output .= $cur_conv_line;\n $cur_conv_line = \"\";",
" if ($j <= count($lines) - 1) {\n $output .= $linebreak;\n }\n } // end for",
" return trim($output);\n } // end quoted_printable_encode\n }",
" $tz = DISPLAY_DEFAULT_TIMEZONE;\n $msg = \"BEGIN:VCALENDAR\\n\";\n $msg .= \"VERSION:2.0\\n\"; // version for iCalendar files vs vCalendar files\n $msg .= \"CALSCALE:GREGORIAN\\n\";\n $msg .= \"METHOD: PUBLISH\\n\";\n $msg .= \"PRODID:<-//ExponentCMS//EN>\\n\";\n if (isset($this->config['rss_cachetime']) && ($this->config['rss_cachetime'] > 0)) {\n $msg .= \"X-PUBLISHED-TTL:PT\" . $this->config['rss_cachetime'] . \"M\\n\";\n }\n $msg .= \"X-WR-CALNAME:$Filename\\n\";",
"// $items = $this->getEventsForDates($dates);\n $items = $this->event->getEventsForDates($dates);",
" for ($i = 0, $iMax = count($items); $i < $iMax; $i++) {",
" // Convert events stored in local time to GMT\n $eventstart = new DateTime(date('r', $items[$i]->eventstart), new DateTimeZone($tz));\n $eventstart->setTimezone(new DateTimeZone('GMT'));\n $eventend = new DateTime(date('r', $items[$i]->eventend), new DateTimeZone($tz));\n $eventend->setTimezone(new DateTimeZone('GMT'));\n if ($items[$i]->is_allday) {\n $dtstart = \"DTSTART;VALUE=DATE:\" . date(\"Ymd\", $items[$i]->eventstart) . \"\\n\";\n $dtend = \"DTEND;VALUE=DATE:\" . date(\"Ymd\", strtotime(\"midnight +1 day\", $items[$i]->eventstart)) . \"\\n\";\n } else {\n $dtstart = \"DTSTART;VALUE=DATE-TIME:\" . $eventstart->format(\"Ymd\\THi00\") . \"Z\\n\";\n if ($items[$i]->eventend) {\n $dtend = \"DTEND;VALUE=DATE-TIME:\" . $eventend->format(\"Ymd\\THi00\") . \"Z\\n\";\n } else {\n $dtend = \"DTEND;VALUE=DATE-TIME:\" . $eventstart->format(\"Ymd\\THi00\") . \"Z\\n\";\n }\n }",
" $body = trim(strip_tags(str_replace(array(\"<br />\", \"<br>\", \"br/>\", \"</p>\"), \"\\n\", $items[$i]->body)));\n if ($items[$i]->is_cancelled) $body = gt('This Event Has Been Cancelled') . ' - ' . $body;\n $body = str_replace(array(\"\\r\"), \"\", $body);\n $body = str_replace(array(\" \"), \" \", $body);\n $body = expString::convertSmartQuotes($body);\n if (!isset($this->params['style'])) {\n // it's going to Outlook so remove all formatting from body text\n $body = quoted_printable_encode($body);\n } elseif ($this->params['style'] == \"g\") {\n // It's going to Google (doesn't like quoted-printable, but likes html breaks)\n $body = str_replace(array(\"\\n\"), \"<br />\", $body);\n } else {\n // It's going elsewhere (doesn't like quoted-printable)\n $body = str_replace(array(\"\\n\"), \" -- \", $body);\n }\n $title = $items[$i]->title;",
" $msg .= \"BEGIN:VEVENT\\n\";\n $msg .= $dtstart . $dtend;\n $msg .= \"UID:\" . $items[$i]->date_id . \"\\n\";\n $msg .= \"DTSTAMP:\" . date(\"Ymd\\THis\", time()) . \"Z\\n\";\n if ($title) {\n $msg .= \"SUMMARY:$title\\n\";\n }\n if ($body) {\n $msg .= \"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:\" . $body . \"\\n\";\n }\n //\tif($link_url) { $msg .= \"URL: $link_url\\n\";}\n if (!empty($this->config['usecategories'])) {\n if (!empty($items[$i]->expCat[0]->title)) {\n $msg .= \"CATEGORIES:\".$items[$i]->expCat[0]->title.\"\\n\";\n } else {\n $msg .= \"CATEGORIES:\".$this->config['uncat'].\"\\n\";\n }\n }\n $msg .= \"END:VEVENT\\n\";\n }\n $msg .= \"END:VCALENDAR\";",
" // Kick it out as a file download\n ob_end_clean();",
" //\t$mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octet-stream;' : \"text/x-vCalendar\";\n //\t$mime_type = \"text/x-vCalendar\";\n $mime_type = 'text/Calendar';\n header('Content-Type: ' . $mime_type);\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n header('Content-length: ' . strlen($msg));\n header('Content-Transfer-Encoding: binary');\n header('Content-Encoding:');\n //\theader(\"Content-Disposition: inline; filename=\".$Filename.\".ics\");\n header('Content-Disposition: attachment; filename=\"' . $Filename . '.ics\"');\n // IE need specific headers\n //\tif (EXPONENT_USER_BROWSER == 'IE') {\n header('Cache-Control: no-cache, must-revalidate');\n header('Pragma: public');\n header('Vary: User-Agent');\n //\t} else {\n header('Pragma: no-cache');\n //\t}\n echo $msg;\n exit();\n } else {\n notfoundController::handle_not_found();\n }\n } else {\n notfoundController::handle_not_found();\n }\n }",
" function send_reminders() {\n if (isset($this->params['title']) || isset($this->params['src'])) {\n $cfg = new expConfig();\n $configs = $cfg->find('all', \"location_data LIKE '%event%'\"); // get all event module configs\n foreach ($configs as $config) {\n $loc = expUnserialize($config->location_data);\n if (!empty($this->params['title'])) {\n if ($this->params['title'] == $config->config['feed_sef_url']) {\n $this->config = $config->config;\n break;\n }\n } elseif (!empty($this->params['src'])) {\n if ($this->params['src'] == $loc->src) {\n $this->config = $config->config;\n break;\n }\n }\n }",
" if (empty($this->config['reminder_active'])) {\n notfoundController::handle_not_found();\n return;\n }\n if (!empty($this->config['reminder_code']) && (empty($this->params['code']) || ($this->params['code'] != $this->config['reminder_code']))) {\n notfoundController::handle_not_authorized();\n return;\n }",
" $this->loc = $loc;\n $locsql = $this->aggregateWhereClause();",
" $view = (isset($this->params['view']) ? $this->params['view'] : '');\n if ($view == \"\") {\n $view = \"send_reminders\"; // default reminder view\n }",
"// $template = expTemplate::get_template_for_action($this, $view, $this->loc);\n global $template;",
" $title = $this->config['feed_title'];\n $template->assign('moduletitle', $title);",
" $time = (isset($this->params['time']) ? intval($this->params['time']) : time());\n $time = (int)$time;",
" $template->assign(\"time\", $time);",
" $startperiod = expDateTime::startOfDayTimestamp($time);\n if (!empty($this->params['days'])) {\n $totaldays = $this->params['days'];\n } else {\n $totaldays = 7; // default 7 days of events\n }",
" $count = 0;\n $info = getdate($startperiod);\n for ($i = 0; $i < $totaldays; $i++) {\n $start = mktime(0, 0, 0, $info['mon'], $info['mday'] + $i, $info['year']);\n $ed = new eventdate();\n $edates = $ed->find('all', $locsql . \" AND (date >= \" . expDateTime::startOfDayTimestamp($start) . \" AND date <= \" . expDateTime::endOfDayTimestamp($start) . \")\");\n $days[$start] = array();\n// $days[$start] = $this->getEventsForDates($edates);\n $days[$start] = $this->event->getEventsForDates($edates);\n for ($j = 0, $jMax = count($days[$start]); $j < $jMax; $j++) {\n $thisloc = expCore::makeLocation($loc->mod, $loc->src, $days[$start][$j]->id);\n $days[$start][$j]->permissions = array(\n \"manage\" => (expPermissions::check(\"manage\", $thisloc) || expPermissions::check(\"manage\", $loc)),\n \"edit\" => (expPermissions::check(\"edit\", $thisloc) || expPermissions::check(\"edit\", $loc)),\n \"delete\" => (expPermissions::check(\"delete\", $thisloc) || expPermissions::check(\"delete\", $loc))\n );\n }\n $counts[$start] = count($days[$start]);\n $count += count($days[$start]);\n $days[$start] = expSorter::sort(array('array' => $days[$start], 'sortby' => 'eventstart', 'order' => 'ASC'));\n }\n $template->assign(\"days\", $days);\n $template->assign(\"counts\", $counts);\n $template->assign(\"start\", $startperiod);\n $template->assign(\"totaldays\", $totaldays);",
" if ($count == 0) {\n flash('error',gt('No Events to Send!'));\n echo show_msg_queue('error');\n return;\n }",
" if (bs3())\n $css = file_get_contents(BASE . \"external/bootstrap3/css/bootstrap.css\");\n elseif (bs2())\n $css = file_get_contents(BASE . \"external/bootstrap/css/bootstrap.css\");\n else\n $css = file_get_contents(BASE . \"framework/modules/events/assets/css/calendar.css\");\n $template->assign(\"css\", $css);\n $template->assign(\"config\", $this->config);\n $template->assign(\"src\", $loc->src);",
" // format and send email\n $subject = $this->config['email_title_reminder'] . \" - $title\";\n $from_addr = $this->config['email_address_reminder'];\n $headers = array(\n \"From\" => $from = $this->config['email_from_reminder'],\n \"Reply-to\" => $reply = $this->config['email_reply_reminder']\n );",
" // set up the html message\n $template->assign(\"showdetail\", !empty($this->config['email_showdetail']));\n $htmlmsg = $template->render();",
" // now the same thing for the text message\n $msg = preg_replace('/(<script[^>]*>.+?<\\/script>|<style[^>]*>.+?<\\/style>)/s', '', $htmlmsg); // remove any script or style blocks\n $msg = trim(strip_tags(str_replace(array(\"<br />\", \"<br>\", \"br/>\"), \"\\n\", $msg)));",
" // Saved. do notifs\n $emails = array();\n if (!empty($this->config['user_list'])) foreach ($this->config['user_list'] as $c) {\n $u = user::getUserById($c);\n $emails[$u->email] = trim(user::getUserAttribution($u->id));\n }\n if (!empty($this->config['group_list'])) foreach ($this->config['group_list'] as $c) {\n $grpusers = group::getUsersInGroup($c);\n foreach ($grpusers as $u) {\n $emails[$u->email] = trim(user::getUserAttribution($u->id));\n }\n }\n if (!empty($this->config['address_list'])) foreach ($this->config['address_list'] as $c) {\n $emails[] = $c;\n }\n if (empty($emails)) {\n flash('error',gt('No One to Send Reminders to!'));\n echo show_msg_queue('error');\n return;\n }",
" $emails = array_flip(array_flip($emails));\n $emails = array_map('trim', $emails);\n// $headers = array(\n// \"MIME-Version\" => \"1.0\",\n// \"Content-type\" => \"text/html; charset=\" . LANG_CHARSET\n// );\n $mail = new expMail();\n $mail->quickSend(array(\n// 'headers' => $headers,\n 'html_message' => $htmlmsg,\n \"text_message\" => $msg,\n 'to' => $emails,\n 'from' => array(trim($this->config['email_address_reminder']) => $this->config['email_from_reminder']),\n 'subject' => $subject,\n ));",
" flash('message',gt('The following reminder was sent via email'));\n echo show_msg_queue();\n// echo($htmlmsg);\n } else {\n flash('error',gt('No Calendar Selected!'));\n echo show_msg_queue('error');\n }\n }",
" /** @deprecated moved to event model\n * @param $edates\n * @param bool $sort_asc\n * @param bool $featuredonly\n * @param bool $condense\n * @return array\n */\n function getEventsForDates($edates, $sort_asc = true, $featuredonly = false, $condense = false) {\n global $eventid;",
" $events = array();\n $featuresql = \"\";\n if ($featuredonly) $featuresql = \" AND is_featured=1\";\n foreach ($edates as $edate) {\n $evs = $this->event->find('all', \"id=\" . $edate->event_id . $featuresql);\n foreach ($evs as $key=>$event) {\n if ($condense) {\n $eventid = $event->id;\n $multiday_event = array_filter($events, create_function('$event', 'global $eventid; return $event->id === $eventid;'));\n if (!empty($multiday_event)) {\n unset($evs[$key]);\n continue;\n }\n }\n $evs[$key]->eventstart += $edate->date;\n $evs[$key]->eventend += $edate->date;\n $evs[$key]->date_id = $edate->id;\n if (!empty($event->expCat)) {\n $catcolor = empty($event->expCat[0]->color) ? null : trim($event->expCat[0]->color);\n// if (substr($catcolor,0,1)=='#') $catcolor = '\" style=\"color:'.$catcolor.';';\n $evs[$key]->color = $catcolor;\n }\n }\n if (count($events) < 500) { // magic number to not crash loop?\n $events = array_merge($events, $evs);\n } else {\n// $evs[$key]->title = gt('Too many events to list').', '.(count($edates)-count($events)).' '.gt('not displayed!');\n// $events = array_merge($events, $evs);\n flash('notice',gt('Too many events to list').', '.(count($edates)-count($events)).' '.gt('not displayed!'));\n break; // keep from breaking system by too much data\n }\n }\n $events = expSorter::sort(array('array' => $events, 'sortby' => 'eventstart', 'order' => $sort_asc ? 'ASC' : 'DESC'));\n return $events;\n }",
" function getExternalEvents($startdate, $enddate, $multiday = false) {\n global $db;",
" $extevents = array();\n $dy = 0; // index of events array\n if (!empty($this->config['pull_gcal'])) foreach ($this->config['pull_gcal'] as $key=>$extgcalurl) {\n// $dy = count($extevents); // index of events array\n $cache_hit = false;\n $gcal_cname = str_replace(array(\"/\",\":\",\"&\",\"?\"),\"_\",$extgcalurl);\n $cache_fname = BASE.'tmp/cache/'.$gcal_cname.\".cache\";\n if (file_exists($cache_fname)) {\n $cache = unserialize(file_get_contents($cache_fname));\n if ($startdate >= $cache['start_date'] || $startdate >= $cache['first_date']) {\n $events = $db->selectObjects('event_cache','feed=\"'.$extgcalurl.'\" AND ' . self::build_daterange_sql($startdate,$enddate,'eventdate',true));\n foreach ($events as $event) {\n if ($multiday) {\n $extevents[$event->eventdate][$dy] = $event;\n $extevents[$event->eventdate][$dy]->feedkey = $key;\n $extevents[$event->eventdate][$dy]->location_data = 'gcalevent' . $key;\n $extevents[$event->eventdate][$dy]->color = !empty($this->config['pull_gcal_color'][$key]) ? $this->config['pull_gcal_color'][$key] : null;\n if ($event->is_allday) {\n $extevents[$event->eventdate][$dy]->eventstart = $event->eventdate;\n }\n $dy++;\n } else {\n $endit = !empty($event->dateFinished) ? $event->dateFinished : $event->eventdate;\n// for ($i = $startdate; $i < $enddate; $i += 86400) {\n for ($i = $event->eventdate; $i <= $endit; $i += 86400) {\n if ((!empty($event->dateFinished) && $i > $event->dateFinished) || (empty($event->dateFinished) && $i > $event->eventdate)) {\n break;\n } else {\n $extevents[$i][$dy] = clone($event);\n $extevents[$i][$dy]->eventdate = (int)$i;\n $extevents[$i][$dy]->eventstart = ($event->eventstart - $event->eventdate);\n $extevents[$i][$dy]->eventend = ($event->eventend - (!empty($event->dateFinished)?$event->dateFinished:$event->eventdate));\n $extevents[$i][$dy]->eventstart = ($extevents[$i][$dy]->eventstart) + $i;\n $extevents[$i][$dy]->eventend = ($extevents[$i][$dy]->eventend) + $i;\n $extevents[$i][$dy]->feedkey = $key;\n $extevents[$i][$dy]->location_data = 'gcalevent' . $key;\n $extevents[$i][$dy]->color = !empty($this->config['pull_gcal_color'][$key]) ? $this->config['pull_gcal_color'][$key] : null;\n $dy++;\n }\n }\n }\n }\n $cache_hit = true;\n }\n }\n if (!$cache_hit) { // pull in the external events\n foreach ($this->get_gcal_events($extgcalurl, $startdate, $enddate, $dy, $key, $multiday) as $date=>$events) {\n foreach ($events as $event) {\n $extevents[$date][] = $event;\n }\n }\n }\n }\n if (!empty($this->config['pull_ical'])) foreach ($this->config['pull_ical'] as $key=>$exticalurl) {\n// $dy = count($extevents); // index of events array\n $cache_hit = false;\n $ical_cname = str_replace(array(\"/\",\":\",\"&\",\"?\"),\"_\",$exticalurl);\n $cache_fname = BASE.'tmp/cache/'.$ical_cname.\".cache\";\n if (file_exists($cache_fname)) {\n $cache = unserialize(file_get_contents($cache_fname));\n if ($startdate >= $cache['start_date'] || $startdate >= $cache['first_date']) {\n $events = $db->selectObjects('event_cache','feed=\"'.$exticalurl.'\" AND ' . self::build_daterange_sql($startdate,$enddate,'eventdate',true));\n foreach ($events as $event) {\n $extevents[$event->eventdate][$dy] = $event;\n $extevents[$event->eventdate][$dy]->location_data = 'icalevent' . $key;\n $extevents[$event->eventdate][$dy]->color = !empty($this->config['pull_ical_color'][$key]) ? $this->config['pull_ical_color'][$key] : null;\n $dy++;\n }\n $cache_hit = true;\n }\n }\n if (!$cache_hit) { // pull in the external events\n foreach ($this->get_ical_events($exticalurl, $startdate, $enddate, $dy, $key, $multiday) as $date=>$events) {\n foreach ($events as $event) {\n $extevents[$date][] = $event;\n }\n }\n }\n }\n return $extevents;\n }",
" public function get_gcal_events($extgcalurl, $startdate, $enddate=null, &$dy=0, $key=0, $multiday=false) {\n $extevents = array();\n if (!empty($startdate)) $begin = date(\"Y-m-d\\Th:i:sP\", expDateTime::startOfDayTimestamp($startdate));\n if (!empty($enddate)) $end = date(\"Y-m-d\\Th:i:sP\", expDateTime::endOfDayTimestamp($enddate));\n else $end = date(\"Y-m-d\\Th:i:sP\", (expDateTime::endOfDayTimestamp($startdate + ((3600*24)*30))));",
" if (substr($extgcalurl, -5) == 'basic') {\n $extgcalurl = substr($extgcalurl, 0, - 5) . 'full';\n }\n $feed = $extgcalurl . \"?orderby=starttime&singleevents=true\";\n if (!empty($startdate)) $feed .= \"&start-min=\" . $begin;\n if (!empty($enddate)) $feed .= \"&start-max=\" . $end;",
" // XML method\n// $s = simplexml_load_file($feed);\n// foreach ($s->entry as $item) {\n// $gd = $item->children('http://schemas.google.com/g/2005');\n// if (!empty($gd->when)) {\n// $dtstart = $gd->when->attributes()->startTime;\n// } elseif (!empty($gd->recurrence)){\n// $dtstart = $gd->recurrence->when->attributes()->startTime;\n// } else {\n// $dtstart = $item->attributes()->When;\n// }\n// //FIXME must convert $dtstart timezone\n// $eventdate = expDateTime::startOfDayTimestamp(strtotime($dtstart));\n// $ourtzoffsets = (int)(date('O',$eventdate)) * 36;\n// $theirtzoffset = -((int)(substr($dtstart,-5,2)) * 3600);\n// $tzoffset = $ourtzoffsets - $theirtzoffset;\n// $extevents[$eventdate][$dy] = new stdClass();\n// $extevents[$eventdate][$dy]->eventdate = $eventdate;\n// $extevents[$eventdate][$dy]->eventstart += strtotime($dtstart) + $tzoffset;\n// if (!empty($gd->when)) {\n// $dtend = $gd->when->attributes()->endTime;\n// } elseif (!empty($gd->recurrence)) {\n// $dtend = $gd->recurrence->when->attributes()->endTime;\n// }\n// //FIXME must convert $dtend timezone\n// if (!empty($dtend)) $extevents[$eventdate][$dy]->eventend += strtotime($dtend) + $tzoffset;\n// // dtstart required, one occurrence, (orig. start date)\n// $extevents[$eventdate][$dy]->title = $item->title;\n// $extevents[$eventdate][$dy]->body = $item->content;\n // End XML method",
" // DOM method\n $doc = new DOMDocument();\n $doc->load($feed);\n $entries = $doc->getElementsByTagName(\"entry\");\n foreach ($entries as $item) {\n $times = $item->getElementsByTagName(\"when\");\n $dtstart = $times->item(0)->getAttributeNode(\"startTime\")->value;\n $eventdate = expDateTime::startOfDayTimestamp(strtotime($dtstart));\n $extevents[$eventdate][$dy] = new stdClass();\n $extevents[$eventdate][$dy]->eventdate = $eventdate;\n $dtend = @$times->item(0)->getAttributeNode(\"endTime\")->value;\n $ourtzoffsets = (int)date('O',$eventdate) * 36;\n $theirtzoffset = -((int)substr($dtstart,-5,2) * 3600);\n $tzoffset = $ourtzoffsets - $theirtzoffset;\n if (strlen($dtstart) > 10) {\n $extevents[$eventdate][$dy]->eventstart = ((int)substr($dtstart, 11, 2) * 3600) + ((int)substr($dtstart, 14, 2) * 60) + $tzoffset;\n// if (date(\"I\", $eventdate)) $extevents[$eventdate][$dy]->eventstart += 3600;\n $extevents[$eventdate][$dy]->eventend = ((int)substr($dtend, 11, 2) * 3600) + ((int)substr($dtend, 14, 2) * 60) + $tzoffset;\n// if (date(\"I\", $eventdate)) $extevents[$eventdate][$dy]->eventend += 3600;\n } else {\n $extevents[$eventdate][$dy]->eventstart = null;\n $extevents[$eventdate][$dy]->is_allday = 1;\n }\n $extevents[$eventdate][$dy]->eventstart += $eventdate;\n $extevents[$eventdate][$dy]->eventend += $eventdate;\n if (empty($dtend)) $extevents[$eventdate][$dy]->eventend = $extevents[$eventdate][$dy]->eventstart;",
" $titles = $item->getElementsByTagName(\"title\");\n $extevents[$eventdate][$dy]->title = $titles->item(0)->nodeValue;\n $contents = $item->getElementsByTagName(\"content\");\n $extevents[$eventdate][$dy]->body = $contents->item(0)->nodeValue;\n // End DOM method",
"// $extevents[$eventdate][$dy]->location_data = serialize(expCore::makeLocation('extevent',$extcal->id));\n $extevents[$eventdate][$dy]->location_data = 'gcalevent' . $key;\n $extevents[$eventdate][$dy]->color = !empty($this->config['pull_gcal_color'][$key]) ? $this->config['pull_gcal_color'][$key] : null;\n $dy++;\n }\n return $extevents;\n }",
" public function get_ical_events($exticalurl, $startdate=null, $enddate=null, &$dy=0, $key=0, $multiday=false) {\n $extevents = array();\n// require_once BASE . 'external/iCalcreator.class.php';\n require_once BASE . 'external/iCalcreator-2.22/iCalcreator.php';\n $v = new vcalendar(); // initiate new CALENDAR\n if (stripos($exticalurl, 'http') === 0) {\n $v->setConfig('url', $exticalurl);\n } else {\n $v->setConfig('directory', dirname($exticalurl));\n $v->setConfig('filename', basename($exticalurl));\n }\n $v->parse();\n if ($startdate === null) {\n $startYear = false;\n $startMonth = false;\n $startDay = false;\n } else {\n $startYear = date('Y', $startdate);\n $startMonth = date('n', $startdate);\n $startDay = date('j', $startdate);\n }\n if ($enddate === null) {\n $endYear = $startYear+1;\n $endMonth = $startMonth;\n $endDay = $startDay;\n } else {\n $endYear = date('Y', $enddate);\n $endMonth = date('n', $enddate);\n $endDay = date('j', $enddate);\n }\n // get all events within period split out recurring events as single events per each day\n $eventArray = $v->selectComponents($startYear, $startMonth, $startDay, $endYear, $endMonth, $endDay, 'vevent');\n // Set the timezone to GMT\n @date_default_timezone_set('GMT');\n $tzarray = getTimezonesAsDateArrays($v);\n // Set the default timezone\n @date_default_timezone_set(DISPLAY_DEFAULT_TIMEZONE);\n if (!empty($eventArray)) foreach ($eventArray as $year => $yearArray) {\n if (!empty($yearArray)) foreach ($yearArray as $month => $monthArray) {\n if (!empty($monthArray)) foreach ($monthArray as $day => $dailyEventsArray) {\n if (!empty($dailyEventsArray)) foreach ($dailyEventsArray as $vevent) {\n // process each event\n $yesterday = false;\n $currdate = $vevent->getProperty('x-current-dtstart');\n $thisday = explode('-', $currdate[1]);\n $thisday2 = substr($thisday[2], 0, 2);\n // if member of a recurrence set,\n // returns array( 'x-current-dtstart', <DATE>)\n // <DATE> = (string) date(\"Y-m-d [H:i:s][timezone/UTC offset]\")\n $dtstart = $vevent->getProperty('dtstart', false, true);\n $dtend = $vevent->getProperty('dtend', false, true);\n if (empty($dtend))\n $dtend = $dtstart;",
" // calculate the cumulative timezone offset in seconds to convert to local/system time\n $tzoffsets = array();\n $date_tzoffset = 0;\n if (!empty($tzarray)) {\n// $ourtzoffsets = -(iCalUtilityFunctions::_tz2offset(date('O',time())));\n $ourtzoffsets = -(iCalUtilityFunctions::_tz2offset(date('O',self::_date2timestamp($dtstart['value']))));\n // Set the timezone to GMT\n @date_default_timezone_set('GMT');\n if (!empty($dtstart['params']['TZID'])) $tzoffsets = getTzOffsetForDate($tzarray, $dtstart['params']['TZID'], $dtstart['value']);\n // Set the default timezone\n @date_default_timezone_set(DISPLAY_DEFAULT_TIMEZONE);\n if (isset($tzoffsets['offsetSec'])) $date_tzoffset = $ourtzoffsets + $tzoffsets['offsetSec'];\n }\n if (empty($tzoffsets)) {\n $date_tzoffset = -(iCalUtilityFunctions::_tz2offset(date('O',self::_date2timestamp($dtstart['value']))));\n }\n //FIXME we must have the real timezone offset for the date by this point",
" //FIXME this is for the google ical feed which is bad!\n if ($dtstart['value']['day'] != (int)$thisday2 && (isset($dtstart['value']['day']) && isset($dtend['value']['hour']))&&\n !((int)$dtstart['value']['hour'] == 0 && (int)$dtstart['value']['min'] == 0 && (int)$dtstart['value']['sec'] == 0\n && (int)$dtend['value']['hour'] == 0 && (int)$dtend['value']['min'] == 0 && (int)$dtend['value']['sec'] == 0\n && ((((int)$dtstart['value']['day'] - (int)$dtend['value']['day']) == -1) || (((int)$dtstart['value']['month'] - (int)$dtend['value']['month']) == -1) || (((int)$dtstart['value']['month'] - (int)$dtend['value']['month']) == -11)))) {\n $dtst = strtotime($currdate[1]);\n $dtst1 = iCalUtilityFunctions::_timestamp2date($dtst);\n $dtstart['value']['year'] = $dtst1['year'];\n $dtstart['value']['month'] = $dtst1['month'];\n $dtstart['value']['day'] = $dtst1['day'];\n $currenddate = $vevent->getProperty('x-current-dtend');\n $dtet = strtotime($currenddate[1]);\n $dtet1 = iCalUtilityFunctions::_timestamp2date($dtet);\n $dtend['value']['year'] = $dtet1['year'];\n $dtend['value']['month'] = $dtet1['month'];\n $dtend['value']['day'] = $dtet1['day'];\n// $date_tzoffset = 0;\n }",
" if (!empty($dtstart['value']['hour']) && !((int)$dtstart['value']['hour'] == 0 && (int)$dtstart['value']['min'] == 0 && (int)$dtstart['value']['sec'] == 0\n && (int)$dtend['value']['hour'] == 0 && (int)$dtend['value']['min'] == 0 && (int)$dtend['value']['sec'] == 0\n && ((((int)$dtstart['value']['day'] - (int)$dtend['value']['day']) == -1) || (((int)$dtstart['value']['month'] - (int)$dtend['value']['month']) == -1) || (((int)$dtstart['value']['month'] - (int)$dtend['value']['month']) == -11)))) {\n $eventdate = expDateTime::startOfDayTimestamp(self::_date2timestamp($dtstart['value']) - $date_tzoffset);\n// $eventend = expDateTime::startOfDayTimestamp(self::_date2timestamp($dtend['value']) - $date_tzoffset);\n $extevents[$eventdate][$dy] = new stdClass();\n $extevents[$eventdate][$dy]->eventdate = new stdClass();\n $extevents[$eventdate][$dy]->eventdate->date = $eventdate;\n// if ((int)($dtstart['value']['hour']) == 0 && (int)($dtstart['value']['min']) == 0 && (int)($dtstart['value']['sec']) == 0\n// && (int)($dtend['value']['hour']) == 0 && (int)($dtend['value']['min']) == 0 && (int)($dtend['value']['sec']) == 0\n// && ((((int)($dtstart['value']['day']) - (int)($dtend['value']['day'])) == -1) || (((int)($dtstart['value']['month']) - (int)($dtend['value']['month'])) == -1) || (((int)($dtstart['value']['month']) - (int)($dtend['value']['month'])) == -11))) {\n//// if ($dtstart['value']['day'] != (int)($thisday2)) {\n// if (date('d',$eventdate) != $thisday2) {\n//// if (date('d',$eventdate) != date('d',$eventend)) {\n// $yesterday = true;\n// } else {\n// $extevents[$eventdate][$dy]->eventstart = null;\n// $extevents[$eventdate][$dy]->is_allday = 1;\n// }\n// } else {\n if (date('d',$eventdate) != $thisday2) {\n// if (date('d',$eventdate) != date('d',$eventend)) {\n $yesterday = true;\n } else {\n $extevents[$eventdate][$dy]->eventstart = ($dtstart['value']['hour'] * 3600) + ($dtstart['value']['min'] * 60) - $date_tzoffset;\n// if (date(\"I\", $eventdate)) $extevents[$eventdate][$dy]->eventstart += 3600; // adjust for daylight savings time\n }\n// }\n } else {\n // this is an all day event\n $eventdate = expDateTime::startOfDayTimestamp(self::_date2timestamp($dtstart['value']));\n// $eventend = expDateTime::startOfDayTimestamp(self::_date2timestamp($dtend['value']));\n $extevents[$eventdate][$dy] = new stdClass();\n $extevents[$eventdate][$dy]->eventdate = new stdClass();\n $extevents[$eventdate][$dy]->eventdate->date = $eventdate;\n// if ($dtstart['value']['day'] != (int)($thisday2)) {\n if (date('d',$eventdate) != $thisday2) {\n// if (date('d',$eventdate) != date('d',$eventend)) {\n $yesterday = true;\n } else {\n $extevents[$eventdate][$dy]->eventstart = null;\n $extevents[$eventdate][$dy]->is_allday = 1;\n }\n }",
" // set the end time if needed\n if (!$yesterday && isset($dtend['value']['hour']) && empty($extevents[$eventdate][$dy]->is_allday)) {\n// if ($dtend['value']['day'] != (int)($thisday2)) {\n// if ((date('d',$eventend) != $thisday2)) {\n// $yesterday = true;\n// } else {\n $extevents[$eventdate][$dy]->eventend = ($dtend['value']['hour'] * 3600) + ($dtend['value']['min'] * 60) - $date_tzoffset;\n// if (date(\"I\", $eventdate)) $extevents[$eventdate][$dy]->eventend += 3600; // adjust for daylight savings time\n// }\n }",
" // convert the start and end times to a full date\n if (isset($extevents[$eventdate][$dy]->eventstart) && $extevents[$eventdate][$dy]->eventstart != null)\n $extevents[$eventdate][$dy]->eventstart += $eventdate;\n if (isset($extevents[$eventdate][$dy]->eventend))\n $extevents[$eventdate][$dy]->eventend += $eventdate;",
" // dtstart required, one occurrence, (orig. start date)\n $extevents[$eventdate][$dy]->title = $vevent->getProperty('summary');\n $body = $vevent->getProperty('description');\n // convert end of lines\n $body = nl2br(str_replace(\"\\\\n\",\" <br>\\n\",$body));\n $body = str_replace(\"\\n\",\" <br>\\n\",$body);\n $body = str_replace(array('==0A','=0A','=C2=A0'),\" <br>\\n\",$body);\n $extevents[$eventdate][$dy]->body = $body;\n $extevents[$eventdate][$dy]->location_data = 'icalevent' . $key;\n $extevents[$eventdate][$dy]->color = !empty($this->config['pull_ical_color'][$key]) ? $this->config['pull_ical_color'][$key] : null;\n if (!$yesterday && $eventdate >= $startdate) {\n $dy++;\n } else {\n unset($extevents[$eventdate][$dy]);\n }\n }\n }\n }\n }\n return $extevents;\n }",
" public static function _date2timestamp( $datetime, $wtz=null ) {\n if( !isset( $datetime['hour'] )) $datetime['hour'] = 0;\n if( !isset( $datetime['min'] )) $datetime['min'] = 0;\n if( !isset( $datetime['sec'] )) $datetime['sec'] = 0;\n if( empty( $wtz ) && ( !isset( $datetime['tz'] ) || empty( $datetime['tz'] )))\n return mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year'] );\n $output = $offset = 0;\n if( empty( $wtz )) {\n if( iCalUtilityFunctions::_isOffset( $datetime['tz'] )) {\n $offset = iCalUtilityFunctions::_tz2offset( $datetime['tz'] ) * -1;\n $wtz = 'UTC';\n }\n else\n $wtz = $datetime['tz'];\n }\n if(( 'Z' == $wtz ) || ( 'GMT' == strtoupper( $wtz )))\n $wtz = 'UTC';\n try {\n $strdate = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['min'], $datetime['sec'] );\n $d = new DateTime( $strdate, new DateTimeZone( $wtz ));\n if( 0 != $offset ) // adjust for offset\n $d->modify( $offset.' seconds' );\n $output = $d->format( 'U' );\n unset( $d );\n }\n catch( Exception $e ) {\n $output = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year'] );\n }\n return $output;\n }",
" /**\n * build/update the external event cache\n *\n */\n public function build_cache() {\n global $db;",
" // get our requested config\n $cfg = new expConfig();\n $configs = $cfg->find('all', \"location_data LIKE '%event%'\"); // get all event module configs\n foreach ($configs as $config) {\n $loc = expUnserialize($config->location_data);\n if (!empty($this->params['title'])) {\n if ($this->params['title'] == $config->config['feed_sef_url']) {\n $this->config = $config->config;\n break;\n }\n } elseif (!empty($this->params['src'])) {\n if ($this->params['src'] == $loc->src) {\n $this->config = $config->config;\n break;\n }\n }\n }",
" // next loop through our config pull urls",
" // google xml pull\n if (!empty($this->config['pull_gcal'])) foreach ($this->config['pull_gcal'] as $key=>$extgcalurl) {\n $start = expDateTime::startOfMonthTimestamp(time());\n $gcal_cname = str_replace(array(\"/\",\":\",\"&\",\"?\"),\"_\",$extgcalurl);\n $cache_fname = BASE.'tmp/cache/'.$gcal_cname.\".cache\";\n $db->delete('event_cache', \"feed='\" . $extgcalurl . \"' AND eventdate > \" . $start); // replace future events\n // loop through 12 months, 1 month at a time\n for ($i=1; $i < 13; $i++) {\n $end = expDateTime::endOfMonthTimestamp($start);\n $tmp = 0;\n $extevents = $this->get_gcal_events($extgcalurl, $start, $end, $tmp, 0, true);\n// $extevents = $this->get_gcal_events($extgcalurl, null, null, 0, 0, 0, true);\n foreach ($extevents as $day) {\n foreach ($day as $extevent) {\n $event_cache = new stdClass();\n $event_cache->feed = $extgcalurl;\n $event_cache->event_id = $extevent->event_id;\n $event_cache->title = $extevent->title;\n $event_cache->body = $extevent->body;\n $event_cache->eventdate = $extevent->eventdate->date;\n if (isset($extevent->dateFinished) && $extevent->dateFinished != -68400)\n $event_cache->dateFinished = $extevent->dateFinished;\n if (isset($extevent->eventstart))\n $event_cache->eventstart = $extevent->eventstart;\n if (isset($extevent->eventend))\n $event_cache->eventend = $extevent->eventend;\n if (isset($extevent->is_allday))\n $event_cache->is_allday = $extevent->is_allday;\n $found = false;\n if ($extevent->eventdate->date < $start) // prevent duplicating events crossing month boundaries\n $found = $db->selectObject('event_cache','feed=\"'.$extgcalurl.'\" AND event_id=\"'.$event_cache->event_id.'\" AND eventdate='.$event_cache->eventdate);\n if (!$found)\n $db->insertObject($event_cache,'event_cache');\n }\n }\n $start = expDateTime::startOfMonthTimestamp($end + 1024);\n }\n $cache_contents = serialize(array('start_date'=>$start,'first_date'=>(int)$db->selectValue('event_cache','eventdate','feed=\"'.$extgcalurl.'\" ORDER BY eventdate'),'refresh_date'=>time()));\n file_put_contents($cache_fname, $cache_contents);\n }",
" // ical pull\n $start = expDateTime::startOfMonthTimestamp(time());\n if (!empty($this->config['pull_ical'])) foreach ($this->config['pull_ical'] as $key=>$exticalurl) {\n $ical_cname = str_replace(array(\"/\",\":\",\"&\",\"?\"),\"_\",$exticalurl);\n $cache_fname = BASE.'tmp/cache/'.$ical_cname.\".cache\";\n $db->delete('event_cache', \"feed='\" . $exticalurl . \"' AND eventdate > \" . $start);\n // get 1 years worth of events\n $extevents = $this->get_ical_events($exticalurl, $start);\n foreach ($extevents as $day) {\n foreach ($day as $extevent) {\n $event_cache = new stdClass();\n $event_cache->feed = $exticalurl;\n $event_cache->title = $extevent->title;\n $event_cache->body = $extevent->body;\n $event_cache->eventdate = $extevent->eventdate->date;\n if (isset($extevent->dateFinished))\n $event_cache->dateFinished = $extevent->dateFinished;\n $event_cache->eventstart = $extevent->eventstart;\n if (isset($extevent->eventend))\n $event_cache->eventend = $extevent->eventend;\n if (isset($extevent->is_allday))\n $event_cache->is_allday = $extevent->is_allday;\n $db->insertObject($event_cache, 'event_cache');\n }\n }\n $cache_contents = serialize(array('start_date'=>$start,'first_date'=>(int)$db->selectValue('event_cache','eventdate','feed=\"'.$exticalurl.'\" ORDER BY eventdate'),'refresh_date'=>time()));\n file_put_contents($cache_fname, $cache_contents);\n }\n flash('message', gt('External Calendar Event cache updated'));\n echo show_msg_queue();\n }",
" function import() {\n $pullable_modules = expModules::listInstalledControllers($this->baseclassname);\n $modules = new expPaginator(array(\n 'records' => $pullable_modules,\n 'controller' => $this->loc->mod,\n 'action' => $this->params['action'],\n 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\n 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Title') => 'title',\n gt('Page') => 'section'\n ),\n ));",
" assign_to_template(array(\n 'modules' => $modules,\n ));\n }",
" function import_select()\n {\n if (empty($this->params['import_aggregate'])) {\n expValidator::setErrorField('import_aggregate[]');\n expValidator::failAndReturnToForm(gt('You must select a module.'), $this->params);\n }\n $extevents = array();\n unset(\n $this->params['begin'],\n $this->params['end']\n ); // always use date value\n $begin = yuidatetimecontrol::parseData('begin', $this->params);\n $end = yuidatetimecontrol::parseData('end', $this->params);\n if ($this->params['file_type'] == 'file') {\n //Get the temp directory to put the uploaded file\n $directory = \"tmp\";",
" //Get the file save it to the temp directory\n if (!empty($_FILES[\"import_file\"]) && $_FILES[\"import_file\"][\"error\"] == UPLOAD_ERR_OK) {\n $file = expFile::fileUpload(\n \"import_file\",\n false,\n false,\n time() . \"_\" . $_FILES['import_file']['name'],\n $directory . '/'\n );\n if ($file === null) {\n switch ($_FILES[\"import_file\"][\"error\"]) {\n case UPLOAD_ERR_INI_SIZE:\n case UPLOAD_ERR_FORM_SIZE:\n $this->params['_formError'] = gt(\n 'The file you attempted to upload is too large. Contact your system administrator if this is a problem.'\n );\n break;\n case UPLOAD_ERR_PARTIAL:\n $this->params['_formError'] = gt('The file was only partially uploaded.');\n break;\n case UPLOAD_ERR_NO_FILE:\n $this->params['_formError'] = gt('No file was uploaded.');\n break;\n default:\n $this->params['_formError'] = gt(\n 'A strange internal error has occurred. Please contact the Exponent Developers.'\n );\n break;\n }\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n } else {\n $extevents = $this->get_ical_events($directory . \"/\" . $file->filename, $begin, $end);\n }\n } else {\n expValidator::setErrorField('import_file');\n expValidator::failAndReturnToForm(gt('File failed to upload.'), $this->params); // file upload error\n }\n } else {\n if (empty($this->params['ext_feed'])) {\n expValidator::setErrorField('ext_feed');\n expValidator::failAndReturnToForm(gt('You must enter a feed url.'), $this->params);\n }\n $extevents = $this->get_ical_events($this->params['ext_feed'], $begin, $end);\n }",
" $src = $this->params['import_aggregate'][0];\n $count = 0;\n foreach ($extevents as $day) {\n foreach ($day as $extevent) {\n $event = array();\n $event['title'] = $extevent->title;\n $event['body'] = $extevent->body;\n $event['eventdate'] = $extevent->eventdate->date;\n $event['eventstart'] = $extevent->eventstart;\n $event['eventstart'] -= $event['eventdate'];\n if (isset($extevent->eventend))\n $event['eventend'] = $extevent->eventend;\n else\n $event['eventend'] = $extevent->eventstart;\n $event['eventend'] -= $event['eventdate'];\n if (isset($extevent->is_allday))\n $event['is_allday'] = $extevent->is_allday;\n $event['module'] = 'event';\n $event['src'] = $src;\n $item = new event(); // create new populated record to auto-set things\n $item->update($event);\n $count++;\n }\n }",
" unlink($directory . \"/\" . $file->filename);",
" // update search index\n $this->addContentToSearch();",
" flashAndFlow('message', $count . ' ' . gt('events were imported.'));\n }",
" /** @deprecated\n * function to build a control requested via ajax\n * we the html just like the control smarty function\n * @deprecated\n */\n public function buildControl() {\n $control = new colorcontrol();\n if (!empty($this->params['value'])) $control->value = $this->params['value'];\n if ($this->params['value'][0] != '#') $this->params['value'] = '#' . $this->params['value'];\n $control->default = $this->params['value'];\n if (!empty($this->params['hide'])) $control->hide = $this->params['hide'];\n if (isset($this->params['flip'])) $control->flip = $this->params['flip'];\n $this->params['name'] = !empty($this->params['name']) ? $this->params['name'] : '';\n $control->name = $this->params['name'];\n $this->params['id'] = !empty($this->params['id']) ? $this->params['id'] : '';\n $control->id = isset($this->params['id']) && $this->params['id'] != \"\" ? $this->params['id'] : \"\";\n //echo $control->id;\n if (empty($control->id)) $control->id = $this->params['name'];\n if (empty($control->name)) $control->name = $this->params['id'];",
" // attempt to translate the label\n if (!empty($this->params['label'])) {\n $this->params['label'] = gt($this->params['label']);\n } else {\n $this->params['label'] = null;\n }\n echo $control->toHTML($this->params['label'], $this->params['name']);\n// $ar = new expAjaxReply(200, gt('The control was created'), json_encode(array('data'=>$code)));\n// $ar->send();\n }",
"}\n",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Models\n * @package Modules\n */",
"class event extends expRecord {\n public $has_many = array('eventdate');\n protected $attachable_item_types = array(\n 'content_expCats'=>'expCat',\n 'content_expFiles'=>'expFile',\n 'content_expTags'=>'expTag'\n );",
" /**\n * Events have special circumstances since they are based on dates\n * 'upcoming', 'month', 'week', 'day', etc...\n *\n * @param string $range\n * @param null $where\n * @param null $order\n * @param null $limit\n * @param int $limitstart\n * @param bool $get_assoc\n * @param bool $get_attached\n * @param array $except\n * @param bool $cascade_except\n * @return array\n */\n public function find($range = 'all', $where = null, $order = null, $limit = null, $limitstart = 0, $get_assoc = true, $get_attached = true, $except = array(), $cascade_except = false)\n {\n if (is_numeric($range) || in_array($range, array('all', 'first', 'bytitle', 'count', 'in', 'bytag', 'bycat'))) {\n return parent::find($range, $where, $order, $limit, $limitstart, $get_assoc, $get_attached, $except, $cascade_except);\n } else { // 'upcoming', 'month', 'week', 'day', etc...\n //note $order is boolean for 'featured'\n //note $limit is number of days, NOT number of records\n //note $limitstart is a unixtimestamp in this instance",
"",
" $ed = new eventdate();\n $day = expDateTime::startOfDayTimestamp(time());\n $sort_asc = true; // For the getEventsForDates call\n if (strcasecmp($range, 'upcoming') == 0) {\n if (!empty($limit)) {\n $eventlimit = \" AND date <= \" . ($day + ($limit * 86400));\n } else {\n $eventlimit = \"\";\n }\n $dates = $ed->find(\"all\", $where . \" AND date >= \" . $day . $eventlimit . \" ORDER BY date ASC \");\n// $begin = $day;\n// $end = null;\n $items = $this->getEventsForDates($dates, $sort_asc, $order ? true : false, true);",
" ",
" // external events\n// $extitems = $this->getExternalEvents($begin, $end);\n // we need to crunch these down\n// $extitem = array();\n// foreach ($extitems as $days) {\n// foreach ($days as $event) {\n// if (empty($event->eventdate->date) || ($viewrange == 'upcoming' && $event->eventdate->date < time())) break;\n// if (empty($event->eventstart)) $event->eventstart = $event->eventdate->date;\n// $extitem[] = $event;\n// }\n// }\n// $items = array_merge($items, $extitem);",
" ",
" // event registration events\n// if (!empty($this->config['aggregate_registrations'])) $regitems = eventregistrationController::getRegEventsForDates($begin, $end, $regcolor);\n // we need to crunch these down\n// $regitem = array();\n// if (!empty($regitems)) foreach ($regitems as $days) {\n// foreach ($days as $value) {\n// $regitem[] = $value;\n// }\n// }\n// $items = array_merge($items, $regitem);",
" ",
" $items = expSorter::sort(array('array' => $items, 'sortby' => 'eventstart', 'order' => 'ASC'));\n return $items;\n }\n }\n }",
" function getEventsForDates($edates, $sort_asc = true, $featuredonly = false, $condense = false) {\n global $eventid;",
" $events = array();\n $featuresql = \"\";\n if ($featuredonly)\n $featuresql = \" AND is_featured=1\";\n foreach ($edates as $edate) {\n $evs = $this->find('all', \"id=\" . $edate->event_id . $featuresql);\n foreach ($evs as $key=>$event) {\n if ($condense) {\n //fixme we're leaving events which ended earlier in the day which won't be displayed, which therefore cancels out tomorrow's event\n $eventid = $event->id;\n $multiday_event = array_filter($events, create_function('$event', 'global $eventid; return $event->id === $eventid;'));\n if (!empty($multiday_event)) {\n unset($evs[$key]);\n continue;\n }\n }\n $evs[$key]->eventstart += $edate->date;\n $evs[$key]->eventend += $edate->date;\n $evs[$key]->date_id = $edate->id;\n if (!empty($event->expCat)) {\n $catcolor = empty($event->expCat[0]->color) ? null : trim($event->expCat[0]->color);\n// if (substr($catcolor,0,1)=='#') $catcolor = '\" style=\"color:'.$catcolor.';';\n $evs[$key]->color = $catcolor;\n }\n }\n if (count($events) < 500) { // magic number to not crash loop?\n $events = array_merge($events, $evs);\n } else {\n// $evs[$key]->title = gt('Too many events to list').', '.(count($edates)-count($events)).' '.gt('not displayed!');\n// $events = array_merge($events, $evs);\n flash('notice',gt('Too many events to list').', '.(count($edates)-count($events)).' '.gt('not displayed!'));\n break; // keep from breaking system by too much data\n }\n }\n $events = expSorter::sort(array('array' => $events, 'sortby' => 'eventstart', 'order' => $sort_asc ? 'ASC' : 'DESC'));\n return $events;\n }",
" public function update($params = array()) {\n $params['eventstart'] = datetimecontrol::parseData('eventstart',$params);\n $params['eventend'] = datetimecontrol::parseData('eventend',$params);\n $this->checkForAttachableItems($params);\n $this->build($params);\n// $id = !empty($params['id']) ? $params['id'] : null;\n// $calevent = new event($id);\n// $calevent->update($params); // prime the record with the parameters",
" if (!empty($params['id'])) { // update existing event\n $calevent = new eventdate();\n \t\tif (!empty($params['is_recurring'])) {\n \t\t\t// For recurring events, check some stuff.\n \t\t\t// Were all dates selected?\n $eventdates = $calevent->find('all',\"event_id=\".$this->id);\n \t\t\tif (count($params['dates']) != count($eventdates)) { // only part of list changed\n \t\t\t\t// yes. just update the original\n// $calevent->update();\n \t\t\t\t// If the date has changed, modify the current date_id\n// \t\t\t} else { // we've split out dates from original\n \t\t\t\t// No, create new and relink affected dates\n \t\t\t\tunset($this->id);\n// $calevent = new event($params); // create a new event based on parameters\n \t\t\t\tif (count($params['dates']) == 1) $this->is_recurring = 0; // Back to a single event.",
" $this->save(true); // save new event to get an event id",
" unset($params['id']);\n \t\t\t\tforeach (array_keys($params['dates']) as $date_id) { // update all the date occurrences being changed\n $eventdate = $calevent->find('first',\"id=\".$date_id);\n $eventdate->event_id = $this->id;\n if (count($params['dates']) == 1) $eventdate->date = expDateTime::startOfDayTimestamp(yuicalendarcontrol::parseData(\"eventdate\",$params));\n $eventdate->update($params);\n \t\t\t\t}\n \t\t\t} else { // all existing event occurrences have changed\n// \t\t\t $eventdate = $db->selectObject('eventdate','id='.intval($params['date_id']));\n $eventdate = $calevent->find('first','id='.intval($params['date_id']));\n $eventdate->date = expDateTime::startOfDayTimestamp(yuicalendarcontrol::parseData(\"eventdate\",$params));\n $eventdate->update();\n }\n \t\t} else { // not recurring\n// $calevent->update();\n \t\t\t// There should be only one eventdate\n// $eventdate = $calevent->eventdate[0]->find('first','event_id = '.$calevent->id);\n $eventdate = $calevent->find('first','event_id = '.$this->id);\n \t\t\t$eventdate->date = expDateTime::startOfDayTimestamp(yuicalendarcontrol::parseData(\"eventdate\",$params));\n $eventdate->update();\n \t\t}\n \t} else { // new event\n \t\t$start_recur = expDateTime::startOfDayTimestamp(yuicalendarcontrol::parseData(\"eventdate\",$params));\n \t\t$stop_recur = expDateTime::startOfDayTimestamp(yuicalendarcontrol::parseData(\"untildate\",$params));",
" \t\tif (!empty($params['recur']) && $params['recur'] != \"recur_none\") { // recurring event\n \t\t\t// Do recurrence\n $freq = $params['recur_freq_'.$params['recur']];",
" \t\t\tswitch ($params['recur']) {\n \t\t\t\tcase \"recur_daily\":\n \t\t\t\t\t$dates = expDateTime::recurringDailyDates($start_recur,$stop_recur,$freq);\n \t\t\t\t\tbreak;\n \t\t\t\tcase \"recur_weekly\":\n $dateinfo = getdate($start_recur); //FIXME hack in case the day of week wasn't checked off\n \t\t\t\t\t$dates = expDateTime::recurringWeeklyDates($start_recur,$stop_recur,$freq,(!empty($params['day']) ? array_keys($params['day']) : array($dateinfo['wday'])));\n \t\t\t\t\tbreak;\n \t\t\t\tcase \"recur_monthly\":\n \t\t\t\t\t$dates = expDateTime::recurringMonthlyDates($start_recur,$stop_recur,$freq,(!empty($params['month_type'])?$params['month_type']:true));\n \t\t\t\t\tbreak;\n \t\t\t\tcase \"recur_yearly\":\n \t\t\t\t\t$dates = expDateTime::recurringYearlyDates($start_recur,$stop_recur,$freq);\n \t\t\t\t\tbreak;\n \t\t\t\tdefault:\n \t\t\t\t\techo \"Bad type: \" . $params['recur'] . \"<br />\";\n \t\t\t\t\treturn;\n \t\t\t\t\tbreak;\n \t\t\t}",
" $this->is_recurring = 1; // Set the recurrence flag.\n \t\t} else { // not recurring\n \t\t\t$dates = array($start_recur);\n \t\t}\n// $calevent->update($params); // prime the record with the parameters\n $this->save(true);\n \t\tforeach ($dates as $d) {\n $edate = new eventdate(array('event_id'=>$this->id,'location_data'=>$this->location_data,'date'=>$d));\n $edate->update();\n }\n \t}\n// $calevent->update($params);\n // call expController->update() to save the image, is it necessary?\n $this->save(true);\n }",
" public function afterDelete() {\n $ed = new eventdate();\n $dates = $ed->find('all','event_id='.$this->id);\n foreach ($dates as $date) {\n $date->delete();\n }\n }",
" public static function dayNames() {\n $days = array();\n for ($i=0; $i < 7; $i++) {\n $days['short'][$i] = substr(strftime(\"%a\", mktime(0, 0, 0, 6, $i+2, 2013)), 0, 1);\n $days['med'][$i] = strftime(\"%a\", mktime(0, 0, 0, 6, $i+2, 2013));\n $days['long'][$i] = strftime('%A ', mktime(0, 0, 0, 6, $i+2, 2013));\n }\n return $days;\n }",
" ",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Models\n * @package Modules\n */",
"class event extends expRecord {\n public $has_many = array('eventdate');\n protected $attachable_item_types = array(\n 'content_expCats'=>'expCat',\n 'content_expFiles'=>'expFile',\n 'content_expTags'=>'expTag'\n );",
" /**\n * Events have special circumstances since they are based on dates\n * 'upcoming', 'month', 'week', 'day', etc...\n *\n * @param string $range\n * @param null $where\n * @param null $order\n * @param null $limit\n * @param int $limitstart\n * @param bool $get_assoc\n * @param bool $get_attached\n * @param array $except\n * @param bool $cascade_except\n * @return array\n */\n public function find($range = 'all', $where = null, $order = null, $limit = null, $limitstart = 0, $get_assoc = true, $get_attached = true, $except = array(), $cascade_except = false)\n {\n if (is_numeric($range) || in_array($range, array('all', 'first', 'bytitle', 'count', 'in', 'bytag', 'bycat'))) {\n return parent::find($range, $where, $order, $limit, $limitstart, $get_assoc, $get_attached, $except, $cascade_except);\n } else { // 'upcoming', 'month', 'week', 'day', etc...\n //note $order is boolean for 'featured'\n //note $limit is number of days, NOT number of records\n //note $limitstart is a unixtimestamp in this instance",
" $order = expString::escape($order);\n if ($limit !== null)\n $limit = intval($limit);\n if ($limitstart !== null)\n $limitstart = intval($limitstart);",
" $ed = new eventdate();\n $day = expDateTime::startOfDayTimestamp(time());\n $sort_asc = true; // For the getEventsForDates call\n if (strcasecmp($range, 'upcoming') == 0) {\n if (!empty($limit)) {\n $eventlimit = \" AND date <= \" . ($day + ($limit * 86400));\n } else {\n $eventlimit = \"\";\n }\n $dates = $ed->find(\"all\", $where . \" AND date >= \" . $day . $eventlimit . \" ORDER BY date ASC \");\n// $begin = $day;\n// $end = null;\n $items = $this->getEventsForDates($dates, $sort_asc, $order ? true : false, true);",
"",
" // external events\n// $extitems = $this->getExternalEvents($begin, $end);\n // we need to crunch these down\n// $extitem = array();\n// foreach ($extitems as $days) {\n// foreach ($days as $event) {\n// if (empty($event->eventdate->date) || ($viewrange == 'upcoming' && $event->eventdate->date < time())) break;\n// if (empty($event->eventstart)) $event->eventstart = $event->eventdate->date;\n// $extitem[] = $event;\n// }\n// }\n// $items = array_merge($items, $extitem);",
"",
" // event registration events\n// if (!empty($this->config['aggregate_registrations'])) $regitems = eventregistrationController::getRegEventsForDates($begin, $end, $regcolor);\n // we need to crunch these down\n// $regitem = array();\n// if (!empty($regitems)) foreach ($regitems as $days) {\n// foreach ($days as $value) {\n// $regitem[] = $value;\n// }\n// }\n// $items = array_merge($items, $regitem);",
"",
" $items = expSorter::sort(array('array' => $items, 'sortby' => 'eventstart', 'order' => 'ASC'));\n return $items;\n }\n }\n }",
" function getEventsForDates($edates, $sort_asc = true, $featuredonly = false, $condense = false) {\n global $eventid;",
" $events = array();\n $featuresql = \"\";\n if ($featuredonly)\n $featuresql = \" AND is_featured=1\";\n foreach ($edates as $edate) {\n $evs = $this->find('all', \"id=\" . $edate->event_id . $featuresql);\n foreach ($evs as $key=>$event) {\n if ($condense) {\n //fixme we're leaving events which ended earlier in the day which won't be displayed, which therefore cancels out tomorrow's event\n $eventid = $event->id;\n $multiday_event = array_filter($events, create_function('$event', 'global $eventid; return $event->id === $eventid;'));\n if (!empty($multiday_event)) {\n unset($evs[$key]);\n continue;\n }\n }\n $evs[$key]->eventstart += $edate->date;\n $evs[$key]->eventend += $edate->date;\n $evs[$key]->date_id = $edate->id;\n if (!empty($event->expCat)) {\n $catcolor = empty($event->expCat[0]->color) ? null : trim($event->expCat[0]->color);\n// if (substr($catcolor,0,1)=='#') $catcolor = '\" style=\"color:'.$catcolor.';';\n $evs[$key]->color = $catcolor;\n }\n }\n if (count($events) < 500) { // magic number to not crash loop?\n $events = array_merge($events, $evs);\n } else {\n// $evs[$key]->title = gt('Too many events to list').', '.(count($edates)-count($events)).' '.gt('not displayed!');\n// $events = array_merge($events, $evs);\n flash('notice',gt('Too many events to list').', '.(count($edates)-count($events)).' '.gt('not displayed!'));\n break; // keep from breaking system by too much data\n }\n }\n $events = expSorter::sort(array('array' => $events, 'sortby' => 'eventstart', 'order' => $sort_asc ? 'ASC' : 'DESC'));\n return $events;\n }",
" public function update($params = array()) {\n $params['eventstart'] = datetimecontrol::parseData('eventstart',$params);\n $params['eventend'] = datetimecontrol::parseData('eventend',$params);\n $this->checkForAttachableItems($params);\n $this->build($params);\n// $id = !empty($params['id']) ? $params['id'] : null;\n// $calevent = new event($id);\n// $calevent->update($params); // prime the record with the parameters",
" if (!empty($params['id'])) { // update existing event\n $calevent = new eventdate();\n \t\tif (!empty($params['is_recurring'])) {\n \t\t\t// For recurring events, check some stuff.\n \t\t\t// Were all dates selected?\n $eventdates = $calevent->find('all',\"event_id=\".$this->id);\n \t\t\tif (count($params['dates']) != count($eventdates)) { // only part of list changed\n \t\t\t\t// yes. just update the original\n// $calevent->update();\n \t\t\t\t// If the date has changed, modify the current date_id\n// \t\t\t} else { // we've split out dates from original\n \t\t\t\t// No, create new and relink affected dates\n \t\t\t\tunset($this->id);\n// $calevent = new event($params); // create a new event based on parameters\n \t\t\t\tif (count($params['dates']) == 1) $this->is_recurring = 0; // Back to a single event.",
" $this->save(true); // save new event to get an event id",
" unset($params['id']);\n \t\t\t\tforeach (array_keys($params['dates']) as $date_id) { // update all the date occurrences being changed\n $eventdate = $calevent->find('first',\"id=\".$date_id);\n $eventdate->event_id = $this->id;\n if (count($params['dates']) == 1) $eventdate->date = expDateTime::startOfDayTimestamp(yuicalendarcontrol::parseData(\"eventdate\",$params));\n $eventdate->update($params);\n \t\t\t\t}\n \t\t\t} else { // all existing event occurrences have changed\n// \t\t\t $eventdate = $db->selectObject('eventdate','id='.intval($params['date_id']));\n $eventdate = $calevent->find('first','id='.intval($params['date_id']));\n $eventdate->date = expDateTime::startOfDayTimestamp(yuicalendarcontrol::parseData(\"eventdate\",$params));\n $eventdate->update();\n }\n \t\t} else { // not recurring\n// $calevent->update();\n \t\t\t// There should be only one eventdate\n// $eventdate = $calevent->eventdate[0]->find('first','event_id = '.$calevent->id);\n $eventdate = $calevent->find('first','event_id = '.$this->id);\n \t\t\t$eventdate->date = expDateTime::startOfDayTimestamp(yuicalendarcontrol::parseData(\"eventdate\",$params));\n $eventdate->update();\n \t\t}\n \t} else { // new event\n \t\t$start_recur = expDateTime::startOfDayTimestamp(yuicalendarcontrol::parseData(\"eventdate\",$params));\n \t\t$stop_recur = expDateTime::startOfDayTimestamp(yuicalendarcontrol::parseData(\"untildate\",$params));",
" \t\tif (!empty($params['recur']) && $params['recur'] != \"recur_none\") { // recurring event\n \t\t\t// Do recurrence\n $freq = $params['recur_freq_'.$params['recur']];",
" \t\t\tswitch ($params['recur']) {\n \t\t\t\tcase \"recur_daily\":\n \t\t\t\t\t$dates = expDateTime::recurringDailyDates($start_recur,$stop_recur,$freq);\n \t\t\t\t\tbreak;\n \t\t\t\tcase \"recur_weekly\":\n $dateinfo = getdate($start_recur); //FIXME hack in case the day of week wasn't checked off\n \t\t\t\t\t$dates = expDateTime::recurringWeeklyDates($start_recur,$stop_recur,$freq,(!empty($params['day']) ? array_keys($params['day']) : array($dateinfo['wday'])));\n \t\t\t\t\tbreak;\n \t\t\t\tcase \"recur_monthly\":\n \t\t\t\t\t$dates = expDateTime::recurringMonthlyDates($start_recur,$stop_recur,$freq,(!empty($params['month_type'])?$params['month_type']:true));\n \t\t\t\t\tbreak;\n \t\t\t\tcase \"recur_yearly\":\n \t\t\t\t\t$dates = expDateTime::recurringYearlyDates($start_recur,$stop_recur,$freq);\n \t\t\t\t\tbreak;\n \t\t\t\tdefault:\n \t\t\t\t\techo \"Bad type: \" . $params['recur'] . \"<br />\";\n \t\t\t\t\treturn;\n \t\t\t\t\tbreak;\n \t\t\t}",
" $this->is_recurring = 1; // Set the recurrence flag.\n \t\t} else { // not recurring\n \t\t\t$dates = array($start_recur);\n \t\t}\n// $calevent->update($params); // prime the record with the parameters\n $this->save(true);\n \t\tforeach ($dates as $d) {\n $edate = new eventdate(array('event_id'=>$this->id,'location_data'=>$this->location_data,'date'=>$d));\n $edate->update();\n }\n \t}\n// $calevent->update($params);\n // call expController->update() to save the image, is it necessary?\n $this->save(true);\n }",
" public function afterDelete() {\n $ed = new eventdate();\n $dates = $ed->find('all','event_id='.$this->id);\n foreach ($dates as $date) {\n $date->delete();\n }\n }",
" public static function dayNames() {\n $days = array();\n for ($i=0; $i < 7; $i++) {\n $days['short'][$i] = substr(strftime(\"%a\", mktime(0, 0, 0, 6, $i+2, 2013)), 0, 1);\n $days['med'][$i] = strftime(\"%a\", mktime(0, 0, 0, 6, $i+2, 2013));\n $days['long'][$i] = strftime('%A ', mktime(0, 0, 0, 6, $i+2, 2013));\n }\n return $days;\n }",
"",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class fileController extends expController {\n public $basemodel_name = \"expFile\";",
" protected $add_permissions = array(\n// 'picker'=>'Manage Files',\n 'import'=>'Import',\n 'export'=>'Export',\n );",
" protected $remove_permissions = array(\n 'delete'\n );",
"",
" public $requires_login = array(",
" 'picker'=>'must be logged in',\n 'editAlt'=>'must be logged in',\n 'editCat'=>'must be logged in',\n 'editShare'=>'must be logged in',\n 'editTitle'=>'must be logged in',",
" );",
" static function displayname() { return gt(\"File Manager\"); }\n static function description() { return gt(\"Add and manage Exponent Files\"); }\n static function author() { return \"Phillip Ball - OIC Group, Inc\"; }",
" public function manage_fixPaths() {\n // fixes file directory issues when the old file class was used to save record\n // where the trailing forward slash was not added. This simply checks to see\n // if the trailing / is there, if not, it adds it.",
" ",
" $file = new expFile();\n $files = $file->find('all');",
" ",
" foreach ($files as $key=>$file) {\n if (substr($files[$key]->directory,-1,1)!=\"/\") {\n $files[$key]->directory = $files[$key]->directory.'/';\n }\n $files[$key]->save();\n }",
" ",
"// eDebug($files,true);\n }",
" ",
" public function picker() {\n// global $user;",
" $expcat = new expCat();\n $cats = $expcat->find('all','module=\"file\"');\n $jscatarray = array();\n $catarray = array();\n $catarray[] = 'Root Folder';\n foreach ($cats as $key=>$cat) {\n $jscatarray[$key]['label'] = $cat->title;\n $jscatarray[$key]['value'] = $cat->id;\n $catarray[$cat->id] = $cat->title;\n }\n $jsuncat['label'] = 'Root';\n $jsuncat['value'] = null;\n array_unshift($jscatarray,$jsuncat);\n $catarray['-1'] = 'All Folders';\n if (strstr($this->params['update'],'?')) {\n $update = explode('?',$this->params['update']);\n if (!empty($update[0])) $this->params['update'] = $update[0];\n }\n assign_to_template(array(\n 'update'=>$this->params['update'],\n 'filter'=>!empty($this->params['filter'])?$this->params['filter']:null,\n 'cats'=>$catarray,\n 'jscats'=>json_encode($jscatarray)\n ));\n }",
" ",
" public function uploader() {\n global $user;\n //expHistory::set('manageable', $this->params);\n flash('message',gt('Upload size limit').': '.ini_get('upload_max_filesize'));\n if(intval(ini_get('upload_max_filesize'))!=intval(ini_get('post_max_size')) && $user->isAdmin()){\n flash('error',gt('In order for the uploader to work correctly, \\'\"post_max_size\\' and \\'upload_max_filesize\\' within your php.ini file must match one another'));\n }",
" $expcat = new expCat();\n $cats = $expcat->find('all','module=\"file\"');\n $catarray = array();\n $catarray[] = 'Root Folder';\n foreach ($cats as $cat) {\n $catarray[$cat->id] = $cat->title;\n }\n assign_to_template(array(\n 'update'=>$this->params['update'],\n \"upload_size\"=>ini_get('upload_max_filesize'),\n \"post_size\"=>ini_get('post_max_size'),\n \"bmax\"=>intval(ini_get('upload_max_filesize')/1024*1000000000),\n 'cats'=>$catarray,\n ));\n }",
" ",
" /**\n * Returns attached file view template configuration settings template\n *\n */\n public function get_view_config() {\n global $template;",
" ",
" // set paths we will search in for the view\n $paths = array(\n BASE.'themes/'.DISPLAY_THEME.'/modules/common/views/file/configure',\n BASE.'framework/modules/common/views/file/configure',\n );",
" foreach ($paths as $path) {\n $view = $path.'/'.$this->params['view'].'.tpl';\n if (is_readable($view)) {\n if (bs(true)) {\n $bstrapview = $path.'/'.$this->params['view'].'.bootstrap.tpl';\n if (file_exists($bstrapview)) {\n $view = $bstrapview;\n }\n }\n if (bs3(true)) {\n $bstrapview = $path.'/'.$this->params['view'].'.bootstrap3.tpl';\n if (file_exists($bstrapview)) {\n $view = $bstrapview;\n }\n }\n $template = new controllertemplate($this, $view);\n $ar = new expAjaxReply(200, 'ok');\n\t\t $ar->send();\n }\n }\n }",
" ",
" /**\n * Returns view template configuration settings view template\n *\n */\n public function get_module_view_config() {\n global $template;",
"// $controller = new $this->params['mod'];\n $controller = expModules::getController($this->params['mod']);\n // set paths we will search in for the view\n $paths = array(\n// BASE.'themes/'.DISPLAY_THEME.'/modules/'.$this->params['mod'].'/views/'.$this->params['mod'].'/configure',\n// BASE.'framework/modules/'.$this->params['mod'].'/views/'.$this->params['mod'].'/configure',\n $controller->viewpath.'/configure',\n \t BASE.'themes/'.DISPLAY_THEME.'/modules/'.$controller->relative_viewpath.'/configure'\n );",
" $config_found = false;\n foreach ($paths as $path) {\n $view = $path.'/'.$this->params['view'].'.config';\n if (is_readable($view)) {\n if (bs(true)) {\n $bstrapview = $path.'/'.$this->params['view'].'.bootstrap.config';\n if (file_exists($bstrapview)) {\n $view = $bstrapview;\n }\n }\n if (bs3(true)) {\n $bstrapview = $path.'/'.$this->params['view'].'.bootstrap3.config';\n if (file_exists($bstrapview)) {\n $view = $bstrapview;\n }\n }\n $template = new controllertemplate($this, $view);\n $config_found = true;\n }\n }\n $parts = explode('_', $this->params['view']);\n if (!$config_found && ($this->params['view'] != $parts[0])) {\n foreach ($paths as $path) {\n $actview = $path.'/'.$parts[0].'.config';\n if (is_readable($actview)) {\n if (bs(true)) {\n $bstrapview = $path . '/' . $actview . '.bootstrap.config';\n if (file_exists($bstrapview)) {\n $actview = $bstrapview;\n }\n }\n if (bs3(true)) {\n $bstrapview = $path . '/' . $actview . '.bootstrap3.config';\n if (file_exists($bstrapview)) {\n $actview = $bstrapview;\n }\n }\n $template = new controllertemplate($this, $actview);\n $config_found = true;\n }\n }\n }\n if (!$config_found) {\n echo \"<p>\".gt('There Are No View Specific Settings').\"</p>\";\n $template = expTemplate::get_common_template('blank', null);\n }",
"// expTemplate::get_config_template($this);\n $ar = new expAjaxReply(200, 'ok');\n $ar->send();\n }",
" /**\n * Get a file record by id or pathname and return it as JSON via Ajax\n */\n public function getFile() {\n if (is_numeric($this->params['id'])) {\n $file = new expFile($this->params['id']);\n } else {\n $efile = new expFile();\n $path = str_replace(BASE, '', $this->params['id']);\n $path = str_replace('\\\\', '/', $path);\n $file = $efile->find('first','directory=\"'.dirname($path).'/'.'\" AND filename=\"'.basename($path).'\"');\n }\n $ar = new expAjaxReply(200, 'ok', $file);\n $ar->send();\n }",
" public function getFilesByJSON() {\n global $user;",
" $modelname = $this->basemodel_name;\n $results = 25; // default get all\n $startIndex = 0; // default start at 0\n// $sort = null; // default don't sort\n// $dir = 'asc'; // default sort dir is asc\n// $sort_dir = SORT_ASC;",
" // How many records to get?\n if(strlen($this->params['results']) > 0) {\n $results = $this->params['results'];\n }",
" // Start at which record?\n if(strlen($this->params['startIndex']) > 0) {\n $startIndex = $this->params['startIndex'];\n }",
" // Sorted?\n if(strlen($this->params['sort']) > 0) {\n if ($this->params['sort'] == 'cat') {\n $sort = 'id';\n } else {\n $sort = $this->params['sort'];\n }\n// if ($sort = 'id') $sort = 'filename';\n }",
" // Sort dir?\n if (($this->params['dir'] == 'false') || ($this->params['dir'] == 'desc') || ($this->params['dir'] == 'yui-dt-desc')) {\n $dir = 'desc';\n $sort_dir = SORT_DESC;\n } else {\n $dir = 'asc';\n $sort_dir = SORT_ASC;\n }\n $totalrecords = 0;",
" if (!empty($this->params['query'])) {\n $filter = '';\n if (!$user->isAdmin()) {\n $filter = \"(poster=\".$user->id.\" OR shared=1) AND \";\n };\n// if ($this->params['update']=='ck' || $this->params['update']=='tiny') {\n if (!empty($this->params['filter']) && $this->params['filter'] == 'image') {\n $filter .= \"is_image=1 AND \";\n }",
"// $this->params['query'] = expString::sanitize($this->params['query']);\n// $totalrecords = $this->$modelname->find('count',\"filename LIKE '%\".$this->params['query'].\"%' OR title LIKE '%\".$this->params['query'].\"%' OR alt LIKE '%\".$this->params['query'].\"%'\");\n// $files = $this->$modelname->find('all',$filter.\"filename LIKE '%\".$this->params['query'].\"%' OR title LIKE '%\".$this->params['query'].\"%' OR alt LIKE '%\".$this->params['query'].\"%'\".$imagesOnly,$sort.' '.$dir, $results, $startIndex);\n $files = $this->$modelname->find('all',$filter.\"(filename LIKE '%\".$this->params['query'].\"%' OR title LIKE '%\".$this->params['query'].\"%' OR alt LIKE '%\".$this->params['query'].\"%')\",$sort.' '.$dir);",
" //FiXME we need to get all records then group by cat, then trim/paginate\n $querycat = !empty($this->params['cat']) ? $this->params['cat'] : '0';\n $groupedfiles = array();\n foreach ($files as $key=>$file) {\n $filecat = !empty($file->expCat[0]->id) ? $file->expCat[0]->id : 0;\n if (($querycat == $filecat || $querycat == -1)) {\n $totalrecords++;\n if (count($groupedfiles) < ($startIndex + $results)) {\n $groupedfiles[$key] = $files[$key];\n if (!empty($file->expCat[0]->title)) {\n $groupedfiles[$key]->cat = $file->expCat[0]->title;\n $groupedfiles[$key]->catid = $file->expCat[0]->id;\n }\n $tmpusr = new user($file->poster);\n $groupedfiles[$key]->user = new stdClass();\n $groupedfiles[$key]->user->firstname = $tmpusr->firstname;\n $groupedfiles[$key]->user->lastname = $tmpusr->lastname;\n $groupedfiles[$key]->user->username = $tmpusr->username;\n }\n }\n }\n $groupedfiles = array_values(array_filter($groupedfiles));\n $files = array_slice($groupedfiles,$startIndex,$results);",
" $returnValue = array(\n 'recordsReturned'=>count($files),\n 'totalRecords'=>$totalrecords,\n 'startIndex'=>$startIndex,\n 'sort'=>$sort,\n 'dir'=>$dir,\n 'pageSize'=>$results,\n 'records'=>$files\n );\n } else {\n if (!$user->isAdmin()) {\n $filter = \"(poster=\".$user->id.\" OR shared=1)\";\n };\n// if ($this->params['update']=='ck' || $this->params['update']=='tiny') {\n if (!empty($this->params['filter']) && $this->params['filter'] == 'image') {\n $filter .= !empty($filter) ? \" AND \" : \"\";\n $filter .= \"is_image=1\";\n }",
" ",
"// $totalrecords = $this->$modelname->find('count',$filter);\n// $files = $this->$modelname->find('all',$filter,$sort.' '.$dir, $results, $startIndex);\n $files = $this->$modelname->find('all', $filter, $sort.' '.$dir);",
" $groupedfiles = array();\n foreach ($files as $key=>$file) {\n if (empty($file->expCat[0]->title)) {\n $totalrecords++;\n if (count($groupedfiles) < ($startIndex + $results)) {\n $groupedfiles[$key] = $files[$key];\n // $files[$key]->cat = $file->expCat[0]->title;\n // $files[$key]->catid = $file->expCat[0]->id;\n $tmpusr = new user($file->poster);\n $groupedfiles[$key]->user = new stdClass();\n $groupedfiles[$key]->user->firstname = $tmpusr->firstname;\n $groupedfiles[$key]->user->lastname = $tmpusr->lastname;\n $groupedfiles[$key]->user->username = $tmpusr->username;\n }\n }\n }\n $groupedfiles = array_values(array_filter($groupedfiles));\n $files = array_slice($groupedfiles,$startIndex,$results);",
" $returnValue = array(\n 'recordsReturned'=>count($files),\n 'totalRecords'=>$totalrecords,\n 'startIndex'=>$startIndex,\n 'sort'=>$sort,\n 'dir'=>$dir,\n 'pageSize'=>$results,\n 'records'=>$files\n );",
" \n }\n ",
" echo json_encode($returnValue);\n }",
" /**\n * create a new virtual folder in response to an ajax request\n * return updated list of virtual folders in response to an ajax request\n */\n public function createFolder() {\n if (!empty($this->params['folder'])) {\n $expcat = new expCat($this->params['folder']);\n if (empty($expcat->id)) {\n $expcat->module = 'file';\n $expcat->title = $this->params['folder'];\n $expcat->update();\n }\n// $this->params['module'] = 'file';\n// $this->params['title'] = $this->params['folder'];\n// parent::update();\n $cats = $expcat->find('all','module=\"file\"','rank');\n $catarray = array();\n $catarray[] = 'Root Folder';\n foreach ($cats as $cat) {\n $catarray[$cat->id] = $cat->title;\n }\n echo json_encode($catarray);\n }\n }",
" public function delete() {\n// global $db,$user;\n global $user;",
" $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->delete();\n if (unlink($file->directory.$file->filename)) {\n flash('message',$file->filename.' '.gt('was successfully deleted'));\n } else {\n flash('error',$file->filename.' '.gt('was deleted from the database, but could not be removed from the file system.'));\n }\n } else {\n flash('error',$file->filename.' '.gt('wasn\\'t deleted because you don\\'t own the file.'));\n }\n redirect_to(array(\"controller\"=>'file',\"action\"=>'picker',\"ajax_action\"=>1,\"update\"=>$this->params['update'],\"filter\"=>$this->params['filter']));",
" } \n ",
" public function deleter() {\n// global $db;",
" $notafile = array();\n// $files = $db->selectObjects('expFiles',1);\n foreach (expFile::selectAllFiles() as $file) {\n if (!is_file(BASE.$file->directory.$file->filename)) {\n $notafile[$file->id] = $file;\n }\n }\n assign_to_template(array(\n 'files'=>$notafile\n ));\n }",
" public function deleteit() {\n global $user;\n if (!empty($this->params['deleteit'])) {\n foreach ($this->params['deleteit'] as $file) {\n $delfile = new expFile($file);\n if ($user->id==$delfile->poster || $user->isAdmin()) {\n $delfile->delete();\n flash('error',$delfile->filename.' '.gt('was deleted from the database.'));\n }\n }\n }\n redirect_to(array(\"controller\"=>'file',\"action\"=>'picker',\"ajax_action\"=>1,\"update\"=>$this->params['update'],\"filter\"=>$this->params['filter']));\n }",
" public function batchDelete() {\n global $user;",
" $error = false;\n// if (get_magic_quotes_gpc()) $this->params['files'] = stripslashes($this->params['files']); // magic quotes fix\n $this->params['files'] = stripslashes($this->params['files']);\n $files = json_decode($this->params['files']);\n switch (json_last_error()) { //FIXME json error checking/reporting, may no longer be needed\n case JSON_ERROR_NONE:\n break;\n case JSON_ERROR_DEPTH:\n $error = 'JSON - Maximum stack depth exceeded';\n break;\n case JSON_ERROR_STATE_MISMATCH:\n $error = 'JSON - Underflow or the modes mismatch';\n break;\n case JSON_ERROR_CTRL_CHAR:\n $error = 'JSON - Unexpected control character found';\n break;\n case JSON_ERROR_SYNTAX:\n $error = 'JSON - Syntax error, malformed JSON';\n break;\n case JSON_ERROR_UTF8:\n $error = 'JSON - Malformed UTF-8 characters, possibly incorrectly encoded';\n break;\n default:\n $error = 'JSON - Unknown error';\n break;\n }",
" if (empty($error)) foreach ($files as $file) {\n $delfile = new expFile($file->id);\n if ($user->id==$delfile->poster || $user->isAdmin()) {\n $delfile->delete();\n unlink($delfile->directory.$delfile->filename);\n } else {\n $error = gt(\"you didn't have permission\");\n }\n }\n if (!empty($error)) {\n $ar = new expAjaxReply(300, gt(\"Some files were NOT deleted because\") . ' ' . $error);\n } else {\n $ar = new expAjaxReply(200, gt('Your files were deleted successfully'), $file);\n }\n $ar->send();\n }",
" public function adder() {\n global $db;",
" $notindb = array();\n $allfiles = expFile::listFlat(BASE.'files',true,null,array(),BASE);\n foreach ($allfiles as $path=>$file) {\n if ($file[0] != '.') {\n// $found = false;\n $npath = preg_replace('/'.$file.'/','',$path, 1);\n// $dbfiles = $db->selectObjects('expFiles',\"filename='\".$file.\"' AND directory='\".$npath.\"'\");\n $dbfile = $db->selectObject('expFiles',\"filename='\".$file.\"' AND directory='\".$npath.\"'\");\n// foreach ($dbfiles as $dbfile) {\n// if (!empty($dbfile)) $found = ($dbfile->directory == str_replace($file,'',$path));\n// }\n// if (!$found) {\n// $notindb[$path] = $file;\n// }\n if (empty($dbfile)) {\n $notindb[$path] = $file;\n }\n }\n }\n assign_to_template(array(\n 'files'=>$notindb\n ));\n }",
" public function addit() {\n foreach ($this->params['addit'] as $file) {\n $newfile = new expFile(array('directory'=>dirname($file).'/','filename'=>basename($file)));\n $newfile->posted = $newfile->last_accessed = filemtime($file);\n $newfile->save();\n flash('message',$newfile->filename.' '.gt('was added to the File Manager.'));\n }\n redirect_to(array(\"controller\"=>'file',\"action\"=>'picker',\"ajax_action\"=>1,\"update\"=>$this->params['update'],\"filter\"=>$this->params['filter']));\n }",
" public function upload() {",
" ",
" // upload the file, but don't save the record yet...\n if ($this->params['resize'] != 'false') {\n $maxwidth = $this->params['max_width'];\n } else {\n $maxwidth = null;\n }\n $file = expFile::fileUpload('Filedata',false,false,null,null,$maxwidth);\n // since most likely this function will only get hit via flash in YUI Uploader\n // and since Flash can't pass cookies, we lose the knowledge of our $user\n // so we're passing the user's ID in as $_POST data. We then instantiate a new $user,\n // and then assign $user->id to $file->poster so we have an audit trail for the upload",
" if (is_object($file)) {\n $resized = !empty($file->resized) ? true : false;\n $user = new user($this->params['usrid']);\n $file->poster = $user->id;\n $file->posted = $file->last_accessed = time();\n $file->save();\n if (!empty($this->params['cat'])) {\n $expcat = new expCat($this->params['cat']);\n $params['expCat'][0] = $expcat->id;\n $file->update($params);\n }",
" // a echo so YUI Uploader is notified of the function's completion\n if ($resized) {\n echo gt('File resized and then saved');\n } else {\n echo gt('File saved');\n }\n } else {\n echo gt('File was NOT uploaded!');\n// flash('error',gt('File was not uploaded!'));\n }",
" } ",
"\n public function quickUpload(){\n global $user;",
" if (!empty($this->params['folder']) || (defined('QUICK_UPLOAD_FOLDER') && QUICK_UPLOAD_FOLDER != '' && QUICK_UPLOAD_FOLDER != 0)) {\n // prevent attempt to place file somewhere other than /files folder\n if (!empty($this->params['folder']) && strpos($this->params['folder'], '..') !== false) {\n $ar = new expAjaxReply(300, gt(\"File was not uploaded!\"));\n $ar->send();\n }\n if (SITE_FILE_MANAGER == 'picker') {\n $quikFolder = !empty($this->params['folder']) ? $this->params['folder'] :QUICK_UPLOAD_FOLDER;\n $destDir = null;\n } elseif (SITE_FILE_MANAGER == 'elfinder') {\n $quikFolder = null;\n $destDir = UPLOAD_DIRECTORY_RELATIVE . (!empty($this->params['folder']) ? $this->params['folder'] :QUICK_UPLOAD_FOLDER) . '/';\n // create folder if non-existant\n expFile::makeDirectory($destDir);\n }\n } else {\n $quikFolder = null;\n $destDir = null;\n }",
" //extensive suitability check before doing anything with the file...\n if (isset($_SERVER['HTTP_X_FILE_NAME'])) { //HTML5 XHR upload\n $file = expFile::fileXHRUpload($_SERVER['HTTP_X_FILE_NAME'],false,false,null,$destDir,intval(QUICK_UPLOAD_WIDTH));\n $file->poster = $user->id;\n $file->posted = $file->last_accessed = time();\n $file->save();\n if (!empty($quikFolder)) {\n $expcat = new expCat($quikFolder);\n $params['expCat'][0] = $expcat->id;\n $file->update($params);\n }\n $ar = new expAjaxReply(200, gt('Your File was uploaded successfully'), $file->id);\n $ar->send();\n } else { //$_POST upload\n if (($_FILES['uploadfile'] == \"none\") OR (empty($_FILES['uploadfile']['name'])) ) {\n $message = gt(\"No file uploaded.\");\n } else if ($_FILES['uploadfile'][\"size\"] == 0) {\n $message = gt(\"The file is zero length.\");\n // } else if (($_FILES['upload'][\"type\"] != \"image/pjpeg\") AND ($_FILES['upload'][\"type\"] != \"image/jpeg\") AND ($_FILES['upload'][\"type\"] != \"image/png\")) {\n // $message = gt(\"The image must be in either JPG or PNG format. Please upload a JPG or PNG instead.\");\n } else if (!is_uploaded_file($_FILES['uploadfile'][\"tmp_name\"])) {\n $message = gt(\"You may be attempting to hack our server.\");\n } else {\n // upload the file, but don't save the record yet...\n $file = expFile::fileUpload('uploadfile',false,false,null,$destDir,intval(QUICK_UPLOAD_WIDTH));\n // since most likely this function will only get hit via flash in YUI Uploader\n // and since Flash can't pass cookies, we lose the knowledge of our $user\n // so we're passing the user's ID in as $_POST data. We then instantiate a new $user,\n // and then assign $user->id to $file->poster so we have an audit trail for the upload\n if (is_object($file)) {\n $file->poster = $user->id;\n $file->posted = $file->last_accessed = time();\n $file->save();\n if (!empty($quikFolder)) {\n $expcat = new expCat($quikFolder);\n $params['expCat'][0] = $expcat->id;\n $file->update($params);\n }\n $ar = new expAjaxReply(200, gt('Your File was uploaded successfully'), $file->id);\n } else {\n $ar = new expAjaxReply(300, gt(\"File was not uploaded!\").' - '.$file);\n }\n $ar->send();\n }\n }\n }",
" public function editCat() {\n global $user;\n $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $expcat = new expCat($this->params['newValue']);\n $params['expCat'][0] = $expcat->id;\n $file->update($params);\n $file->cat = $expcat->title;\n $file->catid = $expcat->id;\n $ar = new expAjaxReply(200, gt('Your Folder was updated successfully'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so you can't edit it.\"));\n }\n $ar->send();\n }",
" public function editTitle() {\n global $user;\n $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->title = $this->params['newValue'];\n $file->save();\n $ar = new expAjaxReply(200, gt('Your title was updated successfully'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so you can't edit it.\"));\n }\n $ar->send();",
" } ",
"\n public function editAlt() {",
" global $user; ",
" $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->alt = $this->params['newValue'];\n $file->save();\n $ar = new expAjaxReply(200, gt('Your alt was updated successfully'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so you can't edit it.\"));\n }\n $ar->send();\n echo json_encode($file); //FIXME we exit before hitting this",
" } ",
"\n public function editShare() {\n global $user;\n $file = new expFile($this->params['id']);\n\t\tif(!isset($this->params['newValue'])) {\n\t\t\t$this->params['newValue'] = 0;\n\t\t}\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->shared = $this->params['newValue'];\n $file->save();\n $ar = new expAjaxReply(200, gt('This file is now shared.'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so it's not yours to share.\"));\n }\n $ar->send();\n echo json_encode($file); //FIXME we exit before hitting this\n }",
" public function import_eql() {\n }",
" public function import_eql_process() {\n global $db;",
" if ($_FILES['file']['error'] != UPLOAD_ERR_OK) {\n \tswitch($_FILES['file']['error']) {\n \t\tcase UPLOAD_ERR_INI_SIZE:\n \t\tcase UPLOAD_ERR_FORM_SIZE:\n \t\t\techo gt('The file you uploaded exceeded the size limits for the server.').'<br />';\n \t\t\tbreak;\n \t\tcase UPLOAD_ERR_PARTIAL:\n \t\t\techo gt('The file you uploaded was only partially uploaded.').'<br />';\n \t\t\tbreak;\n \t\tcase UPLOAD_ERR_NO_FILE:\n \t\t\techo gt('No file was uploaded.').'<br />';\n \t\t\tbreak;\n \t}\n } else {\n $errors = array();\n expSession::clearAllUsersSessionCache();",
" // copy in deprecated definitions files to aid in import\n $src = BASE . \"install/old_definitions\";\n $dst = BASE . \"framework/core/definitions\";\n if (is_dir($src) && expUtil::isReallyWritable($dst)) {\n $dir = opendir($src);\n while (false !== ($file = readdir($dir))) {\n if (($file != '.') && ($file != '..')) {\n if (!file_exists($dst . '/' . $file)) {\n copy($src . '/' . $file, $dst . '/' . $file);\n }\n }\n }\n closedir($dir);\n }",
" expFile::restoreDatabase($_FILES['file']['tmp_name'], $errors);",
" // now remove deprecated definitions files\n $src = BASE . \"install/old_definitions\";\n $dst = BASE . \"framework/core/definitions\";\n if (is_dir($src) && expUtil::isReallyWritable($dst)) {\n $dir = opendir($src);\n while (false !== ($file = readdir($dir))) {\n if (($file != '.') && ($file != '..')) {\n if (file_exists($dst . '/' . $file)) {\n unlink($dst . '/' . $file);\n }\n // remove empty deprecated tables\n $table = substr($file, 0, -4);\n if ($db->tableIsEmpty($table)) {\n $db->dropTable($table);\n }\n }\n }\n closedir($dir);\n }",
" // update search index\n searchController::spider();",
" // check to see if we need to install or upgrade the restored database\n expVersion::checkVersion();",
" assign_to_template(\n array(\n 'success' => !count($errors),\n 'errors' => $errors,\n )\n );\n }\n }",
" public static function getTables() {\n global $db;",
" expDatabase::fix_table_names();\n $tables = $db->getTables();\n if (!function_exists('tmp_removePrefix')) {\n \tfunction tmp_removePrefix($tbl) {\n \t\t// we add 1, because DB_TABLE_PREFIX no longer has the trailing\n \t\t// '_' character - that is automatically added by the database class.\n \t\treturn substr($tbl,strlen(DB_TABLE_PREFIX)+1);\n \t}\n }\n $tables = array_map('tmp_removePrefix',$tables);\n usort($tables,'strnatcmp');\n return $tables;\n }",
" public function export_eql() {\n// global $db, $user;\n global $user;",
"// expDatabase::fix_table_names();\n// $tables = $db->getTables();\n// if (!function_exists('tmp_removePrefix')) {\n// \tfunction tmp_removePrefix($tbl) {\n// \t\t// we add 1, because DB_TABLE_PREFIX no longer has the trailing\n// \t\t// '_' character - that is automatically added by the database class.\n// \t\treturn substr($tbl,strlen(DB_TABLE_PREFIX)+1);\n// \t}\n// }\n// $tables = array_map('tmp_removePrefix',$tables);\n// usort($tables,'strnatcmp');",
" assign_to_template(array(\n 'user' => $user,\n 'tables' => self::getTables(),\n ));\n }",
" public function export_eql_process() {\n// global $db;",
" if (!isset($this->params['tables'])) { // No checkboxes clicked so we'll dump all tables\n $this->params['tables'] = self::getTables();\n $this->params['tables'] = array_flip($this->params['tables']);\n }\n// \techo gt('You must choose at least one table to export.');\n// } else { // All good\n \t$filename = str_replace(\n \t\tarray('__DOMAIN__','__DB__'),\n \t\tarray(str_replace('.','_',HOSTNAME),DB_NAME),\n $this->params['filename']);\n \t$filename = preg_replace('/[^A-Za-z0-9_.-]/','-',strftime($filename,time()).'.eql');",
" \tob_end_clean();\n \tob_start(\"ob_gzhandler\");",
" \tif (isset($this->params['save_sample'])) { // Save as a theme sample is checked off\n \t\t$path = BASE . \"themes/\".DISPLAY_THEME.\"/sample.eql\";\n \t\tif (!$eql = fopen ($path, \"w\")) {\n \t\t\tflash('error',gt(\"Error opening eql file for writing\").\" \".$path);\n \t\t} else {\n //TODO we need to write inside call passing $eql file pointer\n $eqlfile = expFile::dumpDatabase(array_keys($this->params['tables']));\n \t\t\tif (fwrite ($eql, $eqlfile) === FALSE) {\n \t\t\t\tflash('error',gt(\"Error writing to eql file\").\" \".$path);\n \t\t\t}\n \t\t\tfclose ($eql);\n \t\t\tflash('message',gt(\"Sample database (eql file) saved to\").\" '\".DISPLAY_THEME.\"' \".gt(\"theme\"));\n \t\t\texpHistory::back();\n \t\t}\n \t} else {\n \t\t// This code was lifted from phpMyAdmin, but this is Open Source, right?",
" \t\t// 'application/octet-stream' is the registered IANA type but\n \t\t// MSIE and Opera seems to prefer 'application/octetstream'\n \t\t$mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';",
" \t\theader('Content-Type: ' . $mime_type);\n \t\theader('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n \t\t// IE need specific headers\n \t\tif (EXPONENT_USER_BROWSER == 'IE') {\n \t\t\theader('Content-Disposition: inline; filename=\"' . $filename . '\"');\n \t\t\theader('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n \t\t\theader('Pragma: public');\n \t\t} else {\n \t\t\theader('Content-Disposition: attachment; filename=\"' . $filename . '\"');\n \t\t\theader('Pragma: no-cache');\n \t\t}\n echo expFile::dumpDatabase(array_keys($this->params['tables'])); //FIXME we need to echo inside call\n \t\texit; // Exit, since we are exporting\n \t}\n// }\n }",
" public function import_files() {\n }",
" public function import_files_process() {\n if ($_FILES['file']['error'] != UPLOAD_ERR_OK) {\n \tswitch($_FILES['file']['error']) {\n \t\tcase UPLOAD_ERR_INI_SIZE:\n \t\tcase UPLOAD_ERR_FORM_SIZE:\n \t\t\techo gt('The file you uploaded exceeded the size limits for the server.').'<br />';\n \t\t\tbreak;\n \t\tcase UPLOAD_ERR_PARTIAL:\n \t\t\techo gt('The file you uploaded was only partially uploaded.').'<br />';\n \t\t\tbreak;\n \t\tcase UPLOAD_ERR_NO_FILE:\n \t\t\techo gt('No file was uploaded.').'<br />';\n \t\t\tbreak;\n \t}\n } else {\n \t$basename = basename($_FILES['file']['name']);",
" \tinclude_once(BASE.'external/Tar.php');\n \t$tar = new Archive_Tar($_FILES['file']['tmp_name'],'gz');",
" \t$dest_dir = BASE.'tmp/extensionuploads/'.uniqid('');\n \t@mkdir($dest_dir,DIR_DEFAULT_MODE_STR);\n \tif (!file_exists($dest_dir)) {\n \t\techo gt('Unable to create temporary directory to extract files archive.');\n \t} else {\n \t\t$return = $tar->extract($dest_dir);\n \t\tif (!$return) {\n \t\t\techo '<br />'.gt('Error extracting TAR archive').'<br />';\n \t\t} else if (!file_exists($dest_dir.'/files') || !is_dir($dest_dir.'/files')) {\n \t\t\techo '<br />'.gt('Invalid archive format, no \\'/files\\' folder').'<br />';\n \t\t} else {\n \t\t\t// Show the form for specifying which mod types to 'extract'",
" \t\t\t$mods = array(); // Stores the mod classname, the files list, and the module's real name",
" \t\t\t$dh = opendir($dest_dir.'/files');\n \t\t\twhile (($file = readdir($dh)) !== false) {\n \t\t\t\tif ($file{0} != '.' && is_dir($dest_dir.'/files/'.$file)) {\n \t\t\t\t\t$mods[$file] = array(\n \t\t\t\t\t\t'',\n \t\t\t\t\t\tarray_keys(expFile::listFlat($dest_dir.'/files/'.$file,1,null,array(),$dest_dir.'/files/'))\n \t\t\t\t\t);\n //\t\t\t\t\tif (class_exists($file)) {\n //\t\t\t\t\t\t$mods[$file][0] = call_user_func(array($file,'name')); // $file is the class name of the module\n //\t\t\t\t\t}\n \t\t\t\t} elseif ($file != '.' && $file != '..') {\n \t\t\t\t\t$mods[$file] = array(\n \t\t\t\t\t\t'',\n \t\t\t\t\t\t$file\n \t\t\t\t\t);\n \t\t\t\t}\n \t\t\t}",
" assign_to_template(array(\n 'dest_dir' => $dest_dir,\n 'file_data' => $mods,\n ));\n \t\t}\n \t}\n }\n }",
" public function import_files_extract() {\n $dest_dir = $this->params['dest_dir'];\n $files = array();\n foreach (array_keys($this->params['mods']) as $file) {\n \t$files[$file] = expFile::canCreate(BASE.'files/'.$file);\n //\tif (class_exists($mod)) {\n //\t\t$files[$mod][0] = call_user_func(array($mod,'name'));\n //\t}\n //\tforeach (array_keys(expFile::listFlat($dest_dir.'/files',1,null,array(),$dest_dir.'/files/')) as $file) {\n //\t\t$files[$mod][1][$file] = expFile::canCreate(BASE.'files/'.$file);\n //\t}\n }",
" expSession::set('dest_dir',$dest_dir);\n expSession::set('files_data',$files);",
" assign_to_template(array(\n 'files_data' => $files,\n ));\n }",
" public function import_files_finish() {\n $dest_dir = expSession::get('dest_dir');\n $files = expSession::get('files_data');\n if (!file_exists(BASE.'files')) {\n \tmkdir(BASE.'files',DIR_DEFAULT_MODE_STR);\n }",
" $filecount = 0;\n foreach (array_keys($files) as $file) {\n expFile::copyDirectoryStructure($dest_dir.'/files/'.$file,BASE.'files/'.$file);\n \tcopy($dest_dir.'/files/'.$file,BASE.'files/'.$file);\n \t$filecount++;\n }",
" expSession::un_set('dest_dir');\n expSession::un_set('files_data');",
" expFile::removeDirectory($dest_dir);",
" assign_to_template(array(\n 'file_count' => $filecount,\n ));\n }",
" public function export_files() {\n global $user;",
" $loc = expCore::makeLocation($this->params['controller'],isset($this->params['src'])?$this->params['src']:null,isset($this->params['int'])?$this->params['int']:null);\n //$mods = array();\n //$dh = opendir(BASE.'files');\n //while (($file = readdir($dh)) !== false) {\n //\tif (is_dir(BASE.'files/'.$file) && $file{0} != '.' && class_exists($file)) {\n //\t\t$mods[$file] = call_user_func(array($file,'name'));\n //\t}\n //}\n //uasort($mods,'strnatcmp');",
" assign_to_template(array(\n 'user' => $user,\n ));\n }",
" public function export_files_process() {\n// global $db;",
" //if (!isset($this->params['mods'])) {\n //\techo gt('You must select at least one module to export files for.');\n //\treturn;\n //}",
" include_once(BASE.'external/Tar.php');",
" $files = array();\n //foreach (array_keys($this->params['mods']) as $mod) {\n //\tforeach ($db->selectObjects('file',\"directory LIKE 'files/\".$mod.\"%'\") as $file) {\n// foreach ($db->selectObjects('expFiles',1) as $file) {\n foreach (expFile::selectAllFiles() as $file) {\n $files[] = BASE.$file->directory.$file->filename;\n }\n //}",
" $fname = tempnam(BASE.'/tmp','exporter_files_');\n $tar = new Archive_Tar($fname,'gz');\n $tar->createModify($files,'',BASE);",
" $filename = str_replace(\n array('__DOMAIN__','__DB__'),\n array(str_replace('.','_',HOSTNAME),DB_NAME),\n $this->params['filename']);\n $filename = preg_replace('/[^A-Za-z0-9_.-]/','-',strftime($filename,time()).'.tar.gz');",
" if (isset($this->params['save_sample'])) { // Save as a theme sample is checked off\n copy($fname,BASE . \"themes/\".DISPLAY_THEME_REAL.\"/sample.tar.gz\");\n unlink($fname);\n flash('message',gt(\"Sample uploaded files archive saved to\").\" '\".DISPLAY_THEME_REAL.\"' \".gt(\"theme\"));\n expHistory::back();\n } else {\n ob_end_clean();\n // This code was lifted from phpMyAdmin, but this is Open Source, right?",
" // 'application/octet-stream' is the registered IANA type but\n // MSIE and Opera seems to prefer 'application/octetstream'\n $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';",
" header('Content-Type: ' . $mime_type);\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n // IE need specific headers\n if (EXPONENT_USER_BROWSER == 'IE') {\n header('Content-Disposition: inline; filename=\"' . $filename . '\"');\n header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n header('Pragma: public');\n } else {\n header('Content-Disposition: attachment; filename=\"' . $filename . '\"');\n header('Pragma: no-cache');\n }",
" $fh = fopen($fname,'rb');\n while (!feof($fh)) {\n echo fread($fh,8192);\n }\n fclose($fh);\n unlink($fname);\n }",
" exit(''); // Exit, since we are exporting.\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class fileController extends expController {\n public $basemodel_name = \"expFile\";",
"",
" protected $remove_permissions = array(\n 'delete'\n );",
"// protected $manage_permissions = array(\n// 'picker'=>'Manage Files',\n// 'import'=>'Import',\n// 'export'=>'Export',\n// );",
" public $requires_login = array(",
" 'picker'=>'You must be logged in to perform this action',\n 'adder'=>'You must be logged in to perform this action',\n 'addit'=>'You must be logged in to perform this action',\n 'batchDelete'=>'You must be logged in to perform this action',\n 'createFolder'=>'You must be logged in to perform this action',\n 'deleter'=>'You must be logged in to perform this action',\n 'deleteit'=>'You must be logged in to perform this action',\n 'edit'=>'You must be logged in to perform this action',\n 'quickUpload'=>'You must be logged in to perform this action',\n 'upload'=>'You must be logged in to perform this action',\n 'uploader'=>'You must be logged in to perform this action',",
" );",
" static function displayname() { return gt(\"File Manager\"); }\n static function description() { return gt(\"Add and manage Exponent Files\"); }\n static function author() { return \"Phillip Ball - OIC Group, Inc\"; }",
" public function manage_fixPaths() {\n // fixes file directory issues when the old file class was used to save record\n // where the trailing forward slash was not added. This simply checks to see\n // if the trailing / is there, if not, it adds it.",
"",
" $file = new expFile();\n $files = $file->find('all');",
"",
" foreach ($files as $key=>$file) {\n if (substr($files[$key]->directory,-1,1)!=\"/\") {\n $files[$key]->directory = $files[$key]->directory.'/';\n }\n $files[$key]->save();\n }",
"",
"// eDebug($files,true);\n }",
"",
" public function picker() {\n// global $user;",
" $expcat = new expCat();\n $cats = $expcat->find('all','module=\"file\"');\n $jscatarray = array();\n $catarray = array();\n $catarray[] = 'Root Folder';\n foreach ($cats as $key=>$cat) {\n $jscatarray[$key]['label'] = $cat->title;\n $jscatarray[$key]['value'] = $cat->id;\n $catarray[$cat->id] = $cat->title;\n }\n $jsuncat['label'] = 'Root';\n $jsuncat['value'] = null;\n array_unshift($jscatarray,$jsuncat);\n $catarray['-1'] = 'All Folders';\n if (strstr($this->params['update'],'?')) {\n $update = explode('?',$this->params['update']);\n if (!empty($update[0])) $this->params['update'] = $update[0];\n }\n assign_to_template(array(\n 'update'=>$this->params['update'],\n 'filter'=>!empty($this->params['filter'])?$this->params['filter']:null,\n 'cats'=>$catarray,\n 'jscats'=>json_encode($jscatarray)\n ));\n }",
"",
" public function uploader() {\n global $user;\n //expHistory::set('manageable', $this->params);\n flash('message',gt('Upload size limit').': '.ini_get('upload_max_filesize'));\n if(intval(ini_get('upload_max_filesize'))!=intval(ini_get('post_max_size')) && $user->isAdmin()){\n flash('error',gt('In order for the uploader to work correctly, \\'\"post_max_size\\' and \\'upload_max_filesize\\' within your php.ini file must match one another'));\n }",
" $expcat = new expCat();\n $cats = $expcat->find('all','module=\"file\"');\n $catarray = array();\n $catarray[] = 'Root Folder';\n foreach ($cats as $cat) {\n $catarray[$cat->id] = $cat->title;\n }\n assign_to_template(array(\n 'update'=>$this->params['update'],\n \"upload_size\"=>ini_get('upload_max_filesize'),\n \"post_size\"=>ini_get('post_max_size'),\n \"bmax\"=>intval(ini_get('upload_max_filesize')/1024*1000000000),\n 'cats'=>$catarray,\n ));\n }",
"",
" /**\n * Returns attached file view template configuration settings template\n *\n */\n public function get_view_config() {\n global $template;",
"",
" // set paths we will search in for the view\n $paths = array(\n BASE.'themes/'.DISPLAY_THEME.'/modules/common/views/file/configure',\n BASE.'framework/modules/common/views/file/configure',\n );",
" foreach ($paths as $path) {\n $view = $path.'/'.$this->params['view'].'.tpl';\n if (is_readable($view)) {\n if (bs(true)) {\n $bstrapview = $path.'/'.$this->params['view'].'.bootstrap.tpl';\n if (file_exists($bstrapview)) {\n $view = $bstrapview;\n }\n }\n if (bs3(true)) {\n $bstrapview = $path.'/'.$this->params['view'].'.bootstrap3.tpl';\n if (file_exists($bstrapview)) {\n $view = $bstrapview;\n }\n }\n $template = new controllertemplate($this, $view);\n $ar = new expAjaxReply(200, 'ok');\n\t\t $ar->send();\n }\n }\n }",
"",
" /**\n * Returns view template configuration settings view template\n *\n */\n public function get_module_view_config() {\n global $template;",
"// $controller = new $this->params['mod'];\n $controller = expModules::getController($this->params['mod']);\n // set paths we will search in for the view\n $paths = array(\n// BASE.'themes/'.DISPLAY_THEME.'/modules/'.$this->params['mod'].'/views/'.$this->params['mod'].'/configure',\n// BASE.'framework/modules/'.$this->params['mod'].'/views/'.$this->params['mod'].'/configure',\n $controller->viewpath.'/configure',\n \t BASE.'themes/'.DISPLAY_THEME.'/modules/'.$controller->relative_viewpath.'/configure'\n );",
" $config_found = false;\n foreach ($paths as $path) {\n $view = $path.'/'.$this->params['view'].'.config';\n if (is_readable($view)) {\n if (bs(true)) {\n $bstrapview = $path.'/'.$this->params['view'].'.bootstrap.config';\n if (file_exists($bstrapview)) {\n $view = $bstrapview;\n }\n }\n if (bs3(true)) {\n $bstrapview = $path.'/'.$this->params['view'].'.bootstrap3.config';\n if (file_exists($bstrapview)) {\n $view = $bstrapview;\n }\n }\n $template = new controllertemplate($this, $view);\n $config_found = true;\n }\n }\n $parts = explode('_', $this->params['view']);\n if (!$config_found && ($this->params['view'] != $parts[0])) {\n foreach ($paths as $path) {\n $actview = $path.'/'.$parts[0].'.config';\n if (is_readable($actview)) {\n if (bs(true)) {\n $bstrapview = $path . '/' . $actview . '.bootstrap.config';\n if (file_exists($bstrapview)) {\n $actview = $bstrapview;\n }\n }\n if (bs3(true)) {\n $bstrapview = $path . '/' . $actview . '.bootstrap3.config';\n if (file_exists($bstrapview)) {\n $actview = $bstrapview;\n }\n }\n $template = new controllertemplate($this, $actview);\n $config_found = true;\n }\n }\n }\n if (!$config_found) {\n echo \"<p>\".gt('There Are No View Specific Settings').\"</p>\";\n $template = expTemplate::get_common_template('blank', null);\n }",
"// expTemplate::get_config_template($this);\n $ar = new expAjaxReply(200, 'ok');\n $ar->send();\n }",
" /**\n * Get a file record by id or pathname and return it as JSON via Ajax\n */\n public function getFile() {\n if (is_numeric($this->params['id'])) {\n $file = new expFile($this->params['id']);\n } else {\n $efile = new expFile();\n $path = str_replace(BASE, '', $this->params['id']);\n $path = str_replace('\\\\', '/', $path);\n $file = $efile->find('first','directory=\"'.dirname($path).'/'.'\" AND filename=\"'.basename($path).'\"');\n }\n $ar = new expAjaxReply(200, 'ok', $file);\n $ar->send();\n }",
" public function getFilesByJSON() {\n global $user;",
" $modelname = $this->basemodel_name;\n $results = 25; // default get all\n $startIndex = 0; // default start at 0\n// $sort = null; // default don't sort\n// $dir = 'asc'; // default sort dir is asc\n// $sort_dir = SORT_ASC;",
" // How many records to get?\n if(strlen($this->params['results']) > 0) {\n $results = $this->params['results'];\n }",
" // Start at which record?\n if(strlen($this->params['startIndex']) > 0) {\n $startIndex = $this->params['startIndex'];\n }",
" // Sorted?\n if(strlen($this->params['sort']) > 0) {\n if ($this->params['sort'] == 'cat') {\n $sort = 'id';\n } else {\n $sort = $this->params['sort'];\n }\n// if ($sort = 'id') $sort = 'filename';\n }",
" // Sort dir?\n if (($this->params['dir'] == 'false') || ($this->params['dir'] == 'desc') || ($this->params['dir'] == 'yui-dt-desc')) {\n $dir = 'desc';\n $sort_dir = SORT_DESC;\n } else {\n $dir = 'asc';\n $sort_dir = SORT_ASC;\n }\n $totalrecords = 0;",
" if (!empty($this->params['query'])) {\n $filter = '';\n if (!$user->isAdmin()) {\n $filter = \"(poster=\".$user->id.\" OR shared=1) AND \";\n };\n// if ($this->params['update']=='ck' || $this->params['update']=='tiny') {\n if (!empty($this->params['filter']) && $this->params['filter'] == 'image') {\n $filter .= \"is_image=1 AND \";\n }",
"// $this->params['query'] = expString::sanitize($this->params['query']);\n// $totalrecords = $this->$modelname->find('count',\"filename LIKE '%\".$this->params['query'].\"%' OR title LIKE '%\".$this->params['query'].\"%' OR alt LIKE '%\".$this->params['query'].\"%'\");\n// $files = $this->$modelname->find('all',$filter.\"filename LIKE '%\".$this->params['query'].\"%' OR title LIKE '%\".$this->params['query'].\"%' OR alt LIKE '%\".$this->params['query'].\"%'\".$imagesOnly,$sort.' '.$dir, $results, $startIndex);\n $files = $this->$modelname->find('all',$filter.\"(filename LIKE '%\".$this->params['query'].\"%' OR title LIKE '%\".$this->params['query'].\"%' OR alt LIKE '%\".$this->params['query'].\"%')\",$sort.' '.$dir);",
" //FiXME we need to get all records then group by cat, then trim/paginate\n $querycat = !empty($this->params['cat']) ? $this->params['cat'] : '0';\n $groupedfiles = array();\n foreach ($files as $key=>$file) {\n $filecat = !empty($file->expCat[0]->id) ? $file->expCat[0]->id : 0;\n if (($querycat == $filecat || $querycat == -1)) {\n $totalrecords++;\n if (count($groupedfiles) < ($startIndex + $results)) {\n $groupedfiles[$key] = $files[$key];\n if (!empty($file->expCat[0]->title)) {\n $groupedfiles[$key]->cat = $file->expCat[0]->title;\n $groupedfiles[$key]->catid = $file->expCat[0]->id;\n }\n $tmpusr = new user($file->poster);\n $groupedfiles[$key]->user = new stdClass();\n $groupedfiles[$key]->user->firstname = $tmpusr->firstname;\n $groupedfiles[$key]->user->lastname = $tmpusr->lastname;\n $groupedfiles[$key]->user->username = $tmpusr->username;\n }\n }\n }\n $groupedfiles = array_values(array_filter($groupedfiles));\n $files = array_slice($groupedfiles,$startIndex,$results);",
" $returnValue = array(\n 'recordsReturned'=>count($files),\n 'totalRecords'=>$totalrecords,\n 'startIndex'=>$startIndex,\n 'sort'=>$sort,\n 'dir'=>$dir,\n 'pageSize'=>$results,\n 'records'=>$files\n );\n } else {\n if (!$user->isAdmin()) {\n $filter = \"(poster=\".$user->id.\" OR shared=1)\";\n };\n// if ($this->params['update']=='ck' || $this->params['update']=='tiny') {\n if (!empty($this->params['filter']) && $this->params['filter'] == 'image') {\n $filter .= !empty($filter) ? \" AND \" : \"\";\n $filter .= \"is_image=1\";\n }",
"",
"// $totalrecords = $this->$modelname->find('count',$filter);\n// $files = $this->$modelname->find('all',$filter,$sort.' '.$dir, $results, $startIndex);\n $files = $this->$modelname->find('all', $filter, $sort.' '.$dir);",
" $groupedfiles = array();\n foreach ($files as $key=>$file) {\n if (empty($file->expCat[0]->title)) {\n $totalrecords++;\n if (count($groupedfiles) < ($startIndex + $results)) {\n $groupedfiles[$key] = $files[$key];\n // $files[$key]->cat = $file->expCat[0]->title;\n // $files[$key]->catid = $file->expCat[0]->id;\n $tmpusr = new user($file->poster);\n $groupedfiles[$key]->user = new stdClass();\n $groupedfiles[$key]->user->firstname = $tmpusr->firstname;\n $groupedfiles[$key]->user->lastname = $tmpusr->lastname;\n $groupedfiles[$key]->user->username = $tmpusr->username;\n }\n }\n }\n $groupedfiles = array_values(array_filter($groupedfiles));\n $files = array_slice($groupedfiles,$startIndex,$results);",
" $returnValue = array(\n 'recordsReturned'=>count($files),\n 'totalRecords'=>$totalrecords,\n 'startIndex'=>$startIndex,\n 'sort'=>$sort,\n 'dir'=>$dir,\n 'pageSize'=>$results,\n 'records'=>$files\n );",
"\n }\n",
" echo json_encode($returnValue);\n }",
" /**\n * create a new virtual folder in response to an ajax request\n * return updated list of virtual folders in response to an ajax request\n */\n public function createFolder() {\n if (!empty($this->params['folder'])) {\n $expcat = new expCat($this->params['folder']);\n if (empty($expcat->id)) {\n $expcat->module = 'file';\n $expcat->title = $this->params['folder'];\n $expcat->update();\n }\n// $this->params['module'] = 'file';\n// $this->params['title'] = $this->params['folder'];\n// parent::update();\n $cats = $expcat->find('all','module=\"file\"','rank');\n $catarray = array();\n $catarray[] = 'Root Folder';\n foreach ($cats as $cat) {\n $catarray[$cat->id] = $cat->title;\n }\n echo json_encode($catarray);\n }\n }",
" public function delete() {\n// global $db,$user;\n global $user;",
" $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->delete();\n if (unlink($file->directory.$file->filename)) {\n flash('message',$file->filename.' '.gt('was successfully deleted'));\n } else {\n flash('error',$file->filename.' '.gt('was deleted from the database, but could not be removed from the file system.'));\n }\n } else {\n flash('error',$file->filename.' '.gt('wasn\\'t deleted because you don\\'t own the file.'));\n }\n redirect_to(array(\"controller\"=>'file',\"action\"=>'picker',\"ajax_action\"=>1,\"update\"=>$this->params['update'],\"filter\"=>$this->params['filter']));",
" }\n",
" public function deleter() {\n// global $db;",
" $notafile = array();\n// $files = $db->selectObjects('expFiles',1);\n foreach (expFile::selectAllFiles() as $file) {\n if (!is_file(BASE.$file->directory.$file->filename)) {\n $notafile[$file->id] = $file;\n }\n }\n assign_to_template(array(\n 'files'=>$notafile\n ));\n }",
" public function deleteit() {\n global $user;\n if (!empty($this->params['deleteit'])) {\n foreach ($this->params['deleteit'] as $file) {\n $delfile = new expFile($file);\n if ($user->id==$delfile->poster || $user->isAdmin()) {\n $delfile->delete();\n flash('error',$delfile->filename.' '.gt('was deleted from the database.'));\n }\n }\n }\n redirect_to(array(\"controller\"=>'file',\"action\"=>'picker',\"ajax_action\"=>1,\"update\"=>$this->params['update'],\"filter\"=>$this->params['filter']));\n }",
" public function batchDelete() {\n global $user;",
" $error = false;\n// if (get_magic_quotes_gpc()) $this->params['files'] = stripslashes($this->params['files']); // magic quotes fix\n $this->params['files'] = stripslashes($this->params['files']);\n $files = json_decode($this->params['files']);\n switch (json_last_error()) { //FIXME json error checking/reporting, may no longer be needed\n case JSON_ERROR_NONE:\n break;\n case JSON_ERROR_DEPTH:\n $error = 'JSON - Maximum stack depth exceeded';\n break;\n case JSON_ERROR_STATE_MISMATCH:\n $error = 'JSON - Underflow or the modes mismatch';\n break;\n case JSON_ERROR_CTRL_CHAR:\n $error = 'JSON - Unexpected control character found';\n break;\n case JSON_ERROR_SYNTAX:\n $error = 'JSON - Syntax error, malformed JSON';\n break;\n case JSON_ERROR_UTF8:\n $error = 'JSON - Malformed UTF-8 characters, possibly incorrectly encoded';\n break;\n default:\n $error = 'JSON - Unknown error';\n break;\n }",
" if (empty($error)) foreach ($files as $file) {\n $delfile = new expFile($file->id);\n if ($user->id==$delfile->poster || $user->isAdmin()) {\n $delfile->delete();\n unlink($delfile->directory.$delfile->filename);\n } else {\n $error = gt(\"you didn't have permission\");\n }\n }\n if (!empty($error)) {\n $ar = new expAjaxReply(300, gt(\"Some files were NOT deleted because\") . ' ' . $error);\n } else {\n $ar = new expAjaxReply(200, gt('Your files were deleted successfully'), $file);\n }\n $ar->send();\n }",
" public function adder() {\n global $db;",
" $notindb = array();\n $allfiles = expFile::listFlat(BASE.'files',true,null,array(),BASE);\n foreach ($allfiles as $path=>$file) {\n if ($file[0] != '.') {\n// $found = false;\n $npath = preg_replace('/'.$file.'/','',$path, 1);\n// $dbfiles = $db->selectObjects('expFiles',\"filename='\".$file.\"' AND directory='\".$npath.\"'\");\n $dbfile = $db->selectObject('expFiles',\"filename='\".$file.\"' AND directory='\".$npath.\"'\");\n// foreach ($dbfiles as $dbfile) {\n// if (!empty($dbfile)) $found = ($dbfile->directory == str_replace($file,'',$path));\n// }\n// if (!$found) {\n// $notindb[$path] = $file;\n// }\n if (empty($dbfile)) {\n $notindb[$path] = $file;\n }\n }\n }\n assign_to_template(array(\n 'files'=>$notindb\n ));\n }",
" public function addit() {\n foreach ($this->params['addit'] as $file) {\n $newfile = new expFile(array('directory'=>dirname($file).'/','filename'=>basename($file)));\n $newfile->posted = $newfile->last_accessed = filemtime($file);\n $newfile->save();\n flash('message',$newfile->filename.' '.gt('was added to the File Manager.'));\n }\n redirect_to(array(\"controller\"=>'file',\"action\"=>'picker',\"ajax_action\"=>1,\"update\"=>$this->params['update'],\"filter\"=>$this->params['filter']));\n }",
" public function upload() {",
"",
" // upload the file, but don't save the record yet...\n if ($this->params['resize'] != 'false') {\n $maxwidth = $this->params['max_width'];\n } else {\n $maxwidth = null;\n }\n $file = expFile::fileUpload('Filedata',false,false,null,null,$maxwidth);\n // since most likely this function will only get hit via flash in YUI Uploader\n // and since Flash can't pass cookies, we lose the knowledge of our $user\n // so we're passing the user's ID in as $_POST data. We then instantiate a new $user,\n // and then assign $user->id to $file->poster so we have an audit trail for the upload",
" if (is_object($file)) {\n $resized = !empty($file->resized) ? true : false;\n $user = new user($this->params['usrid']);\n $file->poster = $user->id;\n $file->posted = $file->last_accessed = time();\n $file->save();\n if (!empty($this->params['cat'])) {\n $expcat = new expCat($this->params['cat']);\n $params['expCat'][0] = $expcat->id;\n $file->update($params);\n }",
" // a echo so YUI Uploader is notified of the function's completion\n if ($resized) {\n echo gt('File resized and then saved');\n } else {\n echo gt('File saved');\n }\n } else {\n echo gt('File was NOT uploaded!');\n// flash('error',gt('File was not uploaded!'));\n }",
" }",
"\n public function quickUpload(){\n global $user;",
" if (!empty($this->params['folder']) || (defined('QUICK_UPLOAD_FOLDER') && QUICK_UPLOAD_FOLDER != '' && QUICK_UPLOAD_FOLDER != 0)) {\n // prevent attempt to place file somewhere other than /files folder\n if (!empty($this->params['folder']) && strpos($this->params['folder'], '..') !== false) {\n $ar = new expAjaxReply(300, gt(\"File was not uploaded!\"));\n $ar->send();\n }\n if (SITE_FILE_MANAGER == 'picker') {\n $quikFolder = !empty($this->params['folder']) ? $this->params['folder'] :QUICK_UPLOAD_FOLDER;\n $destDir = null;\n } elseif (SITE_FILE_MANAGER == 'elfinder') {\n $quikFolder = null;\n $destDir = UPLOAD_DIRECTORY_RELATIVE . (!empty($this->params['folder']) ? $this->params['folder'] :QUICK_UPLOAD_FOLDER) . '/';\n // create folder if non-existant\n expFile::makeDirectory($destDir);\n }\n } else {\n $quikFolder = null;\n $destDir = null;\n }",
" //extensive suitability check before doing anything with the file...\n if (isset($_SERVER['HTTP_X_FILE_NAME'])) { //HTML5 XHR upload\n $file = expFile::fileXHRUpload($_SERVER['HTTP_X_FILE_NAME'],false,false,null,$destDir,intval(QUICK_UPLOAD_WIDTH));\n $file->poster = $user->id;\n $file->posted = $file->last_accessed = time();\n $file->save();\n if (!empty($quikFolder)) {\n $expcat = new expCat($quikFolder);\n $params['expCat'][0] = $expcat->id;\n $file->update($params);\n }\n $ar = new expAjaxReply(200, gt('Your File was uploaded successfully'), $file->id);\n $ar->send();\n } else { //$_POST upload\n if (($_FILES['uploadfile'] == \"none\") OR (empty($_FILES['uploadfile']['name'])) ) {\n $message = gt(\"No file uploaded.\");\n } else if ($_FILES['uploadfile'][\"size\"] == 0) {\n $message = gt(\"The file is zero length.\");\n // } else if (($_FILES['upload'][\"type\"] != \"image/pjpeg\") AND ($_FILES['upload'][\"type\"] != \"image/jpeg\") AND ($_FILES['upload'][\"type\"] != \"image/png\")) {\n // $message = gt(\"The image must be in either JPG or PNG format. Please upload a JPG or PNG instead.\");\n } else if (!is_uploaded_file($_FILES['uploadfile'][\"tmp_name\"])) {\n $message = gt(\"You may be attempting to hack our server.\");\n } else {\n // upload the file, but don't save the record yet...\n $file = expFile::fileUpload('uploadfile',false,false,null,$destDir,intval(QUICK_UPLOAD_WIDTH));\n // since most likely this function will only get hit via flash in YUI Uploader\n // and since Flash can't pass cookies, we lose the knowledge of our $user\n // so we're passing the user's ID in as $_POST data. We then instantiate a new $user,\n // and then assign $user->id to $file->poster so we have an audit trail for the upload\n if (is_object($file)) {\n $file->poster = $user->id;\n $file->posted = $file->last_accessed = time();\n $file->save();\n if (!empty($quikFolder)) {\n $expcat = new expCat($quikFolder);\n $params['expCat'][0] = $expcat->id;\n $file->update($params);\n }\n $ar = new expAjaxReply(200, gt('Your File was uploaded successfully'), $file->id);\n } else {\n $ar = new expAjaxReply(300, gt(\"File was not uploaded!\").' - '.$file);\n }\n $ar->send();\n }\n }\n }",
" public function editCat() {\n global $user;\n $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $expcat = new expCat($this->params['newValue']);\n $params['expCat'][0] = $expcat->id;\n $file->update($params);\n $file->cat = $expcat->title;\n $file->catid = $expcat->id;\n $ar = new expAjaxReply(200, gt('Your Folder was updated successfully'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so you can't edit it.\"));\n }\n $ar->send();\n }",
" public function editTitle() {\n global $user;\n $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->title = $this->params['newValue'];\n $file->save();\n $ar = new expAjaxReply(200, gt('Your title was updated successfully'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so you can't edit it.\"));\n }\n $ar->send();",
" }",
"\n public function editAlt() {",
" global $user;",
" $file = new expFile($this->params['id']);\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->alt = $this->params['newValue'];\n $file->save();\n $ar = new expAjaxReply(200, gt('Your alt was updated successfully'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so you can't edit it.\"));\n }\n $ar->send();\n echo json_encode($file); //FIXME we exit before hitting this",
" }",
"\n public function editShare() {\n global $user;\n $file = new expFile($this->params['id']);\n\t\tif(!isset($this->params['newValue'])) {\n\t\t\t$this->params['newValue'] = 0;\n\t\t}\n if ($user->id==$file->poster || $user->isAdmin()) {\n $file->shared = $this->params['newValue'];\n $file->save();\n $ar = new expAjaxReply(200, gt('This file is now shared.'), $file);\n } else {\n $ar = new expAjaxReply(300, gt(\"You didn't create this file, so it's not yours to share.\"));\n }\n $ar->send();\n echo json_encode($file); //FIXME we exit before hitting this\n }",
" public function import_eql() {\n }",
" public function import_eql_process() {\n global $db;",
" if ($_FILES['file']['error'] != UPLOAD_ERR_OK) {\n \tswitch($_FILES['file']['error']) {\n \t\tcase UPLOAD_ERR_INI_SIZE:\n \t\tcase UPLOAD_ERR_FORM_SIZE:\n \t\t\techo gt('The file you uploaded exceeded the size limits for the server.').'<br />';\n \t\t\tbreak;\n \t\tcase UPLOAD_ERR_PARTIAL:\n \t\t\techo gt('The file you uploaded was only partially uploaded.').'<br />';\n \t\t\tbreak;\n \t\tcase UPLOAD_ERR_NO_FILE:\n \t\t\techo gt('No file was uploaded.').'<br />';\n \t\t\tbreak;\n \t}\n } else {\n $errors = array();\n expSession::clearAllUsersSessionCache();",
" // copy in deprecated definitions files to aid in import\n $src = BASE . \"install/old_definitions\";\n $dst = BASE . \"framework/core/definitions\";\n if (is_dir($src) && expUtil::isReallyWritable($dst)) {\n $dir = opendir($src);\n while (false !== ($file = readdir($dir))) {\n if (($file != '.') && ($file != '..')) {\n if (!file_exists($dst . '/' . $file)) {\n copy($src . '/' . $file, $dst . '/' . $file);\n }\n }\n }\n closedir($dir);\n }",
" expFile::restoreDatabase($_FILES['file']['tmp_name'], $errors);",
" // now remove deprecated definitions files\n $src = BASE . \"install/old_definitions\";\n $dst = BASE . \"framework/core/definitions\";\n if (is_dir($src) && expUtil::isReallyWritable($dst)) {\n $dir = opendir($src);\n while (false !== ($file = readdir($dir))) {\n if (($file != '.') && ($file != '..')) {\n if (file_exists($dst . '/' . $file)) {\n unlink($dst . '/' . $file);\n }\n // remove empty deprecated tables\n $table = substr($file, 0, -4);\n if ($db->tableIsEmpty($table)) {\n $db->dropTable($table);\n }\n }\n }\n closedir($dir);\n }",
" // update search index\n searchController::spider();",
" // check to see if we need to install or upgrade the restored database\n expVersion::checkVersion();",
" assign_to_template(\n array(\n 'success' => !count($errors),\n 'errors' => $errors,\n )\n );\n }\n }",
" public static function getTables() {\n global $db;",
" expDatabase::fix_table_names();\n $tables = $db->getTables();\n if (!function_exists('tmp_removePrefix')) {\n \tfunction tmp_removePrefix($tbl) {\n \t\t// we add 1, because DB_TABLE_PREFIX no longer has the trailing\n \t\t// '_' character - that is automatically added by the database class.\n \t\treturn substr($tbl,strlen(DB_TABLE_PREFIX)+1);\n \t}\n }\n $tables = array_map('tmp_removePrefix',$tables);\n usort($tables,'strnatcmp');\n return $tables;\n }",
" public function export_eql() {\n// global $db, $user;\n global $user;",
"// expDatabase::fix_table_names();\n// $tables = $db->getTables();\n// if (!function_exists('tmp_removePrefix')) {\n// \tfunction tmp_removePrefix($tbl) {\n// \t\t// we add 1, because DB_TABLE_PREFIX no longer has the trailing\n// \t\t// '_' character - that is automatically added by the database class.\n// \t\treturn substr($tbl,strlen(DB_TABLE_PREFIX)+1);\n// \t}\n// }\n// $tables = array_map('tmp_removePrefix',$tables);\n// usort($tables,'strnatcmp');",
" assign_to_template(array(\n 'user' => $user,\n 'tables' => self::getTables(),\n ));\n }",
" public function export_eql_process() {\n// global $db;",
" if (!isset($this->params['tables'])) { // No checkboxes clicked so we'll dump all tables\n $this->params['tables'] = self::getTables();\n $this->params['tables'] = array_flip($this->params['tables']);\n }\n// \techo gt('You must choose at least one table to export.');\n// } else { // All good\n \t$filename = str_replace(\n \t\tarray('__DOMAIN__','__DB__'),\n \t\tarray(str_replace('.','_',HOSTNAME),DB_NAME),\n $this->params['filename']);\n \t$filename = preg_replace('/[^A-Za-z0-9_.-]/','-',strftime($filename,time()).'.eql');",
" \tob_end_clean();\n \tob_start(\"ob_gzhandler\");",
" \tif (isset($this->params['save_sample'])) { // Save as a theme sample is checked off\n \t\t$path = BASE . \"themes/\".DISPLAY_THEME.\"/sample.eql\";\n \t\tif (!$eql = fopen ($path, \"w\")) {\n \t\t\tflash('error',gt(\"Error opening eql file for writing\").\" \".$path);\n \t\t} else {\n //TODO we need to write inside call passing $eql file pointer\n $eqlfile = expFile::dumpDatabase(array_keys($this->params['tables']));\n \t\t\tif (fwrite ($eql, $eqlfile) === FALSE) {\n \t\t\t\tflash('error',gt(\"Error writing to eql file\").\" \".$path);\n \t\t\t}\n \t\t\tfclose ($eql);\n \t\t\tflash('message',gt(\"Sample database (eql file) saved to\").\" '\".DISPLAY_THEME.\"' \".gt(\"theme\"));\n \t\t\texpHistory::back();\n \t\t}\n \t} else {\n \t\t// This code was lifted from phpMyAdmin, but this is Open Source, right?",
" \t\t// 'application/octet-stream' is the registered IANA type but\n \t\t// MSIE and Opera seems to prefer 'application/octetstream'\n \t\t$mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';",
" \t\theader('Content-Type: ' . $mime_type);\n \t\theader('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n \t\t// IE need specific headers\n \t\tif (EXPONENT_USER_BROWSER == 'IE') {\n \t\t\theader('Content-Disposition: inline; filename=\"' . $filename . '\"');\n \t\t\theader('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n \t\t\theader('Pragma: public');\n \t\t} else {\n \t\t\theader('Content-Disposition: attachment; filename=\"' . $filename . '\"');\n \t\t\theader('Pragma: no-cache');\n \t\t}\n echo expFile::dumpDatabase(array_keys($this->params['tables'])); //FIXME we need to echo inside call\n \t\texit; // Exit, since we are exporting\n \t}\n// }\n }",
" public function import_files() {\n }",
" public function import_files_process() {\n if ($_FILES['file']['error'] != UPLOAD_ERR_OK) {\n \tswitch($_FILES['file']['error']) {\n \t\tcase UPLOAD_ERR_INI_SIZE:\n \t\tcase UPLOAD_ERR_FORM_SIZE:\n \t\t\techo gt('The file you uploaded exceeded the size limits for the server.').'<br />';\n \t\t\tbreak;\n \t\tcase UPLOAD_ERR_PARTIAL:\n \t\t\techo gt('The file you uploaded was only partially uploaded.').'<br />';\n \t\t\tbreak;\n \t\tcase UPLOAD_ERR_NO_FILE:\n \t\t\techo gt('No file was uploaded.').'<br />';\n \t\t\tbreak;\n \t}\n } else {\n \t$basename = basename($_FILES['file']['name']);",
" \tinclude_once(BASE.'external/Tar.php');\n \t$tar = new Archive_Tar($_FILES['file']['tmp_name'],'gz');",
" \t$dest_dir = BASE.'tmp/extensionuploads/'.uniqid('');\n \t@mkdir($dest_dir,DIR_DEFAULT_MODE_STR);\n \tif (!file_exists($dest_dir)) {\n \t\techo gt('Unable to create temporary directory to extract files archive.');\n \t} else {\n \t\t$return = $tar->extract($dest_dir);\n \t\tif (!$return) {\n \t\t\techo '<br />'.gt('Error extracting TAR archive').'<br />';\n \t\t} else if (!file_exists($dest_dir.'/files') || !is_dir($dest_dir.'/files')) {\n \t\t\techo '<br />'.gt('Invalid archive format, no \\'/files\\' folder').'<br />';\n \t\t} else {\n \t\t\t// Show the form for specifying which mod types to 'extract'",
" \t\t\t$mods = array(); // Stores the mod classname, the files list, and the module's real name",
" \t\t\t$dh = opendir($dest_dir.'/files');\n \t\t\twhile (($file = readdir($dh)) !== false) {\n \t\t\t\tif ($file{0} != '.' && is_dir($dest_dir.'/files/'.$file)) {\n \t\t\t\t\t$mods[$file] = array(\n \t\t\t\t\t\t'',\n \t\t\t\t\t\tarray_keys(expFile::listFlat($dest_dir.'/files/'.$file,1,null,array(),$dest_dir.'/files/'))\n \t\t\t\t\t);\n //\t\t\t\t\tif (class_exists($file)) {\n //\t\t\t\t\t\t$mods[$file][0] = call_user_func(array($file,'name')); // $file is the class name of the module\n //\t\t\t\t\t}\n \t\t\t\t} elseif ($file != '.' && $file != '..') {\n \t\t\t\t\t$mods[$file] = array(\n \t\t\t\t\t\t'',\n \t\t\t\t\t\t$file\n \t\t\t\t\t);\n \t\t\t\t}\n \t\t\t}",
" assign_to_template(array(\n 'dest_dir' => $dest_dir,\n 'file_data' => $mods,\n ));\n \t\t}\n \t}\n }\n }",
" public function import_files_extract() {\n $dest_dir = $this->params['dest_dir'];\n $files = array();\n foreach (array_keys($this->params['mods']) as $file) {\n \t$files[$file] = expFile::canCreate(BASE.'files/'.$file);\n //\tif (class_exists($mod)) {\n //\t\t$files[$mod][0] = call_user_func(array($mod,'name'));\n //\t}\n //\tforeach (array_keys(expFile::listFlat($dest_dir.'/files',1,null,array(),$dest_dir.'/files/')) as $file) {\n //\t\t$files[$mod][1][$file] = expFile::canCreate(BASE.'files/'.$file);\n //\t}\n }",
" expSession::set('dest_dir',$dest_dir);\n expSession::set('files_data',$files);",
" assign_to_template(array(\n 'files_data' => $files,\n ));\n }",
" public function import_files_finish() {\n $dest_dir = expSession::get('dest_dir');\n $files = expSession::get('files_data');\n if (!file_exists(BASE.'files')) {\n \tmkdir(BASE.'files',DIR_DEFAULT_MODE_STR);\n }",
" $filecount = 0;\n foreach (array_keys($files) as $file) {\n expFile::copyDirectoryStructure($dest_dir.'/files/'.$file,BASE.'files/'.$file);\n \tcopy($dest_dir.'/files/'.$file,BASE.'files/'.$file);\n \t$filecount++;\n }",
" expSession::un_set('dest_dir');\n expSession::un_set('files_data');",
" expFile::removeDirectory($dest_dir);",
" assign_to_template(array(\n 'file_count' => $filecount,\n ));\n }",
" public function export_files() {\n global $user;",
" $loc = expCore::makeLocation($this->params['controller'],isset($this->params['src'])?$this->params['src']:null,isset($this->params['int'])?$this->params['int']:null);\n //$mods = array();\n //$dh = opendir(BASE.'files');\n //while (($file = readdir($dh)) !== false) {\n //\tif (is_dir(BASE.'files/'.$file) && $file{0} != '.' && class_exists($file)) {\n //\t\t$mods[$file] = call_user_func(array($file,'name'));\n //\t}\n //}\n //uasort($mods,'strnatcmp');",
" assign_to_template(array(\n 'user' => $user,\n ));\n }",
" public function export_files_process() {\n// global $db;",
" //if (!isset($this->params['mods'])) {\n //\techo gt('You must select at least one module to export files for.');\n //\treturn;\n //}",
" include_once(BASE.'external/Tar.php');",
" $files = array();\n //foreach (array_keys($this->params['mods']) as $mod) {\n //\tforeach ($db->selectObjects('file',\"directory LIKE 'files/\".$mod.\"%'\") as $file) {\n// foreach ($db->selectObjects('expFiles',1) as $file) {\n foreach (expFile::selectAllFiles() as $file) {\n $files[] = BASE.$file->directory.$file->filename;\n }\n //}",
" $fname = tempnam(BASE.'/tmp','exporter_files_');\n $tar = new Archive_Tar($fname,'gz');\n $tar->createModify($files,'',BASE);",
" $filename = str_replace(\n array('__DOMAIN__','__DB__'),\n array(str_replace('.','_',HOSTNAME),DB_NAME),\n $this->params['filename']);\n $filename = preg_replace('/[^A-Za-z0-9_.-]/','-',strftime($filename,time()).'.tar.gz');",
" if (isset($this->params['save_sample'])) { // Save as a theme sample is checked off\n copy($fname,BASE . \"themes/\".DISPLAY_THEME_REAL.\"/sample.tar.gz\");\n unlink($fname);\n flash('message',gt(\"Sample uploaded files archive saved to\").\" '\".DISPLAY_THEME_REAL.\"' \".gt(\"theme\"));\n expHistory::back();\n } else {\n ob_end_clean();\n // This code was lifted from phpMyAdmin, but this is Open Source, right?",
" // 'application/octet-stream' is the registered IANA type but\n // MSIE and Opera seems to prefer 'application/octetstream'\n $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';",
" header('Content-Type: ' . $mime_type);\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n // IE need specific headers\n if (EXPONENT_USER_BROWSER == 'IE') {\n header('Content-Disposition: inline; filename=\"' . $filename . '\"');\n header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n header('Pragma: public');\n } else {\n header('Content-Disposition: attachment; filename=\"' . $filename . '\"');\n header('Pragma: no-cache');\n }",
" $fh = fopen($fname,'rb');\n while (!feof($fh)) {\n echo fread($fh,8192);\n }\n fclose($fh);\n unlink($fname);\n }",
" exit(''); // Exit, since we are exporting.\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\n##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * Class to handle files at the File System Level and updating\n * the record for each file.\n *\n * expFile is an extension of expRecord because File information is stored\n * in the database for future access and retrieval. This class also handles\n * and and all File System handling as well: copy, move, delete, upload,\n * and importing of data in preparation of data importation. Upload and\n * import via child classes.\n *\n * @subpackage Models\n * @package Modules\n *\n */\n/** @define \"BASE\" \"../../..\" */\nclass expFile extends expRecord {",
"// ==========================================================\n// Class Constants",
" /*\n * The definition of this constant lets other parts of the subsystem know\n * that the Image Subsystem has been included for use.\n */\n const SYS_IMAGE = 1;\n const IMAGE_ERR_NOGD = '';\n const IMAGE_ERR_NOTSUPPORTED = '_unknown';\n const IMAGE_ERR_FILENOTFOUND = '_notfound';\n const IMAGE_ERR_PERMISSIONDENIED = '_denied';",
"// ===========================================================\n// File Access Control Values",
" /**\n * Mode to use for reading from files\n *\n * @constant string FILE_MODE_READ\n *\n * @access private\n * @PHPUnit Not Defined\n *\n */\n const FILE_MODE_READ = 'rb';",
" /**\n * Mode to use for truncating files, then writing\n *\n * @constant string FILE_MODE_WRITE\n *\n * @access private\n * @PHPUnit Not Defined\n *\n */\n const FILE_MODE_WRITE = 'wb';",
" /**\n * Mode to use for appending to files\n *\n * @constant string FILE_MODE_APPEND\n *\n * @access private\n * @PHPUnit Not Defined\n *\n */\n const FILE_MODE_APPEND = 'ab';",
" /**\n * Use this when a shared (read) lock is required.\n * This is a \"relabel\" of the PHP 'LOCK_SH' constant\n *\n * @constant string FILE_LOCK_SHARED\n *\n * @access private\n * @PHPUnit Not Defined\n *\n */\n const FILE_LOCK_SHARED = LOCK_SH;",
" /**\n * Use this when an exclusive (write) lock is required\n * This is a \"relabel\" of the PHP 'LOCK_EX' constant\n *\n * @constant string FILE_LOCK_EXCLUSIVE\n *\n * @access private\n * @PHPUnit Not Defined\n *\n */\n const FILE_LOCK_EXCLUSIVE = LOCK_EX;",
" // ==========================================================\n // Class Properties and their default values",
" /**\n * Database Table Name to store File info\n *\n * @public\n * @property string $table Database Table Name\n *\n */\n public $table = 'expFiles';\n protected $attachable_table = 'content_expFiles';",
" protected $attachable_item_types = array(\n 'content_expCats' => 'expCat',\n// 'content_expComments'=>'expComment',\n// 'content_expDefinableFields' => 'expDefinableField',\n// 'content_expFiles' => 'expFile',\n// 'content_expRatings'=>'expRating',\n// 'content_expSimpleNote'=>'expSimpleNote',\n// 'content_expTags'=>'expTag',\n );",
" /**\n * Relative OS System File path to where $filename is [to be] located\n *\n * @protected\n * @property string $directory Relative OS System File path\n *\n */\n public $directory = null;",
" /**\n * File Name of File to process\n *\n * @public\n * @property string $filename Name of File to process\n *\n */\n public $filename = null;",
" /**\n * Size of File, in Bytes\n *\n * @protected\n * @property string $filesize Size of File, in Bytes.\n *\n */\n public $filesize = null;",
" /**\n * Mime Type of File.\n *\n * @public\n * @property string $mimetype File MIME Type\n *\n */\n public $mimetype = null;",
" /**\n * Image width in pixels.\n *\n * @public\n * @property string $image_width Image width in pixels\n *\n */\n public $image_width = null;",
" /**\n * Image height in pixels.\n *\n * @public\n * @property string $image_height Image height in pixels\n *\n */\n public $image_height = null;",
" /**\n * Is this file an image.\n # Defaults to FALSE\n *\n * @public\n * @property string $is_image Is this file an image\n *\n */\n public $is_image = false;",
" /**\n * Determines if this file can be overwritten.\n * Also if it can be \"moved\" or \"renamed\" over\n * Default set to FALSE, no it can't\n *\n * @protected boolean\n * @property boolean $fileOverWrite Determines if this file be overwritten\n *\n * @access protected\n * @since 1.1\n */\n protected $fileOverWrite = false;",
" /**\n * Web based Path for current File\n *\n * @public\n * @property string $url Web based Path\n *\n */\n public $url = null;",
" /**\n * Full File System Path for current File. Also used to in FILE Record\n *\n * @public\n * @property string $path Full File System Path\n *\n */\n public $path = null;",
" /**\n * Relative File System Path for current File\n *\n * @public\n * @property string $path_relative Relative File System Path\n *\n */\n public $path_relative = null;",
"// ==========================================================\n// Class Methods",
" /**\n * Class constructor to create a File Class either from a database\n * record or from the File System.\n *\n * Class will either: a) load an existing File Record\n * b) modify an existing File Record\n * c) create a new File Record\n *\n * This will also handle any File System handling that is needed: copy,\n * move, create, delete, read and write.\n *\n * @access public\n *\n * @uses expRecord::__construct\n *\n * @PHPUnit Not Defined\n *\n * @param mixed $params - If an INT is given, this assumes that it needs to\n * load an existing File Record.\n * - If an ARRAY is given, this assumes that the elements\n * of the array are values to the File table that need\n * to be modified or other processing.\n * - If NULL is given, an empty File Object is created\n *\n * @param bool $get_assoc\n * @param bool $get_attached\n *\n * @return \\expFile Object@throws void\n *\n */\n public function __construct($params = array(), $get_assoc = false, $get_attached = true) {\n // Set 'directory' as the default FILE location\n // This will be redefined if a FILE record is loaded\n // or a path is given to the Class\n //eDebug($params,true);\n if (empty($params['directory']))\n $this->directory = UPLOAD_DIRECTORY_RELATIVE;\n // This will pull properties for class properties based upon\n // expRecord table definition\n parent::__construct($params, $get_assoc, $get_attached);",
" // If the 'directory' is the same as the default path then a given,\n // or derived, filename can be added to pathing settings\n //if ( $this->directory == UPLOAD_DIRECTORY_RELATIVE ) {\n if (!stristr($this->directory, BASE)) {\n // Place system level web root\n $this->url = URL_FULL . $this->directory . $this->filename;",
" // Place system level OS root\n $this->path = BASE . $this->directory . $this->filename;",
" // Place system OS relative path\n $this->path_relative = PATH_RELATIVE . $this->directory . $this->filename;\n } else {\n // Otherwise, the URL is not set since we can't use it, nether is\n // RELATIVE, as 'directory' must be an absolute path in this instance\n // Place system level OS root\n $relpath = str_replace(BASE, '', $this->directory);\n $this->path = $this->directory . $this->filename;\n $this->url = URL_FULL . $relpath . $this->filename;\n $this->path_relative = $relpath . $this->filename;\n }",
" // If a file location was given, not derived from the database,\n // basic file information is needed\n if (empty($this->id) && !empty($this->filename)) {\n // File info\n $_fileInfo = self::getImageInfo($this->path);\n // Assign info back to class\n $this->is_image = !empty($_fileInfo['is_image']) ? $_fileInfo['is_image'] : false;\n $this->filesize = !empty($_fileInfo['fileSize']) ? $_fileInfo['fileSize'] : 0;\n if (!empty($_fileInfo['mime'])) $this->mimetype = $_fileInfo['mime'];\n if (!empty($_fileInfo['is_image'])) {\n $this->image_width = $_fileInfo[0];\n $this->image_height = $_fileInfo[1];\n }\n }\n }",
" public function exists() {\n return (!empty($this->id) && is_file(BASE . PATH_RELATIVE . $this->directory . $this->filename));\n }\n// =========================================================================\n// Static Methods",
" public static function selectAllFiles() {\n global $db;",
" return $db->selectObjects('expFiles',1);\n }",
" /**\n * File ($_POST) UPLOAD that also optionally inserts File info into database.\n *\n * File UPLOAD is a straight forward uploader and processor. It can accept\n * filename and destination directory overrides as well. It has an additional\n * pair of flags that allow for an upload NOT to be inserted into the database\n * (default to INSERT) and if it previous file, with the same name, should be\n * overwritten (default to NO overwrite)\n *\n * @static\n * @access public\n *\n * @uses class|method|global|variable description\n * @requires class_name\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param string $_postName The name of the _FILE upload array\n * @param bool|string $_force Force the uploaded to overwrite existing file of same name\n * @param bool|string $_save Save file info to database, defaults to TRUE\n * @param string $_destFile Override the uploaded file name\n * @param string $_destDir Override the default FILE UPLOAD location\n *\n * @param null $_max_width\n *\n * @return object $_objFile expFile Object\n * @return object $errMsg Error message if something failed@throws void\n *\n * @TODO Have file upload overwrite make sure not to duplicate its record in the DB\n */\n public static function fileUpload($_postName = null,\n $_force = false,\n $_save = true,\n $_destFile = null,\n $_destDir = null,\n $_max_width = null\n ) {",
" // Make sure something was sent first off...\n if ((!isset($_SERVER['CONTENT_TYPE'])) ||\n (strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== 0)\n ) {\n return 'bad upload form';\n }",
" //check for errors\n switch ($_FILES[$_postName]['error']) {\n case UPLOAD_ERR_OK:\n // Everything looks good. Continue with the update.\n break;\n case UPLOAD_ERR_INI_SIZE:\n//\t\t\tcase images:\n // This is a tricky one to catch. If the file is too large for\n // POST, then the script won't even run.\n // But if its between post_max_size and upload_max_filesize,\n // we will get here.\n return 'file_too_large';\n case UPLOAD_ERR_FORM_SIZE:\n return 'file_exceeds_form_MAX_FILE_SIZE';\n case UPLOAD_ERR_PARTIAL:\n return 'partial_file';\n case UPLOAD_ERR_NO_FILE:\n return 'no_file_uploaded';\n case UPLOAD_ERR_NO_TMP_DIR:\n return 'missing_tmp_folder';\n case UPLOAD_ERR_CANT_WRITE:\n return 'failed_write_to_disk';\n case UPLOAD_ERR_EXTENSION:\n return 'upload_stopped_by_extension';\n default:\n return 'unknown';\n break;\n }",
" // If $_destDir is not defined, use the default Files directory\n// $_destDir = ( $_destDir == null ) ? UPLOAD_DIRECTORY : $_destDir;\n $_destDir = ($_destDir == null) ? UPLOAD_DIRECTORY_RELATIVE : $_destDir;",
" // If $_destFile is defined, use that name as an override for the\n // uploaded file name\n $_destFile = ($_destFile == null) ? self::fixName($_FILES[$_postName]['name']) : $_destFile;",
" // Fix the filename, so that we don't have funky characters screwing\n // with our attempt to create the destination file.\n // $_destFile = self::fixFileName( $_FILES[$_postName]['name']);\n // eDebug($_destFile,1);",
" // Build destination fille path for future use\n $_destFullPath = BASE . $_destDir . $_destFile;",
" //if the file exists and we don't want to overwrite it, create a new one\n if (file_exists($_destFullPath) && $_force == false) {\n $_destFile = self::resolveDuplicateFilename($_destFullPath);\n $_destFullPath = BASE . $_destDir . $_destFile;\n }",
" //Check to see if the directory exists. If not, create the directory structure.\n // if (!file_exists(BASE . $_destDir)) {\n // self::makeDirectory(BASE . $_destDir);",
" // } ",
"\n // Move the temporary uploaded file into the destination directory,\n // and change the name.\n $resized = false;\n $maxwidth = intval($_max_width);\n if (!empty($maxwidth)) {\n $tempFile = tempnam(sys_get_temp_dir(), 'exp_upload_') . '_' . $_destFile;\n move_uploaded_file($_FILES[$_postName]['tmp_name'], $tempFile);\n require_once(BASE . 'framework/modules/pixidou/includes/class.upload/class.upload.php');\n $handle = new upload($tempFile);\n if ($handle->uploaded) {\n $handle->file_new_name_body = $_destFile;\n $handle->file_new_name_ext = '';\n $handle->image_resize = true;\n $handle->image_x = $maxwidth;\n $handle->image_y = $maxwidth;\n $handle->image_ratio_no_zoom_in = true;\n $handle->jpeg_quality = THUMB_QUALITY;\n $handle->process(BASE . $_destDir);\n if ($handle->processed) {\n if ($handle->image_src_x != $handle->image_dst_x) $resized = true;\n $handle->clean();\n }\n }\n } else {\n $tmp = move_uploaded_file($_FILES[$_postName]['tmp_name'], $_destFullPath);\n }",
" if (file_exists($_destFullPath)) {\n $__oldumask = umask(0);\n chmod($_destFullPath, octdec(FILE_DEFAULT_MODE_STR + 0));\n umask($__oldumask);\n // Checking\n if ($__oldumask != umask()) {\n flash('error', gt('An error occurred while setting file permissions') . ': ' . $_destFullPath);\n }\n } else {\n return 'could not move';\n }",
" // At this point, we are good to go.",
" // Create a new expFile Object for further processing\n $_fileParams = array('filename' => $_destFile, 'directory' => $_destDir);\n $_objFile = new expFile ($_fileParams);",
" // Insert new File Record\n if ($_save === true) {\n $_objFile->save();\n }\n if ($resized) $_objFile->resized = true;\n return $_objFile;\n }",
" /**\n * XHR (HTML5) File UPLOAD that also inserts File info into database.\n *\n * File UPLOAD is a straight forward uploader and processor. It can accept\n * filename and destination directory overrides as well. It has an additional\n * pair of flags that allow for an upload NOT to be inserted into the database\n * (default to INSERT) and if it previous file, with the same name, should be\n * overwritten (default to NO overwrite)\n *\n * @static\n * @access public\n *\n * @uses class|method|global|variable description\n * @requires class_name\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param null $fileName\n * @param bool|string $_force Force the uploaded to overwrite existing file of same name\n * @param bool|string $_save Save file info to database, defaults to TRUE\n * @param string $_destFile Override the uploaded file name\n * @param string $_destDir Override the default FILE UPLOAD location\n *\n * @param null $_max_width\n *\n * @return object $_objFile expFile Object\n * @return object $errMsg Error message if something failed@throws void\n *\n * @TODO Have file upload overwrite make sure not to duplicate its record in the DB\n */\n public static function fileXHRUpload($fileName = null,\n $_force = false,\n $_save = true,\n $_destFile = null,\n $_destDir = null,\n $_max_width = null\n ) {",
" // If $_destDir is not defined, use the default Files directory\n $_destDir = ($_destDir == null) ? UPLOAD_DIRECTORY_RELATIVE : $_destDir;",
" // If $_destFile is defined, use that name as an override for the\n // uploaded file name\n $_destFile = ($_destFile == null) ? self::fixName($fileName) : $_destFile;",
" // Fix the filename, so that we don't have funky characters screwing\n // with our attempt to create the destination file.\n // $_destFile = self::fixFileName( $_FILES[$_postName]['name']);\n // eDebug($_destFile,1);",
" // Build destination fille path for future use\n $_destFullPath = BASE . $_destDir . $_destFile;",
" //if the file exists and we don't want to overwrite it, create a new one\n if (file_exists($_destFullPath) && $_force == false) {\n $_destFile = self::resolveDuplicateFilename($_destFullPath);\n $_destFullPath = BASE . $_destDir . $_destFile;\n }",
" //Check to see if the directory exists. If not, create the directory structure.\n // if (!file_exists(BASE . $_destDir)) {\n // self::makeDirectory(BASE . $_destDir);\n // }",
" // Move the temporary uploaded file into the destination directory,\n // and change the name.\n $resized = false;\n $maxwidth = intval($_max_width);\n if (!empty($maxwidth)) {\n $tempFile = tempnam(sys_get_temp_dir(), 'exp_upload_') . '_' . $_destFile;\n// move_uploaded_file($_FILES[$fileName]['tmp_name'], $tempFile);\n file_put_contents($tempFile, file_get_contents('php://input'));\n require_once(BASE . 'framework/modules/pixidou/includes/class.upload/class.upload.php');\n $handle = new upload($tempFile);\n if ($handle->uploaded) {\n $handle->file_new_name_body = $_destFile;\n $handle->file_new_name_ext = '';\n $handle->image_resize = true;\n $handle->image_x = $maxwidth;\n $handle->image_y = $maxwidth;\n $handle->image_ratio_no_zoom_in = true;\n $handle->jpeg_quality = THUMB_QUALITY;\n $handle->process(BASE . $_destDir);\n if ($handle->processed) {\n if ($handle->image_src_x != $handle->image_dst_x) $resized = true;\n $handle->clean();\n }\n }\n } else {\n file_put_contents($_destFullPath, file_get_contents('php://input', 'r'));\n }",
" if (file_exists($_destFullPath)) {\n $__oldumask = umask(0);\n chmod($_destFullPath, octdec(FILE_DEFAULT_MODE_STR + 0));\n umask($__oldumask);\n // Checking\n if ($__oldumask != umask()) {\n flash('error', gt('An error occurred while setting file permissions') . ': ' . $_destFullPath);\n }\n } else {\n return 'could not move';\n }",
" // At this point, we are good to go.",
" // Create a new expFile Object for further processing\n $_fileParams = array('filename' => $_destFile, 'directory' => $_destDir);\n $_objFile = new expFile ($_fileParams);",
" // Insert new File Record\n if ($_save === true) {\n $_objFile->save();\n }\n if ($resized) $_objFile->resized = true;\n return $_objFile;\n }",
" /**\n * Performs a system level check on the file and retrieves its size\n *\n * @static\n * @access public\n *\n * @uses function filesize() Built-in PHP method\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param bool|string $_path Full path to file to pull info from\n *\n * @return int $_fileSize Size of file in bytes\n * @throws void\n *\n */\n public static function fileSize($_path = false) {\n if ($_path)\n $_fileSize = filesize($_path);\n else\n $_fileSize = 0;",
" return $_fileSize;\n }",
" /**\n * check for duplicate files and returns a file name that's not already in the system\n *\n * @static\n * @access public\n *\n * @uses function filesize() Built-in PHP method\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param string $filepath direct path of the file to check against\n *\n * @return int $newFileName Name of the file that isn't a duplicate\n * @throws void\n *\n */\n public static function resolveDuplicateFilename($filepath) {\n $extension = strrchr($filepath, \".\"); // grab the file extention by looking for the last dot in the string\n $filnameWoExt = str_replace($extension, \"\", str_replace(\"/\", \"\", strrchr($filepath, \"/\"))); // filename sans extention\n $pathToFile = str_replace($filnameWoExt . $extension, \"\", $filepath); // path sans filename",
" $i = \"\";\n $inc = \"\";\n while (file_exists($pathToFile . $filnameWoExt . $inc . $extension)) {\n $i++;\n $inc = \"-\" . $i;\n }",
" //we'll just return the new filename assuming we've\n //already got the path we want on the other side\n return $filnameWoExt . $inc . $extension;\n }",
" /**\n * prompts the user to download a file\n *\n * @static\n * @access public\n *\n * @uses function download() Built-in PHP method\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param string $file Full path to file to download\n *\n * @return void\n * @throws void\n *\n */\n public static function download($file) {\n // we are expecting an int val as a file ID or the whole file object.\n // If all we get is the ID then we'll instantiate a new file object.\n // If that object doesn't have it's id property set or the file doesn't\n // actually exist then we can assume its not a valid file object and\n // return false.\n if (!is_object($file)) $file = new expFile($file);\n //if (empty($file->id) || !file_exists($file->path)) return false;\n if (!file_exists($file->path)) {\n flash('error', gt('The file is unavailable for Download'));\n expHistory::back();\n return false;\n }",
" // NO buffering from here on out or things break unexpectedly. - RAM\n ob_end_clean();",
" // This code was lifted from phpMyAdmin, but this is Open Source, right?\n // 'application/octet-stream' is the registered IANA type but\n // MSIE and Opera seems to prefer 'application/octetstream'\n // It seems that other headers I've added make IE prefer octet-stream again. - RAM",
" $mimetype = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octet-stream;' : $file->mimetype;",
" header('Content-Type: ' . $mimetype);\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n header('Content-Transfer-Encoding: binary');\n//\t\theader('Content-Encoding:');\n header('Content-Disposition: attachment; filename=\"' . $file->filename . '\";');\n $filesize = filesize($file->path);\n if ($filesize) header(\"Content-length: \" . $filesize); // for some reason the webserver cant run stat on the files and this breaks.\n // IE need specific headers\n if (EXPONENT_USER_BROWSER == 'IE') {\n header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n header('Pragma: public');\n header('Vary: User-Agent');\n } else {\n header('Pragma: no-cache');\n }",
" //Read the file out directly\n readfile($file->path);\n exit();\n }",
" /**\n * Replace anything but alphanumeric characters with an UNDERSCORE\n *\n * @static\n * @access public\n *\n * @uses function preg_replace built-in PHP Function\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param string $name File name to 'fix'\n *\n * @return string $name the correct filename\n * @throws void\n *\n */\n public static function fixName($name) {\n $name = preg_replace('/[^A-Za-z0-9\\.]/','_',$name);",
" if ($name[0] == '.')",
" $name[0] = '_';",
"",
" return $name;\n// return preg_replace('/[^A-Za-z0-9\\.]/', '-', $name);\n }",
" /**\n * Return the mimetype for the passed filename\n *\n * @param string $filename\n * @return string\n */\n public static function getMimeType($filename) {\n /* Store an array of commom mimetypes */\n $types = array(\n 'txt' => 'text/plain',\n 'htm' => 'text/html',\n 'html' => 'text/html',\n 'php' => 'text/html',\n 'css' => 'text/css',\n 'js' => 'application/javascript',\n 'json' => 'application/json',\n 'xml' => 'application/xml',",
" // images\n 'png' => 'image/png',\n 'jpe' => 'image/jpeg',\n 'jpeg' => 'image/jpeg',\n 'jpg' => 'image/jpeg',\n 'gif' => 'image/gif',\n 'bmp' => 'image/bmp',\n 'ico' => 'image/vnd.microsoft.icon',\n 'tiff' => 'image/tiff',\n 'tif' => 'image/tiff',\n 'svg' => 'image/svg+xml',\n 'svgz' => 'image/svg+xml',",
" // archives\n 'gz' => 'application/x-gzip',\n 'zip' => 'application/zip',\n 'rar' => 'application/x-rar-compressed',\n 'exe' => 'application/x-msdownload',\n 'msi' => 'application/x-msdownload',\n 'cab' => 'application/vnd.ms-cab-compressed',",
" // audio/video\n 'mp3' => 'audio/mpeg',\n 'ogg' => 'audio/ogg',\n 'qt' => 'video/quicktime',\n 'mov' => 'video/quicktime',\n 'f4v' => 'video/mp4',\n 'mp4' => 'video/mp4',\n 'm4v' => 'video/x-m4v',\n 'ogv' => 'video/ogg',\n '3gp' => 'video/3gpp',\n 'webm' => 'video/webm',\n 'flv' => 'video/x-flv',\n 'swf' => 'application/x-shockwave-flash',",
" // adobe\n 'pdf' => 'application/pdf',\n// 'psd' => 'image/vnd.adobe.photoshop',\n// 'ai' => 'application/postscript',\n// 'eps' => 'application/postscript',\n// 'ps' => 'application/postscript',",
" // ms office\n// 'doc' => 'application/msword',\n// 'rtf' => 'application/rtf',\n// 'xls' => 'application/vnd.ms-excel',\n// 'ppt' => 'application/vnd.ms-powerpoint',",
" // open office\n// 'odt' => 'application/vnd.oasis.opendocument.text',\n// 'ods' => 'application/vnd.oasis.opendocument.spreadsheet'\n );",
" /* Get the file extension,\n * FYI: this is *really* hax.\n */\n $fileparts = explode('.',$filename);\n $extension = strtolower(array_pop($fileparts));\n if(array_key_exists($extension, $types)) {\n /* If we can *guess* the mimetype based on the filename, do that for standardization */\n return $types[$extension];\n } elseif(function_exists('finfo_open')) {\n /* If we don't have to guess, do it the right way */\n $finfo = finfo_open(FILEINFO_MIME);\n $mimetype = finfo_file($finfo, $filename);\n finfo_close($finfo);\n return $mimetype;\n } else {\n /* Otherwise, let the browser guess */\n return 'application/octet-stream';\n }\n }",
"// ==========================================================\n// Class Image Processing Methods\n// @TODO This collection of methods need to be placed in their own Class",
" /**\n * Return size and mimetype information about an image file,\n * given its path/filename. This is a wrapper around the\n * built-in PHP 'getimagesize' function, to make all implementations\n * work identically.\n *\n * @static\n * @access public\n *\n * @uses function getimagesize() Built-in PHP function\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param bool|string $_path Full path to file to pull info from\n *\n * @return array $_sizeinfo An array of Image File info\n * @return array $error message Error message@throws void\n *\n */\n public static function getImageInfo($_path = false) {",
" $_path = __realpath($_path);",
" if (!file_exists($_path)) return self::IMAGE_ERR_FILENOTFOUND;\n if (!is_readable($_path)) return self::IMAGE_ERR_PERMISSIONDENIED;",
" if ($_sizeinfo = @getimagesize($_path)) {\n $_sizeinfo['is_image'] = true;\n// if (!isset($_sizeinfo['mime'])) {\n// // In case this implementation of getimagesize doesn't discover\n// // the mime type\n// $_types = array(\n// 'jpg' => 'image/jpeg',\n// 'jpeg' => 'image/jpeg',\n// 'gif' => 'image/gif',\n// 'png' => 'image/png'\n// );\n//\n// $_fileData = pathinfo($_path);\n// if (array_key_exists($_fileData['extension'], $_types)) $_sizeinfo['mime'] = $_types[$_fileData['extension']];\n// }\n } else {\n $_sizeinfo['is_image'] = false;\n// if (!isset($_sizeinfo['mime'])) {\n// // In case this implementation of getimagesize doesn't discover\n// // the mime type\n// $_types = array(\n// 'mp3' => 'audio/mpeg',\n// 'ogg' => 'audio/ogg',\n// 'flv' => 'video/x-flv',\n// 'f4v' => 'video/mp4',\n// 'mp4' => 'video/mp4',\n// 'ogv' => 'video/ogg',\n// '3gp' => 'video/3gpp',\n// 'webm' => 'video/webm',\n// 'pdf' => 'application/pdf',\n// );\n//\n// $_fileData = pathinfo($_path);\n// if (array_key_exists($_fileData['extension'], $_types)) $_sizeinfo['mime'] = $_types[$_fileData['extension']];\n// }\n }\n $_sizeinfo['mime'] = self::getMimeType($_path);\n $_sizeinfo['fileSize'] = self::fileSize($_path);",
" return $_sizeinfo;\n }",
" /** exdoc\n * Create an image resource handle (from GD) for a given filename.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * At this point, the user should have called self::getImageInfo on the filename\n * and verified that the file does indeed exist, and is readable. A safeguard check\n * is in place, however.\n *\n * @param string $filename The path/filename of the image.\n *\n * @return null|resource|string\n * @node Model:expFile\n */\n public static function openImageFile($filename) {\n if (!EXPONENT_HAS_GD) return null;",
" $sizeinfo = @getimagesize($filename);\n $info = gd_info();",
" if ($sizeinfo['mime'] == 'image/jpeg' && $info['JPG Support'] == true) {\n $img = imagecreatefromjpeg($filename);\n } else if ($sizeinfo['mime'] == 'image/png' && $info['PNG Support'] == true) {\n $img = imagecreatefrompng($filename);\n } else if ($sizeinfo['mime'] == 'image/gif' && $info['GIF Read Support'] == true) {\n $img = imagecreatefromgif($filename);\n } else {\n // Either we have an unknown image type, or an unsupported image type.\n return self::IMAGE_ERR_NOTSUPPORTED;\n }",
" if (function_exists('imagesavealpha')) {\n imagealphablending($img, false);\n imagesavealpha($img, true);\n }\n return $img;\n }",
" /** exdoc\n * Create a new blank image resource, with the specified width and height.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param integer $w Width of the image resource to create (in pixels)\n * @param integer $h Height of the image resource to create (in pixels)\n *\n * @return null|resource\n * @node Model:expFile\n */\n public static function imageCreate($w, $h) {\n if (!EXPONENT_HAS_GD) {\n return null;\n }\n $info = gd_info();\n if (strpos($info['GD Version'], '2.0') !== false) {\n $img = imagecreatetruecolor($w, $h);",
" if (function_exists('imagesavealpha')) {\n imagealphablending($img, false);\n imagesavealpha($img, true);\n }",
" return $img;\n } else {\n return imagecreate($w, $h);\n }\n }",
" function copyToDirectory($destination) {\n //eDebug($this,true);\n copy($this->path, $destination . $this->filename);\n }",
" public static function imageCopyresized($dest, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {\n if (!EXPONENT_HAS_GD) {\n return null;\n }\n $info = gd_info();\n if (strpos($info['GD Version'], '2.0') !== false) {\n return imagecopyresampled($dest, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n } else {\n return imagecopyresized($dest, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n }\n }",
" /** exdoc\n * Proportionally scale an image by a specific percentage\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param float $scale The scaling factor, as a decimal (i.e. 0.5 for 50%)\n *\n * @return array|null|resource|string\n * @node Model:expFile\n */\n public static function imageScaleByPercent($filename, $scale) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" if ($scale == 1) {\n return $original;\n }",
" $w = $scale * $sizeinfo[0];\n $h = $scale * $sizeinfo[1];",
" $thumb = self::imageCreate($w, $h);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, 0, 0, $w, $h, $sizeinfo[0], $sizeinfo[1]);",
" return $thumb;\n }",
" /** exdoc\n * Proportionally scale an image to a given width. Height adjusts accordingly.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param integer $width The desired width of the scaled image, in pixels.\n *\n * @return array|null|resource|string\n * @node Model:expFile\n */\n public static function imageScaleToWidth($filename, $width) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }\n $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $sizeinfo;\n }",
" if ($width == $sizeinfo[0]) {\n return $original;\n }",
" $w = $width;\n $h = ($width / $sizeinfo[0]) * $sizeinfo[1];",
" $thumb = self::imageCreate($w, $h);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, 0, 0, $w, $h, $sizeinfo[0], $sizeinfo[1]);",
" return $thumb;\n }",
" /** exdoc\n * Proportionally scale an image to a given height. Width adjusts accordingly.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param integer $height The desired height of the scaled image, in pixels.\n *\n * @return array|null|resource|string\n * @node Model:expFile\n */\n public static function imageScaleToHeight($filename, $height) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" if ($height == $sizeinfo[1]) {\n return $original;\n }",
" $w = ($height / $sizeinfo[1]) * $sizeinfo[0];\n $h = $height;",
" $thumb = self::imageCreate($w, $h);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, 0, 0, $w, $h, $sizeinfo[0], $sizeinfo[1]);",
" return $thumb;\n }",
" /** exdoc\n * Proportionally scale an image to fit within the given width / height.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param integer $width The maximum width of the scaled image, in pixels.\n * @param integer $height The maximum height of the scaled image, in pixels.\n *\n * @return array|null|resource|string\n * @node Model:expFile\n */\n public static function imageScaleToConstraint($filename, $width, $height) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" if ($width >= $sizeinfo[0] && $height >= $sizeinfo[1]) {\n return $original;\n }",
" $w = $width;\n $h = ($width / $sizeinfo[0]) * $sizeinfo[1];",
" if ($h > $height) { // height is outside\n $w = ($height / $sizeinfo[1]) * $sizeinfo[0];\n $h = $height;\n }",
" $thumb = self::imageCreate($w, $h);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, 0, 0, $w, $h, $sizeinfo[0], $sizeinfo[1]);",
" return $thumb;\n }",
" /** exdoc\n * Scale an image to a square keeping the image aspect ratio.\n * If the image is smaller in either dimension than request square side original is returned.\n * Image is first cropped to a square of length smaller of width or height and then resized.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param $side\n *\n * @return array|null|resource|string\n * @internal param int $size The desired side length of the scaled image, in pixels.\n * @node Model:expFile\n */\n public static function imageScaleToSquare($filename, $side) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" if ($side >= $sizeinfo[0] || $side >= $sizeinfo[1]) {\n return $original;\n }",
" /* The defaults will serve in case the image is a square */\n $src_x = 0;\n $src_y = 0;\n $width = $sizeinfo[0];\n $height = $sizeinfo[1];",
" /*if width greater than height, we crop the image left and right */\n if ($sizeinfo[0] > $sizeinfo[1]) {\n $width = $sizeinfo[1];\n $height = $sizeinfo[1];\n $src_x = round(($sizeinfo[0] - $width) / 2, 0);\n } else {\n /*if height greater than width, we crop the image top and bottom */\n $height = $sizeinfo[0];\n $width = $sizeinfo[0];\n $src_y = round(($sizeinfo[1] - $height) / 2, 0);\n }",
" $w = $side;\n $h = $side;",
" $thumb = self::imageCreate($w, $h);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, $src_x, $src_y, $w, $h, $width, $height);",
" return $thumb;\n }",
" /** exdoc\n * Scale an image to a given width and height, without regard to aspect ratio.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param integer $width The desired width of the scaled image, in pixels.\n * @param integer $height The desired height of the scaled image, in pixels.\n *\n * @return array|null|resource|string\n * @node Model:expFile\n */\n public static function imageScaleManually($filename, $width, $height) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" if ($width == $sizeinfo[0] && $height == $sizeinfo[1]) {\n return $original;\n }",
" $thumb = self::imageCreate($width, $height);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, 0, 0, $width, $height, $sizeinfo[0], $sizeinfo[1]);",
" return $thumb;\n }",
" public static function imageRotate($filename, $degrees) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" $color = imagecolorclosesthwb($original, 255, 255, 255);",
" return imagerotate($original, $degrees, $color);\n }",
" public static function imageFlip($filename, $is_horizontal) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" // Horizontal - invert y coords\n // Vertical - invert x coords",
" $w = $sizeinfo[0];\n $h = $sizeinfo[1];\n $new = self::imageCreate($w, $h);",
" if ($is_horizontal) {\n // Copy column by column\n //$dest,$src,$dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {\n for ($i = 0; $i < $w; $i++) {\n imagecopy($new, $original, // DESTINATION, SOURCE\n $i, 0, // dst_X, dst_Y\n $w - $i - 1, 0, // src_X,src_Y\n 1, $h); //src_W, src_H\n }\n } else {\n // Copy row by row.\n //$dest,$src,$dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {\n for ($i = 0; $i < $h; $i++) {\n imagecopy($new, $original, // DESTINATION, SOURCE\n 0, $i, // dst_X, dst_Y\n 0, $h - $i - 1, // src_X,src_Y\n #$w,1,\t\t// dst_W, dst_H\n $w, 1); //src_W, src_H\n }\n }\n return $new;\n }",
" /** exdoc\n *\n * @state <b>UNDOCUMENTED</b>\n * @node Undocumented\n *\n * @param $img\n * @param $sizeinfo\n * @param null $filename\n * @param int $quality\n */\n public static function imageOutput($img, $sizeinfo, $filename = null, $quality = 75) {\n header('Content-type: ' . $sizeinfo['mime']);\n if ($sizeinfo['mime'] == 'image/jpeg') {\n ($filename != null) ? imagejpeg($img, $filename, $quality) : imagejpeg($img, null, $quality);\n } else if ($sizeinfo['mime'] == 'image/png') {\n ($filename != null) ? imagepng($img, $filename) : imagepng($img);\n } else if ($sizeinfo['mime'] == 'image/gif') {\n ($filename != null) ? imagepng($img, $filename) : imagepng($img);\n }\n }",
" /** exdoc\n *\n * @state <b>UNDOCUMENTED</b>\n * @node Undocumented\n *\n * @param $w\n * @param $h\n * @param $string\n *\n * @return null|resource\n */\n public static function imageCaptcha($w, $h, $string) {\n $img = self::imageCreate($w, $h);\n if ($img) {\n // We were able to create an image.\n $bg = imagecolorallocate($img, 250, 255, 225);\n imagefill($img, 0, 0, $bg);\n #echo $bg;\n $colors = array();\n for ($i = 0; $i < strlen($string) && $i < 10; $i++) {\n $colors[$i] = imagecolorallocate($img, mt_rand(50, 150), mt_rand(50, 150), mt_rand(50, 150));\n }\n $px_per_char = floor($w / (strlen($string) + 1));\n for ($i = 0, $iMax = strlen($string); $i < $iMax; $i++) {\n imagestring($img, mt_rand(4, 6), $px_per_char * ($i + 1) + mt_rand(-5, 5), mt_rand(0, $h / 2), $string{$i}, $colors[($i % 10)]);\n }",
" // Need this to be 'configurable'\n for ($i = 0; $i < strlen($string) / 2 && $i < 10; $i++) {\n $c = imagecolorallocate($img, mt_rand(150, 250), mt_rand(150, 250), mt_rand(150, 250));\n imageline($img, mt_rand(0, $w / 4), mt_rand(5, $h - 5), mt_rand(3 * $w / 4, $w), mt_rand(0, $h), $c);\n }",
" //imagestring($img,6,0,0,$string,$color);\n return $img;\n } else {\n return null;\n }\n }",
" static function recurse_copy($src, $dst) {\n $dir = opendir($src);\n @mkdir($dst,DIR_DEFAULT_MODE_STR);\n while (false !== ($file = readdir($dir))) {\n if (($file != '.') && ($file != '..')) {\n if (is_dir($src . '/' . $file)) {\n self::recurse_copy($src . '/' . $file, $dst . '/' . $file);\n } else {\n if (!copy($src . '/' . $file, $dst . '/' . $file)) {\n return false;\n }\n ;\n }\n }\n }\n closedir($dir);\n return true;\n }",
" /**\n * Recursively removes all files in a given directory, and all\n * the files and directories underneath it.\n * Optionally can skip dotfiles\n *\n * @param string $dir directory to work with\n * @param bool $dot_files should dotfiles be removed?\n *\n * @return array\n */\n public static function removeFilesInDirectory($dir, $dot_files = false) {\n $results['removed'] = array();\n $results['not_removed'] = array();",
" $files = scandir($dir);\n array_shift($files); // remove '.' from array\n array_shift($files); // remove '..' from array\n foreach ($files as $file) {\n if ($dot_files || substr($file, 0, 1) != '.') { // don't remove dot files\n $file = $dir . '/' . $file;\n if (is_dir($file)) {\n self::removeFilesInDirectory($file);\n rmdir($file);\n } else {\n if (is_writeable($file) && !is_dir($file)) {\n unlink($file);\n $results['removed'][] = $file;\n } else {\n $results['not_removed'][] = $file;\n }\n }\n }\n }",
" /*\told routine\n if (is_readable($dir)) {\n $dh = opendir($dir);\n while (($file = readdir($dh)) !== false) {\n $filepath = $dir.'/'.$file;\n if (substr($file,0,1) != '.') {\n if (is_writeable($filepath) && !is_dir($filepath)) {\n unlink($filepath);\n $results['removed'][] = $filepath;\n } else {\n $results['not_removed'][] = $filepath;\n }\n }\n }\n }*/",
" return $results;\n }",
" /** exdoc\n * This method creates a directory and all of its parent directories, if they do not exist,\n * emulating the behavior of the -p option to mkdir on UNIX systems. Returns\n * a SYS_FILES_* constant, indicating its status.\n *\n * @param string $dir The directory to create. This path must be relative to BASE\n * @param null $mode\n * @param bool $is_full\n *\n * @return int\n * @node Model:expFile\n */\n public static function makeDirectory($dir, $mode = null, $is_full = false) {\n $__oldumask = umask(0);\n $parentdir = ($is_full ? \"/\" : BASE); // we will add to parentdir with each directory\n foreach (explode(\"/\", $dir) as $part) {\n if ($part != \"\" && !is_dir($parentdir . $part)) {\n // No parent directory. Create it.\n if (is_file($parentdir . $part)) return SYS_FILES_FOUNDFILE;\n if (expUtil::isReallyWritable($parentdir)) {\n if ($mode == null) $mode = octdec(DIR_DEFAULT_MODE_STR + 0);\n mkdir($parentdir . $part, $mode);\n chmod($parentdir . $part, $mode);\n } else return SYS_FILES_NOTWRITABLE;\n }\n $parentdir .= $part . \"/\";\n }\n umask($__oldumask);\n return SYS_FILES_SUCCESS;\n }",
" /**\n * Recursively removes the given directory, and all\n * of the files and directories underneath it.\n *\n * @param string $dir The path of the directory to remove\n *\n * @node Model:expFile\n *\n * @param string $dir directory to work with\n *\n * @return int\n */\n public static function removeDirectory($dir) {\n if (strpos($dir, BASE) != 0) $dir = BASE . $dir;\n $dh = opendir($dir);\n if ($dh) {\n while (($file = readdir($dh)) !== false) {\n if ($file != \".\" && $file != \"..\" && is_dir(\"$dir/$file\")) {\n if (self::removeDirectory(\"$dir/$file\") == SYS_FILES_NOTDELETABLE) return SYS_FILES_NOTDELETABLE;\n } else if (is_file(\"$dir/$file\") || is_link(is_file(\"$dir/$file\"))) {\n unlink(\"$dir/$file\");\n if (file_exists(\"$dir/$file\")) {\n return SYS_FILES_NOTDELETABLE;\n }\n } else if ($file != \".\" && $file != \"..\") {\n echo \"BAD STUFF HAPPENED<br />\";\n echo \"--------Don't know what to do with $dir/$file<br />\";\n//\t\t\t\t\techo \"<xmp>\";\n echo \"<pre>\";\n print_r(stat(\"$dir/$file\"));\n echo filetype(\"$dir/$file\");\n//\t\t\t\t\techo \"</xmp>\";\n echo \"</pre>\";\n }\n }\n }\n closedir($dh);\n rmdir($dir);\n }",
" /** exdoc\n * Move an uploaded temporary file to a more permanent home inside of the Exponent files/ directory.\n * This function takes into account the default file modes specified in the site configuration.\n *\n * @param string $tmp_name The temporary path of the uploaded file.\n * @param string $dest The full path to the destination file (including the destination filename).\n *\n * @return null|string The destination file if it exists, otherwise null\n * @node Model:expFile\n */\n public static function moveUploadedFile($tmp_name, $dest) {\n move_uploaded_file($tmp_name, $dest);\n if (file_exists($dest)) {\n $__oldumask = umask(0);\n chmod($dest, octdec(FILE_DEFAULT_MODE_STR + 0));\n umask($__oldumask);\n return str_replace(BASE, '', $dest);\n } else return null;\n }",
" /** exdoc\n * Checks to see if the upload destination file exists. This is to prevent\n * accidentally uploading over the top of another file.\n * Returns true if the file already exists, and false if it does not.\n *\n * @param string $dir The directory to contain the existing directory.\n * @param string $name The name of the file control used to upload the\n * file. The files subsystem will look to the $_FILES array\n * to get the filename of the uploaded file.\n *\n * @return bool\n * @node Model:expFile\n */\n public static function uploadDestinationFileExists($dir, $name) {\n return (file_exists(BASE . $dir . \"/\" . self::fixName($_FILES[$name]['name'])));\n }",
" /** exdoc\n * Lists files and directories under a given parent directory. Returns an\n * associative, flat array of files and directories. The key is the full file\n * or directory name, and the value is the file or directory name.\n *\n * @param string $dir The path of the directory to look at.\n * @param boolean $recurse A boolean dictating whether to descend into subdirectories\n * recursively, and list files and subdirectories.\n * @param string $ext An optional file extension. If specified, only files ending with\n * that file extension will show up in the list. Directories are not affected.\n * @param array $exclude_dirs An array of directory names to exclude. These names are\n * path-independent. Specifying \"dir\" will ignore all directories and\n * sub-directories named \"dir\", regardless of their parent.\n * @param string $relative\n *\n * @return array\n * @node Model:expFile\n */\n public static function listFlat($dir, $recurse = false, $ext = null, $exclude_dirs = array(), $relative = \"\") {\n $files = array();\n if (is_readable($dir)) {\n $dh = opendir($dir);\n while (($file = readdir($dh)) !== false) {\n if (is_dir(\"$dir/$file\") && !in_array($file, $exclude_dirs) && $recurse && $file != \".\" && $file != \"..\" && $file != \"CVS\") {\n $files = array_merge($files, self::listFlat(\"$dir/$file\", $recurse, $ext, $exclude_dirs, $relative));\n }\n if (is_file(\"$dir/$file\") && ($ext == null || substr($file, -1 * strlen($ext), strlen($ext)) == $ext)) {\n $files[str_replace($relative, \"\", \"$dir/$file\")] = $file;\n }\n }\n closedir($dh);\n }\n return $files;\n }",
" /** exdoc\n * Looks at the filesystem structure surrounding the destination\n * and determines if the web server can create a new file there.\n * Returns one of the following:\n * <br>SYS_FILES_NOTWRITABLE - unable to create files in destination\n * <br>SYS_FILES_SUCCESS - A file or directory can be created in destination\n * <br>SYS_FILES_FOUNDFILE - Found destination to be a file, not a directory\n *\n * @param string $dest Path to the directory to check\n *\n * @return int\n * @node Model:expFile\n */\n public static function canCreate($dest) {\n if (substr($dest, 0, 1) == '/') $dest = str_replace(BASE, '', $dest);\n $parts = explode('/', $dest);\n $working = BASE;\n for ($i = 0, $iMax = count($parts); $i < $iMax; $i++) {\n if ($parts[$i] != '') {\n if (!file_exists($working . $parts[$i])) {\n return (expUtil::isReallyWritable($working) ? SYS_FILES_SUCCESS : SYS_FILES_NOTWRITABLE);\n }\n $working .= $parts[$i] . '/';\n }\n }\n // If we got this far, then the file we are asking about already exists.\n // Check to see if we can overwrite this file.\n // First however, we need to strip off the '/' that was added a few lines up as the last part of the for loop.\n $working = substr($working, 0, -1);",
" if (!expUtil::isReallyWritable($working)) {\n return SYS_FILES_NOTWRITABLE;\n } else {\n if (is_file($working)) {\n return SYS_FILES_FOUNDFILE;\n } else {\n return SYS_FILES_FOUNDDIR;\n }\n }\n }",
" /**\n * Test if file can be uploaded using tmp folder\n *\n * @param string $tmp\n * @param string $dest\n *\n * @return bool\n */\n public static function canUpload($tmp = 'tmp', $dest = 'files/uploads') {\n $result = expFile::canCreate(BASE . $tmp . '/TEST') != SYS_FILES_SUCCESS;\n $result |= expFile::canCreate(BASE . $dest . '/TEST') != SYS_FILES_SUCCESS;\n return $result;\n }",
" /** exdoc\n * Copies just the directory structure (including subdirectories) of a given directory.\n * Any files in the source directory are ignore, and duplicate copies are made (no symlinks).\n *\n * @param string $src The directory to copy structure from. This must be a full path.\n * @param string $dest The directory to create duplicate structure in. If this directory is not empty,\n * you may run into some problems, because of file/directory conflicts.\n * @param array $exclude_dirs An array of directory names to exclude. These names are\n * path-independent. Specifying \"dir\" will ignore all directories and\n * sub-directories named \"dir\", regardless of their parent.\n *\n * @node Model:expFile\n */\n public static function copyDirectoryStructure($src, $dest, $exclude_dirs = array()) {\n $__oldumask = umask(0);\n if (!is_dir($dest)) {\n $file_path = pathinfo($dest);\n $dest = $file_path['dirname'];\n }\n if (!is_dir($src)) {\n $file_path = pathinfo($src);\n $src = $file_path['dirname'];\n }\n if (!file_exists($dest)) mkdir($dest, fileperms($src));\n $dh = opendir($src);\n while (($file = readdir($dh)) !== false) {\n if (is_dir(\"$src/$file\") && !in_array($file, $exclude_dirs) && substr($file, 0, 1) != \".\" && $file != \"CVS\") {\n if (!file_exists($dest.\"/\".$file)) mkdir($dest.\"/\".$file, fileperms($src.\"/\".$file));\n if (is_dir($dest.\"/\".$file)) {\n self::copyDirectoryStructure($src.\"/\".$file, $dest.\"/\".$file);\n }\n }\n }\n closedir($dh);\n umask($__oldumask);\n }",
" /** exdoc\n * This function takes a database object and dumps\n * all of the records in all of the tables into a string.\n * The contents of the string are suitable for storage\n * in a file or other permanent mechanism, and is in\n * the EQL format naively handled by the current\n * implementation.\n *\n * @param null/array $tables\n * @param null/string $type The type of dump\n * @param null/string/array $opts Record descimiator\n *\n * @return string The content of export file\n * @node Model:expFile\n */\n public static function dumpDatabase($tables = null, $type = null, $opts = null) {\n global $db;",
" //FIXME we need to echo and/or write to file within this method to handle large database dumps\n $dump = EQL_HEADER . \"\\r\\n\";\n if ($type == null || $type == 'export') {\n $dump .= 'VERSION:' . EXPONENT . \"\\r\\n\\r\\n\";\n } else {\n $dump .= 'VERSION:' . EXPONENT . ':' . $type . \"\\r\\n\\r\\n\";\n }",
" if (is_string($tables)) $tables = array($tables);\n if (!is_array($tables)) { // dump all the tables\n $tables = $db->getTables();\n if (!function_exists('tmp_removePrefix')) {\n function tmp_removePrefix($tbl) {\n return substr($tbl, strlen(DB_TABLE_PREFIX) + 1);\n // we add 1, because DB_TABLE_PREFIX no longer has the trailing\n // '_' character - that is automatically added by the database class.\n }\n }\n $tables = array_map('tmp_removePrefix', $tables);\n }\n uasort($tables, 'strnatcmp');\n foreach ($tables as $key=>$table) {\n $where = '1';\n if ($type == 'Form') {\n if ($table == 'forms') {\n $where = 'id=' . $opts;\n } elseif ($table == 'forms_control') {\n $where = 'forms_id=' . $opts;\n }\n } elseif ($type == 'export') {\n if (is_string($opts))\n $where = $opts;\n elseif (is_array($opts) && !empty($opts[$key]))\n $where = $opts[$key];\n }\n $tmp = $db->countObjects($table,$where);\n if ($type != 'export' || $db->countObjects($table, $where)) {\n $tabledef = $db->getDataDefinition($table);\n $dump .= 'TABLE:' . $table . \"\\r\\n\";\n $dump .= 'TABLEDEF:' . str_replace(array(\"\\r\", \"\\n\"), array('\\r', '\\n'), serialize($tabledef)) . \"\\r\\n\";\n foreach ($db->selectObjects($table, $where) as $obj) {\n $dump .= 'RECORD:' . str_replace(array(\"\\r\", \"\\n\"), array('\\r', '\\n'), serialize($obj)) . \"\\r\\n\";\n }\n $dump .= \"\\r\\n\";\n }\n }\n //FIXME $dump may become too large and exhaust memory\n return $dump;\n }",
" /** exdoc\n * This function restores a database (overwriting all data in\n * any existing tables) from an EQL object dump. Returns true if\n * the restore was a success and false if something went horribly wrong\n * (unable to read file, etc.) Even if true is returned, there is a chance\n * that some errors were encountered. Check $errors to be sure everything\n * was fine.\n *\n * @param string $file The filename of the EQL file to restore from\n * @param array $errors A referenced array that stores errors. Whatever\n * variable is passed in this argument will contain all errors encountered\n * during the parse/restore.\n * @param null/string $type The type of eql file to restore\n *\n * @return bool\n * @node Model:expFile\n */\n public static function restoreDatabase($file, &$errors, $type = null) {\n global $db;",
"// $errors = array();",
" if (is_readable($file)) {\n $eql = @fopen($file, \"r\");\n if ($eql) {\n //NOTE changed to fgets($file)\n// $lines = @file($file);\n $line0 = fgets($eql);\n $line1 = fgets($eql);",
" // Sanity check\n// if (count($lines) < 2 || trim($lines[0]) != EQL_HEADER) {\n if ($line1 === false || trim($line0) != EQL_HEADER) {\n $errors[] = gt('Not a valid EQL file');\n return false;\n }",
"// $version = explode(':', trim($lines[1]));\n $version = explode(':', trim($line1));\n $eql_version = $version[1] + 0;\n $current_version = EXPONENT + 0;\n if ((array_key_exists(2, $version) && $type == null) || (array_key_exists(\n 2,\n $version\n ) && $version[2] != $type)\n ) {\n $eql_version = 0; // trying to import wrong eql type\n }",
"// $clear_function = '';\n $fprefix = '';\n // Check version and include necessary converters\n if ($eql_version != $current_version) {\n $errors[] = gt('EQL file was Not a valid EQL version');\n return false;\n //\t\t\t$fprefix = 'expFile::'.implode('',explode('.',$eql_version)).'_';\n //\t\t\tif (function_exists($fprefix.'clearedTable')) {\n //\t\t\t\t$clear_function = $fprefix.'clearedTable';\n //\t\t\t}\n }",
" // make sure the database tables are up to date\n expDatabase::install_dbtables();",
" $table = '';\n $oldformdata = array();\n $itsoldformdata = false;\n $newformdata = array();\n $itsnewformdata = false;\n// for ($i = 2; $i < count($lines); $i++) {\n $line_number = 2;\n while (($line = fgets($eql)) !== false) {\n $table_function = '';\n// $line_number = $i;\n $line_number++;\n// $line = trim($lines[$i]);\n $line = trim($line);\n if ($line != '') {\n $pair = explode(':', $line);\n $pair[1] = implode(':', array_slice($pair, 1));\n $pair = array_slice($pair, 0, 2);",
" if ($pair[0] == 'TABLE') {\n $itsoldformdata = false; // we are on a new table set\n $itsnewformdata = false;\n $table = $pair[1];\n if ($fprefix != '') {\n $table_function = $fprefix . $table;\n }\n if ($db->tableExists($table)) {\n if ($type == null) {\n $db->delete($table); // drop/empty table records\n }\n// if ($clear_function != '') {\n// $clear_function($db, $table);\n// }\n } else {\n if (substr($table, 0, 12) == 'formbuilder_') {\n $formbuildertypes = array(\n 'address',\n 'control',\n 'form',\n 'report'\n );\n $ttype = substr($table, 12);\n if (!in_array($ttype, $formbuildertypes)) {\n $itsoldformdata = true;\n }\n } elseif (substr($table, 0, 6) == 'forms_' && $table != 'forms_control') {\n $itsnewformdata = true;\n }\n //\t\t\t\t\t\tif (!file_exists(BASE.'framework/core/definitions/'.$table.'.php')) {\n $errors[] = sprintf(\n gt('Table \"%s\" not found in the database (line %d)'),\n $table,\n $line_number\n );\n //\t\t\t\t\t\t} else if (!is_readable(BASE.'framework/core/definitions/'.$table.'.php')) {\n //\t\t\t\t\t\t\t$errors[] = sprintf(gt('Data definition file for %s (%s) is not readable (line %d)'),$table,'framework/core/definitions/'.$table.'.php',$line_number);\n //\t\t\t\t\t\t} else {\n //\t\t\t\t\t\t\t$dd = include(BASE.'framework/core/definitions/'.$table.'.php');\n //\t\t\t\t\t\t\t$info = (is_readable(BASE.'framework/core/definitions/'.$table.'.info.php') ? include(BASE.'framework/core/definitions/'.$table.'.info.php') : array());\n //\t\t\t\t\t\t\t$db->createTable($table,$dd,$info);\n //\t\t\t\t\t\t}\n }\n } else {\n if ($pair[0] == 'TABLEDEF') { // new in v2.1.4, re-create a missing table\n $pair[1] = str_replace(array('\\r', '\\n'), array(\"\\r\", \"\\n\"), $pair[1]);\n//\t\t\t\t\t\t$tabledef = expUnserialize($pair[1]);\n $tabledef = @unserialize($pair[1]);\n if (!$db->tableExists($table)) {\n $db->createTable($table, $tabledef, array());\n $errors[] = sprintf(\n gt('* However...we successfully recreated the \"%s\" Table from the EQL file'),\n $table\n );\n } else {\n $db->alterTable($table, $tabledef, array(), true);\n }\n $itsoldformdata = false; // we've recreated the table using the tabledef\n $itsnewformdata = false;\n } else {\n if ($pair[0] == 'RECORD') {\n if ($db->tableExists($table)) {\n // Here we need to check the conversion scripts.\n $pair[1] = str_replace(array('\\r', '\\n'), array(\"\\r\", \"\\n\"), $pair[1]);\n //\t\t\t\t\t\t$object = expUnserialize($pair[1]);\n $object = @unserialize($pair[1]);\n if ($type == 'Form') {\n if ($table == 'forms') {\n $forms_id = $object->id = $db->max(\n $table,\n 'id'\n ) + 1; // create a new record\n $spare = new expRecord();\n $spare->title = $object->title;\n $spare->makeSefUrl();\n $object->sef_url = $spare->sef_url;\n } elseif ($table == 'forms_control') {\n $object->id = null; // create a new record\n $object->forms_id = $forms_id; // assign to new form record\n } elseif (substr($table, 6) == 'forms_') {\n $object->id = null; // create a new record\n }\n }\n if (!$object) {\n $object = unserialize(stripslashes($pair[1]));\n }\n if (function_exists($table_function)) {\n $table_function($db, $object);\n } else {\n if (is_object($object)) {\n $db->insertObject($object, $table);\n } else {\n $errors[] = sprintf(\n gt('Unable to decipher \"%s\" record (line %d)'),\n $pair[0],\n $line_number\n );\n }\n }\n } elseif ($itsoldformdata) {\n $oldformdata[$table][] = $pair[1]; // store for later\n } elseif ($itsnewformdata) {\n $newformdata[$table][] = $pair[1]; // store for later\n }\n } else {\n $errors[] = sprintf(\n gt('Invalid specifier type \"%s\" (line %d)'),\n $pair[0],\n $line_number\n );\n }\n }\n }\n }\n }",
" // check for and process to rebuild old formbuilder module data table\n if (!empty($oldformdata)) {\n foreach ($oldformdata as $tablename => $tabledata) {\n $oldform = $db->selectObject('formbuilder_form', 'table_name=\"' . substr($tablename, 12) . '\"');\n if (!empty($oldform)) {\n // create the old table\n $table = self::updateFormbuilderTable($oldform);",
" // populate the table\n foreach ($tabledata as $record) {\n $record = str_replace('\\r\\n', \"\\r\\n\", $record);\n $object = @unserialize($record);\n if (!$object) {\n $object = unserialize(stripslashes($record));\n }\n if (is_object($object)) {\n $db->insertObject($object, 'formbuilder_' . $table);\n }\n }\n $errors[] = sprintf(\n gt(\n '* However...we successfully recreated the \"formbuilder_%s\" Table from the EQL file'\n ),\n $table\n );\n }\n }\n }",
" // check for and process to rebuild new forms module data table\n if (!empty($newformdata)) {\n foreach ($newformdata as $tablename => $tabledata) {\n $newform = $db->selectObject('forms', 'table_name=\"' . substr($tablename, 6) . '\"');\n if (!empty($newform)) {\n // create the new table\n $form = new forms($newform->id);\n $table = $form->updateTable();",
" // populate the table\n foreach ($tabledata as $record) {\n $record = str_replace('\\r\\n', \"\\r\\n\", $record);\n $object = @unserialize($record);\n if (!$object) {\n $object = unserialize(stripslashes($record));\n }\n if (is_object($object)) {\n// $db->insertObject($object, 'forms_' . $table);\n $form->insertRecord($object);\n }\n }\n $errors[] = sprintf(\n gt('* However...we successfully recreated the \"forms_%s\" Table from the EQL file'),\n $table\n );\n }\n }\n }",
" // ensure the form data table exists and is current\n// foreach ($db->selectObjects('forms') as $f) {\n// if ($f->is_saved) $f->updateTable();\n// }\n $formmodel = new forms();\n $forms = $formmodel->find('all');\n foreach ($forms as $f) {\n if ($f->is_saved) {\n $f->updateTable();\n }\n }",
" // rename mixed case tables if necessary\n expDatabase::fix_table_names();\n// if ($eql_version != $current_version) {\n// $errors[] = gt('EQL file was Not a valid EQL version');\n// return false;\n// }\n return true;\n } else {\n $errors[] = gt('Unable to read EQL file');\n return false;\n }\n } else {\n $errors[] = gt('Unable to find EQL file');\n return false;\n }\n }",
" /** exdoc\n * This function reads a database EQL object dump file and returns an array of the\n * database tables and records, or false if something went horribly wrong\n * (unable to read file, etc.) Even if an array is returned, there is a chance\n * that some errors were encountered. Check $errors to be sure everything\n * was fine.\n *\n * @param string $file The filename of the EQL file to parse\n * @param array $errors A referenced array that stores errors. Whatever\n * variable is passed in this argument will contain all errors encountered\n * during the parse/restore.\n * @param null/string/array $type The list of tables to return, empty = entire file\n * @return array/bool\n * @node Model:expFile\n */\n public static function parseDatabase($file, &$errors, $type = null) {\n// $errors = array();\n $data = array();",
" if (is_readable($file)) {\n $lines = @file($file); //FIXME we may have to change this for handling large files via fgets()...see dumpDatabase() above",
" // Sanity check\n if (count($lines) < 2 || trim($lines[0]) != EQL_HEADER) {\n $errors[] = gt('Not a valid EQL file');\n return false;\n }",
" $version = explode(':', trim($lines[1]));\n $eql_version = $version[1] + 0;\n $current_version = EXPONENT + 0;\n if ((array_key_exists(2, $version) && $type == null) || (array_key_exists(2, $version) && $version[2] != $type)) {\n $eql_version = 0; // trying to import wrong eql type\n }",
" // Check version and include necessary converters\n if ($eql_version != $current_version) {\n $errors[] = gt('EQL file was Not a valid EQL version');\n return false;\n }",
" $table = '';\n for ($i = 2, $iMax = count($lines); $i < $iMax; $i++) {\n $line_number = $i;\n $line = trim($lines[$i]);\n if ($line != '') {\n $pair = explode(':', $line);\n $pair[1] = implode(':', array_slice($pair, 1));\n $pair = array_slice($pair, 0, 2);",
" if ($pair[0] == 'TABLE') {\n $table = $pair[1];\n $data[$table] = new stdClass();\n $data[$table]->name = $table;\n $data[$table]->records = array();\n } else if ($pair[0] == 'TABLEDEF') { // new in v2.1.4, re-create a missing table\n $pair[1] = str_replace('\\r\\n', \"\\r\\n\", $pair[1]);\n $tabledef = @unserialize($pair[1]);\n $data[$table]->tabledef = $tabledef;\n } else if ($pair[0] == 'RECORD') {\n // Here we need to check the conversion scripts.\n $pair[1] = str_replace('\\r\\n', \"\\r\\n\", $pair[1]);\n//\t\t\t\t\t\t$object = expUnserialize($pair[1]);\n $object = @unserialize($pair[1]);\n if (!$object) $object = unserialize(stripslashes($pair[1]));\n if (is_object($object)) {\n $data[$table]->records[] = object2Array($object); //FIXME should we convert this? object2array?\n } else {\n $errors[] = sprintf(gt('Unable to decipher \"%s\" record (line %d)'), $pair[0], $line_number);\n }\n } else {\n $errors[] = sprintf(gt('Invalid specifier type \"%s\" (line %d)'), $pair[0], $line_number);\n }\n }\n }",
" if (!empty($type)) {\n if (!is_array($type)) $type = array($type);\n foreach ($data as $key=>$tbl) {\n if (!in_array($key, $type)) {\n unset($data[$key]);\n }\n }\n }\n return $data;\n } else {\n $errors[] = gt('Unable to read EQL file');\n return false;\n }\n }",
" public function afterDelete() {\n global $db;",
"\t // get and delete all attachments to this file\n\t $db->delete('content_expFiles','expfiles_id='.$this->id);\n }",
" /**\n * recreates a deprecated formbuilder data table\n * needed to import form data from eql file exported prior to v2.1.4\n * this is just the old formbuilder_form::updateTable method\n *\n * @static\n * @param $object\n * @return mixed\n */\n static function updateFormbuilderTable($object) {\n\t\tglobal $db;",
"\t\tif (!empty($object->is_saved)) {\n\t\t\t$datadef = array(\n\t\t\t\t'id'=>array(\n\t\t\t\t\tDB_FIELD_TYPE=>DB_DEF_ID,\n\t\t\t\t\tDB_PRIMARY=>true,\n\t\t\t\t\tDB_INCREMENT=>true),\n\t\t\t\t'ip'=>array(\n\t\t\t\t\tDB_FIELD_TYPE=>DB_DEF_STRING,\n\t\t\t\t\tDB_FIELD_LEN=>25),\n\t\t\t\t'referrer'=>array(\n\t\t\t\t\tDB_FIELD_TYPE=>DB_DEF_STRING,\n\t\t\t\t\tDB_FIELD_LEN=>1000),\n\t\t\t\t'timestamp'=>array(\n\t\t\t\t\tDB_FIELD_TYPE=>DB_DEF_TIMESTAMP),\n\t\t\t\t'user_id'=>array(\n\t\t\t\t\tDB_FIELD_TYPE=>DB_DEF_ID)\n\t\t\t);",
"\t\t\tif (!isset($object->id)) {\n\t\t\t\t$object->table_name = preg_replace('/[^A-Za-z0-9]/','_',$object->name);\n\t\t\t\t$tablename = 'formbuilder_'.$object->table_name;\n\t\t\t\t$index = '';\n\t\t\t\twhile ($db->tableExists($tablename . $index)) {\n\t\t\t\t\t$index++;\n\t\t\t\t}\n\t\t\t\t$tablename = $tablename.$index;\n\t\t\t\t$db->createTable($tablename,$datadef,array());\n\t\t\t\t$object->table_name .= $index;\n\t\t\t} else {\n\t\t\t\tif ($object->table_name == '') {\n\t\t\t\t\t$tablename = preg_replace('/[^A-Za-z0-9]/','_',$object->name);\n\t\t\t\t\t$index = '';\n\t\t\t\t\twhile ($db->tableExists('formbuilder_' . $tablename . $index)) {\n\t\t\t\t\t\t$index++;\n\t\t\t\t\t}\n\t\t\t\t\t$object->table_name = $tablename . $index;\n\t\t\t\t}",
"\t\t\t\t$tablename = 'formbuilder_'.$object->table_name;",
"\t\t\t\t//If table is missing, create a new one.\n\t\t\t\tif (!$db->tableExists($tablename)) {\n\t\t\t\t\t$db->createTable($tablename,$datadef,array());\n\t\t\t\t}",
"\t\t\t\t$ctl = null;\n\t\t\t\t$control_type = '';\n\t\t\t\t$tempdef = array();\n\t\t\t\tforeach ($db->selectObjects('formbuilder_control','form_id='.$object->id) as $control) {\n\t\t\t\t\tif ($control->is_readonly == 0) {\n\t\t\t\t\t\t$ctl = unserialize($control->data);\n\t\t\t\t\t\t$ctl->identifier = $control->name;\n\t\t\t\t\t\t$ctl->caption = $control->caption;\n\t\t\t\t\t\t$ctl->id = $control->id;\n\t\t\t\t\t\t$control_type = get_class($ctl);\n\t\t\t\t\t\t$def = call_user_func(array($control_type,'getFieldDefinition'));\n\t\t\t\t\t\tif ($def != null) {\n\t\t\t\t\t\t\t$tempdef[$ctl->identifier] = $def;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t$datadef = array_merge($datadef,$tempdef);\n\t\t\t\t$db->alterTable($tablename,$datadef,array(),true);\n\t\t\t}\n\t\t}\n\t\treturn $object->table_name;\n\t}",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\n##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * Class to handle files at the File System Level and updating\n * the record for each file.\n *\n * expFile is an extension of expRecord because File information is stored\n * in the database for future access and retrieval. This class also handles\n * and and all File System handling as well: copy, move, delete, upload,\n * and importing of data in preparation of data importation. Upload and\n * import via child classes.\n *\n * @subpackage Models\n * @package Modules\n *\n */\n/** @define \"BASE\" \"../../..\" */\nclass expFile extends expRecord {",
"// ==========================================================\n// Class Constants",
" /*\n * The definition of this constant lets other parts of the subsystem know\n * that the Image Subsystem has been included for use.\n */\n const SYS_IMAGE = 1;\n const IMAGE_ERR_NOGD = '';\n const IMAGE_ERR_NOTSUPPORTED = '_unknown';\n const IMAGE_ERR_FILENOTFOUND = '_notfound';\n const IMAGE_ERR_PERMISSIONDENIED = '_denied';",
"// ===========================================================\n// File Access Control Values",
" /**\n * Mode to use for reading from files\n *\n * @constant string FILE_MODE_READ\n *\n * @access private\n * @PHPUnit Not Defined\n *\n */\n const FILE_MODE_READ = 'rb';",
" /**\n * Mode to use for truncating files, then writing\n *\n * @constant string FILE_MODE_WRITE\n *\n * @access private\n * @PHPUnit Not Defined\n *\n */\n const FILE_MODE_WRITE = 'wb';",
" /**\n * Mode to use for appending to files\n *\n * @constant string FILE_MODE_APPEND\n *\n * @access private\n * @PHPUnit Not Defined\n *\n */\n const FILE_MODE_APPEND = 'ab';",
" /**\n * Use this when a shared (read) lock is required.\n * This is a \"relabel\" of the PHP 'LOCK_SH' constant\n *\n * @constant string FILE_LOCK_SHARED\n *\n * @access private\n * @PHPUnit Not Defined\n *\n */\n const FILE_LOCK_SHARED = LOCK_SH;",
" /**\n * Use this when an exclusive (write) lock is required\n * This is a \"relabel\" of the PHP 'LOCK_EX' constant\n *\n * @constant string FILE_LOCK_EXCLUSIVE\n *\n * @access private\n * @PHPUnit Not Defined\n *\n */\n const FILE_LOCK_EXCLUSIVE = LOCK_EX;",
" // ==========================================================\n // Class Properties and their default values",
" /**\n * Database Table Name to store File info\n *\n * @public\n * @property string $table Database Table Name\n *\n */\n public $table = 'expFiles';\n protected $attachable_table = 'content_expFiles';",
" protected $attachable_item_types = array(\n 'content_expCats' => 'expCat',\n// 'content_expComments'=>'expComment',\n// 'content_expDefinableFields' => 'expDefinableField',\n// 'content_expFiles' => 'expFile',\n// 'content_expRatings'=>'expRating',\n// 'content_expSimpleNote'=>'expSimpleNote',\n// 'content_expTags'=>'expTag',\n );",
" /**\n * Relative OS System File path to where $filename is [to be] located\n *\n * @protected\n * @property string $directory Relative OS System File path\n *\n */\n public $directory = null;",
" /**\n * File Name of File to process\n *\n * @public\n * @property string $filename Name of File to process\n *\n */\n public $filename = null;",
" /**\n * Size of File, in Bytes\n *\n * @protected\n * @property string $filesize Size of File, in Bytes.\n *\n */\n public $filesize = null;",
" /**\n * Mime Type of File.\n *\n * @public\n * @property string $mimetype File MIME Type\n *\n */\n public $mimetype = null;",
" /**\n * Image width in pixels.\n *\n * @public\n * @property string $image_width Image width in pixels\n *\n */\n public $image_width = null;",
" /**\n * Image height in pixels.\n *\n * @public\n * @property string $image_height Image height in pixels\n *\n */\n public $image_height = null;",
" /**\n * Is this file an image.\n # Defaults to FALSE\n *\n * @public\n * @property string $is_image Is this file an image\n *\n */\n public $is_image = false;",
" /**\n * Determines if this file can be overwritten.\n * Also if it can be \"moved\" or \"renamed\" over\n * Default set to FALSE, no it can't\n *\n * @protected boolean\n * @property boolean $fileOverWrite Determines if this file be overwritten\n *\n * @access protected\n * @since 1.1\n */\n protected $fileOverWrite = false;",
" /**\n * Web based Path for current File\n *\n * @public\n * @property string $url Web based Path\n *\n */\n public $url = null;",
" /**\n * Full File System Path for current File. Also used to in FILE Record\n *\n * @public\n * @property string $path Full File System Path\n *\n */\n public $path = null;",
" /**\n * Relative File System Path for current File\n *\n * @public\n * @property string $path_relative Relative File System Path\n *\n */\n public $path_relative = null;",
"// ==========================================================\n// Class Methods",
" /**\n * Class constructor to create a File Class either from a database\n * record or from the File System.\n *\n * Class will either: a) load an existing File Record\n * b) modify an existing File Record\n * c) create a new File Record\n *\n * This will also handle any File System handling that is needed: copy,\n * move, create, delete, read and write.\n *\n * @access public\n *\n * @uses expRecord::__construct\n *\n * @PHPUnit Not Defined\n *\n * @param mixed $params - If an INT is given, this assumes that it needs to\n * load an existing File Record.\n * - If an ARRAY is given, this assumes that the elements\n * of the array are values to the File table that need\n * to be modified or other processing.\n * - If NULL is given, an empty File Object is created\n *\n * @param bool $get_assoc\n * @param bool $get_attached\n *\n * @return \\expFile Object@throws void\n *\n */\n public function __construct($params = array(), $get_assoc = false, $get_attached = true) {\n // Set 'directory' as the default FILE location\n // This will be redefined if a FILE record is loaded\n // or a path is given to the Class\n //eDebug($params,true);\n if (empty($params['directory']))\n $this->directory = UPLOAD_DIRECTORY_RELATIVE;\n // This will pull properties for class properties based upon\n // expRecord table definition\n parent::__construct($params, $get_assoc, $get_attached);",
" // If the 'directory' is the same as the default path then a given,\n // or derived, filename can be added to pathing settings\n //if ( $this->directory == UPLOAD_DIRECTORY_RELATIVE ) {\n if (!stristr($this->directory, BASE)) {\n // Place system level web root\n $this->url = URL_FULL . $this->directory . $this->filename;",
" // Place system level OS root\n $this->path = BASE . $this->directory . $this->filename;",
" // Place system OS relative path\n $this->path_relative = PATH_RELATIVE . $this->directory . $this->filename;\n } else {\n // Otherwise, the URL is not set since we can't use it, nether is\n // RELATIVE, as 'directory' must be an absolute path in this instance\n // Place system level OS root\n $relpath = str_replace(BASE, '', $this->directory);\n $this->path = $this->directory . $this->filename;\n $this->url = URL_FULL . $relpath . $this->filename;\n $this->path_relative = $relpath . $this->filename;\n }",
" // If a file location was given, not derived from the database,\n // basic file information is needed\n if (empty($this->id) && !empty($this->filename)) {\n // File info\n $_fileInfo = self::getImageInfo($this->path);\n // Assign info back to class\n $this->is_image = !empty($_fileInfo['is_image']) ? $_fileInfo['is_image'] : false;\n $this->filesize = !empty($_fileInfo['fileSize']) ? $_fileInfo['fileSize'] : 0;\n if (!empty($_fileInfo['mime'])) $this->mimetype = $_fileInfo['mime'];\n if (!empty($_fileInfo['is_image'])) {\n $this->image_width = $_fileInfo[0];\n $this->image_height = $_fileInfo[1];\n }\n }\n }",
" public function exists() {\n return (!empty($this->id) && is_file(BASE . PATH_RELATIVE . $this->directory . $this->filename));\n }\n// =========================================================================\n// Static Methods",
" public static function selectAllFiles() {\n global $db;",
" return $db->selectObjects('expFiles',1);\n }",
" /**\n * File ($_POST) UPLOAD that also optionally inserts File info into database.\n *\n * File UPLOAD is a straight forward uploader and processor. It can accept\n * filename and destination directory overrides as well. It has an additional\n * pair of flags that allow for an upload NOT to be inserted into the database\n * (default to INSERT) and if it previous file, with the same name, should be\n * overwritten (default to NO overwrite)\n *\n * @static\n * @access public\n *\n * @uses class|method|global|variable description\n * @requires class_name\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param string $_postName The name of the _FILE upload array\n * @param bool|string $_force Force the uploaded to overwrite existing file of same name\n * @param bool|string $_save Save file info to database, defaults to TRUE\n * @param string $_destFile Override the uploaded file name\n * @param string $_destDir Override the default FILE UPLOAD location\n *\n * @param null $_max_width\n *\n * @return object $_objFile expFile Object\n * @return object $errMsg Error message if something failed@throws void\n *\n * @TODO Have file upload overwrite make sure not to duplicate its record in the DB\n */\n public static function fileUpload($_postName = null,\n $_force = false,\n $_save = true,\n $_destFile = null,\n $_destDir = null,\n $_max_width = null\n ) {",
" // Make sure something was sent first off...\n if ((!isset($_SERVER['CONTENT_TYPE'])) ||\n (strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== 0)\n ) {\n return 'bad upload form';\n }",
" //check for errors\n switch ($_FILES[$_postName]['error']) {\n case UPLOAD_ERR_OK:\n // Everything looks good. Continue with the update.\n break;\n case UPLOAD_ERR_INI_SIZE:\n//\t\t\tcase images:\n // This is a tricky one to catch. If the file is too large for\n // POST, then the script won't even run.\n // But if its between post_max_size and upload_max_filesize,\n // we will get here.\n return 'file_too_large';\n case UPLOAD_ERR_FORM_SIZE:\n return 'file_exceeds_form_MAX_FILE_SIZE';\n case UPLOAD_ERR_PARTIAL:\n return 'partial_file';\n case UPLOAD_ERR_NO_FILE:\n return 'no_file_uploaded';\n case UPLOAD_ERR_NO_TMP_DIR:\n return 'missing_tmp_folder';\n case UPLOAD_ERR_CANT_WRITE:\n return 'failed_write_to_disk';\n case UPLOAD_ERR_EXTENSION:\n return 'upload_stopped_by_extension';\n default:\n return 'unknown';\n break;\n }",
" // If $_destDir is not defined, use the default Files directory\n// $_destDir = ( $_destDir == null ) ? UPLOAD_DIRECTORY : $_destDir;\n $_destDir = ($_destDir == null) ? UPLOAD_DIRECTORY_RELATIVE : $_destDir;",
" // If $_destFile is defined, use that name as an override for the\n // uploaded file name\n $_destFile = ($_destFile == null) ? self::fixName($_FILES[$_postName]['name']) : $_destFile;",
" // Fix the filename, so that we don't have funky characters screwing\n // with our attempt to create the destination file.\n // $_destFile = self::fixFileName( $_FILES[$_postName]['name']);\n // eDebug($_destFile,1);",
" // Build destination fille path for future use\n $_destFullPath = BASE . $_destDir . $_destFile;",
" //if the file exists and we don't want to overwrite it, create a new one\n if (file_exists($_destFullPath) && $_force == false) {\n $_destFile = self::resolveDuplicateFilename($_destFullPath);\n $_destFullPath = BASE . $_destDir . $_destFile;\n }",
" //Check to see if the directory exists. If not, create the directory structure.\n // if (!file_exists(BASE . $_destDir)) {\n // self::makeDirectory(BASE . $_destDir);",
" // }",
"\n // Move the temporary uploaded file into the destination directory,\n // and change the name.\n $resized = false;\n $maxwidth = intval($_max_width);\n if (!empty($maxwidth)) {\n $tempFile = tempnam(sys_get_temp_dir(), 'exp_upload_') . '_' . $_destFile;\n move_uploaded_file($_FILES[$_postName]['tmp_name'], $tempFile);\n require_once(BASE . 'framework/modules/pixidou/includes/class.upload/class.upload.php');\n $handle = new upload($tempFile);\n if ($handle->uploaded) {\n $handle->file_new_name_body = $_destFile;\n $handle->file_new_name_ext = '';\n $handle->image_resize = true;\n $handle->image_x = $maxwidth;\n $handle->image_y = $maxwidth;\n $handle->image_ratio_no_zoom_in = true;\n $handle->jpeg_quality = THUMB_QUALITY;\n $handle->process(BASE . $_destDir);\n if ($handle->processed) {\n if ($handle->image_src_x != $handle->image_dst_x) $resized = true;\n $handle->clean();\n }\n }\n } else {\n $tmp = move_uploaded_file($_FILES[$_postName]['tmp_name'], $_destFullPath);\n }",
" if (file_exists($_destFullPath)) {\n $__oldumask = umask(0);\n chmod($_destFullPath, octdec(FILE_DEFAULT_MODE_STR + 0));\n umask($__oldumask);\n // Checking\n if ($__oldumask != umask()) {\n flash('error', gt('An error occurred while setting file permissions') . ': ' . $_destFullPath);\n }\n } else {\n return 'could not move';\n }",
" // At this point, we are good to go.",
" // Create a new expFile Object for further processing\n $_fileParams = array('filename' => $_destFile, 'directory' => $_destDir);\n $_objFile = new expFile ($_fileParams);",
" // Insert new File Record\n if ($_save === true) {\n $_objFile->save();\n }\n if ($resized) $_objFile->resized = true;\n return $_objFile;\n }",
" /**\n * XHR (HTML5) File UPLOAD that also inserts File info into database.\n *\n * File UPLOAD is a straight forward uploader and processor. It can accept\n * filename and destination directory overrides as well. It has an additional\n * pair of flags that allow for an upload NOT to be inserted into the database\n * (default to INSERT) and if it previous file, with the same name, should be\n * overwritten (default to NO overwrite)\n *\n * @static\n * @access public\n *\n * @uses class|method|global|variable description\n * @requires class_name\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param null $fileName\n * @param bool|string $_force Force the uploaded to overwrite existing file of same name\n * @param bool|string $_save Save file info to database, defaults to TRUE\n * @param string $_destFile Override the uploaded file name\n * @param string $_destDir Override the default FILE UPLOAD location\n *\n * @param null $_max_width\n *\n * @return object $_objFile expFile Object\n * @return object $errMsg Error message if something failed@throws void\n *\n * @TODO Have file upload overwrite make sure not to duplicate its record in the DB\n */\n public static function fileXHRUpload($fileName = null,\n $_force = false,\n $_save = true,\n $_destFile = null,\n $_destDir = null,\n $_max_width = null\n ) {",
" // If $_destDir is not defined, use the default Files directory\n $_destDir = ($_destDir == null) ? UPLOAD_DIRECTORY_RELATIVE : $_destDir;",
" // If $_destFile is defined, use that name as an override for the\n // uploaded file name\n $_destFile = ($_destFile == null) ? self::fixName($fileName) : $_destFile;",
" // Fix the filename, so that we don't have funky characters screwing\n // with our attempt to create the destination file.\n // $_destFile = self::fixFileName( $_FILES[$_postName]['name']);\n // eDebug($_destFile,1);",
" // Build destination fille path for future use\n $_destFullPath = BASE . $_destDir . $_destFile;",
" //if the file exists and we don't want to overwrite it, create a new one\n if (file_exists($_destFullPath) && $_force == false) {\n $_destFile = self::resolveDuplicateFilename($_destFullPath);\n $_destFullPath = BASE . $_destDir . $_destFile;\n }",
" //Check to see if the directory exists. If not, create the directory structure.\n // if (!file_exists(BASE . $_destDir)) {\n // self::makeDirectory(BASE . $_destDir);\n // }",
" // Move the temporary uploaded file into the destination directory,\n // and change the name.\n $resized = false;\n $maxwidth = intval($_max_width);\n if (!empty($maxwidth)) {\n $tempFile = tempnam(sys_get_temp_dir(), 'exp_upload_') . '_' . $_destFile;\n// move_uploaded_file($_FILES[$fileName]['tmp_name'], $tempFile);\n file_put_contents($tempFile, file_get_contents('php://input'));\n require_once(BASE . 'framework/modules/pixidou/includes/class.upload/class.upload.php');\n $handle = new upload($tempFile);\n if ($handle->uploaded) {\n $handle->file_new_name_body = $_destFile;\n $handle->file_new_name_ext = '';\n $handle->image_resize = true;\n $handle->image_x = $maxwidth;\n $handle->image_y = $maxwidth;\n $handle->image_ratio_no_zoom_in = true;\n $handle->jpeg_quality = THUMB_QUALITY;\n $handle->process(BASE . $_destDir);\n if ($handle->processed) {\n if ($handle->image_src_x != $handle->image_dst_x) $resized = true;\n $handle->clean();\n }\n }\n } else {\n file_put_contents($_destFullPath, file_get_contents('php://input', 'r'));\n }",
" if (file_exists($_destFullPath)) {\n $__oldumask = umask(0);\n chmod($_destFullPath, octdec(FILE_DEFAULT_MODE_STR + 0));\n umask($__oldumask);\n // Checking\n if ($__oldumask != umask()) {\n flash('error', gt('An error occurred while setting file permissions') . ': ' . $_destFullPath);\n }\n } else {\n return 'could not move';\n }",
" // At this point, we are good to go.",
" // Create a new expFile Object for further processing\n $_fileParams = array('filename' => $_destFile, 'directory' => $_destDir);\n $_objFile = new expFile ($_fileParams);",
" // Insert new File Record\n if ($_save === true) {\n $_objFile->save();\n }\n if ($resized) $_objFile->resized = true;\n return $_objFile;\n }",
" /**\n * Performs a system level check on the file and retrieves its size\n *\n * @static\n * @access public\n *\n * @uses function filesize() Built-in PHP method\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param bool|string $_path Full path to file to pull info from\n *\n * @return int $_fileSize Size of file in bytes\n * @throws void\n *\n */\n public static function fileSize($_path = false) {\n if ($_path)\n $_fileSize = filesize($_path);\n else\n $_fileSize = 0;",
" return $_fileSize;\n }",
" /**\n * check for duplicate files and returns a file name that's not already in the system\n *\n * @static\n * @access public\n *\n * @uses function filesize() Built-in PHP method\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param string $filepath direct path of the file to check against\n *\n * @return int $newFileName Name of the file that isn't a duplicate\n * @throws void\n *\n */\n public static function resolveDuplicateFilename($filepath) {\n $extension = strrchr($filepath, \".\"); // grab the file extention by looking for the last dot in the string\n $filnameWoExt = str_replace($extension, \"\", str_replace(\"/\", \"\", strrchr($filepath, \"/\"))); // filename sans extention\n $pathToFile = str_replace($filnameWoExt . $extension, \"\", $filepath); // path sans filename",
" $i = \"\";\n $inc = \"\";\n while (file_exists($pathToFile . $filnameWoExt . $inc . $extension)) {\n $i++;\n $inc = \"-\" . $i;\n }",
" //we'll just return the new filename assuming we've\n //already got the path we want on the other side\n return $filnameWoExt . $inc . $extension;\n }",
" /**\n * prompts the user to download a file\n *\n * @static\n * @access public\n *\n * @uses function download() Built-in PHP method\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param string $file Full path to file to download\n *\n * @return void\n * @throws void\n *\n */\n public static function download($file) {\n // we are expecting an int val as a file ID or the whole file object.\n // If all we get is the ID then we'll instantiate a new file object.\n // If that object doesn't have it's id property set or the file doesn't\n // actually exist then we can assume its not a valid file object and\n // return false.\n if (!is_object($file)) $file = new expFile($file);\n //if (empty($file->id) || !file_exists($file->path)) return false;\n if (!file_exists($file->path)) {\n flash('error', gt('The file is unavailable for Download'));\n expHistory::back();\n return false;\n }",
" // NO buffering from here on out or things break unexpectedly. - RAM\n ob_end_clean();",
" // This code was lifted from phpMyAdmin, but this is Open Source, right?\n // 'application/octet-stream' is the registered IANA type but\n // MSIE and Opera seems to prefer 'application/octetstream'\n // It seems that other headers I've added make IE prefer octet-stream again. - RAM",
" $mimetype = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octet-stream;' : $file->mimetype;",
" header('Content-Type: ' . $mimetype);\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n header('Content-Transfer-Encoding: binary');\n//\t\theader('Content-Encoding:');\n header('Content-Disposition: attachment; filename=\"' . $file->filename . '\";');\n $filesize = filesize($file->path);\n if ($filesize) header(\"Content-length: \" . $filesize); // for some reason the webserver cant run stat on the files and this breaks.\n // IE need specific headers\n if (EXPONENT_USER_BROWSER == 'IE') {\n header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n header('Pragma: public');\n header('Vary: User-Agent');\n } else {\n header('Pragma: no-cache');\n }",
" //Read the file out directly\n readfile($file->path);\n exit();\n }",
" /**\n * Replace anything but alphanumeric characters with an UNDERSCORE\n *\n * @static\n * @access public\n *\n * @uses function preg_replace built-in PHP Function\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param string $name File name to 'fix'\n *\n * @return string $name the correct filename\n * @throws void\n *\n */\n public static function fixName($name) {\n $name = preg_replace('/[^A-Za-z0-9\\.]/','_',$name);",
" if ($name[0] == '.') // attempt to upload a dot file",
" $name[0] = '_';",
" $name = str_replace('_', '..', $name); // attempt to upload with redirection to new folder",
" return $name;\n// return preg_replace('/[^A-Za-z0-9\\.]/', '-', $name);\n }",
" /**\n * Return the mimetype for the passed filename\n *\n * @param string $filename\n * @return string\n */\n public static function getMimeType($filename) {\n /* Store an array of commom mimetypes */\n $types = array(\n 'txt' => 'text/plain',\n 'htm' => 'text/html',\n 'html' => 'text/html',\n 'php' => 'text/html',\n 'css' => 'text/css',\n 'js' => 'application/javascript',\n 'json' => 'application/json',\n 'xml' => 'application/xml',",
" // images\n 'png' => 'image/png',\n 'jpe' => 'image/jpeg',\n 'jpeg' => 'image/jpeg',\n 'jpg' => 'image/jpeg',\n 'gif' => 'image/gif',\n 'bmp' => 'image/bmp',\n 'ico' => 'image/vnd.microsoft.icon',\n 'tiff' => 'image/tiff',\n 'tif' => 'image/tiff',\n 'svg' => 'image/svg+xml',\n 'svgz' => 'image/svg+xml',",
" // archives\n 'gz' => 'application/x-gzip',\n 'zip' => 'application/zip',\n 'rar' => 'application/x-rar-compressed',\n 'exe' => 'application/x-msdownload',\n 'msi' => 'application/x-msdownload',\n 'cab' => 'application/vnd.ms-cab-compressed',",
" // audio/video\n 'mp3' => 'audio/mpeg',\n 'ogg' => 'audio/ogg',\n 'qt' => 'video/quicktime',\n 'mov' => 'video/quicktime',\n 'f4v' => 'video/mp4',\n 'mp4' => 'video/mp4',\n 'm4v' => 'video/x-m4v',\n 'ogv' => 'video/ogg',\n '3gp' => 'video/3gpp',\n 'webm' => 'video/webm',\n 'flv' => 'video/x-flv',\n 'swf' => 'application/x-shockwave-flash',",
" // adobe\n 'pdf' => 'application/pdf',\n// 'psd' => 'image/vnd.adobe.photoshop',\n// 'ai' => 'application/postscript',\n// 'eps' => 'application/postscript',\n// 'ps' => 'application/postscript',",
" // ms office\n// 'doc' => 'application/msword',\n// 'rtf' => 'application/rtf',\n// 'xls' => 'application/vnd.ms-excel',\n// 'ppt' => 'application/vnd.ms-powerpoint',",
" // open office\n// 'odt' => 'application/vnd.oasis.opendocument.text',\n// 'ods' => 'application/vnd.oasis.opendocument.spreadsheet'\n );",
" /* Get the file extension,\n * FYI: this is *really* hax.\n */\n $fileparts = explode('.',$filename);\n $extension = strtolower(array_pop($fileparts));\n if(array_key_exists($extension, $types)) {\n /* If we can *guess* the mimetype based on the filename, do that for standardization */\n return $types[$extension];\n } elseif(function_exists('finfo_open')) {\n /* If we don't have to guess, do it the right way */\n $finfo = finfo_open(FILEINFO_MIME);\n $mimetype = finfo_file($finfo, $filename);\n finfo_close($finfo);\n return $mimetype;\n } else {\n /* Otherwise, let the browser guess */\n return 'application/octet-stream';\n }\n }",
"// ==========================================================\n// Class Image Processing Methods\n// @TODO This collection of methods need to be placed in their own Class",
" /**\n * Return size and mimetype information about an image file,\n * given its path/filename. This is a wrapper around the\n * built-in PHP 'getimagesize' function, to make all implementations\n * work identically.\n *\n * @static\n * @access public\n *\n * @uses function getimagesize() Built-in PHP function\n *\n * @PHPUnit Not Defined|Implement|Completed\n *\n * @param bool|string $_path Full path to file to pull info from\n *\n * @return array $_sizeinfo An array of Image File info\n * @return array $error message Error message@throws void\n *\n */\n public static function getImageInfo($_path = false) {",
" $_path = __realpath($_path);",
" if (!file_exists($_path)) return self::IMAGE_ERR_FILENOTFOUND;\n if (!is_readable($_path)) return self::IMAGE_ERR_PERMISSIONDENIED;",
" if ($_sizeinfo = @getimagesize($_path)) {\n $_sizeinfo['is_image'] = true;\n// if (!isset($_sizeinfo['mime'])) {\n// // In case this implementation of getimagesize doesn't discover\n// // the mime type\n// $_types = array(\n// 'jpg' => 'image/jpeg',\n// 'jpeg' => 'image/jpeg',\n// 'gif' => 'image/gif',\n// 'png' => 'image/png'\n// );\n//\n// $_fileData = pathinfo($_path);\n// if (array_key_exists($_fileData['extension'], $_types)) $_sizeinfo['mime'] = $_types[$_fileData['extension']];\n// }\n } else {\n $_sizeinfo['is_image'] = false;\n// if (!isset($_sizeinfo['mime'])) {\n// // In case this implementation of getimagesize doesn't discover\n// // the mime type\n// $_types = array(\n// 'mp3' => 'audio/mpeg',\n// 'ogg' => 'audio/ogg',\n// 'flv' => 'video/x-flv',\n// 'f4v' => 'video/mp4',\n// 'mp4' => 'video/mp4',\n// 'ogv' => 'video/ogg',\n// '3gp' => 'video/3gpp',\n// 'webm' => 'video/webm',\n// 'pdf' => 'application/pdf',\n// );\n//\n// $_fileData = pathinfo($_path);\n// if (array_key_exists($_fileData['extension'], $_types)) $_sizeinfo['mime'] = $_types[$_fileData['extension']];\n// }\n }\n $_sizeinfo['mime'] = self::getMimeType($_path);\n $_sizeinfo['fileSize'] = self::fileSize($_path);",
" return $_sizeinfo;\n }",
" /** exdoc\n * Create an image resource handle (from GD) for a given filename.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * At this point, the user should have called self::getImageInfo on the filename\n * and verified that the file does indeed exist, and is readable. A safeguard check\n * is in place, however.\n *\n * @param string $filename The path/filename of the image.\n *\n * @return null|resource|string\n * @node Model:expFile\n */\n public static function openImageFile($filename) {\n if (!EXPONENT_HAS_GD) return null;",
" $sizeinfo = @getimagesize($filename);\n $info = gd_info();",
" if ($sizeinfo['mime'] == 'image/jpeg' && $info['JPG Support'] == true) {\n $img = imagecreatefromjpeg($filename);\n } else if ($sizeinfo['mime'] == 'image/png' && $info['PNG Support'] == true) {\n $img = imagecreatefrompng($filename);\n } else if ($sizeinfo['mime'] == 'image/gif' && $info['GIF Read Support'] == true) {\n $img = imagecreatefromgif($filename);\n } else {\n // Either we have an unknown image type, or an unsupported image type.\n return self::IMAGE_ERR_NOTSUPPORTED;\n }",
" if (function_exists('imagesavealpha')) {\n imagealphablending($img, false);\n imagesavealpha($img, true);\n }\n return $img;\n }",
" /** exdoc\n * Create a new blank image resource, with the specified width and height.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param integer $w Width of the image resource to create (in pixels)\n * @param integer $h Height of the image resource to create (in pixels)\n *\n * @return null|resource\n * @node Model:expFile\n */\n public static function imageCreate($w, $h) {\n if (!EXPONENT_HAS_GD) {\n return null;\n }\n $info = gd_info();\n if (strpos($info['GD Version'], '2.0') !== false) {\n $img = imagecreatetruecolor($w, $h);",
" if (function_exists('imagesavealpha')) {\n imagealphablending($img, false);\n imagesavealpha($img, true);\n }",
" return $img;\n } else {\n return imagecreate($w, $h);\n }\n }",
" function copyToDirectory($destination) {\n //eDebug($this,true);\n copy($this->path, $destination . $this->filename);\n }",
" public static function imageCopyresized($dest, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {\n if (!EXPONENT_HAS_GD) {\n return null;\n }\n $info = gd_info();\n if (strpos($info['GD Version'], '2.0') !== false) {\n return imagecopyresampled($dest, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n } else {\n return imagecopyresized($dest, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);\n }\n }",
" /** exdoc\n * Proportionally scale an image by a specific percentage\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param float $scale The scaling factor, as a decimal (i.e. 0.5 for 50%)\n *\n * @return array|null|resource|string\n * @node Model:expFile\n */\n public static function imageScaleByPercent($filename, $scale) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" if ($scale == 1) {\n return $original;\n }",
" $w = $scale * $sizeinfo[0];\n $h = $scale * $sizeinfo[1];",
" $thumb = self::imageCreate($w, $h);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, 0, 0, $w, $h, $sizeinfo[0], $sizeinfo[1]);",
" return $thumb;\n }",
" /** exdoc\n * Proportionally scale an image to a given width. Height adjusts accordingly.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param integer $width The desired width of the scaled image, in pixels.\n *\n * @return array|null|resource|string\n * @node Model:expFile\n */\n public static function imageScaleToWidth($filename, $width) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }\n $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $sizeinfo;\n }",
" if ($width == $sizeinfo[0]) {\n return $original;\n }",
" $w = $width;\n $h = ($width / $sizeinfo[0]) * $sizeinfo[1];",
" $thumb = self::imageCreate($w, $h);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, 0, 0, $w, $h, $sizeinfo[0], $sizeinfo[1]);",
" return $thumb;\n }",
" /** exdoc\n * Proportionally scale an image to a given height. Width adjusts accordingly.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param integer $height The desired height of the scaled image, in pixels.\n *\n * @return array|null|resource|string\n * @node Model:expFile\n */\n public static function imageScaleToHeight($filename, $height) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" if ($height == $sizeinfo[1]) {\n return $original;\n }",
" $w = ($height / $sizeinfo[1]) * $sizeinfo[0];\n $h = $height;",
" $thumb = self::imageCreate($w, $h);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, 0, 0, $w, $h, $sizeinfo[0], $sizeinfo[1]);",
" return $thumb;\n }",
" /** exdoc\n * Proportionally scale an image to fit within the given width / height.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param integer $width The maximum width of the scaled image, in pixels.\n * @param integer $height The maximum height of the scaled image, in pixels.\n *\n * @return array|null|resource|string\n * @node Model:expFile\n */\n public static function imageScaleToConstraint($filename, $width, $height) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" if ($width >= $sizeinfo[0] && $height >= $sizeinfo[1]) {\n return $original;\n }",
" $w = $width;\n $h = ($width / $sizeinfo[0]) * $sizeinfo[1];",
" if ($h > $height) { // height is outside\n $w = ($height / $sizeinfo[1]) * $sizeinfo[0];\n $h = $height;\n }",
" $thumb = self::imageCreate($w, $h);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, 0, 0, $w, $h, $sizeinfo[0], $sizeinfo[1]);",
" return $thumb;\n }",
" /** exdoc\n * Scale an image to a square keeping the image aspect ratio.\n * If the image is smaller in either dimension than request square side original is returned.\n * Image is first cropped to a square of length smaller of width or height and then resized.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param $side\n *\n * @return array|null|resource|string\n * @internal param int $size The desired side length of the scaled image, in pixels.\n * @node Model:expFile\n */\n public static function imageScaleToSquare($filename, $side) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" if ($side >= $sizeinfo[0] || $side >= $sizeinfo[1]) {\n return $original;\n }",
" /* The defaults will serve in case the image is a square */\n $src_x = 0;\n $src_y = 0;\n $width = $sizeinfo[0];\n $height = $sizeinfo[1];",
" /*if width greater than height, we crop the image left and right */\n if ($sizeinfo[0] > $sizeinfo[1]) {\n $width = $sizeinfo[1];\n $height = $sizeinfo[1];\n $src_x = round(($sizeinfo[0] - $width) / 2, 0);\n } else {\n /*if height greater than width, we crop the image top and bottom */\n $height = $sizeinfo[0];\n $width = $sizeinfo[0];\n $src_y = round(($sizeinfo[1] - $height) / 2, 0);\n }",
" $w = $side;\n $h = $side;",
" $thumb = self::imageCreate($w, $h);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, $src_x, $src_y, $w, $h, $width, $height);",
" return $thumb;\n }",
" /** exdoc\n * Scale an image to a given width and height, without regard to aspect ratio.\n * This is a wrapper around various GD functions, to provide Exponent\n * programmers a single point of entry. It also handles situations where\n * there is no GD support compiled into the server. (In this case, null is returned).\n *\n * @param string $filename The path/filename of the image to scale.\n * @param integer $width The desired width of the scaled image, in pixels.\n * @param integer $height The desired height of the scaled image, in pixels.\n *\n * @return array|null|resource|string\n * @node Model:expFile\n */\n public static function imageScaleManually($filename, $width, $height) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" if ($width == $sizeinfo[0] && $height == $sizeinfo[1]) {\n return $original;\n }",
" $thumb = self::imageCreate($width, $height);\n if (!$thumb) return null;\n self::imageCopyresized($thumb, $original, 0, 0, 0, 0, $width, $height, $sizeinfo[0], $sizeinfo[1]);",
" return $thumb;\n }",
" public static function imageRotate($filename, $degrees) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" $color = imagecolorclosesthwb($original, 255, 255, 255);",
" return imagerotate($original, $degrees, $color);\n }",
" public static function imageFlip($filename, $is_horizontal) {\n $sizeinfo = self::getImageInfo($filename);\n if (!is_array($sizeinfo)) {\n return $sizeinfo;\n }",
" $original = self::openImageFile($filename, $sizeinfo);\n if (!is_resource($original)) {\n return $original;\n }",
" // Horizontal - invert y coords\n // Vertical - invert x coords",
" $w = $sizeinfo[0];\n $h = $sizeinfo[1];\n $new = self::imageCreate($w, $h);",
" if ($is_horizontal) {\n // Copy column by column\n //$dest,$src,$dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {\n for ($i = 0; $i < $w; $i++) {\n imagecopy($new, $original, // DESTINATION, SOURCE\n $i, 0, // dst_X, dst_Y\n $w - $i - 1, 0, // src_X,src_Y\n 1, $h); //src_W, src_H\n }\n } else {\n // Copy row by row.\n //$dest,$src,$dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {\n for ($i = 0; $i < $h; $i++) {\n imagecopy($new, $original, // DESTINATION, SOURCE\n 0, $i, // dst_X, dst_Y\n 0, $h - $i - 1, // src_X,src_Y\n #$w,1,\t\t// dst_W, dst_H\n $w, 1); //src_W, src_H\n }\n }\n return $new;\n }",
" /** exdoc\n *\n * @state <b>UNDOCUMENTED</b>\n * @node Undocumented\n *\n * @param $img\n * @param $sizeinfo\n * @param null $filename\n * @param int $quality\n */\n public static function imageOutput($img, $sizeinfo, $filename = null, $quality = 75) {\n header('Content-type: ' . $sizeinfo['mime']);\n if ($sizeinfo['mime'] == 'image/jpeg') {\n ($filename != null) ? imagejpeg($img, $filename, $quality) : imagejpeg($img, null, $quality);\n } else if ($sizeinfo['mime'] == 'image/png') {\n ($filename != null) ? imagepng($img, $filename) : imagepng($img);\n } else if ($sizeinfo['mime'] == 'image/gif') {\n ($filename != null) ? imagepng($img, $filename) : imagepng($img);\n }\n }",
" /** exdoc\n *\n * @state <b>UNDOCUMENTED</b>\n * @node Undocumented\n *\n * @param $w\n * @param $h\n * @param $string\n *\n * @return null|resource\n */\n public static function imageCaptcha($w, $h, $string) {\n $img = self::imageCreate($w, $h);\n if ($img) {\n // We were able to create an image.\n $bg = imagecolorallocate($img, 250, 255, 225);\n imagefill($img, 0, 0, $bg);\n #echo $bg;\n $colors = array();\n for ($i = 0; $i < strlen($string) && $i < 10; $i++) {\n $colors[$i] = imagecolorallocate($img, mt_rand(50, 150), mt_rand(50, 150), mt_rand(50, 150));\n }\n $px_per_char = floor($w / (strlen($string) + 1));\n for ($i = 0, $iMax = strlen($string); $i < $iMax; $i++) {\n imagestring($img, mt_rand(4, 6), $px_per_char * ($i + 1) + mt_rand(-5, 5), mt_rand(0, $h / 2), $string{$i}, $colors[($i % 10)]);\n }",
" // Need this to be 'configurable'\n for ($i = 0; $i < strlen($string) / 2 && $i < 10; $i++) {\n $c = imagecolorallocate($img, mt_rand(150, 250), mt_rand(150, 250), mt_rand(150, 250));\n imageline($img, mt_rand(0, $w / 4), mt_rand(5, $h - 5), mt_rand(3 * $w / 4, $w), mt_rand(0, $h), $c);\n }",
" //imagestring($img,6,0,0,$string,$color);\n return $img;\n } else {\n return null;\n }\n }",
" static function recurse_copy($src, $dst) {\n $dir = opendir($src);\n @mkdir($dst,DIR_DEFAULT_MODE_STR);\n while (false !== ($file = readdir($dir))) {\n if (($file != '.') && ($file != '..')) {\n if (is_dir($src . '/' . $file)) {\n self::recurse_copy($src . '/' . $file, $dst . '/' . $file);\n } else {\n if (!copy($src . '/' . $file, $dst . '/' . $file)) {\n return false;\n }\n ;\n }\n }\n }\n closedir($dir);\n return true;\n }",
" /**\n * Recursively removes all files in a given directory, and all\n * the files and directories underneath it.\n * Optionally can skip dotfiles\n *\n * @param string $dir directory to work with\n * @param bool $dot_files should dotfiles be removed?\n *\n * @return array\n */\n public static function removeFilesInDirectory($dir, $dot_files = false) {\n $results['removed'] = array();\n $results['not_removed'] = array();",
" $files = scandir($dir);\n array_shift($files); // remove '.' from array\n array_shift($files); // remove '..' from array\n foreach ($files as $file) {\n if ($dot_files || substr($file, 0, 1) != '.') { // don't remove dot files\n $file = $dir . '/' . $file;\n if (is_dir($file)) {\n self::removeFilesInDirectory($file);\n rmdir($file);\n } else {\n if (is_writeable($file) && !is_dir($file)) {\n unlink($file);\n $results['removed'][] = $file;\n } else {\n $results['not_removed'][] = $file;\n }\n }\n }\n }",
" /*\told routine\n if (is_readable($dir)) {\n $dh = opendir($dir);\n while (($file = readdir($dh)) !== false) {\n $filepath = $dir.'/'.$file;\n if (substr($file,0,1) != '.') {\n if (is_writeable($filepath) && !is_dir($filepath)) {\n unlink($filepath);\n $results['removed'][] = $filepath;\n } else {\n $results['not_removed'][] = $filepath;\n }\n }\n }\n }*/",
" return $results;\n }",
" /** exdoc\n * This method creates a directory and all of its parent directories, if they do not exist,\n * emulating the behavior of the -p option to mkdir on UNIX systems. Returns\n * a SYS_FILES_* constant, indicating its status.\n *\n * @param string $dir The directory to create. This path must be relative to BASE\n * @param null $mode\n * @param bool $is_full\n *\n * @return int\n * @node Model:expFile\n */\n public static function makeDirectory($dir, $mode = null, $is_full = false) {\n $__oldumask = umask(0);\n $parentdir = ($is_full ? \"/\" : BASE); // we will add to parentdir with each directory\n foreach (explode(\"/\", $dir) as $part) {\n if ($part != \"\" && !is_dir($parentdir . $part)) {\n // No parent directory. Create it.\n if (is_file($parentdir . $part)) return SYS_FILES_FOUNDFILE;\n if (expUtil::isReallyWritable($parentdir)) {\n if ($mode == null) $mode = octdec(DIR_DEFAULT_MODE_STR + 0);\n mkdir($parentdir . $part, $mode);\n chmod($parentdir . $part, $mode);\n } else return SYS_FILES_NOTWRITABLE;\n }\n $parentdir .= $part . \"/\";\n }\n umask($__oldumask);\n return SYS_FILES_SUCCESS;\n }",
" /**\n * Recursively removes the given directory, and all\n * of the files and directories underneath it.\n *\n * @param string $dir The path of the directory to remove\n *\n * @node Model:expFile\n *\n * @param string $dir directory to work with\n *\n * @return int\n */\n public static function removeDirectory($dir) {\n if (strpos($dir, BASE) != 0) $dir = BASE . $dir;\n $dh = opendir($dir);\n if ($dh) {\n while (($file = readdir($dh)) !== false) {\n if ($file != \".\" && $file != \"..\" && is_dir(\"$dir/$file\")) {\n if (self::removeDirectory(\"$dir/$file\") == SYS_FILES_NOTDELETABLE) return SYS_FILES_NOTDELETABLE;\n } else if (is_file(\"$dir/$file\") || is_link(is_file(\"$dir/$file\"))) {\n unlink(\"$dir/$file\");\n if (file_exists(\"$dir/$file\")) {\n return SYS_FILES_NOTDELETABLE;\n }\n } else if ($file != \".\" && $file != \"..\") {\n echo \"BAD STUFF HAPPENED<br />\";\n echo \"--------Don't know what to do with $dir/$file<br />\";\n//\t\t\t\t\techo \"<xmp>\";\n echo \"<pre>\";\n print_r(stat(\"$dir/$file\"));\n echo filetype(\"$dir/$file\");\n//\t\t\t\t\techo \"</xmp>\";\n echo \"</pre>\";\n }\n }\n }\n closedir($dh);\n rmdir($dir);\n }",
" /** exdoc\n * Move an uploaded temporary file to a more permanent home inside of the Exponent files/ directory.\n * This function takes into account the default file modes specified in the site configuration.\n *\n * @param string $tmp_name The temporary path of the uploaded file.\n * @param string $dest The full path to the destination file (including the destination filename).\n *\n * @return null|string The destination file if it exists, otherwise null\n * @node Model:expFile\n */\n public static function moveUploadedFile($tmp_name, $dest) {\n move_uploaded_file($tmp_name, $dest);\n if (file_exists($dest)) {\n $__oldumask = umask(0);\n chmod($dest, octdec(FILE_DEFAULT_MODE_STR + 0));\n umask($__oldumask);\n return str_replace(BASE, '', $dest);\n } else return null;\n }",
" /** exdoc\n * Checks to see if the upload destination file exists. This is to prevent\n * accidentally uploading over the top of another file.\n * Returns true if the file already exists, and false if it does not.\n *\n * @param string $dir The directory to contain the existing directory.\n * @param string $name The name of the file control used to upload the\n * file. The files subsystem will look to the $_FILES array\n * to get the filename of the uploaded file.\n *\n * @return bool\n * @node Model:expFile\n */\n public static function uploadDestinationFileExists($dir, $name) {\n return (file_exists(BASE . $dir . \"/\" . self::fixName($_FILES[$name]['name'])));\n }",
" /** exdoc\n * Lists files and directories under a given parent directory. Returns an\n * associative, flat array of files and directories. The key is the full file\n * or directory name, and the value is the file or directory name.\n *\n * @param string $dir The path of the directory to look at.\n * @param boolean $recurse A boolean dictating whether to descend into subdirectories\n * recursively, and list files and subdirectories.\n * @param string $ext An optional file extension. If specified, only files ending with\n * that file extension will show up in the list. Directories are not affected.\n * @param array $exclude_dirs An array of directory names to exclude. These names are\n * path-independent. Specifying \"dir\" will ignore all directories and\n * sub-directories named \"dir\", regardless of their parent.\n * @param string $relative\n *\n * @return array\n * @node Model:expFile\n */\n public static function listFlat($dir, $recurse = false, $ext = null, $exclude_dirs = array(), $relative = \"\") {\n $files = array();\n if (is_readable($dir)) {\n $dh = opendir($dir);\n while (($file = readdir($dh)) !== false) {\n if (is_dir(\"$dir/$file\") && !in_array($file, $exclude_dirs) && $recurse && $file != \".\" && $file != \"..\" && $file != \"CVS\") {\n $files = array_merge($files, self::listFlat(\"$dir/$file\", $recurse, $ext, $exclude_dirs, $relative));\n }\n if (is_file(\"$dir/$file\") && ($ext == null || substr($file, -1 * strlen($ext), strlen($ext)) == $ext)) {\n $files[str_replace($relative, \"\", \"$dir/$file\")] = $file;\n }\n }\n closedir($dh);\n }\n return $files;\n }",
" /** exdoc\n * Looks at the filesystem structure surrounding the destination\n * and determines if the web server can create a new file there.\n * Returns one of the following:\n * <br>SYS_FILES_NOTWRITABLE - unable to create files in destination\n * <br>SYS_FILES_SUCCESS - A file or directory can be created in destination\n * <br>SYS_FILES_FOUNDFILE - Found destination to be a file, not a directory\n *\n * @param string $dest Path to the directory to check\n *\n * @return int\n * @node Model:expFile\n */\n public static function canCreate($dest) {\n if (substr($dest, 0, 1) == '/') $dest = str_replace(BASE, '', $dest);\n $parts = explode('/', $dest);\n $working = BASE;\n for ($i = 0, $iMax = count($parts); $i < $iMax; $i++) {\n if ($parts[$i] != '') {\n if (!file_exists($working . $parts[$i])) {\n return (expUtil::isReallyWritable($working) ? SYS_FILES_SUCCESS : SYS_FILES_NOTWRITABLE);\n }\n $working .= $parts[$i] . '/';\n }\n }\n // If we got this far, then the file we are asking about already exists.\n // Check to see if we can overwrite this file.\n // First however, we need to strip off the '/' that was added a few lines up as the last part of the for loop.\n $working = substr($working, 0, -1);",
" if (!expUtil::isReallyWritable($working)) {\n return SYS_FILES_NOTWRITABLE;\n } else {\n if (is_file($working)) {\n return SYS_FILES_FOUNDFILE;\n } else {\n return SYS_FILES_FOUNDDIR;\n }\n }\n }",
" /**\n * Test if file can be uploaded using tmp folder\n *\n * @param string $tmp\n * @param string $dest\n *\n * @return bool\n */\n public static function canUpload($tmp = 'tmp', $dest = 'files/uploads') {\n $result = expFile::canCreate(BASE . $tmp . '/TEST') != SYS_FILES_SUCCESS;\n $result |= expFile::canCreate(BASE . $dest . '/TEST') != SYS_FILES_SUCCESS;\n return $result;\n }",
" /** exdoc\n * Copies just the directory structure (including subdirectories) of a given directory.\n * Any files in the source directory are ignore, and duplicate copies are made (no symlinks).\n *\n * @param string $src The directory to copy structure from. This must be a full path.\n * @param string $dest The directory to create duplicate structure in. If this directory is not empty,\n * you may run into some problems, because of file/directory conflicts.\n * @param array $exclude_dirs An array of directory names to exclude. These names are\n * path-independent. Specifying \"dir\" will ignore all directories and\n * sub-directories named \"dir\", regardless of their parent.\n *\n * @node Model:expFile\n */\n public static function copyDirectoryStructure($src, $dest, $exclude_dirs = array()) {\n $__oldumask = umask(0);\n if (!is_dir($dest)) {\n $file_path = pathinfo($dest);\n $dest = $file_path['dirname'];\n }\n if (!is_dir($src)) {\n $file_path = pathinfo($src);\n $src = $file_path['dirname'];\n }\n if (!file_exists($dest)) mkdir($dest, fileperms($src));\n $dh = opendir($src);\n while (($file = readdir($dh)) !== false) {\n if (is_dir(\"$src/$file\") && !in_array($file, $exclude_dirs) && substr($file, 0, 1) != \".\" && $file != \"CVS\") {\n if (!file_exists($dest.\"/\".$file)) mkdir($dest.\"/\".$file, fileperms($src.\"/\".$file));\n if (is_dir($dest.\"/\".$file)) {\n self::copyDirectoryStructure($src.\"/\".$file, $dest.\"/\".$file);\n }\n }\n }\n closedir($dh);\n umask($__oldumask);\n }",
" /** exdoc\n * This function takes a database object and dumps\n * all of the records in all of the tables into a string.\n * The contents of the string are suitable for storage\n * in a file or other permanent mechanism, and is in\n * the EQL format naively handled by the current\n * implementation.\n *\n * @param null/array $tables\n * @param null/string $type The type of dump\n * @param null/string/array $opts Record descimiator\n *\n * @return string The content of export file\n * @node Model:expFile\n */\n public static function dumpDatabase($tables = null, $type = null, $opts = null) {\n global $db;",
" //FIXME we need to echo and/or write to file within this method to handle large database dumps\n $dump = EQL_HEADER . \"\\r\\n\";\n if ($type == null || $type == 'export') {\n $dump .= 'VERSION:' . EXPONENT . \"\\r\\n\\r\\n\";\n } else {\n $dump .= 'VERSION:' . EXPONENT . ':' . $type . \"\\r\\n\\r\\n\";\n }",
" if (is_string($tables)) $tables = array($tables);\n if (!is_array($tables)) { // dump all the tables\n $tables = $db->getTables();\n if (!function_exists('tmp_removePrefix')) {\n function tmp_removePrefix($tbl) {\n return substr($tbl, strlen(DB_TABLE_PREFIX) + 1);\n // we add 1, because DB_TABLE_PREFIX no longer has the trailing\n // '_' character - that is automatically added by the database class.\n }\n }\n $tables = array_map('tmp_removePrefix', $tables);\n }\n uasort($tables, 'strnatcmp');\n foreach ($tables as $key=>$table) {\n $where = '1';\n if ($type == 'Form') {\n if ($table == 'forms') {\n $where = 'id=' . $opts;\n } elseif ($table == 'forms_control') {\n $where = 'forms_id=' . $opts;\n }\n } elseif ($type == 'export') {\n if (is_string($opts))\n $where = $opts;\n elseif (is_array($opts) && !empty($opts[$key]))\n $where = $opts[$key];\n }\n $tmp = $db->countObjects($table,$where);\n if ($type != 'export' || $db->countObjects($table, $where)) {\n $tabledef = $db->getDataDefinition($table);\n $dump .= 'TABLE:' . $table . \"\\r\\n\";\n $dump .= 'TABLEDEF:' . str_replace(array(\"\\r\", \"\\n\"), array('\\r', '\\n'), serialize($tabledef)) . \"\\r\\n\";\n foreach ($db->selectObjects($table, $where) as $obj) {\n $dump .= 'RECORD:' . str_replace(array(\"\\r\", \"\\n\"), array('\\r', '\\n'), serialize($obj)) . \"\\r\\n\";\n }\n $dump .= \"\\r\\n\";\n }\n }\n //FIXME $dump may become too large and exhaust memory\n return $dump;\n }",
" /** exdoc\n * This function restores a database (overwriting all data in\n * any existing tables) from an EQL object dump. Returns true if\n * the restore was a success and false if something went horribly wrong\n * (unable to read file, etc.) Even if true is returned, there is a chance\n * that some errors were encountered. Check $errors to be sure everything\n * was fine.\n *\n * @param string $file The filename of the EQL file to restore from\n * @param array $errors A referenced array that stores errors. Whatever\n * variable is passed in this argument will contain all errors encountered\n * during the parse/restore.\n * @param null/string $type The type of eql file to restore\n *\n * @return bool\n * @node Model:expFile\n */\n public static function restoreDatabase($file, &$errors, $type = null) {\n global $db;",
"// $errors = array();",
" if (is_readable($file)) {\n $eql = @fopen($file, \"r\");\n if ($eql) {\n //NOTE changed to fgets($file)\n// $lines = @file($file);\n $line0 = fgets($eql);\n $line1 = fgets($eql);",
" // Sanity check\n// if (count($lines) < 2 || trim($lines[0]) != EQL_HEADER) {\n if ($line1 === false || trim($line0) != EQL_HEADER) {\n $errors[] = gt('Not a valid EQL file');\n return false;\n }",
"// $version = explode(':', trim($lines[1]));\n $version = explode(':', trim($line1));\n $eql_version = $version[1] + 0;\n $current_version = EXPONENT + 0;\n if ((array_key_exists(2, $version) && $type == null) || (array_key_exists(\n 2,\n $version\n ) && $version[2] != $type)\n ) {\n $eql_version = 0; // trying to import wrong eql type\n }",
"// $clear_function = '';\n $fprefix = '';\n // Check version and include necessary converters\n if ($eql_version != $current_version) {\n $errors[] = gt('EQL file was Not a valid EQL version');\n return false;\n //\t\t\t$fprefix = 'expFile::'.implode('',explode('.',$eql_version)).'_';\n //\t\t\tif (function_exists($fprefix.'clearedTable')) {\n //\t\t\t\t$clear_function = $fprefix.'clearedTable';\n //\t\t\t}\n }",
" // make sure the database tables are up to date\n expDatabase::install_dbtables();",
" $table = '';\n $oldformdata = array();\n $itsoldformdata = false;\n $newformdata = array();\n $itsnewformdata = false;\n// for ($i = 2; $i < count($lines); $i++) {\n $line_number = 2;\n while (($line = fgets($eql)) !== false) {\n $table_function = '';\n// $line_number = $i;\n $line_number++;\n// $line = trim($lines[$i]);\n $line = trim($line);\n if ($line != '') {\n $pair = explode(':', $line);\n $pair[1] = implode(':', array_slice($pair, 1));\n $pair = array_slice($pair, 0, 2);",
" if ($pair[0] == 'TABLE') {\n $itsoldformdata = false; // we are on a new table set\n $itsnewformdata = false;\n $table = $pair[1];\n if ($fprefix != '') {\n $table_function = $fprefix . $table;\n }\n if ($db->tableExists($table)) {\n if ($type == null) {\n $db->delete($table); // drop/empty table records\n }\n// if ($clear_function != '') {\n// $clear_function($db, $table);\n// }\n } else {\n if (substr($table, 0, 12) == 'formbuilder_') {\n $formbuildertypes = array(\n 'address',\n 'control',\n 'form',\n 'report'\n );\n $ttype = substr($table, 12);\n if (!in_array($ttype, $formbuildertypes)) {\n $itsoldformdata = true;\n }\n } elseif (substr($table, 0, 6) == 'forms_' && $table != 'forms_control') {\n $itsnewformdata = true;\n }\n //\t\t\t\t\t\tif (!file_exists(BASE.'framework/core/definitions/'.$table.'.php')) {\n $errors[] = sprintf(\n gt('Table \"%s\" not found in the database (line %d)'),\n $table,\n $line_number\n );\n //\t\t\t\t\t\t} else if (!is_readable(BASE.'framework/core/definitions/'.$table.'.php')) {\n //\t\t\t\t\t\t\t$errors[] = sprintf(gt('Data definition file for %s (%s) is not readable (line %d)'),$table,'framework/core/definitions/'.$table.'.php',$line_number);\n //\t\t\t\t\t\t} else {\n //\t\t\t\t\t\t\t$dd = include(BASE.'framework/core/definitions/'.$table.'.php');\n //\t\t\t\t\t\t\t$info = (is_readable(BASE.'framework/core/definitions/'.$table.'.info.php') ? include(BASE.'framework/core/definitions/'.$table.'.info.php') : array());\n //\t\t\t\t\t\t\t$db->createTable($table,$dd,$info);\n //\t\t\t\t\t\t}\n }\n } else {\n if ($pair[0] == 'TABLEDEF') { // new in v2.1.4, re-create a missing table\n $pair[1] = str_replace(array('\\r', '\\n'), array(\"\\r\", \"\\n\"), $pair[1]);\n//\t\t\t\t\t\t$tabledef = expUnserialize($pair[1]);\n $tabledef = @unserialize($pair[1]);\n if (!$db->tableExists($table)) {\n $db->createTable($table, $tabledef, array());\n $errors[] = sprintf(\n gt('* However...we successfully recreated the \"%s\" Table from the EQL file'),\n $table\n );\n } else {\n $db->alterTable($table, $tabledef, array(), true);\n }\n $itsoldformdata = false; // we've recreated the table using the tabledef\n $itsnewformdata = false;\n } else {\n if ($pair[0] == 'RECORD') {\n if ($db->tableExists($table)) {\n // Here we need to check the conversion scripts.\n $pair[1] = str_replace(array('\\r', '\\n'), array(\"\\r\", \"\\n\"), $pair[1]);\n //\t\t\t\t\t\t$object = expUnserialize($pair[1]);\n $object = @unserialize($pair[1]);\n if ($type == 'Form') {\n if ($table == 'forms') {\n $forms_id = $object->id = $db->max(\n $table,\n 'id'\n ) + 1; // create a new record\n $spare = new expRecord();\n $spare->title = $object->title;\n $spare->makeSefUrl();\n $object->sef_url = $spare->sef_url;\n } elseif ($table == 'forms_control') {\n $object->id = null; // create a new record\n $object->forms_id = $forms_id; // assign to new form record\n } elseif (substr($table, 6) == 'forms_') {\n $object->id = null; // create a new record\n }\n }\n if (!$object) {\n $object = unserialize(stripslashes($pair[1]));\n }\n if (function_exists($table_function)) {\n $table_function($db, $object);\n } else {\n if (is_object($object)) {\n $db->insertObject($object, $table);\n } else {\n $errors[] = sprintf(\n gt('Unable to decipher \"%s\" record (line %d)'),\n $pair[0],\n $line_number\n );\n }\n }\n } elseif ($itsoldformdata) {\n $oldformdata[$table][] = $pair[1]; // store for later\n } elseif ($itsnewformdata) {\n $newformdata[$table][] = $pair[1]; // store for later\n }\n } else {\n $errors[] = sprintf(\n gt('Invalid specifier type \"%s\" (line %d)'),\n $pair[0],\n $line_number\n );\n }\n }\n }\n }\n }",
" // check for and process to rebuild old formbuilder module data table\n if (!empty($oldformdata)) {\n foreach ($oldformdata as $tablename => $tabledata) {\n $oldform = $db->selectObject('formbuilder_form', 'table_name=\"' . substr($tablename, 12) . '\"');\n if (!empty($oldform)) {\n // create the old table\n $table = self::updateFormbuilderTable($oldform);",
" // populate the table\n foreach ($tabledata as $record) {\n $record = str_replace('\\r\\n', \"\\r\\n\", $record);\n $object = @unserialize($record);\n if (!$object) {\n $object = unserialize(stripslashes($record));\n }\n if (is_object($object)) {\n $db->insertObject($object, 'formbuilder_' . $table);\n }\n }\n $errors[] = sprintf(\n gt(\n '* However...we successfully recreated the \"formbuilder_%s\" Table from the EQL file'\n ),\n $table\n );\n }\n }\n }",
" // check for and process to rebuild new forms module data table\n if (!empty($newformdata)) {\n foreach ($newformdata as $tablename => $tabledata) {\n $newform = $db->selectObject('forms', 'table_name=\"' . substr($tablename, 6) . '\"');\n if (!empty($newform)) {\n // create the new table\n $form = new forms($newform->id);\n $table = $form->updateTable();",
" // populate the table\n foreach ($tabledata as $record) {\n $record = str_replace('\\r\\n', \"\\r\\n\", $record);\n $object = @unserialize($record);\n if (!$object) {\n $object = unserialize(stripslashes($record));\n }\n if (is_object($object)) {\n// $db->insertObject($object, 'forms_' . $table);\n $form->insertRecord($object);\n }\n }\n $errors[] = sprintf(\n gt('* However...we successfully recreated the \"forms_%s\" Table from the EQL file'),\n $table\n );\n }\n }\n }",
" // ensure the form data table exists and is current\n// foreach ($db->selectObjects('forms') as $f) {\n// if ($f->is_saved) $f->updateTable();\n// }\n $formmodel = new forms();\n $forms = $formmodel->find('all');\n foreach ($forms as $f) {\n if ($f->is_saved) {\n $f->updateTable();\n }\n }",
" // rename mixed case tables if necessary\n expDatabase::fix_table_names();\n// if ($eql_version != $current_version) {\n// $errors[] = gt('EQL file was Not a valid EQL version');\n// return false;\n// }\n return true;\n } else {\n $errors[] = gt('Unable to read EQL file');\n return false;\n }\n } else {\n $errors[] = gt('Unable to find EQL file');\n return false;\n }\n }",
" /** exdoc\n * This function reads a database EQL object dump file and returns an array of the\n * database tables and records, or false if something went horribly wrong\n * (unable to read file, etc.) Even if an array is returned, there is a chance\n * that some errors were encountered. Check $errors to be sure everything\n * was fine.\n *\n * @param string $file The filename of the EQL file to parse\n * @param array $errors A referenced array that stores errors. Whatever\n * variable is passed in this argument will contain all errors encountered\n * during the parse/restore.\n * @param null/string/array $type The list of tables to return, empty = entire file\n * @return array/bool\n * @node Model:expFile\n */\n public static function parseDatabase($file, &$errors, $type = null) {\n// $errors = array();\n $data = array();",
" if (is_readable($file)) {\n $lines = @file($file); //FIXME we may have to change this for handling large files via fgets()...see dumpDatabase() above",
" // Sanity check\n if (count($lines) < 2 || trim($lines[0]) != EQL_HEADER) {\n $errors[] = gt('Not a valid EQL file');\n return false;\n }",
" $version = explode(':', trim($lines[1]));\n $eql_version = $version[1] + 0;\n $current_version = EXPONENT + 0;\n if ((array_key_exists(2, $version) && $type == null) || (array_key_exists(2, $version) && $version[2] != $type)) {\n $eql_version = 0; // trying to import wrong eql type\n }",
" // Check version and include necessary converters\n if ($eql_version != $current_version) {\n $errors[] = gt('EQL file was Not a valid EQL version');\n return false;\n }",
" $table = '';\n for ($i = 2, $iMax = count($lines); $i < $iMax; $i++) {\n $line_number = $i;\n $line = trim($lines[$i]);\n if ($line != '') {\n $pair = explode(':', $line);\n $pair[1] = implode(':', array_slice($pair, 1));\n $pair = array_slice($pair, 0, 2);",
" if ($pair[0] == 'TABLE') {\n $table = $pair[1];\n $data[$table] = new stdClass();\n $data[$table]->name = $table;\n $data[$table]->records = array();\n } else if ($pair[0] == 'TABLEDEF') { // new in v2.1.4, re-create a missing table\n $pair[1] = str_replace('\\r\\n', \"\\r\\n\", $pair[1]);\n $tabledef = @unserialize($pair[1]);\n $data[$table]->tabledef = $tabledef;\n } else if ($pair[0] == 'RECORD') {\n // Here we need to check the conversion scripts.\n $pair[1] = str_replace('\\r\\n', \"\\r\\n\", $pair[1]);\n//\t\t\t\t\t\t$object = expUnserialize($pair[1]);\n $object = @unserialize($pair[1]);\n if (!$object) $object = unserialize(stripslashes($pair[1]));\n if (is_object($object)) {\n $data[$table]->records[] = object2Array($object); //FIXME should we convert this? object2array?\n } else {\n $errors[] = sprintf(gt('Unable to decipher \"%s\" record (line %d)'), $pair[0], $line_number);\n }\n } else {\n $errors[] = sprintf(gt('Invalid specifier type \"%s\" (line %d)'), $pair[0], $line_number);\n }\n }\n }",
" if (!empty($type)) {\n if (!is_array($type)) $type = array($type);\n foreach ($data as $key=>$tbl) {\n if (!in_array($key, $type)) {\n unset($data[$key]);\n }\n }\n }\n return $data;\n } else {\n $errors[] = gt('Unable to read EQL file');\n return false;\n }\n }",
" public function afterDelete() {\n global $db;",
"\t // get and delete all attachments to this file\n\t $db->delete('content_expFiles','expfiles_id='.$this->id);\n }",
" /**\n * recreates a deprecated formbuilder data table\n * needed to import form data from eql file exported prior to v2.1.4\n * this is just the old formbuilder_form::updateTable method\n *\n * @static\n * @param $object\n * @return mixed\n */\n static function updateFormbuilderTable($object) {\n\t\tglobal $db;",
"\t\tif (!empty($object->is_saved)) {\n\t\t\t$datadef = array(\n\t\t\t\t'id'=>array(\n\t\t\t\t\tDB_FIELD_TYPE=>DB_DEF_ID,\n\t\t\t\t\tDB_PRIMARY=>true,\n\t\t\t\t\tDB_INCREMENT=>true),\n\t\t\t\t'ip'=>array(\n\t\t\t\t\tDB_FIELD_TYPE=>DB_DEF_STRING,\n\t\t\t\t\tDB_FIELD_LEN=>25),\n\t\t\t\t'referrer'=>array(\n\t\t\t\t\tDB_FIELD_TYPE=>DB_DEF_STRING,\n\t\t\t\t\tDB_FIELD_LEN=>1000),\n\t\t\t\t'timestamp'=>array(\n\t\t\t\t\tDB_FIELD_TYPE=>DB_DEF_TIMESTAMP),\n\t\t\t\t'user_id'=>array(\n\t\t\t\t\tDB_FIELD_TYPE=>DB_DEF_ID)\n\t\t\t);",
"\t\t\tif (!isset($object->id)) {\n\t\t\t\t$object->table_name = preg_replace('/[^A-Za-z0-9]/','_',$object->name);\n\t\t\t\t$tablename = 'formbuilder_'.$object->table_name;\n\t\t\t\t$index = '';\n\t\t\t\twhile ($db->tableExists($tablename . $index)) {\n\t\t\t\t\t$index++;\n\t\t\t\t}\n\t\t\t\t$tablename = $tablename.$index;\n\t\t\t\t$db->createTable($tablename,$datadef,array());\n\t\t\t\t$object->table_name .= $index;\n\t\t\t} else {\n\t\t\t\tif ($object->table_name == '') {\n\t\t\t\t\t$tablename = preg_replace('/[^A-Za-z0-9]/','_',$object->name);\n\t\t\t\t\t$index = '';\n\t\t\t\t\twhile ($db->tableExists('formbuilder_' . $tablename . $index)) {\n\t\t\t\t\t\t$index++;\n\t\t\t\t\t}\n\t\t\t\t\t$object->table_name = $tablename . $index;\n\t\t\t\t}",
"\t\t\t\t$tablename = 'formbuilder_'.$object->table_name;",
"\t\t\t\t//If table is missing, create a new one.\n\t\t\t\tif (!$db->tableExists($tablename)) {\n\t\t\t\t\t$db->createTable($tablename,$datadef,array());\n\t\t\t\t}",
"\t\t\t\t$ctl = null;\n\t\t\t\t$control_type = '';\n\t\t\t\t$tempdef = array();\n\t\t\t\tforeach ($db->selectObjects('formbuilder_control','form_id='.$object->id) as $control) {\n\t\t\t\t\tif ($control->is_readonly == 0) {\n\t\t\t\t\t\t$ctl = unserialize($control->data);\n\t\t\t\t\t\t$ctl->identifier = $control->name;\n\t\t\t\t\t\t$ctl->caption = $control->caption;\n\t\t\t\t\t\t$ctl->id = $control->id;\n\t\t\t\t\t\t$control_type = get_class($ctl);\n\t\t\t\t\t\t$def = call_user_func(array($control_type,'getFieldDefinition'));\n\t\t\t\t\t\tif ($def != null) {\n\t\t\t\t\t\t\t$tempdef[$ctl->identifier] = $def;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t$datadef = array_merge($datadef,$tempdef);\n\t\t\t\t$db->alterTable($tablename,$datadef,array(),true);\n\t\t\t}\n\t\t}\n\t\treturn $object->table_name;\n\t}",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class filedownloadController extends expController {\n\tpublic $useractions = array(\n 'showall'=>'Show all',\n 'tags'=>\"Tags\",\n );\n\tpublic $remove_configs = array(\n// 'comments',\n// 'ealerts',\n 'files',\n 'rss', // because we do this as a custom tab within the module\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" public $rss_is_podcast = true;",
" static function displayname() { return gt(\"File Downloads\"); }\n static function description() { return gt(\"Place files on your website for users to download or use as a podcast.\"); }\n static function isSearchable() { return true; }",
"\t",
" function showall() {\n expHistory::set('viewable', $this->params);\n $limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;\n if (!empty($this->params['view']) && ($this->params['view'] == 'showall_accordion' || $this->params['view'] == 'showall_tabbed')) {\n $limit = '0';\n }\n $order = isset($this->config['order']) ? $this->config['order'] : 'rank';\n $page = new expPaginator(array(\n 'model'=>$this->basemodel_name,\n 'where'=>$this->aggregateWhereClause(),\n 'limit'=>$limit,\n 'order'=>$order,\n 'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],\n 'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),\n 'dontsortwithincat'=>!empty($this->config['dontsort']) ? $this->config['dontsort'] : false,\n 'groups'=>!isset($this->params['group']) ? array() : array($this->params['group']),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('ID#')=>'id',\n gt('Title')=>'title',\n gt('Description')=>'body'\n ),\n ));",
" include_once(BASE.'external/mp3file.php');\n foreach ($page->records as $file) {\n if (!empty($file->expFile['downloadable'][0]) && ($file->expFile['downloadable'][0]->mimetype == \"audio/mpeg\") && (file_exists(BASE.$file->expFile['downloadable'][0]->directory.$file->expFile['downloadable'][0]->filename))) {\n $mp3 = new mp3file(BASE.$file->expFile['downloadable'][0]->directory.$file->expFile['downloadable'][0]->filename);\n $id3 = $mp3->get_metadata();\n if (($id3['Encoding']=='VBR') || ($id3['Encoding']=='CBR')) {\n $file->expFile['downloadable'][0]->duration = $id3['Length mm:ss'];\n }\n }\n }",
"\t\tassign_to_template(array(\n 'page'=>$page,\n 'items'=>$page->records,\n 'rank'=>($order==='rank')?1:0,\n 'params'=>$this->params,\n ));\n }",
" public function downloadfile() {\n if (empty($this->params['fileid'])) {\n flash('error', gt('There was an error while trying to download your file. No File Specified.'));\n expHistory::back();\n }",
" \n $fd = new filedownload($this->params['fileid']); ",
" if (empty($this->params['filenum'])) $this->params['filenum'] = 0;",
" if (empty($fd->expFile['downloadable'][$this->params['filenum']]->id)) {\n flash('error', gt('There was an error while trying to download your file. The file you were looking for could not be found.'));\n expHistory::back();",
" } \n ",
" $fd->downloads++;\n $fd->save();",
" ",
" // this will set the id to the id of the actual file..makes the download go right.\n $this->params['id'] = $fd->expFile['downloadable'][$this->params['filenum']]->id;",
" parent::downloadfile(); ",
" }",
" /**\n * Returns rich snippet PageMap meta data\n *\n * @param $request\n * @param $object\n *\n * @return string\n */\n function meta_rich($request, $object) {\n if (!empty($object->expFile[0]) && file_exists(BASE.$object->expFile[0]->directory.$object->expFile[0]->filename)) {\n $rich_meta = '<!--\n <PageMap>\n <DataObject type=\"action\">\n <Attribute name=\"label\" value=\"' . gt('Download') . '\"/>\n <Attribute name=\"url\" value=\"' . $object->download_link() . '\"/>\n <Attribute name=\"class\" value=\"download\"/>\n </DataObject>\n </PageMap>\n -->';\n return $rich_meta;\n }\n }",
" /**\n * Returns Facebook og: meta data\n *\n * @param $request\n * @param $object\n *\n * @return null\n */\n public function meta_fb($request, $object, $canonical)\n {\n $metainfo = array();\n $metainfo['type'] = 'article';\n if (!empty($object->body)) {\n $desc = str_replace('\"', \"'\", expString::summarize($object->body, 'html', 'para'));\n } else {\n $desc = SITE_DESCRIPTION;\n }\n $metainfo['title'] = substr(empty($object->meta_fb['title']) ? $object->title : $object->meta_fb['title'], 0, 87);\n $metainfo['description'] = substr(empty($object->meta_fb['description']) ? $desc : $object->meta_fb['description'], 0, 199);\n $metainfo['url'] = empty($object->meta_fb['url']) ? $canonical : $object->meta_fb['url'];\n $metainfo['image'] = empty($object->meta_fb['fbimage'][0]) ? '' : $object->meta_fb['fbimage'][0]->url;\n if (empty($metainfo['image'])) {\n if (!empty($object->expFile['downloadable'][0]->is_image)) {\n $metainfo['image'] = $object->expFile['downloadable'][0]->url;\n } else {\n $config = expConfig::getConfig($object->location_data);\n if (!empty($config['expFile']['fbimage'][0])) {\n $file = new expFile($config['expFile']['fbimage'][0]);\n }\n if (!empty($file->id)) {\n $metainfo['image'] = $file->url;\n }\n if (empty($metainfo['image'])) {\n $metainfo['image'] = URL_BASE . MIMEICON_RELATIVE . 'generic_22x22.png';\n }\n }\n }\n $mt = explode('/', $object->expFile['downloadable'][0]->mimetype);\n if ($mt[0] == 'audio' || $mt[0] == 'video') // add an audio/video attachment\n $metainfo[$mt[0]] = $object->expFile['downloadable'][0]->url;",
" return $metainfo;\n }",
" /**\n * Returns Twitter twitter: meta data\n *\n * @param $request\n * @param $object\n *\n * @return null\n */\n public function meta_tw($request, $object, $canonical) {\n $metainfo = array();\n $metainfo['card'] = 'summary';\n if (!empty($object->body)) {\n $desc = str_replace('\"',\"'\",expString::summarize($object->body,'html','para'));\n } else {\n $desc = SITE_DESCRIPTION;\n }\n $config = expConfig::getConfig($object->location_data);\n if (!empty($object->meta_tw['twsite'])) {\n $metainfo['site'] = $object->meta_tw['twsite'];\n } elseif (!empty($config['twsite'])) {\n $metainfo['site'] = $config['twsite'];\n }\n $metainfo['title'] = substr(empty($object->meta_tw['title']) ? $object->title : $object->meta_tw['title'], 0, 87);\n $metainfo['description'] = substr(empty($object->meta_tw['description']) ? $desc : $object->meta_tw['description'], 0, 199);\n $metainfo['image'] = empty($object->meta_tw['twimage'][0]) ? '' : $object->meta_tw['twimage'][0]->url;\n if (empty($metainfo['image'])) {\n if (!empty($object->expFile['images'][0]->is_image)) {\n $metainfo['image'] = $object->expFile['images'][0]->url;\n } else {\n if (!empty($config['expFile']['twimage'][0]))\n $file = new expFile($config['expFile']['twimage'][0]);\n if (!empty($file->id))\n $metainfo['image'] = $file->url;\n if (empty($metainfo['image']))\n $metainfo['image'] = URL_BASE . MIMEICON_RELATIVE . 'generic_22x22.png';\n }\n }\n return $metainfo;\n }",
" function getRSSContent($limit = 0) {\n include_once(BASE.'external/mp3file.php');",
" $fd = new filedownload();\n $items = $fd->find('all',$this->aggregateWhereClause(), isset($this->config['order']) ? $this->config['order'] : 'created_at DESC', $limit);",
" ",
" //Convert the items to rss items\n $rssitems = array();",
" foreach ($items as $key => $item) { ",
" $rss_item = new FeedItem();",
" // Add the basic data\n $rss_item->title = expString::convertSmartQuotes($item->title);\n $rss_item->link = $rss_item->guid = makeLink(array('controller'=>$this->baseclassname, 'action'=>'show', 'title'=>$item->sef_url));\n $rss_item->description = expString::convertSmartQuotes($item->body);\n $rss_item->author = user::getUserById($item->poster)->firstname.' '.user::getUserById($item->poster)->lastname;\n $rss_item->authorEmail = user::getEmailById($item->poster);\n// $rss_item->date = isset($item->publish_date) ? date(DATE_RSS,$item->publish_date) : date(DATE_RSS, $item->created_at);\n $rss_item->date = isset($item->publish_date) ? $item->publish_date : $item->created_at;\n if (!empty($item->expCat[0]->title))\n $rss_item->category = array($item->expCat[0]->title);",
" // Add the attachment/enclosure info\n $rss_item->enclosure = new Enclosure();\n $rss_item->enclosure->url = !empty($item->expFile['downloadable'][0]->url) ? $item->expFile['downloadable'][0]->url : '';\n $rss_item->enclosure->length = !empty($item->expFile['downloadable'][0]->filesize) ? $item->expFile['downloadable'][0]->filesize : '';\n $rss_item->enclosure->type = !empty($item->expFile['downloadable'][0]->mimetype) ? $item->expFile['downloadable'][0]->mimetype : '';\n if ($rss_item->enclosure->type == 'audio/mpeg')\n $rss_item->enclosure->type = 'audio/mpg';",
" // Add iTunes info\n $rss_item->itunes = new iTunes();\n $rss_item->itunes->subtitle = expString::convertSmartQuotes($item->title);\n $rss_item->itunes->summary = expString::convertSmartQuotes($item->body);\n $rss_item->itunes->author = user::getUserById($item->poster)->firstname.' '.user::getUserById($item->poster)->lastname;\n $tags = '';\n foreach ($item->expTag as $tag) {\n $tags .= $tag->title.\", \";\n }\n if (!empty($tags)) {\n $rss_item->itunes->keywords = $tags;\n }\n if (($rss_item->enclosure->type == \"audio/mpg\") && (file_exists(BASE.$item->expFile['downloadable'][0]->directory.$item->expFile['downloadable'][0]->filename))) {\n $mp3 = new mp3file(BASE.$item->expFile['downloadable'][0]->directory.$item->expFile['downloadable'][0]->filename);\n $id3 = $mp3->get_metadata();\n if (($id3['Encoding']=='VBR') || ($id3['Encoding']=='CBR')) {\n $rss_item->itunes->duration = $id3['Length mm:ss'];\n }\n if (!empty($id3['artist'])) {\n $rss_item->author = $id3['artist'];\n $rss_item->itunes->author = $id3['artist'];\n }\n if (!empty($id3['comment'])) {\n $rss_item->itunes->subtitle = $id3['comment'];\n }\n } else {\n $rss_item->itunes->duration = 'Unknown';\n }",
" // Add the item to the array.\n $rssitems[$key] = $rss_item;",
" if ($limit && count($rssitems) >= $limit)\n break;\n }\n return $rssitems;\n }",
"\t",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class filedownloadController extends expController {\n\tpublic $useractions = array(\n 'showall'=>'Show all',\n 'tags'=>\"Tags\",\n );\n\tpublic $remove_configs = array(\n// 'comments',\n// 'ealerts',\n 'files',\n 'rss', // because we do this as a custom tab within the module\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" public $rss_is_podcast = true;",
" static function displayname() { return gt(\"File Downloads\"); }\n static function description() { return gt(\"Place files on your website for users to download or use as a podcast.\"); }\n static function isSearchable() { return true; }",
"",
" function showall() {\n expHistory::set('viewable', $this->params);\n $limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;\n if (!empty($this->params['view']) && ($this->params['view'] == 'showall_accordion' || $this->params['view'] == 'showall_tabbed')) {\n $limit = '0';\n }\n $order = isset($this->config['order']) ? $this->config['order'] : 'rank';\n $page = new expPaginator(array(\n 'model'=>$this->basemodel_name,\n 'where'=>$this->aggregateWhereClause(),\n 'limit'=>$limit,\n 'order'=>$order,\n 'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],\n 'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),\n 'dontsortwithincat'=>!empty($this->config['dontsort']) ? $this->config['dontsort'] : false,\n 'groups'=>!isset($this->params['group']) ? array() : array($this->params['group']),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('ID#')=>'id',\n gt('Title')=>'title',\n gt('Description')=>'body'\n ),\n ));",
" include_once(BASE.'external/mp3file.php');\n foreach ($page->records as $file) {\n if (!empty($file->expFile['downloadable'][0]) && ($file->expFile['downloadable'][0]->mimetype == \"audio/mpeg\") && (file_exists(BASE.$file->expFile['downloadable'][0]->directory.$file->expFile['downloadable'][0]->filename))) {\n $mp3 = new mp3file(BASE.$file->expFile['downloadable'][0]->directory.$file->expFile['downloadable'][0]->filename);\n $id3 = $mp3->get_metadata();\n if (($id3['Encoding']=='VBR') || ($id3['Encoding']=='CBR')) {\n $file->expFile['downloadable'][0]->duration = $id3['Length mm:ss'];\n }\n }\n }",
"\t\tassign_to_template(array(\n 'page'=>$page,\n 'items'=>$page->records,\n 'rank'=>($order==='rank')?1:0,\n 'params'=>$this->params,\n ));\n }",
" public function downloadfile() {\n if (empty($this->params['fileid'])) {\n flash('error', gt('There was an error while trying to download your file. No File Specified.'));\n expHistory::back();\n }",
"\n $fd = new filedownload(intval($this->params['fileid']));",
" if (empty($this->params['filenum'])) $this->params['filenum'] = 0;",
" if (empty($fd->expFile['downloadable'][$this->params['filenum']]->id)) {\n flash('error', gt('There was an error while trying to download your file. The file you were looking for could not be found.'));\n expHistory::back();",
" }\n",
" $fd->downloads++;\n $fd->save();",
"",
" // this will set the id to the id of the actual file..makes the download go right.\n $this->params['id'] = $fd->expFile['downloadable'][$this->params['filenum']]->id;",
" parent::downloadfile();",
" }",
" /**\n * Returns rich snippet PageMap meta data\n *\n * @param $request\n * @param $object\n *\n * @return string\n */\n function meta_rich($request, $object) {\n if (!empty($object->expFile[0]) && file_exists(BASE.$object->expFile[0]->directory.$object->expFile[0]->filename)) {\n $rich_meta = '<!--\n <PageMap>\n <DataObject type=\"action\">\n <Attribute name=\"label\" value=\"' . gt('Download') . '\"/>\n <Attribute name=\"url\" value=\"' . $object->download_link() . '\"/>\n <Attribute name=\"class\" value=\"download\"/>\n </DataObject>\n </PageMap>\n -->';\n return $rich_meta;\n }\n }",
" /**\n * Returns Facebook og: meta data\n *\n * @param $request\n * @param $object\n *\n * @return null\n */\n public function meta_fb($request, $object, $canonical)\n {\n $metainfo = array();\n $metainfo['type'] = 'article';\n if (!empty($object->body)) {\n $desc = str_replace('\"', \"'\", expString::summarize($object->body, 'html', 'para'));\n } else {\n $desc = SITE_DESCRIPTION;\n }\n $metainfo['title'] = substr(empty($object->meta_fb['title']) ? $object->title : $object->meta_fb['title'], 0, 87);\n $metainfo['description'] = substr(empty($object->meta_fb['description']) ? $desc : $object->meta_fb['description'], 0, 199);\n $metainfo['url'] = empty($object->meta_fb['url']) ? $canonical : $object->meta_fb['url'];\n $metainfo['image'] = empty($object->meta_fb['fbimage'][0]) ? '' : $object->meta_fb['fbimage'][0]->url;\n if (empty($metainfo['image'])) {\n if (!empty($object->expFile['downloadable'][0]->is_image)) {\n $metainfo['image'] = $object->expFile['downloadable'][0]->url;\n } else {\n $config = expConfig::getConfig($object->location_data);\n if (!empty($config['expFile']['fbimage'][0])) {\n $file = new expFile($config['expFile']['fbimage'][0]);\n }\n if (!empty($file->id)) {\n $metainfo['image'] = $file->url;\n }\n if (empty($metainfo['image'])) {\n $metainfo['image'] = URL_BASE . MIMEICON_RELATIVE . 'generic_22x22.png';\n }\n }\n }\n $mt = explode('/', $object->expFile['downloadable'][0]->mimetype);\n if ($mt[0] == 'audio' || $mt[0] == 'video') // add an audio/video attachment\n $metainfo[$mt[0]] = $object->expFile['downloadable'][0]->url;",
" return $metainfo;\n }",
" /**\n * Returns Twitter twitter: meta data\n *\n * @param $request\n * @param $object\n *\n * @return null\n */\n public function meta_tw($request, $object, $canonical) {\n $metainfo = array();\n $metainfo['card'] = 'summary';\n if (!empty($object->body)) {\n $desc = str_replace('\"',\"'\",expString::summarize($object->body,'html','para'));\n } else {\n $desc = SITE_DESCRIPTION;\n }\n $config = expConfig::getConfig($object->location_data);\n if (!empty($object->meta_tw['twsite'])) {\n $metainfo['site'] = $object->meta_tw['twsite'];\n } elseif (!empty($config['twsite'])) {\n $metainfo['site'] = $config['twsite'];\n }\n $metainfo['title'] = substr(empty($object->meta_tw['title']) ? $object->title : $object->meta_tw['title'], 0, 87);\n $metainfo['description'] = substr(empty($object->meta_tw['description']) ? $desc : $object->meta_tw['description'], 0, 199);\n $metainfo['image'] = empty($object->meta_tw['twimage'][0]) ? '' : $object->meta_tw['twimage'][0]->url;\n if (empty($metainfo['image'])) {\n if (!empty($object->expFile['images'][0]->is_image)) {\n $metainfo['image'] = $object->expFile['images'][0]->url;\n } else {\n if (!empty($config['expFile']['twimage'][0]))\n $file = new expFile($config['expFile']['twimage'][0]);\n if (!empty($file->id))\n $metainfo['image'] = $file->url;\n if (empty($metainfo['image']))\n $metainfo['image'] = URL_BASE . MIMEICON_RELATIVE . 'generic_22x22.png';\n }\n }\n return $metainfo;\n }",
" function getRSSContent($limit = 0) {\n include_once(BASE.'external/mp3file.php');",
" $fd = new filedownload();\n $items = $fd->find('all',$this->aggregateWhereClause(), isset($this->config['order']) ? $this->config['order'] : 'created_at DESC', $limit);",
"",
" //Convert the items to rss items\n $rssitems = array();",
" foreach ($items as $key => $item) {",
" $rss_item = new FeedItem();",
" // Add the basic data\n $rss_item->title = expString::convertSmartQuotes($item->title);\n $rss_item->link = $rss_item->guid = makeLink(array('controller'=>$this->baseclassname, 'action'=>'show', 'title'=>$item->sef_url));\n $rss_item->description = expString::convertSmartQuotes($item->body);\n $rss_item->author = user::getUserById($item->poster)->firstname.' '.user::getUserById($item->poster)->lastname;\n $rss_item->authorEmail = user::getEmailById($item->poster);\n// $rss_item->date = isset($item->publish_date) ? date(DATE_RSS,$item->publish_date) : date(DATE_RSS, $item->created_at);\n $rss_item->date = isset($item->publish_date) ? $item->publish_date : $item->created_at;\n if (!empty($item->expCat[0]->title))\n $rss_item->category = array($item->expCat[0]->title);",
" // Add the attachment/enclosure info\n $rss_item->enclosure = new Enclosure();\n $rss_item->enclosure->url = !empty($item->expFile['downloadable'][0]->url) ? $item->expFile['downloadable'][0]->url : '';\n $rss_item->enclosure->length = !empty($item->expFile['downloadable'][0]->filesize) ? $item->expFile['downloadable'][0]->filesize : '';\n $rss_item->enclosure->type = !empty($item->expFile['downloadable'][0]->mimetype) ? $item->expFile['downloadable'][0]->mimetype : '';\n if ($rss_item->enclosure->type == 'audio/mpeg')\n $rss_item->enclosure->type = 'audio/mpg';",
" // Add iTunes info\n $rss_item->itunes = new iTunes();\n $rss_item->itunes->subtitle = expString::convertSmartQuotes($item->title);\n $rss_item->itunes->summary = expString::convertSmartQuotes($item->body);\n $rss_item->itunes->author = user::getUserById($item->poster)->firstname.' '.user::getUserById($item->poster)->lastname;\n $tags = '';\n foreach ($item->expTag as $tag) {\n $tags .= $tag->title.\", \";\n }\n if (!empty($tags)) {\n $rss_item->itunes->keywords = $tags;\n }\n if (($rss_item->enclosure->type == \"audio/mpg\") && (file_exists(BASE.$item->expFile['downloadable'][0]->directory.$item->expFile['downloadable'][0]->filename))) {\n $mp3 = new mp3file(BASE.$item->expFile['downloadable'][0]->directory.$item->expFile['downloadable'][0]->filename);\n $id3 = $mp3->get_metadata();\n if (($id3['Encoding']=='VBR') || ($id3['Encoding']=='CBR')) {\n $rss_item->itunes->duration = $id3['Length mm:ss'];\n }\n if (!empty($id3['artist'])) {\n $rss_item->author = $id3['artist'];\n $rss_item->itunes->author = $id3['artist'];\n }\n if (!empty($id3['comment'])) {\n $rss_item->itunes->subtitle = $id3['comment'];\n }\n } else {\n $rss_item->itunes->duration = 'Unknown';\n }",
" // Add the item to the array.\n $rssitems[$key] = $rss_item;",
" if ($limit && count($rssitems) >= $limit)\n break;\n }\n return $rssitems;\n }",
"",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class formsController extends expController {\n public $useractions = array(\n 'enterdata' => 'Input Records',\n 'showall' => 'Show All Records',\n 'show' => 'Show a Single Record',\n );",
"",
" public $remove_configs = array(\n 'aggregation',\n 'categories',\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n// 'pagination',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" protected $add_permissions = array(\n 'viewdata' => \"View Data\",\n 'enter_data' => \"Enter Data\" // slight naming variation to not fully restrict enterdata method\n );",
"// public $codequality = 'beta';",
" static function displayname() {\n return gt(\"Forms\");\n }",
" static function description() {\n return gt(\"Allows the creation of forms that can be emailed, or even viewed if they are optionally stored in the database\");\n }",
" static function author() {\n return \"Dave Leffler\";\n }",
" static function isSearchable() {\n return false;\n }",
" function searchName() {\n return gt(\"Forms\");\n }",
" function searchCategory() {\n return gt('Form Data');\n }",
" static function requiresConfiguration()\n {\n return true;\n }",
" public function showall() {\n if ((!empty($this->config['unrestrict_view']) || expPermissions::check('viewdata', $this->loc))) {\n expHistory::set('viewable', $this->params);\n $f = null;\n if (!empty($this->config)) {\n $f = $this->forms->find('first', 'id=' . $this->config['forms_id']);\n } elseif (!empty($this->params['title'])) {",
" $f = $this->forms->find('first', 'sef_url=\"' . $this->params['title'] . '\"');",
" $this->get_defaults($f);\n } elseif (!empty($this->params['id'])) {\n $f = $this->forms->find('first', 'id=' . $this->params['id']);\n $this->get_defaults($f);\n }",
" if (!empty($f)) {\n if (empty($this->config['report_filter']) && empty($this->params['filter'])) { // allow for param of 'filter' also\n $where = '1';\n } elseif (!empty($this->params['filter'])) {",
" $where = $this->params['filter'];",
" } else {\n $where = $this->config['report_filter'];\n }\n $fc = new forms_control();\n if (empty($this->config['column_names_list'])) {\n //define some default columns...\n $controls = $fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly=0 AND is_static = 0', 'rank');\n foreach (array_slice($controls, 0, 5) as $control) { // default to only first 5 columns\n $this->config['column_names_list'][] = $control->name;\n }\n }",
" // pre-process records\n $items = $f->selectRecordsArray($where);\n $columns = array();\n foreach ($this->config['column_names_list'] as $column_name) {\n if ($column_name == \"ip\") {\n// $columns[gt('IP Address')] = 'ip';\n $columns['ip'] = gt('IP Address');\n } elseif ($column_name == \"referrer\") {\n// $columns[gt('Referrer')] = 'referrer';\n $columns['referrer'] = gt('Referrer');\n } elseif ($column_name == \"location_data\") {\n// $columns[gt('Entry Point')] = 'location_data';\n $columns['location_data'] = gt('Entry Point');\n } elseif ($column_name == \"user_id\") {\n foreach ($items as $key => $item) {\n if ($item[$column_name] != 0) {\n $locUser = user::getUserById($item[$column_name]);\n $item[$column_name] = $locUser->username;\n } else {\n $item[$column_name] = '';\n }\n $items[$key] = $item;\n }\n// $columns[gt('Posted by')] = 'user_id';\n $columns['user_id'] = gt('Posted by');\n } elseif ($column_name == \"timestamp\") {\n foreach ($items as $key => $item) {\n $item[$column_name] = strftime(DISPLAY_DATETIME_FORMAT, $item[$column_name]);\n $items[$key] = $item;\n }\n// $columns[gt('Timestamp')] = 'timestamp';\n $columns['timestamp'] = gt('Timestamp');\n } else {\n $control = $fc->find('first', \"name='\" . $column_name . \"' AND forms_id=\" . $f->id, 'rank');\n if ($control) {\n $ctl = expUnserialize($control->data);\n $control_type = get_class($ctl);\n foreach ($items as $key => $item) {\n //We have to add special sorting for date time columns!!!\n $item[$column_name] = @call_user_func(\n array($control_type, 'templateFormat'),\n $item[$column_name],\n $ctl\n );\n $items[$key] = $item;\n }\n// $columns[$control->caption] = $column_name;\n $columns[$column_name] = $control->caption;\n }\n }\n }",
" $page = new expPaginator(\n array(\n 'records' => $items,\n 'where' => 1,\n// 'limit' => (isset($this->params['limit']) && $this->params['limit'] != '') ? $this->params['limit'] : 10,\n 'order' => (isset($this->params['order']) && $this->params['order'] != '') ? $this->params['order'] : (!empty($this->config['order']) ? $this->config['order'] : 'id'),\n 'dir' => (isset($this->params['dir']) && $this->params['dir'] != '') ? $this->params['dir'] : 'ASC',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n 'src' => $this->loc->src,\n 'columns' => $columns\n )\n );",
" assign_to_template(\n array(\n// \"backlink\" => expHistory::getLastNotEditable(),\n \"backlink\" => expHistory::getLast('viewable'),\n \"f\" => $f,\n \"page\" => $page,\n \"title\" => !empty($this->config['report_name']) ? $this->config['report_name'] : '',\n \"description\" => !empty($this->config['report_desc']) ? $this->config['report_desc'] : null,\n \"filtered\" => !empty($this->config['report_filter']) ? $this->config['report_filter'] : ''\n )\n );\n }\n } else {\n assign_to_template(array(\n \"error\" => 1,\n ));\n }\n }",
" public function show() {\n if (!empty($this->config['unrestrict_view']) || expPermissions::check('viewdata', $this->loc)) {\n expHistory::set('viewable', $this->params);\n $f = null;\n if (!empty($this->config)) {\n $f = $this->forms->find('first', 'id=' . $this->config['forms_id']);\n } elseif (!empty($this->params['forms_id'])) {\n $f = $this->forms->find('first', 'id=' . $this->params['forms_id']);\n } elseif (!empty($this->params['title'])) {",
" $f = $this->forms->find('first', 'sef_url=\"' . $this->params['title'] . '\"');",
" redirect_to(array('controller' => 'forms', 'action' => 'enterdata', 'forms_id' => $f->id));\n }",
" if (!empty($f)) {\n $fc = new forms_control();\n $controls = $fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly=0 AND is_static = 0', 'rank');\n $id = !empty($this->params['id']) ? $this->params['id'] : null;\n $data = $f->getRecord($id);",
" $fields = array();\n $captions = array();\n if ($controls && $data) {\n foreach ($controls as $c) {\n $ctl = expUnserialize($c->data);\n $control_type = get_class($ctl);\n $name = $c->name;\n $fields[$name] = call_user_func(array($control_type, 'templateFormat'), $data->$name, $ctl);\n $captions[$name] = $c->caption;\n }",
" // system added fields\n $captions['ip'] = gt('IP Address');\n $captions['timestamp'] = gt('Timestamp');\n $captions['user_id'] = gt('Posted by');\n $fields['ip'] = $data->ip;\n $fields['timestamp'] = strftime(DISPLAY_DATETIME_FORMAT, $data->timestamp);\n $locUser = user::getUserById($data->user_id);\n $fields['user_id'] = !empty($locUser->username) ? $locUser->username : '';",
" // add a browse other records (next/prev) feature here\n $field = !empty($this->config['order']) ? $this->config['order'] : 'id';\n $data->next = $f->getRecord($field . ' > ' . $data->$field . ' ORDER BY ' . $field);\n if (!empty($data->next) && $data->next != $data->id) {\n assign_to_template(\n array(\n \"next\" => $data->next,\n )\n );\n }\n $data->prev = $f->getRecord($field . ' < ' . $data->$field . ' ORDER BY ' . $field . ' DESC');\n if (!empty($data->prev) && $data->prev != $data->id) {\n assign_to_template(\n array(\n \"prev\" => $data->prev,\n )\n );\n }\n }",
" $count = $f->countRecords();\n assign_to_template(\n array(\n // \"backlink\"=>expHistory::getLastNotEditable(),\n // 'backlink' => expHistory::getLast('editable'),\n 'backlink' => makeLink(expHistory::getBack(1)),\n \"f\" => $f,\n // \"record_id\" => $this->params['id'],\n \"record_id\" => !empty($data->id) ? $data->id : null,\n \"title\" => !empty($this->config['report_name']) ? $this->config['report_name'] : gt(\n 'Viewing Record'\n ),\n \"description\" => !empty($this->config['report_desc']) ? $this->config['report_desc'] : null,\n 'fields' => $fields,\n 'captions' => $captions,\n \"count\" => $count,\n 'is_email' => 0,\n \"css\" => file_get_contents(BASE . \"framework/core/assets/css/tables.css\"),\n )\n );\n }\n } else {\n assign_to_template(array(\n \"error\" => 1,\n ));\n }\n }",
" public function enter_data() {\n $this->enterdata();\n }",
" public function enterdata() {\n if (empty($this->config['restrict_enter']) || expPermissions::check('enterdata', $this->loc)) {",
" global $user;",
" expHistory::set('viewable', $this->params);\n $f = null;\n if (!empty($this->config)) {\n $f = $this->forms->find('first', 'id=' . $this->config['forms_id']);\n } elseif (!empty($this->params['forms_id'])) {\n $f = $this->forms->find('first', 'id=' . $this->params['forms_id']);\n $this->get_defaults($f);\n }",
" if (!empty($f)) {\n $form = new form();\n $form->id = $f->sef_url;\n $form->horizontal = !empty($this->config['style']);\n if (!empty($this->params['id'])) {\n $fc = new forms_control();\n $controls = $fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly = 0 AND is_static = 0','rank');\n $data = $f->getRecord($this->params['id']);\n } else {\n if (!empty($f->forms_control)) {\n $controls = $f->forms_control;\n } else {\n $controls = array();\n }\n $data = expSession::get('forms_data_' . $f->id);\n }\n // display list of email addresses\n if (!empty($this->config['select_email'])) {\n //Building Email List...\n $emaillist = array();\n if (!empty($this->config['user_list'])) foreach ($this->config['user_list'] as $c) {\n $u = user::getUserById($c);\n if (!empty($u->email)) {\n if (!empty($u->firstname) || !empty($u->lastname)) {\n $title = $u->firstname . ' ' . $u->lastname . ' ('. $u->email . ')';\n } else {\n $title = $u->username . ' ('. $u->email . ')';\n }\n $emaillist[$u->email] = $title;\n }\n }\n if (!empty($this->config['group_list'])) foreach ($this->config['group_list'] as $c) {\n// $grpusers = group::getUsersInGroup($c);\n// foreach ($grpusers as $u) {\n// $emaillist[] = $u->email;\n// }\n $g = group::getGroupById($c);\n $emaillist[$c] = $g->name;\n }\n if (!empty($this->config['address_list'])) foreach ($this->config['address_list'] as $c) {\n $emaillist[$c] = $c;\n }\n //This is an easy way to remove duplicates\n $emaillist = array_flip(array_flip($emaillist));\n $emaillist = array_map('trim', $emaillist);\n $emaillist = array_reverse($emaillist, true);\n if (empty($this->config['select_exclude_all']))\n $emaillist[0] = gt('All Addresses');\n $emaillist = array_reverse($emaillist, true);\n if (!empty($this->config['select_dropdown']))\n $form->register('email_dest', gt('Send Response to'), new dropdowncontrol('', $emaillist));\n else\n $form->register('email_dest', gt('Send Response to'), new radiogroupcontrol('', $emaillist));\n }\n// $paged = false;\n foreach ($controls as $key=>$c) {\n $ctl = expUnserialize($c->data);\n $ctl->_id = $c->id;\n $ctl->_readonly = $c->is_readonly;\n $ctl->_ishidden = !empty($ctl->is_hidden) && empty($this->params['id']); // hide it if entering new data\n if (!empty($this->params['id'])) {\n if ($c->is_readonly == 0) {\n $name = $c->name;\n if ($c->is_static == 0) {\n $ctl->default = $data->$name;\n }\n }\n } else {\n if (!empty($data[$c->name])) $ctl->default = $data[$c->name];\n }\n if ($key == 0) $ctl->focus = true; // first control gets the focus\n $form->register($c->name, $c->caption, $ctl);\n// if (get_class($ctl) == 'pagecontrol') $paged = true;\n }",
" // if we are editing an existing record we'll need to do recaptcha here since we won't call confirm_data\n if (!empty($this->params['id'])) {\n $antispam = '';\n if (SITE_USE_ANTI_SPAM && ANTI_SPAM_CONTROL == 'recaptcha') {\n // make sure we have the proper config.\n if (!defined('RECAPTCHA_PUB_KEY')) {\n $antispam .= '<h2 style=\"color:red\">' . gt('reCaptcha configuration is missing the public key.') . '</h2>';\n }\n if ($user->isLoggedIn() && ANTI_SPAM_USERS_SKIP == 1) {\n // skip it for logged on users based on config\n } else {\n // include the library and show the form control\n require_once(BASE . 'external/ReCaptcha/autoload.php'); //FIXME not sure we need this here\n $re_theme = (RECAPTCHA_THEME == 'dark') ? 'dark' : 'light';\n $antispam .= '<input type=\"hidden\" class=\"hiddenRecaptcha required\" name=\"hiddenRecaptcha\" id=\"hiddenRecaptcha\">';\n $antispam .= '<div class=\"g-recaptcha\" data-sitekey=\"' . RECAPTCHA_PUB_KEY . '\" data-theme=\"' . $re_theme . '\"></div>';\n $antispam .= '<script type=\"text/javascript\" src=\"https://www.google.com/recaptcha/api.js?hl=' . LOCALE . '\" async defer></script>';\n $antispam .= '<p>' . gt('Fill out the above security question to submit your form.') . '</p>';\n }\n }\n $form->register(uniqid(''), '', new htmlcontrol($antispam));\n }",
" if (empty($this->config['submitbtn'])) $this->config['submitbtn'] = gt('Submit');\n if (!empty($this->params['id'])) {\n $cancel = gt('Cancel');\n $form->meta('action', 'submit_data');\n $form->meta('isedit', 1);\n $form->meta('data_id', $data->id);\n $form->location($this->loc);\n assign_to_template(array(\n 'edit_mode' => 1,\n ));\n } else {\n $cancel = '';\n $form->meta(\"action\", \"confirm_data\");\n }\n if (empty($this->config['submitbtn'])) $this->config['submitbtn'] = gt('Submit');\n if (empty($this->config['resetbtn'])) $this->config['resetbtn'] = '';\n $form->register(\"submit\", \"\", new buttongroupcontrol($this->config['submitbtn'], $this->config['resetbtn'], $cancel, 'finish'));",
" $form->meta(\"m\", $this->loc->mod);\n $form->meta(\"s\", $this->loc->src);\n $form->meta(\"i\", $this->loc->int);\n $form->meta(\"id\", $f->id);\n $formmsg = '';\n $form->location(expCore::makeLocation(\"forms\", $this->loc->src, $this->loc->int));\n if (count($controls) == 0) {\n $form->controls['submit']->disabled = true;\n $formmsg .= gt('This form is blank. Select \"Design Form\" to add input fields.') . '<br>';\n } elseif (empty($f->is_saved) && empty($this->config['is_email'])) {\n $form->controls['submit']->disabled = true;\n $formmsg .= gt('There are no actions assigned to this form. Select \"Configure Settings\" then either select \"Email Form Data\" and/or \"Save Submissions to Database\".');\n }\n $count = $f->countRecords();\n if ($formmsg) {\n flash('notice', $formmsg);\n }\n if (empty($this->config['description'])) $this->config['description'] = '';\n assign_to_template(array(\n \"description\" => $this->config['description'],\n \"form_html\" => $form->toHTML(),\n \"form\" => $f,\n \"count\" => $count,\n// 'paged' => $paged,\n ));\n }\n } else {\n assign_to_template(array(\n \"error\" => 1,\n ));\n }\n }",
" public function confirm_data() {\n $f = new forms($this->params['id']);\n $cols = $f->forms_control;\n $counts = array();\n $responses = array();\n $captions = array();",
" foreach ($cols as $col) {\n $newupload = false;\n $coldef = expUnserialize($col->data);\n $coldata = new ReflectionClass($coldef);\n if (empty($coldef->is_hidden)) {\n $coltype = $coldata->getName();\n if ($coltype == 'uploadcontrol' && !empty($_FILES)) {\n $newupload = true;\n $value = call_user_func(array($coltype, 'parseData'), $col->name, $_FILES, true);\n } else {\n $value = call_user_func(array($coltype, 'parseData'), $col->name, $this->params, true);\n }\n $value = call_user_func(array($coltype, 'templateFormat'), $value, $coldef); // convert parsed value to user readable\n //eDebug($value);\n// $counts[$col->caption] = isset($counts[$col->caption]) ? $counts[$col->caption] + 1 : 1;\n// $num = $counts[$col->caption] > 1 ? $counts[$col->caption] : '';",
" if (!empty($this->params[$col->name])) {\n// if ($coltype == 'checkboxcontrol') {\n// $responses[$col->caption . $num] = gt('Yes');\n// } else {\n// $responses[$col->caption . $num] = $value;\n $responses[$col->name] = $value;\n $captions[$col->name] = $col->caption;\n// }\n } else {\n if ($coltype == 'checkboxcontrol') {\n// $responses[$col->caption . $num] = gt('No');\n $responses[$col->name] = gt('No');\n $captions[$col->name] = $col->caption;\n } elseif ($coltype == 'datetimecontrol' || $coltype == 'calendarcontrol') {\n// $responses[$col->name] = $value;\n $responses[$col->name] = $value;\n $captions[$col->name] = $col->caption;\n } elseif ($coltype == 'uploadcontrol') {\n if ($newupload) {\n $this->params[$col->name] = PATH_RELATIVE . call_user_func(\n array($coltype, 'moveFile'),\n $col->name,\n $_FILES,\n true\n );\n }\n // $value = call_user_func(array($coltype,'buildDownloadLink'),$this->params[$col->name],$_FILES[$col->name]['name'],true);\n //eDebug($value);\n// $responses[$col->caption . $num] = $_FILES[$col->name]['name'];\n// $responses[$col->name] = $_FILES[$col->name]['name'];\n// $responses[$col->name] = $this->params[$col->name];\n $responses[$col->name] = call_user_func(array($coltype, 'templateFormat'), $this->params[$col->name], null); // convert parsed value to user readable\n $captions[$col->name] = $col->caption;\n } elseif ($coltype != 'htmlcontrol' && $coltype != 'pagecontrol') {\n// $responses[$col->caption . $num] = '';\n $responses[$col->name] = '';\n $captions[$col->name] = $col->caption;\n }\n }\n }\n }",
" // remove some post data we don't want to pass thru to the form\n unset(\n $this->params['controller'],\n $this->params['action'],\n $this->params['view']\n );\n foreach ($this->params as $k => $v) {\n // $this->params[$k]=htmlentities(htmlspecialchars($v,ENT_COMPAT,LANG_CHARSET));\n $this->params[$k] = htmlspecialchars($v, ENT_COMPAT, LANG_CHARSET);\n }\n expSession::set('forms_data_' . $this->params['id'], $this->params);",
" assign_to_template(array(\n 'responses' => $responses,\n 'captions' => $captions,\n 'postdata' => $this->params,\n ));\n }",
" public function submit_data() {\n // Check for form errors\n $this->params['manual_redirect'] = true;\n if (!expValidator::check_antispam($this->params)) {\n flash('error', gt('Security Validation Failed'));\n expHistory::back();\n }",
" global $db, $user;\n $f = new forms($this->params['id']);\n $fc = new forms_control();\n $controls = $fc->find('all', \"forms_id=\" . $f->id . \" AND is_readonly=0\",'rank');\n $this->get_defaults($f);",
" $db_data = new stdClass();\n $emailFields = array();\n $captions = array();\n $attachments = array();\n foreach ($controls as $c) {\n $ctl = expUnserialize($c->data);\n $control_type = get_class($ctl);\n $def = call_user_func(array($control_type, \"getFieldDefinition\"));\n if ($def != null) {\n $emailValue = htmlspecialchars_decode(call_user_func(array($control_type, 'parseData'), $c->name, $this->params, true));\n $value = stripslashes(expString::escape($emailValue));",
" //eDebug($value);\n $varname = $c->name;\n $db_data->$varname = $value;\n // $fields[$c->name] = call_user_func(array($control_type,'templateFormat'),$value,$ctl);\n if (!$ctl->is_hidden) {\n $emailFields[$c->name] = call_user_func(array($control_type, 'templateFormat'), $value, $ctl);\n $captions[$c->name] = $c->caption;\n if (strtolower($c->name) == \"email\" && expValidator::isValidEmail($value)) {\n $from = $value;\n }\n if (strtolower($c->name) == \"name\") {\n $from_name = $value;\n }\n if (get_class($ctl) == 'uploadcontrol') {\n $attachments[] = htmlspecialchars_decode($this->params[$c->name]);\n }\n }\n }\n }",
" if (!isset($this->params['data_id']) || (isset($this->params['data_id']) && expPermissions::check(\"editdata\", $f->loc))) {\n if (!empty($f->is_saved)) {\n if (isset($this->params['data_id'])) {\n //if this is an edit we remove the record and insert a new one.\n $olddata = $f->getRecord($this->params['data_id']);\n $db_data->ip = $olddata->ip;\n $db_data->user_id = $olddata->user_id;\n $db_data->timestamp = $olddata->timestamp;\n $db_data->referrer = $olddata->referrer;\n $db_data->location_data = $olddata->location_data;\n $f->deleteRecord($this->params['data_id']);\n } else {\n $db_data->ip = $_SERVER['REMOTE_ADDR'];\n if (expSession::loggedIn()) {\n $db_data->user_id = $user->id;\n $from = $user->email;\n $from_name = $user->firstname . \" \" . $user->lastname . \" (\" . $user->username . \")\";\n } else {\n $db_data->user_id = 0;\n }\n $db_data->timestamp = time();\n $referrer = $db->selectValue(\"sessionticket\", \"referrer\", \"ticket = '\" . expSession::getTicketString() . \"'\");\n $db_data->referrer = $referrer;\n $location_data = null;\n if (!empty($this->params['src'])) {\n $mod = !empty($this->params['module']) ? $this->params['module'] : $this->params['controller'];\n expCore::makeLocation($mod,$this->params['src'],$this->params['int']);\n }\n $db_data->location_data = $location_data;\n }\n $f->insertRecord($db_data);\n } else {\n $referrer = $db->selectValue(\"sessionticket\", \"referrer\", \"ticket = '\" . expSession::getTicketString() . \"'\");\n }",
" //Email stuff here...\n //Don't send email if this is an edit.\n if (!empty($this->config['is_email']) && !isset($this->params['data_id'])) {\n //Building Email List...\n $emaillist = array();\n if (!empty($this->config['select_email']) && !empty($this->params['email_dest'])) {\n if (strval(intval($this->params['email_dest'])) == strval($this->params['email_dest'])) {\n foreach (group::getUsersInGroup($this->params['email_dest']) as $locUser) {\n if ($locUser->email != '') $emaillist[$locUser->email] = trim(user::getUserAttribution($locUser->id));\n }\n } else {\n $emaillist[] = $this->params['email_dest'];\n }\n } else { // send to all form addressee's\n $emaillist = array();\n if (!empty($this->config['user_list'])) foreach ($this->config['user_list'] as $c) {\n $u = user::getUserById($c);\n $emaillist[$u->email] = trim(user::getUserAttribution($u->id));\n }\n if (!empty($this->config['group_list'])) foreach ($this->config['group_list'] as $c) {\n $grpusers = group::getUsersInGroup($c);\n foreach ($grpusers as $u) {\n $emaillist[$u->email] = trim(user::getUserAttribution($u->id));\n }\n }\n if (!empty($this->config['address_list'])) foreach ($this->config['address_list'] as $c) {\n $emaillist[] = $c;\n }\n }\n //This is an easy way to remove duplicates\n $emaillist = array_flip(array_flip($emaillist));\n $emaillist = array_map('trim', $emaillist);",
" if (empty($this->config['report_def'])) {\n $msgtemplate = expTemplate::get_template_for_action($this, 'email/default_report', $this->loc);",
" } else {\n $msgtemplate = expTemplate::get_template_for_action($this, 'email/custom_report', $this->loc);\n $msgtemplate->assign('template', $this->config['report_def']);\n }\n $msgtemplate->assign(\"fields\", $emailFields);\n $msgtemplate->assign(\"captions\", $captions);\n $msgtemplate->assign('title', $this->config['report_name']);\n $msgtemplate->assign(\"is_email\", 1);\n if (!empty($referrer)) $msgtemplate->assign(\"referrer\", $referrer);\n $emailText = $msgtemplate->render();\n $emailText = trim(strip_tags(str_replace(array(\"<br />\", \"<br>\", \"br/>\"), \"\\n\", $emailText)));\n $msgtemplate->assign(\"css\", file_get_contents(BASE . \"framework/core/assets/css/tables.css\"));\n $emailHtml = $msgtemplate->render();",
" if (empty($from)) {\n $from = trim(SMTP_FROMADDRESS);\n }\n if (empty($from_name)) {\n $from_name = trim(ORGANIZATION_NAME);\n }\n // $headers = array(\n // \"MIME-Version\"=>\"1.0\",\n // \"Content-type\"=>\"text/html; charset=\".LANG_CHARSET\n // );\n if (count($emaillist)) {\n $mail = new expMail();\n if (!empty($attachments)) {\n foreach ($attachments as $attachment) {\n if (strlen(PATH_RELATIVE) != 1)\n $attachment = str_replace(PATH_RELATIVE, '', $attachment); // strip relative path for links coming from templates\n if (file_exists(BASE . $attachment)) {\n// $relpath = str_replace(PATH_RELATIVE, '', BASE);\n// $finfo = finfo_open(FILEINFO_MIME_TYPE);\n// $ftype = finfo_file($finfo, $relpath . $attachment);\n// finfo_close($finfo);\n $mail->attach_file_on_disk(BASE . $attachment, expFile::getMimeType($attachment));\n }\n }\n }\n $mail->quickSend(array(\n //\t'headers'=>$headers,\n 'html_message' => $emailHtml,\n \"text_message\" => $emailText,\n 'to' => $emaillist,\n 'from' => array(trim($from) => $from_name),\n 'subject' => $this->config['subject'],\n ));\n }\n }",
" if (!empty($this->config['is_auto_respond']) && !isset($this->params['data_id']) && !empty($db_data->email)) {\n if (empty($from)) {\n $from = trim(SMTP_FROMADDRESS);\n }\n if (empty($from_name)) {\n $from_name = trim(ORGANIZATION_NAME);\n }\n// $headers = array(\n// \"MIME-Version\" => \"1.0\",\n// \"Content-type\" => \"text/html; charset=\" . LANG_CHARSET\n// );",
" $tmsg = trim(strip_tags(str_replace(array(\"<br />\", \"<br>\", \"br/>\"), \"\\n\", $this->config['auto_respond_body'])));",
" if ($this->config['auto_respond_form']) ",
" $tmsg .= \"\\n\" . $emailText;\n $hmsg = $this->config['auto_respond_body'];",
" if ($this->config['auto_respond_form']) ",
" $hmsg .= \"\\n\" . $emailHtml;\n $mail = new expMail();\n $mail->quickSend(array(\n// 'headers' => $headers,\n \"text_message\" => $tmsg,\n 'html_message' => $hmsg,\n 'to' => $db_data->email,\n 'from' => array(trim($from) => $from_name),\n 'subject' => $this->config['auto_respond_subject'],\n ));\n }",
" // clear the users post data from the session.\n expSession::un_set('forms_data_' . $f->id);",
" //If is a new post show response, otherwise redirect to the flow.\n if (!isset($this->params['data_id'])) {\n if (empty($this->config['response'])) $this->config['response'] = gt('Thanks for your submission');\n assign_to_template(array(\n \"backlink\"=>expHistory::getLastNotEditable(),\n \"response_html\"=>$this->config['response'],\n ));\n } else {\n flash('message', gt('Record was updated!'));\n // expHistory::back();\n expHistory::returnTo('editable');\n }\n }\n }",
" /**\n * delete item in saved data\n *\n */\n function delete() {\n if (empty($this->params['id']) || empty($this->params['forms_id'])) {\n flash('error', gt('Missing id for the') . ' ' . gt('item') . ' ' . gt('you would like to delete'));\n expHistory::back();\n }",
" $f = new forms($this->params['forms_id']);\n $f->deleteRecord($this->params['id']);",
" expHistory::back();\n }",
" /**\n * delete all items in saved data\n *\n */\n function delete_records() {\n if (empty($this->params['forms_id'])) {\n flash('error', gt('Missing id for the') . ' ' . gt('form records') . ' ' . gt('you would like to delete'));\n expHistory::back();\n }",
" $f = new forms($this->params['forms_id']);\n $recs = $f->getRecords();\n foreach ($recs as $rec) {\n $f->deleteRecord($rec->id);\n }",
" flash('message', gt('All form records were deleted!'));\n expHistory::back();\n }",
" /**\n * Manage site forms\n *\n */\n public function manage() {\n expHistory::set('manageable', $this->params);\n $forms = $this->forms->find('all', 1);\n foreach($forms as $key=>$f) {\n if (!empty($f->table_name) && $f->tableExists() ) {\n $forms[$key]->count = $f->countRecords();\n }\n $forms[$key]->control_count = count($f->forms_control);\n }",
" assign_to_template(array(\n 'select' => !empty($this->params['select']),\n 'forms' => $forms\n ));\n }",
" /**\n * Assign selected form to current module\n *\n */\n public function activate() {\n // assign new form assigned\n $this->config['forms_id'] = $this->params['id'];\n // set default settings for this form\n $f = new forms($this->params['id']);\n if (!empty($f->description)) $this->config['description'] = $f->description;\n if (!empty($f->response)) $this->config['response'] = $f->response;\n if (!empty($f->report_name)) $this->config['report_name'] = $f->report_name;\n if (!empty($f->report_desc)) $this->config['report_desc'] = $f->report_desc;\n if (!empty($f->column_names_list)) $this->config['column_names_list'] = $f->column_names_list;\n if (!empty($f->report_def)) $this->config['report_def'] = $f->report_def;",
" // setup and save the config\n $config = new expConfig($this->loc);\n $config->update(array('config' => $this->config));",
" expHistory::back();\n }",
" public function edit_form() {\n expHistory::set('editable', $this->params);\n if (!empty($this->params['id'])) {\n $f = $this->forms->find('first', 'id=' . $this->params['id']);\n } else {\n $f = new forms();\n }\n $fields = array();\n $column_names = array();\n $cols = array();",
" if (!empty($f->column_names_list)) {\n $cols = explode('|!|', $f->column_names_list);\n }\n $fc = new forms_control();\n foreach ($fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly=0','rank') as $control) {\n $ctl = expUnserialize($control->data);\n $control_type = get_class($ctl);\n $def = call_user_func(array($control_type, 'getFieldDefinition'));\n if ($def != null) {\n $fields[$control->name] = $control->caption;\n if (in_array($control->name, $cols)) {\n $column_names[$control->name] = $control->caption;\n }\n }\n }\n $fields['ip'] = gt('IP Address');\n if (in_array('ip', $cols)) $column_names['ip'] = gt('IP Address');\n $fields['user_id'] = gt('Posted by');\n if (in_array('user_id', $cols)) $column_names['user_id'] = gt('Posted by');\n $fields['timestamp'] = gt('Timestamp');\n if (in_array('timestamp', $cols)) $column_names['timestamp'] = gt('Timestamp');\n// if (in_array('location_data', $cols)) $column_names['location_data'] = gt('Entry Point');",
" if (!empty($this->params['copy'])) {\n $f->old_id = $f->id;\n $f->id = null;\n $f->sef_url = null;\n $f->is_saved = false;\n $f->table_name = null;\n }\n $fieldlist = '[';\n if (isset($f->id)) {\n $fc = new forms_control();\n foreach ($fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly=0','rank') as $control) {\n $ctl = expUnserialize($control->data);\n $control_type = get_class($ctl);\n $def = call_user_func(array($control_type, 'getFieldDefinition'));\n if ($def != null) {\n $fields[$control->name] = $control->caption;\n if (in_array($control->name, $cols)) {\n $column_names[$control->name] = $control->caption;\n }\n }\n if ($control_type != 'pagecontrol' && $control_type != 'htmlcontrol') {\n $fieldlist .= '[\"{\\$fields[\\'' . $control->name . '\\']}\",\"' . $control->caption . '\",\"' . gt('Insert') . ' ' . $control->caption . ' ' . gt('Field') . '\"],';\n }\n }\n $fields['ip'] = gt('IP Address');\n if (in_array('ip', $cols)) $column_names['ip'] = gt('IP Address');\n $fields['user_id'] = gt('Posted by');\n if (in_array('user_id', $cols)) $column_names['user_id'] = gt('Posted by');\n $fields['timestamp'] = gt('Timestamp');\n if (in_array('timestamp', $cols)) $column_names['timestamp'] = gt('Timestamp');\n// if (in_array('location_data', $cols)) $column_names['location_data'] = gt('Entry Point');\n }\n $fieldlist .= ']';",
" assign_to_template(array(\n 'column_names' => $column_names,\n 'fields' => $fields,\n 'form' => $f,\n 'fieldlist' => $fieldlist,\n ));\n }",
" /**\n * Updates the form\n */\n public function update_form() {\n $this->forms->update($this->params);\n if (!empty($this->params['old_id'])) {\n // copy all the controls to the new form\n $fc = new forms_control();\n $controls = $fc->find('all','forms_id='.$this->params['old_id'],'rank');\n foreach ($controls as $control) {\n $control->id = null;\n $control->forms_id = $this->forms->id;\n $control->update();\n }\n }\n// if (!empty($this->params['is_saved']) && empty($this->params['table_name'])) {\n if (!empty($this->params['is_saved'])) {\n // we are now saving data to the database and need to create it first\n// $form = new forms($this->params['id']);\n $this->params['table_name'] = $this->forms->updateTable();\n// $this->params['_validate'] = false; // we don't want a check for unique sef_name\n// parent::update(); // now with a form tablename\n }\n expHistory::back();\n }",
" public function delete_form() {\n expHistory::set('editable', $this->params);\n $modelname = $this->basemodel_name;\n if (empty($this->params['id'])) {\n flash('error', gt('Missing id for the') . ' ' . $modelname . ' ' . gt('you would like to delete'));\n expHistory::back();\n }\n $form = new $modelname($this->params['id']);",
" $form->delete();\n expHistory::returnTo('manageable');\n }",
" public function design_form() {\n if (!empty($this->params['id'])) {\n expHistory::set('editable', $this->params);\n $f = new forms($this->params['id']);\n $controls = $f->forms_control;",
" $form = new fakeform();\n $form->horizontal = !empty($this->config['style']) ? $this->config['style'] : false;\n if (isset($this->params['style']))\n $form->horizontal = $this->params['style'];\n foreach ($controls as $c) {\n $ctl = expUnserialize($c->data);\n $ctl->_id = $c->id;\n $ctl->_readonly = $c->is_readonly;\n $ctl->_controltype = get_class($ctl);\n $form->register($c->name, $c->caption, $ctl);\n }",
" $types = expTemplate::listControlTypes();\n $types[\".break\"] = gt('Static - Spacer');\n $types[\".line\"] = gt('Static - Horizontal Line');\n uasort($types, \"strnatcmp\");\n if (!bs3())\n array_unshift($types, '[' . gt('Please Select' . ']'));",
" $forms_list = array();\n $forms = $f->find('all', 1);\n if (!empty($forms)) foreach ($forms as $frm) {\n if ($frm->id != $f->id)\n $forms_list[$frm->id] = $frm->title;\n }",
" assign_to_template(array(\n 'form' => $f,\n 'forms_list' => $forms_list,\n 'form_html' => $form->toHTML($f->id),\n 'backlink' => expHistory::getLastNotEditable(),\n 'types' => $types,\n 'style' => $form->horizontal\n ));\n }\n }",
" public function edit_control() {\n $f = new forms($this->params['forms_id']);\n if ($f) {\n if (bs2()) {\n expCSS::pushToHead(array(\n \"corecss\"=>\"forms-bootstrap\"\n ));\n } elseif (bs3()) {\n expCSS::pushToHead(array(\n \"corecss\"=>\"forms-bootstrap3\"\n ));\n } else {\n expCSS::pushToHead(array(\n \"corecss\" => \"forms\",\n ));\n }",
" if (isset($this->params['control_type']) && $this->params['control_type']{0} == \".\") {\n // there is nothing to edit for these type controls, so add it then return\n $htmlctl = new htmlcontrol();\n $htmlctl->identifier = uniqid(\"\");\n $htmlctl->caption = \"\";\n if (!empty($this->params['rank']))\n $htmlctl->rank = $this->params['rank'];\n switch ($this->params['control_type']) {\n case \".break\":\n $htmlctl->html = \"<br />\";\n break;\n case \".line\":\n $htmlctl->html = \"<hr size='1' />\";\n break;\n }\n $ctl = new forms_control();\n $ctl->name = uniqid(\"\");\n $ctl->caption = \"\";\n $ctl->data = serialize($htmlctl);\n $ctl->forms_id = $f->id;\n $ctl->is_readonly = 1;\n if (!empty($this->params['rank']))\n $ctl->rank = $this->params['rank'];\n $ctl->update();\n if (!expJavascript::inAjaxAction())\n expHistory::returnTo('editable');\n else { // we need a graceful exit for inAjaxAction\n assign_to_template(array(\n 'form_html' => ucfirst(substr($this->params['control_type'],1)) . ' ' . gt('control was added to form') . '<input type=\"hidden\" name=\"staticcontrol\" id=\"'.$ctl->id.'\" />',\n 'type' => 'static',\n ));\n }\n } else {\n $control_type = \"\";\n $ctl = null;\n if (isset($this->params['id'])) {\n $control = new forms_control($this->params['id']);\n if ($control) {\n $ctl = expUnserialize($control->data);\n $ctl->identifier = $control->name;\n $ctl->caption = $control->caption;\n $ctl->id = $control->id;\n $control_type = get_class($ctl);\n $f->id = $control->forms_id;\n }\n }\n if ($control_type == \"\") $control_type = $this->params['control_type'];\n $form = call_user_func(array($control_type, \"form\"), $ctl);\n $form->location($this->loc);\n if ($ctl) {\n if (isset($form->controls['identifier']->disabled)) $form->controls['identifier']->disabled = true;\n $form->meta(\"id\", $ctl->id);\n $form->meta(\"identifier\", $ctl->identifier);\n }\n $form->meta(\"action\", \"save_control\");\n// $form->meta('control_type', $control_type);\n $form->meta('forms_id', $f->id);\n $types = expTemplate::listControlTypes();\n $othertypes = expTemplate::listSimilarControlTypes($control_type);\n if (count($othertypes) > 1) {\n $otherlist = new dropdowncontrol($control_type,$othertypes);\n $form->registerBefore('identifier','control_type',gt('Control Type'),$otherlist);\n } else {\n $form->registerBefore('identifier','control_type',gt('Control Type'),new genericcontrol('hidden',$control_type));\n }\n assign_to_template(array(\n 'form_html' => $form->toHTML(),\n 'type' => $types[$control_type],\n 'is_edit' => ($ctl == null ? 0 : 1),\n ));\n }\n }\n }",
" public function save_control() {\n $f = new forms($this->params['forms_id']);\n if ($f) {\n $ctl = null;\n $control = null;\n // get previous data from existing control\n if (isset($this->params['id'])) {\n $control = new forms_control($this->params['id']);\n if ($control) {\n $ctl = expUnserialize($control->data);\n $ctl->identifier = $control->name;\n $ctl->caption = $control->caption;\n }\n } else {\n $control = new forms_control();\n }",
" // update control with data from form\n// $ctl1 = new $this->params['control_type']();\n// $ctl1 = expCore::cast($ctl1,$ctl);\n if (!empty($ctl)) {\n $ctl1 = expCore::cast($ctl,$this->params['control_type']);\n } else {\n $ctl1 = $ctl;\n }\n if (call_user_func(array($this->params['control_type'], 'useGeneric')) == true) {\n $ctl1 = call_user_func(array('genericcontrol', 'update'), $this->params, $ctl1);\n } else {\n $ctl1 = call_user_func(array($this->params['control_type'], 'update'), $this->params, $ctl1);\n }\n if (!empty($this->params['rank']))\n $ctl1->rank = $this->params['rank'];",
" //lets make sure the name submitted by the user is not a duplicate. if so we will fail back to the form\n if (!empty($control->id)) {\n //FIXME change this to an expValidator call\n $check = $control->getControl('name=\"' . $ctl1->identifier . '\" AND forms_id=' . $f->id . ' AND id != ' . $control->id);\n if (!empty($check) && empty($this->params['id'])) {\n //expValidator::failAndReturnToForm(gt('A field with the same name already exists for this form'), $_$this->params\n flash('error', gt('A field by the name\").\" \"' . $ctl1->identifier . '\" \".gt(\"already exists on this form'));\n expHistory::returnTo('editable');\n }\n }",
" if ($ctl1 != null) {\n $name = substr(preg_replace('/[^A-Za-z0-9]/', '_', $ctl1->identifier), 0, 20);\n if (!isset($this->params['id']) && $control->countControls(\"name='\" . $name . \"' AND forms_id=\" . $this->params['forms_id']) > 0) {\n $this->params['_formError'] = gt('Identifier must be unique.');\n expSession::set('last_POST', $this->params);\n } elseif ($name == 'id' || $name == 'ip' || $name == 'user_id' || $name == 'timestamp' || $name == 'location_data') {\n $this->params['_formError'] = sprintf(gt('Identifier cannot be \"%s\".'), $name);\n expSession::set('last_POST', $this->params);\n } else {\n if (!isset($this->params['id'])) {\n $control->name = $name;\n }\n $control->caption = $ctl1->caption;\n $control->forms_id = $this->params['forms_id'];\n $control->is_static = (!empty($ctl1->is_static) ? $ctl1->is_static : 0);\n if (!empty($ctl1->pattern)) $ctl1->pattern = addslashes($ctl1->pattern);\n $control->data = serialize($ctl1);",
" if (!empty($this->params['rank']))\n $control->rank = $this->params['rank'];\n if (!empty($control->id)) {\n $control->update();\n } else {\n $control->update();\n // reset summary report to all columns\n if (!$control->is_static) {\n $f->column_names_list = null;\n $f->update();\n //FIXME we also need to update any config column_names_list settings?\n }\n }\n $f->updateTable();\n }\n }\n }\n if (!expJavascript::inAjaxAction())\n expHistory::returnTo('editable');\n else {\n echo $control->id;\n }\n }",
" public function delete_control() {\n $ctl = null;\n if (isset($this->params['id'])) {\n $ctl = new forms_control($this->params['id']);\n }",
" if ($ctl) {\n $f = new forms($ctl->forms_id);\n $ctl->delete();\n $f->updateTable();\n if (!expJavascript::inAjaxAction())\n expHistory::returnTo('editable');\n }\n }",
" public function rerank_control() {\n if (!empty($this->params['id'])) {\n $fc = new forms_control($this->params['id']);\n $fc->rerank_control($this->params['rank']);\n // if we reranked a pagecontrol, we need to check/auto-correct the rank if needed\n $fc->update(array('rank'=>$this->params['rank'])); // force auto-validation of ranks\n }\n }",
" /**\n * Output a single control to an ajax request\n */\n public function build_control() {\n if (!empty($this->params['id'])) {\n $control = new forms_control($this->params['id']);\n $form = new fakeform();\n $form->horizontal = !empty($this->config['style']) ? $this->config['style'] : false;\n $ctl = expUnserialize($control->data);\n $ctl->_id = $control->id;\n $ctl->_readonly = $control->is_readonly;\n $ctl->_controltype = get_class($ctl);\n if (isset($this->params['style']))\n $form->horizontal = $this->params['style'];\n $form->register($control->name, $control->caption, $ctl);\n $form->style_form();\n echo $form->controlToHTML($control->name);\n }\n }",
" function configure() {\n $fields = array();\n $column_names = array();\n $cols = array();\n// $forms_list = array();\n// $forms = $this->forms->find('all', 1);\n// if (!empty($forms)) foreach ($forms as $form) {\n// $forms_list[$form->id] = $form->title;\n// } else {\n// $forms_list[0] = gt('You must select a form1');\n// }\n if (!empty($this->config['column_names_list'])) {\n $cols = $this->config['column_names_list'];\n }\n $fieldlist = '[';\n if (isset($this->config['forms_id'])) {\n $fc = new forms_control();\n foreach ($fc->find('all', 'forms_id=' . $this->config['forms_id'] . ' AND is_readonly=0','rank') as $control) {\n $ctl = expUnserialize($control->data);\n $control_type = get_class($ctl);\n $def = call_user_func(array($control_type, 'getFieldDefinition'));\n if ($def != null) {\n $fields[$control->name] = $control->caption;\n if (in_array($control->name, $cols)) {\n $column_names[$control->name] = $control->caption;\n }\n }\n if ($control_type != 'pagecontrol' && $control_type != 'htmlcontrol') {\n $fieldlist .= '[\"{\\$fields[\\'' . $control->name . '\\']}\",\"' . $control->caption . '\",\"' . gt('Insert') . ' ' . $control->caption . ' ' . gt('Field') . '\"],';\n }\n }\n $fields['ip'] = gt('IP Address');\n if (in_array('ip', $cols)) $column_names['ip'] = gt('IP Address');\n $fields['user_id'] = gt('Posted by');\n if (in_array('user_id', $cols)) $column_names['user_id'] = gt('Posted by');\n $fields['timestamp'] = gt('Timestamp');\n if (in_array('timestamp', $cols)) $column_names['timestamp'] = gt('Timestamp');\n// if (in_array('location_data', $cols)) $column_names['location_data'] = gt('Entry Point');\n }\n $fieldlist .= ']';\n $title = gt('No Form Assigned Yet!');\n if (!empty($this->config['forms_id'])) {\n $form = $this->forms->find('first', 'id=' . $this->config['forms_id']);\n $this->config['is_saved'] = $form->is_saved;\n $this->config['table_name'] = $form->table_name;\n $title = $form->title;\n }\n assign_to_template(array(\n// 'forms_list' => $forms_list,\n 'form_title' => $title,\n 'column_names' => $column_names,\n 'fields' => $fields,\n 'fieldlist' => $fieldlist,\n ));",
" parent::configure();\n }",
" /**\n * create a new default config array using the form defaults\n */\n private function get_defaults($form) {\n if (empty($this->config)) { // NEVER overwrite an existing config\n $this->config = array();\n $config = get_object_vars($form);\n if (!empty($config['column_names_list'])) {\n $config['column_names_list'] = explode('|!|', $config['column_names_list']); //fixme $form->column_names_list is a serialized array?\n }\n unset ($config['forms_control']);\n $this->config = $config;\n }\n }",
" /**\n * get the metainfo for this module\n *\n * @return array\n */\n function metainfo() {\n global $router;",
" if (empty($router->params['action'])) return false;\n $metainfo = array('title'=>'', 'keywords'=>'', 'description'=>'', 'canonical'=> '', 'noindex' => false, 'nofollow' => false);",
" // figure out what metadata to pass back based on the action we are in.\n switch ($router->params['action']) {\n case 'showall':\n $metainfo['title'] = gt(\"Showing Form Records\") . ' - ' . SITE_TITLE;\n $metainfo['keywords'] = SITE_KEYWORDS;\n $metainfo['description'] = SITE_DESCRIPTION;\n break;\n case 'show':\n $metainfo['title'] = gt(\"Showing Form Record\") . ' - ' . SITE_TITLE;\n $metainfo['keywords'] = SITE_KEYWORDS;\n $metainfo['description'] = SITE_DESCRIPTION;\n break;\n default:\n $metainfo = parent::metainfo();\n }\n return $metainfo;\n }",
" public function export_csv() {\n if (!empty($this->params['id'])) {\n $f = new forms($this->params['id']);\n $this->get_defaults($f); // fills $this->config with form defaults if needed\n $items = $f->getRecords();",
" $fc = new forms_control();\n //FIXME should we default to only 5 columns or all columns? and should we pick up modules columns ($this->config) or just form defaults ($f->)\n //$f->column_names_list is a serialized array\n //$this->config['column_names_list'] is an array\n if ($this->config['column_names_list'] == '') {\n //define some default columns...\n $controls = $fc->find('all', \"forms_id=\" . $f->id . \" AND is_readonly = 0 AND is_static = 0\", \"rank\");\n// foreach (array_slice($controls, 0, 5) as $control) {\n foreach ($controls as $control) {\n// if ($this->config['column_names_list'] != '')\n// $this->config['column_names_list'] .= '|!|';\n// $this->config['column_names_list'] .= $control->name;\n $this->config['column_names_list'][$control->name] = $control->name;\n }\n }",
"// $rpt_columns2 = explode(\"|!|\", $this->config['column_names_list']);",
" $rpt_columns = array();\n // popuplate field captions/labels\n foreach ($this->config['column_names_list'] as $column) {\n $control = $fc->find('first', \"forms_id=\" . $f->id . \" AND name = '\" . $column . \"' AND is_readonly = 0 AND is_static = 0\", \"rank\");\n if (!empty($control)) {\n $rpt_columns[$control->name] = $control->caption;\n } else {\n switch ($column) {\n case 'ip':\n $rpt_columns[$column] = gt('IP Address');\n break;\n case 'referrer':\n $rpt_columns[$column] = gt('Event ID');\n break;\n case 'user_id':\n $rpt_columns[$column] = gt('Posted by');\n break;\n case 'timestamp':\n $rpt_columns[$column] = gt('Timestamp');\n break;\n }\n }\n }",
" // populate field data\n foreach ($rpt_columns as $column_name=>$column_caption) {\n if ($column_name == \"ip\" || $column_name == \"referrer\" || $column_name == \"location_data\") {\n } elseif ($column_name == \"user_id\") {\n foreach ($items as $key => $item) {\n if ($item->$column_name != 0) {\n $locUser = user::getUserById($item->$column_name);\n $item->$column_name = $locUser->username;\n } else {\n $item->$column_name = '';\n }\n $items[$key] = $item;\n }\n } elseif ($column_name == \"timestamp\") {\n// $srt = $column_name . \"_srt\";\n foreach ($items as $key => $item) {\n// $item->$srt = $item->$column_name;\n $item->$column_name = strftime(\"%m/%d/%y %T\", $item->$column_name); // needs to be in a machine readable format\n $items[$key] = $item;\n }\n } else {\n $control = $fc->find('first', \"name='\" . $column_name . \"' AND forms_id=\" . $this->params['id'],'rank');\n if ($control) {\n// $ctl = unserialize($control->data);\n $ctl = expUnserialize($control->data);\n $control_type = get_class($ctl);\n// $srt = $column_name . \"_srt\";\n// $datadef = call_user_func(array($control_type, 'getFieldDefinition'));\n foreach ($items as $key => $item) {\n //We have to add special sorting for date time columns!!!\n// if (isset($datadef[DB_FIELD_TYPE]) && $datadef[DB_FIELD_TYPE] == DB_DEF_TIMESTAMP) {\n// $item->$srt = $item->$column_name;\n// }\n $item->$column_name = call_user_func(array($control_type, 'templateFormat'), $item->$column_name, $ctl);\n $items[$key] = $item;\n }\n }\n }\n }",
" if (LANG_CHARSET == 'UTF-8') {\n $file = chr(0xEF) . chr(0xBB) . chr(0xBF); // add utf-8 signature to file to open appropriately in Excel, etc...\n } else {\n $file = \"\";\n }",
" $file .= self::sql2csv($items, $rpt_columns);",
" // CREATE A TEMP FILE\n $tmpfname = tempnam(getcwd(), \"rep\"); // Rig",
" $handle = fopen($tmpfname, \"w\");\n fwrite($handle, $file);\n fclose($handle);",
" if (file_exists($tmpfname)) {",
" ob_end_clean();",
" // This code was lifted from phpMyAdmin, but this is Open Source, right?\n // 'application/octet-stream' is the registered IANA type but\n // MSIE and Opera seems to prefer 'application/octetstream'\n // It seems that other headers I've added make IE prefer octet-stream again. - RAM",
" $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octet-stream;' : 'text/comma-separated-values;';\n header('Content-Type: ' . $mime_type . ' charset=' . LANG_CHARSET . \"'\");\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n $filesize = filesize($tmpfname);\n header('Content-length: ' . $filesize);\n header('Content-Transfer-Encoding: binary');\n// header('Content-Encoding:');\n header('Content-Disposition: attachment; filename=\"report.csv\"');\n if ($filesize) header('Content-length: ' . $filesize); // for some reason the webserver cant run stat on the files and this breaks.\n // IE need specific headers\n if (EXPONENT_USER_BROWSER == 'IE') {\n header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n header('Pragma: public');\n header('Vary: User-Agent');\n } else {\n header('Pragma: no-cache');\n }\n //Read the file out directly\n readfile($tmpfname);",
"// if (DEVELOPMENT == 0) exit();\n unlink($tmpfname);\n exit();\n } else {\n error_log(\"error file doesn't exist\", 0);\n }\n }\n// expHistory::back();\n }",
" /**\n * This converts the sql statement into a nice CSV.\n * We grab the items array which is stored funkily in the DB in an associative array when we pull it.\n * So basically our aray looks like this:\n *\n * ITEMS\n * {[id]=>myID, [Name]=>name, [Address]=>myaddr}\n * {[id]=>myID1, [Name]=>name1, [Address]=>myaddr1}\n * {[id]=>myID2, [Name]=>name2, [Address]=>myaddr2}\n * {[id]=>myID3, [Name]=>name3, [Address]=>myaddr3}\n * {[id]=>myID4, [Name]=>name4, [Address]=>myaddr4}\n * {[id]=>myID5, [Name]=>name5, [Address]=>myaddr5}\n *\n * So by nature of the array, the keys are repetated in each line (id, name, etc)\n * So if we want to make a header row, we just run through once at the beginning and\n * use the array_keys function to strip out a functional header\n *\n * @param $items\n *\n * @param null $rptcols\n *\n * @return string\n */\n public static function sql2csv($items, $rptcols = null) {\n $str = \"\";\n foreach ($rptcols as $individual_Header) {\n if (!is_array($rptcols) || in_array($individual_Header, $rptcols)) $str .= $individual_Header . \",\"; //FIXME $individual_Header is ALWAYS in $rptcols?\n }\n $str .= \"\\r\\n\";\n foreach ($items as $item) {\n foreach ($rptcols as $key => $rowitem) {\n if (!is_array($rptcols) || property_exists($item, $key)) {\n $rowitem = str_replace(\",\", \" \", $item->$key);\n $str .= $rowitem . \",\";\n }\n } //foreach rowitem\n $str = substr($str, 0, strlen($str) - 1);\n $str .= \"\\r\\n\";\n } //end of foreach loop\n return $str;\n }",
" /**\n * Export form, controls and optionally the data table\n *\n */\n public function export_eql() {\n assign_to_template(array(\n \"id\" => $this->params['id'],\n ));\n }",
" /**\n * Export form, controls and optionally the data table\n *\n */\n public function export_eql_process() {\n if (!empty($this->params['id'])) {\n $f = new forms($this->params['id']);",
" $filename = preg_replace('/[^A-Za-z0-9_.-]/','-',$f->sef_url.'.eql');",
" ob_end_clean();\n ob_start(\"ob_gzhandler\");",
" // This code was lifted from phpMyAdmin, but this is Open Source, right?",
" // 'application/octet-stream' is the registered IANA type but\n // MSIE and Opera seems to prefer 'application/octetstream'\n $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';",
" header('Content-Type: ' . $mime_type);\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n // IE need specific headers\n if (EXPONENT_USER_BROWSER == 'IE') {\n header('Content-Disposition: inline; filename=\"' . $filename . '\"');\n header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n header('Pragma: public');\n } else {\n header('Content-Disposition: attachment; filename=\"' . $filename . '\"');\n header('Pragma: no-cache');\n }\n $tables = array(\n 'forms',\n 'forms_control'\n );\n if (!empty($this->params['include_data'])) {\n $tables[] = 'forms_'.$f->table_name;\n }\n echo expFile::dumpDatabase($tables, 'Form', $this->params['id']); //FIXME we need to echo inside call\n exit; // Exit, since we are exporting\n }\n// expHistory::back();\n }",
" /**\n * Import form, controls and optionally the data table\n *\n */\n public function import_eql() {\n }",
" /**\n * Import form, controls and optionally the data table\n *\n */\n public function import_eql_process() {\n $errors = array();",
" //FIXME check for duplicate form data table name before import?\n expFile::restoreDatabase($_FILES['file']['tmp_name'], $errors, 'Form');",
" if (empty($errors)) {\n flash('message',gt('Form was successfully imported'));\n } else {\n $message = gt('Form import encountered the following errors') . ':<br>';\n foreach ($errors as $error) {\n $message .= '* ' . $error . '<br>';\n }\n flash('error', $message);\n }\n expHistory::back();\n }",
" public function import_csv() {\n if (expFile::canCreate(BASE . \"tmp/test\") != SYS_FILES_SUCCESS) {\n assign_to_template(array(\n \"error\" => \"The /tmp directory is not writable. Please contact your administrator.\",\n ));\n } else {\n //Setup the arrays with the name/value pairs for the dropdown menus\n $delimiterArray = Array(\n ',' => gt('Comma'),\n ';' => gt('Semicolon'),\n ':' => gt('Colon'),\n ' ' => gt('Space'));",
" $forms = $this->forms->find('all', 1);\n $formslist = array();\n $formslist[0] = gt('--Create a New Form--');\n foreach ($forms as $aform) {\n if (!empty($aform->is_saved)) {\n $formslist[$aform->id] = $aform->title;\n if (empty($formslist[$aform->id])) $formslist[$aform->id] = gt('Untitled');\n }\n }",
"// //Setup the meta data (hidden values)\n// $form = new form();\n// $form->meta(\"controller\", \"forms\");\n// $form->meta(\"action\", \"import_csv_mapper\");\n//\n// //Register the dropdown menus\n// $form->register(\"delimiter\", gt('Delimiter Character'), new dropdowncontrol(\",\", $delimiterArray));\n// $form->register(\"upload\", gt('CSV File to Upload'), new uploadcontrol());\n// $form->register(\"use_header\", gt('First Row is a Header'), new checkboxcontrol(0, 0));\n// $form->register(\"rowstart\", gt('Forms Data begins in Row'), new textcontrol(\"1\", 1, 0, 6));\n// $form->register(\"forms_id\", gt('Target Form'), new dropdowncontrol(\"0\", $formslist));\n// $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n// \"form_html\" => $form->tohtml(),\n 'delimiters' => $delimiterArray,\n 'forms_list' => $formslist,\n ));\n }\n }",
" public function import_csv_mapper() {\n //Check to make sure the user filled out the required input.\n if (!is_numeric($this->params[\"rowstart\"])) {\n unset($this->params[\"rowstart\"]);\n $this->params['_formError'] = gt('The starting row must be a number.');\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit('Redirecting...');\n }",
" if (!empty($this->params['forms_id'])) {\n // if we are importing to an existing form, jump to that step\n $this->import_csv_data_mapper();\n } else {\n //Get the temp directory to put the uploaded file\n $directory = \"tmp\";",
" //Get the file save it to the temp directory\n if ($_FILES[\"upload\"][\"error\"] == UPLOAD_ERR_OK) {\n //\t$file = file::update(\"upload\",$directory,null,time().\"_\".$_FILES['upload']['name']);\n $file = expFile::fileUpload(\"upload\", false, false, time() . \"_\" . $_FILES['upload']['name'], $directory.'/'); //FIXME quick hack to remove file model\n if ($file == null) {\n switch ($_FILES[\"upload\"][\"error\"]) {\n case UPLOAD_ERR_INI_SIZE:\n case UPLOAD_ERR_FORM_SIZE:\n $this->params['_formError'] = gt('The file you attempted to upload is too large. Contact your system administrator if this is a problem.');\n break;\n case UPLOAD_ERR_PARTIAL:\n $this->params['_formError'] = gt('The file was only partially uploaded.');\n break;\n case UPLOAD_ERR_NO_FILE:\n $this->params['_formError'] = gt('No file was uploaded.');\n break;\n default:\n $this->params['_formError'] = gt('A strange internal error has occurred. Please contact the Exponent Developers.');\n break;\n }\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n }\n /*\n if (mime_content_type(BASE.$directory.\"/\".$file->filename) != \"text/plain\"){\n $this->params['_formError'] = \"File is not a delimited text file.\";\n expSession::set(\"last_POST\",$this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n */",
" //split the line into its columns\n $headerinfo = null;\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $fh = fopen(BASE . $directory . \"/\" . $file->filename, \"r\");\n if (!empty($this->params[\"use_header\"])) $this->params[\"rowstart\"]++;\n for ($x = 0; $x < $this->params[\"rowstart\"]; $x++) {\n $lineInfo = fgetcsv($fh, 2000, $this->params[\"delimiter\"]);\n if ($x == 0 && !empty($this->params[\"use_header\"])) $headerinfo = $lineInfo;\n }\n fclose($fh);\n ini_set('auto_detect_line_endings',$line_end);",
" // get list of simple non-static controls if we are also creating a new form\n $types = expTemplate::listControlTypes(false);\n uasort($types, \"strnatcmp\");\n $types = array_merge(array('none'=>gt('--Disregard this column--')),$types);",
" //Check to see if the line got split, otherwise throw an error\n if ($lineInfo == null) {\n $this->params['_formError'] = sprintf(gt('This file does not appear to be delimited by \"%s\". <br />Please specify a different delimiter.<br /><br />'), $this->params[\"delimiter\"]);\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n } else {\n //Setup the meta data (hidden values)\n $form = new form();\n $form->meta(\"controller\", \"forms\");\n $form->meta(\"action\", \"import_csv_form_prep\"); // we are creating a new form first\n // $form->meta(\"action\", \"import_csv_data\"); // we are importing into an existing form //FIXME\n $form->meta(\"delimiter\", $this->params[\"delimiter\"]);\n $form->meta(\"filename\", $directory . \"/\" . $file->filename);\n $form->meta(\"use_header\", $this->params[\"use_header\"]);\n $form->meta(\"rowstart\", $this->params[\"rowstart\"]);\n for ($i = 0, $iMax = count($lineInfo); $i < $iMax; $i++) {\n if ($headerinfo != null) {\n $title = $headerinfo[$i] . ' (' . $lineInfo[$i] .')';\n // $label = str_replace('&', 'and', $headerinfo[$i]);\n // $label = preg_replace(\"/(-)$/\", \"\", preg_replace('/(-){2,}/', '-', strtolower(preg_replace(\"/([^0-9a-z-_\\+])/i\", '-', $label))));\n // $form->register(\"name[$i]\", null, new genericcontrol('hidden',$label));\n $form->register(\"name[$i]\", null, new genericcontrol('hidden',$headerinfo[$i]));\n } else {\n $form->register(\"name[$i]\", null, new genericcontrol('hidden','Field'.$i));\n $title = $lineInfo[$i];\n }\n $form->register(\"data[$i]\", null, new genericcontrol('hidden',$lineInfo[$i]));\n $form->register(\"control[$i]\", $title, new dropdowncontrol(\"none\", $types));\n }\n $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n \"form_html\" => $form->tohtml(),\n ));\n }\n }\n }",
" public function import_csv_form_prep() {\n $form = new form();\n $form->meta(\"controller\", \"forms\");\n $form->meta(\"action\", \"import_csv_form_add\");\n $form->meta(\"delimiter\", $this->params[\"delimiter\"]);\n $form->meta(\"filename\", $this->params[\"filename\"]);\n $form->meta(\"use_header\", $this->params[\"use_header\"]);\n $form->meta(\"rowstart\", $this->params[\"rowstart\"]);",
" // condense our responses to present form shell for confirmation\n $form->register(\"title\", gt('Form Title'), new textcontrol(''));\n $formcontrols = array();\n foreach ($this->params['control'] as $key=>$control) {\n if ($control != \"none\") {\n $formcontrols[$key] = new stdClass();\n $formcontrols[$key]->control = $control;\n $label = str_replace('&', 'and', $this->params['name'][$key]);\n $label = preg_replace(\"/(-)$/\", \"\", preg_replace('/(-){2,}/', '_', strtolower(preg_replace(\"/([^0-9a-z-_\\+])/i\", '_', $label))));\n $formcontrols[$key]->name = $label;\n $formcontrols[$key]->caption = $this->params['name'][$key];\n $formcontrols[$key]->data = $this->params['data'][$key];\n }\n }",
" foreach ($formcontrols as $i=>$control) {\n $form->register(\"column[$i]\", ucfirst($control->control) . ' ' . gt('Field Identifier') . ' (' . $control->caption . ' - ' . $control->data . ')', new textcontrol($control->name));\n $form->register(\"control[$i]\", null, new genericcontrol('hidden',$control->control));\n $form->register(\"caption[$i]\", null, new genericcontrol('hidden',$control->caption));\n $form->register(\"data[$i]\", null, new genericcontrol('hidden',$control->data));\n }",
" $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n \"form_html\" => $form->tohtml(),\n ));\n }",
" public function import_csv_form_add() {",
" // create the form\n $f = new forms();\n $f->title = $this->params['title'];\n $f->is_saved = true;\n $f->update();",
" // create the form controls\n foreach ($this->params['control'] as $key=>$control) {\n $params = array();\n $fc = new forms_control();\n $this->params['column'][$key] = str_replace('&', 'and', $this->params['column'][$key]);\n $this->params['column'][$key] = preg_replace(\"/(-)$/\", \"\", preg_replace('/(-){2,}/', '-', strtolower(preg_replace(\"/([^0-9a-z-_\\+])/i\", '-', $this->params['column'][$key]))));\n $fc->name = $params['identifier'] = $this->params['column'][$key];\n $fc->caption = $params['caption'] = $this->params['caption'][$key];\n $params['description'] = '';\n if ($control == 'datetimecontrol') {\n $params['showdate'] = $params['showtime'] = true;\n }\n// if ($control == 'htmlcontrol') {\n// $params['html'] = $this->params['data'][$key];\n// }\n if ($control == 'radiogroupcontrol' || $control == 'dropdowncontrol') {\n $params['default'] = $params['items'] = $this->params['data'][$key];\n }\n $fc->forms_id = $f->id;\n $ctl = null;\n $ctl = call_user_func(array($control, 'update'), $params, $ctl);\n $fc->data = serialize($ctl);\n $fc->update();\n }",
" flash('notice', gt('New Form Created'));\n $this->params['forms_id'] = $f->id;\n// unset($this->params['caption']);\n unset($this->params['control']);\n $this->import_csv_data_display();\n }",
" public function import_csv_data_mapper() {\n// global $template;\n //Get the temp directory to put the uploaded file\n $directory = \"tmp\";",
" //Get the file save it to the temp directory\n if ($_FILES[\"upload\"][\"error\"] == UPLOAD_ERR_OK) {\n //\t$file = file::update(\"upload\",$directory,null,time().\"_\".$_FILES['upload']['name']);\n $file = expFile::fileUpload(\"upload\", false, false, time() . \"_\" . $_FILES['upload']['name'], $directory.'/'); //FIXME quick hack to remove file model\n if ($file == null) {\n switch ($_FILES[\"upload\"][\"error\"]) {\n case UPLOAD_ERR_INI_SIZE:\n case UPLOAD_ERR_FORM_SIZE:\n $this->params['_formError'] = gt('The file you attempted to upload is too large. Contact your system administrator if this is a problem.');\n break;\n case UPLOAD_ERR_PARTIAL:\n $this->params['_formError'] = gt('The file was only partially uploaded.');\n break;\n case UPLOAD_ERR_NO_FILE:\n $this->params['_formError'] = gt('No file was uploaded.');\n break;\n default:\n $this->params['_formError'] = gt('A strange internal error has occurred. Please contact the Exponent Developers.');\n break;\n }\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n }\n /*\n if (mime_content_type(BASE.$directory.\"/\".$file->filename) != \"text/plain\"){\n $this->params['_formError'] = \"File is not a delimited text file.\";\n expSession::set(\"last_POST\",$this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n */",
" //split the line into its columns\n $headerinfo = null;\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $fh = fopen(BASE . $directory . \"/\" . $file->filename, \"r\");\n if (!empty($this->params[\"use_header\"])) $this->params[\"rowstart\"]++;\n for ($x = 0; $x < $this->params[\"rowstart\"]; $x++) {\n $lineInfo = fgetcsv($fh, 2000, $this->params[\"delimiter\"]);\n if ($x == 0 && !empty($this->params[\"use_header\"])) $headerinfo = $lineInfo;\n }\n fclose($fh);\n ini_set('auto_detect_line_endings',$line_end);",
" // pull in the form control definitions here\n $f = new forms($this->params['forms_id']);\n $fields = array(\n \"none\" => gt('--Disregard this column--'),\n );\n foreach ($f->forms_control as $control) {\n $fields[$control->name] = $control->caption;\n }",
" //Check to see if the line got split, otherwise throw an error\n if ($lineInfo == null) {\n $this->params['_formError'] = sprintf(gt('This file does not appear to be delimited by \"%s\". <br />Please specify a different delimiter.<br /><br />'), $this->params[\"delimiter\"]);\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n } else {\n //Setup the meta data (hidden values)\n $form = new form();\n $form->meta(\"controller\", \"forms\");\n $form->meta(\"action\", \"import_csv_data_display\");\n $form->meta(\"rowstart\", $this->params[\"rowstart\"]);\n $form->meta(\"use_header\", $this->params[\"use_header\"]);\n $form->meta(\"filename\", $directory . \"/\" . $file->filename);\n $form->meta(\"delimiter\", $this->params[\"delimiter\"]);\n $form->meta(\"forms_id\", $this->params[\"forms_id\"]);",
" for ($i = 0, $iMax = count($lineInfo); $i < $iMax; $i++) {\n if ($headerinfo != null) {\n $title = $headerinfo[$i] . ' (' . $lineInfo[$i] .')';\n } else {\n $title = $lineInfo[$i];\n }\n $form->register(\"column[$i]\", $title, new dropdowncontrol(\"none\", $fields));\n }\n $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n \"form_html\" => $form->tohtml(),\n ));\n }\n }",
" public function import_csv_data_display() {\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $file = fopen(BASE . $this->params[\"filename\"], \"r\");\n $record = array();\n $records = array();\n $linenum = 1;",
" // pull in the form control definitions here\n $f = new forms($this->params['forms_id']);\n $fields = array();\n foreach ($f->forms_control as $control) {\n $fields[$control->name] = $control->caption;\n }",
" while (($filedata = fgetcsv($file, 2000, $this->params[\"delimiter\"])) != false) {\n if ($linenum >= $this->params[\"rowstart\"]) {\n $i = 0;\n foreach ($filedata as $field) {\n if (!empty($this->params[\"column\"][$i]) && $this->params[\"column\"][$i] != \"none\") {\n $colname = $this->params[\"column\"][$i];\n $record[$colname] = trim($field);\n $this->params['caption'][$i] = $fields[$colname];\n } else {\n unset($this->params['column'][$i]);\n }\n $i++;\n }\n $record['linenum'] = $linenum;\n $records[] = $record;\n }\n $linenum++;\n }\n fclose($file);\n ini_set('auto_detect_line_endings',$line_end);",
" assign_to_template(array(\n \"records\" => $records,\n \"params\" => $this->params,\n ));\n }",
" public function import_csv_data_add() {\n global $user;\n",
"",
" $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $file = fopen(BASE . $this->params[\"filename\"], \"r\");\n $recordsdone = 0;\n $linenum = 1;\n $f = new forms($this->params['forms_id']);\n $f->updateTable();",
" $fields = array();\n $multi_item_control_items = array();\n $multi_item_control_ids = array();\n foreach ($f->forms_control as $control) {\n $fields[$control->name] = expUnserialize($control->data);\n $ctltype = get_class($fields[$control->name]);\n if (in_array($ctltype,array('radiogroupcontrol','dropdowncontrol'))) {\n if (!array_key_exists($control->id,$multi_item_control_items)) {\n $multi_item_control_items[$control->name] = null;\n $multi_item_control_ids[$control->name] = $control->id;\n }\n }\n }",
" while (($filedata = fgetcsv($file, 2000, $this->params[\"delimiter\"])) != false) {\n if ($linenum >= $this->params[\"rowstart\"] && in_array($linenum,$this->params['importrecord'])) {\n $i = 0;\n $db_data = new stdClass();\n $db_data->ip = '';\n $db_data->user_id = $user->id;\n $db_data->timestamp = time();\n $db_data->referrer = '';\n $db_data->location_data = '';\n foreach ($filedata as $field) {\n if (!empty($this->params[\"column\"][$i]) && $this->params[\"column\"][$i] != \"none\") {\n $colname = $this->params[\"column\"][$i];\n $control_type = get_class($fields[$colname]);\n $params[$colname] = $field;\n $def = call_user_func(array($control_type, \"getFieldDefinition\"));\n if (!empty($def)) {\n $db_data->$colname = call_user_func(array($control_type, 'convertData'), $colname, $params);\n }\n if (!empty($db_data->$colname) && array_key_exists($colname,$multi_item_control_items) && !in_array($db_data->$colname,$multi_item_control_items[$colname])) {\n $multi_item_control_items[$colname][] = $db_data->$colname;\n }\n }\n $i++;\n }\n $f->insertRecord($db_data);\n $recordsdone++;\n }\n $linenum++;\n }",
" fclose($file);\n ini_set('auto_detect_line_endings',$line_end);",
" // update multi-item forms controls\n if (!empty($multi_item_control_ids)) {\n foreach ($multi_item_control_ids as $key=>$control_id) {\n $fc = new forms_control($control_id);\n $ctl = expUnserialize($fc->data);\n $ctl->items = $multi_item_control_items[$key];\n $fc->data = serialize($ctl);\n $fc->update();\n }\n }\n unlink(BASE . $this->params[\"filename\"]);\n flash('notice', $recordsdone.' '.gt('Records Imported'));\n expHistory::back();\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class formsController extends expController {\n public $useractions = array(\n 'enterdata' => 'Input Records',\n 'showall' => 'Show All Records',\n 'show' => 'Show a Single Record',\n );",
" protected $add_permissions = array(\n 'viewdata' => \"View Data\",\n 'enter_data' => \"Enter Data\", // slight naming variation to not fully restrict enterdata method\n );\n protected $manage_permissions = array(\n 'design' => 'Design Form',\n );",
" public $remove_configs = array(\n 'aggregation',\n 'categories',\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n// 'pagination',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
"",
"// public $codequality = 'beta';",
" static function displayname() {\n return gt(\"Forms\");\n }",
" static function description() {\n return gt(\"Allows the creation of forms that can be emailed, or even viewed if they are optionally stored in the database\");\n }",
" static function author() {\n return \"Dave Leffler\";\n }",
" static function isSearchable() {\n return false;\n }",
" function searchName() {\n return gt(\"Forms\");\n }",
" function searchCategory() {\n return gt('Form Data');\n }",
" static function requiresConfiguration()\n {\n return true;\n }",
" public function showall() {\n if ((!empty($this->config['unrestrict_view']) || expPermissions::check('viewdata', $this->loc))) {\n expHistory::set('viewable', $this->params);\n $f = null;\n if (!empty($this->config)) {\n $f = $this->forms->find('first', 'id=' . $this->config['forms_id']);\n } elseif (!empty($this->params['title'])) {",
" $f = $this->forms->find('first', 'sef_url=\"' . expString::escape($this->params['title']) . '\"');",
" $this->get_defaults($f);\n } elseif (!empty($this->params['id'])) {\n $f = $this->forms->find('first', 'id=' . $this->params['id']);\n $this->get_defaults($f);\n }",
" if (!empty($f)) {\n if (empty($this->config['report_filter']) && empty($this->params['filter'])) { // allow for param of 'filter' also\n $where = '1';\n } elseif (!empty($this->params['filter'])) {",
" $where = expString::escape($this->params['filter']);",
" } else {\n $where = $this->config['report_filter'];\n }\n $fc = new forms_control();\n if (empty($this->config['column_names_list'])) {\n //define some default columns...\n $controls = $fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly=0 AND is_static = 0', 'rank');\n foreach (array_slice($controls, 0, 5) as $control) { // default to only first 5 columns\n $this->config['column_names_list'][] = $control->name;\n }\n }",
" // pre-process records\n $items = $f->selectRecordsArray($where);\n $columns = array();\n foreach ($this->config['column_names_list'] as $column_name) {\n if ($column_name == \"ip\") {\n// $columns[gt('IP Address')] = 'ip';\n $columns['ip'] = gt('IP Address');\n } elseif ($column_name == \"referrer\") {\n// $columns[gt('Referrer')] = 'referrer';\n $columns['referrer'] = gt('Referrer');\n } elseif ($column_name == \"location_data\") {\n// $columns[gt('Entry Point')] = 'location_data';\n $columns['location_data'] = gt('Entry Point');\n } elseif ($column_name == \"user_id\") {\n foreach ($items as $key => $item) {\n if ($item[$column_name] != 0) {\n $locUser = user::getUserById($item[$column_name]);\n $item[$column_name] = $locUser->username;\n } else {\n $item[$column_name] = '';\n }\n $items[$key] = $item;\n }\n// $columns[gt('Posted by')] = 'user_id';\n $columns['user_id'] = gt('Posted by');\n } elseif ($column_name == \"timestamp\") {\n foreach ($items as $key => $item) {\n $item[$column_name] = strftime(DISPLAY_DATETIME_FORMAT, $item[$column_name]);\n $items[$key] = $item;\n }\n// $columns[gt('Timestamp')] = 'timestamp';\n $columns['timestamp'] = gt('Timestamp');\n } else {\n $control = $fc->find('first', \"name='\" . $column_name . \"' AND forms_id=\" . $f->id, 'rank');\n if ($control) {\n $ctl = expUnserialize($control->data);\n $control_type = get_class($ctl);\n foreach ($items as $key => $item) {\n //We have to add special sorting for date time columns!!!\n $item[$column_name] = @call_user_func(\n array($control_type, 'templateFormat'),\n $item[$column_name],\n $ctl\n );\n $items[$key] = $item;\n }\n// $columns[$control->caption] = $column_name;\n $columns[$column_name] = $control->caption;\n }\n }\n }",
" $page = new expPaginator(\n array(\n 'records' => $items,\n 'where' => 1,\n// 'limit' => (isset($this->params['limit']) && $this->params['limit'] != '') ? $this->params['limit'] : 10,\n 'order' => (isset($this->params['order']) && $this->params['order'] != '') ? $this->params['order'] : (!empty($this->config['order']) ? $this->config['order'] : 'id'),\n 'dir' => (isset($this->params['dir']) && $this->params['dir'] != '') ? $this->params['dir'] : 'ASC',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n 'src' => $this->loc->src,\n 'columns' => $columns\n )\n );",
" assign_to_template(\n array(\n// \"backlink\" => expHistory::getLastNotEditable(),\n \"backlink\" => expHistory::getLast('viewable'),\n \"f\" => $f,\n \"page\" => $page,\n \"title\" => !empty($this->config['report_name']) ? $this->config['report_name'] : '',\n \"description\" => !empty($this->config['report_desc']) ? $this->config['report_desc'] : null,\n \"filtered\" => !empty($this->config['report_filter']) ? $this->config['report_filter'] : ''\n )\n );\n }\n } else {\n assign_to_template(array(\n \"error\" => 1,\n ));\n }\n }",
" public function show() {\n if (!empty($this->config['unrestrict_view']) || expPermissions::check('viewdata', $this->loc)) {\n expHistory::set('viewable', $this->params);\n $f = null;\n if (!empty($this->config)) {\n $f = $this->forms->find('first', 'id=' . $this->config['forms_id']);\n } elseif (!empty($this->params['forms_id'])) {\n $f = $this->forms->find('first', 'id=' . $this->params['forms_id']);\n } elseif (!empty($this->params['title'])) {",
" $f = $this->forms->find('first', 'sef_url=\"' . expString::escape($this->params['title']) . '\"');",
" redirect_to(array('controller' => 'forms', 'action' => 'enterdata', 'forms_id' => $f->id));\n }",
" if (!empty($f)) {\n $fc = new forms_control();\n $controls = $fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly=0 AND is_static = 0', 'rank');\n $id = !empty($this->params['id']) ? $this->params['id'] : null;\n $data = $f->getRecord($id);",
" $fields = array();\n $captions = array();\n if ($controls && $data) {\n foreach ($controls as $c) {\n $ctl = expUnserialize($c->data);\n $control_type = get_class($ctl);\n $name = $c->name;\n $fields[$name] = call_user_func(array($control_type, 'templateFormat'), $data->$name, $ctl);\n $captions[$name] = $c->caption;\n }",
" // system added fields\n $captions['ip'] = gt('IP Address');\n $captions['timestamp'] = gt('Timestamp');\n $captions['user_id'] = gt('Posted by');\n $fields['ip'] = $data->ip;\n $fields['timestamp'] = strftime(DISPLAY_DATETIME_FORMAT, $data->timestamp);\n $locUser = user::getUserById($data->user_id);\n $fields['user_id'] = !empty($locUser->username) ? $locUser->username : '';",
" // add a browse other records (next/prev) feature here\n $field = !empty($this->config['order']) ? $this->config['order'] : 'id';\n $data->next = $f->getRecord($field . ' > ' . $data->$field . ' ORDER BY ' . $field);\n if (!empty($data->next) && $data->next != $data->id) {\n assign_to_template(\n array(\n \"next\" => $data->next,\n )\n );\n }\n $data->prev = $f->getRecord($field . ' < ' . $data->$field . ' ORDER BY ' . $field . ' DESC');\n if (!empty($data->prev) && $data->prev != $data->id) {\n assign_to_template(\n array(\n \"prev\" => $data->prev,\n )\n );\n }\n }",
" $count = $f->countRecords();\n assign_to_template(\n array(\n // \"backlink\"=>expHistory::getLastNotEditable(),\n // 'backlink' => expHistory::getLast('editable'),\n 'backlink' => makeLink(expHistory::getBack(1)),\n \"f\" => $f,\n // \"record_id\" => $this->params['id'],\n \"record_id\" => !empty($data->id) ? $data->id : null,\n \"title\" => !empty($this->config['report_name']) ? $this->config['report_name'] : gt(\n 'Viewing Record'\n ),\n \"description\" => !empty($this->config['report_desc']) ? $this->config['report_desc'] : null,\n 'fields' => $fields,\n 'captions' => $captions,\n \"count\" => $count,\n 'is_email' => 0,\n \"css\" => file_get_contents(BASE . \"framework/core/assets/css/tables.css\"),\n )\n );\n }\n } else {\n assign_to_template(array(\n \"error\" => 1,\n ));\n }\n }",
" public function enter_data() {\n $this->enterdata();\n }",
" public function enterdata() {\n if (empty($this->config['restrict_enter']) || expPermissions::check('enterdata', $this->loc)) {",
" global $user;",
" expHistory::set('viewable', $this->params);\n $f = null;\n if (!empty($this->config)) {\n $f = $this->forms->find('first', 'id=' . $this->config['forms_id']);\n } elseif (!empty($this->params['forms_id'])) {\n $f = $this->forms->find('first', 'id=' . $this->params['forms_id']);\n $this->get_defaults($f);\n }",
" if (!empty($f)) {\n $form = new form();\n $form->id = $f->sef_url;\n $form->horizontal = !empty($this->config['style']);\n if (!empty($this->params['id'])) {\n $fc = new forms_control();\n $controls = $fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly = 0 AND is_static = 0','rank');\n $data = $f->getRecord($this->params['id']);\n } else {\n if (!empty($f->forms_control)) {\n $controls = $f->forms_control;\n } else {\n $controls = array();\n }\n $data = expSession::get('forms_data_' . $f->id);\n }\n // display list of email addresses\n if (!empty($this->config['select_email'])) {\n //Building Email List...\n $emaillist = array();\n if (!empty($this->config['user_list'])) foreach ($this->config['user_list'] as $c) {\n $u = user::getUserById($c);\n if (!empty($u->email)) {\n if (!empty($u->firstname) || !empty($u->lastname)) {\n $title = $u->firstname . ' ' . $u->lastname . ' ('. $u->email . ')';\n } else {\n $title = $u->username . ' ('. $u->email . ')';\n }\n $emaillist[$u->email] = $title;\n }\n }\n if (!empty($this->config['group_list'])) foreach ($this->config['group_list'] as $c) {\n// $grpusers = group::getUsersInGroup($c);\n// foreach ($grpusers as $u) {\n// $emaillist[] = $u->email;\n// }\n $g = group::getGroupById($c);\n $emaillist[$c] = $g->name;\n }\n if (!empty($this->config['address_list'])) foreach ($this->config['address_list'] as $c) {\n $emaillist[$c] = $c;\n }\n //This is an easy way to remove duplicates\n $emaillist = array_flip(array_flip($emaillist));\n $emaillist = array_map('trim', $emaillist);\n $emaillist = array_reverse($emaillist, true);\n if (empty($this->config['select_exclude_all']))\n $emaillist[0] = gt('All Addresses');\n $emaillist = array_reverse($emaillist, true);\n if (!empty($this->config['select_dropdown']))\n $form->register('email_dest', gt('Send Response to'), new dropdowncontrol('', $emaillist));\n else\n $form->register('email_dest', gt('Send Response to'), new radiogroupcontrol('', $emaillist));\n }\n// $paged = false;\n foreach ($controls as $key=>$c) {\n $ctl = expUnserialize($c->data);\n $ctl->_id = $c->id;\n $ctl->_readonly = $c->is_readonly;\n $ctl->_ishidden = !empty($ctl->is_hidden) && empty($this->params['id']); // hide it if entering new data\n if (!empty($this->params['id'])) {\n if ($c->is_readonly == 0) {\n $name = $c->name;\n if ($c->is_static == 0) {\n $ctl->default = $data->$name;\n }\n }\n } else {\n if (!empty($data[$c->name])) $ctl->default = $data[$c->name];\n }\n if ($key == 0) $ctl->focus = true; // first control gets the focus\n $form->register($c->name, $c->caption, $ctl);\n// if (get_class($ctl) == 'pagecontrol') $paged = true;\n }",
" // if we are editing an existing record we'll need to do recaptcha here since we won't call confirm_data\n if (!empty($this->params['id'])) {\n $antispam = '';\n if (SITE_USE_ANTI_SPAM && ANTI_SPAM_CONTROL == 'recaptcha') {\n // make sure we have the proper config.\n if (!defined('RECAPTCHA_PUB_KEY')) {\n $antispam .= '<h2 style=\"color:red\">' . gt('reCaptcha configuration is missing the public key.') . '</h2>';\n }\n if ($user->isLoggedIn() && ANTI_SPAM_USERS_SKIP == 1) {\n // skip it for logged on users based on config\n } else {\n // include the library and show the form control\n require_once(BASE . 'external/ReCaptcha/autoload.php'); //FIXME not sure we need this here\n $re_theme = (RECAPTCHA_THEME == 'dark') ? 'dark' : 'light';\n $antispam .= '<input type=\"hidden\" class=\"hiddenRecaptcha required\" name=\"hiddenRecaptcha\" id=\"hiddenRecaptcha\">';\n $antispam .= '<div class=\"g-recaptcha\" data-sitekey=\"' . RECAPTCHA_PUB_KEY . '\" data-theme=\"' . $re_theme . '\"></div>';\n $antispam .= '<script type=\"text/javascript\" src=\"https://www.google.com/recaptcha/api.js?hl=' . LOCALE . '\" async defer></script>';\n $antispam .= '<p>' . gt('Fill out the above security question to submit your form.') . '</p>';\n }\n }\n $form->register(uniqid(''), '', new htmlcontrol($antispam));\n }",
" if (empty($this->config['submitbtn'])) $this->config['submitbtn'] = gt('Submit');\n if (!empty($this->params['id'])) {\n $cancel = gt('Cancel');\n $form->meta('action', 'submit_data');\n $form->meta('isedit', 1);\n $form->meta('data_id', $data->id);\n $form->location($this->loc);\n assign_to_template(array(\n 'edit_mode' => 1,\n ));\n } else {\n $cancel = '';\n $form->meta(\"action\", \"confirm_data\");\n }\n if (empty($this->config['submitbtn'])) $this->config['submitbtn'] = gt('Submit');\n if (empty($this->config['resetbtn'])) $this->config['resetbtn'] = '';\n $form->register(\"submit\", \"\", new buttongroupcontrol($this->config['submitbtn'], $this->config['resetbtn'], $cancel, 'finish'));",
" $form->meta(\"m\", $this->loc->mod);\n $form->meta(\"s\", $this->loc->src);\n $form->meta(\"i\", $this->loc->int);\n $form->meta(\"id\", $f->id);\n $formmsg = '';\n $form->location(expCore::makeLocation(\"forms\", $this->loc->src, $this->loc->int));\n if (count($controls) == 0) {\n $form->controls['submit']->disabled = true;\n $formmsg .= gt('This form is blank. Select \"Design Form\" to add input fields.') . '<br>';\n } elseif (empty($f->is_saved) && empty($this->config['is_email'])) {\n $form->controls['submit']->disabled = true;\n $formmsg .= gt('There are no actions assigned to this form. Select \"Configure Settings\" then either select \"Email Form Data\" and/or \"Save Submissions to Database\".');\n }\n $count = $f->countRecords();\n if ($formmsg) {\n flash('notice', $formmsg);\n }\n if (empty($this->config['description'])) $this->config['description'] = '';\n assign_to_template(array(\n \"description\" => $this->config['description'],\n \"form_html\" => $form->toHTML(),\n \"form\" => $f,\n \"count\" => $count,\n// 'paged' => $paged,\n ));\n }\n } else {\n assign_to_template(array(\n \"error\" => 1,\n ));\n }\n }",
" public function confirm_data() {\n $f = new forms($this->params['id']);\n $cols = $f->forms_control;\n $counts = array();\n $responses = array();\n $captions = array();",
" foreach ($cols as $col) {\n $newupload = false;\n $coldef = expUnserialize($col->data);\n $coldata = new ReflectionClass($coldef);\n if (empty($coldef->is_hidden)) {\n $coltype = $coldata->getName();\n if ($coltype == 'uploadcontrol' && !empty($_FILES)) {\n $newupload = true;\n $value = call_user_func(array($coltype, 'parseData'), $col->name, $_FILES, true);\n } else {\n $value = call_user_func(array($coltype, 'parseData'), $col->name, $this->params, true);\n }\n $value = call_user_func(array($coltype, 'templateFormat'), $value, $coldef); // convert parsed value to user readable\n //eDebug($value);\n// $counts[$col->caption] = isset($counts[$col->caption]) ? $counts[$col->caption] + 1 : 1;\n// $num = $counts[$col->caption] > 1 ? $counts[$col->caption] : '';",
" if (!empty($this->params[$col->name])) {\n// if ($coltype == 'checkboxcontrol') {\n// $responses[$col->caption . $num] = gt('Yes');\n// } else {\n// $responses[$col->caption . $num] = $value;\n $responses[$col->name] = $value;\n $captions[$col->name] = $col->caption;\n// }\n } else {\n if ($coltype == 'checkboxcontrol') {\n// $responses[$col->caption . $num] = gt('No');\n $responses[$col->name] = gt('No');\n $captions[$col->name] = $col->caption;\n } elseif ($coltype == 'datetimecontrol' || $coltype == 'calendarcontrol') {\n// $responses[$col->name] = $value;\n $responses[$col->name] = $value;\n $captions[$col->name] = $col->caption;\n } elseif ($coltype == 'uploadcontrol') {\n if ($newupload) {\n $this->params[$col->name] = PATH_RELATIVE . call_user_func(\n array($coltype, 'moveFile'),\n $col->name,\n $_FILES,\n true\n );\n }\n // $value = call_user_func(array($coltype,'buildDownloadLink'),$this->params[$col->name],$_FILES[$col->name]['name'],true);\n //eDebug($value);\n// $responses[$col->caption . $num] = $_FILES[$col->name]['name'];\n// $responses[$col->name] = $_FILES[$col->name]['name'];\n// $responses[$col->name] = $this->params[$col->name];\n $responses[$col->name] = call_user_func(array($coltype, 'templateFormat'), $this->params[$col->name], null); // convert parsed value to user readable\n $captions[$col->name] = $col->caption;\n } elseif ($coltype != 'htmlcontrol' && $coltype != 'pagecontrol') {\n// $responses[$col->caption . $num] = '';\n $responses[$col->name] = '';\n $captions[$col->name] = $col->caption;\n }\n }\n }\n }",
" // remove some post data we don't want to pass thru to the form\n unset(\n $this->params['controller'],\n $this->params['action'],\n $this->params['view']\n );\n foreach ($this->params as $k => $v) {\n // $this->params[$k]=htmlentities(htmlspecialchars($v,ENT_COMPAT,LANG_CHARSET));\n $this->params[$k] = htmlspecialchars($v, ENT_COMPAT, LANG_CHARSET);\n }\n expSession::set('forms_data_' . $this->params['id'], $this->params);",
" assign_to_template(array(\n 'responses' => $responses,\n 'captions' => $captions,\n 'postdata' => $this->params,\n ));\n }",
" public function submit_data() {\n // Check for form errors\n $this->params['manual_redirect'] = true;\n if (!expValidator::check_antispam($this->params)) {\n flash('error', gt('Security Validation Failed'));\n expHistory::back();\n }",
" global $db, $user;\n $f = new forms($this->params['id']);\n $fc = new forms_control();\n $controls = $fc->find('all', \"forms_id=\" . $f->id . \" AND is_readonly=0\",'rank');\n $this->get_defaults($f);",
" $db_data = new stdClass();\n $emailFields = array();\n $captions = array();\n $attachments = array();\n foreach ($controls as $c) {\n $ctl = expUnserialize($c->data);\n $control_type = get_class($ctl);\n $def = call_user_func(array($control_type, \"getFieldDefinition\"));\n if ($def != null) {\n $emailValue = htmlspecialchars_decode(call_user_func(array($control_type, 'parseData'), $c->name, $this->params, true));\n $value = stripslashes(expString::escape($emailValue));",
" //eDebug($value);\n $varname = $c->name;\n $db_data->$varname = $value;\n // $fields[$c->name] = call_user_func(array($control_type,'templateFormat'),$value,$ctl);\n if (!$ctl->is_hidden) {\n $emailFields[$c->name] = call_user_func(array($control_type, 'templateFormat'), $value, $ctl);\n $captions[$c->name] = $c->caption;\n if (strtolower($c->name) == \"email\" && expValidator::isValidEmail($value)) {\n $from = $value;\n }\n if (strtolower($c->name) == \"name\") {\n $from_name = $value;\n }\n if (get_class($ctl) == 'uploadcontrol') {\n $attachments[] = htmlspecialchars_decode($this->params[$c->name]);\n }\n }\n }\n }",
" if (!isset($this->params['data_id']) || (isset($this->params['data_id']) && expPermissions::check(\"editdata\", $f->loc))) {\n if (!empty($f->is_saved)) {\n if (isset($this->params['data_id'])) {\n //if this is an edit we remove the record and insert a new one.\n $olddata = $f->getRecord($this->params['data_id']);\n $db_data->ip = $olddata->ip;\n $db_data->user_id = $olddata->user_id;\n $db_data->timestamp = $olddata->timestamp;\n $db_data->referrer = $olddata->referrer;\n $db_data->location_data = $olddata->location_data;\n $f->deleteRecord($this->params['data_id']);\n } else {\n $db_data->ip = $_SERVER['REMOTE_ADDR'];\n if (expSession::loggedIn()) {\n $db_data->user_id = $user->id;\n $from = $user->email;\n $from_name = $user->firstname . \" \" . $user->lastname . \" (\" . $user->username . \")\";\n } else {\n $db_data->user_id = 0;\n }\n $db_data->timestamp = time();\n $referrer = $db->selectValue(\"sessionticket\", \"referrer\", \"ticket = '\" . expSession::getTicketString() . \"'\");\n $db_data->referrer = $referrer;\n $location_data = null;\n if (!empty($this->params['src'])) {\n $mod = !empty($this->params['module']) ? $this->params['module'] : $this->params['controller'];\n expCore::makeLocation($mod,$this->params['src'],$this->params['int']);\n }\n $db_data->location_data = $location_data;\n }\n $f->insertRecord($db_data);\n } else {\n $referrer = $db->selectValue(\"sessionticket\", \"referrer\", \"ticket = '\" . expSession::getTicketString() . \"'\");\n }",
" //Email stuff here...\n //Don't send email if this is an edit.\n if (!empty($this->config['is_email']) && !isset($this->params['data_id'])) {\n //Building Email List...\n $emaillist = array();\n if (!empty($this->config['select_email']) && !empty($this->params['email_dest'])) {\n if (strval(intval($this->params['email_dest'])) == strval($this->params['email_dest'])) {\n foreach (group::getUsersInGroup($this->params['email_dest']) as $locUser) {\n if ($locUser->email != '') $emaillist[$locUser->email] = trim(user::getUserAttribution($locUser->id));\n }\n } else {\n $emaillist[] = $this->params['email_dest'];\n }\n } else { // send to all form addressee's\n $emaillist = array();\n if (!empty($this->config['user_list'])) foreach ($this->config['user_list'] as $c) {\n $u = user::getUserById($c);\n $emaillist[$u->email] = trim(user::getUserAttribution($u->id));\n }\n if (!empty($this->config['group_list'])) foreach ($this->config['group_list'] as $c) {\n $grpusers = group::getUsersInGroup($c);\n foreach ($grpusers as $u) {\n $emaillist[$u->email] = trim(user::getUserAttribution($u->id));\n }\n }\n if (!empty($this->config['address_list'])) foreach ($this->config['address_list'] as $c) {\n $emaillist[] = $c;\n }\n }\n //This is an easy way to remove duplicates\n $emaillist = array_flip(array_flip($emaillist));\n $emaillist = array_map('trim', $emaillist);",
" if (empty($this->config['report_def'])) {\n $msgtemplate = expTemplate::get_template_for_action($this, 'email/default_report', $this->loc);",
" } else {\n $msgtemplate = expTemplate::get_template_for_action($this, 'email/custom_report', $this->loc);\n $msgtemplate->assign('template', $this->config['report_def']);\n }\n $msgtemplate->assign(\"fields\", $emailFields);\n $msgtemplate->assign(\"captions\", $captions);\n $msgtemplate->assign('title', $this->config['report_name']);\n $msgtemplate->assign(\"is_email\", 1);\n if (!empty($referrer)) $msgtemplate->assign(\"referrer\", $referrer);\n $emailText = $msgtemplate->render();\n $emailText = trim(strip_tags(str_replace(array(\"<br />\", \"<br>\", \"br/>\"), \"\\n\", $emailText)));\n $msgtemplate->assign(\"css\", file_get_contents(BASE . \"framework/core/assets/css/tables.css\"));\n $emailHtml = $msgtemplate->render();",
" if (empty($from)) {\n $from = trim(SMTP_FROMADDRESS);\n }\n if (empty($from_name)) {\n $from_name = trim(ORGANIZATION_NAME);\n }\n // $headers = array(\n // \"MIME-Version\"=>\"1.0\",\n // \"Content-type\"=>\"text/html; charset=\".LANG_CHARSET\n // );\n if (count($emaillist)) {\n $mail = new expMail();\n if (!empty($attachments)) {\n foreach ($attachments as $attachment) {\n if (strlen(PATH_RELATIVE) != 1)\n $attachment = str_replace(PATH_RELATIVE, '', $attachment); // strip relative path for links coming from templates\n if (file_exists(BASE . $attachment)) {\n// $relpath = str_replace(PATH_RELATIVE, '', BASE);\n// $finfo = finfo_open(FILEINFO_MIME_TYPE);\n// $ftype = finfo_file($finfo, $relpath . $attachment);\n// finfo_close($finfo);\n $mail->attach_file_on_disk(BASE . $attachment, expFile::getMimeType($attachment));\n }\n }\n }\n $mail->quickSend(array(\n //\t'headers'=>$headers,\n 'html_message' => $emailHtml,\n \"text_message\" => $emailText,\n 'to' => $emaillist,\n 'from' => array(trim($from) => $from_name),\n 'subject' => $this->config['subject'],\n ));\n }\n }",
" if (!empty($this->config['is_auto_respond']) && !isset($this->params['data_id']) && !empty($db_data->email)) {\n if (empty($from)) {\n $from = trim(SMTP_FROMADDRESS);\n }\n if (empty($from_name)) {\n $from_name = trim(ORGANIZATION_NAME);\n }\n// $headers = array(\n// \"MIME-Version\" => \"1.0\",\n// \"Content-type\" => \"text/html; charset=\" . LANG_CHARSET\n// );",
" $tmsg = trim(strip_tags(str_replace(array(\"<br />\", \"<br>\", \"br/>\"), \"\\n\", $this->config['auto_respond_body'])));",
" if ($this->config['auto_respond_form'])",
" $tmsg .= \"\\n\" . $emailText;\n $hmsg = $this->config['auto_respond_body'];",
" if ($this->config['auto_respond_form'])",
" $hmsg .= \"\\n\" . $emailHtml;\n $mail = new expMail();\n $mail->quickSend(array(\n// 'headers' => $headers,\n \"text_message\" => $tmsg,\n 'html_message' => $hmsg,\n 'to' => $db_data->email,\n 'from' => array(trim($from) => $from_name),\n 'subject' => $this->config['auto_respond_subject'],\n ));\n }",
" // clear the users post data from the session.\n expSession::un_set('forms_data_' . $f->id);",
" //If is a new post show response, otherwise redirect to the flow.\n if (!isset($this->params['data_id'])) {\n if (empty($this->config['response'])) $this->config['response'] = gt('Thanks for your submission');\n assign_to_template(array(\n \"backlink\"=>expHistory::getLastNotEditable(),\n \"response_html\"=>$this->config['response'],\n ));\n } else {\n flash('message', gt('Record was updated!'));\n // expHistory::back();\n expHistory::returnTo('editable');\n }\n }\n }",
" /**\n * delete item in saved data\n *\n */\n function delete() {\n if (empty($this->params['id']) || empty($this->params['forms_id'])) {\n flash('error', gt('Missing id for the') . ' ' . gt('item') . ' ' . gt('you would like to delete'));\n expHistory::back();\n }",
" $f = new forms($this->params['forms_id']);\n $f->deleteRecord($this->params['id']);",
" expHistory::back();\n }",
" /**\n * delete all items in saved data\n *\n */\n function delete_records() {\n if (empty($this->params['forms_id'])) {\n flash('error', gt('Missing id for the') . ' ' . gt('form records') . ' ' . gt('you would like to delete'));\n expHistory::back();\n }",
" $f = new forms($this->params['forms_id']);\n $recs = $f->getRecords();\n foreach ($recs as $rec) {\n $f->deleteRecord($rec->id);\n }",
" flash('message', gt('All form records were deleted!'));\n expHistory::back();\n }",
" /**\n * Manage site forms\n *\n */\n public function manage() {\n expHistory::set('manageable', $this->params);\n $forms = $this->forms->find('all', 1);\n foreach($forms as $key=>$f) {\n if (!empty($f->table_name) && $f->tableExists() ) {\n $forms[$key]->count = $f->countRecords();\n }\n $forms[$key]->control_count = count($f->forms_control);\n }",
" assign_to_template(array(\n 'select' => !empty($this->params['select']),\n 'forms' => $forms\n ));\n }",
" /**\n * Assign selected form to current module\n *\n */\n public function activate() {\n // assign new form assigned\n $this->config['forms_id'] = $this->params['id'];\n // set default settings for this form\n $f = new forms($this->params['id']);\n if (!empty($f->description)) $this->config['description'] = $f->description;\n if (!empty($f->response)) $this->config['response'] = $f->response;\n if (!empty($f->report_name)) $this->config['report_name'] = $f->report_name;\n if (!empty($f->report_desc)) $this->config['report_desc'] = $f->report_desc;\n if (!empty($f->column_names_list)) $this->config['column_names_list'] = $f->column_names_list;\n if (!empty($f->report_def)) $this->config['report_def'] = $f->report_def;",
" // setup and save the config\n $config = new expConfig($this->loc);\n $config->update(array('config' => $this->config));",
" expHistory::back();\n }",
" public function edit_form() {\n expHistory::set('editable', $this->params);\n if (!empty($this->params['id'])) {\n $f = $this->forms->find('first', 'id=' . $this->params['id']);\n } else {\n $f = new forms();\n }\n $fields = array();\n $column_names = array();\n $cols = array();",
" if (!empty($f->column_names_list)) {\n $cols = explode('|!|', $f->column_names_list);\n }\n $fc = new forms_control();\n foreach ($fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly=0','rank') as $control) {\n $ctl = expUnserialize($control->data);\n $control_type = get_class($ctl);\n $def = call_user_func(array($control_type, 'getFieldDefinition'));\n if ($def != null) {\n $fields[$control->name] = $control->caption;\n if (in_array($control->name, $cols)) {\n $column_names[$control->name] = $control->caption;\n }\n }\n }\n $fields['ip'] = gt('IP Address');\n if (in_array('ip', $cols)) $column_names['ip'] = gt('IP Address');\n $fields['user_id'] = gt('Posted by');\n if (in_array('user_id', $cols)) $column_names['user_id'] = gt('Posted by');\n $fields['timestamp'] = gt('Timestamp');\n if (in_array('timestamp', $cols)) $column_names['timestamp'] = gt('Timestamp');\n// if (in_array('location_data', $cols)) $column_names['location_data'] = gt('Entry Point');",
" if (!empty($this->params['copy'])) {\n $f->old_id = $f->id;\n $f->id = null;\n $f->sef_url = null;\n $f->is_saved = false;\n $f->table_name = null;\n }\n $fieldlist = '[';\n if (isset($f->id)) {\n $fc = new forms_control();\n foreach ($fc->find('all', 'forms_id=' . $f->id . ' AND is_readonly=0','rank') as $control) {\n $ctl = expUnserialize($control->data);\n $control_type = get_class($ctl);\n $def = call_user_func(array($control_type, 'getFieldDefinition'));\n if ($def != null) {\n $fields[$control->name] = $control->caption;\n if (in_array($control->name, $cols)) {\n $column_names[$control->name] = $control->caption;\n }\n }\n if ($control_type != 'pagecontrol' && $control_type != 'htmlcontrol') {\n $fieldlist .= '[\"{\\$fields[\\'' . $control->name . '\\']}\",\"' . $control->caption . '\",\"' . gt('Insert') . ' ' . $control->caption . ' ' . gt('Field') . '\"],';\n }\n }\n $fields['ip'] = gt('IP Address');\n if (in_array('ip', $cols)) $column_names['ip'] = gt('IP Address');\n $fields['user_id'] = gt('Posted by');\n if (in_array('user_id', $cols)) $column_names['user_id'] = gt('Posted by');\n $fields['timestamp'] = gt('Timestamp');\n if (in_array('timestamp', $cols)) $column_names['timestamp'] = gt('Timestamp');\n// if (in_array('location_data', $cols)) $column_names['location_data'] = gt('Entry Point');\n }\n $fieldlist .= ']';",
" assign_to_template(array(\n 'column_names' => $column_names,\n 'fields' => $fields,\n 'form' => $f,\n 'fieldlist' => $fieldlist,\n ));\n }",
" /**\n * Updates the form\n */\n public function update_form() {\n $this->forms->update($this->params);\n if (!empty($this->params['old_id'])) {\n // copy all the controls to the new form\n $fc = new forms_control();\n $controls = $fc->find('all','forms_id='.$this->params['old_id'],'rank');\n foreach ($controls as $control) {\n $control->id = null;\n $control->forms_id = $this->forms->id;\n $control->update();\n }\n }\n// if (!empty($this->params['is_saved']) && empty($this->params['table_name'])) {\n if (!empty($this->params['is_saved'])) {\n // we are now saving data to the database and need to create it first\n// $form = new forms($this->params['id']);\n $this->params['table_name'] = $this->forms->updateTable();\n// $this->params['_validate'] = false; // we don't want a check for unique sef_name\n// parent::update(); // now with a form tablename\n }\n expHistory::back();\n }",
" public function delete_form() {\n expHistory::set('editable', $this->params);\n $modelname = $this->basemodel_name;\n if (empty($this->params['id'])) {\n flash('error', gt('Missing id for the') . ' ' . $modelname . ' ' . gt('you would like to delete'));\n expHistory::back();\n }\n $form = new $modelname($this->params['id']);",
" $form->delete();\n expHistory::returnTo('manageable');\n }",
" public function design_form() {\n if (!empty($this->params['id'])) {\n expHistory::set('editable', $this->params);\n $f = new forms($this->params['id']);\n $controls = $f->forms_control;",
" $form = new fakeform();\n $form->horizontal = !empty($this->config['style']) ? $this->config['style'] : false;\n if (isset($this->params['style']))\n $form->horizontal = $this->params['style'];\n foreach ($controls as $c) {\n $ctl = expUnserialize($c->data);\n $ctl->_id = $c->id;\n $ctl->_readonly = $c->is_readonly;\n $ctl->_controltype = get_class($ctl);\n $form->register($c->name, $c->caption, $ctl);\n }",
" $types = expTemplate::listControlTypes();\n $types[\".break\"] = gt('Static - Spacer');\n $types[\".line\"] = gt('Static - Horizontal Line');\n uasort($types, \"strnatcmp\");\n if (!bs3())\n array_unshift($types, '[' . gt('Please Select' . ']'));",
" $forms_list = array();\n $forms = $f->find('all', 1);\n if (!empty($forms)) foreach ($forms as $frm) {\n if ($frm->id != $f->id)\n $forms_list[$frm->id] = $frm->title;\n }",
" assign_to_template(array(\n 'form' => $f,\n 'forms_list' => $forms_list,\n 'form_html' => $form->toHTML($f->id),\n 'backlink' => expHistory::getLastNotEditable(),\n 'types' => $types,\n 'style' => $form->horizontal\n ));\n }\n }",
" public function edit_control() {\n $f = new forms($this->params['forms_id']);\n if ($f) {\n if (bs2()) {\n expCSS::pushToHead(array(\n \"corecss\"=>\"forms-bootstrap\"\n ));\n } elseif (bs3()) {\n expCSS::pushToHead(array(\n \"corecss\"=>\"forms-bootstrap3\"\n ));\n } else {\n expCSS::pushToHead(array(\n \"corecss\" => \"forms\",\n ));\n }",
" if (isset($this->params['control_type']) && $this->params['control_type']{0} == \".\") {\n // there is nothing to edit for these type controls, so add it then return\n $htmlctl = new htmlcontrol();\n $htmlctl->identifier = uniqid(\"\");\n $htmlctl->caption = \"\";\n if (!empty($this->params['rank']))\n $htmlctl->rank = $this->params['rank'];\n switch ($this->params['control_type']) {\n case \".break\":\n $htmlctl->html = \"<br />\";\n break;\n case \".line\":\n $htmlctl->html = \"<hr size='1' />\";\n break;\n }\n $ctl = new forms_control();\n $ctl->name = uniqid(\"\");\n $ctl->caption = \"\";\n $ctl->data = serialize($htmlctl);\n $ctl->forms_id = $f->id;\n $ctl->is_readonly = 1;\n if (!empty($this->params['rank']))\n $ctl->rank = $this->params['rank'];\n $ctl->update();\n if (!expJavascript::inAjaxAction())\n expHistory::returnTo('editable');\n else { // we need a graceful exit for inAjaxAction\n assign_to_template(array(\n 'form_html' => ucfirst(substr($this->params['control_type'],1)) . ' ' . gt('control was added to form') . '<input type=\"hidden\" name=\"staticcontrol\" id=\"'.$ctl->id.'\" />',\n 'type' => 'static',\n ));\n }\n } else {\n $control_type = \"\";\n $ctl = null;\n if (isset($this->params['id'])) {\n $control = new forms_control($this->params['id']);\n if ($control) {\n $ctl = expUnserialize($control->data);\n $ctl->identifier = $control->name;\n $ctl->caption = $control->caption;\n $ctl->id = $control->id;\n $control_type = get_class($ctl);\n $f->id = $control->forms_id;\n }\n }\n if ($control_type == \"\") $control_type = $this->params['control_type'];\n $form = call_user_func(array($control_type, \"form\"), $ctl);\n $form->location($this->loc);\n if ($ctl) {\n if (isset($form->controls['identifier']->disabled)) $form->controls['identifier']->disabled = true;\n $form->meta(\"id\", $ctl->id);\n $form->meta(\"identifier\", $ctl->identifier);\n }\n $form->meta(\"action\", \"save_control\");\n// $form->meta('control_type', $control_type);\n $form->meta('forms_id', $f->id);\n $types = expTemplate::listControlTypes();\n $othertypes = expTemplate::listSimilarControlTypes($control_type);\n if (count($othertypes) > 1) {\n $otherlist = new dropdowncontrol($control_type,$othertypes);\n $form->registerBefore('identifier','control_type',gt('Control Type'),$otherlist);\n } else {\n $form->registerBefore('identifier','control_type',gt('Control Type'),new genericcontrol('hidden',$control_type));\n }\n assign_to_template(array(\n 'form_html' => $form->toHTML(),\n 'type' => $types[$control_type],\n 'is_edit' => ($ctl == null ? 0 : 1),\n ));\n }\n }\n }",
" public function save_control() {\n $f = new forms($this->params['forms_id']);\n if ($f) {\n $ctl = null;\n $control = null;\n // get previous data from existing control\n if (isset($this->params['id'])) {\n $control = new forms_control($this->params['id']);\n if ($control) {\n $ctl = expUnserialize($control->data);\n $ctl->identifier = $control->name;\n $ctl->caption = $control->caption;\n }\n } else {\n $control = new forms_control();\n }",
" // update control with data from form\n// $ctl1 = new $this->params['control_type']();\n// $ctl1 = expCore::cast($ctl1,$ctl);\n if (!empty($ctl)) {\n $ctl1 = expCore::cast($ctl,$this->params['control_type']);\n } else {\n $ctl1 = $ctl;\n }\n if (call_user_func(array($this->params['control_type'], 'useGeneric')) == true) {\n $ctl1 = call_user_func(array('genericcontrol', 'update'), $this->params, $ctl1);\n } else {\n $ctl1 = call_user_func(array($this->params['control_type'], 'update'), $this->params, $ctl1);\n }\n if (!empty($this->params['rank']))\n $ctl1->rank = $this->params['rank'];",
" //lets make sure the name submitted by the user is not a duplicate. if so we will fail back to the form\n if (!empty($control->id)) {\n //FIXME change this to an expValidator call\n $check = $control->getControl('name=\"' . $ctl1->identifier . '\" AND forms_id=' . $f->id . ' AND id != ' . $control->id);\n if (!empty($check) && empty($this->params['id'])) {\n //expValidator::failAndReturnToForm(gt('A field with the same name already exists for this form'), $_$this->params\n flash('error', gt('A field by the name\").\" \"' . $ctl1->identifier . '\" \".gt(\"already exists on this form'));\n expHistory::returnTo('editable');\n }\n }",
" if ($ctl1 != null) {\n $name = substr(preg_replace('/[^A-Za-z0-9]/', '_', $ctl1->identifier), 0, 20);\n if (!isset($this->params['id']) && $control->countControls(\"name='\" . $name . \"' AND forms_id=\" . $this->params['forms_id']) > 0) {\n $this->params['_formError'] = gt('Identifier must be unique.');\n expSession::set('last_POST', $this->params);\n } elseif ($name == 'id' || $name == 'ip' || $name == 'user_id' || $name == 'timestamp' || $name == 'location_data') {\n $this->params['_formError'] = sprintf(gt('Identifier cannot be \"%s\".'), $name);\n expSession::set('last_POST', $this->params);\n } else {\n if (!isset($this->params['id'])) {\n $control->name = $name;\n }\n $control->caption = $ctl1->caption;\n $control->forms_id = $this->params['forms_id'];\n $control->is_static = (!empty($ctl1->is_static) ? $ctl1->is_static : 0);\n if (!empty($ctl1->pattern)) $ctl1->pattern = addslashes($ctl1->pattern);\n $control->data = serialize($ctl1);",
" if (!empty($this->params['rank']))\n $control->rank = $this->params['rank'];\n if (!empty($control->id)) {\n $control->update();\n } else {\n $control->update();\n // reset summary report to all columns\n if (!$control->is_static) {\n $f->column_names_list = null;\n $f->update();\n //FIXME we also need to update any config column_names_list settings?\n }\n }\n $f->updateTable();\n }\n }\n }\n if (!expJavascript::inAjaxAction())\n expHistory::returnTo('editable');\n else {\n echo $control->id;\n }\n }",
" public function delete_control() {\n $ctl = null;\n if (isset($this->params['id'])) {\n $ctl = new forms_control($this->params['id']);\n }",
" if ($ctl) {\n $f = new forms($ctl->forms_id);\n $ctl->delete();\n $f->updateTable();\n if (!expJavascript::inAjaxAction())\n expHistory::returnTo('editable');\n }\n }",
" public function rerank_control() {\n if (!empty($this->params['id'])) {\n $fc = new forms_control($this->params['id']);\n $fc->rerank_control($this->params['rank']);\n // if we reranked a pagecontrol, we need to check/auto-correct the rank if needed\n $fc->update(array('rank'=>$this->params['rank'])); // force auto-validation of ranks\n }\n }",
" /**\n * Output a single control to an ajax request\n */\n public function build_control() {\n if (!empty($this->params['id'])) {\n $control = new forms_control($this->params['id']);\n $form = new fakeform();\n $form->horizontal = !empty($this->config['style']) ? $this->config['style'] : false;\n $ctl = expUnserialize($control->data);\n $ctl->_id = $control->id;\n $ctl->_readonly = $control->is_readonly;\n $ctl->_controltype = get_class($ctl);\n if (isset($this->params['style']))\n $form->horizontal = $this->params['style'];\n $form->register($control->name, $control->caption, $ctl);\n $form->style_form();\n echo $form->controlToHTML($control->name);\n }\n }",
" function configure() {\n $fields = array();\n $column_names = array();\n $cols = array();\n// $forms_list = array();\n// $forms = $this->forms->find('all', 1);\n// if (!empty($forms)) foreach ($forms as $form) {\n// $forms_list[$form->id] = $form->title;\n// } else {\n// $forms_list[0] = gt('You must select a form1');\n// }\n if (!empty($this->config['column_names_list'])) {\n $cols = $this->config['column_names_list'];\n }\n $fieldlist = '[';\n if (isset($this->config['forms_id'])) {\n $fc = new forms_control();\n foreach ($fc->find('all', 'forms_id=' . $this->config['forms_id'] . ' AND is_readonly=0','rank') as $control) {\n $ctl = expUnserialize($control->data);\n $control_type = get_class($ctl);\n $def = call_user_func(array($control_type, 'getFieldDefinition'));\n if ($def != null) {\n $fields[$control->name] = $control->caption;\n if (in_array($control->name, $cols)) {\n $column_names[$control->name] = $control->caption;\n }\n }\n if ($control_type != 'pagecontrol' && $control_type != 'htmlcontrol') {\n $fieldlist .= '[\"{\\$fields[\\'' . $control->name . '\\']}\",\"' . $control->caption . '\",\"' . gt('Insert') . ' ' . $control->caption . ' ' . gt('Field') . '\"],';\n }\n }\n $fields['ip'] = gt('IP Address');\n if (in_array('ip', $cols)) $column_names['ip'] = gt('IP Address');\n $fields['user_id'] = gt('Posted by');\n if (in_array('user_id', $cols)) $column_names['user_id'] = gt('Posted by');\n $fields['timestamp'] = gt('Timestamp');\n if (in_array('timestamp', $cols)) $column_names['timestamp'] = gt('Timestamp');\n// if (in_array('location_data', $cols)) $column_names['location_data'] = gt('Entry Point');\n }\n $fieldlist .= ']';\n $title = gt('No Form Assigned Yet!');\n if (!empty($this->config['forms_id'])) {\n $form = $this->forms->find('first', 'id=' . $this->config['forms_id']);\n $this->config['is_saved'] = $form->is_saved;\n $this->config['table_name'] = $form->table_name;\n $title = $form->title;\n }\n assign_to_template(array(\n// 'forms_list' => $forms_list,\n 'form_title' => $title,\n 'column_names' => $column_names,\n 'fields' => $fields,\n 'fieldlist' => $fieldlist,\n ));",
" parent::configure();\n }",
" /**\n * create a new default config array using the form defaults\n */\n private function get_defaults($form) {\n if (empty($this->config)) { // NEVER overwrite an existing config\n $this->config = array();\n $config = get_object_vars($form);\n if (!empty($config['column_names_list'])) {\n $config['column_names_list'] = explode('|!|', $config['column_names_list']); //fixme $form->column_names_list is a serialized array?\n }\n unset ($config['forms_control']);\n $this->config = $config;\n }\n }",
" /**\n * get the metainfo for this module\n *\n * @return array\n */\n function metainfo() {\n global $router;",
" if (empty($router->params['action'])) return false;\n $metainfo = array('title'=>'', 'keywords'=>'', 'description'=>'', 'canonical'=> '', 'noindex' => false, 'nofollow' => false);",
" // figure out what metadata to pass back based on the action we are in.\n switch ($router->params['action']) {\n case 'showall':\n $metainfo['title'] = gt(\"Showing Form Records\") . ' - ' . SITE_TITLE;\n $metainfo['keywords'] = SITE_KEYWORDS;\n $metainfo['description'] = SITE_DESCRIPTION;\n break;\n case 'show':\n $metainfo['title'] = gt(\"Showing Form Record\") . ' - ' . SITE_TITLE;\n $metainfo['keywords'] = SITE_KEYWORDS;\n $metainfo['description'] = SITE_DESCRIPTION;\n break;\n default:\n $metainfo = parent::metainfo();\n }\n return $metainfo;\n }",
" public function export_csv() {\n if (!empty($this->params['id'])) {\n $f = new forms($this->params['id']);\n $this->get_defaults($f); // fills $this->config with form defaults if needed\n $items = $f->getRecords();",
" $fc = new forms_control();\n //FIXME should we default to only 5 columns or all columns? and should we pick up modules columns ($this->config) or just form defaults ($f->)\n //$f->column_names_list is a serialized array\n //$this->config['column_names_list'] is an array\n if ($this->config['column_names_list'] == '') {\n //define some default columns...\n $controls = $fc->find('all', \"forms_id=\" . $f->id . \" AND is_readonly = 0 AND is_static = 0\", \"rank\");\n// foreach (array_slice($controls, 0, 5) as $control) {\n foreach ($controls as $control) {\n// if ($this->config['column_names_list'] != '')\n// $this->config['column_names_list'] .= '|!|';\n// $this->config['column_names_list'] .= $control->name;\n $this->config['column_names_list'][$control->name] = $control->name;\n }\n }",
"// $rpt_columns2 = explode(\"|!|\", $this->config['column_names_list']);",
" $rpt_columns = array();\n // popuplate field captions/labels\n foreach ($this->config['column_names_list'] as $column) {\n $control = $fc->find('first', \"forms_id=\" . $f->id . \" AND name = '\" . $column . \"' AND is_readonly = 0 AND is_static = 0\", \"rank\");\n if (!empty($control)) {\n $rpt_columns[$control->name] = $control->caption;\n } else {\n switch ($column) {\n case 'ip':\n $rpt_columns[$column] = gt('IP Address');\n break;\n case 'referrer':\n $rpt_columns[$column] = gt('Event ID');\n break;\n case 'user_id':\n $rpt_columns[$column] = gt('Posted by');\n break;\n case 'timestamp':\n $rpt_columns[$column] = gt('Timestamp');\n break;\n }\n }\n }",
" // populate field data\n foreach ($rpt_columns as $column_name=>$column_caption) {\n if ($column_name == \"ip\" || $column_name == \"referrer\" || $column_name == \"location_data\") {\n } elseif ($column_name == \"user_id\") {\n foreach ($items as $key => $item) {\n if ($item->$column_name != 0) {\n $locUser = user::getUserById($item->$column_name);\n $item->$column_name = $locUser->username;\n } else {\n $item->$column_name = '';\n }\n $items[$key] = $item;\n }\n } elseif ($column_name == \"timestamp\") {\n// $srt = $column_name . \"_srt\";\n foreach ($items as $key => $item) {\n// $item->$srt = $item->$column_name;\n $item->$column_name = strftime(\"%m/%d/%y %T\", $item->$column_name); // needs to be in a machine readable format\n $items[$key] = $item;\n }\n } else {\n $control = $fc->find('first', \"name='\" . $column_name . \"' AND forms_id=\" . $this->params['id'],'rank');\n if ($control) {\n// $ctl = unserialize($control->data);\n $ctl = expUnserialize($control->data);\n $control_type = get_class($ctl);\n// $srt = $column_name . \"_srt\";\n// $datadef = call_user_func(array($control_type, 'getFieldDefinition'));\n foreach ($items as $key => $item) {\n //We have to add special sorting for date time columns!!!\n// if (isset($datadef[DB_FIELD_TYPE]) && $datadef[DB_FIELD_TYPE] == DB_DEF_TIMESTAMP) {\n// $item->$srt = $item->$column_name;\n// }\n $item->$column_name = call_user_func(array($control_type, 'templateFormat'), $item->$column_name, $ctl);\n $items[$key] = $item;\n }\n }\n }\n }",
" if (LANG_CHARSET == 'UTF-8') {\n $file = chr(0xEF) . chr(0xBB) . chr(0xBF); // add utf-8 signature to file to open appropriately in Excel, etc...\n } else {\n $file = \"\";\n }",
" $file .= self::sql2csv($items, $rpt_columns);",
" // CREATE A TEMP FILE\n $tmpfname = tempnam(getcwd(), \"rep\"); // Rig",
" $handle = fopen($tmpfname, \"w\");\n fwrite($handle, $file);\n fclose($handle);",
" if (file_exists($tmpfname)) {",
" ob_end_clean();",
" // This code was lifted from phpMyAdmin, but this is Open Source, right?\n // 'application/octet-stream' is the registered IANA type but\n // MSIE and Opera seems to prefer 'application/octetstream'\n // It seems that other headers I've added make IE prefer octet-stream again. - RAM",
" $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octet-stream;' : 'text/comma-separated-values;';\n header('Content-Type: ' . $mime_type . ' charset=' . LANG_CHARSET . \"'\");\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n $filesize = filesize($tmpfname);\n header('Content-length: ' . $filesize);\n header('Content-Transfer-Encoding: binary');\n// header('Content-Encoding:');\n header('Content-Disposition: attachment; filename=\"report.csv\"');\n if ($filesize) header('Content-length: ' . $filesize); // for some reason the webserver cant run stat on the files and this breaks.\n // IE need specific headers\n if (EXPONENT_USER_BROWSER == 'IE') {\n header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n header('Pragma: public');\n header('Vary: User-Agent');\n } else {\n header('Pragma: no-cache');\n }\n //Read the file out directly\n readfile($tmpfname);",
"// if (DEVELOPMENT == 0) exit();\n unlink($tmpfname);\n exit();\n } else {\n error_log(\"error file doesn't exist\", 0);\n }\n }\n// expHistory::back();\n }",
" /**\n * This converts the sql statement into a nice CSV.\n * We grab the items array which is stored funkily in the DB in an associative array when we pull it.\n * So basically our aray looks like this:\n *\n * ITEMS\n * {[id]=>myID, [Name]=>name, [Address]=>myaddr}\n * {[id]=>myID1, [Name]=>name1, [Address]=>myaddr1}\n * {[id]=>myID2, [Name]=>name2, [Address]=>myaddr2}\n * {[id]=>myID3, [Name]=>name3, [Address]=>myaddr3}\n * {[id]=>myID4, [Name]=>name4, [Address]=>myaddr4}\n * {[id]=>myID5, [Name]=>name5, [Address]=>myaddr5}\n *\n * So by nature of the array, the keys are repetated in each line (id, name, etc)\n * So if we want to make a header row, we just run through once at the beginning and\n * use the array_keys function to strip out a functional header\n *\n * @param $items\n *\n * @param null $rptcols\n *\n * @return string\n */\n public static function sql2csv($items, $rptcols = null) {\n $str = \"\";\n foreach ($rptcols as $individual_Header) {\n if (!is_array($rptcols) || in_array($individual_Header, $rptcols)) $str .= $individual_Header . \",\"; //FIXME $individual_Header is ALWAYS in $rptcols?\n }\n $str .= \"\\r\\n\";\n foreach ($items as $item) {\n foreach ($rptcols as $key => $rowitem) {\n if (!is_array($rptcols) || property_exists($item, $key)) {\n $rowitem = str_replace(\",\", \" \", $item->$key);\n $str .= $rowitem . \",\";\n }\n } //foreach rowitem\n $str = substr($str, 0, strlen($str) - 1);\n $str .= \"\\r\\n\";\n } //end of foreach loop\n return $str;\n }",
" /**\n * Export form, controls and optionally the data table\n *\n */\n public function export_eql() {\n assign_to_template(array(\n \"id\" => $this->params['id'],\n ));\n }",
" /**\n * Export form, controls and optionally the data table\n *\n */\n public function export_eql_process() {\n if (!empty($this->params['id'])) {\n $f = new forms($this->params['id']);",
" $filename = preg_replace('/[^A-Za-z0-9_.-]/','-',$f->sef_url.'.eql');",
" ob_end_clean();\n ob_start(\"ob_gzhandler\");",
" // This code was lifted from phpMyAdmin, but this is Open Source, right?",
" // 'application/octet-stream' is the registered IANA type but\n // MSIE and Opera seems to prefer 'application/octetstream'\n $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';",
" header('Content-Type: ' . $mime_type);\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n // IE need specific headers\n if (EXPONENT_USER_BROWSER == 'IE') {\n header('Content-Disposition: inline; filename=\"' . $filename . '\"');\n header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n header('Pragma: public');\n } else {\n header('Content-Disposition: attachment; filename=\"' . $filename . '\"');\n header('Pragma: no-cache');\n }\n $tables = array(\n 'forms',\n 'forms_control'\n );\n if (!empty($this->params['include_data'])) {\n $tables[] = 'forms_'.$f->table_name;\n }\n echo expFile::dumpDatabase($tables, 'Form', $this->params['id']); //FIXME we need to echo inside call\n exit; // Exit, since we are exporting\n }\n// expHistory::back();\n }",
" /**\n * Import form, controls and optionally the data table\n *\n */\n public function import_eql() {\n }",
" /**\n * Import form, controls and optionally the data table\n *\n */\n public function import_eql_process() {\n $errors = array();",
" //FIXME check for duplicate form data table name before import?\n expFile::restoreDatabase($_FILES['file']['tmp_name'], $errors, 'Form');",
" if (empty($errors)) {\n flash('message',gt('Form was successfully imported'));\n } else {\n $message = gt('Form import encountered the following errors') . ':<br>';\n foreach ($errors as $error) {\n $message .= '* ' . $error . '<br>';\n }\n flash('error', $message);\n }\n expHistory::back();\n }",
" public function import_csv() {\n if (expFile::canCreate(BASE . \"tmp/test\") != SYS_FILES_SUCCESS) {\n assign_to_template(array(\n \"error\" => \"The /tmp directory is not writable. Please contact your administrator.\",\n ));\n } else {\n //Setup the arrays with the name/value pairs for the dropdown menus\n $delimiterArray = Array(\n ',' => gt('Comma'),\n ';' => gt('Semicolon'),\n ':' => gt('Colon'),\n ' ' => gt('Space'));",
" $forms = $this->forms->find('all', 1);\n $formslist = array();\n $formslist[0] = gt('--Create a New Form--');\n foreach ($forms as $aform) {\n if (!empty($aform->is_saved)) {\n $formslist[$aform->id] = $aform->title;\n if (empty($formslist[$aform->id])) $formslist[$aform->id] = gt('Untitled');\n }\n }",
"// //Setup the meta data (hidden values)\n// $form = new form();\n// $form->meta(\"controller\", \"forms\");\n// $form->meta(\"action\", \"import_csv_mapper\");\n//\n// //Register the dropdown menus\n// $form->register(\"delimiter\", gt('Delimiter Character'), new dropdowncontrol(\",\", $delimiterArray));\n// $form->register(\"upload\", gt('CSV File to Upload'), new uploadcontrol());\n// $form->register(\"use_header\", gt('First Row is a Header'), new checkboxcontrol(0, 0));\n// $form->register(\"rowstart\", gt('Forms Data begins in Row'), new textcontrol(\"1\", 1, 0, 6));\n// $form->register(\"forms_id\", gt('Target Form'), new dropdowncontrol(\"0\", $formslist));\n// $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n// \"form_html\" => $form->tohtml(),\n 'delimiters' => $delimiterArray,\n 'forms_list' => $formslist,\n ));\n }\n }",
" public function import_csv_mapper() {\n //Check to make sure the user filled out the required input.\n if (!is_numeric($this->params[\"rowstart\"])) {\n unset($this->params[\"rowstart\"]);\n $this->params['_formError'] = gt('The starting row must be a number.');\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit('Redirecting...');\n }",
" if (!empty($this->params['forms_id'])) {\n // if we are importing to an existing form, jump to that step\n $this->import_csv_data_mapper();\n } else {\n //Get the temp directory to put the uploaded file\n $directory = \"tmp\";",
" //Get the file save it to the temp directory\n if ($_FILES[\"upload\"][\"error\"] == UPLOAD_ERR_OK) {\n //\t$file = file::update(\"upload\",$directory,null,time().\"_\".$_FILES['upload']['name']);\n $file = expFile::fileUpload(\"upload\", false, false, time() . \"_\" . $_FILES['upload']['name'], $directory.'/'); //FIXME quick hack to remove file model\n if ($file == null) {\n switch ($_FILES[\"upload\"][\"error\"]) {\n case UPLOAD_ERR_INI_SIZE:\n case UPLOAD_ERR_FORM_SIZE:\n $this->params['_formError'] = gt('The file you attempted to upload is too large. Contact your system administrator if this is a problem.');\n break;\n case UPLOAD_ERR_PARTIAL:\n $this->params['_formError'] = gt('The file was only partially uploaded.');\n break;\n case UPLOAD_ERR_NO_FILE:\n $this->params['_formError'] = gt('No file was uploaded.');\n break;\n default:\n $this->params['_formError'] = gt('A strange internal error has occurred. Please contact the Exponent Developers.');\n break;\n }\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n }\n /*\n if (mime_content_type(BASE.$directory.\"/\".$file->filename) != \"text/plain\"){\n $this->params['_formError'] = \"File is not a delimited text file.\";\n expSession::set(\"last_POST\",$this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n */",
" //split the line into its columns\n $headerinfo = null;\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $fh = fopen(BASE . $directory . \"/\" . $file->filename, \"r\");\n if (!empty($this->params[\"use_header\"])) $this->params[\"rowstart\"]++;\n for ($x = 0; $x < $this->params[\"rowstart\"]; $x++) {\n $lineInfo = fgetcsv($fh, 2000, $this->params[\"delimiter\"]);\n if ($x == 0 && !empty($this->params[\"use_header\"])) $headerinfo = $lineInfo;\n }\n fclose($fh);\n ini_set('auto_detect_line_endings',$line_end);",
" // get list of simple non-static controls if we are also creating a new form\n $types = expTemplate::listControlTypes(false);\n uasort($types, \"strnatcmp\");\n $types = array_merge(array('none'=>gt('--Disregard this column--')),$types);",
" //Check to see if the line got split, otherwise throw an error\n if ($lineInfo == null) {\n $this->params['_formError'] = sprintf(gt('This file does not appear to be delimited by \"%s\". <br />Please specify a different delimiter.<br /><br />'), $this->params[\"delimiter\"]);\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n } else {\n //Setup the meta data (hidden values)\n $form = new form();\n $form->meta(\"controller\", \"forms\");\n $form->meta(\"action\", \"import_csv_form_prep\"); // we are creating a new form first\n // $form->meta(\"action\", \"import_csv_data\"); // we are importing into an existing form //FIXME\n $form->meta(\"delimiter\", $this->params[\"delimiter\"]);\n $form->meta(\"filename\", $directory . \"/\" . $file->filename);\n $form->meta(\"use_header\", $this->params[\"use_header\"]);\n $form->meta(\"rowstart\", $this->params[\"rowstart\"]);\n for ($i = 0, $iMax = count($lineInfo); $i < $iMax; $i++) {\n if ($headerinfo != null) {\n $title = $headerinfo[$i] . ' (' . $lineInfo[$i] .')';\n // $label = str_replace('&', 'and', $headerinfo[$i]);\n // $label = preg_replace(\"/(-)$/\", \"\", preg_replace('/(-){2,}/', '-', strtolower(preg_replace(\"/([^0-9a-z-_\\+])/i\", '-', $label))));\n // $form->register(\"name[$i]\", null, new genericcontrol('hidden',$label));\n $form->register(\"name[$i]\", null, new genericcontrol('hidden',$headerinfo[$i]));\n } else {\n $form->register(\"name[$i]\", null, new genericcontrol('hidden','Field'.$i));\n $title = $lineInfo[$i];\n }\n $form->register(\"data[$i]\", null, new genericcontrol('hidden',$lineInfo[$i]));\n $form->register(\"control[$i]\", $title, new dropdowncontrol(\"none\", $types));\n }\n $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n \"form_html\" => $form->tohtml(),\n ));\n }\n }\n }",
" public function import_csv_form_prep() {\n $form = new form();\n $form->meta(\"controller\", \"forms\");\n $form->meta(\"action\", \"import_csv_form_add\");\n $form->meta(\"delimiter\", $this->params[\"delimiter\"]);\n $form->meta(\"filename\", $this->params[\"filename\"]);\n $form->meta(\"use_header\", $this->params[\"use_header\"]);\n $form->meta(\"rowstart\", $this->params[\"rowstart\"]);",
" // condense our responses to present form shell for confirmation\n $form->register(\"title\", gt('Form Title'), new textcontrol(''));\n $formcontrols = array();\n foreach ($this->params['control'] as $key=>$control) {\n if ($control != \"none\") {\n $formcontrols[$key] = new stdClass();\n $formcontrols[$key]->control = $control;\n $label = str_replace('&', 'and', $this->params['name'][$key]);\n $label = preg_replace(\"/(-)$/\", \"\", preg_replace('/(-){2,}/', '_', strtolower(preg_replace(\"/([^0-9a-z-_\\+])/i\", '_', $label))));\n $formcontrols[$key]->name = $label;\n $formcontrols[$key]->caption = $this->params['name'][$key];\n $formcontrols[$key]->data = $this->params['data'][$key];\n }\n }",
" foreach ($formcontrols as $i=>$control) {\n $form->register(\"column[$i]\", ucfirst($control->control) . ' ' . gt('Field Identifier') . ' (' . $control->caption . ' - ' . $control->data . ')', new textcontrol($control->name));\n $form->register(\"control[$i]\", null, new genericcontrol('hidden',$control->control));\n $form->register(\"caption[$i]\", null, new genericcontrol('hidden',$control->caption));\n $form->register(\"data[$i]\", null, new genericcontrol('hidden',$control->data));\n }",
" $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n \"form_html\" => $form->tohtml(),\n ));\n }",
" public function import_csv_form_add() {",
" // create the form\n $f = new forms();\n $f->title = $this->params['title'];\n $f->is_saved = true;\n $f->update();",
" // create the form controls\n foreach ($this->params['control'] as $key=>$control) {\n $params = array();\n $fc = new forms_control();\n $this->params['column'][$key] = str_replace('&', 'and', $this->params['column'][$key]);\n $this->params['column'][$key] = preg_replace(\"/(-)$/\", \"\", preg_replace('/(-){2,}/', '-', strtolower(preg_replace(\"/([^0-9a-z-_\\+])/i\", '-', $this->params['column'][$key]))));\n $fc->name = $params['identifier'] = $this->params['column'][$key];\n $fc->caption = $params['caption'] = $this->params['caption'][$key];\n $params['description'] = '';\n if ($control == 'datetimecontrol') {\n $params['showdate'] = $params['showtime'] = true;\n }\n// if ($control == 'htmlcontrol') {\n// $params['html'] = $this->params['data'][$key];\n// }\n if ($control == 'radiogroupcontrol' || $control == 'dropdowncontrol') {\n $params['default'] = $params['items'] = $this->params['data'][$key];\n }\n $fc->forms_id = $f->id;\n $ctl = null;\n $ctl = call_user_func(array($control, 'update'), $params, $ctl);\n $fc->data = serialize($ctl);\n $fc->update();\n }",
" flash('notice', gt('New Form Created'));\n $this->params['forms_id'] = $f->id;\n// unset($this->params['caption']);\n unset($this->params['control']);\n $this->import_csv_data_display();\n }",
" public function import_csv_data_mapper() {\n// global $template;\n //Get the temp directory to put the uploaded file\n $directory = \"tmp\";",
" //Get the file save it to the temp directory\n if ($_FILES[\"upload\"][\"error\"] == UPLOAD_ERR_OK) {\n //\t$file = file::update(\"upload\",$directory,null,time().\"_\".$_FILES['upload']['name']);\n $file = expFile::fileUpload(\"upload\", false, false, time() . \"_\" . $_FILES['upload']['name'], $directory.'/'); //FIXME quick hack to remove file model\n if ($file == null) {\n switch ($_FILES[\"upload\"][\"error\"]) {\n case UPLOAD_ERR_INI_SIZE:\n case UPLOAD_ERR_FORM_SIZE:\n $this->params['_formError'] = gt('The file you attempted to upload is too large. Contact your system administrator if this is a problem.');\n break;\n case UPLOAD_ERR_PARTIAL:\n $this->params['_formError'] = gt('The file was only partially uploaded.');\n break;\n case UPLOAD_ERR_NO_FILE:\n $this->params['_formError'] = gt('No file was uploaded.');\n break;\n default:\n $this->params['_formError'] = gt('A strange internal error has occurred. Please contact the Exponent Developers.');\n break;\n }\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n }\n /*\n if (mime_content_type(BASE.$directory.\"/\".$file->filename) != \"text/plain\"){\n $this->params['_formError'] = \"File is not a delimited text file.\";\n expSession::set(\"last_POST\",$this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n */",
" //split the line into its columns\n $headerinfo = null;\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $fh = fopen(BASE . $directory . \"/\" . $file->filename, \"r\");\n if (!empty($this->params[\"use_header\"])) $this->params[\"rowstart\"]++;\n for ($x = 0; $x < $this->params[\"rowstart\"]; $x++) {\n $lineInfo = fgetcsv($fh, 2000, $this->params[\"delimiter\"]);\n if ($x == 0 && !empty($this->params[\"use_header\"])) $headerinfo = $lineInfo;\n }\n fclose($fh);\n ini_set('auto_detect_line_endings',$line_end);",
" // pull in the form control definitions here\n $f = new forms($this->params['forms_id']);\n $fields = array(\n \"none\" => gt('--Disregard this column--'),\n );\n foreach ($f->forms_control as $control) {\n $fields[$control->name] = $control->caption;\n }",
" //Check to see if the line got split, otherwise throw an error\n if ($lineInfo == null) {\n $this->params['_formError'] = sprintf(gt('This file does not appear to be delimited by \"%s\". <br />Please specify a different delimiter.<br /><br />'), $this->params[\"delimiter\"]);\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n } else {\n //Setup the meta data (hidden values)\n $form = new form();\n $form->meta(\"controller\", \"forms\");\n $form->meta(\"action\", \"import_csv_data_display\");\n $form->meta(\"rowstart\", $this->params[\"rowstart\"]);\n $form->meta(\"use_header\", $this->params[\"use_header\"]);\n $form->meta(\"filename\", $directory . \"/\" . $file->filename);\n $form->meta(\"delimiter\", $this->params[\"delimiter\"]);\n $form->meta(\"forms_id\", $this->params[\"forms_id\"]);",
" for ($i = 0, $iMax = count($lineInfo); $i < $iMax; $i++) {\n if ($headerinfo != null) {\n $title = $headerinfo[$i] . ' (' . $lineInfo[$i] .')';\n } else {\n $title = $lineInfo[$i];\n }\n $form->register(\"column[$i]\", $title, new dropdowncontrol(\"none\", $fields));\n }\n $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n \"form_html\" => $form->tohtml(),\n ));\n }\n }",
" public function import_csv_data_display() {\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $file = fopen(BASE . $this->params[\"filename\"], \"r\");\n $record = array();\n $records = array();\n $linenum = 1;",
" // pull in the form control definitions here\n $f = new forms($this->params['forms_id']);\n $fields = array();\n foreach ($f->forms_control as $control) {\n $fields[$control->name] = $control->caption;\n }",
" while (($filedata = fgetcsv($file, 2000, $this->params[\"delimiter\"])) != false) {\n if ($linenum >= $this->params[\"rowstart\"]) {\n $i = 0;\n foreach ($filedata as $field) {\n if (!empty($this->params[\"column\"][$i]) && $this->params[\"column\"][$i] != \"none\") {\n $colname = $this->params[\"column\"][$i];\n $record[$colname] = trim($field);\n $this->params['caption'][$i] = $fields[$colname];\n } else {\n unset($this->params['column'][$i]);\n }\n $i++;\n }\n $record['linenum'] = $linenum;\n $records[] = $record;\n }\n $linenum++;\n }\n fclose($file);\n ini_set('auto_detect_line_endings',$line_end);",
" assign_to_template(array(\n \"records\" => $records,\n \"params\" => $this->params,\n ));\n }",
" public function import_csv_data_add() {\n global $user;\n",
" if (!empty($this->params['filename']) && (strpos($this->params['filename'], 'tmp/') === false || strpos($this->params['folder'], '..') !== false)) {\n header('Location: ' . URL_FULL);\n exit(); // attempt to hack the site\n }",
" $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $file = fopen(BASE . $this->params[\"filename\"], \"r\");\n $recordsdone = 0;\n $linenum = 1;\n $f = new forms($this->params['forms_id']);\n $f->updateTable();",
" $fields = array();\n $multi_item_control_items = array();\n $multi_item_control_ids = array();\n foreach ($f->forms_control as $control) {\n $fields[$control->name] = expUnserialize($control->data);\n $ctltype = get_class($fields[$control->name]);\n if (in_array($ctltype,array('radiogroupcontrol','dropdowncontrol'))) {\n if (!array_key_exists($control->id,$multi_item_control_items)) {\n $multi_item_control_items[$control->name] = null;\n $multi_item_control_ids[$control->name] = $control->id;\n }\n }\n }",
" while (($filedata = fgetcsv($file, 2000, $this->params[\"delimiter\"])) != false) {\n if ($linenum >= $this->params[\"rowstart\"] && in_array($linenum,$this->params['importrecord'])) {\n $i = 0;\n $db_data = new stdClass();\n $db_data->ip = '';\n $db_data->user_id = $user->id;\n $db_data->timestamp = time();\n $db_data->referrer = '';\n $db_data->location_data = '';\n foreach ($filedata as $field) {\n if (!empty($this->params[\"column\"][$i]) && $this->params[\"column\"][$i] != \"none\") {\n $colname = $this->params[\"column\"][$i];\n $control_type = get_class($fields[$colname]);\n $params[$colname] = $field;\n $def = call_user_func(array($control_type, \"getFieldDefinition\"));\n if (!empty($def)) {\n $db_data->$colname = call_user_func(array($control_type, 'convertData'), $colname, $params);\n }\n if (!empty($db_data->$colname) && array_key_exists($colname,$multi_item_control_items) && !in_array($db_data->$colname,$multi_item_control_items[$colname])) {\n $multi_item_control_items[$colname][] = $db_data->$colname;\n }\n }\n $i++;\n }\n $f->insertRecord($db_data);\n $recordsdone++;\n }\n $linenum++;\n }",
" fclose($file);\n ini_set('auto_detect_line_endings',$line_end);",
" // update multi-item forms controls\n if (!empty($multi_item_control_ids)) {\n foreach ($multi_item_control_ids as $key=>$control_id) {\n $fc = new forms_control($control_id);\n $ctl = expUnserialize($fc->data);\n $ctl->items = $multi_item_control_items[$key];\n $fc->data = serialize($ctl);\n $fc->update();\n }\n }\n unlink(BASE . $this->params[\"filename\"]);\n flash('notice', $recordsdone.' '.gt('Records Imported'));\n expHistory::back();\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class helpController extends expController {\n\tpublic $useractions = array(\n 'showall'=>'Show all',\n 'select_version'=>'Select Help Version'\n );\n public $remove_configs = array(\n 'categories',\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'pagination',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" static function displayname() { return gt(\"Help\"); }\n static function description() { return gt(\"Manage Exponent CMS help files.\"); }\n static function isSearchable() { return true; }",
"\t",
" function __construct($src=null, $params=array()) {\n parent::__construct($src,$params);\n // only set the system help version if it's not already set as a session variable\n if (!expSession::is_set('help-version')) {\n $version = help_version::getCurrentHelpVersion();\n if (empty($version)) {\n // there is no help version set to 'is_current'\n $hv = new help_version();\n \t $newversion = $hv->find('first','1');\n if (!empty($newversion)) {\n $this->params['is_current'] = 1;\n \t $newversion->update($this->params);\n $version = $newversion->version;\n }\n }\n if(!empty($params['version'])) {\n $version = isset($params['version']) ? (($params['version'] == 'current') ? $version : $params['version']) : $version;\n }\n expSession::set('help-version',$version);\n }\n $this->help_version = expSession::get('help-version');\n\t}",
" /**\n * Display list of help documents\n */\n\tpublic function showall() {\n\t expHistory::set('viewable', $this->params);\n\t $hv = new help_version();\n\t //$current_version = $hv->find('first', 'is_current=1');\n\t $ref_version = $hv->find('first', 'version=\\''.$this->help_version.'\\'');\n",
" // pagination parameter..hard coded for now.\t ",
"\t\t$where = $this->aggregateWhereClause();\n\t $where .= 'AND help_version_id='.(empty($ref_version->id)?'0':$ref_version->id);\n if (empty($this->params['parent'])) {\n $where .= ' AND (parent=0 OR parent IS NULL)';\n } else {",
" $where .= ' AND parent=' . $this->params['parent'];",
" }\n//\t $limit = 999;\n\t $order = isset($this->config['order']) ? $this->config['order'] : 'rank';",
"\t // grab the pagination object\n\t\t$page = new expPaginator(array(\n 'model'=>'help',\n 'where'=> $where,\n//\t 'limit'=>$limit,\n 'order'=>$order,\n 'dir'=>'ASC',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title',\n gt('Details')=>'body',\n gt('Version')=>'help_version_id'\n ),\n ));\n $help = new help();\n\t foreach ($page->records as $key=>$doc) {\n $page->records[$key]->children = $help->find('count','parent='.$doc->id);\n }\n\t assign_to_template(array(\n 'current_version'=>$ref_version,\n 'page'=>$page,\n 'rank'=>($order==='rank')?1:0\n ));\n\t}",
" /**\n * Display a help document\n */\n\tpublic function show() {\n\t expHistory::set('viewable', $this->params);\n\t $help = new help();\n if (empty($this->params['version']) || $this->params['version'] == 'current') {\n $version_id = help_version::getCurrentHelpVersionId();\n\t } else {\n $version_id = help_version::getHelpVersionId($this->params['version']);\n if (empty($version_id)) {\n $version_id = help_version::getCurrentHelpVersionId();\n }\n\t }",
"",
"\t $doc = $help->find('first', 'help_version_id='.$version_id.' AND sef_url=\"'.$this->params['title'].'\"');\n $children = $help->find('count','parent='.$doc->id);\n if (empty($doc)) {\n redirect_to(array('controller'=>'notfound','action'=>'page_not_found','title'=>$this->params['title']));\n }\n $config = expConfig::getConfig($doc->location_data);",
"\t assign_to_template(array(\n 'doc'=>$doc,\n 'children'=>$children,\n \"hv\"=>$this->help_version,\n 'config'=>$config\n ));\n\t}",
" /**\n * Create or Edit a help document\n */\n\tpublic function edit() {\n global $db;",
"\t expHistory::set('editable', $this->params);\n\t $id = empty($this->params['id']) ? null : $this->params['id'];\n\t $help = new help($id);\n if (!empty($this->params['copy'])) $help->id = null;",
"\t // get the id of the current version and use it if we need to.\n if (expSession::is_set('help-version')) {\n $version_id = help_version::getHelpVersionId(expSession::get('help-version')); // version the site is currently using\n } else {\n $version_id = help_version::getCurrentHelpVersionId();\n }\n\t if (empty($help->help_version_id)) $help->help_version_id = $version_id;",
" $parentlist = array('0'=>'-- '.gt('Top Level Help Doc').' --');\n $order = isset($this->config['order']) ? $this->config['order'] : 'rank';\n $helpdocs = $help->find('all',\"help_version_id=\".$help->help_version_id.\" AND location_data='\".serialize($help->loc).\"'\",$order);\n foreach ($helpdocs as $helpdoc) {\n $parentlist[$helpdoc->id] = $helpdoc->title;\n }",
"\t\t$sectionlist = array();\n// $helpsections = $help->find('all',\"help_version_id=\".$help->help_version_id);\n//\t\tforeach ($helpsections as $helpsection) {\n//\t\t\tif (!empty($helpsection->location_data)) {\n//\t\t\t\t$helpsrc = expUnserialize($helpsection->location_data);\n//\t\t\t\tif (!array_key_exists($helpsrc->src, $sectionlist)) {\n// $sectionlist[$helpsrc->src] = $db->selectValue('section', 'name', 'id=\"' . $db->selectValue('sectionref', 'section', 'module = \"help\" AND source=\"' . $helpsrc->src .'\"').'\"');\n//\t\t\t\t}\n//\t\t\t}\n//\t\t}\n $helplocs = $help->findValue('all', 'location_data', \"help_version_id=\" . $version_id, null, true);\n foreach ($helplocs as $helploc) {\n if (!empty($helploc)) {\n $helpsrc = expUnserialize($helploc);\n $sectionlist[$helpsrc->src] = $db->selectValue('sectionref', 'section', 'module = \"help\" AND source=\"' . $helpsrc->src . '\"');\n }\n }\n $sectionlist[$this->loc->src] .= ' '.gt(\"(current section)\");",
"\t assign_to_template(array(\n 'record'=>$help,\n 'parents'=>$parentlist,\n \"current_section\"=>$this->loc->src,\n \"sections\"=>$sectionlist\n ));\n\t}",
" /**\n * Manage help documents\n */\n\tpublic function manage() {\n\t expHistory::set('manageable', $this->params);\n\t global $db;",
"\t ",
"\t $hv = new help_version();\n\t $current_version = $hv->find('first', 'is_current=1');",
"\t ",
"\t if (empty($current_version)) {\n\t flash('error', gt(\"You don't have any software versions created yet. Please do so now.\"));\n\t redirect_to(array('controller'=>'help', 'action'=>'edit_version'));\n// $this->edit_version();\n\t }",
" $sections = array();\n foreach ($db->selectObjects('sectionref','module=\"help\"') as $sectionref) {\n if (!empty($sectionref->source) && empty($sections[$sectionref->source])) {\n $sections[$sectionref->source] = $db->selectValue('section', 'name', 'id=\"' . $sectionref->section .'\"');\n }\n }\n",
"\t $where = empty($this->params['version']) ? 1 : 'help_version_id='.$this->params['version'];",
"\t $page = new expPaginator(array(\n 'model'=>'help',\n 'where'=>$where,\n 'limit'=>30,\n 'order' => (isset($this->params['order']) ? $this->params['order'] : 'help_version_id'),\n 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'DESC'),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title',\n gt('Version')=>'help_version_id',\n gt('Section')=>'section',\n// gt('Location')=>'location_data'\n ),\n ));",
"\t assign_to_template(array(\n 'current_version'=>$current_version,\n 'page'=>$page,\n 'sections'=>$sections\n ));\n\t}",
" /**\n * Routine to copy all existing help docs from a version to the new version\n * @static\n * @param $from\n * @param $to\n * @return bool\n */\n\tprivate static function copydocs($from, $to) {\n\t $help = new help();\n $order = 'rank DESC';\n $old_parents = $help->getHelpParents($from);\n $new_parents = array();",
" // copy parent help docs\n\t $current_docs = $help->find('all', 'help_version_id='.$from.' AND parent=0',$order);\n\t foreach ($current_docs as $doc) {\n $origid = $doc->id;\n\t unset($doc->id);\n\t $doc->help_version_id = $to;",
"\t\t ",
"//\t $tmpsef = $doc->sef_url;\n//\t $doc->sef_url = \"\";\n//\t $doc->save();\n//\t $doc->sef_url = $tmpsef;\n//\t $doc->do_not_validate = array('sef_url');\n\t $doc->save();\n if (in_array($origid, $old_parents)) {\n $new_parents[$origid] = $doc->id;\n }",
"//\t $doc->sef_url = $doc->makeSefUrl();\n//\t $doc->save();",
"\t foreach($doc->expFile as $subtype=>$files) {\n\t foreach($files as $file) {\n\t $doc->attachItem($file, $subtype);\n\t }\n\t }\n\t }",
" // copy child help docs\n $current_docs = $help->find('all', 'help_version_id='.$from.' AND parent!=0',$order);\n \t foreach ($current_docs as $key=>$doc) {\n \t unset($doc->id);\n $doc->parent = $new_parents[$doc->parent];\n \t $doc->help_version_id = $to;\n \t $doc->save();\n \t foreach($doc->expFile as $subtype=>$files) {\n \t foreach($files as $file) {\n \t $doc->attachItem($file, $subtype);\n \t }",
" \t }\n \t }",
"\t // get version #'s for the two versions\n $oldvers = help_version::getHelpVersion($from);\n $newvers = help_version::getHelpVersion($to);",
"\t // send a message saying what we've done\n\t flash('message', gt('Copied all docs from version').' '.$oldvers.' '.gt('to new version').' '.$newvers);\n\t return true;\n\t}",
" /**\n * Manage help versions\n */\n\tpublic function manage_versions() {\n\t expHistory::set('manageable', $this->params);",
"\t ",
"\t $hv = new help_version();\n\t $current_version = $hv->find('first', 'is_current=1');",
"\t ",
"\t $sql = 'SELECT hv.*, COUNT(h.title) AS num_docs FROM '.DB_TABLE_PREFIX.'_help h ';\n\t $sql .= 'RIGHT JOIN '.DB_TABLE_PREFIX.'_help_version hv ON h.help_version_id=hv.id GROUP BY hv.version';",
"\t $page = new expPaginator(array(\n 'sql'=>$sql,\n 'limit'=>30,\n 'order' => (isset($this->params['order']) ? $this->params['order'] : 'version'),\n 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'DESC'),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Version')=>'version',\n gt('Title')=>'title',\n gt('Current')=>'is_current',\n gt('# of Docs')=>'num_docs'\n ),\n ));",
"\t ",
"\t assign_to_template(array(\n 'current_version'=>$current_version,\n 'page'=>$page\n ));\n\t}",
" /**\n * Create or Edit details about a help version\n */\n\tpublic function edit_version() {\n\t expHistory::set('editable', $this->params);\n\t $id = empty($this->params['id']) ? null : $this->params['id'];\n\t $version = new help_version($id);\n\t assign_to_template(array(\n 'record'=>$version\n ));\n\t}",
" /**\n * Delete a help version and all assoc docs\n */\n\tpublic function delete_version() {\n\t if (empty($this->params['id'])) {\n\t flash('error', gt('The version you are trying to delete could not be found'));\n\t }",
"\t ",
"\t // get the version\n\t $version = new help_version($this->params['id']);\n\t if (empty($version->id)) {\n\t flash('error', gt('The version you are trying to delete could not be found'));\n\t }",
"\t ",
"\t // if we have errors than lets get outta here!\n\t if (!expQueue::isQueueEmpty('error')) expHistory::back();",
"\t ",
"\t // delete the version\n\t $version->delete();",
"\t ",
"\t expSession::un_set('help-version');",
"\t flash('message', gt('Deleted version').' '.$version->version.' '.gt('and all documents in that version.'));",
"\t expHistory::back();\t ",
"\t}",
" /**\n * Creates a new help version, possibly based on existing help version\n */\n\tpublic function update_version() {\n\t // get the current version\n\t $hv = new help_version();\n\t $current_version = $hv->find('first', 'is_current=1');",
"\t ",
"\t // check to see if the we have a new current version and unset the old current version.\n\t if (!empty($this->params['is_current'])) {\n//\t $db->sql('UPDATE '.DB_TABLE_PREFIX.'_help_version set is_current=0');\n help_version::clearHelpVersion();\n\t }\n\t expSession::un_set('help-version');",
"\t // save the version\n\t $id = empty($this->params['id']) ? null : $this->params['id'];\n\t $version = new help_version();\n\t // if we don't have a current version yet so we will force this one to be it\n\t if (empty($current_version->id)) $this->params['is_current'] = 1;\n\t $version->update($this->params);",
"\t ",
"\t // if this is a new version we need to copy over docs\n\t if (empty($id)) {",
"\t self::copydocs($current_version->id, $version->id);\t ",
"\t }\n // let's update the search index to reflect the current help version\n searchController::spider();",
"\t flash('message', gt('Saved help version').' '.$version->version);\n\t expHistory::back();\n\t}",
" /**\n * Switches current help version globally\n */\n\tpublic function activate_version() {\n\t // unset the old current version.\n help_version::clearHelpVersion();\n\t expSession::un_set('help-version');",
"\t\t$id = $this->params['id'];\n\t $version = new help_version($id);\n\t $this->params['is_current'] = 1;\n\t $version->update($this->params);\n // let's update the search index to reflect the current help version\n searchController::spider();",
"\t flash('message', gt('Changed active help version to').' '.$version->version);\n\t expHistory::back();\n\t}",
" /**\n * Displays available help versions\n */\n\tpublic function select_version() {\n \t $hv = expSession::get('help-version');\n $selected = help_version::getHelpVersionId($hv);\n $versions = help_version::getHelpVersionsDropdown();\n \t assign_to_template(array(\n 'current_version'=>$hv,\n 'selected'=>$selected,\n 'versions'=>$versions\n ));\n\t}",
" /**\n * Switches current help version temporarily\n */\n\tpublic function switch_version() {\n\t // unset the current version.\n\t expSession::un_set('help-version');\n // set the requested version.\n $version = help_version::getHelpVersion($this->params['version']);\n expSession::set('help-version',$version);\n\t flash('message', gt('Now displaying Help version').' '.$version);\n expHistory::back();\n\t}",
" /**\n \t * add only current version of docs to search index\n \t * @return int\n \t */\n \tfunction addContentToSearch() {\n global $db;",
" $count = 0;\n $help = new help();\n $where = 'help_version_id=\"'.help_version::getCurrentHelpVersionId().'\"';\n $where .= (!empty($this->params['id'])) ? ' AND id='.$this->params['id'] : null;\n $content = $db->selectArrays($help->tablename,$where);\n foreach ($content as $cnt) {\n $origid = $cnt['id'];\n unset($cnt['id']);",
" // get the location data for this content\n// if (isset($cnt['location_data'])) $loc = expUnserialize($cnt['location_data']);\n// $src = isset($loc->src) ? $loc->src : null;\n// $search_record = new search($cnt, false, false);\n //build the search record and save it.\n $sql = \"original_id=\" . $origid . \" AND ref_module='\" . $this->baseclassname . \"'\";\n $oldindex = $db->selectObject('search', $sql);\n if (!empty($oldindex)) {\n $search_record = new search($oldindex->id, false, false);\n $search_record->update($cnt);\n } else {\n $search_record = new search($cnt, false, false);\n }",
" $search_record->original_id = $origid;\n $search_record->posted = empty($cnt['created_at']) ? null : $cnt['created_at'];\n// $link = str_replace(URL_FULL,'', makeLink(array('controller'=>$this->baseclassname, 'action'=>'show', 'title'=>$cnt['sef_url'])));\n $link = str_replace(URL_FULL,'', makeLink(array('controller'=>$this->baseclassname, 'action'=>'show', 'title'=>$cnt['sef_url'])));\n//\t if (empty($search_record->title)) $search_record->title = 'Untitled';\n $search_record->view_link = $link;\n// $search_record->ref_module = $this->classname;\n $search_record->ref_module = $this->baseclassname;\n $search_record->category = $this->searchName();\n $search_record->ref_type = $this->searchCategory();\n $search_record->save();\n $count++;\n }",
" return $count;\n }",
" /**\n * Hack to try and determine page which help doc is assoc with\n * @static\n * @param $params\n * @return null|void\n */\n\tpublic static function getSection($params) {\n\t global $db;",
" $help = new help();\n if (empty($params['version']) || $params['version']=='current') {\n $version_id = help_version::getCurrentHelpVersionId();\n } else {\n $version_id = help_version::getHelpVersionId($params['version']);\n if (empty($version_id)) {\n $version_id = help_version::getCurrentHelpVersionId();\n }\n }\n $doc = $help->find('first','help_version_id='.$version_id.' and sef_url=\"'.$params['title'].'\"');\n\t $session_section = expSession::get('last_section') ? expSession::get('last_section') : 1 ;\n $help_sectionref = $db->selectObject('sectionref','module=\"help\" AND source=\"'. expUnserialize($doc->location_data)->src.'\"');\n $sid = !empty($help_sectionref) ? $help_sectionref->section : (($doc->section!=0) ? $doc->section : $session_section);\n if (!expSession::get('last_section')) {\n expSession::set('last_section',$sid);\n }\n//\t $section = $db->selectObject('section','id='. intval($sid));\n $section = new section(intval($sid));\n\t return $section;\n\t}",
"\t",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
1,
0,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class helpController extends expController {\n\tpublic $useractions = array(\n 'showall'=>'Show all',\n 'select_version'=>'Select Help Version'\n );\n public $remove_configs = array(\n 'categories',\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'pagination',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" static function displayname() { return gt(\"Help\"); }\n static function description() { return gt(\"Manage Exponent CMS help files.\"); }\n static function isSearchable() { return true; }",
"",
" function __construct($src=null, $params=array()) {\n parent::__construct($src,$params);\n // only set the system help version if it's not already set as a session variable\n if (!expSession::is_set('help-version')) {\n $version = help_version::getCurrentHelpVersion();\n if (empty($version)) {\n // there is no help version set to 'is_current'\n $hv = new help_version();\n \t $newversion = $hv->find('first','1');\n if (!empty($newversion)) {\n $this->params['is_current'] = 1;\n \t $newversion->update($this->params);\n $version = $newversion->version;\n }\n }\n if(!empty($params['version'])) {\n $version = isset($params['version']) ? (($params['version'] == 'current') ? $version : $params['version']) : $version;\n }\n expSession::set('help-version',$version);\n }\n $this->help_version = expSession::get('help-version');\n\t}",
" /**\n * Display list of help documents\n */\n\tpublic function showall() {\n\t expHistory::set('viewable', $this->params);\n\t $hv = new help_version();\n\t //$current_version = $hv->find('first', 'is_current=1');\n\t $ref_version = $hv->find('first', 'version=\\''.$this->help_version.'\\'');\n",
" // pagination parameter..hard coded for now.",
"\t\t$where = $this->aggregateWhereClause();\n\t $where .= 'AND help_version_id='.(empty($ref_version->id)?'0':$ref_version->id);\n if (empty($this->params['parent'])) {\n $where .= ' AND (parent=0 OR parent IS NULL)';\n } else {",
" $where .= ' AND parent=' . intval($this->params['parent']);",
" }\n//\t $limit = 999;\n\t $order = isset($this->config['order']) ? $this->config['order'] : 'rank';",
"\t // grab the pagination object\n\t\t$page = new expPaginator(array(\n 'model'=>'help',\n 'where'=> $where,\n//\t 'limit'=>$limit,\n 'order'=>$order,\n 'dir'=>'ASC',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title',\n gt('Details')=>'body',\n gt('Version')=>'help_version_id'\n ),\n ));\n $help = new help();\n\t foreach ($page->records as $key=>$doc) {\n $page->records[$key]->children = $help->find('count','parent='.$doc->id);\n }\n\t assign_to_template(array(\n 'current_version'=>$ref_version,\n 'page'=>$page,\n 'rank'=>($order==='rank')?1:0\n ));\n\t}",
" /**\n * Display a help document\n */\n\tpublic function show() {\n\t expHistory::set('viewable', $this->params);\n\t $help = new help();\n if (empty($this->params['version']) || $this->params['version'] == 'current') {\n $version_id = help_version::getCurrentHelpVersionId();\n\t } else {\n $version_id = help_version::getHelpVersionId($this->params['version']);\n if (empty($version_id)) {\n $version_id = help_version::getCurrentHelpVersionId();\n }\n\t }",
"\t $this->params['title'] = expString::escape($this->params['title']); // escape title to prevent sql injection",
"\t $doc = $help->find('first', 'help_version_id='.$version_id.' AND sef_url=\"'.$this->params['title'].'\"');\n $children = $help->find('count','parent='.$doc->id);\n if (empty($doc)) {\n redirect_to(array('controller'=>'notfound','action'=>'page_not_found','title'=>$this->params['title']));\n }\n $config = expConfig::getConfig($doc->location_data);",
"\t assign_to_template(array(\n 'doc'=>$doc,\n 'children'=>$children,\n \"hv\"=>$this->help_version,\n 'config'=>$config\n ));\n\t}",
" /**\n * Create or Edit a help document\n */\n\tpublic function edit() {\n global $db;",
"\t expHistory::set('editable', $this->params);\n\t $id = empty($this->params['id']) ? null : $this->params['id'];\n\t $help = new help($id);\n if (!empty($this->params['copy'])) $help->id = null;",
"\t // get the id of the current version and use it if we need to.\n if (expSession::is_set('help-version')) {\n $version_id = help_version::getHelpVersionId(expSession::get('help-version')); // version the site is currently using\n } else {\n $version_id = help_version::getCurrentHelpVersionId();\n }\n\t if (empty($help->help_version_id)) $help->help_version_id = $version_id;",
" $parentlist = array('0'=>'-- '.gt('Top Level Help Doc').' --');\n $order = isset($this->config['order']) ? $this->config['order'] : 'rank';\n $helpdocs = $help->find('all',\"help_version_id=\".$help->help_version_id.\" AND location_data='\".serialize($help->loc).\"'\",$order);\n foreach ($helpdocs as $helpdoc) {\n $parentlist[$helpdoc->id] = $helpdoc->title;\n }",
"\t\t$sectionlist = array();\n// $helpsections = $help->find('all',\"help_version_id=\".$help->help_version_id);\n//\t\tforeach ($helpsections as $helpsection) {\n//\t\t\tif (!empty($helpsection->location_data)) {\n//\t\t\t\t$helpsrc = expUnserialize($helpsection->location_data);\n//\t\t\t\tif (!array_key_exists($helpsrc->src, $sectionlist)) {\n// $sectionlist[$helpsrc->src] = $db->selectValue('section', 'name', 'id=\"' . $db->selectValue('sectionref', 'section', 'module = \"help\" AND source=\"' . $helpsrc->src .'\"').'\"');\n//\t\t\t\t}\n//\t\t\t}\n//\t\t}\n $helplocs = $help->findValue('all', 'location_data', \"help_version_id=\" . $version_id, null, true);\n foreach ($helplocs as $helploc) {\n if (!empty($helploc)) {\n $helpsrc = expUnserialize($helploc);\n $sectionlist[$helpsrc->src] = $db->selectValue('sectionref', 'section', 'module = \"help\" AND source=\"' . $helpsrc->src . '\"');\n }\n }\n $sectionlist[$this->loc->src] .= ' '.gt(\"(current section)\");",
"\t assign_to_template(array(\n 'record'=>$help,\n 'parents'=>$parentlist,\n \"current_section\"=>$this->loc->src,\n \"sections\"=>$sectionlist\n ));\n\t}",
" /**\n * Manage help documents\n */\n\tpublic function manage() {\n\t expHistory::set('manageable', $this->params);\n\t global $db;",
"",
"\t $hv = new help_version();\n\t $current_version = $hv->find('first', 'is_current=1');",
"",
"\t if (empty($current_version)) {\n\t flash('error', gt(\"You don't have any software versions created yet. Please do so now.\"));\n\t redirect_to(array('controller'=>'help', 'action'=>'edit_version'));\n// $this->edit_version();\n\t }",
" $sections = array();\n foreach ($db->selectObjects('sectionref','module=\"help\"') as $sectionref) {\n if (!empty($sectionref->source) && empty($sections[$sectionref->source])) {\n $sections[$sectionref->source] = $db->selectValue('section', 'name', 'id=\"' . $sectionref->section .'\"');\n }\n }\n",
"\t $where = empty($this->params['version']) ? 1 : 'help_version_id='.intval($this->params['version']);",
"\t $page = new expPaginator(array(\n 'model'=>'help',\n 'where'=>$where,\n 'limit'=>30,\n 'order' => (isset($this->params['order']) ? $this->params['order'] : 'help_version_id'),\n 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'DESC'),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title',\n gt('Version')=>'help_version_id',\n gt('Section')=>'section',\n// gt('Location')=>'location_data'\n ),\n ));",
"\t assign_to_template(array(\n 'current_version'=>$current_version,\n 'page'=>$page,\n 'sections'=>$sections\n ));\n\t}",
" /**\n * Routine to copy all existing help docs from a version to the new version\n * @static\n * @param $from\n * @param $to\n * @return bool\n */\n\tprivate static function copydocs($from, $to) {\n\t $help = new help();\n $order = 'rank DESC';\n $old_parents = $help->getHelpParents($from);\n $new_parents = array();",
" // copy parent help docs\n\t $current_docs = $help->find('all', 'help_version_id='.$from.' AND parent=0',$order);\n\t foreach ($current_docs as $doc) {\n $origid = $doc->id;\n\t unset($doc->id);\n\t $doc->help_version_id = $to;",
"",
"//\t $tmpsef = $doc->sef_url;\n//\t $doc->sef_url = \"\";\n//\t $doc->save();\n//\t $doc->sef_url = $tmpsef;\n//\t $doc->do_not_validate = array('sef_url');\n\t $doc->save();\n if (in_array($origid, $old_parents)) {\n $new_parents[$origid] = $doc->id;\n }",
"//\t $doc->sef_url = $doc->makeSefUrl();\n//\t $doc->save();",
"\t foreach($doc->expFile as $subtype=>$files) {\n\t foreach($files as $file) {\n\t $doc->attachItem($file, $subtype);\n\t }\n\t }\n\t }",
" // copy child help docs\n $current_docs = $help->find('all', 'help_version_id='.$from.' AND parent!=0',$order);\n \t foreach ($current_docs as $key=>$doc) {\n \t unset($doc->id);\n $doc->parent = $new_parents[$doc->parent];\n \t $doc->help_version_id = $to;\n \t $doc->save();\n \t foreach($doc->expFile as $subtype=>$files) {\n \t foreach($files as $file) {\n \t $doc->attachItem($file, $subtype);\n \t }",
" \t }\n \t }",
"\t // get version #'s for the two versions\n $oldvers = help_version::getHelpVersion($from);\n $newvers = help_version::getHelpVersion($to);",
"\t // send a message saying what we've done\n\t flash('message', gt('Copied all docs from version').' '.$oldvers.' '.gt('to new version').' '.$newvers);\n\t return true;\n\t}",
" /**\n * Manage help versions\n */\n\tpublic function manage_versions() {\n\t expHistory::set('manageable', $this->params);",
"",
"\t $hv = new help_version();\n\t $current_version = $hv->find('first', 'is_current=1');",
"",
"\t $sql = 'SELECT hv.*, COUNT(h.title) AS num_docs FROM '.DB_TABLE_PREFIX.'_help h ';\n\t $sql .= 'RIGHT JOIN '.DB_TABLE_PREFIX.'_help_version hv ON h.help_version_id=hv.id GROUP BY hv.version';",
"\t $page = new expPaginator(array(\n 'sql'=>$sql,\n 'limit'=>30,\n 'order' => (isset($this->params['order']) ? $this->params['order'] : 'version'),\n 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'DESC'),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Version')=>'version',\n gt('Title')=>'title',\n gt('Current')=>'is_current',\n gt('# of Docs')=>'num_docs'\n ),\n ));",
"",
"\t assign_to_template(array(\n 'current_version'=>$current_version,\n 'page'=>$page\n ));\n\t}",
" /**\n * Create or Edit details about a help version\n */\n\tpublic function edit_version() {\n\t expHistory::set('editable', $this->params);\n\t $id = empty($this->params['id']) ? null : $this->params['id'];\n\t $version = new help_version($id);\n\t assign_to_template(array(\n 'record'=>$version\n ));\n\t}",
" /**\n * Delete a help version and all assoc docs\n */\n\tpublic function delete_version() {\n\t if (empty($this->params['id'])) {\n\t flash('error', gt('The version you are trying to delete could not be found'));\n\t }",
"",
"\t // get the version\n\t $version = new help_version($this->params['id']);\n\t if (empty($version->id)) {\n\t flash('error', gt('The version you are trying to delete could not be found'));\n\t }",
"",
"\t // if we have errors than lets get outta here!\n\t if (!expQueue::isQueueEmpty('error')) expHistory::back();",
"",
"\t // delete the version\n\t $version->delete();",
"",
"\t expSession::un_set('help-version');",
"\t flash('message', gt('Deleted version').' '.$version->version.' '.gt('and all documents in that version.'));",
"\t expHistory::back();",
"\t}",
" /**\n * Creates a new help version, possibly based on existing help version\n */\n\tpublic function update_version() {\n\t // get the current version\n\t $hv = new help_version();\n\t $current_version = $hv->find('first', 'is_current=1');",
"",
"\t // check to see if the we have a new current version and unset the old current version.\n\t if (!empty($this->params['is_current'])) {\n//\t $db->sql('UPDATE '.DB_TABLE_PREFIX.'_help_version set is_current=0');\n help_version::clearHelpVersion();\n\t }\n\t expSession::un_set('help-version');",
"\t // save the version\n\t $id = empty($this->params['id']) ? null : $this->params['id'];\n\t $version = new help_version();\n\t // if we don't have a current version yet so we will force this one to be it\n\t if (empty($current_version->id)) $this->params['is_current'] = 1;\n\t $version->update($this->params);",
"",
"\t // if this is a new version we need to copy over docs\n\t if (empty($id)) {",
"\t self::copydocs($current_version->id, $version->id);",
"\t }\n // let's update the search index to reflect the current help version\n searchController::spider();",
"\t flash('message', gt('Saved help version').' '.$version->version);\n\t expHistory::back();\n\t}",
" /**\n * Switches current help version globally\n */\n\tpublic function activate_version() {\n\t // unset the old current version.\n help_version::clearHelpVersion();\n\t expSession::un_set('help-version');",
"\t\t$id = $this->params['id'];\n\t $version = new help_version($id);\n\t $this->params['is_current'] = 1;\n\t $version->update($this->params);\n // let's update the search index to reflect the current help version\n searchController::spider();",
"\t flash('message', gt('Changed active help version to').' '.$version->version);\n\t expHistory::back();\n\t}",
" /**\n * Displays available help versions\n */\n\tpublic function select_version() {\n \t $hv = expSession::get('help-version');\n $selected = help_version::getHelpVersionId($hv);\n $versions = help_version::getHelpVersionsDropdown();\n \t assign_to_template(array(\n 'current_version'=>$hv,\n 'selected'=>$selected,\n 'versions'=>$versions\n ));\n\t}",
" /**\n * Switches current help version temporarily\n */\n\tpublic function switch_version() {\n\t // unset the current version.\n\t expSession::un_set('help-version');\n // set the requested version.\n $version = help_version::getHelpVersion($this->params['version']);\n expSession::set('help-version',$version);\n\t flash('message', gt('Now displaying Help version').' '.$version);\n expHistory::back();\n\t}",
" /**\n \t * add only current version of docs to search index\n \t * @return int\n \t */\n \tfunction addContentToSearch() {\n global $db;",
" $count = 0;\n $help = new help();\n $where = 'help_version_id=\"'.help_version::getCurrentHelpVersionId().'\"';\n $where .= (!empty($this->params['id'])) ? ' AND id='.$this->params['id'] : null;\n $content = $db->selectArrays($help->tablename,$where);\n foreach ($content as $cnt) {\n $origid = $cnt['id'];\n unset($cnt['id']);",
" // get the location data for this content\n// if (isset($cnt['location_data'])) $loc = expUnserialize($cnt['location_data']);\n// $src = isset($loc->src) ? $loc->src : null;\n// $search_record = new search($cnt, false, false);\n //build the search record and save it.\n $sql = \"original_id=\" . $origid . \" AND ref_module='\" . $this->baseclassname . \"'\";\n $oldindex = $db->selectObject('search', $sql);\n if (!empty($oldindex)) {\n $search_record = new search($oldindex->id, false, false);\n $search_record->update($cnt);\n } else {\n $search_record = new search($cnt, false, false);\n }",
" $search_record->original_id = $origid;\n $search_record->posted = empty($cnt['created_at']) ? null : $cnt['created_at'];\n// $link = str_replace(URL_FULL,'', makeLink(array('controller'=>$this->baseclassname, 'action'=>'show', 'title'=>$cnt['sef_url'])));\n $link = str_replace(URL_FULL,'', makeLink(array('controller'=>$this->baseclassname, 'action'=>'show', 'title'=>$cnt['sef_url'])));\n//\t if (empty($search_record->title)) $search_record->title = 'Untitled';\n $search_record->view_link = $link;\n// $search_record->ref_module = $this->classname;\n $search_record->ref_module = $this->baseclassname;\n $search_record->category = $this->searchName();\n $search_record->ref_type = $this->searchCategory();\n $search_record->save();\n $count++;\n }",
" return $count;\n }",
" /**\n * Hack to try and determine page which help doc is assoc with\n * @static\n * @param $params\n * @return null|void\n */\n\tpublic static function getSection($params) {\n\t global $db;",
" $help = new help();\n if (empty($params['version']) || $params['version']=='current') {\n $version_id = help_version::getCurrentHelpVersionId();\n } else {\n $version_id = help_version::getHelpVersionId($params['version']);\n if (empty($version_id)) {\n $version_id = help_version::getCurrentHelpVersionId();\n }\n }\n $doc = $help->find('first','help_version_id='.$version_id.' and sef_url=\"'.$params['title'].'\"');\n\t $session_section = expSession::get('last_section') ? expSession::get('last_section') : 1 ;\n $help_sectionref = $db->selectObject('sectionref','module=\"help\" AND source=\"'. expUnserialize($doc->location_data)->src.'\"');\n $sid = !empty($help_sectionref) ? $help_sectionref->section : (($doc->section!=0) ? $doc->section : $session_section);\n if (!expSession::get('last_section')) {\n expSession::set('last_section',$sid);\n }\n//\t $section = $db->selectObject('section','id='. intval($sid));\n $section = new section(intval($sid));\n\t return $section;\n\t}",
"",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Models\n * @package Modules\n */",
"class help_version extends expRecord {\n//\tpublic $table = 'help_version';\n\tpublic $validates = array(\n\t\t'uniqueness_of'=>array(\n\t\t\t'version'=>array('message'=>'This version number is already in use.'),\n\t\t));",
" public function afterDelete() {\n\t // get and delete the docs for this version\n\t $help = new help();\n\t $docs = $help->find('all', 'help_version_id='.$this->id);\n\t foreach ($docs as $doc) {\n\t $doc->delete();\n\t }\n }",
" public static function getCurrentHelpVersionId() {\n global $db;",
" return $db->selectValue('help_version', 'id', 'is_current=1');\n }",
" public static function getCurrentHelpVersion() {\n global $db;",
" return $db->selectValue('help_version','version','is_current=1');\n }",
" public static function getHelpVersionId($version) {\n global $db;\n",
" return $db->selectValue('help_version', 'id', 'version=\"'.$version.'\"');",
" }",
" public static function getHelpVersion($version_id) {\n global $db;\n",
" return $db->selectValue('help_version', 'version', 'id=\"'.$version_id.'\"');",
" }",
" public static function getHelpVersionsDropdown() {\n global $db;",
" return $db->selectDropdown('help_version','version',1,'version DESC');\n }",
" public static function clearHelpVersion() {\n global $db;",
" \t // unset the old current version.\n \t $db->toggle('help_version',\"is_current\",'is_current=1');\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Models\n * @package Modules\n */",
"class help_version extends expRecord {\n//\tpublic $table = 'help_version';\n\tpublic $validates = array(\n\t\t'uniqueness_of'=>array(\n\t\t\t'version'=>array('message'=>'This version number is already in use.'),\n\t\t));",
" public function afterDelete() {\n\t // get and delete the docs for this version\n\t $help = new help();\n\t $docs = $help->find('all', 'help_version_id='.$this->id);\n\t foreach ($docs as $doc) {\n\t $doc->delete();\n\t }\n }",
" public static function getCurrentHelpVersionId() {\n global $db;",
" return $db->selectValue('help_version', 'id', 'is_current=1');\n }",
" public static function getCurrentHelpVersion() {\n global $db;",
" return $db->selectValue('help_version','version','is_current=1');\n }",
" public static function getHelpVersionId($version) {\n global $db;\n",
" return $db->selectValue('help_version', 'id', 'version=\"'.$db->escapeString($version).'\"');",
" }",
" public static function getHelpVersion($version_id) {\n global $db;\n",
" return $db->selectValue('help_version', 'version', 'id=\"'.intval($version_id).'\"');",
" }",
" public static function getHelpVersionsDropdown() {\n global $db;",
" return $db->selectDropdown('help_version','version',1,'version DESC');\n }",
" public static function clearHelpVersion() {\n global $db;",
" \t // unset the old current version.\n \t $db->toggle('help_version',\"is_current\",'is_current=1');\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class importexportController extends expController {",
"",
" // hide the configs we don't need\n public $remove_configs = array(\n 'aggregation',\n 'categories',\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)\n",
" //protected $permissions = array_merge(array(\"test\"=>'Test'), array('copyProduct'=>\"Copy Product\"));\n protected $add_permissions = array(\n 'import' => 'Import Data',\n 'export' => 'Export Data'\n );",
"\n static function displayname() {\n return gt(\"Data Import / Export Module\");\n }",
" static function description() {\n return gt(\"Use this module to import and export data from your Exponent website.\");\n }",
" static function hasSources() {\n return false;\n }",
" static function hasContent() {\n return false;\n }",
"// function __construct($src = null, $params = array()) {\n// parent::__construct($src, $params);\n// }",
" function manage() {\n global $available_controllers;",
" expHistory::set('manageable', $this->params);\n $importDD = array();\n $exportDD = array();\n foreach ($available_controllers as $key => $path) {\n if (strpos($key, \"Controller\") !== false) {\n $c = new $key();\n if ($c->canImportData()) $importDD[$key] = $c->name();\n if ($c->canExportData()) $exportDD[$key] = $c->name();\n }\n }\n assign_to_template(array(\n 'importDD' => $importDD,\n 'exportDD' => $exportDD,\n ));\n }",
" function import() {\n $type = expModules::getController($this->params['import_type']);\n if (method_exists($type, 'import')) { // allow for controller specific method\n redirect_to(array('controller'=>$type->baseclassname, 'action'=>'import'));\n }",
" $pullable_modules = expModules::listInstalledControllers($type->baseclassname);\n $modules = new expPaginator(array(\n 'records' => $pullable_modules,\n 'controller' => $this->loc->mod,\n 'action' => $this->params['action'],\n 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\n 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Title') => 'title',\n gt('Page') => 'section'\n ),\n ));",
" assign_to_template(array(\n 'modules' => $modules,\n 'import_type' => $type->baseclassname\n ));\n }",
" function import_select() {\n $type = expModules::getController($this->params['import_type']);\n if (method_exists($type, 'import_select')) { // allow for controller specific method\n redirect_to(array('controller'=>$type->baseclassname, 'action'=>'import_select'));\n }",
" if (empty($this->params['import_aggregate'])) {\n expValidator::setErrorField('import_aggregate[]');\n expValidator::failAndReturnToForm(gt('You must select a module.'), $this->params);\n }",
" //Get the temp directory to put the uploaded file\n $directory = \"tmp\";",
" //Get the file save it to the temp directory\n if (!empty($_FILES[\"import_file\"]) && $_FILES[\"import_file\"][\"error\"] == UPLOAD_ERR_OK) {\n $file = expFile::fileUpload(\"import_file\", false, false, time() . \"_\" . $_FILES['import_file']['name'], $directory.'/');\n if ($file === null) {\n switch ($_FILES[\"import_file\"][\"error\"]) {\n case UPLOAD_ERR_INI_SIZE:\n case UPLOAD_ERR_FORM_SIZE:\n $this->params['_formError'] = gt('The file you attempted to upload is too large. Contact your system administrator if this is a problem.');\n break;\n case UPLOAD_ERR_PARTIAL:\n $this->params['_formError'] = gt('The file was only partially uploaded.');\n break;\n case UPLOAD_ERR_NO_FILE:\n $this->params['_formError'] = gt('No file was uploaded.');\n break;\n default:\n $this->params['_formError'] = gt('A strange internal error has occurred. Please contact the Exponent Developers.');\n break;\n }\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n } else {\n $errors = array();\n $data = expFile::parseDatabase(BASE . $directory . \"/\" . $file->filename, $errors, $type->model_table); //FIXME this may crash on large .eql files\n if (!empty($errors)) {\n $message = gt('Importing encountered the following errors') . ':<br>';\n foreach ($errors as $error) {\n $message .= '* ' . $error . '<br>';\n }\n flash('error', $message);\n }",
" assign_to_template(array(\n 'import_type' => $this->params['import_type'],\n 'items' => $data[$type->model_table]->records,\n 'filename' => $directory . \"/\" . $file->filename,\n 'source' => $this->params['import_aggregate'][0]\n ));\n }\n } else {\n expValidator::setErrorField('import_file');\n expValidator::failAndReturnToForm(gt('File failed to upload.'), $this->params); // file upload error\n }\n }",
" function import_process() {\n $type = expModules::getController($this->params['import_type']);\n if (method_exists($type, 'import_process')) { // allow for controller specific method\n redirect_to(array('controller'=>$type->baseclassname, 'action'=>'import_process'));\n }",
" if (!count($this->params['items'])) {\n expValidator::setErrorField('items');\n expValidator::failAndReturnToForm(gt('You must select at least one item.'), $this->params);",
"",
" }",
" $filename = $this->params['filename'];\n $src = $this->params['source'];\n $selected = $this->params['items'];\n $errors = array();\n $model = new $type->basemodel_name;\n $tables = array();\n $attached = $model->getAttachableItemTables();\n foreach ($attached as $link=>$model) {\n $tables[] = $link;\n $attach = new $model;\n $tables[] = $attach->tablename;\n }\n array_unshift($tables, $type->model_table);\n $data = expFile::parseDatabase(BASE . $filename, $errors, $tables); //FIXME this may crash on large .eql files",
" // parse out attachments data using the content_id for easier access\n $attachments = array();\n foreach ($attached as $link=>$model) {\n if (!empty($data[$link]->records)) {\n $attachments[$link] = array();\n foreach ($data[$link]->records as $item) {\n $attachments[$link][$item['content_id']] = $item;\n }\n $attach = new $model;\n foreach ($data[$attach->tablename]->records as $item) {\n $attachments[$link][$item['id']]['content'] = $item;\n }\n }\n }",
" foreach ($selected as $select) {\n $current_id = $data[$type->model_table]->records[$select]['id'];\n unset( // clear out the stuff that gets auto-set when integrated into existing records\n $data[$type->model_table]->records[$select]['id'],\n $data[$type->model_table]->records[$select]['sef_url'],\n $data[$type->model_table]->records[$select]['rank']\n );\n $data[$type->model_table]->records[$select]['location_data'] = serialize(expCore::makeLocation($type->baseclassname, $src));\n $item = new $type->basemodel_name($data[$type->model_table]->records[$select]); // create new populated record to auto-set things\n $item->update();",
" if ($this->params['import_attached']) {\n $params = array();;\n foreach ($attached as $link=>$model) {\n foreach ($attachments[$link] as $aitem) {\n if ($aitem['content_id'] == $current_id) {\n //$item is content_ record\n //$item['content'] is the attachment\n switch ($model) {\n case 'expCat':\n foreach ($data['expCats']->records as $key=>$ct) {\n if ($ct['id'] == $aitem['expcats_id']) {\n $cat = new expCat($ct['title']);\n if (empty($cat->id)) {\n $cat->title = $ct['title'];\n $cat->module = $type->baseclassname;\n $cat->save();\n }\n $params['expCat'][] = $cat->id;\n }\n }\n break;\n case 'expComment':\n foreach ($data['expComments']->records as $key=>$cm) {\n unset($cm['id']);\n $cm['parent_id'] = 0; //fixme this flattens reply comments\n $comment = new expComment($cm);\n $comment->update(); // create and attach the comment\n $comment->attachComment($type->baseclassname, $item->id, $aitem['subtype']);\n }\n break;\n case 'expFile':\n //FIXME we can't handle file attachments since this is only a db import\n break;\n case 'expTag':\n foreach ($data['expTags']->records as $key=>$tg) {\n if ($tg['id'] == $aitem['exptags_id']) {\n $tag = new expTag($tg['title']);\n if (empty($tag->id))\n $tag->update(array('title'=>$tg['title']));\n $params['expTag'][] = $tag->id;\n }\n }\n break;\n }\n }\n }\n }\n $item->update($params); // add expCat & expTag attachments to item\n }\n }\n unlink($this->params['filename']);",
" // update search index\n $type->addContentToSearch();",
" flashAndFlow('message', count($selected) . ' ' . $type->baseclassname . ' ' . gt('items were imported.'));\n }",
" function export() {\n $type = expModules::getController($this->params['export_type']);\n if (method_exists($type, 'export')) { // allow for controller specific method\n redirect_to(array('controller'=>$type->baseclassname, 'action'=>'export'));\n }",
" $pullable_modules = expModules::listInstalledControllers($type->baseclassname);\n $modules = new expPaginator(array(\n 'records' => $pullable_modules,\n 'controller' => $this->loc->mod,\n 'action' => $this->params['action'],\n 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\n 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Title') => 'title',\n gt('Page') => 'section'\n ),\n ));\n assign_to_template(array(\n 'modules' => $modules,\n 'export_type' => $type->baseclassname\n ));\n }",
" function export_process() {\n $type = expModules::getController($this->params['export_type']);\n if (method_exists($type, 'export_process')) { // allow for controller specific method\n redirect_to(array('controller'=>$type->baseclassname, 'action'=>'export_process'));\n }",
" if (!empty($this->params['export_aggregate'])) {\n $tables = array($type->model_table);\n $selected = $this->params['export_aggregate'];\n $where = '(';\n foreach ($selected as $key=>$src) {\n if ($key) $where .= ' OR ';\n $where .= \"location_data='\" . serialize(expCore::makeLocation($type->baseclassname, $src)) . \"'\";\n }\n $where .= ')';\n $awhere[] = $where;",
" if ($this->params['export_attached']) {\n $model = new $type->basemodel_name;\n foreach ($model->getAttachableItemTables() as $link=>$model) {\n $tables[] = $link;\n $awhere[] = \"content_type='\" . $type->baseclassname . \"'\";\n $attach = new $model;\n $tables[] = $attach->tablename;\n $awhere[] = '';\n }\n }",
" $filename = $type->baseclassname . '.eql';",
" ob_end_clean();\n ob_start(\"ob_gzhandler\");",
" // 'application/octet-stream' is the registered IANA type but\n // MSIE and Opera seems to prefer 'application/octetstream'\n $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';",
" header('Content-Type: ' . $mime_type);\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n // IE need specific headers\n if (EXPONENT_USER_BROWSER == 'IE') {\n header('Content-Disposition: inline; filename=\"' . $filename . '\"');\n header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n header('Pragma: public');\n } else {\n header('Content-Disposition: attachment; filename=\"' . $filename . '\"');\n header('Pragma: no-cache');\n }\n echo expFile::dumpDatabase($tables, 'export', $awhere); //FIXME we need to echo inside call\n exit; // Exit, since we are exporting\n }\n expHistory::back();\n }",
" function validate() {\n// global $db;",
" //eDebug($this->params,true); ",
" set_time_limit(0);\n //$file = new expFile($this->params['expFile']['import_file'][0]);\n if (!empty($_FILES['import_file']['error'])) {\n flash('error', gt('There was an error uploading your file. Please try again.'));\n redirect_to(array('controller' => 'store', 'action' => 'import_external_addresses'));\n }",
" $file = new stdClass();\n $file->path = $_FILES['import_file']['tmp_name'];\n echo gt(\"Attempting import\").\"...<br/>\";",
" $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $checkhandle = fopen($file->path, \"r\");\n $checkdata = fgetcsv($checkhandle, 10000, \",\");\n $fieldCount = count($checkdata);",
" $count = 1;\n while (($checkdata = fgetcsv($checkhandle, 10000, \",\")) !== FALSE) {\n $count++;\n if (count($checkdata) != $fieldCount) {\n echo gt(\"Line \") . $count . \" \".gt(\"of your CSV import file does not contain the correct number of columns.\").\"<br/>\";\n echo gt(\"Found\").\" \" . $fieldCount . \" \".gt(\"header fields, but only\").\" \" . count($checkdata) . \" \".gt(\"field in row\").\" \" . $count . \" \".gt(\"Please check your file and try again.\");\n exit();\n }\n }\n fclose($checkhandle);\n ini_set('auto_detect_line_endings',$line_end);",
" echo \"<br/>\" . gt(\"CSV File passed validation\") . \"...<br/>\";",
" if ($this->params['import_type'] == 'store') $this->importProduct($file);\n //else if($this->params['import_type'] == 'address') $this->importAddresses($file);\n }",
" /*function importAddresses($file)\n {\n $handle = fopen($file->path, \"r\");\n $data = fgetcsv($handle, 10000, \",\");",
" //eDebug($data); \n $source = ''; ",
" foreach ($data as $key=>$value)\n {",
" $dataset[$value] = ''; ",
" if($key == 2 && $value=='Unique_Bill_Name') $source = '1'; //SMC\n }",
" ",
" //eDebug($source);\n //eDebug($dataset,true);\n $count = 1;\n $errorSet = array();\n $successSet = array();\n eDebug($dataset);",
" ",
" $extAddy = null;\n while (($data = fgetcsv($handle, 10000, \",\")) !== FALSE) {\n $count++;",
" $extAddy = new external_address(); ",
" $bName = explode(' ',$data[3]);\n eDebug($bName);\n $extAddy->firstname = $bName[0];\n if(count($bName) == 3)\n {\n $extAddy->middlename = $bName[1];",
" $extAddy->lastname = $bName[2]; ",
" }\n else if (count($bName) ==1)\n {\n $extAddy->middlename = '';",
" $extAddy->lastname = ''; ",
" }\n else\n {\n $extAddy->middlename = '';",
" $extAddy->lastname = $bName[1]; \n }\n ",
" $extAddy->organization = $data[4];\n $extAddy->address1 = $data[5];",
" $extAddy->address2 = $data[6]; \n $extAddy->address2 = $data[6]; \n $extAddy->city = $data[7]; \n ",
" $s = new geoRegion();\n $state = $s->find('first','code=\"'.trim($data[8]).'\"');\n eDebug($state);",
" $extAddy->state = $state->id; \n $extAddy->zip = str_ireplace(\"'\",'',$data[9]); \n $extAddy->phone = $data[20]; \n $extAddy->email = $data[21]; ",
" $extAddy->source = $source;",
" \n ",
" //shipping\n if($data[3] == $data[12] && $data[5] == $data[14] && $data[6] == $data[15]) //shipping and billing same\n {\n $extAddy->is_billing = 1;",
" $extAddy->is_shipping = 1; \n $extAddy->save(false); ",
" }\n else",
" { ",
" $extAddy->is_billing = 1;",
" $extAddy->is_shipping = 0; \n $extAddy->save(false); \n \n $extAddy = new external_address(); ",
" $sName = explode(' ',$data[12]);\n eDebug($sName);\n $extAddy->firstname = $sName[0];\n if(count($sName) == 3)\n {\n $extAddy->middlename = $sName[1];",
" $extAddy->lastname = $sName[2]; ",
" }\n else if (count($sName) ==1)\n {\n $extAddy->middlename = '';",
" $extAddy->lastname = ''; ",
" }\n else\n {\n $extAddy->middlename = '';",
" $extAddy->lastname = $sName[1]; \n }\n ",
" $extAddy->organization = $data[13];\n $extAddy->address1 = $data[14];",
" $extAddy->address2 = $data[15]; \n $extAddy->city = $data[16]; \n ",
" $s = new geoRegion();\n $state = $s->find('first','code=\"'.trim($data[17]).'\"');\n eDebug($state);",
" $extAddy->state = $state->id; \n $extAddy->zip = str_ireplace(\"'\",'',$data[18]); \n $extAddy->phone = $data[20]; \n $extAddy->email = $data[21]; ",
" $extAddy->is_billing = 0;\n $extAddy->is_shipping = 1;",
" $extAddy->source = $source; \n ",
" $extAddy->save(false);\n }",
" ",
" echo \"Successfully imported row \" . $count . \", name: \" . $extAddy->firstname . \" \" . $extAddy->lastname . \"<br/>\";\n //eDebug($product);",
" \n } \n ",
" if(count($errorSet))\n {\n echo \"<br/><hr><br/><font color='red'>The following records were NOT imported:<br/>\";\n foreach ($errorSet as $row=>$err)\n {\n echo \"Row: \" . $row . \". Reason:<br/>\";\n if (is_array($err))\n {\n foreach ($err as $e)\n {\n echo \"--\" . $e . \"<br/>\";\n }\n }\n else echo \"--\" . $err . \"<br/>\";\n }\n echo \"</font>\";",
" } ",
" }*/",
" function importProduct($file=null) {\n if (empty($file->path)) {\n $file = new stdClass();\n $file->path = $_FILES['import_file']['tmp_name'];\n }\n if (empty($file->path)) {\n echo gt('Not a Product Import CSV File');\n return;\n }\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $handle = fopen($file->path, \"r\");",
" // read in the header line\n $header = fgetcsv($handle, 10000, \",\");\n if (!($header[0] == 'id' || $header[0] == 'model')) {\n echo gt('Not a Product Import CSV File');\n return;\n }",
" $count = 1;\n $errorSet = array();\n $product = null;\n /* original order of columns\n 0=id\n 1=parent_id\n 2=child_rank\n 3=title\n 4=body\n 5=model\n 6=warehouse_location\n 7=sef_url\n//FIXME this is where canonical should be\n 8=meta_title\n 9=meta_keywords\n 10=meta_description\n 11=tax_class_id\n 12=quantity\n 13=availability_type\n 14=base_price\n 15=special_price\n 16=use_special_price\n 17=active_type\n 18=product_status_id\n 19=category1\n 20=category2\n 21=category3\n 22=category4\n ..\n 30=category12\n 31=surcharge\n 32=rank category_rank\n 33=feed_title\n 34=feed_body\n 35=weight\n 36=height\n 37=width\n 38=length\n 39=companies_id\n 40=image1 url to mainimage to download\n 41=image2 url to additional image to download\n ..\n 44=image5 url to additional image to download\n*/",
" // read in the data lines\n// while (($data = fgetcsv($handle, 10000, \",\")) !== FALSE) {\n while (($row = fgetcsv($handle, 10000, \",\")) !== FALSE) {\n $count++;\n $createCats = array();\n $createCatsRank = array();\n $data = array_combine($header, $row);",
" //eDebug($data, true);\n if ($header[0] == 'id') {\n if (isset($data['id']) && $data['id'] != 0) {\n $product = new product($data['id'], false, false);\n if (empty($product->id)) {\n $errorSet[$count] = gt(\"Is not an existing product ID.\");\n continue;\n }\n } else {\n //$errorSet[$count] = \"Product ID not supplied.\";\n //continue;\n $product = new product();\n //$product->save(false);\n }\n } elseif ($header[0] == 'model') {\n if (!empty($data['model'])) {\n $p = new product();\n $product = $p->find('first','model=\"' . $data['model'] . '\"');\n if (empty($product->id)) {\n $errorSet[$count] = gt(\"Is not an existing product SKU/Model.\");\n continue;\n }\n } else {\n $product = new product();\n }\n }\n if ($product->product_type != 'product') {\n $errorSet[$count] = gt(\"Existing product is wrong product type.\");\n continue;\n }",
" // new products must have a title\n if (empty($product->id)) { // new product require mandatory values\n $checkTitle = trim($data['title']);\n if (empty($checkTitle)) {\n $errorSet[$count] = gt(\"No product name (title) supplied.\");\n continue;\n }\n $product->minimum_order_quantity = 1;\n }",
" // parse $data columns\n foreach ($data as $key=>$value) {\n $value = trim($value);\n switch ($key) {\n case 'parent_id': // integer\n case 'child_rank':\n case 'tax_class_id':\n case 'quantity':\n case 'availability_type':\n case 'use_special_price':\n case 'active_type':\n case 'product_status_id':\n $product->$key = intval($value);\n break;\n case 'companies_id':\n if (is_numeric($value)) {\n $product->$key = intval($value);\n } elseif (!empty($value)) { // it's a company name, not a company id#\n $co = new company();\n $company = $co->find('first', 'title=' . $value);\n if (empty($company->id)) {\n $params['title'] = $value;\n $company->update();\n }\n $product->$key = $company->id;\n }\n break;\n case 'sef_url':\n $product->$key = stripslashes(stripslashes($value));\n if (!is_bool(expValidator::uniqueness_of('sef_url', $product, array()))) {\n $product->makeSefUrl();\n }\n break;\n case 'title': // string\n case 'model':\n case 'warehouse_location':\n case 'meta_title':\n case 'meta_keywords':\n case 'meta_description':\n case 'feed_title':\n case 'feed_body':\n $product->$key = stripslashes(stripslashes($value));\n break;\n case 'body':\n $product->$key = utf8_encode(stripslashes(expString::parseAndTrimImport(($value), true)));\n break;\n case 'base_price': // float\n case 'special_price':\n case 'surcharge':\n case 'weight':\n case 'height':\n case 'width':\n case 'length':\n $product->$key = floatval($value);\n break;\n case 'image1':\n case 'image2':\n case 'image3':\n case 'image4':\n case 'image5':\n if (!empty($value)) {\n $product->save(false);\n if (is_integer($value)) {\n $_objFile = new expFile ($value);\n } else {\n // import image from url\n $_destFile = basename($value); // get filename from end of url\n $_destDir = UPLOAD_DIRECTORY_RELATIVE;\n $_destFullPath = BASE . $_destDir . $_destFile;\n if (file_exists($_destFullPath)) {\n $_destFile = expFile::resolveDuplicateFilename($_destFullPath);\n $_destFullPath = BASE . $_destDir . $_destFile;\n }",
" expCore::saveData($value, $_destFullPath); // download the image",
" if (file_exists($_destFullPath)) {\n $__oldumask = umask(0);\n chmod($_destFullPath, octdec(FILE_DEFAULT_MODE_STR + 0));\n umask($__oldumask);",
" // Create a new expFile Object\n $_fileParams = array('filename' => $_destFile, 'directory' => $_destDir);\n $_objFile = new expFile ($_fileParams);\n $_objFile->save();\n }\n }\n // attach product images expFile object\n if (!empty($_objFile->id)) {\n if ($key == 'image1') {\n $product->attachItem($_objFile, 'mainimage');\n } else {\n $product->attachItem($_objFile, 'images', false);\n }\n }\n }\n break;\n case 'category1':\n case 'category2':\n case 'category3':\n case 'category4':\n case 'category5':\n case 'category6':\n case 'category7':\n case 'category8':\n case 'category9':\n case 'category10':\n case 'category11':\n case 'category12':\n if ($product->parent_id == 0) {\n// $rank = !empty($data['rank']) ? $data['rank'] : 1;\n $rank = intval(str_replace('category', '', $key));\n// if (!empty($value)) $result = storeCategory::parseCategory($value);\n if (!empty($value)) $result = storeCategory::importCategoryString($value);\n else continue;",
"// if (is_numeric($result)) {\n if ($result) {\n $createCats[] = $result;\n $createCatsRank[$result] = $rank;\n } else {\n $errorSet[$count][] = $result;\n continue 2;\n }\n }\n break;\n default:\n if (property_exists('product', $key)) {\n $product->key = $value;\n }\n }\n }",
"// $checkTitle = trim($data['title']);\n// if (empty($checkTitle)) {\n// $errorSet[$count] = gt(\"No product name (title) supplied, skipping this record...\");\n// continue;\n// }\n// $product->parent_id = $data[1];\n// $product->child_rank = $data[2];\n// $product->title = stripslashes(stripslashes($data[3]));\n// $product->body = utf8_encode(stripslashes(expString::parseAndTrimImport(($data[4]), true)));\n// //$product->body = utf8_encode(stripslashes(stripslashes(($data[4]))));\n// $product->model = stripslashes(stripslashes($data[5]));\n// $product->warehouse_location = stripslashes(stripslashes($data[6]));\n// $product->sef_url = stripslashes(stripslashes($data[7]));\n////FIXME this is where canonical should be\n// $product->meta_title = stripslashes(stripslashes($data[8]));\n// $product->meta_keywords = stripslashes(stripslashes($data[9]));\n// $product->meta_description = stripslashes(stripslashes($data[10]));\n//\n// $product->tax_class_id = $data[11];\n//\n// $product->quantity = $data[12];\n//\n// $product->availability_type = $data[13];\n//\n// $product->base_price = $data[14];\n// $product->special_price = $data[15];\n// $product->use_special_price = $data[16];\n// $product->active_type = $data[17];\n// $product->product_status_id = $data[18];\n//\n// $product->surcharge = $data[31];\n// $product->feed_title = stripslashes(stripslashes($data[33]));\n// $product->feed_body = stripslashes(stripslashes($data[34]));\n// if (!empty($data[35])) $product->weight = $data[35];\n// if (!empty($data[36])) $product->height = $data[36];\n// if (!empty($data[37])) $product->width = $data[37];\n// if (!empty($data[38])) $product->length = $data[38];\n// if (!empty($data[39])) $product->companies_id = $data[39];\n// if (!empty($data[40])) {\n// // import image from url\n// $_destFile = basename($data[40]); // get filename from end of url\n// $_destDir = UPLOAD_DIRECTORY_RELATIVE;\n// $_destFullPath = BASE . $_destDir . $_destFile;\n// if (file_exists($_destFullPath)) {\n// $_destFile = expFile::resolveDuplicateFilename($_destFullPath);\n// $_destFullPath = BASE . $_destDir . $_destFile;\n// }\n//\n// expCore::saveData($data[40], $_destFullPath); // download the image\n//\n// if (file_exists($_destFullPath)) {\n// $__oldumask = umask(0);\n// chmod($_destFullPath, octdec(FILE_DEFAULT_MODE_STR + 0));\n// umask($__oldumask);\n//\n// // Create a new expFile Object\n// $_fileParams = array('filename' => $_destFile, 'directory' => $_destDir);\n// $_objFile = new expFile ($_fileParams);\n// $_objFile->save();\n// // attach/replace product main image with new expFile object\n// $product->attachItem($_objFile, 'mainimage');\n// }\n// }\n// for ($i=41; $i<=44; $i++) {\n// if (!empty($data[$i])) {\n// // import image from url\n// $_destFile = basename($data[$i]); // get filename from end of url\n// $_destDir = UPLOAD_DIRECTORY_RELATIVE;\n// $_destFullPath = BASE . $_destDir . $_destFile;\n// if (file_exists($_destFullPath)) {\n// $_destFile = expFile::resolveDuplicateFilename($_destFullPath);\n// $_destFullPath = BASE . $_destDir . $_destFile;\n// }\n//\n// expCore::saveData($data[$i], $_destFullPath); // download the image\n//\n// if (file_exists($_destFullPath)) {\n// $__oldumask = umask(0);\n// chmod($_destFullPath, octdec(FILE_DEFAULT_MODE_STR + 0));\n// umask($__oldumask);\n//\n// // Create a new expFile Object\n// $_fileParams = array('filename' => $_destFile, 'directory' => $_destDir);\n// $_objFile = new expFile ($_fileParams);\n// $_objFile->save();\n// // attach product additional images with new expFile object\n// $product->attachItem($_objFile, 'images', false);\n// }\n// }\n// }\n//\n// if (empty($product->id)) $product->minimum_order_quantity = 1;\n//\n// if ($product->parent_id == 0) {\n// $createCats = array();\n// $createCatsRank = array();\n// for ($x = 19; $x <= 30; $x++) {\n// if (!empty($data[$x])) $result = storeCategory::parseCategory($data[$x]);\n// else continue;\n//\n// if (is_numeric($result)) {\n// $createCats[] = $result;\n// $createCatsRank[$result] = $data[32];\n// } else {\n// $errorSet[$count][] = $result;\n// continue 2;\n// }\n// }\n// }",
" //NOTE: we manipulate existing user input fields to store them properly?\n //eDebug($createCats,true);\n if (!empty($product->user_input_fields) && is_array($product->user_input_fields))\n $product->user_input_fields = serialize($product->user_input_fields);\n //eDebug($product->user_input_fields);",
" if (!empty($product->user_input_fields) && !is_array($product->user_input_fields))\n $product->user_input_fields = str_replace(\"'\", \"\\'\", $product->user_input_fields);",
" //eDebug($product->user_input_fields,true);\n $product->save(true);\n //eDebug($product->body);",
" //sort order and categories\n if ($product->parent_id == 0) {\n $product->saveCategories($createCats, $createCatsRank);\n //eDebug($createCatsRank);\n }\n echo \"Successfully imported/updated row \" . $count . \", product: \" . $product->title . \"<br/>\";\n //eDebug($product);",
" }",
" if (count($errorSet)) {\n echo \"<br/><hr><br/><div style='color:red'><strong>\".gt('The following records were NOT imported').\":</strong><br/>\";\n foreach ($errorSet as $rownum => $err) {\n echo \"Row: \" . $rownum;\n if (is_array($err)) {\n foreach ($err as $e) {\n echo \" -- \" . $e . \"<br/>\";\n }\n } else echo \" -- \" . $err . \"<br/>\";\n }\n echo \"</div>\";\n }",
" fclose($handle);\n ini_set('auto_detect_line_endings',$line_end);",
" // update search index\n $this->addContentToSearch();\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class importexportController extends expController {",
" protected $add_permissions = array(\n 'import' => 'Import Data',\n 'export' => 'Export Data'\n );\n protected $manage_permissions = array(\n 'importProduct' => 'Import Product',\n );",
" // hide the configs we don't need\n public $remove_configs = array(\n 'aggregation',\n 'categories',\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)\n",
"",
"\n static function displayname() {\n return gt(\"Data Import / Export Module\");\n }",
" static function description() {\n return gt(\"Use this module to import and export data from your Exponent website.\");\n }",
" static function hasSources() {\n return false;\n }",
" static function hasContent() {\n return false;\n }",
"// function __construct($src = null, $params = array()) {\n// parent::__construct($src, $params);\n// }",
" function manage() {\n global $available_controllers;",
" expHistory::set('manageable', $this->params);\n $importDD = array();\n $exportDD = array();\n foreach ($available_controllers as $key => $path) {\n if (strpos($key, \"Controller\") !== false) {\n $c = new $key();\n if ($c->canImportData()) $importDD[$key] = $c->name();\n if ($c->canExportData()) $exportDD[$key] = $c->name();\n }\n }\n assign_to_template(array(\n 'importDD' => $importDD,\n 'exportDD' => $exportDD,\n ));\n }",
" function import() {\n $type = expModules::getController($this->params['import_type']);\n if (method_exists($type, 'import')) { // allow for controller specific method\n redirect_to(array('controller'=>$type->baseclassname, 'action'=>'import'));\n }",
" $pullable_modules = expModules::listInstalledControllers($type->baseclassname);\n $modules = new expPaginator(array(\n 'records' => $pullable_modules,\n 'controller' => $this->loc->mod,\n 'action' => $this->params['action'],\n 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\n 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Title') => 'title',\n gt('Page') => 'section'\n ),\n ));",
" assign_to_template(array(\n 'modules' => $modules,\n 'import_type' => $type->baseclassname\n ));\n }",
" function import_select() {\n $type = expModules::getController($this->params['import_type']);\n if (method_exists($type, 'import_select')) { // allow for controller specific method\n redirect_to(array('controller'=>$type->baseclassname, 'action'=>'import_select'));\n }",
" if (empty($this->params['import_aggregate'])) {\n expValidator::setErrorField('import_aggregate[]');\n expValidator::failAndReturnToForm(gt('You must select a module.'), $this->params);\n }",
" //Get the temp directory to put the uploaded file\n $directory = \"tmp\";",
" //Get the file save it to the temp directory\n if (!empty($_FILES[\"import_file\"]) && $_FILES[\"import_file\"][\"error\"] == UPLOAD_ERR_OK) {\n $file = expFile::fileUpload(\"import_file\", false, false, time() . \"_\" . $_FILES['import_file']['name'], $directory.'/');\n if ($file === null) {\n switch ($_FILES[\"import_file\"][\"error\"]) {\n case UPLOAD_ERR_INI_SIZE:\n case UPLOAD_ERR_FORM_SIZE:\n $this->params['_formError'] = gt('The file you attempted to upload is too large. Contact your system administrator if this is a problem.');\n break;\n case UPLOAD_ERR_PARTIAL:\n $this->params['_formError'] = gt('The file was only partially uploaded.');\n break;\n case UPLOAD_ERR_NO_FILE:\n $this->params['_formError'] = gt('No file was uploaded.');\n break;\n default:\n $this->params['_formError'] = gt('A strange internal error has occurred. Please contact the Exponent Developers.');\n break;\n }\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n } else {\n $errors = array();\n $data = expFile::parseDatabase(BASE . $directory . \"/\" . $file->filename, $errors, $type->model_table); //FIXME this may crash on large .eql files\n if (!empty($errors)) {\n $message = gt('Importing encountered the following errors') . ':<br>';\n foreach ($errors as $error) {\n $message .= '* ' . $error . '<br>';\n }\n flash('error', $message);\n }",
" assign_to_template(array(\n 'import_type' => $this->params['import_type'],\n 'items' => $data[$type->model_table]->records,\n 'filename' => $directory . \"/\" . $file->filename,\n 'source' => $this->params['import_aggregate'][0]\n ));\n }\n } else {\n expValidator::setErrorField('import_file');\n expValidator::failAndReturnToForm(gt('File failed to upload.'), $this->params); // file upload error\n }\n }",
" function import_process() {\n $type = expModules::getController($this->params['import_type']);\n if (method_exists($type, 'import_process')) { // allow for controller specific method\n redirect_to(array('controller'=>$type->baseclassname, 'action'=>'import_process'));\n }",
" if (!count($this->params['items'])) {\n expValidator::setErrorField('items');\n expValidator::failAndReturnToForm(gt('You must select at least one item.'), $this->params);",
" }",
" if (!empty($this->params['filename']) && (strpos($this->params['filename'], 'tmp/') === false || strpos($this->params['folder'], '..') !== false)) {\n header('Location: ' . URL_FULL);\n exit(); // attempt to hack the site",
" }",
" $filename = $this->params['filename'];\n $src = $this->params['source'];\n $selected = $this->params['items'];\n $errors = array();\n $model = new $type->basemodel_name;\n $tables = array();\n $attached = $model->getAttachableItemTables();\n foreach ($attached as $link=>$model) {\n $tables[] = $link;\n $attach = new $model;\n $tables[] = $attach->tablename;\n }\n array_unshift($tables, $type->model_table);\n $data = expFile::parseDatabase(BASE . $filename, $errors, $tables); //FIXME this may crash on large .eql files",
" // parse out attachments data using the content_id for easier access\n $attachments = array();\n foreach ($attached as $link=>$model) {\n if (!empty($data[$link]->records)) {\n $attachments[$link] = array();\n foreach ($data[$link]->records as $item) {\n $attachments[$link][$item['content_id']] = $item;\n }\n $attach = new $model;\n foreach ($data[$attach->tablename]->records as $item) {\n $attachments[$link][$item['id']]['content'] = $item;\n }\n }\n }",
" foreach ($selected as $select) {\n $current_id = $data[$type->model_table]->records[$select]['id'];\n unset( // clear out the stuff that gets auto-set when integrated into existing records\n $data[$type->model_table]->records[$select]['id'],\n $data[$type->model_table]->records[$select]['sef_url'],\n $data[$type->model_table]->records[$select]['rank']\n );\n $data[$type->model_table]->records[$select]['location_data'] = serialize(expCore::makeLocation($type->baseclassname, $src));\n $item = new $type->basemodel_name($data[$type->model_table]->records[$select]); // create new populated record to auto-set things\n $item->update();",
" if ($this->params['import_attached']) {\n $params = array();;\n foreach ($attached as $link=>$model) {\n foreach ($attachments[$link] as $aitem) {\n if ($aitem['content_id'] == $current_id) {\n //$item is content_ record\n //$item['content'] is the attachment\n switch ($model) {\n case 'expCat':\n foreach ($data['expCats']->records as $key=>$ct) {\n if ($ct['id'] == $aitem['expcats_id']) {\n $cat = new expCat($ct['title']);\n if (empty($cat->id)) {\n $cat->title = $ct['title'];\n $cat->module = $type->baseclassname;\n $cat->save();\n }\n $params['expCat'][] = $cat->id;\n }\n }\n break;\n case 'expComment':\n foreach ($data['expComments']->records as $key=>$cm) {\n unset($cm['id']);\n $cm['parent_id'] = 0; //fixme this flattens reply comments\n $comment = new expComment($cm);\n $comment->update(); // create and attach the comment\n $comment->attachComment($type->baseclassname, $item->id, $aitem['subtype']);\n }\n break;\n case 'expFile':\n //FIXME we can't handle file attachments since this is only a db import\n break;\n case 'expTag':\n foreach ($data['expTags']->records as $key=>$tg) {\n if ($tg['id'] == $aitem['exptags_id']) {\n $tag = new expTag($tg['title']);\n if (empty($tag->id))\n $tag->update(array('title'=>$tg['title']));\n $params['expTag'][] = $tag->id;\n }\n }\n break;\n }\n }\n }\n }\n $item->update($params); // add expCat & expTag attachments to item\n }\n }\n unlink($this->params['filename']);",
" // update search index\n $type->addContentToSearch();",
" flashAndFlow('message', count($selected) . ' ' . $type->baseclassname . ' ' . gt('items were imported.'));\n }",
" function export() {\n $type = expModules::getController($this->params['export_type']);\n if (method_exists($type, 'export')) { // allow for controller specific method\n redirect_to(array('controller'=>$type->baseclassname, 'action'=>'export'));\n }",
" $pullable_modules = expModules::listInstalledControllers($type->baseclassname);\n $modules = new expPaginator(array(\n 'records' => $pullable_modules,\n 'controller' => $this->loc->mod,\n 'action' => $this->params['action'],\n 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\n 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Title') => 'title',\n gt('Page') => 'section'\n ),\n ));\n assign_to_template(array(\n 'modules' => $modules,\n 'export_type' => $type->baseclassname\n ));\n }",
" function export_process() {\n $type = expModules::getController($this->params['export_type']);\n if (method_exists($type, 'export_process')) { // allow for controller specific method\n redirect_to(array('controller'=>$type->baseclassname, 'action'=>'export_process'));\n }",
" if (!empty($this->params['export_aggregate'])) {\n $tables = array($type->model_table);\n $selected = $this->params['export_aggregate'];\n $where = '(';\n foreach ($selected as $key=>$src) {\n if ($key) $where .= ' OR ';\n $where .= \"location_data='\" . serialize(expCore::makeLocation($type->baseclassname, $src)) . \"'\";\n }\n $where .= ')';\n $awhere[] = $where;",
" if ($this->params['export_attached']) {\n $model = new $type->basemodel_name;\n foreach ($model->getAttachableItemTables() as $link=>$model) {\n $tables[] = $link;\n $awhere[] = \"content_type='\" . $type->baseclassname . \"'\";\n $attach = new $model;\n $tables[] = $attach->tablename;\n $awhere[] = '';\n }\n }",
" $filename = $type->baseclassname . '.eql';",
" ob_end_clean();\n ob_start(\"ob_gzhandler\");",
" // 'application/octet-stream' is the registered IANA type but\n // MSIE and Opera seems to prefer 'application/octetstream'\n $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';",
" header('Content-Type: ' . $mime_type);\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n // IE need specific headers\n if (EXPONENT_USER_BROWSER == 'IE') {\n header('Content-Disposition: inline; filename=\"' . $filename . '\"');\n header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n header('Pragma: public');\n } else {\n header('Content-Disposition: attachment; filename=\"' . $filename . '\"');\n header('Pragma: no-cache');\n }\n echo expFile::dumpDatabase($tables, 'export', $awhere); //FIXME we need to echo inside call\n exit; // Exit, since we are exporting\n }\n expHistory::back();\n }",
" function validate() {\n// global $db;",
" //eDebug($this->params,true);",
" set_time_limit(0);\n //$file = new expFile($this->params['expFile']['import_file'][0]);\n if (!empty($_FILES['import_file']['error'])) {\n flash('error', gt('There was an error uploading your file. Please try again.'));\n redirect_to(array('controller' => 'store', 'action' => 'import_external_addresses'));\n }",
" $file = new stdClass();\n $file->path = $_FILES['import_file']['tmp_name'];\n echo gt(\"Attempting import\").\"...<br/>\";",
" $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $checkhandle = fopen($file->path, \"r\");\n $checkdata = fgetcsv($checkhandle, 10000, \",\");\n $fieldCount = count($checkdata);",
" $count = 1;\n while (($checkdata = fgetcsv($checkhandle, 10000, \",\")) !== FALSE) {\n $count++;\n if (count($checkdata) != $fieldCount) {\n echo gt(\"Line \") . $count . \" \".gt(\"of your CSV import file does not contain the correct number of columns.\").\"<br/>\";\n echo gt(\"Found\").\" \" . $fieldCount . \" \".gt(\"header fields, but only\").\" \" . count($checkdata) . \" \".gt(\"field in row\").\" \" . $count . \" \".gt(\"Please check your file and try again.\");\n exit();\n }\n }\n fclose($checkhandle);\n ini_set('auto_detect_line_endings',$line_end);",
" echo \"<br/>\" . gt(\"CSV File passed validation\") . \"...<br/>\";",
" if ($this->params['import_type'] == 'store') $this->importProduct($file);\n //else if($this->params['import_type'] == 'address') $this->importAddresses($file);\n }",
" /*function importAddresses($file)\n {\n $handle = fopen($file->path, \"r\");\n $data = fgetcsv($handle, 10000, \",\");",
" //eDebug($data);\n $source = '';",
" foreach ($data as $key=>$value)\n {",
" $dataset[$value] = '';",
" if($key == 2 && $value=='Unique_Bill_Name') $source = '1'; //SMC\n }",
"",
" //eDebug($source);\n //eDebug($dataset,true);\n $count = 1;\n $errorSet = array();\n $successSet = array();\n eDebug($dataset);",
"",
" $extAddy = null;\n while (($data = fgetcsv($handle, 10000, \",\")) !== FALSE) {\n $count++;",
" $extAddy = new external_address();",
" $bName = explode(' ',$data[3]);\n eDebug($bName);\n $extAddy->firstname = $bName[0];\n if(count($bName) == 3)\n {\n $extAddy->middlename = $bName[1];",
" $extAddy->lastname = $bName[2];",
" }\n else if (count($bName) ==1)\n {\n $extAddy->middlename = '';",
" $extAddy->lastname = '';",
" }\n else\n {\n $extAddy->middlename = '';",
" $extAddy->lastname = $bName[1];\n }\n",
" $extAddy->organization = $data[4];\n $extAddy->address1 = $data[5];",
" $extAddy->address2 = $data[6];\n $extAddy->address2 = $data[6];\n $extAddy->city = $data[7];\n",
" $s = new geoRegion();\n $state = $s->find('first','code=\"'.trim($data[8]).'\"');\n eDebug($state);",
" $extAddy->state = $state->id;\n $extAddy->zip = str_ireplace(\"'\",'',$data[9]);\n $extAddy->phone = $data[20];\n $extAddy->email = $data[21];",
" $extAddy->source = $source;",
"\n",
" //shipping\n if($data[3] == $data[12] && $data[5] == $data[14] && $data[6] == $data[15]) //shipping and billing same\n {\n $extAddy->is_billing = 1;",
" $extAddy->is_shipping = 1;\n $extAddy->save(false);",
" }\n else",
" {",
" $extAddy->is_billing = 1;",
" $extAddy->is_shipping = 0;\n $extAddy->save(false);",
" $extAddy = new external_address();",
" $sName = explode(' ',$data[12]);\n eDebug($sName);\n $extAddy->firstname = $sName[0];\n if(count($sName) == 3)\n {\n $extAddy->middlename = $sName[1];",
" $extAddy->lastname = $sName[2];",
" }\n else if (count($sName) ==1)\n {\n $extAddy->middlename = '';",
" $extAddy->lastname = '';",
" }\n else\n {\n $extAddy->middlename = '';",
" $extAddy->lastname = $sName[1];\n }\n",
" $extAddy->organization = $data[13];\n $extAddy->address1 = $data[14];",
" $extAddy->address2 = $data[15];\n $extAddy->city = $data[16];\n",
" $s = new geoRegion();\n $state = $s->find('first','code=\"'.trim($data[17]).'\"');\n eDebug($state);",
" $extAddy->state = $state->id;\n $extAddy->zip = str_ireplace(\"'\",'',$data[18]);\n $extAddy->phone = $data[20];\n $extAddy->email = $data[21];",
" $extAddy->is_billing = 0;\n $extAddy->is_shipping = 1;",
" $extAddy->source = $source;\n",
" $extAddy->save(false);\n }",
"",
" echo \"Successfully imported row \" . $count . \", name: \" . $extAddy->firstname . \" \" . $extAddy->lastname . \"<br/>\";\n //eDebug($product);",
"\n }\n",
" if(count($errorSet))\n {\n echo \"<br/><hr><br/><font color='red'>The following records were NOT imported:<br/>\";\n foreach ($errorSet as $row=>$err)\n {\n echo \"Row: \" . $row . \". Reason:<br/>\";\n if (is_array($err))\n {\n foreach ($err as $e)\n {\n echo \"--\" . $e . \"<br/>\";\n }\n }\n else echo \"--\" . $err . \"<br/>\";\n }\n echo \"</font>\";",
" }",
" }*/",
" function importProduct($file=null) {\n if (empty($file->path)) {\n $file = new stdClass();\n $file->path = $_FILES['import_file']['tmp_name'];\n }\n if (empty($file->path)) {\n echo gt('Not a Product Import CSV File');\n return;\n }\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $handle = fopen($file->path, \"r\");",
" // read in the header line\n $header = fgetcsv($handle, 10000, \",\");\n if (!($header[0] == 'id' || $header[0] == 'model')) {\n echo gt('Not a Product Import CSV File');\n return;\n }",
" $count = 1;\n $errorSet = array();\n $product = null;\n /* original order of columns\n 0=id\n 1=parent_id\n 2=child_rank\n 3=title\n 4=body\n 5=model\n 6=warehouse_location\n 7=sef_url\n//FIXME this is where canonical should be\n 8=meta_title\n 9=meta_keywords\n 10=meta_description\n 11=tax_class_id\n 12=quantity\n 13=availability_type\n 14=base_price\n 15=special_price\n 16=use_special_price\n 17=active_type\n 18=product_status_id\n 19=category1\n 20=category2\n 21=category3\n 22=category4\n ..\n 30=category12\n 31=surcharge\n 32=rank category_rank\n 33=feed_title\n 34=feed_body\n 35=weight\n 36=height\n 37=width\n 38=length\n 39=companies_id\n 40=image1 url to mainimage to download\n 41=image2 url to additional image to download\n ..\n 44=image5 url to additional image to download\n*/",
" // read in the data lines\n// while (($data = fgetcsv($handle, 10000, \",\")) !== FALSE) {\n while (($row = fgetcsv($handle, 10000, \",\")) !== FALSE) {\n $count++;\n $createCats = array();\n $createCatsRank = array();\n $data = array_combine($header, $row);",
" //eDebug($data, true);\n if ($header[0] == 'id') {\n if (isset($data['id']) && $data['id'] != 0) {\n $product = new product($data['id'], false, false);\n if (empty($product->id)) {\n $errorSet[$count] = gt(\"Is not an existing product ID.\");\n continue;\n }\n } else {\n //$errorSet[$count] = \"Product ID not supplied.\";\n //continue;\n $product = new product();\n //$product->save(false);\n }\n } elseif ($header[0] == 'model') {\n if (!empty($data['model'])) {\n $p = new product();\n $product = $p->find('first','model=\"' . $data['model'] . '\"');\n if (empty($product->id)) {\n $errorSet[$count] = gt(\"Is not an existing product SKU/Model.\");\n continue;\n }\n } else {\n $product = new product();\n }\n }\n if ($product->product_type != 'product') {\n $errorSet[$count] = gt(\"Existing product is wrong product type.\");\n continue;\n }",
" // new products must have a title\n if (empty($product->id)) { // new product require mandatory values\n $checkTitle = trim($data['title']);\n if (empty($checkTitle)) {\n $errorSet[$count] = gt(\"No product name (title) supplied.\");\n continue;\n }\n $product->minimum_order_quantity = 1;\n }",
" // parse $data columns\n foreach ($data as $key=>$value) {\n $value = trim($value);\n switch ($key) {\n case 'parent_id': // integer\n case 'child_rank':\n case 'tax_class_id':\n case 'quantity':\n case 'availability_type':\n case 'use_special_price':\n case 'active_type':\n case 'product_status_id':\n $product->$key = intval($value);\n break;\n case 'companies_id':\n if (is_numeric($value)) {\n $product->$key = intval($value);\n } elseif (!empty($value)) { // it's a company name, not a company id#\n $co = new company();\n $company = $co->find('first', 'title=' . $value);\n if (empty($company->id)) {\n $params['title'] = $value;\n $company->update();\n }\n $product->$key = $company->id;\n }\n break;\n case 'sef_url':\n $product->$key = stripslashes(stripslashes($value));\n if (!is_bool(expValidator::uniqueness_of('sef_url', $product, array()))) {\n $product->makeSefUrl();\n }\n break;\n case 'title': // string\n case 'model':\n case 'warehouse_location':\n case 'meta_title':\n case 'meta_keywords':\n case 'meta_description':\n case 'feed_title':\n case 'feed_body':\n $product->$key = stripslashes(stripslashes($value));\n break;\n case 'body':\n $product->$key = utf8_encode(stripslashes(expString::parseAndTrimImport(($value), true)));\n break;\n case 'base_price': // float\n case 'special_price':\n case 'surcharge':\n case 'weight':\n case 'height':\n case 'width':\n case 'length':\n $product->$key = floatval($value);\n break;\n case 'image1':\n case 'image2':\n case 'image3':\n case 'image4':\n case 'image5':\n if (!empty($value)) {\n $product->save(false);\n if (is_integer($value)) {\n $_objFile = new expFile ($value);\n } else {\n // import image from url\n $_destFile = basename($value); // get filename from end of url\n $_destDir = UPLOAD_DIRECTORY_RELATIVE;\n $_destFullPath = BASE . $_destDir . $_destFile;\n if (file_exists($_destFullPath)) {\n $_destFile = expFile::resolveDuplicateFilename($_destFullPath);\n $_destFullPath = BASE . $_destDir . $_destFile;\n }",
" expCore::saveData($value, $_destFullPath); // download the image",
" if (file_exists($_destFullPath)) {\n $__oldumask = umask(0);\n chmod($_destFullPath, octdec(FILE_DEFAULT_MODE_STR + 0));\n umask($__oldumask);",
" // Create a new expFile Object\n $_fileParams = array('filename' => $_destFile, 'directory' => $_destDir);\n $_objFile = new expFile ($_fileParams);\n $_objFile->save();\n }\n }\n // attach product images expFile object\n if (!empty($_objFile->id)) {\n if ($key == 'image1') {\n $product->attachItem($_objFile, 'mainimage');\n } else {\n $product->attachItem($_objFile, 'images', false);\n }\n }\n }\n break;\n case 'category1':\n case 'category2':\n case 'category3':\n case 'category4':\n case 'category5':\n case 'category6':\n case 'category7':\n case 'category8':\n case 'category9':\n case 'category10':\n case 'category11':\n case 'category12':\n if ($product->parent_id == 0) {\n// $rank = !empty($data['rank']) ? $data['rank'] : 1;\n $rank = intval(str_replace('category', '', $key));\n// if (!empty($value)) $result = storeCategory::parseCategory($value);\n if (!empty($value)) $result = storeCategory::importCategoryString($value);\n else continue;",
"// if (is_numeric($result)) {\n if ($result) {\n $createCats[] = $result;\n $createCatsRank[$result] = $rank;\n } else {\n $errorSet[$count][] = $result;\n continue 2;\n }\n }\n break;\n default:\n if (property_exists('product', $key)) {\n $product->key = $value;\n }\n }\n }",
"// $checkTitle = trim($data['title']);\n// if (empty($checkTitle)) {\n// $errorSet[$count] = gt(\"No product name (title) supplied, skipping this record...\");\n// continue;\n// }\n// $product->parent_id = $data[1];\n// $product->child_rank = $data[2];\n// $product->title = stripslashes(stripslashes($data[3]));\n// $product->body = utf8_encode(stripslashes(expString::parseAndTrimImport(($data[4]), true)));\n// //$product->body = utf8_encode(stripslashes(stripslashes(($data[4]))));\n// $product->model = stripslashes(stripslashes($data[5]));\n// $product->warehouse_location = stripslashes(stripslashes($data[6]));\n// $product->sef_url = stripslashes(stripslashes($data[7]));\n////FIXME this is where canonical should be\n// $product->meta_title = stripslashes(stripslashes($data[8]));\n// $product->meta_keywords = stripslashes(stripslashes($data[9]));\n// $product->meta_description = stripslashes(stripslashes($data[10]));\n//\n// $product->tax_class_id = $data[11];\n//\n// $product->quantity = $data[12];\n//\n// $product->availability_type = $data[13];\n//\n// $product->base_price = $data[14];\n// $product->special_price = $data[15];\n// $product->use_special_price = $data[16];\n// $product->active_type = $data[17];\n// $product->product_status_id = $data[18];\n//\n// $product->surcharge = $data[31];\n// $product->feed_title = stripslashes(stripslashes($data[33]));\n// $product->feed_body = stripslashes(stripslashes($data[34]));\n// if (!empty($data[35])) $product->weight = $data[35];\n// if (!empty($data[36])) $product->height = $data[36];\n// if (!empty($data[37])) $product->width = $data[37];\n// if (!empty($data[38])) $product->length = $data[38];\n// if (!empty($data[39])) $product->companies_id = $data[39];\n// if (!empty($data[40])) {\n// // import image from url\n// $_destFile = basename($data[40]); // get filename from end of url\n// $_destDir = UPLOAD_DIRECTORY_RELATIVE;\n// $_destFullPath = BASE . $_destDir . $_destFile;\n// if (file_exists($_destFullPath)) {\n// $_destFile = expFile::resolveDuplicateFilename($_destFullPath);\n// $_destFullPath = BASE . $_destDir . $_destFile;\n// }\n//\n// expCore::saveData($data[40], $_destFullPath); // download the image\n//\n// if (file_exists($_destFullPath)) {\n// $__oldumask = umask(0);\n// chmod($_destFullPath, octdec(FILE_DEFAULT_MODE_STR + 0));\n// umask($__oldumask);\n//\n// // Create a new expFile Object\n// $_fileParams = array('filename' => $_destFile, 'directory' => $_destDir);\n// $_objFile = new expFile ($_fileParams);\n// $_objFile->save();\n// // attach/replace product main image with new expFile object\n// $product->attachItem($_objFile, 'mainimage');\n// }\n// }\n// for ($i=41; $i<=44; $i++) {\n// if (!empty($data[$i])) {\n// // import image from url\n// $_destFile = basename($data[$i]); // get filename from end of url\n// $_destDir = UPLOAD_DIRECTORY_RELATIVE;\n// $_destFullPath = BASE . $_destDir . $_destFile;\n// if (file_exists($_destFullPath)) {\n// $_destFile = expFile::resolveDuplicateFilename($_destFullPath);\n// $_destFullPath = BASE . $_destDir . $_destFile;\n// }\n//\n// expCore::saveData($data[$i], $_destFullPath); // download the image\n//\n// if (file_exists($_destFullPath)) {\n// $__oldumask = umask(0);\n// chmod($_destFullPath, octdec(FILE_DEFAULT_MODE_STR + 0));\n// umask($__oldumask);\n//\n// // Create a new expFile Object\n// $_fileParams = array('filename' => $_destFile, 'directory' => $_destDir);\n// $_objFile = new expFile ($_fileParams);\n// $_objFile->save();\n// // attach product additional images with new expFile object\n// $product->attachItem($_objFile, 'images', false);\n// }\n// }\n// }\n//\n// if (empty($product->id)) $product->minimum_order_quantity = 1;\n//\n// if ($product->parent_id == 0) {\n// $createCats = array();\n// $createCatsRank = array();\n// for ($x = 19; $x <= 30; $x++) {\n// if (!empty($data[$x])) $result = storeCategory::parseCategory($data[$x]);\n// else continue;\n//\n// if (is_numeric($result)) {\n// $createCats[] = $result;\n// $createCatsRank[$result] = $data[32];\n// } else {\n// $errorSet[$count][] = $result;\n// continue 2;\n// }\n// }\n// }",
" //NOTE: we manipulate existing user input fields to store them properly?\n //eDebug($createCats,true);\n if (!empty($product->user_input_fields) && is_array($product->user_input_fields))\n $product->user_input_fields = serialize($product->user_input_fields);\n //eDebug($product->user_input_fields);",
" if (!empty($product->user_input_fields) && !is_array($product->user_input_fields))\n $product->user_input_fields = str_replace(\"'\", \"\\'\", $product->user_input_fields);",
" //eDebug($product->user_input_fields,true);\n $product->save(true);\n //eDebug($product->body);",
" //sort order and categories\n if ($product->parent_id == 0) {\n $product->saveCategories($createCats, $createCatsRank);\n //eDebug($createCatsRank);\n }\n echo \"Successfully imported/updated row \" . $count . \", product: \" . $product->title . \"<br/>\";\n //eDebug($product);",
" }",
" if (count($errorSet)) {\n echo \"<br/><hr><br/><div style='color:red'><strong>\".gt('The following records were NOT imported').\":</strong><br/>\";\n foreach ($errorSet as $rownum => $err) {\n echo \"Row: \" . $rownum;\n if (is_array($err)) {\n foreach ($err as $e) {\n echo \" -- \" . $e . \"<br/>\";\n }\n } else echo \" -- \" . $err . \"<br/>\";\n }\n echo \"</div>\";\n }",
" fclose($handle);\n ini_set('auto_detect_line_endings',$line_end);",
" // update search index\n $this->addContentToSearch();\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\n##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class migrationController extends expController {",
" protected $add_permissions = array(",
" 'analyze'=>'Analyze Data',\n 'migrate'=>'Migrate Data'\n );",
" // this is a list of modules that we can convert to exp2 type modules.\n public $new_modules = array(\n// 'addressbookmodule'=>'address',\n 'imagegallerymodule'=>'photo',\n 'linklistmodule'=>'links',\n 'newsmodule'=>'news',\n 'slideshowmodule'=>'photo',\n 'snippetmodule'=>'snippet',\n 'swfmodule'=>'text',\n 'textmodule'=>'text',\n 'resourcesmodule'=>'filedownload',\n 'rotatormodule'=>'text',\n 'faqmodule'=>'faq',\n 'headlinemodule'=>'text',\n 'linkmodule'=>'links',\n 'weblogmodule'=>'blog',\n 'listingmodule'=>'portfolio',\n 'youtubemodule'=>'media',\n 'mediaplayermodule'=>'media',\n 'bannermodule'=>'banner',\n 'feedlistmodule'=>'rss',\n 'simplepollmodule'=>'simplePoll',\n 'navigationmodule'=>'navigation',\n 'calendarmodule'=>'event',\n 'formmodule'=>'forms',\n 'contactmodule'=>'forms', // this module is converted to a functionally similar form\n 'containermodule'=>'container',\n );",
" // these are modules that have either been deprecated or have no content to migrate\n // Not sure we need to note deprecated modules...\n public $deprecated_modules = array(\n 'administrationmodule',\n// 'containermodule', // not really deprecated, but must be in this list to skip processing?\n// 'navigationmodule', // views are still used, so modules need to be imported?\n 'loginmodule',\n 'searchmodule', \n 'imagemanagermodule',\n 'imageworkshopmodule',\n 'inboxmodule',\n 'rssmodule',\n// the following 0.97/98 modules were added to this list\n 'articlemodule',\n 'bbmodule',\n 'pagemodule',\n 'previewmodule',\n 'tasklistmodule',\n 'wizardmodule',\n// other older or user-contributed modules we don't want to deal with\n 'addressbookmodule', // moved to deprecated list since this is NOT the type of address we use in 2.x\n 'cataloguemodule',\n 'codemapmodule',\n 'extendedlistingmodule',\n 'googlemapmodule',\n 'greekingmodule',\n 'guestbookmodule',\n 'keywordmodule',\n 'sharedcoremodule',\n 'svgallerymodule',\n 'uiswitchermodule',\n 'filemanagermodule',\n );",
"\t/**\n\t * name of module\n\t * @return string\n\t */\n static function displayname() { return gt(\"Content Migration Controller\"); }",
"\t/**\n\t * description of module\n\t * @return string\n\t */\n static function description() { return gt(\"Use this module to pull Exponent 1 style content from your old site.\"); }",
"\t/**\n\t * if module has associated sources\n\t * @return bool\n\t */\n static function hasSources() { return false; }",
"\t/**\n\t * if module has associated content\n\t * @return bool\n\t */\n static function hasContent() { return false; }",
"\t/**\n\t * gather info about all pages in old site for user selection\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function manage_pages() {\n global $db;",
" expHistory::set('manageable', $this->params);\n $old_db = $this->connect();\n $pages = $old_db->selectObjects('section','id > 1');\n foreach($pages as $page) {\n\t\t\tif ($db->selectObject('section',\"id='\".$page->id.\"'\")) {\n\t\t\t\t$page->exists = true;\n\t\t\t} else {\n\t\t\t\t$page->exists = false;\n\t\t\t}\n\t\t}\n assign_to_template(array(\n 'pages'=>$pages\n ));\n }",
"\t/**\n\t * copy selected pages over from old site\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function migrate_pages() {\n global $db;",
"\t\t$del_pages = '';\n if (isset($this->params['wipe_pages'])) {\n $db->delete('section',\"id > '1'\");\n\t\t\t$del_pages = ' '.gt('after clearing database of pages');\n\t\t}\n $successful = 0;\n $failed = 0;\n $old_db = $this->connect();\n\t\tif (!empty($this->params['pages'])) {\n\t\t\tforeach($this->params['pages'] as $pageid) {\n\t\t\t\t$page = $old_db->selectObject('section', 'id='.$pageid);\n\t\t\t\t// make sure the SEF name is valid\n\t\t\t\tglobal $router;\n\t\t\t\tif (empty($page->sef_name)) {\n\t\t\t\t\tif (isset($page->name)) {\n\t\t\t\t\t\t$page->sef_name = $router->encode($page->name);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$page->sef_name = $router->encode('Untitled');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t$dupe = $db->selectValue('section', 'sef_name', 'sef_name=\"'.$page->sef_name.'\"');\n\t\t\t\tif (!empty($dupe)) {\n\t\t\t\t\tlist($u, $s) = explode(' ',microtime());\n $page->sef_name .= '-'.$s.'-'.$u;\n\t\t\t\t}\n// $page->sef_name = $page->sef_name;\n// unset($page->sef_name);\n\t\t\t\t$ret = $db->insertObject($page, 'section');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$failed++;\n\t\t\t\t} else {\n\t\t\t\t\t$successful++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!empty($this->params['rep_pages'])) {\n\t\t\tforeach($this->params['rep_pages'] as $pageid) {\n\t\t\t\t$db->delete('section','id='.$pageid);\n\t\t\t\t$page = $old_db->selectObject('section', 'id='.$pageid);\n\t\t\t\t// make sure the SEF name is valid\n\t\t\t\tglobal $router;\n\t\t\t\tif (empty($page->sef_name)) {\n\t\t\t\t\tif (isset($page->name)) {\n\t\t\t\t\t\t$page->sef_name = $router->encode($page->name);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$page->sef_name = $router->encode('Untitled');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t$dupe = $db->selectValue('section', 'sef_name', 'sef_name=\"'.$page->sef_name.'\"');\n\t\t\t\tif (!empty($dupe)) {\n\t\t\t\t\tlist($u, $s) = explode(' ',microtime());\n $page->sef_name .= '-'.$s.'-'.$u;\n\t\t\t\t}\n// $page->sef_name = $page->sef_name;\n// unset($page->sef_name);\n\t\t\t\t$ret = $db->insertObject($page, 'section');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$failed++;\n\t\t\t\t} else {\n\t\t\t\t\t$successful++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"\t\tif (isset($this->params['copy_permissions'])) {\n\t\t\t$db->delete('userpermission',\"module = 'navigation' AND source = ''\");\n\t\t\t$db->delete('grouppermission',\"module = 'navigation' AND source = ''\");\n\t\t\t\n\t\t\t$users = $db->selectObjects('user','id > 1');\n\t\t\tforeach($users as $user) {\n\t\t\t\t$pages = $old_db->selectObjects('userpermission',\"uid='\".$user->id.\"' AND module = 'navigationmodule' AND source = ''\");\n\t\t\t\tforeach($pages as $page) {\n\t\t\t\t\tif ($db->selectObject('section','id = '.$page->internal)) {\n\t\t\t\t\t\t if ($page->permission != 'administrate') {\n $page->module = 'navigation';\n\t\t\t\t\t\t\t $db->insertObject($page,'userpermission');\n\t\t\t\t\t\t }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\t\t\n\t\t\t$groups = $db->selectObjects('group','1');\n\t\t\tforeach($groups as $group) {\n\t\t\t\t$pages = $old_db->selectObjects('grouppermission',\"gid='\".$group->id.\"' AND module = 'navigationmodule' AND source = ''\");\n\t\t\t\tforeach($pages as $page) {\n\t\t\t\t\tif ($db->selectObject('section','id = '.$page->internal)) {\n\t\t\t\t\t\t if ($page->permission != 'administrate') {\n $page->module = 'navigation';\n\t\t\t\t\t\t\t $db->insertObject($page,'grouppermission');\n\t\t\t\t\t\t }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\t\t\n\t\t}",
" flash('message', $successful.' '.gt('pages were imported from').' '.$this->config['database'].$del_pages);\n if ($failed > 0) {\n flash('error', $failed.' '.gt('pages could not be imported from').' '.$this->config['database'].' '.gt('This is usually because a page with the same ID already exists in the database you importing to.'));\n }",
" expSession::clearCurrentUserSessionCache();\n expHistory::back();\n }",
"\t/**\n\t * gather info about all files in old site for user selection\n\t * @return void\n\t */\n public function manage_files() {\n expHistory::set('manageable', $this->params);\n $old_db = $this->connect();\n $files = $old_db->selectObjects('file');\n assign_to_template(array(\n 'count'=>count($files)\n ));\n }",
"\t/**\n\t * copy selected file information (not the files themselves) over from old site\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function migrate_files() {\n global $db;",
" expHistory::set('manageable', $this->params);\n $old_db = $this->connect();\n $db->delete('expFiles');",
" //import the files\n $oldfiles = $old_db->selectObjects('file');\n foreach ($oldfiles as $oldfile) {\n unset(\n $oldfile->name,\n $oldfile->collection_id\n );\n $file = $oldfile;\n $file->directory = $file->directory.\"/\";\n $db->insertObject($file,'expFiles');\n\t\t\t$oldfile->exists = file_exists(BASE.$oldfile->directory.\"/\".$oldfile->filename);\n\t\t}\n assign_to_template(array(\n 'files'=>$oldfiles,\n 'count'=>count($oldfiles)\n ));\n }",
"\t/**\n\t * gather info about all modules in old site for user selection\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function manage_content() {\n //global $db;\n //$containers = $db->selectObjects('container', 'external=\"N;\"');\n //eDebug($containers);\n $old_db = $this->connect();",
" $sql = 'SELECT *, COUNT(module) as count FROM '.$this->config['prefix'].'_sectionref WHERE is_original=1 GROUP BY module';\n $modules = $old_db->selectObjectsBySql($sql);\n\t\tfor ($i = 0, $iMax = count($modules); $i < $iMax; $i++) {\n if (array_key_exists($modules[$i]->module, $this->new_modules)) {\n $newmod = expModules::getController($this->new_modules[$modules[$i]->module]);\n// $newmod = $this->new_modules[$modules[$i]->module];\n $modules[$i]->action = '<span style=\"color:green;\">'.gt('Converting content to').' '.$newmod->displayname().\"</span>\";\n// $modules[$i]->action = '<span style=\"color:green;\">'.gt('Converting content to').' '.$newmod::displayname().\"</span>\"; //TODO this doesn't work w/ php 5.2\n } elseif (in_array($modules[$i]->module, $this->deprecated_modules)) {\n // $modules[$i]->action = '<span style=\"color:red;\">This module is deprecated and will not be migrated.</span>';\n $modules[$i]->notmigrating = 1;\n// } elseif (in_array($modules[$i]->module, $this->needs_written)) {\n// $modules[$i]->action = '<span style=\"color:orange;\">'.gt('Still needs migration script written').'</span>';\n } else {\n $modules[$i]->action = gt('Migrating as is.');\n }\n }\n //eDebug($modules);",
" assign_to_template(array(\n 'modules'=>$modules\n ));\n }",
"\t/**\n\t * copy selected modules and their contents over from old site\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function migrate_content() {\n global $db;",
" $old_db = $this->connect();\n if (isset($this->params['wipe_content'])) {\n $db->delete('sectionref');\n $db->delete('container');\n $db->delete('text');\n $db->delete('snippet');\n $db->delete('links');\n $db->delete('news');\n// $db->delete('filedownloads');\n $db->delete('filedownload');\n $db->delete('photo');\n $db->delete('headline');\n $db->delete('blog');\n// $db->delete('faqs');\n $db->delete('faq');\n $db->delete('portfolio');\n $db->delete('media');\n $db->delete('banner');\n $db->delete('companies');\n $db->delete('addresses');\n $db->delete('content_expComments');\n $db->delete('content_expFiles');\n $db->delete('content_expSimpleNote');\n $db->delete('content_expTags');\n $db->delete('content_expCats');\n $db->delete('expComments');\n $db->delete('expConfigs', 'id>1'); // don't delete migration config\n// $db->delete('expFiles');\t\t\t// deleted and rebuilt during (previous) file migration\n $db->delete('expeAlerts');\n $db->delete('expeAlerts_subscribers');\n $db->delete('expeAlerts_temp');\n $db->delete('expSimpleNote');\n $db->delete('expRss');\n $db->delete('expCats');\n $db->delete('calendar');\n $db->delete('eventdate');\n $db->delete('calendarmodule_config');\n $db->delete('calendar_external');\n $db->delete('calendar_reminder_address');\n $db->delete('event');\n $db->delete('poll_question');\n $db->delete('poll_answer');\n $db->delete('poll_timeblock');\n $db->delete('simplepollmodule_config');\n $db->delete('simplepoll_question');\n $db->delete('simplepoll_answer');\n $db->delete('simplepoll_timeblock');\n $db->delete('formbuilder_address');\n $db->delete('formbuilder_control');\n $db->delete('formbuilder_form');\n $db->delete('formbuilder_report');\n $db->delete('forms');\n $db->delete('forms_control');\n @$this->msg['clearedcontent']++;\n }\n\t\t\n\t\tif (!empty($this->params['replace'])) {\n\t\t\tforeach($this->params['replace'] as $replace) {\n\t\t\t\tswitch ($replace) {\n\t\t\t\t case 'containermodule':\n\t\t\t\t\t $db->delete('container');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'textmodule':\n\t\t\t\t\tcase 'rotatormodule':\n\t\t\t\t\tcase 'swfmodule':\n\t\t\t\t\t\t$db->delete('text');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'snippetmodule':\n\t\t\t\t\t\t$db->delete('snippet');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'linklistmodule':\n\t\t\t\t\tcase 'linkmodule':\n\t\t\t\t\t\t$db->delete('links');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'newsmodule':\n\t\t\t\t\t\t$db->delete('news');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'resourcesmodule':\n//\t\t\t\t\t\t$db->delete('filedownloads');\n $db->delete('filedownload');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'imagegallerymodule':\n\t\t\t\t\tcase 'slideshowmodule':\n\t\t\t\t\t\t$db->delete('photo');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'headlinemodule':\n\t\t\t\t\t\t$db->delete('headline');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'weblogmodule':\n\t\t\t\t\t\t$db->delete('blog');\n\t\t\t\t\t\t$db->delete('expComments');\n\t\t\t\t\t\t$db->delete('content_expComments');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'faqmodule':\n\t\t\t\t\t\t$db->delete('faq');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'listingmodule':\n\t\t\t\t\t\t$db->delete('portfolio');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'calendarmodule':\n\t\t\t\t\t\t$db->delete('calendar');\n\t\t\t\t\t\t$db->delete('eventdate');\n\t\t\t\t\t\t$db->delete('calendarmodule_config');\n $db->delete('calendar_external');\n $db->delete('calendar_reminder_address');\n $db->delete('event');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'simplepollmodule':\n\t\t\t\t\t\t$db->delete('poll_question');\n\t\t\t\t\t\t$db->delete('poll_answer');\n\t\t\t\t\t\t$db->delete('poll_timeblock');\n\t\t\t\t\t\t$db->delete('simplepollmodule_config');\n $db->delete('simplepoll_question');\n $db->delete('simplepoll_answer');\n $db->delete('simplepoll_timeblock');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'formmodule':\n\t\t\t\t\t\t$db->delete('formbuilder_address');\n\t\t\t\t\t\t$db->delete('formbuilder_control');\n\t\t\t\t\t\t$db->delete('formbuilder_form');\n\t\t\t\t\t\t$db->delete('formbuilder_report');\n $db->delete('forms');\n $db->delete('forms_control');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'youtubemodule':\n\t\t\t\t\tcase 'mediaplayermodule':\n\t\t\t\t\t\t$db->delete('media');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'bannermodule':\n\t\t\t\t\t\t$db->delete('banner');\n\t\t\t\t\t\t$db->delete('companies');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'addressmodule':\n\t\t\t\t\t\t$db->delete('addresses');\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
" //pull the sectionref data for selected modules\n\t\tif (empty($this->params['migrate'])) {\n\t\t\t$where = '1';\n\t\t} else {\n\t\t\t$where = '';\n\t\t\tforeach ($this->params['migrate'] as $key) {\n\t\t\t\tif (!empty($where)) {$where .= \" or\";}\n\t\t\t\t$where .= \" module='\".$key.\"'\";\n\t\t\t}\n\t\t}",
" // pull the sectionref data for selected modules\n $secref = $old_db->selectObjects('sectionref',$where);\n if (empty($this->params['migrate'])) $this->params['migrate'] = array();\n foreach ($secref as $sr) {\n // convert hard coded modules which are only found in sectionref\n if (array_key_exists($sr->module, $this->new_modules) && ($sr->refcount==1000)) {\n\t $iloc = expCore::makeLocation($sr->module,$sr->source,$sr->internal);\n $tmp = new stdClass();\n\t $tmp->module = '';\n// $this->convert($iloc,$iloc->mod,1);\n $this->convert($iloc,$tmp,1); // convert the hard-coded module",
" // convert the source to new exp controller\n $sr->module = $this->new_modules[$sr->module];\n }",
" // copy over and convert sectionrefs\n if (!in_array($sr->module, $this->deprecated_modules)) {\n // if the module is not in the deprecation list, we're hitting here\n if (!$db->selectObject('sectionref',\"source='\".$sr->source.\"'\")) {\n\t\t\t\t\tif (array_key_exists($sr->module, $this->new_modules)) {\n\t\t\t\t\t\t// convert the source to new exp controller\n\t\t\t\t\t\t$sr->module = $this->new_modules[$sr->module];\n\t\t\t\t\t}\n $db->insertObject($sr, 'sectionref');\n @$this->msg['sectionref']++;\n }\n }\n }",
" //pull over all the top level containers\n $containers = $old_db->selectObjects('container', 'external=\"N;\"');\n foreach ($containers as $cont) {\n $oldint = expUnserialize($cont->internal);\n $newint = expCore::makeLocation('container',$oldint->src);\n if (!$db->selectObject('container',\"internal='\".serialize($newint).\"'\")) {\n unset($cont->id);\n $cont->internal = serialize($newint);\n $cont->action = 'showall';\n if ($cont->view == 'Default') {\n $cont->view = 'showall';\n } else {\n $cont->view = 'showall_'.$cont->view;\n }\n $cont->view_data = null;\n $db->insertObject($cont, 'container');\n @$this->msg['container']++;\n }\n }\n // echo \"Imported containermodules<br>\";",
" // // this will pull all the old modules. if we have a exp2 equivalent module\n // // we will convert it to the new type of module before pulling.\n $cwhere = ' and (';\n $i=0;\n foreach ($this->params['migrate'] as $key) {\n $cwhere .= ($i==0) ? \"\" : \" or \";\n $cwhere .= \"internal like '%\".$key.\"%'\";\n $i=1;\n }\n $cwhere .= \")\";\n $modules = $old_db->selectObjects('container', 'external != \"N;\"'.$cwhere.' ORDER BY \"rank\"');\n foreach($modules as $module) {\n $iloc = expUnserialize($module->internal);\n if (array_key_exists($iloc->mod, $this->new_modules)) {\n // convert new modules added via container\n unset(\n $module->internal,\n $module->action\n );\n// unset($module->view);\n $this->convert($iloc, $module);\n// } else if (!in_array($iloc->mod, $this->deprecated_modules)) {\n// // add old school modules not in the deprecation list\n////\t\t\t\tif ($iloc->mod == 'calendarmodule' && $module->view == 'Upcoming Events - Summary') {\n////\t\t\t\t\t$module->view = 'Upcoming Events - Headlines';\n////\t\t\t\t}\n//\t\t\t\t$linked = $this->pulldata($iloc, $module);\n//\t\t\t\tif ($linked) {\n//\t\t\t\t\t$newmodule['i_mod'] = $iloc->mod;\n//\t\t\t\t\t$newmodule['modcntrol'] = $iloc->mod;\n//\t\t\t\t\t$newmodule['rank'] = $module->rank;\n//\t\t\t\t\t$newmodule['views'] = $module->view;\n//\t\t\t\t\t$newmodule['title'] = $module->title;\n//\t\t\t\t\t$newmodule['actions'] = '';\n// $section = $old_db->selectObject('sectionref',\"module='\".$iloc->mod.\"' AND source='\".$iloc->src.\"' AND is_original='0'\");\n// $_POST['current_section'] = empty($section->section) ? 1 : $section->section;\n//\t\t\t\t\t$module = container::update($newmodule,$module,expUnserialize($module->external));\n//// if ($iloc->mod == 'calendarmodule') {\n//// $config = $old_db->selectObject('calendarmodule_config', \"location_data='\".serialize($iloc).\"'\");\n//// $config->id = '';\n//// $config->enable_categories = 1;\n//// $config->enable_tags = 0;\n//// $config->location_data = $module->internal;\n//// $config->aggregate = serialize(Array($iloc->src));\n//// $db->insertObject($config, 'calendarmodule_config');\n//// }\n//\t\t\t\t}\n//\t\t\t\t$res = $db->insertObject($module, 'container');\n//\t\t\t\tif ($res) { @$this->msg['container']++; }\n }\n }",
"\t\tif (isset($this->params['copy_permissions'])) {\n\t\t\t$db->delete('userpermission',\"module != 'navigation'\");\n\t\t\t$db->delete('grouppermission',\"module != 'navigation'\");",
"\t\t\t$users = $db->selectObjects('user','id > 1');\n\t\t\tforeach($users as $user) {\n\t\t\t\t$containers = $old_db->selectObjects('userpermission',\"uid='\".$user->id.\"' AND source != ''\");\n\t\t\t\tforeach($containers as $item) {\n $loc = expCore::makeLocation($item->module,$item->source);\n\t\t\t\t\tif (array_key_exists($item->module, $this->new_modules)) {\n\t\t\t\t\t\t$loc->mod = $this->new_modules[$item->module];\n\t\t\t\t\t\t$item->module = $this->new_modules[$item->module];\n $item = $this->convert_permission($item);\n }\n\t\t\t\t\tif ($item && $db->selectObject('container',\"internal = '\".serialize($loc).\"'\")) {\n\t\t\t\t\t\t$db->insertObject($item,'userpermission');\n\t\t\t\t\t\tif ($item->permission == 'edit') { // if they had edit permission, we'll also give them create permission\n\t\t\t\t\t\t\t$item->permission = 'create';\n\t\t\t\t\t\t\t@$db->insertObject($item,'userpermission');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t$groups = $db->selectObjects('group','1');\n\t\t\tforeach($groups as $group) {\n\t\t\t\t$containers = $old_db->selectObjects('grouppermission',\"gid='\".$group->id.\"' AND source != ''\");\n\t\t\t\tforeach($containers as $item) {\n $loc = expCore::makeLocation($loc->mod = $item->module,$item->source);\n\t\t\t\t\tif (array_key_exists($item->module, $this->new_modules)) {\n\t\t\t\t\t\t$loc->mod = $this->new_modules[$item->module];\n\t\t\t\t\t\t$item->module = $this->new_modules[$item->module];\n\t\t\t\t\t\t$item = $this->convert_permission($item);\n\t\t\t\t\t}\n\t\t\t\t\tif ($item && $db->selectObject('container',\"internal = '\".serialize($loc).\"'\")) {\n\t\t\t\t\t\t$db->insertObject($item,'grouppermission');\n\t\t\t\t\t\tif ($item->permission == 'edit') { // if they had edit permission, we'll also give them create permission\n\t\t\t\t\t\t\t$item->permission = 'create';\n\t\t\t\t\t\t\t@$db->insertObject($item,'grouppermission');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}",
" // migrate the active controller list (modstate)\n $activemods = $old_db->selectObjects('modstate',1);\n foreach($activemods as $mod) {\n if (array_key_exists($mod->module, $this->new_modules)) {\n $mod->module = $this->new_modules[$mod->module];\n }\n if (array_key_exists($mod->module, $this->new_modules) || !in_array($mod->module, $this->deprecated_modules)) {\n// $mod->path = '';\n// $mod->user_runnable = 1;\n// $mod->controller = 1;\n// $mod->os_module = 1;\n// $mod->name = '';\n// $mod->author = '';\n// $mod->description = '';\n// $mod->codequality = '';\n if ($db->selectObject('modstate',\"module='\".$mod->module.\"'\")) {\n $db->updateObject($mod,'modstate',null,'module');\n } else {\n $db->insertObject($mod,'modstate');\n }\n }\n }",
"\t\tsearchController::spider();\n expSession::clearCurrentUserSessionCache();\n assign_to_template(array(\n 'msg'=>@$this->msg\n ));\n }",
"\t/**\n\t * gather info about all users/groups in old site for user selection\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n\tpublic function manage_users() {\n global $db;",
" expHistory::set('manageable', $this->params);\n $old_db = $this->connect();\n $users = $old_db->selectObjects('user','id > 1');\n foreach($users as $user) {\n\t\t\tif ($db->selectObject('user',\"id='\".$user->id.\"'\")) {\n\t\t\t\t$user->exists = true;\n\t\t\t} else {\n\t\t\t\t$user->exists = false;\n\t\t\t}\n\t\t}",
" $groups = $old_db->selectObjects('group');\n foreach($groups as $group) {\n\t\t\tif ($db->selectObject('group',\"id='\".$group->id.\"'\")) {\n\t\t\t\t$group->exists = true;\n\t\t\t} else {\n\t\t\t\t$group->exists = false;\n\t\t\t}\n\t\t}\n\t\tassign_to_template(array(\n 'users'=>$users,\n 'groups'=>$groups\n ));\n }",
"\t/**\n\t * copy selected users/groups over from old site\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function migrate_users() {\n global $db;",
"\t\tif (isset($this->params['wipe_groups'])) {\n\t\t\t$db->delete('group');\n\t\t\t$db->delete('groupmembership');\n\t\t}\n\t\tif (isset($this->params['wipe_users'])) {\n\t\t\t$db->delete('user','id > 1');\n\t\t}\n $old_db = $this->connect();\n//\t\tprint_r(\"<pre>\");\n//\t\tprint_r($old_db->selectAndJoinObjects('', '', 'group', 'groupmembership','id', 'group_id', 'name = \"Editors\"', ''));",
" $gsuccessful = 0;\n $gfailed = 0;\n\t\tif (!empty($this->params['groups'])) {\n\t\t\tforeach($this->params['groups'] as $groupid) {\n\t\t\t\t$group = $old_db->selectObject('group', 'id='.$groupid);\n\t\t\t\t$ret = $db->insertObject($group, 'group');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$gfailed++;\n\t\t\t\t} else {\n\t\t\t\t\t$gsuccessful++;\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tif (!empty($this->params['rep_groups'])) {\n\t\t\tforeach($this->params['rep_groups'] as $groupid) {\n\t\t\t\t$db->delete('group','id='.$groupid);\n\t\t\t\t$group = $old_db->selectObject('group', 'id='.$groupid);\n\t\t\t\t$ret = $db->insertObject($group, 'group');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$gfailed++;\n\t\t\t\t} else {\n\t\t\t\t\t$gsuccessful++;\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n $successful = 0;\n $failed = 0;\n\t\tif (!empty($this->params['users'])) {\n\t\t\tforeach($this->params['users'] as $userid) {\n\t\t\t\t$user = $old_db->selectObject('user', 'id='.$userid);\n\t\t\t\t$ret = $db->insertObject($user, 'user');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$failed++;\n\t\t\t\t} else {\n\t\t\t\t\t$successful++;\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tif (!empty($this->params['rep_users'])) {\n\t\t\tforeach($this->params['rep_users'] as $userid) {\n\t\t\t\t$db->delete('user','id='.$userid);\n\t\t\t\t$user = $old_db->selectObject('user', 'id='.$userid);\n\t\t\t\t$ret = $db->insertObject($user, 'user');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$failed++;\n\t\t\t\t} else {\n\t\t\t\t\t$successful++;\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t $users = new stdClass();\n\t $groups = new stdClass();\n\t\tif (!empty($this->params['groups']) && !empty($this->params['rep_groups'])) {\n\t\t\t$groups = array_merge($this->params['groups'],$this->params['rep_groups']);\n\t\t} elseif (!empty($this->params['groups'])) {\n\t\t\t$groups = $this->params['groups'];\n\t\t} elseif (!empty($this->params['rep_groups'])) {\n\t\t\t$groups = $this->params['rep_groups'];\n\t\t}\n\t\tif (!empty($this->params['users']) && !empty($this->params['rep_users'])) {\n\t\t\t$users = array_merge($this->params['users'],$this->params['rep_users']);\n\t\t} elseif (!empty($this->params['users'])) {\n\t\t\t$users = $this->params['users'];\n\t\t} elseif (!empty($this->params['rep_users'])) {\n\t\t\t$users = $this->params['rep_users'];\n\t\t}\n\t\tif (!empty($groups) && !empty($users)) {\n\t\t\tforeach($groups as $groupid) {\n\t\t\t\t$groupmembers = $old_db->selectObjects('groupmembership', 'group_id='.$groupid);\n\t\t\t\tforeach($groupmembers as $userid) {\n\t\t\t\t\tif (in_array($userid->member_id,$users)) {\n\t\t\t\t\t\t$db->insertObject($userid, 'groupmembership');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n flash('message', $successful.' '.gt('users and').' '.$gsuccessful.' '.gt('groups were imported from').' '.$this->config['database']);\n if ($failed > 0 || $gfailed > 0) {\n\t\t\t$msg = '';\n\t\t\tif ($failed > 0) {\n\t\t\t\t$msg = $failed.' users ';\n\t\t\t}\n\t\t\tif ($gfailed > 0) {\n\t\t\t\tif ($msg != '') { $msg .= ' and ';}\n\t\t\t\t$msg .= $gfailed.' groups ';\n\t\t\t}\n flash('error', $msg.' '.gt('could not be imported from').' '.$this->config['database'].' '.gt('This is usually because a user with the username or group with that name already exists in the database you importing to.'));\n }\n expSession::clearCurrentUserSessionCache();\n expHistory::back();\n }",
"\t/**\n\t * main routine to convert old school module data into new controller format\n\t * @var \\mysqli_database $db the exponent database object\n\t * @param $iloc\n\t * @param $module\n\t * @param int $hc\n\t * @return\n\t */\n private function convert($iloc, $module, $hc=0) {\n if (!in_array($iloc->mod, $this->params['migrate'])) return $module;\n global $db;\n $old_db = $this->connect();\n\t\t$linked = false;\n\t $loc = new stdClass();\n $newconfig = new expConfig();\n if ((!empty($module->is_existing) && $module->is_existing)) {\n $linked = true;\n }",
" switch ($iloc->mod) {\n case 'textmodule':\n\t\t\t\t@$module->view = 'showall';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n\t\t\t\t$ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"text\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'textmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'textmodule';\n $textitems = $old_db->selectObjects('textitem', \"location_data='\".serialize($iloc).\"'\");\n if ($textitems) {\n foreach ($textitems as $ti) {\n $text = new text();\n $loc = expUnserialize($ti->location_data);\n $loc->mod = \"text\";\n $text->location_data = serialize($loc);\n $text->body = $ti->text;\n $text->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n }\n\t\t\t\tbreak;\n case 'rotatormodule':\n $module->action = 'showRandom';\n $module->view = 'showRandom';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"text\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'rotatormodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'rotatormodule';\n $textitems = $old_db->selectObjects('rotator_item', \"location_data='\".serialize($iloc).\"'\");\n if ($textitems) {\n foreach ($textitems as $ti) {\n $text = new text();\n $loc = expUnserialize($ti->location_data);\n $loc->mod = \"text\";\n $text->location_data = serialize($loc);\n $text->body = $ti->text;\n $text->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n }\n\t\t\t\tbreak;\n case 'snippetmodule':\n\t\t\t\t$module->view = 'showall';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"snippet\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'snippetmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'snippetmodule';\n $textitems = $old_db->selectObjects('textitem', \"location_data='\".serialize($iloc).\"'\");\n if ($textitems) {\n foreach ($textitems as $ti) {\n $text = new snippet();\n $loc = expUnserialize($ti->location_data);\n $loc->mod = \"snippet\";\n $text->location_data = serialize($loc);\n $text->body = $ti->text;\n // if the item exists in the current db, we won't save it\n $te = $text->find('first',\"location_data='\".$text->location_data.\"'\");\n if (empty($te)) {\n $text->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n }\n }\n\t\t\t\tbreak;\n case 'linklistmodule':\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'Quick Links':\n\t\t\t\t\t\t@$module->view = \"showall_quicklinks\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t@$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"links\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'linklistmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'linklistmodule';\n $links = $old_db->selectArrays('linklist_link', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($links) {\n\t\t\t\t\tforeach ($links as $link) {\n\t\t\t\t\t\t$lnk = new links();\n\t\t\t\t\t\t$loc = expUnserialize($link['location_data']);\n\t\t\t\t\t\t$loc->mod = \"links\";\n\t\t\t\t\t\t$lnk->title = (!empty($link['name'])) ? $link['name'] : 'Untitled';\n\t\t\t\t\t\t$lnk->body = $link['description'];\n\t\t\t\t\t\t$lnk->new_window = $link['opennew'];\n\t\t\t\t\t\t$lnk->url = (!empty($link['url'])) ? $link['url'] : '#';\n\t\t\t\t\t\t$lnk->rank = $link['rank']+1;\n\t\t\t\t\t\t$lnk->poster = 1;\n\t\t\t\t\t\t$lnk->editor = 1;\n\t\t\t\t\t\t$lnk->location_data = serialize($loc);\n\t\t\t\t\t\t$lnk->save();\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'linkmodule': // user mod, not widely distributed\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'Summary':\n\t\t\t\t\t\t@$module->view = \"showall_quicklinks\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t@$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldconfig = $old_db->selectObject('linkmodule_config', \"location_data='\".serialize($iloc).\"'\");\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_rss == 1) {\n $newconfig->config['enable_rss'] = true;\n $newconfig->config['advertise'] = true;\n $newconfig->config['feed_title'] = $oldconfig->feed_title;\n $newconfig->config['feed_desc'] = $oldconfig->feed_desc;\n $newconfig->config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;\n $newconfig->config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;\n }\n if (!empty($oldconfig->orderhow)) {\n if ($oldconfig->orderby == 'name') $newconfig->config['order'] = 'title';\n switch ($oldconfig->orderhow) {\n case '1':\n $newconfig->config['order'] .= ' DESC';\n break;\n case '2':\n $newconfig->config['order'] = 'rank';\n break;\n }\n }\n if ($oldconfig->enable_categories == 1) {\n $newconfig->config['usecategories'] = true;\n }\n }",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"links\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'linkmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'linkmodule';\n $links = $old_db->selectArrays('link', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($links) {\n\t\t\t\t\tforeach ($links as $link) {\n\t\t\t\t\t\t$lnk = new links();\n\t\t\t\t\t\t$loc = expUnserialize($link['location_data']);\n\t\t\t\t\t\t$loc->mod = \"links\";\n\t\t\t\t\t\t$lnk->title = (!empty($link['name'])) ? $link['name'] : 'Untitled';\n\t\t\t\t\t\t$lnk->body = $link['description'];\n\t\t\t\t\t\t$lnk->new_window = $link['opennew'];\n\t\t\t\t\t\t$lnk->url = (!empty($link['url'])) ? $link['url'] : '#';\n\t\t\t\t\t\t$lnk->rank = $link['rank']+1;\n\t\t\t\t\t\t$lnk->poster = 1;\n\t\t\t\t\t\t$lnk->editor = 1;\n\t\t\t\t\t\t$lnk->location_data = serialize($loc);\n\t\t\t\t\t\t$lnk->save();\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n if (!empty($oldconfig) && $oldconfig->enable_categories == 1 && $link['category_id']) {\n $params = null;\n $oldcat = $old_db->selectObject('category','id = '.$link['category_id']);\n $cat = new expCat($oldcat->name);\n if (empty($cat->id)) {\n $cat->title = $oldcat->name;\n $cat->color = $oldcat->color;\n $catloc = expUnserialize($oldcat->location_data);\n if (array_key_exists($catloc->mod, $this->new_modules)) {\n $mod = expModules::getModuleName($this->new_modules[$catloc->mod]);\n $cat->module = $mod;\n }\n $cat->save();\n $cat->rank = $oldcat->rank + 1;\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n $lnk->update($params);\n }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'swfmodule':\n\t\t\t\t$module->view = 'showall';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"text\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'swfmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'swfmodule';\n $swfitems = $old_db->selectObjects('swfitem', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($swfitems) {\n\t\t\t\t\tforeach ($swfitems as $ti) {\n\t\t\t\t\t\t$text = new text();\n\t\t\t\t\t\t$file = new expFile($ti->swf_id);\n\t\t\t\t\t\t$loc = expUnserialize($ti->location_data);\n\t\t\t\t\t\t$loc->mod = \"text\";\n\t\t\t\t\t\t$text->location_data = serialize($loc);\n\t\t\t\t\t\t$text->title = $ti->name;\n\t\t\t\t\t\t$swfcode = '\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" height=\"'.$ti->height.'\" width=\"'.$ti->width.'\">\n\t\t\t\t\t\t\t\t <param name=\"bgcolor\" value=\"'.$ti->bgcolor.'\" />\n\t\t\t\t\t\t\t\t\t'.($ti->transparentbg?\"<param name=\\\"wmode\\\" value=\\\"transparent\\\" />\":\"\").'\n\t\t\t\t\t\t\t\t <param name=\"quality\" value=\"high\" />\n\t\t\t\t\t\t\t\t <param name=\"movie\" value=\"'.$file->path_relative.'\" />\n\t\t\t\t\t\t\t\t <embed bgcolor= \"'.$ti->bgcolor.'\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" quality=\"high\" src=\"'.$file->path_relative.'\" type=\"application/x-shockwave-flash\" height=\"'.$ti->height.'\" width=\"'.$ti->width.'\"'.($ti->transparentbg?\" wmode=\\\"transparent\\\"\":\"\").'>\n\t\t\t\t\t\t\t\t </embed>\n\t\t\t\t\t\t\t </object>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t';\n\t\t\t\t\t\t$text->body = $swfcode;\n\t\t\t\t\t\t$text->save();\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'newsmodule':\n $only_featured = false;\n $usebody = 0;\n\t\t\t\tswitch ($module->view) {\n case 'Featured News':\n $only_featured = true;\n $module->view = 'showall';\n break;\n\t\t\t\t\tcase 'Headlines':\n $usebody = 2;\n\t\t\t\t\t\t$module->view = 'showall_headlines';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Summary':\n case 'Default':\n $usebody = 1;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldconfig = $old_db->selectObject('newsmodule_config', \"location_data='\".serialize($iloc).\"'\");\n $oldviewconfig = expUnserialize($old_db->selectValue('container','view_data', \"internal='\".serialize($iloc).\"'\"));\n $ploc = clone($iloc);\n $ploc->mod = \"news\";\n // fudge a config to get attached files to appear\n $newconfig->config = expUnserialize('a:14:{s:9:\"feedmaker\";s:0:\"\";s:11:\"filedisplay\";s:7:\"Gallery\";s:6:\"ffloat\";s:4:\"Left\";s:6:\"fwidth\";s:3:\"120\";s:7:\"fmargin\";s:1:\"5\";s:7:\"piwidth\";s:3:\"100\";s:5:\"thumb\";s:3:\"100\";s:7:\"spacing\";s:2:\"10\";s:10:\"floatthumb\";s:8:\"No Float\";s:6:\"tclass\";s:0:\"\";s:5:\"limit\";s:0:\"\";s:9:\"pagelinks\";s:14:\"Top and Bottom\";s:10:\"feed_title\";s:0:\"\";s:9:\"feed_desc\";s:0:\"\";}');\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_rss == 1) {\n $newconfig->config['enable_rss'] = true;\n $newconfig->config['advertise'] = true;\n $newconfig->config['feed_title'] = $oldconfig->feed_title;\n $newconfig->config['feed_desc'] = $oldconfig->feed_desc;\n $newconfig->config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;\n $newconfig->config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;\n }\n if (!empty($oldconfig->item_limit)) {\n $newconfig->config['limit'] = $oldconfig->item_limit;\n $newconfig->config['multipageonly'] = true;\n }\n if (!empty($oldconfig->sortfield)) {\n switch ($oldconfig->sortfield) {\n case 'publish':\n $newconfig->config['order'] = 'publish';\n break;\n case 'edited':\n $newconfig->config['order'] = 'edited_at';\n break;\n case 'posted':\n default:\n $newconfig->config['order'] = 'created_at';\n break;\n }\n if ($oldconfig->sortorder == 'DESC') {\n $newconfig->config['order'] .= ' DESC';\n }\n }\n if (!empty($oldconfig->aggregate) && $oldconfig->aggregate != 'a:0:{}') {\n $merged = expUnserialize($oldconfig->aggregate);\n foreach ($merged as $merge) {\n $newconfig->config['aggregate'][] = $merge;\n }\n }\n if (!empty($oldconfig->pull_rss) && $oldconfig->pull_rss) {\n $pulled = expUnserialize($oldconfig->rss_feed);\n foreach ($pulled as $pull) {\n $newconfig->config['pull_rss'][] = $pull;\n }\n }\n }\n if ($usebody) {\n $newconfig->config['usebody'] = $usebody;\n }\n if (!empty($oldviewconfig['num_items'])) {\n $newconfig->config['limit'] = $oldviewconfig['num_items'];\n// $newconfig->config['pagelinks'] = \"Don't show page links\";\n }\n $only_featured = empty($oldviewconfig['featured_only']) ? 0 : 1;\n if ($only_featured) {\n $newconfig->config['only_featured'] = true;\n }",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'newsmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'newsmodule';\n $newsitems = $old_db->selectArrays('newsitem', \"location_data='\".serialize($iloc).\"'\");\n if ($newsitems) {\n foreach ($newsitems as $ni) {\n unset($ni['id']);\n $news = new news($ni);\n $loc = expUnserialize($ni['location_data']);\n $loc->mod = \"news\";\n $news->location_data = serialize($loc);\n $news->title = (!empty($ni['title'])) ? $ni['title'] : gt('Untitled');\n $news->body = (!empty($ni['body'])) ? $ni['body'] : gt('(empty)');\n $news->save();\n\t\t\t\t\t\t// default is to create with current time\n $news->created_at = $ni['posted'];\n $news->migrated_at = $ni['edited'];\n $news->update();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n if (!empty($ni['file_id'])) {\n $file = new expFile($ni['file_id']);\n $news->attachItem($file,'');\n }\n if (isset($oldconfig->enable_tags) && $oldconfig->enable_tags = true) {\n\t $params = null;;\n\t\t\t\t\t\t\t$oldtags = expUnserialize($ni['tags']);\n if (!empty($oldtags)) {\n foreach ($oldtags as $oldtag){\n $tagtitle = strtolower(trim($old_db->selectValue('tags','name','id = '.$oldtag)));\n $tag = new expTag($tagtitle);\n //\t\t\t\t\t\t\t\t$tag->title = $old_db->selectValue('tags','name','id = '.$oldtag);\n if (empty($tag->id))\n $tag->update(array('title'=>$tagtitle));\n $params['expTag'][] = $tag->id;\n }\n }\n $news->update($params);\n }\n }\n }\n\t\t\t\tbreak;\n case 'resourcesmodule':\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'One Click Download - Descriptive':\n\t\t\t\t\t\t$module->view = 'showall_headlines';\n\t\t\t\t\t\tbreak;\n case 'Recent':\n $module->view = 'showall_recent';\n $newconfig->config['usebody'] = 2;\n break;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldconfig = $old_db->selectObject('resourcesmodule_config', \"location_data='\".serialize($iloc).\"'\");\n $oldviewconfig = expUnserialize($old_db->selectValue('container','view_data', \"internal='\".serialize($iloc).\"'\"));\n $ploc = clone($iloc);\n $ploc->mod = \"filedownload\";\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_categories == 1 && $module->view != 'showall_recent') {\n $newconfig->config['usecategories'] = true;\n }\n if (!empty($oldconfig->description)) {\n $newconfig->config['moduledescription'] = $oldconfig->description;\n }\n if (isset($oldconfig->enable_rss)) {\n $dorss = $oldconfig->enable_rss;\n } elseif (isset($oldconfig->enable_podcasting)) {\n $dorss = $oldconfig->enable_podcasting;\n } else {\n $dorss = false;\n }\n if ($dorss) {\n $newconfig->config['enable_rss'] = true;\n $newconfig->config['advertise'] = true;\n $newconfig->config['feed_title'] = $oldconfig->feed_title;\n $newconfig->config['feed_desc'] = $oldconfig->feed_desc;\n $newconfig->config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;\n $newconfig->config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;\n }\n if (!empty($oldconfig->orderhow)) {\n switch ($oldconfig->orderby) {\n case 'edited':\n $newconfig->config['order'] = 'edited_at';\n break;\n case 'downloads':\n $newconfig->config['order'] = 'downloads';\n break;\n case 'name':\n $newconfig->config['order'] = 'title';\n break;\n case 'posted':\n default:\n $newconfig->config['order'] = 'created_at';\n break;\n }\n switch ($oldconfig->orderhow) {\n case '2':\n $newconfig->config['order'] = 'rank';\n break;\n case '1':\n $newconfig->config['order'] .= ' DESC';\n break;\n }\n }\n }\n if (!empty($oldviewconfig['num_posts'])) {\n $newconfig->config['limit'] = $oldviewconfig['num_posts'];\n// $newconfig->config['pagelinks'] = \"Don't show page links\";\n }\n $newconfig->config['usebody'] = 2;\n if (!empty($oldviewconfig['show_descriptions'])) {\n $newconfig->config['show_info'] = $oldviewconfig['show_descriptions'] ? 1 : 0;\n if ($oldviewconfig['show_descriptions']) {\n $newconfig->config['usebody'] = 0;\n }\n }\n $newconfig->config['quick_download'] = !empty($oldviewconfig['direct_download']) ? $oldviewconfig['direct_download'] : 0;\n $newconfig->config['show_icon'] = !empty($oldviewconfig['show_icons']) ? $oldviewconfig['show_icons'] : 0;\n $newconfig->config['show_player'] = !empty($oldviewconfig['show_player']) ? $oldviewconfig['show_player'] : 0;",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n//\t\t\t\tif ($db->countObjects('filedownloads', \"location_data='\".serialize($ploc).\"'\")) {\n if ($db->countObjects('filedownload', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'resourcesmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'resourcesmodule';\n $resourceitems = $old_db->selectArrays('resourceitem', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($resourceitems) {\n\t\t\t\t\tforeach ($resourceitems as $ri) {\n\t\t\t\t\t\tunset($ri['id']);\n\t\t\t\t\t\t$filedownload = new filedownload($ri);\n\t\t\t\t\t\t$loc = expUnserialize($ri['location_data']);\n\t\t\t\t\t\t$loc->mod = \"filedownload\";\n\t\t\t\t\t\t$filedownload->title = (!empty($ri['name'])) ? $ri['name'] : 'Untitled';\n\t\t\t\t\t\t$filedownload->body = $ri['description'];\n\t\t\t\t\t\t$filedownload->downloads = $ri['num_downloads'];\n\t\t\t\t\t\t$filedownload->location_data = serialize($loc);\n\t\t\t\t\t\tif (!empty($ri['file_id'])) {\n\t\t\t\t\t\t\t$filedownload->save();\n\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t\t\t$file = new expFile($ri['file_id']);\n\t\t\t\t\t\t\t$filedownload->attachItem($file,'downloadable');\n\t\t\t\t\t\t\t// default is to create with current time\t\t\t\t\t\t\n\t\t\t\t\t\t\t$filedownload->created_at = $ri['posted'];\n\t\t\t\t\t\t\t$filedownload->migrated_at = $ri['edited'];\n $filedownload->publish = $ri['posted'];\n\t\t\t\t\t\t\t$filedownload->update();\n if (!empty($oldconfig) && $oldconfig->enable_categories == 1 && $ri['category_id']) {\n $params = null;\n $oldcat = $old_db->selectObject('category','id = '.$ri['category_id']);\n $cat = new expCat($oldcat->name);\n if (empty($cat->id)) {\n $cat->title = $oldcat->name;\n $cat->color = $oldcat->color;\n $catloc = expUnserialize($oldcat->location_data);\n if (array_key_exists($catloc->mod, $this->new_modules)) {\n $mod = expModules::getModuleName($this->new_modules[$catloc->mod]);\n $cat->module = $mod;\n }\n $cat->save();\n $cat->rank = $oldcat->rank +1;\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n $filedownload->update($params);\n }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'imagegallerymodule':\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'Slideshow':\n\t\t\t\t\t\t$module->action = 'slideshow';\n\t\t\t\t\t\t$module->view = 'slideshow';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldviewconfig = expUnserialize($old_db->selectValue('container','view_data', \"internal='\".serialize($iloc).\"'\"));\n $newconfig->config['usecategories'] = true;\n $newconfig->config['multipageonly'] = true;\n $newconfig->config['speed'] = empty($oldviewconfig['delay']) ? 0: $oldviewconfig['delay']/1000;\n $newconfig->config['pa_show_controls'] = empty($oldviewconfig['controller']) ? 0 : 1;",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"photo\";\n\t\t\t\tif ($db->countObjects('photo', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'imagegallerymodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"//\t\t\t\t$iloc->mod = 'imagegallerymodule';\n $galleries = $old_db->selectArrays('imagegallery_gallery', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($galleries) {\n\t\t\t\t\tforeach ($galleries as $gallery) {\n $params = null;;\n $cat = new expCat($gallery['name']);\n if (empty($cat->id)) {\n $cat->title = $gallery['name'];\n $cat->rank = $gallery['galleryorder']+1;\n $cat->module = 'photo';\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n\t\t\t\t\t\t$gis = $old_db->selectArrays('imagegallery_image', \"gallery_id='\".$gallery['id'].\"'\");\n\t\t\t\t\t\tforeach ($gis as $gi) {\n\t\t\t\t\t\t\t$photo = new photo();\n\t\t\t\t\t\t\t$loc = expUnserialize($gallery['location_data']);\n\t\t\t\t\t\t\t$loc->mod = \"photo\";\n\t\t\t\t\t\t\t$photo->title = (!empty($gi['name'])) ? $gi['name'] : 'Untitled';\n\t\t\t\t\t\t\t$photo->body = $gi['description'];\n\t\t\t\t\t\t\t$photo->alt = !empty($gi['alt']) ? $gi['alt'] : $photo->title;\n\t\t\t\t\t\t\t$photo->location_data = serialize($loc);\n\t\t\t\t\t\t\tif (!empty($gi['file_id'])) {\n\t\t\t\t\t\t\t\t$photo->save();\n\t\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t\t\t\t$file = new expFile($gi['file_id']);\n\t\t\t\t\t\t\t\t$photo->attachItem($file,'');\n\t\t\t\t\t\t\t\t$photo->created_at = $gi['posted'];\n\t\t\t\t\t\t\t\t$photo->migrated_at = $gi['posted'];\n\t\t\t\t\t\t\t\t$photo->update(array(\"validate\"=>false));\t\t\t\t\t\t\t\t\n $photo->update($params); // save gallery name as category\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n // pick up some module config settings based on last gallery\n $newconfig->config['pa_showall_thumbbox'] = $gallery['box_size'];\n $newconfig->config['pa_showall_enlarged'] = $gallery['pop_size'];\n $newconfig->config['limit'] = $gallery['perpage'];\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'slideshowmodule':\n $module->action = 'slideshow';\n $module->view = 'slideshow';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"photo\";\n\t\t\t\tif ($db->countObjects('photo', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'slideshowmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'slideshowmodule';\n $gis = $old_db->selectArrays('slideshow_slide', \"location_data='\".serialize($iloc).\"'\");\n if ($gis) {\n foreach ($gis as $gi) {\n $photo = new photo();\n $loc->mod = \"photo\";\n $loc->src = $iloc->src;\n $loc->int = $iloc->int;\n $photo->title = (!empty($gi['name'])) ? $gi['name'] : 'Untitled';\n $photo->body = $gi['description'];\n $photo->alt = !empty($gi['alt']) ? $gi['alt'] : $photo->title;\n $photo->location_data = serialize($loc);\n $te = $photo->find('first',\"location_data='\".$photo->location_data.\"'\");\n if (empty($te)) {\n if (!empty($gi['file_id'])) {\n $photo->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n $file = new expFile($gi['file_id']);\n $photo->attachItem($file,'');\n $photo->update(array(\"validate\"=>false));\n }\n }\n }\n }\n\t\t\t\tbreak;\n case 'headlinemodule':\n $module->view = 'showall_headline';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"text\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'headlinemodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'headlinemodule';\n $headlines = $old_db->selectObjects('headline', \"location_data='\".serialize($iloc).\"'\");\n if ($headlines) {\n foreach ($headlines as $hl) {\n $headline = new text();\n $loc = expUnserialize($hl->location_data);\n $loc->mod = \"text\";\n $headline->location_data = serialize($loc);\n $headline->title = $hl->headline;\n $headline->poster = 1;\n// $headline->created_at = time();\n// $headline->migrated_at = time();\n $headline->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n }\n\t\t\t\tbreak;\n case 'weblogmodule':\n $usebody = 0;\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'By Author':\n\t\t\t\t\t\t$module->action = 'authors';\n\t\t\t\t\t\t$module->view = 'authors';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'By Tag':\n\t\t\t\t\t\t$module->action = 'tags';\n\t\t\t\t\t\t$module->view = 'tags_list';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Monthly':\n\t\t\t\t\t\t$module->action = 'dates';\n\t\t\t\t\t\t$module->view = 'dates';\n\t\t\t\t\t\tbreak;\n case 'Summary':\n $usebody = 2;\n\t\t\t\t\t\t$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n case 'Default':\n $usebody = 1;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldconfig = $old_db->selectObject('weblogmodule_config', \"location_data='\".serialize($iloc).\"'\");\n $oldviewconfig = expUnserialize($old_db->selectValue('container','view_data', \"internal='\".serialize($iloc).\"'\"));\n $ploc = clone($iloc);\n $ploc->mod = \"blog\";\n $newconfig->config['add_source'] = '1';\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_rss == 1) {\n $newconfig->config['enable_rss'] = true;\n $newconfig->config['advertise'] = true;\n $newconfig->config['feed_title'] = $oldconfig->feed_title;\n $newconfig->config['feed_desc'] = $oldconfig->feed_desc;\n $newconfig->config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;\n $newconfig->config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;\n }\n if (!empty($oldconfig->items_per_page)) {\n $newconfig->config['limit'] = $oldconfig->items_per_page;\n $newconfig->config['multipageonly'] = true;\n }\n if (!empty($oldviewconfig['num_posts'])) {\n $newconfig->config['limit'] = $oldviewconfig['num_posts'];\n // $newconfig->config['pagelinks'] = \"Don't show page links\";\n }\n if (!empty($oldconfig->allow_comments)) {\n $newconfig->config['usescomments'] = !$oldconfig->allow_comments;\n }\n if (!empty($oldconfig->aggregate) && $oldconfig->aggregate != 'a:0:{}') {\n $merged = expUnserialize($oldconfig->aggregate);\n foreach ($merged as $merge) {\n $newconfig->config['aggregate'][] = $merge;\n }\n }\n }\n if ($usebody) {\n $newconfig->config['usebody'] = $usebody;\n }",
" //check to see if it's already pulled in (circumvent !is_original)\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'weblogmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'weblogmodule';\n $blogitems = $old_db->selectArrays('weblog_post', \"location_data='\".serialize($iloc).\"'\");\n if ($blogitems) {\n foreach ($blogitems as $bi) {\n unset($bi['id']);\n $post = new blog($bi);\n $loc = expUnserialize($bi['location_data']);\n $loc->mod = \"blog\";\n $post->location_data = serialize($loc);\n $post->title = (!empty($bi['title'])) ? $bi['title'] : gt('Untitled');\n $post->body = (!empty($bi['body'])) ? $bi['body'] : gt('(empty)');\n $post->save();\n\t\t\t\t\t\t// default is to create with current time\t\t\t\t\t\t\n $post->created_at = $bi['posted'];\n $post->migrated_at = $bi['edited'];\n $post->update();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t\t// this next section is moot since there are no attachments to blogs\n // if (!empty($bi['file_id'])) {\n // $file = new expFile($bi['file_id']);\n // $post->attachItem($file,'downloadable');\n // }",
" if (isset($oldconfig->enable_tags) && $oldconfig->enable_tags = true) {\n\t $params = null;;\n\t\t\t\t\t\t\t$oldtags = expUnserialize($bi['tags']);\n\t\t\t\t\t\t\tforeach ($oldtags as $oldtag){\n\t\t\t\t\t\t\t\t$tagtitle = strtolower(trim($old_db->selectValue('tags','name','id = '.$oldtag)));\n\t\t\t\t\t\t\t\t$tag = new expTag($tagtitle);\n//\t\t\t\t\t\t\t\t$tag->title = $old_db->selectValue('tags','name','id = '.$oldtag);\n\t\t\t\t\t\t\t\tif (empty($tag->id))\n $tag->update(array('title'=>$tagtitle));\n\t\t\t\t\t\t\t\t$params['expTag'][] = $tag->id;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t$post->update($params);\n }",
"\t\t\t\t\t\t$comments = $old_db->selectArrays('weblog_comment', \"parent_id='\".$post->id.\"'\");\n\t\t\t\t\t\tforeach($comments as $comment) {\n\t\t\t\t\t\t\tunset($comment['id']);\n\t\t\t\t\t\t\t$newcomment = new expComment($comment);\n\t\t\t\t\t\t\t$newcomment->created_at = $comment['posted'];\n\t\t\t\t\t\t\t$newcomment->migrated_at = $comment['edited'];\n $newcomment->publish = $comment['posted'];\n\t\t\t\t\t\t\t$newcomment->update();\n\t\t\t\t\t\t\t// attach the comment to the blog post it belongs to\n// $obj = new stdClass();\n//\t\t\t\t\t\t\t$obj->content_type = 'blog';\n//\t\t\t\t\t\t\t$obj->content_id = $post->id;\n//\t\t\t\t\t\t\t$obj->expcomments_id = $newcomment->id;\n//\t\t\t\t\t\t\tif(isset($this->params['subtype'])) $obj->subtype = $this->params['subtype'];\n//\t\t\t\t\t\t\t$db->insertObject($obj, $newcomment->attachable_table);\n $newcomment->attachComment('blog', $post->id);\n\t\t\t\t\t\t}\n }\n }\n\t\t\t\tbreak;\n case 'faqmodule':\n\t\t\t\t$module->view = 'showall';",
" $oldconfig = $old_db->selectObject('faqmodule_config', \"location_data='\".serialize($iloc).\"'\");\n if (!empty($oldconfig) && $oldconfig->enable_categories == 1) {\n $newconfig->config['usecategories'] = true;\n }\n $newconfig->config['use_toc'] = true;",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"faq\";\n//\t\t\t\tif ($db->countObjects('faqs', \"location_data='\".serialize($ploc).\"'\")) {\n if ($db->countObjects('faq', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'faqmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'faqmodule';\n $faqs = $old_db->selectArrays('faq', \"location_data='\".serialize($iloc).\"'\");\n if ($faqs) {\n foreach ($faqs as $fqi) {\n unset($fqi['id']);\n $faq = new faq($fqi);\n $loc = expUnserialize($fqi['location_data']);\n $loc->mod = \"faq\";\n $faq->location_data = serialize($loc);\n $faq->question = (!empty($fqi['question'])) ? $fqi['question'] : 'Untitled?';\n $faq->answer = $fqi['answer'];\n $faq->rank = $fqi['rank']+1;\n $faq->include_in_faq = 1;\n $faq->submitter_name = 'Unknown';\n $faq->submitter_email = 'address@website.com';\n $faq->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n if (!empty($oldconfig) && $oldconfig->enable_categories == 1 && $fqi['category_id']) {\n $params = null;\n $oldcat = $old_db->selectObject('category','id = '.$fqi['category_id']);\n $cat = new expCat($oldcat->name);\n if (empty($cat->id)) {\n $cat->title = $oldcat->name;\n $cat->color = $oldcat->color;\n $catloc = expUnserialize($oldcat->location_data);\n if (array_key_exists($catloc->mod, $this->new_modules)) {\n $mod = expModules::getModuleName($this->new_modules[$catloc->mod]);\n $cat->module = $mod;\n }\n $cat->save();\n $cat->rank = $oldcat->rank + 1;\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n $faq->update($params);\n }\n }\n }\n\t\t\t\tbreak;\n case 'listingmodule':\n $usebody = 0;\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'Simple':\n $module->view = 'showall_simple_list';\n $usebody = 2;\n\t\t\t\t\t\tbreak;\n case 'Default':\n $usebody = 1;\n case 'Full':\n $module->view = 'showall';\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldconfig = $old_db->selectObject('listingmodule_config', \"location_data='\".serialize($iloc).\"'\");\n // fudge a config to get attached files to appear\n $newconfig->config = expUnserialize('a:11:{s:11:\"filedisplay\";s:7:\"Gallery\";s:6:\"ffloat\";s:4:\"Left\";s:6:\"fwidth\";s:3:\"120\";s:7:\"fmargin\";s:1:\"5\";s:7:\"piwidth\";s:3:\"100\";s:5:\"thumb\";s:3:\"100\";s:7:\"spacing\";s:2:\"10\";s:10:\"floatthumb\";s:8:\"No Float\";s:6:\"tclass\";s:0:\"\";s:5:\"limit\";s:0:\"\";s:9:\"pagelinks\";s:14:\"Top and Bottom\";}');\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_categories == 1) {\n $newconfig->config['usecategories'] = true;\n }\n if (!empty($oldconfig->items_perpage)) {\n $newconfig->config['limit'] = $oldconfig->items_perpage;\n $newconfig->config['multipageonly'] = true;\n }\n if (!empty($oldconfig->orderhow)) {\n if ($oldconfig->orderby == 'name') $newconfig->config['order'] = 'title';\n switch ($oldconfig->orderhow) {\n case '1':\n $newconfig->config['order'] .= ' DESC';\n break;\n case '2':\n $newconfig->config['order'] = 'rank';\n break;\n }\n }\n if (!empty($oldconfig->description)) {\n $newconfig->config['moduledescription'] = $oldconfig->description;\n }\n }\n if ($usebody) {\n $newconfig->config['usebody'] = $usebody;\n }",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"portfolio\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'listingmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'listingmodule';\n $listingitems = $old_db->selectArrays('listing', \"location_data='\".serialize($iloc).\"'\");\n if ($listingitems) {\n foreach ($listingitems as $li) {\n unset($li['id']);\n $listing = new portfolio($li);\n\t\t\t\t\t\t$listing->title = (!empty($li['name'])) ? $li['name'] : 'Untitled?';\n $loc = expUnserialize($li['location_data']);\n $loc->mod = \"portfolio\";\n $listing->location_data = serialize($loc);\n $listing->featured = true;\n $listing->poster = 1;\n $listing->body = \"<p>\".$li['summary'].\"</p>\".$li['body'];\n $listing->save();\n\t\t\t\t\t\t// default is to create with current time\t\t\t\t\t\t\n// $listing->created_at = time();\n// $listing->migrated_at = time();\n// $listing->update();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n if (!empty($li['file_id'])) {\n\t\t\t\t\t\t\t$file = new expFile($li['file_id']);\n\t\t\t\t\t\t\t$listing->attachItem($file,'');\n\t\t\t\t\t\t}\n if (!empty($oldconfig) && $oldconfig->enable_categories == 1 && $li['category_id']) {\n $params = null;\n $oldcat = $old_db->selectObject('category','id = '.$li['category_id']);\n $cat = new expCat($oldcat->name);\n if (empty($cat->id)) {\n $cat->title = $oldcat->name;\n $cat->color = $oldcat->color;\n $catloc = expUnserialize($oldcat->location_data);\n if (array_key_exists($catloc->mod, $this->new_modules)) {\n $mod = expModules::getModuleName($this->new_modules[$catloc->mod]);\n $cat->module = $mod;\n }\n $cat->save();\n $cat->rank = $oldcat->rank + 1;\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n $listing->update($params);\n }\n }\n }\n\t\t\t\tbreak;\n case 'youtubemodule': //must convert to media player\n\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"media\";\n\t\t\t\tif ($db->countObjects('media', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'youtubemodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"//\t\t\t\t$iloc->mod = 'youtubemodule';\n $videos = $old_db->selectArrays('youtube', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($videos) {\n\t\t\t\t\tforeach ($videos as $vi) {\n\t\t\t\t\t\tunset ($vi['id']);\n\t\t\t\t\t\t$video = new media($vi);\n\t\t\t\t\t\t$loc = expUnserialize($vi['location_data']);\n\t\t\t\t\t\t$loc->mod = \"media\";\n\t\t\t\t\t\t$video->title = $vi['name'];\n\t\t\t\t\t\tif (empty($video->title)) { $video->title = 'Untitled'; }\n\t\t\t\t\t\t$video->location_data = serialize($loc);\n $video->body = $vi['description'];\n//\t\t\t\t\t\t$yt = explode(\"watch?v=\",$vi['url']);\n//\t\t\t\t\t\tif (empty($yt[1])) {\n//\t\t\t\t\t\t\tbreak;\n//\t\t\t\t\t\t} else {\n//\t\t\t\t\t\t\t$ytid = $yt[1];\n//\t\t\t\t\t\t}\n//\t\t\t\t\t\tunset ($video->url);\n//\t\t\t\t\t\t$video->embed_code = '<iframe title=\"YouTube video player\" width=\"'.$vi['width'].'\" height=\"'.$vi['height'].'\" src=\"http://www.youtube.com/embed/'.$ytid.'\" frameborder=\"0\" allowfullscreen></iframe>';\n\t\t\t\t\t\t$video->save();\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'mediaplayermodule': // must convert media player\n\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"media\";\n\t\t\t\tif ($db->countObjects('media', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'mediaplayermodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"//\t\t\t\t$iloc->mod = 'mediaplayermodule';\n $movies = $old_db->selectArrays('mediaitem', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($movies) {\n\t\t\t\t\tforeach ($movies as $mi) {\n\t\t\t\t\t\tunset ($mi['id']);\n\t\t\t\t\t\t$movie = new media($mi);\n\t\t\t\t\t\t$loc = expUnserialize($mi['location_data']);\n\t\t\t\t\t\t$loc->mod = \"media\";\n\t\t\t\t\t\t$movie->title = $mi['name'];\n\t\t\t\t\t\tif (empty($movie->title)) { $movie->title = 'Untitled'; }\n $movie->body = $mi['description'];\n\t\t\t\t\t\tunset (\n $mi['bgcolor'],\n $mi['alignment'],\n $mi['loop_media'],\n $mi['auto_rewind'],\n $mi['autoplay'],\n $mi['hide_controls']\n );\n\t\t\t\t\t\t$movie->location_data = serialize($loc);\n\t\t\t\t\t\t$movie->poster = 1;\n\t\t\t\t\t\t$movie->rank = 1;\n\t\t\t\t\t\tif (!empty($mi['media_id'])) {\n\t\t\t\t\t\t\t$movie->save();\n\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t\t\t$file = new expFile($mi['media_id']);\n\t\t\t\t\t\t\t$movie->attachItem($file,'files');\n\t\t\t\t\t\t\tif (!empty($mi['alt_image_id'])) {\n\t\t\t\t\t\t\t\t$file = new expFile($mi['alt_image_id']);\n\t\t\t\t\t\t\t\t$movie->attachItem($file,'splash');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'bannermodule':\n\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"banner\";\n\t\t\t\tif ($db->countObjects('banner', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'bannermodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"//\t\t\t\t$iloc->mod = 'bannermodule';\n $banners = $old_db->selectArrays('banner_ad', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($banners) {\n\t\t\t\t\tforeach ($banners as $bi) {\n\t\t\t\t\t\t$oldclicks = $old_db->selectObjects('banner_click', \"ad_id='\".$bi['id'].\"'\");\n\t\t\t\t\t\t$oldcompany = $old_db->selectObject('banner_affiliate', \"id='\".$bi['affiliate_id'].\"'\");\n\t\t\t\t\t\tunset ($bi['id']);\n\t\t\t\t\t\t$banner = new banner($bi);\n\t\t\t\t\t\t$loc = expUnserialize($bi['location_data']);\n\t\t\t\t\t\t$loc->mod = \"banner\";\n\t\t\t\t\t\t$banner->title = $bi['name'];\n\t\t\t\t\t\t$banner->url = (!empty($bi['url'])) ? $bi['url'] : '#';\n\t\t\t\t\t\tif (empty($banner->title)) { $banner->title = 'Untitled'; }\n\t\t\t\t\t\t$banner->location_data = serialize($loc);\n\t\t\t\t\t\t$newcompany = $db->selectObject('companies', \"title='\".$oldcompany->name.\"'\");\n\t\t\t\t\t\tif ($newcompany == null) {\n\t\t\t\t\t\t\t$newcompany = new company();\n\t\t\t\t\t\t\t$newcompany->title = (!empty($oldcompany->name)) ? $oldcompany->name : 'Untitled';\n\t\t\t\t\t\t\t$newcompany->body = $oldcompany->contact_info;\n\t\t\t\t\t\t\t$newcompany->location_data = $banner->location_data;\n\t\t\t\t\t\t\t$newcompany->save();\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t\t$banner->companies_id = $newcompany->id;\n\t\t\t\t\t\t$banner->clicks = 0;\n\t\t\t\t\t\tforeach($oldclicks as $click) {\n\t\t\t\t\t\t\t$banner->clicks += $click->clicks;\n\t\t\t\t\t\t}\n if (!empty($bi['file_id'])) {\n $file = new expFile($bi['file_id']);\n $banner->attachItem($file,'');\n }\n\t\t\t\t\t\t$banner->save();\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n// case 'addressbookmodule': // user mod, not widely distributed\n//\n//\t\t\t\t@$module->view = 'myaddressbook';\n//\t\t\t\t@$module->action = 'myaddressbook';\n//\n//\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n//\t\t\t\t// $ploc = $iloc;\n//\t\t\t\t// $ploc->mod = \"addresses\";\n//\t\t\t\t// if ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t// $iloc->mod = 'addressbookmodule';\n//\t\t\t\t\t// $linked = true;\n//\t\t\t\t\t// break;\n//\t\t\t\t// }\n//\n//// $iloc->mod = 'addressbookmodule';\n// $addresses = $old_db->selectArrays('addressbook_contact', \"location_data='\".serialize($iloc).\"'\");\n//\t\t\t\tif ($addresses) {\n//\t\t\t\t\tforeach ($addresses as $address) {\n////\t\t\t\t\t\tunset($address['id']);\n//\t\t\t\t\t\t$addr = new address();\n//\t\t\t\t\t\t$addr->user_id = 1;\n//\t\t\t\t\t\t$addr->is_default = 1;\n//\t\t\t\t\t\t$addr->is_billing = 1;\n//\t\t\t\t\t\t$addr->is_shipping = 1;\n//\t\t\t\t\t\t$addr->firstname = (!empty($address['firstname'])) ? $address['firstname'] : 'blank';\n//\t\t\t\t\t\t$addr->lastname = (!empty($address['lastname'])) ? $address['lastname'] : 'blank';\n//\t\t\t\t\t\t$addr->address1 = (!empty($address['address1'])) ? $address['address1'] : 'blank';\n//\t\t\t\t\t\t$addr->city = (!empty($address['city'])) ? $address['city'] : 'blank';\n//\t\t\t\t\t\t$address['state'] = (!empty($address['state'])) ? $address['state'] : 'CA';\n//\t\t\t\t\t\t$state = $db->selectObject('geo_region', 'code=\"'.strtoupper($address['state']).'\"');\n//\t\t\t\t\t\t$addr->state = empty($state->id) ? 0 : $state->id;\n//\t\t\t\t\t\t$addr->zip = (!empty($address['zip'])) ? $address['zip'] : '99999';\n//\t\t\t\t\t\t$addr->phone = (!empty($address['phone'])) ? $address['phone'] : '800-555-1212';\n//\t\t\t\t\t\t$addr->email = (!empty($address['email'])) ? $address['email'] : 'address@website.com';\n//\t\t\t\t\t\t$addr->organization = $address['business'];\n//\t\t\t\t\t\t$addr->phone2 = $address['cell'];\n//\t\t\t\t\t\t$addr->save();\n//\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n//\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n//\t\t\t\t\t}\n//\t\t\t\t}\n//\t\t\t\tbreak;\n case 'feedlistmodule':\n\t\t\t\t@$module->view = 'showall';",
"// $iloc->mod = 'feedlistmodule';\n $feedlist = $old_db->selectObject('feedlistmodule_config', \"location_data='\".serialize($iloc).\"'\");\n if ($feedlist->enable_rss == 1) {\n\t\t\t\t\t$loc = expUnserialize($feedlist->location_data);\n\t\t\t\t\t$loc->mod = \"rss\";\n\t\t\t\t\t$newconfig->config['enable_rss'] = true;\n $newconfig->config['advertise'] = true;\n\t\t\t\t\t$newconfig->config['feed_title'] = $feedlist->feed_title;\n\t\t\t\t\t$newconfig->config['feed_desc'] = $feedlist->feed_desc;\n\t\t\t\t\t$newconfig->config['rss_limit'] = isset($feedlist->rss_limit) ? $feedlist->rss_limit : 24;\n\t\t\t\t\t$newconfig->config['rss_cachetime'] = isset($feedlist->rss_cachetime) ? $feedlist->rss_cachetime : 1440;\n\t\t\t\t\t$newconfig->location_data = $loc;\n//\t\t\t\t\t$newconfig->save();\n\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n\t\t\t\tbreak;\n case 'simplepollmodule': // added v2.0.9\n $oldconfig = $old_db->selectObject('simplepollmodule_config', \"location_data='\".serialize($iloc).\"'\");\n if (!empty($oldconfig)) {\n if (!empty($oldconfig->thank_you_message)) {\n $newconfig->config['thank_you_message'] = 'Thank you for voting.';\n }\n if (!empty($oldconfig->already_voted_message)) {\n $newconfig->config['already_voted_message'] = 'You have already voted in this poll.';\n }\n if (!empty($oldconfig->voting_closed_message)) {\n $newconfig->config['voting_closed_message'] = 'Voting has been closed for this poll.';\n }\n if (!empty($oldconfig->anonymous_timeout)) {\n $newconfig->config['anonymous_timeout'] = '5';\n }\n }",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"simplePoll\";\n\t\t\t\tif ($db->countObjects('simplepoll_question', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'simplepollmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"//\t\t\t\t$iloc->mod = 'simplepollmodule';\n $oldquestions = $old_db->selectArrays('poll_question', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($oldquestions) {\n\t\t\t\t\tforeach ($oldquestions as $qi) {\n\t\t\t\t\t\t$oldanswers = $old_db->selectArrays('poll_answer', \"question_id='\".$qi['id'].\"'\");\n\t\t\t\t\t\t$oldblocks = $old_db->selectArrays('poll_timeblock', \"question_id='\".$qi['id'].\"'\");\n\t\t\t\t\t\tunset ($qi['id']);\n $active = $qi['is_active'];\n unset ($qi['is_active']);\n\t\t\t\t\t\t$question = new simplepoll_question($qi);\n\t\t\t\t\t\t$loc = expUnserialize($qi['location_data']);\n\t\t\t\t\t\t$loc->mod = \"simplePoll\";\n $question->active = $active;\n\t\t\t\t\t\tif (empty($question->question)) { $question->question = 'Untitled'; }\n $question->location_data = serialize($loc);\n $question->save();",
" foreach ($oldanswers as $oi) {\n unset (\n $oi['id'],\n $oi['question_id']\n );\n $newanswer = new simplepoll_answer($oi);\n $newanswer->simplepoll_question_id = $question->id;\n// $question->simplepoll_answer[] = $newanswer;\n $newanswer->update();\n }\n// $question->update();",
"\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'navigationmodule': // added v2.0.9\n if (!empty($module->view)) {\n if ($module->view == 'Breadcrumb') {\n @$module->view = 'breadcrumb';\n @$module->action = 'breadcrumb';\n } else {\n @$module->view = 'showall_'.$module->view;\n }\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n\t\t\t\tbreak;\n case 'calendarmodule': // added v2.1.0\n if ($module->view == 'Default') {\n @$module->view = 'showall';\n } elseif ($module->view == 'Upcoming Events - Summary') {\n $module->view = 'showall_Upcoming Events - Headlines';\n } else {\n @$module->view = 'showall_'.$module->view;\n }\n $oldconfig = $old_db->selectObject('calendarmodule_config', \"location_data='\".serialize($iloc).\"'\");\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_ical == 1) {\n $newconfig->config['enable_ical'] = true;\n $newconfig->config['feed_title'] = $oldconfig->feed_title;\n $newconfig->config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;\n $newconfig->config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;\n }\n if (!empty($oldconfig->hidemoduletitle)) {\n $newconfig->config['hidemoduletitle'] = $oldconfig->hidemoduletitle;\n }\n if (!empty($oldconfig->moduledescription)) {\n $newconfig->config['moduledescription'] = $oldconfig->moduledescription;\n }\n if (!empty($oldconfig->aggregate) && $oldconfig->aggregate != 'a:0:{}') {\n $merged = expUnserialize($oldconfig->aggregate);\n foreach ($merged as $merge) {\n $newconfig->config['aggregate'][] = $merge;\n }\n }\n if (!empty($oldconfig->enable_feedback)) {\n $newconfig->config['enable_feedback'] = $oldconfig->enable_feedback;\n }\n if (!empty($oldconfig->email_title_reminder)) {\n $newconfig->config['email_title_reminder'] = $oldconfig->email_title_reminder;\n }\n if (!empty($oldconfig->email_from_reminder)) {\n $newconfig->config['email_from_reminder'] = $oldconfig->email_from_reminder;\n }\n if (!empty($oldconfig->email_address_reminder)) {\n $newconfig->config['email_address_reminder'] = $oldconfig->email_address_reminder;\n }\n if (!empty($oldconfig->email_reply_reminder)) {\n $newconfig->config['email_reply_reminder'] = $oldconfig->email_reply_reminder;\n }\n if (!empty($oldconfig->email_showdetail)) {\n $newconfig->config['email_showdetail'] = $oldconfig->email_showdetail;\n }\n if (!empty($oldconfig->email_signature)) {\n $newconfig->config['email_signature'] = $oldconfig->email_signature;\n }\n if (empty($oldconfig->enable_tags)) {\n $newconfig->config['disabletags'] = true;\n }\n if (!empty($oldconfig->enable_categories)) {\n $newconfig->config['usecategories'] = $oldconfig->enable_categories;\n }",
" // we have to pull in external addresses for reminders\n $addrs = $old_db->selectObjects('calendar_reminder_address',\"calendar_id=\".$oldconfig->id);\n foreach ($addrs as $addr) {\n if (!empty($addr->user_id)) {\n $newconfig->config['users'][] = $addr->user_id;\n } elseif (!empty($addr->group_id)) {\n $newconfig->config['groups'][] = $addr->group_id;\n } elseif (!empty($addr->email)) {\n $newconfig->config['addresses'][] = $addr->email;\n }\n }\n }",
" //check to see if it's already pulled in (circumvent !is_original)\n\t\t\t\t$ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"event\";\n\t\t\t\tif ($db->countObjects('event', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'calendarmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'calendarmodule';\n // convert each eventdate\n $eds = $old_db->selectObjects('eventdate',\"1\");\n foreach ($eds as $ed) {\n $cloc = expUnserialize($ed->location_data);\n $cloc->mod = 'event';\n $ed->location_data = serialize($cloc);\n $db->insertObject($ed,'eventdate');\n }",
" // convert each calendar to an event\n $cals = $old_db->selectObjects('calendar',\"1\");\n foreach ($cals as $cal) {\n unset($cal->approved);\n $cat = $cal->category_id;\n unset($cal->category_id);\n $tags = $cal->tags;\n unset(\n $cal->tags,\n $cal->file_id\n );\n $loc = expUnserialize($cal->location_data);\n $loc->mod = \"event\";\n $cal->location_data = serialize($loc);\n $cal->created_at = $cal->posted;\n unset($cal->posted);\n $cal->edited_at = $cal->edited;\n unset($cal->edited);\n $db->insertObject($cal,'event');",
" $ev = new event($cal->id);\n $ev->save();\n if (!empty($oldconfig->enable_tags)) {\n $params = null;;\n $oldtags = expUnserialize($tags);\n if (!empty($oldtags)) {\n foreach ($oldtags as $oldtag){\n $tagtitle = strtolower(trim($old_db->selectValue('tags','name','id = '.$oldtag)));\n $tag = new expTag($tagtitle);\n//\t\t\t\t\t\t\t\t$tag->title = $old_db->selectValue('tags','name','id = '.$oldtag);\n if (empty($tag->id))\n $tag->update(array('title'=>$tagtitle));\n $params['expTag'][] = $tag->id;\n }\n }\n $ev->update($params);\n }\n if (!empty($oldconfig->enable_categories) && $cat) {\n $params = null;\n $oldcat = $old_db->selectObject('category','id = '.$cat);\n $cat = new expCat($oldcat->name);\n if (empty($cat->id)) {\n $cat->title = $oldcat->name;\n $cat->color = $oldcat->color;\n $catloc = expUnserialize($oldcat->location_data);\n if (array_key_exists($catloc->mod, $this->new_modules)) {\n $mod = expModules::getModuleName($this->new_modules[$catloc->mod]);\n $cat->module = $mod;\n }\n $cat->save();\n $cat->rank = $oldcat->rank +1;\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n $ev->update($params);\n }\n }\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n break;\n case 'contactmodule': // v2.1.1 now converted to a forms 2.0 module\n\t\t\t\t$module->view = \"enterdata\";\n $module->action = \"enterdata\";",
"// $iloc->mod = 'contactmodule';\n $contactform = $old_db->selectObject('contactmodule_config', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($contactform) {\n // for forms 2.0 we create a site form (form & report consolidated)\n $newform = new forms();\n $newform->title = 'Contact Form';\n $newform->is_saved = false;\n $newform->table_name = '';\n $newform->description = '';\n $newform->response = $contactform->final_message;\n $newform->update();",
" // now add the controls to the site form\n\t\t\t\t\t$control = new stdClass();\n\t\t\t\t\t$control->name = 'name';\n\t\t\t\t\t$control->caption = 'Your Name';\n\t\t\t\t\t$control->forms_id = $newform->id;\n\t\t\t\t\t$control->data = 'O:11:\"textcontrol\":14:{s:4:\"size\";i:0;s:9:\"maxlength\";i:0;s:7:\"caption\";s:9:\"Your Name\";s:11:\"placeholder\";s:8:\"John Doe\";s:9:\"accesskey\";s:0:\"\";s:7:\"default\";s:0:\"\";s:8:\"disabled\";b:0;s:8:\"required\";b:1;s:8:\"tabindex\";i:-1;s:7:\"inError\";i:0;s:4:\"type\";s:4:\"text\";s:6:\"filter\";s:0:\"\";s:10:\"identifier\";s:4:\"name\";s:11:\"description\";s:22:\"Please enter your name\";}';\n\t\t\t\t\t$control->rank = 1;\n\t\t\t\t\t$control->is_readonly = 0;\n\t\t\t\t\t$control->is_static = 0;\n\t\t\t\t\t$db->insertObject($control, 'forms_control');\n\t\t\t\t\t$control->name = 'email';\n\t\t\t\t\t$control->caption = 'Your Email';\n\t\t\t\t\t$control->data = 'O:11:\"textcontrol\":14:{s:4:\"size\";i:0;s:9:\"maxlength\";i:0;s:7:\"caption\";s:10:\"Your Email\";s:11:\"placeholder\";s:18:\"johndoe@mailer.org\";s:9:\"accesskey\";s:0:\"\";s:7:\"default\";s:0:\"\";s:8:\"disabled\";b:0;s:8:\"required\";b:1;s:8:\"tabindex\";i:-1;s:7:\"inError\";i:0;s:4:\"type\";s:4:\"text\";s:6:\"filter\";s:0:\"\";s:10:\"identifier\";s:5:\"email\";s:11:\"description\";s:31:\"Please enter your email address\";}';\n\t\t\t\t\t$control->rank = 2;\n\t\t\t\t\t$db->insertObject($control, 'forms_control');\n\t\t\t\t\t$control->name = 'subject';\n\t\t\t\t\t$control->caption = 'Subject';\n\t\t\t\t\t$control->data = 'O:11:\"textcontrol\":14:{s:4:\"size\";i:0;s:9:\"maxlength\";i:0;s:7:\"caption\";s:7:\"Subject\";s:11:\"placeholder\";s:22:\"Subject line for email\";s:9:\"accesskey\";s:0:\"\";s:7:\"default\";s:0:\"\";s:8:\"disabled\";b:0;s:8:\"required\";b:1;s:8:\"tabindex\";i:-1;s:7:\"inError\";i:0;s:4:\"type\";s:4:\"text\";s:6:\"filter\";s:0:\"\";s:10:\"identifier\";s:7:\"subject\";s:11:\"description\";s:21:\"Enter a quick summary\";}';\n\t\t\t\t\t$control->rank = 3;\n\t\t\t\t\t$db->insertObject($control, 'forms_control');\n\t\t\t\t\t$control->name = 'message';\n\t\t\t\t\t$control->caption = 'Message';\n\t\t\t\t\t$control->data = 'O:17:\"texteditorcontrol\":13:{s:4:\"cols\";i:60;s:4:\"rows\";i:8;s:9:\"accesskey\";s:0:\"\";s:7:\"default\";s:0:\"\";s:8:\"disabled\";b:0;s:8:\"required\";b:0;s:8:\"tabindex\";i:-1;s:7:\"inError\";i:0;s:4:\"type\";s:4:\"text\";s:8:\"maxchars\";i:0;s:10:\"identifier\";s:7:\"message\";s:7:\"caption\";s:7:\"Message\";s:11:\"description\";s:33:\"Enter the content of your message\";}';\n\t\t\t\t\t$control->rank = 4;\n\t\t\t\t\t$db->insertObject($control, 'forms_control');",
" // and then an expConfig to link to that site form with config settings\n $newconfig->config['forms_id'] = $newform->id;\n $newconfig->config['title'] = 'Send us an e-mail';\n $newconfig->config['description'] = '';\n $newconfig->config['is_email'] = true;\n if (!empty($contactform->subject)) {\n $newconfig->config['report_name'] = $contactform->subject;\n $newconfig->config['subject'] = $contactform->subject;\n }\n if (!empty($contactform->final_message)) $newconfig->config['response'] = $contactform->final_message;\n $newconfig->config['submitbtn'] = 'Send Message';\n $newconfig->config['resetbtn'] = 'Reset';",
" // we have to pull in addresses for emails\n $addrs = $old_db->selectObjects('contact_contact', \"location_data='\".serialize($iloc).\"'\");\n foreach ($addrs as $addr) {\n if (!empty($addr->user_id)) {\n $newconfig->config['user_list'][] = $addr->user_id;\n } elseif (!empty($addr->email)) {\n $newconfig->config['address_list'][] = $addr->email;\n }\n }",
"\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'formmodule': // convert to forms module\n $module->view = \"enterdata\";\n $module->action = \"enterdata\";",
" // new form update\n $oldform = $old_db->selectObject('formbuilder_form', \"location_data='\".serialize($iloc).\"'\");\n $oldreport = $old_db->selectObject('formbuilder_report', \"location_data='\".serialize($iloc).\"'\");",
" if (!empty($oldform->id)) {\n $newform = new forms();\n $newform->title = $oldform->name;\n $newform->is_saved = $oldform->is_saved;\n $newform->table_name = $oldform->table_name;\n if (empty($newform->title) && !empty($newform->table_name)) $newform->title = implode(' ',explode('_',$newform->table_name));\n $newform->description = $oldform->description;\n $newform->response = $oldform->response;\n $newform->report_name = $oldreport->name;\n $newform->report_desc = $oldreport->description;\n $newform->report_def = $oldreport->text;\n $newform->column_names_list = $oldreport->column_names;\n $newform->update();",
" // copy & convert each formbuilder_control to a forms_control\n $fcs = $old_db->selectObjects('formbuilder_control',\"form_id=\".$oldform->id);\n foreach ($fcs as $fc) {\n $fc->forms_id = $newform->id;\n unset (\n $fc->id,\n $fc->form_id\n );\n $db->insertObject($fc,'forms_control');\n }",
" // import form saved data\n if ($oldform->is_saved) {\n $newform->updateTable(); // creates the table in database\n $records = $old_db->selectObjects('formbuilder_'.$oldform->table_name, 1);\n foreach($records as $record) {\n //FIXME do we want to add a forms_id field?\n// $db->insertObject($record, 'forms_'.$oldform->table_name);\n $oldform->insertRecord($record);\n }\n }",
" // convert the form & report configs to an expConfig object for this module\n $newconfig = new expConfig();\n $newconfig->config['forms_id'] = $newform->id;\n if (!empty($oldform->name)) $newconfig->config['title'] = $oldform->name;\n if (!empty($oldform->description)) $newconfig->config['description'] = $oldform->description;\n if (!empty($oldform->response)) $newconfig->config['response'] = $oldform->response;\n if (!empty($oldform->is_email)) $newconfig->config['is_email'] = $oldform->is_email;\n if (!empty($oldform->select_email)) $newconfig->config['select_email'] = $oldform->select_email;\n if (!empty($oldform->submitbtn)) $newconfig->config['submitbtn'] = $oldform->submitbtn;\n if (!empty($oldform->resetbtn)) $newconfig->config['resetbtn'] = $oldform->resetbtn;\n if (!empty($oldform->style)) $newconfig->config['style'] = $oldform->style;\n if (!empty($oldform->subject)) $newconfig->config['subject'] = $oldform->subject;\n if (!empty($oldform->is_auto_respond)) $newconfig->config['is_auto_respond'] = $oldform->is_auto_respond;\n if (!empty($oldform->auto_respond_subject)) $newconfig->config['auto_respond_subject'] = $oldform->auto_respond_subject;\n if (!empty($oldform->auto_respond_body)) $newconfig->config['auto_respond_body'] = $oldform->auto_respond_body;\n if (!empty($oldreport->name)) $newconfig->config['report_name'] = $oldreport->name;\n if (!empty($oldreport->description)) $newconfig->config['report_desc'] = $oldreport->description;\n if (!empty($oldreport->text)) $newconfig->config['report_def'] = $oldreport->text;\n if (!empty($oldreport->column_names)) $newconfig->config['column_names_list'] = explode('|!|',$oldreport->column_names);",
" // we have to pull in addresses for emails\n $addrs = $old_db->selectObjects('formbuilder_address',\"form_id=\".$oldform->id);\n foreach ($addrs as $addr) {\n if (!empty($addr->user_id)) {\n $newconfig->config['user_list'][] = $addr->user_id;\n } elseif (!empty($addr->group_id)) {\n $newconfig->config['group_list'][] = $addr->group_id;\n } elseif (!empty($addr->email)) {\n $newconfig->config['address_list'][] = $addr->email;\n }\n }",
" // now save/attach the expConfig\n if ($newconfig->config != null) {\n $newconfig->location_data = expCore::makeLocation($this->new_modules[$iloc->mod],$iloc->src);\n }\n }",
" @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n break;\n case 'containermodule':\n if (!$hc) {\n $module->action = 'showall';\n if ($module->view == 'Default') {\n @$module->view = 'showall';\n } else {\n @$module->view = 'showall_'.$module->view;\n }\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n\t\t\t\tbreak;\n default:\n @$this->msg['noconverter'][$iloc->mod]++;\n\t\t\t\tbreak;\n\t\t}\n // quick check for non hard coded modules\n // We add a container if they're not hard coded.\n (!$hc) ? $this->add_container($iloc,$module,$linked,$newconfig) : \"\";",
" return $module;\n }",
"//\t/**\n//\t * pull over extra/related data required for old school modules\n//\t * @var \\mysqli_database $db the exponent database object\n//\t * @param $iloc\n//\t * @param $module\n//\t * @return bool\n//\t */\n// private function pulldata($iloc, $module) {\n// global $db;\n// $old_db = $this->connect();\n//\t\t$linked = false;\n// if ((!empty($module->is_existing) && $module->is_existing)) {\n// $linked = true;\n// }\n//\n// switch ($iloc->mod) {\n//// case 'calendarmodule':\n////\t\t\t\tif ($db->countObjects('calendar', \"location_data='\".serialize($iloc).\"'\")) {\n////\t\t\t\t\t$linked = true;\n////\t\t\t\t\tbreak;\n////\t\t\t\t}\n//// $events = $old_db->selectObjects('eventdate', \"location_data='\".serialize($iloc).\"'\");\n//// foreach($events as $event) {\n//// $res = $db->insertObject($event, 'eventdate');\n////\t\t\t\t\tif ($res) { @$this->msg['migrated'][$iloc->mod]['count']++; }\n//// }\n//// $cals = $old_db->selectObjects('calendar', \"location_data='\".serialize($iloc).\"'\");\n//// foreach($cals as $cal) {\n//// unset($cal->allow_registration);\n//// unset($cal->registration_limit);\n//// unset($cal->registration_allow_multiple);\n//// unset($cal->registration_cutoff);\n//// unset($cal->registration_price);\n//// unset($cal->registration_count);\n//// $db->insertObject($cal, 'calendar');\n//// }\n//// $configs = $old_db->selectObjects('calendarmodule_config', \"location_data='\".serialize($iloc).\"'\");\n//// foreach ($configs as $config) {\n//// $reminders = $old_db->selectObjects('calendar_reminder_address', \"calendar_id='\".$config->id.\"'\");\n////\t\t\t\t\t$config->id = '';\n////\t\t\t\t\t$config->enable_categories = 0;\n////\t\t\t\t\t$config->enable_tags = 0;\n//// $db->insertObject($config, 'calendarmodule_config');\n//// foreach($reminders as $reminder) {\n//// $reminder->calendar_id = $config->id;\n//// $db->insertObject($reminder, 'calendar_reminder_address');\n//// }\n//// }\n////\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $iloc->mod;\n////\t\t\t\tbreak;\n//// case 'simplepollmodule':\n////\t\t\t\tif ($db->countObjects('poll_question', \"location_data='\".serialize($iloc).\"'\")) {\n////\t\t\t\t\tbreak;\n////\t\t\t\t}\n//// $questions = $old_db->selectObjects('poll_question', \"location_data='\".serialize($iloc).\"'\");\n//// foreach($questions as $question) {\n//// $db->insertObject($question, 'poll_question');\n////\t\t\t\t\t$answers = $old_db->selectObjects('poll_answer', \"question_id='\".$question->id.\"'\");\n////\t\t\t\t\tforeach($answers as $answer) {\n////\t\t\t\t\t\t$db->insertObject($answer, 'poll_answer');\n////\t\t\t\t\t}\n////\t\t\t\t\t$timeblocks = $old_db->selectObjects('poll_timeblock', \"question_id='\".$question->id.\"'\");\n////\t\t\t\t\tforeach($timeblocks as $timeblock) {\n////\t\t\t\t\t\t$db->insertObject($timeblock, 'poll_timeblock');\n////\t\t\t\t\t}\n////\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n//// }\n//// $configs = $old_db->selectObjects('simplepollmodule_config', \"location_data='\".serialize($iloc).\"'\");\n//// foreach ($configs as $config) {\n//// $db->insertObject($config, 'simplepollmodule_config');\n//// }\n////\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $iloc->mod;\n////\t\t\t\tbreak;\n//// case 'formmodule':\n////\t\t\t\tif ($db->countObjects('formbuilder_form', \"location_data='\".serialize($iloc).\"'\")) {\n////\t\t\t\t\tbreak;\n////\t\t\t\t}\n//// $form = $old_db->selectObject('formbuilder_form', \"location_data='\".serialize($iloc).\"'\");\n////\t\t\t\t$oldformid = $form->id;\n////\t\t\t\tunset($form->id);\n//// $form->id = $db->insertObject($form, 'formbuilder_form');\n////\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n////\t\t\t\t$addresses = $old_db->selectObjects('formbuilder_address', \"form_id='\".$oldformid.\"'\");\n//// foreach($addresses as $address) {\n////\t\t\t\t\tunset($address->id);\n////\t\t\t\t\t$address->form_id = $form->id;\n//// $db->insertObject($address, 'formbuilder_address');\n////\t\t\t\t}\n////\t\t\t\t$controls = $old_db->selectObjects('formbuilder_control', \"form_id='\".$oldformid.\"'\");\n//// foreach($controls as $control) {\n////\t\t\t\t\tunset($control->id);\n////\t\t\t\t\t$control->form_id = $form->id;\n//// $db->insertObject($control, 'formbuilder_control');\n////\t\t\t\t}\n////\t\t\t\t$reports = $old_db->selectObjects('formbuilder_report', \"form_id='\".$oldformid.\"'\");\n//// foreach($reports as $report) {\n////\t\t\t\t\tunset($report->id);\n////\t\t\t\t\t$report->form_id = $form->id;\n//// $db->insertObject($report, 'formbuilder_report');\n////\t\t\t\t}\n////\t\t\t\tif (isset($form->table_name)) {\n////\t\t\t\t\tif (isset($this->params['wipe_content'])) {\n////\t\t\t\t\t\t$db->delete('formbuilder_'.$form->table_name);\n////\t\t\t\t\t}\n////\t\t\t\t\tformbuilder_form::updateTable($form);\n////\t\t\t\t\t$records = $old_db->selectObjects('formbuilder_'.$form->table_name, 1);\n////\t\t\t\t\tforeach($records as $record) {\n////\t\t\t\t\t\t$db->insertObject($record, 'formbuilder_'.$form->table_name);\n////\t\t\t\t\t}\n////\t\t\t\t}\n////\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $iloc->mod;\n////\t\t\t\tbreak;\n// }\n// return $linked;\n// }",
" /**\n * used to create containers, expConfigs, and expRss for new modules\n * @param $iloc\n * @param $m\n * @param bool $linked\n * @param $newconfig\n * @var \\mysqli_database $db the exponent database object\n * @return void\n */\n\tprivate function add_container($iloc,$m,$linked=false,$newconfig) {\n// global $db;",
" // first the container\n// $old_db = $this->connect();\n// $section = $old_db->selectObject('sectionref',\"module='\".$iloc->mod.\"' AND source='\".$iloc->src.\"' AND is_original='0'\");\n// unset($m->id);\n// $oldext = expUnserialize($m->external);\n// $m->external = serialize(expCore::makeLocation('container',$oldext->src));\n////\t\tif ($iloc->mod != 'contactmodule') {\n//\t\t\t$iloc->mod = $this->new_modules[$iloc->mod];\n////\t\t\t$m->internal = (isset($m->internal) && strstr($m->internal,\"Controller\")) ? $m->internal : serialize($iloc);\n// $m->internal = serialize($iloc);\n//\t\t\t$m->action = isset($m->action) ? $m->action : 'showall';\n//\t\t\t$m->view = isset($m->view) ? $m->view : 'showall';\n//\t\t\tif ($m->view == \"Default\") {\n//\t\t\t\t$m->view = 'showall';\n//\t\t\t}\n//\t\t} else { // must be an old school contactmodule\n//\t\t\t$iloc->mod = $this->new_modules[$iloc->mod];\n//\t\t\t$m->internal = serialize($iloc);\n//\t\t}",
" $params = get_object_vars($m);\n unset($params['id']);\n $old_db = $this->connect();\n $section = $old_db->selectObject('sectionref',\"module='\".$iloc->mod.\"' AND source='\".$iloc->src.\"' AND is_original='0'\");\n $params['current_section'] = empty($section->section) ? 1 : $section->section;\n $oldext = expUnserialize($params['external']);\n $params['external'] = serialize(expCore::makeLocation('container',$oldext->src));\n $iloc->mod = $this->new_modules[$iloc->mod];\n $params['modcntrol'] = $iloc->mod;\n $params['internal'] = serialize($iloc);\n $params['rank'] = $params['rank']+1;\n $params['action'] = !empty($params['action']) ? $params['action'] : 'showall';\n $params['view'] = !empty($params['view']) ? $params['view'] : 'showall';\n if ($params['view'] == \"Default\") {\n $params['view'] = 'showall';\n }",
" $m = new container();\n if (!$linked) {\n $params['existing_source'] = $iloc->src;\n }\n $m->update($params);\n\t\tif ($linked) {\n//\t\t\t$newmodule['i_mod'] = $iloc->mod;\n//\t\t\t$newmodule['modcntrol'] = $iloc->mod;\n//\t\t\t$newmodule['rank'] = $m->rank;\n//\t\t\t$newmodule['views'] = $m->view;\n//\t\t\t$newmodule['title'] = $m->title;\n//\t\t\t$newmodule['actions'] = $m->action;\n//\t\t\t$_POST['current_section'] = empty($section->section) ? 1 : $section->section;\n//\t\t\t$m = container::update($newmodule,$m,expUnserialize($m->external));\n// $params = array();\n// $params['rank'] = $newmod['rank'];\n// $params['view'] = $newmod['view'];\n// $params['title'] = $newmod['title'];\n// $params['action'] = $newmod['action'];\n// $params['is_private'] = $newmod['is_private'];\n $newconfig->config['aggregate'][] = $iloc->src;\n if ($iloc->mod == 'blog') {\n $newconfig->config['add_source'] = 1; // we need to make our blog aggregation discrete\n }\n }\n// $db->insertObject($m, 'container');",
" // now save the expConfig\n if (!empty($newconfig->config['enable_rss']) && $newconfig->config['enable_rss'] == true) {\n $newrss = new expRss();\n $newrss->enable_rss = $newconfig->config['enable_rss'];\n $newrss->advertise = $newconfig->config['enable_rss'];\n $newrss->title = $newconfig->config['feed_title'];\n// $newrss->sef_url = expCore::makeSefUrl($newrss->title,'expRss');\n\t\t\t$newrss->sef_url = $this->makeSefUrl($newrss->title);\n $newrss->feed_desc = $newconfig->config['feed_desc'];\n $newrss->rss_limit = $newconfig->config['rss_limit'];\n $newrss->rss_cachetime = $newconfig->config['rss_cachetime'];\n }\n if ($newconfig->config != null) {\n// $newmodinternal = expUnserialize($m->internal);\n// $newmod = expModules::getModuleName($newmodinternal->mod);\n// $newmodinternal->mod = $newmod;\n $newconfig->location_data = expUnserialize($m->internal);\n $newconfig->save();\n }",
" // and save the expRss table\n if (!empty($newrss->enable_rss)) {\n $newmodinternal = expUnserialize($m->internal);\n $newrss->module = $newmodinternal->mod;\n $newrss->src = $newmodinternal->src;\n $newrss->save();\n }\n }",
"\t/**\n\t * module customized function to circumvent going to previous page\n\t * @return void\n\t */\n\tfunction saveconfig() {\n \n // unset some unneeded params\n unset(\n $this->params['module'],\n $this->params['controller'],\n $this->params['src'],\n $this->params['int'],\n $this->params['id'],\n $this->params['action'],\n $this->params['PHPSESSID'],\n $this->params['__utma'],\n $this->params['__utmb'],\n $this->params['__utmc'],\n $this->params['__utmz'],\n $this->params['__utmt'],\n $this->params['__utmli'],\n $this->params['__cfduid']\n );\n \n // setup and save the config\n $config = new expConfig($this->loc);\n $config->update(array('config'=>$this->params));\n\t\t// update our object config\n\t\t$this->config = expUnserialize($config->config);\n// flash('message', 'Migration Configuration Saved');\n// expHistory::back();\n $this->connect(); // now make sure the parameters work",
"\t\tif (isset($this->params['fix_database'])) $this->fix_database();\n //NOTE we need to push the button.css file to head for coolwater theme?\n expCSS::pushToHead(array(\n// \t\t \"unique\"=>\"button\",\n \t\t \"corecss\"=>\"button\",\n \t\t ));\n\t\techo '<h2>'.gt('Migration Configuration Saved').'</h2><br />';\n\t\techo '<p>'.gt('We\\'ve successfully connected to the Old database').'</p><br />';\n if (bs()) {\n $btn_class = 'btn btn-default';\n } else {\n $btn_class = \"awesome \" . BTN_SIZE . \" \" . BTN_COLOR;\n };\n\t\techo \"<a class=\\\"\".$btn_class.\"\\\" href=\\\"\".expCore::makeLink(array('controller'=>'migration','action'=>'manage_users')).\"\\\">\".gt('Next Step -> Migrate Users & Groups').\"</a>\";\n }\n\t\n\t/**\n\t * connect to old site's database\n\t *\n\t * @return mysqli_database\n\t */\n private function connect() {\n // check for required info...then make the DB connection.\n if (\n empty($this->config['username']) ||\n empty($this->config['password']) ||\n empty($this->config['database']) ||\n empty($this->config['server']) ||\n empty($this->config['prefix']) ||\n empty($this->config['port'])\n ) {\n flash('error', gt('You are missing some required database connection information. Please enter DB information.'));\n redirect_to (array('controller'=>'migration', 'action'=>'configure'));\n// $this->configure();\n }",
" $database = expDatabase::connect($this->config['username'],$this->config['password'],$this->config['server'].':'.$this->config['port'],$this->config['database']);",
" if (empty($database->havedb)) {\n flash('error', gt('An error was encountered trying to connect to the database you specified. Please check your DB config.'));\n redirect_to (array('controller'=>'migration', 'action'=>'configure'));\n// $this->configure();\n }",
" $database->prefix = $this->config['prefix']. '_';;\n return $database;\n }",
"\t/**\n\t * several things that may clear up problems in the old database and do a better job of migrating data\n\t * @return void\n\t */\n\tprivate function fix_database() {\n\t\t// let's test the connection\n\t\t$old_db = $this->connect();\n\t\t\n\t\tprint_r(\"<h2>\".gt('We\\'re connected to the Old Database!').\"</h2><br><br><h3>\".gt('Running several checks and fixes on the old database').\"<br>\".gt('to enhance Migration.').\"</h3><br>\");",
"\t\tprint_r(\"<pre>\");\n\t// upgrade sectionref's that have lost their originals\n\t\tprint_r(\"<strong>\".gt('Searching for sectionrefs that have lost their originals').\"</strong><br><br>\");\n\t\t$sectionrefs = $old_db->selectObjects('sectionref',\"is_original=0\");\n\t\tprint_r(\"Found: \".count($sectionrefs).\" copies (not originals)<br>\");\n\t\tforeach ($sectionrefs as $sectionref) {\n\t\t\tif ($old_db->selectObject('sectionref',\"module='\".$sectionref->module.\"' AND source='\".$sectionref->source.\"' AND is_original='1'\") == null) {\n\t\t\t// There is no original for this sectionref so change it to the original\n//\t\t\t\t$sectionref->is_original = 1;\n\t\t\t\t$old_db->updateObject($sectionref,\"sectionref\");\n\t\t\t\tprint_r(\"Fixed: \".$sectionref->module.\" - \".$sectionref->source.\"<br>\");\n\t\t\t}\n\t\t}\n\t\tprint_r(\"</pre>\");\n\t\n\t\tprint_r(\"<pre>\");\n\t// upgrade sectionref's that point to missing sections (pages)\n\t\tprint_r(\"<strong>\".gt('Searching for sectionrefs pointing to missing sections/pages').\" <br>\".gt('to fix for the Recycle Bin').\"</strong><br><br>\");\n\t\t$sectionrefs = $old_db->selectObjects('sectionref',\"refcount!=0\");\n\t\tforeach ($sectionrefs as $sectionref) {\n\t\t\tif ($old_db->selectObject('section',\"id='\".$sectionref->section.\"'\") == null) {\n\t\t\t// There is no section/page for sectionref so change the refcount\n\t\t\t\t$sectionref->refcount = 0;\n\t\t\t\t$old_db->updateObject($sectionref,\"sectionref\");\n\t\t\t\tprint_r(\"Fixed: \".$sectionref->module.\" - \".$sectionref->source.\"<br>\");\n\t\t\t}\n\t\t}\n\t\tprint_r(\"</pre>\");",
"\t}",
"\t/**\n\t * Take an old school permission and convert it to a newmodule permission\n\t *\n\t * @param $item\n\t * @return mixed\n\t */\n\tprivate function convert_permission($item) {\n\t\tif ($item == null) return null;\n\t\tswitch ($item->permission) {\n\t\t case 'administrate':\n\t\t\t $item->permission = 'manage';\n\t\t\t\tbreak;\n\t\t\tcase 'post':\n\t\t\tcase 'create_slide':\n\t\t\tcase 'add':\n\t\t\tcase 'add_item':\n case 'add_module':\n\t\t\t\t$item->permission = 'create';\n\t\t\t\tbreak;\n\t\t\tcase 'edit_item':\n\t\t\tcase 'edit_slide':\n case 'edit_module':\n\t\t\t\t$item->permission = 'edit';\n\t\t\t\tbreak;\n\t\t\tcase 'delete_item':\n\t\t\tcase 'delete_slide':\n case 'delete_module':\n\t\t\t\t$item->permission = 'delete';\n\t\t\t\tbreak;\n\t\t\tcase 'order':\n\t\t\tcase 'import':\n case 'orders_modules':\n\t\t\t\t$item->permission = 'configure';\n\t\t\t\tbreak;\n\t\t\tcase 'view_unpublished':\n\t\t\t\t$item->permission = 'show_unpublished';\n\t\t\t\tbreak;\n case 'approve_comments':\n $item->permission = 'approve';\n break;\n\t\t\tcase 'manage_categories':\n\t\t\tcase 'manage_approval':\n\t\t\tcase 'approve':\n\t\t\tcase 'can_download':\n\t\t\tcase 'comment':\n\t\t\tcase 'edit_comments':\n\t\t\tcase 'delete_comments':\n\t\t\tcase 'view_private':\n $item = null;\n\t\t\t\tbreak;\n\t\t\tcase 'create':\n\t\t\tcase 'configure':\n\t\t\tcase 'delete':\n\t\t\tcase 'edit':\n\t\t\tcase 'manage':\n\t\t\tcase 'spider':\n\t\t\tcase 'view':\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t\treturn $item;\n\t}",
"}",
"?>"
] |
[
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\n##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class migrationController extends expController {",
" protected $manage_permissions = array(",
" 'analyze'=>'Analyze Data',\n 'migrate'=>'Migrate Data'\n );",
" // this is a list of modules that we can convert to exp2 type modules.\n public $new_modules = array(\n// 'addressbookmodule'=>'address',\n 'imagegallerymodule'=>'photo',\n 'linklistmodule'=>'links',\n 'newsmodule'=>'news',\n 'slideshowmodule'=>'photo',\n 'snippetmodule'=>'snippet',\n 'swfmodule'=>'text',\n 'textmodule'=>'text',\n 'resourcesmodule'=>'filedownload',\n 'rotatormodule'=>'text',\n 'faqmodule'=>'faq',\n 'headlinemodule'=>'text',\n 'linkmodule'=>'links',\n 'weblogmodule'=>'blog',\n 'listingmodule'=>'portfolio',\n 'youtubemodule'=>'media',\n 'mediaplayermodule'=>'media',\n 'bannermodule'=>'banner',\n 'feedlistmodule'=>'rss',\n 'simplepollmodule'=>'simplePoll',\n 'navigationmodule'=>'navigation',\n 'calendarmodule'=>'event',\n 'formmodule'=>'forms',\n 'contactmodule'=>'forms', // this module is converted to a functionally similar form\n 'containermodule'=>'container',\n );",
" // these are modules that have either been deprecated or have no content to migrate\n // Not sure we need to note deprecated modules...\n public $deprecated_modules = array(\n 'administrationmodule',\n// 'containermodule', // not really deprecated, but must be in this list to skip processing?\n// 'navigationmodule', // views are still used, so modules need to be imported?\n 'loginmodule',\n 'searchmodule', \n 'imagemanagermodule',\n 'imageworkshopmodule',\n 'inboxmodule',\n 'rssmodule',\n// the following 0.97/98 modules were added to this list\n 'articlemodule',\n 'bbmodule',\n 'pagemodule',\n 'previewmodule',\n 'tasklistmodule',\n 'wizardmodule',\n// other older or user-contributed modules we don't want to deal with\n 'addressbookmodule', // moved to deprecated list since this is NOT the type of address we use in 2.x\n 'cataloguemodule',\n 'codemapmodule',\n 'extendedlistingmodule',\n 'googlemapmodule',\n 'greekingmodule',\n 'guestbookmodule',\n 'keywordmodule',\n 'sharedcoremodule',\n 'svgallerymodule',\n 'uiswitchermodule',\n 'filemanagermodule',\n );",
"\t/**\n\t * name of module\n\t * @return string\n\t */\n static function displayname() { return gt(\"Content Migration Controller\"); }",
"\t/**\n\t * description of module\n\t * @return string\n\t */\n static function description() { return gt(\"Use this module to pull Exponent 1 style content from your old site.\"); }",
"\t/**\n\t * if module has associated sources\n\t * @return bool\n\t */\n static function hasSources() { return false; }",
"\t/**\n\t * if module has associated content\n\t * @return bool\n\t */\n static function hasContent() { return false; }",
"\t/**\n\t * gather info about all pages in old site for user selection\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function manage_pages() {\n global $db;",
" expHistory::set('manageable', $this->params);\n $old_db = $this->connect();\n $pages = $old_db->selectObjects('section','id > 1');\n foreach($pages as $page) {\n\t\t\tif ($db->selectObject('section',\"id='\".$page->id.\"'\")) {\n\t\t\t\t$page->exists = true;\n\t\t\t} else {\n\t\t\t\t$page->exists = false;\n\t\t\t}\n\t\t}\n assign_to_template(array(\n 'pages'=>$pages\n ));\n }",
"\t/**\n\t * copy selected pages over from old site\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function migrate_pages() {\n global $db;",
"\t\t$del_pages = '';\n if (isset($this->params['wipe_pages'])) {\n $db->delete('section',\"id > '1'\");\n\t\t\t$del_pages = ' '.gt('after clearing database of pages');\n\t\t}\n $successful = 0;\n $failed = 0;\n $old_db = $this->connect();\n\t\tif (!empty($this->params['pages'])) {\n\t\t\tforeach($this->params['pages'] as $pageid) {\n\t\t\t\t$page = $old_db->selectObject('section', 'id='.$pageid);\n\t\t\t\t// make sure the SEF name is valid\n\t\t\t\tglobal $router;\n\t\t\t\tif (empty($page->sef_name)) {\n\t\t\t\t\tif (isset($page->name)) {\n\t\t\t\t\t\t$page->sef_name = $router->encode($page->name);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$page->sef_name = $router->encode('Untitled');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t$dupe = $db->selectValue('section', 'sef_name', 'sef_name=\"'.$page->sef_name.'\"');\n\t\t\t\tif (!empty($dupe)) {\n\t\t\t\t\tlist($u, $s) = explode(' ',microtime());\n $page->sef_name .= '-'.$s.'-'.$u;\n\t\t\t\t}\n// $page->sef_name = $page->sef_name;\n// unset($page->sef_name);\n\t\t\t\t$ret = $db->insertObject($page, 'section');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$failed++;\n\t\t\t\t} else {\n\t\t\t\t\t$successful++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!empty($this->params['rep_pages'])) {\n\t\t\tforeach($this->params['rep_pages'] as $pageid) {\n\t\t\t\t$db->delete('section','id='.$pageid);\n\t\t\t\t$page = $old_db->selectObject('section', 'id='.$pageid);\n\t\t\t\t// make sure the SEF name is valid\n\t\t\t\tglobal $router;\n\t\t\t\tif (empty($page->sef_name)) {\n\t\t\t\t\tif (isset($page->name)) {\n\t\t\t\t\t\t$page->sef_name = $router->encode($page->name);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$page->sef_name = $router->encode('Untitled');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t$dupe = $db->selectValue('section', 'sef_name', 'sef_name=\"'.$page->sef_name.'\"');\n\t\t\t\tif (!empty($dupe)) {\n\t\t\t\t\tlist($u, $s) = explode(' ',microtime());\n $page->sef_name .= '-'.$s.'-'.$u;\n\t\t\t\t}\n// $page->sef_name = $page->sef_name;\n// unset($page->sef_name);\n\t\t\t\t$ret = $db->insertObject($page, 'section');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$failed++;\n\t\t\t\t} else {\n\t\t\t\t\t$successful++;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"\t\tif (isset($this->params['copy_permissions'])) {\n\t\t\t$db->delete('userpermission',\"module = 'navigation' AND source = ''\");\n\t\t\t$db->delete('grouppermission',\"module = 'navigation' AND source = ''\");\n\t\t\t\n\t\t\t$users = $db->selectObjects('user','id > 1');\n\t\t\tforeach($users as $user) {\n\t\t\t\t$pages = $old_db->selectObjects('userpermission',\"uid='\".$user->id.\"' AND module = 'navigationmodule' AND source = ''\");\n\t\t\t\tforeach($pages as $page) {\n\t\t\t\t\tif ($db->selectObject('section','id = '.$page->internal)) {\n\t\t\t\t\t\t if ($page->permission != 'administrate') {\n $page->module = 'navigation';\n\t\t\t\t\t\t\t $db->insertObject($page,'userpermission');\n\t\t\t\t\t\t }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\t\t\n\t\t\t$groups = $db->selectObjects('group','1');\n\t\t\tforeach($groups as $group) {\n\t\t\t\t$pages = $old_db->selectObjects('grouppermission',\"gid='\".$group->id.\"' AND module = 'navigationmodule' AND source = ''\");\n\t\t\t\tforeach($pages as $page) {\n\t\t\t\t\tif ($db->selectObject('section','id = '.$page->internal)) {\n\t\t\t\t\t\t if ($page->permission != 'administrate') {\n $page->module = 'navigation';\n\t\t\t\t\t\t\t $db->insertObject($page,'grouppermission');\n\t\t\t\t\t\t }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\t\t\n\t\t}",
" flash('message', $successful.' '.gt('pages were imported from').' '.$this->config['database'].$del_pages);\n if ($failed > 0) {\n flash('error', $failed.' '.gt('pages could not be imported from').' '.$this->config['database'].' '.gt('This is usually because a page with the same ID already exists in the database you importing to.'));\n }",
" expSession::clearCurrentUserSessionCache();\n expHistory::back();\n }",
"\t/**\n\t * gather info about all files in old site for user selection\n\t * @return void\n\t */\n public function manage_files() {\n expHistory::set('manageable', $this->params);\n $old_db = $this->connect();\n $files = $old_db->selectObjects('file');\n assign_to_template(array(\n 'count'=>count($files)\n ));\n }",
"\t/**\n\t * copy selected file information (not the files themselves) over from old site\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function migrate_files() {\n global $db;",
" expHistory::set('manageable', $this->params);\n $old_db = $this->connect();\n $db->delete('expFiles');",
" //import the files\n $oldfiles = $old_db->selectObjects('file');\n foreach ($oldfiles as $oldfile) {\n unset(\n $oldfile->name,\n $oldfile->collection_id\n );\n $file = $oldfile;\n $file->directory = $file->directory.\"/\";\n $db->insertObject($file,'expFiles');\n\t\t\t$oldfile->exists = file_exists(BASE.$oldfile->directory.\"/\".$oldfile->filename);\n\t\t}\n assign_to_template(array(\n 'files'=>$oldfiles,\n 'count'=>count($oldfiles)\n ));\n }",
"\t/**\n\t * gather info about all modules in old site for user selection\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function manage_content() {\n //global $db;\n //$containers = $db->selectObjects('container', 'external=\"N;\"');\n //eDebug($containers);\n $old_db = $this->connect();",
" $sql = 'SELECT *, COUNT(module) as count FROM '.$this->config['prefix'].'_sectionref WHERE is_original=1 GROUP BY module';\n $modules = $old_db->selectObjectsBySql($sql);\n\t\tfor ($i = 0, $iMax = count($modules); $i < $iMax; $i++) {\n if (array_key_exists($modules[$i]->module, $this->new_modules)) {\n $newmod = expModules::getController($this->new_modules[$modules[$i]->module]);\n// $newmod = $this->new_modules[$modules[$i]->module];\n $modules[$i]->action = '<span style=\"color:green;\">'.gt('Converting content to').' '.$newmod->displayname().\"</span>\";\n// $modules[$i]->action = '<span style=\"color:green;\">'.gt('Converting content to').' '.$newmod::displayname().\"</span>\"; //TODO this doesn't work w/ php 5.2\n } elseif (in_array($modules[$i]->module, $this->deprecated_modules)) {\n // $modules[$i]->action = '<span style=\"color:red;\">This module is deprecated and will not be migrated.</span>';\n $modules[$i]->notmigrating = 1;\n// } elseif (in_array($modules[$i]->module, $this->needs_written)) {\n// $modules[$i]->action = '<span style=\"color:orange;\">'.gt('Still needs migration script written').'</span>';\n } else {\n $modules[$i]->action = gt('Migrating as is.');\n }\n }\n //eDebug($modules);",
" assign_to_template(array(\n 'modules'=>$modules\n ));\n }",
"\t/**\n\t * copy selected modules and their contents over from old site\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function migrate_content() {\n global $db;",
" $old_db = $this->connect();\n if (isset($this->params['wipe_content'])) {\n $db->delete('sectionref');\n $db->delete('container');\n $db->delete('text');\n $db->delete('snippet');\n $db->delete('links');\n $db->delete('news');\n// $db->delete('filedownloads');\n $db->delete('filedownload');\n $db->delete('photo');\n $db->delete('headline');\n $db->delete('blog');\n// $db->delete('faqs');\n $db->delete('faq');\n $db->delete('portfolio');\n $db->delete('media');\n $db->delete('banner');\n $db->delete('companies');\n $db->delete('addresses');\n $db->delete('content_expComments');\n $db->delete('content_expFiles');\n $db->delete('content_expSimpleNote');\n $db->delete('content_expTags');\n $db->delete('content_expCats');\n $db->delete('expComments');\n $db->delete('expConfigs', 'id>1'); // don't delete migration config\n// $db->delete('expFiles');\t\t\t// deleted and rebuilt during (previous) file migration\n $db->delete('expeAlerts');\n $db->delete('expeAlerts_subscribers');\n $db->delete('expeAlerts_temp');\n $db->delete('expSimpleNote');\n $db->delete('expRss');\n $db->delete('expCats');\n $db->delete('calendar');\n $db->delete('eventdate');\n $db->delete('calendarmodule_config');\n $db->delete('calendar_external');\n $db->delete('calendar_reminder_address');\n $db->delete('event');\n $db->delete('poll_question');\n $db->delete('poll_answer');\n $db->delete('poll_timeblock');\n $db->delete('simplepollmodule_config');\n $db->delete('simplepoll_question');\n $db->delete('simplepoll_answer');\n $db->delete('simplepoll_timeblock');\n $db->delete('formbuilder_address');\n $db->delete('formbuilder_control');\n $db->delete('formbuilder_form');\n $db->delete('formbuilder_report');\n $db->delete('forms');\n $db->delete('forms_control');\n @$this->msg['clearedcontent']++;\n }\n\t\t\n\t\tif (!empty($this->params['replace'])) {\n\t\t\tforeach($this->params['replace'] as $replace) {\n\t\t\t\tswitch ($replace) {\n\t\t\t\t case 'containermodule':\n\t\t\t\t\t $db->delete('container');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'textmodule':\n\t\t\t\t\tcase 'rotatormodule':\n\t\t\t\t\tcase 'swfmodule':\n\t\t\t\t\t\t$db->delete('text');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'snippetmodule':\n\t\t\t\t\t\t$db->delete('snippet');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'linklistmodule':\n\t\t\t\t\tcase 'linkmodule':\n\t\t\t\t\t\t$db->delete('links');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'newsmodule':\n\t\t\t\t\t\t$db->delete('news');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'resourcesmodule':\n//\t\t\t\t\t\t$db->delete('filedownloads');\n $db->delete('filedownload');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'imagegallerymodule':\n\t\t\t\t\tcase 'slideshowmodule':\n\t\t\t\t\t\t$db->delete('photo');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'headlinemodule':\n\t\t\t\t\t\t$db->delete('headline');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'weblogmodule':\n\t\t\t\t\t\t$db->delete('blog');\n\t\t\t\t\t\t$db->delete('expComments');\n\t\t\t\t\t\t$db->delete('content_expComments');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'faqmodule':\n\t\t\t\t\t\t$db->delete('faq');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'listingmodule':\n\t\t\t\t\t\t$db->delete('portfolio');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'calendarmodule':\n\t\t\t\t\t\t$db->delete('calendar');\n\t\t\t\t\t\t$db->delete('eventdate');\n\t\t\t\t\t\t$db->delete('calendarmodule_config');\n $db->delete('calendar_external');\n $db->delete('calendar_reminder_address');\n $db->delete('event');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'simplepollmodule':\n\t\t\t\t\t\t$db->delete('poll_question');\n\t\t\t\t\t\t$db->delete('poll_answer');\n\t\t\t\t\t\t$db->delete('poll_timeblock');\n\t\t\t\t\t\t$db->delete('simplepollmodule_config');\n $db->delete('simplepoll_question');\n $db->delete('simplepoll_answer');\n $db->delete('simplepoll_timeblock');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'formmodule':\n\t\t\t\t\t\t$db->delete('formbuilder_address');\n\t\t\t\t\t\t$db->delete('formbuilder_control');\n\t\t\t\t\t\t$db->delete('formbuilder_form');\n\t\t\t\t\t\t$db->delete('formbuilder_report');\n $db->delete('forms');\n $db->delete('forms_control');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'youtubemodule':\n\t\t\t\t\tcase 'mediaplayermodule':\n\t\t\t\t\t\t$db->delete('media');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'bannermodule':\n\t\t\t\t\t\t$db->delete('banner');\n\t\t\t\t\t\t$db->delete('companies');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'addressmodule':\n\t\t\t\t\t\t$db->delete('addresses');\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
" //pull the sectionref data for selected modules\n\t\tif (empty($this->params['migrate'])) {\n\t\t\t$where = '1';\n\t\t} else {\n\t\t\t$where = '';\n\t\t\tforeach ($this->params['migrate'] as $key) {\n\t\t\t\tif (!empty($where)) {$where .= \" or\";}\n\t\t\t\t$where .= \" module='\".$key.\"'\";\n\t\t\t}\n\t\t}",
" // pull the sectionref data for selected modules\n $secref = $old_db->selectObjects('sectionref',$where);\n if (empty($this->params['migrate'])) $this->params['migrate'] = array();\n foreach ($secref as $sr) {\n // convert hard coded modules which are only found in sectionref\n if (array_key_exists($sr->module, $this->new_modules) && ($sr->refcount==1000)) {\n\t $iloc = expCore::makeLocation($sr->module,$sr->source,$sr->internal);\n $tmp = new stdClass();\n\t $tmp->module = '';\n// $this->convert($iloc,$iloc->mod,1);\n $this->convert($iloc,$tmp,1); // convert the hard-coded module",
" // convert the source to new exp controller\n $sr->module = $this->new_modules[$sr->module];\n }",
" // copy over and convert sectionrefs\n if (!in_array($sr->module, $this->deprecated_modules)) {\n // if the module is not in the deprecation list, we're hitting here\n if (!$db->selectObject('sectionref',\"source='\".$sr->source.\"'\")) {\n\t\t\t\t\tif (array_key_exists($sr->module, $this->new_modules)) {\n\t\t\t\t\t\t// convert the source to new exp controller\n\t\t\t\t\t\t$sr->module = $this->new_modules[$sr->module];\n\t\t\t\t\t}\n $db->insertObject($sr, 'sectionref');\n @$this->msg['sectionref']++;\n }\n }\n }",
" //pull over all the top level containers\n $containers = $old_db->selectObjects('container', 'external=\"N;\"');\n foreach ($containers as $cont) {\n $oldint = expUnserialize($cont->internal);\n $newint = expCore::makeLocation('container',$oldint->src);\n if (!$db->selectObject('container',\"internal='\".serialize($newint).\"'\")) {\n unset($cont->id);\n $cont->internal = serialize($newint);\n $cont->action = 'showall';\n if ($cont->view == 'Default') {\n $cont->view = 'showall';\n } else {\n $cont->view = 'showall_'.$cont->view;\n }\n $cont->view_data = null;\n $db->insertObject($cont, 'container');\n @$this->msg['container']++;\n }\n }\n // echo \"Imported containermodules<br>\";",
" // // this will pull all the old modules. if we have a exp2 equivalent module\n // // we will convert it to the new type of module before pulling.\n $cwhere = ' and (';\n $i=0;\n foreach ($this->params['migrate'] as $key) {\n $cwhere .= ($i==0) ? \"\" : \" or \";\n $cwhere .= \"internal like '%\".$key.\"%'\";\n $i=1;\n }\n $cwhere .= \")\";\n $modules = $old_db->selectObjects('container', 'external != \"N;\"'.$cwhere.' ORDER BY \"rank\"');\n foreach($modules as $module) {\n $iloc = expUnserialize($module->internal);\n if (array_key_exists($iloc->mod, $this->new_modules)) {\n // convert new modules added via container\n unset(\n $module->internal,\n $module->action\n );\n// unset($module->view);\n $this->convert($iloc, $module);\n// } else if (!in_array($iloc->mod, $this->deprecated_modules)) {\n// // add old school modules not in the deprecation list\n////\t\t\t\tif ($iloc->mod == 'calendarmodule' && $module->view == 'Upcoming Events - Summary') {\n////\t\t\t\t\t$module->view = 'Upcoming Events - Headlines';\n////\t\t\t\t}\n//\t\t\t\t$linked = $this->pulldata($iloc, $module);\n//\t\t\t\tif ($linked) {\n//\t\t\t\t\t$newmodule['i_mod'] = $iloc->mod;\n//\t\t\t\t\t$newmodule['modcntrol'] = $iloc->mod;\n//\t\t\t\t\t$newmodule['rank'] = $module->rank;\n//\t\t\t\t\t$newmodule['views'] = $module->view;\n//\t\t\t\t\t$newmodule['title'] = $module->title;\n//\t\t\t\t\t$newmodule['actions'] = '';\n// $section = $old_db->selectObject('sectionref',\"module='\".$iloc->mod.\"' AND source='\".$iloc->src.\"' AND is_original='0'\");\n// $_POST['current_section'] = empty($section->section) ? 1 : $section->section;\n//\t\t\t\t\t$module = container::update($newmodule,$module,expUnserialize($module->external));\n//// if ($iloc->mod == 'calendarmodule') {\n//// $config = $old_db->selectObject('calendarmodule_config', \"location_data='\".serialize($iloc).\"'\");\n//// $config->id = '';\n//// $config->enable_categories = 1;\n//// $config->enable_tags = 0;\n//// $config->location_data = $module->internal;\n//// $config->aggregate = serialize(Array($iloc->src));\n//// $db->insertObject($config, 'calendarmodule_config');\n//// }\n//\t\t\t\t}\n//\t\t\t\t$res = $db->insertObject($module, 'container');\n//\t\t\t\tif ($res) { @$this->msg['container']++; }\n }\n }",
"\t\tif (isset($this->params['copy_permissions'])) {\n\t\t\t$db->delete('userpermission',\"module != 'navigation'\");\n\t\t\t$db->delete('grouppermission',\"module != 'navigation'\");",
"\t\t\t$users = $db->selectObjects('user','id > 1');\n\t\t\tforeach($users as $user) {\n\t\t\t\t$containers = $old_db->selectObjects('userpermission',\"uid='\".$user->id.\"' AND source != ''\");\n\t\t\t\tforeach($containers as $item) {\n $loc = expCore::makeLocation($item->module,$item->source);\n\t\t\t\t\tif (array_key_exists($item->module, $this->new_modules)) {\n\t\t\t\t\t\t$loc->mod = $this->new_modules[$item->module];\n\t\t\t\t\t\t$item->module = $this->new_modules[$item->module];\n $item = $this->convert_permission($item);\n }\n\t\t\t\t\tif ($item && $db->selectObject('container',\"internal = '\".serialize($loc).\"'\")) {\n\t\t\t\t\t\t$db->insertObject($item,'userpermission');\n\t\t\t\t\t\tif ($item->permission == 'edit') { // if they had edit permission, we'll also give them create permission\n\t\t\t\t\t\t\t$item->permission = 'create';\n\t\t\t\t\t\t\t@$db->insertObject($item,'userpermission');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t$groups = $db->selectObjects('group','1');\n\t\t\tforeach($groups as $group) {\n\t\t\t\t$containers = $old_db->selectObjects('grouppermission',\"gid='\".$group->id.\"' AND source != ''\");\n\t\t\t\tforeach($containers as $item) {\n $loc = expCore::makeLocation($loc->mod = $item->module,$item->source);\n\t\t\t\t\tif (array_key_exists($item->module, $this->new_modules)) {\n\t\t\t\t\t\t$loc->mod = $this->new_modules[$item->module];\n\t\t\t\t\t\t$item->module = $this->new_modules[$item->module];\n\t\t\t\t\t\t$item = $this->convert_permission($item);\n\t\t\t\t\t}\n\t\t\t\t\tif ($item && $db->selectObject('container',\"internal = '\".serialize($loc).\"'\")) {\n\t\t\t\t\t\t$db->insertObject($item,'grouppermission');\n\t\t\t\t\t\tif ($item->permission == 'edit') { // if they had edit permission, we'll also give them create permission\n\t\t\t\t\t\t\t$item->permission = 'create';\n\t\t\t\t\t\t\t@$db->insertObject($item,'grouppermission');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}",
" // migrate the active controller list (modstate)\n $activemods = $old_db->selectObjects('modstate',1);\n foreach($activemods as $mod) {\n if (array_key_exists($mod->module, $this->new_modules)) {\n $mod->module = $this->new_modules[$mod->module];\n }\n if (array_key_exists($mod->module, $this->new_modules) || !in_array($mod->module, $this->deprecated_modules)) {\n// $mod->path = '';\n// $mod->user_runnable = 1;\n// $mod->controller = 1;\n// $mod->os_module = 1;\n// $mod->name = '';\n// $mod->author = '';\n// $mod->description = '';\n// $mod->codequality = '';\n if ($db->selectObject('modstate',\"module='\".$mod->module.\"'\")) {\n $db->updateObject($mod,'modstate',null,'module');\n } else {\n $db->insertObject($mod,'modstate');\n }\n }\n }",
"\t\tsearchController::spider();\n expSession::clearCurrentUserSessionCache();\n assign_to_template(array(\n 'msg'=>@$this->msg\n ));\n }",
"\t/**\n\t * gather info about all users/groups in old site for user selection\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n\tpublic function manage_users() {\n global $db;",
" expHistory::set('manageable', $this->params);\n $old_db = $this->connect();\n $users = $old_db->selectObjects('user','id > 1');\n foreach($users as $user) {\n\t\t\tif ($db->selectObject('user',\"id='\".$user->id.\"'\")) {\n\t\t\t\t$user->exists = true;\n\t\t\t} else {\n\t\t\t\t$user->exists = false;\n\t\t\t}\n\t\t}",
" $groups = $old_db->selectObjects('group');\n foreach($groups as $group) {\n\t\t\tif ($db->selectObject('group',\"id='\".$group->id.\"'\")) {\n\t\t\t\t$group->exists = true;\n\t\t\t} else {\n\t\t\t\t$group->exists = false;\n\t\t\t}\n\t\t}\n\t\tassign_to_template(array(\n 'users'=>$users,\n 'groups'=>$groups\n ));\n }",
"\t/**\n\t * copy selected users/groups over from old site\n\t * @var \\mysqli_database $db the exponent database object\n\t * @return void\n\t */\n public function migrate_users() {\n global $db;",
"\t\tif (isset($this->params['wipe_groups'])) {\n\t\t\t$db->delete('group');\n\t\t\t$db->delete('groupmembership');\n\t\t}\n\t\tif (isset($this->params['wipe_users'])) {\n\t\t\t$db->delete('user','id > 1');\n\t\t}\n $old_db = $this->connect();\n//\t\tprint_r(\"<pre>\");\n//\t\tprint_r($old_db->selectAndJoinObjects('', '', 'group', 'groupmembership','id', 'group_id', 'name = \"Editors\"', ''));",
" $gsuccessful = 0;\n $gfailed = 0;\n\t\tif (!empty($this->params['groups'])) {\n\t\t\tforeach($this->params['groups'] as $groupid) {\n\t\t\t\t$group = $old_db->selectObject('group', 'id='.$groupid);\n\t\t\t\t$ret = $db->insertObject($group, 'group');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$gfailed++;\n\t\t\t\t} else {\n\t\t\t\t\t$gsuccessful++;\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tif (!empty($this->params['rep_groups'])) {\n\t\t\tforeach($this->params['rep_groups'] as $groupid) {\n\t\t\t\t$db->delete('group','id='.$groupid);\n\t\t\t\t$group = $old_db->selectObject('group', 'id='.$groupid);\n\t\t\t\t$ret = $db->insertObject($group, 'group');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$gfailed++;\n\t\t\t\t} else {\n\t\t\t\t\t$gsuccessful++;\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n $successful = 0;\n $failed = 0;\n\t\tif (!empty($this->params['users'])) {\n\t\t\tforeach($this->params['users'] as $userid) {\n\t\t\t\t$user = $old_db->selectObject('user', 'id='.$userid);\n\t\t\t\t$ret = $db->insertObject($user, 'user');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$failed++;\n\t\t\t\t} else {\n\t\t\t\t\t$successful++;\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tif (!empty($this->params['rep_users'])) {\n\t\t\tforeach($this->params['rep_users'] as $userid) {\n\t\t\t\t$db->delete('user','id='.$userid);\n\t\t\t\t$user = $old_db->selectObject('user', 'id='.$userid);\n\t\t\t\t$ret = $db->insertObject($user, 'user');\n\t\t\t\tif (empty($ret)) {\n\t\t\t\t\t$failed++;\n\t\t\t\t} else {\n\t\t\t\t\t$successful++;\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t $users = new stdClass();\n\t $groups = new stdClass();\n\t\tif (!empty($this->params['groups']) && !empty($this->params['rep_groups'])) {\n\t\t\t$groups = array_merge($this->params['groups'],$this->params['rep_groups']);\n\t\t} elseif (!empty($this->params['groups'])) {\n\t\t\t$groups = $this->params['groups'];\n\t\t} elseif (!empty($this->params['rep_groups'])) {\n\t\t\t$groups = $this->params['rep_groups'];\n\t\t}\n\t\tif (!empty($this->params['users']) && !empty($this->params['rep_users'])) {\n\t\t\t$users = array_merge($this->params['users'],$this->params['rep_users']);\n\t\t} elseif (!empty($this->params['users'])) {\n\t\t\t$users = $this->params['users'];\n\t\t} elseif (!empty($this->params['rep_users'])) {\n\t\t\t$users = $this->params['rep_users'];\n\t\t}\n\t\tif (!empty($groups) && !empty($users)) {\n\t\t\tforeach($groups as $groupid) {\n\t\t\t\t$groupmembers = $old_db->selectObjects('groupmembership', 'group_id='.$groupid);\n\t\t\t\tforeach($groupmembers as $userid) {\n\t\t\t\t\tif (in_array($userid->member_id,$users)) {\n\t\t\t\t\t\t$db->insertObject($userid, 'groupmembership');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n flash('message', $successful.' '.gt('users and').' '.$gsuccessful.' '.gt('groups were imported from').' '.$this->config['database']);\n if ($failed > 0 || $gfailed > 0) {\n\t\t\t$msg = '';\n\t\t\tif ($failed > 0) {\n\t\t\t\t$msg = $failed.' users ';\n\t\t\t}\n\t\t\tif ($gfailed > 0) {\n\t\t\t\tif ($msg != '') { $msg .= ' and ';}\n\t\t\t\t$msg .= $gfailed.' groups ';\n\t\t\t}\n flash('error', $msg.' '.gt('could not be imported from').' '.$this->config['database'].' '.gt('This is usually because a user with the username or group with that name already exists in the database you importing to.'));\n }\n expSession::clearCurrentUserSessionCache();\n expHistory::back();\n }",
"\t/**\n\t * main routine to convert old school module data into new controller format\n\t * @var \\mysqli_database $db the exponent database object\n\t * @param $iloc\n\t * @param $module\n\t * @param int $hc\n\t * @return\n\t */\n private function convert($iloc, $module, $hc=0) {\n if (!in_array($iloc->mod, $this->params['migrate'])) return $module;\n global $db;\n $old_db = $this->connect();\n\t\t$linked = false;\n\t $loc = new stdClass();\n $newconfig = new expConfig();\n if ((!empty($module->is_existing) && $module->is_existing)) {\n $linked = true;\n }",
" switch ($iloc->mod) {\n case 'textmodule':\n\t\t\t\t@$module->view = 'showall';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n\t\t\t\t$ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"text\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'textmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'textmodule';\n $textitems = $old_db->selectObjects('textitem', \"location_data='\".serialize($iloc).\"'\");\n if ($textitems) {\n foreach ($textitems as $ti) {\n $text = new text();\n $loc = expUnserialize($ti->location_data);\n $loc->mod = \"text\";\n $text->location_data = serialize($loc);\n $text->body = $ti->text;\n $text->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n }\n\t\t\t\tbreak;\n case 'rotatormodule':\n $module->action = 'showRandom';\n $module->view = 'showRandom';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"text\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'rotatormodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'rotatormodule';\n $textitems = $old_db->selectObjects('rotator_item', \"location_data='\".serialize($iloc).\"'\");\n if ($textitems) {\n foreach ($textitems as $ti) {\n $text = new text();\n $loc = expUnserialize($ti->location_data);\n $loc->mod = \"text\";\n $text->location_data = serialize($loc);\n $text->body = $ti->text;\n $text->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n }\n\t\t\t\tbreak;\n case 'snippetmodule':\n\t\t\t\t$module->view = 'showall';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"snippet\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'snippetmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'snippetmodule';\n $textitems = $old_db->selectObjects('textitem', \"location_data='\".serialize($iloc).\"'\");\n if ($textitems) {\n foreach ($textitems as $ti) {\n $text = new snippet();\n $loc = expUnserialize($ti->location_data);\n $loc->mod = \"snippet\";\n $text->location_data = serialize($loc);\n $text->body = $ti->text;\n // if the item exists in the current db, we won't save it\n $te = $text->find('first',\"location_data='\".$text->location_data.\"'\");\n if (empty($te)) {\n $text->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n }\n }\n\t\t\t\tbreak;\n case 'linklistmodule':\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'Quick Links':\n\t\t\t\t\t\t@$module->view = \"showall_quicklinks\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t@$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"links\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'linklistmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'linklistmodule';\n $links = $old_db->selectArrays('linklist_link', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($links) {\n\t\t\t\t\tforeach ($links as $link) {\n\t\t\t\t\t\t$lnk = new links();\n\t\t\t\t\t\t$loc = expUnserialize($link['location_data']);\n\t\t\t\t\t\t$loc->mod = \"links\";\n\t\t\t\t\t\t$lnk->title = (!empty($link['name'])) ? $link['name'] : 'Untitled';\n\t\t\t\t\t\t$lnk->body = $link['description'];\n\t\t\t\t\t\t$lnk->new_window = $link['opennew'];\n\t\t\t\t\t\t$lnk->url = (!empty($link['url'])) ? $link['url'] : '#';\n\t\t\t\t\t\t$lnk->rank = $link['rank']+1;\n\t\t\t\t\t\t$lnk->poster = 1;\n\t\t\t\t\t\t$lnk->editor = 1;\n\t\t\t\t\t\t$lnk->location_data = serialize($loc);\n\t\t\t\t\t\t$lnk->save();\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'linkmodule': // user mod, not widely distributed\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'Summary':\n\t\t\t\t\t\t@$module->view = \"showall_quicklinks\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t@$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldconfig = $old_db->selectObject('linkmodule_config', \"location_data='\".serialize($iloc).\"'\");\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_rss == 1) {\n $newconfig->config['enable_rss'] = true;\n $newconfig->config['advertise'] = true;\n $newconfig->config['feed_title'] = $oldconfig->feed_title;\n $newconfig->config['feed_desc'] = $oldconfig->feed_desc;\n $newconfig->config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;\n $newconfig->config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;\n }\n if (!empty($oldconfig->orderhow)) {\n if ($oldconfig->orderby == 'name') $newconfig->config['order'] = 'title';\n switch ($oldconfig->orderhow) {\n case '1':\n $newconfig->config['order'] .= ' DESC';\n break;\n case '2':\n $newconfig->config['order'] = 'rank';\n break;\n }\n }\n if ($oldconfig->enable_categories == 1) {\n $newconfig->config['usecategories'] = true;\n }\n }",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"links\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'linkmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'linkmodule';\n $links = $old_db->selectArrays('link', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($links) {\n\t\t\t\t\tforeach ($links as $link) {\n\t\t\t\t\t\t$lnk = new links();\n\t\t\t\t\t\t$loc = expUnserialize($link['location_data']);\n\t\t\t\t\t\t$loc->mod = \"links\";\n\t\t\t\t\t\t$lnk->title = (!empty($link['name'])) ? $link['name'] : 'Untitled';\n\t\t\t\t\t\t$lnk->body = $link['description'];\n\t\t\t\t\t\t$lnk->new_window = $link['opennew'];\n\t\t\t\t\t\t$lnk->url = (!empty($link['url'])) ? $link['url'] : '#';\n\t\t\t\t\t\t$lnk->rank = $link['rank']+1;\n\t\t\t\t\t\t$lnk->poster = 1;\n\t\t\t\t\t\t$lnk->editor = 1;\n\t\t\t\t\t\t$lnk->location_data = serialize($loc);\n\t\t\t\t\t\t$lnk->save();\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n if (!empty($oldconfig) && $oldconfig->enable_categories == 1 && $link['category_id']) {\n $params = null;\n $oldcat = $old_db->selectObject('category','id = '.$link['category_id']);\n $cat = new expCat($oldcat->name);\n if (empty($cat->id)) {\n $cat->title = $oldcat->name;\n $cat->color = $oldcat->color;\n $catloc = expUnserialize($oldcat->location_data);\n if (array_key_exists($catloc->mod, $this->new_modules)) {\n $mod = expModules::getModuleName($this->new_modules[$catloc->mod]);\n $cat->module = $mod;\n }\n $cat->save();\n $cat->rank = $oldcat->rank + 1;\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n $lnk->update($params);\n }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'swfmodule':\n\t\t\t\t$module->view = 'showall';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"text\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'swfmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'swfmodule';\n $swfitems = $old_db->selectObjects('swfitem', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($swfitems) {\n\t\t\t\t\tforeach ($swfitems as $ti) {\n\t\t\t\t\t\t$text = new text();\n\t\t\t\t\t\t$file = new expFile($ti->swf_id);\n\t\t\t\t\t\t$loc = expUnserialize($ti->location_data);\n\t\t\t\t\t\t$loc->mod = \"text\";\n\t\t\t\t\t\t$text->location_data = serialize($loc);\n\t\t\t\t\t\t$text->title = $ti->name;\n\t\t\t\t\t\t$swfcode = '\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" height=\"'.$ti->height.'\" width=\"'.$ti->width.'\">\n\t\t\t\t\t\t\t\t <param name=\"bgcolor\" value=\"'.$ti->bgcolor.'\" />\n\t\t\t\t\t\t\t\t\t'.($ti->transparentbg?\"<param name=\\\"wmode\\\" value=\\\"transparent\\\" />\":\"\").'\n\t\t\t\t\t\t\t\t <param name=\"quality\" value=\"high\" />\n\t\t\t\t\t\t\t\t <param name=\"movie\" value=\"'.$file->path_relative.'\" />\n\t\t\t\t\t\t\t\t <embed bgcolor= \"'.$ti->bgcolor.'\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" quality=\"high\" src=\"'.$file->path_relative.'\" type=\"application/x-shockwave-flash\" height=\"'.$ti->height.'\" width=\"'.$ti->width.'\"'.($ti->transparentbg?\" wmode=\\\"transparent\\\"\":\"\").'>\n\t\t\t\t\t\t\t\t </embed>\n\t\t\t\t\t\t\t </object>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t';\n\t\t\t\t\t\t$text->body = $swfcode;\n\t\t\t\t\t\t$text->save();\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'newsmodule':\n $only_featured = false;\n $usebody = 0;\n\t\t\t\tswitch ($module->view) {\n case 'Featured News':\n $only_featured = true;\n $module->view = 'showall';\n break;\n\t\t\t\t\tcase 'Headlines':\n $usebody = 2;\n\t\t\t\t\t\t$module->view = 'showall_headlines';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Summary':\n case 'Default':\n $usebody = 1;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldconfig = $old_db->selectObject('newsmodule_config', \"location_data='\".serialize($iloc).\"'\");\n $oldviewconfig = expUnserialize($old_db->selectValue('container','view_data', \"internal='\".serialize($iloc).\"'\"));\n $ploc = clone($iloc);\n $ploc->mod = \"news\";\n // fudge a config to get attached files to appear\n $newconfig->config = expUnserialize('a:14:{s:9:\"feedmaker\";s:0:\"\";s:11:\"filedisplay\";s:7:\"Gallery\";s:6:\"ffloat\";s:4:\"Left\";s:6:\"fwidth\";s:3:\"120\";s:7:\"fmargin\";s:1:\"5\";s:7:\"piwidth\";s:3:\"100\";s:5:\"thumb\";s:3:\"100\";s:7:\"spacing\";s:2:\"10\";s:10:\"floatthumb\";s:8:\"No Float\";s:6:\"tclass\";s:0:\"\";s:5:\"limit\";s:0:\"\";s:9:\"pagelinks\";s:14:\"Top and Bottom\";s:10:\"feed_title\";s:0:\"\";s:9:\"feed_desc\";s:0:\"\";}');\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_rss == 1) {\n $newconfig->config['enable_rss'] = true;\n $newconfig->config['advertise'] = true;\n $newconfig->config['feed_title'] = $oldconfig->feed_title;\n $newconfig->config['feed_desc'] = $oldconfig->feed_desc;\n $newconfig->config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;\n $newconfig->config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;\n }\n if (!empty($oldconfig->item_limit)) {\n $newconfig->config['limit'] = $oldconfig->item_limit;\n $newconfig->config['multipageonly'] = true;\n }\n if (!empty($oldconfig->sortfield)) {\n switch ($oldconfig->sortfield) {\n case 'publish':\n $newconfig->config['order'] = 'publish';\n break;\n case 'edited':\n $newconfig->config['order'] = 'edited_at';\n break;\n case 'posted':\n default:\n $newconfig->config['order'] = 'created_at';\n break;\n }\n if ($oldconfig->sortorder == 'DESC') {\n $newconfig->config['order'] .= ' DESC';\n }\n }\n if (!empty($oldconfig->aggregate) && $oldconfig->aggregate != 'a:0:{}') {\n $merged = expUnserialize($oldconfig->aggregate);\n foreach ($merged as $merge) {\n $newconfig->config['aggregate'][] = $merge;\n }\n }\n if (!empty($oldconfig->pull_rss) && $oldconfig->pull_rss) {\n $pulled = expUnserialize($oldconfig->rss_feed);\n foreach ($pulled as $pull) {\n $newconfig->config['pull_rss'][] = $pull;\n }\n }\n }\n if ($usebody) {\n $newconfig->config['usebody'] = $usebody;\n }\n if (!empty($oldviewconfig['num_items'])) {\n $newconfig->config['limit'] = $oldviewconfig['num_items'];\n// $newconfig->config['pagelinks'] = \"Don't show page links\";\n }\n $only_featured = empty($oldviewconfig['featured_only']) ? 0 : 1;\n if ($only_featured) {\n $newconfig->config['only_featured'] = true;\n }",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'newsmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'newsmodule';\n $newsitems = $old_db->selectArrays('newsitem', \"location_data='\".serialize($iloc).\"'\");\n if ($newsitems) {\n foreach ($newsitems as $ni) {\n unset($ni['id']);\n $news = new news($ni);\n $loc = expUnserialize($ni['location_data']);\n $loc->mod = \"news\";\n $news->location_data = serialize($loc);\n $news->title = (!empty($ni['title'])) ? $ni['title'] : gt('Untitled');\n $news->body = (!empty($ni['body'])) ? $ni['body'] : gt('(empty)');\n $news->save();\n\t\t\t\t\t\t// default is to create with current time\n $news->created_at = $ni['posted'];\n $news->migrated_at = $ni['edited'];\n $news->update();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n if (!empty($ni['file_id'])) {\n $file = new expFile($ni['file_id']);\n $news->attachItem($file,'');\n }\n if (isset($oldconfig->enable_tags) && $oldconfig->enable_tags = true) {\n\t $params = null;;\n\t\t\t\t\t\t\t$oldtags = expUnserialize($ni['tags']);\n if (!empty($oldtags)) {\n foreach ($oldtags as $oldtag){\n $tagtitle = strtolower(trim($old_db->selectValue('tags','name','id = '.$oldtag)));\n $tag = new expTag($tagtitle);\n //\t\t\t\t\t\t\t\t$tag->title = $old_db->selectValue('tags','name','id = '.$oldtag);\n if (empty($tag->id))\n $tag->update(array('title'=>$tagtitle));\n $params['expTag'][] = $tag->id;\n }\n }\n $news->update($params);\n }\n }\n }\n\t\t\t\tbreak;\n case 'resourcesmodule':\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'One Click Download - Descriptive':\n\t\t\t\t\t\t$module->view = 'showall_headlines';\n\t\t\t\t\t\tbreak;\n case 'Recent':\n $module->view = 'showall_recent';\n $newconfig->config['usebody'] = 2;\n break;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldconfig = $old_db->selectObject('resourcesmodule_config', \"location_data='\".serialize($iloc).\"'\");\n $oldviewconfig = expUnserialize($old_db->selectValue('container','view_data', \"internal='\".serialize($iloc).\"'\"));\n $ploc = clone($iloc);\n $ploc->mod = \"filedownload\";\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_categories == 1 && $module->view != 'showall_recent') {\n $newconfig->config['usecategories'] = true;\n }\n if (!empty($oldconfig->description)) {\n $newconfig->config['moduledescription'] = $oldconfig->description;\n }\n if (isset($oldconfig->enable_rss)) {\n $dorss = $oldconfig->enable_rss;\n } elseif (isset($oldconfig->enable_podcasting)) {\n $dorss = $oldconfig->enable_podcasting;\n } else {\n $dorss = false;\n }\n if ($dorss) {\n $newconfig->config['enable_rss'] = true;\n $newconfig->config['advertise'] = true;\n $newconfig->config['feed_title'] = $oldconfig->feed_title;\n $newconfig->config['feed_desc'] = $oldconfig->feed_desc;\n $newconfig->config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;\n $newconfig->config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;\n }\n if (!empty($oldconfig->orderhow)) {\n switch ($oldconfig->orderby) {\n case 'edited':\n $newconfig->config['order'] = 'edited_at';\n break;\n case 'downloads':\n $newconfig->config['order'] = 'downloads';\n break;\n case 'name':\n $newconfig->config['order'] = 'title';\n break;\n case 'posted':\n default:\n $newconfig->config['order'] = 'created_at';\n break;\n }\n switch ($oldconfig->orderhow) {\n case '2':\n $newconfig->config['order'] = 'rank';\n break;\n case '1':\n $newconfig->config['order'] .= ' DESC';\n break;\n }\n }\n }\n if (!empty($oldviewconfig['num_posts'])) {\n $newconfig->config['limit'] = $oldviewconfig['num_posts'];\n// $newconfig->config['pagelinks'] = \"Don't show page links\";\n }\n $newconfig->config['usebody'] = 2;\n if (!empty($oldviewconfig['show_descriptions'])) {\n $newconfig->config['show_info'] = $oldviewconfig['show_descriptions'] ? 1 : 0;\n if ($oldviewconfig['show_descriptions']) {\n $newconfig->config['usebody'] = 0;\n }\n }\n $newconfig->config['quick_download'] = !empty($oldviewconfig['direct_download']) ? $oldviewconfig['direct_download'] : 0;\n $newconfig->config['show_icon'] = !empty($oldviewconfig['show_icons']) ? $oldviewconfig['show_icons'] : 0;\n $newconfig->config['show_player'] = !empty($oldviewconfig['show_player']) ? $oldviewconfig['show_player'] : 0;",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n//\t\t\t\tif ($db->countObjects('filedownloads', \"location_data='\".serialize($ploc).\"'\")) {\n if ($db->countObjects('filedownload', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'resourcesmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'resourcesmodule';\n $resourceitems = $old_db->selectArrays('resourceitem', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($resourceitems) {\n\t\t\t\t\tforeach ($resourceitems as $ri) {\n\t\t\t\t\t\tunset($ri['id']);\n\t\t\t\t\t\t$filedownload = new filedownload($ri);\n\t\t\t\t\t\t$loc = expUnserialize($ri['location_data']);\n\t\t\t\t\t\t$loc->mod = \"filedownload\";\n\t\t\t\t\t\t$filedownload->title = (!empty($ri['name'])) ? $ri['name'] : 'Untitled';\n\t\t\t\t\t\t$filedownload->body = $ri['description'];\n\t\t\t\t\t\t$filedownload->downloads = $ri['num_downloads'];\n\t\t\t\t\t\t$filedownload->location_data = serialize($loc);\n\t\t\t\t\t\tif (!empty($ri['file_id'])) {\n\t\t\t\t\t\t\t$filedownload->save();\n\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t\t\t$file = new expFile($ri['file_id']);\n\t\t\t\t\t\t\t$filedownload->attachItem($file,'downloadable');\n\t\t\t\t\t\t\t// default is to create with current time\t\t\t\t\t\t\n\t\t\t\t\t\t\t$filedownload->created_at = $ri['posted'];\n\t\t\t\t\t\t\t$filedownload->migrated_at = $ri['edited'];\n $filedownload->publish = $ri['posted'];\n\t\t\t\t\t\t\t$filedownload->update();\n if (!empty($oldconfig) && $oldconfig->enable_categories == 1 && $ri['category_id']) {\n $params = null;\n $oldcat = $old_db->selectObject('category','id = '.$ri['category_id']);\n $cat = new expCat($oldcat->name);\n if (empty($cat->id)) {\n $cat->title = $oldcat->name;\n $cat->color = $oldcat->color;\n $catloc = expUnserialize($oldcat->location_data);\n if (array_key_exists($catloc->mod, $this->new_modules)) {\n $mod = expModules::getModuleName($this->new_modules[$catloc->mod]);\n $cat->module = $mod;\n }\n $cat->save();\n $cat->rank = $oldcat->rank +1;\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n $filedownload->update($params);\n }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'imagegallerymodule':\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'Slideshow':\n\t\t\t\t\t\t$module->action = 'slideshow';\n\t\t\t\t\t\t$module->view = 'slideshow';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldviewconfig = expUnserialize($old_db->selectValue('container','view_data', \"internal='\".serialize($iloc).\"'\"));\n $newconfig->config['usecategories'] = true;\n $newconfig->config['multipageonly'] = true;\n $newconfig->config['speed'] = empty($oldviewconfig['delay']) ? 0: $oldviewconfig['delay']/1000;\n $newconfig->config['pa_show_controls'] = empty($oldviewconfig['controller']) ? 0 : 1;",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"photo\";\n\t\t\t\tif ($db->countObjects('photo', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'imagegallerymodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"//\t\t\t\t$iloc->mod = 'imagegallerymodule';\n $galleries = $old_db->selectArrays('imagegallery_gallery', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($galleries) {\n\t\t\t\t\tforeach ($galleries as $gallery) {\n $params = null;;\n $cat = new expCat($gallery['name']);\n if (empty($cat->id)) {\n $cat->title = $gallery['name'];\n $cat->rank = $gallery['galleryorder']+1;\n $cat->module = 'photo';\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n\t\t\t\t\t\t$gis = $old_db->selectArrays('imagegallery_image', \"gallery_id='\".$gallery['id'].\"'\");\n\t\t\t\t\t\tforeach ($gis as $gi) {\n\t\t\t\t\t\t\t$photo = new photo();\n\t\t\t\t\t\t\t$loc = expUnserialize($gallery['location_data']);\n\t\t\t\t\t\t\t$loc->mod = \"photo\";\n\t\t\t\t\t\t\t$photo->title = (!empty($gi['name'])) ? $gi['name'] : 'Untitled';\n\t\t\t\t\t\t\t$photo->body = $gi['description'];\n\t\t\t\t\t\t\t$photo->alt = !empty($gi['alt']) ? $gi['alt'] : $photo->title;\n\t\t\t\t\t\t\t$photo->location_data = serialize($loc);\n\t\t\t\t\t\t\tif (!empty($gi['file_id'])) {\n\t\t\t\t\t\t\t\t$photo->save();\n\t\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t\t\t\t$file = new expFile($gi['file_id']);\n\t\t\t\t\t\t\t\t$photo->attachItem($file,'');\n\t\t\t\t\t\t\t\t$photo->created_at = $gi['posted'];\n\t\t\t\t\t\t\t\t$photo->migrated_at = $gi['posted'];\n\t\t\t\t\t\t\t\t$photo->update(array(\"validate\"=>false));\t\t\t\t\t\t\t\t\n $photo->update($params); // save gallery name as category\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n // pick up some module config settings based on last gallery\n $newconfig->config['pa_showall_thumbbox'] = $gallery['box_size'];\n $newconfig->config['pa_showall_enlarged'] = $gallery['pop_size'];\n $newconfig->config['limit'] = $gallery['perpage'];\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'slideshowmodule':\n $module->action = 'slideshow';\n $module->view = 'slideshow';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"photo\";\n\t\t\t\tif ($db->countObjects('photo', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'slideshowmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'slideshowmodule';\n $gis = $old_db->selectArrays('slideshow_slide', \"location_data='\".serialize($iloc).\"'\");\n if ($gis) {\n foreach ($gis as $gi) {\n $photo = new photo();\n $loc->mod = \"photo\";\n $loc->src = $iloc->src;\n $loc->int = $iloc->int;\n $photo->title = (!empty($gi['name'])) ? $gi['name'] : 'Untitled';\n $photo->body = $gi['description'];\n $photo->alt = !empty($gi['alt']) ? $gi['alt'] : $photo->title;\n $photo->location_data = serialize($loc);\n $te = $photo->find('first',\"location_data='\".$photo->location_data.\"'\");\n if (empty($te)) {\n if (!empty($gi['file_id'])) {\n $photo->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n $file = new expFile($gi['file_id']);\n $photo->attachItem($file,'');\n $photo->update(array(\"validate\"=>false));\n }\n }\n }\n }\n\t\t\t\tbreak;\n case 'headlinemodule':\n $module->view = 'showall_headline';",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"text\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'headlinemodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'headlinemodule';\n $headlines = $old_db->selectObjects('headline', \"location_data='\".serialize($iloc).\"'\");\n if ($headlines) {\n foreach ($headlines as $hl) {\n $headline = new text();\n $loc = expUnserialize($hl->location_data);\n $loc->mod = \"text\";\n $headline->location_data = serialize($loc);\n $headline->title = $hl->headline;\n $headline->poster = 1;\n// $headline->created_at = time();\n// $headline->migrated_at = time();\n $headline->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n }\n\t\t\t\tbreak;\n case 'weblogmodule':\n $usebody = 0;\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'By Author':\n\t\t\t\t\t\t$module->action = 'authors';\n\t\t\t\t\t\t$module->view = 'authors';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'By Tag':\n\t\t\t\t\t\t$module->action = 'tags';\n\t\t\t\t\t\t$module->view = 'tags_list';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Monthly':\n\t\t\t\t\t\t$module->action = 'dates';\n\t\t\t\t\t\t$module->view = 'dates';\n\t\t\t\t\t\tbreak;\n case 'Summary':\n $usebody = 2;\n\t\t\t\t\t\t$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n case 'Default':\n $usebody = 1;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t$module->view = 'showall';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldconfig = $old_db->selectObject('weblogmodule_config', \"location_data='\".serialize($iloc).\"'\");\n $oldviewconfig = expUnserialize($old_db->selectValue('container','view_data', \"internal='\".serialize($iloc).\"'\"));\n $ploc = clone($iloc);\n $ploc->mod = \"blog\";\n $newconfig->config['add_source'] = '1';\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_rss == 1) {\n $newconfig->config['enable_rss'] = true;\n $newconfig->config['advertise'] = true;\n $newconfig->config['feed_title'] = $oldconfig->feed_title;\n $newconfig->config['feed_desc'] = $oldconfig->feed_desc;\n $newconfig->config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;\n $newconfig->config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;\n }\n if (!empty($oldconfig->items_per_page)) {\n $newconfig->config['limit'] = $oldconfig->items_per_page;\n $newconfig->config['multipageonly'] = true;\n }\n if (!empty($oldviewconfig['num_posts'])) {\n $newconfig->config['limit'] = $oldviewconfig['num_posts'];\n // $newconfig->config['pagelinks'] = \"Don't show page links\";\n }\n if (!empty($oldconfig->allow_comments)) {\n $newconfig->config['usescomments'] = !$oldconfig->allow_comments;\n }\n if (!empty($oldconfig->aggregate) && $oldconfig->aggregate != 'a:0:{}') {\n $merged = expUnserialize($oldconfig->aggregate);\n foreach ($merged as $merge) {\n $newconfig->config['aggregate'][] = $merge;\n }\n }\n }\n if ($usebody) {\n $newconfig->config['usebody'] = $usebody;\n }",
" //check to see if it's already pulled in (circumvent !is_original)\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'weblogmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'weblogmodule';\n $blogitems = $old_db->selectArrays('weblog_post', \"location_data='\".serialize($iloc).\"'\");\n if ($blogitems) {\n foreach ($blogitems as $bi) {\n unset($bi['id']);\n $post = new blog($bi);\n $loc = expUnserialize($bi['location_data']);\n $loc->mod = \"blog\";\n $post->location_data = serialize($loc);\n $post->title = (!empty($bi['title'])) ? $bi['title'] : gt('Untitled');\n $post->body = (!empty($bi['body'])) ? $bi['body'] : gt('(empty)');\n $post->save();\n\t\t\t\t\t\t// default is to create with current time\t\t\t\t\t\t\n $post->created_at = $bi['posted'];\n $post->migrated_at = $bi['edited'];\n $post->update();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t\t// this next section is moot since there are no attachments to blogs\n // if (!empty($bi['file_id'])) {\n // $file = new expFile($bi['file_id']);\n // $post->attachItem($file,'downloadable');\n // }",
" if (isset($oldconfig->enable_tags) && $oldconfig->enable_tags = true) {\n\t $params = null;;\n\t\t\t\t\t\t\t$oldtags = expUnserialize($bi['tags']);\n\t\t\t\t\t\t\tforeach ($oldtags as $oldtag){\n\t\t\t\t\t\t\t\t$tagtitle = strtolower(trim($old_db->selectValue('tags','name','id = '.$oldtag)));\n\t\t\t\t\t\t\t\t$tag = new expTag($tagtitle);\n//\t\t\t\t\t\t\t\t$tag->title = $old_db->selectValue('tags','name','id = '.$oldtag);\n\t\t\t\t\t\t\t\tif (empty($tag->id))\n $tag->update(array('title'=>$tagtitle));\n\t\t\t\t\t\t\t\t$params['expTag'][] = $tag->id;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t$post->update($params);\n }",
"\t\t\t\t\t\t$comments = $old_db->selectArrays('weblog_comment', \"parent_id='\".$post->id.\"'\");\n\t\t\t\t\t\tforeach($comments as $comment) {\n\t\t\t\t\t\t\tunset($comment['id']);\n\t\t\t\t\t\t\t$newcomment = new expComment($comment);\n\t\t\t\t\t\t\t$newcomment->created_at = $comment['posted'];\n\t\t\t\t\t\t\t$newcomment->migrated_at = $comment['edited'];\n $newcomment->publish = $comment['posted'];\n\t\t\t\t\t\t\t$newcomment->update();\n\t\t\t\t\t\t\t// attach the comment to the blog post it belongs to\n// $obj = new stdClass();\n//\t\t\t\t\t\t\t$obj->content_type = 'blog';\n//\t\t\t\t\t\t\t$obj->content_id = $post->id;\n//\t\t\t\t\t\t\t$obj->expcomments_id = $newcomment->id;\n//\t\t\t\t\t\t\tif(isset($this->params['subtype'])) $obj->subtype = $this->params['subtype'];\n//\t\t\t\t\t\t\t$db->insertObject($obj, $newcomment->attachable_table);\n $newcomment->attachComment('blog', $post->id);\n\t\t\t\t\t\t}\n }\n }\n\t\t\t\tbreak;\n case 'faqmodule':\n\t\t\t\t$module->view = 'showall';",
" $oldconfig = $old_db->selectObject('faqmodule_config', \"location_data='\".serialize($iloc).\"'\");\n if (!empty($oldconfig) && $oldconfig->enable_categories == 1) {\n $newconfig->config['usecategories'] = true;\n }\n $newconfig->config['use_toc'] = true;",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"faq\";\n//\t\t\t\tif ($db->countObjects('faqs', \"location_data='\".serialize($ploc).\"'\")) {\n if ($db->countObjects('faq', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'faqmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'faqmodule';\n $faqs = $old_db->selectArrays('faq', \"location_data='\".serialize($iloc).\"'\");\n if ($faqs) {\n foreach ($faqs as $fqi) {\n unset($fqi['id']);\n $faq = new faq($fqi);\n $loc = expUnserialize($fqi['location_data']);\n $loc->mod = \"faq\";\n $faq->location_data = serialize($loc);\n $faq->question = (!empty($fqi['question'])) ? $fqi['question'] : 'Untitled?';\n $faq->answer = $fqi['answer'];\n $faq->rank = $fqi['rank']+1;\n $faq->include_in_faq = 1;\n $faq->submitter_name = 'Unknown';\n $faq->submitter_email = 'address@website.com';\n $faq->save();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n if (!empty($oldconfig) && $oldconfig->enable_categories == 1 && $fqi['category_id']) {\n $params = null;\n $oldcat = $old_db->selectObject('category','id = '.$fqi['category_id']);\n $cat = new expCat($oldcat->name);\n if (empty($cat->id)) {\n $cat->title = $oldcat->name;\n $cat->color = $oldcat->color;\n $catloc = expUnserialize($oldcat->location_data);\n if (array_key_exists($catloc->mod, $this->new_modules)) {\n $mod = expModules::getModuleName($this->new_modules[$catloc->mod]);\n $cat->module = $mod;\n }\n $cat->save();\n $cat->rank = $oldcat->rank + 1;\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n $faq->update($params);\n }\n }\n }\n\t\t\t\tbreak;\n case 'listingmodule':\n $usebody = 0;\n\t\t\t\tswitch ($module->view) {\n\t\t\t\t\tcase 'Simple':\n $module->view = 'showall_simple_list';\n $usebody = 2;\n\t\t\t\t\t\tbreak;\n case 'Default':\n $usebody = 1;\n case 'Full':\n $module->view = 'showall';\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t}",
" $oldconfig = $old_db->selectObject('listingmodule_config', \"location_data='\".serialize($iloc).\"'\");\n // fudge a config to get attached files to appear\n $newconfig->config = expUnserialize('a:11:{s:11:\"filedisplay\";s:7:\"Gallery\";s:6:\"ffloat\";s:4:\"Left\";s:6:\"fwidth\";s:3:\"120\";s:7:\"fmargin\";s:1:\"5\";s:7:\"piwidth\";s:3:\"100\";s:5:\"thumb\";s:3:\"100\";s:7:\"spacing\";s:2:\"10\";s:10:\"floatthumb\";s:8:\"No Float\";s:6:\"tclass\";s:0:\"\";s:5:\"limit\";s:0:\"\";s:9:\"pagelinks\";s:14:\"Top and Bottom\";}');\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_categories == 1) {\n $newconfig->config['usecategories'] = true;\n }\n if (!empty($oldconfig->items_perpage)) {\n $newconfig->config['limit'] = $oldconfig->items_perpage;\n $newconfig->config['multipageonly'] = true;\n }\n if (!empty($oldconfig->orderhow)) {\n if ($oldconfig->orderby == 'name') $newconfig->config['order'] = 'title';\n switch ($oldconfig->orderhow) {\n case '1':\n $newconfig->config['order'] .= ' DESC';\n break;\n case '2':\n $newconfig->config['order'] = 'rank';\n break;\n }\n }\n if (!empty($oldconfig->description)) {\n $newconfig->config['moduledescription'] = $oldconfig->description;\n }\n }\n if ($usebody) {\n $newconfig->config['usebody'] = $usebody;\n }",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"portfolio\";\n\t\t\t\tif ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'listingmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'listingmodule';\n $listingitems = $old_db->selectArrays('listing', \"location_data='\".serialize($iloc).\"'\");\n if ($listingitems) {\n foreach ($listingitems as $li) {\n unset($li['id']);\n $listing = new portfolio($li);\n\t\t\t\t\t\t$listing->title = (!empty($li['name'])) ? $li['name'] : 'Untitled?';\n $loc = expUnserialize($li['location_data']);\n $loc->mod = \"portfolio\";\n $listing->location_data = serialize($loc);\n $listing->featured = true;\n $listing->poster = 1;\n $listing->body = \"<p>\".$li['summary'].\"</p>\".$li['body'];\n $listing->save();\n\t\t\t\t\t\t// default is to create with current time\t\t\t\t\t\t\n// $listing->created_at = time();\n// $listing->migrated_at = time();\n// $listing->update();\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n if (!empty($li['file_id'])) {\n\t\t\t\t\t\t\t$file = new expFile($li['file_id']);\n\t\t\t\t\t\t\t$listing->attachItem($file,'');\n\t\t\t\t\t\t}\n if (!empty($oldconfig) && $oldconfig->enable_categories == 1 && $li['category_id']) {\n $params = null;\n $oldcat = $old_db->selectObject('category','id = '.$li['category_id']);\n $cat = new expCat($oldcat->name);\n if (empty($cat->id)) {\n $cat->title = $oldcat->name;\n $cat->color = $oldcat->color;\n $catloc = expUnserialize($oldcat->location_data);\n if (array_key_exists($catloc->mod, $this->new_modules)) {\n $mod = expModules::getModuleName($this->new_modules[$catloc->mod]);\n $cat->module = $mod;\n }\n $cat->save();\n $cat->rank = $oldcat->rank + 1;\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n $listing->update($params);\n }\n }\n }\n\t\t\t\tbreak;\n case 'youtubemodule': //must convert to media player\n\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"media\";\n\t\t\t\tif ($db->countObjects('media', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'youtubemodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"//\t\t\t\t$iloc->mod = 'youtubemodule';\n $videos = $old_db->selectArrays('youtube', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($videos) {\n\t\t\t\t\tforeach ($videos as $vi) {\n\t\t\t\t\t\tunset ($vi['id']);\n\t\t\t\t\t\t$video = new media($vi);\n\t\t\t\t\t\t$loc = expUnserialize($vi['location_data']);\n\t\t\t\t\t\t$loc->mod = \"media\";\n\t\t\t\t\t\t$video->title = $vi['name'];\n\t\t\t\t\t\tif (empty($video->title)) { $video->title = 'Untitled'; }\n\t\t\t\t\t\t$video->location_data = serialize($loc);\n $video->body = $vi['description'];\n//\t\t\t\t\t\t$yt = explode(\"watch?v=\",$vi['url']);\n//\t\t\t\t\t\tif (empty($yt[1])) {\n//\t\t\t\t\t\t\tbreak;\n//\t\t\t\t\t\t} else {\n//\t\t\t\t\t\t\t$ytid = $yt[1];\n//\t\t\t\t\t\t}\n//\t\t\t\t\t\tunset ($video->url);\n//\t\t\t\t\t\t$video->embed_code = '<iframe title=\"YouTube video player\" width=\"'.$vi['width'].'\" height=\"'.$vi['height'].'\" src=\"http://www.youtube.com/embed/'.$ytid.'\" frameborder=\"0\" allowfullscreen></iframe>';\n\t\t\t\t\t\t$video->save();\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'mediaplayermodule': // must convert media player\n\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"media\";\n\t\t\t\tif ($db->countObjects('media', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'mediaplayermodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"//\t\t\t\t$iloc->mod = 'mediaplayermodule';\n $movies = $old_db->selectArrays('mediaitem', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($movies) {\n\t\t\t\t\tforeach ($movies as $mi) {\n\t\t\t\t\t\tunset ($mi['id']);\n\t\t\t\t\t\t$movie = new media($mi);\n\t\t\t\t\t\t$loc = expUnserialize($mi['location_data']);\n\t\t\t\t\t\t$loc->mod = \"media\";\n\t\t\t\t\t\t$movie->title = $mi['name'];\n\t\t\t\t\t\tif (empty($movie->title)) { $movie->title = 'Untitled'; }\n $movie->body = $mi['description'];\n\t\t\t\t\t\tunset (\n $mi['bgcolor'],\n $mi['alignment'],\n $mi['loop_media'],\n $mi['auto_rewind'],\n $mi['autoplay'],\n $mi['hide_controls']\n );\n\t\t\t\t\t\t$movie->location_data = serialize($loc);\n\t\t\t\t\t\t$movie->poster = 1;\n\t\t\t\t\t\t$movie->rank = 1;\n\t\t\t\t\t\tif (!empty($mi['media_id'])) {\n\t\t\t\t\t\t\t$movie->save();\n\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t\t\t$file = new expFile($mi['media_id']);\n\t\t\t\t\t\t\t$movie->attachItem($file,'files');\n\t\t\t\t\t\t\tif (!empty($mi['alt_image_id'])) {\n\t\t\t\t\t\t\t\t$file = new expFile($mi['alt_image_id']);\n\t\t\t\t\t\t\t\t$movie->attachItem($file,'splash');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'bannermodule':\n\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"banner\";\n\t\t\t\tif ($db->countObjects('banner', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'bannermodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"//\t\t\t\t$iloc->mod = 'bannermodule';\n $banners = $old_db->selectArrays('banner_ad', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($banners) {\n\t\t\t\t\tforeach ($banners as $bi) {\n\t\t\t\t\t\t$oldclicks = $old_db->selectObjects('banner_click', \"ad_id='\".$bi['id'].\"'\");\n\t\t\t\t\t\t$oldcompany = $old_db->selectObject('banner_affiliate', \"id='\".$bi['affiliate_id'].\"'\");\n\t\t\t\t\t\tunset ($bi['id']);\n\t\t\t\t\t\t$banner = new banner($bi);\n\t\t\t\t\t\t$loc = expUnserialize($bi['location_data']);\n\t\t\t\t\t\t$loc->mod = \"banner\";\n\t\t\t\t\t\t$banner->title = $bi['name'];\n\t\t\t\t\t\t$banner->url = (!empty($bi['url'])) ? $bi['url'] : '#';\n\t\t\t\t\t\tif (empty($banner->title)) { $banner->title = 'Untitled'; }\n\t\t\t\t\t\t$banner->location_data = serialize($loc);\n\t\t\t\t\t\t$newcompany = $db->selectObject('companies', \"title='\".$oldcompany->name.\"'\");\n\t\t\t\t\t\tif ($newcompany == null) {\n\t\t\t\t\t\t\t$newcompany = new company();\n\t\t\t\t\t\t\t$newcompany->title = (!empty($oldcompany->name)) ? $oldcompany->name : 'Untitled';\n\t\t\t\t\t\t\t$newcompany->body = $oldcompany->contact_info;\n\t\t\t\t\t\t\t$newcompany->location_data = $banner->location_data;\n\t\t\t\t\t\t\t$newcompany->save();\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t\t$banner->companies_id = $newcompany->id;\n\t\t\t\t\t\t$banner->clicks = 0;\n\t\t\t\t\t\tforeach($oldclicks as $click) {\n\t\t\t\t\t\t\t$banner->clicks += $click->clicks;\n\t\t\t\t\t\t}\n if (!empty($bi['file_id'])) {\n $file = new expFile($bi['file_id']);\n $banner->attachItem($file,'');\n }\n\t\t\t\t\t\t$banner->save();\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n// case 'addressbookmodule': // user mod, not widely distributed\n//\n//\t\t\t\t@$module->view = 'myaddressbook';\n//\t\t\t\t@$module->action = 'myaddressbook';\n//\n//\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n//\t\t\t\t// $ploc = $iloc;\n//\t\t\t\t// $ploc->mod = \"addresses\";\n//\t\t\t\t// if ($db->countObjects($ploc->mod, \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t// $iloc->mod = 'addressbookmodule';\n//\t\t\t\t\t// $linked = true;\n//\t\t\t\t\t// break;\n//\t\t\t\t// }\n//\n//// $iloc->mod = 'addressbookmodule';\n// $addresses = $old_db->selectArrays('addressbook_contact', \"location_data='\".serialize($iloc).\"'\");\n//\t\t\t\tif ($addresses) {\n//\t\t\t\t\tforeach ($addresses as $address) {\n////\t\t\t\t\t\tunset($address['id']);\n//\t\t\t\t\t\t$addr = new address();\n//\t\t\t\t\t\t$addr->user_id = 1;\n//\t\t\t\t\t\t$addr->is_default = 1;\n//\t\t\t\t\t\t$addr->is_billing = 1;\n//\t\t\t\t\t\t$addr->is_shipping = 1;\n//\t\t\t\t\t\t$addr->firstname = (!empty($address['firstname'])) ? $address['firstname'] : 'blank';\n//\t\t\t\t\t\t$addr->lastname = (!empty($address['lastname'])) ? $address['lastname'] : 'blank';\n//\t\t\t\t\t\t$addr->address1 = (!empty($address['address1'])) ? $address['address1'] : 'blank';\n//\t\t\t\t\t\t$addr->city = (!empty($address['city'])) ? $address['city'] : 'blank';\n//\t\t\t\t\t\t$address['state'] = (!empty($address['state'])) ? $address['state'] : 'CA';\n//\t\t\t\t\t\t$state = $db->selectObject('geo_region', 'code=\"'.strtoupper($address['state']).'\"');\n//\t\t\t\t\t\t$addr->state = empty($state->id) ? 0 : $state->id;\n//\t\t\t\t\t\t$addr->zip = (!empty($address['zip'])) ? $address['zip'] : '99999';\n//\t\t\t\t\t\t$addr->phone = (!empty($address['phone'])) ? $address['phone'] : '800-555-1212';\n//\t\t\t\t\t\t$addr->email = (!empty($address['email'])) ? $address['email'] : 'address@website.com';\n//\t\t\t\t\t\t$addr->organization = $address['business'];\n//\t\t\t\t\t\t$addr->phone2 = $address['cell'];\n//\t\t\t\t\t\t$addr->save();\n//\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n//\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n//\t\t\t\t\t}\n//\t\t\t\t}\n//\t\t\t\tbreak;\n case 'feedlistmodule':\n\t\t\t\t@$module->view = 'showall';",
"// $iloc->mod = 'feedlistmodule';\n $feedlist = $old_db->selectObject('feedlistmodule_config', \"location_data='\".serialize($iloc).\"'\");\n if ($feedlist->enable_rss == 1) {\n\t\t\t\t\t$loc = expUnserialize($feedlist->location_data);\n\t\t\t\t\t$loc->mod = \"rss\";\n\t\t\t\t\t$newconfig->config['enable_rss'] = true;\n $newconfig->config['advertise'] = true;\n\t\t\t\t\t$newconfig->config['feed_title'] = $feedlist->feed_title;\n\t\t\t\t\t$newconfig->config['feed_desc'] = $feedlist->feed_desc;\n\t\t\t\t\t$newconfig->config['rss_limit'] = isset($feedlist->rss_limit) ? $feedlist->rss_limit : 24;\n\t\t\t\t\t$newconfig->config['rss_cachetime'] = isset($feedlist->rss_cachetime) ? $feedlist->rss_cachetime : 1440;\n\t\t\t\t\t$newconfig->location_data = $loc;\n//\t\t\t\t\t$newconfig->save();\n\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n\t\t\t\tbreak;\n case 'simplepollmodule': // added v2.0.9\n $oldconfig = $old_db->selectObject('simplepollmodule_config', \"location_data='\".serialize($iloc).\"'\");\n if (!empty($oldconfig)) {\n if (!empty($oldconfig->thank_you_message)) {\n $newconfig->config['thank_you_message'] = 'Thank you for voting.';\n }\n if (!empty($oldconfig->already_voted_message)) {\n $newconfig->config['already_voted_message'] = 'You have already voted in this poll.';\n }\n if (!empty($oldconfig->voting_closed_message)) {\n $newconfig->config['voting_closed_message'] = 'Voting has been closed for this poll.';\n }\n if (!empty($oldconfig->anonymous_timeout)) {\n $newconfig->config['anonymous_timeout'] = '5';\n }\n }",
"\t\t\t\t//check to see if it's already pulled in (circumvent !is_original)\n $ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"simplePoll\";\n\t\t\t\tif ($db->countObjects('simplepoll_question', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'simplepollmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"//\t\t\t\t$iloc->mod = 'simplepollmodule';\n $oldquestions = $old_db->selectArrays('poll_question', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($oldquestions) {\n\t\t\t\t\tforeach ($oldquestions as $qi) {\n\t\t\t\t\t\t$oldanswers = $old_db->selectArrays('poll_answer', \"question_id='\".$qi['id'].\"'\");\n\t\t\t\t\t\t$oldblocks = $old_db->selectArrays('poll_timeblock', \"question_id='\".$qi['id'].\"'\");\n\t\t\t\t\t\tunset ($qi['id']);\n $active = $qi['is_active'];\n unset ($qi['is_active']);\n\t\t\t\t\t\t$question = new simplepoll_question($qi);\n\t\t\t\t\t\t$loc = expUnserialize($qi['location_data']);\n\t\t\t\t\t\t$loc->mod = \"simplePoll\";\n $question->active = $active;\n\t\t\t\t\t\tif (empty($question->question)) { $question->question = 'Untitled'; }\n $question->location_data = serialize($loc);\n $question->save();",
" foreach ($oldanswers as $oi) {\n unset (\n $oi['id'],\n $oi['question_id']\n );\n $newanswer = new simplepoll_answer($oi);\n $newanswer->simplepoll_question_id = $question->id;\n// $question->simplepoll_answer[] = $newanswer;\n $newanswer->update();\n }\n// $question->update();",
"\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'navigationmodule': // added v2.0.9\n if (!empty($module->view)) {\n if ($module->view == 'Breadcrumb') {\n @$module->view = 'breadcrumb';\n @$module->action = 'breadcrumb';\n } else {\n @$module->view = 'showall_'.$module->view;\n }\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n\t\t\t\tbreak;\n case 'calendarmodule': // added v2.1.0\n if ($module->view == 'Default') {\n @$module->view = 'showall';\n } elseif ($module->view == 'Upcoming Events - Summary') {\n $module->view = 'showall_Upcoming Events - Headlines';\n } else {\n @$module->view = 'showall_'.$module->view;\n }\n $oldconfig = $old_db->selectObject('calendarmodule_config', \"location_data='\".serialize($iloc).\"'\");\n if (!empty($oldconfig)) {\n if ($oldconfig->enable_ical == 1) {\n $newconfig->config['enable_ical'] = true;\n $newconfig->config['feed_title'] = $oldconfig->feed_title;\n $newconfig->config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;\n $newconfig->config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;\n }\n if (!empty($oldconfig->hidemoduletitle)) {\n $newconfig->config['hidemoduletitle'] = $oldconfig->hidemoduletitle;\n }\n if (!empty($oldconfig->moduledescription)) {\n $newconfig->config['moduledescription'] = $oldconfig->moduledescription;\n }\n if (!empty($oldconfig->aggregate) && $oldconfig->aggregate != 'a:0:{}') {\n $merged = expUnserialize($oldconfig->aggregate);\n foreach ($merged as $merge) {\n $newconfig->config['aggregate'][] = $merge;\n }\n }\n if (!empty($oldconfig->enable_feedback)) {\n $newconfig->config['enable_feedback'] = $oldconfig->enable_feedback;\n }\n if (!empty($oldconfig->email_title_reminder)) {\n $newconfig->config['email_title_reminder'] = $oldconfig->email_title_reminder;\n }\n if (!empty($oldconfig->email_from_reminder)) {\n $newconfig->config['email_from_reminder'] = $oldconfig->email_from_reminder;\n }\n if (!empty($oldconfig->email_address_reminder)) {\n $newconfig->config['email_address_reminder'] = $oldconfig->email_address_reminder;\n }\n if (!empty($oldconfig->email_reply_reminder)) {\n $newconfig->config['email_reply_reminder'] = $oldconfig->email_reply_reminder;\n }\n if (!empty($oldconfig->email_showdetail)) {\n $newconfig->config['email_showdetail'] = $oldconfig->email_showdetail;\n }\n if (!empty($oldconfig->email_signature)) {\n $newconfig->config['email_signature'] = $oldconfig->email_signature;\n }\n if (empty($oldconfig->enable_tags)) {\n $newconfig->config['disabletags'] = true;\n }\n if (!empty($oldconfig->enable_categories)) {\n $newconfig->config['usecategories'] = $oldconfig->enable_categories;\n }",
" // we have to pull in external addresses for reminders\n $addrs = $old_db->selectObjects('calendar_reminder_address',\"calendar_id=\".$oldconfig->id);\n foreach ($addrs as $addr) {\n if (!empty($addr->user_id)) {\n $newconfig->config['users'][] = $addr->user_id;\n } elseif (!empty($addr->group_id)) {\n $newconfig->config['groups'][] = $addr->group_id;\n } elseif (!empty($addr->email)) {\n $newconfig->config['addresses'][] = $addr->email;\n }\n }\n }",
" //check to see if it's already pulled in (circumvent !is_original)\n\t\t\t\t$ploc = clone($iloc);\n\t\t\t\t$ploc->mod = \"event\";\n\t\t\t\tif ($db->countObjects('event', \"location_data='\".serialize($ploc).\"'\")) {\n//\t\t\t\t\t$iloc->mod = 'calendarmodule';\n//\t\t\t\t\t$linked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"// $iloc->mod = 'calendarmodule';\n // convert each eventdate\n $eds = $old_db->selectObjects('eventdate',\"1\");\n foreach ($eds as $ed) {\n $cloc = expUnserialize($ed->location_data);\n $cloc->mod = 'event';\n $ed->location_data = serialize($cloc);\n $db->insertObject($ed,'eventdate');\n }",
" // convert each calendar to an event\n $cals = $old_db->selectObjects('calendar',\"1\");\n foreach ($cals as $cal) {\n unset($cal->approved);\n $cat = $cal->category_id;\n unset($cal->category_id);\n $tags = $cal->tags;\n unset(\n $cal->tags,\n $cal->file_id\n );\n $loc = expUnserialize($cal->location_data);\n $loc->mod = \"event\";\n $cal->location_data = serialize($loc);\n $cal->created_at = $cal->posted;\n unset($cal->posted);\n $cal->edited_at = $cal->edited;\n unset($cal->edited);\n $db->insertObject($cal,'event');",
" $ev = new event($cal->id);\n $ev->save();\n if (!empty($oldconfig->enable_tags)) {\n $params = null;;\n $oldtags = expUnserialize($tags);\n if (!empty($oldtags)) {\n foreach ($oldtags as $oldtag){\n $tagtitle = strtolower(trim($old_db->selectValue('tags','name','id = '.$oldtag)));\n $tag = new expTag($tagtitle);\n//\t\t\t\t\t\t\t\t$tag->title = $old_db->selectValue('tags','name','id = '.$oldtag);\n if (empty($tag->id))\n $tag->update(array('title'=>$tagtitle));\n $params['expTag'][] = $tag->id;\n }\n }\n $ev->update($params);\n }\n if (!empty($oldconfig->enable_categories) && $cat) {\n $params = null;\n $oldcat = $old_db->selectObject('category','id = '.$cat);\n $cat = new expCat($oldcat->name);\n if (empty($cat->id)) {\n $cat->title = $oldcat->name;\n $cat->color = $oldcat->color;\n $catloc = expUnserialize($oldcat->location_data);\n if (array_key_exists($catloc->mod, $this->new_modules)) {\n $mod = expModules::getModuleName($this->new_modules[$catloc->mod]);\n $cat->module = $mod;\n }\n $cat->save();\n $cat->rank = $oldcat->rank +1;\n $cat->update();\n }\n $params['expCat'][] = $cat->id;\n $ev->update($params);\n }\n }\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n break;\n case 'contactmodule': // v2.1.1 now converted to a forms 2.0 module\n\t\t\t\t$module->view = \"enterdata\";\n $module->action = \"enterdata\";",
"// $iloc->mod = 'contactmodule';\n $contactform = $old_db->selectObject('contactmodule_config', \"location_data='\".serialize($iloc).\"'\");\n\t\t\t\tif ($contactform) {\n // for forms 2.0 we create a site form (form & report consolidated)\n $newform = new forms();\n $newform->title = 'Contact Form';\n $newform->is_saved = false;\n $newform->table_name = '';\n $newform->description = '';\n $newform->response = $contactform->final_message;\n $newform->update();",
" // now add the controls to the site form\n\t\t\t\t\t$control = new stdClass();\n\t\t\t\t\t$control->name = 'name';\n\t\t\t\t\t$control->caption = 'Your Name';\n\t\t\t\t\t$control->forms_id = $newform->id;\n\t\t\t\t\t$control->data = 'O:11:\"textcontrol\":14:{s:4:\"size\";i:0;s:9:\"maxlength\";i:0;s:7:\"caption\";s:9:\"Your Name\";s:11:\"placeholder\";s:8:\"John Doe\";s:9:\"accesskey\";s:0:\"\";s:7:\"default\";s:0:\"\";s:8:\"disabled\";b:0;s:8:\"required\";b:1;s:8:\"tabindex\";i:-1;s:7:\"inError\";i:0;s:4:\"type\";s:4:\"text\";s:6:\"filter\";s:0:\"\";s:10:\"identifier\";s:4:\"name\";s:11:\"description\";s:22:\"Please enter your name\";}';\n\t\t\t\t\t$control->rank = 1;\n\t\t\t\t\t$control->is_readonly = 0;\n\t\t\t\t\t$control->is_static = 0;\n\t\t\t\t\t$db->insertObject($control, 'forms_control');\n\t\t\t\t\t$control->name = 'email';\n\t\t\t\t\t$control->caption = 'Your Email';\n\t\t\t\t\t$control->data = 'O:11:\"textcontrol\":14:{s:4:\"size\";i:0;s:9:\"maxlength\";i:0;s:7:\"caption\";s:10:\"Your Email\";s:11:\"placeholder\";s:18:\"johndoe@mailer.org\";s:9:\"accesskey\";s:0:\"\";s:7:\"default\";s:0:\"\";s:8:\"disabled\";b:0;s:8:\"required\";b:1;s:8:\"tabindex\";i:-1;s:7:\"inError\";i:0;s:4:\"type\";s:4:\"text\";s:6:\"filter\";s:0:\"\";s:10:\"identifier\";s:5:\"email\";s:11:\"description\";s:31:\"Please enter your email address\";}';\n\t\t\t\t\t$control->rank = 2;\n\t\t\t\t\t$db->insertObject($control, 'forms_control');\n\t\t\t\t\t$control->name = 'subject';\n\t\t\t\t\t$control->caption = 'Subject';\n\t\t\t\t\t$control->data = 'O:11:\"textcontrol\":14:{s:4:\"size\";i:0;s:9:\"maxlength\";i:0;s:7:\"caption\";s:7:\"Subject\";s:11:\"placeholder\";s:22:\"Subject line for email\";s:9:\"accesskey\";s:0:\"\";s:7:\"default\";s:0:\"\";s:8:\"disabled\";b:0;s:8:\"required\";b:1;s:8:\"tabindex\";i:-1;s:7:\"inError\";i:0;s:4:\"type\";s:4:\"text\";s:6:\"filter\";s:0:\"\";s:10:\"identifier\";s:7:\"subject\";s:11:\"description\";s:21:\"Enter a quick summary\";}';\n\t\t\t\t\t$control->rank = 3;\n\t\t\t\t\t$db->insertObject($control, 'forms_control');\n\t\t\t\t\t$control->name = 'message';\n\t\t\t\t\t$control->caption = 'Message';\n\t\t\t\t\t$control->data = 'O:17:\"texteditorcontrol\":13:{s:4:\"cols\";i:60;s:4:\"rows\";i:8;s:9:\"accesskey\";s:0:\"\";s:7:\"default\";s:0:\"\";s:8:\"disabled\";b:0;s:8:\"required\";b:0;s:8:\"tabindex\";i:-1;s:7:\"inError\";i:0;s:4:\"type\";s:4:\"text\";s:8:\"maxchars\";i:0;s:10:\"identifier\";s:7:\"message\";s:7:\"caption\";s:7:\"Message\";s:11:\"description\";s:33:\"Enter the content of your message\";}';\n\t\t\t\t\t$control->rank = 4;\n\t\t\t\t\t$db->insertObject($control, 'forms_control');",
" // and then an expConfig to link to that site form with config settings\n $newconfig->config['forms_id'] = $newform->id;\n $newconfig->config['title'] = 'Send us an e-mail';\n $newconfig->config['description'] = '';\n $newconfig->config['is_email'] = true;\n if (!empty($contactform->subject)) {\n $newconfig->config['report_name'] = $contactform->subject;\n $newconfig->config['subject'] = $contactform->subject;\n }\n if (!empty($contactform->final_message)) $newconfig->config['response'] = $contactform->final_message;\n $newconfig->config['submitbtn'] = 'Send Message';\n $newconfig->config['resetbtn'] = 'Reset';",
" // we have to pull in addresses for emails\n $addrs = $old_db->selectObjects('contact_contact', \"location_data='\".serialize($iloc).\"'\");\n foreach ($addrs as $addr) {\n if (!empty($addr->user_id)) {\n $newconfig->config['user_list'][] = $addr->user_id;\n } elseif (!empty($addr->email)) {\n $newconfig->config['address_list'][] = $addr->email;\n }\n }",
"\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n\t\t\t\t}\n\t\t\t\tbreak;\n case 'formmodule': // convert to forms module\n $module->view = \"enterdata\";\n $module->action = \"enterdata\";",
" // new form update\n $oldform = $old_db->selectObject('formbuilder_form', \"location_data='\".serialize($iloc).\"'\");\n $oldreport = $old_db->selectObject('formbuilder_report', \"location_data='\".serialize($iloc).\"'\");",
" if (!empty($oldform->id)) {\n $newform = new forms();\n $newform->title = $oldform->name;\n $newform->is_saved = $oldform->is_saved;\n $newform->table_name = $oldform->table_name;\n if (empty($newform->title) && !empty($newform->table_name)) $newform->title = implode(' ',explode('_',$newform->table_name));\n $newform->description = $oldform->description;\n $newform->response = $oldform->response;\n $newform->report_name = $oldreport->name;\n $newform->report_desc = $oldreport->description;\n $newform->report_def = $oldreport->text;\n $newform->column_names_list = $oldreport->column_names;\n $newform->update();",
" // copy & convert each formbuilder_control to a forms_control\n $fcs = $old_db->selectObjects('formbuilder_control',\"form_id=\".$oldform->id);\n foreach ($fcs as $fc) {\n $fc->forms_id = $newform->id;\n unset (\n $fc->id,\n $fc->form_id\n );\n $db->insertObject($fc,'forms_control');\n }",
" // import form saved data\n if ($oldform->is_saved) {\n $newform->updateTable(); // creates the table in database\n $records = $old_db->selectObjects('formbuilder_'.$oldform->table_name, 1);\n foreach($records as $record) {\n //FIXME do we want to add a forms_id field?\n// $db->insertObject($record, 'forms_'.$oldform->table_name);\n $oldform->insertRecord($record);\n }\n }",
" // convert the form & report configs to an expConfig object for this module\n $newconfig = new expConfig();\n $newconfig->config['forms_id'] = $newform->id;\n if (!empty($oldform->name)) $newconfig->config['title'] = $oldform->name;\n if (!empty($oldform->description)) $newconfig->config['description'] = $oldform->description;\n if (!empty($oldform->response)) $newconfig->config['response'] = $oldform->response;\n if (!empty($oldform->is_email)) $newconfig->config['is_email'] = $oldform->is_email;\n if (!empty($oldform->select_email)) $newconfig->config['select_email'] = $oldform->select_email;\n if (!empty($oldform->submitbtn)) $newconfig->config['submitbtn'] = $oldform->submitbtn;\n if (!empty($oldform->resetbtn)) $newconfig->config['resetbtn'] = $oldform->resetbtn;\n if (!empty($oldform->style)) $newconfig->config['style'] = $oldform->style;\n if (!empty($oldform->subject)) $newconfig->config['subject'] = $oldform->subject;\n if (!empty($oldform->is_auto_respond)) $newconfig->config['is_auto_respond'] = $oldform->is_auto_respond;\n if (!empty($oldform->auto_respond_subject)) $newconfig->config['auto_respond_subject'] = $oldform->auto_respond_subject;\n if (!empty($oldform->auto_respond_body)) $newconfig->config['auto_respond_body'] = $oldform->auto_respond_body;\n if (!empty($oldreport->name)) $newconfig->config['report_name'] = $oldreport->name;\n if (!empty($oldreport->description)) $newconfig->config['report_desc'] = $oldreport->description;\n if (!empty($oldreport->text)) $newconfig->config['report_def'] = $oldreport->text;\n if (!empty($oldreport->column_names)) $newconfig->config['column_names_list'] = explode('|!|',$oldreport->column_names);",
" // we have to pull in addresses for emails\n $addrs = $old_db->selectObjects('formbuilder_address',\"form_id=\".$oldform->id);\n foreach ($addrs as $addr) {\n if (!empty($addr->user_id)) {\n $newconfig->config['user_list'][] = $addr->user_id;\n } elseif (!empty($addr->group_id)) {\n $newconfig->config['group_list'][] = $addr->group_id;\n } elseif (!empty($addr->email)) {\n $newconfig->config['address_list'][] = $addr->email;\n }\n }",
" // now save/attach the expConfig\n if ($newconfig->config != null) {\n $newconfig->location_data = expCore::makeLocation($this->new_modules[$iloc->mod],$iloc->src);\n }\n }",
" @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n break;\n case 'containermodule':\n if (!$hc) {\n $module->action = 'showall';\n if ($module->view == 'Default') {\n @$module->view = 'showall';\n } else {\n @$module->view = 'showall_'.$module->view;\n }\n @$this->msg['migrated'][$iloc->mod]['count']++;\n @$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];\n }\n\t\t\t\tbreak;\n default:\n @$this->msg['noconverter'][$iloc->mod]++;\n\t\t\t\tbreak;\n\t\t}\n // quick check for non hard coded modules\n // We add a container if they're not hard coded.\n (!$hc) ? $this->add_container($iloc,$module,$linked,$newconfig) : \"\";",
" return $module;\n }",
"//\t/**\n//\t * pull over extra/related data required for old school modules\n//\t * @var \\mysqli_database $db the exponent database object\n//\t * @param $iloc\n//\t * @param $module\n//\t * @return bool\n//\t */\n// private function pulldata($iloc, $module) {\n// global $db;\n// $old_db = $this->connect();\n//\t\t$linked = false;\n// if ((!empty($module->is_existing) && $module->is_existing)) {\n// $linked = true;\n// }\n//\n// switch ($iloc->mod) {\n//// case 'calendarmodule':\n////\t\t\t\tif ($db->countObjects('calendar', \"location_data='\".serialize($iloc).\"'\")) {\n////\t\t\t\t\t$linked = true;\n////\t\t\t\t\tbreak;\n////\t\t\t\t}\n//// $events = $old_db->selectObjects('eventdate', \"location_data='\".serialize($iloc).\"'\");\n//// foreach($events as $event) {\n//// $res = $db->insertObject($event, 'eventdate');\n////\t\t\t\t\tif ($res) { @$this->msg['migrated'][$iloc->mod]['count']++; }\n//// }\n//// $cals = $old_db->selectObjects('calendar', \"location_data='\".serialize($iloc).\"'\");\n//// foreach($cals as $cal) {\n//// unset($cal->allow_registration);\n//// unset($cal->registration_limit);\n//// unset($cal->registration_allow_multiple);\n//// unset($cal->registration_cutoff);\n//// unset($cal->registration_price);\n//// unset($cal->registration_count);\n//// $db->insertObject($cal, 'calendar');\n//// }\n//// $configs = $old_db->selectObjects('calendarmodule_config', \"location_data='\".serialize($iloc).\"'\");\n//// foreach ($configs as $config) {\n//// $reminders = $old_db->selectObjects('calendar_reminder_address', \"calendar_id='\".$config->id.\"'\");\n////\t\t\t\t\t$config->id = '';\n////\t\t\t\t\t$config->enable_categories = 0;\n////\t\t\t\t\t$config->enable_tags = 0;\n//// $db->insertObject($config, 'calendarmodule_config');\n//// foreach($reminders as $reminder) {\n//// $reminder->calendar_id = $config->id;\n//// $db->insertObject($reminder, 'calendar_reminder_address');\n//// }\n//// }\n////\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $iloc->mod;\n////\t\t\t\tbreak;\n//// case 'simplepollmodule':\n////\t\t\t\tif ($db->countObjects('poll_question', \"location_data='\".serialize($iloc).\"'\")) {\n////\t\t\t\t\tbreak;\n////\t\t\t\t}\n//// $questions = $old_db->selectObjects('poll_question', \"location_data='\".serialize($iloc).\"'\");\n//// foreach($questions as $question) {\n//// $db->insertObject($question, 'poll_question');\n////\t\t\t\t\t$answers = $old_db->selectObjects('poll_answer', \"question_id='\".$question->id.\"'\");\n////\t\t\t\t\tforeach($answers as $answer) {\n////\t\t\t\t\t\t$db->insertObject($answer, 'poll_answer');\n////\t\t\t\t\t}\n////\t\t\t\t\t$timeblocks = $old_db->selectObjects('poll_timeblock', \"question_id='\".$question->id.\"'\");\n////\t\t\t\t\tforeach($timeblocks as $timeblock) {\n////\t\t\t\t\t\t$db->insertObject($timeblock, 'poll_timeblock');\n////\t\t\t\t\t}\n////\t\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n//// }\n//// $configs = $old_db->selectObjects('simplepollmodule_config', \"location_data='\".serialize($iloc).\"'\");\n//// foreach ($configs as $config) {\n//// $db->insertObject($config, 'simplepollmodule_config');\n//// }\n////\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $iloc->mod;\n////\t\t\t\tbreak;\n//// case 'formmodule':\n////\t\t\t\tif ($db->countObjects('formbuilder_form', \"location_data='\".serialize($iloc).\"'\")) {\n////\t\t\t\t\tbreak;\n////\t\t\t\t}\n//// $form = $old_db->selectObject('formbuilder_form', \"location_data='\".serialize($iloc).\"'\");\n////\t\t\t\t$oldformid = $form->id;\n////\t\t\t\tunset($form->id);\n//// $form->id = $db->insertObject($form, 'formbuilder_form');\n////\t\t\t\t@$this->msg['migrated'][$iloc->mod]['count']++;\n////\t\t\t\t$addresses = $old_db->selectObjects('formbuilder_address', \"form_id='\".$oldformid.\"'\");\n//// foreach($addresses as $address) {\n////\t\t\t\t\tunset($address->id);\n////\t\t\t\t\t$address->form_id = $form->id;\n//// $db->insertObject($address, 'formbuilder_address');\n////\t\t\t\t}\n////\t\t\t\t$controls = $old_db->selectObjects('formbuilder_control', \"form_id='\".$oldformid.\"'\");\n//// foreach($controls as $control) {\n////\t\t\t\t\tunset($control->id);\n////\t\t\t\t\t$control->form_id = $form->id;\n//// $db->insertObject($control, 'formbuilder_control');\n////\t\t\t\t}\n////\t\t\t\t$reports = $old_db->selectObjects('formbuilder_report', \"form_id='\".$oldformid.\"'\");\n//// foreach($reports as $report) {\n////\t\t\t\t\tunset($report->id);\n////\t\t\t\t\t$report->form_id = $form->id;\n//// $db->insertObject($report, 'formbuilder_report');\n////\t\t\t\t}\n////\t\t\t\tif (isset($form->table_name)) {\n////\t\t\t\t\tif (isset($this->params['wipe_content'])) {\n////\t\t\t\t\t\t$db->delete('formbuilder_'.$form->table_name);\n////\t\t\t\t\t}\n////\t\t\t\t\tformbuilder_form::updateTable($form);\n////\t\t\t\t\t$records = $old_db->selectObjects('formbuilder_'.$form->table_name, 1);\n////\t\t\t\t\tforeach($records as $record) {\n////\t\t\t\t\t\t$db->insertObject($record, 'formbuilder_'.$form->table_name);\n////\t\t\t\t\t}\n////\t\t\t\t}\n////\t\t\t\t@$this->msg['migrated'][$iloc->mod]['name'] = $iloc->mod;\n////\t\t\t\tbreak;\n// }\n// return $linked;\n// }",
" /**\n * used to create containers, expConfigs, and expRss for new modules\n * @param $iloc\n * @param $m\n * @param bool $linked\n * @param $newconfig\n * @var \\mysqli_database $db the exponent database object\n * @return void\n */\n\tprivate function add_container($iloc,$m,$linked=false,$newconfig) {\n// global $db;",
" // first the container\n// $old_db = $this->connect();\n// $section = $old_db->selectObject('sectionref',\"module='\".$iloc->mod.\"' AND source='\".$iloc->src.\"' AND is_original='0'\");\n// unset($m->id);\n// $oldext = expUnserialize($m->external);\n// $m->external = serialize(expCore::makeLocation('container',$oldext->src));\n////\t\tif ($iloc->mod != 'contactmodule') {\n//\t\t\t$iloc->mod = $this->new_modules[$iloc->mod];\n////\t\t\t$m->internal = (isset($m->internal) && strstr($m->internal,\"Controller\")) ? $m->internal : serialize($iloc);\n// $m->internal = serialize($iloc);\n//\t\t\t$m->action = isset($m->action) ? $m->action : 'showall';\n//\t\t\t$m->view = isset($m->view) ? $m->view : 'showall';\n//\t\t\tif ($m->view == \"Default\") {\n//\t\t\t\t$m->view = 'showall';\n//\t\t\t}\n//\t\t} else { // must be an old school contactmodule\n//\t\t\t$iloc->mod = $this->new_modules[$iloc->mod];\n//\t\t\t$m->internal = serialize($iloc);\n//\t\t}",
" $params = get_object_vars($m);\n unset($params['id']);\n $old_db = $this->connect();\n $section = $old_db->selectObject('sectionref',\"module='\".$iloc->mod.\"' AND source='\".$iloc->src.\"' AND is_original='0'\");\n $params['current_section'] = empty($section->section) ? 1 : $section->section;\n $oldext = expUnserialize($params['external']);\n $params['external'] = serialize(expCore::makeLocation('container',$oldext->src));\n $iloc->mod = $this->new_modules[$iloc->mod];\n $params['modcntrol'] = $iloc->mod;\n $params['internal'] = serialize($iloc);\n $params['rank'] = $params['rank']+1;\n $params['action'] = !empty($params['action']) ? $params['action'] : 'showall';\n $params['view'] = !empty($params['view']) ? $params['view'] : 'showall';\n if ($params['view'] == \"Default\") {\n $params['view'] = 'showall';\n }",
" $m = new container();\n if (!$linked) {\n $params['existing_source'] = $iloc->src;\n }\n $m->update($params);\n\t\tif ($linked) {\n//\t\t\t$newmodule['i_mod'] = $iloc->mod;\n//\t\t\t$newmodule['modcntrol'] = $iloc->mod;\n//\t\t\t$newmodule['rank'] = $m->rank;\n//\t\t\t$newmodule['views'] = $m->view;\n//\t\t\t$newmodule['title'] = $m->title;\n//\t\t\t$newmodule['actions'] = $m->action;\n//\t\t\t$_POST['current_section'] = empty($section->section) ? 1 : $section->section;\n//\t\t\t$m = container::update($newmodule,$m,expUnserialize($m->external));\n// $params = array();\n// $params['rank'] = $newmod['rank'];\n// $params['view'] = $newmod['view'];\n// $params['title'] = $newmod['title'];\n// $params['action'] = $newmod['action'];\n// $params['is_private'] = $newmod['is_private'];\n $newconfig->config['aggregate'][] = $iloc->src;\n if ($iloc->mod == 'blog') {\n $newconfig->config['add_source'] = 1; // we need to make our blog aggregation discrete\n }\n }\n// $db->insertObject($m, 'container');",
" // now save the expConfig\n if (!empty($newconfig->config['enable_rss']) && $newconfig->config['enable_rss'] == true) {\n $newrss = new expRss();\n $newrss->enable_rss = $newconfig->config['enable_rss'];\n $newrss->advertise = $newconfig->config['enable_rss'];\n $newrss->title = $newconfig->config['feed_title'];\n// $newrss->sef_url = expCore::makeSefUrl($newrss->title,'expRss');\n\t\t\t$newrss->sef_url = $this->makeSefUrl($newrss->title);\n $newrss->feed_desc = $newconfig->config['feed_desc'];\n $newrss->rss_limit = $newconfig->config['rss_limit'];\n $newrss->rss_cachetime = $newconfig->config['rss_cachetime'];\n }\n if ($newconfig->config != null) {\n// $newmodinternal = expUnserialize($m->internal);\n// $newmod = expModules::getModuleName($newmodinternal->mod);\n// $newmodinternal->mod = $newmod;\n $newconfig->location_data = expUnserialize($m->internal);\n $newconfig->save();\n }",
" // and save the expRss table\n if (!empty($newrss->enable_rss)) {\n $newmodinternal = expUnserialize($m->internal);\n $newrss->module = $newmodinternal->mod;\n $newrss->src = $newmodinternal->src;\n $newrss->save();\n }\n }",
"\t/**\n\t * module customized function to circumvent going to previous page\n\t * @return void\n\t */\n\tfunction saveconfig() {\n \n // unset some unneeded params\n unset(\n $this->params['module'],\n $this->params['controller'],\n $this->params['src'],\n $this->params['int'],\n $this->params['id'],\n $this->params['action'],\n $this->params['PHPSESSID'],\n $this->params['__utma'],\n $this->params['__utmb'],\n $this->params['__utmc'],\n $this->params['__utmz'],\n $this->params['__utmt'],\n $this->params['__utmli'],\n $this->params['__cfduid']\n );\n \n // setup and save the config\n $config = new expConfig($this->loc);\n $config->update(array('config'=>$this->params));\n\t\t// update our object config\n\t\t$this->config = expUnserialize($config->config);\n// flash('message', 'Migration Configuration Saved');\n// expHistory::back();\n $this->connect(); // now make sure the parameters work",
"\t\tif (isset($this->params['fix_database'])) $this->fix_database();\n //NOTE we need to push the button.css file to head for coolwater theme?\n expCSS::pushToHead(array(\n// \t\t \"unique\"=>\"button\",\n \t\t \"corecss\"=>\"button\",\n \t\t ));\n\t\techo '<h2>'.gt('Migration Configuration Saved').'</h2><br />';\n\t\techo '<p>'.gt('We\\'ve successfully connected to the Old database').'</p><br />';\n if (bs()) {\n $btn_class = 'btn btn-default';\n } else {\n $btn_class = \"awesome \" . BTN_SIZE . \" \" . BTN_COLOR;\n };\n\t\techo \"<a class=\\\"\".$btn_class.\"\\\" href=\\\"\".expCore::makeLink(array('controller'=>'migration','action'=>'manage_users')).\"\\\">\".gt('Next Step -> Migrate Users & Groups').\"</a>\";\n }\n\t\n\t/**\n\t * connect to old site's database\n\t *\n\t * @return mysqli_database\n\t */\n private function connect() {\n // check for required info...then make the DB connection.\n if (\n empty($this->config['username']) ||\n empty($this->config['password']) ||\n empty($this->config['database']) ||\n empty($this->config['server']) ||\n empty($this->config['prefix']) ||\n empty($this->config['port'])\n ) {\n flash('error', gt('You are missing some required database connection information. Please enter DB information.'));\n redirect_to (array('controller'=>'migration', 'action'=>'configure'));\n// $this->configure();\n }",
" $database = expDatabase::connect($this->config['username'],$this->config['password'],$this->config['server'].':'.$this->config['port'],$this->config['database']);",
" if (empty($database->havedb)) {\n flash('error', gt('An error was encountered trying to connect to the database you specified. Please check your DB config.'));\n redirect_to (array('controller'=>'migration', 'action'=>'configure'));\n// $this->configure();\n }",
" $database->prefix = $this->config['prefix']. '_';;\n return $database;\n }",
"\t/**\n\t * several things that may clear up problems in the old database and do a better job of migrating data\n\t * @return void\n\t */\n\tprivate function fix_database() {\n\t\t// let's test the connection\n\t\t$old_db = $this->connect();\n\t\t\n\t\tprint_r(\"<h2>\".gt('We\\'re connected to the Old Database!').\"</h2><br><br><h3>\".gt('Running several checks and fixes on the old database').\"<br>\".gt('to enhance Migration.').\"</h3><br>\");",
"\t\tprint_r(\"<pre>\");\n\t// upgrade sectionref's that have lost their originals\n\t\tprint_r(\"<strong>\".gt('Searching for sectionrefs that have lost their originals').\"</strong><br><br>\");\n\t\t$sectionrefs = $old_db->selectObjects('sectionref',\"is_original=0\");\n\t\tprint_r(\"Found: \".count($sectionrefs).\" copies (not originals)<br>\");\n\t\tforeach ($sectionrefs as $sectionref) {\n\t\t\tif ($old_db->selectObject('sectionref',\"module='\".$sectionref->module.\"' AND source='\".$sectionref->source.\"' AND is_original='1'\") == null) {\n\t\t\t// There is no original for this sectionref so change it to the original\n//\t\t\t\t$sectionref->is_original = 1;\n\t\t\t\t$old_db->updateObject($sectionref,\"sectionref\");\n\t\t\t\tprint_r(\"Fixed: \".$sectionref->module.\" - \".$sectionref->source.\"<br>\");\n\t\t\t}\n\t\t}\n\t\tprint_r(\"</pre>\");\n\t\n\t\tprint_r(\"<pre>\");\n\t// upgrade sectionref's that point to missing sections (pages)\n\t\tprint_r(\"<strong>\".gt('Searching for sectionrefs pointing to missing sections/pages').\" <br>\".gt('to fix for the Recycle Bin').\"</strong><br><br>\");\n\t\t$sectionrefs = $old_db->selectObjects('sectionref',\"refcount!=0\");\n\t\tforeach ($sectionrefs as $sectionref) {\n\t\t\tif ($old_db->selectObject('section',\"id='\".$sectionref->section.\"'\") == null) {\n\t\t\t// There is no section/page for sectionref so change the refcount\n\t\t\t\t$sectionref->refcount = 0;\n\t\t\t\t$old_db->updateObject($sectionref,\"sectionref\");\n\t\t\t\tprint_r(\"Fixed: \".$sectionref->module.\" - \".$sectionref->source.\"<br>\");\n\t\t\t}\n\t\t}\n\t\tprint_r(\"</pre>\");",
"\t}",
"\t/**\n\t * Take an old school permission and convert it to a newmodule permission\n\t *\n\t * @param $item\n\t * @return mixed\n\t */\n\tprivate function convert_permission($item) {\n\t\tif ($item == null) return null;\n\t\tswitch ($item->permission) {\n\t\t case 'administrate':\n\t\t\t $item->permission = 'manage';\n\t\t\t\tbreak;\n\t\t\tcase 'post':\n\t\t\tcase 'create_slide':\n\t\t\tcase 'add':\n\t\t\tcase 'add_item':\n case 'add_module':\n\t\t\t\t$item->permission = 'create';\n\t\t\t\tbreak;\n\t\t\tcase 'edit_item':\n\t\t\tcase 'edit_slide':\n case 'edit_module':\n\t\t\t\t$item->permission = 'edit';\n\t\t\t\tbreak;\n\t\t\tcase 'delete_item':\n\t\t\tcase 'delete_slide':\n case 'delete_module':\n\t\t\t\t$item->permission = 'delete';\n\t\t\t\tbreak;\n\t\t\tcase 'order':\n\t\t\tcase 'import':\n case 'orders_modules':\n\t\t\t\t$item->permission = 'configure';\n\t\t\t\tbreak;\n\t\t\tcase 'view_unpublished':\n\t\t\t\t$item->permission = 'show_unpublished';\n\t\t\t\tbreak;\n case 'approve_comments':\n $item->permission = 'approve';\n break;\n\t\t\tcase 'manage_categories':\n\t\t\tcase 'manage_approval':\n\t\t\tcase 'approve':\n\t\t\tcase 'can_download':\n\t\t\tcase 'comment':\n\t\t\tcase 'edit_comments':\n\t\t\tcase 'delete_comments':\n\t\t\tcase 'view_private':\n $item = null;\n\t\t\t\tbreak;\n\t\t\tcase 'create':\n\t\t\tcase 'configure':\n\t\t\tcase 'delete':\n\t\t\tcase 'edit':\n\t\t\tcase 'manage':\n\t\t\tcase 'spider':\n\t\t\tcase 'view':\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t\treturn $item;\n\t}",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\r\n\r\n##################################################\r\n#\r\n# Copyright (c) 2004-2016 OIC Group, Inc.\r\n#\r\n# This file is part of Exponent\r\n#\r\n# Exponent is free software; you can redistribute\r\n# it and/or modify it under the terms of the GNU\r\n# General Public License as published by the Free\r\n# Software Foundation; either version 2 of the\r\n# License, or (at your option) any later version.\r\n#\r\n# GPL: http://www.gnu.org/licenses/gpl.txt\r\n#\r\n##################################################\r\n/**\r\n * @subpackage Controllers\r\n * @package Modules\r\n */\r\nclass navigationController extends expController {\r\n public $basemodel_name = 'section';\r\n public $useractions = array(\r\n 'showall' => 'Show Navigation',\r\n 'breadcrumb' => 'Breadcrumb',\r\n );\r\n public $remove_configs = array(\r\n 'aggregation',\r\n 'categories',\r\n 'comments',\r\n 'ealerts',\r\n 'facebook',\r\n 'files',\r\n 'pagination',\r\n 'rss',\r\n 'tags',\r\n 'twitter',\r\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)\r\n protected $add_permissions = array(\r\n 'view' => \"View Page\"\r\n );\r\n protected $remove_permissions = array(\r\n// 'configure',\r\n// 'create',\r\n// 'delete',\r\n// 'edit'\r\n );\r\n\r\n static function displayname() { return gt(\"Navigation\"); }\r\n\r\n static function description() { return gt(\"Places navigation links/menus on the page.\"); }\r\n\r\n static function isSearchable() { return true; }\r\n\r\n function searchName() { return gt('Webpage'); }\r\n\r\n /**\r\n * @param null $src\r\n * @param array $params\r\n *\r\n */\r\n function __construct($src = null, $params = array())\r\n {\r\n parent::__construct($src, $params);\r\n if (!empty($params['id'])) // we normally throw out the $loc->int EXCEPT with navigation pages\r\n $this->loc = expCore::makeLocation($this->baseclassname, $src, $params['id']);\r\n }\r\n\r\n public function showall() {\r\n global $user, $sectionObj, $sections;\r\n\r\n expHistory::set('viewable', $this->params);\r\n $id = $sectionObj->id;\r\n $current = null;\r\n // all we need to do is determine the current section\r\n $navsections = $sections;\r\n if ($sectionObj->parent == -1) {\r\n $current = $sectionObj;\r\n } else {\r\n foreach ($navsections as $section) {\r\n if ($section->id == $id) {\r\n $current = $section;\r\n break;\r\n }\r\n }\r\n }\r\n assign_to_template(array(\r\n 'sections' => $navsections,\r\n 'current' => $current,\r\n 'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),\r\n ));\r\n }\r\n\r\n public function breadcrumb() {\r\n global $sectionObj;\r\n\r\n expHistory::set('viewable', $this->params);\r\n $id = $sectionObj->id;\r\n $current = null;\r\n // Show not only the location of a page in the hierarchy but also the location of a standalone page\r\n $current = new section($id);\r\n if ($current->parent == -1) { // standalone page\r\n $navsections = section::levelTemplate(-1, 0);\r\n foreach ($navsections as $section) {\r\n if ($section->id == $id) {\r\n $current = $section;\r\n break;\r\n }\r\n }\r\n } else {\r\n $navsections = section::levelTemplate(0, 0);\r\n foreach ($navsections as $section) {\r\n if ($section->id == $id) {\r\n $current = $section;\r\n break;\r\n }\r\n }\r\n }\r\n assign_to_template(array(\r\n 'sections' => $navsections,\r\n 'current' => $current,\r\n ));\r\n }\r\n\r\n /**\r\n * @deprecated 2.3.4 moved to section model\r\n */\r\n public static function navhierarchy($notyui=false) {\r\n global $sections;\r\n\r\n $json_array = array();\r\n for ($i = 0, $iMax = count($sections); $i < $iMax; $i++) {\r\n if ($sections[$i]->depth == 0) {\r\n $obj = new stdClass();\r\n// \t\t\t\t$obj->id = $sections[$i]->name.$sections[$i]->id;\r\n $obj->id = $sections[$i]->id;\r\n $obj->text = $sections[$i]->name;\r\n $obj->title = $sections[$i]->page_title;\r\n $obj->description = $sections[$i]->description;\r\n $obj->new_window = $sections[$i]->new_window;\r\n $obj->expFile = $sections[$i]->expFile;\r\n $obj->glyph = $sections[$i]->glyph;\r\n $obj->glyph_only = $sections[$i]->glyph_only;\r\n $obj->type = $sections[$i]->alias_type;\r\n if ($sections[$i]->active == 1) {\r\n $obj->url = $sections[$i]->link;\r\n if ($obj->type == 1 && substr($obj->url, 0, 4) != 'http') {\r\n $obj->url = 'http://' . $obj->url;\r\n }\r\n } else {\r\n $obj->url = \"#\";\r\n $obj->onclick = \"onclick: { fn: return false }\";\r\n }\r\n if ($obj->type == 3) { // mostly a hack instead of adding more table fields\r\n $obj->width = $sections[$i]->internal_id;\r\n $obj->class = $sections[$i]->external_link;\r\n }\r\n /*if ($sections[$i]->active == 1) {\r\n $obj->disabled = false;\r\n } else {\r\n $obj->disabled = true;\r\n }*/\r\n //$obj->disabled = true;\r\n $obj->itemdata = self::getChildren($i,$notyui);\r\n $obj->maxitems = count($obj->itemdata);\r\n $obj->maxdepth = 0;\r\n foreach ($obj->itemdata as $menu) {\r\n if ($menu->maxdepth > $obj->maxdepth) $obj->maxdepth = $menu->maxdepth;\r\n }\r\n }\r\n $json_array[] = $obj;\r\n }\r\n return $json_array;\r\n }\r\n\r\n /**\r\n * @deprecated 2.3.4 moved to section model\r\n */\r\n public static function navtojson() {\r\n return json_encode(self::navhierarchy());\r\n }\r\n\r\n /**\r\n * @deprecated 2.3.4 moved to section model\r\n */\r\n public static function getChildren(&$i, $notyui=false) {\r\n global $sections;\r\n\r\n //\t\techo \"i=\".$i.\"<br>\";\r\n if ($i + 1 == count($sections)) { // last entry\r\n return array();\r\n } elseif ($sections[$i]->depth == $sections[$i + 1]->depth) {\r\n return array();\r\n } else {\r\n $ret_depth = $sections[$i]->depth;\r\n $i++;\r\n $ret_array = array();\r\n for ($iMax = count($sections); $i < $iMax; $i++) {\r\n // start setting up the objects to return\r\n $obj = new stdClass();\r\n $obj->id = $sections[$i]->id;\r\n $obj->text = $sections[$i]->name;\r\n $obj->title = $sections[$i]->page_title;\r\n $obj->description = $sections[$i]->description;\r\n $obj->new_window = $sections[$i]->new_window;\r\n $obj->expFile = $sections[$i]->expFile;\r\n $obj->glyph = $sections[$i]->glyph;\r\n $obj->glyph_only = $sections[$i]->glyph_only;\r\n $obj->depth = $sections[$i]->depth;\r\n if ($sections[$i]->active == 1) {\r\n $obj->url = $sections[$i]->link;\r\n if ($sections[$i]->alias_type == 1 && substr($obj->url, 0, 4) != 'http') {\r\n $obj->url = 'http://' . $obj->url;\r\n }\r\n } else {\r\n $obj->url = \"#\";\r\n $obj->onclick = \"onclick: { fn: return false }\";\r\n }\r\n //echo \"i=\".$i.\"<br>\";\r\n if (self::hasChildren($i)) {\r\n if ($notyui) {\r\n $obj->itemdata = self::getChildren($i,$notyui);\r\n $obj->maxitems = count($obj->itemdata);\r\n $obj->maxdepth = 0;\r\n foreach ($obj->itemdata as $menu) {\r\n if (!empty($menu->maxdepth)) {\r\n if ($menu->maxdepth > $obj->maxdepth) $obj->maxdepth = $menu->maxdepth;\r\n } else {\r\n if ($menu->depth > $obj->maxdepth) $obj->maxdepth = $menu->depth;\r\n }\r\n }\r\n } else {\r\n $obj->submenu = new stdClass();\r\n $obj->submenu->id = $sections[$i]->name . $sections[$i]->id;\r\n //echo \"getting children of \".$sections[$i]->name;\r\n $obj->submenu->itemdata = self::getChildren($i,$notyui);\r\n $obj->maxitems = count($obj->submenu->itemdata);\r\n $obj->maxdepth = 0;\r\n foreach ($obj->submenu->itemdata as $menu) {\r\n if (!empty($menu->maxdepth)) {\r\n if ($menu->maxdepth > $obj->maxdepth) $obj->maxdepth = $menu->maxdepth;\r\n } else {\r\n if ($menu->depth > $obj->maxdepth) $obj->maxdepth = $menu->depth;\r\n }\r\n }\r\n }\r\n $ret_array[] = $obj;\r\n } else {\r\n $obj->maxdepth = $obj->depth;\r\n $ret_array[] = $obj;\r\n }\r\n if (($i + 1) >= count($sections) || $sections[$i + 1]->depth <= $ret_depth) {\r\n return $ret_array;\r\n }\r\n }\r\n return array();\r\n }\r\n }\r\n\r\n /**\r\n * @deprecated 2.3.4 moved to section model\r\n */\r\n public static function hasChildren($i) {\r\n global $sections;\r\n\r\n if (($i + 1) >= count($sections)) return false;\r\n return ($sections[$i]->depth < $sections[$i + 1]->depth) ? true : false;\r\n }\r\n\r\n /** exdoc\r\n * Creates a location object, based off of the three arguments passed, and returns it.\r\n *\r\n * @return array\r\n * @deprecated 2.3.4 moved to section model\r\n */\r\n public static function initializeNavigation() {\r\n $sections = section::levelTemplate(0, 0);\r\n return $sections;\r\n }\r\n\r\n /**\r\n * returns all the section's children\r\n *\r\n * @static\r\n *\r\n * @param int $parent top level parent id\r\n * @param int $depth variable to hold level of recursion\r\n * @param array $parents\r\n *\r\n * @return array\r\n * @deprecated 2.3.4 moved to section model\r\n */\r\n public static function levelTemplate($parent, $depth = 0, $parents = array()) {\r\n global $user;\r\n\r\n if ($parent != 0) $parents[] = $parent;\r\n $nodes = array();\r\n $cache = expSession::getCacheValue('navigation');\r\n $sect = new section();\r\n if (!isset($cache['kids'][$parent])) {\r\n $kids = $sect->find('all','parent=' . $parent);\r\n $cache['kids'][$parent] = $kids;\r\n expSession::setCacheValue('navigation', $cache);\r\n } else {\r\n $kids = $cache['kids'][$parent];\r\n }\r\n $kids = expSorter::sort(array('array' => $kids, 'sortby' => 'rank', 'order' => 'ASC'));\r\n for ($i = 0, $iMax = count($kids); $i < $iMax; $i++) {\r\n $child = $kids[$i];\r\n //foreach ($kids as $child) {\r\n if ($child->public == 1 || expPermissions::check('view', expCore::makeLocation('navigation', '', $child->id))) {\r\n $child->numParents = count($parents);\r\n $child->depth = $depth;\r\n $child->first = ($i == 0 ? 1 : 0);\r\n $child->last = ($i == count($kids) - 1 ? 1 : 0);\r\n $child->parents = $parents;\r\n $child->canManage = (isset($user->is_acting_admin) && $user->is_acting_admin == 1 ? 1 : 0);\r\n $child->canManageRank = $child->canManage;\r\n if (!isset($child->sef_name)) {\r\n $child->sef_name = '';\r\n }\r\n // Generate the link attribute base on alias type.\r\n if ($child->alias_type == 1) {\r\n // External link. Set the link to the configured website URL.\r\n // This is guaranteed to be a full URL because of the\r\n // section::updateExternalAlias() method in models-1/section.php\r\n $child->link = $child->external_link;\r\n } else if ($child->alias_type == 2) {\r\n // Internal link.\r\n // Need to check and see if the internal_id is pointing at an external link.\r\n// $dest = $db->selectObject('section', 'id=' . $child->internal_id);\r\n $dest = $sect->find('first','id=' . $child->internal_id);\r\n if (!empty($dest->alias_type) && $dest->alias_type == 1) {\r\n // This internal alias is pointing at an external alias.\r\n // Use the external_link of the destination section for the link\r\n $child->link = $dest->external_link;\r\n } else {\r\n // Pointing at a regular section. This is guaranteed to be\r\n // a regular section because aliases cannot be turned into sections,\r\n // (and vice-versa) and because the section::updateInternalLink\r\n // does 'alias to alias' dereferencing before the section is saved\r\n // (see models-1/section.php)\r\n //added by Tyler to pull the descriptions through for the children view\r\n $child->description = !empty($dest->description) ? $dest->description : '';\r\n $child->link = expCore::makeLink(array('section' => $child->internal_id));\r\n }\r\n } else {\r\n // Normal link, alias_type == 0. Just create the URL from the section's id.\r\n $child->link = expCore::makeLink(array('section' => $child->id), '', $child->sef_name);\r\n }\r\n //$child->numChildren = $db->countObjects('section','parent='.$child->id);\r\n $nodes[] = $child;\r\n $nodes = array_merge($nodes, section::levelTemplate($child->id, $depth + 1, $parents));\r\n }\r\n }\r\n return $nodes;\r\n }\r\n\r\n /**\r\n * Returns a flat representation of the full site hierarchy.\r\n *\r\n * @param int $parent top level parent id\r\n * @param int $depth variable to hold level of recursion\r\n * @param array $ignore_ids array of pages to ignore\r\n * @param bool $full include a 'top' level entry\r\n * @param string $perm permission level to build list\r\n * @param bool $addstandalones should we add the stand-alone pages also\r\n * @param bool $addinternalalias\r\n *\r\n * @return array\r\n * @deprecated 2.3.4 moved to section model, HOWEVER still used in theme config\r\n */\r\n public static function levelDropdownControlArray($parent, $depth = 0, $ignore_ids = array(), $full = false, $perm = 'view', $addstandalones = false, $addinternalalias = true) {\r\n global $db;\r\n\r\n $ar = array();\r\n if ($parent == 0 && $full) {\r\n $ar[0] = '<' . gt('Top of Hierarchy') . '>';\r\n }\r\n if ($addinternalalias) {\r\n $intalias = '';\r\n } else {\r\n $intalias = ' AND alias_type != 2';\r\n }\r\n $nodes = $db->selectObjects('section', 'parent=' . $parent . $intalias, 'rank');\r\n foreach ($nodes as $node) {\r\n if ((($perm == 'view' && $node->public == 1) || expPermissions::check($perm, expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {\r\n if ($node->active == 1) {\r\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;\r\n } else {\r\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';\r\n }\r\n $ar[$node->id] = $text;\r\n foreach (self::levelDropdownControlArray($node->id, $depth + 1, $ignore_ids, $full, $perm, $addstandalones, $addinternalalias) as $id => $text) {\r\n $ar[$id] = $text;\r\n }\r\n }\r\n }\r\n if ($addstandalones && $parent == 0) {\r\n $sections = $db->selectObjects('section', 'parent=-1');\r\n foreach ($sections as $node) {\r\n if ((($perm == 'view' && $node->public == 1) || expPermissions::check($perm, expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {\r\n if ($node->active == 1) {\r\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;\r\n } else {\r\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';\r\n }\r\n $ar[$node->id] = '(' . gt('Standalone') . ') ' . $text;\r\n }\r\n }\r\n// $ar = array_merge($ar,$sections);\r\n }\r\n return $ar;\r\n }\r\n\r\n /**\r\n * add all module items to search index\r\n *\r\n * @return int\r\n */\r\n function addContentToSearch() {\r\n global $db;\r\n\r\n //global $sections;\r\n //\t\tglobal $router;\r\n// $db->delete('search', \"ref_module='navigation' AND ref_type='section'\");\r\n $db->delete('search', \"ref_module='\".$this->baseclassname.\"' AND ref_type='section'\");\r\n // this now ensures we get internal pages, instead of relying on the global $sections, which does not.\r\n $sections = $db->selectObjects('section', 'active=1');\r\n foreach ($sections as $section) {\r\n $search_record = new stdClass();\r\n// $search_record->category = 'Webpages';\r\n// $search_record->ref_module = 'navigationController';\r\n// $search_record->ref_type = 'section';\r\n// $search_record->ref_module = $this->classname;\r\n $search_record->ref_module = $this->baseclassname;\r\n $search_record->category = $this->searchName();\r\n $search_record->ref_type = $this->searchCategory();\r\n $search_record->original_id = $section->id;\r\n $search_record->title = $section->name;\r\n //$search_record->view_link = $router->buildUrlByPageId($section->id);\r\n $link = str_replace(URL_FULL, '', makeLink(array('section' => $section->id)));\r\n if ($link . '/' == URL_FULL) $link = '';\r\n $search_record->view_link = $link;\r\n $search_record->body = $section->description;\r\n $search_record->keywords = $section->keywords;\r\n // now we're going to grab all the textmodules on this page and build the body for the page based off the content\r\n // of all the text module added together.\r\n $loc = expCore::makeLocation('text');\r\n $controllername = 'text';\r\n foreach ($db->selectObjects('sectionref', \"module='\" . $controllername . \"' AND section=\" . $section->id) as $module) {\r\n $loc->src = $module->source;\r\n// $controller = new $controllername();\r\n $controller = expModules::getController($controllername);\r\n $textitems = $db->selectObjects($controller->model_table, \"location_data='\" . serialize($loc) . \"'\");\r\n foreach ($textitems as $textitem) {\r\n if (!empty($textitem)) {\r\n $search_record->body .= ' ' . search::removeHTML($textitem->body) . ' ';\r\n $search_record->keywords .= \" \" . $textitem->title;\r\n }\r\n }\r\n }\r\n $db->insertObject($search_record, 'search');\r\n }\r\n return count($sections);\r\n }\r\n\r\n /**\r\n * Retrieve either the entire hierarchy, or a subset of the hierarchy, as an array suitable for use\r\n * in a dropdowncontrol. This is used primarily by the section datatype for moving and adding\r\n * sections to specific parts of the site hierarchy.\r\n *\r\n * @param int $parent The id of the subtree parent. If passed as 0 (the default), the entire subtree is parsed.\r\n * @param int $depth\r\n * @param int $default\r\n * @param array $ignore_ids a value-array of IDs to be ignored when generating the list. This is used\r\n * when moving a section, since a section cannot be made a subsection of itself or any of its subsections.\r\n *\r\n * @return string\r\n */\r\n function levelShowDropdown($parent, $depth = 0, $default = 0, $ignore_ids = array()) {\r\n global $db;\r\n\r\n $html = '';\r\n $nodes = $db->selectObjects('section', 'parent=' . $parent, 'rank');\r\n//\t\t$nodes = expSorter::sort(array('array'=>$nodes,'sortby'=>'rank', 'order'=>'ASC'));\r\n foreach ($nodes as $node) {\r\n if (($node->public == 1 || expPermissions::check('view', expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {\r\n $html .= '<option value=\"' . $node->id . '\" ';\r\n if ($default == $node->id) $html .= 'selected';\r\n $html .= '>';\r\n if ($node->active == 1) {\r\n $html .= str_pad('', $depth * 3, '.', STR_PAD_LEFT) . $node->name;\r\n } else {\r\n $html .= str_pad('', $depth * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';\r\n }\r\n $html .= '</option>';\r\n $html .= self::levelShowDropdown($node->id, $depth + 1, $default, $ignore_ids);\r\n }\r\n }\r\n return $html;\r\n }\r\n\r\n /**\r\n * recursively lists the template hierarchy\r\n *\r\n * @static\r\n *\r\n * @param int $parent top level parent id\r\n * @param int $depth variable to hold level of recursion\r\n *\r\n * @return array\r\n * @deprecated 2.0.0 this only for deprecated templates\r\n */\r\n public static function getTemplateHierarchyFlat($parent, $depth = 1) {\r\n global $db;\r\n\r\n $arr = array();\r\n $kids = $db->selectObjects('section_template', 'parent=' . $parent, 'rank');\r\n//\t\t$kids = expSorter::sort(array('array'=>$kids,'sortby'=>'rank', 'order'=>'ASC'));\r\n for ($i = 0, $iMax = count($kids); $i < $iMax; $i++) {\r\n $page = $kids[$i];\r\n $page->depth = $depth;\r\n $page->first = ($i == 0 ? 1 : 0);\r\n $page->last = ($i == count($kids) - 1 ? 1 : 0);\r\n $arr[] = $page;\r\n $arr = array_merge($arr, self::getTemplateHierarchyFlat($page->id, $depth + 1));\r\n }\r\n return $arr;\r\n }\r\n\r\n /**\r\n * @deprecated 2.0.0 this only for deprecated templates\r\n */\r\n public static function process_section($section, $template) {\r\n global $db;\r\n\r\n if (!is_object($template)) {\r\n $template = $db->selectObject('section_template', 'id=' . $template);\r\n $section->subtheme = $template->subtheme;\r\n $db->updateObject($section, 'section');\r\n }\r\n $prefix = '@st' . $template->id;\r\n $refs = $db->selectObjects('sectionref', \"source LIKE '$prefix%'\");\r\n // Copy all modules and content for this section\r\n foreach ($refs as $ref) {\r\n $src = substr($ref->source, strlen($prefix)) . $section->id;\r\n if (call_user_func(array($ref->module, 'hasContent'))) {\r\n $oloc = expCore::makeLocation($ref->module, $ref->source);\r\n $nloc = expCore::makeLocation($ref->module, $src);\r\n if ($ref->module != \"container\") {\r\n call_user_func(array($ref->module, 'copyContent'), $oloc, $nloc);\r\n } else {\r\n call_user_func(array($ref->module, 'copyContent'), $oloc, $nloc, $section->id);\r\n }\r\n }\r\n }\r\n // Grab sub pages\r\n foreach ($db->selectObjects('section_template', 'parent=' . $template->id) as $t) {\r\n self::process_subsections($section, $t);\r\n }\r\n\r\n }\r\n\r\n /**\r\n * @deprecated 2.0.0 this only for deprecated templates\r\n */\r\n function process_subsections($parent_section, $subtpl) {\r\n global $db, $router;\r\n\r\n $section = new stdClass();\r\n $section->parent = $parent_section->id;\r\n $section->name = $subtpl->name;\r\n $section->sef_name = $router->encode($section->name);\r\n $section->subtheme = $subtpl->subtheme;\r\n $section->active = $subtpl->active;\r\n $section->public = $subtpl->public;\r\n $section->rank = $subtpl->rank;\r\n $section->page_title = $subtpl->page_title;\r\n $section->keywords = $subtpl->keywords;\r\n $section->description = $subtpl->description;\r\n $section->id = $db->insertObject($section, 'section');\r\n self::process_section($section, $subtpl);\r\n }\r\n\r\n /**\r\n * Delete page and send its contents to the recycle bin\r\n *\r\n * @param $parent\r\n * @deprecated 2.3.4 moved to section model\r\n */\r\n public static function deleteLevel($parent) {\r\n global $db;\r\n\r\n $kids = $db->selectObjects('section', 'parent=' . $parent);\r\n foreach ($kids as $kid) {\r\n self::deleteLevel($kid->id);\r\n }\r\n $secrefs = $db->selectObjects('sectionref', 'section=' . $parent);\r\n foreach ($secrefs as $secref) {\r\n $loc = expCore::makeLocation($secref->module, $secref->source, $secref->internal);\r\n recyclebin::sendToRecycleBin($loc, $parent);\r\n //FIXME if we delete the module & sectionref the module completely disappears\r\n// if (class_exists($secref->module)) {\r\n// $modclass = $secref->module;\r\n// //FIXME: more module/controller glue code\r\n// if (expModules::controllerExists($modclass)) {\r\n// $modclass = expModules::getControllerClassName($modclass);\r\n// $mod = new $modclass($loc->src);\r\n// $mod->delete_instance();\r\n// } else {\r\n// $mod = new $modclass();\r\n// $mod->deleteIn($loc);\r\n// }\r\n// }\r\n }\r\n// $db->delete('sectionref', 'section=' . $parent);\r\n $db->delete('section', 'parent=' . $parent);\r\n }\r\n\r\n /**\r\n * Move content page and its children to stand-alones\r\n *\r\n * @param $parent\r\n * @deprecated 2.3.4 moved to section model\r\n */\r\n public static function removeLevel($parent) {\r\n global $db;\r\n\r\n $kids = $db->selectObjects('section', 'parent=' . $parent);\r\n foreach ($kids as $kid) {\r\n $kid->parent = -1;\r\n $db->updateObject($kid, 'section');\r\n self::removeLevel($kid->id);\r\n }\r\n }\r\n\r\n /**\r\n * Check for cascading page view permission, esp. if not public\r\n * @deprecated 2.3.4 moved to section model\r\n */\r\n public static function canView($section) {\r\n global $db;\r\n\r\n if ($section == null) {\r\n return false;\r\n }\r\n if ($section->public == 0) {\r\n // Not a public section. Check permissions.\r\n return expPermissions::check('view', expCore::makeLocation('navigation', '', $section->id));\r\n } else { // Is public. check parents.\r\n if ($section->parent <= 0) {\r\n // Out of parents, and since we are still checking, we haven't hit a private section.\r\n return true;\r\n } else {\r\n $s = $db->selectObject('section', 'id=' . $section->parent);\r\n return self::canView($s);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Check to see if page is public with cascading\r\n * @deprecated 2.3.4 moved to section model\r\n */\r\n public static function isPublic($s) {\r\n if ($s == null) {\r\n return false;\r\n }\r\n while ($s->public && $s->parent > 0) {\r\n $s = new section($s->parent);\r\n }\r\n $lineage = (($s->public) ? 1 : 0);\r\n return $lineage;\r\n }\r\n\r\n public static function canManageStandalones() {\r\n global $user;\r\n\r\n if ($user->isAdmin()) return true;\r\n $standalones = section::levelTemplate(-1, 0);\r\n //\t\t$canmanage = false;\r\n foreach ($standalones as $standalone) {\r\n $loc = expCore::makeLocation('navigation', '', $standalone->id);\r\n if (expPermissions::check('manage', $loc)) return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Reassign permissions based on a check/change in menu/page hierarchy\r\n *\r\n * @static\r\n *\r\n * @param $id\r\n */\r\n public static function checkForSectionalAdmins($id) {\r\n global $db;\r\n\r\n $section = $db->selectObject('section', 'id=' . $id);\r\n $branch = section::levelTemplate($id, 0);\r\n array_unshift($branch, $section);\r\n $allusers = array();\r\n $allgroups = array();\r\n while ($section->parent > 0) {\r\n //\t\t\t$ploc = expCore::makeLocation('navigationController', null, $section);\r\n $allusers = array_merge($allusers, $db->selectColumn('userpermission', 'uid', \"permission='manage' AND module='navigation' AND internal=\" . $section->parent));\r\n $allgroups = array_merge($allgroups, $db->selectColumn('grouppermission', 'gid', \"permission='manage' AND module='navigation' AND internal=\" . $section->parent));\r\n $section = $db->selectObject('section', 'id=' . $section->parent);\r\n }\r\n foreach ($branch as $section) {\r\n $sloc = expCore::makeLocation('navigation', null, $section->id);\r\n // remove any manage permissions for this page and it's children\r\n // $db->delete('userpermission', \"module='navigationController' AND internal=\".$section->id);\r\n // $db->delete('grouppermission', \"module='navigationController' AND internal=\".$section->id);\r\n foreach ($allusers as $uid) {\r\n $u = user::getUserById($uid);\r\n expPermissions::grant($u, 'manage', $sloc);\r\n }\r\n foreach ($allgroups as $gid) {\r\n $g = group::getGroupById($gid);\r\n expPermissions::grantGroup($g, 'manage', $sloc);\r\n }\r\n }\r\n }\r\n\r\n function manage() {\r\n global $db, $router, $user;\r\n\r\n expHistory::set('manageable', $router->params);\r\n assign_to_template(array(\r\n 'canManageStandalones' => self::canManageStandalones(),\r\n 'sasections' => $db->selectObjects('section', 'parent=-1'),\r\n 'user' => $user,\r\n// 'canManagePagesets' => $user->isAdmin(),\r\n// 'templates' => $db->selectObjects('section_template', 'parent=0'),\r\n ));\r\n }\r\n\r\n public function manage_sitemap() {\r\n global $db, $user, $sectionObj, $sections;\r\n\r\n expHistory::set('viewable', $this->params);\r\n $id = $sectionObj->id;\r\n $current = null;\r\n // all we need to do is determine the current section\r\n $navsections = $sections;\r\n if ($sectionObj->parent == -1) {\r\n $current = $sectionObj;\r\n } else {\r\n foreach ($navsections as $section) {\r\n if ($section->id == $id) {\r\n $current = $section;\r\n break;\r\n }\r\n }\r\n }\r\n assign_to_template(array(\r\n 'sasections' => $db->selectObjects('section', 'parent=-1'),\r\n 'sections' => $navsections,\r\n 'current' => $current,\r\n 'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),\r\n ));\r\n }\r\n\r\n /**\r\n * Ajax request for specific pages as json date to yui tree\r\n */\r\n public static function returnChildrenAsJSON() {\r\n global $db;\r\n\r\n //$nav = section::levelTemplate(intval($_REQUEST['id'], 0));\r\n $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;\r\n $nav = $db->selectObjects('section', 'parent=' . $id, 'rank');\r\n //FIXME $manage_all is moot w/ cascading perms now?\r\n $manage_all = false;\r\n if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $id))) {\r\n $manage_all = true;\r\n }\r\n //FIXME recode to use foreach $key=>$value\r\n $navcount = count($nav);\r\n for ($i = 0; $i < $navcount; $i++) {\r\n if ($manage_all || expPermissions::check('manage', expCore::makeLocation('navigation', '', $nav[$i]->id))) {\r\n $nav[$i]->manage = 1;\r\n $view = true;\r\n } else {\r\n $nav[$i]->manage = 0;\r\n $view = $nav[$i]->public ? true : expPermissions::check('view', expCore::makeLocation('navigation', '', $nav[$i]->id));\r\n }\r\n $nav[$i]->link = expCore::makeLink(array('section' => $nav[$i]->id), '', $nav[$i]->sef_name);\r\n if (!$view) unset($nav[$i]);\r\n }\r\n $nav= array_values($nav);\r\n// $nav[$navcount - 1]->last = true;\r\n if (count($nav)) $nav[count($nav) - 1]->last = true;\r\n// echo expJavascript::ajaxReply(201, '', $nav);\r\n $ar = new expAjaxReply(201, '', $nav);\r\n $ar->send();\r\n }\r\n\r\n /**\r\n * Ajax request for all pages as json date to jstree\r\n */\r\n public static function returnChildrenAsJSON2() {\r\n global $db;\r\n\r\n $icons = array(\r\n 0 => 'addpage',\r\n 1 => 'addextpage',\r\n 2 => 'addintpage',\r\n 3 => 'addfreeform',\r\n );\r\n\r\n $navs = $db->selectObjects('section', 'parent!=-1', 'rank');\r\n foreach ($navs as $i=>$nav) {\r\n $navs[$i]->parent = $nav->parent?$nav->parent:'#';\r\n $navs[$i]->text = $nav->name;\r\n $navs[$i]->icon = $icons[$nav->alias_type];\r\n if (!$nav->active) {\r\n $navs[$i]->icon .= ' inactive';\r\n $attr = new stdClass();\r\n $attr->class = 'inactive'; // class to obscure elements\r\n $navs[$i]->a_attr = $attr;\r\n }\r\n if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $navs[$i]->id))) {\r\n $navs[$i]->manage = 1;\r\n $view = true;\r\n } else {\r\n $navs[$i]->manage = 0;\r\n $navs[$i]->state->disabled = true;\r\n $view = $navs[$i]->public ? true : expPermissions::check('view', expCore::makeLocation('navigation', '', $navs[$i]->id));\r\n }\r\n $navs[$i]->link = expCore::makeLink(array('section' => $navs[$i]->id), '', $navs[$i]->sef_name);\r\n if (!$view) {\r\n// unset($navs[$i]); //FIXME this breaks jstree if we remove a parent and not the child\r\n $attr = new stdClass();\r\n $attr->class = 'hidden'; // bs3 class to hide elements\r\n $navs[$i]->li_attr = $attr;\r\n }\r\n }\r\n $navs= array_values($navs);\r\n// header('Content-Type: application/json; charset=utf8');\r\n\t\techo json_encode($navs);\r\n// echo expJavascript::ajaxReply(201, '', $navs);\r\n exit;\r\n }\r\n\r\n /**\r\n * Ajax function to reorder page hierarchy from yui tree control\r\n */\r\n public static function DragnDropReRank() {\r\n global $db, $router;\r\n\r\n $move = $router->params['move'];\r\n $target = $router->params['target'];\r\n $type = $router->params['type'];\r\n $targSec = $db->selectObject(\"section\",\"id=\".$target);\r\n// $targSec = new section($target);\r\n $check_id = $targSec->parent;\r\n $moveSec = $db->selectObject(\"section\",\"id=\".$move);\r\n// $moveSec = new section($move);\r\n\r\n // dropped on top of page\r\n if ($type == \"append\") {\r\n //save the old parent in case we are changing the depth of the moving section\r\n $oldParent = $moveSec->parent;\r\n //assign the parent of the moving section to the ID of the target section\r\n $moveSec->parent = $targSec->id;\r\n //set the rank of the moving section to 0 since it will appear first in the new order\r\n $moveSec->rank = 1;\r\n //select all children currently of the parent we're about to append to\r\n $targSecChildren = $db->selectObjects(\"section\", \"parent=\" . $targSec->id . \" ORDER BY rank\");\r\n //update the ranks of the children to +1 higher to accommodate our new rank 0 section being moved in.\r\n $newrank = 1;\r\n foreach ($targSecChildren as $value) {\r\n if ($value->id != $moveSec->id) {\r\n $value->rank = $newrank;\r\n $db->updateObject($value, 'section');\r\n $newrank++;\r\n }\r\n }\r\n $db->updateObject($moveSec, 'section');\r\n if ($oldParent != $moveSec->parent) {\r\n //we need to re-rank the children of the parent that the miving section has just left\r\n $childOfLastMove = $db->selectObjects(\"section\", \"parent=\" . $oldParent . \" ORDER BY rank\");\r\n for ($i = 0, $iMax = count($childOfLastMove); $i < $iMax; $i++) {\r\n $childOfLastMove[$i]->rank = $i;\r\n $db->updateObject($childOfLastMove[$i], 'section');\r\n }\r\n\r\n }\r\n// echo $moveSec->name . \" was appended to \" . $targSec->name;\r\n\r\n } elseif ($type == \"after\") { // dropped between (after) pages\r\n if ($targSec->parent == $moveSec->parent) {\r\n //are we moving up...\r\n if ($targSec->rank < $moveSec->rank) {\r\n $moveSec->rank = $targSec->rank + 1;\r\n $moveNextSiblings = $db->selectObjects(\"section\", \"id!=\" . $moveSec->id . \" AND parent=\" . $targSec->parent . \" AND rank>\" . $targSec->rank . \" ORDER BY rank\");\r\n $rerank = $moveSec->rank + 1;\r\n foreach ($moveNextSiblings as $value) {\r\n if ($value->id != $moveSec->id) {\r\n $value->rank = $rerank;\r\n $db->updateObject($value, 'section');\r\n $rerank++;\r\n }\r\n }\r\n $db->updateObject($targSec, 'section');\r\n// $targSec->update();\r\n $db->updateObject($moveSec, 'section');\r\n// $moveSec->update();\r\n //or are we moving down...\r\n } else {\r\n $targSec->rank = $targSec->rank - 1;\r\n $moveSec->rank = $targSec->rank + 1;\r\n $movePreviousSiblings = $db->selectObjects(\"section\", \"id!=\" . $moveSec->id . \" AND parent=\" . $targSec->parent . \" AND rank<=\" . $targSec->rank . \" ORDER BY rank\");\r\n $rerank = 1;\r\n foreach ($movePreviousSiblings as $value) {\r\n if ($value->id != $moveSec->id) {\r\n $value->rank = $rerank;\r\n $db->updateObject($value, 'section');\r\n $rerank++;\r\n }\r\n }\r\n $db->updateObject($targSec, 'section');\r\n// $targSec->update();\r\n $db->updateObject($moveSec, 'section');\r\n// $moveSec->update();\r\n }\r\n } else { // 'before', is this used?\r\n //store ranks from the depth we're moving from. Used to re-rank the level depth the moving section is moving from.\r\n $oldRank = $moveSec->rank;\r\n $oldParent = $moveSec->parent;\r\n //select all children of the target sections parent with a rank higher than it's own\r\n $moveNextSiblings = $db->selectObjects(\"section\", \"parent=\" . $targSec->parent . \" AND rank>\" . $targSec->rank . \" ORDER BY rank\");\r\n //update moving sections rank and parent\r\n $moveSec->rank = $targSec->rank + 1;\r\n $moveSec->parent = $targSec->parent;\r\n //$rerank=$moveSec->rank+1;\r\n foreach ($moveNextSiblings as $value) {\r\n $value->rank = $value->rank + 1;\r\n $db->updateObject($value, 'section');\r\n }\r\n $db->updateObject($moveSec, 'section');\r\n //handle re-ranking of previous parent\r\n $oldSiblings = $db->selectObjects(\"section\", \"parent=\" . $oldParent . \" AND rank>\" . $oldRank . \" ORDER BY rank\");\r\n $rerank = 1;\r\n foreach ($oldSiblings as $value) {\r\n if ($value->id != $moveSec->id) {\r\n $value->rank = $rerank;\r\n $db->updateObject($value, 'section');\r\n $rerank++;\r\n }\r\n }\r\n if ($oldParent != $moveSec->parent) {\r\n //we need to re-rank the children of the parent that the moving section has just left\r\n $childOfLastMove = $db->selectObjects(\"section\", \"parent=\" . $oldParent . \" ORDER BY rank\");\r\n for ($i = 0, $iMax = count($childOfLastMove); $i < $iMax; $i++) {\r\n $childOfLastMove[$i]->rank = $i;\r\n $db->updateObject($childOfLastMove[$i], 'section');\r\n }\r\n }\r\n }\r\n }\r\n self::checkForSectionalAdmins($move);\r\n expSession::clearAllUsersSessionCache('navigation');\r\n }\r\n\r\n /**\r\n * Ajax function to reorder page hierarchy from jstree control\r\n */\r\n public static function DragnDropReRank2() {\r\n global $router, $db;\r\n\r\n $id = $router->params['id'];\r\n $page = new section($id);\r\n $old_rank = $page->rank;\r\n $old_parent = $page->parent;\r\n $new_rank = $router->params['position'] + 1; // rank\r\n $new_parent = intval($router->params['parent']);\r\n\r\n $db->decrement($page->tablename, 'rank', 1, 'rank>' . $old_rank . ' AND parent=' . $old_parent); // close in hole\r\n $db->increment($page->tablename, 'rank', 1, 'rank>=' . $new_rank . ' AND parent=' . $new_parent); // make room\r\n\r\n $params = array();\r\n $params['parent'] = $new_parent;\r\n $params['rank'] = $new_rank;\r\n $page->update($params);\r\n\r\n self::checkForSectionalAdmins($id);\r\n expSession::clearAllUsersSessionCache('navigation');\r\n }\r\n\r\n function edit_section() {\r\n global $db, $user;\r\n\r\n $parent = new section($this->params['parent']);\r\n if (empty($parent->id)) $parent->id = 0;\r\n assign_to_template(array(\r\n 'haveStandalone' => ($db->countObjects('section', 'parent=-1') && $parent->id >= 0),\r\n 'parent' => $parent,\r\n 'isAdministrator' => $user->isAdmin(),\r\n ));\r\n }\r\n\r\n function edit_contentpage() {\r\n //FIXME we come here for new/edit content/standalone pages\r\n // FIXME: Allow non-administrative users to manage certain parts of the section hierarchy.\r\n //if ($user->is_acting_admin == 1 /*TODO: section admin*/) {\r\n// $section = null;\r\n $section = new stdClass();\r\n if (isset($this->params['id'])) {\r\n // Check to see if an id was passed in get. If so, retrieve that section from\r\n // the database, and perform an edit on it.\r\n $section = $this->section->find($this->params['id']);\r\n } elseif (isset($this->params['parent'])) {\r\n // The isset check is merely a precaution. This action should\r\n // ALWAYS be invoked with a parent or id value.\r\n $section = new section($this->params);\r\n } else {\r\n notfoundController::handle_not_found();\r\n exit;\r\n }\r\n if (!empty($section->id)) {\r\n $check_id = $section->id;\r\n } else {\r\n $check_id = $section->parent;\r\n }\r\n if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $check_id))) {\r\n if (empty($section->id)) {\r\n $section->active = 1;\r\n $section->public = 1;\r\n if (!isset($section->parent)) {\r\n // This is another precaution. The parent attribute\r\n // should ALWAYS be set by the caller.\r\n //FJD - if that's the case, then we should die.\r\n notfoundController::handle_not_authorized();\r\n exit;\r\n //$section->parent = 0;\r\n }\r\n }\r\n assign_to_template(array(\r\n 'section' => $section,\r\n 'glyphs' => self::get_glyphs(),\r\n ));\r\n } else { // User does not have permission to manage sections. Throw a 403\r\n notfoundController::handle_not_authorized();\r\n }\r\n }\r\n\r\n private static function get_glyphs() {\r\n if (bs()) {\r\n require_once(BASE . 'external/font-awesome.class.php');\r\n $fa = new Smk_FontAwesome;\r\n if (bs3()) {\r\n $icons = $fa->getArray(BASE . 'external/font-awesome4/css/font-awesome.css');\r\n $icons = $fa->sortByName($icons);\r\n return $fa->nameGlyph($icons);\r\n } elseif (bs2()) {\r\n expCSS::auto_compile_less(\r\n 'external/font-awesome/less/font-awesome.less',\r\n 'external/font-awesome/css/font-awesome.css'\r\n ); // font-awesome is included within bootstrap2, but not as a separate .css file\r\n $icons = $fa->getArray(BASE . 'external/font-awesome/css/font-awesome.css', 'icon-');\r\n return $fa->nameGlyph($icons, 'icon-');\r\n }\r\n } else {\r\n return array();\r\n }\r\n }\r\n\r\n function edit_internalalias() {\r\n $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);\r\n if ($section->parent == -1) {\r\n notfoundController::handle_not_found();\r\n exit;\r\n } // doesn't work for standalone pages\r\n if (empty($section->id)) {\r\n $section->public = 1;\r\n if (!isset($section->parent)) {\r\n // This is another precaution. The parent attribute\r\n // should ALWAYS be set by the caller.\r\n //FJD - if that's the case, then we should die.\r\n notfoundController::handle_not_authorized();\r\n exit;\r\n //$section->parent = 0;\r\n }\r\n }\r\n assign_to_template(array(\r\n 'section' => $section,\r\n 'glyphs' => self::get_glyphs(),\r\n ));\r\n }\r\n\r\n function edit_freeform() {\r\n $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);\r\n if ($section->parent == -1) {\r\n notfoundController::handle_not_found();\r\n exit;\r\n } // doesn't work for standalone pages\r\n if (empty($section->id)) {\r\n $section->public = 1;\r\n if (!isset($section->parent)) {\r\n // This is another precaution. The parent attribute\r\n // should ALWAYS be set by the caller.\r\n //FJD - if that's the case, then we should die.\r\n notfoundController::handle_not_authorized();\r\n exit;\r\n //$section->parent = 0;\r\n }\r\n }\r\n assign_to_template(array(\r\n 'section' => $section,\r\n 'glyphs' => self::get_glyphs(),\r\n ));\r\n }\r\n\r\n function edit_externalalias() {\r\n $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);\r\n if ($section->parent == -1) {\r\n notfoundController::handle_not_found();\r\n exit;\r\n } // doesn't work for standalone pages\r\n if (empty($section->id)) {\r\n $section->public = 1;\r\n if (!isset($section->parent)) {\r\n // This is another precaution. The parent attribute\r\n // should ALWAYS be set by the caller.\r\n //FJD - if that's the case, then we should die.\r\n notfoundController::handle_not_authorized();\r\n exit;\r\n //$section->parent = 0;\r\n }\r\n }\r\n assign_to_template(array(\r\n 'section' => $section,\r\n 'glyphs' => self::get_glyphs(),\r\n ));\r\n }\r\n\r\n function update() {\r\n parent::update();\r\n expSession::clearAllUsersSessionCache('navigation');\r\n }\r\n\r\n function move_standalone() {\r\n expSession::clearAllUsersSessionCache('navigation');\r\n assign_to_template(array(\r\n 'parent' => $this->params['parent'],\r\n ));\r\n }\r\n\r\n /**\r\n * Move standalone back to hierarchy\r\n *\r\n */\r\n function reparent_standalone() {\r\n $standalone = $this->section->find($this->params['page']);\r\n if ($standalone) {\r\n $standalone->parent = $this->params['parent'];\r\n $standalone->update();\r\n expSession::clearAllUsersSessionCache('navigation');\r\n expHistory::back();\r\n } else {\r\n notfoundController::handle_not_found();\r\n }\r\n }\r\n\r\n /**\r\n * Move content page to standalones\r\n *\r\n */\r\n function remove() {\r\n global $db;\r\n\r\n $section = $db->selectObject('section', 'id=' . $this->params['id']);\r\n if ($section) {\r\n section::removeLevel($section->id);\r\n $db->decrement('section', 'rank', 1, 'rank > ' . $section->rank . ' AND parent=' . $section->parent);\r\n $section->parent = -1;\r\n $db->updateObject($section, 'section');\r\n expSession::clearAllUsersSessionCache('navigation');\r\n expHistory::back();\r\n } else {\r\n notfoundController::handle_not_authorized();\r\n }\r\n }\r\n\r\n function delete_standalones() {\r\n if (!empty($this->params['deleteit'])) {\r\n foreach ($this->params['deleteit'] as $page) {\r\n $section = new section(intval($page));\r\n if ($section) {\r\n// self::deleteLevel($section->id);\r\n $section->delete();\r\n }\r\n }\r\n }\r\n expSession::clearAllUsersSessionCache('navigation');\r\n expHistory::back();\r\n }\r\n\r\n // create a psuedo global manage pages permission\r\n public static function checkPermissions($permission,$location) {\r\n global $exponent_permissions_r, $router;\r\n\r\n // only applies to the 'manage' method\r\n if (empty($location->src) && empty($location->int) && (!empty($router->params['action']) && $router->params['action'] == 'manage') || strpos($router->current_url, 'action=manage') !== false) {\r\n if (!empty($exponent_permissions_r['navigation'])) foreach ($exponent_permissions_r['navigation'] as $page) {\r\n foreach ($page as $pageperm) {\r\n if (!empty($pageperm['manage'])) return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Rebuild the sectionref table as a list of modules on a page\r\n * @deprecated 2.3.4 moved to sectionref model\r\n */\r\n public static function rebuild_sectionrefs() {\r\n global $db;\r\n\r\n // recursive run though all the nested containers\r\n function scan_container($container_id, $page_id) {\r\n global $db;\r\n\r\n $containers = $db->selectObjects('container',\"external='\" . $container_id . \"'\");\r\n $ret = '';\r\n foreach ($containers as $container) {\r\n $iLoc = expUnserialize($container->internal);\r\n $newret = recyclebin::restoreFromRecycleBin($iLoc, $page_id);\r\n if (!empty($newret)) $ret .= $newret . '<br>';\r\n if ($iLoc->mod == 'container') {\r\n $ret .= scan_container($container->internal, $page_id);\r\n }\r\n }\r\n return $ret;\r\n }\r\n\r\n // recursive run through all the nested pages\r\n function scan_page($parent_id) {\r\n global $db;\r\n\r\n $sections = $db->selectObjects('section','parent=' . $parent_id);\r\n $ret = '';\r\n foreach ($sections as $page) {\r\n $cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));\r\n $ret .= scan_container($cLoc, $page->id);\r\n $ret .= scan_page($page->id);\r\n }\r\n return $ret;\r\n }\r\n\r\n // first remove duplicate records\r\n $db->sql('DELETE FROM ' . $db->prefix . 'sectionref WHERE id NOT IN (SELECT * FROM (SELECT MIN(n.id) FROM ' . $db->prefix . 'sectionref n GROUP BY n.module, n.source) x)');\r\n $ret = scan_page(0); // the page hierarchy\r\n $ret .= scan_page(-1); // now the stand alone pages\r\n\r\n // we need to get the non-main containers such as sidebars, footers, etc...\r\n $hardcodedmods = $db->selectObjects('sectionref',\"refcount=1000 AND source NOT LIKE '%@section%' AND source NOT LIKE '%@random%'\");\r\n foreach ($hardcodedmods as $hardcodedmod) {\r\n if ($hardcodedmod->module == 'container') {\r\n $page_id = intval(preg_replace('/\\D/', '', $hardcodedmod->source));\r\n if (empty($page_id)) {\r\n $page_id = SITE_DEFAULT_SECTION; // we'll default to the home page\r\n }\r\n $ret .= scan_container(serialize(expCore::makeLocation($hardcodedmod->module, $hardcodedmod->source)), $page_id);\r\n } else {\r\n $hardcodedmod->section = 0; // this is a hard-coded non-container module\r\n $db->updateObject($hardcodedmod, 'sectionref');\r\n }\r\n }\r\n\r\n // mark modules in the recycle bin as section 0\r\n $db->columnUpdate('sectionref', 'section', 0, \"refcount=0\");\r\n// $recycledmods = $db->selectObjects('sectionref',\"refcount=0\");\r\n// foreach ($recycledmods as $recycledmod) {\r\n// $recycledmod->section = 0; // this is a module in the recycle bin\r\n// $db->updateObject($recycledmod, 'sectionref');\r\n// }\r\n return $ret;\r\n }\r\n\r\n}\r\n\r",
"?>"
] |
[
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################\n/**\n * @subpackage Controllers\n * @package Modules\n */\nclass navigationController extends expController {\n public $basemodel_name = 'section';\n public $useractions = array(\n 'showall' => 'Show Navigation',\n 'breadcrumb' => 'Breadcrumb',\n );\n protected $remove_permissions = array(\n// 'configure',\n// 'create',\n// 'delete',\n// 'edit'\n );\n protected $add_permissions = array(\n 'manage' => 'Manage',\n 'view' => \"View Page\"\n );\n protected $manage_permissions = array(\n 'move' => 'Move Page',\n 'remove' => 'Remove Page',\n 'reparent' => 'Reparent Page',\n );\n public $remove_configs = array(\n 'aggregation',\n 'categories',\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'pagination',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" static function displayname() { return gt(\"Navigation\"); }",
" static function description() { return gt(\"Places navigation links/menus on the page.\"); }",
" static function isSearchable() { return true; }",
" function searchName() { return gt('Webpage'); }",
" /**\n * @param null $src\n * @param array $params\n *\n */\n function __construct($src = null, $params = array())\n {\n parent::__construct($src, $params);\n if (!empty($params['id'])) // we normally throw out the $loc->int EXCEPT with navigation pages\n $this->loc = expCore::makeLocation($this->baseclassname, $src, $params['id']);\n }",
" public function showall() {\n global $user, $sectionObj, $sections;",
" expHistory::set('viewable', $this->params);\n $id = $sectionObj->id;\n $current = null;\n // all we need to do is determine the current section\n $navsections = $sections;\n if ($sectionObj->parent == -1) {\n $current = $sectionObj;\n } else {\n foreach ($navsections as $section) {\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n }\n assign_to_template(array(\n 'sections' => $navsections,\n 'current' => $current,\n 'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),\n ));\n }",
" public function breadcrumb() {\n global $sectionObj;",
" expHistory::set('viewable', $this->params);\n $id = $sectionObj->id;\n $current = null;\n // Show not only the location of a page in the hierarchy but also the location of a standalone page\n $current = new section($id);\n if ($current->parent == -1) { // standalone page\n $navsections = section::levelTemplate(-1, 0);\n foreach ($navsections as $section) {\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n } else {\n $navsections = section::levelTemplate(0, 0);\n foreach ($navsections as $section) {\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n }\n assign_to_template(array(\n 'sections' => $navsections,\n 'current' => $current,\n ));\n }",
" /**\n * @deprecated 2.3.4 moved to section model\n */\n public static function navhierarchy($notyui=false) {\n global $sections;",
" $json_array = array();\n for ($i = 0, $iMax = count($sections); $i < $iMax; $i++) {\n if ($sections[$i]->depth == 0) {\n $obj = new stdClass();\n// \t\t\t\t$obj->id = $sections[$i]->name.$sections[$i]->id;\n $obj->id = $sections[$i]->id;\n $obj->text = $sections[$i]->name;\n $obj->title = $sections[$i]->page_title;\n $obj->description = $sections[$i]->description;\n $obj->new_window = $sections[$i]->new_window;\n $obj->expFile = $sections[$i]->expFile;\n $obj->glyph = $sections[$i]->glyph;\n $obj->glyph_only = $sections[$i]->glyph_only;\n $obj->type = $sections[$i]->alias_type;\n if ($sections[$i]->active == 1) {\n $obj->url = $sections[$i]->link;\n if ($obj->type == 1 && substr($obj->url, 0, 4) != 'http') {\n $obj->url = 'http://' . $obj->url;\n }\n } else {\n $obj->url = \"#\";\n $obj->onclick = \"onclick: { fn: return false }\";\n }\n if ($obj->type == 3) { // mostly a hack instead of adding more table fields\n $obj->width = $sections[$i]->internal_id;\n $obj->class = $sections[$i]->external_link;\n }\n /*if ($sections[$i]->active == 1) {\n $obj->disabled = false;\n } else {\n $obj->disabled = true;\n }*/\n //$obj->disabled = true;\n $obj->itemdata = self::getChildren($i,$notyui);\n $obj->maxitems = count($obj->itemdata);\n $obj->maxdepth = 0;\n foreach ($obj->itemdata as $menu) {\n if ($menu->maxdepth > $obj->maxdepth) $obj->maxdepth = $menu->maxdepth;\n }\n }\n $json_array[] = $obj;\n }\n return $json_array;\n }",
" /**\n * @deprecated 2.3.4 moved to section model\n */\n public static function navtojson() {\n return json_encode(self::navhierarchy());\n }",
" /**\n * @deprecated 2.3.4 moved to section model\n */\n public static function getChildren(&$i, $notyui=false) {\n global $sections;",
" //\t\techo \"i=\".$i.\"<br>\";\n if ($i + 1 == count($sections)) { // last entry\n return array();\n } elseif ($sections[$i]->depth == $sections[$i + 1]->depth) {\n return array();\n } else {\n $ret_depth = $sections[$i]->depth;\n $i++;\n $ret_array = array();\n for ($iMax = count($sections); $i < $iMax; $i++) {\n // start setting up the objects to return\n $obj = new stdClass();\n $obj->id = $sections[$i]->id;\n $obj->text = $sections[$i]->name;\n $obj->title = $sections[$i]->page_title;\n $obj->description = $sections[$i]->description;\n $obj->new_window = $sections[$i]->new_window;\n $obj->expFile = $sections[$i]->expFile;\n $obj->glyph = $sections[$i]->glyph;\n $obj->glyph_only = $sections[$i]->glyph_only;\n $obj->depth = $sections[$i]->depth;\n if ($sections[$i]->active == 1) {\n $obj->url = $sections[$i]->link;\n if ($sections[$i]->alias_type == 1 && substr($obj->url, 0, 4) != 'http') {\n $obj->url = 'http://' . $obj->url;\n }\n } else {\n $obj->url = \"#\";\n $obj->onclick = \"onclick: { fn: return false }\";\n }\n //echo \"i=\".$i.\"<br>\";\n if (self::hasChildren($i)) {\n if ($notyui) {\n $obj->itemdata = self::getChildren($i,$notyui);\n $obj->maxitems = count($obj->itemdata);\n $obj->maxdepth = 0;\n foreach ($obj->itemdata as $menu) {\n if (!empty($menu->maxdepth)) {\n if ($menu->maxdepth > $obj->maxdepth) $obj->maxdepth = $menu->maxdepth;\n } else {\n if ($menu->depth > $obj->maxdepth) $obj->maxdepth = $menu->depth;\n }\n }\n } else {\n $obj->submenu = new stdClass();\n $obj->submenu->id = $sections[$i]->name . $sections[$i]->id;\n //echo \"getting children of \".$sections[$i]->name;\n $obj->submenu->itemdata = self::getChildren($i,$notyui);\n $obj->maxitems = count($obj->submenu->itemdata);\n $obj->maxdepth = 0;\n foreach ($obj->submenu->itemdata as $menu) {\n if (!empty($menu->maxdepth)) {\n if ($menu->maxdepth > $obj->maxdepth) $obj->maxdepth = $menu->maxdepth;\n } else {\n if ($menu->depth > $obj->maxdepth) $obj->maxdepth = $menu->depth;\n }\n }\n }\n $ret_array[] = $obj;\n } else {\n $obj->maxdepth = $obj->depth;\n $ret_array[] = $obj;\n }\n if (($i + 1) >= count($sections) || $sections[$i + 1]->depth <= $ret_depth) {\n return $ret_array;\n }\n }\n return array();\n }\n }",
" /**\n * @deprecated 2.3.4 moved to section model\n */\n public static function hasChildren($i) {\n global $sections;",
" if (($i + 1) >= count($sections)) return false;\n return ($sections[$i]->depth < $sections[$i + 1]->depth) ? true : false;\n }",
" /** exdoc\n * Creates a location object, based off of the three arguments passed, and returns it.\n *\n * @return array\n * @deprecated 2.3.4 moved to section model\n */\n public static function initializeNavigation() {\n $sections = section::levelTemplate(0, 0);\n return $sections;\n }",
" /**\n * returns all the section's children\n *\n * @static\n *\n * @param int $parent top level parent id\n * @param int $depth variable to hold level of recursion\n * @param array $parents\n *\n * @return array\n * @deprecated 2.3.4 moved to section model\n */\n public static function levelTemplate($parent, $depth = 0, $parents = array()) {\n global $user;",
" if ($parent != 0) $parents[] = $parent;\n $nodes = array();\n $cache = expSession::getCacheValue('navigation');\n $sect = new section();\n if (!isset($cache['kids'][$parent])) {\n $kids = $sect->find('all','parent=' . $parent);\n $cache['kids'][$parent] = $kids;\n expSession::setCacheValue('navigation', $cache);\n } else {\n $kids = $cache['kids'][$parent];\n }\n $kids = expSorter::sort(array('array' => $kids, 'sortby' => 'rank', 'order' => 'ASC'));\n for ($i = 0, $iMax = count($kids); $i < $iMax; $i++) {\n $child = $kids[$i];\n //foreach ($kids as $child) {\n if ($child->public == 1 || expPermissions::check('view', expCore::makeLocation('navigation', '', $child->id))) {\n $child->numParents = count($parents);\n $child->depth = $depth;\n $child->first = ($i == 0 ? 1 : 0);\n $child->last = ($i == count($kids) - 1 ? 1 : 0);\n $child->parents = $parents;\n $child->canManage = (isset($user->is_acting_admin) && $user->is_acting_admin == 1 ? 1 : 0);\n $child->canManageRank = $child->canManage;\n if (!isset($child->sef_name)) {\n $child->sef_name = '';\n }\n // Generate the link attribute base on alias type.\n if ($child->alias_type == 1) {\n // External link. Set the link to the configured website URL.\n // This is guaranteed to be a full URL because of the\n // section::updateExternalAlias() method in models-1/section.php\n $child->link = $child->external_link;\n } else if ($child->alias_type == 2) {\n // Internal link.\n // Need to check and see if the internal_id is pointing at an external link.\n// $dest = $db->selectObject('section', 'id=' . $child->internal_id);\n $dest = $sect->find('first','id=' . $child->internal_id);\n if (!empty($dest->alias_type) && $dest->alias_type == 1) {\n // This internal alias is pointing at an external alias.\n // Use the external_link of the destination section for the link\n $child->link = $dest->external_link;\n } else {\n // Pointing at a regular section. This is guaranteed to be\n // a regular section because aliases cannot be turned into sections,\n // (and vice-versa) and because the section::updateInternalLink\n // does 'alias to alias' dereferencing before the section is saved\n // (see models-1/section.php)\n //added by Tyler to pull the descriptions through for the children view\n $child->description = !empty($dest->description) ? $dest->description : '';\n $child->link = expCore::makeLink(array('section' => $child->internal_id));\n }\n } else {\n // Normal link, alias_type == 0. Just create the URL from the section's id.\n $child->link = expCore::makeLink(array('section' => $child->id), '', $child->sef_name);\n }\n //$child->numChildren = $db->countObjects('section','parent='.$child->id);\n $nodes[] = $child;\n $nodes = array_merge($nodes, section::levelTemplate($child->id, $depth + 1, $parents));\n }\n }\n return $nodes;\n }",
" /**\n * Returns a flat representation of the full site hierarchy.\n *\n * @param int $parent top level parent id\n * @param int $depth variable to hold level of recursion\n * @param array $ignore_ids array of pages to ignore\n * @param bool $full include a 'top' level entry\n * @param string $perm permission level to build list\n * @param bool $addstandalones should we add the stand-alone pages also\n * @param bool $addinternalalias\n *\n * @return array\n * @deprecated 2.3.4 moved to section model, HOWEVER still used in theme config\n */\n public static function levelDropdownControlArray($parent, $depth = 0, $ignore_ids = array(), $full = false, $perm = 'view', $addstandalones = false, $addinternalalias = true) {\n global $db;",
" $ar = array();\n if ($parent == 0 && $full) {\n $ar[0] = '<' . gt('Top of Hierarchy') . '>';\n }\n if ($addinternalalias) {\n $intalias = '';\n } else {\n $intalias = ' AND alias_type != 2';\n }\n $nodes = $db->selectObjects('section', 'parent=' . $parent . $intalias, 'rank');\n foreach ($nodes as $node) {\n if ((($perm == 'view' && $node->public == 1) || expPermissions::check($perm, expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {\n if ($node->active == 1) {\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;\n } else {\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';\n }\n $ar[$node->id] = $text;\n foreach (self::levelDropdownControlArray($node->id, $depth + 1, $ignore_ids, $full, $perm, $addstandalones, $addinternalalias) as $id => $text) {\n $ar[$id] = $text;\n }\n }\n }\n if ($addstandalones && $parent == 0) {\n $sections = $db->selectObjects('section', 'parent=-1');\n foreach ($sections as $node) {\n if ((($perm == 'view' && $node->public == 1) || expPermissions::check($perm, expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {\n if ($node->active == 1) {\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;\n } else {\n $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';\n }\n $ar[$node->id] = '(' . gt('Standalone') . ') ' . $text;\n }\n }\n// $ar = array_merge($ar,$sections);\n }\n return $ar;\n }",
" /**\n * add all module items to search index\n *\n * @return int\n */\n function addContentToSearch() {\n global $db;",
" //global $sections;\n //\t\tglobal $router;\n// $db->delete('search', \"ref_module='navigation' AND ref_type='section'\");\n $db->delete('search', \"ref_module='\".$this->baseclassname.\"' AND ref_type='section'\");\n // this now ensures we get internal pages, instead of relying on the global $sections, which does not.\n $sections = $db->selectObjects('section', 'active=1');\n foreach ($sections as $section) {\n $search_record = new stdClass();\n// $search_record->category = 'Webpages';\n// $search_record->ref_module = 'navigationController';\n// $search_record->ref_type = 'section';\n// $search_record->ref_module = $this->classname;\n $search_record->ref_module = $this->baseclassname;\n $search_record->category = $this->searchName();\n $search_record->ref_type = $this->searchCategory();\n $search_record->original_id = $section->id;\n $search_record->title = $section->name;\n //$search_record->view_link = $router->buildUrlByPageId($section->id);\n $link = str_replace(URL_FULL, '', makeLink(array('section' => $section->id)));\n if ($link . '/' == URL_FULL) $link = '';\n $search_record->view_link = $link;\n $search_record->body = $section->description;\n $search_record->keywords = $section->keywords;\n // now we're going to grab all the textmodules on this page and build the body for the page based off the content\n // of all the text module added together.\n $loc = expCore::makeLocation('text');\n $controllername = 'text';\n foreach ($db->selectObjects('sectionref', \"module='\" . $controllername . \"' AND section=\" . $section->id) as $module) {\n $loc->src = $module->source;\n// $controller = new $controllername();\n $controller = expModules::getController($controllername);\n $textitems = $db->selectObjects($controller->model_table, \"location_data='\" . serialize($loc) . \"'\");\n foreach ($textitems as $textitem) {\n if (!empty($textitem)) {\n $search_record->body .= ' ' . search::removeHTML($textitem->body) . ' ';\n $search_record->keywords .= \" \" . $textitem->title;\n }\n }\n }\n $db->insertObject($search_record, 'search');\n }\n return count($sections);\n }",
" /**\n * Retrieve either the entire hierarchy, or a subset of the hierarchy, as an array suitable for use\n * in a dropdowncontrol. This is used primarily by the section datatype for moving and adding\n * sections to specific parts of the site hierarchy.\n *\n * @param int $parent The id of the subtree parent. If passed as 0 (the default), the entire subtree is parsed.\n * @param int $depth\n * @param int $default\n * @param array $ignore_ids a value-array of IDs to be ignored when generating the list. This is used\n * when moving a section, since a section cannot be made a subsection of itself or any of its subsections.\n *\n * @return string\n */\n function levelShowDropdown($parent, $depth = 0, $default = 0, $ignore_ids = array()) {\n global $db;",
" $html = '';\n $nodes = $db->selectObjects('section', 'parent=' . $parent, 'rank');\n//\t\t$nodes = expSorter::sort(array('array'=>$nodes,'sortby'=>'rank', 'order'=>'ASC'));\n foreach ($nodes as $node) {\n if (($node->public == 1 || expPermissions::check('view', expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {\n $html .= '<option value=\"' . $node->id . '\" ';\n if ($default == $node->id) $html .= 'selected';\n $html .= '>';\n if ($node->active == 1) {\n $html .= str_pad('', $depth * 3, '.', STR_PAD_LEFT) . $node->name;\n } else {\n $html .= str_pad('', $depth * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';\n }\n $html .= '</option>';\n $html .= self::levelShowDropdown($node->id, $depth + 1, $default, $ignore_ids);\n }\n }\n return $html;\n }",
" /**\n * recursively lists the template hierarchy\n *\n * @static\n *\n * @param int $parent top level parent id\n * @param int $depth variable to hold level of recursion\n *\n * @return array\n * @deprecated 2.0.0 this only for deprecated templates\n */\n public static function getTemplateHierarchyFlat($parent, $depth = 1) {\n global $db;",
" $arr = array();\n $kids = $db->selectObjects('section_template', 'parent=' . $parent, 'rank');\n//\t\t$kids = expSorter::sort(array('array'=>$kids,'sortby'=>'rank', 'order'=>'ASC'));\n for ($i = 0, $iMax = count($kids); $i < $iMax; $i++) {\n $page = $kids[$i];\n $page->depth = $depth;\n $page->first = ($i == 0 ? 1 : 0);\n $page->last = ($i == count($kids) - 1 ? 1 : 0);\n $arr[] = $page;\n $arr = array_merge($arr, self::getTemplateHierarchyFlat($page->id, $depth + 1));\n }\n return $arr;\n }",
" /**\n * @deprecated 2.0.0 this only for deprecated templates\n */\n public static function process_section($section, $template) {\n global $db;",
" if (!is_object($template)) {\n $template = $db->selectObject('section_template', 'id=' . $template);\n $section->subtheme = $template->subtheme;\n $db->updateObject($section, 'section');\n }\n $prefix = '@st' . $template->id;\n $refs = $db->selectObjects('sectionref', \"source LIKE '$prefix%'\");\n // Copy all modules and content for this section\n foreach ($refs as $ref) {\n $src = substr($ref->source, strlen($prefix)) . $section->id;\n if (call_user_func(array($ref->module, 'hasContent'))) {\n $oloc = expCore::makeLocation($ref->module, $ref->source);\n $nloc = expCore::makeLocation($ref->module, $src);\n if ($ref->module != \"container\") {\n call_user_func(array($ref->module, 'copyContent'), $oloc, $nloc);\n } else {\n call_user_func(array($ref->module, 'copyContent'), $oloc, $nloc, $section->id);\n }\n }\n }\n // Grab sub pages\n foreach ($db->selectObjects('section_template', 'parent=' . $template->id) as $t) {\n self::process_subsections($section, $t);\n }",
" }",
" /**\n * @deprecated 2.0.0 this only for deprecated templates\n */\n function process_subsections($parent_section, $subtpl) {\n global $db, $router;",
" $section = new stdClass();\n $section->parent = $parent_section->id;\n $section->name = $subtpl->name;\n $section->sef_name = $router->encode($section->name);\n $section->subtheme = $subtpl->subtheme;\n $section->active = $subtpl->active;\n $section->public = $subtpl->public;\n $section->rank = $subtpl->rank;\n $section->page_title = $subtpl->page_title;\n $section->keywords = $subtpl->keywords;\n $section->description = $subtpl->description;\n $section->id = $db->insertObject($section, 'section');\n self::process_section($section, $subtpl);\n }",
" /**\n * Delete page and send its contents to the recycle bin\n *\n * @param $parent\n * @deprecated 2.3.4 moved to section model\n */\n public static function deleteLevel($parent) {\n global $db;",
" $kids = $db->selectObjects('section', 'parent=' . $parent);\n foreach ($kids as $kid) {\n self::deleteLevel($kid->id);\n }\n $secrefs = $db->selectObjects('sectionref', 'section=' . $parent);\n foreach ($secrefs as $secref) {\n $loc = expCore::makeLocation($secref->module, $secref->source, $secref->internal);\n recyclebin::sendToRecycleBin($loc, $parent);\n //FIXME if we delete the module & sectionref the module completely disappears\n// if (class_exists($secref->module)) {\n// $modclass = $secref->module;\n// //FIXME: more module/controller glue code\n// if (expModules::controllerExists($modclass)) {\n// $modclass = expModules::getControllerClassName($modclass);\n// $mod = new $modclass($loc->src);\n// $mod->delete_instance();\n// } else {\n// $mod = new $modclass();\n// $mod->deleteIn($loc);\n// }\n// }\n }\n// $db->delete('sectionref', 'section=' . $parent);\n $db->delete('section', 'parent=' . $parent);\n }",
" /**\n * Move content page and its children to stand-alones\n *\n * @param $parent\n * @deprecated 2.3.4 moved to section model\n */\n public static function removeLevel($parent) {\n global $db;",
" $kids = $db->selectObjects('section', 'parent=' . $parent);\n foreach ($kids as $kid) {\n $kid->parent = -1;\n $db->updateObject($kid, 'section');\n self::removeLevel($kid->id);\n }\n }",
" /**\n * Check for cascading page view permission, esp. if not public\n * @deprecated 2.3.4 moved to section model\n */\n public static function canView($section) {\n global $db;",
" if ($section == null) {\n return false;\n }\n if ($section->public == 0) {\n // Not a public section. Check permissions.\n return expPermissions::check('view', expCore::makeLocation('navigation', '', $section->id));\n } else { // Is public. check parents.\n if ($section->parent <= 0) {\n // Out of parents, and since we are still checking, we haven't hit a private section.\n return true;\n } else {\n $s = $db->selectObject('section', 'id=' . $section->parent);\n return self::canView($s);\n }\n }\n }",
" /**\n * Check to see if page is public with cascading\n * @deprecated 2.3.4 moved to section model\n */\n public static function isPublic($s) {\n if ($s == null) {\n return false;\n }\n while ($s->public && $s->parent > 0) {\n $s = new section($s->parent);\n }\n $lineage = (($s->public) ? 1 : 0);\n return $lineage;\n }",
" public static function canManageStandalones() {\n global $user;",
" if ($user->isAdmin()) return true;\n $standalones = section::levelTemplate(-1, 0);\n //\t\t$canmanage = false;\n foreach ($standalones as $standalone) {\n $loc = expCore::makeLocation('navigation', '', $standalone->id);\n if (expPermissions::check('manage', $loc)) return true;\n }\n return false;\n }",
" /**\n * Reassign permissions based on a check/change in menu/page hierarchy\n *\n * @static\n *\n * @param $id\n */\n public static function checkForSectionalAdmins($id) {\n global $db;",
" $section = $db->selectObject('section', 'id=' . $id);\n $branch = section::levelTemplate($id, 0);\n array_unshift($branch, $section);\n $allusers = array();\n $allgroups = array();\n while ($section->parent > 0) {\n //\t\t\t$ploc = expCore::makeLocation('navigationController', null, $section);\n $allusers = array_merge($allusers, $db->selectColumn('userpermission', 'uid', \"permission='manage' AND module='navigation' AND internal=\" . $section->parent));\n $allgroups = array_merge($allgroups, $db->selectColumn('grouppermission', 'gid', \"permission='manage' AND module='navigation' AND internal=\" . $section->parent));\n $section = $db->selectObject('section', 'id=' . $section->parent);\n }\n foreach ($branch as $section) {\n $sloc = expCore::makeLocation('navigation', null, $section->id);\n // remove any manage permissions for this page and it's children\n // $db->delete('userpermission', \"module='navigationController' AND internal=\".$section->id);\n // $db->delete('grouppermission', \"module='navigationController' AND internal=\".$section->id);\n foreach ($allusers as $uid) {\n $u = user::getUserById($uid);\n expPermissions::grant($u, 'manage', $sloc);\n }\n foreach ($allgroups as $gid) {\n $g = group::getGroupById($gid);\n expPermissions::grantGroup($g, 'manage', $sloc);\n }\n }\n }",
" function manage() {\n global $db, $router, $user;",
" expHistory::set('manageable', $router->params);\n assign_to_template(array(\n 'canManageStandalones' => self::canManageStandalones(),\n 'sasections' => $db->selectObjects('section', 'parent=-1'),\n 'user' => $user,\n// 'canManagePagesets' => $user->isAdmin(),\n// 'templates' => $db->selectObjects('section_template', 'parent=0'),\n ));\n }",
" public function manage_sitemap() {\n global $db, $user, $sectionObj, $sections;",
" expHistory::set('viewable', $this->params);\n $id = $sectionObj->id;\n $current = null;\n // all we need to do is determine the current section\n $navsections = $sections;\n if ($sectionObj->parent == -1) {\n $current = $sectionObj;\n } else {\n foreach ($navsections as $section) {\n if ($section->id == $id) {\n $current = $section;\n break;\n }\n }\n }\n assign_to_template(array(\n 'sasections' => $db->selectObjects('section', 'parent=-1'),\n 'sections' => $navsections,\n 'current' => $current,\n 'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),\n ));\n }",
" /**\n * Ajax request for specific pages as json date to yui tree\n */\n public static function returnChildrenAsJSON() {\n global $db;",
" //$nav = section::levelTemplate(intval($_REQUEST['id'], 0));\n $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;\n $nav = $db->selectObjects('section', 'parent=' . $id, 'rank');\n //FIXME $manage_all is moot w/ cascading perms now?\n $manage_all = false;\n if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $id))) {\n $manage_all = true;\n }\n //FIXME recode to use foreach $key=>$value\n $navcount = count($nav);\n for ($i = 0; $i < $navcount; $i++) {\n if ($manage_all || expPermissions::check('manage', expCore::makeLocation('navigation', '', $nav[$i]->id))) {\n $nav[$i]->manage = 1;\n $view = true;\n } else {\n $nav[$i]->manage = 0;\n $view = $nav[$i]->public ? true : expPermissions::check('view', expCore::makeLocation('navigation', '', $nav[$i]->id));\n }\n $nav[$i]->link = expCore::makeLink(array('section' => $nav[$i]->id), '', $nav[$i]->sef_name);\n if (!$view) unset($nav[$i]);\n }\n $nav= array_values($nav);\n// $nav[$navcount - 1]->last = true;\n if (count($nav)) $nav[count($nav) - 1]->last = true;\n// echo expJavascript::ajaxReply(201, '', $nav);\n $ar = new expAjaxReply(201, '', $nav);\n $ar->send();\n }",
" /**\n * Ajax request for all pages as json date to jstree\n */\n public static function returnChildrenAsJSON2() {\n global $db;",
" $icons = array(\n 0 => 'addpage',\n 1 => 'addextpage',\n 2 => 'addintpage',\n 3 => 'addfreeform',\n );",
" $navs = $db->selectObjects('section', 'parent!=-1', 'rank');\n foreach ($navs as $i=>$nav) {\n $navs[$i]->parent = $nav->parent?$nav->parent:'#';\n $navs[$i]->text = $nav->name;\n $navs[$i]->icon = $icons[$nav->alias_type];\n if (!$nav->active) {\n $navs[$i]->icon .= ' inactive';\n $attr = new stdClass();\n $attr->class = 'inactive'; // class to obscure elements\n $navs[$i]->a_attr = $attr;\n }\n if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $navs[$i]->id))) {\n $navs[$i]->manage = 1;\n $view = true;\n } else {\n $navs[$i]->manage = 0;\n $navs[$i]->state->disabled = true;\n $view = $navs[$i]->public ? true : expPermissions::check('view', expCore::makeLocation('navigation', '', $navs[$i]->id));\n }\n $navs[$i]->link = expCore::makeLink(array('section' => $navs[$i]->id), '', $navs[$i]->sef_name);\n if (!$view) {\n// unset($navs[$i]); //FIXME this breaks jstree if we remove a parent and not the child\n $attr = new stdClass();\n $attr->class = 'hidden'; // bs3 class to hide elements\n $navs[$i]->li_attr = $attr;\n }\n }\n $navs= array_values($navs);\n// header('Content-Type: application/json; charset=utf8');\n\t\techo json_encode($navs);\n// echo expJavascript::ajaxReply(201, '', $navs);\n exit;\n }",
" /**\n * Ajax function to reorder page hierarchy from yui tree control\n */\n public static function DragnDropReRank() {\n global $db, $router;",
" $move = $router->params['move'];\n $target = $router->params['target'];\n $type = $router->params['type'];\n $targSec = $db->selectObject(\"section\",\"id=\".$target);\n// $targSec = new section($target);\n $check_id = $targSec->parent;\n $moveSec = $db->selectObject(\"section\",\"id=\".$move);\n// $moveSec = new section($move);",
" // dropped on top of page\n if ($type == \"append\") {\n //save the old parent in case we are changing the depth of the moving section\n $oldParent = $moveSec->parent;\n //assign the parent of the moving section to the ID of the target section\n $moveSec->parent = $targSec->id;\n //set the rank of the moving section to 0 since it will appear first in the new order\n $moveSec->rank = 1;\n //select all children currently of the parent we're about to append to\n $targSecChildren = $db->selectObjects(\"section\", \"parent=\" . $targSec->id . \" ORDER BY rank\");\n //update the ranks of the children to +1 higher to accommodate our new rank 0 section being moved in.\n $newrank = 1;\n foreach ($targSecChildren as $value) {\n if ($value->id != $moveSec->id) {\n $value->rank = $newrank;\n $db->updateObject($value, 'section');\n $newrank++;\n }\n }\n $db->updateObject($moveSec, 'section');\n if ($oldParent != $moveSec->parent) {\n //we need to re-rank the children of the parent that the miving section has just left\n $childOfLastMove = $db->selectObjects(\"section\", \"parent=\" . $oldParent . \" ORDER BY rank\");\n for ($i = 0, $iMax = count($childOfLastMove); $i < $iMax; $i++) {\n $childOfLastMove[$i]->rank = $i;\n $db->updateObject($childOfLastMove[$i], 'section');\n }",
" }\n// echo $moveSec->name . \" was appended to \" . $targSec->name;",
" } elseif ($type == \"after\") { // dropped between (after) pages\n if ($targSec->parent == $moveSec->parent) {\n //are we moving up...\n if ($targSec->rank < $moveSec->rank) {\n $moveSec->rank = $targSec->rank + 1;\n $moveNextSiblings = $db->selectObjects(\"section\", \"id!=\" . $moveSec->id . \" AND parent=\" . $targSec->parent . \" AND rank>\" . $targSec->rank . \" ORDER BY rank\");\n $rerank = $moveSec->rank + 1;\n foreach ($moveNextSiblings as $value) {\n if ($value->id != $moveSec->id) {\n $value->rank = $rerank;\n $db->updateObject($value, 'section');\n $rerank++;\n }\n }\n $db->updateObject($targSec, 'section');\n// $targSec->update();\n $db->updateObject($moveSec, 'section');\n// $moveSec->update();\n //or are we moving down...\n } else {\n $targSec->rank = $targSec->rank - 1;\n $moveSec->rank = $targSec->rank + 1;\n $movePreviousSiblings = $db->selectObjects(\"section\", \"id!=\" . $moveSec->id . \" AND parent=\" . $targSec->parent . \" AND rank<=\" . $targSec->rank . \" ORDER BY rank\");\n $rerank = 1;\n foreach ($movePreviousSiblings as $value) {\n if ($value->id != $moveSec->id) {\n $value->rank = $rerank;\n $db->updateObject($value, 'section');\n $rerank++;\n }\n }\n $db->updateObject($targSec, 'section');\n// $targSec->update();\n $db->updateObject($moveSec, 'section');\n// $moveSec->update();\n }\n } else { // 'before', is this used?\n //store ranks from the depth we're moving from. Used to re-rank the level depth the moving section is moving from.\n $oldRank = $moveSec->rank;\n $oldParent = $moveSec->parent;\n //select all children of the target sections parent with a rank higher than it's own\n $moveNextSiblings = $db->selectObjects(\"section\", \"parent=\" . $targSec->parent . \" AND rank>\" . $targSec->rank . \" ORDER BY rank\");\n //update moving sections rank and parent\n $moveSec->rank = $targSec->rank + 1;\n $moveSec->parent = $targSec->parent;\n //$rerank=$moveSec->rank+1;\n foreach ($moveNextSiblings as $value) {\n $value->rank = $value->rank + 1;\n $db->updateObject($value, 'section');\n }\n $db->updateObject($moveSec, 'section');\n //handle re-ranking of previous parent\n $oldSiblings = $db->selectObjects(\"section\", \"parent=\" . $oldParent . \" AND rank>\" . $oldRank . \" ORDER BY rank\");\n $rerank = 1;\n foreach ($oldSiblings as $value) {\n if ($value->id != $moveSec->id) {\n $value->rank = $rerank;\n $db->updateObject($value, 'section');\n $rerank++;\n }\n }\n if ($oldParent != $moveSec->parent) {\n //we need to re-rank the children of the parent that the moving section has just left\n $childOfLastMove = $db->selectObjects(\"section\", \"parent=\" . $oldParent . \" ORDER BY rank\");\n for ($i = 0, $iMax = count($childOfLastMove); $i < $iMax; $i++) {\n $childOfLastMove[$i]->rank = $i;\n $db->updateObject($childOfLastMove[$i], 'section');\n }\n }\n }\n }\n self::checkForSectionalAdmins($move);\n expSession::clearAllUsersSessionCache('navigation');\n }",
" /**\n * Ajax function to reorder page hierarchy from jstree control\n */\n public static function DragnDropReRank2() {\n global $router, $db;",
" $id = $router->params['id'];\n $page = new section($id);\n $old_rank = $page->rank;\n $old_parent = $page->parent;\n $new_rank = $router->params['position'] + 1; // rank\n $new_parent = intval($router->params['parent']);",
" $db->decrement($page->tablename, 'rank', 1, 'rank>' . $old_rank . ' AND parent=' . $old_parent); // close in hole\n $db->increment($page->tablename, 'rank', 1, 'rank>=' . $new_rank . ' AND parent=' . $new_parent); // make room",
" $params = array();\n $params['parent'] = $new_parent;\n $params['rank'] = $new_rank;\n $page->update($params);",
" self::checkForSectionalAdmins($id);\n expSession::clearAllUsersSessionCache('navigation');\n }",
" function edit_section() {\n global $db, $user;",
" $parent = new section($this->params['parent']);\n if (empty($parent->id)) $parent->id = 0;\n assign_to_template(array(\n 'haveStandalone' => ($db->countObjects('section', 'parent=-1') && $parent->id >= 0),\n 'parent' => $parent,\n 'isAdministrator' => $user->isAdmin(),\n ));\n }",
" function edit_contentpage() {\n //FIXME we come here for new/edit content/standalone pages\n // FIXME: Allow non-administrative users to manage certain parts of the section hierarchy.\n //if ($user->is_acting_admin == 1 /*TODO: section admin*/) {\n// $section = null;\n $section = new stdClass();\n if (isset($this->params['id'])) {\n // Check to see if an id was passed in get. If so, retrieve that section from\n // the database, and perform an edit on it.\n $section = $this->section->find($this->params['id']);\n } elseif (isset($this->params['parent'])) {\n // The isset check is merely a precaution. This action should\n // ALWAYS be invoked with a parent or id value.\n $section = new section($this->params);\n } else {\n notfoundController::handle_not_found();\n exit;\n }\n if (!empty($section->id)) {\n $check_id = $section->id;\n } else {\n $check_id = $section->parent;\n }\n if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $check_id))) {\n if (empty($section->id)) {\n $section->active = 1;\n $section->public = 1;\n if (!isset($section->parent)) {\n // This is another precaution. The parent attribute\n // should ALWAYS be set by the caller.\n //FJD - if that's the case, then we should die.\n notfoundController::handle_not_authorized();\n exit;\n //$section->parent = 0;\n }\n }\n assign_to_template(array(\n 'section' => $section,\n 'glyphs' => self::get_glyphs(),\n ));\n } else { // User does not have permission to manage sections. Throw a 403\n notfoundController::handle_not_authorized();\n }\n }",
" private static function get_glyphs() {\n if (bs()) {\n require_once(BASE . 'external/font-awesome.class.php');\n $fa = new Smk_FontAwesome;\n if (bs3()) {\n $icons = $fa->getArray(BASE . 'external/font-awesome4/css/font-awesome.css');\n $icons = $fa->sortByName($icons);\n return $fa->nameGlyph($icons);\n } elseif (bs2()) {\n expCSS::auto_compile_less(\n 'external/font-awesome/less/font-awesome.less',\n 'external/font-awesome/css/font-awesome.css'\n ); // font-awesome is included within bootstrap2, but not as a separate .css file\n $icons = $fa->getArray(BASE . 'external/font-awesome/css/font-awesome.css', 'icon-');\n return $fa->nameGlyph($icons, 'icon-');\n }\n } else {\n return array();\n }\n }",
" function edit_internalalias() {\n $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);\n if ($section->parent == -1) {\n notfoundController::handle_not_found();\n exit;\n } // doesn't work for standalone pages\n if (empty($section->id)) {\n $section->public = 1;\n if (!isset($section->parent)) {\n // This is another precaution. The parent attribute\n // should ALWAYS be set by the caller.\n //FJD - if that's the case, then we should die.\n notfoundController::handle_not_authorized();\n exit;\n //$section->parent = 0;\n }\n }\n assign_to_template(array(\n 'section' => $section,\n 'glyphs' => self::get_glyphs(),\n ));\n }",
" function edit_freeform() {\n $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);\n if ($section->parent == -1) {\n notfoundController::handle_not_found();\n exit;\n } // doesn't work for standalone pages\n if (empty($section->id)) {\n $section->public = 1;\n if (!isset($section->parent)) {\n // This is another precaution. The parent attribute\n // should ALWAYS be set by the caller.\n //FJD - if that's the case, then we should die.\n notfoundController::handle_not_authorized();\n exit;\n //$section->parent = 0;\n }\n }\n assign_to_template(array(\n 'section' => $section,\n 'glyphs' => self::get_glyphs(),\n ));\n }",
" function edit_externalalias() {\n $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);\n if ($section->parent == -1) {\n notfoundController::handle_not_found();\n exit;\n } // doesn't work for standalone pages\n if (empty($section->id)) {\n $section->public = 1;\n if (!isset($section->parent)) {\n // This is another precaution. The parent attribute\n // should ALWAYS be set by the caller.\n //FJD - if that's the case, then we should die.\n notfoundController::handle_not_authorized();\n exit;\n //$section->parent = 0;\n }\n }\n assign_to_template(array(\n 'section' => $section,\n 'glyphs' => self::get_glyphs(),\n ));\n }",
" function update() {\n parent::update();\n expSession::clearAllUsersSessionCache('navigation');\n }",
" function move_standalone() {\n expSession::clearAllUsersSessionCache('navigation');\n assign_to_template(array(\n 'parent' => $this->params['parent'],\n ));\n }",
" /**\n * Move standalone back to hierarchy\n *\n */\n function reparent_standalone() {\n $standalone = $this->section->find($this->params['page']);\n if ($standalone) {\n $standalone->parent = $this->params['parent'];\n $standalone->update();\n expSession::clearAllUsersSessionCache('navigation');\n expHistory::back();\n } else {\n notfoundController::handle_not_found();\n }\n }",
" /**\n * Move content page to standalones\n *\n */\n function remove() {\n global $db;",
" $section = $db->selectObject('section', 'id=' . $this->params['id']);\n if ($section) {\n section::removeLevel($section->id);\n $db->decrement('section', 'rank', 1, 'rank > ' . $section->rank . ' AND parent=' . $section->parent);\n $section->parent = -1;\n $db->updateObject($section, 'section');\n expSession::clearAllUsersSessionCache('navigation');\n expHistory::back();\n } else {\n notfoundController::handle_not_authorized();\n }\n }",
" function delete_standalones() {\n if (!empty($this->params['deleteit'])) {\n foreach ($this->params['deleteit'] as $page) {\n $section = new section(intval($page));\n if ($section) {\n// self::deleteLevel($section->id);\n $section->delete();\n }\n }\n }\n expSession::clearAllUsersSessionCache('navigation');\n expHistory::back();\n }",
" /**\n * permission functions to aggregate a module's visible permissions based on add/remove permissions\n *\n * @return array\n */\n public function permissions() {\n //set the permissions array\n return $this->add_permissions;\n }",
" // create a psuedo global manage pages permission\n public static function checkPermissions($permission,$location) {\n global $exponent_permissions_r, $router;",
" // only applies to the 'manage' method\n if (empty($location->src) && empty($location->int) && ((!empty($router->params['action']) && $router->params['action'] == 'manage') || strpos($router->current_url, 'action=manage') !== false)) {\n if (!empty($exponent_permissions_r['navigation'])) foreach ($exponent_permissions_r['navigation'] as $page) {\n foreach ($page as $pageperm) {\n if (!empty($pageperm['manage'])) return true;\n }\n }\n }\n return false;\n }",
" /**\n * Rebuild the sectionref table as a list of modules on a page\n * @deprecated 2.3.4 moved to sectionref model\n */\n public static function rebuild_sectionrefs() {\n global $db;",
" // recursive run though all the nested containers\n function scan_container($container_id, $page_id) {\n global $db;",
" $containers = $db->selectObjects('container',\"external='\" . $container_id . \"'\");\n $ret = '';\n foreach ($containers as $container) {\n $iLoc = expUnserialize($container->internal);\n $newret = recyclebin::restoreFromRecycleBin($iLoc, $page_id);\n if (!empty($newret)) $ret .= $newret . '<br>';\n if ($iLoc->mod == 'container') {\n $ret .= scan_container($container->internal, $page_id);\n }\n }\n return $ret;\n }",
" // recursive run through all the nested pages\n function scan_page($parent_id) {\n global $db;",
" $sections = $db->selectObjects('section','parent=' . $parent_id);\n $ret = '';\n foreach ($sections as $page) {\n $cLoc = serialize(expCore::makeLocation('container','@section' . $page->id));\n $ret .= scan_container($cLoc, $page->id);\n $ret .= scan_page($page->id);\n }\n return $ret;\n }",
" // first remove duplicate records\n $db->sql('DELETE FROM ' . $db->prefix . 'sectionref WHERE id NOT IN (SELECT * FROM (SELECT MIN(n.id) FROM ' . $db->prefix . 'sectionref n GROUP BY n.module, n.source) x)');\n $ret = scan_page(0); // the page hierarchy\n $ret .= scan_page(-1); // now the stand alone pages",
" // we need to get the non-main containers such as sidebars, footers, etc...\n $hardcodedmods = $db->selectObjects('sectionref',\"refcount=1000 AND source NOT LIKE '%@section%' AND source NOT LIKE '%@random%'\");\n foreach ($hardcodedmods as $hardcodedmod) {\n if ($hardcodedmod->module == 'container') {\n $page_id = intval(preg_replace('/\\D/', '', $hardcodedmod->source));\n if (empty($page_id)) {\n $page_id = SITE_DEFAULT_SECTION; // we'll default to the home page\n }\n $ret .= scan_container(serialize(expCore::makeLocation($hardcodedmod->module, $hardcodedmod->source)), $page_id);\n } else {\n $hardcodedmod->section = 0; // this is a hard-coded non-container module\n $db->updateObject($hardcodedmod, 'sectionref');\n }\n }",
" // mark modules in the recycle bin as section 0\n $db->columnUpdate('sectionref', 'section', 0, \"refcount=0\");\n// $recycledmods = $db->selectObjects('sectionref',\"refcount=0\");\n// foreach ($recycledmods as $recycledmod) {\n// $recycledmod->section = 0; // this is a module in the recycle bin\n// $db->updateObject($recycledmod, 'sectionref');\n// }\n return $ret;\n }",
"}\n",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class newsController extends expController {\n public $useractions = array(\n 'showall'=>'Show all News',\n 'tags'=>\"Tags\",\n );",
"",
" public $remove_configs = array(\n 'categories',\n 'comments',\n// 'ealerts',\n// 'facebook',\n// 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" protected $add_permissions = array(\n 'showUnpublished'=>'View Unpublished News',\n 'import'=>'Import News Items',\n 'export'=>'Export News Items'\n );",
"\n static function displayname() { return gt(\"News\"); }\n static function description() { return gt(\"Display & manage news type content on your site.\"); }\n static function isSearchable() { return true; }",
" static function canImportData() {\n return true;\n }",
" static function canExportData() {\n return true;\n }",
" public function showall() {\n expHistory::set('viewable', $this->params);\n // figure out if should limit the results\n if (isset($this->params['limit'])) {\n $limit = $this->params['limit'] == 'none' ? null : $this->params['limit'];\n } else {\n $limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;",
" } ",
" $order = isset($this->config['order']) ? $this->config['order'] : 'publish DESC';",
" // pull the news posts from the database\n $items = $this->news->find('all', $this->aggregateWhereClause(), $order);",
" // merge in any RSS news and perform the sort and limit the number of posts we return to the configured amount.\n if (!empty($this->config['pull_rss'])) $items = $this->mergeRssData($items);",
" ",
" // setup the pagination object to paginate the news stories.\n $page = new expPaginator(array(\n 'records'=>$items,\n 'limit'=>$limit,\n 'order'=>$order,\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'view'=>empty($this->params['view']) ? null : $this->params['view']\n ));",
" ",
" assign_to_template(array(\n 'page'=>$page,\n 'items'=>$page->records,\n 'rank'=>($order==='rank')?1:0,\n 'params'=>$this->params,\n ));\n }",
" public function showall_by_date() {\n\t expHistory::set('viewable', $this->params);\n if (!empty($this->params['day'])) {\n $start_date = expDateTime::startOfDayTimestamp(mktime(0, 0, 0, $this->params['month'], $this->params['day'], $this->params['year']));\n $end_date = expDateTime::endOfDayTimestamp(mktime(23, 59, 59, $this->params['month'], $this->params['day'], $this->params['year']));\n $format_date = DISPLAY_DATE_FORMAT;\n } elseif (!empty($this->params['month'])) {\n $start_date = expDateTime::startOfMonthTimestamp(mktime(0, 0, 0, $this->params['month'], 1, $this->params['year']));\n $end_date = expDateTime::endOfMonthTimestamp(mktime(0, 0, 0, $this->params['month'], 1, $this->params['year']));\n $format_date = \"%B %Y\";\n } elseif (!empty($this->params['year'])) {\n $start_date = expDateTime::startOfYearTimestamp(mktime(0, 0, 0, 1, 1, $this->params['year']));\n $end_date = expDateTime::endOfYearTimestamp(mktime(23, 59, 59, 12, 31, $this->params['year']));\n $format_date = \"%Y\";\n } else {\n exit();\n }",
"\t\t$page = new expPaginator(array(\n 'model'=>$this->basemodel_name,\n// 'where'=>($this->aggregateWhereClause()?$this->aggregateWhereClause().\" AND \":\"\").\"publish >= '\".$start_date.\"' AND publish <= '\".$end_date.\"'\",\n 'where'=>\"publish >= '\".$start_date.\"' AND publish <= '\".$end_date.\"'\",\n 'limit'=>isset($this->config['limit']) ? $this->config['limit'] : 10,\n 'order'=>'publish',\n 'dir'=>'desc',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));",
"\t\tassign_to_template(array(\n 'page'=>$page,\n 'moduletitle'=>gt('News for').' \"'.expDateTime::format_date($start_date,$format_date).'\"')\n );\n\t}",
" public function show() {\n expHistory::set('viewable', $this->params);\n // figure out if we're looking this up by id or title\n $id = null;\n if (isset($this->params['id'])) {\n $id = $this->params['id'];\n } elseif (isset($this->params['title'])) {",
" $id = $this->params['title'];",
" }",
" $record = new news($id);\n if (empty($record->id))\n redirect_to(array('controller'=>'notfound','action'=>'page_not_found','title'=>$this->params['title']));",
" $config = expConfig::getConfig($record->location_data);\n if (empty($this->config))\n $this->config = $config;\n if (empty($this->loc->src)) {\n $r_loc = expUnserialize($record->location_data);\n $this->loc->src = $r_loc->src;\n }",
" $order = !empty($config['order']) ? $config['order'] : 'publish DESC';\n if (strstr($order,\" \")) {\n $orderby = explode(\" \",$order);\n $order = $orderby[0];\n $order_direction = $orderby[1];\n } else {\n $order_direction = '';\n }\n if ($order_direction == 'DESC') {\n $order_direction_next = '';\n } else {\n $order_direction_next = 'DESC';\n }\n $nextwhere = $this->aggregateWhereClause().' AND '.$order.' > '.$record->$order.' ORDER BY '.$order.' '.$order_direction_next;\n $record->next = $record->find('first',$nextwhere);\n $prevwhere = $this->aggregateWhereClause().' AND '.$order.' < '.$record->$order.' ORDER BY '.$order.' '.$order_direction;\n $record->prev = $record->find('first',$prevwhere);",
" assign_to_template(array(\n 'record'=>$record,\n 'config'=>$config,\n 'params'=>$this->params\n ));\n }",
" public function showUnpublished() {\n expHistory::set('viewable', $this->params);",
" ",
" // setup the where clause for looking up records.\n $where = parent::aggregateWhereClause();\n $where = \"((unpublish != 0 AND unpublish < \".time().\") OR (publish > \".time().\")) AND \".$where;\n if (isset($this->config['only_featured'])) $where .= ' AND is_featured=1';",
" $page = new expPaginator(array(\n 'model'=>'news',\n 'where'=>$where,\n 'limit'=>25,\n 'order'=>'unpublish',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title',\n gt('Published On')=>'publish',\n gt('Status')=>'unpublish'\n ),\n ));",
" ",
" assign_to_template(array(\n 'page'=>$page\n ));\n }",
" ",
" public function showExpired() {\n redirect_to(array('controller'=>'news', 'action'=>'showUnpublished','src'=>$this->params['src']));\n }",
" ",
"// public function configure() {\n// parent::configure();\n// assign_to_template(array('sortopts'=>$this->sortopts));\n// }",
" \n public function saveConfig() { ",
" if (!empty($this->params['aggregate']) || !empty($this->params['pull_rss'])) {\n if ($this->params['order'] == 'rank ASC') {\n expValidator::failAndReturnToForm(gt('User defined ranking is not allowed when aggregating or pull RSS data feeds.'), $this->params);\n }\n }",
" \n parent::saveConfig();\n }\n ",
" public function getRSSContent($limit = 0) {\n // pull the news posts from the database\n $items = $this->news->find('all', $this->aggregateWhereClause(), isset($this->config['order']) ? $this->config['order'] : 'publish DESC', $limit);",
" //Convert the newsitems to rss items\n $rssitems = array();",
" foreach ($items as $key => $item) { ",
" $rss_item = new FeedItem();\n $rss_item->title = expString::convertSmartQuotes($item->title);\n $rss_item->link = $rss_item->guid = makeLink(array('controller'=>'news', 'action'=>'show', 'title'=>$item->sef_url));\n $rss_item->description = expString::convertSmartQuotes($item->body);\n $rss_item->author = user::getUserById($item->poster)->firstname.' '.user::getUserById($item->poster)->lastname;\n $rss_item->authorEmail = user::getEmailById($item->poster);\n// $rss_item->date = date(DATE_RSS,$item->publish_date);\n $rss_item->date = $item->publish_date;\n $rssitems[$key] = $rss_item;",
" if ($limit && count($rssitems) >= $limit)\n break;\n }\n return $rssitems;\n }",
" /**\n * Pull RSS Feed and display as news items\n *\n * @param $items\n * @return array\n */\n private function mergeRssData($items) {",
" if (!empty($this->config['pull_rss'])) { ",
" $RSS = new SimplePie();\n\t $RSS->set_cache_location(BASE.'tmp/rsscache'); // default is ./cache\n//\t $RSS->set_cache_duration(3600); // default is 3600\n\t $RSS->set_timeout(20); // default is 10\n//\t $RSS->set_output_encoding('UTF-8'); // default is UTF-8\n $news = array();\n foreach($this->config['pull_rss'] as $url) {\n $RSS->set_feed_url($url);\n $feed = $RSS->init();\n if (!$feed) {\n // an error occurred in the rss.\n continue;\n }\n\t $RSS->handle_content_type();\n foreach ($RSS->get_items() as $rssItem) {\n $rssObject = new stdClass();\n $rssObject->title = $rssItem->get_title();\n $rssObject->body = $rssItem->get_description();\n $rssObject->rss_link = $rssItem->get_permalink();\n $rssObject->publish = $rssItem->get_date('U');\n $rssObject->publish_date = $rssItem->get_date('U');\n $rssObject->poster = $rssItem->get_author()->get_name();\n $rssObject->isRss = true;\n\t\t\t\t\t$t = explode(' • ',$rssObject->title);\n\t\t\t\t\t$rssObject->forum = $t[0];\n\t\t\t\t\tif (!empty($t[1])) {\n $rssObject->topic = $t[1];\n } else {\n $t = explode(' • ',$rssObject->title);\n $rssObject->forum = $t[0];\n if (!empty($t[1])) {\n $rssObject->topic = $t[1];\n }\n }\n $news[] = $rssObject;\n }\n }\n $items = array_merge($items, $news);\n }\n return $items;\n }",
" /**\n * additional check for display of search hit, only display published\n *\n * @param $record\n *\n * @return bool\n */\n public static function searchHit($record) {\n $news = new news($record->original_id);\n if (expPermissions::check('showUnpublished', expUnserialize($record->location_data)) || ($news->publish == 0 || $news->publish <= time()) && ($news->unpublish == 0 || $news->unpublish > time())) {\n return true;\n } else {\n return false;\n }\n }",
" private function sortDescending($a,$b) {\n return ($a->publish_date > $b->publish_date ? -1 : 1);\n }",
" private function sortAscending($a,$b) {\n return ($a->publish_date < $b->publish_date ? -1 : 1);\n }",
" /**\n * The aggregateWhereClause function creates a sql where clause which also includes aggregated module content\n *\n * @param string $type\n *\n * @return string\n */\n \tfunction aggregateWhereClause($type='') {\n $sql = parent::aggregateWhereClause();\n $sql = \"(publish = 0 or publish <= \" . time() . \") AND (unpublish=0 OR unpublish > \".time().\") AND \".$sql;\n if (isset($this->config['only_featured'])) $sql .= ' AND is_featured=1';",
" return $sql;\n }",
" /**\n * Returns Facebook og: meta data\n *\n * @param $request\n * @param $object\n *\n * @return null\n */\n public function meta_fb($request, $object, $canonical) {\n $metainfo = array();\n $metainfo['type'] = 'article';\n if (!empty($object->body)) {\n $desc = str_replace('\"',\"'\",expString::summarize($object->body,'html','para'));\n } else {\n $desc = SITE_DESCRIPTION;\n }\n $metainfo['title'] = substr(empty($object->meta_fb['title']) ? $object->title : $object->meta_fb['title'], 0, 87);\n $metainfo['description'] = substr(empty($object->meta_fb['description']) ? $desc : $object->meta_fb['description'], 0, 199);\n $metainfo['url'] = empty($object->meta_fb['url']) ? $canonical : $object->meta_fb['url'];\n $metainfo['image'] = empty($object->meta_fb['fbimage'][0]) ? '' : $object->meta_fb['fbimage'][0]->url;\n if (empty($metainfo['image'])) {\n if (!empty($object->expFile['images'][0]->is_image)) {\n $metainfo['image'] = $object->expFile['images'][0]->url;\n } else {\n $config = expConfig::getConfig($object->location_data);\n if (!empty($config['expFile']['fbimage'][0]))\n $file = new expFile($config['expFile']['fbimage'][0]);\n if (!empty($file->id))\n $metainfo['image'] = $file->url;\n if (empty($metainfo['image']))\n $metainfo['image'] = URL_BASE . MIMEICON_RELATIVE . 'generic_22x22.png';\n }\n }\n return $metainfo;\n }",
" /**\n * Returns Twitter twitter: meta data\n *\n * @param $request\n * @param $object\n *\n * @return null\n */\n public function meta_tw($request, $object, $canonical) {\n $metainfo = array();\n $metainfo['card'] = 'summary';\n if (!empty($object->body)) {\n $desc = str_replace('\"',\"'\",expString::summarize($object->body,'html','para'));\n } else {\n $desc = SITE_DESCRIPTION;\n }\n $config = expConfig::getConfig($object->location_data);\n if (!empty($object->meta_tw['twsite'])) {\n $metainfo['site'] = $object->meta_tw['twsite'];\n } elseif (!empty($config['twsite'])) {\n $metainfo['site'] = $config['twsite'];\n }\n $metainfo['title'] = substr(empty($object->meta_tw['title']) ? $object->title : $object->meta_tw['title'], 0, 87);\n $metainfo['description'] = substr(empty($object->meta_tw['description']) ? $desc : $object->meta_tw['description'], 0, 199);\n $metainfo['image'] = empty($object->meta_tw['twimage'][0]) ? '' : $object->meta_tw['twimage'][0]->url;\n if (empty($metainfo['image'])) {\n if (!empty($object->expFile['images'][0]->is_image)) {\n $metainfo['image'] = $object->expFile['images'][0]->url;\n } else {\n if (!empty($config['expFile']['twimage'][0]))\n $file = new expFile($config['expFile']['twimage'][0]);\n if (!empty($file->id))\n $metainfo['image'] = $file->url;\n if (empty($metainfo['image']))\n $metainfo['image'] = URL_BASE . MIMEICON_RELATIVE . 'generic_22x22.png';\n }\n }\n return $metainfo;\n }",
"// function import() {\n// $pullable_modules = expModules::listInstalledControllers('news');\n// $modules = new expPaginator(array(\n// 'records' => $pullable_modules,\n// 'controller' => $this->loc->mod,\n// 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\n// 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\n// 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n// 'columns' => array(\n// gt('Title') => 'title',\n// gt('Page') => 'section'\n// ),\n// ));\n//\n// assign_to_template(array(\n// 'modules' => $modules,\n// ));\n// }\n//\n// function import_select() {\n// //Get the temp directory to put the uploaded file\n// $directory = \"tmp\";\n//\n// //Get the file save it to the temp directory\n// if ($_FILES[\"import_file\"][\"error\"] == UPLOAD_ERR_OK) {\n// $file = expFile::fileUpload(\"import_file\", false, false, time() . \"_\" . $_FILES['import_file']['name'], $directory.'/');\n// if ($file == null) {\n// switch ($_FILES[\"import_file\"][\"error\"]) {\n// case UPLOAD_ERR_INI_SIZE:\n// case UPLOAD_ERR_FORM_SIZE:\n// $this->params['_formError'] = gt('The file you attempted to upload is too large. Contact your system administrator if this is a problem.');\n// break;\n// case UPLOAD_ERR_PARTIAL:\n// $this->params['_formError'] = gt('The file was only partially uploaded.');\n// break;\n// case UPLOAD_ERR_NO_FILE:\n// $this->params['_formError'] = gt('No file was uploaded.');\n// break;\n// default:\n// $this->params['_formError'] = gt('A strange internal error has occurred. Please contact the Exponent Developers.');\n// break;\n// }\n// expSession::set(\"last_POST\", $this->params);\n// header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n// exit(\"\");\n// } else {\n// $errors = array();\n// $data = expFile::parseDatabase(BASE . $directory . \"/\" . $file->filename, $errors, 'news');\n// if (!empty($errors)) {\n// $message = gt('Importing encountered the following errors') . ':<br>';\n// foreach ($errors as $error) {\n// $message .= '* ' . $error . '<br>';\n// }\n// flash('error', $message);\n// }\n//\n// assign_to_template(array(\n// 'items' => $data['news']->records,\n// 'filename' => $directory . \"/\" . $file->filename,\n// 'source' => $this->params['aggregate'][0]\n// ));\n// }\n// }\n// }\n//\n// function import_process() {\n// $filename = $this->params['filename'];\n// $src = $this->params['source'];\n// $selected = $this->params['items'];\n// $errors = array();\n// $data = expFile::parseDatabase(BASE . $filename, $errors, 'news');\n// foreach ($selected as $select) {\n// $item = new news();\n// foreach ($data['news']->records[$select] as $key => $value) {\n// if ($key != 'id' && $key != 'location_data') {\n// $item->$key = $value;\n// }\n// }\n// $item->id = null;\n// $item->rank = null;\n// $item->location_data = serialize(expCore::makeLocation('news', $src));\n// $item->save();\n// }\n// flash('message', count($selected) . ' ' . gt('News items were imported.'));\n// expHistory::back();\n// }\n//\n// function export() {\n// $pullable_modules = expModules::listInstalledControllers('news');\n// $modules = new expPaginator(array(\n// 'records' => $pullable_modules,\n// 'controller' => $this->loc->mod,\n// 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\n// 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\n// 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n// 'columns' => array(\n// gt('Title') => 'title',\n// gt('Page') => 'section'\n// ),\n// ));\n// assign_to_template(array(\n// 'modules' => $modules,\n// ));\n// }\n//\n// function export_process() {\n// if (!empty($this->params['aggregate'])) {\n// $selected = $this->params['aggregate'];\n// $where = '(';\n// foreach ($selected as $key=>$src) {\n// if ($key) $where .= ' OR ';\n// $where .= \"location_data='\" . serialize(expCore::makeLocation('news', $src)) . \"'\";\n// }\n// $where .= ')';\n//\n// $filename = 'news.eql';\n//\n// ob_end_clean();\n// ob_start(\"ob_gzhandler\");\n//\n// // 'application/octet-stream' is the registered IANA type but\n// // MSIE and Opera seems to prefer 'application/octetstream'\n// $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';\n//\n// header('Content-Type: ' . $mime_type);\n// header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n// // IE need specific headers\n// if (EXPONENT_USER_BROWSER == 'IE') {\n// header('Content-Disposition: inline; filename=\"' . $filename . '\"');\n// header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n// header('Pragma: public');\n// } else {\n// header('Content-Disposition: attachment; filename=\"' . $filename . '\"');\n// header('Pragma: no-cache');\n// }\n// echo expFile::dumpDatabase('news', 'export', $where);\n// exit; // Exit, since we are exporting\n// }\n// expHistory::back();\n// }",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class newsController extends expController {\n public $useractions = array(\n 'showall'=>'Show all News',\n 'tags'=>\"Tags\",\n );",
" protected $add_permissions = array(\n 'showUnpublished'=>'View Unpublished News',\n 'showExpired'=>'View Unpublished News',\n );\n protected $manage_permissions = array(\n 'import'=>'Import News Items',\n 'export'=>'Export News Items'\n );",
" public $remove_configs = array(\n 'categories',\n 'comments',\n// 'ealerts',\n// 'facebook',\n// 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
"",
"\n static function displayname() { return gt(\"News\"); }\n static function description() { return gt(\"Display & manage news type content on your site.\"); }\n static function isSearchable() { return true; }",
" static function canImportData() {\n return true;\n }",
" static function canExportData() {\n return true;\n }",
" public function showall() {\n expHistory::set('viewable', $this->params);\n // figure out if should limit the results\n if (isset($this->params['limit'])) {\n $limit = $this->params['limit'] == 'none' ? null : $this->params['limit'];\n } else {\n $limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;",
" }",
" $order = isset($this->config['order']) ? $this->config['order'] : 'publish DESC';",
" // pull the news posts from the database\n $items = $this->news->find('all', $this->aggregateWhereClause(), $order);",
" // merge in any RSS news and perform the sort and limit the number of posts we return to the configured amount.\n if (!empty($this->config['pull_rss'])) $items = $this->mergeRssData($items);",
"",
" // setup the pagination object to paginate the news stories.\n $page = new expPaginator(array(\n 'records'=>$items,\n 'limit'=>$limit,\n 'order'=>$order,\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'view'=>empty($this->params['view']) ? null : $this->params['view']\n ));",
"",
" assign_to_template(array(\n 'page'=>$page,\n 'items'=>$page->records,\n 'rank'=>($order==='rank')?1:0,\n 'params'=>$this->params,\n ));\n }",
" public function showall_by_date() {\n\t expHistory::set('viewable', $this->params);\n if (!empty($this->params['day'])) {\n $start_date = expDateTime::startOfDayTimestamp(mktime(0, 0, 0, $this->params['month'], $this->params['day'], $this->params['year']));\n $end_date = expDateTime::endOfDayTimestamp(mktime(23, 59, 59, $this->params['month'], $this->params['day'], $this->params['year']));\n $format_date = DISPLAY_DATE_FORMAT;\n } elseif (!empty($this->params['month'])) {\n $start_date = expDateTime::startOfMonthTimestamp(mktime(0, 0, 0, $this->params['month'], 1, $this->params['year']));\n $end_date = expDateTime::endOfMonthTimestamp(mktime(0, 0, 0, $this->params['month'], 1, $this->params['year']));\n $format_date = \"%B %Y\";\n } elseif (!empty($this->params['year'])) {\n $start_date = expDateTime::startOfYearTimestamp(mktime(0, 0, 0, 1, 1, $this->params['year']));\n $end_date = expDateTime::endOfYearTimestamp(mktime(23, 59, 59, 12, 31, $this->params['year']));\n $format_date = \"%Y\";\n } else {\n exit();\n }",
"\t\t$page = new expPaginator(array(\n 'model'=>$this->basemodel_name,\n// 'where'=>($this->aggregateWhereClause()?$this->aggregateWhereClause().\" AND \":\"\").\"publish >= '\".$start_date.\"' AND publish <= '\".$end_date.\"'\",\n 'where'=>\"publish >= '\".$start_date.\"' AND publish <= '\".$end_date.\"'\",\n 'limit'=>isset($this->config['limit']) ? $this->config['limit'] : 10,\n 'order'=>'publish',\n 'dir'=>'desc',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));",
"\t\tassign_to_template(array(\n 'page'=>$page,\n 'moduletitle'=>gt('News for').' \"'.expDateTime::format_date($start_date,$format_date).'\"')\n );\n\t}",
" public function show() {\n expHistory::set('viewable', $this->params);\n // figure out if we're looking this up by id or title\n $id = null;\n if (isset($this->params['id'])) {\n $id = $this->params['id'];\n } elseif (isset($this->params['title'])) {",
" $id = expString::escape($this->params['title']);",
" }",
" $record = new news($id);\n if (empty($record->id))\n redirect_to(array('controller'=>'notfound','action'=>'page_not_found','title'=>$this->params['title']));",
" $config = expConfig::getConfig($record->location_data);\n if (empty($this->config))\n $this->config = $config;\n if (empty($this->loc->src)) {\n $r_loc = expUnserialize($record->location_data);\n $this->loc->src = $r_loc->src;\n }",
" $order = !empty($config['order']) ? $config['order'] : 'publish DESC';\n if (strstr($order,\" \")) {\n $orderby = explode(\" \",$order);\n $order = $orderby[0];\n $order_direction = $orderby[1];\n } else {\n $order_direction = '';\n }\n if ($order_direction == 'DESC') {\n $order_direction_next = '';\n } else {\n $order_direction_next = 'DESC';\n }\n $nextwhere = $this->aggregateWhereClause().' AND '.$order.' > '.$record->$order.' ORDER BY '.$order.' '.$order_direction_next;\n $record->next = $record->find('first',$nextwhere);\n $prevwhere = $this->aggregateWhereClause().' AND '.$order.' < '.$record->$order.' ORDER BY '.$order.' '.$order_direction;\n $record->prev = $record->find('first',$prevwhere);",
" assign_to_template(array(\n 'record'=>$record,\n 'config'=>$config,\n 'params'=>$this->params\n ));\n }",
" public function showUnpublished() {\n expHistory::set('viewable', $this->params);",
"",
" // setup the where clause for looking up records.\n $where = parent::aggregateWhereClause();\n $where = \"((unpublish != 0 AND unpublish < \".time().\") OR (publish > \".time().\")) AND \".$where;\n if (isset($this->config['only_featured'])) $where .= ' AND is_featured=1';",
" $page = new expPaginator(array(\n 'model'=>'news',\n 'where'=>$where,\n 'limit'=>25,\n 'order'=>'unpublish',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title',\n gt('Published On')=>'publish',\n gt('Status')=>'unpublish'\n ),\n ));",
"",
" assign_to_template(array(\n 'page'=>$page\n ));\n }",
"",
" public function showExpired() {\n redirect_to(array('controller'=>'news', 'action'=>'showUnpublished','src'=>$this->params['src']));\n }",
"",
"// public function configure() {\n// parent::configure();\n// assign_to_template(array('sortopts'=>$this->sortopts));\n// }",
"\n public function saveconfig() {",
" if (!empty($this->params['aggregate']) || !empty($this->params['pull_rss'])) {\n if ($this->params['order'] == 'rank ASC') {\n expValidator::failAndReturnToForm(gt('User defined ranking is not allowed when aggregating or pull RSS data feeds.'), $this->params);\n }\n }",
"\n parent::saveconfig();\n }\n",
" public function getRSSContent($limit = 0) {\n // pull the news posts from the database\n $items = $this->news->find('all', $this->aggregateWhereClause(), isset($this->config['order']) ? $this->config['order'] : 'publish DESC', $limit);",
" //Convert the newsitems to rss items\n $rssitems = array();",
" foreach ($items as $key => $item) {",
" $rss_item = new FeedItem();\n $rss_item->title = expString::convertSmartQuotes($item->title);\n $rss_item->link = $rss_item->guid = makeLink(array('controller'=>'news', 'action'=>'show', 'title'=>$item->sef_url));\n $rss_item->description = expString::convertSmartQuotes($item->body);\n $rss_item->author = user::getUserById($item->poster)->firstname.' '.user::getUserById($item->poster)->lastname;\n $rss_item->authorEmail = user::getEmailById($item->poster);\n// $rss_item->date = date(DATE_RSS,$item->publish_date);\n $rss_item->date = $item->publish_date;\n $rssitems[$key] = $rss_item;",
" if ($limit && count($rssitems) >= $limit)\n break;\n }\n return $rssitems;\n }",
" /**\n * Pull RSS Feed and display as news items\n *\n * @param $items\n * @return array\n */\n private function mergeRssData($items) {",
" if (!empty($this->config['pull_rss'])) {",
" $RSS = new SimplePie();\n\t $RSS->set_cache_location(BASE.'tmp/rsscache'); // default is ./cache\n//\t $RSS->set_cache_duration(3600); // default is 3600\n\t $RSS->set_timeout(20); // default is 10\n//\t $RSS->set_output_encoding('UTF-8'); // default is UTF-8\n $news = array();\n foreach($this->config['pull_rss'] as $url) {\n $RSS->set_feed_url($url);\n $feed = $RSS->init();\n if (!$feed) {\n // an error occurred in the rss.\n continue;\n }\n\t $RSS->handle_content_type();\n foreach ($RSS->get_items() as $rssItem) {\n $rssObject = new stdClass();\n $rssObject->title = $rssItem->get_title();\n $rssObject->body = $rssItem->get_description();\n $rssObject->rss_link = $rssItem->get_permalink();\n $rssObject->publish = $rssItem->get_date('U');\n $rssObject->publish_date = $rssItem->get_date('U');\n $rssObject->poster = $rssItem->get_author()->get_name();\n $rssObject->isRss = true;\n\t\t\t\t\t$t = explode(' • ',$rssObject->title);\n\t\t\t\t\t$rssObject->forum = $t[0];\n\t\t\t\t\tif (!empty($t[1])) {\n $rssObject->topic = $t[1];\n } else {\n $t = explode(' • ',$rssObject->title);\n $rssObject->forum = $t[0];\n if (!empty($t[1])) {\n $rssObject->topic = $t[1];\n }\n }\n $news[] = $rssObject;\n }\n }\n $items = array_merge($items, $news);\n }\n return $items;\n }",
" /**\n * additional check for display of search hit, only display published\n *\n * @param $record\n *\n * @return bool\n */\n public static function searchHit($record) {\n $news = new news($record->original_id);\n if (expPermissions::check('showUnpublished', expUnserialize($record->location_data)) || ($news->publish == 0 || $news->publish <= time()) && ($news->unpublish == 0 || $news->unpublish > time())) {\n return true;\n } else {\n return false;\n }\n }",
" private function sortDescending($a,$b) {\n return ($a->publish_date > $b->publish_date ? -1 : 1);\n }",
" private function sortAscending($a,$b) {\n return ($a->publish_date < $b->publish_date ? -1 : 1);\n }",
" /**\n * The aggregateWhereClause function creates a sql where clause which also includes aggregated module content\n *\n * @param string $type\n *\n * @return string\n */\n \tfunction aggregateWhereClause($type='') {\n $sql = parent::aggregateWhereClause();\n $sql = \"(publish = 0 or publish <= \" . time() . \") AND (unpublish=0 OR unpublish > \".time().\") AND \".$sql;\n if (isset($this->config['only_featured'])) $sql .= ' AND is_featured=1';",
" return $sql;\n }",
" /**\n * Returns Facebook og: meta data\n *\n * @param $request\n * @param $object\n *\n * @return null\n */\n public function meta_fb($request, $object, $canonical) {\n $metainfo = array();\n $metainfo['type'] = 'article';\n if (!empty($object->body)) {\n $desc = str_replace('\"',\"'\",expString::summarize($object->body,'html','para'));\n } else {\n $desc = SITE_DESCRIPTION;\n }\n $metainfo['title'] = substr(empty($object->meta_fb['title']) ? $object->title : $object->meta_fb['title'], 0, 87);\n $metainfo['description'] = substr(empty($object->meta_fb['description']) ? $desc : $object->meta_fb['description'], 0, 199);\n $metainfo['url'] = empty($object->meta_fb['url']) ? $canonical : $object->meta_fb['url'];\n $metainfo['image'] = empty($object->meta_fb['fbimage'][0]) ? '' : $object->meta_fb['fbimage'][0]->url;\n if (empty($metainfo['image'])) {\n if (!empty($object->expFile['images'][0]->is_image)) {\n $metainfo['image'] = $object->expFile['images'][0]->url;\n } else {\n $config = expConfig::getConfig($object->location_data);\n if (!empty($config['expFile']['fbimage'][0]))\n $file = new expFile($config['expFile']['fbimage'][0]);\n if (!empty($file->id))\n $metainfo['image'] = $file->url;\n if (empty($metainfo['image']))\n $metainfo['image'] = URL_BASE . MIMEICON_RELATIVE . 'generic_22x22.png';\n }\n }\n return $metainfo;\n }",
" /**\n * Returns Twitter twitter: meta data\n *\n * @param $request\n * @param $object\n *\n * @return null\n */\n public function meta_tw($request, $object, $canonical) {\n $metainfo = array();\n $metainfo['card'] = 'summary';\n if (!empty($object->body)) {\n $desc = str_replace('\"',\"'\",expString::summarize($object->body,'html','para'));\n } else {\n $desc = SITE_DESCRIPTION;\n }\n $config = expConfig::getConfig($object->location_data);\n if (!empty($object->meta_tw['twsite'])) {\n $metainfo['site'] = $object->meta_tw['twsite'];\n } elseif (!empty($config['twsite'])) {\n $metainfo['site'] = $config['twsite'];\n }\n $metainfo['title'] = substr(empty($object->meta_tw['title']) ? $object->title : $object->meta_tw['title'], 0, 87);\n $metainfo['description'] = substr(empty($object->meta_tw['description']) ? $desc : $object->meta_tw['description'], 0, 199);\n $metainfo['image'] = empty($object->meta_tw['twimage'][0]) ? '' : $object->meta_tw['twimage'][0]->url;\n if (empty($metainfo['image'])) {\n if (!empty($object->expFile['images'][0]->is_image)) {\n $metainfo['image'] = $object->expFile['images'][0]->url;\n } else {\n if (!empty($config['expFile']['twimage'][0]))\n $file = new expFile($config['expFile']['twimage'][0]);\n if (!empty($file->id))\n $metainfo['image'] = $file->url;\n if (empty($metainfo['image']))\n $metainfo['image'] = URL_BASE . MIMEICON_RELATIVE . 'generic_22x22.png';\n }\n }\n return $metainfo;\n }",
"// function import() {\n// $pullable_modules = expModules::listInstalledControllers('news');\n// $modules = new expPaginator(array(\n// 'records' => $pullable_modules,\n// 'controller' => $this->loc->mod,\n// 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\n// 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\n// 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n// 'columns' => array(\n// gt('Title') => 'title',\n// gt('Page') => 'section'\n// ),\n// ));\n//\n// assign_to_template(array(\n// 'modules' => $modules,\n// ));\n// }\n//\n// function import_select() {\n// //Get the temp directory to put the uploaded file\n// $directory = \"tmp\";\n//\n// //Get the file save it to the temp directory\n// if ($_FILES[\"import_file\"][\"error\"] == UPLOAD_ERR_OK) {\n// $file = expFile::fileUpload(\"import_file\", false, false, time() . \"_\" . $_FILES['import_file']['name'], $directory.'/');\n// if ($file == null) {\n// switch ($_FILES[\"import_file\"][\"error\"]) {\n// case UPLOAD_ERR_INI_SIZE:\n// case UPLOAD_ERR_FORM_SIZE:\n// $this->params['_formError'] = gt('The file you attempted to upload is too large. Contact your system administrator if this is a problem.');\n// break;\n// case UPLOAD_ERR_PARTIAL:\n// $this->params['_formError'] = gt('The file was only partially uploaded.');\n// break;\n// case UPLOAD_ERR_NO_FILE:\n// $this->params['_formError'] = gt('No file was uploaded.');\n// break;\n// default:\n// $this->params['_formError'] = gt('A strange internal error has occurred. Please contact the Exponent Developers.');\n// break;\n// }\n// expSession::set(\"last_POST\", $this->params);\n// header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n// exit(\"\");\n// } else {\n// $errors = array();\n// $data = expFile::parseDatabase(BASE . $directory . \"/\" . $file->filename, $errors, 'news');\n// if (!empty($errors)) {\n// $message = gt('Importing encountered the following errors') . ':<br>';\n// foreach ($errors as $error) {\n// $message .= '* ' . $error . '<br>';\n// }\n// flash('error', $message);\n// }\n//\n// assign_to_template(array(\n// 'items' => $data['news']->records,\n// 'filename' => $directory . \"/\" . $file->filename,\n// 'source' => $this->params['aggregate'][0]\n// ));\n// }\n// }\n// }\n//\n// function import_process() {\n// $filename = $this->params['filename'];\n// $src = $this->params['source'];\n// $selected = $this->params['items'];\n// $errors = array();\n// $data = expFile::parseDatabase(BASE . $filename, $errors, 'news');\n// foreach ($selected as $select) {\n// $item = new news();\n// foreach ($data['news']->records[$select] as $key => $value) {\n// if ($key != 'id' && $key != 'location_data') {\n// $item->$key = $value;\n// }\n// }\n// $item->id = null;\n// $item->rank = null;\n// $item->location_data = serialize(expCore::makeLocation('news', $src));\n// $item->save();\n// }\n// flash('message', count($selected) . ' ' . gt('News items were imported.'));\n// expHistory::back();\n// }\n//\n// function export() {\n// $pullable_modules = expModules::listInstalledControllers('news');\n// $modules = new expPaginator(array(\n// 'records' => $pullable_modules,\n// 'controller' => $this->loc->mod,\n// 'order' => isset($this->params['order']) ? $this->params['order'] : 'section',\n// 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '',\n// 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n// 'columns' => array(\n// gt('Title') => 'title',\n// gt('Page') => 'section'\n// ),\n// ));\n// assign_to_template(array(\n// 'modules' => $modules,\n// ));\n// }\n//\n// function export_process() {\n// if (!empty($this->params['aggregate'])) {\n// $selected = $this->params['aggregate'];\n// $where = '(';\n// foreach ($selected as $key=>$src) {\n// if ($key) $where .= ' OR ';\n// $where .= \"location_data='\" . serialize(expCore::makeLocation('news', $src)) . \"'\";\n// }\n// $where .= ')';\n//\n// $filename = 'news.eql';\n//\n// ob_end_clean();\n// ob_start(\"ob_gzhandler\");\n//\n// // 'application/octet-stream' is the registered IANA type but\n// // MSIE and Opera seems to prefer 'application/octetstream'\n// $mime_type = (EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA') ? 'application/octetstream' : 'application/octet-stream';\n//\n// header('Content-Type: ' . $mime_type);\n// header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n// // IE need specific headers\n// if (EXPONENT_USER_BROWSER == 'IE') {\n// header('Content-Disposition: inline; filename=\"' . $filename . '\"');\n// header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\n// header('Pragma: public');\n// } else {\n// header('Content-Disposition: attachment; filename=\"' . $filename . '\"');\n// header('Pragma: no-cache');\n// }\n// echo expFile::dumpDatabase('news', 'export', $where);\n// exit; // Exit, since we are exporting\n// }\n// expHistory::back();\n// }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class photosController extends expController {\n public $basemodel_name = 'photo';\n// public $useractions = array(\n// 'showall'=>'Gallery',\n// 'slideshow'=>'Slideshow',\n// //'showall_tags'=>\"Tag Categories\"\n// );",
"",
" public $remove_configs = array(\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'pagination', // we need to customize it in this module?\n 'rss',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" static function displayname() { return gt(\"Photo Album\"); }\n static function description() { return gt(\"Displays and manages images.\"); }\n static function isSearchable() { return true; }",
" ",
" public function showall() {\n expHistory::set('viewable', $this->params);\n $limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;\n if (!empty($this->params['view']) && ($this->params['view'] == 'showall_accordion' || $this->params['view'] == 'showall_tabbed')) {\n $limit = '0';\n }\n $order = isset($this->config['order']) ? $this->config['order'] : \"rank\";\n $page = new expPaginator(array(\n 'model'=>'photo',\n 'where'=>$this->aggregateWhereClause(),\n 'limit'=>$limit,\n 'order'=>$order,\n 'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],\n 'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),\n 'groups'=>!isset($this->params['gallery']) ? array() : array($this->params['gallery']),\n 'grouplimit'=>!empty($this->params['view']) && $this->params['view'] == 'showall_galleries' ? 1 : null,\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));",
" ",
" assign_to_template(array(\n 'page'=>$page,\n 'params'=>$this->params,\n ));\n }",
" ",
" function show() {\n expHistory::set('viewable', $this->params);",
" ",
" // figure out if we're looking this up by id or title\n $id = null;\n if (isset($this->params['id'])) {\n $id = $this->params['id'];\n } elseif (isset($this->params['title'])) {",
" $id = $this->params['title'];",
" }\n $record = new photo($id);\n if (empty($record->id))\n redirect_to(array('controller'=>'notfound','action'=>'page_not_found','title'=>$this->params['title']));",
" $config = expConfig::getConfig($record->location_data);\n if (empty($this->config))\n $this->config = $config;\n if (empty($this->loc->src)) {\n $r_loc = expUnserialize($record->location_data);\n $this->loc->src = $r_loc->src;\n }",
" $where = $this->aggregateWhereClause();\n// $maxrank = $db->max($this->model_table,'rank','',$where);\n//\n// $record->next = $db->selectValue($this->model_table,'sef_url',$where.\" AND rank=\".($record->rank+1));\n// $record->prev = $db->selectValue($this->model_table,'sef_url',$where.\" AND rank=\".($record->rank-1));\n//\n// if ($record->rank==$maxrank) {\n// $where = $where.\" AND rank=1\";\n// $record->next = $db->selectValue($this->model_table,'sef_url',$where);\n// }\n//\n// if ($record->rank==1) {\n// $where = $where.\" AND rank=\".$maxrank;\n// $record->prev = $db->selectValue($this->model_table,'sef_url',$where);\n// }\n $record->addNextPrev($where);",
" assign_to_template(array(\n 'record'=>$record,\n 'imgnum'=>$record->rank,\n 'imgtot'=>count($record->find('all',$this->aggregateWhereClause())),\n// \"next\"=>$next,\n// \"previous\"=>$prev,\n 'config'=>$config\n ));\n }",
" ",
" public function slideshow() {\n expHistory::set('viewable', $this->params);\n $order = isset($this->config['order']) ? $this->config['order'] : \"rank\";\n $page = new expPaginator(array(\n 'model'=>'photo',\n 'where'=>$this->aggregateWhereClause(),\n 'limit'=>(isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10,\n 'order'=>$order,\n 'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],\n 'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),\n 'groups'=>empty($this->params['gallery']) ? array() : array($this->params['gallery']),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));",
" assign_to_template(array(\n// 'slides'=>$slides\n 'slides'=>$page->records,\n ));\n }",
" ",
" public function showall_tags() {\n $images = $this->image->find('all');\n $used_tags = array();\n foreach ($images as $image) {\n foreach($image->expTag as $tag) {\n if (isset($used_tags[$tag->id])) {\n $used_tags[$tag->id]->count++;\n } else {\n $exptag = new expTag($tag->id);\n $used_tags[$tag->id] = $exptag;\n $used_tags[$tag->id]->count = 1;\n }",
" \n }\n }\n ",
" assign_to_template(array(\n 'tags'=>$used_tags\n ));",
" } ",
"\n /**\n * Returns rich snippet PageMap meta data\n *\n * @param $request\n * @param $object\n *\n * @return string\n */\n function meta_rich($request, $object) {\n if (!empty($object->expFile[0]) && file_exists(BASE.$object->expFile[0]->directory.$object->expFile[0]->filename)) {\n return '<!--\n <PageMap>\n <DataObject type=\"thumbnail\">\n <Attribute name=\"src\" value=\"'.URL_FULL.$object->expFile[0]->directory.$object->expFile[0]->filename.'\"/>\n <Attribute name=\"width\" value=\"'.$object->expFile[0]->image_width.'\"/>\n <Attribute name=\"height\" value=\"'.$object->expFile[0]->image_width.'\"/>\n </DataObject>\n </PageMap>\n -->';\n } else return null;\n }",
" public function update() {",
" //populate the alt tag field if the user didn't\n if (empty($this->params['alt'])) $this->params['alt'] = $this->params['title'];",
" ",
" // call expController update to save the image\n parent::update();\n }",
" public function multi_add() {\n// global $db;",
"// $tags = $db->selectObjects('expTags', '1', 'title ASC');\n// $taglist = '';\n// foreach ($tags as $tag) {\n// $taglist .= \"'\" . $tag->title . \"',\";\n// }\n// $taglist = expTag::getAllTags();\n// $modelname = $this->basemodel_name;\n// assign_to_template(array(\n// 'record' => $record,\n// 'table' => $this->$modelname->tablename,\n// 'controller' => $this->params['controller'],\n// 'taglist' => $taglist\n// ));\n }",
" public function multi_update() {\n// global $db;",
" if (!empty($this->params['expFile'])) {\n if (!empty($this->params['title'])) {\n $prefix = $this->params['title'] . ' - ';\n } else {\n $prefix = '';\n }\n $params = array();\n //check for and handle tags\n if (array_key_exists('expTag', $this->params)) {\n $tags = explode(\",\", trim($this->params['expTag']));",
" foreach ($tags as $tag) {\n if (!empty($tag)) {\n $tag = strtolower(trim($tag));\n $tag = str_replace(array('\"', \"'\"), \"\", $tag); // strip double and single quotes\n if (!empty($tag)) {\n $expTag = new expTag($tag);\n if (empty($expTag->id))\n $expTag->update(array('title' => $tag));\n $params['expTag'][] = $expTag->id;\n }\n }\n }\n }",
" //check for and handle cats\n if (array_key_exists('expCat', $this->params) && !empty($this->params['expCat'])) {\n $catid = $this->params['expCat'];\n $params['expCat'][] = $catid;\n }\n foreach ($this->params['expFile'] as $fileid) {\n $params['expFile'][0] = new expFile($fileid);\n if (!empty($params['expFile'][0]->id)) {\n $photo = new photo();\n $photo->expFile = $params['expFile'];\n $loc = expCore::makeLocation(\"photo\",$this->params['src']);\n $photo->location_data = serialize($loc);\n // $photo->body = $gi['description'];\n // $photo->alt = !empty($gi['alt']) ? $gi['alt'] : $photo->title;\n $filename = pathinfo($params['expFile'][0]->filename);\n $photo->title = $prefix . $filename['filename'];\n if (!empty($params['expTag'])) {\n $photo->expTag = $params['expTag'];\n }\n if (!empty($params['expCat'])) {\n $photo->expCat = $params['expCat'];\n }\n $photo->update($params); // save gallery name as category\n }\n }\n $this->addContentToSearch();\n }\n expHistory::back();\n }",
" function delete_multi() {\n expHistory::set('manageable', $this->params);\n $order = isset($this->config['order']) ? $this->config['order'] : \"rank\";\n $page = new expPaginator(array(\n 'model'=>'photo',\n 'where'=>$this->aggregateWhereClause(),\n 'order'=>$order,\n 'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],\n 'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),\n 'groups'=>!isset($this->params['gallery']) ? array() : array($this->params['gallery']),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));",
" assign_to_template(array(\n 'page'=>$page,\n ));\n }",
" function delete_multi_act() {\n foreach ($this->params['pic'] as $pic_id=>$value) {\n $obj = new photo($pic_id);\n $obj->delete();\n }\n expHistory::back();\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class photosController extends expController {\n public $basemodel_name = 'photo';\n// public $useractions = array(\n// 'showall'=>'Gallery',\n// 'slideshow'=>'Slideshow',\n// //'showall_tags'=>\"Tag Categories\"\n// );",
" protected $manage_permissions = array(\n 'multi'=>'Bulk Actions',\n );",
" public $remove_configs = array(\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'pagination', // we need to customize it in this module?\n 'rss',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" static function displayname() { return gt(\"Photo Album\"); }\n static function description() { return gt(\"Displays and manages images.\"); }\n static function isSearchable() { return true; }",
"",
" public function showall() {\n expHistory::set('viewable', $this->params);\n $limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;\n if (!empty($this->params['view']) && ($this->params['view'] == 'showall_accordion' || $this->params['view'] == 'showall_tabbed')) {\n $limit = '0';\n }\n $order = isset($this->config['order']) ? $this->config['order'] : \"rank\";\n $page = new expPaginator(array(\n 'model'=>'photo',\n 'where'=>$this->aggregateWhereClause(),\n 'limit'=>$limit,\n 'order'=>$order,\n 'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],\n 'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),\n 'groups'=>!isset($this->params['gallery']) ? array() : array($this->params['gallery']),\n 'grouplimit'=>!empty($this->params['view']) && $this->params['view'] == 'showall_galleries' ? 1 : null,\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));",
"",
" assign_to_template(array(\n 'page'=>$page,\n 'params'=>$this->params,\n ));\n }",
"",
" function show() {\n expHistory::set('viewable', $this->params);",
"",
" // figure out if we're looking this up by id or title\n $id = null;\n if (isset($this->params['id'])) {\n $id = $this->params['id'];\n } elseif (isset($this->params['title'])) {",
" $id = expString::escape($this->params['title']);",
" }\n $record = new photo($id);\n if (empty($record->id))\n redirect_to(array('controller'=>'notfound','action'=>'page_not_found','title'=>$this->params['title']));",
" $config = expConfig::getConfig($record->location_data);\n if (empty($this->config))\n $this->config = $config;\n if (empty($this->loc->src)) {\n $r_loc = expUnserialize($record->location_data);\n $this->loc->src = $r_loc->src;\n }",
" $where = $this->aggregateWhereClause();\n// $maxrank = $db->max($this->model_table,'rank','',$where);\n//\n// $record->next = $db->selectValue($this->model_table,'sef_url',$where.\" AND rank=\".($record->rank+1));\n// $record->prev = $db->selectValue($this->model_table,'sef_url',$where.\" AND rank=\".($record->rank-1));\n//\n// if ($record->rank==$maxrank) {\n// $where = $where.\" AND rank=1\";\n// $record->next = $db->selectValue($this->model_table,'sef_url',$where);\n// }\n//\n// if ($record->rank==1) {\n// $where = $where.\" AND rank=\".$maxrank;\n// $record->prev = $db->selectValue($this->model_table,'sef_url',$where);\n// }\n $record->addNextPrev($where);",
" assign_to_template(array(\n 'record'=>$record,\n 'imgnum'=>$record->rank,\n 'imgtot'=>count($record->find('all',$this->aggregateWhereClause())),\n// \"next\"=>$next,\n// \"previous\"=>$prev,\n 'config'=>$config\n ));\n }",
"",
" public function slideshow() {\n expHistory::set('viewable', $this->params);\n $order = isset($this->config['order']) ? $this->config['order'] : \"rank\";\n $page = new expPaginator(array(\n 'model'=>'photo',\n 'where'=>$this->aggregateWhereClause(),\n 'limit'=>(isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10,\n 'order'=>$order,\n 'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],\n 'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),\n 'groups'=>empty($this->params['gallery']) ? array() : array($this->params['gallery']),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));",
" assign_to_template(array(\n// 'slides'=>$slides\n 'slides'=>$page->records,\n ));\n }",
"",
" public function showall_tags() {\n $images = $this->image->find('all');\n $used_tags = array();\n foreach ($images as $image) {\n foreach($image->expTag as $tag) {\n if (isset($used_tags[$tag->id])) {\n $used_tags[$tag->id]->count++;\n } else {\n $exptag = new expTag($tag->id);\n $used_tags[$tag->id] = $exptag;\n $used_tags[$tag->id]->count = 1;\n }",
"\n }\n }\n",
" assign_to_template(array(\n 'tags'=>$used_tags\n ));",
" }",
"\n /**\n * Returns rich snippet PageMap meta data\n *\n * @param $request\n * @param $object\n *\n * @return string\n */\n function meta_rich($request, $object) {\n if (!empty($object->expFile[0]) && file_exists(BASE.$object->expFile[0]->directory.$object->expFile[0]->filename)) {\n return '<!--\n <PageMap>\n <DataObject type=\"thumbnail\">\n <Attribute name=\"src\" value=\"'.URL_FULL.$object->expFile[0]->directory.$object->expFile[0]->filename.'\"/>\n <Attribute name=\"width\" value=\"'.$object->expFile[0]->image_width.'\"/>\n <Attribute name=\"height\" value=\"'.$object->expFile[0]->image_width.'\"/>\n </DataObject>\n </PageMap>\n -->';\n } else return null;\n }",
" public function update() {",
" //populate the alt tag field if the user didn't\n if (empty($this->params['alt'])) $this->params['alt'] = $this->params['title'];",
"",
" // call expController update to save the image\n parent::update();\n }",
" public function multi_add() {\n// global $db;",
"// $tags = $db->selectObjects('expTags', '1', 'title ASC');\n// $taglist = '';\n// foreach ($tags as $tag) {\n// $taglist .= \"'\" . $tag->title . \"',\";\n// }\n// $taglist = expTag::getAllTags();\n// $modelname = $this->basemodel_name;\n// assign_to_template(array(\n// 'record' => $record,\n// 'table' => $this->$modelname->tablename,\n// 'controller' => $this->params['controller'],\n// 'taglist' => $taglist\n// ));\n }",
" public function multi_update() {\n// global $db;",
" if (!empty($this->params['expFile'])) {\n if (!empty($this->params['title'])) {\n $prefix = $this->params['title'] . ' - ';\n } else {\n $prefix = '';\n }\n $params = array();\n //check for and handle tags\n if (array_key_exists('expTag', $this->params)) {\n $tags = explode(\",\", trim($this->params['expTag']));",
" foreach ($tags as $tag) {\n if (!empty($tag)) {\n $tag = strtolower(trim($tag));\n $tag = str_replace(array('\"', \"'\"), \"\", $tag); // strip double and single quotes\n if (!empty($tag)) {\n $expTag = new expTag($tag);\n if (empty($expTag->id))\n $expTag->update(array('title' => $tag));\n $params['expTag'][] = $expTag->id;\n }\n }\n }\n }",
" //check for and handle cats\n if (array_key_exists('expCat', $this->params) && !empty($this->params['expCat'])) {\n $catid = $this->params['expCat'];\n $params['expCat'][] = $catid;\n }\n foreach ($this->params['expFile'] as $fileid) {\n $params['expFile'][0] = new expFile($fileid);\n if (!empty($params['expFile'][0]->id)) {\n $photo = new photo();\n $photo->expFile = $params['expFile'];\n $loc = expCore::makeLocation(\"photo\",$this->params['src']);\n $photo->location_data = serialize($loc);\n // $photo->body = $gi['description'];\n // $photo->alt = !empty($gi['alt']) ? $gi['alt'] : $photo->title;\n $filename = pathinfo($params['expFile'][0]->filename);\n $photo->title = $prefix . $filename['filename'];\n if (!empty($params['expTag'])) {\n $photo->expTag = $params['expTag'];\n }\n if (!empty($params['expCat'])) {\n $photo->expCat = $params['expCat'];\n }\n $photo->update($params); // save gallery name as category\n }\n }\n $this->addContentToSearch();\n }\n expHistory::back();\n }",
" function delete_multi() {\n expHistory::set('manageable', $this->params);\n $order = isset($this->config['order']) ? $this->config['order'] : \"rank\";\n $page = new expPaginator(array(\n 'model'=>'photo',\n 'where'=>$this->aggregateWhereClause(),\n 'order'=>$order,\n 'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],\n 'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),\n 'groups'=>!isset($this->params['gallery']) ? array() : array($this->params['gallery']),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));",
" assign_to_template(array(\n 'page'=>$page,\n ));\n }",
" function delete_multi_act() {\n foreach ($this->params['pic'] as $pic_id=>$value) {\n $obj = new photo($pic_id);\n $obj->delete();\n }\n expHistory::back();\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class pixidouController extends expController {",
"// public $cacheDir = \"framework/modules/pixidou/images/\";",
"\tpublic $cacheDir = \"tmp/pixidou/\";\n public $requires_login = array(",
" 'editor',\n 'exitEditor'",
" );",
" static function displayname() { return gt(\"Pixidou Image Editor\"); }\n static function description() { return gt(\"Add and manage Exponent Files\"); }\n static function author() { return \"Phillip Ball - OIC Group, Inc\"; }",
" static function hasSources()\n {\n return false;\n }",
" function editor() {\n global $user;",
" ",
" $file = new expFile($this->params['id']);",
" \n $canSaveOg = $user->id==$file->poster || $user->is_admin ? 1 : 0 ;\n\t if (file_exists(BASE.$file->directory.$file->filename)) {\n\t\t\t$file->copyToDirectory(BASE.$this->cacheDir);",
"\t\t\tassign_to_template(array(\n 'image'=>$file,\n 'update'=>$this->params['update'],\n 'saveog'=>$canSaveOg\n ));\n\t } else {",
"\t\t flash('error',gt('The file').' \"'.BASE.$file->directory.$file->filename.'\" '.gt('does not exist on the server.'));\n\t\t redirect_to(array(\"controller\"=>'file',\"action\"=>'picker',\"ajax_action\"=>1,\"update\"=>$this->params['update'],\"filter\"=>$this->params['filter']));",
"\t }\n }",
" ",
" public function exitEditor() {\n // clean up parameters\n $this->params['fid'] = intval($this->params['fid']);\n if (!empty($this->params['cpi']) && strpos($this->params['cpi'], '..') !== false) {\n $this->params['exitType'] = 'error';\n }\n switch ($this->params['exitType']) {\n case 'saveAsCopy':",
" $oldimage = new expFile($this->params['fid']); \n $copyname = expFile::resolveDuplicateFilename($oldimage->path); \n copy(BASE.$this->cacheDir.\"/\".$this->params['cpi'],$oldimage->directory.$copyname); //copy the edited file over to the files dir",
" $newFile = new expFile(array(\"filename\"=>$copyname)); //construct a new expFile\n $newFile->directory = $oldimage->directory;\n $newFile->title = $oldimage->title;\n $newFile->shared = $oldimage->shared;\n $newFile->mimetype = $oldimage->mimetype;\n $newFile->posted = time();",
" $newFile->filesize = filesize(BASE.$this->cacheDir.\"/\".$this->params['cpi']);\n $resized = getimagesize(BASE.$this->cacheDir.\"/\".$this->params['cpi']);",
" $newFile->image_width = $resized[0];\n $newFile->image_height = $resized[1];\n $newFile->alt = $oldimage->alt;\n $newFile->is_image = $oldimage->is_image;\n $newFile->save(); //Save it to the database",
" break;\n case 'saveAsIs':\n //eDebug($this->params,true);\n $oldimage = new expFile($this->params['fid']);",
" $resized = getimagesize(BASE.$this->cacheDir.\"/\".$this->params['cpi']);",
" $oldimage->image_width = $resized[0];\n $oldimage->image_height = $resized[1];\n $oldimage->save();",
" copy(BASE.$this->cacheDir.\"/\".$this->params['cpi'],$oldimage->directory.$oldimage->filename); //copy the edited file over to the files dir",
" break;",
" ",
" default:\n # code...\n break;\n }\n // proper file types to look for",
" $types = array(\".jpg\",\".gif\",\".png\");\n ",
" //Pixidou images directory, the editor's cache",
" $cachedir = BASE.$this->cacheDir;\n ",
" if (is_dir($cachedir) && is_readable($cachedir) ) {\n $dh = opendir($cachedir);\n while (($tmpfile = readdir($dh)) !== false) {",
" if (in_array(substr($tmpfile,-4,4),$types)) {\n $filename = $cachedir.$tmpfile;",
" unlink($filename);\n }\n }\n }",
" \n redirect_to(array(\"controller\"=>'file',\"action\"=>'picker',\"ajax_action\"=>1,\"update\"=>$this->params['update'],\"filter\"=>$this->params['filter']));",
" }",
" ",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class pixidouController extends expController {",
"",
"\tpublic $cacheDir = \"tmp/pixidou/\";\n public $requires_login = array(",
" 'editor'=>'You must be logged in to perform this action',\n 'exitEditor'=>'You must be logged in to perform this action',",
" );",
" static function displayname() { return gt(\"Pixidou Image Editor\"); }\n static function description() { return gt(\"Add and manage Exponent Files\"); }\n static function author() { return \"Phillip Ball - OIC Group, Inc\"; }",
" static function hasSources()\n {\n return false;\n }",
" function editor() {\n global $user;",
"",
" $file = new expFile($this->params['id']);",
"\n $canSaveOg = $user->id==$file->poster || $user->isSuperAdmin() ? 1 : 0 ;\n\t if (file_exists(BASE . $file->directory . $file->filename)) {\n\t\t\t$file->copyToDirectory(BASE . $this->cacheDir);",
"\t\t\tassign_to_template(array(\n 'image'=>$file,\n 'update'=>$this->params['update'],\n 'saveog'=>$canSaveOg\n ));\n\t } else {",
"\t\t flash('error', gt('The file') . ' \"' . BASE . $file->directory . $file->filename . '\" ' . gt('does not exist on the server.'));\n\t\t redirect_to(array(\"controller\"=>'file', \"action\"=>'picker', \"ajax_action\"=>1, \"update\"=>$this->params['update'], \"filter\"=>$this->params['filter']));",
"\t }\n }",
"",
" public function exitEditor() {\n // clean up parameters\n $this->params['fid'] = intval($this->params['fid']);\n if (!empty($this->params['cpi']) && strpos($this->params['cpi'], '..') !== false) {\n $this->params['exitType'] = 'error';\n }\n switch ($this->params['exitType']) {\n case 'saveAsCopy':",
" $oldimage = new expFile($this->params['fid']);\n $copyname = expFile::resolveDuplicateFilename($oldimage->path);\n copy(BASE . $this->cacheDir . \"/\" . $this->params['cpi'], $oldimage->directory . $copyname); //copy the edited file over to the files dir",
" $newFile = new expFile(array(\"filename\"=>$copyname)); //construct a new expFile\n $newFile->directory = $oldimage->directory;\n $newFile->title = $oldimage->title;\n $newFile->shared = $oldimage->shared;\n $newFile->mimetype = $oldimage->mimetype;\n $newFile->posted = time();",
" $newFile->filesize = filesize(BASE . $this->cacheDir . \"/\" . $this->params['cpi']);\n $resized = getimagesize(BASE . $this->cacheDir . \"/\" . $this->params['cpi']);",
" $newFile->image_width = $resized[0];\n $newFile->image_height = $resized[1];\n $newFile->alt = $oldimage->alt;\n $newFile->is_image = $oldimage->is_image;\n $newFile->save(); //Save it to the database",
" break;\n case 'saveAsIs':\n //eDebug($this->params,true);\n $oldimage = new expFile($this->params['fid']);",
" $resized = getimagesize(BASE . $this->cacheDir . \"/\" . $this->params['cpi']);",
" $oldimage->image_width = $resized[0];\n $oldimage->image_height = $resized[1];\n $oldimage->save();",
" copy(BASE . $this->cacheDir . \"/\" . $this->params['cpi'], $oldimage->directory . $oldimage->filename); //copy the edited file over to the files dir",
" break;",
"",
" default:\n # code...\n break;\n }\n // proper file types to look for",
" $types = array(\".jpg\", \".gif\", \".png\");\n",
" //Pixidou images directory, the editor's cache",
" $cachedir = BASE . $this->cacheDir;\n",
" if (is_dir($cachedir) && is_readable($cachedir) ) {\n $dh = opendir($cachedir);\n while (($tmpfile = readdir($dh)) !== false) {",
" if (in_array(substr($tmpfile, -4, 4), $types)) {\n $filename = $cachedir . $tmpfile;",
" unlink($filename);\n }\n }\n }",
"\n redirect_to(array(\"controller\"=>'file', \"action\"=>'picker', \"ajax_action\"=>1, \"update\"=>$this->params['update'], \"filter\"=>$this->params['filter']));",
" }",
"",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class portfolioController extends expController {\n public $useractions = array(\n 'showall'=>'Show all', \n 'tags'=>\"Tags\",\n 'slideshow'=>\"Slideshow\"\n );",
"",
" public $remove_configs = array(\n 'comments',\n 'ealerts',\n 'facebook',\n 'rss',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" protected $add_permissions = array(\n 'import'=>'Import Portfolio Items',\n 'export'=>'Export Portfolio Items'\n );",
"\n static function displayname() { return gt(\"Portfolio\"); }\n static function description() { return gt(\"Display a portfolio or listing.\"); }\n static function isSearchable() { return true; }",
" static function canImportData() {\n return true;\n }",
" static function canExportData() {\n return true;\n }",
" public function showall() {\n expHistory::set('viewable', $this->params);\n $limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;\n if (!empty($this->params['view']) && ($this->params['view'] == 'showall_accordion' || $this->params['view'] == 'showall_tabbed')) {\n $limit = '0';\n }\n $order = isset($this->config['order']) ? $this->config['order'] : 'rank';\n $page = new expPaginator(array(\n 'model'=>$this->basemodel_name,\n 'where'=>$this->aggregateWhereClause(),\n 'limit'=>$limit,\n 'order'=>$order,\n 'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],\n 'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),\n 'groups'=>!isset($this->params['group']) ? array() : array($this->params['group']),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));",
" assign_to_template(array(\n 'page'=>$page,\n 'rank'=>($order==='rank')?1:0,\n 'params'=>$this->params,\n ));\n }\n \n public function slideshow() {\n expHistory::set('viewable', $this->params);",
" $order = isset($this->config['order']) ? $this->config['order'] : 'rank';\n //FIXME we need to change this to expPaginator to get category grouping\n $s = new portfolio();\n $slides = $s->find('all',$this->aggregateWhereClause(),$order);",
" assign_to_template(array(\n 'slides'=>$slides,\n 'rank'=>($order==='rank')?1:0\n ));\n }",
" /**\n * Returns rich snippet PageMap meta data\n *\n * @param $request\n * @param $object\n *\n * @return string\n */\n function meta_rich($request, $object) {\n if (!empty($object->expFile[0]) && file_exists(BASE.$object->expFile[0]->directory.$object->expFile[0]->filename)) {\n $rich_meta = '<!--\n <PageMap>\n <DataObject type=\"thumbnail\">\n <Attribute name=\"src\" value=\"' . URL_FULL . $object->expFile[0]->directory . $object->expFile[0]->filename . '\"/>\n <Attribute name=\"width\" value=\"' . $object->expFile[0]->image_width . '\"/>\n <Attribute name=\"height\" value=\"' . $object->expFile[0]->image_height . '\"/>\n </DataObject>\n </PageMap>\n -->';\n return $rich_meta;\n }\n }",
" /**\n * The aggregateWhereClause function creates a sql where clause which also includes aggregated module content\n *\n * @param string $type\n *\n * @return string\n */\n \tfunction aggregateWhereClause($type='') {\n $sql = parent::aggregateWhereClause();\n $sql .= (!empty($this->config['only_featured']))?\"AND featured=1\":\"\";",
" return $sql;\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class portfolioController extends expController {\n public $useractions = array(\n 'showall'=>'Show all', \n 'tags'=>\"Tags\",\n 'slideshow'=>\"Slideshow\"\n );",
" protected $manage_permissions = array(\n 'import'=>'Import Portfolio Items',\n 'export'=>'Export Portfolio Items'\n );",
" public $remove_configs = array(\n 'comments',\n 'ealerts',\n 'facebook',\n 'rss',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
"",
"\n static function displayname() { return gt(\"Portfolio\"); }\n static function description() { return gt(\"Display a portfolio or listing.\"); }\n static function isSearchable() { return true; }",
" static function canImportData() {\n return true;\n }",
" static function canExportData() {\n return true;\n }",
" public function showall() {\n expHistory::set('viewable', $this->params);\n $limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;\n if (!empty($this->params['view']) && ($this->params['view'] == 'showall_accordion' || $this->params['view'] == 'showall_tabbed')) {\n $limit = '0';\n }\n $order = isset($this->config['order']) ? $this->config['order'] : 'rank';\n $page = new expPaginator(array(\n 'model'=>$this->basemodel_name,\n 'where'=>$this->aggregateWhereClause(),\n 'limit'=>$limit,\n 'order'=>$order,\n 'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],\n 'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),\n 'groups'=>!isset($this->params['group']) ? array() : array($this->params['group']),\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>$this->loc->src,\n 'columns'=>array(\n gt('Title')=>'title'\n ),\n ));",
" assign_to_template(array(\n 'page'=>$page,\n 'rank'=>($order==='rank')?1:0,\n 'params'=>$this->params,\n ));\n }\n \n public function slideshow() {\n expHistory::set('viewable', $this->params);",
" $order = isset($this->config['order']) ? $this->config['order'] : 'rank';\n //FIXME we need to change this to expPaginator to get category grouping\n $s = new portfolio();\n $slides = $s->find('all',$this->aggregateWhereClause(),$order);",
" assign_to_template(array(\n 'slides'=>$slides,\n 'rank'=>($order==='rank')?1:0\n ));\n }",
" /**\n * Returns rich snippet PageMap meta data\n *\n * @param $request\n * @param $object\n *\n * @return string\n */\n function meta_rich($request, $object) {\n if (!empty($object->expFile[0]) && file_exists(BASE.$object->expFile[0]->directory.$object->expFile[0]->filename)) {\n $rich_meta = '<!--\n <PageMap>\n <DataObject type=\"thumbnail\">\n <Attribute name=\"src\" value=\"' . URL_FULL . $object->expFile[0]->directory . $object->expFile[0]->filename . '\"/>\n <Attribute name=\"width\" value=\"' . $object->expFile[0]->image_width . '\"/>\n <Attribute name=\"height\" value=\"' . $object->expFile[0]->image_height . '\"/>\n </DataObject>\n </PageMap>\n -->';\n return $rich_meta;\n }\n }",
" /**\n * The aggregateWhereClause function creates a sql where clause which also includes aggregated module content\n *\n * @param string $type\n *\n * @return string\n */\n \tfunction aggregateWhereClause($type='') {\n $sql = parent::aggregateWhereClause();\n $sql .= (!empty($this->config['only_featured']))?\"AND featured=1\":\"\";",
" return $sql;\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */\nclass recyclebinController extends expController\n{",
" protected $add_permissions = array(",
" 'showall' => 'View Recycle Bin',\n 'show' => 'View Recycle Bin',\n 'remove' => 'Remove Recycle Bin Item'\n );",
" //protected $remove_permissions = array('edit');",
" static function displayname()\n {\n return gt(\"Recycle Bin Manager\");\n }",
" static function description()\n {\n return gt(\"Manage modules that have been deleted from your web pages\");\n }",
" static function author()\n {\n return \"Phillip Ball - OIC Group, Inc\";\n }",
" static function hasSources()\n {\n return false;\n }",
" static function hasContent()\n {\n return false;\n }",
" function showall()\n {\n expHistory::set('manageable', $this->params);",
" //initialize a new recycle bin and grab the previously trashed items\n $bin = new recyclebin();\n $orphans = $bin->moduleOrphans();",
" assign_to_template(\n array(\n 'items' => $orphans\n )\n );\n }",
" public function show()\n {\n //instantiate an expRecord for the module in question\n //$mod = new $this->params['recymod']();\n define('SOURCE_SELECTOR', 1);\n define('PREVIEW_READONLY', 1); // for mods",
" //initialize a new recycle bin and grab the previously trashed items\n $bin = new recyclebin();\n $orphans = $bin->moduleOrphans($this->params['recymod']);",
" assign_to_template(\n array(\n 'items' => $orphans,\n 'module' => $this->params['recymod']\n )\n );\n }",
" /**\n * Permanently remove a module from the recycle bin and all it's items from the system\n *\n */\n public function remove()\n {\n global $db;\n",
"",
" $mod = expModules::getController($this->params['mod'], $this->params['src']);\n if ($mod != null) {\n $mod->delete_instance(); // delete all assoc items\n $db->delete(\n 'sectionref',\n \"source='\" . $this->params['src'] . \"' and module='\" . $this->params['mod'] . \"'\"\n ); // delete recycle bin holder\n flash('notice', gt('Item removed from Recycle Bin'));\n }\n expHistory::back();\n }",
" /**\n * Permanently remove all modules from the recycle bin and all their items from the system\n *\n */\n public function remove_all()\n {\n global $db;",
" $bin = new recyclebin();\n $orphans = $bin->moduleOrphans();\n foreach ($orphans as $orphan) {\n $mod = expModules::getController($orphan->module, $orphan->source);\n if ($mod != null) {\n $mod->delete_instance(); // delete all assoc items\n $db->delete(\n 'sectionref',\n \"source='\" . $orphan->source . \"' and module='\" . $orphan->module . \"'\"\n ); // delete recycle bin holder\n }\n }\n flash('notice', gt('Recycle Bin has been Emptied'));\n expHistory::back();\n }",
"}",
"?>"
] |
[
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */\nclass recyclebinController extends expController\n{",
" protected $manage_permissions = array(",
" 'showall' => 'View Recycle Bin',\n 'show' => 'View Recycle Bin',\n 'remove' => 'Remove Recycle Bin Item'\n );",
" //protected $remove_permissions = array('edit');",
" static function displayname()\n {\n return gt(\"Recycle Bin Manager\");\n }",
" static function description()\n {\n return gt(\"Manage modules that have been deleted from your web pages\");\n }",
" static function author()\n {\n return \"Phillip Ball - OIC Group, Inc\";\n }",
" static function hasSources()\n {\n return false;\n }",
" static function hasContent()\n {\n return false;\n }",
" function showall()\n {\n expHistory::set('manageable', $this->params);",
" //initialize a new recycle bin and grab the previously trashed items\n $bin = new recyclebin();\n $orphans = $bin->moduleOrphans();",
" assign_to_template(\n array(\n 'items' => $orphans\n )\n );\n }",
" public function show()\n {\n //instantiate an expRecord for the module in question\n //$mod = new $this->params['recymod']();\n define('SOURCE_SELECTOR', 1);\n define('PREVIEW_READONLY', 1); // for mods",
" //initialize a new recycle bin and grab the previously trashed items\n $bin = new recyclebin();\n $orphans = $bin->moduleOrphans($this->params['recymod']);",
" assign_to_template(\n array(\n 'items' => $orphans,\n 'module' => $this->params['recymod']\n )\n );\n }",
" /**\n * Permanently remove a module from the recycle bin and all it's items from the system\n *\n */\n public function remove()\n {\n global $db;\n",
" $this->params['mod'] = expString::escape($this->params['mod']);\n $this->params['src'] = expString::escape($this->params['src']);",
" $mod = expModules::getController($this->params['mod'], $this->params['src']);\n if ($mod != null) {\n $mod->delete_instance(); // delete all assoc items\n $db->delete(\n 'sectionref',\n \"source='\" . $this->params['src'] . \"' and module='\" . $this->params['mod'] . \"'\"\n ); // delete recycle bin holder\n flash('notice', gt('Item removed from Recycle Bin'));\n }\n expHistory::back();\n }",
" /**\n * Permanently remove all modules from the recycle bin and all their items from the system\n *\n */\n public function remove_all()\n {\n global $db;",
" $bin = new recyclebin();\n $orphans = $bin->moduleOrphans();\n foreach ($orphans as $orphan) {\n $mod = expModules::getController($orphan->module, $orphan->source);\n if ($mod != null) {\n $mod->delete_instance(); // delete all assoc items\n $db->delete(\n 'sectionref',\n \"source='\" . $orphan->source . \"' and module='\" . $orphan->module . \"'\"\n ); // delete recycle bin holder\n }\n }\n flash('notice', gt('Recycle Bin has been Emptied'));\n expHistory::back();\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class reportController extends expController {",
" protected $add_permissions = array(\n 'build_report' => 'Manage',",
" 'cart_summary' => 'View Cart Summary Report',",
"",
" 'dashboard' => 'View the e-Commerce Dashboard',",
" 'order_report' => 'Generate Order Report',\n 'product_report' => 'Generate Product Report',",
" 'generateOrderReport' => 'View Order Report',\n 'generateProductReport' => 'View Product Report',",
"",
" 'print_orders' => 'Print Orders',",
" 'batch_export' => 'Export Products',",
" 'show_payment_summary' => 'Show Payment Summary',",
" 'export_order_items' => 'Export Order Items File');",
"\n static function displayname() {\n return gt(\"Ecom Report Builder\");\n }",
" static function description() {\n return gt(\"Build reports based on store activity\");\n }",
" static function author() {\n return \"Phillip Ball - OIC Group, Inc\";\n }",
" static function hasSources() {\n return false;\n }",
" protected $o;\n protected $oneday = 86400;\n protected $tstart;\n protected $tend;\n protected $prev_month;\n protected $prev_hour = '12';\n protected $prev_min = '00';\n protected $prev_ampm = 'AM';\n protected $now_date;\n protected $now_hour;\n protected $now_min;\n protected $now_ampm;",
" function __construct($src = null, $params = array()) {\n parent::__construct($src, $params);\n $this->o = new order();\n $this->tstart = time() - $this->oneday;\n $this->tend = time();\n// $this->prev_month = strftime(\"%A, %d %B %Y\", mktime(0,0,0,(strftime(\"%m\")-1),1,strftime(\"%Y\")));\n// $this->now_date = strftime(\"%A, %d %B %Y\");\n $this->prev_month = strftime(DISPLAY_DATE_FORMAT, mktime(0, 0, 0, (strftime(\"%m\") - 1), 1, strftime(\"%Y\")));\n $this->now_date = strftime(DISPLAY_DATE_FORMAT);\n $this->now_hour = strftime(\"%I\");\n $this->now_min = strftime(\"%M\");\n $this->now_ampm = strftime(\"%p\");\n }",
" private function setDateParams($params) {\n //eDebug($params,true);\n if (!empty($params['quickrange'])) {\n if ($params['quickrange'] == 1) {\n $this->tstart = time() - $this->oneday * 7;\n } else if ($params['quickrange'] == 2) {\n $this->tstart = time() - $this->oneday * 30;\n } else if ($params['quickrange'] == 0) {\n $this->tstart = time() - $this->oneday;\n }\n $this->prev_month = strftime(DISPLAY_DATE_FORMAT,$this->tstart);\n } else if (isset($params['date-starttime'])) { //FIXME OLD calendar control format\n $formatedStart = $params['date-starttime'] . ' ' . $params['time-h-starttime'] . \":\" . $params['time-m-starttime'] . ' ' . $params['ampm-starttime'];\n $this->tstart = strtotime($formatedStart);\n $this->tend = strtotime($params['date-endtime'] . ' ' . $params['time-h-endtime'] . \":\" . $params['time-m-endtime'] . ' ' . $params['ampm-endtime']);",
" // parse out date into calendarcontrol fields\n $this->prev_month = $formatedStart;\n $this->prev_hour = $params['time-h-starttime'];\n $this->prev_min = $params['time-m-starttime'];\n $this->prev_ampm = $params['ampm-starttime'];",
" // parse out date into calendarcontrol fields\n $this->now_date = $params['date-endtime'];\n $this->now_hour = $params['time-h-endtime'];\n $this->now_min = $params['time-m-endtime'];\n $this->now_ampm = $params['ampm-endtime'];\n } elseif (isset($params['starttime'])) {\n $this->tstart = strtotime($params['starttime']);\n $this->tend = strtotime($params['endtime']);",
" // parse out date into calendarcontrol fields\n $this->prev_month = date('m/d/Y', $this->tstart);\n $this->prev_hour = date('h', $this->tstart);\n $this->prev_min = date('i', $this->tstart);\n $this->prev_ampm = date('a', $this->tstart);",
" // parse out date into calendarcontrol fields\n $this->now_date = date('m/d/Y', $this->tend);\n $this->now_hour = date('h', $this->tend);\n $this->now_min = date('i', $this->tend);\n $this->now_ampm = date('a', $this->tend);\n } else {\n $this->tstart = time() - $this->oneday;\n }\n return;\n }",
" function dashboard() {\n global $db;",
" $quickrange = array(0 => gt('Last 24 Hours'), 1 => gt('Last 7 Days'), 2 => gt('Last 30 Days'));\n $this->setDateParams($this->params);\n if (!isset($this->params['quickrange'])) {\n $this->params['quickrange'] = 0;\n }",
" $except = array('order_discounts', 'billingmethod', 'order_status_changes', 'billingmethod', 'order_discounts');\n $orders = $this->o->find('all', 'purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend, null, null, 0, true, false, $except, true);\n $oar = array();\n foreach ($orders as $order) {\n //eDebug($order,true);\n if (empty($oar[$order->order_type->title])) {\n $oar[$order->order_type->title] = array();\n $oar[$order->order_type->title]['grand_total'] = null;\n $oar[$order->order_type->title]['num_orders'] = null;\n $oar[$order->order_type->title]['num_items'] = null;\n }\n $oar[$order->order_type->title]['grand_total'] += $order->grand_total;\n $oar[$order->order_type->title]['num_orders']++;\n $oar[$order->order_type->title]['num_items'] += count($order->orderitem);",
" if (empty($oar[$order->order_type->title][$order->order_status->title])) {\n $oar[$order->order_type->title][$order->order_status->title] = array();\n $oar[$order->order_type->title][$order->order_status->title]['grand_total'] = null;\n $oar[$order->order_type->title][$order->order_status->title]['num_orders'] = null;\n $oar[$order->order_type->title][$order->order_status->title]['num_items'] = null;\n }\n $oar[$order->order_type->title][$order->order_status->title]['grand_total'] += $order->grand_total;\n $oar[$order->order_type->title][$order->order_status->title]['num_orders']++;\n $oar[$order->order_type->title][$order->order_status->title]['num_items'] += count($order->orderitem);\n }",
" $sql = \"SELECT COUNT(*) as c FROM \" . $db->prefix . \"orders, \" . $db->prefix . \"sessionticket WHERE ticket = sessionticket_ticket\";\n $allCarts = $db->countObjectsBySql($sql);",
" assign_to_template(array(\n 'orders' => $oar,\n 'quickrange' => $quickrange,\n 'quickrange_default' => $this->params['quickrange'],\n 'prev_month' => $this->prev_month,\n 'now_date' => $this->now_date,\n 'now_hour' => $this->now_hour,\n 'now_min' => $this->now_min,\n 'now_ampm' => $this->now_ampm,\n 'prev_hour' => $this->prev_hour,\n 'prev_min' => $this->prev_min,\n 'prev_ampm' => $this->prev_ampm,\n 'active_carts' => $allCarts\n ));\n }",
" function cart_summary() {\n global $db;",
" $p = $this->params;\n $sql = \"SELECT DISTINCT(o.id), o.invoice_id, FROM_UNIXTIME(o.purchased,'%c/%e/%y %h:%i:%s %p') as purchased_date, b.firstname as bfirst, b.lastname as blast, concat('\".expCore::getCurrencySymbol().\"',format(o.grand_total,2)) as grand_total, os.title as status_title from \";\n $sql .= $db->prefix . \"orders as o \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"orderitems as oi ON oi.orders_id = o.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"product as p ON oi.product_id = p.id \";\n if (!empty($p['order_status'][0]) && $p['order_status'][0] != -1) $sql .= \"INNER JOIN \" . $db->prefix . \"order_type as ot ON o.order_type_id = ot.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"order_status as os ON os.id = o.order_status_id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"billingmethods as b ON b.orders_id = o.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"shippingmethods as s ON s.id = oi.shippingmethods_id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"geo_region as gr ON (gr.id = b.state OR gr.id = s.state) \";\n if (!empty($p['discounts'][0]) && $p['discounts'][0] != -1) $sql .= \"LEFT JOIN \" . $db->prefix . \"order_discounts as od ON od.orders_id = o.id \";",
" $sqlwhere = \"WHERE o.purchased != 0\";",
" if (!empty($p['date-startdate'])) $sqlwhere .= \" AND o.purchased >= \" . strtotime($p['date-startdate'] . \" \" . $p['time-h-startdate'] . \":\" . $p['time-m-startdate'] . \" \" . $p['ampm-startdate']);\n /*if ($p->['time-h-startdate'] == )\n if ($p->['time-m-startdate'] == )\n if ($p->['ampm-startdate'] == )*/",
" if (!empty($p['date-enddate'])) $sqlwhere .= \" AND o.purchased <= \" . strtotime($p['date-enddate'] . \" \" . $p['time-h-enddate'] . \":\" . $p['time-m-enddate'] . \" \" . $p['ampm-enddate']);\n /*if ($p->['date-enddate'] == )\n if ($p->['time-h-enddate'] == )\n if ($p->['time-m-enddate'] == )\n if ($p->['ampm-enddate'] == )*/",
" $inc = 0;\n $sqltmp = '';\n if (!empty($p['order_status'])) foreach ($p['order_status'] as $os) {\n if ($os == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (o.order_status_id = \" . $os;\n } else {\n $sqltmp .= \" OR o.order_status_id = \" . $os;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" $inc = 0;\n $sqltmp = '';\n if (!empty($p['order_type'])) foreach ($p['order_type'] as $ot) {\n if ($ot == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (o.order_type_id = \" . $ot;\n } else {\n $sqltmp .= \" OR o.order_type_id = \" . $ot;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!empty($p['order-range-num'])) {\n $operator = '';\n switch ($p['order-range-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND o.invoice_id\" . $operator . $p['order-range-num'];\n }",
" if (!empty($p['order-price-num'])) {\n $operator = '';\n switch ($p['order-price-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND o.grand_total\" . $operator . $p['order-price-num'];\n }",
" if (!empty($p['pnam'])) {\n $sqlwhere .= \" AND p.title LIKE '%\" . $p['pnam'] . \"%'\";\n }",
" if (!empty($p['sku'])) {\n $sqlwhere .= \" AND p.model LIKE '%\" . $p['sku'] . \"%'\";\n }",
" $inc = 0;\n $sqltmp = '';\n if (!empty($p['discounts'])) foreach ($p['discounts'] as $d) {\n if ($d == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (od.discounts_id = \" . $d;\n } else {\n $sqltmp .= \" OR od.discounts_id = \" . $d;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!empty($p['blshpname'])) {\n $sqlwhere .= \" AND (b.firstname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR s.firstname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR b.lastname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR s.lastname LIKE '%\" . $p['blshpname'] . \"%')\";\n }",
" if (!empty($p['email'])) {\n $sqlwhere .= \" AND (b.email LIKE '%\" . $p['email'] . \"%'\";\n $sqlwhere .= \" OR s.email LIKE '%\" . $p['email'] . \"%')\";\n }",
" if (!empty($p['zip'])) {\n if ($p['bl-sp-zip'] == 'b') $sqlwhere .= \" AND b.zip LIKE '%\" . $p['zip'] . \"%'\";\n else if ($p['bl-sp-zip'] == 's') $sqlwhere .= \" AND s.zip LIKE '%\" . $p['zip'] . \"%'\";\n }",
" if (isset($p['state'])) {\n $inc = 0;\n $sqltmp = '';\n foreach ($p['state'] as $s) {\n if ($s == -1) continue;\n else if ($inc == 0) {\n $inc++;\n if ($p['bl-sp-state'] == 'b') $sqltmp .= \" AND (b.state = \" . $s;\n else if ($p['bl-sp-state'] == 's') $sqltmp .= \" AND (s.state = \" . $s;\n } else {\n if ($p['bl-sp-state'] == 'b') $sqltmp .= \" OR b.state = \" . $s;\n else if ($p['bl-sp-state'] == 's') $sqltmp .= \" OR s.state = \" . $s;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" if (isset($p['payment_method'])) {\n $inc = 0;\n $sqltmp = '';\n foreach ($p['payment_method'] as $s) {\n if ($s == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (o.order_status_id = \" . $s;\n } else {\n $sqltmp .= \" OR o.order_status_id = \" . $s;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" //echo $sql . $sqlwhere . \"<br>\";\n /*\n Need: order, orderitems, order status, ordertype, billingmethods, geo region, shipping methods, products",
" [date-startdate] => \n [time-h-startdate] => \n [time-m-startdate] => ",
" [ampm-startdate] => am",
" [date-enddate] => \n [time-h-enddate] => \n [time-m-enddate] => ",
" [ampm-enddate] => am\n [order_status] => Array\n (\n [0] => 0\n [1] => 1\n [2] => 2\n )",
" [order_type] => Array\n (\n [0] => 0\n [1] => 2\n )",
" [order-range-op] => e",
" [order-range-num] => ",
" [order-price-op] => l",
" [order-price-num] => \n [pnam] => \n [sku] => ",
" [discounts] => Array\n (\n [0] => -1\n )\n",
" [blshpname] => \n [email] => ",
" [bl-sp-zip] => s",
" [zip] => ",
" [bl-sp-state] => s\n [state] => Array\n (\n [0] => -1\n )",
" [status] => Array\n (\n [0] => -1\n )",
" )\n */\n expSession::set('order_print_query', $sql . $sqlwhere);\n //$where = 1;//$this->aggregateWhereClause();\n //$order = 'id';\n //$prod = new product();\n // $order = new order();",
" //$items = $prod->find('all', 1, 'id DESC',25); \n //$items = $order->find('all', 1, 'id DESC',25); ",
" //$res = $mod->find('all',$sql,'id',25);",
" //eDebug($items);",
" $page = new expPaginator(array(\n //'model'=>'order',\n //'records'=>$items,\n // 'where'=>$where,\n 'sql' => $sql . $sqlwhere,\n 'limit' => empty($this->config['limit']) ? 25 : $this->config['limit'],\n 'order' => 'invoice_id',\n 'order_direction' => 'DESC',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n 'columns' => array(\n 'actupon' => true,\n gt('Order #') => 'invoice_id|controller=order,action=show,showby=id',\n gt('Date') => 'purchased_date',\n gt('First') => 'bfirst',\n gt('Last') => 'blast',\n gt('Total') => 'grand_total',\n gt('Status') => 'status_title'\n ),\n ));",
" $action_items = array(\n 'print_orders' => 'Print Orders',\n 'export_odbc' => 'Export Shipping Data to CSV'\n );\n assign_to_template(array(\n 'page' => $page,\n 'action_items' => $action_items\n ));\n }",
" function order_report() {\n // stub function. I'm sure eventually we can pull up exising reports to pre-populate our form.\n $os = new order_status();\n $oss = $os->find('all');\n $order_status = array();\n $order_status[-1] = gt('--Any--');\n foreach ($oss as $status) {\n $order_status[$status->id] = $status->title;\n }",
" $ot = new order_type();\n $ots = $ot->find('all');\n $order_type = array();\n $order_type[-1] = gt('--Any--');\n foreach ($ots as $orderType) {\n $order_type[$orderType->id] = $orderType->title;\n }",
" $dis = new discounts();\n $diss = $dis->find('all');\n $discounts = array();\n $discounts[-1] = gt('--Any--');\n foreach ($diss as $discount) {\n $discounts[$discount->id] = $discount->coupon_code;\n }",
" /*$geo = new geoRegion();",
" $geos = $geo->find('all'); ",
" $states = array();\n $states[-1] = gt('--Any--');\n foreach ($geos as $skey=>$state)\n {\n $states[$skey] = $state->name;\n } */",
" $payment_methods = billingmethod::$payment_types;\n $payment_methods[-1] = gt('--Any--');\n ksort($payment_methods);\n //array('-1'=>'', 'V'=>'Visa','MC'=>'Mastercard','D'=>'Discover','AMEX'=>'American Express','PP'=>'PayPal','GC'=>'Google Checkout','Other'=>'Other');",
" //eDebug(mktime(0,0,0,(strftime(\"%m\")-1),1,strftime(\"%Y\")));\n// $prev_month = strftime(\"%A, %d %B %Y\", mktime(0,0,0,(strftime(\"%m\")-1),1,strftime(\"%Y\")));",
" //eDebug(strftime(\"%A, %d %B %Y\", mktime(0,0,0,(strftime(\"%m\")-1),1,strftime(\"%Y\")))); ",
"// $now_date = strftime(\"%A, %d %B %Y\");\n $prev_month = strftime(DISPLAY_DATE_FORMAT, mktime(0, 0, 0, (strftime(\"%m\") - 1), 1, strftime(\"%Y\")));\n $now_date = strftime(DISPLAY_DATE_FORMAT);\n $now_hour = strftime(\"%I\");\n $now_min = strftime(\"%M\");\n $now_ampm = strftime(\"%p\");",
" assign_to_template(array(\n 'prev_month' => $prev_month,\n 'now_date' => $now_date,\n 'now_hour' => $now_hour,\n 'now_min' => $now_min,\n 'now_ampm' => $now_ampm,\n 'order_status' => $order_status,\n 'discounts' => $discounts,\n// 'states'=>$states,\n 'order_type' => $order_type,\n 'payment_methods' => $payment_methods\n ));\n }",
" function generateOrderReport() {\n global $db;\n //eDebug($this->params);\n $p = $this->params;",
" //eDebug();",
" //build ",
" $start_sql = \"SELECT DISTINCT(o.id), \";\n $count_sql = \"SELECT COUNT(DISTINCT(o.id)) as c, \";\n $sql = \"o.invoice_id, FROM_UNIXTIME(o.purchased,'%c/%e/%y %h:%i:%s %p') as purchased_date, b.firstname as bfirst, b.lastname as blast, concat('\".expCore::getCurrencySymbol().\"',format(o.grand_total,2)) as grand_total, os.title as status_title, ot.title as order_type\";\n if ((count($p['order_status_changed']) == 1 && $p['order_status_changed'][0] != -1) || count($p['order_status_changed']) > 1 || (!empty($p['include_status_date']) && (!empty($p['date-sstartdate']) || !empty($p['date-senddate'])))) $sql .= \", FROM_UNIXTIME(osc.created_at,'%c/%e/%y %h:%i:%s %p') as status_changed_date\";\n $sql .= \" from \" . $db->prefix . \"orders as o \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"orderitems as oi ON oi.orders_id = o.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"order_type as ot ON ot.id = o.order_type_id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"product as p ON oi.product_id = p.id \";\n //if ($p['order_type'][0] != -1) $sql .= \"INNER JOIN \" . $db->prefix . \"order_type as ot ON o.order_type_id = ot.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"order_status as os ON os.id = o.order_status_id \";\n if ((count($p['order_status_changed']) == 1 && $p['order_status_changed'][0] != -1) || count($p['order_status_changed']) > 1 || (!empty($p['include_status_date']) && (!empty($p['date-sstartdate']) || !empty($p['date-senddate'])))) $sql .= \"INNER JOIN \" . $db->prefix . \"order_status_changes as osc ON osc.orders_id = o.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"billingmethods as b ON b.orders_id = o.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"shippingmethods as s ON s.id = oi.shippingmethods_id \";\n $sql .= \"LEFT JOIN \" . $db->prefix . \"geo_region as gr ON (gr.id = b.state OR gr.id = s.state) \";\n if ($p['discounts'][0] != -1) $sql .= \"LEFT JOIN \" . $db->prefix . \"order_discounts as od ON od.orders_id = o.id \";",
" $sqlwhere = \"WHERE o.purchased != 0\";",
" if (!empty($p['include_purchased_date']) && !empty($p['date-pstartdate'])) $sqlwhere .= \" AND o.purchased >= \" . strtotime($p['date-pstartdate'] . \" \" . $p['time-h-pstartdate'] . \":\" . $p['time-m-pstartdate'] . \" \" . $p['ampm-pstartdate']);\n /*if ($p->['time-h-startdate'] == )\n if ($p->['time-m-startdate'] == )\n if ($p->['ampm-startdate'] == )*/\n if (!empty($p['include_purchased_date']) && !empty($p['date-penddate'])) $sqlwhere .= \" AND o.purchased <= \" . strtotime($p['date-penddate'] . \" \" . $p['time-h-penddate'] . \":\" . $p['time-m-penddate'] . \" \" . $p['ampm-penddate']);\n /*if ($p->['date-enddate'] == )\n if ($p->['time-h-enddate'] == )\n if ($p->['time-m-enddate'] == )\n if ($p->['ampm-enddate'] == )*/\n if (!empty($p['include_status_date']) && !empty($p['date-sstartdate'])) $sqlwhere .= \" AND osc.created_at >= \" . strtotime($p['date-sstartdate'] . \" \" . $p['time-h-sstartdate'] . \":\" . $p['time-m-sstartdate'] . \" \" . $p['ampm-sstartdate']);",
" if (!empty($p['include_status_date']) && !empty($p['date-senddate'])) $sqlwhere .= \" AND osc.created_at <= \" . strtotime($p['date-senddate'] . \" \" . $p['time-h-senddate'] . \":\" . $p['time-m-senddate'] . \" \" . $p['ampm-senddate']);",
" $inc = 0;\n $sqltmp = '';\n foreach ($p['order_status'] as $os) {\n if ($os == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (o.order_status_id = \" . $os;\n } else {\n $sqltmp .= \" OR o.order_status_id = \" . $os;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" $inc = 0;\n $sqltmp = '';\n foreach ($p['order_status_changed'] as $osc) {\n if ($osc == -1) continue;\n else if ($inc == 0) {\n $inc++;\n //$sqltmp .= \" AND ((osc.to_status_id = \" . $osc . \" AND (osc.from_status_id != \" . $osc . \")\";\n $sqltmp .= \" AND (osc.to_status_id = \" . $osc;\n } else {\n //$sqltmp .= \" OR (osc.to_status_id = \" . $osc . \" AND (osc.from_status_id != \" . $osc . \")\";\n $sqltmp .= \" OR osc.to_status_id = \" . $osc;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" $inc = 0;\n $sqltmp = '';\n foreach ($p['order_type'] as $ot) {\n if ($ot == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (o.order_type_id = \" . $ot;\n } else {\n $sqltmp .= \" OR o.order_type_id = \" . $ot;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!empty($p['order-range-num'])) {\n $operator = '';\n switch ($p['order-range-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND o.invoice_id\" . $operator . $p['order-range-num'];\n }",
" if (!empty($p['order-price-num'])) {\n $operator = '';\n switch ($p['order-price-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND o.grand_total\" . $operator . $p['order-price-num'];\n }",
" if (!empty($p['pnam'])) {\n $sqlwhere .= \" AND p.title LIKE '%\" . $p['pnam'] . \"%'\";\n }",
" if (!empty($p['sku'])) {\n $sqlwhere .= \" AND p.model LIKE '%\" . $p['sku'] . \"%'\";\n }",
" $inc = 0;\n $sqltmp = '';\n if (isset($p['product_status'])) {\n foreach ($p['product_status'] as $pstat) {\n if ($pstat == -1 || empty($pstat)) continue;",
" $product_status = new product_status($pstat);\n if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (oi.products_status = '\" . $product_status->title . \"'\";\n } else {\n $sqltmp .= \" OR oi.products_status = '\" . $product_status->title . \"'\";\n }\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!empty($p['uidata'])) {\n $sqlwhere .= \" AND oi.user_input_fields != '' AND oi.user_input_fields != 'a:0:{}'\";\n }",
" $inc = 0;\n $sqltmp = '';\n foreach ($p['discounts'] as $d) {\n if ($d == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (od.discounts_id = \" . $d;\n } else {\n $sqltmp .= \" OR od.discounts_id = \" . $d;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!empty($p['blshpname'])) {\n $sqlwhere .= \" AND (b.firstname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR s.firstname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR b.lastname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR s.lastname LIKE '%\" . $p['blshpname'] . \"%')\";\n }",
" if (!empty($p['email'])) {\n $sqlwhere .= \" AND (b.email LIKE '%\" . $p['email'] . \"%'\";\n $sqlwhere .= \" OR s.email LIKE '%\" . $p['email'] . \"%')\";\n }",
" if (!empty($p['zip'])) {\n if ($p['bl-sp-zip'] == 'b') $sqlwhere .= \" AND b.zip LIKE '%\" . $p['zip'] . \"%'\";\n else if ($p['bl-sp-zip'] == 's') $sqlwhere .= \" AND s.zip LIKE '%\" . $p['zip'] . \"%'\";\n }",
" if (isset($p['state'])) {\n $inc = 0;\n $sqltmp = '';\n foreach ($p['state'] as $s) {\n if ($s == -1) continue;\n else if ($inc == 0) {\n $inc++;\n if ($p['bl-sp-state'] == 'b') $sqltmp .= \" AND (b.state = \" . $s;\n else if ($p['bl-sp-state'] == 's') $sqltmp .= \" AND (s.state = \" . $s;\n } else {\n if ($p['bl-sp-state'] == 'b') $sqltmp .= \" OR b.state = \" . $s;\n else if ($p['bl-sp-state'] == 's') $sqltmp .= \" OR s.state = \" . $s;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" if (isset($p['payment_method'])) {\n $inc = 0;\n $sqltmp = '';",
" //get each calculator's id ",
"\n foreach ($p['payment_method'] as $s) {\n if ($s == -1) continue;\n if ($s == 'VisaCard' || $s == 'AmExCard' || $s == 'MasterCard' || $s == 'DiscoverCard') {\n $paymentQuery = 'b.billing_options LIKE \"%' . $s . '%\"';\n } else {\n $bc = new billingcalculator();\n $calc = $bc->findBy('calculator_name', $s);\n $paymentQuery = 'billingcalculator_id = ' . $calc->id;\n }",
" if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND ( \" . $paymentQuery;\n } else {\n $sqltmp .= \" OR \" . $paymentQuery;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" //echo $sql . $sqlwhere . \"<br>\";\n /*\n Need: order, orderitems, order status, ordertype, billingmethods, geo region, shipping methods, products",
" [date-startdate] => \n [time-h-startdate] => \n [time-m-startdate] => ",
" [ampm-startdate] => am",
" [date-enddate] => \n [time-h-enddate] => \n [time-m-enddate] => ",
" [ampm-enddate] => am\n [order_status] => Array\n (\n [0] => 0\n [1] => 1\n [2] => 2\n )",
" [order_type] => Array\n (\n [0] => 0\n [1] => 2\n )",
" [order-range-op] => e",
" [order-range-num] => ",
" [order-price-op] => l",
" [order-price-num] => \n [pnam] => \n [sku] => ",
" [discounts] => Array\n (\n [0] => -1\n )\n",
" [blshpname] => \n [email] => ",
" [bl-sp-zip] => s",
" [zip] => ",
" [bl-sp-state] => s\n [state] => Array\n (\n [0] => -1\n )",
" [status] => Array\n (\n [0] => -1\n )",
" )\n */",
" //$sqlwhere .= \" ORDER BY purchased_date DESC\";\n $count_sql .= $sql . $sqlwhere;\n $sql = $start_sql . $sql;\n expSession::set('order_print_query', $sql . $sqlwhere);\n $reportRecords = $db->selectObjectsBySql($sql . $sqlwhere);\n expSession::set('order_export_values', $reportRecords);",
" //eDebug(expSession::get('order_export_values'));\n //$where = 1;//$this->aggregateWhereClause();\n //$order = 'id';\n //$prod = new product();\n // $order = new order();",
" //$items = $prod->find('all', 1, 'id DESC',25); \n //$items = $order->find('all', 1, 'id DESC',25); ",
" //$res = $mod->find('all',$sql,'id',25);\n //eDebug($items);",
" //eDebug($sql . $sqlwhere); ",
"\n $page = new expPaginator(array(\n //'model'=>'order',\n //'records'=>$items,\n // 'where'=>$where,\n 'count_sql' => $count_sql,\n 'sql' => $sql . $sqlwhere,\n 'limit' => empty($this->config['limit']) ? 350 : $this->config['limit'],\n 'order' => 'invoice_id',\n 'dir' => 'DESC',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n 'columns' => array(\n 'actupon' => true,\n gt('Order #') => 'invoice_id|controller=order,action=show,showby=id',\n gt('Purchased Date') => 'purchased_date',\n gt('First') => 'bfirst',\n gt('Last') => 'blast',\n gt('Total') => 'grand_total',\n gt('Status Changed Date') => 'status_changed_date',\n gt('Order Type') => 'order_type',\n gt('Status') => 'status_title'\n ),\n ));\n",
" //strftime(\"%a %d-%m-%Y\", get_first_day(3, 1, 2007)); Thursday, 1 April 2010 ",
" //$d_month_previous = date('n', mktime(0,0,0,(strftime(\"%m\")-1),1,strftime(\"%Y\")));",
" $action_items = array(\n 'print_orders' => 'Print Orders',\n 'export_odbc' => 'Export Shipping Data to CSV',\n 'export_status_report' => 'Export Order Status Data to CSV',\n 'export_inventory' => 'Export Inventory Data to CSV',\n 'export_user_input_report' => 'Export User Input Data to CSV',\n 'export_order_items' => 'Export Order Items Data to CSV',\n 'show_payment_summary' => 'Show Payment & Tax Summary'\n );\n assign_to_template(array(\n 'page' => $page,\n 'action_items' => $action_items\n ));\n }",
" function show_payment_summary() {\n global $db;",
" $payments = billingmethod::$payment_types;",
" $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n if (!empty($this->params['act-upon'])) foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);",
" $payment_summary = array();\n // $Credit Cards\n// $sql = \"SELECT orders_id, billing_cost, billing_options, calculator_name, user_title FROM \" . $db->prefix . \"billingmethods, \" . $db->prefix . \"billingcalculator WHERE \" . $db->prefix . \"billingcalculator.id = billingcalculator_id and orders_id IN (\" . $orders_string . \")\";\n $sql = \"SELECT orders_id, billing_cost, billing_options, calculator_name, title FROM \" . $db->prefix . \"billingmethods, \" . $db->prefix . \"billingcalculator WHERE \" . $db->prefix . \"billingcalculator.id = billingcalculator_id and orders_id IN (\" . $orders_string . \")\";\n $res = $db->selectObjectsBySql($sql);\n if (!empty($res)) {\n foreach ($res as $item) {\n $options = expUnserialize($item->billing_options);\n if (!empty($item->billing_cost)) {\n// if ($item->user_title == 'Credit Card') {\n if ($item->title == 'Credit Card') { //FIXME there is no billingmethod->title ...this is translated??\n if (!empty($options->cc_type)) {\n //@$payment_summary[$payments[$options->cc_type]] += $item->billing_cost;\n @$payment_summary[$payments[$options->cc_type]] += $options->result->amount_captured;\n }\n } else {\n @$payment_summary[$payments[$item->calculator_name]] += $item->billing_cost;\n }\n }\n }\n }",
" $payments_key_arr = array();\n $payment_values_arr = array();\n foreach ($payment_summary as $key => $item) {\n $payments_key_arr[] = '\"' . $key . '\"';\n $payment_values_arr[] = round($item, 2);\n }\n $payments_key = implode(\",\", $payments_key_arr);\n $payment_values = implode(\",\", $payment_values_arr);",
" //tax\n// $tax_sql = \"SELECT SUM(tax) as tax_total FROM \" . $db->prefix . \"orders WHERE id IN (\" . $orders_string . \")\";\n// $tax_res = $db->selectObjectBySql($tax_sql);\n $tax_types = taxController::getTaxRates();\n// $tax_type_formatted = $tax_types[0]->zonename . ' - ' . $tax_types[0]->classname . ' - ' . $tax_types[0]->rate . '%';",
" $ord = new order();\n $tax_res2 = $ord->find('all',\"id IN (\" . $orders_string . \")\");",
" $taxes = array();\n foreach ($tax_res2 as $tt) {\n $key = key($tt->taxzones);\n if (!empty($key)) {\n $tname = $tt->taxzones[$key]->name;\n if (!isset($taxes[$key]['format'])) {\n $taxes[$key] = array();\n $taxes[$key]['total'] =0;\n }\n $taxes[$key]['format'] = $tname . ' - ' . $tt->taxzones[$key]->rate . '%';\n $taxes[$key]['total'] += $tt->tax;\n }\n }",
" assign_to_template(array(\n 'payment_summary' => $payment_summary,\n 'payments_key' => $payments_key,\n 'payment_values' => $payment_values,\n// 'tax_total' => !empty($tax_res->tax_total) ? $tax_res->tax_total : 0,\n// 'tax_type' => $tax_type_formatted,\n 'taxes' => $taxes\n ));\n }",
" function export_user_input_report() {\n $order = new order();\n $out = '\"ITEM_NAME\",\"QUANTITY\",\"PERSONALIZATION\"' . chr(13) . chr(10);\n //eDebug($this->params,true);\n $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);\n $orders = $order->find('all', 'id IN (' . $orders_string . ')');\n //eDebug($orders,true);\n $pattern = '/\\(.*\\)/i';\n $items = array();\n $top = array();\n foreach ($orders as $order) { //eDebug($order,true);\n foreach ($order->orderitem as $oi) {\n // eDebug($oi,true);\n $item = array();\n if ($oi->user_input_fields == '' || $oi->user_input_fields == 'a:0:{}') continue;\n else $item['user_input_data'] = expUnserialize($oi->user_input_fields);;",
" $model = preg_replace($pattern, '', preg_replace('/\\s/', '', $oi->products_model));\n $item['model'] = $model;\n //$item['name'] = strip_tags($oi->products_name);\n $item['qty'] = $oi->quantity;",
" $items[] = $item;\n }\n }\n unset($item);\n foreach ($items as $item) {\n $line = '';",
" //$line = expString::outputField(\"SMC Inventory - Laurie\"); ",
" $line .= expString::outputField($item['model']);\n //$line.= expString::outputField($item['name']);\n $line .= expString::outputField($item['qty']);\n $ui = array();\n $uiInfo = '';\n foreach ($item['user_input_data'] as $tlArray) {\n foreach ($tlArray as $ifKey => $if) {\n $uiInfo .= $ifKey . '=' . $if . \" | \";\n }\n }\n $line .= expString::outputField(strtoupper(substr_replace($uiInfo, '', strrpos($uiInfo, ' |'), strlen(' |'))), chr(13) . chr(10));\n $out .= $line;\n }\n //eDebug($out,true);\n self::download($out, 'User_Input_Export_' . time() . '.csv', 'application/csv');\n // [firstname] => Fred [middlename] => J [lastname] => Dirkse [organization] => OIC Group, Inc. [address1] => PO Box 1111 [address2] => [city] => Peoria [state] => 23 [zip] => 61653 [country] => [phone] => 309-555-1212 begin_of_the_skype_highlighting 309-555-1212 end_of_the_skype_highlighting [email] => fred@oicgroup.net [shippingcalculator_id] => 4 [option] => 01 [option_title] => 8-10 Day [shipping_cost] => 5.95\n }",
" function export_inventory() {\n $order = new order();\n $out = '\"BADDR_LAST_NM\",\"ITEM_NAME\",\"ITEM_DESC\",\"ITEM_QUANTITY\"' . chr(13) . chr(10);\n //eDebug($this->params,true);\n $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);\n $orders = $order->find('all', 'id IN (' . $orders_string . ')');\n //eDebug($orders,true);\n $pattern = '/\\(.*\\)/i';\n $items = array();\n $top = array();\n foreach ($orders as $order) { //eDebug($order,true);\n foreach ($order->orderitem as $oi) {\n $model = preg_replace($pattern, '', preg_replace('/\\s/', '', $oi->products_model));\n if (stripos($model, 'DUI') === 0) {\n $top[$model]['name'] = strip_tags($oi->products_name);\n if (isset($top[$model]['qty'])) $top[$model]['qty'] += $oi->quantity;\n else $top[$model]['qty'] = $oi->quantity;\n } else {\n $items[$model]['name'] = strip_tags($oi->products_name);\n if (isset($items[$model]['qty'])) $items[$model]['qty'] += $oi->quantity;\n else $items[$model]['qty'] = $oi->quantity;\n }\n }\n }\n ksort($top, SORT_STRING);\n ksort($items, SORT_STRING);\n foreach ($top as $model => $item) {\n $line = '';\n $line = expString::outputField(\"SMC Inventory - Laurie\");\n $line .= expString::outputField($model);\n $line .= expString::outputField($item['name']);\n $line .= expString::outputField($item['qty'], chr(13) . chr(10));\n $out .= $line;\n }\n foreach ($items as $model => $item) {\n $line = '';\n $line = expString::outputField(\"SMC Inventory - Laurie\");\n $line .= expString::outputField($model);\n $line .= expString::outputField($item['name']);\n $line .= expString::outputField($item['qty'], chr(13) . chr(10));\n $out .= $line;\n }\n //eDebug($out,true);\n self::download($out, 'Inventory_Export_' . time() . '.csv', 'application/csv');\n // [firstname] => Fred [middlename] => J [lastname] => Dirkse [organization] => OIC Group, Inc. [address1] => PO Box 1111 [address2] => [city] => Peoria [state] => 23 [zip] => 61653 [country] => [phone] => 309-555-1212 begin_of_the_skype_highlighting 309-555-1212 end_of_the_skype_highlighting [email] => fred@oicgroup.net [shippingcalculator_id] => 4 [option] => 01 [option_title] => 8-10 Day [shipping_cost] => 5.95",
" }",
" function generateProductReport() {\n global $db;\n // eDebug($this->params);\n $p = $this->params;\n $sqlids = \"SELECT DISTINCT(p.id) from \";\n $count_sql = \"SELECT COUNT(DISTINCT(p.id)) as c FROM \";\n $sqlstart = \"SELECT DISTINCT(p.id), p.title, p.model, concat('\".expCore::getCurrencySymbol().\"',format(p.base_price,2)) as base_price\";//, ps.title as status from \";\n $sql = $db->prefix . \"product as p \";\n if (!isset($p['allproducts'])){\n $sql .= \"INNER JOIN \" . $db->prefix . \"product_status as ps ON p.product_status_id = ps.id \";\n $sqlstart .= \", ps.title as status from \";\n if (!isset($p['uncategorized'])){\n $sql .= \"INNER JOIN \" . $db->prefix . \"product_storeCategories as psc ON p.id = psc.product_id \";\n }\n } else {\n $sqlstart .= \" from \";\n }\n //$sqlidsjoin = \"INNER JOIN \" . $db->prefix . \"product as childp ON p.id = childp.parent_id \";\n $sqlwhere = 'WHERE (1=1 ';",
" $inc = 0;\n $sqltmp = '';\n if (isset($p['product_status'])) {\n foreach ($p['product_status'] as $os) {\n if ($os == '') continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (p.product_status_id = \" . $os;\n } else {\n $sqltmp .= \" OR p.product_status_id = \" . $os;\n }",
" }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" $inc = 0;\n $sqltmp = '';\n if (!empty($p['product_type'])) foreach ($p['product_type'] as $ot) {\n if ($ot == '') continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (p.product_type = '\" . $ot . \"'\";\n } else {\n $sqltmp .= \" OR p.product_type = '\" . $ot . \"'\";\n }",
" }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!isset($p['allproducts'])) {\n if (!isset($p['uncategorized'])) {\n $inc = 0;\n $sqltmp = '';\n if (!empty($p['storeCategory'])) foreach ($p['storeCategory'] as $ot) {\n if ($ot == '') continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (psc.storecategories_id = \" . $ot;\n } else {\n $sqltmp .= \" OR psc.storecategories_id = \" . $ot;\n }",
" }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n } else {\n $sqlwhere .= \" AND psc.storecategories_id = 0 AND p.parent_id = 0\";\n }\n }",
" if (!empty($p['product-range-num'])) {\n $operator = '';\n switch ($p['product-range-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND p.id\" . $operator . $p['product-range-num'];\n }",
" $inc = 0;\n $sqltmp = '';\n if (isset($p['company'])) {\n foreach ($p['company'] as $os) {\n if ($os == '') continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (p.companies_id = \" . $os;\n } else {\n $sqltmp .= \" OR p.companies_id = \" . $os;\n }",
" }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" if (!empty($p['product-price-num'])) {\n $operator = '';\n switch ($p['product-price-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND p.base_price\" . $operator . $p['product-price-num'];\n }",
" if (!empty($p['pnam'])) {\n $sqlwhere .= \" AND p.title LIKE '%\" . $p['pnam'] . \"%'\";\n }",
" if (!empty($p['sku'])) {\n $sqlwhere .= \" AND p.model LIKE '%\" . $p['sku'] . \"%'\";\n }",
" $sqlwhere .= \")\";",
" $exportSQL = $sqlids . $sql . $sqlwhere; // . \")\"; // \" OR p.parent_id IN (\".$sqlids . $sql . $sqlwhere . \")\";\n //$sqlidswhere = \" OR p.id IN (SELECT id FROM\".$db->prefix.\"_product WHERE parent_id=)\";\n// eDebug($sqlstart . $sql . $sqlwhere);\n// eDebug($count_sql . $sql . $sqlwhere);\n// eDebug(\"Stored:\" . $exportSQL);\n expSession::set('product_export_query', $exportSQL);\n //expSession::set('product_export_query', \"SELECT DISTINCT(p.id) FROM `exponent_product` p WHERE (title like '%Velcro%' OR feed_title like '%Velcro%' OR title like '%Multicam%' OR feed_title like '%Multicam%') AND parent_id = 0\");",
" $product = new product();",
" //$items = $product->find('all', '', 'id', 25); \n //$page = new expPaginator(); \n //eDebug($page,true); ",
" $page = new expPaginator(array(\n// 'model' => 'product',\n //'records'=>$items,\n // 'where'=>$where,\n 'sql' => $sqlstart . $sql . $sqlwhere,\n //'sql'=>\"SELECT DISTINCT(p.id), p.title, p.model, p.base_price FROM `exponent_product` p WHERE (title like '%Velcro%' OR feed_title like '%Velcro%' OR title like '%Multicam%' OR feed_title like '%Multicam%') AND parent_id = 0\",\n //'count_sql'=>\"SELECT COUNT(DISTINCT(p.id)) FROM `exponent_product` p WHERE (title like '%Velcro%' OR feed_title like '%Velcro%' OR title like '%Multicam%' OR feed_title like '%Multicam%') AND parent_id = 0\",\n 'count_sql' => $count_sql . $sql . $sqlwhere,\n 'limit' => empty($this->config['limit']) ? 350 : $this->config['limit'],\n 'order' => 'id',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => 'store',\n 'action' => $this->params['action'],\n 'columns' => array(\n 'actupon' => true,\n 'ID' => 'id',\n gt('Product') => 'title|controller=store,action=show,showby=id',\n 'SKU' => 'model',\n gt('Price') => 'base_price',\n gt('Status') => 'status'\n ),\n //'columns'=>array('Product'=>'title','SKU'=>'model'),\n ));\n //eDebug($page,true);\n /*$page = new expPaginator(array(\n 'model'=>'order',\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n 'sql'=>$sql,\n 'order'=>'purchased',\n 'dir'=>'DESC',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns'=>array(\n 'Customer'=>'lastname',",
" 'Invoice #'=>'invoice_id', ",
" 'Total'=>'total',\n 'Date Purchased'=>'purchased',\n 'Status'=>'order_status_id',\n )\n )); */\n $action_items = array(\n 'batch_export' => 'Export Product List to CSV',\n 'status_export' => 'Export Product Status Report to CSV'\n );\n assign_to_template(array(\n 'page' => $page,\n 'action_items' => $action_items\n ));",
" // \n // \n // assign_to_template(array('page'=>$page)); ",
" }",
" /**\n * @deprecated 2.3.3 moved to expString\n */\n public static function parseAndTrimExport($str, $isHTML = false) { //�Death from above�? �",
" //echo \"1<br>\"; eDebug($str); ",
"\n $str = str_replace(\"�\", \"’\", $str);\n $str = str_replace(\"�\", \"‘\", $str);\n $str = str_replace(\"�\", \"®\", $str);\n $str = str_replace(\"�\", \"-\", $str);\n $str = str_replace(\"�\", \"—\", $str);\n $str = str_replace(\"�\", \"”\", $str);\n $str = str_replace(\"�\", \"“\", $str);\n $str = str_replace(\"\\r\\n\", \" \", $str);\n $str = str_replace(\"\\t\", \" \", $str);\n $str = str_replace(\",\", \"\\,\", $str);\n $str = str_replace(\"�\", \"¼\", $str);\n $str = str_replace(\"�\", \"½\", $str);\n $str = str_replace(\"�\", \"¾\", $str);",
" if (!$isHTML) {\n $str = str_replace('\\\"', \""\", $str);\n $str = str_replace('\"', \""\", $str);\n } else {\n $str = str_replace('\"', '\"\"', $str);\n }",
" //$str = htmlspecialchars($str);\n //$str = utf8_encode($str);\n $str = trim(str_replace(\"�\", \"™\", $str));\n //echo \"2<br>\"; eDebug($str,die);\n return $str;\n }",
" /**\n * @deprecated 2.3.3 moved to expString\n */\n public static function parseAndTrimImport($str, $isHTML = false) { //�Death from above�? �\n //echo \"1<br>\"; eDebug($str);\n// global $db;",
" $str = str_replace(\"�\", \"’\", $str);\n $str = str_replace(\"�\", \"‘\", $str);\n $str = str_replace(\"�\", \"®\", $str);\n $str = str_replace(\"�\", \"-\", $str);\n $str = str_replace(\"�\", \"—\", $str);\n $str = str_replace(\"�\", \"”\", $str);\n $str = str_replace(\"�\", \"“\", $str);\n $str = str_replace(\"\\r\\n\", \" \", $str);\n $str = str_replace(\"\\,\", \",\", $str);\n $str = str_replace('\"\"', '\"', $str); //do this no matter what...in case someone added a quote in a non HTML field\n if (!$isHTML) {",
" //if HTML, then leave the single quotes alone, otheriwse replace w/ special Char ",
" $str = str_replace('\"', \""\", $str);\n }\n $str = str_replace(\"�\", \"¼\", $str);\n $str = str_replace(\"�\", \"½\", $str);\n $str = str_replace(\"�\", \"¾\", $str);\n //$str = htmlspecialchars($str);\n //$str = utf8_encode($str);\n// if (DB_ENGINE=='mysqli') {\n//\t $str = @mysqli_real_escape_string($db->connection,trim(str_replace(\"�\", \"™\", $str)));\n// } elseif(DB_ENGINE=='mysql') {\n// $str = @mysql_real_escape_string(trim(str_replace(\"�\", \"™\", $str)),$db->connection);\n// } else {\n//\t $str = trim(str_replace(\"�\", \"™\", $str));\n// }\n $str = @expString::escape(trim(str_replace(\"�\", \"™\", $str)));\n //echo \"2<br>\"; eDebug($str,die);\n return $str;\n }",
" /**\n * @deprecated 2.3.3 moved to expString\n */\n public static function parseAndTrim($str, $isHTML = false) { //�Death from above�? �\n //echo \"1<br>\"; eDebug($str);\n// global $db;",
" $str = str_replace(\"�\", \"’\", $str);\n $str = str_replace(\"�\", \"‘\", $str);\n $str = str_replace(\"�\", \"®\", $str);\n $str = str_replace(\"�\", \"-\", $str);\n $str = str_replace(\"�\", \"—\", $str);\n $str = str_replace(\"�\", \"”\", $str);\n $str = str_replace(\"�\", \"“\", $str);\n $str = str_replace(\"\\r\\n\", \" \", $str);",
" //$str = str_replace(\",\",\"\\,\",$str); ",
"\n $str = str_replace('\\\"', \""\", $str);\n $str = str_replace('\"', \""\", $str);\n $str = str_replace(\"�\", \"¼\", $str);\n $str = str_replace(\"�\", \"½\", $str);\n $str = str_replace(\"�\", \"¾\", $str);\n //$str = htmlspecialchars($str);\n //$str = utf8_encode($str);\n// if (DB_ENGINE=='mysqli') {\n//\t $str = @mysqli_real_escape_string($db->connection,trim(str_replace(\"�\", \"™\", $str)));\n// } elseif(DB_ENGINE=='mysql') {\n// $str = @mysql_real_escape_string(trim(str_replace(\"�\", \"™\", $str)),$db->connection);\n// } else {\n//\t $str = trim(str_replace(\"�\", \"™\", $str));\n// }\n $str = @expString::escape(trim(str_replace(\"�\", \"™\", $str)));\n //echo \"2<br>\"; eDebug($str,die);\n return $str;\n }",
" /**\n * @deprecated 2.3.3 moved to expString\n */\n function outputField($val, $eof = ',', $isHTML = false) {\n $newVal = expString::parseAndTrimExport($val, $isHTML);\n if ($newVal != '') return '\"' . $newVal . '\"' . $eof;\n else return $eof;\n }",
" function print_orders() {\n// global $db, $timer;\n //eDebug($this->params,true);\n //eDebug($timer->mark());\n //eDebug( expSession::get('order_print_query'));\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n //$sql = expSession::get('order_print_query');\n //eDebug($sql);\n //expSession::set('product_export_query','');\n //$orders = $db->selectArraysBySql($sql);\n $obs = expSession::get('order_export_values');\n usort($obs, array(\"reportController\", \"sortPrintOrders\"));\n foreach ($obs as $ob) {\n $orders[] = array('id' => $ob->id);\n }\n //eDebug($prods);\n } else {\n foreach ($this->params['act-upon'] as $order) {\n $orders[] = array('id' => $order);\n }\n }",
" //eDebug(\"Done with print_orders: \" . $timer->mark());\n //eDebug($orders,true);\n $oc = new orderController();\n $oc->getPDF($orders);\n }",
" //sort print orders by id, newest to oldest\n static function sortPrintOrders($a, $b) {\n if ($a->invoice_id > $b->invoice_id) return -1;\n else if ($a->invoice_id < $b->invoice_id) return 1;\n else if ($a->invoice_id == $b->invoice_id) return 0;\n }",
" function export_odbc() {\n $order = new order();\n $out = '\"order_id\",\"shipping_method_id\",\"shipping_option\",\"shipping_cost\",\"firstname\",\"middlename\",\"lastname\",\"organization\",\"address1\",\"address2\",\"city\",\"state\",\"zip\",\"country\",\"phone\"' . chr(13) . chr(10);\n //eDebug($this->params,true);\n $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);\n $orders = $order->find('all', 'id IN (' . $orders_string . ')');\n //eDebug($orders);\n foreach ($orders as $order) {\n $line = expString::outputField($order->invoice_id);\n foreach ($order->shippingmethods as $m) {\n $line .= expString::outputField($m->id);\n $line .= expString::outputField($m->option_title);\n $line .= expString::outputField($order->shipping_total + $order->surcharge_total);\n $line .= expString::outputField($m->firstname);\n $line .= expString::outputField($m->middlename);\n $line .= expString::outputField($m->lastname);\n $line .= expString::outputField($m->organization);\n $line .= expString::outputField($m->address1);\n $line .= expString::outputField($m->address2);\n $line .= expString::outputField($m->city);\n// $state = new geoRegion($m->state);\n //eDebug($state);\n// $line .= expString::outputField($state->code);\n $line .= expString::outputField(geoRegion::getAbbrev($m->state));\n $line .= expString::outputField($m->zip);\n// $line .= expString::outputField('US');\n $line .= expString::outputField(geoRegion::getCountryCode($m->country));\n $line .= expString::outputField($m->phone, chr(13) . chr(10));\n break;\n }\n $out .= $line;\n }\n //eDebug($out,true);\n self::download($out, 'Shipping_Export.csv', 'application/csv');\n // [firstname] => Fred [middlename] => J [lastname] => Dirkse [organization] => OIC Group, Inc. [address1] => PO Box 1111 [address2] => [city] => Peoria [state] => 23 [zip] => 61653 [country] => [phone] => 309-555-1212 begin_of_the_skype_highlighting 309-555-1212 end_of_the_skype_highlighting [email] => fred@oicgroup.net [shippingcalculator_id] => 4 [option] => 01 [option_title] => 8-10 Day [shipping_cost] => 5.95",
" }",
" function export_order_items() {\n $order = new order();\n $out = '\"order_id\",\"quantity\",\"SKU\",\"product_title\",\"firstname\",\"middlename\",\"lastname\",\"organization\",\"address1\",\"address2\",\"city\",\"state\",\"zip\"' . chr(13) . chr(10);\n //eDebug($this->params,true);\n $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);\n $orders = $order->find('all', 'id IN (' . $orders_string . ')');\n //eDebug($orders);\n foreach ($orders as $order) {\n $m = array_shift($order->shippingmethods);\n foreach ($order->orderitem as $orderitem) {\n $line = expString::outputField($order->invoice_id);\n $line .= expString::outputField($orderitem->quantity);\n $line .= expString::outputField($orderitem->products_model);\n $line .= expString::outputField($orderitem->products_name);",
" $line .= expString::outputField($m->firstname);\n $line .= expString::outputField($m->middlename);\n $line .= expString::outputField($m->lastname);\n $line .= expString::outputField($m->organization);\n $line .= expString::outputField($m->address1);\n $line .= expString::outputField($m->address2);\n $line .= expString::outputField($m->city);\n $state = new geoRegion($m->state);\n $line .= expString::outputField($state->code);\n $line .= expString::outputField($m->zip, chr(13) . chr(10));\n $out .= $line;\n }\n }\n //eDebug($out,true);\n self::download($out, 'Order_Item_Export.csv', 'application/csv');\n // [firstname] => Fred [middlename] => J [lastname] => Dirkse [organization] => OIC Group, Inc. [address1] => PO Box 1111 [address2] => [city] => Peoria [state] => 23 [zip] => 61653 [country] => [phone] => 309-555-1212 begin_of_the_skype_highlighting 309-555-1212 end_of_the_skype_highlighting [email] => fred@oicgroup.net [shippingcalculator_id] => 4 [option] => 01 [option_title] => 8-10 Day [shipping_cost] => 5.95",
" }",
" function export_status_report() {\n $order = new order();\n $out = '\"ITEM_NAME\",\"ITEM_DESC\",\"ITEM_QUANTITY\",\"ITEM_STATUS\"' . chr(13) . chr(10);\n //eDebug($this->params,true);\n $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);\n $orders = $order->find('all', 'id IN (' . $orders_string . ')', null, null, null, true, true, array('order_discounts', 'billingmethod', 'order_status_changes', 'order_status', 'order_type'), true);\n $pattern = '/\\(.*\\)/i';\n foreach ($orders as $order) {\n foreach ($order->orderitem as $oi) {\n $model = preg_replace($pattern, '', preg_replace('/\\s/', '', $oi->products_model));\n $line = '';\n $line .= expString::outputField($model);\n $line .= expString::outputField($oi->products_name);\n $line .= expString::outputField($oi->quantity);\n $line .= expString::outputField($oi->products_status, chr(13) . chr(10));\n $out .= $line;\n }\n }\n self::download($out, 'Status_Export_' . time() . '.csv', 'application/csv');\n }",
" static function download($file, $name, $type) {\n if (!headers_sent()) {\n //echo $file;\n //exit();\n ob_clean();\n header('Content-Description: File Transfer');\n header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1\n header('Pragma: public');\n// header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n // force download dialog\n header('Content-Type: application/force-download');\n //header('Content-Type: application/octet-stream', false);\n header('Content-Type: application/download', false);\n header('Content-Type: ' . $type, false);\n //header('Content-Type: application/pdf', false);\n // use the Content-Disposition header to supply a recommended filename\n header('Content-Disposition: attachment; filename=\"' . $name . '\";');\n header('Content-Transfer-Encoding: ascii');\n header('Content-Length: ' . strlen($file));\n //header('Content-Length: '.filesize($this->tmp_rendered));\n echo $file;\n //echo readfile($this->tmp_rendered);\n } else {\n echo \"Oops, headers already sent. Check DEVELOPMENT variable?\";\n }\n die();\n }",
" /**\n * @deprecated 2.3.3 moved to expString\n */\n function stripLineEndings($val) {\n return preg_replace('/\\r\\n/', ' ', trim($val));\n }",
" function productFeed() {\n// global $db;\n //check query password to avoid DDOS\n /*\n * condition = new",
" * description \n * id - SKU \n * link \n * price \n * title \n * brand - manufacturer \n * image link - fullsized image, up to 10, comma seperated \n * product type - category - \"Electronics > Audio > Audio Accessories MP3 Player Accessories\",\"Health & Beauty > Healthcare > Biometric Monitors > Pedometers\" ",
" */\n $out = '\"id\",\"condition\",\"description\",\"like\",\"price\",\"title\",\"brand\",\"image link\",\"product type\"' . chr(13) . chr(10);",
" $p = new product();\n $prods = $p->find('all', 'parent_id=0 AND ');\n //$prods = $db->selectObjects('product','parent_id=0 AND');\n }",
" function abandoned_carts() {\n global $db;",
" $allCarts = array();\n $carts = array();\n $cartsWithoutItems = array();\n $cartsWithItems = array();\n $cartsWithItemsAndInfo = array();\n $summary = array();\n $valueproducts = '';",
" $quickrange = array(0 => gt('Last 24 Hours'), 1 => gt('Last 7 Days'), 2 => gt('Last 30 Days'));\n $this->setDateParams($this->params);\n if (!isset($this->params['quickrange'])) {\n $this->params['quickrange'] = 0;\n }",
" // purchased == 0 or invoice_id == 0 on unsubmitted orders\n $sql = \"SELECT * FROM \" . $db->prefix . \"orders WHERE purchased = 0 AND edited_at >= \" . $this->tstart . \" AND edited_at <= \" . $this->tend . \" AND sessionticket_ticket NOT IN \";\n $sql .= \"(SELECT ticket FROM \" . $db->prefix . \"sessionticket) ORDER BY edited_at DESC\";\n // echo $sql;\n $allCarts = $db->selectObjectsBySql($sql);\n foreach ($allCarts as $item) {",
" $sql = \"SELECT * FROM \" . $db->prefix . \"orderitems WHERE orders_id =\" . $item->id;",
" $carts = $db->selectObjectsBySql($sql);\n foreach ($carts as $item2) {\n $valueproducts += $item2->products_price_adjusted * $item2->quantity;\n }",
" $carts['last_visit'] = date('Y-m-d, g:i:s A', $item->edited_at);\n $carts['referrer'] = $item->orig_referrer;",
" if (count($carts) > 2) {\n if (!empty($item->user_id)) {\n $u = $db->selectObject('user', 'id=' . $item->user_id);\n $carts['name'] = $u->firstname . ' ' . $u->lastname;\n $carts['email'] = $u->email;\n $cartsWithItemsAndInfo[] = $carts;\n // $cartsWithItemsAndInfo['length_of_time'] = round(abs($item->last_active - $item->start_time) / 60,2).\" minutes\";\n // $cartsWithItemsAndInfo['ip_address'] = $item->ip_address;\n // $cartsWithItemsAndInfo['referrer'] = $item->referrer;\n } else {\n $cartsWithItems[] = $carts;\n // $cartsWithItems['length_of_time'] = round(abs($item->last_active - $item->start_time) / 60,2).\" minutes\";\n // $cartsWithItems['ip_address'] = $item->ip_address;\n // $cartsWithItems['referrer'] = $item->referrer;\n }",
" } else {\n $item->last_visit = date('Y-m-d, g:i:s A', $item->edited_at);\n $cartsWithoutItems[] = $item;\n }\n }\n //Added the count\n $allCarts['count'] = count($allCarts);\n $cartsWithoutItems['count'] = count($cartsWithoutItems);\n $cartsWithItems['count'] = count($cartsWithItems); //for the added values at the top\n $cartsWithItemsAndInfo['count'] = count($cartsWithItemsAndInfo); //for the added values at the top",
" // eDebug($allCarts);\n // eDebug($cartsWithoutItems);\n // eDebug($cartsWithItems);\n // eDebug($cartsWithItemsAndInfo);\n // exit();\n $summary['totalcarts'] = $allCarts['count'];\n $summary['valueproducts'] = $valueproducts;\n $summary['cartsWithoutItems'] = round(($allCarts['count'] ? $cartsWithoutItems['count'] / $allCarts['count'] : 0) * 100, 2) . '%';\n $summary['cartsWithItems'] = round(($allCarts['count'] ? $cartsWithItems['count'] / $allCarts['count'] : 0) * 100, 2) . '%';\n $summary['cartsWithItemsAndInfo'] = round(($allCarts['count'] ? $cartsWithItemsAndInfo['count'] / $allCarts['count'] : 0) * 100, 2) . '%';",
" assign_to_template(array(\n 'quickrange' => $quickrange,\n 'quickrange_default' => $this->params['quickrange'],\n 'summary' => $summary,\n 'cartsWithoutItems' => $cartsWithoutItems,\n 'cartsWithItems' => $cartsWithItems,\n 'cartsWithItemsAndInfo' => $cartsWithItemsAndInfo\n ));\n }",
" function pruge_abandoned_carts()\n {\n global $db;",
" $db->delete(\"orders\",\"`invoice_id` = '0' AND `edited_at` < UNIX_TIMESTAMP(now())-5184000 AND `sessionticket_ticket` NOT IN (SELECT `ticket` FROM `\".$db->prefix.\"sessionticket`)\");\n $db->delete(\"orderitems\",\"`orders_id` NOT IN (SELECT `id` FROM `\".$db->prefix.\"orders`)\");\n $db->delete(\"shippingmethods\",\"`id` NOT IN (SELECT `shippingmethods_id` FROM `\".$db->prefix.\"orders`)\");\n }",
" function current_carts() {\n global $db;",
" $allCarts = array();\n $carts = array();\n $cartsWithoutItems = array();\n $cartsWithItems = array();\n $cartsWithItemsAndInfo = array();\n $summary = array();\n $valueproducts = '';\n // $sql = \"SELECT * FROM \" . $db->prefix . \"orders WHERE DATEDIFF(FROM_UNIXTIME(edited_at, '%Y-%m-%d'), '\" . date('Y-m-d') . \"') = 0\";",
" $sql = \"SELECT * FROM \" . $db->prefix . \"orders, \" . $db->prefix . \"sessionticket WHERE ticket = sessionticket_ticket\";",
" $allCarts = $db->selectObjectsBySql($sql);",
" // eDebug($allCarts, true);\n foreach ($allCarts as $item) {",
" $sql = \"SELECT * FROM \" . $db->prefix . \"orderitems WHERE orders_id =\" . $item->id;",
" $carts = $db->selectObjectsBySql($sql);",
" foreach ($carts as $item2) {\n $valueproducts += $item2->products_price_adjusted * $item2->quantity;\n }",
" $carts['length_of_time'] = round(abs($item->last_active - $item->start_time) / 60, 2) . \" minutes\";\n $carts['ip_address'] = $item->ip_address;\n $carts['referrer'] = $item->referrer;",
" if (count($carts) > 3) {\n if (!empty($item->user_id)) {\n $u = $db->selectObject('user', 'id=' . $item->user_id);\n $carts['name'] = $u->firstname . ' ' . $u->lastname;\n $carts['email'] = $u->email;\n $cartsWithItemsAndInfo[] = $carts;\n // $cartsWithItemsAndInfo['length_of_time'] = round(abs($item->last_active - $item->start_time) / 60,2).\" minutes\";\n // $cartsWithItemsAndInfo['ip_address'] = $item->ip_address;\n // $cartsWithItemsAndInfo['referrer'] = $item->referrer;\n } else {\n $cartsWithItems[] = $carts;\n // $cartsWithItems['length_of_time'] = round(abs($item->last_active - $item->start_time) / 60,2).\" minutes\";\n // $cartsWithItems['ip_address'] = $item->ip_address;\n // $cartsWithItems['referrer'] = $item->referrer;\n }",
" } else {\n $item->length_of_time = round(abs($item->last_active - $item->start_time) / 60, 2) . \" minutes\";\n $cartsWithoutItems[] = $item;\n }\n }\n //Added the count\n $allCarts['count'] = count($allCarts);\n $cartsWithoutItems['count'] = count($cartsWithoutItems);\n $cartsWithItems['count'] = count($cartsWithItems); //for the added values at the top\n $cartsWithItemsAndInfo['count'] = count($cartsWithItemsAndInfo); //for the added values at the top",
" // eDebug($allCarts);\n // eDebug($cartsWithoutItems);\n // eDebug($cartsWithItems);\n // eDebug($cartsWithItemsAndInfo);",
" $summary['totalcarts'] = $allCarts['count'];\n $summary['valueproducts'] = intval($valueproducts);\n $summary['cartsWithoutItems'] = round(($allCarts['count'] ? $cartsWithoutItems['count'] / $allCarts['count'] : 0) * 100, 2) . '%';\n $summary['cartsWithItems'] = round(($allCarts['count'] ? $cartsWithItems['count'] / $allCarts['count'] : 0) * 100, 2) . '%';\n $summary['cartsWithItemsAndInfo'] = round(($allCarts['count'] ? $cartsWithItemsAndInfo['count'] / $allCarts['count'] : 0) * 100, 2) . '%';",
" // eDebug($summary, true);\n assign_to_template(array(\n 'summary' => $summary,\n 'cartsWithoutItems' => $cartsWithoutItems,\n 'cartsWithItems' => $cartsWithItems,\n 'cartsWithItemsAndInfo' => $cartsWithItemsAndInfo\n ));\n /*\n $this->setDateParams($this->params);\n $except = array('order_discounts', 'billingmethod', 'order_status_changes', 'billingmethod','order_discounts');\n //$orders = $this->o->find('all','purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend,null,null,null,true,false,$except,true);\n // $sql = \"SELECT DATE_FORMAT(created_at, '%Y-%m-%d') as formattedDate FROM orders WHERE created_at\n eDebug(date('Y-m-d'), true);\n // eDebug($this->tend);\n eDebug(date('Y-m-d, g:i:s A', $this->tend));",
" $allOrderCount = $this->o->find('count','created_at >= ' . $this->tstart . ' AND created_at <= ' . $this->tend,null,null,null,true,false,$except,true); ",
" $sql = \"SELECT COUNT(DISTINCT(`orders_id`)) as c FROM \" . $db->prefix . \"orderitems oi \";\n $sql .= \"JOIN \" . $db->prefix . \"orders o ON oi.orders_id = o.id \";\n $sql .= \"WHERE o.created_at >= \" . $this->tstart . \" AND o.created_at <= \" . $this->tend;\n //$sql .= \" AND o.user_id != 0 AND o.order_type_id = 1\";",
" ",
" eDebug($sql);\n $allCartsWithItems = $db->countObjectsBySql($sql);",
" ",
" $sql = \"SELECT COUNT(DISTINCT(`orders_id`)) as c FROM \" . $db->prefix . \"orderitems oi \";\n $sql .= \"JOIN \" . $db->prefix . \"orders o ON oi.orders_id = o.id \";\n $sql .= \"WHERE o.created_at >= \" . $this->tstart . \" AND o.created_at <= \" . $this->tend;\n eDebug($sql);\n $realUserCartsWithItems = $db->countObjectsBySql($sql);",
" \n $ordersInCheckout = $this->o->find('count','created_at >= ' . $this->tstart . ' AND created_at <= ' . $this->tend . \" AND user_id != 0\",null,null,null,true,false,$except,true); \n \n //$ordersPurchased = $this->o->find('count','purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend . \" AND user_id != 0 AND order_type_id = 1\",null,null,null,true,false,$except,true); \n //$ordersPurchased = $this->o->find('count','purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend . \" AND user_id != 0\",null,null,null,true,false,$except,true); \n $ordersPurchased = $this->o->find('count','purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend,null,null,null,true,false,$except,true); \n $orders = $this->o->find('all','purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend,null,null,null,true,false,$except,true); \n \n eDebug(\"All:\" . $allOrderCount); \n eDebug(\"Carts w/ Items:\" . $allCartsWithItems); \n eDebug(\"Carts w/ Items in Checkout:\" . $ordersInCheckout); \n eDebug(\"Purchased:\" . $ordersPurchased); \n ",
" $totalAbandoned = ($allCartsWithItems - $ordersPurchased) / $allCartsWithItems;\n $checkoutAbandoned = ($ordersInCheckout - $ordersPurchased) / $ordersInCheckout;\n eDebug(\"Total Abandoned: \" . $totalAbandoned);\n eDebug(\"Checkout Abandoned: \" . $checkoutAbandoned);",
" \n \n \n ",
" $quickrange = array(0=>'Last 24 Hours',1=>'Last 7 Days',2=>'Last 30 Days');\n $quickrange_default = isset($this->params['quickrange']) ? $this->params['quickrange'] : 0;\n assign_to_template(array('orders'=>$oar,'quickrange'=>$quickrange,'quickrange_default'=>$quickrange_default));",
" assign_to_template(array('prev_month'=>$this->prev_month, 'now_date'=>$this->now_date, 'now_hour'=>$this->now_hour, 'now_min'=>$this->now_min, 'now_ampm'=>$this->now_ampm, 'prev_hour'=>$this->prev_hour, 'prev_min'=>$this->prev_min, 'prev_ampm'=>$this->prev_ampm)); ",
" */\n }",
" function batch_export() {\n global $db;\n //eDebug($this->params);\n //$sql = \"SELECT * INTO OUTFILE '\" . BASE . \"tmp/export.csv' FIELDS TERMINATED BY ',' FROM exponent_product WHERE 1 LIMIT 10\";\n// $out = '\"id\",\"parent_id\",\"child_rank\",\"title\",\"body\",\"model\",\"warehouse_location\",\"sef_url\",\"canonical\",\"meta_title\",\"meta_keywords\",\"meta_description\",\"tax_class_id\",\"quantity\",\"availability_type\",\"base_price\",\"special_price\",\"use_special_price\",\"active_type\",\"product_status_id\",\"category1\",\"category2\",\"category3\",\"category4\",\"category5\",\"category6\",\"category7\",\"category8\",\"category9\",\"category10\",\"category11\",\"category12\",\"surcharge\",\"category_rank\",\"feed_title\",\"feed_body\"' . chr(13) . chr(10);\n $out = '\"id\",\"parent_id\",\"child_rank\",\"title\",\"body\",\"model\",\"warehouse_location\",\"sef_url\",\"meta_title\",\"meta_keywords\",\"meta_description\",\"tax_class_id\",\"quantity\",\"availability_type\",\"base_price\",\"special_price\",\"use_special_price\",\"active_type\",\"product_status_id\",\"category1\",\"category2\",\"category3\",\"category4\",\"category5\",\"category6\",\"category7\",\"category8\",\"category9\",\"category10\",\"category11\",\"category12\",\"surcharge\",\"category_rank\",\"feed_title\",\"feed_body\",\"weight\",\"width\",\"height\",\"length\",\"companies_id\"' . chr(13) . chr(10);\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $sql = expSession::get('product_export_query');\n if (empty($sql)) $sql = 'SELECT DISTINCT(p.id) from ' . $db->prefix . 'product as p WHERE (1=1 )';\n //eDebug($sql);\n //expSession::set('product_export_query','');\n $prods = $db->selectArraysBySql($sql);\n //eDebug($prods);\n } else {\n foreach ($this->params['act-upon'] as $prod) {\n $prods[] = array('id' => $prod);\n }\n }\n set_time_limit(0);\n $baseProd = new product();",
" //$p = new product($pid['id'], false, false);\n foreach ($prods as $pid) {\n $except = array('company', 'crosssellItem', 'optiongroup');\n $p = $baseProd->find('first', 'id=' . $pid['id'], null, null, 0, true, false, $except, true);",
" //eDebug($p,true);\n $out .= expString::outputField($p->id);\n $out .= expString::outputField($p->parent_id);\n $out .= expString::outputField($p->child_rank);\n $out .= expString::outputField($p->title);\n $out .= expString::outputField(expString::stripLineEndings($p->body), \",\", true);\n $out .= expString::outputField($p->model);\n $out .= expString::outputField($p->warehouse_location);\n $out .= expString::outputField($p->sef_url);\n// $out .= expString::outputField($p->canonical); //FIXME this is NOT in import\n $out .= expString::outputField($p->meta_title);\n $out .= expString::outputField($p->meta_keywords);\n $out .= expString::outputField($p->meta_description);\n $out .= expString::outputField($p->tax_class_id);\n $out .= expString::outputField($p->quantity);\n $out .= expString::outputField($p->availability_type);\n $out .= expString::outputField($p->base_price);\n $out .= expString::outputField($p->special_price);\n $out .= expString::outputField($p->use_special_price);\n $out .= expString::outputField($p->active_type);\n $out .= expString::outputField($p->product_status_id);",
" $rank = 0;\n //eDebug($p);\n for ($x = 0; $x < 12; $x++) {\n $this->catstring = '';\n if (isset($p->storeCategory[$x])) {\n $out .= expString::outputField(storeCategory::buildCategoryString($p->storeCategory[$x]->id, true));\n $rank = $db->selectValue('product_storeCategories', 'rank', 'product_id=' . $p->id . ' AND storecategories_id=' . $p->storeCategory[$x]->id);\n } else $out .= ',';\n }\n $out .= expString::outputField($p->surcharge);\n $out .= expString::outputField($rank);\n $out .= expString::outputField($p->feed_title);\n $out .= expString::outputField($p->feed_body);\n $out .= expString::outputField($p->weight);\n $out .= expString::outputField($p->height);\n $out .= expString::outputField($p->width);\n $out .= expString::outputField($p->length);\n $out .= expString::outputField($p->companies_id, chr(13) . chr(10)); //Removed the extra \",\" in the last element",
" foreach ($p->childProduct as $cp) {\n //$p = new product($pid['id'], true, false);\n //eDebug($p,true);\n $out .= expString::outputField($cp->id);\n $out .= expString::outputField($cp->parent_id);\n $out .= expString::outputField($cp->child_rank);\n $out .= expString::outputField($cp->title);\n $out .= expString::outputField(expString::stripLineEndings($cp->body));\n $out .= expString::outputField($cp->model);\n $out .= expString::outputField($cp->warehouse_location);\n $out .= expString::outputField($cp->sef_url);\n// $out .= expString::outputField($cp->canonical); //FIXME this is NOT in import\n $out .= expString::outputField($cp->meta_title);\n $out .= expString::outputField($cp->meta_keywords);\n $out .= expString::outputField($cp->meta_description);\n $out .= expString::outputField($cp->tax_class_id);\n $out .= expString::outputField($cp->quantity);\n $out .= expString::outputField($cp->availability_type);\n $out .= expString::outputField($cp->base_price);\n $out .= expString::outputField($cp->special_price);\n $out .= expString::outputField($cp->use_special_price);\n $out .= expString::outputField($cp->active_type);\n $out .= expString::outputField($cp->product_status_id);\n $out .= ',,,,,,,,,,,,'; // for store categories\n $out .= expString::outputField($cp->surcharge);\n $out .= ',,,'; // for rank, feed title, feed body\n $out .= expString::outputField($cp->weight);\n $out .= expString::outputField($cp->height);\n $out .= expString::outputField($cp->width);\n $out .= expString::outputField($cp->length);\n $out .= expString::outputField($cp->companies_id, chr(13) . chr(10)); //Removed the extra \",\" in the last element\n //echo($out);\n }",
" }",
" $outFile = 'tmp/product_export_' . time() . '.csv';\n $outHandle = fopen(BASE . $outFile, 'w');\n fwrite($outHandle, $out);\n fclose($outHandle);",
" echo \"<br/><br/>\".gt('Download the file here').\": <a href='\" . PATH_RELATIVE . $outFile . \"'>\".gt('Product Export').\"</a>\";",
" /*eDebug(BASE . \"tmp/export.csv\");\n $db->sql($sql);\n eDebug($db->error());*/",
" /*OPTIONALLY ENCLOSED BY '\" . '\"' . ",
" \"' ESCAPED BY '\\\\'\n LINES TERMINATED BY '\" . '\\\\n' .\n \"' */\n }",
" function payment_report() {\n// global $db;\n $payment_methods = array('-1' => '', 'V' => 'Visa', 'MC' => 'Mastercard', 'D' => 'Discover', 'AMEX' => 'American Express', 'PP' => 'PayPal', 'GC' => 'Google Checkout', 'Other' => 'Other');\n //5 paypal\n //4 credit card - VisaCard, MasterCard, AmExCard, DiscoverCard",
" $oids = \"(\";",
" eDebug(expSession::get('order_print_query'));\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n //$sql = expSession::get('order_print_query');\n //eDebug($sql);\n //expSession::set('product_export_query','');\n //$orders = $db->selectArraysBySql($sql);\n $obs = expSession::get('order_export_values');\n usort($obs, array(\"reportController\", \"sortPrintOrders\"));\n foreach ($obs as $ob) {\n $oids .= $ob->id . \",\";\n }\n //eDebug($prods);\n } else {\n if (!empty($this->params['act-upon'])) foreach ($this->params['act-upon'] as $order) {\n $oids .= $order->id . \",\";\n }\n }\n $oids = strrev(expUtil::right(strrev($oids), strlen($oids) - 1));\n $oids .= \")\";\n eDebug($oids);\n //eDebug($orders,true);",
" }",
" function status_export() {\n global $db;\n //eDebug($this->params);\n //$sql = \"SELECT * INTO OUTFILE '\" . BASE . \"tmp/export.csv' FIELDS TERMINATED BY ',' FROM exponent_product WHERE 1 LIMIT 10\";",
" //is | parent_id | SKU |WAREHOUSE LOCATION | Title | Vendor/Manufacturer | Product Status | Notes",
" $out = '\"id\",\"parent_id\",\"model\",\"warehouse_location\",\"title\",\"vendor\",\"product_status\",\"notes\"' . chr(13) . chr(10);\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $sql = expSession::get('product_export_query');\n if (empty($sql)) $sql = 'SELECT DISTINCT(p.id) from ' . $db->prefix . 'product as p WHERE (1=1 )';\n //eDebug($sql);\n //expSession::set('product_export_query','');\n $prods = $db->selectArraysBySql($sql);\n //eDebug($prods);\n } else {\n foreach ($this->params['act-upon'] as $prod) {\n $prods[] = array('id' => $prod);\n }\n }",
" $stats = new product_status();\n $stats = $stats->find('all');",
"// $statuses = array();\n $statuses = array(0=>'');\n foreach ($stats as $stat) {\n $statuses[$stat->id] = $stat->title;\n }",
"// eDebug($statuses);",
" set_time_limit(0);\n $baseProd = new product();",
" //$p = new product($pid['id'], false, false);\n //id | parent_id | SKU |WAREHOUSE LOCATION | Title | Vendor/Manufacturer | Product Status | Notes\n foreach ($prods as $pid) {\n $except = array('crosssellItem', 'optiongroup', 'childProduct');\n $p = $baseProd->find('first', 'id=' . $pid['id'], null, null, 0, true, true, $except, true);",
" /*if(count($p->expSimpleNote))\n {\n eDebug($p,true);\n }\n else\n {\n continue;\n }*/",
" $out .= expString::outputField($p->id);\n $out .= expString::outputField($p->parent_id);\n $out .= expString::outputField($p->model);\n $out .= expString::outputField($p->warehouse_location);\n $out .= expString::outputField($p->title);\n $out .= expString::outputField($p->company->title);\n $out .= expString::outputField($statuses[$p->product_status_id]);",
" $noteString = '';\n foreach ($p->expSimpleNote as $note) {\n $noteString .= \"(\" . $note->name . \" - \" . date('M d Y H:i A', $note->created_at) . \") \" . $note->body . \"||\";\n }\n $out .= expString::outputField($noteString, chr(13) . chr(10));",
" $cps = $baseProd->find('all', 'parent_id=' . $p->id, null, null, 0, true, true, $except, true);\n foreach ($cps as $cp) {\n $out .= expString::outputField($cp->id);\n $out .= expString::outputField($cp->parent_id);\n $out .= expString::outputField($cp->model);\n $out .= expString::outputField($cp->warehouse_location);\n $out .= expString::outputField($cp->title);\n $out .= expString::outputField($cp->company->title);\n $out .= expString::outputField($statuses[$cp->product_status_id]);",
" $noteString = '';\n foreach ($cp->expSimpleNote as $note) {\n $noteString .= \"(\" . $note->name . \" - \" . date('M d Y H:i A', $note->created_at) . \") \" . $note->body . \"||\";\n }\n $out .= expString::outputField($noteString, chr(13) . chr(10));\n }\n }",
" //eDebug($out,true);\n $outFile = 'tmp/product_status_' . time() . '.csv';\n $outHandle = fopen(BASE . $outFile, 'w');\n fwrite($outHandle, $out);\n fclose($outHandle);",
" echo \"<br/><br/>\".gt('Download the file here').\": <a href='\" . PATH_RELATIVE . $outFile . \"'>\".gt('Product Export').\"</a>\";",
" /*eDebug(BASE . \"tmp/export.csv\");\n $db->sql($sql);\n eDebug($db->error());*/",
" /*OPTIONALLY ENCLOSED BY '\" . '\"' . ",
" \"' ESCAPED BY '\\\\'\n LINES TERMINATED BY '\" . '\\\\n' .\n \"' */\n }",
" //public $catstring = '';",
" /**\n * @deprecated 2.3.4 moved to storeCategory\n */\n public static function buildCategoryString($catID, $reset = false) {\n static $cstr = '';\n if ($reset) $cstr = '';\n if (strlen($cstr) > 0) $cstr .= \"::\";\n $cat = new storeCategory($catID);\n //eDebug($cat);\n if (!empty($cat->parent_id)) self::buildCategoryString($cat->parent_id);\n $cstr .= $cat->title . \"::\";\n return substr($cstr, 0, -2);\n }",
" function product_report() {\n $pts = storeController::getProductTypes();\n $newPts = array();\n foreach ($pts as $pt) {\n $newPts[$pt] = $pt;\n }\n assign_to_template(array(\n 'product_types' => $newPts\n ));\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
0,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class reportController extends expController {",
" protected $manage_permissions = array(\n 'abandoned_carts' => 'Abandoned Carts Report',\n 'batch_export' => 'Export Products',",
" 'cart_summary' => 'View Cart Summary Report',",
" 'current_carts' => 'Current Carts Report',",
" 'dashboard' => 'View the e-Commerce Dashboard',",
" 'download' => 'Download Report',",
" 'generateOrderReport' => 'View Order Report',\n 'generateProductReport' => 'View Product Report',",
" 'order_report' => 'Generate Order Report',\n 'payment_report' => 'Generate Payment Report',",
" 'print_orders' => 'Print Orders',",
" 'product_report' => 'Generate Product Report',\n 'purge_abandoned_carts' => 'Purge Abandoned Carts',",
" 'show_payment_summary' => 'Show Payment Summary',",
" 'status_export' => 'Export Status',\n );",
"\n static function displayname() {\n return gt(\"Ecom Report Builder\");\n }",
" static function description() {\n return gt(\"Build reports based on store activity\");\n }",
" static function author() {\n return \"Phillip Ball - OIC Group, Inc\";\n }",
" static function hasSources() {\n return false;\n }",
" protected $o;\n protected $oneday = 86400;\n protected $tstart;\n protected $tend;\n protected $prev_month;\n protected $prev_hour = '12';\n protected $prev_min = '00';\n protected $prev_ampm = 'AM';\n protected $now_date;\n protected $now_hour;\n protected $now_min;\n protected $now_ampm;",
" function __construct($src = null, $params = array()) {\n parent::__construct($src, $params);\n $this->o = new order();\n $this->tstart = time() - $this->oneday;\n $this->tend = time();\n// $this->prev_month = strftime(\"%A, %d %B %Y\", mktime(0,0,0,(strftime(\"%m\")-1),1,strftime(\"%Y\")));\n// $this->now_date = strftime(\"%A, %d %B %Y\");\n $this->prev_month = strftime(DISPLAY_DATE_FORMAT, mktime(0, 0, 0, (strftime(\"%m\") - 1), 1, strftime(\"%Y\")));\n $this->now_date = strftime(DISPLAY_DATE_FORMAT);\n $this->now_hour = strftime(\"%I\");\n $this->now_min = strftime(\"%M\");\n $this->now_ampm = strftime(\"%p\");\n }",
" private function setDateParams($params) {\n //eDebug($params,true);\n if (!empty($params['quickrange'])) {\n if ($params['quickrange'] == 1) {\n $this->tstart = time() - $this->oneday * 7;\n } else if ($params['quickrange'] == 2) {\n $this->tstart = time() - $this->oneday * 30;\n } else if ($params['quickrange'] == 0) {\n $this->tstart = time() - $this->oneday;\n }\n $this->prev_month = strftime(DISPLAY_DATE_FORMAT,$this->tstart);\n } else if (isset($params['date-starttime'])) { //FIXME OLD calendar control format\n $formatedStart = $params['date-starttime'] . ' ' . $params['time-h-starttime'] . \":\" . $params['time-m-starttime'] . ' ' . $params['ampm-starttime'];\n $this->tstart = strtotime($formatedStart);\n $this->tend = strtotime($params['date-endtime'] . ' ' . $params['time-h-endtime'] . \":\" . $params['time-m-endtime'] . ' ' . $params['ampm-endtime']);",
" // parse out date into calendarcontrol fields\n $this->prev_month = $formatedStart;\n $this->prev_hour = $params['time-h-starttime'];\n $this->prev_min = $params['time-m-starttime'];\n $this->prev_ampm = $params['ampm-starttime'];",
" // parse out date into calendarcontrol fields\n $this->now_date = $params['date-endtime'];\n $this->now_hour = $params['time-h-endtime'];\n $this->now_min = $params['time-m-endtime'];\n $this->now_ampm = $params['ampm-endtime'];\n } elseif (isset($params['starttime'])) {\n $this->tstart = strtotime($params['starttime']);\n $this->tend = strtotime($params['endtime']);",
" // parse out date into calendarcontrol fields\n $this->prev_month = date('m/d/Y', $this->tstart);\n $this->prev_hour = date('h', $this->tstart);\n $this->prev_min = date('i', $this->tstart);\n $this->prev_ampm = date('a', $this->tstart);",
" // parse out date into calendarcontrol fields\n $this->now_date = date('m/d/Y', $this->tend);\n $this->now_hour = date('h', $this->tend);\n $this->now_min = date('i', $this->tend);\n $this->now_ampm = date('a', $this->tend);\n } else {\n $this->tstart = time() - $this->oneday;\n }\n return;\n }",
" function dashboard() {\n global $db;",
" $quickrange = array(0 => gt('Last 24 Hours'), 1 => gt('Last 7 Days'), 2 => gt('Last 30 Days'));\n $this->setDateParams($this->params);\n if (!isset($this->params['quickrange'])) {\n $this->params['quickrange'] = 0;\n }",
" $except = array('order_discounts', 'billingmethod', 'order_status_changes', 'billingmethod', 'order_discounts');\n $orders = $this->o->find('all', 'purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend, null, null, 0, true, false, $except, true);\n $oar = array();\n foreach ($orders as $order) {\n //eDebug($order,true);\n if (empty($oar[$order->order_type->title])) {\n $oar[$order->order_type->title] = array();\n $oar[$order->order_type->title]['grand_total'] = null;\n $oar[$order->order_type->title]['num_orders'] = null;\n $oar[$order->order_type->title]['num_items'] = null;\n }\n $oar[$order->order_type->title]['grand_total'] += $order->grand_total;\n $oar[$order->order_type->title]['num_orders']++;\n $oar[$order->order_type->title]['num_items'] += count($order->orderitem);",
" if (empty($oar[$order->order_type->title][$order->order_status->title])) {\n $oar[$order->order_type->title][$order->order_status->title] = array();\n $oar[$order->order_type->title][$order->order_status->title]['grand_total'] = null;\n $oar[$order->order_type->title][$order->order_status->title]['num_orders'] = null;\n $oar[$order->order_type->title][$order->order_status->title]['num_items'] = null;\n }\n $oar[$order->order_type->title][$order->order_status->title]['grand_total'] += $order->grand_total;\n $oar[$order->order_type->title][$order->order_status->title]['num_orders']++;\n $oar[$order->order_type->title][$order->order_status->title]['num_items'] += count($order->orderitem);\n }",
" $sql = \"SELECT COUNT(*) as c FROM \" . $db->prefix . \"orders, \" . $db->prefix . \"sessionticket WHERE ticket = sessionticket_ticket\";\n $allCarts = $db->countObjectsBySql($sql);",
" assign_to_template(array(\n 'orders' => $oar,\n 'quickrange' => $quickrange,\n 'quickrange_default' => $this->params['quickrange'],\n 'prev_month' => $this->prev_month,\n 'now_date' => $this->now_date,\n 'now_hour' => $this->now_hour,\n 'now_min' => $this->now_min,\n 'now_ampm' => $this->now_ampm,\n 'prev_hour' => $this->prev_hour,\n 'prev_min' => $this->prev_min,\n 'prev_ampm' => $this->prev_ampm,\n 'active_carts' => $allCarts\n ));\n }",
" function cart_summary() {\n global $db;",
" $p = $this->params;\n $sql = \"SELECT DISTINCT(o.id), o.invoice_id, FROM_UNIXTIME(o.purchased,'%c/%e/%y %h:%i:%s %p') as purchased_date, b.firstname as bfirst, b.lastname as blast, concat('\".expCore::getCurrencySymbol().\"',format(o.grand_total,2)) as grand_total, os.title as status_title from \";\n $sql .= $db->prefix . \"orders as o \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"orderitems as oi ON oi.orders_id = o.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"product as p ON oi.product_id = p.id \";\n if (!empty($p['order_status'][0]) && $p['order_status'][0] != -1) $sql .= \"INNER JOIN \" . $db->prefix . \"order_type as ot ON o.order_type_id = ot.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"order_status as os ON os.id = o.order_status_id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"billingmethods as b ON b.orders_id = o.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"shippingmethods as s ON s.id = oi.shippingmethods_id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"geo_region as gr ON (gr.id = b.state OR gr.id = s.state) \";\n if (!empty($p['discounts'][0]) && $p['discounts'][0] != -1) $sql .= \"LEFT JOIN \" . $db->prefix . \"order_discounts as od ON od.orders_id = o.id \";",
" $sqlwhere = \"WHERE o.purchased != 0\";",
" if (!empty($p['date-startdate'])) $sqlwhere .= \" AND o.purchased >= \" . strtotime($p['date-startdate'] . \" \" . $p['time-h-startdate'] . \":\" . $p['time-m-startdate'] . \" \" . $p['ampm-startdate']);\n /*if ($p->['time-h-startdate'] == )\n if ($p->['time-m-startdate'] == )\n if ($p->['ampm-startdate'] == )*/",
" if (!empty($p['date-enddate'])) $sqlwhere .= \" AND o.purchased <= \" . strtotime($p['date-enddate'] . \" \" . $p['time-h-enddate'] . \":\" . $p['time-m-enddate'] . \" \" . $p['ampm-enddate']);\n /*if ($p->['date-enddate'] == )\n if ($p->['time-h-enddate'] == )\n if ($p->['time-m-enddate'] == )\n if ($p->['ampm-enddate'] == )*/",
" $inc = 0;\n $sqltmp = '';\n if (!empty($p['order_status'])) foreach ($p['order_status'] as $os) {\n if ($os == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (o.order_status_id = \" . $os;\n } else {\n $sqltmp .= \" OR o.order_status_id = \" . $os;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" $inc = 0;\n $sqltmp = '';\n if (!empty($p['order_type'])) foreach ($p['order_type'] as $ot) {\n if ($ot == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (o.order_type_id = \" . $ot;\n } else {\n $sqltmp .= \" OR o.order_type_id = \" . $ot;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!empty($p['order-range-num'])) {\n $operator = '';\n switch ($p['order-range-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND o.invoice_id\" . $operator . $p['order-range-num'];\n }",
" if (!empty($p['order-price-num'])) {\n $operator = '';\n switch ($p['order-price-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND o.grand_total\" . $operator . $p['order-price-num'];\n }",
" if (!empty($p['pnam'])) {\n $sqlwhere .= \" AND p.title LIKE '%\" . $p['pnam'] . \"%'\";\n }",
" if (!empty($p['sku'])) {\n $sqlwhere .= \" AND p.model LIKE '%\" . $p['sku'] . \"%'\";\n }",
" $inc = 0;\n $sqltmp = '';\n if (!empty($p['discounts'])) foreach ($p['discounts'] as $d) {\n if ($d == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (od.discounts_id = \" . $d;\n } else {\n $sqltmp .= \" OR od.discounts_id = \" . $d;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!empty($p['blshpname'])) {\n $sqlwhere .= \" AND (b.firstname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR s.firstname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR b.lastname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR s.lastname LIKE '%\" . $p['blshpname'] . \"%')\";\n }",
" if (!empty($p['email'])) {\n $sqlwhere .= \" AND (b.email LIKE '%\" . $p['email'] . \"%'\";\n $sqlwhere .= \" OR s.email LIKE '%\" . $p['email'] . \"%')\";\n }",
" if (!empty($p['zip'])) {\n if ($p['bl-sp-zip'] == 'b') $sqlwhere .= \" AND b.zip LIKE '%\" . $p['zip'] . \"%'\";\n else if ($p['bl-sp-zip'] == 's') $sqlwhere .= \" AND s.zip LIKE '%\" . $p['zip'] . \"%'\";\n }",
" if (isset($p['state'])) {\n $inc = 0;\n $sqltmp = '';\n foreach ($p['state'] as $s) {\n if ($s == -1) continue;\n else if ($inc == 0) {\n $inc++;\n if ($p['bl-sp-state'] == 'b') $sqltmp .= \" AND (b.state = \" . $s;\n else if ($p['bl-sp-state'] == 's') $sqltmp .= \" AND (s.state = \" . $s;\n } else {\n if ($p['bl-sp-state'] == 'b') $sqltmp .= \" OR b.state = \" . $s;\n else if ($p['bl-sp-state'] == 's') $sqltmp .= \" OR s.state = \" . $s;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" if (isset($p['payment_method'])) {\n $inc = 0;\n $sqltmp = '';\n foreach ($p['payment_method'] as $s) {\n if ($s == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (o.order_status_id = \" . $s;\n } else {\n $sqltmp .= \" OR o.order_status_id = \" . $s;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" //echo $sql . $sqlwhere . \"<br>\";\n /*\n Need: order, orderitems, order status, ordertype, billingmethods, geo region, shipping methods, products",
" [date-startdate] =>\n [time-h-startdate] =>\n [time-m-startdate] =>",
" [ampm-startdate] => am",
" [date-enddate] =>\n [time-h-enddate] =>\n [time-m-enddate] =>",
" [ampm-enddate] => am\n [order_status] => Array\n (\n [0] => 0\n [1] => 1\n [2] => 2\n )",
" [order_type] => Array\n (\n [0] => 0\n [1] => 2\n )",
" [order-range-op] => e",
" [order-range-num] =>",
" [order-price-op] => l",
" [order-price-num] =>\n [pnam] =>\n [sku] =>",
" [discounts] => Array\n (\n [0] => -1\n )\n",
" [blshpname] =>\n [email] =>",
" [bl-sp-zip] => s",
" [zip] =>",
" [bl-sp-state] => s\n [state] => Array\n (\n [0] => -1\n )",
" [status] => Array\n (\n [0] => -1\n )",
" )\n */\n expSession::set('order_print_query', $sql . $sqlwhere);\n //$where = 1;//$this->aggregateWhereClause();\n //$order = 'id';\n //$prod = new product();\n // $order = new order();",
" //$items = $prod->find('all', 1, 'id DESC',25);\n //$items = $order->find('all', 1, 'id DESC',25);",
" //$res = $mod->find('all',$sql,'id',25);",
" //eDebug($items);",
" $page = new expPaginator(array(\n //'model'=>'order',\n //'records'=>$items,\n // 'where'=>$where,\n 'sql' => $sql . $sqlwhere,\n 'limit' => empty($this->config['limit']) ? 25 : $this->config['limit'],\n 'order' => 'invoice_id',\n 'order_direction' => 'DESC',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n 'columns' => array(\n 'actupon' => true,\n gt('Order #') => 'invoice_id|controller=order,action=show,showby=id',\n gt('Date') => 'purchased_date',\n gt('First') => 'bfirst',\n gt('Last') => 'blast',\n gt('Total') => 'grand_total',\n gt('Status') => 'status_title'\n ),\n ));",
" $action_items = array(\n 'print_orders' => 'Print Orders',\n 'export_odbc' => 'Export Shipping Data to CSV'\n );\n assign_to_template(array(\n 'page' => $page,\n 'action_items' => $action_items\n ));\n }",
" function order_report() {\n // stub function. I'm sure eventually we can pull up exising reports to pre-populate our form.\n $os = new order_status();\n $oss = $os->find('all');\n $order_status = array();\n $order_status[-1] = gt('--Any--');\n foreach ($oss as $status) {\n $order_status[$status->id] = $status->title;\n }",
" $ot = new order_type();\n $ots = $ot->find('all');\n $order_type = array();\n $order_type[-1] = gt('--Any--');\n foreach ($ots as $orderType) {\n $order_type[$orderType->id] = $orderType->title;\n }",
" $dis = new discounts();\n $diss = $dis->find('all');\n $discounts = array();\n $discounts[-1] = gt('--Any--');\n foreach ($diss as $discount) {\n $discounts[$discount->id] = $discount->coupon_code;\n }",
" /*$geo = new geoRegion();",
" $geos = $geo->find('all');",
" $states = array();\n $states[-1] = gt('--Any--');\n foreach ($geos as $skey=>$state)\n {\n $states[$skey] = $state->name;\n } */",
" $payment_methods = billingmethod::$payment_types;\n $payment_methods[-1] = gt('--Any--');\n ksort($payment_methods);\n //array('-1'=>'', 'V'=>'Visa','MC'=>'Mastercard','D'=>'Discover','AMEX'=>'American Express','PP'=>'PayPal','GC'=>'Google Checkout','Other'=>'Other');",
" //eDebug(mktime(0,0,0,(strftime(\"%m\")-1),1,strftime(\"%Y\")));\n// $prev_month = strftime(\"%A, %d %B %Y\", mktime(0,0,0,(strftime(\"%m\")-1),1,strftime(\"%Y\")));",
" //eDebug(strftime(\"%A, %d %B %Y\", mktime(0,0,0,(strftime(\"%m\")-1),1,strftime(\"%Y\"))));",
"// $now_date = strftime(\"%A, %d %B %Y\");\n $prev_month = strftime(DISPLAY_DATE_FORMAT, mktime(0, 0, 0, (strftime(\"%m\") - 1), 1, strftime(\"%Y\")));\n $now_date = strftime(DISPLAY_DATE_FORMAT);\n $now_hour = strftime(\"%I\");\n $now_min = strftime(\"%M\");\n $now_ampm = strftime(\"%p\");",
" assign_to_template(array(\n 'prev_month' => $prev_month,\n 'now_date' => $now_date,\n 'now_hour' => $now_hour,\n 'now_min' => $now_min,\n 'now_ampm' => $now_ampm,\n 'order_status' => $order_status,\n 'discounts' => $discounts,\n// 'states'=>$states,\n 'order_type' => $order_type,\n 'payment_methods' => $payment_methods\n ));\n }",
" function generateOrderReport() {\n global $db;\n //eDebug($this->params);\n $p = $this->params;",
" //eDebug();",
" //build",
" $start_sql = \"SELECT DISTINCT(o.id), \";\n $count_sql = \"SELECT COUNT(DISTINCT(o.id)) as c, \";\n $sql = \"o.invoice_id, FROM_UNIXTIME(o.purchased,'%c/%e/%y %h:%i:%s %p') as purchased_date, b.firstname as bfirst, b.lastname as blast, concat('\".expCore::getCurrencySymbol().\"',format(o.grand_total,2)) as grand_total, os.title as status_title, ot.title as order_type\";\n if ((count($p['order_status_changed']) == 1 && $p['order_status_changed'][0] != -1) || count($p['order_status_changed']) > 1 || (!empty($p['include_status_date']) && (!empty($p['date-sstartdate']) || !empty($p['date-senddate'])))) $sql .= \", FROM_UNIXTIME(osc.created_at,'%c/%e/%y %h:%i:%s %p') as status_changed_date\";\n $sql .= \" from \" . $db->prefix . \"orders as o \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"orderitems as oi ON oi.orders_id = o.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"order_type as ot ON ot.id = o.order_type_id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"product as p ON oi.product_id = p.id \";\n //if ($p['order_type'][0] != -1) $sql .= \"INNER JOIN \" . $db->prefix . \"order_type as ot ON o.order_type_id = ot.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"order_status as os ON os.id = o.order_status_id \";\n if ((count($p['order_status_changed']) == 1 && $p['order_status_changed'][0] != -1) || count($p['order_status_changed']) > 1 || (!empty($p['include_status_date']) && (!empty($p['date-sstartdate']) || !empty($p['date-senddate'])))) $sql .= \"INNER JOIN \" . $db->prefix . \"order_status_changes as osc ON osc.orders_id = o.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"billingmethods as b ON b.orders_id = o.id \";\n $sql .= \"INNER JOIN \" . $db->prefix . \"shippingmethods as s ON s.id = oi.shippingmethods_id \";\n $sql .= \"LEFT JOIN \" . $db->prefix . \"geo_region as gr ON (gr.id = b.state OR gr.id = s.state) \";\n if ($p['discounts'][0] != -1) $sql .= \"LEFT JOIN \" . $db->prefix . \"order_discounts as od ON od.orders_id = o.id \";",
" $sqlwhere = \"WHERE o.purchased != 0\";",
" if (!empty($p['include_purchased_date']) && !empty($p['date-pstartdate'])) $sqlwhere .= \" AND o.purchased >= \" . strtotime($p['date-pstartdate'] . \" \" . $p['time-h-pstartdate'] . \":\" . $p['time-m-pstartdate'] . \" \" . $p['ampm-pstartdate']);\n /*if ($p->['time-h-startdate'] == )\n if ($p->['time-m-startdate'] == )\n if ($p->['ampm-startdate'] == )*/\n if (!empty($p['include_purchased_date']) && !empty($p['date-penddate'])) $sqlwhere .= \" AND o.purchased <= \" . strtotime($p['date-penddate'] . \" \" . $p['time-h-penddate'] . \":\" . $p['time-m-penddate'] . \" \" . $p['ampm-penddate']);\n /*if ($p->['date-enddate'] == )\n if ($p->['time-h-enddate'] == )\n if ($p->['time-m-enddate'] == )\n if ($p->['ampm-enddate'] == )*/\n if (!empty($p['include_status_date']) && !empty($p['date-sstartdate'])) $sqlwhere .= \" AND osc.created_at >= \" . strtotime($p['date-sstartdate'] . \" \" . $p['time-h-sstartdate'] . \":\" . $p['time-m-sstartdate'] . \" \" . $p['ampm-sstartdate']);",
" if (!empty($p['include_status_date']) && !empty($p['date-senddate'])) $sqlwhere .= \" AND osc.created_at <= \" . strtotime($p['date-senddate'] . \" \" . $p['time-h-senddate'] . \":\" . $p['time-m-senddate'] . \" \" . $p['ampm-senddate']);",
" $inc = 0;\n $sqltmp = '';\n foreach ($p['order_status'] as $os) {\n if ($os == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (o.order_status_id = \" . $os;\n } else {\n $sqltmp .= \" OR o.order_status_id = \" . $os;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" $inc = 0;\n $sqltmp = '';\n foreach ($p['order_status_changed'] as $osc) {\n if ($osc == -1) continue;\n else if ($inc == 0) {\n $inc++;\n //$sqltmp .= \" AND ((osc.to_status_id = \" . $osc . \" AND (osc.from_status_id != \" . $osc . \")\";\n $sqltmp .= \" AND (osc.to_status_id = \" . $osc;\n } else {\n //$sqltmp .= \" OR (osc.to_status_id = \" . $osc . \" AND (osc.from_status_id != \" . $osc . \")\";\n $sqltmp .= \" OR osc.to_status_id = \" . $osc;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" $inc = 0;\n $sqltmp = '';\n foreach ($p['order_type'] as $ot) {\n if ($ot == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (o.order_type_id = \" . $ot;\n } else {\n $sqltmp .= \" OR o.order_type_id = \" . $ot;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!empty($p['order-range-num'])) {\n $operator = '';\n switch ($p['order-range-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND o.invoice_id\" . $operator . $p['order-range-num'];\n }",
" if (!empty($p['order-price-num'])) {\n $operator = '';\n switch ($p['order-price-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND o.grand_total\" . $operator . $p['order-price-num'];\n }",
" if (!empty($p['pnam'])) {\n $sqlwhere .= \" AND p.title LIKE '%\" . $p['pnam'] . \"%'\";\n }",
" if (!empty($p['sku'])) {\n $sqlwhere .= \" AND p.model LIKE '%\" . $p['sku'] . \"%'\";\n }",
" $inc = 0;\n $sqltmp = '';\n if (isset($p['product_status'])) {\n foreach ($p['product_status'] as $pstat) {\n if ($pstat == -1 || empty($pstat)) continue;",
" $product_status = new product_status($pstat);\n if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (oi.products_status = '\" . $product_status->title . \"'\";\n } else {\n $sqltmp .= \" OR oi.products_status = '\" . $product_status->title . \"'\";\n }\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!empty($p['uidata'])) {\n $sqlwhere .= \" AND oi.user_input_fields != '' AND oi.user_input_fields != 'a:0:{}'\";\n }",
" $inc = 0;\n $sqltmp = '';\n foreach ($p['discounts'] as $d) {\n if ($d == -1) continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (od.discounts_id = \" . $d;\n } else {\n $sqltmp .= \" OR od.discounts_id = \" . $d;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!empty($p['blshpname'])) {\n $sqlwhere .= \" AND (b.firstname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR s.firstname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR b.lastname LIKE '%\" . $p['blshpname'] . \"%'\";\n $sqlwhere .= \" OR s.lastname LIKE '%\" . $p['blshpname'] . \"%')\";\n }",
" if (!empty($p['email'])) {\n $sqlwhere .= \" AND (b.email LIKE '%\" . $p['email'] . \"%'\";\n $sqlwhere .= \" OR s.email LIKE '%\" . $p['email'] . \"%')\";\n }",
" if (!empty($p['zip'])) {\n if ($p['bl-sp-zip'] == 'b') $sqlwhere .= \" AND b.zip LIKE '%\" . $p['zip'] . \"%'\";\n else if ($p['bl-sp-zip'] == 's') $sqlwhere .= \" AND s.zip LIKE '%\" . $p['zip'] . \"%'\";\n }",
" if (isset($p['state'])) {\n $inc = 0;\n $sqltmp = '';\n foreach ($p['state'] as $s) {\n if ($s == -1) continue;\n else if ($inc == 0) {\n $inc++;\n if ($p['bl-sp-state'] == 'b') $sqltmp .= \" AND (b.state = \" . $s;\n else if ($p['bl-sp-state'] == 's') $sqltmp .= \" AND (s.state = \" . $s;\n } else {\n if ($p['bl-sp-state'] == 'b') $sqltmp .= \" OR b.state = \" . $s;\n else if ($p['bl-sp-state'] == 's') $sqltmp .= \" OR s.state = \" . $s;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" if (isset($p['payment_method'])) {\n $inc = 0;\n $sqltmp = '';",
" //get each calculator's id",
"\n foreach ($p['payment_method'] as $s) {\n if ($s == -1) continue;\n if ($s == 'VisaCard' || $s == 'AmExCard' || $s == 'MasterCard' || $s == 'DiscoverCard') {\n $paymentQuery = 'b.billing_options LIKE \"%' . $s . '%\"';\n } else {\n $bc = new billingcalculator();\n $calc = $bc->findBy('calculator_name', $s);\n $paymentQuery = 'billingcalculator_id = ' . $calc->id;\n }",
" if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND ( \" . $paymentQuery;\n } else {\n $sqltmp .= \" OR \" . $paymentQuery;\n }\n }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" //echo $sql . $sqlwhere . \"<br>\";\n /*\n Need: order, orderitems, order status, ordertype, billingmethods, geo region, shipping methods, products",
" [date-startdate] =>\n [time-h-startdate] =>\n [time-m-startdate] =>",
" [ampm-startdate] => am",
" [date-enddate] =>\n [time-h-enddate] =>\n [time-m-enddate] =>",
" [ampm-enddate] => am\n [order_status] => Array\n (\n [0] => 0\n [1] => 1\n [2] => 2\n )",
" [order_type] => Array\n (\n [0] => 0\n [1] => 2\n )",
" [order-range-op] => e",
" [order-range-num] =>",
" [order-price-op] => l",
" [order-price-num] =>\n [pnam] =>\n [sku] =>",
" [discounts] => Array\n (\n [0] => -1\n )\n",
" [blshpname] =>\n [email] =>",
" [bl-sp-zip] => s",
" [zip] =>",
" [bl-sp-state] => s\n [state] => Array\n (\n [0] => -1\n )",
" [status] => Array\n (\n [0] => -1\n )",
" )\n */",
" //$sqlwhere .= \" ORDER BY purchased_date DESC\";\n $count_sql .= $sql . $sqlwhere;\n $sql = $start_sql . $sql;\n expSession::set('order_print_query', $sql . $sqlwhere);\n $reportRecords = $db->selectObjectsBySql($sql . $sqlwhere);\n expSession::set('order_export_values', $reportRecords);",
" //eDebug(expSession::get('order_export_values'));\n //$where = 1;//$this->aggregateWhereClause();\n //$order = 'id';\n //$prod = new product();\n // $order = new order();",
" //$items = $prod->find('all', 1, 'id DESC',25);\n //$items = $order->find('all', 1, 'id DESC',25);",
" //$res = $mod->find('all',$sql,'id',25);\n //eDebug($items);",
" //eDebug($sql . $sqlwhere);",
"\n $page = new expPaginator(array(\n //'model'=>'order',\n //'records'=>$items,\n // 'where'=>$where,\n 'count_sql' => $count_sql,\n 'sql' => $sql . $sqlwhere,\n 'limit' => empty($this->config['limit']) ? 350 : $this->config['limit'],\n 'order' => 'invoice_id',\n 'dir' => 'DESC',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n 'columns' => array(\n 'actupon' => true,\n gt('Order #') => 'invoice_id|controller=order,action=show,showby=id',\n gt('Purchased Date') => 'purchased_date',\n gt('First') => 'bfirst',\n gt('Last') => 'blast',\n gt('Total') => 'grand_total',\n gt('Status Changed Date') => 'status_changed_date',\n gt('Order Type') => 'order_type',\n gt('Status') => 'status_title'\n ),\n ));\n",
" //strftime(\"%a %d-%m-%Y\", get_first_day(3, 1, 2007)); Thursday, 1 April 2010",
" //$d_month_previous = date('n', mktime(0,0,0,(strftime(\"%m\")-1),1,strftime(\"%Y\")));",
" $action_items = array(\n 'print_orders' => 'Print Orders',\n 'export_odbc' => 'Export Shipping Data to CSV',\n 'export_status_report' => 'Export Order Status Data to CSV',\n 'export_inventory' => 'Export Inventory Data to CSV',\n 'export_user_input_report' => 'Export User Input Data to CSV',\n 'export_order_items' => 'Export Order Items Data to CSV',\n 'show_payment_summary' => 'Show Payment & Tax Summary'\n );\n assign_to_template(array(\n 'page' => $page,\n 'action_items' => $action_items\n ));\n }",
" function show_payment_summary() {\n global $db;",
" $payments = billingmethod::$payment_types;",
" $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n if (!empty($this->params['act-upon'])) foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);",
" $payment_summary = array();\n // $Credit Cards\n// $sql = \"SELECT orders_id, billing_cost, billing_options, calculator_name, user_title FROM \" . $db->prefix . \"billingmethods, \" . $db->prefix . \"billingcalculator WHERE \" . $db->prefix . \"billingcalculator.id = billingcalculator_id and orders_id IN (\" . $orders_string . \")\";\n $sql = \"SELECT orders_id, billing_cost, billing_options, calculator_name, title FROM \" . $db->prefix . \"billingmethods, \" . $db->prefix . \"billingcalculator WHERE \" . $db->prefix . \"billingcalculator.id = billingcalculator_id and orders_id IN (\" . $orders_string . \")\";\n $res = $db->selectObjectsBySql($sql);\n if (!empty($res)) {\n foreach ($res as $item) {\n $options = expUnserialize($item->billing_options);\n if (!empty($item->billing_cost)) {\n// if ($item->user_title == 'Credit Card') {\n if ($item->title == 'Credit Card') { //FIXME there is no billingmethod->title ...this is translated??\n if (!empty($options->cc_type)) {\n //@$payment_summary[$payments[$options->cc_type]] += $item->billing_cost;\n @$payment_summary[$payments[$options->cc_type]] += $options->result->amount_captured;\n }\n } else {\n @$payment_summary[$payments[$item->calculator_name]] += $item->billing_cost;\n }\n }\n }\n }",
" $payments_key_arr = array();\n $payment_values_arr = array();\n foreach ($payment_summary as $key => $item) {\n $payments_key_arr[] = '\"' . $key . '\"';\n $payment_values_arr[] = round($item, 2);\n }\n $payments_key = implode(\",\", $payments_key_arr);\n $payment_values = implode(\",\", $payment_values_arr);",
" //tax\n// $tax_sql = \"SELECT SUM(tax) as tax_total FROM \" . $db->prefix . \"orders WHERE id IN (\" . $orders_string . \")\";\n// $tax_res = $db->selectObjectBySql($tax_sql);\n $tax_types = taxController::getTaxRates();\n// $tax_type_formatted = $tax_types[0]->zonename . ' - ' . $tax_types[0]->classname . ' - ' . $tax_types[0]->rate . '%';",
" $ord = new order();\n $tax_res2 = $ord->find('all',\"id IN (\" . $orders_string . \")\");",
" $taxes = array();\n foreach ($tax_res2 as $tt) {\n $key = key($tt->taxzones);\n if (!empty($key)) {\n $tname = $tt->taxzones[$key]->name;\n if (!isset($taxes[$key]['format'])) {\n $taxes[$key] = array();\n $taxes[$key]['total'] =0;\n }\n $taxes[$key]['format'] = $tname . ' - ' . $tt->taxzones[$key]->rate . '%';\n $taxes[$key]['total'] += $tt->tax;\n }\n }",
" assign_to_template(array(\n 'payment_summary' => $payment_summary,\n 'payments_key' => $payments_key,\n 'payment_values' => $payment_values,\n// 'tax_total' => !empty($tax_res->tax_total) ? $tax_res->tax_total : 0,\n// 'tax_type' => $tax_type_formatted,\n 'taxes' => $taxes\n ));\n }",
" function export_user_input_report() {\n $order = new order();\n $out = '\"ITEM_NAME\",\"QUANTITY\",\"PERSONALIZATION\"' . chr(13) . chr(10);\n //eDebug($this->params,true);\n $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);\n $orders = $order->find('all', 'id IN (' . $orders_string . ')');\n //eDebug($orders,true);\n $pattern = '/\\(.*\\)/i';\n $items = array();\n $top = array();\n foreach ($orders as $order) { //eDebug($order,true);\n foreach ($order->orderitem as $oi) {\n // eDebug($oi,true);\n $item = array();\n if ($oi->user_input_fields == '' || $oi->user_input_fields == 'a:0:{}') continue;\n else $item['user_input_data'] = expUnserialize($oi->user_input_fields);;",
" $model = preg_replace($pattern, '', preg_replace('/\\s/', '', $oi->products_model));\n $item['model'] = $model;\n //$item['name'] = strip_tags($oi->products_name);\n $item['qty'] = $oi->quantity;",
" $items[] = $item;\n }\n }\n unset($item);\n foreach ($items as $item) {\n $line = '';",
" //$line = expString::outputField(\"SMC Inventory - Laurie\");",
" $line .= expString::outputField($item['model']);\n //$line.= expString::outputField($item['name']);\n $line .= expString::outputField($item['qty']);\n $ui = array();\n $uiInfo = '';\n foreach ($item['user_input_data'] as $tlArray) {\n foreach ($tlArray as $ifKey => $if) {\n $uiInfo .= $ifKey . '=' . $if . \" | \";\n }\n }\n $line .= expString::outputField(strtoupper(substr_replace($uiInfo, '', strrpos($uiInfo, ' |'), strlen(' |'))), chr(13) . chr(10));\n $out .= $line;\n }\n //eDebug($out,true);\n self::download($out, 'User_Input_Export_' . time() . '.csv', 'application/csv');\n // [firstname] => Fred [middlename] => J [lastname] => Dirkse [organization] => OIC Group, Inc. [address1] => PO Box 1111 [address2] => [city] => Peoria [state] => 23 [zip] => 61653 [country] => [phone] => 309-555-1212 begin_of_the_skype_highlighting 309-555-1212 end_of_the_skype_highlighting [email] => fred@oicgroup.net [shippingcalculator_id] => 4 [option] => 01 [option_title] => 8-10 Day [shipping_cost] => 5.95\n }",
" function export_inventory() {\n $order = new order();\n $out = '\"BADDR_LAST_NM\",\"ITEM_NAME\",\"ITEM_DESC\",\"ITEM_QUANTITY\"' . chr(13) . chr(10);\n //eDebug($this->params,true);\n $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);\n $orders = $order->find('all', 'id IN (' . $orders_string . ')');\n //eDebug($orders,true);\n $pattern = '/\\(.*\\)/i';\n $items = array();\n $top = array();\n foreach ($orders as $order) { //eDebug($order,true);\n foreach ($order->orderitem as $oi) {\n $model = preg_replace($pattern, '', preg_replace('/\\s/', '', $oi->products_model));\n if (stripos($model, 'DUI') === 0) {\n $top[$model]['name'] = strip_tags($oi->products_name);\n if (isset($top[$model]['qty'])) $top[$model]['qty'] += $oi->quantity;\n else $top[$model]['qty'] = $oi->quantity;\n } else {\n $items[$model]['name'] = strip_tags($oi->products_name);\n if (isset($items[$model]['qty'])) $items[$model]['qty'] += $oi->quantity;\n else $items[$model]['qty'] = $oi->quantity;\n }\n }\n }\n ksort($top, SORT_STRING);\n ksort($items, SORT_STRING);\n foreach ($top as $model => $item) {\n $line = '';\n $line = expString::outputField(\"SMC Inventory - Laurie\");\n $line .= expString::outputField($model);\n $line .= expString::outputField($item['name']);\n $line .= expString::outputField($item['qty'], chr(13) . chr(10));\n $out .= $line;\n }\n foreach ($items as $model => $item) {\n $line = '';\n $line = expString::outputField(\"SMC Inventory - Laurie\");\n $line .= expString::outputField($model);\n $line .= expString::outputField($item['name']);\n $line .= expString::outputField($item['qty'], chr(13) . chr(10));\n $out .= $line;\n }\n //eDebug($out,true);\n self::download($out, 'Inventory_Export_' . time() . '.csv', 'application/csv');\n // [firstname] => Fred [middlename] => J [lastname] => Dirkse [organization] => OIC Group, Inc. [address1] => PO Box 1111 [address2] => [city] => Peoria [state] => 23 [zip] => 61653 [country] => [phone] => 309-555-1212 begin_of_the_skype_highlighting 309-555-1212 end_of_the_skype_highlighting [email] => fred@oicgroup.net [shippingcalculator_id] => 4 [option] => 01 [option_title] => 8-10 Day [shipping_cost] => 5.95",
" }",
" function generateProductReport() {\n global $db;\n // eDebug($this->params);\n $p = $this->params;\n $sqlids = \"SELECT DISTINCT(p.id) from \";\n $count_sql = \"SELECT COUNT(DISTINCT(p.id)) as c FROM \";\n $sqlstart = \"SELECT DISTINCT(p.id), p.title, p.model, concat('\".expCore::getCurrencySymbol().\"',format(p.base_price,2)) as base_price\";//, ps.title as status from \";\n $sql = $db->prefix . \"product as p \";\n if (!isset($p['allproducts'])){\n $sql .= \"INNER JOIN \" . $db->prefix . \"product_status as ps ON p.product_status_id = ps.id \";\n $sqlstart .= \", ps.title as status from \";\n if (!isset($p['uncategorized'])){\n $sql .= \"INNER JOIN \" . $db->prefix . \"product_storeCategories as psc ON p.id = psc.product_id \";\n }\n } else {\n $sqlstart .= \" from \";\n }\n //$sqlidsjoin = \"INNER JOIN \" . $db->prefix . \"product as childp ON p.id = childp.parent_id \";\n $sqlwhere = 'WHERE (1=1 ';",
" $inc = 0;\n $sqltmp = '';\n if (isset($p['product_status'])) {\n foreach ($p['product_status'] as $os) {\n if ($os == '') continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (p.product_status_id = \" . $os;\n } else {\n $sqltmp .= \" OR p.product_status_id = \" . $os;\n }",
" }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" $inc = 0;\n $sqltmp = '';\n if (!empty($p['product_type'])) foreach ($p['product_type'] as $ot) {\n if ($ot == '') continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (p.product_type = '\" . $ot . \"'\";\n } else {\n $sqltmp .= \" OR p.product_type = '\" . $ot . \"'\";\n }",
" }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";",
" if (!isset($p['allproducts'])) {\n if (!isset($p['uncategorized'])) {\n $inc = 0;\n $sqltmp = '';\n if (!empty($p['storeCategory'])) foreach ($p['storeCategory'] as $ot) {\n if ($ot == '') continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (psc.storecategories_id = \" . $ot;\n } else {\n $sqltmp .= \" OR psc.storecategories_id = \" . $ot;\n }",
" }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n } else {\n $sqlwhere .= \" AND psc.storecategories_id = 0 AND p.parent_id = 0\";\n }\n }",
" if (!empty($p['product-range-num'])) {\n $operator = '';\n switch ($p['product-range-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND p.id\" . $operator . $p['product-range-num'];\n }",
" $inc = 0;\n $sqltmp = '';\n if (isset($p['company'])) {\n foreach ($p['company'] as $os) {\n if ($os == '') continue;\n else if ($inc == 0) {\n $inc++;\n $sqltmp .= \" AND (p.companies_id = \" . $os;\n } else {\n $sqltmp .= \" OR p.companies_id = \" . $os;\n }",
" }\n if (!empty($sqltmp)) $sqlwhere .= $sqltmp .= \")\";\n }",
" if (!empty($p['product-price-num'])) {\n $operator = '';\n switch ($p['product-price-op']) {\n case 'g':\n $operator = '>';\n break;\n case 'l':\n $operator = '<';\n break;\n case 'e':\n $operator = '=';\n break;\n }\n $sqlwhere .= \" AND p.base_price\" . $operator . $p['product-price-num'];\n }",
" if (!empty($p['pnam'])) {\n $sqlwhere .= \" AND p.title LIKE '%\" . $p['pnam'] . \"%'\";\n }",
" if (!empty($p['sku'])) {\n $sqlwhere .= \" AND p.model LIKE '%\" . $p['sku'] . \"%'\";\n }",
" $sqlwhere .= \")\";",
" $exportSQL = $sqlids . $sql . $sqlwhere; // . \")\"; // \" OR p.parent_id IN (\".$sqlids . $sql . $sqlwhere . \")\";\n //$sqlidswhere = \" OR p.id IN (SELECT id FROM\".$db->prefix.\"_product WHERE parent_id=)\";\n// eDebug($sqlstart . $sql . $sqlwhere);\n// eDebug($count_sql . $sql . $sqlwhere);\n// eDebug(\"Stored:\" . $exportSQL);\n expSession::set('product_export_query', $exportSQL);\n //expSession::set('product_export_query', \"SELECT DISTINCT(p.id) FROM `exponent_product` p WHERE (title like '%Velcro%' OR feed_title like '%Velcro%' OR title like '%Multicam%' OR feed_title like '%Multicam%') AND parent_id = 0\");",
" $product = new product();",
" //$items = $product->find('all', '', 'id', 25);\n //$page = new expPaginator();\n //eDebug($page,true);",
" $page = new expPaginator(array(\n// 'model' => 'product',\n //'records'=>$items,\n // 'where'=>$where,\n 'sql' => $sqlstart . $sql . $sqlwhere,\n //'sql'=>\"SELECT DISTINCT(p.id), p.title, p.model, p.base_price FROM `exponent_product` p WHERE (title like '%Velcro%' OR feed_title like '%Velcro%' OR title like '%Multicam%' OR feed_title like '%Multicam%') AND parent_id = 0\",\n //'count_sql'=>\"SELECT COUNT(DISTINCT(p.id)) FROM `exponent_product` p WHERE (title like '%Velcro%' OR feed_title like '%Velcro%' OR title like '%Multicam%' OR feed_title like '%Multicam%') AND parent_id = 0\",\n 'count_sql' => $count_sql . $sql . $sqlwhere,\n 'limit' => empty($this->config['limit']) ? 350 : $this->config['limit'],\n 'order' => 'id',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => 'store',\n 'action' => $this->params['action'],\n 'columns' => array(\n 'actupon' => true,\n 'ID' => 'id',\n gt('Product') => 'title|controller=store,action=show,showby=id',\n 'SKU' => 'model',\n gt('Price') => 'base_price',\n gt('Status') => 'status'\n ),\n //'columns'=>array('Product'=>'title','SKU'=>'model'),\n ));\n //eDebug($page,true);\n /*$page = new expPaginator(array(\n 'model'=>'order',\n 'controller'=>$this->params['controller'],\n 'action'=>$this->params['action'],\n 'sql'=>$sql,\n 'order'=>'purchased',\n 'dir'=>'DESC',\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns'=>array(\n 'Customer'=>'lastname',",
" 'Invoice #'=>'invoice_id',",
" 'Total'=>'total',\n 'Date Purchased'=>'purchased',\n 'Status'=>'order_status_id',\n )\n )); */\n $action_items = array(\n 'batch_export' => 'Export Product List to CSV',\n 'status_export' => 'Export Product Status Report to CSV'\n );\n assign_to_template(array(\n 'page' => $page,\n 'action_items' => $action_items\n ));",
" //\n //\n // assign_to_template(array('page'=>$page));",
" }",
" /**\n * @deprecated 2.3.3 moved to expString\n */\n public static function parseAndTrimExport($str, $isHTML = false) { //�Death from above�? �",
" //echo \"1<br>\"; eDebug($str);",
"\n $str = str_replace(\"�\", \"’\", $str);\n $str = str_replace(\"�\", \"‘\", $str);\n $str = str_replace(\"�\", \"®\", $str);\n $str = str_replace(\"�\", \"-\", $str);\n $str = str_replace(\"�\", \"—\", $str);\n $str = str_replace(\"�\", \"”\", $str);\n $str = str_replace(\"�\", \"“\", $str);\n $str = str_replace(\"\\r\\n\", \" \", $str);\n $str = str_replace(\"\\t\", \" \", $str);\n $str = str_replace(\",\", \"\\,\", $str);\n $str = str_replace(\"�\", \"¼\", $str);\n $str = str_replace(\"�\", \"½\", $str);\n $str = str_replace(\"�\", \"¾\", $str);",
" if (!$isHTML) {\n $str = str_replace('\\\"', \""\", $str);\n $str = str_replace('\"', \""\", $str);\n } else {\n $str = str_replace('\"', '\"\"', $str);\n }",
" //$str = htmlspecialchars($str);\n //$str = utf8_encode($str);\n $str = trim(str_replace(\"�\", \"™\", $str));\n //echo \"2<br>\"; eDebug($str,die);\n return $str;\n }",
" /**\n * @deprecated 2.3.3 moved to expString\n */\n public static function parseAndTrimImport($str, $isHTML = false) { //�Death from above�? �\n //echo \"1<br>\"; eDebug($str);\n// global $db;",
" $str = str_replace(\"�\", \"’\", $str);\n $str = str_replace(\"�\", \"‘\", $str);\n $str = str_replace(\"�\", \"®\", $str);\n $str = str_replace(\"�\", \"-\", $str);\n $str = str_replace(\"�\", \"—\", $str);\n $str = str_replace(\"�\", \"”\", $str);\n $str = str_replace(\"�\", \"“\", $str);\n $str = str_replace(\"\\r\\n\", \" \", $str);\n $str = str_replace(\"\\,\", \",\", $str);\n $str = str_replace('\"\"', '\"', $str); //do this no matter what...in case someone added a quote in a non HTML field\n if (!$isHTML) {",
" //if HTML, then leave the single quotes alone, otheriwse replace w/ special Char",
" $str = str_replace('\"', \""\", $str);\n }\n $str = str_replace(\"�\", \"¼\", $str);\n $str = str_replace(\"�\", \"½\", $str);\n $str = str_replace(\"�\", \"¾\", $str);\n //$str = htmlspecialchars($str);\n //$str = utf8_encode($str);\n// if (DB_ENGINE=='mysqli') {\n//\t $str = @mysqli_real_escape_string($db->connection,trim(str_replace(\"�\", \"™\", $str)));\n// } elseif(DB_ENGINE=='mysql') {\n// $str = @mysql_real_escape_string(trim(str_replace(\"�\", \"™\", $str)),$db->connection);\n// } else {\n//\t $str = trim(str_replace(\"�\", \"™\", $str));\n// }\n $str = @expString::escape(trim(str_replace(\"�\", \"™\", $str)));\n //echo \"2<br>\"; eDebug($str,die);\n return $str;\n }",
" /**\n * @deprecated 2.3.3 moved to expString\n */\n public static function parseAndTrim($str, $isHTML = false) { //�Death from above�? �\n //echo \"1<br>\"; eDebug($str);\n// global $db;",
" $str = str_replace(\"�\", \"’\", $str);\n $str = str_replace(\"�\", \"‘\", $str);\n $str = str_replace(\"�\", \"®\", $str);\n $str = str_replace(\"�\", \"-\", $str);\n $str = str_replace(\"�\", \"—\", $str);\n $str = str_replace(\"�\", \"”\", $str);\n $str = str_replace(\"�\", \"“\", $str);\n $str = str_replace(\"\\r\\n\", \" \", $str);",
" //$str = str_replace(\",\",\"\\,\",$str);",
"\n $str = str_replace('\\\"', \""\", $str);\n $str = str_replace('\"', \""\", $str);\n $str = str_replace(\"�\", \"¼\", $str);\n $str = str_replace(\"�\", \"½\", $str);\n $str = str_replace(\"�\", \"¾\", $str);\n //$str = htmlspecialchars($str);\n //$str = utf8_encode($str);\n// if (DB_ENGINE=='mysqli') {\n//\t $str = @mysqli_real_escape_string($db->connection,trim(str_replace(\"�\", \"™\", $str)));\n// } elseif(DB_ENGINE=='mysql') {\n// $str = @mysql_real_escape_string(trim(str_replace(\"�\", \"™\", $str)),$db->connection);\n// } else {\n//\t $str = trim(str_replace(\"�\", \"™\", $str));\n// }\n $str = @expString::escape(trim(str_replace(\"�\", \"™\", $str)));\n //echo \"2<br>\"; eDebug($str,die);\n return $str;\n }",
" /**\n * @deprecated 2.3.3 moved to expString\n */\n function outputField($val, $eof = ',', $isHTML = false) {\n $newVal = expString::parseAndTrimExport($val, $isHTML);\n if ($newVal != '') return '\"' . $newVal . '\"' . $eof;\n else return $eof;\n }",
" function print_orders() {\n// global $db, $timer;\n //eDebug($this->params,true);\n //eDebug($timer->mark());\n //eDebug( expSession::get('order_print_query'));\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n //$sql = expSession::get('order_print_query');\n //eDebug($sql);\n //expSession::set('product_export_query','');\n //$orders = $db->selectArraysBySql($sql);\n $obs = expSession::get('order_export_values');\n usort($obs, array(\"reportController\", \"sortPrintOrders\"));\n foreach ($obs as $ob) {\n $orders[] = array('id' => $ob->id);\n }\n //eDebug($prods);\n } else {\n foreach ($this->params['act-upon'] as $order) {\n $orders[] = array('id' => $order);\n }\n }",
" //eDebug(\"Done with print_orders: \" . $timer->mark());\n //eDebug($orders,true);\n $oc = new orderController();\n $oc->getPDF($orders);\n }",
" //sort print orders by id, newest to oldest\n static function sortPrintOrders($a, $b) {\n if ($a->invoice_id > $b->invoice_id) return -1;\n else if ($a->invoice_id < $b->invoice_id) return 1;\n else if ($a->invoice_id == $b->invoice_id) return 0;\n }",
" function export_odbc() {\n $order = new order();\n $out = '\"order_id\",\"shipping_method_id\",\"shipping_option\",\"shipping_cost\",\"firstname\",\"middlename\",\"lastname\",\"organization\",\"address1\",\"address2\",\"city\",\"state\",\"zip\",\"country\",\"phone\"' . chr(13) . chr(10);\n //eDebug($this->params,true);\n $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);\n $orders = $order->find('all', 'id IN (' . $orders_string . ')');\n //eDebug($orders);\n foreach ($orders as $order) {\n $line = expString::outputField($order->invoice_id);\n foreach ($order->shippingmethods as $m) {\n $line .= expString::outputField($m->id);\n $line .= expString::outputField($m->option_title);\n $line .= expString::outputField($order->shipping_total + $order->surcharge_total);\n $line .= expString::outputField($m->firstname);\n $line .= expString::outputField($m->middlename);\n $line .= expString::outputField($m->lastname);\n $line .= expString::outputField($m->organization);\n $line .= expString::outputField($m->address1);\n $line .= expString::outputField($m->address2);\n $line .= expString::outputField($m->city);\n// $state = new geoRegion($m->state);\n //eDebug($state);\n// $line .= expString::outputField($state->code);\n $line .= expString::outputField(geoRegion::getAbbrev($m->state));\n $line .= expString::outputField($m->zip);\n// $line .= expString::outputField('US');\n $line .= expString::outputField(geoRegion::getCountryCode($m->country));\n $line .= expString::outputField($m->phone, chr(13) . chr(10));\n break;\n }\n $out .= $line;\n }\n //eDebug($out,true);\n self::download($out, 'Shipping_Export.csv', 'application/csv');\n // [firstname] => Fred [middlename] => J [lastname] => Dirkse [organization] => OIC Group, Inc. [address1] => PO Box 1111 [address2] => [city] => Peoria [state] => 23 [zip] => 61653 [country] => [phone] => 309-555-1212 begin_of_the_skype_highlighting 309-555-1212 end_of_the_skype_highlighting [email] => fred@oicgroup.net [shippingcalculator_id] => 4 [option] => 01 [option_title] => 8-10 Day [shipping_cost] => 5.95",
" }",
" function export_order_items() {\n $order = new order();\n $out = '\"order_id\",\"quantity\",\"SKU\",\"product_title\",\"firstname\",\"middlename\",\"lastname\",\"organization\",\"address1\",\"address2\",\"city\",\"state\",\"zip\"' . chr(13) . chr(10);\n //eDebug($this->params,true);\n $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);\n $orders = $order->find('all', 'id IN (' . $orders_string . ')');\n //eDebug($orders);\n foreach ($orders as $order) {\n $m = array_shift($order->shippingmethods);\n foreach ($order->orderitem as $orderitem) {\n $line = expString::outputField($order->invoice_id);\n $line .= expString::outputField($orderitem->quantity);\n $line .= expString::outputField($orderitem->products_model);\n $line .= expString::outputField($orderitem->products_name);",
" $line .= expString::outputField($m->firstname);\n $line .= expString::outputField($m->middlename);\n $line .= expString::outputField($m->lastname);\n $line .= expString::outputField($m->organization);\n $line .= expString::outputField($m->address1);\n $line .= expString::outputField($m->address2);\n $line .= expString::outputField($m->city);\n $state = new geoRegion($m->state);\n $line .= expString::outputField($state->code);\n $line .= expString::outputField($m->zip, chr(13) . chr(10));\n $out .= $line;\n }\n }\n //eDebug($out,true);\n self::download($out, 'Order_Item_Export.csv', 'application/csv');\n // [firstname] => Fred [middlename] => J [lastname] => Dirkse [organization] => OIC Group, Inc. [address1] => PO Box 1111 [address2] => [city] => Peoria [state] => 23 [zip] => 61653 [country] => [phone] => 309-555-1212 begin_of_the_skype_highlighting 309-555-1212 end_of_the_skype_highlighting [email] => fred@oicgroup.net [shippingcalculator_id] => 4 [option] => 01 [option_title] => 8-10 Day [shipping_cost] => 5.95",
" }",
" function export_status_report() {\n $order = new order();\n $out = '\"ITEM_NAME\",\"ITEM_DESC\",\"ITEM_QUANTITY\",\"ITEM_STATUS\"' . chr(13) . chr(10);\n //eDebug($this->params,true);\n $order_ids = array();\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $obs = expSession::get('order_export_values');\n foreach ($obs as $ob) {\n $order_ids[] = $ob->id;\n }\n } else {\n foreach ($this->params['act-upon'] as $order_id) {\n $order_ids[] = $order_id;\n }\n }\n $order_ids = array_unique($order_ids);\n $orders_string = implode(',', $order_ids);\n $orders = $order->find('all', 'id IN (' . $orders_string . ')', null, null, null, true, true, array('order_discounts', 'billingmethod', 'order_status_changes', 'order_status', 'order_type'), true);\n $pattern = '/\\(.*\\)/i';\n foreach ($orders as $order) {\n foreach ($order->orderitem as $oi) {\n $model = preg_replace($pattern, '', preg_replace('/\\s/', '', $oi->products_model));\n $line = '';\n $line .= expString::outputField($model);\n $line .= expString::outputField($oi->products_name);\n $line .= expString::outputField($oi->quantity);\n $line .= expString::outputField($oi->products_status, chr(13) . chr(10));\n $out .= $line;\n }\n }\n self::download($out, 'Status_Export_' . time() . '.csv', 'application/csv');\n }",
" static function download($file, $name, $type) {\n if (!headers_sent()) {\n //echo $file;\n //exit();\n ob_clean();\n header('Content-Description: File Transfer');\n header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1\n header('Pragma: public');\n// header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past\n header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');\n // force download dialog\n header('Content-Type: application/force-download');\n //header('Content-Type: application/octet-stream', false);\n header('Content-Type: application/download', false);\n header('Content-Type: ' . $type, false);\n //header('Content-Type: application/pdf', false);\n // use the Content-Disposition header to supply a recommended filename\n header('Content-Disposition: attachment; filename=\"' . $name . '\";');\n header('Content-Transfer-Encoding: ascii');\n header('Content-Length: ' . strlen($file));\n //header('Content-Length: '.filesize($this->tmp_rendered));\n echo $file;\n //echo readfile($this->tmp_rendered);\n } else {\n echo \"Oops, headers already sent. Check DEVELOPMENT variable?\";\n }\n die();\n }",
" /**\n * @deprecated 2.3.3 moved to expString\n */\n function stripLineEndings($val) {\n return preg_replace('/\\r\\n/', ' ', trim($val));\n }",
" function productFeed() {\n// global $db;\n //check query password to avoid DDOS\n /*\n * condition = new",
" * description\n * id - SKU\n * link\n * price\n * title\n * brand - manufacturer\n * image link - fullsized image, up to 10, comma seperated\n * product type - category - \"Electronics > Audio > Audio Accessories MP3 Player Accessories\",\"Health & Beauty > Healthcare > Biometric Monitors > Pedometers\"",
" */\n $out = '\"id\",\"condition\",\"description\",\"like\",\"price\",\"title\",\"brand\",\"image link\",\"product type\"' . chr(13) . chr(10);",
" $p = new product();\n $prods = $p->find('all', 'parent_id=0 AND ');\n //$prods = $db->selectObjects('product','parent_id=0 AND');\n }",
" function abandoned_carts() {\n global $db;",
" $allCarts = array();\n $carts = array();\n $cartsWithoutItems = array();\n $cartsWithItems = array();\n $cartsWithItemsAndInfo = array();\n $summary = array();\n $valueproducts = '';",
" $quickrange = array(0 => gt('Last 24 Hours'), 1 => gt('Last 7 Days'), 2 => gt('Last 30 Days'));\n $this->setDateParams($this->params);\n if (!isset($this->params['quickrange'])) {\n $this->params['quickrange'] = 0;\n }",
" // purchased == 0 or invoice_id == 0 on unsubmitted orders\n $sql = \"SELECT * FROM \" . $db->prefix . \"orders WHERE purchased = 0 AND edited_at >= \" . $this->tstart . \" AND edited_at <= \" . $this->tend . \" AND sessionticket_ticket NOT IN \";\n $sql .= \"(SELECT ticket FROM \" . $db->prefix . \"sessionticket) ORDER BY edited_at DESC\";\n // echo $sql;\n $allCarts = $db->selectObjectsBySql($sql);\n foreach ($allCarts as $item) {",
" $sql = \"SELECT * FROM \" . $db->prefix . \"orderitems WHERE orders_id =\" . $item->id;",
" $carts = $db->selectObjectsBySql($sql);\n foreach ($carts as $item2) {\n $valueproducts += $item2->products_price_adjusted * $item2->quantity;\n }",
" $carts['last_visit'] = date('Y-m-d, g:i:s A', $item->edited_at);\n $carts['referrer'] = $item->orig_referrer;",
" if (count($carts) > 2) {\n if (!empty($item->user_id)) {\n $u = $db->selectObject('user', 'id=' . $item->user_id);\n $carts['name'] = $u->firstname . ' ' . $u->lastname;\n $carts['email'] = $u->email;\n $cartsWithItemsAndInfo[] = $carts;\n // $cartsWithItemsAndInfo['length_of_time'] = round(abs($item->last_active - $item->start_time) / 60,2).\" minutes\";\n // $cartsWithItemsAndInfo['ip_address'] = $item->ip_address;\n // $cartsWithItemsAndInfo['referrer'] = $item->referrer;\n } else {\n $cartsWithItems[] = $carts;\n // $cartsWithItems['length_of_time'] = round(abs($item->last_active - $item->start_time) / 60,2).\" minutes\";\n // $cartsWithItems['ip_address'] = $item->ip_address;\n // $cartsWithItems['referrer'] = $item->referrer;\n }",
" } else {\n $item->last_visit = date('Y-m-d, g:i:s A', $item->edited_at);\n $cartsWithoutItems[] = $item;\n }\n }\n //Added the count\n $allCarts['count'] = count($allCarts);\n $cartsWithoutItems['count'] = count($cartsWithoutItems);\n $cartsWithItems['count'] = count($cartsWithItems); //for the added values at the top\n $cartsWithItemsAndInfo['count'] = count($cartsWithItemsAndInfo); //for the added values at the top",
" // eDebug($allCarts);\n // eDebug($cartsWithoutItems);\n // eDebug($cartsWithItems);\n // eDebug($cartsWithItemsAndInfo);\n // exit();\n $summary['totalcarts'] = $allCarts['count'];\n $summary['valueproducts'] = $valueproducts;\n $summary['cartsWithoutItems'] = round(($allCarts['count'] ? $cartsWithoutItems['count'] / $allCarts['count'] : 0) * 100, 2) . '%';\n $summary['cartsWithItems'] = round(($allCarts['count'] ? $cartsWithItems['count'] / $allCarts['count'] : 0) * 100, 2) . '%';\n $summary['cartsWithItemsAndInfo'] = round(($allCarts['count'] ? $cartsWithItemsAndInfo['count'] / $allCarts['count'] : 0) * 100, 2) . '%';",
" assign_to_template(array(\n 'quickrange' => $quickrange,\n 'quickrange_default' => $this->params['quickrange'],\n 'summary' => $summary,\n 'cartsWithoutItems' => $cartsWithoutItems,\n 'cartsWithItems' => $cartsWithItems,\n 'cartsWithItemsAndInfo' => $cartsWithItemsAndInfo\n ));\n }",
" function pruge_abandoned_carts()\n {\n global $db;",
" $db->delete(\"orders\",\"`invoice_id` = '0' AND `edited_at` < UNIX_TIMESTAMP(now())-5184000 AND `sessionticket_ticket` NOT IN (SELECT `ticket` FROM `\".$db->prefix.\"sessionticket`)\");\n $db->delete(\"orderitems\",\"`orders_id` NOT IN (SELECT `id` FROM `\".$db->prefix.\"orders`)\");\n $db->delete(\"shippingmethods\",\"`id` NOT IN (SELECT `shippingmethods_id` FROM `\".$db->prefix.\"orders`)\");\n }",
" function current_carts() {\n global $db;",
" $allCarts = array();\n $carts = array();\n $cartsWithoutItems = array();\n $cartsWithItems = array();\n $cartsWithItemsAndInfo = array();\n $summary = array();\n $valueproducts = '';\n // $sql = \"SELECT * FROM \" . $db->prefix . \"orders WHERE DATEDIFF(FROM_UNIXTIME(edited_at, '%Y-%m-%d'), '\" . date('Y-m-d') . \"') = 0\";",
" $sql = \"SELECT * FROM \" . $db->prefix . \"orders, \" . $db->prefix . \"sessionticket WHERE ticket = sessionticket_ticket\";",
" $allCarts = $db->selectObjectsBySql($sql);",
" // eDebug($allCarts, true);\n foreach ($allCarts as $item) {",
" $sql = \"SELECT * FROM \" . $db->prefix . \"orderitems WHERE orders_id =\" . $item->id;",
" $carts = $db->selectObjectsBySql($sql);",
" foreach ($carts as $item2) {\n $valueproducts += $item2->products_price_adjusted * $item2->quantity;\n }",
" $carts['length_of_time'] = round(abs($item->last_active - $item->start_time) / 60, 2) . \" minutes\";\n $carts['ip_address'] = $item->ip_address;\n $carts['referrer'] = $item->referrer;",
" if (count($carts) > 3) {\n if (!empty($item->user_id)) {\n $u = $db->selectObject('user', 'id=' . $item->user_id);\n $carts['name'] = $u->firstname . ' ' . $u->lastname;\n $carts['email'] = $u->email;\n $cartsWithItemsAndInfo[] = $carts;\n // $cartsWithItemsAndInfo['length_of_time'] = round(abs($item->last_active - $item->start_time) / 60,2).\" minutes\";\n // $cartsWithItemsAndInfo['ip_address'] = $item->ip_address;\n // $cartsWithItemsAndInfo['referrer'] = $item->referrer;\n } else {\n $cartsWithItems[] = $carts;\n // $cartsWithItems['length_of_time'] = round(abs($item->last_active - $item->start_time) / 60,2).\" minutes\";\n // $cartsWithItems['ip_address'] = $item->ip_address;\n // $cartsWithItems['referrer'] = $item->referrer;\n }",
" } else {\n $item->length_of_time = round(abs($item->last_active - $item->start_time) / 60, 2) . \" minutes\";\n $cartsWithoutItems[] = $item;\n }\n }\n //Added the count\n $allCarts['count'] = count($allCarts);\n $cartsWithoutItems['count'] = count($cartsWithoutItems);\n $cartsWithItems['count'] = count($cartsWithItems); //for the added values at the top\n $cartsWithItemsAndInfo['count'] = count($cartsWithItemsAndInfo); //for the added values at the top",
" // eDebug($allCarts);\n // eDebug($cartsWithoutItems);\n // eDebug($cartsWithItems);\n // eDebug($cartsWithItemsAndInfo);",
" $summary['totalcarts'] = $allCarts['count'];\n $summary['valueproducts'] = intval($valueproducts);\n $summary['cartsWithoutItems'] = round(($allCarts['count'] ? $cartsWithoutItems['count'] / $allCarts['count'] : 0) * 100, 2) . '%';\n $summary['cartsWithItems'] = round(($allCarts['count'] ? $cartsWithItems['count'] / $allCarts['count'] : 0) * 100, 2) . '%';\n $summary['cartsWithItemsAndInfo'] = round(($allCarts['count'] ? $cartsWithItemsAndInfo['count'] / $allCarts['count'] : 0) * 100, 2) . '%';",
" // eDebug($summary, true);\n assign_to_template(array(\n 'summary' => $summary,\n 'cartsWithoutItems' => $cartsWithoutItems,\n 'cartsWithItems' => $cartsWithItems,\n 'cartsWithItemsAndInfo' => $cartsWithItemsAndInfo\n ));\n /*\n $this->setDateParams($this->params);\n $except = array('order_discounts', 'billingmethod', 'order_status_changes', 'billingmethod','order_discounts');\n //$orders = $this->o->find('all','purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend,null,null,null,true,false,$except,true);\n // $sql = \"SELECT DATE_FORMAT(created_at, '%Y-%m-%d') as formattedDate FROM orders WHERE created_at\n eDebug(date('Y-m-d'), true);\n // eDebug($this->tend);\n eDebug(date('Y-m-d, g:i:s A', $this->tend));",
" $allOrderCount = $this->o->find('count','created_at >= ' . $this->tstart . ' AND created_at <= ' . $this->tend,null,null,null,true,false,$except,true);",
" $sql = \"SELECT COUNT(DISTINCT(`orders_id`)) as c FROM \" . $db->prefix . \"orderitems oi \";\n $sql .= \"JOIN \" . $db->prefix . \"orders o ON oi.orders_id = o.id \";\n $sql .= \"WHERE o.created_at >= \" . $this->tstart . \" AND o.created_at <= \" . $this->tend;\n //$sql .= \" AND o.user_id != 0 AND o.order_type_id = 1\";",
"",
" eDebug($sql);\n $allCartsWithItems = $db->countObjectsBySql($sql);",
"",
" $sql = \"SELECT COUNT(DISTINCT(`orders_id`)) as c FROM \" . $db->prefix . \"orderitems oi \";\n $sql .= \"JOIN \" . $db->prefix . \"orders o ON oi.orders_id = o.id \";\n $sql .= \"WHERE o.created_at >= \" . $this->tstart . \" AND o.created_at <= \" . $this->tend;\n eDebug($sql);\n $realUserCartsWithItems = $db->countObjectsBySql($sql);",
"\n $ordersInCheckout = $this->o->find('count','created_at >= ' . $this->tstart . ' AND created_at <= ' . $this->tend . \" AND user_id != 0\",null,null,null,true,false,$except,true);",
" //$ordersPurchased = $this->o->find('count','purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend . \" AND user_id != 0 AND order_type_id = 1\",null,null,null,true,false,$except,true);\n //$ordersPurchased = $this->o->find('count','purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend . \" AND user_id != 0\",null,null,null,true,false,$except,true);\n $ordersPurchased = $this->o->find('count','purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend,null,null,null,true,false,$except,true);\n $orders = $this->o->find('all','purchased >= ' . $this->tstart . ' AND purchased <= ' . $this->tend,null,null,null,true,false,$except,true);",
" eDebug(\"All:\" . $allOrderCount);\n eDebug(\"Carts w/ Items:\" . $allCartsWithItems);\n eDebug(\"Carts w/ Items in Checkout:\" . $ordersInCheckout);\n eDebug(\"Purchased:\" . $ordersPurchased);\n",
" $totalAbandoned = ($allCartsWithItems - $ordersPurchased) / $allCartsWithItems;\n $checkoutAbandoned = ($ordersInCheckout - $ordersPurchased) / $ordersInCheckout;\n eDebug(\"Total Abandoned: \" . $totalAbandoned);\n eDebug(\"Checkout Abandoned: \" . $checkoutAbandoned);",
"",
"\n",
" $quickrange = array(0=>'Last 24 Hours',1=>'Last 7 Days',2=>'Last 30 Days');\n $quickrange_default = isset($this->params['quickrange']) ? $this->params['quickrange'] : 0;\n assign_to_template(array('orders'=>$oar,'quickrange'=>$quickrange,'quickrange_default'=>$quickrange_default));",
" assign_to_template(array('prev_month'=>$this->prev_month, 'now_date'=>$this->now_date, 'now_hour'=>$this->now_hour, 'now_min'=>$this->now_min, 'now_ampm'=>$this->now_ampm, 'prev_hour'=>$this->prev_hour, 'prev_min'=>$this->prev_min, 'prev_ampm'=>$this->prev_ampm));",
" */\n }",
" function batch_export() {\n global $db;\n //eDebug($this->params);\n //$sql = \"SELECT * INTO OUTFILE '\" . BASE . \"tmp/export.csv' FIELDS TERMINATED BY ',' FROM exponent_product WHERE 1 LIMIT 10\";\n// $out = '\"id\",\"parent_id\",\"child_rank\",\"title\",\"body\",\"model\",\"warehouse_location\",\"sef_url\",\"canonical\",\"meta_title\",\"meta_keywords\",\"meta_description\",\"tax_class_id\",\"quantity\",\"availability_type\",\"base_price\",\"special_price\",\"use_special_price\",\"active_type\",\"product_status_id\",\"category1\",\"category2\",\"category3\",\"category4\",\"category5\",\"category6\",\"category7\",\"category8\",\"category9\",\"category10\",\"category11\",\"category12\",\"surcharge\",\"category_rank\",\"feed_title\",\"feed_body\"' . chr(13) . chr(10);\n $out = '\"id\",\"parent_id\",\"child_rank\",\"title\",\"body\",\"model\",\"warehouse_location\",\"sef_url\",\"meta_title\",\"meta_keywords\",\"meta_description\",\"tax_class_id\",\"quantity\",\"availability_type\",\"base_price\",\"special_price\",\"use_special_price\",\"active_type\",\"product_status_id\",\"category1\",\"category2\",\"category3\",\"category4\",\"category5\",\"category6\",\"category7\",\"category8\",\"category9\",\"category10\",\"category11\",\"category12\",\"surcharge\",\"category_rank\",\"feed_title\",\"feed_body\",\"weight\",\"width\",\"height\",\"length\",\"companies_id\"' . chr(13) . chr(10);\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $sql = expSession::get('product_export_query');\n if (empty($sql)) $sql = 'SELECT DISTINCT(p.id) from ' . $db->prefix . 'product as p WHERE (1=1 )';\n //eDebug($sql);\n //expSession::set('product_export_query','');\n $prods = $db->selectArraysBySql($sql);\n //eDebug($prods);\n } else {\n foreach ($this->params['act-upon'] as $prod) {\n $prods[] = array('id' => $prod);\n }\n }\n set_time_limit(0);\n $baseProd = new product();",
" //$p = new product($pid['id'], false, false);\n foreach ($prods as $pid) {\n $except = array('company', 'crosssellItem', 'optiongroup');\n $p = $baseProd->find('first', 'id=' . $pid['id'], null, null, 0, true, false, $except, true);",
" //eDebug($p,true);\n $out .= expString::outputField($p->id);\n $out .= expString::outputField($p->parent_id);\n $out .= expString::outputField($p->child_rank);\n $out .= expString::outputField($p->title);\n $out .= expString::outputField(expString::stripLineEndings($p->body), \",\", true);\n $out .= expString::outputField($p->model);\n $out .= expString::outputField($p->warehouse_location);\n $out .= expString::outputField($p->sef_url);\n// $out .= expString::outputField($p->canonical); //FIXME this is NOT in import\n $out .= expString::outputField($p->meta_title);\n $out .= expString::outputField($p->meta_keywords);\n $out .= expString::outputField($p->meta_description);\n $out .= expString::outputField($p->tax_class_id);\n $out .= expString::outputField($p->quantity);\n $out .= expString::outputField($p->availability_type);\n $out .= expString::outputField($p->base_price);\n $out .= expString::outputField($p->special_price);\n $out .= expString::outputField($p->use_special_price);\n $out .= expString::outputField($p->active_type);\n $out .= expString::outputField($p->product_status_id);",
" $rank = 0;\n //eDebug($p);\n for ($x = 0; $x < 12; $x++) {\n $this->catstring = '';\n if (isset($p->storeCategory[$x])) {\n $out .= expString::outputField(storeCategory::buildCategoryString($p->storeCategory[$x]->id, true));\n $rank = $db->selectValue('product_storeCategories', 'rank', 'product_id=' . $p->id . ' AND storecategories_id=' . $p->storeCategory[$x]->id);\n } else $out .= ',';\n }\n $out .= expString::outputField($p->surcharge);\n $out .= expString::outputField($rank);\n $out .= expString::outputField($p->feed_title);\n $out .= expString::outputField($p->feed_body);\n $out .= expString::outputField($p->weight);\n $out .= expString::outputField($p->height);\n $out .= expString::outputField($p->width);\n $out .= expString::outputField($p->length);\n $out .= expString::outputField($p->companies_id, chr(13) . chr(10)); //Removed the extra \",\" in the last element",
" foreach ($p->childProduct as $cp) {\n //$p = new product($pid['id'], true, false);\n //eDebug($p,true);\n $out .= expString::outputField($cp->id);\n $out .= expString::outputField($cp->parent_id);\n $out .= expString::outputField($cp->child_rank);\n $out .= expString::outputField($cp->title);\n $out .= expString::outputField(expString::stripLineEndings($cp->body));\n $out .= expString::outputField($cp->model);\n $out .= expString::outputField($cp->warehouse_location);\n $out .= expString::outputField($cp->sef_url);\n// $out .= expString::outputField($cp->canonical); //FIXME this is NOT in import\n $out .= expString::outputField($cp->meta_title);\n $out .= expString::outputField($cp->meta_keywords);\n $out .= expString::outputField($cp->meta_description);\n $out .= expString::outputField($cp->tax_class_id);\n $out .= expString::outputField($cp->quantity);\n $out .= expString::outputField($cp->availability_type);\n $out .= expString::outputField($cp->base_price);\n $out .= expString::outputField($cp->special_price);\n $out .= expString::outputField($cp->use_special_price);\n $out .= expString::outputField($cp->active_type);\n $out .= expString::outputField($cp->product_status_id);\n $out .= ',,,,,,,,,,,,'; // for store categories\n $out .= expString::outputField($cp->surcharge);\n $out .= ',,,'; // for rank, feed title, feed body\n $out .= expString::outputField($cp->weight);\n $out .= expString::outputField($cp->height);\n $out .= expString::outputField($cp->width);\n $out .= expString::outputField($cp->length);\n $out .= expString::outputField($cp->companies_id, chr(13) . chr(10)); //Removed the extra \",\" in the last element\n //echo($out);\n }",
" }",
" $outFile = 'tmp/product_export_' . time() . '.csv';\n $outHandle = fopen(BASE . $outFile, 'w');\n fwrite($outHandle, $out);\n fclose($outHandle);",
" echo \"<br/><br/>\".gt('Download the file here').\": <a href='\" . PATH_RELATIVE . $outFile . \"'>\".gt('Product Export').\"</a>\";",
" /*eDebug(BASE . \"tmp/export.csv\");\n $db->sql($sql);\n eDebug($db->error());*/",
" /*OPTIONALLY ENCLOSED BY '\" . '\"' .",
" \"' ESCAPED BY '\\\\'\n LINES TERMINATED BY '\" . '\\\\n' .\n \"' */\n }",
" function payment_report() {\n// global $db;\n $payment_methods = array('-1' => '', 'V' => 'Visa', 'MC' => 'Mastercard', 'D' => 'Discover', 'AMEX' => 'American Express', 'PP' => 'PayPal', 'GC' => 'Google Checkout', 'Other' => 'Other');\n //5 paypal\n //4 credit card - VisaCard, MasterCard, AmExCard, DiscoverCard",
" $oids = \"(\";",
" eDebug(expSession::get('order_print_query'));\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n //$sql = expSession::get('order_print_query');\n //eDebug($sql);\n //expSession::set('product_export_query','');\n //$orders = $db->selectArraysBySql($sql);\n $obs = expSession::get('order_export_values');\n usort($obs, array(\"reportController\", \"sortPrintOrders\"));\n foreach ($obs as $ob) {\n $oids .= $ob->id . \",\";\n }\n //eDebug($prods);\n } else {\n if (!empty($this->params['act-upon'])) foreach ($this->params['act-upon'] as $order) {\n $oids .= $order->id . \",\";\n }\n }\n $oids = strrev(expUtil::right(strrev($oids), strlen($oids) - 1));\n $oids .= \")\";\n eDebug($oids);\n //eDebug($orders,true);",
" }",
" function status_export() {\n global $db;\n //eDebug($this->params);\n //$sql = \"SELECT * INTO OUTFILE '\" . BASE . \"tmp/export.csv' FIELDS TERMINATED BY ',' FROM exponent_product WHERE 1 LIMIT 10\";",
" //is | parent_id | SKU |WAREHOUSE LOCATION | Title | Vendor/Manufacturer | Product Status | Notes",
" $out = '\"id\",\"parent_id\",\"model\",\"warehouse_location\",\"title\",\"vendor\",\"product_status\",\"notes\"' . chr(13) . chr(10);\n if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {\n $sql = expSession::get('product_export_query');\n if (empty($sql)) $sql = 'SELECT DISTINCT(p.id) from ' . $db->prefix . 'product as p WHERE (1=1 )';\n //eDebug($sql);\n //expSession::set('product_export_query','');\n $prods = $db->selectArraysBySql($sql);\n //eDebug($prods);\n } else {\n foreach ($this->params['act-upon'] as $prod) {\n $prods[] = array('id' => $prod);\n }\n }",
" $stats = new product_status();\n $stats = $stats->find('all');",
"// $statuses = array();\n $statuses = array(0=>'');\n foreach ($stats as $stat) {\n $statuses[$stat->id] = $stat->title;\n }",
"// eDebug($statuses);",
" set_time_limit(0);\n $baseProd = new product();",
" //$p = new product($pid['id'], false, false);\n //id | parent_id | SKU |WAREHOUSE LOCATION | Title | Vendor/Manufacturer | Product Status | Notes\n foreach ($prods as $pid) {\n $except = array('crosssellItem', 'optiongroup', 'childProduct');\n $p = $baseProd->find('first', 'id=' . $pid['id'], null, null, 0, true, true, $except, true);",
" /*if(count($p->expSimpleNote))\n {\n eDebug($p,true);\n }\n else\n {\n continue;\n }*/",
" $out .= expString::outputField($p->id);\n $out .= expString::outputField($p->parent_id);\n $out .= expString::outputField($p->model);\n $out .= expString::outputField($p->warehouse_location);\n $out .= expString::outputField($p->title);\n $out .= expString::outputField($p->company->title);\n $out .= expString::outputField($statuses[$p->product_status_id]);",
" $noteString = '';\n foreach ($p->expSimpleNote as $note) {\n $noteString .= \"(\" . $note->name . \" - \" . date('M d Y H:i A', $note->created_at) . \") \" . $note->body . \"||\";\n }\n $out .= expString::outputField($noteString, chr(13) . chr(10));",
" $cps = $baseProd->find('all', 'parent_id=' . $p->id, null, null, 0, true, true, $except, true);\n foreach ($cps as $cp) {\n $out .= expString::outputField($cp->id);\n $out .= expString::outputField($cp->parent_id);\n $out .= expString::outputField($cp->model);\n $out .= expString::outputField($cp->warehouse_location);\n $out .= expString::outputField($cp->title);\n $out .= expString::outputField($cp->company->title);\n $out .= expString::outputField($statuses[$cp->product_status_id]);",
" $noteString = '';\n foreach ($cp->expSimpleNote as $note) {\n $noteString .= \"(\" . $note->name . \" - \" . date('M d Y H:i A', $note->created_at) . \") \" . $note->body . \"||\";\n }\n $out .= expString::outputField($noteString, chr(13) . chr(10));\n }\n }",
" //eDebug($out,true);\n $outFile = 'tmp/product_status_' . time() . '.csv';\n $outHandle = fopen(BASE . $outFile, 'w');\n fwrite($outHandle, $out);\n fclose($outHandle);",
" echo \"<br/><br/>\".gt('Download the file here').\": <a href='\" . PATH_RELATIVE . $outFile . \"'>\".gt('Product Export').\"</a>\";",
" /*eDebug(BASE . \"tmp/export.csv\");\n $db->sql($sql);\n eDebug($db->error());*/",
" /*OPTIONALLY ENCLOSED BY '\" . '\"' .",
" \"' ESCAPED BY '\\\\'\n LINES TERMINATED BY '\" . '\\\\n' .\n \"' */\n }",
" //public $catstring = '';",
" /**\n * @deprecated 2.3.4 moved to storeCategory\n */\n public static function buildCategoryString($catID, $reset = false) {\n static $cstr = '';\n if ($reset) $cstr = '';\n if (strlen($cstr) > 0) $cstr .= \"::\";\n $cat = new storeCategory($catID);\n //eDebug($cat);\n if (!empty($cat->parent_id)) self::buildCategoryString($cat->parent_id);\n $cstr .= $cat->title . \"::\";\n return substr($cstr, 0, -2);\n }",
" function product_report() {\n $pts = storeController::getProductTypes();\n $newPts = array();\n foreach ($pts as $pt) {\n $newPts[$pt] = $pt;\n }\n assign_to_template(array(\n 'product_types' => $newPts\n ));\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class searchController extends expController {\n public $useractions = array(\n 'show'=>'Show Search Form',\n 'cloud'=>'Show Tag Cloud'\n );",
" protected $add_permissions = array(\n 'spider'=>'Spider Site'",
" );",
"",
" public $remove_configs = array(\n 'aggregation',\n 'categories',\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" static function displayname() { return gt(\"Search Form\"); }\n static function description() { return gt(\"Add a form to allow users to search for content on your website.\"); }\n static function hasSources() { return false; }\n static function hasContent() { return false; }",
" public function search()\n {\n global $router;",
" $terms = $this->params['search_string'];",
" // If magic quotes is on and the user uses modifiers like \" (quotes) they get escaped. We don't want that in this case.\n if (get_magic_quotes_gpc()) {\n $terms = stripslashes($terms);\n }\n $terms = htmlspecialchars($terms);",
" if ($router->current_url == substr(URL_FULL, 0, -1)) { // give us a user friendly url\n unset($router->params['int']);\n// unset($router->params['src']);\n// $router->params['src'] = '1';\n redirect_to($router->params);\n }",
" $search = new search();",
" $page = new expPaginator(array(\n// 'model'=>'search',\n 'records'=>$search->getSearchResults($terms, !empty($this->config['only_best']), 0, !empty($this->config['eventlimit']) ? $this->config['eventlimit'] : null),\n //'sql'=>$sql,\n 'limit'=>(isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10,\n 'order'=>'score',\n 'dir'=>'DESC',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'dontsortwithincat'=>true,\n 'controller' => $this->params['controller'],\n 'action' => $this->params['action'],\n 'src' => $this->loc->src,\n ));",
" if (!empty($this->config['is_categorized'])) {\n $results = array();\n foreach ($page->records as $hit) {\n if (!isset($results[$hit->category])) {\n $results[$hit->category] = array();\n }\n $results[$hit->category][] = $hit;\n }\n assign_to_template(array(\n 'results'=>$results,\n ));\n }",
" // include CSS for results\n // auto-include the CSS for pagination links\n\t expCSS::pushToHead(array(\n//\t\t \"unique\"=>\"search-results\",\n\t\t \"link\"=>$this->asset_path.\"css/results.css\",\n\t\t )\n\t\t);",
" assign_to_template(array(\n 'page'=>$page,\n 'terms'=>$terms,\n 'params'=>$this->params,\n ));\n }",
" ",
" public static function spider() {\n global $db;",
" // reinitialize search index\n\t $db->delete('search');",
" $mods = array();\n // old school modules\n//\t foreach (expModules::modules_list() as $mod) {\n////\t\t $name = @call_user_func(array($mod,'name'));\n// $name = @call_user_func(array($mod,'searchName'));\n//\t\t if (class_exists($mod) && is_callable(array($mod,'spiderContent'))) {\n// $mods[$name] = call_user_func(array($mod,'spiderContent'));\n//\t\t }\n//\t }",
" // 2.0 modules\n//\t foreach (expModules::listControllers() as $ctlname=>$ctl) {\n foreach (expModules::getActiveControllersList() as $ctl) {\n $ctlname = expModules::getModuleClassName($ctl);\n\t\t $controller = new $ctlname();\n\t\t if (method_exists($controller,'isSearchable') && $controller->isSearchable()) {\n//\t\t\t $mods[$controller->name()] = $controller->addContentToSearch();\n $mods[$controller->searchName()] = $controller->addContentToSearch();\n\t\t }\n\t }",
"\t",
"\t uksort($mods,'strnatcasecmp');\n\t assign_to_template(array(\n 'mods'=>$mods\n ));\n }",
" ",
" public function show() {\n //no need to do anything..we're just showing the form... so far! MUAHAHAHAHAHAAA! what?\n// redirect_to(array(\"controller\"=>'search',\"action\"=>'showall'));\n }",
" ",
" public function showall() {\n// redirect_to(array(\"controller\"=>'search',\"action\"=>'show'));\n// $this->show();\n }",
" /**\n * tag cloud\n */\n function cloud() {\n global $db;",
" expHistory::set('manageable', $this->params);\n $page = new expPaginator(array(\n 'model'=>'expTag',\n 'where'=>null,\n// 'limit'=>999,\n 'order'=>\"title\",\n 'dontsortwithincat'=>true,\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>static::hasSources() == true ? $this->loc->src : null,\n 'columns'=>array(gt('ID#')=>'id',gt('Title')=>'title',gt('Body')=>'body'),\n ));",
"// foreach ($db->selectColumn('content_expTags','content_type',null,null,true) as $contenttype) {\n// foreach ($page->records as $key => $value) {\n// $attatchedat = $page->records[$key]->findWhereAttachedTo($contenttype);\n// if (!empty($attatchedat)) {\n// $page->records[$key]->attachedcount = @$page->records[$key]->attachedcount + count($attatchedat);\n// $page->records[$key]->attached[$contenttype] = $attatchedat;\n// }\n// }\n// }\n $tags_list = array();\n foreach ($page->records as $key=>$record) {\n $count = $db->countObjects('content_expTags','exptags_id=' . $record->id);\n if ($count) {\n $page->records[$key]->attachedcount = $count;\n $tags_list[$record->title] = new stdClass();\n $tags_list[$record->title]->count = $count;\n $tags_list[$record->title]->sef_url = $record->sef_url;\n $tags_list[$record->title]->title = $record->title;\n } else {\n unset($page->records[$key]);\n }\n }\n // trim the tag cloud to our limit.\n $page->records = expSorter::sort(array('array'=>$page->records, 'order'=>'attachedcount DESC', 'type'=>'a'));\n if (!empty($this->config['limit'])) $page->records = array_slice($page->records,0,$this->config['limit']);\n if (!empty($this->config['order']) && $this->config['order'] != 'hits') {\n $page->records = expSorter::sort(array('array'=>$page->records, 'order'=>'title ASC', 'ignore_case'=>true, 'sort_type'=>'a'));\n }\n assign_to_template(array(\n 'page'=>$page,\n 'tags_list'=>$tags_list\n ));\n }",
" // some general search stuff\n public function autocomplete() {\n return;\n global $db;",
" $model = $this->params['model'];\n $mod = new $model();\n $srchcol = explode(\",\",$this->params['searchoncol']);\n /*for ($i=0; $i<count($srchcol); $i++) {\n if ($i>=1) $sql .= \" OR \";\n $sql .= $srchcol[$i].' LIKE \\'%'.$this->params['query'].'%\\'';\n }*/\n // $sql .= ' AND parent_id=0';\n //eDebug($sql);",
" ",
" //$res = $mod->find('all',$sql,'id',25);\n $sql = \"select DISTINCT(p.id), p.title, model, sef_url, f.id as fileid from \".$db->prefix.\"product as p INNER JOIN \".$db->prefix.\"content_expfiles as cef ON p.id=cef.content_id INNER JOIN \".$db->prefix.\"expfiles as f ON cef.expfiles_id = f.id where match (p.title,p.model,p.body) against ('\" . $this->params['query'] . \"') AND p.parent_id=0 order by match (p.title,p.model,p.body) against ('\" . $this->params['query'] . \"') desc LIMIT 25\";\n //$res = $db->selectObjectsBySql($sql);\n //$res = $db->selectObjectBySql('SELECT * FROM `exponent_product`');",
" ",
" $ar = new expAjaxReply(200, gt('Here\\'s the items you wanted'), $res);\n $ar->send();\n }",
"\t",
"\tpublic function searchQueryReport() {\n\t\tglobal $db;",
"\t\t",
"\t\t//Instantiate the search model\n\t\t$search = new search();",
"\t\t",
"\t\t//Store the keywords that returns nothing\n $badSearch = array();\n\t\t$badSearchArr = array();",
"\t\t",
"\t\t//User Records Initialization\n\t\t$all_user = -1;\n\t\t$anonymous = -2;\n\t\t$uname = array('id'=>array($all_user, $anonymous), 'name'=>array('All Users', 'Anonymous'));",
"\t\t$user_default = '';\n\t\t$where = '';",
"\t\t",
"\t\tif(isset($this->params['user_id']) && $this->params['user_id'] != -1) {\n\t\t\t$user_default = $this->params['user_id'];\n\t\t}",
"\t\t",
"\t\texpHistory::set('manageable', $this->params);",
"\t\t$ctr = 2;\n\t\t$ctr2 = 0;",
"\t\t",
"\t\t//Getting the search users\n\t\t$records = $db->selectObjects('search_queries');",
"\t\t\n\t\t",
"\t\tforeach($records as $item) {\n\t\t\t$u = user::getUserById($item->user_id);",
"\t\t\tif($item->user_id == 0) {\n\t\t\t\t$item->user_id = $anonymous;\n\t\t\t}",
"\t\t\t",
"\t\t\tif(!in_array($item->user_id, $uname['id'])) {\n\t\t\t\t$uname['name'][$ctr] = $u->firstname . ' ' . $u->lastname;\n\t\t\t\t$uname['id'][$ctr] = $item->user_id;\n\t\t\t\t$ctr++;\n\t\t\t}",
"\t\t\t",
"\t\t\t$result = $search->getSearchResults($item->query, false, true);\n\t\t\tif(empty($result) && !in_array($item->query, $badSearchArr)) {\n\t\t\t\t$badSearchArr[] = $item->query;\n\t\t\t\t$badSearch[$ctr2]['query'] = $item->query;\n\t\t\t\t$badSearch[$ctr2]['count'] = $db->countObjects(\"search_queries\", \"query='{$item->query}'\");\n\t\t\t\t$ctr2++;\n\t\t\t}",
"\t\t\t\n\t\t}\n\t",
"\t\t//Check if the user choose from the dropdown\n\t\tif(!empty($user_default)) {\n\t\t\tif($user_default == $anonymous) {\n\t\t\t\t$u_id = 0;\n\t\t\t} else {\n\t\t\t\t$u_id = $user_default;\n\t\t\t}\n\t\t\t$where .= \"user_id = {$u_id}\";\n\t\t}",
"\t",
"\t\t//Get all the search query records\n\t\t$records = $db->selectObjects('search_queries', $where);\n for ($i = 0, $iMax = count($records); $i < $iMax; $i++) {\n\t\t\tif(!empty($records[$i]->user_id)) {\n\t\t\t\t$u = user::getUserById($records[$i]->user_id);\n\t\t\t\t$records[$i]->user = $u->firstname . ' ' . $u->lastname;\n\t\t\t}\n\t\t}",
"\t\t",
" $page = new expPaginator(array(\n 'records' => $records,\n 'where'=>1,\n 'model'=>'search_queries',\n 'limit'=>(isset($this->config['limit']) && $this->config['limit'] != '') ? 10 : $this->config['limit'],\n 'order'=>empty($this->config['order']) ? 'timestamp' : $this->config['order'],\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'columns'=>array(\n 'ID'=>'id',\n gt('Query')=>'query',\n gt('Timestamp')=>'timestamp',\n gt('User')=>'user_id',\n ),\n ));",
" $uname['id'] = implode($uname['id'],',');\n $uname['name'] = implode($uname['name'],',');\n assign_to_template(array(\n 'page'=>$page,\n 'users'=>$uname,\n 'user_default' => $user_default,\n 'badSearch' => $badSearch\n ));",
"\t\t",
"\t}",
"\t",
"\tpublic function topSearchReport() {\n\t\tglobal $db;\n\t\t$limit = intval(TOP_SEARCH);",
"\t\t",
"\t\tif(empty($limit)) {\n\t\t\t$limit = 10;\n\t\t}",
"\t\t$count = $db->countObjects('search_queries');",
"\t",
"\t\t$records = $db->selectObjectsBySql(\"SELECT COUNT(query) cnt, query FROM \" .$db->prefix . \"search_queries GROUP BY query ORDER BY cnt DESC LIMIT 0, {$limit}\");",
" $records_key_arr = array();\n $records_values_arr = array();\n\t\tforeach($records as $item) {\n\t\t\t$records_key_arr[] = '\"' . addslashes($item->query) . '\"';\n\t\t\t$records_values_arr[] = number_format((($item->cnt / $count)*100), 2);\n\t\t}\n\t\t$records_key = implode(\",\", $records_key_arr);\n\t\t$records_values = implode(\",\", $records_values_arr);",
"\t\t",
"\t\tassign_to_template(array(\n 'records'=>$records,\n 'total'=>$count,\n 'limit' => $limit,\n 'records_key' => $records_key,\n 'records_values' => $records_values\n ));\n\t}",
" function delete_search_queries() {\n $sq = new search_queries();\n $sqall = $sq->find('all');\n if (!empty($sqall)) foreach ($sqall as $sqd) {\n $sqd->delete();\n }\n flash('message', gt(\"Search Queries successfully deleted.\"));\n expHistory::back();\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
0,
1,
1,
0,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
1,
0,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class searchController extends expController {\n public $useractions = array(\n 'show'=>'Show Search Form',\n 'cloud'=>'Show Tag Cloud'\n );",
" protected $manage_permissions = array(\n 'spider'=>'Spider Site',\n 'searchQueryReport'=>'Search Query Report',\n 'topSearchReport'=>'Top Search Report',",
" );",
"",
" public $remove_configs = array(\n 'aggregation',\n 'categories',\n 'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)",
" static function displayname() { return gt(\"Search Form\"); }\n static function description() { return gt(\"Add a form to allow users to search for content on your website.\"); }\n static function hasSources() { return false; }\n static function hasContent() { return false; }",
" public function search()\n {\n global $router;",
" $terms = $this->params['search_string'];",
" // If magic quotes is on and the user uses modifiers like \" (quotes) they get escaped. We don't want that in this case.\n if (get_magic_quotes_gpc()) {\n $terms = stripslashes($terms);\n }\n $terms = htmlspecialchars($terms);",
" if ($router->current_url == substr(URL_FULL, 0, -1)) { // give us a user friendly url\n unset($router->params['int']);\n// unset($router->params['src']);\n// $router->params['src'] = '1';\n redirect_to($router->params);\n }",
" $search = new search();",
" $page = new expPaginator(array(\n// 'model'=>'search',\n 'records'=>$search->getSearchResults($terms, !empty($this->config['only_best']), 0, !empty($this->config['eventlimit']) ? $this->config['eventlimit'] : null),\n //'sql'=>$sql,\n 'limit'=>(isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10,\n 'order'=>'score',\n 'dir'=>'DESC',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'dontsortwithincat'=>true,\n 'controller' => $this->params['controller'],\n 'action' => $this->params['action'],\n 'src' => $this->loc->src,\n ));",
" if (!empty($this->config['is_categorized'])) {\n $results = array();\n foreach ($page->records as $hit) {\n if (!isset($results[$hit->category])) {\n $results[$hit->category] = array();\n }\n $results[$hit->category][] = $hit;\n }\n assign_to_template(array(\n 'results'=>$results,\n ));\n }",
" // include CSS for results\n // auto-include the CSS for pagination links\n\t expCSS::pushToHead(array(\n//\t\t \"unique\"=>\"search-results\",\n\t\t \"link\"=>$this->asset_path.\"css/results.css\",\n\t\t )\n\t\t);",
" assign_to_template(array(\n 'page'=>$page,\n 'terms'=>$terms,\n 'params'=>$this->params,\n ));\n }",
"",
" public static function spider() {\n global $db;",
" // reinitialize search index\n\t $db->delete('search');",
" $mods = array();\n // old school modules\n//\t foreach (expModules::modules_list() as $mod) {\n////\t\t $name = @call_user_func(array($mod,'name'));\n// $name = @call_user_func(array($mod,'searchName'));\n//\t\t if (class_exists($mod) && is_callable(array($mod,'spiderContent'))) {\n// $mods[$name] = call_user_func(array($mod,'spiderContent'));\n//\t\t }\n//\t }",
" // 2.0 modules\n//\t foreach (expModules::listControllers() as $ctlname=>$ctl) {\n foreach (expModules::getActiveControllersList() as $ctl) {\n $ctlname = expModules::getModuleClassName($ctl);\n\t\t $controller = new $ctlname();\n\t\t if (method_exists($controller,'isSearchable') && $controller->isSearchable()) {\n//\t\t\t $mods[$controller->name()] = $controller->addContentToSearch();\n $mods[$controller->searchName()] = $controller->addContentToSearch();\n\t\t }\n\t }",
"",
"\t uksort($mods,'strnatcasecmp');\n\t assign_to_template(array(\n 'mods'=>$mods\n ));\n }",
"",
" public function show() {\n //no need to do anything..we're just showing the form... so far! MUAHAHAHAHAHAAA! what?\n// redirect_to(array(\"controller\"=>'search',\"action\"=>'showall'));\n }",
"",
" public function showall() {\n// redirect_to(array(\"controller\"=>'search',\"action\"=>'show'));\n// $this->show();\n }",
" /**\n * tag cloud\n */\n function cloud() {\n global $db;",
" expHistory::set('manageable', $this->params);\n $page = new expPaginator(array(\n 'model'=>'expTag',\n 'where'=>null,\n// 'limit'=>999,\n 'order'=>\"title\",\n 'dontsortwithincat'=>true,\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'src'=>static::hasSources() == true ? $this->loc->src : null,\n 'columns'=>array(gt('ID#')=>'id',gt('Title')=>'title',gt('Body')=>'body'),\n ));",
"// foreach ($db->selectColumn('content_expTags','content_type',null,null,true) as $contenttype) {\n// foreach ($page->records as $key => $value) {\n// $attatchedat = $page->records[$key]->findWhereAttachedTo($contenttype);\n// if (!empty($attatchedat)) {\n// $page->records[$key]->attachedcount = @$page->records[$key]->attachedcount + count($attatchedat);\n// $page->records[$key]->attached[$contenttype] = $attatchedat;\n// }\n// }\n// }\n $tags_list = array();\n foreach ($page->records as $key=>$record) {\n $count = $db->countObjects('content_expTags','exptags_id=' . $record->id);\n if ($count) {\n $page->records[$key]->attachedcount = $count;\n $tags_list[$record->title] = new stdClass();\n $tags_list[$record->title]->count = $count;\n $tags_list[$record->title]->sef_url = $record->sef_url;\n $tags_list[$record->title]->title = $record->title;\n } else {\n unset($page->records[$key]);\n }\n }\n // trim the tag cloud to our limit.\n $page->records = expSorter::sort(array('array'=>$page->records, 'order'=>'attachedcount DESC', 'type'=>'a'));\n if (!empty($this->config['limit'])) $page->records = array_slice($page->records,0,$this->config['limit']);\n if (!empty($this->config['order']) && $this->config['order'] != 'hits') {\n $page->records = expSorter::sort(array('array'=>$page->records, 'order'=>'title ASC', 'ignore_case'=>true, 'sort_type'=>'a'));\n }\n assign_to_template(array(\n 'page'=>$page,\n 'tags_list'=>$tags_list\n ));\n }",
" // some general search stuff\n public function autocomplete() {\n return;\n global $db;",
" $model = $this->params['model'];\n $mod = new $model();\n $srchcol = explode(\",\",$this->params['searchoncol']);\n /*for ($i=0; $i<count($srchcol); $i++) {\n if ($i>=1) $sql .= \" OR \";\n $sql .= $srchcol[$i].' LIKE \\'%'.$this->params['query'].'%\\'';\n }*/\n // $sql .= ' AND parent_id=0';\n //eDebug($sql);",
"",
" //$res = $mod->find('all',$sql,'id',25);\n $sql = \"select DISTINCT(p.id), p.title, model, sef_url, f.id as fileid from \".$db->prefix.\"product as p INNER JOIN \".$db->prefix.\"content_expfiles as cef ON p.id=cef.content_id INNER JOIN \".$db->prefix.\"expfiles as f ON cef.expfiles_id = f.id where match (p.title,p.model,p.body) against ('\" . $this->params['query'] . \"') AND p.parent_id=0 order by match (p.title,p.model,p.body) against ('\" . $this->params['query'] . \"') desc LIMIT 25\";\n //$res = $db->selectObjectsBySql($sql);\n //$res = $db->selectObjectBySql('SELECT * FROM `exponent_product`');",
"",
" $ar = new expAjaxReply(200, gt('Here\\'s the items you wanted'), $res);\n $ar->send();\n }",
"",
"\tpublic function searchQueryReport() {\n\t\tglobal $db;",
"",
"\t\t//Instantiate the search model\n\t\t$search = new search();",
"",
"\t\t//Store the keywords that returns nothing\n $badSearch = array();\n\t\t$badSearchArr = array();",
"",
"\t\t//User Records Initialization\n\t\t$all_user = -1;\n\t\t$anonymous = -2;\n\t\t$uname = array('id'=>array($all_user, $anonymous), 'name'=>array('All Users', 'Anonymous'));",
"\t\t$user_default = '';\n\t\t$where = '';",
"",
"\t\tif(isset($this->params['user_id']) && $this->params['user_id'] != -1) {\n\t\t\t$user_default = $this->params['user_id'];\n\t\t}",
"",
"\t\texpHistory::set('manageable', $this->params);",
"\t\t$ctr = 2;\n\t\t$ctr2 = 0;",
"",
"\t\t//Getting the search users\n\t\t$records = $db->selectObjects('search_queries');",
"\n",
"\t\tforeach($records as $item) {\n\t\t\t$u = user::getUserById($item->user_id);",
"\t\t\tif($item->user_id == 0) {\n\t\t\t\t$item->user_id = $anonymous;\n\t\t\t}",
"",
"\t\t\tif(!in_array($item->user_id, $uname['id'])) {\n\t\t\t\t$uname['name'][$ctr] = $u->firstname . ' ' . $u->lastname;\n\t\t\t\t$uname['id'][$ctr] = $item->user_id;\n\t\t\t\t$ctr++;\n\t\t\t}",
"",
"\t\t\t$result = $search->getSearchResults($item->query, false, true);\n\t\t\tif(empty($result) && !in_array($item->query, $badSearchArr)) {\n\t\t\t\t$badSearchArr[] = $item->query;\n\t\t\t\t$badSearch[$ctr2]['query'] = $item->query;\n\t\t\t\t$badSearch[$ctr2]['count'] = $db->countObjects(\"search_queries\", \"query='{$item->query}'\");\n\t\t\t\t$ctr2++;\n\t\t\t}",
"\n\t\t}\n",
"\t\t//Check if the user choose from the dropdown\n\t\tif(!empty($user_default)) {\n\t\t\tif($user_default == $anonymous) {\n\t\t\t\t$u_id = 0;\n\t\t\t} else {\n\t\t\t\t$u_id = $user_default;\n\t\t\t}\n\t\t\t$where .= \"user_id = {$u_id}\";\n\t\t}",
"",
"\t\t//Get all the search query records\n\t\t$records = $db->selectObjects('search_queries', $where);\n for ($i = 0, $iMax = count($records); $i < $iMax; $i++) {\n\t\t\tif(!empty($records[$i]->user_id)) {\n\t\t\t\t$u = user::getUserById($records[$i]->user_id);\n\t\t\t\t$records[$i]->user = $u->firstname . ' ' . $u->lastname;\n\t\t\t}\n\t\t}",
"",
" $page = new expPaginator(array(\n 'records' => $records,\n 'where'=>1,\n 'model'=>'search_queries',\n 'limit'=>(isset($this->config['limit']) && $this->config['limit'] != '') ? 10 : $this->config['limit'],\n 'order'=>empty($this->config['order']) ? 'timestamp' : $this->config['order'],\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'columns'=>array(\n 'ID'=>'id',\n gt('Query')=>'query',\n gt('Timestamp')=>'timestamp',\n gt('User')=>'user_id',\n ),\n ));",
" $uname['id'] = implode($uname['id'],',');\n $uname['name'] = implode($uname['name'],',');\n assign_to_template(array(\n 'page'=>$page,\n 'users'=>$uname,\n 'user_default' => $user_default,\n 'badSearch' => $badSearch\n ));",
"",
"\t}",
"",
"\tpublic function topSearchReport() {\n\t\tglobal $db;\n\t\t$limit = intval(TOP_SEARCH);",
"",
"\t\tif(empty($limit)) {\n\t\t\t$limit = 10;\n\t\t}",
"\t\t$count = $db->countObjects('search_queries');",
"",
"\t\t$records = $db->selectObjectsBySql(\"SELECT COUNT(query) cnt, query FROM \" .$db->prefix . \"search_queries GROUP BY query ORDER BY cnt DESC LIMIT 0, {$limit}\");",
" $records_key_arr = array();\n $records_values_arr = array();\n\t\tforeach($records as $item) {\n\t\t\t$records_key_arr[] = '\"' . addslashes($item->query) . '\"';\n\t\t\t$records_values_arr[] = number_format((($item->cnt / $count)*100), 2);\n\t\t}\n\t\t$records_key = implode(\",\", $records_key_arr);\n\t\t$records_values = implode(\",\", $records_values_arr);",
"",
"\t\tassign_to_template(array(\n 'records'=>$records,\n 'total'=>$count,\n 'limit' => $limit,\n 'records_key' => $records_key,\n 'records_values' => $records_values\n ));\n\t}",
" function delete_search_queries() {\n $sq = new search_queries();\n $sqall = $sq->find('all');\n if (!empty($sqall)) foreach ($sqall as $sqd) {\n $sqd->delete();\n }\n flash('message', gt(\"Search Queries successfully deleted.\"));\n expHistory::back();\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class simplePollController extends expController {\n\tpublic $basemodel_name = 'simplepoll_question';\n\tpublic $useractions = array(\n 'showall'=>'Show Poll Question',\n 'showRandom'=>'Show Random Question',\n\t);\n\tpublic $remove_configs = array(\n 'aggregation',\n 'categories',\n\t\t'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'pagination',\n\t\t'rss',\n\t\t'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)\n// public $codequality = 'beta';",
" static function displayname() { return gt(\"Simple Poll\"); }\n static function description() { return gt(\"A simple poll that asks a visitor one question with multiple answers. Can manage multiple questions, though it only displays one.\"); }\n//\tfunction isSearchable() { return true; }",
" public function __construct($src=null, $params=array()) {\n parent::__construct($src, $params);\n $this->simplepoll_timeblock = new simplepoll_timeblock();\n }",
"\tpublic function showall() {\n expHistory::set('viewable', $this->params);\n $where = $this->aggregateWhereClause();\n $where .= \" AND active = 1\";\n $question = $this->simplepoll_question->find('first', $where);\n if (empty($question)) $question = $this->simplepoll_question->find('first', $this->aggregateWhereClause());\n assign_to_template(array(\n 'question'=>$question,\n ));\n\t}",
" public function showRandom() {\n \t expHistory::set('viewable', $this->params);\n $question = $this->simplepoll_question->find('first', $this->aggregateWhereClause(), 'RAND()');\n \t\tassign_to_template(array(\n 'question'=>$question,\n ));\n \t}",
" public function manage_questions() {\n global $router;",
" expHistory::set('manageable', $router->params);\n $where = $this->aggregateWhereClause();\n $questions = $this->simplepoll_question->find('all', $where);\n assign_to_template(array(\n 'questions'=>$questions,\n ));\n }",
" public function manage_question() {\n global $router;",
" $question = null;\n if (isset($this->params['id'])) {\n $question = $this->simplepoll_question->find('first','id='.$this->params['id']);\n }",
" if ($question) {\n expHistory::set('manageable', $router->params);\n assign_to_template(array(\n 'question'=>$question,\n ));\n }\n }",
" public function delete() {\n // if no active question, set first question as active\n $question = $this->simplepoll_question->find('first', 'id='.$this->params['id']);\n parent::delete();\n $question = $this->simplepoll_question->find('first', \"location_data='\".$question->location_data.\"' AND active = 1\");\n if (empty($question)) {\n $question = $this->simplepoll_question->find('first', \"location_data='\".$question->location_data.\"'\");\n $question->update(array('active'=>1));\n }\n }",
" public function edit_answer() {\n $id = !empty($this->params['id']) ? $this->params['id'] : null;\n $answer = new simplepoll_answer($id);\n if (empty($answer->simplepoll_question->id) && !empty($this->params['question_id'])) {\n $answer->simplepoll_question = $this->simplepoll_question->find('first', 'id='.$this->params['question_id']);\n }\n assign_to_template(array(\n 'answer'=>$answer,\n ));\n }",
" public function update_answer() {\n $answer = new simplepoll_answer($this->params);\n $answer->update();\n\t expHistory::returnTo('manageable');\n }",
" public function delete_answer() {\n if (isset($this->params['id'])) {\n $answer = new simplepoll_answer($this->params['id']);\n $answer->delete();\n }\n expHistory::back();\n }",
" public function activate() {\n $this->simplepoll_question->toggle();\n $active = $this->simplepoll_question->find('first',\"id=\".$this->params['id']);\n $active->update(array('active'=>1));\n\t expHistory::returnTo('manageable');\n }",
" public function vote() {\n global $user;",
" if (isset($this->params['choice'])) {",
" $answer = new simplepoll_answer($this->params['choice']);",
" if (empty($this->config)) {\n $this->config['anonymous_timeout'] = 5*3600;\n $this->config['thank_you_message'] = 'Thank you for voting.';\n $this->config['already_voted_message'] = 'You have already voted in this poll.';\n $this->config['voting_closed_message'] = 'Voting has been closed for this poll.';\n }",
" // Check to see if voting is even allowed:\n if ($answer->simplepoll_question->open_voting) {\n // Time blocking\n// $timeblock = null;\n if (is_object($user) && $user->id > 0) {\n $timeblock = $this->simplepoll_timeblock->find('first','user_id='.$user->id.' AND simplepoll_question_id='.$answer->simplepoll_question_id);\n// $timeblock = $db->selectObject('simplepoll_timeblock','user_id='.$user->id.' AND simplepoll_question_id='.$answer->simplepoll_question_id);\n } else {\n $timeblock = $this->simplepoll_timeblock->find('first',\"ip_hash='\".md5($_SERVER['REMOTE_ADDR']).\"' AND simplepoll_question_id=\".$answer->simplepoll_question_id);\n// $timeblock = $db->selectObject('simplepoll_timeblock',\"ip_hash='\".md5($_SERVER['REMOTE_ADDR']).\"' AND simplepoll_question_id=\".$answer->simplepoll_question_id);\n }",
" if ($timeblock == null || ($timeblock->lock_expires < time() && $timeblock->lock_expires != 0)) {\n if ($timeblock == null)\n $timeblock = new simplepoll_timeblock();\n $answer->vote_count++;\n $answer->update();",
" // Update the timeblock\n $timeblock->simplepoll_question_id = $answer->simplepoll_question_id;\n if (is_object($user) && $user->id > 0) {\n $timeblock->lock_expires = 0;\n $timeblock->user_id = $user->id;\n $timeblock->ip_hash = '';\n } else {\n $timeblock->lock_expires = time()+($this->config['anonymous_timeout']*3600);\n $timeblock->user_id = 0;\n $timeblock->ip_hash = md5($_SERVER['REMOTE_ADDR']);\n }",
"// if (isset($timeblock->id)) {\n// $db->updateObject($timeblock,'simplepoll_timeblock');\n// } else {\n// $db->insertObject($timeblock,'simplepoll_timeblock');\n// }\n $timeblock->update();",
" flash('message', $this->config['thank_you_message']);\n if ($answer->simplepoll_question->open_results) {\n redirect_to(array('controller'=>'simplePoll', 'action'=>'results','id'=>$answer->simplepoll_question_id));\n } else {\n expHistory::back();\n }\n } else {\n flash('error', $this->config['already_voted_message']);\n expHistory::back();\n }\n } else {\n flash('error', $this->config['voting_closed_message']);\n expHistory::back();\n }\n } else {\n flash('error', gt('You must select an answer to vote'));\n \t expHistory::back();\n }\n }",
" public function results() {\n if (isset($this->params['id'])) {\n $question = $this->simplepoll_question->find('first', 'id='.$this->params['id']);\n }\n if (!empty($question) && $question->open_results) {\n $total = 0;\n foreach ($question->simplepoll_answer as $answer) {\n $total += $answer->vote_count;\n }\n assign_to_template(array(\n 'question'=>$question,\n 'vote_total'=>$total,\n ));\n }\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */",
"class simplePollController extends expController {\n\tpublic $basemodel_name = 'simplepoll_question';\n\tpublic $useractions = array(\n 'showall'=>'Show Poll Question',\n 'showRandom'=>'Show Random Question',\n\t);\n\tpublic $remove_configs = array(\n 'aggregation',\n 'categories',\n\t\t'comments',\n 'ealerts',\n 'facebook',\n 'files',\n 'pagination',\n\t\t'rss',\n\t\t'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)\n// public $codequality = 'beta';",
" static function displayname() { return gt(\"Simple Poll\"); }\n static function description() { return gt(\"A simple poll that asks a visitor one question with multiple answers. Can manage multiple questions, though it only displays one.\"); }\n//\tfunction isSearchable() { return true; }",
" public function __construct($src=null, $params=array()) {\n parent::__construct($src, $params);\n $this->simplepoll_timeblock = new simplepoll_timeblock();\n }",
"\tpublic function showall() {\n expHistory::set('viewable', $this->params);\n $where = $this->aggregateWhereClause();\n $where .= \" AND active = 1\";\n $question = $this->simplepoll_question->find('first', $where);\n if (empty($question)) $question = $this->simplepoll_question->find('first', $this->aggregateWhereClause());\n assign_to_template(array(\n 'question'=>$question,\n ));\n\t}",
" public function showRandom() {\n \t expHistory::set('viewable', $this->params);\n $question = $this->simplepoll_question->find('first', $this->aggregateWhereClause(), 'RAND()');\n \t\tassign_to_template(array(\n 'question'=>$question,\n ));\n \t}",
" public function manage_questions() {\n global $router;",
" expHistory::set('manageable', $router->params);\n $where = $this->aggregateWhereClause();\n $questions = $this->simplepoll_question->find('all', $where);\n assign_to_template(array(\n 'questions'=>$questions,\n ));\n }",
" public function manage_question() {\n global $router;",
" $question = null;\n if (isset($this->params['id'])) {\n $question = $this->simplepoll_question->find('first','id='.$this->params['id']);\n }",
" if ($question) {\n expHistory::set('manageable', $router->params);\n assign_to_template(array(\n 'question'=>$question,\n ));\n }\n }",
" public function delete() {\n // if no active question, set first question as active\n $question = $this->simplepoll_question->find('first', 'id='.$this->params['id']);\n parent::delete();\n $question = $this->simplepoll_question->find('first', \"location_data='\".$question->location_data.\"' AND active = 1\");\n if (empty($question)) {\n $question = $this->simplepoll_question->find('first', \"location_data='\".$question->location_data.\"'\");\n $question->update(array('active'=>1));\n }\n }",
" public function edit_answer() {\n $id = !empty($this->params['id']) ? $this->params['id'] : null;\n $answer = new simplepoll_answer($id);\n if (empty($answer->simplepoll_question->id) && !empty($this->params['question_id'])) {\n $answer->simplepoll_question = $this->simplepoll_question->find('first', 'id='.$this->params['question_id']);\n }\n assign_to_template(array(\n 'answer'=>$answer,\n ));\n }",
" public function update_answer() {\n $answer = new simplepoll_answer($this->params);\n $answer->update();\n\t expHistory::returnTo('manageable');\n }",
" public function delete_answer() {\n if (isset($this->params['id'])) {\n $answer = new simplepoll_answer($this->params['id']);\n $answer->delete();\n }\n expHistory::back();\n }",
" public function activate() {\n $this->simplepoll_question->toggle();\n $active = $this->simplepoll_question->find('first',\"id=\".$this->params['id']);\n $active->update(array('active'=>1));\n\t expHistory::returnTo('manageable');\n }",
" public function vote() {\n global $user;",
" if (isset($this->params['choice'])) {",
" $answer = new simplepoll_answer(intval($this->params['choice']));",
" if (empty($this->config)) {\n $this->config['anonymous_timeout'] = 5*3600;\n $this->config['thank_you_message'] = 'Thank you for voting.';\n $this->config['already_voted_message'] = 'You have already voted in this poll.';\n $this->config['voting_closed_message'] = 'Voting has been closed for this poll.';\n }",
" // Check to see if voting is even allowed:\n if ($answer->simplepoll_question->open_voting) {\n // Time blocking\n// $timeblock = null;\n if (is_object($user) && $user->id > 0) {\n $timeblock = $this->simplepoll_timeblock->find('first','user_id='.$user->id.' AND simplepoll_question_id='.$answer->simplepoll_question_id);\n// $timeblock = $db->selectObject('simplepoll_timeblock','user_id='.$user->id.' AND simplepoll_question_id='.$answer->simplepoll_question_id);\n } else {\n $timeblock = $this->simplepoll_timeblock->find('first',\"ip_hash='\".md5($_SERVER['REMOTE_ADDR']).\"' AND simplepoll_question_id=\".$answer->simplepoll_question_id);\n// $timeblock = $db->selectObject('simplepoll_timeblock',\"ip_hash='\".md5($_SERVER['REMOTE_ADDR']).\"' AND simplepoll_question_id=\".$answer->simplepoll_question_id);\n }",
" if ($timeblock == null || ($timeblock->lock_expires < time() && $timeblock->lock_expires != 0)) {\n if ($timeblock == null)\n $timeblock = new simplepoll_timeblock();\n $answer->vote_count++;\n $answer->update();",
" // Update the timeblock\n $timeblock->simplepoll_question_id = $answer->simplepoll_question_id;\n if (is_object($user) && $user->id > 0) {\n $timeblock->lock_expires = 0;\n $timeblock->user_id = $user->id;\n $timeblock->ip_hash = '';\n } else {\n $timeblock->lock_expires = time()+($this->config['anonymous_timeout']*3600);\n $timeblock->user_id = 0;\n $timeblock->ip_hash = md5($_SERVER['REMOTE_ADDR']);\n }",
"// if (isset($timeblock->id)) {\n// $db->updateObject($timeblock,'simplepoll_timeblock');\n// } else {\n// $db->insertObject($timeblock,'simplepoll_timeblock');\n// }\n $timeblock->update();",
" flash('message', $this->config['thank_you_message']);\n if ($answer->simplepoll_question->open_results) {\n redirect_to(array('controller'=>'simplePoll', 'action'=>'results','id'=>$answer->simplepoll_question_id));\n } else {\n expHistory::back();\n }\n } else {\n flash('error', $this->config['already_voted_message']);\n expHistory::back();\n }\n } else {\n flash('error', $this->config['voting_closed_message']);\n expHistory::back();\n }\n } else {\n flash('error', gt('You must select an answer to vote'));\n \t expHistory::back();\n }\n }",
" public function results() {\n if (isset($this->params['id'])) {\n $question = $this->simplepoll_question->find('first', 'id='.$this->params['id']);\n }\n if (!empty($question) && $question->open_results) {\n $total = 0;\n foreach ($question->simplepoll_answer as $answer) {\n $total += $answer->vote_count;\n }\n assign_to_template(array(\n 'question'=>$question,\n 'vote_total'=>$total,\n ));\n }\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */\n/** @define \"BASE\" \"../../../..\" */",
"class loginController extends expController {\n\tpublic $remove_configs = array(\n 'aggregation',\n 'categories',\n 'comments',\n\t\t'ealerts',\n 'facebook',\n 'files',\n 'pagination',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)\n public $useractions = array(\n\t 'showlogin'=>'Login',\n );",
" static function displayname() { return gt(\"Login Manager\"); }\n static function description() { return gt(\"This is the login management module. It allows for logging in, logging out, etc.\"); }",
" static function hasSources() {\n return false;\n }",
"\t/**\n\t * Display a login view\n\t */\n\tpublic static function showlogin() {\n\t\tglobal $db, $user, $order, $router;",
"\t\t$oicount = !empty($order->item_count) ? $order->item_count : 0;\n\t\t// FIGURE OUT IF WE\"RE IN PREVIEW MODE OR NOT\n\t\t$level = 99;\n\t\tif (expSession::is_set('uilevel')) {\n\t\t\t$level = expSession::get('uilevel');\n\t\t}\n\t\t$previewtext = $level == UILEVEL_PREVIEW ? gt('Turn Preview Mode off') : gt('Turn Preview Mode on');\n\t\t$previewclass = $level == UILEVEL_PREVIEW ? 'preview_on' : 'preview_off';",
" if (!expSession::is_set('redirecturl')) expSession::set('redirecturl', expHistory::getLast());\n if (!expSession::is_set('redirecturl_error')) {\n expSession::set('redirecturl_error', makeLink(array('controller'=>'login', 'action'=>'showlogin')));\n expHistory::set('viewable', $router->params);\n }",
"\t\t//eDebug($order);\n\t\tif (expSession::loggedIn() && $user->username != \"anonymous\") {\n\t\t\t$loggedin = 1;\n\t\t\t// Generate display name as username if the first and last name fields are blank.\n\t\t\t$display_name = $user->firstname . ' ' .$user->lastname;\n\t\t\tif (trim($display_name) == '') {\n\t\t\t\t$display_name = $user->username;\n\t\t\t}\n\t\t\t// Need to check for groups and whatnot\n\t\t\tif ($db->countObjects('groupmembership','member_id='.$user->id.' AND is_admin=1')) {\n\t\t\t\t$is_group_admin = 1;\n\t\t\t} else {\n\t\t\t\t$is_group_admin = 0;\n\t\t\t}",
"\t\t\tassign_to_template(array(\n 'oicount'=>$oicount,\n 'previewtext'=>$previewtext,\n 'previewclass'=>$previewclass,\n 'loggedin'=>$loggedin,\n 'user'=>$user,\n 'displayname'=>$display_name,\n 'is_group_admin'=>$is_group_admin\n ));\n\t\t} else {\n\t\t\t//$template->assign('isecom',in_array('storeController',listActiveControllers()));\n\t\t\t$loggedin = 0;\n\t\t\tassign_to_template(array(\n 'oicount'=>$oicount,\n 'previewtext'=>$previewtext,\n 'previewclass'=>$previewclass,\n 'loggedin'=>$loggedin,\n 'user'=>$user\n ));\n if (expSession::get('customer-login')) {\n assign_to_template(array(\n 'checkout'=>true\n ));\n }\n\t\t}\n\t}",
"\t/**\n\t * main logout method\n\t */\n\tpublic static function logout() {\n\t\texpSession::logout();\n\t\texpSession::un_set(\"permissions\");\n\t\texpSession::un_set('uilevel');\n\t\texpSession::clearCurrentUserSessionCache();\n\t\tflash('message', gt('You have been logged out'));\n\t\tredirect_to(array(\"section\"=>SITE_DEFAULT_SECTION));\n\t}",
"\t/**\n\t * main login method\n\t */\n\tpublic static function login() {",
"\t\tuser::login(expString::sanitize($_POST['username']),expString::sanitize($_POST['password']));",
"\t\tif (!isset($_SESSION[SYS_SESSION_KEY]['user'])) { // didn't successfully log in\n\t\t\tflash('error', gt('Invalid Username / Password'));\n\t\t\tif (expSession::is_set('redirecturl_error')) {\n\t\t\t\t$url = expSession::get('redirecturl_error');\n\t\t\t\texpSession::un_set('redirecturl_error');\n\t\t\t\theader(\"Location: \".$url);\n\t\t\t} else {\n\t\t\t\texpHistory::back();\n\t\t\t}\n\t\t} else { // we're logged in\n\t\t\tglobal $user;",
" if (expSession::get('customer-login')) expSession::un_set('customer-login');\n\t\t\tif (!empty($_POST['username'])) flash('message', gt('Welcome back').' '.expString::sanitize($_POST['username']));\n if ($user->isAdmin()) {\n expHistory::back();\n } else {\n foreach ($user->groups as $g) {\n if (!empty($g->redirect)) {\n $url = URL_FULL.$g->redirect;\n break;\n }\n }\n if (isset($url)) {\n header(\"Location: \".$url);\n } else {\n expHistory::back();\n }\n }\n\t\t}\n\t}",
"\t/**\n\t * method to redirect to a login if needed\n\t */\n\tpublic static function loginredirect() {\n\t\tglobal $user, $router;",
"\t\tob_start();\n\t\tif ($user->isLoggedIn()) {\n\t\t\theader('Location: ' . expSession::get('redirecturl'));\n\t\t} else {\n\t\t\t//expSession::set('redirecturl', expHistory::getLastNotEditable());\n\t\t\texpSession::set('redirecturl', expHistory::getLast());\n\t\t\texpSession::set('redirecturl_error', makeLink(array('controller'=>'login', 'action'=>'loginredirect')));\n//\t\t\texpHistory::flowSet(SYS_FLOW_PUBLIC,SYS_FLOW_ACTION);\n\t\t\texpHistory::set('viewable', $router->params);\n\t\t}\n//\t\tredirect_to(array('controller'=>'login', 'action'=>'showlogin'));\n renderAction(array('controller'=>'login','action'=>'showlogin','no_output'=>true));\n\t}",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */\n/** @define \"BASE\" \"../../../..\" */",
"class loginController extends expController {\n\tpublic $remove_configs = array(\n 'aggregation',\n 'categories',\n 'comments',\n\t\t'ealerts',\n 'facebook',\n 'files',\n 'pagination',\n 'rss',\n 'tags',\n 'twitter',\n ); // all options: ('aggregation','categories','comments','ealerts','facebook','files','pagination','rss','tags','twitter',)\n public $useractions = array(\n\t 'showlogin'=>'Login',\n );",
" static function displayname() { return gt(\"Login Manager\"); }\n static function description() { return gt(\"This is the login management module. It allows for logging in, logging out, etc.\"); }",
" static function hasSources() {\n return false;\n }",
"\t/**\n\t * Display a login view\n\t */\n\tpublic static function showlogin() {\n\t\tglobal $db, $user, $order, $router;",
"\t\t$oicount = !empty($order->item_count) ? $order->item_count : 0;\n\t\t// FIGURE OUT IF WE\"RE IN PREVIEW MODE OR NOT\n\t\t$level = 99;\n\t\tif (expSession::is_set('uilevel')) {\n\t\t\t$level = expSession::get('uilevel');\n\t\t}\n\t\t$previewtext = $level == UILEVEL_PREVIEW ? gt('Turn Preview Mode off') : gt('Turn Preview Mode on');\n\t\t$previewclass = $level == UILEVEL_PREVIEW ? 'preview_on' : 'preview_off';",
" if (!expSession::is_set('redirecturl')) expSession::set('redirecturl', expHistory::getLast());\n if (!expSession::is_set('redirecturl_error')) {\n expSession::set('redirecturl_error', makeLink(array('controller'=>'login', 'action'=>'showlogin')));\n expHistory::set('viewable', $router->params);\n }",
"\t\t//eDebug($order);\n\t\tif (expSession::loggedIn() && $user->username != \"anonymous\") {\n\t\t\t$loggedin = 1;\n\t\t\t// Generate display name as username if the first and last name fields are blank.\n\t\t\t$display_name = $user->firstname . ' ' .$user->lastname;\n\t\t\tif (trim($display_name) == '') {\n\t\t\t\t$display_name = $user->username;\n\t\t\t}\n\t\t\t// Need to check for groups and whatnot\n\t\t\tif ($db->countObjects('groupmembership','member_id='.$user->id.' AND is_admin=1')) {\n\t\t\t\t$is_group_admin = 1;\n\t\t\t} else {\n\t\t\t\t$is_group_admin = 0;\n\t\t\t}",
"\t\t\tassign_to_template(array(\n 'oicount'=>$oicount,\n 'previewtext'=>$previewtext,\n 'previewclass'=>$previewclass,\n 'loggedin'=>$loggedin,\n 'user'=>$user,\n 'displayname'=>$display_name,\n 'is_group_admin'=>$is_group_admin\n ));\n\t\t} else {\n\t\t\t//$template->assign('isecom',in_array('storeController',listActiveControllers()));\n\t\t\t$loggedin = 0;\n\t\t\tassign_to_template(array(\n 'oicount'=>$oicount,\n 'previewtext'=>$previewtext,\n 'previewclass'=>$previewclass,\n 'loggedin'=>$loggedin,\n 'user'=>$user\n ));\n if (expSession::get('customer-login')) {\n assign_to_template(array(\n 'checkout'=>true\n ));\n }\n\t\t}\n\t}",
"\t/**\n\t * main logout method\n\t */\n\tpublic static function logout() {\n\t\texpSession::logout();\n\t\texpSession::un_set(\"permissions\");\n\t\texpSession::un_set('uilevel');\n\t\texpSession::clearCurrentUserSessionCache();\n\t\tflash('message', gt('You have been logged out'));\n\t\tredirect_to(array(\"section\"=>SITE_DEFAULT_SECTION));\n\t}",
"\t/**\n\t * main login method\n\t */\n\tpublic static function login() {",
"\t\tuser::login(expString::escape(expString::sanitize($_POST['username'])),expString::escape(expString::sanitize($_POST['password'])));",
"\t\tif (!isset($_SESSION[SYS_SESSION_KEY]['user'])) { // didn't successfully log in\n\t\t\tflash('error', gt('Invalid Username / Password'));\n\t\t\tif (expSession::is_set('redirecturl_error')) {\n\t\t\t\t$url = expSession::get('redirecturl_error');\n\t\t\t\texpSession::un_set('redirecturl_error');\n\t\t\t\theader(\"Location: \".$url);\n\t\t\t} else {\n\t\t\t\texpHistory::back();\n\t\t\t}\n\t\t} else { // we're logged in\n\t\t\tglobal $user;",
" if (expSession::get('customer-login')) expSession::un_set('customer-login');\n\t\t\tif (!empty($_POST['username'])) flash('message', gt('Welcome back').' '.expString::sanitize($_POST['username']));\n if ($user->isAdmin()) {\n expHistory::back();\n } else {\n foreach ($user->groups as $g) {\n if (!empty($g->redirect)) {\n $url = URL_FULL.$g->redirect;\n break;\n }\n }\n if (isset($url)) {\n header(\"Location: \".$url);\n } else {\n expHistory::back();\n }\n }\n\t\t}\n\t}",
"\t/**\n\t * method to redirect to a login if needed\n\t */\n\tpublic static function loginredirect() {\n\t\tglobal $user, $router;",
"\t\tob_start();\n\t\tif ($user->isLoggedIn()) {\n\t\t\theader('Location: ' . expSession::get('redirecturl'));\n\t\t} else {\n\t\t\t//expSession::set('redirecturl', expHistory::getLastNotEditable());\n\t\t\texpSession::set('redirecturl', expHistory::getLast());\n\t\t\texpSession::set('redirecturl_error', makeLink(array('controller'=>'login', 'action'=>'loginredirect')));\n//\t\t\texpHistory::flowSet(SYS_FLOW_PUBLIC,SYS_FLOW_ACTION);\n\t\t\texpHistory::set('viewable', $router->params);\n\t\t}\n//\t\tredirect_to(array('controller'=>'login', 'action'=>'showlogin'));\n renderAction(array('controller'=>'login','action'=>'showlogin','no_output'=>true));\n\t}",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */\n/** @define \"BASE\" \"../../../..\" */",
"class usersController extends expController {\n public $basemodel_name = 'user';",
" protected $add_permissions = array(",
" 'toggle_extension' => 'Activate Extensions',\n 'kill_session' => 'End Sessions',\n 'boot_user' => 'Boot Users',\n 'userperms' => 'User Permissions',\n 'groupperms' => 'Group Permissions',\n 'import' => 'Import Users',\n 'export' => 'Export Users',",
" );\n protected $remove_permissions = array(\n 'create',\n 'edit'",
" );",
" static function displayname() {\n return gt(\"User Manager\");\n }",
" static function description() {\n return gt(\"This is the user management module. It allows for creating user, editing user, etc.\");\n }",
" static function hasSources() {\n return false;\n }",
" static function hasContent() {\n return false;\n }",
" static function canImportData() {\n return true;\n }",
" public function manage() {\n global $user;",
" expHistory::set('manageable', $this->params);\n// $limit = empty($this->config['limit']) ? 10 : $this->config['limit'];\n// $order = empty($this->config['order']) ? 'username' : $this->config['order'];\n if ($user->is_system_user == 1) {\n// $filter = 1; //'1';\n $where = '';\n } elseif ($user->isSuperAdmin()) {\n// $filter = 2; //\"is_system_user != 1\";\n $where = \"is_system_user != 1\";\n } else {\n// $filter = 3; //\"is_admin != 1\";\n $where = \"is_admin != 1\";\n }\n $page = new expPaginator(array(\n 'model'=>'user',\n 'where'=>$where,\n// 'limit'=>$limit,\n// 'order'=>$order,\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'columns'=>array(\n gt('Username')=>'username',\n gt('First Name')=>'firstname',\n gt('Last Name')=>'lastname',\n gt('Is Admin')=>'is_acting_admin',\n )\n ));",
" assign_to_template(array('page'=>$page));\n// assign_to_template(array(\n// 'filter' => $filter\n// ));\n }",
" public function create() {\n redirect_to(array('controller' => 'users', 'action' => 'edituser'));\n// $this->edituser();\n }",
" public function edituser() {\n global $user, $db;",
" // set history\n expHistory::set('editable', $this->params);\n expSession::set(\"userkey\", sha1(microtime()));\n expSession::clearCurrentUserSessionCache();",
" $id = !empty($this->params['id']) ? $this->params['id'] : null;",
" // check to see if we should be editing. You either need to be an admin, or editing own account.\n if ($user->isAdmin() || ($user->id == $id && !$user->globalPerm('prevent_profile_change'))) {\n $u = new user($id);\n if ($u->isSuperAdmin() && $user->isActingAdmin()) { // prevent regular admin's from editing super-admins\n flash('error', gt('You do not have the proper permissions to edit this user'));\n expHistory::back();\n }\n } else {\n flash('error', gt('You do not have the proper permissions to edit this user'));\n expHistory::back();\n }\n $active_extensions = $db->selectObjects('profileextension', 'active=1', 'rank');",
" //If there is no image uploaded, use the default avatar\n if (empty($u->image)) $u->image = PATH_RELATIVE . \"framework/modules/users/assets/images/avatar_not_found.jpg\";",
" assign_to_template(array(\n 'edit_user' => $u,\n 'extensions' => $active_extensions,\n \"userkey\" => expSession::get(\"userkey\")\n ));",
" if ($user->isAdmin()) {\n $page = new expPaginator(array(\n 'model' => 'group',\n 'where' => 1,\n 'limit' => (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10,\n 'order' => empty($this->config['order']) ? 'name' : $this->config['order'],\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Name') => 'name',\n gt('Description') => 'description',\n ),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n ));",
" assign_to_template(array(\n 'groups' => $page,\n 'mygroups' => $u->getGroupMemberships(),\n ));\n }\n }",
" public function update() {\n global $user, $db;",
" // get the id of user we are editing, if there is one\n $id = !empty($this->params['id']) ? $this->params['id'] : null;\n if ((($user->id == $id) || $user->isAdmin()) && $this->params['userkey'] != expSession::get(\"userkey\")) expHistory::back();",
" // make sure this user should be updating user accounts\n if (!$user->isLoggedIn() && SITE_ALLOW_REGISTRATION == 0) {\n flash('error', gt('This site does not allow user registrations'));\n expHistory::back();\n } elseif (!$user->isAdmin() && ($user->isLoggedIn() && $user->id != $id)) {\n flash('error', gt('You do not have permission to edit this user account'));\n expHistory::back();\n }\n",
" // if this is a new user account we need to check the password. ",
" // the password fields wont come thru on an edit. Otherwise we will\n // just update the existing account.\n if (!empty($id)) {\n $u = new user($id);\n $u->update($this->params);\n if ($user->isAdmin() && $user->id != $id) {\n flash('message', gt('Account information for') . ' ' . $u->username . ' ' . gt('has been updated.'));\n } else {\n flash('message', gt('Thank you') . ' ' . $u->firstname . '. ' . gt('Your account information has been updated.'));\n }\n if ($user->id == $id) {\n $_SESSION[SYS_SESSION_KEY]['user'] = $u;\n $user = $u;\n }\n } else {\n $u = new user($this->params);\n $ret = $u->setPassword($this->params['pass1'], $this->params['pass2']);\n if ($ret != true) expValidator::failAndReturnToForm($ret, $this->params);\n $u->save();\n if ($user->isAdmin()) {\n flash('message', gt('Created new user account for') . ' ' . $u->username);\n } else {\n user::login($u->username, $this->params['pass1']);\n flash('message', gt('Thank you') . ' ' . $u->firstname . '. ' . gt('Your new account has been created.'));\n }\n }",
" // update the user profiles\n if (!empty($u->id)) {\n $this->params['user_id'] = $u->id;\n // get the active profile extensions and save them out\n $active_extensions = $db->selectObjects('profileextension', 'active=1');\n foreach ($active_extensions as $pe) {\n if (is_file(BASE . $pe->classfile)) {\n include_once(BASE . $pe->classfile);\n $ext = new $pe->classname();\n $db->delete($ext->tablename, 'user_id=' . $u->id);\n $ext->update($this->params);\n }\n }\n }",
" // update group membership assignment\n if (!empty($this->params['member'])) {\n $old_groups = $db->selectObjects('groupmembership', 'member_id=' . $u->id);\n// $db->delete('groupmembership', 'member_id=' . $u->id); // start from scratch\n $memb = new stdClass();\n $memb->member_id = $u->id;\n foreach ($this->params['member'] as $grp) {\n $memb->group_id = $grp;\n $memb->is_admin = false;\n foreach ($old_groups as $oldgroup) {\n if ($oldgroup->group_id == $grp) {\n if ($oldgroup->is_admin) $memb->is_admin = true; // retain group admin setting\n }\n }\n $db->insertObject($memb, 'groupmembership');\n }\n if ($u->id == $user->id) expSession::triggerRefresh();\n }\n",
" // if this is a new account then we will check to see if we need to send ",
" // a welcome message or admin notification of new accounts.\n if (empty($id)) {\n // Calculate Group Memberships for newly created users. Any groups that\n // are marked as 'inclusive' automatically pick up new users. This is the part\n // of the code that goes out, finds those groups, and makes the new user a member\n // of them.\n $memb = new stdClass();\n $memb->member_id = $u->id;\n // Also need to process the groupcodes, for promotional signup\n// $code_where = '';\n// if (isset($this->params['groupcode']) && $this->params['groupcode'] != '') {\n// $code_where = \" OR code='\" . $this->params['groupcode'] . \"'\";\n// }\n // Add to default plus any groupcode groups\n// foreach ($db->selectObjects('group', 'inclusive=1' . $code_where) as $g) {\n foreach ($db->selectObjects('group', 'inclusive=1') as $g) {\n $memb->group_id = $g->id;\n $db->insertObject($memb, 'groupmembership');\n }",
" // if we added the user to any group than we need to reload their permissions\n// expPermissions::load($u); //FIXME why are we doing this? this loads the edited user perms over the current user???",
" //signup email stuff\n if (USER_REGISTRATION_SEND_WELCOME && !empty($u->email)) {\n $msg = $u->firstname . \", \\n\\n\";\n $msg .= sprintf(USER_REGISTRATION_WELCOME_MSG, $u->firstname, $u->lastname, $u->username);",
" $mail = new expMail();\n $mail->quickSend(array(\n 'text_message' => $msg,\n 'to' => array(trim($u->email) => trim(user::getUserAttribution($u->id))),\n 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),\n 'subject' => USER_REGISTRATION_WELCOME_SUBJECT,\n ));",
" flash('message', gt('A welcome email has been sent to') . ' ' . $u->email);\n }",
" // send and email notification to the admin of the site.\n if (USER_REGISTRATION_SEND_NOTIF && !$user->isAdmin()) {\n $msg = gt(\"When\") . \": \" . date(\"F j, Y, g:i a\") . \"\\n\\n\";\n $msg .= gt(\"Their name is\") . \": \" . $u->firstname . \" \" . $u->lastname . \"\\n\\n\";",
" $mail = new expMail();\n $mail->quickSend(array(\n 'text_message' => $msg,\n 'to' => trim(USER_REGISTRATION_ADMIN_EMAIL),\n 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),\n 'subject' => USER_REGISTRATION_NOTIF_SUBJECT,\n ));\n }\n }",
" // we need to reload our updated profile if we just edited our own account\n if ($id == $user->id) {\n $user->getUserProfile();\n// expPermissions::load($user); // not sure this is necessary since we can't add groups here\n }",
" expHistory::back();\n }",
" public function delete() {\n global $user, $db;\n if (!$user->isAdmin()) {\n flash('error', gt('You do not have permission to delete user accounts'));\n expHistory::back();\n }",
" if (empty($this->params['id'])) {\n flash('error', gt('No user selected.'));\n expHistory::back();\n }",
" // remove group memeberships\n $db->delete('groupmembership', 'member_id=' . $this->params['id']);",
" // remove user permissions\n $db->delete('userpermission', 'uid=' . $this->params['id']);",
" //remove user profiles\n $active_extensions = $db->selectObjects('profileextension', 'active=1');\n foreach ($active_extensions as $pe) {\n if (is_file(BASE . $pe->classfile)) {\n include_once(BASE . $pe->classfile);\n $ext = new $pe->classname();\n $db->delete($ext->table, 'user_id=' . $this->params['id']);\n }\n }",
" // remove user address\n $address = new address();\n $db->delete($address->table, 'user_id=' . $this->params['id']);",
" parent::delete();\n }",
" public function manage_sessions() {\n// global $db, $user;\n global $db;",
" expHistory::set('manageable', $this->params);",
" //cleans up any old sessions\n if (SESSION_TIMEOUT_ENABLE == true) {\n $db->delete('sessionticket', 'last_active < ' . (time() - SESSION_TIMEOUT));\n// } else {\n// $db->delete('sessionticket', '1');\n }",
" if (isset($this->params['id']) && $this->params['id'] == 0) {\n $sessions = $db->selectObjects('sessionticket', \"uid<>0\");\n $filtered = 1;\n } else {\n $sessions = $db->selectObjects('sessionticket');\n $filtered = 0;\n }",
"//\t $sessions = $db->selectObjects('sessionticket');\n for ($i = 0, $iMax = count($sessions); $i < $iMax; $i++) {\n $sessions[$i]->user = new user($sessions[$i]->uid);\n if ($sessions[$i]->uid == 0) {\n $sessions[$i]->user->id = 0;\n }\n $sessions[$i]->duration = expDateTime::duration($sessions[$i]->last_active, $sessions[$i]->start_time);\n }",
" assign_to_template(array(\n 'sessions' => $sessions,\n 'filter' => $filtered\n ));\n }",
" public function kill_session() {\n global $user, $db;\n $ticket = $db->selectObject('sessionticket', \"ticket='\" . preg_replace('/[^A-Za-z0-9.]/', '', $this->params['ticket']) . \"'\");\n if ($ticket) {\n $u = new user($ticket->uid);\n if ($user->isSuperAdmin() || ($user->isActingAdmin() && !$u->isAdmin())) {\n // We can only kick the user if they are A) not an acting admin, or\n // B) The current user is a super user and the kicked user is not.\n $db->delete('sessionticket', \"ticket='\" . $ticket->ticket . \"'\");\n }\n }\n expHistory::back();\n }",
" public function boot_user() {\n global $user, $db;\n if (!empty($this->params['id'])) {\n $u = new user($this->params['id']);\n if ($user->isSuperAdmin() || ($user->isActingAdmin() && !$u->isAdmin())) {\n // We can only kick the user if they are A) not an acting admin, or\n // B) The current user is a super user and the kicked user is not.\n $db->delete('sessionticket', 'uid=' . $u->id);\n }\n }\n expHistory::back();\n }",
" /**\n * This function scans two directories and searches for php files to add to the extensions database.\n * If you have added new extensions since the last time you have visited the page, it will add them to the database\n * in effect enabling your new extension to be tacked onto users profiles. You then have to enable it in the menu, but at least\n * now it is in the system and when the user goes to edit his profile, it will check for extensions and this one will be in!\n *\n * @global string This function uses the global $db save information through the Exponenet database connection.\n */\n public function manage_extensions() {\n global $db;",
" // set history\n expHistory::set('manageable', $this->params);",
" // Lets find all the user profiles availabe and then see if they are\n // in the database yet. If not we will add them.\n $ext_dirs = array(\n 'framework/modules/users/extensions',\n 'themes/' . DISPLAY_THEME . '/modules/users/extensions'\n );\n foreach ($ext_dirs as $dir) {\n if (is_readable(BASE . $dir)) {\n $dh = opendir(BASE . $dir);\n while (($file = readdir($dh)) !== false) {\n if (is_file(BASE . \"$dir/$file\") && is_readable(BASE . \"$dir/$file\") && substr($file, 0, 1) != '_' && substr($file, 0, 1) != '.') {\n include_once(BASE . \"$dir/$file\");\n $classname = substr($file, 0, -4);\n $class = new $classname();\n $extension = $db->selectObject('profileextension', \"title='\" . $class->name() . \"'\");\n if (empty($extension->id)) {\n $pe = new profileextension();\n $pe->title = $class->name();\n $pe->body = $class->description();\n $pe->classfile = \"$dir/$file\";\n $pe->classname = $classname;\n $pe->save();\n }\n }\n }\n }\n }",
" $page = new expPaginator(array(\n 'model' => 'profileextension',\n 'where' => 1,\n 'limit' => 25,\n 'order' => 'title',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Name') => 'title',\n gt('Description') => 'body',\n gt('Active') => 'active'\n ),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n ));",
" assign_to_template(array(\n 'page' => $page\n ));\n }",
" public function manage_groups() {\n expHistory::set('manageable', $this->params);\n $page = new expPaginator(array(\n 'model' => 'group',\n 'where' => 1,\n// 'limit' => (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10,\n 'order' => empty($this->config['order']) ? 'name' : $this->config['order'],\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Name') => 'name',\n gt('Description') => 'description',\n gt('Type') => 'inclusive',\n ),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n ));",
" foreach ($page->records as $key=>$group) {\n $page->records[$key]->members = group::getUsersInGroup($group->id);\n }",
" assign_to_template(array(\n 'page' => $page,\n ));\n }",
" public function reset_password() {\n expHistory::set('editable', $this->params);\n }",
" public function send_new_password() {\n global $db;",
" // find the user",
"",
" $u = user::getUserByName($this->params['username']);\n if (empty($u)) {\n $u = user::getUserByEmail($this->params['username']);\n if (!empty($u) && $u->count > 1) {\n expValidator::failAndReturnToForm(gt('That email address applies to more than one user account, please enter your username instead.'));\n }\n }\n $u = new user($u->id);",
" if (!expValidator::check_antispam($this->params)) {\n expValidator::failAndReturnToForm(gt('Anti-spam verification failed. Please try again.'), $this->params);\n } elseif (empty($u->id)) {\n expValidator::failAndReturnToForm(gt('We were unable to find an account with that username/email'), $this->params);\n } elseif (empty($u->email)) {\n expValidator::failAndReturnToForm(gt('Your account does not appear to have an email address. Please contact the site administrators to reset your password'), $this->params);\n } elseif ($u->isAdmin()) {\n expValidator::failAndReturnToForm(gt('You cannot reset passwords for an administrator account.'), $this->params);\n }",
" $tok = new stdClass();\n $tok->uid = $u->id;\n $tok->expires = time() + 2 * 3600;\n $tok->token = md5(time()) . uniqid('');",
" $email = $template = expTemplate::get_template_for_action($this, 'email/password_reset_email', $this->loc);\n $email->assign('token', $tok);\n $email->assign('username', $u->username);\n $msg = $email->render();\n $mail = new expMail();\n $mail->quickSend(array(\n 'html_message' => $msg,\n 'to' => array(trim($u->email) => trim(user::getUserAttribution($u->id))),\n 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),\n 'subject' => gt('Password Reset Requested'),\n ));",
" $db->delete('passreset_token', 'uid=' . $u->id);\n $db->insertObject($tok, 'passreset_token');\n flash('message', gt('An email has been sent to you with instructions on how to finish resetting your password.') . '<br><br>' .\n gt('This new password request is only valid for 2 hours. If you have not completed the password reset process within 2 hours, the new password request will expire.'));",
" expHistory::back();\n }",
" public function confirm_password_reset() {\n global $db;",
" $db->delete('passreset_token', 'expires < ' . time());",
" $tok = $db->selectObject('passreset_token', 'uid=' . $this->params['uid'] . \" AND token='\" . preg_replace('/[^A-Za-z0-9]/', '', $this->params['token']) . \"'\");",
" if ($tok == null) {\n flash('error', gt('Your password reset request has expired. Please try again.'));\n expHistory::back();\n }",
" // create the password\n $newpass = '';\n for ($i = 0, $iMax = mt_rand(12, 20); $i < $iMax; $i++) {\n $num = mt_rand(48, 122);\n if (($num > 97 && $num < 122) || ($num > 65 && $num < 90) || ($num > 48 && $num < 57)) $newpass .= chr($num);\n else $i--;\n }",
" // look up the user\n $u = new user($tok->uid);",
" // get the email message body and render it\n $email = $template = expTemplate::get_template_for_action($this, 'email/confirm_password_email', $this->loc);\n $email->assign('newpass', $newpass);\n $email->assign('username', $u->username);\n $msg = $email->render();",
" // send the new password to the user\n $mail = new expMail();\n $mail->quickSend(array(\n 'html_message' => $msg,\n 'to' => array(trim($u->email) => trim(user::getUserAttribution($u->id))),\n 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),\n 'subject' => gt('The account password for') . ' ' . HOSTNAME . ' ' . gt('was reset'),\n ));",
" // Save new password\n $u->update(array('password' => user::encryptPassword($newpass)));",
" // cleanup the reset token\n $db->delete('passreset_token', 'uid=' . $tok->uid);",
" flash('message', gt('Your password has been reset and the new password has been emailed to you.'));",
" // send the user the login page.\n redirect_to(array('controller' => 'login', 'action' => 'loginredirect'));\n }",
" public function change_password() {\n global $user;",
" expHistory::set('editable', $this->params);\n $id = isset($this->params['id']) ? $this->params['id'] : $user->id;",
" if ($user->isAdmin() || ($user->id == $id)) {\n $isuser = ($user->id == $id) ? 1 : 0;\n $u = new user($id);\n } else {\n flash('error', gt('You do not have the proper permissions to do that'));\n expHistory::back();\n }\n assign_to_template(array(\n 'u' => $u,\n 'isuser' => $isuser\n ));\n }",
" public function save_change_password() {\n global $user;",
" $isuser = ($this->params['uid'] == $user->id) ? 1 : 0;",
" if (!$user->isAdmin() && !$isuser) {\n flash('error', gt('You do not have permissions to change this users password.'));\n expHistory::back();\n }",
" if (($isuser && empty($this->params['password'])) || (!empty($this->params['password']) && $user->password != user::encryptPassword($this->params['password']))) {\n flash('error', gt('The current password you entered is not correct.'));\n expHistory::returnTo('editable');\n }\n //eDebug($user);",
" $u = new user($this->params['uid']);",
"\n $ret = $u->setPassword($this->params['new_password1'], $this->params['new_password2']);\n //eDebug($u, true);\n if (is_string($ret)) {\n flash('error', $ret);\n expHistory::returnTo('editable');\n } else {\n $params = array();\n $params['is_admin'] = !empty($u->is_admin);\n $params['is_acting_admin'] = !empty($u->is_acting_admin);\n $u->update($params);\n }",
" if (!$isuser) {\n flash('message', gt('The password for') . ' ' . $u->username . ' ' . gt('has been changed.'));\n } else {\n $user->password = $u->password;\n flash('message', gt('Your password has been changed.'));\n }\n expHistory::back();\n }",
" public function edit_userpassword() {\n expHistory::set('editable', $this->params);\n if (empty($this->params['id'])) {\n flash('error', gt('You must specify the user whose password you want to change'));\n expHistory::back();\n }",
" $u = new user($this->params['id']);\n assign_to_template(array(\n 'u' => $u\n ));\n }",
" public function update_userpassword() {",
"",
" if (empty($this->params['id'])) {\n expValidator::failAndReturnToForm(gt('You must specify the user whose password you want to change'), $this->params);\n }",
" if (empty($this->params['new_password1'])) {\n expValidator::setErrorField('new_password1');\n expValidator::failAndReturnToForm(gt('You must specify a new password for this user.'), $this->params);\n }",
" if (empty($this->params['new_password2'])) {\n expValidator::setErrorField('new_password2');\n expValidator::failAndReturnToForm(gt('You must confirm the password.'), $this->params);",
" }",
" $u = new user($this->params['id']);\n $ret = $u->setPassword($this->params['new_password1'], $this->params['new_password2']);\n if (is_string($ret)) {\n expValidator::setErrorField('new_password1');\n $this->params['new_password1'] = '';\n $this->params['new_password2'] = '';\n expValidator::failAndReturnToForm($ret, $this->params);\n } else {\n $u->save(true);\n }",
" flash('message', gt('Password reset for user') . ' ' . $u->username);\n expHistory::back();\n }",
" public function edit_group() {\n global $db;",
" expHistory::set('editable', $this->params);\n $id = isset($this->params['id']) ? $this->params['id'] : null;\n $group = new group($id);\n $group->redirect = $db->selectValue('section', 'id', \"sef_name='\" . $group->redirect . \"'\");\n assign_to_template(array(\n 'record' => $group\n ));\n }",
" public function manage_group_memberships() {\n global $db, $user;\n// expHistory::set('manageable', $this->params);",
" $memb = $db->selectObject('groupmembership', 'member_id=' . $user->id . ' AND group_id=' . $this->params['id'] . ' AND is_admin=1');",
" $perm_level = 0;\n if ($memb) $perm_level = 1;\n if (expPermissions::check('user_management', expCore::makeLocation('administrationmodule'))) $perm_level = 2;",
" $group = $db->selectObject('group', 'id=' . $this->params['id']);\n $users = user::getAllUsers(0);",
" $members = array();\n $admins = array();\n foreach ($db->selectObjects('groupmembership', 'group_id=' . $group->id) as $m) {\n $members[] = $m->member_id;\n if ($m->is_admin == 1) {\n $admins[] = $m->member_id;\n }\n }",
" for ($i = 0, $iMax = count($users); $i < $iMax; $i++) {\n if (in_array($users[$i]->id, $members)) {\n $users[$i]->is_member = 1;\n } else {\n $users[$i]->is_member = 0;\n }",
" if (in_array($users[$i]->id, $admins)) {\n $users[$i]->is_admin = 1;\n } else {\n $users[$i]->is_admin = 0;\n }\n }",
" //$limit = empty($this->config['limit']) ? 10 : $this->config['limit'];\n $page = new expPaginator(array(\n// 'model'=>'user',\n 'records' => $users,\n 'where' => 1,\n// 'limit'=>9999, // unless we're showing all users on a page at once, there's no way to\n // add all users to a group, since it's rebuilding the group on save...\n 'order' => empty($this->config['order']) ? 'username' : $this->config['order'],\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Username') => 'username',\n gt('First Name') => 'firstname',\n gt('Last Name') => 'lastname',\n gt('Is Member') => 'is_member',\n gt('Is Admin') => 'is_admin',\n ),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n ));",
" assign_to_template(array(\n 'page' => $page,\n 'group' => $group,\n 'users' => $users,\n 'canAdd' => (count($members) < count($users) ? 1 : 0),\n 'hasMember' => (count($members) > 0 ? 1 : 0),\n 'perm_level' => $perm_level,\n ));\n }",
" public function update_group() {\n global $db;",
" $group = new group();\n if (!empty($this->params['redirect'])) {\n $this->params['redirect'] = $db->selectValue('section', 'sef_name', 'id=' . $this->params['redirect']);\n }\n $group->update($this->params);\n expHistory::back();\n }",
" public function delete_group() {\n global $user, $db;\n if (!$user->isAdmin()) {\n flash('error', gt('You do not have permission to delete user groups'));\n expHistory::back();\n }",
" if (empty($this->params['id'])) {\n flash('error', gt('No group selected.'));\n expHistory::back();\n }",
" // remove group members\n $db->delete('groupmembership', 'group_id=' . $this->params['id']);",
" // remove group permissions\n $db->delete('grouppermission', 'gid=' . $this->params['id']);",
" // remove group\n $db->delete('group', 'id=' . $this->params['id']);\n expHistory::back();\n }",
" public function toggle_extension() {\n global $db;\n if (isset($this->params['id'])) $db->toggle('profileextension', 'active', 'id=' . $this->params['id']);\n expHistory::back();\n }",
" public function update_memberships() {\n// global $user, $db;\n global $db;",
" //$memb = $db->selectObject('groupmembership','member_id='.$user->id.' AND group_id='.$this->params['id'].' AND is_admin=1');\n $group = $db->selectObject('group', 'id=' . $this->params['id']);",
" $db->delete('groupmembership', 'group_id=' . $group->id);\n $memb = new stdClass();\n $memb->group_id = $group->id;\n if ($this->params['memdata'] != \"\") {\n foreach ($this->params['memdata'] as $u => $str) {\n $memb->member_id = $u;\n $memb->is_admin = $str['is_admin'];\n $db->insertObject($memb, 'groupmembership');\n }\n }\n expSession::triggerRefresh();\n expHistory::back();\n }",
" public function getUsersByJSON() {\n $modelname = $this->basemodel_name;\n $results = 25; // default get 25\n $startIndex = 0; // default start at 0\n $sort = null; // default don't sort\n $dir = 'asc'; // default sort dir is asc\n $sort_dir = SORT_ASC;",
" // How many records to get?\n if (strlen($this->params['results']) > 0) {\n $results = $this->params['results'];\n }",
" // Start at which record?\n if (strlen($this->params['startIndex']) > 0) {\n $startIndex = $this->params['startIndex'];\n }",
" // Sorted?\n if (strlen($this->params['sort']) > 0) {\n $sort = $this->params['sort'];\n if ($sort = 'id') $sort = 'username';\n }",
" if (!empty($this->params['filter'])) {\n switch ($this->params['filter']) {\n case '1' :\n $filter = '';\n break;\n case '2' :\n $filter = \"is_system_user != 1\";\n break;\n case '3' :\n $filter = \"is_admin != 1\";\n }\n }",
"// if (!empty($_GET['filter'])) {\n// switch ($_GET['filter']) {\n// case '1' :\n// $filter = '';\n// break;\n// case '2' :\n// $filter = \"is_system_user != 1\";\n// break;\n// case '3' :\n// $filter = \"is_admin != 1\";\n// }\n// }",
" // Sort dir?\n if ((strlen($this->params['dir']) > 0) && ($this->params['dir'] == 'desc')) {\n $dir = 'desc';\n $sort_dir = SORT_DESC;\n } else {\n $dir = 'asc';\n $sort_dir = SORT_ASC;\n }",
" if (!empty($this->params['query'])) {",
"// $this->params['query'] = $this->params['query'];\n $totalrecords = $this->$modelname->find('count', (empty($filter) ? '' : $filter . \" AND \") . \"(username LIKE '%\" . $this->params['query'] . \"%' OR firstname LIKE '%\" . $this->params['query'] . \"%' OR lastname LIKE '%\" . $this->params['query'] . \"%' OR email LIKE '%\" . $this->params['query'] . \"%')\");",
" $users = $this->$modelname->find('all', (empty($filter) ? '' : $filter . \" AND \") . \"(username LIKE '%\" . $this->params['query'] . \"%' OR firstname LIKE '%\" . $this->params['query'] . \"%' OR lastname LIKE '%\" . $this->params['query'] . \"%' OR email LIKE '%\" . $this->params['query'] . \"%')\", $sort . ' ' . $dir, $results, $startIndex);",
" for ($i = 0, $iMax = count($users); $i < $iMax; $i++) {\n if (ECOM == 1) {\n $users[$i]->usernamelabel = \"<a href='viewuser/{$users[$i]->id}' class='fileinfo'>{$users[$i]->username}</a>\";\n } else {\n $users[$i]->usernamelabel = $users[$i]->username;\n }\n }",
" $returnValue = array(\n 'recordsReturned' => count($users),\n 'totalRecords' => $totalrecords,\n 'startIndex' => $startIndex,\n 'sort' => $sort,\n 'dir' => $dir,\n 'pageSize' => $results,\n 'records' => $users\n );\n } else {",
" $totalrecords = $this->$modelname->find('count', $filter);",
" $users = $this->$modelname->find('all', $filter, $sort . ' ' . $dir, $results, $startIndex);",
" for ($i = 0, $iMax = count($users); $i < $iMax; $i++) {\n if (ECOM == 1) {\n $users[$i]->usernamelabel = \"<a href='viewuser/{$users[$i]->id}' class='fileinfo'>{$users[$i]->username}</a>\";\n } else {\n $users[$i]->usernamelabel = $users[$i]->username;\n }\n }",
" $returnValue = array(\n 'recordsReturned' => count($users),\n 'totalRecords' => $totalrecords,\n 'startIndex' => $startIndex,\n 'sort' => $sort,\n 'dir' => $dir,\n 'pageSize' => $results,\n 'records' => $users\n );",
" }",
" echo json_encode($returnValue);\n }",
" public function viewuser() {\n global $user;",
" if (!empty($this->params['id'])) {\n $u = new user($this->params['id']);\n } elseif (!empty($user->id)) {\n $u = $user;\n } else {\n flash('error', gt('You may not view this user'));\n expHistory::back();\n }\n $address = new address();",
" $billings = $address->find('all', 'user_id=' . $u->id . ' AND is_billing = 1');\n $shippings = $address->find('all', 'user_id=' . $u->id . ' AND is_shipping = 1');",
" // build out a SQL query that gets all the data we need and is sortable.\n $sql = 'SELECT o.*, b.firstname as firstname, b.billing_cost as total, b.middlename as middlename, b.lastname as lastname, os.title as status, ot.title as order_type ';\n $sql .= 'FROM ' . DB_TABLE_PREFIX . '_orders o, ' . DB_TABLE_PREFIX . '_billingmethods b, ';\n $sql .= DB_TABLE_PREFIX . '_order_status os, ';\n $sql .= DB_TABLE_PREFIX . '_order_type ot ';\n $sql .= 'WHERE o.id = b.orders_id AND o.order_status_id = os.id AND o.order_type_id = ot.id AND o.purchased > 0 AND user_id =' . $u->id;",
" $limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;\n $order = !empty($this->params['order']) ? $this->params['order'] : 'purchased';\n $dir = !empty($this->params['dir']) ? $this->params['dir'] : 'DESC';\n //eDebug($sql, true);\n $orders = new expPaginator(array(\n //'model'=>'order',\n 'sql' => $sql,\n 'limit' => $limit,\n 'order' => $order,\n 'dir' => $dir,\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Order #') => 'invoice_id',\n gt('Total') => 'total',\n gt('Date Purchased') => 'purchased',\n// gt('Type') => 'order_type_id',\n gt('Status') => 'order_status_id',\n gt('Ref') => 'orig_referrer',\n ),\n 'controller' => $this->params['controller'],\n 'action' => $this->params['action'],\n ));",
" assign_to_template(array(\n 'u' => $u,\n 'billings' => $billings,\n 'shippings' => $shippings,\n 'orders' => $orders,\n ));\n }",
" public function userperms() {\n global $user;",
" if (!empty($this->params['mod']) && $user->isAdmin()) {\n $loc = expCore::makeLocation($this->params['mod'], isset($this->params['src']) ? $this->params['src'] : null, isset($this->params['int']) ? $this->params['int'] : null);\n $users = array();\n $modclass = expModules::getModuleClassName(($loc->mod));\n $mod = new $modclass();\n $perms = $mod->permissions($loc->int);\n $have_users = 0;\n foreach (user::getAllUsers(false) as $u) {\n $have_users = 1;\n foreach ($perms as $perm => $name) {\n// \t\t\t$var = 'perms_'.$perm;\n if (expPermissions::checkUser($u, $perm, $loc, true)) {\n $u->$perm = 1;\n } else if (expPermissions::checkUser($u, $perm, $loc)) {\n $u->$perm = 2;\n } else {\n $u->$perm = 0;\n }\n }\n $users[] = $u;\n }",
" $p[gt(\"User Name\")] = 'username';\n $p[gt(\"First Name\")] = 'firstname';\n $p[gt(\"Last Name\")] = 'lastname';\n foreach ($mod->permissions() as $value) {\n // $p[gt($value)]=$key;\n $p[gt($value)] = 'no-sort';\n }",
"// if (SEF_URLS == 1) {\n $page = new expPaginator(array(\n //'model'=>'user',\n// 'limit' => (isset($this->params['limit']) ? $this->params['limit'] : 20),\n 'records' => $users,\n //'sql'=>$sql,\n 'order' => (isset($this->params['order']) ? $this->params['order'] : 'username'),\n 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'ASC'),\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->params['controller'],\n 'action' => $this->params['action'],\n 'columns' => $p,\n ));\n// } else {\n// $page = new expPaginator(array(\n// //'model'=>'user',\n//// 'limit' => (isset($this->params['limit']) ? $this->params['limit'] : 20),\n// 'records' => $users,\n// //'sql'=>$sql,\n// 'order' => (isset($this->params['order']) ? $this->params['order'] : 'username'),\n// 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'ASC'),\n// 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n// 'controller' => $this->params['module'],\n// 'action' => $this->params['action'],\n// 'columns' => $p,\n// ));\n// }",
" assign_to_template(array(\n 'user_form' => 1,\n 'have_users' => $have_users,\n 'users' => $users,\n 'page' => $page,\n 'perms' => $perms,\n 'loc' => $loc,\n// 'title'=>($modclass != 'navigationController' || ($modclass == 'navigationController' && !empty($loc->src))) ? $mod->name().' '.($modclass != 'containermodule' ? gt('module') : '').' ' : gt('Page'),\n 'title' => ($loc->mod != 'navigation' || ($loc->mod == 'navigation' && !empty($loc->src))) ? $mod->name() . ' ' . ($loc->mod != 'container' ? gt('module') : '') . ' ' : gt('Page'),\n ));\n } else {\n// echo SITE_403_HTML;\n notfoundController::handle_not_authorized();\n }\n }",
" public function userperms_save() {\n global $user;",
" $loc = expCore::makeLocation($this->params['mod'], isset($this->params['src']) ? $this->params['src'] : null, isset($this->params['int']) ? $this->params['int'] : null);\n foreach ($this->params['users'] as $u) {\n expPermissions::revokeAll($u, $loc);\n }\n foreach ($this->params['permdata'] as $k => $user_str) {\n $perms = array_keys($user_str);\n $u = user::getUserById($k);\n for ($i = 0, $iMax = count($perms); $i < $iMax; $i++) {\n expPermissions::grant($u, $perms[$i], $loc);\n }",
" if ($k == $user->id) {\n expPermissions::load($user);\n }\n }\n expSession::triggerRefresh();\n expHistory::back();\n }",
" public function groupperms() {\n global $user;",
" if (!empty($this->params['mod']) && $user->isAdmin()) {\n $loc = expCore::makeLocation($this->params['mod'], isset($this->params['src']) ? $this->params['src'] : null, isset($this->params['int']) ? $this->params['int'] : null);\n $users = array(); // users = groups\n $modclass = expModules::getModuleClassName($loc->mod);\n $mod = new $modclass();\n $perms = $mod->permissions($loc->int);",
" foreach (group::getAllGroups() as $g) {\n foreach ($perms as $perm => $name) {\n// \t\t\t$var = 'perms_'.$perm;\n if (expPermissions::checkGroup($g, $perm, $loc, true)) {\n $g->$perm = 1;\n } else if (expPermissions::checkGroup($g, $perm, $loc)) {\n $g->$perm = 2;\n } else {\n $g->$perm = 0;\n }\n }\n $users[] = $g;\n }",
" $p[gt(\"Group\")] = 'username';\n foreach ($mod->permissions() as $value) {\n // $p[gt($value)]=$key;\n $p[gt($value)] = 'no-sort';\n }",
"// if (SEF_URLS == 1) {\n $page = new expPaginator(array(\n //'model'=>'user',\n// 'limit' => (isset($this->params['limit']) ? $this->params['limit'] : 20),\n 'records' => $users,\n //'sql'=>$sql,\n 'order' => (isset($this->params['order']) ? $this->params['order'] : 'name'),\n 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'ASC'),\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->params['controller'],\n 'action' => $this->params['action'],\n 'columns' => $p,\n ));\n// } else {\n// $page = new expPaginator(array(\n// //'model'=>'user',\n//// 'limit' => (isset($this->params['limit']) ? $this->params['limit'] : 20),\n// 'records' => $users,\n// //'sql'=>$sql,\n// 'order' => (isset($this->params['order']) ? $this->params['order'] : 'name'),\n// 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'ASC'),\n// 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n// 'controller' => $this->params['module'],\n// 'action' => $this->params['action'],\n// 'columns' => $p,\n// ));\n// }",
" assign_to_template(array(\n 'user_form' => 0,\n 'is_group' => 1,\n 'have_users' => count($users) > 0, // users = groups\n 'users' => $users,\n 'page' => $page,\n 'perms' => $perms,\n 'loc' => $loc,\n// 'title'=>($modclass != 'navigationController' || ($modclass == 'navigationController' && !empty($loc->src))) ? $mod->name().' '.($modclass != 'containermodule' ? gt('module') : '').' ' : gt('Page'),\n 'title' => ($loc->mod != 'navigation' || ($loc->mod == 'navigation' && !empty($loc->src))) ? $mod->name() . ' ' . ($loc->mod != 'container' ? gt('module') : '') . ' ' : gt('Page'),\n ));\n } else {\n// echo SITE_403_HTML;\n notfoundController::handle_not_authorized();\n }\n }",
" public function groupperms_save() {\n $loc = expCore::makeLocation($this->params['mod'], isset($this->params['src']) ? $this->params['src'] : null, isset($this->params['int']) ? $this->params['int'] : null);\n foreach ($this->params['users'] as $g) {\n expPermissions::revokeAllGroup($g, $loc);\n }\n foreach ($this->params['permdata'] as $k => $group_str) {\n $perms = array_keys($group_str);\n $g = group::getGroupById($k);\n for ($i = 0, $iMax = count($perms); $i < $iMax; $i++) {\n expPermissions::grantGroup($g, $perms[$i], $loc);\n }\n }\n expSession::triggerRefresh();\n expHistory::back();\n }",
" public function import() {\n if (expFile::canCreate(BASE . \"tmp/test\") != SYS_FILES_SUCCESS) {\n assign_to_template(array(\n \"error\" => \"The /tmp directory is not writable. Please contact your administrator.\",\n ));\n } else {\n //Setup the arrays with the name/value pairs for the dropdown menus\n $delimiterArray = Array(\n ',' => gt('Comma'),\n ';' => gt('Semicolon'),\n ':' => gt('Colon'),\n ' ' => gt('Space'));",
"// //Setup the mete data (hidden values)\n// $form = new form();\n// $form->meta(\"controller\", \"users\");\n// $form->meta(\"action\", \"import_users_mapper\");\n//\n// //Register the dropdown menus\n// $form->register(\"delimiter\", gt('Delimiter Character'), new dropdowncontrol(\",\", $delimiterArray));\n// $form->register(\"upload\", gt('CSV File to Upload'), new uploadcontrol());\n// $form->register(\"use_header\", gt('First Row is a Header'), new checkboxcontrol(0, 0));\n// $form->register(\"rowstart\", gt('User Data begins in Row'), new textcontrol(\"1\", 1, 0, 6));\n// $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n// \"form_html\" => $form->tohtml(),\n 'delimiters' => $delimiterArray,\n ));\n }\n }",
" public function import_users_mapper() {\n //Check to make sure the user filled out the required input.\n //FIXME needs to be the newer fail form\n if (!is_numeric($this->params[\"rowstart\"])) {\n unset($this->params[\"rowstart\"]);\n $this->params['_formError'] = gt('The starting row must be a number.');\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit('Redirecting...');\n }",
" //Get the temp directory to put the uploaded file\n $directory = \"tmp\";",
" //Get the file save it to the temp directory\n if ($_FILES[\"upload\"][\"error\"] == UPLOAD_ERR_OK) {\n //\t$file = file::update(\"upload\",$directory,null,time().\"_\".$_FILES['upload']['name']);\n $file = expFile::fileUpload(\"upload\", false, false, time() . \"_\" . $_FILES['upload']['name'], $directory.'/');\n if ($file == null) {\n switch ($_FILES[\"upload\"][\"error\"]) {\n case UPLOAD_ERR_INI_SIZE:\n case UPLOAD_ERR_FORM_SIZE:\n $this->params['_formError'] = gt('The file you attempted to upload is too large. Contact your system administrator if this is a problem.');\n break;\n case UPLOAD_ERR_PARTIAL:\n $this->params['_formError'] = gt('The file was only partially uploaded.');\n break;\n case UPLOAD_ERR_NO_FILE:\n $this->params['_formError'] = gt('No file was uploaded.');\n break;\n default:\n $this->params['_formError'] = gt('A strange internal error has occurred. Please contact the Exponent Developers.');\n break;\n }\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n }\n /*\n if (mime_content_type(BASE.$directory.\"/\".$file->filename) != \"text/plain\"){\n $this->params['_formError'] = \"File is not a delimited text file.\";\n expSession::set(\"last_POST\",$this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n */",
" //split the line into its columns\n $headerinfo = null;\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $fh = fopen(BASE . $directory . \"/\" . $file->filename, \"r\");\n if (!empty($this->params[\"use_header\"])) $this->params[\"rowstart\"]++;\n for ($x = 0; $x < $this->params[\"rowstart\"]; $x++) {\n $lineInfo = fgetcsv($fh, 2000, $this->params[\"delimiter\"]);\n if ($x == 0 && !empty($this->params[\"use_header\"])) $headerinfo = $lineInfo;\n }",
" $colNames = array(\n \"none\" => gt('--Disregard this column--'),\n \"username\" => gt('Username'),\n \"password\" => gt('Password'),\n \"firstname\" => gt('First Name'),\n \"lastname\" => gt('Last Name'),\n \"email\" => gt('Email Address')\n );",
" //Check to see if the line got split, otherwise throw an error\n if ($lineInfo == null) {\n $this->params['_formError'] = sprintf(gt('This file does not appear to be delimited by \"%s\". <br />Please specify a different delimiter.<br /><br />'), $this->params[\"delimiter\"]);\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n } else {\n //Setup the meta data (hidden values)\n $form = new form();\n $form->meta(\"controller\", \"users\");\n $form->meta(\"action\", \"import_users_process\");\n $form->meta(\"rowstart\", $this->params[\"rowstart\"]);\n $form->meta(\"use_header\", $this->params[\"use_header\"]);\n $form->meta(\"filename\", $directory . \"/\" . $file->filename);\n $form->meta(\"delimiter\", $this->params[\"delimiter\"]);\n for ($i = 0, $iMax = count($lineInfo); $i < $iMax; $i++) {\n if ($headerinfo != null) {\n $title = $headerinfo[$i] . ' (' . $lineInfo[$i] .')';\n if (array_key_exists($headerinfo[$i], $colNames)) {\n $default = $headerinfo[$i];\n } else {\n $default = \"none\";\n }\n } else {\n $title = $lineInfo[$i];\n $default = \"none\";\n }\n $form->register(\"column[$i]\", $title, new dropdowncontrol($default, $colNames));\n }\n $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n \"form_html\" => $form->tohtml(),\n ));\n }\n }",
" public function import_users_process() {\n if (in_array(\"username\", $this->params[\"column\"]) == false) {\n $unameOptions = array(\n \"FILN\" => gt('First Initial / Last Name'),\n \"FILNNUM\" => gt('First Initial / Last Name / Random Number'),\n \"EMAIL\" => gt('Email Address'),\n \"FNLN\" => gt('First Name / Last Name'));\n } else {\n $unameOptions = array(\"INFILE\" => gt('Username Specified in CSV File'));\n }",
" if (in_array(\"password\", $this->params[\"column\"]) == false) {\n $pwordOptions = array(\n \"RAND\" => gt('Generate Random Passwords'),\n \"DEFPASS\" => gt('Use the Default Password Supplied Below'));\n } else {\n $pwordOptions = array(\"INFILE\" => gt('Password Specified in CSV File'));\n }\n if (count($pwordOptions) == 1) {\n $disabled = true;\n } else {\n $disabled = false;\n }",
"// $form = new form();\n// $form->meta(\"controller\", \"users\");\n// $form->meta(\"action\", \"import_users_display\");\n// $form->meta(\"column\", $this->params[\"column\"]);\n// $form->meta(\"delimiter\", $this->params[\"delimiter\"]);\n// $form->meta(\"use_header\", $this->params[\"use_header\"]);\n// $form->meta(\"filename\", $this->params[\"filename\"]);\n// $form->meta(\"rowstart\", $this->params[\"rowstart\"]);\n//\n// $form->register(\"unameOptions\", gt('User Name Generations Options'), new dropdowncontrol(\"INFILE\", $unameOptions));\n// $form->register(\"pwordOptions\", gt('Password Generation Options'), new dropdowncontrol(\"defpass\", $pwordOptions));\n// $form->register(\"pwordText\", gt('Default Password'), new textcontrol(\"\", 10, $disabled));\n// $form->register(\"update\", gt('Update users already in database, instead of creating new user?'), new checkboxcontrol(0, 0));\n// $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n// \"form_html\" => $form->tohtml(),\n 'uname_options' => $unameOptions,\n 'pword_options' => $pwordOptions,\n 'pword_disabled' => $disabled,\n 'params' => $this->params\n ));\n }",
" public function import_users_display() {\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $file = fopen(BASE . $this->params[\"filename\"], \"r\");\n $userinfo = array();\n $userarray = array();\n $usersdone = array();\n $linenum = 1;",
" while (($filedata = fgetcsv($file, 2000, $this->params[\"delimiter\"])) != false) {",
" if ($linenum >= $this->params[\"rowstart\"]) {\n $i = 0;",
" $userinfo['username'] = \"\";\n $userinfo['firstname'] = \"\";\n $userinfo['lastname'] = \"\";\n $userinfo['is_admin'] = 0;\n $userinfo['is_acting_admin'] = 0;\n// $userinfo['is_locked'] = 0;\n $userinfo['email'] = '';\n $userinfo['changed'] = \"\";",
" foreach ($filedata as $field) {\n if (!empty($this->params[\"column\"][$i]) && $this->params[\"column\"][$i] != \"none\") {\n $colname = $this->params[\"column\"][$i];\n $userinfo[$colname] = trim($field);\n } else {\n unset($this->params['column'][$i]);\n }\n $i++;\n }",
" switch ($this->params[\"unameOptions\"]) {\n case \"FILN\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname']{0} . $userinfo['lastname']));\n } else {\n $userinfo['username'] = \"\";\n// $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"FILNNUM\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname']{0} . $userinfo['lastname'] . mt_rand(100, 999)));\n } else {\n $userinfo['username'] = \"\";\n// $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"EMAIL\":\n if ($userinfo['email'] != \"\") {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['email']));\n } else {\n $userinfo['username'] = \"\";\n// $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"FNLN\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname'] . $userinfo['lastname']));\n } else {\n $userinfo['username'] = \"\";\n// $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"INFILE\":\n if ($userinfo['username'] != \"\") {\n $userinfo['username'] = str_replace(\" \", \"\", $userinfo['username']);\n } else {\n $userinfo['username'] = \"\";\n// $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n }",
" if ((!isset($userinfo['changed'])) || ($userinfo['changed'] != \"skipped\")) {\n// switch ($this->params[\"pwordOptions\"]) {\n// case \"RAND\":\n// $newpass = \"\";\n// for ($i = 0; $i < mt_rand(12, 20); $i++) {\n// $num = mt_rand(48, 122);\n// if (($num > 97 && $num < 122) || ($num > 65 && $num < 90) || ($num > 48 && $num < 57)) $newpass .= chr($num);\n// else $i--;\n// }\n// $userinfo['clearpassword'] = $newpass;\n// break;\n// case \"DEFPASS\":\n// $userinfo['clearpassword'] = str_replace(\" \", \"\", trim($this->params[\"pwordText\"]));\n// break;\n// }\n//\n// $userinfo['password'] = user::encryptPassword($userinfo['clearpassword']);",
" $suffix = \"\";\n while (user::getUserByName($userinfo['username'] . $suffix) != null) { //username already exists\n if (!empty($this->params[\"update\"])) {\n if (in_array($userinfo['username'], $usersdone)) {\n $suffix = '-rand-' . mt_rand(100, 999);\n } else {\n $tmp = user::getUserByName($userinfo['username'] . $suffix);\n $userinfo['id'] = $tmp->id;\n $userinfo['changed'] = 1;\n break;\n }\n } else {\n $suffix = '-rand-' . mt_rand(100, 999);\n }\n }",
" $userinfo['username'] = $userinfo['username'] . $suffix;\n $userinfo['linenum'] = $linenum;\n $userarray[] = $userinfo;\n $usersdone[] = $userinfo['username'];\n } else {\n $userinfo['linenum'] = $linenum;\n $userarray[] = $userinfo;\n }\n }\n $linenum++;\n }\n assign_to_template(array(\n \"userarray\" => $userarray,\n \"params\" => $this->params,\n ));\n }",
" public function import_users_add() {",
"",
" $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $file = fopen(BASE . $this->params[\"filename\"], \"r\");\n $userinfo = array();\n $userarray = array();\n $usersdone = array();\n $linenum = 1;",
" while (($filedata = fgetcsv($file, 2000, $this->params[\"delimiter\"])) != false) {",
" if ($linenum >= $this->params[\"rowstart\"] && in_array($linenum,$this->params['importuser'])) {\n $i = 0;",
" $userinfo['username'] = \"\";\n $userinfo['firstname'] = \"\";\n $userinfo['lastname'] = \"\";\n $userinfo['is_admin'] = 0;\n $userinfo['is_acting_admin'] = 0;\n// $userinfo['is_locked'] = 0;\n $userinfo['email'] = '';\n $userinfo['changed'] = \"\";",
" foreach ($filedata as $field) {\n if ($this->params[\"column\"][$i] != \"none\") {\n $colname = $this->params[\"column\"][$i];\n $userinfo[$colname] = trim($field);\n }\n $i++;\n }",
" switch ($this->params[\"unameOptions\"]) {\n case \"FILN\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname']{0} . $userinfo['lastname']));\n } else {\n $userinfo['username'] = \"\";\n $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"FILNNUM\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname']{0} . $userinfo['lastname'] . mt_rand(100, 999)));\n } else {\n $userinfo['username'] = \"\";\n $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"EMAIL\":\n if ($userinfo['email'] != \"\") {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['email']));\n } else {\n $userinfo['username'] = \"\";\n $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"FNLN\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname'] . $userinfo['lastname']));\n } else {\n $userinfo['username'] = \"\";\n $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"INFILE\":\n if ($userinfo['username'] != \"\") {\n $userinfo['username'] = str_replace(\" \", \"\", $userinfo['username']);\n } else {\n $userinfo['username'] = \"\";\n $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n }",
" if ((!isset($userinfo['changed'])) || ($userinfo['changed'] != \"skipped\")) {\n switch ($this->params[\"pwordOptions\"]) {\n case \"RAND\":\n $newpass = \"\";\n for ($i = 0, $iMax = mt_rand(12, 20); $i < $iMax; $i++) {\n $num = mt_rand(48, 122);\n if (($num > 97 && $num < 122) || ($num > 65 && $num < 90) || ($num > 48 && $num < 57)) $newpass .= chr($num);\n else $i--;\n }\n $userinfo['clearpassword'] = $newpass;\n break;\n case \"DEFPASS\":\n $userinfo['clearpassword'] = str_replace(\" \", \"\", trim($this->params[\"pwordText\"]));\n break;\n }",
" $userinfo['password'] = user::encryptPassword($userinfo['clearpassword']);",
" $suffix = \"\";\n while (user::getUserByName($userinfo['username'] . $suffix) != null) { //username already exists\n if (!empty($this->params[\"update\"])) {\n if (in_array($userinfo['username'], $usersdone)) { // username exists because we already created it\n $suffix = mt_rand(100, 999);\n } else {\n $tmp = user::getUserByName($userinfo['username'] . $suffix);\n $userinfo['id'] = $tmp->id;\n $userinfo['changed'] = 1;\n break;\n }\n } else {\n $suffix = mt_rand(100, 999);\n }\n }",
" $userinfo['username'] = $userinfo['username'] . $suffix;\n $newuser = new user($userinfo);\n $newuser->update();\n $userinfo['linenum'] = $linenum;\n $userarray[] = $userinfo;\n $usersdone[] = $userinfo['username'];\n if (USER_REGISTRATION_SEND_WELCOME && $this->params['sendemail'] && !empty($newuser->email)) {\n $msg = $newuser->firstname . \", \\n\\n\";\n $msg .= sprintf(USER_REGISTRATION_WELCOME_MSG, $newuser->firstname, $newuser->lastname, $newuser->username);\n $msg .= \"/n/nYour new password is: \".$userinfo['clearpassword'];\n $mail = new expMail();\n $mail->quickSend(array(\n 'text_message' => $msg,\n 'to' => array(trim($newuser->email) => trim(user::getUserAttribution($newuser->id))),\n 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),\n 'subject' => USER_REGISTRATION_WELCOME_SUBJECT,\n ));\n }\n } else {\n $userinfo['linenum'] = $linenum;\n $userarray[] = $userinfo;\n }\n }\n $linenum++;\n }\n fclose($file);\n ini_set('auto_detect_line_endings',$line_end);\n assign_to_template(array(\n \"userarray\" => $userarray,\n ));\n unlink(BASE . $this->params[\"filename\"]);\n }",
" public function sync_LDAPUsers() {\n if (USE_LDAP == 1 && function_exists('ldap_connect')) {\n $ldap = new expLDAP();\n $updated = $ldap->syncLDAPUsers();\n $ldap->close();\n flash('message', $updated.' '.gt('LDAP Users Updated'));\n }\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * @subpackage Controllers\n * @package Modules\n */\n/** @define \"BASE\" \"../../../..\" */",
"class usersController extends expController {\n public $basemodel_name = 'user';",
"// protected $remove_permissions = array(\n// 'create',\n// 'edit'\n// );\n protected $manage_permissions = array(",
" 'toggle_extension' => 'Activate Extensions',\n 'kill_session' => 'End Sessions',\n 'boot_user' => 'Boot Users',\n 'userperms' => 'User Permissions',\n 'groupperms' => 'Group Permissions',\n 'import' => 'Import Users',\n 'export' => 'Export Users',",
" 'update' => 'Update Users',",
" );",
" static function displayname() {\n return gt(\"User Manager\");\n }",
" static function description() {\n return gt(\"This is the user management module. It allows for creating user, editing user, etc.\");\n }",
" static function hasSources() {\n return false;\n }",
" static function hasContent() {\n return false;\n }",
" static function canImportData() {\n return true;\n }",
" public function manage() {\n global $user;",
" expHistory::set('manageable', $this->params);\n// $limit = empty($this->config['limit']) ? 10 : $this->config['limit'];\n// $order = empty($this->config['order']) ? 'username' : $this->config['order'];\n if ($user->is_system_user == 1) {\n// $filter = 1; //'1';\n $where = '';\n } elseif ($user->isSuperAdmin()) {\n// $filter = 2; //\"is_system_user != 1\";\n $where = \"is_system_user != 1\";\n } else {\n// $filter = 3; //\"is_admin != 1\";\n $where = \"is_admin != 1\";\n }\n $page = new expPaginator(array(\n 'model'=>'user',\n 'where'=>$where,\n// 'limit'=>$limit,\n// 'order'=>$order,\n 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller'=>$this->baseclassname,\n 'action'=>$this->params['action'],\n 'columns'=>array(\n gt('Username')=>'username',\n gt('First Name')=>'firstname',\n gt('Last Name')=>'lastname',\n gt('Is Admin')=>'is_acting_admin',\n )\n ));",
" assign_to_template(array('page'=>$page));\n// assign_to_template(array(\n// 'filter' => $filter\n// ));\n }",
" public function create() {\n redirect_to(array('controller' => 'users', 'action' => 'edituser'));\n// $this->edituser();\n }",
" public function edituser() {\n global $user, $db;",
" // set history\n expHistory::set('editable', $this->params);\n expSession::set(\"userkey\", sha1(microtime()));\n expSession::clearCurrentUserSessionCache();",
" $id = !empty($this->params['id']) ? $this->params['id'] : null;",
" // check to see if we should be editing. You either need to be an admin, or editing own account.\n if ($user->isAdmin() || ($user->id == $id && !$user->globalPerm('prevent_profile_change'))) {\n $u = new user($id);\n if ($u->isSuperAdmin() && $user->isActingAdmin()) { // prevent regular admin's from editing super-admins\n flash('error', gt('You do not have the proper permissions to edit this user'));\n expHistory::back();\n }\n } else {\n flash('error', gt('You do not have the proper permissions to edit this user'));\n expHistory::back();\n }\n $active_extensions = $db->selectObjects('profileextension', 'active=1', 'rank');",
" //If there is no image uploaded, use the default avatar\n if (empty($u->image)) $u->image = PATH_RELATIVE . \"framework/modules/users/assets/images/avatar_not_found.jpg\";",
" assign_to_template(array(\n 'edit_user' => $u,\n 'extensions' => $active_extensions,\n \"userkey\" => expSession::get(\"userkey\")\n ));",
" if ($user->isAdmin()) {\n $page = new expPaginator(array(\n 'model' => 'group',\n 'where' => 1,\n 'limit' => (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10,\n 'order' => empty($this->config['order']) ? 'name' : $this->config['order'],\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Name') => 'name',\n gt('Description') => 'description',\n ),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n ));",
" assign_to_template(array(\n 'groups' => $page,\n 'mygroups' => $u->getGroupMemberships(),\n ));\n }\n }",
" public function update() {\n global $user, $db;",
" // get the id of user we are editing, if there is one\n $id = !empty($this->params['id']) ? $this->params['id'] : null;\n if ((($user->id == $id) || $user->isAdmin()) && $this->params['userkey'] != expSession::get(\"userkey\")) expHistory::back();",
" // make sure this user should be updating user accounts\n if (!$user->isLoggedIn() && SITE_ALLOW_REGISTRATION == 0) {\n flash('error', gt('This site does not allow user registrations'));\n expHistory::back();\n } elseif (!$user->isAdmin() && ($user->isLoggedIn() && $user->id != $id)) {\n flash('error', gt('You do not have permission to edit this user account'));\n expHistory::back();\n }\n",
" // if this is a new user account we need to check the password.",
" // the password fields wont come thru on an edit. Otherwise we will\n // just update the existing account.\n if (!empty($id)) {\n $u = new user($id);\n $u->update($this->params);\n if ($user->isAdmin() && $user->id != $id) {\n flash('message', gt('Account information for') . ' ' . $u->username . ' ' . gt('has been updated.'));\n } else {\n flash('message', gt('Thank you') . ' ' . $u->firstname . '. ' . gt('Your account information has been updated.'));\n }\n if ($user->id == $id) {\n $_SESSION[SYS_SESSION_KEY]['user'] = $u;\n $user = $u;\n }\n } else {\n $u = new user($this->params);\n $ret = $u->setPassword($this->params['pass1'], $this->params['pass2']);\n if ($ret != true) expValidator::failAndReturnToForm($ret, $this->params);\n $u->save();\n if ($user->isAdmin()) {\n flash('message', gt('Created new user account for') . ' ' . $u->username);\n } else {\n user::login($u->username, $this->params['pass1']);\n flash('message', gt('Thank you') . ' ' . $u->firstname . '. ' . gt('Your new account has been created.'));\n }\n }",
" // update the user profiles\n if (!empty($u->id)) {\n $this->params['user_id'] = $u->id;\n // get the active profile extensions and save them out\n $active_extensions = $db->selectObjects('profileextension', 'active=1');\n foreach ($active_extensions as $pe) {\n if (is_file(BASE . $pe->classfile)) {\n include_once(BASE . $pe->classfile);\n $ext = new $pe->classname();\n $db->delete($ext->tablename, 'user_id=' . $u->id);\n $ext->update($this->params);\n }\n }\n }",
" // update group membership assignment\n if (!empty($this->params['member'])) {\n $old_groups = $db->selectObjects('groupmembership', 'member_id=' . $u->id);\n// $db->delete('groupmembership', 'member_id=' . $u->id); // start from scratch\n $memb = new stdClass();\n $memb->member_id = $u->id;\n foreach ($this->params['member'] as $grp) {\n $memb->group_id = $grp;\n $memb->is_admin = false;\n foreach ($old_groups as $oldgroup) {\n if ($oldgroup->group_id == $grp) {\n if ($oldgroup->is_admin) $memb->is_admin = true; // retain group admin setting\n }\n }\n $db->insertObject($memb, 'groupmembership');\n }\n if ($u->id == $user->id) expSession::triggerRefresh();\n }\n",
" // if this is a new account then we will check to see if we need to send",
" // a welcome message or admin notification of new accounts.\n if (empty($id)) {\n // Calculate Group Memberships for newly created users. Any groups that\n // are marked as 'inclusive' automatically pick up new users. This is the part\n // of the code that goes out, finds those groups, and makes the new user a member\n // of them.\n $memb = new stdClass();\n $memb->member_id = $u->id;\n // Also need to process the groupcodes, for promotional signup\n// $code_where = '';\n// if (isset($this->params['groupcode']) && $this->params['groupcode'] != '') {\n// $code_where = \" OR code='\" . $this->params['groupcode'] . \"'\";\n// }\n // Add to default plus any groupcode groups\n// foreach ($db->selectObjects('group', 'inclusive=1' . $code_where) as $g) {\n foreach ($db->selectObjects('group', 'inclusive=1') as $g) {\n $memb->group_id = $g->id;\n $db->insertObject($memb, 'groupmembership');\n }",
" // if we added the user to any group than we need to reload their permissions\n// expPermissions::load($u); //FIXME why are we doing this? this loads the edited user perms over the current user???",
" //signup email stuff\n if (USER_REGISTRATION_SEND_WELCOME && !empty($u->email)) {\n $msg = $u->firstname . \", \\n\\n\";\n $msg .= sprintf(USER_REGISTRATION_WELCOME_MSG, $u->firstname, $u->lastname, $u->username);",
" $mail = new expMail();\n $mail->quickSend(array(\n 'text_message' => $msg,\n 'to' => array(trim($u->email) => trim(user::getUserAttribution($u->id))),\n 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),\n 'subject' => USER_REGISTRATION_WELCOME_SUBJECT,\n ));",
" flash('message', gt('A welcome email has been sent to') . ' ' . $u->email);\n }",
" // send and email notification to the admin of the site.\n if (USER_REGISTRATION_SEND_NOTIF && !$user->isAdmin()) {\n $msg = gt(\"When\") . \": \" . date(\"F j, Y, g:i a\") . \"\\n\\n\";\n $msg .= gt(\"Their name is\") . \": \" . $u->firstname . \" \" . $u->lastname . \"\\n\\n\";",
" $mail = new expMail();\n $mail->quickSend(array(\n 'text_message' => $msg,\n 'to' => trim(USER_REGISTRATION_ADMIN_EMAIL),\n 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),\n 'subject' => USER_REGISTRATION_NOTIF_SUBJECT,\n ));\n }\n }",
" // we need to reload our updated profile if we just edited our own account\n if ($id == $user->id) {\n $user->getUserProfile();\n// expPermissions::load($user); // not sure this is necessary since we can't add groups here\n }",
" expHistory::back();\n }",
" public function delete() {\n global $user, $db;\n if (!$user->isAdmin()) {\n flash('error', gt('You do not have permission to delete user accounts'));\n expHistory::back();\n }",
" if (empty($this->params['id'])) {\n flash('error', gt('No user selected.'));\n expHistory::back();\n }",
" // remove group memeberships\n $db->delete('groupmembership', 'member_id=' . $this->params['id']);",
" // remove user permissions\n $db->delete('userpermission', 'uid=' . $this->params['id']);",
" //remove user profiles\n $active_extensions = $db->selectObjects('profileextension', 'active=1');\n foreach ($active_extensions as $pe) {\n if (is_file(BASE . $pe->classfile)) {\n include_once(BASE . $pe->classfile);\n $ext = new $pe->classname();\n $db->delete($ext->table, 'user_id=' . $this->params['id']);\n }\n }",
" // remove user address\n $address = new address();\n $db->delete($address->table, 'user_id=' . $this->params['id']);",
" parent::delete();\n }",
" public function manage_sessions() {\n// global $db, $user;\n global $db;",
" expHistory::set('manageable', $this->params);",
" //cleans up any old sessions\n if (SESSION_TIMEOUT_ENABLE == true) {\n $db->delete('sessionticket', 'last_active < ' . (time() - SESSION_TIMEOUT));\n// } else {\n// $db->delete('sessionticket', '1');\n }",
" if (isset($this->params['id']) && $this->params['id'] == 0) {\n $sessions = $db->selectObjects('sessionticket', \"uid<>0\");\n $filtered = 1;\n } else {\n $sessions = $db->selectObjects('sessionticket');\n $filtered = 0;\n }",
"//\t $sessions = $db->selectObjects('sessionticket');\n for ($i = 0, $iMax = count($sessions); $i < $iMax; $i++) {\n $sessions[$i]->user = new user($sessions[$i]->uid);\n if ($sessions[$i]->uid == 0) {\n $sessions[$i]->user->id = 0;\n }\n $sessions[$i]->duration = expDateTime::duration($sessions[$i]->last_active, $sessions[$i]->start_time);\n }",
" assign_to_template(array(\n 'sessions' => $sessions,\n 'filter' => $filtered\n ));\n }",
" public function kill_session() {\n global $user, $db;\n $ticket = $db->selectObject('sessionticket', \"ticket='\" . preg_replace('/[^A-Za-z0-9.]/', '', $this->params['ticket']) . \"'\");\n if ($ticket) {\n $u = new user($ticket->uid);\n if ($user->isSuperAdmin() || ($user->isActingAdmin() && !$u->isAdmin())) {\n // We can only kick the user if they are A) not an acting admin, or\n // B) The current user is a super user and the kicked user is not.\n $db->delete('sessionticket', \"ticket='\" . $ticket->ticket . \"'\");\n }\n }\n expHistory::back();\n }",
" public function boot_user() {\n global $user, $db;\n if (!empty($this->params['id'])) {\n $u = new user($this->params['id']);\n if ($user->isSuperAdmin() || ($user->isActingAdmin() && !$u->isAdmin())) {\n // We can only kick the user if they are A) not an acting admin, or\n // B) The current user is a super user and the kicked user is not.\n $db->delete('sessionticket', 'uid=' . $u->id);\n }\n }\n expHistory::back();\n }",
" /**\n * This function scans two directories and searches for php files to add to the extensions database.\n * If you have added new extensions since the last time you have visited the page, it will add them to the database\n * in effect enabling your new extension to be tacked onto users profiles. You then have to enable it in the menu, but at least\n * now it is in the system and when the user goes to edit his profile, it will check for extensions and this one will be in!\n *\n * @global string This function uses the global $db save information through the Exponenet database connection.\n */\n public function manage_extensions() {\n global $db;",
" // set history\n expHistory::set('manageable', $this->params);",
" // Lets find all the user profiles availabe and then see if they are\n // in the database yet. If not we will add them.\n $ext_dirs = array(\n 'framework/modules/users/extensions',\n 'themes/' . DISPLAY_THEME . '/modules/users/extensions'\n );\n foreach ($ext_dirs as $dir) {\n if (is_readable(BASE . $dir)) {\n $dh = opendir(BASE . $dir);\n while (($file = readdir($dh)) !== false) {\n if (is_file(BASE . \"$dir/$file\") && is_readable(BASE . \"$dir/$file\") && substr($file, 0, 1) != '_' && substr($file, 0, 1) != '.') {\n include_once(BASE . \"$dir/$file\");\n $classname = substr($file, 0, -4);\n $class = new $classname();\n $extension = $db->selectObject('profileextension', \"title='\" . $class->name() . \"'\");\n if (empty($extension->id)) {\n $pe = new profileextension();\n $pe->title = $class->name();\n $pe->body = $class->description();\n $pe->classfile = \"$dir/$file\";\n $pe->classname = $classname;\n $pe->save();\n }\n }\n }\n }\n }",
" $page = new expPaginator(array(\n 'model' => 'profileextension',\n 'where' => 1,\n 'limit' => 25,\n 'order' => 'title',\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Name') => 'title',\n gt('Description') => 'body',\n gt('Active') => 'active'\n ),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n ));",
" assign_to_template(array(\n 'page' => $page\n ));\n }",
" public function manage_groups() {\n expHistory::set('manageable', $this->params);\n $page = new expPaginator(array(\n 'model' => 'group',\n 'where' => 1,\n// 'limit' => (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10,\n 'order' => empty($this->config['order']) ? 'name' : $this->config['order'],\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Name') => 'name',\n gt('Description') => 'description',\n gt('Type') => 'inclusive',\n ),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n ));",
" foreach ($page->records as $key=>$group) {\n $page->records[$key]->members = group::getUsersInGroup($group->id);\n }",
" assign_to_template(array(\n 'page' => $page,\n ));\n }",
" public function reset_password() {\n expHistory::set('editable', $this->params);\n }",
" public function send_new_password() {\n global $db;",
" // find the user",
" $this->params['username'] = expString::escape($this->params['username']);",
" $u = user::getUserByName($this->params['username']);\n if (empty($u)) {\n $u = user::getUserByEmail($this->params['username']);\n if (!empty($u) && $u->count > 1) {\n expValidator::failAndReturnToForm(gt('That email address applies to more than one user account, please enter your username instead.'));\n }\n }\n $u = new user($u->id);",
" if (!expValidator::check_antispam($this->params)) {\n expValidator::failAndReturnToForm(gt('Anti-spam verification failed. Please try again.'), $this->params);\n } elseif (empty($u->id)) {\n expValidator::failAndReturnToForm(gt('We were unable to find an account with that username/email'), $this->params);\n } elseif (empty($u->email)) {\n expValidator::failAndReturnToForm(gt('Your account does not appear to have an email address. Please contact the site administrators to reset your password'), $this->params);\n } elseif ($u->isAdmin()) {\n expValidator::failAndReturnToForm(gt('You cannot reset passwords for an administrator account.'), $this->params);\n }",
" $tok = new stdClass();\n $tok->uid = $u->id;\n $tok->expires = time() + 2 * 3600;\n $tok->token = md5(time()) . uniqid('');",
" $email = $template = expTemplate::get_template_for_action($this, 'email/password_reset_email', $this->loc);\n $email->assign('token', $tok);\n $email->assign('username', $u->username);\n $msg = $email->render();\n $mail = new expMail();\n $mail->quickSend(array(\n 'html_message' => $msg,\n 'to' => array(trim($u->email) => trim(user::getUserAttribution($u->id))),\n 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),\n 'subject' => gt('Password Reset Requested'),\n ));",
" $db->delete('passreset_token', 'uid=' . $u->id);\n $db->insertObject($tok, 'passreset_token');\n flash('message', gt('An email has been sent to you with instructions on how to finish resetting your password.') . '<br><br>' .\n gt('This new password request is only valid for 2 hours. If you have not completed the password reset process within 2 hours, the new password request will expire.'));",
" expHistory::back();\n }",
" public function confirm_password_reset() {\n global $db;",
" $db->delete('passreset_token', 'expires < ' . time());",
" $tok = $db->selectObject('passreset_token', 'uid=' . intval($this->params['uid']) . \" AND token='\" . preg_replace('/[^A-Za-z0-9]/', '', expString::escape($this->params['token'])) . \"'\");",
" if ($tok == null) {\n flash('error', gt('Your password reset request has expired. Please try again.'));\n expHistory::back();\n }",
" // create the password\n $newpass = '';\n for ($i = 0, $iMax = mt_rand(12, 20); $i < $iMax; $i++) {\n $num = mt_rand(48, 122);\n if (($num > 97 && $num < 122) || ($num > 65 && $num < 90) || ($num > 48 && $num < 57)) $newpass .= chr($num);\n else $i--;\n }",
" // look up the user\n $u = new user($tok->uid);",
" // get the email message body and render it\n $email = $template = expTemplate::get_template_for_action($this, 'email/confirm_password_email', $this->loc);\n $email->assign('newpass', $newpass);\n $email->assign('username', $u->username);\n $msg = $email->render();",
" // send the new password to the user\n $mail = new expMail();\n $mail->quickSend(array(\n 'html_message' => $msg,\n 'to' => array(trim($u->email) => trim(user::getUserAttribution($u->id))),\n 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),\n 'subject' => gt('The account password for') . ' ' . HOSTNAME . ' ' . gt('was reset'),\n ));",
" // Save new password\n $u->update(array('password' => user::encryptPassword($newpass)));",
" // cleanup the reset token\n $db->delete('passreset_token', 'uid=' . $tok->uid);",
" flash('message', gt('Your password has been reset and the new password has been emailed to you.'));",
" // send the user the login page.\n redirect_to(array('controller' => 'login', 'action' => 'loginredirect'));\n }",
" public function change_password() {\n global $user;",
" expHistory::set('editable', $this->params);\n $id = isset($this->params['id']) ? $this->params['id'] : $user->id;",
" if ($user->isAdmin() || ($user->id == $id)) {\n $isuser = ($user->id == $id) ? 1 : 0;\n $u = new user($id);\n } else {\n flash('error', gt('You do not have the proper permissions to do that'));\n expHistory::back();\n }\n assign_to_template(array(\n 'u' => $u,\n 'isuser' => $isuser\n ));\n }",
" public function save_change_password() {\n global $user;",
" $isuser = ($this->params['uid'] == $user->id) ? 1 : 0;",
" if (!$user->isAdmin() && !$isuser) {\n flash('error', gt('You do not have permissions to change this users password.'));\n expHistory::back();\n }",
" if (($isuser && empty($this->params['password'])) || (!empty($this->params['password']) && $user->password != user::encryptPassword($this->params['password']))) {\n flash('error', gt('The current password you entered is not correct.'));\n expHistory::returnTo('editable');\n }\n //eDebug($user);",
" $u = new user(intval($this->params['uid']));",
"\n $ret = $u->setPassword($this->params['new_password1'], $this->params['new_password2']);\n //eDebug($u, true);\n if (is_string($ret)) {\n flash('error', $ret);\n expHistory::returnTo('editable');\n } else {\n $params = array();\n $params['is_admin'] = !empty($u->is_admin);\n $params['is_acting_admin'] = !empty($u->is_acting_admin);\n $u->update($params);\n }",
" if (!$isuser) {\n flash('message', gt('The password for') . ' ' . $u->username . ' ' . gt('has been changed.'));\n } else {\n $user->password = $u->password;\n flash('message', gt('Your password has been changed.'));\n }\n expHistory::back();\n }",
" public function edit_userpassword() {\n expHistory::set('editable', $this->params);\n if (empty($this->params['id'])) {\n flash('error', gt('You must specify the user whose password you want to change'));\n expHistory::back();\n }",
" $u = new user($this->params['id']);\n assign_to_template(array(\n 'u' => $u\n ));\n }",
" public function update_userpassword() {",
" global $user;",
" if (!$user->isAdmin() && $this->params['id'] != $user->id) {\n flash('error', gt('You do not have permissions to change this users password.'));\n expHistory::back();\n }\n",
" if (empty($this->params['id'])) {\n expValidator::failAndReturnToForm(gt('You must specify the user whose password you want to change'), $this->params);\n }",
" if (empty($this->params['new_password1'])) {\n expValidator::setErrorField('new_password1');\n expValidator::failAndReturnToForm(gt('You must specify a new password for this user.'), $this->params);\n }",
" if (empty($this->params['new_password2'])) {\n expValidator::setErrorField('new_password2');\n expValidator::failAndReturnToForm(gt('You must confirm the password.'), $this->params);",
" }",
" $u = new user($this->params['id']);\n $ret = $u->setPassword($this->params['new_password1'], $this->params['new_password2']);\n if (is_string($ret)) {\n expValidator::setErrorField('new_password1');\n $this->params['new_password1'] = '';\n $this->params['new_password2'] = '';\n expValidator::failAndReturnToForm($ret, $this->params);\n } else {\n $u->save(true);\n }",
" flash('message', gt('Password reset for user') . ' ' . $u->username);\n expHistory::back();\n }",
" public function edit_group() {\n global $db;",
" expHistory::set('editable', $this->params);\n $id = isset($this->params['id']) ? $this->params['id'] : null;\n $group = new group($id);\n $group->redirect = $db->selectValue('section', 'id', \"sef_name='\" . $group->redirect . \"'\");\n assign_to_template(array(\n 'record' => $group\n ));\n }",
" public function manage_group_memberships() {\n global $db, $user;\n// expHistory::set('manageable', $this->params);",
" $memb = $db->selectObject('groupmembership', 'member_id=' . $user->id . ' AND group_id=' . $this->params['id'] . ' AND is_admin=1');",
" $perm_level = 0;\n if ($memb) $perm_level = 1;\n if (expPermissions::check('user_management', expCore::makeLocation('administrationmodule'))) $perm_level = 2;",
" $group = $db->selectObject('group', 'id=' . $this->params['id']);\n $users = user::getAllUsers(0);",
" $members = array();\n $admins = array();\n foreach ($db->selectObjects('groupmembership', 'group_id=' . $group->id) as $m) {\n $members[] = $m->member_id;\n if ($m->is_admin == 1) {\n $admins[] = $m->member_id;\n }\n }",
" for ($i = 0, $iMax = count($users); $i < $iMax; $i++) {\n if (in_array($users[$i]->id, $members)) {\n $users[$i]->is_member = 1;\n } else {\n $users[$i]->is_member = 0;\n }",
" if (in_array($users[$i]->id, $admins)) {\n $users[$i]->is_admin = 1;\n } else {\n $users[$i]->is_admin = 0;\n }\n }",
" //$limit = empty($this->config['limit']) ? 10 : $this->config['limit'];\n $page = new expPaginator(array(\n// 'model'=>'user',\n 'records' => $users,\n 'where' => 1,\n// 'limit'=>9999, // unless we're showing all users on a page at once, there's no way to\n // add all users to a group, since it's rebuilding the group on save...\n 'order' => empty($this->config['order']) ? 'username' : $this->config['order'],\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Username') => 'username',\n gt('First Name') => 'firstname',\n gt('Last Name') => 'lastname',\n gt('Is Member') => 'is_member',\n gt('Is Admin') => 'is_admin',\n ),\n 'controller' => $this->baseclassname,\n 'action' => $this->params['action'],\n ));",
" assign_to_template(array(\n 'page' => $page,\n 'group' => $group,\n 'users' => $users,\n 'canAdd' => (count($members) < count($users) ? 1 : 0),\n 'hasMember' => (count($members) > 0 ? 1 : 0),\n 'perm_level' => $perm_level,\n ));\n }",
" public function update_group() {\n global $db;",
" $group = new group();\n if (!empty($this->params['redirect'])) {\n $this->params['redirect'] = $db->selectValue('section', 'sef_name', 'id=' . $this->params['redirect']);\n }\n $group->update($this->params);\n expHistory::back();\n }",
" public function delete_group() {\n global $user, $db;\n if (!$user->isAdmin()) {\n flash('error', gt('You do not have permission to delete user groups'));\n expHistory::back();\n }",
" if (empty($this->params['id'])) {\n flash('error', gt('No group selected.'));\n expHistory::back();\n }",
" // remove group members\n $db->delete('groupmembership', 'group_id=' . $this->params['id']);",
" // remove group permissions\n $db->delete('grouppermission', 'gid=' . $this->params['id']);",
" // remove group\n $db->delete('group', 'id=' . $this->params['id']);\n expHistory::back();\n }",
" public function toggle_extension() {\n global $db;\n if (isset($this->params['id'])) $db->toggle('profileextension', 'active', 'id=' . $this->params['id']);\n expHistory::back();\n }",
" public function update_memberships() {\n// global $user, $db;\n global $db;",
" //$memb = $db->selectObject('groupmembership','member_id='.$user->id.' AND group_id='.$this->params['id'].' AND is_admin=1');\n $group = $db->selectObject('group', 'id=' . $this->params['id']);",
" $db->delete('groupmembership', 'group_id=' . $group->id);\n $memb = new stdClass();\n $memb->group_id = $group->id;\n if ($this->params['memdata'] != \"\") {\n foreach ($this->params['memdata'] as $u => $str) {\n $memb->member_id = $u;\n $memb->is_admin = $str['is_admin'];\n $db->insertObject($memb, 'groupmembership');\n }\n }\n expSession::triggerRefresh();\n expHistory::back();\n }",
" public function getUsersByJSON() {\n $modelname = $this->basemodel_name;\n $results = 25; // default get 25\n $startIndex = 0; // default start at 0\n $sort = null; // default don't sort\n $dir = 'asc'; // default sort dir is asc\n $sort_dir = SORT_ASC;",
" // How many records to get?\n if (strlen($this->params['results']) > 0) {\n $results = $this->params['results'];\n }",
" // Start at which record?\n if (strlen($this->params['startIndex']) > 0) {\n $startIndex = $this->params['startIndex'];\n }",
" // Sorted?\n if (strlen($this->params['sort']) > 0) {\n $sort = $this->params['sort'];\n if ($sort = 'id') $sort = 'username';\n }",
" if (!empty($this->params['filter'])) {\n switch ($this->params['filter']) {\n case '1' :\n $filter = '';\n break;\n case '2' :\n $filter = \"is_system_user != 1\";\n break;\n case '3' :\n $filter = \"is_admin != 1\";\n }\n }",
"// if (!empty($_GET['filter'])) {\n// switch ($_GET['filter']) {\n// case '1' :\n// $filter = '';\n// break;\n// case '2' :\n// $filter = \"is_system_user != 1\";\n// break;\n// case '3' :\n// $filter = \"is_admin != 1\";\n// }\n// }",
" // Sort dir?\n if ((strlen($this->params['dir']) > 0) && ($this->params['dir'] == 'desc')) {\n $dir = 'desc';\n $sort_dir = SORT_DESC;\n } else {\n $dir = 'asc';\n $sort_dir = SORT_ASC;\n }",
" if (!empty($this->params['query'])) {",
"// $this->params['query'] = $this->params['query'];\n $totalrecords = $this->$modelname->find('count', (empty($filter) ? '' : $filter . \" AND \") . \"(username LIKE '%\" . $this->params['query'] . \"%' OR firstname LIKE '%\" . $this->params['query'] . \"%' OR lastname LIKE '%\" . $this->params['query'] . \"%' OR email LIKE '%\" . $this->params['query'] . \"%')\");",
" $users = $this->$modelname->find('all', (empty($filter) ? '' : $filter . \" AND \") . \"(username LIKE '%\" . $this->params['query'] . \"%' OR firstname LIKE '%\" . $this->params['query'] . \"%' OR lastname LIKE '%\" . $this->params['query'] . \"%' OR email LIKE '%\" . $this->params['query'] . \"%')\", $sort . ' ' . $dir, $results, $startIndex);",
" for ($i = 0, $iMax = count($users); $i < $iMax; $i++) {\n if (ECOM == 1) {\n $users[$i]->usernamelabel = \"<a href='viewuser/{$users[$i]->id}' class='fileinfo'>{$users[$i]->username}</a>\";\n } else {\n $users[$i]->usernamelabel = $users[$i]->username;\n }\n }",
" $returnValue = array(\n 'recordsReturned' => count($users),\n 'totalRecords' => $totalrecords,\n 'startIndex' => $startIndex,\n 'sort' => $sort,\n 'dir' => $dir,\n 'pageSize' => $results,\n 'records' => $users\n );\n } else {",
" $totalrecords = $this->$modelname->find('count', $filter);",
" $users = $this->$modelname->find('all', $filter, $sort . ' ' . $dir, $results, $startIndex);",
" for ($i = 0, $iMax = count($users); $i < $iMax; $i++) {\n if (ECOM == 1) {\n $users[$i]->usernamelabel = \"<a href='viewuser/{$users[$i]->id}' class='fileinfo'>{$users[$i]->username}</a>\";\n } else {\n $users[$i]->usernamelabel = $users[$i]->username;\n }\n }",
" $returnValue = array(\n 'recordsReturned' => count($users),\n 'totalRecords' => $totalrecords,\n 'startIndex' => $startIndex,\n 'sort' => $sort,\n 'dir' => $dir,\n 'pageSize' => $results,\n 'records' => $users\n );",
" }",
" echo json_encode($returnValue);\n }",
" public function viewuser() {\n global $user;",
" if (!empty($this->params['id'])) {\n $u = new user($this->params['id']);\n } elseif (!empty($user->id)) {\n $u = $user;\n } else {\n flash('error', gt('You may not view this user'));\n expHistory::back();\n }\n $address = new address();",
" $billings = $address->find('all', 'user_id=' . $u->id . ' AND is_billing = 1');\n $shippings = $address->find('all', 'user_id=' . $u->id . ' AND is_shipping = 1');",
" // build out a SQL query that gets all the data we need and is sortable.\n $sql = 'SELECT o.*, b.firstname as firstname, b.billing_cost as total, b.middlename as middlename, b.lastname as lastname, os.title as status, ot.title as order_type ';\n $sql .= 'FROM ' . DB_TABLE_PREFIX . '_orders o, ' . DB_TABLE_PREFIX . '_billingmethods b, ';\n $sql .= DB_TABLE_PREFIX . '_order_status os, ';\n $sql .= DB_TABLE_PREFIX . '_order_type ot ';\n $sql .= 'WHERE o.id = b.orders_id AND o.order_status_id = os.id AND o.order_type_id = ot.id AND o.purchased > 0 AND user_id =' . $u->id;",
" $limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;\n $order = !empty($this->params['order']) ? $this->params['order'] : 'purchased';\n $dir = !empty($this->params['dir']) ? $this->params['dir'] : 'DESC';\n //eDebug($sql, true);\n $orders = new expPaginator(array(\n //'model'=>'order',\n 'sql' => $sql,\n 'limit' => $limit,\n 'order' => $order,\n 'dir' => $dir,\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'columns' => array(\n gt('Order #') => 'invoice_id',\n gt('Total') => 'total',\n gt('Date Purchased') => 'purchased',\n// gt('Type') => 'order_type_id',\n gt('Status') => 'order_status_id',\n gt('Ref') => 'orig_referrer',\n ),\n 'controller' => $this->params['controller'],\n 'action' => $this->params['action'],\n ));",
" assign_to_template(array(\n 'u' => $u,\n 'billings' => $billings,\n 'shippings' => $shippings,\n 'orders' => $orders,\n ));\n }",
" public function userperms() {\n global $user;",
" if (!empty($this->params['mod']) && $user->isAdmin()) {\n $loc = expCore::makeLocation($this->params['mod'], isset($this->params['src']) ? $this->params['src'] : null, isset($this->params['int']) ? $this->params['int'] : null);\n $users = array();\n $modclass = expModules::getModuleClassName(($loc->mod));\n $mod = new $modclass();\n $perms = $mod->permissions($loc->int);\n $have_users = 0;\n foreach (user::getAllUsers(false) as $u) {\n $have_users = 1;\n foreach ($perms as $perm => $name) {\n// \t\t\t$var = 'perms_'.$perm;\n if (expPermissions::checkUser($u, $perm, $loc, true)) {\n $u->$perm = 1;\n } else if (expPermissions::checkUser($u, $perm, $loc)) {\n $u->$perm = 2;\n } else {\n $u->$perm = 0;\n }\n }\n $users[] = $u;\n }",
" $p[gt(\"User Name\")] = 'username';\n $p[gt(\"First Name\")] = 'firstname';\n $p[gt(\"Last Name\")] = 'lastname';\n foreach ($mod->permissions() as $value) {\n // $p[gt($value)]=$key;\n $p[gt($value)] = 'no-sort';\n }",
"// if (SEF_URLS == 1) {\n $page = new expPaginator(array(\n //'model'=>'user',\n// 'limit' => (isset($this->params['limit']) ? $this->params['limit'] : 20),\n 'records' => $users,\n //'sql'=>$sql,\n 'order' => (isset($this->params['order']) ? $this->params['order'] : 'username'),\n 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'ASC'),\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->params['controller'],\n 'action' => $this->params['action'],\n 'columns' => $p,\n ));\n// } else {\n// $page = new expPaginator(array(\n// //'model'=>'user',\n//// 'limit' => (isset($this->params['limit']) ? $this->params['limit'] : 20),\n// 'records' => $users,\n// //'sql'=>$sql,\n// 'order' => (isset($this->params['order']) ? $this->params['order'] : 'username'),\n// 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'ASC'),\n// 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n// 'controller' => $this->params['module'],\n// 'action' => $this->params['action'],\n// 'columns' => $p,\n// ));\n// }",
" assign_to_template(array(\n 'user_form' => 1,\n 'have_users' => $have_users,\n 'users' => $users,\n 'page' => $page,\n 'perms' => $perms,\n 'loc' => $loc,\n// 'title'=>($modclass != 'navigationController' || ($modclass == 'navigationController' && !empty($loc->src))) ? $mod->name().' '.($modclass != 'containermodule' ? gt('module') : '').' ' : gt('Page'),\n 'title' => ($loc->mod != 'navigation' || ($loc->mod == 'navigation' && !empty($loc->src))) ? $mod->name() . ' ' . ($loc->mod != 'container' ? gt('module') : '') . ' ' : gt('Page'),\n ));\n } else {\n// echo SITE_403_HTML;\n notfoundController::handle_not_authorized();\n }\n }",
" public function userperms_save() {\n global $user;",
" $loc = expCore::makeLocation($this->params['mod'], isset($this->params['src']) ? $this->params['src'] : null, isset($this->params['int']) ? $this->params['int'] : null);\n foreach ($this->params['users'] as $u) {\n expPermissions::revokeAll($u, $loc);\n }\n foreach ($this->params['permdata'] as $k => $user_str) {\n $perms = array_keys($user_str);\n $u = user::getUserById($k);\n for ($i = 0, $iMax = count($perms); $i < $iMax; $i++) {\n expPermissions::grant($u, $perms[$i], $loc);\n }",
" if ($k == $user->id) {\n expPermissions::load($user);\n }\n }\n expSession::triggerRefresh();\n expHistory::back();\n }",
" public function groupperms() {\n global $user;",
" if (!empty($this->params['mod']) && $user->isAdmin()) {\n $loc = expCore::makeLocation($this->params['mod'], isset($this->params['src']) ? $this->params['src'] : null, isset($this->params['int']) ? $this->params['int'] : null);\n $users = array(); // users = groups\n $modclass = expModules::getModuleClassName($loc->mod);\n $mod = new $modclass();\n $perms = $mod->permissions($loc->int);",
" foreach (group::getAllGroups() as $g) {\n foreach ($perms as $perm => $name) {\n// \t\t\t$var = 'perms_'.$perm;\n if (expPermissions::checkGroup($g, $perm, $loc, true)) {\n $g->$perm = 1;\n } else if (expPermissions::checkGroup($g, $perm, $loc)) {\n $g->$perm = 2;\n } else {\n $g->$perm = 0;\n }\n }\n $users[] = $g;\n }",
" $p[gt(\"Group\")] = 'username';\n foreach ($mod->permissions() as $value) {\n // $p[gt($value)]=$key;\n $p[gt($value)] = 'no-sort';\n }",
"// if (SEF_URLS == 1) {\n $page = new expPaginator(array(\n //'model'=>'user',\n// 'limit' => (isset($this->params['limit']) ? $this->params['limit'] : 20),\n 'records' => $users,\n //'sql'=>$sql,\n 'order' => (isset($this->params['order']) ? $this->params['order'] : 'name'),\n 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'ASC'),\n 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n 'controller' => $this->params['controller'],\n 'action' => $this->params['action'],\n 'columns' => $p,\n ));\n// } else {\n// $page = new expPaginator(array(\n// //'model'=>'user',\n//// 'limit' => (isset($this->params['limit']) ? $this->params['limit'] : 20),\n// 'records' => $users,\n// //'sql'=>$sql,\n// 'order' => (isset($this->params['order']) ? $this->params['order'] : 'name'),\n// 'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'ASC'),\n// 'page' => (isset($this->params['page']) ? $this->params['page'] : 1),\n// 'controller' => $this->params['module'],\n// 'action' => $this->params['action'],\n// 'columns' => $p,\n// ));\n// }",
" assign_to_template(array(\n 'user_form' => 0,\n 'is_group' => 1,\n 'have_users' => count($users) > 0, // users = groups\n 'users' => $users,\n 'page' => $page,\n 'perms' => $perms,\n 'loc' => $loc,\n// 'title'=>($modclass != 'navigationController' || ($modclass == 'navigationController' && !empty($loc->src))) ? $mod->name().' '.($modclass != 'containermodule' ? gt('module') : '').' ' : gt('Page'),\n 'title' => ($loc->mod != 'navigation' || ($loc->mod == 'navigation' && !empty($loc->src))) ? $mod->name() . ' ' . ($loc->mod != 'container' ? gt('module') : '') . ' ' : gt('Page'),\n ));\n } else {\n// echo SITE_403_HTML;\n notfoundController::handle_not_authorized();\n }\n }",
" public function groupperms_save() {\n $loc = expCore::makeLocation($this->params['mod'], isset($this->params['src']) ? $this->params['src'] : null, isset($this->params['int']) ? $this->params['int'] : null);\n foreach ($this->params['users'] as $g) {\n expPermissions::revokeAllGroup($g, $loc);\n }\n foreach ($this->params['permdata'] as $k => $group_str) {\n $perms = array_keys($group_str);\n $g = group::getGroupById($k);\n for ($i = 0, $iMax = count($perms); $i < $iMax; $i++) {\n expPermissions::grantGroup($g, $perms[$i], $loc);\n }\n }\n expSession::triggerRefresh();\n expHistory::back();\n }",
" public function import() {\n if (expFile::canCreate(BASE . \"tmp/test\") != SYS_FILES_SUCCESS) {\n assign_to_template(array(\n \"error\" => \"The /tmp directory is not writable. Please contact your administrator.\",\n ));\n } else {\n //Setup the arrays with the name/value pairs for the dropdown menus\n $delimiterArray = Array(\n ',' => gt('Comma'),\n ';' => gt('Semicolon'),\n ':' => gt('Colon'),\n ' ' => gt('Space'));",
"// //Setup the mete data (hidden values)\n// $form = new form();\n// $form->meta(\"controller\", \"users\");\n// $form->meta(\"action\", \"import_users_mapper\");\n//\n// //Register the dropdown menus\n// $form->register(\"delimiter\", gt('Delimiter Character'), new dropdowncontrol(\",\", $delimiterArray));\n// $form->register(\"upload\", gt('CSV File to Upload'), new uploadcontrol());\n// $form->register(\"use_header\", gt('First Row is a Header'), new checkboxcontrol(0, 0));\n// $form->register(\"rowstart\", gt('User Data begins in Row'), new textcontrol(\"1\", 1, 0, 6));\n// $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n// \"form_html\" => $form->tohtml(),\n 'delimiters' => $delimiterArray,\n ));\n }\n }",
" public function import_users_mapper() {\n //Check to make sure the user filled out the required input.\n //FIXME needs to be the newer fail form\n if (!is_numeric($this->params[\"rowstart\"])) {\n unset($this->params[\"rowstart\"]);\n $this->params['_formError'] = gt('The starting row must be a number.');\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit('Redirecting...');\n }",
" //Get the temp directory to put the uploaded file\n $directory = \"tmp\";",
" //Get the file save it to the temp directory\n if ($_FILES[\"upload\"][\"error\"] == UPLOAD_ERR_OK) {\n //\t$file = file::update(\"upload\",$directory,null,time().\"_\".$_FILES['upload']['name']);\n $file = expFile::fileUpload(\"upload\", false, false, time() . \"_\" . $_FILES['upload']['name'], $directory.'/');\n if ($file == null) {\n switch ($_FILES[\"upload\"][\"error\"]) {\n case UPLOAD_ERR_INI_SIZE:\n case UPLOAD_ERR_FORM_SIZE:\n $this->params['_formError'] = gt('The file you attempted to upload is too large. Contact your system administrator if this is a problem.');\n break;\n case UPLOAD_ERR_PARTIAL:\n $this->params['_formError'] = gt('The file was only partially uploaded.');\n break;\n case UPLOAD_ERR_NO_FILE:\n $this->params['_formError'] = gt('No file was uploaded.');\n break;\n default:\n $this->params['_formError'] = gt('A strange internal error has occurred. Please contact the Exponent Developers.');\n break;\n }\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n }\n /*\n if (mime_content_type(BASE.$directory.\"/\".$file->filename) != \"text/plain\"){\n $this->params['_formError'] = \"File is not a delimited text file.\";\n expSession::set(\"last_POST\",$this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n }\n */",
" //split the line into its columns\n $headerinfo = null;\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $fh = fopen(BASE . $directory . \"/\" . $file->filename, \"r\");\n if (!empty($this->params[\"use_header\"])) $this->params[\"rowstart\"]++;\n for ($x = 0; $x < $this->params[\"rowstart\"]; $x++) {\n $lineInfo = fgetcsv($fh, 2000, $this->params[\"delimiter\"]);\n if ($x == 0 && !empty($this->params[\"use_header\"])) $headerinfo = $lineInfo;\n }",
" $colNames = array(\n \"none\" => gt('--Disregard this column--'),\n \"username\" => gt('Username'),\n \"password\" => gt('Password'),\n \"firstname\" => gt('First Name'),\n \"lastname\" => gt('Last Name'),\n \"email\" => gt('Email Address')\n );",
" //Check to see if the line got split, otherwise throw an error\n if ($lineInfo == null) {\n $this->params['_formError'] = sprintf(gt('This file does not appear to be delimited by \"%s\". <br />Please specify a different delimiter.<br /><br />'), $this->params[\"delimiter\"]);\n expSession::set(\"last_POST\", $this->params);\n header(\"Location: \" . $_SERVER['HTTP_REFERER']);\n exit(\"\");\n } else {\n //Setup the meta data (hidden values)\n $form = new form();\n $form->meta(\"controller\", \"users\");\n $form->meta(\"action\", \"import_users_process\");\n $form->meta(\"rowstart\", $this->params[\"rowstart\"]);\n $form->meta(\"use_header\", $this->params[\"use_header\"]);\n $form->meta(\"filename\", $directory . \"/\" . $file->filename);\n $form->meta(\"delimiter\", $this->params[\"delimiter\"]);\n for ($i = 0, $iMax = count($lineInfo); $i < $iMax; $i++) {\n if ($headerinfo != null) {\n $title = $headerinfo[$i] . ' (' . $lineInfo[$i] .')';\n if (array_key_exists($headerinfo[$i], $colNames)) {\n $default = $headerinfo[$i];\n } else {\n $default = \"none\";\n }\n } else {\n $title = $lineInfo[$i];\n $default = \"none\";\n }\n $form->register(\"column[$i]\", $title, new dropdowncontrol($default, $colNames));\n }\n $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n \"form_html\" => $form->tohtml(),\n ));\n }\n }",
" public function import_users_process() {\n if (in_array(\"username\", $this->params[\"column\"]) == false) {\n $unameOptions = array(\n \"FILN\" => gt('First Initial / Last Name'),\n \"FILNNUM\" => gt('First Initial / Last Name / Random Number'),\n \"EMAIL\" => gt('Email Address'),\n \"FNLN\" => gt('First Name / Last Name'));\n } else {\n $unameOptions = array(\"INFILE\" => gt('Username Specified in CSV File'));\n }",
" if (in_array(\"password\", $this->params[\"column\"]) == false) {\n $pwordOptions = array(\n \"RAND\" => gt('Generate Random Passwords'),\n \"DEFPASS\" => gt('Use the Default Password Supplied Below'));\n } else {\n $pwordOptions = array(\"INFILE\" => gt('Password Specified in CSV File'));\n }\n if (count($pwordOptions) == 1) {\n $disabled = true;\n } else {\n $disabled = false;\n }",
"// $form = new form();\n// $form->meta(\"controller\", \"users\");\n// $form->meta(\"action\", \"import_users_display\");\n// $form->meta(\"column\", $this->params[\"column\"]);\n// $form->meta(\"delimiter\", $this->params[\"delimiter\"]);\n// $form->meta(\"use_header\", $this->params[\"use_header\"]);\n// $form->meta(\"filename\", $this->params[\"filename\"]);\n// $form->meta(\"rowstart\", $this->params[\"rowstart\"]);\n//\n// $form->register(\"unameOptions\", gt('User Name Generations Options'), new dropdowncontrol(\"INFILE\", $unameOptions));\n// $form->register(\"pwordOptions\", gt('Password Generation Options'), new dropdowncontrol(\"defpass\", $pwordOptions));\n// $form->register(\"pwordText\", gt('Default Password'), new textcontrol(\"\", 10, $disabled));\n// $form->register(\"update\", gt('Update users already in database, instead of creating new user?'), new checkboxcontrol(0, 0));\n// $form->register(\"submit\", \"\", new buttongroupcontrol(gt('Next'), \"\", gt('Cancel')));",
" assign_to_template(array(\n// \"form_html\" => $form->tohtml(),\n 'uname_options' => $unameOptions,\n 'pword_options' => $pwordOptions,\n 'pword_disabled' => $disabled,\n 'params' => $this->params\n ));\n }",
" public function import_users_display() {\n $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $file = fopen(BASE . $this->params[\"filename\"], \"r\");\n $userinfo = array();\n $userarray = array();\n $usersdone = array();\n $linenum = 1;",
" while (($filedata = fgetcsv($file, 2000, $this->params[\"delimiter\"])) != false) {",
" if ($linenum >= $this->params[\"rowstart\"]) {\n $i = 0;",
" $userinfo['username'] = \"\";\n $userinfo['firstname'] = \"\";\n $userinfo['lastname'] = \"\";\n $userinfo['is_admin'] = 0;\n $userinfo['is_acting_admin'] = 0;\n// $userinfo['is_locked'] = 0;\n $userinfo['email'] = '';\n $userinfo['changed'] = \"\";",
" foreach ($filedata as $field) {\n if (!empty($this->params[\"column\"][$i]) && $this->params[\"column\"][$i] != \"none\") {\n $colname = $this->params[\"column\"][$i];\n $userinfo[$colname] = trim($field);\n } else {\n unset($this->params['column'][$i]);\n }\n $i++;\n }",
" switch ($this->params[\"unameOptions\"]) {\n case \"FILN\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname']{0} . $userinfo['lastname']));\n } else {\n $userinfo['username'] = \"\";\n// $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"FILNNUM\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname']{0} . $userinfo['lastname'] . mt_rand(100, 999)));\n } else {\n $userinfo['username'] = \"\";\n// $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"EMAIL\":\n if ($userinfo['email'] != \"\") {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['email']));\n } else {\n $userinfo['username'] = \"\";\n// $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"FNLN\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname'] . $userinfo['lastname']));\n } else {\n $userinfo['username'] = \"\";\n// $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"INFILE\":\n if ($userinfo['username'] != \"\") {\n $userinfo['username'] = str_replace(\" \", \"\", $userinfo['username']);\n } else {\n $userinfo['username'] = \"\";\n// $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n }",
" if ((!isset($userinfo['changed'])) || ($userinfo['changed'] != \"skipped\")) {\n// switch ($this->params[\"pwordOptions\"]) {\n// case \"RAND\":\n// $newpass = \"\";\n// for ($i = 0; $i < mt_rand(12, 20); $i++) {\n// $num = mt_rand(48, 122);\n// if (($num > 97 && $num < 122) || ($num > 65 && $num < 90) || ($num > 48 && $num < 57)) $newpass .= chr($num);\n// else $i--;\n// }\n// $userinfo['clearpassword'] = $newpass;\n// break;\n// case \"DEFPASS\":\n// $userinfo['clearpassword'] = str_replace(\" \", \"\", trim($this->params[\"pwordText\"]));\n// break;\n// }\n//\n// $userinfo['password'] = user::encryptPassword($userinfo['clearpassword']);",
" $suffix = \"\";\n while (user::getUserByName($userinfo['username'] . $suffix) != null) { //username already exists\n if (!empty($this->params[\"update\"])) {\n if (in_array($userinfo['username'], $usersdone)) {\n $suffix = '-rand-' . mt_rand(100, 999);\n } else {\n $tmp = user::getUserByName($userinfo['username'] . $suffix);\n $userinfo['id'] = $tmp->id;\n $userinfo['changed'] = 1;\n break;\n }\n } else {\n $suffix = '-rand-' . mt_rand(100, 999);\n }\n }",
" $userinfo['username'] = $userinfo['username'] . $suffix;\n $userinfo['linenum'] = $linenum;\n $userarray[] = $userinfo;\n $usersdone[] = $userinfo['username'];\n } else {\n $userinfo['linenum'] = $linenum;\n $userarray[] = $userinfo;\n }\n }\n $linenum++;\n }\n assign_to_template(array(\n \"userarray\" => $userarray,\n \"params\" => $this->params,\n ));\n }",
" public function import_users_add() {",
" if (!empty($this->params['filename']) && (strpos($this->params['filename'], 'tmp/') === false || strpos($this->params['folder'], '..') !== false)) {\n header('Location: ' . URL_FULL);\n exit(); // attempt to hack the site\n }",
" $line_end = ini_get('auto_detect_line_endings');\n ini_set('auto_detect_line_endings',TRUE);\n $file = fopen(BASE . $this->params[\"filename\"], \"r\");\n $userinfo = array();\n $userarray = array();\n $usersdone = array();\n $linenum = 1;",
" while (($filedata = fgetcsv($file, 2000, $this->params[\"delimiter\"])) != false) {",
" if ($linenum >= $this->params[\"rowstart\"] && in_array($linenum,$this->params['importuser'])) {\n $i = 0;",
" $userinfo['username'] = \"\";\n $userinfo['firstname'] = \"\";\n $userinfo['lastname'] = \"\";\n $userinfo['is_admin'] = 0;\n $userinfo['is_acting_admin'] = 0;\n// $userinfo['is_locked'] = 0;\n $userinfo['email'] = '';\n $userinfo['changed'] = \"\";",
" foreach ($filedata as $field) {\n if ($this->params[\"column\"][$i] != \"none\") {\n $colname = $this->params[\"column\"][$i];\n $userinfo[$colname] = trim($field);\n }\n $i++;\n }",
" switch ($this->params[\"unameOptions\"]) {\n case \"FILN\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname']{0} . $userinfo['lastname']));\n } else {\n $userinfo['username'] = \"\";\n $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"FILNNUM\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname']{0} . $userinfo['lastname'] . mt_rand(100, 999)));\n } else {\n $userinfo['username'] = \"\";\n $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"EMAIL\":\n if ($userinfo['email'] != \"\") {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['email']));\n } else {\n $userinfo['username'] = \"\";\n $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"FNLN\":\n if (($userinfo['firstname'] != \"\") && ($userinfo['lastname'] != \"\")) {\n $userinfo['username'] = str_replace(\" \", \"\", strtolower($userinfo['firstname'] . $userinfo['lastname']));\n } else {\n $userinfo['username'] = \"\";\n $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n case \"INFILE\":\n if ($userinfo['username'] != \"\") {\n $userinfo['username'] = str_replace(\" \", \"\", $userinfo['username']);\n } else {\n $userinfo['username'] = \"\";\n $userinfo['clearpassword'] = \"\";\n $userinfo['changed'] = \"skipped\";\n }\n break;\n }",
" if ((!isset($userinfo['changed'])) || ($userinfo['changed'] != \"skipped\")) {\n switch ($this->params[\"pwordOptions\"]) {\n case \"RAND\":\n $newpass = \"\";\n for ($i = 0, $iMax = mt_rand(12, 20); $i < $iMax; $i++) {\n $num = mt_rand(48, 122);\n if (($num > 97 && $num < 122) || ($num > 65 && $num < 90) || ($num > 48 && $num < 57)) $newpass .= chr($num);\n else $i--;\n }\n $userinfo['clearpassword'] = $newpass;\n break;\n case \"DEFPASS\":\n $userinfo['clearpassword'] = str_replace(\" \", \"\", trim($this->params[\"pwordText\"]));\n break;\n }",
" $userinfo['password'] = user::encryptPassword($userinfo['clearpassword']);",
" $suffix = \"\";\n while (user::getUserByName($userinfo['username'] . $suffix) != null) { //username already exists\n if (!empty($this->params[\"update\"])) {\n if (in_array($userinfo['username'], $usersdone)) { // username exists because we already created it\n $suffix = mt_rand(100, 999);\n } else {\n $tmp = user::getUserByName($userinfo['username'] . $suffix);\n $userinfo['id'] = $tmp->id;\n $userinfo['changed'] = 1;\n break;\n }\n } else {\n $suffix = mt_rand(100, 999);\n }\n }",
" $userinfo['username'] = $userinfo['username'] . $suffix;\n $newuser = new user($userinfo);\n $newuser->update();\n $userinfo['linenum'] = $linenum;\n $userarray[] = $userinfo;\n $usersdone[] = $userinfo['username'];\n if (USER_REGISTRATION_SEND_WELCOME && $this->params['sendemail'] && !empty($newuser->email)) {\n $msg = $newuser->firstname . \", \\n\\n\";\n $msg .= sprintf(USER_REGISTRATION_WELCOME_MSG, $newuser->firstname, $newuser->lastname, $newuser->username);\n $msg .= \"/n/nYour new password is: \".$userinfo['clearpassword'];\n $mail = new expMail();\n $mail->quickSend(array(\n 'text_message' => $msg,\n 'to' => array(trim($newuser->email) => trim(user::getUserAttribution($newuser->id))),\n 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),\n 'subject' => USER_REGISTRATION_WELCOME_SUBJECT,\n ));\n }\n } else {\n $userinfo['linenum'] = $linenum;\n $userarray[] = $userinfo;\n }\n }\n $linenum++;\n }\n fclose($file);\n ini_set('auto_detect_line_endings',$line_end);\n assign_to_template(array(\n \"userarray\" => $userarray,\n ));\n unlink(BASE . $this->params[\"filename\"]);\n }",
" public function sync_LDAPUsers() {\n if (USE_LDAP == 1 && function_exists('ldap_connect')) {\n $ldap = new expLDAP();\n $updated = $ldap->syncLDAPUsers();\n $ldap->close();\n flash('message', $updated.' '.gt('LDAP Users Updated'));\n }\n }",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1156, 821, 538, 1298, 1110, 656, 639, 481, 1974, 221, 1264, 168, 235, 25, 598, 133, 55, 383, 63, 58, 352, 125, 394, 59, 2152, 117, 137, 259, 537, 2235, 33, 72, 1773, 250, 679, 739, 285, 1941, 540, 62, 528, 25, 1290, 256, 199, 122, 41, 99, 2020, 355, 147, 129, 1499], "buggy_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 24, 31, 25, 27, 50, 27, 27, 25, 44, 26, 25, 29, 34, 25, 24, 24, 25, 25, 27, 26, 68, 1, 54, 26, 428, 41, 29, 44, 55, 24, 24, 1, 28, 30, 25, 29, 25, 25, 29, 146, 128, 27], "filenames": ["framework/core/controllers/expController.php", "framework/core/expFramework.php", "framework/core/models/expRecord.php", "framework/core/subsystems/database/mysqli.php", "framework/core/subsystems/expDatabase.php", "framework/core/subsystems/expPaginator.php", "framework/core/subsystems/expSettings.php", "framework/core/subsystems/expString.php", "framework/core/subsystems/expTheme.php", "framework/modules/addressbook/controllers/addressController.php", "framework/modules/administration/controllers/administrationController.php", "framework/modules/banners/controllers/bannerController.php", "framework/modules/blog/controllers/blogController.php", "framework/modules/core/controllers/expCatController.php", "framework/modules/core/controllers/expCommentController.php", "framework/modules/core/controllers/expDefinableFieldController.php", "framework/modules/core/controllers/expHTMLEditorController.php", "framework/modules/core/controllers/expSimpleNoteController.php", "framework/modules/core/controllers/expTagController.php", "framework/modules/eaas/controllers/eaasController.php", "framework/modules/ealerts/controllers/ealertController.php", "framework/modules/ecommerce/controllers/billingController.php", "framework/modules/ecommerce/controllers/ecomconfigController.php", "framework/modules/ecommerce/controllers/eventregistrationController.php", "framework/modules/ecommerce/controllers/orderController.php", "framework/modules/ecommerce/controllers/order_statusController.php", "framework/modules/ecommerce/controllers/purchaseOrderController.php", "framework/modules/ecommerce/controllers/shippingController.php", "framework/modules/ecommerce/controllers/storeCategoryController.php", "framework/modules/ecommerce/controllers/storeController.php", "framework/modules/ecommerce/controllers/taxController.php", "framework/modules/ecommerce/products/models/donation.php", "framework/modules/events/controllers/eventController.php", "framework/modules/events/models/event.php", "framework/modules/file/controllers/fileController.php", "framework/modules/file/models/expFile.php", "framework/modules/filedownloads/controllers/filedownloadController.php", "framework/modules/forms/controllers/formsController.php", "framework/modules/help/controllers/helpController.php", "framework/modules/help/models/help_version.php", "framework/modules/importexport/controllers/importexportController.php", "framework/modules/migration/controllers/migrationController.php", "framework/modules/navigation/controllers/navigationController.php", "framework/modules/news/controllers/newsController.php", "framework/modules/photoalbum/controllers/photosController.php", "framework/modules/pixidou/controllers/pixidouController.php", "framework/modules/portfolio/controllers/portfolioController.php", "framework/modules/recyclebin/controllers/recyclebinController.php", "framework/modules/report/controllers/reportController.php", "framework/modules/search/controllers/searchController.php", "framework/modules/simplepoll/controllers/simplePollController.php", "framework/modules/users/controllers/loginController.php", "framework/modules/users/controllers/usersController.php"], "fixing_code_end_loc": [1183, 823, 543, 1298, 1110, 664, 643, 481, 1977, 221, 1263, 171, 234, 29, 599, 133, 59, 383, 69, 52, 358, 126, 397, 57, 2154, 120, 130, 262, 538, 2232, 25, 72, 1774, 255, 685, 741, 285, 1949, 541, 62, 535, 25, 1306, 259, 202, 121, 40, 102, 2025, 356, 147, 129, 1513], "fixing_code_start_loc": [44, 288, 107, 354, 1102, 26, 194, 37, 244, 25, 27, 25, 32, 26, 27, 50, 27, 27, 26, 43, 26, 25, 29, 33, 25, 25, 25, 25, 25, 26, 25, 68, 1, 55, 25, 428, 41, 30, 44, 55, 25, 24, 1, 29, 31, 24, 30, 25, 25, 29, 146, 128, 27], "message": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "C723D5FF-CEE4-461B-911F-E760A7BF1805", "versionEndExcluding": null, "versionEndIncluding": "2.3.9", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SQL injection vulnerability in framework/modules/filedownloads/controllers/filedownloadController.php in Exponent CMS 2.3.9 and earlier allows remote attackers to execute arbitrary SQL commands via the fileid parameter."}, {"lang": "es", "value": "Vulnerabilidad de inyecci\u00f3n SQL en framework/modules/filedownloads/controllers/filedownloadController.php en Exponent CMS 2.3.9 y versiones anteriores permite a atacantes remotos ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro fileid."}], "evaluatorComment": null, "id": "CVE-2016-9087", "lastModified": "2017-04-04T01:59:01.853", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-03-07T16:59:01.603", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/139484/Exponent-CMS-2.3.9-SQL-Injection.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://seclists.org/fulldisclosure/2016/Nov/12"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/97271"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/fdafb5ec97838e4edbd685f587f28d3174ebb3db"}, "type": "CWE-89"}
| 356
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"* [Bug 1485] Sometimes ntpd crashes",
"",
"(4.2.7p366) 2013/04/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1866] Disable some debugging output in refclock_oncore.\n(4.2.7p365) 2013/04/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2149] Log an error message if /proc/net/if_inet6 cannot be opened.\n(4.2.7p364) 2013/03/26 Released by Harlan Stenn <stenn@ntp.org>\n* Bump sntp/include/autogen-version.def .\n(4.2.7p363) 2013/03/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2357] sntp/libopts/usage.c sometimes needs -lintl.\n* Upgrade to libopts from 5.17.3pre10.\n(4.2.7p362) 2013/03/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2364] \"sed -i\" is not portable.\n(4.2.7p361) 2013/03/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2357] sntp/libopts/usage.c sometimes needs -lintl.\n* [Bug 2365] \"make check\" fails in libevent.\n(4.2.7p360) 2013/03/15 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade libevent (coverity fixes, etc.).\n* EEXIST is OK for mkdir() in sntp/kod_management.c.\n(4.2.7p359) 2013/03/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2359] Fix send_via_ntp_signd() prototype.\n(4.2.7p358) 2013/02/27 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to autogen-5.17.3pre4 and libopts-38.0.13.\n* [Bug 2357] sntp/libopts/usage.c on NetBSD needs -lintl.\n(4.2.7p357) 2013/02/22 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to autogen-5.17.2pre and libopts-38.0.13.\n(4.2.7p356) 2013/02/19 Released by Harlan Stenn <stenn@ntp.org>\n* Added loc/debian.\n(4.2.7p355) 2013/02/18 Released by Harlan Stenn <stenn@ntp.org>\n* CID 739708: Check return status of fcntl() in refclock_arc.c.\n* CID 739709: Check return status of fcntl() in refclock_datum.c.\n* CID 739710: Check return status of mkdir() in sntp/kod_management.c.\n* CID 739711: Ignore return status of remove() in ntp-keygen.c.\n* CID 739723: Print sizeof as unsigned.\n* CID 971094: Clean up time of check/time of use in check_leap_file().\n(4.2.7p354) 2013/02/10 Released by Harlan Stenn <stenn@ntp.org>\n* CID 97194: Check return from setsockopt().\n* CID 739473,739532: Out-of-bounds access/illegal address computation.\n* CID 739558: Double close.\n* CID 739559: Double close.\n* CID 739713: devmask/recmask copy/paste error.\n* CID 739714: Fix code indentation level.\n* CID 739715: Clean up sockaddr_dump().\n(4.2.7p353) 2013/02/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2326] Check hourly for a new leapfile if the old one expired.\n(4.2.7p352) 2013/01/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2326] Notice when a new leapfile has been installed.\n(4.2.7p351) 2013/01/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2328] Don't apply small time adjustments on Windows versions\n which don't support this.\n(4.2.7p350) 2013/01/21 Released by Harlan Stenn <stenn@ntp.org>\n* Added sntp/loc/netbsd based on info from Christos Zoulas.\n(4.2.7p349) 2013/01/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2321] Fixed Windows build, but autogen update still required.\n(4.2.7p348) 2013/01/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2327] Rename sntp/ag-tpl/:Old to sntp/ag-tpl/Old.\n* Cleanup to ntpsnmpd-opts.def.\n* Cleanup to ntpq.texi.\n* Documentation cleanup to the ntpd, ntpdc, ntpq and ntp-wait\n .def files.\n* In ntp.conf.def, cleanup SEE ALSO, document 'rlimit' options.\n* Add a reference to RFC5907 in the ntpsnmpd documentation.\n(4.2.7p347) 2013/01/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2325] Re-enable mlockall() check under Linux post-1223 fix.\n(4.2.7p346) 2013/01/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1223] reorganize inclusion of sys/resource.h.\n(4.2.7p345) 2013/01/04 Released by Harlan Stenn <stenn@ntp.org>\n* Update several .def files to use autogen-5.17 feature set.\n(4.2.7p344) 2013/01/03 Released by Harlan Stenn <stenn@ntp.org>\n* Refactor and enhance mdoc2texi.\n* Make sure agtexi-file.tpl defines label-str.\n* Cleanup to ntp.conf.def.\n* Upgrade to autogen-5.17 and libopts-37.0.12.\n(4.2.7p343) 2013/01/02 Released by Harlan Stenn <stenn@ntp.org>\n* Update the copyright year.\n(4.2.7p342) 2012/12/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2081 - Backward Incompatible] rawstats now logs everything.\n(4.2.7p341) 2012/12/30 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.7p340) 2012/12/29 Released by Harlan Stenn <stenn@ntp.org>\n* mdoc2texi fixes: trailing punctuation.\n(4.2.7p339) 2012/12/26 Released by Harlan Stenn <stenn@ntp.org>\n* mdoc2texi fixes: parseQuote, closing of list item tables.\n* ntp-wait, ntpd, ntpdc, ntpq, ntpsnmpd autogen documentation updates.\n(4.2.7p338) 2012/12/25 Released by Harlan Stenn <stenn@ntp.org>\n* mdoc2texi fixes: Handle_ArCmFlIc, Handle_Fn, HandleQ.\n* ntp-keygen autogen documentation updates.\n* ntpq autogen docs.\n(4.2.7p337) 2012/12/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1223] More final cleanup for rlimit changes.\n(4.2.7p336) 2012/12/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1223] Final cleanup for rlimit changes.\n(4.2.7p335) 2012/12/18 Released by Harlan Stenn <stenn@ntp.org>\n* Update documentation templates and definitions.\n* Create agtexi-file.tpl .\n(4.2.7p334) 2012/12/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2114] Update tests for sntp's synch distance.\n* Create ntp-keygen.{html,texi}.\n(4.2.7p333) 2012/12/07 Released by Harlan Stenn <stenn@ntp.org>\n* Autogen documentation cleanup.\n(4.2.7p332) 2012/12/06 Released by Harlan Stenn <stenn@ntp.org>\n* sntp documentation cleanup.\n(4.2.7p331) 2012/12/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2114] Correctly calculate sntp's synch distance.\n(4.2.7p330) 2012/12/03 Released by Harlan Stenn <stenn@ntp.org>\n* autogen doc cleanup\n(4.2.7p329) 2012/12/01 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2278] ACTS flag3 mismatch between code and driver18.html.\n* Use an enum for the ACTS state table.\n* html doc reconciliation with DLM's copy.\n(4.2.7p328) 2012/11/30 Released by Harlan Stenn <stenn@ntp.org>\n* html doc reconciliation with DLM's copy.\n(4.2.7p327) 2012/11/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2024] Identify Events in the system status word in decode.html.'\n* [Bug 2040] Provide a command-line option for the identity key bits.\n* Create loc/darwin for Mac OSX\n(4.2.7p326) 2012/11/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1214] 'proto: precision = ...' should be at INFO, not NOTICE.\n* [Bug 2246] Clear sys_leap when voting says to disarm the leap.\n(4.2.7p325) 2012/11/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2202] ntpq.html: there is no \"acv\" billboard.\n* [Bug 2306] keep pps hack for Win32 even if user-mode/loopback\n PPS API is activated on a serial line.\n(4.2.7p324) 2012/11/19 Released by Harlan Stenn <stenn@ntp.org>\n* Reinstate doc fix to authentic.html from Mike T.\n* [Bug 1223] cleanup for rlimit changes.\n* [Bug 2098] Install DLM's HTML documentation.\n* [Bug 2306] Added user-mode/loop-back PPS API provider for Win32\n(4.2.7p323) 2012/11/18 Released by Harlan Stenn <stenn@ntp.org>\n* html/ updates from Dave Mills.\n(4.2.7p322) 2012/11/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1223] Allow configurable values for RLIMIT_STACK and\n RLIMIT_MEMLOCK.\n* [Bug 1320] Log ntpd's initial command-line parameters. (updated fix)\n* [Bug 2120] no sysexits.h under QNX.\n* [Bug 2123] cleanup to html/leap.html.\n(4.2.7p321) 2012/11/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1320] Log ntpd's initial command-line parameters.\n(4.2.7p320) 2012/11/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 969] Clarify ntpdate.html documentation about -u and ntpd.\n* [Bug 1217] libisc/ifiter_sysctl.c:internal_current(): Ignore RTM\n messages with wrong version\n(4.2.7p319) 2012/11/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2296] Fix compile problem with building with old OpenSSL.\n(4.2.7p318) 2012/11/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2301] Remove spurious debug output from ntpq.\n(4.2.7p317) 2012/11/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 922] Allow interspersed -4 and -6 flags on the ntpq command line.\n(4.2.7p316) 2012/10/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2296] Update fix for Bug 2294 to handle --without-crypto.\n(4.2.7p315) 2012/10/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2294] ntpd crashes in FIPS mode.\n(4.2.7p314) 2012/10/23 Released by Harlan Stenn <stenn@ntp.org>\n* Document a tricky malloc() of dns_ctx in sntp.\n(4.2.7p313) 2012/10/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2291] sntp should report why it cannot open file.kod.\n* [Bug 2293] add support for SO_BINTIME, refine support for\n SO_TIMESTAMPNS (bug 1374)\n(4.2.7p312) 2012/10/11 Released by Harlan Stenn <stenn@ntp.org>\n* Clean up testing/debugging of fix for [Bug 938] from sntp/main.c .\n(4.2.7p311) 2012/10/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 938] The argument to the -D flag takes a number, not a string.\n* [Bug 1013] ntpdate's HTML page claims wrong default version.\n* [Bug 1374] Support SO_TIMESTAMPNS.\n(4.2.7p310) 2012/10/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1374] Support SO_TIMESTAMPNS.\n* [Bug 2266] Remove deprecated refclock_trak.c from Windows Makefile\n equivalents.\n* [Bug 2274] Bring libopts/enum.c back to (old) ANSI C compliance.\n(4.2.7p309) 2012/10/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2287] ntpdate returns 0 even if adjtime() call fails.\n(4.2.7p308) 2012/09/29 Released by Harlan Stenn <stenn@ntp.org>\n* CID 97198: Check return from ioctl() calls in refclock_acts.c.\n(4.2.7p307) 2012/09/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1997] Fix sntp broadcast timeouts.\n* [Bug 2234] Fix incorrect ntptrace html documentation.\n* [Bug 2262] Install html docs in $htmldir.\n* Fix typo in html/select.html.\n(4.2.7p306) 2012/09/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 752] ToS cleanup from Mike Tatarinov.\n(4.2.7p305) 2012/09/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 752] Use proper ToS network packet markings for IPv4 and IPv6.\n* [Bug 1232] Convert SHM refclock to use struct timespec.\n* [Bug 2258] Add syslog message about leap insertion.\n* [Bug 2263] broadcast server doesn't work for host with\n OS_MISSES_SPECIFIC_ROUTE_UPDATES.\n* [Bug 2271] Decode refclock types when built with --disable-all-clocks.\n* [Bug 2276] clk_sel240x.c #define's _XOPEN_SOURCE, breaking QNX6.\n* Updates to driver28.html.\n(4.2.7p304) 2012/09/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2264] Cleanup SEL240X Refclock.\n* In refclock_wwv.c rename SECOND to WWV_SEC and MINUTE to WWV_MIN.\n(4.2.7p303) 2012/09/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1232] Add nanosecond support to SHM driver.\n(4.2.7p302) 2012/09/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2160] Log warning about expired leapseconds file.\n(4.2.7p301) 2012/09/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2164] Greater precision needed for ntpq offset report.\n* Clean the man5_MANS in ntpd/ .\n(4.2.7p300) 2012/09/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2262] Install sntp.html into htmldir.\n* [Bug 2270] Install fails due to repeated man5 page names.\n(4.2.7p299) 2012/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* More cleanup to the bootstrap script.\n(4.2.7p298) 2012/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* Handle additional man page sections in the bootstrap script.\n* Remove extraneous parens.\n* Add a missing \"%s\" syslog format string.\n(4.2.7p297) 2012/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* Fix mdoc2man.\n* Distribute ntp.conf.def and ntp.keys.def.\n(4.2.7p296) 2012/08/31 Released by Harlan Stenn <stenn@ntp.org>\n* Begin support for autogen maintaining ntp.conf and ntp.keys docs.\n* Upgrade to autogen-5.16.2 and libopts-36.5.11.\n* Potential bugfix for agtexi-cmd.tpl.\n(4.2.7p295) 2012/08/11 Released by Harlan Stenn <stenn@ntp.org>\n* Look for syslog's facilitynames[].\n(4.2.7p294) 2012/08/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2242] configure fails to detect getifaddrs function on Solaris.\n* [Bug 2249] Bad operator for 'test' in 'make check' of libevent.\n* [Bug 2252] palisade: formats nanosecs to a 6-char field.\n* Attempt to resolve strict-aliasing violation in refclock_tsyncpci.c.\n* Fix && -> & typo in refclock_palisade.c debug statements.\n(4.2.7p293) 2012/08/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2247] (more) Get rid of the TRAK refclock - deprecated since 2006.\n* Documentation cleanup from Mike T.\n* Cleanup kclk_sel240x.o rules in libparse/Makefile.am.\n(4.2.7p292) 2012/08/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1545] Note why we are logging the Version string.\n* [Bug 1872] Remove legacy ppsclock fdpps, #ifdef PPS.\n* [Bug 2075] Fix spelling of 'incompatible'.\n* [Bug 2247] Get rid of the TRAK refclock - deprecated since 2006.\n* Clean up an exit status in ntpq.c.\n(4.2.7p291) 2012/07/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2241] MDNS registration should only happen if requested.\n(4.2.7p290) 2012/07/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1454] Add parse clock support for the SEL-240x GPS products.\n* CID 709185: refclock_chu.c will leak fd==0 (better fix)\n(4.2.7p289) 2012/07/16 Released by Harlan Stenn <stenn@ntp.org>\n* CID 97123: Future-proof possible change to refclock_nmea.c.\n* CID 97377: ntp-keygen.c's followlink() might not NUL-terminate.\n* CID 709185: refclock_chu.c will leak fd==0 (which should be impossible).\n(4.2.7p288) 2012/07/03 Released by Harlan Stenn <stenn@ntp.org>\n* CID 709173: Make sure a libisc function we do not use is called properly.\n(4.2.7p287) 2012/07/03 Released by Harlan Stenn <stenn@ntp.org>\n* Remove 1024 associations-per-server limit from ntpq.\n* Remove blank line between ntpq mreadvar associations.\n(4.2.7p286) 2012/06/28 Released by Harlan Stenn <stenn@ntp.org>\n* CID 97193: check return from sscanf() in ntp_config.c.\n* CID 709169: check return from open(\"/dev/null\", 0) and friends.\n* CID 709207: Initialize \"quality\" for ulink_receive.\n(4.2.7p285) 2012/06/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2227] Enable mrulist access control via \"restrict ... nomrulist\".\n* Automake-1.12 wants us to use AM_PROG_AR.\n* Conditionalize msyslog messages about rejected mode 6 requests due to\n nomodify and nomrulist restrictions under \"logconfig +sysinfo\".\n* Increment sys_restricted in a few rejection paths due to nomodify\n restrictions where previosuly overlooked.\n(4.2.7p284) 2012/06/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2225] libevent configure hangs.\n* Update bundled libevent to git master, post libevent 2.1.1-alpha.\n(4.2.7p283) 2012/06/16 Released by Harlan Stenn <stenn@ntp.org>\n* In sntp/m4/ntp_openssl.m4, Support multiple package names for the\n crypto library. Add legacy support for -Wl,-rpath.\n(4.2.7p282) 2012/06/15 Released by Harlan Stenn <stenn@ntp.org>\n* tickadj may need to be linked with PTHREAD_LIBS.\n(4.2.7p281) 2012/06/14 Released by Harlan Stenn <stenn@ntp.org>\n* U_INT32_MAX cleanup in include/ntp_types.h .\n* When linking, ntp_keygen and tickadj need $(LIBM).\n(4.2.7p280) 2012/06/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2224] Use-after-free in routing socket code after dropping root.\n(4.2.7p279) 2012/06/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2211] findbcastinter(): possibly undefined variable iface used.\n* [Bug 2220] Incorrect check for maximum association id in ntpq.\n(4.2.7p278) 2012/06/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2204] Build with --enable-getifaddrs=glibc fails.\n* [Bug 2178] refclock_tsyncpci.c reach register fails to shift.\n* [Bug 2191] dcfd -Y y2kcheck on CentOS 6.2 x86_64 breaks make check.\n(4.2.7p277) 2012/05/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2193] Building timestruct tests with Clang 3.1 fails.\n(4.2.7p276) 2012/05/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2179] Remove sntp/header.h.\n(4.2.7p275) 2012/04/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1744] Remove obsolete ntpdate/ntptime* items.\n(4.2.7p274) 2012/04/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2174] ntpd rejects source UDP ports less than 123 as bogus.\n(4.2.7p273) 2012/04/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2141] handle_sigio() calls get_systime(), which must be\n reentrant when SIGIO is used. Sanity checks relative to the prior\n get_systime() are disabled in ntpd on systems with signaled I/O, but\n active in sntp and ntpdate.\n* Correct authnumfreekeys accounting broken in 4.2.7p262.\n(4.2.7p272) 2012/04/14 Released by Harlan Stenn <stenn@ntp.org>\n* LCRYPTO is gone - replace with VER_SUFFIX.\n* Change the link order for ntpsntpd.\n* Remove extra 'nlist' check from configure.ac.\n(4.2.7p271) 2012/04/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1122] openssl detection via pkg-config fails when no additional\n -Idir flags are needed.\n* Avoid overwriting user variable LDFLAGS with OpenSSL flags, instead\n they are added to LDFLAGS_NTP.\n(4.2.7p270) 2012/03/26 Released by Harlan Stenn <stenn@ntp.org>\n* Update driver45.html page.\n(4.2.7p269) 2012/03/25 Released by Harlan Stenn <stenn@ntp.org>\n* Clean up configure.ac.\n* Cleanup configure.ac's TSYNC PCI section.\n(4.2.7p268) 2012/03/24 Released by Harlan Stenn <stenn@ntp.org>\n* Update driver45.html page.\n(4.2.7p267) 2012/03/23 Released by Harlan Stenn <stenn@ntp.org>\n* Initial cut at a basic driver45.html page.\n(4.2.7p266) 2012/03/21 Released by Harlan Stenn <stenn@ntp.org>\n* Add refclock_tsyncpci.c (driver 45) supporting Spectracom TSYNC timing\n boards.\n(4.2.7p265) 2012/03/20 Released by Harlan Stenn <stenn@ntp.org>\n* Treat zero counter as indication of precise system time in Windows\n PPSAPI helper function pps_ntp_timestamp_from_counter(), enabling\n PPSAPI providers to use the Windows 8 precise clock directly.\n(4.2.7p264) 2012/03/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2160] Note if leapseconds file is past its prime.\n* Use GetSystemTimePreciseAsFileTime() on Windows 8.\n(4.2.7p263) 2012/03/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2156] clock instability with LOCAL driver, from Miroslav Lichvar.\n* [Bug 2159] Windows ntpd using leapfile erroneous leap second 20120401.\n(4.2.7p262) 2012/02/29 Released by Harlan Stenn <stenn@ntp.org>\n* Improve ntpd scalability for servers with many trusted keys.\n(4.2.7p261) 2012/02/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2048] add the clock variable timecode to SHM refclock.\n(4.2.7p260) 2012/02/24 Released by Harlan Stenn <stenn@ntp.org>\n* Fix the check-scm-rev invocation in several Makefile.am's.\n(4.2.7p259) 2012/02/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2148] ntpd 4.2.7p258 segfault with 0x0100000 bit in NMEA mode.\n* refclock_nmea.c merge cleanup thanks to Juergen Perlinger.\n(4.2.7p258) 2012/02/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2140] Rework of Windows I/O completion port handling to avoid\n garbling serial input in UNIX line discipline emulation.\n* [Bug 2143] NMEA driver: discard data if quality indication not good,\n add statistic counters (mode bit enabled) to clockstats file.\n(4.2.7p257) 2012/02/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2135] defer calls to 'io_input' to main thread under Windows.\n(4.2.7p256) 2012/02/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2131] Set the system variable settimeofday only after clock step.\n* [Bug 2134] --enable-C99-snprintf does not force rpl_snprintf use.\n(4.2.7p255) 2012/01/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 603] Only link with nlist()-related libraries when needed:\n More cleanup.\n(4.2.7p254) 2012/01/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 603] Only link with nlist()-related libraries when needed.\n(4.2.7p253) 2012/01/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2126] Compile error on Windows with libopts from Autogen 5.14.\n* Update one of the license URLs.\n(4.2.7p252) 2012/01/25 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to autogen-5.14 (and libopts-36.1.11).\n(4.2.7p251) 2012/01/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2115] ntptrace should accept both rootdispersion and rootdisp.\n(4.2.7p250) 2012/01/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2113] Warn about ignored extra args in ntpq.\n* Update the copyright year.\n(4.2.7p249) 2012/01/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2111] Remove minpoll delay before iburst for pool and\n manycastclient.\n* Move refclock-specific scheduled timer code under #ifdef REFCLOCK\n and move \"action\" and \"nextaction\" data for same from struct peer to\n struct refclockproc. These provide a way to schedule a callback some\n seconds in the future.\n(4.2.7p248) 2012/01/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2109] \"make clean check\" is broken with gtest available.\n* [Bug 2110] systime.c typo breaks build on microsecond clocks.\n(4.2.7p247) 2012/01/07 Released by Harlan Stenn <stenn@ntp.org>\n* Fix build break triggered by updating deps-ver and libntp/systime.c at\n the same time by explicitly depending systime_s.c on systime.c.\n(4.2.7p246) 2012/01/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2104] ntpdc fault with oversize -c command.\n* [Bug 2106] Fix warnings when using -Wformat-security.\n* Refactor timespecops.h and timevalops.h into inline functions.\n(4.2.7p245) 2011/12/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2100] conversion problem with timespec/timeval <--> l_fp fixed;\n added tests to expose the bug.\n(4.2.7p244) 2011/12/25 Released by Harlan Stenn <stenn@ntp.org>\n* Updates from 4.2.6p5.\n(4.2.7p243) 2011/12/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2095] ntptrace now needs 'rv' instead of 'pstat', reported\n by Michael Tatarinov.\n(4.2.7p242) 2011/12/21 Released by Harlan Stenn <stenn@ntp.org>\n* Include missing html/icons/sitemap.png, reported by Michael Tatarinov.\n* Documentation updates from Dave Mills.\n(4.2.7p241) 2011/12/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2015] Overriding sys_tick should recalculate sys_precision.\n* [Bug 2037] Fuzzed non-interpolated clock may decrease.\n* [Bug 2068] \"tos ceiling\" default and cap changed to 15.\n* Floor peer delay using system precision, as with jitter, reflecting\n inability to measure shorter intervals.\n(4.2.7p240) 2011/12/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2092] clock_select() selection jitter miscalculated.\n* [Bug 2093] Reintroduce smaller stratum factor to system peer metric.\n(4.2.7p239) 2011/12/11 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p238) 2011/12/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2082] from 4.2.6p5-RC3: 3-char refid sent by ntpd 4.2.6p5-RC2\n ends with extra dot.\n* [Bug 2085] from 4.2.6p5-RC3: clock_update() sys_rootdisp calculation\n omits root delay.\n* [Bug 2086] from 4.2.6p5-RC3: get_systime() should not offset by\n sys_residual.\n* [Bug 2087] from 4.2.6p5-RC3: sys_jitter calculation overweights\n sys.peer jitter.\n* from 4.2.6p5-RC3: Ensure NULL peer->dstadr is not accessed in orphan\n parent selection.\n(4.2.7p237) 2011/12/01 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2050] from 4.2.6p5-RC2: Orphan mode stratum counting to infinity.\n* [Bug 2059] from 4.2.6p5-RC2: optional billboard column \"server\" does\n not honor -n.\n* [Bug 2066] from 4.2.6p5-RC2: ntpq lopeers ipv6 \"local\" column overrun.\n* [Bug 2068] from 4.2.6p5-RC2: ntpd sends nonprintable stratum 16 refid\n to ntpq.\n* [Bug 2069] from 4.2.6p5-RC2: broadcastclient, multicastclient spin up\n duplicate ephemeral associations without broadcastdelay.\n* [Bug 2072] from 4.2.6p5-RC2: Orphan parent selection metric needs\n ntohl().\n* [Bug 2073] Correct ntpq billboard's MODE_PASSIVE t from 'u' to 'S'.\n* from 4.2.6p5-RC2: Exclude not-yet-determined sys_refid from use in\n loopback TEST12 (from Dave Mills).\n* from 4.2.6p5-RC2: Never send KoD rate limiting response to MODE_SERVER.\n* Floor calculation of sys_rootdisp at sys_mindisp in clock_update (from\n Dave Mills).\n* Restore 4.2.6 clock_combine() weighting to ntp-dev, reverting to pre-\n 4.2.7p70 method while also avoiding divide-by-zero (from Dave Mills).\n* Round l_fp traffic interval when converting to integer in rate limit\n and KoD calculation.\n(4.2.7p236) 2011/11/16 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p235) 2011/11/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2052] Autokey CRYPTO_ASSOC host@group vallen needs checking.\n(4.2.7p234) 2011/11/07 Released by Harlan Stenn <stenn@ntp.org>\n* Clean up -libm entries regarding libntp.a\n(4.2.7p233) 2011/11/06 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p232) 2011/11/05 Released by Harlan Stenn <stenn@ntp.org>\n* Update the NEWS file so we note the default disable of mode 7 requests.\n* Clean up some bitrotted code in libntp/socket.c.\n(4.2.7p231) 2011/11/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1940] ignore auth key if hex decoding fails.\n* Add ntpq reslist command to query access restrictions, similar to\n ntpdc's reslist.\n(4.2.7p230) 2011/11/01 Released by Harlan Stenn <stenn@ntp.org>\n* Disable mode 7 (ntpdc) query processing in ntpd by default. ntpq is\n believed to provide all functionality ntpdc did, and uses a less-\n fragile protocol that's safer and easier to maintain. If you do find\n some management via ntpdc is needed, you can use \"enable mode7\" in the\n ntpd configuration.\n* Directly limit the number of datagrams in a mrulist response, rather\n than limiting the number of entries returned to indirectly limit the\n datagram count.\n* Documentation updates from Dave Mills.\n(4.2.7p229) 2011/10/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1995] fix wrong use of ZERO() macro in 'ntp_calendar.c'\n(4.2.7p228) 2011/10/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1995] add compile time stamp based era unfolding for\n 'step_systime()' and necessary support to 'ntp-calendar.c'.\n(4.2.7p227) 2011/10/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2036] gcc 2.95.3 preprocessor can't nest #ifdef in macro args.\n* A number of compiler warnings eliminated.\n(4.2.7p226) 2011/10/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2035] ntpq -c mrulist sleeps 1 sec between queries, not 5 msec.\n* Documentation updates from Dave Mills.\n(4.2.7p225) 2011/10/15 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p224) 2011/10/14 Released by Harlan Stenn <stenn@ntp.org>\n* ntpq mrulist shows intermediate counts every five seconds while\n retrieving list, and allows Ctrl-C interruption of the retrieval,\n showing the incomplete list as retrieved. Reduce delay between\n successive mrulist retrieval queries from 30 to 5 msec. Do not\n give up mrulist retrieval when a single query times out.\n(4.2.7p223) 2011/10/12 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p222) 2011/10/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2029] \"make check\" clutters syslog.\n* Log signal description along with number on ntpd exit.\n(4.2.7p221) 2011/10/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2025] Switching between daemon and kernel loops can doubly-\n correct drift\n* [Bug 2028] ntpd -n (nofork) redirects logging to stderr.\n* Documentation updates from Dave Mills.\n(4.2.7p220) 2011/10/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1945] mbg_gps166.h use of _TM_DEFINED conflicts with MS VC.\n* [Bug 1946] parse_start uses open; does not work on Windows.\n* [Bug 1947] Porting parse-based Wharton refclock driver to Windows.\n* [Bug 2024] Remove unused system event code EVNT_CLKHOP.\n(4.2.7p219) 2011/10/04 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p218) 2011/10/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2019] Allow selection of cipher for private key files.\n* Documentation updates from Dave Mills.\n* ntp-keygen private key cipher default now triple-key triple DES CBC.\n* ntp-keygen -M is intended to ignore all other defaults and\n options, so do not attempt to open existing Autokey host certificate\n before generating symmetric keys and terminating.\n* Restore IFF, MV, and GQ identity parameter filename convention to\n ntpkey_<scheme>par_<group/host> in ntpd, matching ntp-keygen.\n* Change some error logging to syslog to ignore logconfig mask, such\n as reporting PPSAPI failure in NMEA and WWVB refclocks.\n* ntp-keygen on Windows XP and later systems will now create links\n expected by ntpd. They are hardlinks on Windows, soft on POSIX.\n* Conditionalize NMEA serial open message under clockevent.\n* Send all peer variables to trappers in report_event().\n(4.2.7p217) 2011/09/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2020] ntp-keygen -s no longer sets host in cert file name.\n* [Backward Incompatible] ntp-keygen -i option long name changed from\n misleading --issuer-name to --ident.\n(4.2.7p216) 2011/09/27 Released by Harlan Stenn <stenn@ntp.org>\n* sntp documentation tag cleanup.\n* mdoc2man improvements.\n(4.2.7p215) 2011/09/24 Released by Harlan Stenn <stenn@ntp.org>\n* Use patched mdoc2man script, from Eric Feng.\n* Sync with ntp-4.2.6p4 (a no-op).\n(4.2.7p214) 2011/09/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1981] Initial offset convergence applies frequency correction 2x\n with kernel discipline.\n* [Bug 2008] Initial offset convergence degraded with 500 PPM adjtime().\n* [Bug 2009] EVNT_NSET adj_systime() mishandled by Windows ntpd.\n(4.2.7p213) 2011/09/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1999] NMEA does not send PMOTG messages any more.\n(4.2.7p212) 2011/09/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2003] from 4.2.6p4-RC3: ntpq_read_assoc_peervars() broken.\n(4.2.7p211) 2011/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* Update libevent to git head (2.1 branch) as of 2.0.14-stable.\n(4.2.7p210) 2011/08/31 Released by Harlan Stenn <stenn@ntp.org>\n* Require -D4 or higher for ntpd SIGALRM debug trace from [Bug 2000].\n(4.2.7p209) 2011/08/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2000] ntpd worker threads must block signals expected in main\n thread.\n* [Bug 2001] add ntpq -c timerstats like ntpdc -c timerstats.\n* [Bug 2001] from 4.2.6p4-RC3: ntpdc timerstats reports overruns as\n handled.\n* Update sntp tests to track the change of root dispersion to\n synchronization distance.\n(4.2.7p208) 2011/08/24 Released by Harlan Stenn <stenn@ntp.org>\n* Fix the CLOCK_MONOTONIC TRACE() message.\n(4.2.7p207) 2011/08/22 Released by Harlan Stenn <stenn@ntp.org>\n* Restore the original CLOCK_MONOTONIC output format in sntp.\n* Cleanups for ntp-wait-opts.def and ntp.keys.def .\n(4.2.7p206) 2011/08/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1993] ntpd Windows port adj_systime() broken in 4.2.7p203.\n* sntp documentation and behavior improvements suggested by\n Steven Sommars.\n* Have sntp report synchronization distance instead of root dispersion.\n* Clean up ntp-wait-opts.def .\n(4.2.7p205) 2011/08/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1992] util/tg2 doesn't compile, needs libntp.\n(4.2.7p204) 2011/08/16 Released by Harlan Stenn <stenn@ntp.org>\n* Added support for Garmin's $PGRMF sentence to NMEA driver\n* [Bug 1988] Better sntp send failed error message needed.\n* [Bug 1989] sntp manual page sometimes refers to SNTP as a program.\n* [Bug 1990] sntp output should include stratum.\n(4.2.7p203) 2011/08/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1986] Require Visual C++ 2005 or later compilers in Windows port.\n* Actually use long long for (u_)int64 by correcting spelling of\n SIZEOF_LONG_LONG in ntp_types.h.\n* Force .exe minimum Windows version to 0x0400 to allow NT4 in\n vs2005/*.vcproj files.\n* Fix make distcheck with --enable-libevent-regress problem with\n unwritable $srcdir.\n* Correct init_logging()'s def_syslogmask type to u_int32 following\n change of ntp_syslogmask from u_long to u_int32 in p202.\n(4.2.7p202) 2011/08/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1983] --without-sntp build breaks in sntp subdir.\n* [Bug 1984] from 4.2.6p4-RC3: ntp/libisc fails to compile on OS X 10.7.\n* [Bug 1985] from 4.2.6p4-RC3: \"logconfig =allall\" rejected.\n(4.2.7p201) 2011/08/05 Released by Harlan Stenn <stenn@ntp.org>\n* sntp: change -h/--headspace to -g/--gap, and change the default gap\n from 10 to 50ms\n* [Backward Incompatible] from 4.2.6p4: sntp: -l/--filelog ->\n -l/--logfile, to be consistent with ntpd.\n* Documentation updates from Dave Mills.\n* From 4.2.6p4: libopts/file.c fix from Bruce Korb (arg-type=file).\n(4.2.7p200) 2011/08/04 Released by Harlan Stenn <stenn@ntp.org>\n* Sync with 4.2.6p4-RC2.\n(4.2.7p199) 2011/07/29 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p198) 2011/07/28 Released by Harlan Stenn <stenn@ntp.org>\n* remove old binsubdir stuff from SNTP, as NTP_LOCINFO does that now.\n(4.2.7p197) 2011/07/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1975] from 4.2.6p4-RC2: libntp/mktime.c won't work with 64-bit\n time_t\n* [Bug 1976] genLocInfo writes to srcdir break 'make distcheck'.\n* [Bug 1977] Fix flag/description mismatches in ntp-keygen-opts.def.\n* Do not force \"legacy\" when --with-locfile is not given, genLocInfo\n will find the correct default for the system.\n* Fix warnings in ntp_request.c ([Bug 1973] oversight) and sntp/main.c\n (CID 159, apparent overrun due to union, actually correct).\n* Update sntp/loc/solaris to conform to stock locations.\n(4.2.7p196) 2011/07/27 Released by Harlan Stenn <stenn@ntp.org>\n* DEFAULT INSTALLATION DIRECTORY CHANGES ON SOME OSes: to get the old\n behavior, pass --with-locfile=legacy to 'configure'\n* [Bug 1972] from 4.2.6p4-RC2: checking for struct rtattr fails.\n* [Bug 1973] Widen reference clock mode from 8 to 32 bits.\n* Removed sntp/m4/ntp_bindir.m4 - no longer needed.\n* Move loc/ to sntp/loc/ .\n* Move scripts/cvo.sh to sntp/scripts/cvo.sh .\n* Move scripts/genLocInfo to sntp/scripts/genLocInfo .\n* Give NTP_LOCINFO an optional path-to argument.\n* Remove hacks to get NTP_LOCINFO-related data to sntp/ .\n* Move sntp/include/mansec2subst.sed to sntp/scripts/mansec2subst.sed .\n* If no \"more specific\" loc file is found for redhat* or fedora*,\n look for a loc/redhat file.\n* If no \"more specific\" loc file is found and uname says this is Linux,\n look for a loc/linux file.\n* Improve the help text: --with-locfile=XXX .\n* work around solaris /bin/sh issues for genLocInfo.\n(4.2.7p195) 2011/07/25 Released by Harlan Stenn <stenn@ntp.org>\n* Added loc/redhat.\n(4.2.7p194) 2011/07/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1608] from 4.2.6p4-RC2: Parse Refclock driver should honor\n trusttime.\n* Add support for installing programs and scripts to libexec.\n* Added loc/solaris.\n(4.2.7p193) 2011/07/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1970] from 4.2.6p4-RC2: UNLINK_EXPR_SLIST() causes crash if list\n is empty.\n* Update libevent to 2.1 HEAD as of merge of 2.0.13-stable-dev.\n* Match addr_eqprefix() sizeof and memcpy destination to make it clear\n to static analysis that there is no buffer overrun (CID 402).\n(4.2.7p192) 2011/07/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1966] Broken FILES section for ntp.keys.def.\n(4.2.7p191) 2011/07/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1948] Update man page section layout.\n* [Bug 1963] add reset command for ntpq :config, similar to ntpdc's.\n* [Bug 1964] --without-sntp should not build sntp.\n(4.2.7p190) 2011/07/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1961] from 4.2.6p4: html2man update: distribute ntp-wait.html.\n* Require autogen-5.12.\n(4.2.7p189) 2011/07/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1134] from 4.2.6p4-RC1: ntpd fails binding to tentative IPv6\n addresses.\n* [Bug 1790] from 4.2.6p4-RC1: Update config.guess and config.sub to\n detect AIX6.\n(4.2.7p188) 2011/06/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1958] genLocInfo must export PATH.\n* ntp-wait: some versions of ntpd spell \"associd\" differently.\n(4.2.7p187) 2011/06/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1954] Fix typos in [s]bin_PROGRAMS in ntpd/Makefile.am.\n* Implement --with-locfile=filename configure argument. If filename is\n empty we'll look under loc/ for a good fit. If the filename contains\n a / character, it will be treated as a \"normal\" pathname. Otherwise,\n that explicit file will be searched for under loc/ .\n(4.2.7p186) 2011/06/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1950] Control installation of event_rpcgen.py.\n* Update .point-changed-filelist for the new man pages.\n* Update the building of OS-specific programs.\n* Finish conversion to genLocInfo.\n* validate MANTAGFMT in genLocInfo.\n* Documentation update from Dave Mills.\n(4.2.7p185) 2011/06/21 Released by Harlan Stenn <stenn@ntp.org>\n* ntp_locs.m4: handle the case where . is not in the PATH.\n* More genLocInfo cleanup.\n(4.2.7p184) 2011/06/20 Released by Harlan Stenn <stenn@ntp.org>\n* Added ntp_locs.m4.\n* genLocInfo improvements.\n* Add the man page tag \"flavor\" to the loc.* files.\n* Add/distribute genLocInfo.\n(4.2.7p183) 2011/06/19 Released by Harlan Stenn <stenn@ntp.org>\n* Update the autogen include list for scripts/Makefile.am.\n* Added loc.freebsd (and distribute it).\n* Added loc.legacy (and distribute it).\n(4.2.7p182) 2011/06/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1304] Update sntp.html to reflect new implementation.\n* Update .point-changed-filelist .\n* ntpdc documentation fixes.\n* Update ntp-wait autogen docs.\n* Update the ntpd autogen docs.\n* Update the ntpsnmpd autogen docs.\n* Use autogen to produce ntp-keygen docs.\n* Add \"license name\" to ntp.lic for autogen-5.11.10.\n* Prepare for ntp.keys.5.\n(4.2.7p181) 2011/06/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1938] addr_eqprefix() doesn't clear enough storage.\n(4.2.7p180) 2011/06/06 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to libevent-2.0.12.\n* More sntp.1 cleanups.\n* Produce ntpq.1 with the new autogen macros.\n* Remove the deprecated \"detail\" stanza from ntpdc-opts.def.\n(4.2.7p179) 2011/06/03 Released by Harlan Stenn <stenn@ntp.org>\n* Update cmd-doc.tlib to autogen-5.11.10pre5.\n* Upgrade local autoopts templates to 5.11.10pre5.\n(4.2.7p178) 2011/06/02 Released by Harlan Stenn <stenn@ntp.org>\n* Update the std_def_list to include the ntp.lic file.\n* Distribute the ntp.lic file.\n* Add http://ntp.org/license to the ntp.lic file.\n(4.2.7p177) 2011/06/01 Released by Harlan Stenn <stenn@ntp.org>\n* Use the latest autogen's new copyright template code.\n* Clean up the ntp.lic file.\n(4.2.7p176) 2011/05/31 Released by Harlan Stenn <stenn@ntp.org>\n* sntp documentation cleanup.\n* autogen documentation template cleanup.\n(4.2.7p175) 2011/05/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1936] Correctly set IPV6_MULTICAST_LOOP.\n* cmd-doc.tlib cleanup from Bruce Korb.\n* sntp documentation cleanup.\n(4.2.7p174) 2011/05/28 Released by Harlan Stenn <stenn@ntp.org>\n* ntpdc documentation cleanup.\n* sntp documentation cleanup.\n* Don't build libevent with openssl support. Right now, libevent\n doesn't use pkg-config to find openssl's installation location.\n(4.2.7p173) 2011/05/25 Released by Harlan Stenn <stenn@ntp.org>\n* Typo in emalloc.c hides file and line number from emalloc() error msg.\n* parsesolaris.c compile fails on SPARC Solaris with conflicting printf.\n* ntp_util.c compile fails on AIX and OSF with conflicting statsdir.\n(4.2.7p172) 2011/05/24 Released by Harlan Stenn <stenn@ntp.org>\n* Remove hardcoded 1/960 s. fudge for <CR> transmission time at 9600 8n1\n from WWVB/Spectracom driver introduced in 4.2.7p169.\n(4.2.7p171) 2011/05/23 Released by Harlan Stenn <stenn@ntp.org>\n* Eliminate warnings about shadowing global \"basename\" on Linux.\n* Use filegen_config() consistently when changing filegen options.\n* mprintf() should go to stdout, not stderr. DPRINTF() uses mprintf().\n* Repair a few simulator problems (more remain).\n* Documentation updates from Dave Mills.\n(4.2.7p170) 2011/05/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1932] libevent/util_internal.h builtin_expect compile error with\n gcc 2.95.\n* Use 64-bit scalars in LFPTOD() and DTOLFP() on more platforms by\n conditionalizing on HAVE_U_INT64 rather than UINT64_MAX.\n(4.2.7p169) 2011/05/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1933] WWVB/Spectracom driver timestamps LFs, not CRs.\n(4.2.7p168) 2011/05/16 Released by Harlan Stenn <stenn@ntp.org>\n* Convert receive buffer queue from doubly-linked list to FIFO.\n(4.2.7p167) 2011/05/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1927] io_closeclock() should purge pending recvbufs.\n* [Bug 1931] cv always includes fudgetime1, never fudgetime2.\n* Use acts_close() in acts_shutdown() to avoid leaving a stale lockfile\n if unpeered via runtime configuration while the modem is open.\n* Correct acts_close() test of pp->io.fd to see if it is open.\n* 4.2.7p164 documentation updates re: 'tos orphanwait' expanded scope.\n(4.2.7p166) 2011/05/13 Released by Harlan Stenn <stenn@ntp.org>\n* If we have local overrides for autogen template files, use them.\n* Convert more of the sntp-opt.def documentation from man to mdoc.\n(4.2.7p165) 2011/05/11 Released by Harlan Stenn <stenn@ntp.org>\n* Convert snmp docs to mdoc format, which requires autogen 5.11.9.\n* from 4.2.6p4-RC1: Require autogen 5.11.9.\n(4.2.7p164) 2011/05/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 988] Local clock eats up -g option, so ntpd stops with large\n initial time offset.\n* [Bug 1921] LOCAL, ACTS drivers with \"prefer\" excluded from initial\n candidate list.\n* [Bug 1922] \"tos orphanwait\" applied incorrectly at startup.\n* [Bug 1923] orphan parent favored over LOCAL, ACTS drivers.\n* [Bug 1924] Billboard tally codes sometimes do not match operation,\n variables.\n* Change \"pool DNS\" messages from msyslog to debug trace output.\n* Remove unused FLAG_SYSPEER from peer->status.\n* Respect \"tos orphanwait\" at startup. Previously there was an\n unconditional 300 s. startup orphanwait, though other values were\n respected for subsequent orphan wait periods after no_sys_peer events.\n* Apply \"tos orphanwait\" (def. 300 seconds) to LOCAL and ACTS reference\n clock drivers, in addition to orphan parent operation. LOCAL and ACTS\n are not selectable during the orphanwait delay at startup and after\n each no_sys_peer event. This prevents a particular form of clock-\n hopping, such as using LOCAL briefly at startup before remote peers\n are selectable. This fixes the issue reported in [Bug 988].\n* Documentation updates from Dave Mills.\n(4.2.7p163) 2011/05/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1911] missing curly brace in libntp/ntp_rfc2553.c\n(4.2.7p162) 2011/05/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1910] Support the Tristate Ltd. TS-GPSclock-01.\n(4.2.7p161) 2011/05/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1904] 4.2.7p160 Windows build broken (POSIX_SHELL).\n* [Bug 1906] 4.2.7p160 - libtool: compile: cannot determine name of\n library object in ./libevent\n* Share a single sntp/libevent/build-aux directory between all three\n configure scripts.\n* Add missing --enable-local-libevent help to top-level configure.\n(4.2.7p160) 2011/05/01 Released by Harlan Stenn <stenn@ntp.org>\n* from 4.2.6p4-RC1: Upgrade to libopts 35.0.10 from AutoGen 5.11.9pre8.\n* [Bug 1901] Simulator does not set progname.\n(4.2.7p159) 2011/04/28 Released by Harlan Stenn <stenn@ntp.org>\n* Fix a couple of unused variable warnings.\n* cleanup in timespecops.c / timevalops.c\n(4.2.7p158) 2011/04/24 Released by Harlan Stenn <stenn@ntp.org>\n* Update libevent --disable-libevent-regress handling to work when\n building libevent using mingw.\n(4.2.7p157) 2011/04/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1890] 4.2.7p156 segfault in duplicate freeaddrinfo().\n(4.2.7p156) 2011/04/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1851] freeaddrinfo() called after getaddrinfo() fails.\n(4.2.7p155) 2011/04/18 Released by Harlan Stenn <stenn@ntp.org>\n* Fix leak in refclock_datum.c start failure path.\n(4.2.7p154) 2011/04/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1887] DNS fails on 4.2.7p153 using threads.\n(4.2.7p153) 2011/04/16 Released by Harlan Stenn <stenn@ntp.org>\n* A few more Coverity Scan cleanups.\n(4.2.7p152) 2011/04/15 Released by Harlan Stenn <stenn@ntp.org>\n* Update embedded libevent to current 2.1 git HEAD.\n(4.2.7p151) 2011/04/14 Released by Harlan Stenn <stenn@ntp.org>\n* Detect vsnprintf() support for \"%m\" and disable our \"%m\" expansion.\n* Add --enable-c99-sprintf to configure args for -noopenssl variety of\n flock-build to avoid regressions in (v)snprintf() replacement.\n* More msnprintf() unit tests.\n* Coverity Scan error checking fixes.\n* Log failure to fetch time from HOPF_P hardware.\n* Check HOPF_S sscanf() conversion count before converted values.\n(4.2.7p150) 2011/04/13 Released by Harlan Stenn <stenn@ntp.org>\n* Remove never-used, incomplete ports/winnt/ntpd/refclock_trimbledc.[ch]\n* On systems without C99-compliant (v)snprintf(), use C99-snprintf\n replacements (http://www.jhweiss.de/software/snprintf.html)\n* Remove remaining sprintf() calls except refclock_ripencc.c (which is\n kept out of --enable-all-clocks as a result), upstream libs which use\n sprintf() only after careful buffer sizing.\n(4.2.7p149) 2011/04/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1881] describe the {+,-,s} characters in configure --help output.\n(4.2.7p148) 2011/04/09 Released by Harlan Stenn <stenn@ntp.org>\n* Use _mkgmtime() as timegm() in the Windows port, rather than\n libntp/mktime.c's timegm(). Fixed [Bug 1875] on Windows using the old\n asn2ntp() code from before 4.2.7p147.\n* ntp_crypto.c string buffer safety.\n* Remove use of MAXFILENAME in mode 7 (ntpdc) on-wire structs.\n* Change ntpd MAXFILENAME from 128 to 256 to match ntp-keygen.\n* Buffer safety and sign extension fixes (thanks Coverity Scan).\n(4.2.7p147) 2011/04/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1875] 'asn2ntp()' rewritten with 'caltontp()'; 'timegm()'\n substitute likely to crash with 64bit time_t.\n(4.2.7p146) 2011/04/05 Released by Harlan Stenn <stenn@ntp.org>\n* String buffer safety cleanup, converting to strlcpy() and strlcat().\n* Use utmpname() before pututline() so repeated steps do not\n accidentally record into wtmp where utmp was intended.\n* Use setutent() before each pututline() including first.\n(4.2.7p145) 2011/04/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1840] ntp_lists.h FIFO macros buggy.\n(4.2.7p144) 2011/04/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1874] ntpq -c \"rv 0 sys_var_list\" empty.\n(4.2.7p143) 2011/03/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1732] ntpd ties up CPU on disconnected USB refclock.\n* [Bug 1861] tickadj build failure using uClibc.\n* [Bug 1862] in6addr_any test in configure fooled by arm gcc 4.1.3 -O2.\n* Remove kernel line discipline driver code for clk and chu, deprecate\n related LDISC_ flags, and remove associated ntpd code to decode the\n timestamps, remove clktest line discipline test program.\n* Remove \"signal_no_reset: signal 17 had flags 4000000\" logging, as it\n indicates no problem and is interpreted as an error. Previously some\n bits had been ignored one-by-one, but Linux SA_RESTORER definition is\n unavailable to user headers.\n(4.2.7p142) 2011/03/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1844] ntpd 4.2.7p131 NetBSD, --gc-sections links bad executable.\n* Fix \"make distcheck\" break in libevent/sample caused by typo.\n(4.2.7p141) 2011/03/20 Released by Harlan Stenn <stenn@ntp.org>\n* Add \"ntpq -c iostats\" similar to \"ntpdc -c iostats\".\n* Compare entire timestamp to reject duplicates in refclock_pps().\n(4.2.7p140) 2011/03/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1848] ntpd 4.2.7p139 --disable-thread-support does not compile.\n* Add --disable-thread-support to one flock-build variation.\n* One more lock-while-init in lib/isc/task.c to quiet lock analysis.\n(4.2.7p139) 2011/03/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1848] make check ntpd --saveconfigquit clutters syslog.\n(4.2.7p138) 2011/03/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1846] MacOSX: debug symbol not found by propdelay or tickadj.\n(4.2.7p137) 2011/03/07 Released by Harlan Stenn <stenn@ntp.org>\n* Use TRACE() instead of DPRINTF() for libntp and utilities, which\n use the \"debug\" variable regardless of #ifdef DEBUG.\n* Declare debug in libntp instead of each program. Expose extern\n declaration to utilities, libntp, and DEBUG ntpd.\n* Lock under-construction task, taskmgr objects to satisfy Coverity's\n mostly-correct assumptions about which variables are protected by\n which locks.\n(4.2.7p136) 2011/03/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1839] 4.2.7p135 still installs libevent ev*.h headers.\n(4.2.7p135) 2011/03/02 Released by Harlan Stenn <stenn@ntp.org>\n* libevent: When building on systems with CLOCK_MONOTONIC available,\n separate the internal timeline (possibly counting since system boot)\n from the gettimeofday() timeline in event_base cached timevals. Adds\n new event_base_tv_cached() to retrieve cached callback round start\n time on the internal timeline, and changes\n event_based_gettimeofday_cached() to always return times using the\n namesake timeline. This preserves the benefit of using the never-\n stepped monotonic clock for event timeouts while providing clients\n with times consistently using gettimeofday().\n* Correct event_base_gettimeofday_cached() workaround code in\n sntp to work with corrected libevent.\n* Remove sntp l_fp_output() test now that it uses prettydate().\n* [Bug 1839] 4.2.7p131 installs libevent ev*.h headers.\n* Ensure CONFIG_SHELL is not empty before relying on it for #! scripts.\n(4.2.7p134) 2011/02/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1837] Build fails on Win7 due to regedit requiring privilege.\n* Provide fallback definitions for GetAdaptersAddresses() for Windows\n build environments lacking iphlpapi.h.\n* Rename file containing 1.xxxx ChangeSet revision from version to\n scm-rev to avoid invoking GNU make implicit rules attempting to\n compile version.c into version. Problem was with sntp/version.o\n during make distcheck after fix for spurious sntp rebuilds.\n* Add INC_ALIGNED_PTR() macro to align pointers like malloc().\n(4.2.7p133) 2011/02/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1834] ntpdate 4.2.7p131 aborts with assertion failure.\n* Move sntp last in top-level Makefile.am SUBDIRS so that the libevent\n tearoff (if required) and sntp are compiled after the rest.\n* Use a single set of Automake options for each package in configure.ac\n AM_INIT, remove Makefile.am AUTOMAKE_OPTIONS= lines.\n* Correct spurious sntp rebuilds triggered by a make misperception\n sntp/version was out-of-date relative to phony target FRC.version.\n* Do not cache paths to perl, test, or pkg-config, searching the PATH\n at configure time is worth it to pick up tool updates.\n(4.2.7p132) 2011/02/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1832] ntpdate doesn't allow timeout > 2s.\n* [Bug 1833] The checking sem_timedwait() fails without -pthread.\n* ElectricFence was suffering bitrot - remove it. valgrind works well.\n* Enable all relevant automake warnings.\n* Correct Solaris 2.1x PTHREAD_ONCE_INIT extra braces test to avoid\n triggering warnings due to excess braces.\n* Remove libevent-cfg from sntp/Makefile.am.\n* Provide bug report and URL options to Autoconf.\n* Avoid relying on remake rules for routine build/flock-build for\n libevent as for the top-level and sntp subproject.\n(4.2.7p131) 2011/02/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1087] -v/--normalverbose conflicts with -v/--version in sntp.\n* [Bug 1088] sntp should (only) report the time difference without -s/-a.\n* older autoconf sometimes dislikes [].\n* Move \"can't write KoD file\" warning from sntp shutdown to startup.\n* refclock_acts.c cleanup from Dave Mills.\n* Convert sntp to libevent event-driven socket programming. Instead of\n blocking name resolution and querying one NTP server at a time,\n resolve server names and send NTP queries without blocking. Add\n sntp command-line options to adjust timing and optionally wait for all\n servers to respond instead of exiting after the first.\n* Import libevent 2.0.10-stable plus local patches as a tearoff, used\n only if the target system lacks an installed libevent 2.0.9 or later.\n* Move blocking worker and resolver to libntp from ntpd.\n* Use threads rather than forked child processes for blocking worker\n when possible. Override with configure --disable-thread-support.\n* Move init_logging(), change_logfile(), and setup_logfile() from ntpd\n to libntp, use them in sntp.\n* Test --without-sntp in flock-build script's -no-refclocks variety.\n* Avoid invoking config.status twice in a row in build script.\n* Move more m4sh tests needed by libntp to shared .m4 files.\n* Split up ntp_libntp.m4 into smaller, more specific subsets.\n* Enable gcc -Wcast-align, fix many instances of warnings when casting\n a pointer to a more-strictly-aligned underlying type.\n(4.2.7p130) 2011/02/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1811] Update the download location in WHERE-TO-START.\n(4.2.7p129) 2011/02/09 Released by Harlan Stenn <stenn@ntp.org>\n* Add missing \"break;\" to ntp_control.c ctl_putsys() for caliberrs, used\n by ntpq -c kerninfo introduced in 4.2.7p104.\n* Fix leak in ntp_control.c read_mru_list().\n(4.2.7p128) 2011/01/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1799] ntpq mrv crash.\n* [Bug 1801] ntpq mreadvar requires prior association caching.\n(4.2.7p127) 2011/01/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1797] Restore stale timestamp check from the RANGEGATE cleanup.\n(4.2.7p126) 2011/01/27 Released by Harlan Stenn <stenn@ntp.org>\n* Fix unexposed fencepost error in format_time_fraction().\n* Add more unit tests for timeval_tostr() and timespec_tostr().\n(4.2.7p125) 2011/01/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1794] ntpq -c rv missing clk_wander information.\n* [Bug 1795] ntpq readvar does not display last variable.\n(4.2.7p124) 2011/01/25 Released by Harlan Stenn <stenn@ntp.org>\n* sntp/Makefile.am needs any passed-in CFLAGS.\n(4.2.7p123) 2011/01/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1788] tvtots.c tables inaccurate\n(4.2.7p122) 2011/01/22 Released by Harlan Stenn <stenn@ntp.org>\n* ACTS refclock cleanup from Dave Mills.\n* Avoid shadowing the \"group\" global variable.\n(4.2.7p121) 2011/01/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1786] Remove extra semicolon from ntp_proto.c .\n(4.2.7p120) 2011/01/20 Released by Harlan Stenn <stenn@ntp.org>\n* Change new timeval and timespec to string routines to use snprintf()\n rather than hand-crafted conversion, avoid signed int overflow there.\n* Add configure support for SIZEOF_LONG_LONG to enable portable use of\n snprintf() with time_t.\n* Grow ntpd/work_thread.c arrays as needed.\n* Add DEBUG_* variants of ntp_assert.h macros which compile away using\n ./configure --disable-debugging.\n* Fix tvalops.cpp unit test failures for 32-bit builds.\n* Return to a single autoreconf invocation in ./bootstrap script.\n* Fix warnings seen on FreeBSD 9.\n* crypto group changes from Dave Mills.\n* Lose the RANGEGATE check in PPS, from Dave Mills.\n* ACTS refclock cleanup from Dave Mills.\n* Documentation updates from Dave Mills.\n* NMEA driver documentation update from Juergen Perlinger.\n(4.2.7p119) 2011/01/18 Released by Harlan Stenn <stenn@ntp.org>\n* added timespecops.{c,h} and tievalops.{c.h} to libntp and include\n added tspecops.cpp to tests/libntp\n* Correct msyslog.c build break on Solaris 2.9 from #ifdef/#if mixup.\n(4.2.7p118) 2011/01/15 Released by Harlan Stenn <stenn@ntp.org>\n* Simplify the built-sources stuff in sntp/ .\n* Fix check for -lipv6 on HP-UX 11.\n(4.2.7p117) 2011/01/13 Released by Harlan Stenn <stenn@ntp.org>\n* Add configure --without-sntp option to disable building sntp and\n sntp/tests. withsntp=no in the environment changes the default.\n* Build infrastructure cleanup:\n Move m4 directory to sntp/m4.\n Share a single set of genver output between sntp and the top level.\n Share a single set of autogen included .defs in sntp/include.\n Share a single set of build-aux scripts (e.g. config.guess, missing).\n Add ntp_libntp.m4 and ntp_ipv6.m4 to reduce configure.ac duplication.\n Warn and exit build/flock-build if bootstrap needs to be run.\n(4.2.7p116) 2011/01/10 Released by Harlan Stenn <stenn@ntp.org>\n* refclock_nmea.c refactoring by Juergen Perlinger.\n(4.2.7p115) 2011/01/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1780] Windows ntpd 4.2.7p114 crashes in ioctl().\n* [Bug 1781] longlong undefined in sntp handle_pkt() on Debian amd64.\n(4.2.7p114) 2011/01/08 Released by Harlan Stenn <stenn@ntp.org>\n* Fix for openssl pkg-config detection eval failure.\n* Add erealloc_zero(), refactor estrdup(), emalloc(), emalloc_zero() to\n separate tracking callsite file/line from using debug MS C runtime,\n and to reduce code duplication.\n(4.2.7p113) 2011/01/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1776] sntp mishandles -t/--timeout and -a/--authentication.\n* Default to silent make rules, override with make V=1 or ./configure\n --disable-silent-rules.\n* Correct --with-openssl-incdir defaulting with pkg-config.\n* Correct ./build on systems without gtest available.\n* Begin moving some of the low-level socket stuff to libntp.\n(4.2.7p112) 2011/01/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1773] openssl not detected during ./configure.\n* [Bug 1774] Segfaults if cryptostats enabled and built without OpenSSL.\n* Use make V=0 in build script to increase signal/noise ratio.\n(4.2.7p111) 2011/01/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1772] refclock_open() return value check wrong for ACTS.\n* Default --with-openssl-libdir and --with-openssl-incdir to the values\n from pkg-config, falling back on our usual search paths if pkg-config\n is not available or does not have openssl.pc on PKG_CONFIG_PATH.\n* Change refclock_open() to return -1 on failure like open().\n* Update all refclock_open() callers to check for fd <= 0 indicating\n failure, so they work with older and newer refclock_open() and can\n easily backport.\n* Initialize refclockproc.rio.fd to -1, harmonize refclock shutdown\n entrypoints to avoid crashing, particularly if refclock_open() fails.\n* Enable tickadj-like taming of wildly off-spec Windows clock using\n NTPD_TICKADJ_PPM env. var. specifying baseline slew.\n(4.2.7p110) 2011/01/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1771] algorithmic error in 'clocktime()' fixed.\n* Unit tests extended for hard-coded system time.\n* make V=0 and configure --enable-silent-rules supported.\n* setvar modemsetup = ATE0... overrides ACTS driver default.\n* Preserve last timecode in ACTS driver (ntpq -ccv).\n* Tolerate previous ATE1 state when sending ACTS setup.\n* Enable raw tty line discipline in Windows port.\n* Allow tty open/close/open to succeed on Windows port.\n* Enable ACTS and CHU reference clock drivers on Windows.\n(4.2.7p109) 2011/01/02 Released by Harlan Stenn <stenn@ntp.org>\n* Remove nearly all strcpy() and most strcat() from NTP distribution.\n One major pocket remains in ntp_crypto.c. libopts & libisc also have\n (safe) uses of strcpy() and strcat() remaining.\n* Documentation updates from Dave Mills.\n(4.2.7p108) 2011/01/01 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1764] Move Palisade modem control logic to configure.ac.\n* [Bug 1768] TIOCFLUSH undefined in linux for refclock_acts.\n* Autokey multiple identity group improvements from Dave Mills.\n* from 4.2.6p3: Update the copyright year.\n(4.2.7p107) 2010/12/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1764] Palisade driver doesn't build on Linux.\n* [Bug 1766] Oncore clock has offset/high jitter at startup.\n* Move ntp_control.h variable IDs to ntp_control.c, remove their use by\n ntpq. They are implementation details private to ntpd. [Bug 597] was\n caused by ntpq's reliance on these IDs it need not know about.\n* refclock_acts.c updates from Dave Mills.\n(4.2.7p106) 2010/12/30 Released by Harlan Stenn <stenn@ntp.org>\n* from 4.2.6p3: Update genCommitLog for the bk-5 release.\n(4.2.7p105) 2010/12/29 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.7p104) 2010/12/28 Released by Harlan Stenn <stenn@ntp.org>\n* from 4.2.6p3: Create and use scripts/check--help when generating\n .texi files.\n* from 4.2.6p3: Update bk triggers for the bk-5 release.\n* Support for multiple Autokey identity groups from Dave Mills.\n* Documentation updates from Dave Mills.\n* Add ntpq kerninfo, authinfo, and sysinfo commands similar to ntpdc's.\n(4.2.7p103) 2010/12/24 Released by Harlan Stenn <stenn@ntp.org>\n* Add ntpq pstats command similar to ntpdc's.\n* Remove ntpq pstatus command, rv/readvar does the same and more.\n* Documentation updates from Dave Mills.\n(4.2.7p102) 2010/12/23 Released by Harlan Stenn <stenn@ntp.org>\n* Allow ntpq &1 associd use without preceding association-fetching.\n* Documentation updates from Dave Mills.\n(4.2.7p101) 2010/12/22 Released by Harlan Stenn <stenn@ntp.org>\n* from 4.2.6p3-RC12: Upgrade to libopts 34.0.9 from AutoGen 5.11.6pre7.\n* from 4.2.6p3-RC12: Relax minimum Automake version to 1.10 with updated\n libopts.m4.\n(4.2.7p100) 2010/12/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1743] from 4.2.6p3-RC12: Display timezone offset when showing\n time for sntp in the local timezone (documentation updates).\n(4.2.7p99) 2010/12/21 Released by Harlan Stenn <stenn@ntp.org>\n* Add unit tests for msnprintf().\n(4.2.7p98) 2010/12/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1761] clockstuff/clktest-opts.h omitted from tarball.\n* [Bug 1762] from 4.2.6p3-RC12: manycastclient responses interfere.\n* Documentation updates from Dave Mills.\n(4.2.7p97) 2010/12/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1458] from 4.2.6p3-RC12: Can not compile NTP on FreeBSD 4.7.\n* [Bug 1760] from 4.2.6p3-RC12: ntpd Windows interpolation cannot be\n disabled.\n* from 4.2.6p3-RC12: Upgrade to libopts 34.0.9 from AutoGen 5.11.6pre5.\n* Documentation updates from Dave Mills.\n(4.2.7p96) 2010/12/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1758] from 4.2.6p3-RC12: setsockopt IPV6_MULTICAST_IF with wrong\n ifindex.\n* Documentation updates from Dave Mills.\n(4.2.7p95) 2010/12/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1753] 4.2.7p94 faults on startup in newpeer(), strdup(NULL).\n* [Bug 1754] from 4.2.6p3-RC12: --version output should be more verbose.\n* [Bug 1757] from 4.2.6p3-RC12: oncore snprintf(\"%m\") doesn't expand %m.\n* from 4.2.6p3-RC12: Suppress ntp-keygen OpenSSL version display for\n --help, --version, display both build and runtime OpenSSL versions\n when they differ.\n* from 4.2.6p3-RC12: Upgrade to libopts 33.5.8 from AutoGen 5.11.6pre3.\n* Documentation updates from Dave Mills.\n(4.2.7p94) 2010/12/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1751] from 4.2.6p3-RC12: Support for Atari FreeMiNT OS.\n* Documentation updates from Dave Mills.\n(4.2.7p93) 2010/12/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1510] from 4.2.6p3-RC12: Add modes 20/21 for driver 8 to support\n RAWDCF @ 75 baud.\n* [Bug 1741] from 4.2.6p3-RC12: Enable multicast reception on each\n address (Windows).\n* from 4.2.6p3-RC12: Other manycastclient repairs:\n Separate handling of scope ID embedded in many in6_addr from ifindex\n used for IPv6 multicasting ioctls.\n Add INT_PRIVACY endpt bit flag for IPv6 RFC 4941 privacy addresses.\n Enable outbound multicast from only one address per interface in the\n same subnet, and in that case prefer embedded MAC address modified\n EUI-64 IPv6 addresses first, then static, and last RFC 4941 privacy\n addresses.\n Use setsockopt(IP[V6]_MULTICAST_IF) before each send to multicast to\n select the local source address, using the correct socket is not\n enough.\n* \"server ... ident <groupname>\" changes from Dave Mills.\n* Documentation updates from Dave Mills.\n(4.2.7p92) 2010/12/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1743] from 4.2.6p3-RC12: Display timezone offset when showing\n time for sntp in the local timezone.\n(4.2.7p91) 2010/12/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1732] ntpd ties up CPU on disconnected USB device.\n* [Bug 1742] form 4.2.6p3-RC12: Fix a typo in an error message in the\n \"build\" script.\n(4.2.7p90) 2010/12/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1738] Windows ntpd has wrong net adapter name.\n* [Bug 1740] ntpdc -c reslist packet count wrongly treated as signed.\n(4.2.7p89) 2010/12/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1736] tos int, bool options broken in 4.2.7p66.\n* from 4.2.6p3-RC12: Clean up the SNTP documentation.\n(4.2.7p88) 2010/12/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1735] 'clocktime()' aborts ntpd on bogus input\n(4.2.7p87) 2010/12/01 Released by Harlan Stenn <stenn@ntp.org>\n* from 4.2.6p3-RC12: Clean up m4 quoting in configure.ac, *.m4 files,\n resolving intermittent AC_LANG_PROGRAM possibly undefined errors.\n(4.2.7p86) 2010/11/29 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p85) 2010/11/24 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p84) 2010/11/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1618] Unreachable code in jjy_start().\n* [Bug 1725] from 4.2.6p3-RC11: ntpd sends multicast from only one\n address.\n* from 4.2.6p3-RC11: Upgrade libopts to 33.3.8.\n* from 4.2.6p3-RC11: Bump minimum Automake version to 1.11, required for\n AM_COND_IF use in LIBOPTS_CHECK.\n* An almost complete rebuild of the initial loopfilter configuration\n process, including the code that determines the interval between\n frequency file updates, from Dave Mills.\n* Documentation updates from Dave Mills.\n* Add ntp-keygen -l/--lifetime to control certificate expiry.\n* JJY driver improvements for Tristate JJY01/02, including changes\n to its clockstats format.\n* Add \"nonvolatile\" ntp.conf directive to control how often the\n driftfile is written.\n(4.2.7p83) 2010/11/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1727] ntp-keygen PLEN, ILEN undeclared --without-crypto.\n* Remove top-level libopts, use sntp/libopts.\n* from 4.2.6p3-RC11: Remove log_msg() and debug_msg() from sntp in favor\n of msyslog().\n* Documentation updates from Dave Mills.\n(4.2.7p82) 2010/11/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1728] from 4.2.6p3-RC11: In ntp_openssl.m4, don't add\n -I/usr/include or -L/usr/lib to CPPFLAGS or LDFLAGS.\n(4.2.7p81) 2010/11/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1681] from 4.2.6p3-RC10: More sntp logging cleanup.\n* [Bug 1683] from 4.2.6p3-RC10: Non-localhost on loopback exempted from\n nic rules.\n* [Bug 1719] Cleanup for ntp-keygen and fix -V crash, from Dave Mills.\n(4.2.7p80) 2010/11/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1574] from 4.2.6p3-RC9: sntp doesn't set tv_usec correctly.\n* [Bug 1681] from 4.2.6p3-RC9: sntp logging cleanup.\n* [Bug 1683] from 4.2.6p3-RC9: Interface binding does not seem to work\n as intended.\n* [Bug 1708] make check fails with googletest 1.4.0.\n* [Bug 1709] from 4.2.6p3-RC9: ntpdate ignores replies with equal\n receive and transmit timestamps.\n* [Bug 1715] sntp utilitiesTest.IPv6Address failed.\n* [Bug 1718] Improve gtest checks in configure.ac.\n(4.2.7p79) 2010/11/07 Released by Harlan Stenn <stenn@ntp.org>\n* Correct frequency estimate with no drift file, from David Mills.\n(4.2.7p78) 2010/11/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1697] filegen implementation should be improved.\n* Refactor calendar functions in terms of new common code.\n* Documentation updates from Dave Mills.\n(4.2.7p77) 2010/11/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1692] packageinfo.sh needs to be \"sourced\" using ./ .\n* [Bug 1695] ntpdate takes longer than necessary.\n(4.2.7p76) 2010/11/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1690] Unit tests fails to build on some systems.\n* [Bug 1691] Use first NMEA sentence each second.\n* Put the sntp tests under sntp/ .\n* ... and only build/run them if we have gtest.\n* Documentation updates from Dave Mills.\n(4.2.7p75) 2010/10/30 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* Include Linus Karlsson's GSoC 2010 testing code.\n(4.2.7p74) 2010/10/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1685] from 4.2.6p3-RC8: NMEA driver mode byte confusion.\n* from 4.2.6p3-RC8: First cut at using scripts/checkChangeLog.\n* Documentation updates from Dave Mills.\n(4.2.7p73) 2010/10/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1680] Fix alignment of clock_select() arrays.\n* refinements to new startup behavior from David Mills.\n* For the bootstrap script, touch .html files last.\n* Add 'make check' test case that would have caught [Bug 1678].\n(4.2.7p72) 2010/10/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1679] Fix test for -lsocket.\n* Clean up missing ;; entries in configure.ac.\n(4.2.7p71) 2010/10/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1676] from 4.2.6p3-RC7: NMEA: $GPGLL did not work after fix\n for Bug 1571.\n* [Bug 1678] \"restrict source\" treated as \"restrict default\".\n* from 4.2.6p3-RC7: Added scripts/checkChangeLog.\n(4.2.7p70) 2010/10/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1571] from 4.2.6p3-RC6: NMEA does not relate data to PPS edge.\n* [Bug 1572] from 4.2.p63-RC6: NMEA time adjustment for GPZDG buggy.\n* [Bug 1675] from 4.2.6p3-RC6: Prohibit includefile remote config.\n* Enable generating ntpd/ntp_keyword.h after keyword-gen.c changes on\n Windows as well as POSIX platforms.\n* Fix from Dave Mills for a rare singularity in clock_combine().\n(4.2.7p69) 2010/10/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1671] Automatic delay calibration is sometimes inaccurate.\n(4.2.7p68) 2010/10/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1669] from 4.2.6p3-RC5: NTP fails to compile on IBM AIX 5.3.\n* [Bug 1670] Fix peer->bias and broadcastdelay.\n* Documentation updates from Dave Mills.\n* Documentation EOL cleanup.\n(4.2.7p67) 2010/10/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1649] from 4.2.6p3-RC5: Require NMEA checksum if $GPRMC or\n previously seen.\n(4.2.7p66) 2010/10/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1277] Provide and use O(1) FIFOs, esp. in the config tree code.\n* Remove unused 'bias' configuration keyword.\n(4.2.7p65) 2010/10/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1584] from 4.2.6p3-RC4: wrong SNMP type for precision,\n resolution.\n* Remove 'calldelay' and 'sign' remnants from parser, ntp_config.c.\n(4.2.7p64) 2010/10/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1584] from 4.2.6p3-RC3: ntpsnmpd OID must be mib-2.197.\n* [Bug 1659] from 4.2.6p3-RC4: Need CLOCK_TRUETIME not CLOCK_TRUE.\n* [Bug 1663] ntpdsim should not open net sockets.\n* [Bug 1665] from 4.2.6p3-RC4: is_anycast() u_int32_t should be u_int32.\n* from 4.2.6p3: ntpsnmpd, libntpq warning cleanup.\n* Remove 'calldelay' and 'sign' keywords (Dave Mills).\n* Documentation updates from Dave Mills.\n(4.2.7p63) 2010/10/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1080] from 4.2.6p3-RC3: ntpd on ipv6 routers very chatty.\n* Documentation nit cleanup.\n* Documentation updates from Dave Mills.\n(4.2.7p62) 2010/10/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 750] from 4.2.6p3-RC3: Non-existing device causes coredump with \n RIPE-NCC driver.\n* [Bug 1567] from 4.2.6p3-RC3: Support Arbiter 1093C Satellite Clock on\n Windows.\n* [Bug 1581] from 4.2.6p3-RC3: printf format string mismatch leftover.\n* [Bug 1659] from 4.2.6p3-RC3: Support Truetime Satellite Clocks on\n Windows. \n* [Bug 1660] from 4.2.6p3-RC3: On some systems, test is in /usr/bin, not\n /bin. \n* [Bug 1661] from 4.2.6p3-RC3: Re-indent refclock_ripencc.c.\n* Lose peer_count from ntp_peer.c and ntp_proto.c (Dave Mills).\n* Documentation updates from Dave Mills.\n(4.2.7p61) 2010/10/06 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation and code cleanup from Dave Mills. No more NTP_MAXASSOC.\n(4.2.7p60) 2010/10/04 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p59) 2010/10/02 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* Variable name cleanup from Dave Mills.\n* [Bug 1657] darwin needs res_9_init, not res_init.\n(4.2.7p58) 2010/09/30 Released by Harlan Stenn <stenn@ntp.org>\n* Clock select bugfix from Dave Mills.\n* [Bug 1554] peer may stay selected as system peer after becoming\n unreachable.\n* [Bug 1644] from 4.2.6p3-RC3: cvo.sh should use lsb_release to identify\n linux distros.\n* [Bug 1646] ntpd crashes with relative path to logfile.\n(4.2.7p57) 2010/09/27 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p56) 2010/09/25 Released by Harlan Stenn <stenn@ntp.org>\n* Clock combining algorithm improvements from Dave Mills.\n* Documentation updates from Dave Mills.\n* [Bug 1642] ntpdsim can't find simulate block in config file.\n* [Bug 1643] from 4.2.6p3-RC3: Range-check the decoding of the RIPE-NCC\n status codes.\n(4.2.7p55) 2010/09/22 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* [Bug 1636] from 4.2.6p3-RC2: segfault after denied remote config.\n(4.2.7p54) 2010/09/21 Released by Harlan Stenn <stenn@ntp.org>\n* More Initial convergence improvements from Dave Mills.\n* Documentation updates from Dave Mills.\n* [Bug 1635] from 4.2.6p3-RC2: \"filegen ... enable\" is not default.\n(4.2.7p53) 2010/09/20 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* More Initial convergence improvements from Dave Mills.\n(4.2.7p52) 2010/09/19 Released by Harlan Stenn <stenn@ntp.org>\n* Initial convergence improvements from Dave Mills.\n(4.2.7p51) 2010/09/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1344] from 4.2.6p3-RC1: ntpd on Windows exits without logging\n cause.\n* [Bug 1629] 4.2.7p50 configure.ac changes invalidate config.cache.\n* [Bug 1630] 4.2.7p50 cannot bootstrap on Autoconf 2.61.\n(4.2.7p50) 2010/09/16 Released by Harlan Stenn <stenn@ntp.org>\n* Cleanup NTP_LIB_M.\n* [Bug 1628] Clean up -lxnet/-lsocket usage for (open)solaris.\n(4.2.7p49) 2010/09/13 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p48) 2010/09/12 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p47) 2010/09/11 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* [Bug 1588] finish configure --disable-autokey implementation.\n* [Bug 1616] refclock_acts.c: if (pp->leap == 2) is always false.\n* [Bug 1620] [Backward Incompatible] \"discard minimum\" value should be in\n seconds, not log2 seconds.\n(4.2.7p46) 2010/09/10 Released by Harlan Stenn <stenn@ntp.org>\n* Use AC_SEARCH_LIBS instead of AC_CHECK_LIB for NTP_LIB_M.\n(4.2.7p45) 2010/09/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1578] Consistently use -lm when needed.\n(4.2.7p44) 2010/08/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1573] from 4.2.6p3-beta1: Miscalculation of offset in sntp.\n(4.2.7p43) 2010/08/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1602] Refactor some of the sntp/ directory to facililtate testing.\n(4.2.7p42) 2010/08/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1593] ntpd abort in free() with logconfig syntax error.\n* [Bug 1595] from 4.2.6p3-beta1: empty last line in key file causes\n duplicate key to be added\n* [Bug 1597] from 4.2.6p3-beta1: packet processing ignores RATE KoD packets,\n Because of a bug in string comparison.\n(4.2.7p41) 2010/07/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1581] from 4.2.6p3-beta1: ntp_intres.c size_t printf format\n string mismatch.\n* [Bug 1586] ntpd 4.2.7p40 doesn't write to syslog after fork on QNX.\n* Avoid race with parallel builds using same source directory in\n scripts/genver by using build directory for temporary files.\n* orphanwait documentation updates.\n(4.2.7p40) 2010/07/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1395] ease ntpdate elimination with ntpd -w/--wait-sync\n* [Bug 1396] allow servers on ntpd command line like ntpdate\n(4.2.7p39) 2010/07/09 Released by Harlan Stenn <stenn@ntp.org>\n* Fix typo in driver28.html.\n* [Bug 1581] from 4.2.6p2: size_t printf format string mismatches, IRIG\n string buffers undersized. Mostly backported from earlier ntp-dev\n fixes by Juergen Perlinger.\n(4.2.7p38) 2010/06/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1570] backported to 4.2.6p2-RC7.\n* [Bug 1575] from 4.2.6p2-RC7: use 'snprintf' with LIB_BUFLENGTH in\n inttoa.c, tvtoa.c and utvtoa.c\n* [Bug 1576] backported to 4.2.6p2-RC7.\n* Typo fix in a comment in ntp_proto.c.\n(4.2.7p37) 2010/06/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1576] sys/sysctl.h depends on sys/param.h on OpenBSD.\n(4.2.7p36) 2010/06/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1560] Initial support for orphanwait, from Dave Mills.\n* clock_filter()/reachability fixes from Dave Mills.\n(4.2.7p35) 2010/06/12 Released by Harlan Stenn <stenn@ntp.org>\n* Rewrite of multiprecision macros in 'ntp_fp.h' from J. Perlinger\n <perlinger@ntp.org>\n* [Bug 715] from 4.2.6p2-RC6: libisc Linux IPv6 interface iteration\n drops multicast flags.\n(4.2.7p34) 2010/06/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1570] serial clock drivers get outdated input from kernel tty\n line buffer after startup\n(4.2.7p33) 2010/06/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1561] from 4.2.6p2-RC5: ntpq, ntpdc \"passwd\" prompts for MD5\n password w/SHA1.\n* [Bug 1565] from 4.2.6p2-RC5: sntp/crypto.c compile fails on MacOS over\n vsnprintf().\n* from 4.2.6p2-RC5: Windows port: do not exit in\n ntp_timestamp_from_counter() without first logging the reason.\n(4.2.7p32) 2010/05/19 Released by Harlan Stenn <stenn@ntp.org>\n* Copyright file cleanup from Dave Mills.\n* [Bug 1555] from 4.2.6p2-RC4: sntp illegal C (mixed code and\n declarations).\n* [Bug 1558] pool prototype associations have 0.0.0.0 for remote addr.\n* configure.ac: add --disable-autokey, #define AUTOKEY to enable future\n support for building without Autokey, but with OpenSSL for its digest\n algorithms (hash functions). Code must be modified to use #ifdef\n AUTOKEY instead of #ifdef OPENSSL where appropriate to complete this.\n* include/ntp_crypto.h: make assumption AUTOKEY implies OPENSSL explicit.\n(4.2.7p31) 2010/05/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1325] from 4.2.6p2-RC3: unreachable code sntp recv_bcst_data().\n* [Bug 1459] from 4.2.6p2-RC3: sntp MD5 authentication does not work\n with ntpd.\n* [Bug 1552] from 4.2.6p2-RC3: update and complete broadcast and crypto\n features in sntp.\n* [Bug 1553] from 4.2.6p2-RC3: sntp/configure.ac OpenSSL support.\n* from 4.2.6p2-RC3: Escape unprintable characters in a refid in ntpq -p\n billboard.\n* from 4.2.6p2-RC3: Simplify hash client code by providing OpenSSL\n EVP_*() API when built without OpenSSL. (already in 4.2.7)\n* from 4.2.6p2-RC3: Do not depend on ASCII in sntp.\n(4.2.7p30) 2010/05/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1526] ntpd DNS pipe read EINTR with no network at startup.\n* Update the ChangeLog entries when merging items from -stable.\n(4.2.7p29) 2010/05/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1542] ntpd mrulist response may have incorrect last.older.\n* [Bug 1543] ntpq mrulist must refresh nonce when retrying.\n* [Bug 1544] ntpq mrulist sscanf timestamp format mismatch on 64-bit.\n* Windows compiling hints/winnt.html update from G. Sunil Tej.\n(4.2.7p28) 2010/05/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1512] from 4.2.6p2-RC3: ntpsnmpd should connect to net-snmpd\n via a unix-domain socket by default.\n Provide a command-line 'socket name' option.\n* [Bug 1538] from 4.2.6p2-RC3: update refclock_nmea.c's call to\n getprotobyname().\n* [Bug 1541] from 4.2.6p2-RC3: Fix wrong keyword for \"maxclock\".\n(4.2.7p27) 2010/04/27 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.7p26) 2010/04/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1465] from 4.2.6p2-RC2: Make sure time from TS2100 is not\n invalid (backport from -dev).\n* [Bug 1528] from 4.2.6p2-RC2: Fix EDITLINE_LIBS link order for ntpq\n and ntpdc.\n* [Bug 1531] Require nonce with mrulist requests.\n* [Bug 1532] Remove ntpd support for ntpdc's monlist in favor of ntpq's\n mrulist.\n* [Bug 1534] from 4.2.6p2-RC2: conflicts with VC++ 2010 errno.h.\n* [Bug 1535] from 4.2.6p2-RC2: \"restrict -4 default\" and \"restrict\n -6 default\" ignored.\n(4.2.7p25) 2010/04/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1528] from 4.2.6p2-RC2: Remove --with-arlib from br-flock.\n* [Bug 1503] [Bug 1504] [Bug 1518] [Bug 1522] from 4.2.6p2-RC2:\n all of which were fixed in 4.2.7 previously. \n(4.2.7p24) 2010/04/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1390] Control PPS on the Oncore M12.\n* [Bug 1518] Windows ntpd should lock to one processor more\n conservatively.\n* [Bug 1520] '%u' formats for size_t gives warnings with 64-bit builds.\n* [Bug 1522] Enable range syntax \"trustedkey (301 ... 399)\".\n* Documentation updates for 4.2.7p22 changes and additions, updating\n ntpdc.html, ntpq.html, accopt.html, confopt.html, manyopt.html,\n miscopt.html, and miscopt.txt.\n* accopt.html: non-ntpport doc changes from Dave Mills.\n* Modify full MRU list preemption when full to match \"discard monitor\"\n documentation, by removing exception for count == 1.\n(4.2.7p23) 2010/04/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1516] unpeer by IP address fails, DNS name works.\n* [Bug 1517] ntpq and ntpdc should verify reverse DNS before use.\n ntpq and ntpdc now use the following format for showing purported\n DNS names from IP address \"reverse\" DNS lookups when the DNS name\n does not exist or does not include the original IP address among\n the results: \"192.168.1.2 (fake.dns.local)\".\n(4.2.7p22) 2010/04/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1432] Don't set inheritable flag for linux capabilities.\n* [Bug 1465] Make sure time from TS2100 is not invalid.\n* [Bug 1483] AI_NUMERICSERV undefined in 4.2.7p20.\n* [Bug 1497] fudge is broken by getnetnum() change.\n* [Bug 1503] Auto-enabling of monitor for \"restrict ... limited\" wrong.\n* [Bug 1504] ntpdate tickles ntpd \"discard minimum 1\" rate limit if\n \"restrict ... limited\" is used.\n* ntpdate: stop querying source after KoD packet response, log it.\n* ntpdate: rate limit each server to 2s between packets.\n* From J. N. Perlinger: avoid pointer wraparound warnings in dolfptoa(),\n printf format mismatches with 64-bit size_t.\n* Broadcast client (ephemeral) associations should be demobilized only\n if they are not heard from for 10 consecutive polls, regardless of\n surviving the clock selection. Fix from David Mills.\n* Add \"ntpq -c ifstats\" similar to \"ntpdc -c ifstats\".\n* Add \"ntpq -c sysstats\" similar to \"ntpdc -c sysstats\".\n* Add \"ntpq -c monstats\" to show monlist knobs and stats.\n* Add \"ntpq -c mrulist\" similar to \"ntpdc -c monlist\" but not\n limited to 600 rows, and with filtering and sorting options:\n ntpq -c \"mrulist mincount=2 laddr=192.168.1.2 sort=-avgint\"\n ntpq -c \"mrulist sort=addr\"\n ntpq -c \"mrulist mincount=2 sort=count\"\n ntpq -c \"mrulist sort=-lstint\"\n* Modify internal representation of MRU list to use l_fp fixed-point\n NTP timestamps instead of seconds since startup. This increases the\n resolution and substantially improves accuracy of sorts involving\n timestamps, at the cost of flushing all MRU entries when the clock is\n stepped, to ensure the timestamps can be compared with the current\n get_systime() results.\n* Add ntp.conf \"mru\" directive to configure MRU parameters, such as\n \"mru mindepth 600 maxage 64 maxdepth 5000 maxmem 1024\" or\n \"mru initalloc 0 initmem 16 incalloc 99 incmem 4\". Several pairs are\n equivalent with one in units of MRU entries and its twin in units of\n kilobytes of memory, so the last one used in ntp.conf controls:\n maxdepth/maxmem, initalloc/initmem, incalloc/incmem. With the above\n values, ntpd will preallocate 16kB worth of MRU entries, allocating\n 4kB worth each time more are needed, with a hard limit of 1MB of MRU\n entries. Until there are more than 600 entries none would be reused.\n Then only entries for addresses last seen 64 seconds or longer ago are\n reused.\n* Limit \"ntpdc -c monlist\" response in ntpd to 600 entries, the previous\n overall limit on the MRU list depth which was driven by the monlist\n implementation limit of one request with a single multipacket\n response.\n* New \"pool\" directive implementation modeled on manycastclient.\n* Do not abort on non-ASCII characters in ntp.conf, ignore them.\n* ntpq: increase response reassembly limit from 24 to 32 packets, add\n discussion in comment regarding results with even larger MAXFRAGS.\n* ntpq: handle \"passwd MYPASSWORD\" (without prompting) as with ntpdc.\n* ntpdc: do not examine argument to \"passwd\" if not supplied.\n* configure: remove check for pointer type used with qsort(), we\n require ANSI C which mandates void *.\n* Reset sys_kodsent to 0 in proto_clr_stats().\n* Add sptoa()/sockporttoa() similar to stoa()/socktoa() adding :port.\n* Use memcpy() instead of memmove() when buffers can not overlap.\n* Remove sockaddr_storage from our sockaddr_u union of sockaddr,\n sockaddr_in, and sockaddr_in6, shaving about 100 bytes from its size\n and substantially decreasing MRU entry memory consumption.\n* Extend ntpq readvar (alias rv) to allow fetching up to three named\n variables in one operation: ntpq -c \"rv 0 version offset frequency\".\n* ntpq: use srchost variable to show .POOL. prototype associations'\n hostname instead of address 0.0.0.0.\n* \"restrict source ...\" configures override restrictions for time\n sources, allows tight default restrictions to be used with the pool\n directive (where server addresses are not known in advance).\n* Ignore \"preempt\" modifier on manycastclient and pool prototype\n associations. The resulting associations are preemptible, but the\n prototype must not be.\n* Maintain and use linked list of associations (struct peer) in ntpd,\n avoiding walking 128 hash table entries to iterate over peers.\n* Remove more workarounds unneeded since we require ISO C90 AKA ANSI C:\n - remove fallback implementations for memmove(), memset, strstr().\n - do not test for atexit() or memcpy().\n* Collapse a bunch of code duplication in ntpd/ntp_restrict.c added with\n support for IPv6.\n* Correct some corner case failures in automatically enabling the MRU\n list if any \"restrict ... limited\" is in effect, and in disabling MRU\n maintenance. (ntp_monitor.c, ntp_restrict.c)\n* Reverse the internal sort order of the address restriction lists, but\n preserve the same behavior. This allows removal of special-case code\n related to the default restrictions and more straightforward lookups\n of restrictions for a given address (now, stop on first match).\n* Move ntp_restrict.c MRU doubly-linked list maintenance code into\n ntp_lists.h macros, allowing more duplicated source excision.\n* Repair ntpdate.c to no longer test HAVE_TIMER_SETTIME.\n* Do not reference peer_node/unpeer_node after freeing when built with\n --disable-saveconfig and using DNS.\n(4.2.7p21) 2010/03/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1514] from 4.2.6p1-RC6: Typo in ntp_proto.c: fabs(foo < .4)\n should be fabs(foo) < .4.\n* [Bug 1464] from 4.2.6p1-RC6: synchronization source wrong for\n refclocks ARCRON_MSF (27) and SHM (28).\n* From 4.2.6p1-RC6: Correct Windows port's refclock_open() to\n return 0 on failure not -1.\n* From 4.2.6p1-RC6: Correct CHU, dumbclock, and WWVB drivers to\n check for 0 returned from refclock_open() on failure.\n* From 4.2.6p1-RC6: Correct \"SIMUL=4 ./flock-build -1\" to\n prioritize -1/--one.\n* [Bug 1306] constant conditionals in audio_gain().\n(4.2.7p20) 2010/02/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1483] hostname in ntp.conf \"restrict\" parameter rejected.\n* Use all addresses for each restrict by hostname.\n* Use async DNS to resolve trap directive hostnames.\n(4.2.7p19) 2010/02/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1338] Update the association type codes in ntpq.html.\n* [Bug 1478] from 4.2.6p1-RC5: linking fails: EVP_MD_pkey_type.\n* [Bug 1479] from 4.2.6p1-RC5: not finding readline headers.\n* [Bug 1484] from 4.2.6p1-RC5: ushort is not defined in QNX6.\n(4.2.7p18) 2010/02/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1480] from 4.2.6p1-RC5: snprintf() cleanup caused \n unterminated refclock IDs.\n* Stop using getaddrinfo() to convert numeric address strings to on-wire\n addresses in favor of is_ip_address() alone.\n(4.2.7p17) 2010/02/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1477] from 4.2.6p1-RC5: First non-gmake make in clone\n w/VPATH can't make COPYRIGHT.\n* Attempts to cure CID 108 CID 118 CID 119 TAINTED_SCALAR warnings.\n* Broaden ylwrap workaround VPATH_HACK to all non-GNU make.\n(4.2.7p16) 2010/02/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1474] from 4.2.6p1-RC4: ntp_keygen LCRYPTO after libntp.a.\n* Include 4.2.6p1-RC4: Remove arlib.\n(4.2.7p15) 2010/02/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1455] from 4.2.6p1: ntpd does not try /etc/ntp.audio.\n* Include 4.2.6p1: Convert many sprintf() calls to snprintf(), also\n strcpy(), strcat().\n* Include 4.2.6p1: Fix widely cut-n-pasted bug in refclock shutdown\n after failed start.\n* Include 4.2.6p1: Remove some dead code checking for emalloc()\n returning NULL.\n(4.2.7p14) 2010/02/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1338] ntpq displays incorrect association type codes.\n* [Bug 1469] u_int32, int32 changes broke HP-UX 10.20 build.\n* [Bug 1470] from 4.2.6p1: \"make distdir\" compiles keyword-gen.\n* [Bug 1471] CID 120 CID 121 CID 122 is_ip_address() uninit family.\n* [Bug 1472] CID 116 CID 117 minor warnings in new DNS code.\n* [Bug 1473] from 4.2.6p1: \"make distcheck\" version.m4 error.\n(4.2.7p13) 2010/01/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1467] from 4.2.6p1: Fix bogus rebuild of sntp/sntp.html.\n(4.2.7p12) 2010/01/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1468] 'make install' broken for root on default NFS mount.\n(4.2.7p11) 2010/01/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 47] Debugging and logging do not work after a fork.\n* [Bug 1010] getaddrinfo() could block and thus should not be called by\n the main thread/process.\n* New async DNS resolver in ntpd allows nonblocking queries anytime,\n instead of only once at startup.\n(4.2.7p10) 2010/01/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1140] from 4.2.6p1-RC5: Clean up debug.html, decode.html,\n and ntpq.html.\n* Include 4.2.6p1-RC3: Use TZ=UTC instead of TZ= when calling date in\n scripts/mkver.in .\n* [Bug 1448] from 4.2.6p1-RC3: Some macros not correctly conditionally\n or absolutely defined on Windows.\n* [Bug 1449] from 4.2.6p1-RC3: ntpsim.h in ntp_config.c should be used\n conditionally.\n* [Bug 1450] from 4.2.6p1-RC3: Option to exclude warnings not\n unconditionally defined on Windows.\n(4.2.7p9) 2010/01/13 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.7p8) 2010/01/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 702] ntpd service logic should use libopts to examine cmdline.\n* [Bug 1451] from 4.2.6p1-RC3: sntp leaks KoD entry updating.\n* [Bug 1453] from 4.2.6p1-RC3: Use $CC in config.cache filename.\n(4.2.7p7) 2009/12/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 620] ntpdc getresponse() esize != *rsize s/b size != *rsize.\n* [Bug 1446] 4.2.7p6 requires autogen, missing ntpd.1, *.texi, *.menu.\n(4.2.7p6) 2009/12/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1443] Remove unnecessary dependencies on ntp_io.h\n* [Bug 1442] Move Windows functions into libntp files\n* [Bug 1127] from 4.2.6p1-RC3: Check the return of X590_verify().\n* [Bug 1439] from 4.2.6p1-RC3: .texi gen after binary is linked.\n* [Bug 1440] from 4.2.6p1-RC3: Update configure.ac to support kfreebsd.\n* [Bug 1445] from 4.2.6p1-RC3: IRIX does not have -lcap or support\n linux capabilities.\n(4.2.7p5) 2009/12/25 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.6p1-RC2\n(4.2.7p4) 2009/12/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1429] ntpd -4 option does not reliably force IPv4 resolution.\n* [Bug 1431] System headers must come before ntp headers in ntp_intres.c .\n(4.2.7p3) 2009/12/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1426] scripts/VersionName needs . on the search path.\n* [Bug 1427] quote missing in ./build - shows up on NetBSD.\n* [Bug 1428] Use AC_HEADER_RESOLV to fix breaks from resolv.h\n(4.2.7p2) 2009/12/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1419] ntpdate, ntpdc, sntp, ntpd ignore configure --bindir.\n* [Bug 1421] add util/tg2, a clone of tg that works on Linux, NetBSD, and\n FreeBSD\n(4.2.7p1) 2009/12/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1348] ntpd Windows port should wait for sendto() completion.\n* [Bug 1413] test OpenSSL headers regarding -Wno-strict-prototypes.\n* [Bug 1418] building ntpd/ntpdc/ntpq statically with ssl fails.\n(4.2.7p0) 2009/12/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1412] m4/os_cflags.m4 caches results that depend on $CC.\n* [Bug 1414] Enable \"make distcheck\" success with BSD make.\n(4.2.7) 2009/12/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1407] configure.ac: recent GNU Make -v does not include \"version\".\n---\n(4.2.6p5) 2011/12/24 Released by Harlan Stenn <stenn@ntp.org>",
"No changes from 4.2.6p5-RC3.",
"---\n(4.2.6p5-RC3) 2011/12/08 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 2082] 3-char refid sent by ntpd 4.2.6p5-RC2 ends with extra dot.\n* [Bug 2085] clock_update() sys_rootdisp calculation omits root delay.\n* [Bug 2086] get_systime() should not offset by sys_residual.\n* [Bug 2087] sys_jitter calculation overweights sys.peer jitter.\n* Ensure NULL peer->dstadr is not accessed in orphan parent selection.",
"---\n(4.2.6p5-RC2) 2011/11/30 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 2050] Orphan mode stratum counting to infinity.\n* [Bug 2059] optional billboard column \"server\" does not honor -n.\n* [Bug 2066] ntpq lopeers ipv6 \"local\" column overrun.\n* [Bug 2068] ntpd sends nonprintable stratum 16 refid to ntpq.\n* [Bug 2069] broadcastclient, multicastclient spin up duplicate\n ephemeral associations without broadcastdelay.\n* [Bug 2072] Orphan parent selection metric needs ntohl().\n* Exclude not-yet-determined sys_refid from use in loopback TEST12\n (from David Mills).\n* Never send KoD rate limiting response to MODE_SERVER response.",
"---\n(4.2.6p5-RC1) 2011/10/18 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 2034] Listening address configuration with prefix misapplied.",
"---\n(4.2.6p4) 2011/09/22 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1984] ntp/libisc fails to compile on OS X 10.7 (Lion).\n* [Bug 1985] \"logconfig =allall\" rejected.\n* [Bug 2001] ntpdc timerstats reports overruns as handled.\n* [Bug 2003] libntpq ntpq_read_assoc_peervars() broken.\n* [Backward Incompatible] sntp: -l/--filelog -> -l/--logfile, to be\n consistent with ntpd.\n* libopts/file.c fix from Bruce Korb (arg-type=file).",
"---\n(4.2.6p4-RC2) 2011/08/04 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1608] Parse Refclock driver should honor trusttime.\n* [Bug 1961] html2man update: distribute ntp-wait.html.\n* [Bug 1970] UNLINK_EXPR_SLIST() causes crash if list is empty.\n* [Bug 1972] checking for struct rtattr fails.\n* [Bug 1975] libntp/mktime.c won't work with 64-bit time_t\n* [Bug 1978] [Bug 1134] fix in 4.2.6p4-RC1 doesn't build on older Linux.\n* Backport several fixes for Coverity warnings from ntp-dev.\n* Backport if_nametoindex() check for hpux.",
"---\n(4.2.6p4-RC1) 2011/07/10 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1134] ntpd fails binding to tentative IPv6 addresses.\n* [Bug 1790] Update config.guess and config.sub to detect AIX6.\n* [Bug 1961] html2man needs an update.\n* Update the NEWS file.",
"---\n(4.2.6p4-beta2) 2011/05/25 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1695] ntpdate takes longer than necessary.\n* [Bug 1832] ntpdate doesn't allow timeout > 2s.\n* [Bug 1933] WWVB/Spectracom driver timestamps LFs, not CRs.\n* Backport utility routines from ntp-dev: mprintf(), emalloc_zero().",
"---\n(4.2.6p4-beta1) 2011/05/16 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1554] peer may stay selected as system peer after becoming\n unreachable.\n* [Bug 1921] LOCAL, ACTS drivers with \"prefer\" excluded from initial\n candidate list.\n* [Bug 1923] orphan parent favored over LOCAL, ACTS drivers.\n* [Bug 1924] Billboard tally codes sometimes do not match operation,\n variables.\n* Enable tickadj-like taming of wildly off-spec Windows clock using\n NTPD_TICKADJ_PPM env. var. specifying baseline slew.\n* Upgrade to AutoGen 5.11.9 (and require it).\n* Upgrade to libopts 35.0.10 from AutoGen 5.11.9pre8.",
"---\n(4.2.6p3) 2011/01/03 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1764] Palisade driver doesn't build on Linux\n* Create and use scripts/check--help when generating .texi files.\n* Update bk triggers for the bk-5 release.\n* Update genCommitLog for the bk-5 release.\n* Update the copyright year.",
"---\n(4.2.6p3-RC12) 2010/12/25 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1458] Can not compile NTP on FreeBSD 4.7.\n* [Bug 1510] Add modes 20/21 for driver 8 to support RAWDCF @ 75 baud.\n* [Bug 1618] Unreachable code in jjy_start(). (backport from ntp-dev)\n* [Bug 1719] ntp-keygen -V crash. (backport)\n* [Bug 1740] ntpdc treats many counters as signed. (backport)\n* [Bug 1741] Enable multicast reception on each address (Windows).\n* [Bug 1742] Fix a typo in an error message in the \"build\" script.\n* [Bug 1743] Display timezone offset when showing time for sntp in the\nlocal timezone.\n* [Bug 1751] Support for Atari FreeMiNT OS.\n* [Bug 1754] --version output should be more verbose.\n* [Bug 1757] oncore snprintf(\"%m\") doesn't expand %m.\n* [Bug 1758] setsockopt IPV6_MULTICAST_IF with wrong ifindex.\n* [Bug 1760] ntpd Windows interpolation cannot be disabled.\n* [Bug 1762] manycastclient solicitation responses interfere.\n* Upgrade to libopts 34.0.9 from AutoGen 5.11.6pre7.\n* Relax minimum Automake version to 1.10 with updated libopts.m4.\n* Suppress ntp-keygen OpenSSL version display for --help, --version,\ndisplay both build and runtime OpenSSL versions when they differ.\n* Clean up m4 quoting in configure.ac, *.m4 files, resolving\n intermittent AC_LANG_PROGRAM possibly undefined errors.\n* Clean up the SNTP documentation.\n* Other manycastclient repairs:\n Separate handling of scope ID embedded in many in6_addr from ifindex\n used for IPv6 multicasting ioctls.\n Add INT_PRIVACY endpt bit flag for IPv6 RFC 4941 privacy addresses.\n Enable outbound multicast from only one address per interface in the\n same subnet, and in that case prefer embedded MAC address modified\n EUI-64 IPv6 addresses first, then static, and last RFC 4941 privacy\n addresses.\n Use setsockopt(IP[V6]_MULTICAST_IF) before each send to multicast to\n select the local source address, using the correct socket is not\n enough.",
"---\n(4.2.6p3-RC11) 2010/11/28 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1725] ntpd sends multicast from only one address.\n* [Bug 1728] In ntp_openssl.m4, don't add -I/usr/include or -L/usr/lib\n to CPPFLAGS or LDFLAGS.\n* [Bug 1733] IRIX doesn't have 'head' (affects scripts/checkChangeLog).\n* Remove log_msg() and debug_msg() from sntp in favor of msyslog().\n* Use a single copy of libopts/, in sntp/.\n* Upgrade libopts to 33.3.8.\n* Bump minimum Automake version to 1.11, required for AM_COND_IF\n use in LIBOPTS_CHECK.\n* Improvements to the 'build' script.",
"---\n(4.2.6p3-RC10) 2010/11/14 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1681] More sntp logging cleanup.\n* [Bug 1683] Non-localhost on loopback exempted from nic rules.",
"---\n(4.2.6p3-RC9) 2010/11/10 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1574] sntp:set_time doesn't set tv_usec correctly.\n* [Bug 1681] sntp logging cleanup.\n* [Bug 1683] Interface binding does not seem to work as intended.\n* [Bug 1691] Use first NMEA sentence each second.\n* [Bug 1692] packageinfo.sh needs to be \"sourced\" using ./ .\n* [Bug 1709] ntpdate ignores replies with equal receive and transmit\n timestamps.\n* Backport sntp from -dev",
"---\n(4.2.6p3-RC8) 2010/10/29 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1685] NMEA driver mode byte confusion.\n* First cut at using scripts/checkChangeLog.",
"---\n(4.2.6p3-RC7) 2010/10/25 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1676] NMEA: $GPGLL did not work after fix for Bug 1571.\n* Added scripts/checkChangeLog.",
"---\n(4.2.6p3-RC6) 2010/10/24 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1571] NMEA does not relate data to PPS edge.\n* [Bug 1572] NMEA time adjustment for GPZDG buggy.\n* [Bug 1675] Prohibit includefile remote config.",
"---\n(4.2.6p3-RC5) 2010/10/22 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1649] Require NMEA checksum if $GPRMC or previously seen.\n* [Bug 1669] NTP 4.2.6p2 fails to compile on IBM AIX 5.3.",
"---\n(4.2.6p3-RC4) 2010/10/16 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1584] wrong SNMP type for precision, resolution.\n* [Bug 1659] Need CLOCK_TRUETIME not CLOCK_TRUE.\n* [Bug 1665] is_anycast() u_int32_t should be u_int32.\n* ntpsnmpd, libntpq warning cleanup.",
"---\n(4.2.6p3-RC3) 2010/10/14 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 750] Non-existing device causes coredump with RIPE-NCC driver.\n* [Bug 1080] ntpd on ipv6 routers very chatty.\n* [Bug 1567] Support Arbiter 1093C Satellite Clock on Windows.\n* [Bug 1581] printf format string mismatch leftover.\n* [Bug 1584] ntpsnmpd OID must be mib-2.197.\n* [Bug 1643] Range-check the decoding of the RIPE-NCC status codes.\n* [Bug 1644] cvo.sh should use lsb_release to identify linux distros.\n* [Bug 1659] Support Truetime Satellite Clocks on Windows.\n* [Bug 1660] On some systems, test is in /usr/bin, not /bin.\n* [Bug 1661] Re-indent refclock_ripencc.c.",
"---\n(4.2.6p3-RC2) 2010/09/25 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1635] \"filegen ... enable\" is not default.\n* [Bug 1636] yyparse() segfault after denied filegen remote config.",
"---\n(4.2.6p3-RC1) 2010/09/18 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1344] ntpd on Windows exits without logging cause.",
"---\n(4.2.6p3-beta1) 2010/09/11 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1573] Miscalculation of offset in sntp.\n* [Bug 1595] empty last line in key file causes duplicate key to be added\n* [Bug 1597] packet processing ignores RATE KoD packets, because of\n a bug in string comparison.\n* [Bug 1581] ntp_intres.c size_t printf format string mismatch.",
"---\n(4.2.6p2) 2010/07/09 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1581] size_t printf format string mismatches, IRIG string buffers\n undersized. Mostly backported from earlier ntp-dev fixes by Juergen\n Perlinger.",
"---\n(4.2.6p2-RC7) 2010/06/19 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1570] serial clock drivers get outdated input from kernel tty\n line buffer after startup\n* [Bug 1575] use 'snprintf' with LIB_BUFLENGTH in inttoa.c, tvtoa.c and\n utvtoa.c\n* [Bug 1576] sys/sysctl.h depends on sys/param.h on OpenBSD.",
"---\n(4.2.6p2-RC6) 2010/06/12 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 715] libisc Linux IPv6 interface iteration drops multicast flags.",
"---\n(4.2.6p2-RC5) 2010/06/03 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1561] ntpq, ntpdc \"passwd\" prompts for MD5 password w/SHA1.\n* [Bug 1565] sntp/crypto.c compile fails on MacOS over vsnprintf().\n* Windows port: do not exit in ntp_timestamp_from_counter() without\n first logging the reason.\n* Support \"passwd blah\" syntax in ntpq.",
"---\n(4.2.6p2-RC4) 2010/05/19 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1555] 4.2.6p2-RC3 sntp illegal C (mixed code and declarations).",
"---\n(4.2.6p2-RC3) 2010/05/11 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1325] unreachable code in sntp recv_bcst_data().\n* [Bug 1459] sntp MD5 authentication does not work with ntpd.\n* [Bug 1512] ntpsnmpd should connect to net-snmpd via a unix-domain\n socket by default. Provide a command-line 'socket name' option.\n* [Bug 1538] update refclock_nmea.c's call to getprotobyname().\n* [Bug 1541] Fix wrong keyword for \"maxclock\".\n* [Bug 1552] update and complete broadcast and crypto features in sntp.\n* [Bug 1553] sntp/configure.ac OpenSSL support.\n* Escape unprintable characters in a refid in ntpq -p billboard.\n* Simplify hash client code by providing OpenSSL EVP_*() API when built\n without OpenSSL. (from ntp-dev)\n* Do not depend on ASCII values for ('A' - '0'), ('a' - '0') in sntp.\n* Windows compiling hints/winnt.html update from G. Sunil Tej.",
"---\n(4.2.6p2-RC2) 2010/04/27 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1465] Make sure time from TS2100 is not invalid (backport from\n ntp-dev).\n* [Bug 1528] Fix EDITLINE_LIBS link order for ntpq and ntpdc.\n* [Bug 1534] win32/include/isc/net.h conflicts with VC++ 2010 errno.h.\n* [Bug 1535] \"restrict -4 default\" and \"restrict -6 default\" ignored.\n* Remove --with-arlib from br-flock.",
"---\n(4.2.6p2-RC1) 2010/04/18 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1503] Auto-enabling of monitor for \"restrict ... limited\" wrong.\n* [Bug 1504] ntpdate tickles ntpd \"discard minimum 1\" rate limit if\n \"restrict ... limited\" is used.\n* [Bug 1518] Windows ntpd should lock to one processor more\n conservatively.\n* [Bug 1522] Enable range syntax \"trustedkey (301 ... 399)\".\n* Update html/authopt.html controlkey, requestkey, and trustedkey docs.",
"---\n(4.2.6p1) 2010/04/09 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.6p1-RC6) 2010/03/31 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1514] Typo in ntp_proto.c: fabs(foo < .4) should be fabs(foo) < .4.\n* [Bug 1464] synchronization source wrong for refclocks ARCRON_MSF (27)\n and SHM (28).\n* Correct Windows port's refclock_open() to return 0 on failure not -1.\n* Correct CHU, dumbclock, and WWVB drivers to check for 0 returned from\n refclock_open() on failure.\n* Correct \"SIMUL=4 ./flock-build -1\" to prioritize -1/--one.",
"---\n(4.2.6p1-RC5) 2010/02/09 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1140] Clean up debug.html, decode.html, and ntpq.html.\n* [Bug 1438] Remove dead code from sntp/networking.c.\n* [Bug 1477] 1st non-gmake make in clone w/VPATH can't make COPYRIGHT.\n* [Bug 1478] linking fails with undefined reference EVP_MD_pkey_type.\n* [Bug 1479] Compilation fails because of not finding readline headers.\n* [Bug 1480] snprintf() cleanup caused unterminated refclock IDs.\n* [Bug 1484] ushort is not defined in QNX6.",
"---\n(4.2.6p1-RC4) 2010/02/04 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1455] ntpd does not try /etc/ntp.audio as documented.\n* [Bug 1467] Fix bogus rebuild of sntp/sntp.html\n* [Bug 1470] \"make distdir\" in $srcdir builds keyword-gen, libntp.a.\n* [Bug 1473] \"make distcheck\" before build can't make sntp/version.m4.\n* [Bug 1474] ntp_keygen needs LCRYPTO after libntp.a.\n* Convert many sprintf() calls to snprintf(), also strcpy(), strcat().\n* Fix widely cut-n-pasted bug in refclock shutdown after failed start.\n* Remove some dead code checking for emalloc() returning NULL.\n* Remove arlib.",
"---\n(4.2.6p1-RC3) 2010/01/24 Released by Harlan Stenn <stenn@ntp.org>",
"* Use TZ=UTC instead of TZ= when calling date in scripts/mkver.in .\n* [Bug 1448] Some macros not correctly conditionally or absolutely defined\n on Windows.\n* [Bug 1449] ntpsim.h in ntp_config.c should be used conditionally.\n* [Bug 1450] Option to exclude warnings not unconditionally defined on Windows.\n* [Bug 1127] Properly check the return of X590_verify() - missed one.\n* [Bug 1439] .texi generation must wait until after binary is linked.\n* [Bug 1440] Update configure.ac to support kfreebsd.\n* [Bug 1445] IRIX does not have -lcap or support linux capabilities.\n* [Bug 1451] CID 115: sntp leaks KoD entry when updating existing.\n* [Bug 1453] Use $CC in config.cache filename in ./build script.",
"---\n(4.2.6p1-RC2) 2009/12/25 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1411] Fix status messages in refclock_oncore.c.\n* [Bug 1416] MAXDNAME undefined on Solaris 2.6.\n* [Bug 1419] ntpdate, ntpdc, sntp, ntpd ignore configure --bindir.\n* [Bug 1424] Fix check for rtattr (rtnetlink.h).\n* [Bug 1425] unpeer by association ID sets up for duplicate free().\n* [Bug 1426] scripts/VersionName needs . on the search path.\n* [Bug 1427] quote missing in ./build - shows up on NetBSD.\n* [Bug 1428] Use AC_HEADER_RESOLV to fix breaks from resolv.h\n* [Bug 1429] ntpd -4 option does not reliably force IPv4 resolution.\n* [Bug 1431] System headers must come before ntp headers in ntp_intres.c .\n* [Bug 1434] HP-UX 11 ip_mreq undeclared, _HPUX_SOURCE helps some.\n* [Bug 1435] sntp: Test for -lresolv using the same tests as in ntp.",
"---\n(4.2.6p1-RC1) 2009/12/20 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1409] Put refclock_neoclock4x.c under the NTP COPYRIGHT notice.\n This should allow debian and other distros to add this refclock driver\n in further distro releases.\n Detect R2 hardware releases.\n* [Bug 1412] m4/os_cflags.m4 caches results that depend on $CC.\n* [Bug 1413] test OpenSSL headers regarding -Wno-strict-prototypes.\n* [Bug 1414] Enable \"make distcheck\" success with BSD make.\n* [Bug 1415] Fix Mac OS X link problem.\n* [Bug 1418] building ntpd/ntpdc/ntpq statically with ssl fails.\n* Build infrastructure updates to enable beta releases of ntp-stable.",
"---\n(4.2.6) 2009/12/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Sec 1331] from4.2.4p8: DoS with mode 7 packets - CVE-2009-3563.\n* [Bug 508] Fixed leap second handling for Windows.\n(4.2.5p250-RC) 2009/11/30 Released by Harlan Stenn <stenn@ntp.org>\n* sntp documentation updates.\n* [Bug 761] internal resolver does not seem to honor -4/-6 qualifiers\n* [Bug 1386] Deferred DNS doesn't work on NetBSD\n* [Bug 1391] avoid invoking autogen twice for .c and .h files.\n* [Bug 1397] shmget() refclock_shm failing because of file mode.\n* Pass no_needed to ntp_intres as first part of fixing [Bug 975].\n* Add ./configure --enable-force-defer-DNS to help debugging.\n(4.2.5p249-RC) 2009/11/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1400] An empty KOD DB file causes sntp to coredump.\n* sntp: documentation cleanup.\n* sntp: clean up some error messages.\n* sntp: Use the precision to control how many offset digits are shown.\n* sntp: Show root dispersion.\n* Cleanup from the automake/autoconf upgrades.\n(4.2.5p248-RC) 2009/11/26 Released by Harlan Stenn <stenn@ntp.org>\n* Prepare for the generation of sntp.html.\n* Documentation changes from Dave Mills.\n* [Bug 1387] Storage leak in ntp_intres (minor).\n* [Bug 1389] buffer overflow in refclock_oncore.c\n* [Bug 1391] .texi usage text from installed, not built binaries.\n* [Bug 1392] intres retries duplicate assocations endlessly.\n* Correct *-opts.h dependency so default 'get' action isn't used.\n(4.2.5p247-RC) 2009/11/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1142] nodebug builds shed no light on -d, -D option failure.\n* [Bug 1179] point out the problem with -i/--jaildir and -u/--user when\n they are disabled by configure.\n* [Bug 1308] support systems that lack fork().\n* [Bug 1343] sntp doesn't link on Solaris 7, needs -lresolv.\n(4.2.5p246-RC) 2009/11/17 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to autogen-5.10\n* [Bug 1378] Unnecessary resetting of peers during interface update.\n* [Bug 1382] p245 configure --disable-dependency-tracking won't build.\n* [Bug 1384] ntpq :config core dumped with a blank password.\n(4.2.5p245-RC) 2009/11/14 Released by Harlan Stenn <stenn@ntp.org>\n* Cleanup from Dave Mills.\n* [Bug 1343] sntp illegal C does not compile on Solaris 7.\n* [Bug 1381] Version .deps generated include file dependencies to allow\n known dependency-breaking changes to force .deps to be cleaned,\n triggered by changing the contents of deps-ver and/or sntp/deps-ver.\n(4.2.5p244-RC) 2009/11/12 Released by Harlan Stenn <stenn@ntp.org>\n* keygen.html updates from Dave Mills.\n* [Bug 1003] ntpdc unconfig command doesn't prompt for keyid.\n* [Bug 1376] Enable authenticated ntpq and ntpdc using newly-available\n digest types.\n* ntp-keygen, Autokey OpenSSL build vs. run version mismatch is now a\n non-fatal warning.\n(4.2.5p243-RC) 2009/11/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1226] Fix deferred DNS lookups.\n* new crypto signature cleanup.\n(4.2.5p242-RC) 2009/11/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1363] CID 92 clarify fallthrough case in clk_trimtsip.c\n* [Bug 1366] ioctl(TIOCSCTTY, 0) fails on NetBSD *[0-2].* > 3.99.7.\n* [Bug 1368] typos in libntp --without-crypto case\n* [Bug 1371] deferred DNS lookup failing with INFO_ERR_AUTH.\n* CID 87 dead code in ntpq.c atoascii().\n* Fix authenticated ntpdc, broken in p240.\n* Stub out isc/mem.h, shaving 47k from a MIPS ntpd binary.\n* Shrink keyword scanner FSM entries from 64 to 32 bits apiece.\n* Documention updates from Dave Mills.\n* authkeys.c cleanup from Dave Mills.\n(4.2.5p241-RC) 2009/11/07 Released by Harlan Stenn <stenn@ntp.org>\n* html/authopt.html update from Dave Mills.\n* Remove unused file from sntp/Makefile.am's distribution list.\n* new crypto signature cleanup.\n(4.2.5p240-RC) 2009/11/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1364] clock_gettime() not detected, need -lrt on Debian 5.0.3.\n* Provide all of OpenSSL's signature methods for ntp.keys (FIPS 140-2).\n(4.2.5p239-RC) 2009/10/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1357] bogus assert from refclock_shm.\n* [Bug 1359] Debug message cleanup.\n* CID 101: more pointer/array cleanup.\n* [Bug 1356] core dump from refclock_nmea when can't open /dev/gpsU.\n* [Bug 1358] AIX 4.3 sntp/networking.c IPV6_JOIN_GROUP undeclared.\n* CID 101: pointer/array cleanup.\n(4.2.5p238-RC) 2009/10/27 Released by Harlan Stenn <stenn@ntp.org>\n* Changes from Dave Mills.\n* driver4.html updates from Dave Mills.\n* [Bug 1252] PPSAPI cleanup on ntpd/refclock_wwvb.c.\n* [Bug 1354] libtool error building after bootstrap with Autoconf 2.64.\n* Allow NTP_VPATH_HACK configure test to handle newer gmake versions.\n* CIDs 94-99 make it more clearly impossible for sock_hash() to return\n a negative number.\n* CID 105, 106 ensure ntpdc arrays are not overrun even if callers\n misbehave.\n* CID 113 use va_end() in refclock_true.c true_debug().\n* Get rid of configure tests for __ss_family and __ss_len when the more\n common ss_family and ss_len are present.\n(4.2.5p237-RC) 2009/10/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 610] NMEA support for using PPSAPI on a different device.\n* [Bug 1238] use only fudge time2 to offset NMEA serial timestamp.\n* [Bug 1355] ntp-dev won't compile on OpenBSD 4.6.\n(4.2.5p236-RC) 2009/10/22 Released by Harlan Stenn <stenn@ntp.org>\n* Cleanup from Dave Mills.\n* [Bug 1343] ntpd/ntp_io.c close_fd() does not compile on Solaris 7.\n* [Bug 1353] ntpq \"rv 0 settimeofday\" always shows UNKNOWN on unix.\n* Do not attempt to execute built binaries from ntpd/Makefile when\n cross-compiling (keyword-gen and ntpd --saveconfigquit).\n* sntp/main.c: Remove duplicate global adr_buf[] (also defined in\n networking.c) which Piotr Grudzinski identified breaking his build.\n* Correct in6addr_any test in configure.ac to attempt link too.\n(4.2.5p235-RC) 2009/10/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1343] lib/isc build breaks on systems without IPv6 headers.\n(4.2.5p234-RC) 2009/10/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1339] redux, use unmodified lib/isc/win32/strerror.c and\n move #define strerror... to a header not used by lib/isc code.\n* [Bug 1345] illegal 'grep' option prevents compilation.\n* [Bug 1346] keyword scanner broken where char defaults to unsigned.\n* [Bug 1347] ntpd/complete.conf missing multicastclient test case.\n(4.2.5p233-RC) 2009/10/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1337] cast setsockopt() v4 address pointer to void *.\n* [Bug 1342] ignore|drop one IPv6 address on an interface blocks all\n addresses on that interface.\n* Documentation cleanup and updates.\n(4.2.5p232-RC) 2009/10/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1302] OpenSSL under Windows needs applink support.\n* [Bug 1337] fix incorrect args to setsockopt(fd, IP_MULTICAST_IF,...).\n* [Bug 1339] Fix Windows-only ntp_strerror() infinite recursion.\n* [Bug 1341] NMEA driver requires working PPSAPI #ifdef HAVE_PPSAPI.\n* Construct ntpd keyword scanner finite state machine at compile time\n rather than at runtime, shrink entries from 40+ to 8 bytes.\n* Update documentation for ntpq --old-rv, saveconfig, saveconfigdir,\n ntpd -I -L and -M, and interface/nic rules. (From Dave Hart)\n* [Bug 1337] fix incorrect args to setsockopt(fd, IP_MULTICAST_IF,...)\n(4.2.5p231-RC) 2009/10/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1335] Broadcast client degraded by wildcard default change.\n(4.2.5p230-RC) 2009/10/09 Released by Harlan Stenn <stenn@ntp.org>\n* Start the 4.2.6 Release Candidate cycle.\n* Broadcast and transit phase cleanup from Dave Mills.\n(4.2.5p229) 2009/10/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1334] ntpsnmpd undefined reference to `ntpqOptions'.\n* Change ntpsnmpd/Makefile.am include file order to fix FreeBSD build.\n(4.2.5p228) 2009/10/06 Released by Harlan Stenn <stenn@ntp.org>\n* Reclaim syntax tree memory after application in ntpd built with\n configure --disable-saveconfig.\n* [Bug 1135] ntpq uses sizeof(u_long) where sizeof(u_int32) is meant.\n* [Bug 1333] ntpd --interface precedence over --novirtualips lost.\n(4.2.5p227) 2009/10/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1135] :config fails with \"Server disallowed request\"\n* [Bug 1330] disallow interface/nic rules when --novirtualips or\n --interface are used.\n* [Bug 1332] ntpq -c 'rv 0 variablename' returns extra stuff.\n* Add test of ntpd --saveconfigquit fidelity using new complete.conf.\n* Documentation updates from Dave Hart/Dave Mills.\n(4.2.5p226) 2009/10/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1318] Allow multiple -g options on ntpd command line.\n* [Bug 1327] ntpq, ntpdc, ntp-keygen -d & -D should work with configure\n --disable-debugging.\n* Add ntpd --saveconfigquit <filename> option for future build-time\n testing of saveconfig fidelity.\n* Clockhop and autokey cleanup from Dave Mills.\n* Documentation updates from Dave Mills.\n(4.2.5p225) 2009/09/30 Released by Harlan Stenn <stenn@ntp.org>\n* authopt documentation changes from Dave Mills/Dave Hart.\n* [Bug 1324] support bracketed IPv6 numeric addresses for restrict.\n(4.2.5p224) 2009/09/29 Released by Harlan Stenn <stenn@ntp.org>\n* Clockhop and documentation fixes from Dave Mills.\n* Remove \"tos maxhop\" ntp.conf knob.\n(4.2.5p223) 2009/09/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1321] build doesn't work if . isn't on $PATH.\n* [Bug 1323] Implement \"revoke #\" to match documentation, deprecate\n \"crypto revoke #\".\n(4.2.5p222) 2009/09/27 Released by Harlan Stenn <stenn@ntp.org>\n* Update libisc code using bind-9.6.1-P1.tar.gz, rearrange our copy to\n mirror the upstream layout (lib/isc/...), and merge in NTP-local\n modifications to libisc. There is a new procedure to ease future\n libisc merges using a separate \"upstream\" bk repo. That will enable\n normal bk pull automerge to handle carrying forward any local changes\n and should enable us to take updated libisc snapshots more often.\n* Updated build and flock-build scripts. flock-build --one is a way\n to perform a flock-build compatible solitary build, handy for a repo\n clone's first build on a machine with autoconf, automake, etc.\n* Compiling ntp_parser.y using BSD make correctly places ntp_parser.h\n in the top-level ntpd directory instead of A.*/ntpd.\n* bootstrap script updated to remove potentially stale .deps dirs.\n* Remove unneeded Makefile.am files from the lib/isc/include tree.\n(4.2.5p221) 2009/09/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1316] segfault if refclock_nmea can't open file.\n* [Bug 1317] Distribute cvo.sh.\n(4.2.5p220) 2009/09/25 Released by Harlan Stenn <stenn@ntp.org>\n* Rearrange libisc code to match the upstream layout in BIND. This is\n step one of two, changing the layout but keeping our existing libisc.\n(4.2.5p219) 2009/09/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1315] \"interface ignore 0.0.0.0\" is ignored.\n* add implicit \"nic ignore all\" rule before any rules from ntp.conf, so\n \"nic listen eth0\" alone means the same as \"-I eth0\".\n* add wildcard match class for interface/nic rules.\n* fix mistaken carryover of prefixlen from one rule to the next.\n* Ensure IPv6 localhost address ::1 is included in libisc's Windows IPv6\n address enumeration, allowing ntpq and ntpdc's hardcoding to 127.0.0.1 \n on Windows to end.\n(4.2.5p218) 2009/09/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1314] saveconfig emits -4 and -6 on when not given.\n* correct parsing and processing of setvar directive.\n* highlight location of ntpq :config syntax errors with ^.\n* clarify (former) NO_ARG, SINGLE_ARG, MULTIPLE_ARG renaming to\n FOLLBY_TOKEN, FOLLBY_STRING, FOLLBY_STRINGS_TO_EOC.\n* parser, saveconfig cleanup to store T_ identifiers in syntax tree.\n(4.2.5p217) 2009/09/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1300] reject remote configuration of dangerous items.\n(4.2.5p216) 2009/09/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1312] ntpq/ntpdc MD5 passwords truncated to 8 chars on Suns.\n* CID 10 missing free(up); in refclock_palisade.c error return, again.\n* CID 83 added assertion to demonstrate config_nic_rules() does not\n call strchr(NULL, '/').\n(4.2.5p215) 2009/09/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1292] Workaround last VC6 unsigned __int64 kink.\n(4.2.5p214) 2009/09/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1303] remove top-level \"autokey\" directive.\n* use \"nic listen 192.168.0.0/16\" instead of\n \"nic listen 192.168.0.0 prefixlen 16\".\n(4.2.5p213) 2009/09/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1310] fix Thunderbolt mode in refclock_palisade.c\n(4.2.5p212) 2009/09/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 983] add interface [listen | ignore | drop] ... directive.\n* [Bug 1243] MD5auth_setkey zero-fills key from first zero octet.\n* [Bug 1295] leftover fix, do not crash on exit in free_config_trap()\n when \"trap 1.2.3.4\" is used without any further options.\n* [Bug 1311] 4.2.5p211 doesn't build in no-debug mode.\n* document interface (alias nic) and unpeer.\n* Correct syntax error line & column numbers.\n* CID 79: kod_init_kod_db() fails to fclose(db_s) in two error paths.\n* CID 80: attempt to quiet Coverity false positive re: leaking \"reason\"\n in main().\n* Documentation updates from Dave Mills.\n* CID 81: savedconfig leaked in save_config().\n* Make the code agree with the spec and the book (Dave Mills).\n(4.2.5p211) 2009/09/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 663] respect ntpq -c and -p order on command line.\n* [Bug 1292] more VC6 unsigned __int64 workarounds.\n* [Bug 1296] Added Support for Trimble Acutime Gold.\n(4.2.5p210) 2009/09/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1294] Use OPENSSL_INC and OPENSSL_LIB macros for Windows\n and remove unnecessary reference to applink.c for Windows\n* [Bug 1295] trap directive options are not optional.\n* [Bug 1297] yylex() must always set yylval before returning.\n(4.2.5p209) 2009/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1290] Fix to use GETTIMEOFDAY macro\n* [Bug 1289] Update project files for VC6, VS2003, VS2005, VS 2008\n(4.2.5p208) 2009/08/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1293] make configuration dumper ready for release, specifically:\n* rename ntpq dumpcfg command to \"saveconfig\".\n* require authentication for saveconfig.\n* \"restrict ... nomodify\" prevents saveconfig and :config.\n* \"saveconfig .\" shorthand to save to startup configuration file.\n* support strftime() substitution in saveconfig arg to timestamp\n the output filename, for example \"saveconfig %Y%m%d-%H%M%S.conf\".\n* display saveconfig response message from ntpd in ntpq.\n* save output filename in \"savedconfig\" variable, fetched with ntpq -c\n \"rv 0 savedconfig\".\n* document saveconfig in html/ntpq.html.\n* add ./configure --disable-saveconfig to build a smaller ntpd.\n* log saveconfig failures and successes to syslog.\n(4.2.5p207) 2009/08/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1292] Minor Windows source tweaks for VC6-era SDK headers.\n(4.2.5p206) 2009/08/26 Released by Harlan Stenn <stenn@ntp.org>\n* accopt.html typo fixes from Dave Mills.\n* [Bug 1283] default to remembering KoD in sntp.\n* clean up numerous sntp/kod_management.c bugs.\n* use all addresses resolved from each DNS name in sntp.\n(4.2.5p205) 2009/08/18 Released by Harlan Stenn <stenn@ntp.org>\n* accopt.html typo fixes from Dave Mills.\n* [Bug 1285] Log ntpq :config/config-from-file events.\n* [Bug 1286] dumpcfg omits statsdir, mangles filegen.\n(4.2.5p204) 2009/08/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1284] infinite loop in ntpd dumping more than one trustedkey\n(4.2.5p203) 2009/08/16 Released by Harlan Stenn <stenn@ntp.org>\n* Add ntpq -c dumpcfg, Google Summer of Code project of Max Kuehn\n(4.2.5p202) 2009/08/14 Released by Harlan Stenn <stenn@ntp.org>\n* install the binary and man page for sntp.\n(4.2.5p201) 2009/08/13 Released by Harlan Stenn <stenn@ntp.org>\n* sntp: out with the old, in with the new.\n(4.2.5p200) 2009/08/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1281] Build ntpd on Windows without big SDK download, burn,\n and install by checking in essentially unchanging messages.mc build\n products to avoid requiring mc.exe, which is not included with VC++\n 2008 EE.\n(4.2.5p199) 2009/08/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1279] Cleanup for warnings from Veracode static analysis.\n(4.2.5p198) 2009/08/03 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to autogen-5.9.9-pre5.\n(4.2.5p197) 2009/07/30 Released by Harlan Stenn <stenn@ntp.org>\n* The build script now has . at the end of PATH for config.guess.\n(4.2.5p196) 2009/07/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1272] gsoc_sntp IPv6 build problems under HP-UX 10.\n* [Bug 1273] CID 10: Palisade leaks unit struct in error path.\n* [Bug 1274] CID 67: ensure resolve_hosts() output count and pointers\n are consistent.\n* [Bug 1275] CID 45: CID 46: old sntp uses uninitialized guesses[0],\n precs[0].\n* [Bug 1276] CID 52: crypto_xmit() may call crypto_alice[23]()\n with NULL peer.\n(4.2.5p195) 2009/07/27 Released by Harlan Stenn <stenn@ntp.org>\n* cvo.sh: Add support for CentOS, Fedora, Slackware, SuSE, and QNX.\n(4.2.5p194) 2009/07/26 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* Use scripts/cvo.sh in the build script to get better subdir names.\n(4.2.5p193) 2009/07/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1261] CID 34: simulate_server() rbuf.msg_flags uninitialized.\n* [Bug 1262] CID 35: xpkt.mac uninitialized in simulate_server().\n* [Bug 1263] CID 37: CID 38: CID 40: CID 43: multiple refclocks \n uninitialized tm_zone (arc, chronolog, dumbclock, pcf).\n* [Bug 1264] CID 64: gsoc_sntp on_wire() frees wrong ptr receiving KoD.\n* [Bug 1265] CID 65: CID 66: gsoc_sntp on_wire() leaks x_pkt, r_pkt.\n* [Bug 1266] CID 39: datum_pts_start() uninitialized arg.c_ospeed.\n* [Bug 1267] CID 44: old sntp handle_saving() writes stack garbage to\n file when clearing.\n* [Bug 1268] CID 63: resolve_hosts() leaks error message buffer.\n* [Bug 1269] CID 74: use assertion to ensure move_fd() does not return\n negative descriptors.\n* [Bug 1270] CID 70: gsoc_sntp recv_bcst_data mdevadr.ipv6mr_interface\n uninitialized.\n(4.2.5p192) 2009/07/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 965] CID 42: ss_family uninitialized.\n* [Bug 1250] CID 53: kod_init_kod_db() overruns kod_db malloc'd buffer.\n* [Bug 1251] CID 68: search_entry() mishandles dst argument.\n* [Bug 1252] CID 32: Quiet Coverity warning with assertion.\n* [Bug 1253] CID 50: gsoc_sntp/crypto.c auth_init() always returns a \n list with one entry.\n* [Bug 1254] CID 56: tv_to_str() leaks a struct tm each call.\n* [Bug 1255] CID 55: pkt_output() leaks a copy of each packet.\n* [Bug 1256] CID 51: Coverity doesn't recognize our assertion macros as\n terminal.\n* [Bug 1257] CID 57: gsoc_sntp auth_init() fails to fclose(keyfile).\n* [Bug 1258] CID 54: gsoc_sntp resolve_hosts() needs simplification.\n* [Bug 1259] CID 59: gsoc_sntp recv_bcast_data() fails to free(rdata)\n on error paths.\n* [Bug 1260] CID 60: gsoc_sntp recvpkt() fails to free(rdata).\n* Updated to AutoGen-5.9.9pre2.\n(4.2.5p191) 2009/07/21 Released by Harlan Stenn <stenn@ntp.org>\n* Updated to AutoGen-5.9.9pre1.\n(4.2.5p190) 2009/07/20 Released by Harlan Stenn <stenn@ntp.org>\n* Updated to AutoGen-5.9.8.\n* [Bug 1248] RES_MSSNTP typo in ntp_proto.c.\n* [Bug 1246] use a common template for singly-linked lists, convert most\n doubly-linked lists to singly-linked.\n* Log warning about signd blocking when restrict mssntp used.\n(4.2.5p189) 2009/07/16 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation cleanup from Dave Mills.\n(4.2.5p188) 2009/07/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1245] Broken xmt time sent in fast_xmit() of 4.2.5p187.\n(4.2.5p187) 2009/07/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1042] multicast listeners IPv4+6 ignore new interfaces.\n* [Bug 1237] Windows serial code treat CR and LF both as line\n terminators.\n* [Bug 1238] use fudge time2 for serial timecode offset in NMEA driver.\n* [Bug 1242] Remove --enable-wintime, symmetric workaround is now\n always enabled.\n* [Bug 1244] NTP_INSIST(fd != maxactivefd) failure in intres child\n* Added restrict keyword \"mssntp\" for Samba4 DC operation, by Dave Mills.\n(4.2.5p186) 2009/07/08 Released by Harlan Stenn <stenn@ntp.org>\n* ntp_proto.c cleanup from Dave Mills.\n(4.2.5p185) 2009/07/01 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* [Bug 1234] convert NMEA driver to use common PPSAPI code.\n* timepps-Solaris.h pps_handle_t changed from pointer to scalar\n* Spectracom refclock added to Windows port of ntpd\n* [Bug 1236] Declaration order fixed.\n* Bracket private ONCORE debug statements with #if 0 rather than #ifdef\n DEBUG\n* Delete ONCORE debug statement that is now handled elsewhere.\n(4.2.5p184) 2009/06/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1233] atom refclock fudge time1 sign flipped in 4.2.5p164.\n(4.2.5p183) 2009/06/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1196] setsockopt(SO_EXCLUSIVEADDRUSE) can fail on Windows 2000\n and earlier with WSAINVAL, do not log a complaint in that case.\n* [Bug 1210] ONCORE driver terminates ntpd without logging a reason.\n* [Bug 1218] Correct comment in refclock_oncore on /etc/ntp.oncore*\n configuration file search order.\n* Change ONCORE driver to log using msyslog as well as to any\n clockstats file.\n* [Bug 1231] ntpsnmpd build fails after sockaddr union changes.\n(4.2.5p182) 2009/06/18 Released by Harlan Stenn <stenn@ntp.org>\n* Add missing header dependencies to the ntpdc layout verification.\n* prefer.html updates from Dave Mills.\n* [Bug 1205] Add ntpd --usepcc and --pccfreq options on Windows\n* [Bug 1215] unpeer by association ID\n* [Bug 1225] Broadcast address miscalculated on Windows 4.2.5p180\n* [Bug 1229] autokey segfaults in cert_install().\n* Use a union for structs sockaddr, sockaddr_storage, sockaddr_in, and\n sockaddr_in6 to remove casts and enable type checking. Collapse\n some previously separate IPv4/IPv6 paths into a single codepath.\n(4.2.5p181) 2009/06/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1206] Required compiler changes for Windows\n* [Bug 1084] PPSAPI for ntpd on Windows with DLL backends\n* [Bug 1204] Unix-style refclock device paths on Windows\n* [Bug 1205] partial fix, disable RDTSC use by default on Windows\n* [Bug 1208] decodenetnum() buffer overrun on [ with no ]\n* [Bug 1211] keysdir free()d twice #ifdef DEBUG\n* Enable ONCORE, ARCRON refclocks on Windows (untested)\n(4.2.5p180) 2009/05/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1200] Enable IPv6 in Windows port\n* Lose FLAG_FIXPOLL, from Dave Mills.\n(4.2.5p179) 2009/05/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1041] xmt -> aorg timestamp cleanup from Dave Mills,\n reported by Dave Hart.\n* [Bug 1193] Compile error: conflicting types for emalloc.\n* [Bug 1196] VC6 winsock2.h does not define SO_EXCLUSIVEADDRUSE.\n* Leap/expire cleanup from Dave Mills.\n(4.2.5p178) 2009/05/21 Released by Harlan Stenn <stenn@ntp.org>\n* Provide erealloc() and estrdup(), a la emalloc().\n* Improve ntp.conf's parser error messages.\n* [Bug 320] \"restrict default ignore\" does not affect IPv6.\n* [Bug 1192] \"restrict -6 ...\" reports a syntax error.\n(4.2.5p177) 2009/05/18 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p7\n* [Bug 1174] nmea_shutdown assumes that nmea has a unit assigned\n* [Bug 1190] NMEA refclock fudge flag4 1 obscures position in timecode\n* Update NMEA refclock documentation in html/drivers/driver20.html\n(4.2.5p176) 2009/05/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1154] mDNS registration should be done later, repeatedly and only\n if asked for. (second try for fix)\n(4.2.5p175) 2009/05/12 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p7-RC7\n* [Bug 1180] ntpd won't start with more than ~1000 interfaces\n* [Bug 1182] Documentation typos and missing bits.\n* [Bug 1183] COM port support should extend past COM3\n* [Bug 1184] ntpd is deaf when restricted to second IP on the same net\n* Clean up configure.ac NTP_CACHEVERSION interface, display cache\n version when clearing. Fixes a regression.\n(4.2.5p174) 2009/05/09 Released by Harlan Stenn <stenn@ntp.org>\n* Stale leapsecond file fixes from Dave Mills.\n(4.2.5p173) 2009/05/08 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p7-RC6\n(4.2.5p172) 2009/05/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1175] Instability in PLL daemon mode.\n* [Bug 1176] refclock_parse.c does not compile without PPSAPI.\n(4.2.5p171) 2009/05/04 Released by Harlan Stenn <stenn@ntp.org>\n* Autokey documentation cleanup from Dave Mills.\n* [Bug 1171] line editing libs found without headers (Solaris 11)\n* [Bug 1173] NMEA refclock fails with Solaris PPSAPI\n* Fix problem linking msntp on Solaris when sntp subdir is configured\n before parent caused by different gethostent library search order.\n* Do not clear config.cache when it is empty.\n(4.2.5p170) 2009/05/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1152] adjust PARSE to new refclock_pps logic\n* Include 4.2.4p7-RC5\n* loopfilter FLL/PLL crossover cleanup from Dave Mills.\n* Documentation updates from Dave Mills.\n* ntp-keygen cleanup from Dave Mills.\n* crypto API cleanup from Dave Mills.\n* Add NTP_CACHEVERSION mechanism to ignore incompatible config.cache\n* Enable gcc -Wstrict-overflow for gsoc_sntp as well\n(4.2.5p169) 2009/04/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1171] Note that we never look for -lreadline by default.\n* [Bug 1090] Fix bogus leap seconds in refclock_hpgps.\n(4.2.5p168) 2009/04/29 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p7-RC4\n* [Bug 1169] quiet compiler warnings\n* Re-enable gcc -Wstrict-prototypes when not building with OpenSSL\n* Enable gcc -Wstrict-overflow\n* ntpq/ntpdc emit newline after accepting password on Windows\n* Updates from Dave Mills:\n* ntp-keygen.c: Updates.\n* Fix the error return and syslog function ID in refclock_{param,ppsapi}.\n* Make sure syspoll is within the peer's minpoll/maxpoll bounds.\n* ntp_crypto.c: Use sign_siglen, not len. sign key filename cleanup.\n* Bump NTP_MAXEXTEN from 1024 to 2048, update values for some field lengths.\n* m4/ntp_lineeditlibs.m4: fix warnings from newer Autoconf\n* [Bug 1166] Remove truncation of position (blanking) code in refclock_nmea.c\n(4.2.5p167) 2009/04/26 Released by Harlan Stenn <stenn@ntp.org>\n* Crypto cleanup from Dave Mills.\n(4.2.5p166) 2009/04/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1165] Clean up small memory leaks in the config file parser\n* Correct logconfig keyword declaration to MULTIPLE_ARG\n* Enable filename and line number leak reporting on Windows when built\n DEBUG for all the typical C runtime allocators such as calloc,\n malloc, and strdup. Previously only emalloc calls were covered.\n* Add DEBUG-only code to free dynamically allocated memory that would\n otherwise remain allocated at ntpd exit, to allow less forgivable\n leaks to stand out in leaks reported after exit.\n* Ensure termination of strings in ports/winnt/libisc/isc_strerror.c\n and quiet compiler warnings.\n* [Bug 1057] ntpdc unconfig failure\n* [Bug 1161] unpeer AKA unconfig command for ntpq :config\n* PPS and crypto cleanup in ntp_proto.c from Dave Mills.\n(4.2.5p165) 2009/04/23 Released by Harlan Stenn <stenn@ntp.org>\n* WWVB refclock cleanup from Dave Mills.\n* Code cleanup: requested_key -> request_key.\n* [Bug 833] ignore whitespace at end of remote configuration lines\n* [Bug 1033] ntpdc/ntpq crash prompting for keyid on Windows\n* [Bug 1028] Support for W32Time authentication via Samba.\n* quiet ntp_parser.c malloc redeclaration warning\n* Mitigation and PPS/PPSAPI cleanup from Dave Mills.\n* Documentation updates from Dave Mills.\n* timepps-Solaris.h patches from Dave Hart.\n(4.2.5p164) 2009/04/22 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p7-RC3\n* PPS/PPSAPI cleanup from Dave Mills.\n* Documentation updates from Dave Mills.\n* [Bug 1125] C runtime per-thread initialization on Windows\n* [Bug 1152] temporarily disable refclock_parse, refclock_true until\n maintainers can repair build break from pps_sample()\n* [Bug 1153] refclock_nmea should not mix UTC with GPS time\n* [Bug 1159] ntpq overlap diagnostic message test buggy\n(4.2.5p163) 2009/04/10 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.5p162) 2009/04/09 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* Mitigation and PPS cleanup from Dave Mills.\n* Include 4.2.4p7-RC2\n* [Bug 216] New interpolation scheme for Windows eliminates 1ms jitter\n* remove a bunch of #ifdef SYS_WINNT from portable code\n* 64-bit time_t cleanup for building on newer Windows compilers\n* Only set CMOS clock during ntpd exit on Windows if the computer is\n shutting down or restarting.\n* [Bug 1148] NMEA reference clock improvements\n* remove deleted gsoc_sntp/utilities.o from repository so that .o build\n products can be cleaned up without corrupting the repository.\n(4.2.5p161) 2009/03/31 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.5p160) 2009/03/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1141] refclock_report missing braces cause spurious \"peer event:\n clock clk_unspec\" log entries\n* Include 4.2.4p7-RC1\n(4.2.5p159) 2009/03/28 Released by Harlan Stenn <stenn@ntp.org>\n* \"bias\" changes from Dave Mills.\n(4.2.5p158) 2009/01/30 Released by Harlan Stenn <stenn@ntp.org>\n* Fix [CID 72], a typo introduced at the latest fix to prettydate.c.\n(4.2.5p157) 2009/01/26 Released by Harlan Stenn <stenn@ntp.org>\n* Cleanup/fixes for ntp_proto.c and ntp_crypto.c from Dave Mills.\n(4.2.5p156) 2009/01/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1118] Fixed sign extension for 32 bit time_t in caljulian() and prettydate().\n Fixed some compiler warnings about missing prototypes.\n Fixed some other simple compiler warnings.\n* [Bug 1119] [CID 52] Avoid a possible null-dereference in ntp_crypto.c.\n* [Bug 1120] [CID 51] INSIST that peer is non-null before we dereference it.\n* [Bug 1121] [CID 47] double fclose() in ntp-keygen.c.\n(4.2.5p155) 2009/01/18 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* CHU frequency updates.\n* Design assertion fixes for ntp_crypto.c from Dave Mills.\n(4.2.5p154) 2009/01/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 992] support interface event change on Linux from\n Miroslav Lichvar.\n(4.2.5p153) 2009/01/09 Released by Harlan Stenn <stenn@ntp.org>\n* Renamed gsoc_sntp/:fetch-stubs to gsoc_sntp/fetch-stubs to avoid\n file name problems under Windows.\n Removed German umlaut from log msg for 4.2.5p142.\n(4.2.5p152) 2009/01/08 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p6: 2009/01/08 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.5p151) 2008/12/23 Released by Harlan Stenn <stenn@ntp.org>\n* Stats file logging cleanup from Dave Mills.\n(4.2.5p150) 2008/12/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1099] Fixed wrong behaviour in sntp's crypto.c.\n* [Bug 1103] Fix 64-bit issues in the new calendar code.\n(4.2.5p149) 2008/12/05 Released by Harlan Stenn <stenn@ntp.org>\n* Fixed mismatches in data types and OID definitions in ntpSnmpSubAgent.c\n* added a premliminary MIB file to ntpsnmpd (ntpv4-mib.mib)\n(4.2.5p148) 2008/12/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1070] Fix use of ntpq_parsestring() in ntpsnmpd.\n(4.2.5p147) 2008/11/27 Released by Harlan Stenn <stenn@ntp.org>\n* Update gsoc_sntp's GCC warning code.\n(4.2.5p146) 2008/11/26 Released by Harlan Stenn <stenn@ntp.org>\n* Update Solaris CFLAGS for gsoc_sntp.\n(4.2.5p145) 2008/11/20 Released by Harlan Stenn <stenn@ntp.org>\n* Deal with time.h for sntp under linux.\n* Provide rpl_malloc() for sntp for systems that need it.\n* Handle ss_len and socklen type for sntp.\n* Fixes to the sntp configure.ac script.\n* Provide INET6_ADDRSTRLEN if it is missing.\n* [Bug 1095] overflow in caljulian.c.\n(4.2.5p144) 2008/11/19 Released by Harlan Stenn <stenn@ntp.org>\n* Use int32, not int32_t.\n* Avoid the sched*() functions under OSF - link problems.\n(4.2.5p143) 2008/11/17 Released by Harlan Stenn <stenn@ntp.org>\n* sntp cleanup and fixes.\n(4.2.5p142) 2008/11/16 Released by Harlan Stenn <stenn@ntp.org>\n* Imported GSoC SNTP code from Johannes Maximilian Kuehn.\n(4.2.5p141) 2008/11/13 Released by Harlan Stenn <stenn@ntp.org>\n* New caltontp.c and calyearstart.c from Juergen Perlinger.\n(4.2.5p140) 2008/11/12 Released by Harlan Stenn <stenn@ntp.org>\n* Cleanup lint from the ntp_scanner files.\n* [Bug 1011] gmtime() returns NULL on windows where it would not under Unix.\n* Updated caljulian.c and prettydate.c from Juergen Perlinger.\n(4.2.5p139) 2008/11/11 Released by Harlan Stenn <stenn@ntp.org>\n* Typo fix to driver20.html.\n(4.2.5p138) 2008/11/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 474] --disable-ipv6 is broken.\n* IPv6 interfaces were being looked for twice.\n* SHM driver grabs more samples, add clockstats\n* decode.html and driver20.html updates from Dave Mills.\n(4.2.5p137) 2008/11/01 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1069] #undef netsnmp's PACKAGE_* macros.\n* [Bug 1068] Older versions of netsnmp do not have netsnmp_daemonize().\n(4.2.5p136) 2008/10/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1078] statsdir configuration parsing is broken.\n(4.2.5p135) 2008/09/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1072] clock_update should not allow updates older than sys_epoch.\n(4.2.5p134) 2008/09/17 Released by Harlan Stenn <stenn@ntp.org>\n* Clean up build process for ntpsnmpd.\n(4.2.5p133) 2008/09/16 Released by Harlan Stenn <stenn@ntp.org>\n* Add options processing to ntpsnmpd.\n* [Bug 1062] Check net-snmp headers before deciding to build ntpsnmpd.\n* Clean up the libntpq.a build.\n* Regenerate ntp_parser.[ch] from ntp_parser.y\n(4.2.5p132) 2008/09/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1067] Multicast DNS service registration must come after the fork\n on Solaris.\n* [Bug 1066] Error messages should log as errors.\n(4.2.5p131) 2008/09/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1065] Re-enable support for the timingstats file.\n(4.2.5p130) 2008/09/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1064] Implement --with-net-snmp-config=progname\n* [Bug 1063] ntpSnmpSubagentObject.h is missing from the distribution.\n(4.2.5p129) 2008/09/11 Released by Harlan Stenn <stenn@ntp.org>\n* Quiet some libntpq-related warnings.\n(4.2.5p128) 2008/09/08 Released by Harlan Stenn <stenn@ntp.org>\n* Import Heiko Gerstung's GSoC2008 NTP MIB daemon.\n(4.2.5p127) 2008/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* Regenerate ntpd/ntp_parser.c\n(4.2.5p126) 2008/08/31 Released by Harlan Stenn <stenn@ntp.org>\n* Stop libtool-1.5 from looking for C++ or Fortran.\n* [BUG 610] Documentation update for NMEA reference clock driver.\n* [Bug 828] Fix IPv4/IPv6 address parsing.\n* Changes from Dave Mills:\n Documentation updates.\n Fix a corner case where a frequency update was reported but not set.\n When LEAP_NOTINSYNC->LEAP_NOWARNING, call crypto_update() if we have\n crypto_flags.\n(4.2.5p125) 2008/08/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1052] Add linuxPPS support to ONCORE driver.\n(4.2.5p124) 2008/08/17 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* Include 4.2.4p5: 2008/08/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 861] leap info was not being transmitted.\n* [Bug 1046] refnumtoa.c is using the wrong header file.\n* [Bug 1047] enable/disable options processing fix.\n* header file cleanup.\n* [Bug 1037] buffer in subroutine was 1 byte short.\n* configure.ac: cleanup, add option for wintime, and lay the groundwork\n for the changes needed for bug 1028.\n* Fixes from Dave Mills: 'bias' and 'interleave' work. Separate\n phase and frequency discipline (for long poll intervals). Update\n TAI function to match current leapsecond processing.\n* Documentation updates from Dave Mills.\n* [Bug 1037] Use all 16 of the MD5 passwords generated by ntp-keygen.\n* Fixed the incorrect edge parameter being passed to time_pps_kcbind in\n NMEA refclock driver.\n* [Bug 399] NMEA refclock driver does not honor time1 offset if flag3 set.\n* [Bug 985] Modifications to NMEA reference clock driver to support Accord\n GPS Clock.\n* poll time updates from Dave Mills.\n* local refclock documentation updates from Dave Mills.\n* [Bug 1022] Fix compilation problems with yesterday's commit.\n* Updates and cleanup from Dave Mills:\n I've now spent eleven months of a sabbatical year - 7 days a week, 6-10\n hours most days - working on NTP. I have carefully reviewed every major\n algorithm, examined its original design and evolution from that design.\n I've trimmed off dead code and briar patches and did zillions of tests\n contrived to expose evil vulnerabilities. The development article is in\n rather good shape and should be ready for prime time.",
" 1. The protostats statistics files have been very useful in exposing\n little twitches and turns when something hiccups, like a broken PPS\n signal. Most of what used to be syslog messages are now repackaged as\n protostats messages with optional syslog as well. These can also be sent\n as traps which might be handy to tiggle a beeper or celltext. These, the\n sysstats files and cryptostats files reveal the ambient health of a busy\n server, monitor traffic and error counts and spot crypto attacks.",
" 2. Close inspection of the clock discipline behavior at long poll\n intervals (36 h) showed it not doing as well as it should. I redesigned\n the FLL loop to improve nominal accuracy from several tens of\n milliseconds to something less than ten milliseconds.",
" 3. Autokey (again). The enhanced error checking was becoming a major\n pain. I found a way to toss out gobs of ugly fat code and replace the\n function with a much simpler and more comprehensive scheme. It resists\n bait-and-switch attacks and quickly detect cases when the protocol is\n not correctly synchronized.",
" 4. The interface code for the kernel PPS signal was not in sync with the\n kernel code itself. Some error checks were duplicated and some\n ineffective. I found none of the PPS-capable drivers, including the atom\n driver, do anything when the prefer peer fails; the kernel PPS signal\n remains in control. The atom driver now disables the kernel PPS when the\n prefer peer comes bum. This is important when the prefer peer is not a\n reference clock but a remote NTP server.",
" 5. The flake restrict bit turned out to be really interesting,\n especially with symmtric modes and of those especially those using\n Autokey. Small changes in the recovery procedures when packets are lost\n now avoid almost all scenarios which previously required protocol resets.",
" 6. I've always been a little uncomfortable when using the clock filter\n with long poll intervals because the samples become less and less\n correlated as the sample age exceeds the Allan intercept. Various\n schemes have been used over the years to cope with this fact. The latest\n one and the one that works the best is to use a modified sort metric\n where the delay is used when the age of the sample is less than the\n intercept and the sum of delay and dispersion above that. The net result\n is that, at small poll intervals the algorithm operates as a minimum\n filter, while at larger poll intervals it morphs to FIFO. Left\n unmodified, a sample could be used when twelve days old. This along with\n the FLL modifications has made a dramatic improvement at large poll\n intervals.",
"- [Backward Incompatible] The 'state' variable is no longer reported or\n available via ntpq output. The following system status bit names\n have been changed:\n - sync_alarm -> leap_alarm\n - sync_atomic -> sync_pps\n - sync_lf_clock -> sync_lf_radio\n - sync_hf_clock -> sync_hf_radio\n - sync_uhf_clock -> sync_uhf_radio\n - sync_local_proto -> sync_local\n - sync_udp/time -> sync_other\n Other names have been changed as well. See the change history for\n libntp/statestr.c for more details.\n Other backward-incompatible changes in ntpq include:\n - assID -> associd\n - rootdispersion -> rootdisp\n - pkt_head -> pkt_neader\n See the change history for other details.",
"* Updates and cleanup from Dave Mills.\n* [Bug 995] Remove spurious ; from ntp-keygen.c.\n* More cleanup and changes from Dave Mills.\n* [Bug 980] Direct help to stdout.\n---\n(4.2.4p8) 2009/12/08 Released by Harlan Stenn <stenn@ntp.org>",
"* [Sec 1331] DoS with mode 7 packets - CVE-2009-3563.",
"---\n(4.2.4p7) 2009/05/18 Released by Harlan Stenn <stenn@ntp.org>",
"* [Sec 1151] Remote exploit if autokey is enabled - CVE-2009-1252.\n* [Bug 1187] Update the copyright date.\n* [Bug 1191] ntpd fails on Win2000 - \"Address already in use\" after fix\n for [Sec 1149].",
"---\n(4.2.4p7-RC7) 2009/05/12 Released by Harlan Stenn <stenn@ntp.org>",
"* ntp.isc.org -> ntp.org cleanup.\n* [Bug 1178] Use prior FORCE_DNSRETRY behavior as needed at runtime,\n add configure --enable-ignore-dns-errors to be even more stubborn",
"---\n(4.2.4p7-RC6) 2009/05/08 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 784] Make --enable-linuxcaps the default when available\n* [Bug 1179] error messages for -u/--user and -i lacking droproot\n* Updated JJY reference clock driver from Takao Abe\n* [Bug 1071] Log a message and exit before trying to use FD_SET with a\n descriptor larger than FD_SETSIZE, which will corrupt memory\n* On corruption of the iface list head in add_interface, log and exit",
"---\n(4.2.4p7-RC5) 2009/05/02 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1172] 4.2.4p7-RC{3,4} fail to build on linux.\n* flock-build script unportable 'set -m' use removed",
"---\n(4.2.4p7-RC4) 2009/04/29 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1167] use gcc -Winit-self only if it is understood",
"---\n(4.2.4p7-RC3) 2009/04/22 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 787] Bug fixes for 64-bit time_t on Windows\n* [Bug 813] Conditional naming of Event\n* [Bug 1147] System errors should be logged to msyslog()\n* [Bug 1155] Fix compile problem on Windows with VS2005\n* [Bug 1156] lock_thread_to_processor() should be declared in header\n* [Bug 1157] quiet OpenSSL warnings, clean up configure.ac\n* [Bug 1158] support for aix6.1\n* [Bug 1160] MacOS X is like BSD regarding F_SETOWN",
"---\n(4.2.4p7-RC2) 2009/04/09 Released by Harlan Stenn <stenn@ntp.org>",
"* [Sec 1144] limited buffer overflow in ntpq. CVE-2009-0159\n* [Sec 1149] use SO_EXCLUSIVEADDRUSE on Windows",
"---\n(4.2.4p7-RC1) 2009/03/30 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1131] UDP sockets should not use SIGPOLL on Solaris.\n* build system email address cleanup\n* [Bug 774] parsesolaris.c does not compile under the new Solaris\n* [Bug 873] Windows serial refclock proper TTY line discipline emulation\n* [Bug 1014] Enable building with VC9 (in Visual Studio 2008,\n Visual C++ 2008, or SDK)\n* [Bug 1117] Deferred interface binding under Windows works only correctly\n if FORCE_DNSRETRY is defined\n* [BUG 1124] Lock QueryPerformanceCounter() client threads to same CPU\n* DPRINTF macro made safer, always evaluates to a statement and will not\n misassociate an else which follows the macro.",
"---\n(4.2.4p6) 2009/01/08 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1113] Fixed build errors with recent versions of openSSL. \n* [Sec 1111] Fix incorrect check of EVP_VerifyFinal()'s return value.\n* Update the copyright year.",
"---\n(4.2.4p5) 2008/08/17 Released by Harlan Stenn <stenn@ntp.org>",
"* [BUG 1051] Month off by one in leap second message written to clockstats\n file fixed.\n* [Bug 450] Windows only: Under original Windows NT we must not discard the\n wildcard socket to workaround a bug in NT's getsockname().\n* [Bug 1038] Built-in getpass() function also prompts for password if\n not built with DEBUG.\n* [Bug 841] Obsolete the \"dynamic\" keyword and make deferred binding\n to local interfaces the default.\n Emit a warning if that keyword is used for configuration.\n* [Bug 959] Refclock on Windows not properly releasing recvbuffs.\n* [Bug 993] Fix memory leak when fetching system messages.\n* much cleanup, fixes, and changes from Dave Mills.\n* ntp_control.c: LEAPTAB is a filestamp, not an unsigned. From Dave Mills.\n* ntp_config.c: ntp_minpoll fixes from Dave Mills.\n* ntp-keygen updates from Dave Mills.\n* refresh epoch, throttle, and leap cleanup from Dave Mills.\n* Documentation cleanup from Dave Mills.\n* [Bug 918] Only use a native md5.h if MD5Init() is available.\n* [Bug 979] Provide ntptimeval if it is not otherwise present.\n* [Bug 634] Re-instantiate syslog() and logfiles after the daemon fork.\n* [Bug 952] Use md5 code with a friendlier license.\n* [Bug 977] Fix mismatching #ifdefs for builds without IPv6.\n* [Bug 830] Fix the checking order of the interface options.\n* Clean up the logfile/syslog setup.\n* [Bug 970] Lose obsolete -g flag to ntp-keygen.\n* The -e flag to ntp-keygen can write GQ keys now, too.\n* ntp_proto.c: sys_survivors and hpoll cleanup from Dave Mills.\n* ntp_loopfilter.c: sys_poll cleanup from Dave Mills.\n* refclock_wwv.c: maximum-likelihood digit and DSYNC fixes from Dave Mills.\n* [Bug 967] preemptable associations are lost forever on a step.\n* ntp_config.c: [CID 48] missing \"else\" clause.\n* [Bug 833] ntpq config keyword is quote-mark unfriendly.\n* Rename the ntpq \"config\" keyword to \":config\".\n* Dave Mills shifted some orphan processing.\n* Fix typos in the [Bug 963] patch.\n* bootstrap: squawk if genver fails. Use -f with cp in case Dave does a chown.\n* Remove obsolete simulator command-line options.\n* ntp_request.c: [CID 36] zero sin_zero.\n* [Bug 963] get_systime() is too noisy.\n* [Bug 960] spurious syslog:crypto_setup:spurious crypto command\n* [Bug 964] Change *-*-linux* to *-*-*linux* to allow for uclinux.\n* Changes from Dave Mills:\n - ntp_util.c: cleanup.\n - ntp_timer.c: watch the non-burst packet rate.\n - ntp_request.c: cleanup.\n - ntp_restrict.c: RES_LIMITED cleanup.\n - ntp_proto.c: RES_LIMITED, rate bucktes, counters, overall cleanup.\n - ntp_peer.c: disallow peer_unconfig().\n - ntp_monitor.c: RES_LIMITED cleanup.\n - ntp_loopfilter.c: poll interval cleanup.\n - ntp_crypto.c: volley -> retry. Cleanup TAI leap message.\n - ntp_config: average and minimum are ^2 values.\n - ntpdc: unknownversion is really \"declined\", not \"bad version\".\n - Packet retry cleanup.\n* [Bug 961] refclock_tpro.c:tpro_poll() calls refclock_receive() twice.\n* [Bug 957] Windows only: Let command line parameters from the Windows SCM GUI\n override the standard parameters from the ImagePath registry key.\n* Added HAVE_INT32_T to the Windows config.h to avoid duplicate definitions.\n* Work around a VPATH difference in FreeBSD's 'make' command.\n* Update bugreport URL.\n* Update -I documentation.\n* [Bug 713] Fix bug reporting information.\n* A bug in the application of the negative-sawtooth for 12 channel receivers. \n* The removal of unneeded startup code used for the original LinuxPPS, it now\n conforms to the PPSAPI and does not need special code. \n* ntp-keygen.c: Coverity fixes [CID 33,47].\n* Volley cleanup from Dave Mills.\n* Fuzz cleanup from Dave Mills.\n* [Bug 861] Leap second cleanups from Dave Mills.\n* ntpsim.c: add missing protypes and fix [CID 34], a nit.\n* Upgraded bison at UDel.\n* Update br-flock and flock-build machine lists.\n* [Bug 752] QoS: add parse/config handling code. \n* Fix the #include order in tickadj.c for picky machines.\n* [Bug 752] QoS: On some systems, netinet/ip.h needs netinet/ip_systm.h.\n* [Bug 752] Update the QoS tagging (code only - configuration to follow).\n* Orphan mode and other protocol cleanup from Dave Mills.\n* Documentation cleanup from Dave Mills.\n* [Bug 940] ntp-keygen uses -v. Disallow it as a shortcut for --version.\n* more cleanup to ntp_lineeditlibs.m4.\n* Documentation updates from Dave Mills.\n* -ledit cleanup for ntpdc and ntpq.\n* Association and other cleanup from Dave Mills.\n* NTP_UNREACH changes from Dave Mills.\n* Fix the readline history test.\n* [Bug 931] Require -lreadline to be asked for explicitly.\n* [Bug 764] When looking for -lreadline support, also try using -lncurses.\n* [Bug 909] Fix int32_t errors for ntohl().\n* [Bug 376/214] Enhancements to support multiple if names and IP addresses.\n* [Bug 929] int32_t is undefined on Windows. Casting wrong.\n* [Bug 928] readlink missing braces.\n* [Bug 788] Update macros to support VS 2005.\n* ntpd/ntp_timer.c: add missing sys_tai parameter for debug printf\n* [Bug 917] config parse leaves files open\n* [Bug 912] detect conflicting enable/disable configuration on interfaces\n sharing an IP address\n* [Bug 771] compare scopeid if available for IPv6 addresses\n* Lose obsolete crypto subcommands (Dave Mills).\n* WWV is an HF source, not an LF source (Dave Mills).\n* [Bug 899] Only show -i/--jaildir -u/--user options if we HAVE_DROPROOT.\n* [Bug 916] 'cryptosw' is undefined if built without OpenSSL.\n* [Bug 891] 'restrict' config file keyword does not work (partial fix).\n* [Bug 890] the crypto command seems to be required now.\n* [Bug 915] ntpd cores during processing of x509 certificates.\n* Crypto lint cleanup from Dave Mills.\n* [Bug 897] Check RAND_status() - we may not need a .rnd file.\n* Crypto cleanup from Dave Mills.\n* [Bug 911] Fix error message in cmd_args.c.\n* [Bug 895] Log assertion failures via syslog(), not stderr.\n* Documentation updates from Dave Mills.\n* Crypto cleanup from Dave Mills.\n* [Bug 905] ntp_crypto.c fails to compile without -DDEBUG.\n* Avoid double peer stats logging.\n* ntp-keygen cleanup from Dave Mills.\n* libopts needs to be built after ElectricFence.\n* [Bug 894] Initialize keysdir before calling crypto_setup().\n* Calysto cleanup for ntpq.\n* ntp-keygen -i takes an arg.\n* Cleanup and fixes from Dave Mills.\n* [Bug 887] Fix error in ntp_types.h (for sizeof int != 4).\n* Bug 880 bug fixes for Windows build\n* Improve Calysto support.\n* The \"revoke\" parameter is a crypto command.\n* The driftfile wander threshold is a real number.\n* [Bug 850] Fix the wander threshold parameter on the driftfile command.\n* ntp_io.c: Dead code cleanup - Coverity View 19.\n* Leap file related cleanup from Dave Mills.\n* ntp_peer.c: Set peer->srcadr before (not after) calling set_peerdstadr().\n* Initialize offset in leap_file() - Coverity View 17.\n* Use the correct stratum on KISS codes.\n* Fuzz bits cleanup.\n* Show more digits in some debug printf's.\n* Use drift_file_sw internally to control writing the drift file.\n* Implement the wander_threshold option for the driftfile config keyword.\n* reformat ntp_control.c; do not use c++ // comments.\n* [Bug 629] Undo bug #629 fixes as they cause more problems than were being\n solved\n* Changes from Dave Mills: in/out-bound data rates, leapsecond cleanup,\n driftfile write cleanup, packet buffer length checks, documentation updates.\n* More assertion checks and malloc()->emalloc(), courtesy of Calysto.\n* [Bug 864] Place ntpd service in maintenance mode if using SMF on Solaris\n* [Bug 862] includefile nesting; preserve phonelist on reconfig.\n* [Bug 604] ntpd regularly dies on linux/alpha.\n* more leap second infrastructure fixes from Dave Mills.\n* [Bug 858] recent leapfile changes broke non-OpenSSL builds.\n* Use emalloc() instead of malloc() in refclock_datum.c (Calysto).\n* Start using 'design by contract' assertions.\n* [Bug 767] Fast sync to refclocks wanted.\n* Allow null driftfile.\n* Use YYERROR_VERBOSE for the new parser, and fix related BUILT_SOURCES.\n* [Bug 629] changes to ensure broadcast works including on wildcard addresses\n* [Bug 853] get_node() must return a pointer to maximally-aligned memory.\n* Initial leap file fixes from Dave Mills.\n* [Bug 858] Recent leapfile changes broke without OPENSSL.\n* Use a char for DIR_SEP, not a string.\n* [Bug 850] driftfile parsing changes.\n* driftfile maintenance changes from Dave Mills. Use clock_phi instead of\n stats_write_tolerance.\n* [Bug 828] refid string not being parsed correctly.\n* [Bug 846] Correct includefile parsing.\n* [Bug 827] New parsing code does not handle \"fudge\" correctly.\n* Enable debugging capability in the config parser.\n* [Bug 839] Crypto password not read from ntp.conf.\n* Have autogen produce writable output files.\n* [Bug 825] Correct logconfig -/+ keyword processing.\n* [Bug 828] Correct parsing of \" delimited strings.\n* Cleanup FILE * usage after fclose() in ntp_filegen.c.\n* [Bug 843] Windows Completion port code was incorrectly merged from -stable.\n* [Bug 840] do fudge configuration AFTER peers (thus refclocks) have been\n configured.\n* [Bug 824] Added new parser modules to the Windows project file.\n* [Bug 832] Add libisc/log.c headers to the distribution.\n* [Bug 808] Only write the drift file if we are in state 4.\n* Initial import of libisc/log.c and friends.\n* [Bug 826] Fix redefinition of PI.\n* [Bug 825] ntp_scanner.c needs to #include <config.h> .\n* [Bug 824] New parser code has some build problems with the SIM code.\n* [Bug 817] Use longnames for setting ntp variables on the command-line;\n Allowing '-v' with and without an arg to disambiguate usage is error-prone.\n* [Bug 822] set progname once, early.\n* [Bug 819] remove erroneous #if 0 in Windows completion port code.\n* The new config code missed an #ifdef for building without refclocks.\n* Distribute some files needed by the new config parsing code.\n* [Bug 819] Timeout for WaitForMultipleObjects was 500ms instead of INFINITE\n* Use autogen 5.9.1.\n* Fix clktest command-line arg processing.'\n* Audio documentation updates from Dave Mills.\n* New config file parsing code, from Sachin Kamboj.\n* fuzz bit cleanup from Dave Mills.\n* replay cleanup from Dave Mills.\n* [Bug 542] Tolerate missing directory separator at EO statsdir.\n* [Bug 812] ntpd should drop supplementary groups.\n* [Bug 815] Fix warning compiling 4.2.5p22 under Windows with VC6.\n* [Bug 740] Fix kernel/daemon startup drift anomaly.\n* refclock_wwv.c fixes from Dave Mills.\n* [Bug 810] Fix ntp-keygen documentation.\n* [Bug 787] Bug fixes for 64-bit time_t on Windows.\n* [Bug 796] Clean up duplicate #defines in ntp_control.c.\n* [Bug 569] Use the correct precision for the Leitch CSD-5300.\n* [Bug 795] Moved declaration of variable to top of function.\n* [Bug 798] ntpq [p typo crashes ntpq/ntpdc.\n* [Bug 786] Fix refclock_bancomm.c on Solaris.\n* [Bug 774] parsesolaris.c does not compile under the new Solaris.\n* [Bug 782] Remove P() macros from Windows files.\n* [Bug 778] ntpd fails to lock with drift=+500 when started with drift=-500.\n* [Bug 592] Trimble Thunderbolt GPS support.\n* IRIG, CHU, WWV, WWVB refclock improvements from Dave Mills.\n* [Bug 757] Lose ULONG_CONST().\n* [Bug 756] Require ANSI C (function prototypes).\n* codec (audio) and ICOM changes from Dave Mills.",
"---",
"* [Bug 450] Windows only: Under original Windows NT we must not discard the\n wildcard socket to workaround a bug in NT's getsockname().\n* [Bug 1038] Built-in getpass() function also prompts for password if\n not built with DEBUG.\n* [Bug 841] Obsolete the \"dynamic\" keyword and make deferred binding\n to local interfaces the default.\n Emit a warning if that keyword is used for configuration.\n* [Bug 959] Refclock on Windows not properly releasing recvbuffs.\n* [Bug 993] Fix memory leak when fetching system messages.\n* [Bug 987] Wake up the resolver thread/process when a new interface has\n become available.\n* Correctly apply negative-sawtooth for oncore 12 channel receiver.\n* Startup code for original LinuxPPS removed. LinuxPPS now conforms to\n the PPSAPI.\n* [Bug 1000] allow implicit receive buffer allocation for Windows.\n fixes startup for windows systems with many interfaces.\n reduces dropped packets on network bursts.\n additionally fix timer() starvation during high load.\n* [Bug 990] drop minimum time restriction for interface update interval.\n* [Bug 977] Fix mismatching #ifdefs for builds without IPv6.\n* Update the copyright year.\n* Build system cleanup (make autogen-generated files writable).\n* [Bug 957] Windows only: Let command line parameters from the Windows SCM GUI\n override the standard parameters from the ImagePath registry key.\n* Fixes for ntpdate:\n* [Bug 532] nptdate timeout is too long if several servers are supplied.\n* [Bug 698] timeBeginPeriod is called without timeEndPeriod in some NTP tools.\n* [Bug 857] ntpdate debug mode adjusts system clock when it shouldn't.\n* [Bug 908] ntpdate crashes sometimes.\n* [Bug 982] ntpdate(and ntptimeset) buffer overrun if HAVE_POLL_H isn't set\n (dup of 908).\n* [Bug 997] ntpdate buffer too small and unsafe.\n* ntpdate.c: Under Windows check whether NTP port in use under same conditions\n as under other OSs.\n* ntpdate.c: Fixed some typos and indents (tabs/spaces).",
"(4.2.4p4) Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 902] Fix problems with the -6 flag.\n* Updated include/copyright.def (owner and year).\n* [Bug 878] Avoid ntpdc use of refid value as unterminated string.\n* [Bug 881] Corrected display of pll offset on 64bit systems.\n* [Bug 886] Corrected sign handling on 64bit in ntpdc loopinfo command.\n* [Bug 889] avoid malloc() interrupted by SIGIO risk\n* ntpd/refclock_parse.c: cleanup shutdown while the file descriptor is still\n open.\n* [Bug 885] use emalloc() to get a message at the end of the memory\n unsigned types cannot be less than 0\n default_ai_family is a short\n lose trailing , from enum list\n clarify ntp_restrict.c for easier automated analysis\n* [Bug 884] don't access recv buffers after having them passed to the free\n list.\n* [Bug 882] allow loopback interfaces to share addresses with other\n interfaces.",
"---\n(4.2.4p3) Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 863] unable to stop ntpd on Windows as the handle reference for events\n changed",
"---\n(4.2.4p2) Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 854] Broadcast address was not correctly set for interface addresses\n* [Bug 829] reduce syslog noise, while there fix Enabled/Disable logging\n to reflect the actual configuration.\n* [Bug 795] Moved declaration of variable to top of function.\n* [Bug 789] Fix multicast client crypto authentication and make sure arriving\n multicast packets do not disturb the autokey dance.\n* [Bug 785] improve handling of multicast interfaces\n (multicast routers still need to run a multicast routing software/daemon)\n* ntpd/refclock_parse.c: cleanup shutdown while the file descriptor is still\n open.\n* [Bug 885] use emalloc() to get a message at the end of the memory\n unsigned types cannot be less than 0\n default_ai_family is a short\n lose trailing , from enum list\n* [Bug 884] don't access recv buffers after having them passed to the free list.\n* [Bug 882] allow loopback interfaces to share addresses with other interfaces.\n* [Bug 527] Don't write from source address length to wrong location\n* Upgraded autogen and libopts.\n* [Bug 811] ntpd should not read a .ntprc file.",
"---\n(4.2.4p1) (skipped)",
"---\n(4.2.4p0) Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 793] Update Hans Lambermont's email address in ntpsweep.\n* [Bug 776] Remove unimplemented \"rate\" flag from ntpdate.\n* [Bug 586] Avoid lookups if AI_NUMERICHOST is set.\n* [Bug 770] Fix numeric parameters to ntp-keygen (Alain Guibert).\n* [Bug 768] Fix io_setbclient() error message.\n* [Bug 765] Use net_bind_service capability on linux.\n* [Bug 760] The background resolver must be aware of the 'dynamic' keyword.\n* [Bug 753] make union timestamp anonymous (Philip Prindeville).\n* confopt.html: move description for \"dynamic\" keyword into the right section.\n* pick the right type for the recv*() length argument.",
"---\n(4.2.4) Released by Harlan Stenn <stenn@ntp.org>",
"* monopt.html fixes from Dave Mills.\n* [Bug 452] Do not report kernel PLL/FLL flips.\n* [Bug 746] Expert mouseCLOCK USB v2.0 support added.'\n* driver8.html updates.\n* [Bug 747] Drop <NOBR> tags from ntpdc.html.\n* sntp now uses the returned precision to control decimal places.\n* sntp -u will use an unprivileged port for its queries.\n* [Bug 741] \"burst\" doesn't work with !unfit peers.\n* [Bug 735] Fix a make/gmake VPATH issue on Solaris.\n* [Bug 739] ntpd -x should not take an argument.\n* [Bug 737] Some systems need help providing struct iovec.\n* [Bug 717] Fix libopts compile problem.\n* [Bug 728] parse documentation fixes.\n* [Bug 734] setsockopt(..., IP_MULTICAST_IF, ...) fails on 64-bit platforms.\n* [Bug 732] C-DEX JST2000 patch from Hideo Kuramatsu.\n* [Bug 721] check for __ss_family and __ss_len separately.\n* [Bug 666] ntpq opeers displays jitter rather than dispersion.\n* [Bug 718] Use the recommended type for the saddrlen arg to getsockname().\n* [Bug 715] Fix a multicast issue under Linux.\n* [Bug 690] Fix a Windows DNS lookup buffer overflow.\n* [Bug 670] Resolved a Windows issue with the dynamic interface rescan code.\n* K&R C support is being deprecated.\n* [Bug 714] ntpq -p should conflict with -i, not -c.\n* WWV refclock improvements from Dave Mills.\n* [Bug 708] Use thread affinity only for the clock interpolation thread.\n* [Bug 706] ntpd can be running several times in parallel.\n* [Bug 704] Documentation typos.\n* [Bug 701] coverity: NULL dereference in ntp_peer.c\n* [Bug 695] libopts does not protect against macro collisions.\n* [Bug 693] __adjtimex is independent of ntp_{adj,get}time.\n* [Bug 692] sys_limitrejected was not being incremented.\n* [Bug 691] restrictions() assumption not always valid.\n* [Bug 689] Deprecate HEATH GC-1001 II; the driver never worked.\n* [Bug 688] Fix documentation typos.\n* [Bug 686] Handle leap seconds better under Windows.\n* [Bug 685] Use the Windows multimedia timer.\n* [Bug 684] Only allow debug options if debugging is enabled.\n* [Bug 683] Use the right version string.\n* [Bug 680] Fix the generated version string on Windows.\n* [Bug 678] Use the correct size for control messages.\n* [Bug 677] Do not check uint_t in configure.ac.\n* [Bug 676] Use the right value for msg_namelen.\n* [Bug 675] Make sure ntpd builds without debugging.\n* [Bug 672] Fix cross-platform structure padding/size differences.\n* [Bug 660] New TIMESTAMP code fails tp build on Solaris Express.\n* [Bug 659] libopts does not build under Windows.\n* [Bug 658] HP-UX with cc needs -Wp,-H8166 in CFLAGS.\n* [Bug 656] ntpdate doesn't work with multicast address.\n* [Bug 638] STREAMS_TLI is deprecated - remove it.\n* [Bug 635] Fix tOptions definition.\n* [Bug 628] Fallback to ntp discipline not working for large offsets.\n* [Bug 622] Dynamic interface tracking for ntpd.\n* [Bug 603] Don't link with libelf if it's not needed.\n* [Bug 523] ntpd service under Windows does't shut down properly.\n* [Bug 500] sntp should always be built.\n* [Bug 479] Fix the -P option.\n* [Bug 421] Support the bc637PCI-U card.\n* [Bug 342] Deprecate broken TRAK refclock driver.\n* [Bug 340] Deprecate broken MSF EES refclock driver.\n* [Bug 153] Don't do DNS lookups on address masks.\n* [Bug 143] Fix interrupted system call on HP-UX.\n* [Bug 42] Distribution tarballs should be signed.\n* Support separate PPS devices for PARSE refclocks.\n* [Bug 637, 51?] Dynamic interface scanning can now be done.\n* Options processing now uses GNU AutoGen.",
"---\n(4.2.2p4) Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 710] compat getnameinfo() has off-by-one error\n* [Bug 690] Buffer overflow in Windows when doing DNS Lookups",
"---\n(4.2.2p3) Released by Harlan Stenn <stenn@ntp.org>",
"* Make the ChangeLog file cleaner and easier to read\n* [Bug 601] ntpq's decodeint uses an extra level of indirection\n* [Bug 657] Different OSes need different sized args for IP_MULTICAST_LOOP\n* release engineering/build changes\n* Documentation fixes\n* Get sntp working under AIX-5",
"---\n(4.2.2p2) (broken)",
"* Get sntp working under AIX-5",
"---\n(4.2.2p1)",
"* [Bug 661] Use environment variable to specify the base path to openssl.\n* Resolve an ambiguity in the copyright notice\n* Added some new documentation files\n* URL cleanup in the documentation\n* [Bug 657]: IP_MULTICAST_LOOP uses a u_char value/size\n* quiet gcc4 complaints\n* more Coverity fixes\n* [Bug 614] manage file descriptors better\n* [Bug 632] update kernel PPS offsets when PPS offset is re-configured\n* [Bug 637] Ignore UP in*addr_any interfaces\n* [Bug 633] Avoid writing files in srcdir\n* release engineering/build changes",
"---\n(4.2.2)",
"* SNTP\n* Many bugfixes\n* Implements the current \"goal state\" of NTPv4\n* Autokey improvements\n* Much better IPv6 support\n* [Bug 360] ntpd loses handles with LAN connection disabled.\n* [Bug 239] Fix intermittent autokey failure with multicast clients.\n* Rewrite of the multicast code\n* New version numbering scheme",
"---\n(4.2.0)",
"* More stuff than I have time to document\n* IPv6 support\n* Bugfixes\n* call-gap filtering\n* wwv and chu refclock improvements\n* OpenSSL integration",
"---\n(4.1.2)",
"* clock state machine bugfix\n* Lose the source port check on incoming packets\n* (x)ntpdc compatibility patch\n* Virtual IP improvements\n* ntp_loopfilter fixes and improvements\n* ntpdc improvements\n* GOES refclock fix\n* JJY driver\n* Jupiter refclock fixes\n* Neoclock4X refclock fixes\n* AIX 5 port\n* bsdi port fixes\n* Cray unicos port upgrade\n* HP MPE/iX port\n* Win/NT port upgrade\n* Dynix PTX port fixes\n* Document conversion from CVS to BK\n* readline support for ntpq",
"---\n(4.1.0)",
"* CERT problem fixed (99k23)",
"* Huff-n-Puff filter\n* Preparation for OpenSSL support\n* Resolver changes/improvements are not backward compatible with mode 7\n requests (which are implementation-specific anyway)\n* leap second stuff\n* manycast should work now\n* ntp-genkeys does new good things.\n* scripts/ntp-close\n* PPS cleanup and improvements\n* readline support for ntpdc\n* Crypto/authentication rewrite\n* WINNT builds with MD5 by default\n* WINNT no longer requires Perl for building with Visual C++ 6.0\n* algorithmic improvements, bugfixes\n* Solaris dosynctodr info update\n* html/pic/* is *lots* smaller\n* New/updated drivers: Forum Graphic GPS, WWV/H, Heath GC-100 II, HOPF\n serial and PCI, ONCORE, ulink331\n* Rewrite of the audio drivers",
"---\n(4.0.99)",
"* Driver updates: CHU, DCF, GPS/VME, Oncore, PCF, Ulink, WWVB, burst\n If you use the ONCORE driver with a HARDPPS kernel module,\n you *must* have a properly specified:\n\tpps <filename> [assert/clear] [hardpps]\n line in the /etc/ntp.conf file.\n* PARSE cleanup\n* PPS cleanup\n* ntpd, ntpq, ntpdate cleanup and fixes\n* NT port improvements\n* AIX, BSDI, DEC OSF, FreeBSD, NetBSD, Reliant, SCO, Solaris port improvements",
"---\n(4.0.98)",
"* Solaris kernel FLL bug is fixed in 106541-07\n* Bug/lint cleanup\n* PPS cleanup\n* ReliantUNIX patches\n* NetInfo support\n* Ultralink driver\n* Trimble OEM Ace-II support\n* DCF77 power choices\n* Oncore improvements",
"---\n(4.0.97)",
"* NT patches\n* AIX,SunOS,IRIX portability\n* NeXT portability\n* ntptimeset utility added\n* cygwin portability patches",
"---\n(4.0.96)",
"* -lnsl, -lsocket, -lgen configuration patches\n* Y2K patches from AT&T\n* Linux portability cruft",
"---\n(4.0.95)",
"* NT port cleanup/replacement\n* a few portability fixes\n* VARITEXT Parse clock added",
"---\n(4.0.94)",
"* PPS updates (including ntp.config options)\n* Lose the old DES stuff in favor of the (optional) RSAREF stuff\n* html cleanup/updates\n* numerous drivers cleaned up\n* numerous portability patches and code cleanup",
"---\n(4.0.93)",
"* Oncore refclock needs PPS or one of two ioctls.\n* Don't make ntptime under Linux. It doesn't compile for too many folks.\n* Autokey cleanup\n* ReliantUnix patches\n* html cleanup\n* tickadj cleanup\n* PARSE cleanup\n* IRIX -n32 cleanup\n* byte order cleanup\n* ntptrace improvements and patches\n* ntpdc improvements and patches\n* PPS cleanup\n* mx4200 cleanup\n* New clock state machine\n* SCO cleanup\n* Skip alias interfaces",
"---\n(4.0.92)",
"* chronolog and dumbclock refclocks\n* SCO updates\n* Cleanup/bugfixes\n* Y2K patches\n* Updated palisade driver\n* Plug memory leak\n* wharton kernel clock\n* Oncore clock upgrades\n* NMEA clock improvements\n* PPS improvements\n* AIX portability patches",
"---\n(4.0.91)",
"* New ONCORE driver\n* New MX4200 driver\n* Palisade improvements\n* config file bugfixes and problem reporting\n* autoconf upgrade and cleanup\n* HP-UX, IRIX lint cleanup\n* AIX portability patches\n* NT cleanup",
"---\n(4.0.90)",
"* Nanoseconds\n* New palisade driver\n* New Oncore driver",
"---\n(4.0.73)",
"* README.hackers added\n* PARSE driver is working again\n* Solaris 2.6 has nasty kernel bugs. DO NOT enable pll!\n* DES is out of the distribution.",
"---\n(4.0.72)",
"* K&R C compiling should work again.\n* IRIG patches.\n* MX4200 driver patches.\n* Jupiter driver added.\n* Palisade driver added. Needs work (ANSI, ntoh/hton, sizeof double, ???)"
] |
[
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1, 163], "buggy_code_start_loc": [1, 159], "filenames": ["ChangeLog", "include/ntp.h"], "fixing_code_end_loc": [3, 162], "fixing_code_start_loc": [2, 159], "message": "The ULOGTOD function in ntp.d in SNTP before 4.2.7p366 does not properly perform type conversions from a precision value to a double, which allows remote attackers to cause a denial of service (infinite loop) via a crafted NTP packet.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:fedoraproject:fedora:21:*:*:*:*:*:*:*", "matchCriteriaId": "56BDB5A0-0839-4A20-A003-B8CD56F48171", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:22:*:*:*:*:*:*:*", "matchCriteriaId": "253C303A-E577-4488-93E6-68A8DD942C38", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:23:*:*:*:*:*:*:*", "matchCriteriaId": "E79AB8DD-C907-4038-A931-1A5A4CFB6A5B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:suse:linux_enterprise_debuginfo:11:sp2:*:*:*:*:*:*", "matchCriteriaId": "D5900A25-FDD7-4900-BF7C-F3ECCB714D2B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:suse:linux_enterprise_debuginfo:11:sp3:*:*:*:*:*:*", "matchCriteriaId": "58D3B6FD-B474-4B09-B644-A8634A629280", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:10:sp4:*:*:ltss:*:*:*", "matchCriteriaId": "35BBD83D-BDC7-4678-BE94-639F59281139", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:11:sp2:*:*:ltss:*:*:*", "matchCriteriaId": "CB6476C7-03F2-4939-AB85-69AA524516D9", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:11:sp3:*:*:ltss:*:*:*", "matchCriteriaId": "B12243B2-D726-404C-ABFF-F1AB51BA1783", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:manager:2.1:*:*:*:*:*:*:*", "matchCriteriaId": "2A33B9F5-E0D1-4A3E-9FFB-5602A25F3227", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:manager_proxy:2.1:*:*:*:*:*:*:*", "matchCriteriaId": "53F0F5A0-70D9-4305-A834-B6FF71E27B30", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:openstack_cloud:5:*:*:*:*:*:*:*", "matchCriteriaId": "88BCD7DC-0FEF-477D-8698-F8D8F1A49D90", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:redhat:enterprise_linux_desktop:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "EE249E1B-A1FD-4E08-AA71-A0E1F10FFE97", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_desktop:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "33C068A4-3780-4EAB-A937-6082DF847564", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_hpc_node:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "C2FAC325-6EEB-466D-9EBA-8ED4DBC9CFBF", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_hpc_node:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "3C84489B-B08C-4854-8A12-D01B6E45CF79", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "9BBCD86A-E6C7-4444-9D74-F861084090F0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "51EF4996-72F4-4FA4-814F-F5991E7A8318", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_workstation:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "E5ED5807-55B7-47C5-97A6-03233F4FBC3A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_workstation:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "825ECE2D-E232-46E0-A047-074B34DB1E97", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:debian:debian_linux:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "16F59A04-14CF-49E2-9973-645477EA09DA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:debian:debian_linux:8.0:*:*:*:*:*:*:*", "matchCriteriaId": "C11E6FB0-C8C0-4527-9AA0-CB9B316F8F43", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:canonical:ubuntu_linux:12.04:*:*:*:lts:*:*:*", "matchCriteriaId": "B6B7CAD7-9D4E-4FDB-88E3-1E583210A01F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:14.04:*:*:*:lts:*:*:*", "matchCriteriaId": "B5A6F2F3-4894-4392-8296-3B8DD2679084", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:15.04:*:*:*:*:*:*:*", "matchCriteriaId": "F38D3B7E-8429-473F-BB31-FC3583EE5A5B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:15.10:*:*:*:*:*:*:*", "matchCriteriaId": "E88A537F-F4D0-46B9-9E37-965233C2A355", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:ntp:ntp:*:p355:*:*:*:*:*:*", "matchCriteriaId": "07FBDFE4-D886-4461-A360-480F50BD12C7", "versionEndExcluding": null, "versionEndIncluding": "4.2.7", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:novell:leap:42.2:*:*:*:*:*:*:*", "matchCriteriaId": "A64AAD2D-38ED-4BA2-A27A-A2716F28D43A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:opensuse:leap:42.1:*:*:*:*:*:*:*", "matchCriteriaId": "4863BE36-D16A-4D75-90D9-FD76DB5B48B7", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:tim_4r-ie_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "E0730ED6-676B-4200-BC07-C0B4531B242C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:tim_4r-ie:-:*:*:*:*:*:*:*", "matchCriteriaId": "0B87B16C-9E9F-448B-9255-B2BB2B8CAD63", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:tim_4r-id_dnp3_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "B8851DB6-6B63-4D78-A100-50F81B4DF75B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:tim_4r-id_dnp3:-:*:*:*:*:*:*:*", "matchCriteriaId": "1A8AC343-6F4F-4CAF-BD09-F8F1D2F6DBB0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:oracle:linux:6:-:*:*:*:*:*:*", "matchCriteriaId": "D7B037A8-72A6-4DFF-94B2-D688A5F6F876", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}], "descriptions": [{"lang": "en", "value": "The ULOGTOD function in ntp.d in SNTP before 4.2.7p366 does not properly perform type conversions from a precision value to a double, which allows remote attackers to cause a denial of service (infinite loop) via a crafted NTP packet."}, {"lang": "es", "value": "La funci\u00f3n ULOGTOD en el archivo ntp.d en SNTP en versiones anteriores a la 4.2.7p366 no realiza apropiadamente las conversiones de tipo de un valor de precisi\u00f3n a uno doble, lo que permite a los atacantes remotos causar una denegaci\u00f3n de servicio (bucle infinito) por medio de un paquete NTP creado."}], "evaluatorComment": null, "id": "CVE-2015-5219", "lastModified": "2023-02-13T00:51:47.453", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 5.0, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:N/AC:L/Au:N/C:N/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2017-07-21T14:29:00.867", "references": [{"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://aix.software.ibm.com/aix/efixes/security/ntp_advisory4.asc"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "http://bk1.ntp.org/ntp-dev/?PAGE=patch&REV=51786731Gr4-NOrTBC_a_uXO4wuGhg"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-November/170926.html"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-October/169167.html"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-September/166992.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://rhn.redhat.com/errata/RHSA-2016-0780.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://rhn.redhat.com/errata/RHSA-2016-2583.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.debian.org/security/2015/dsa-3388"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2015/08/25/3"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.oracle.com/technetwork/topics/security/linuxbulletinapr2016-2952096.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/76473"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.ubuntu.com/usn/USN-2783-1"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking"], "url": "https://bugzilla.redhat.com/show_bug.cgi?id=1255118"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-497656.pdf"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/ntp-project/ntp/commit/5f295cd05c3c136d39f5b3e500a2d781bdbb59c8"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "US Government Resource"], "url": "https://us-cert.cisa.gov/ics/advisories/icsa-21-103-11"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=isg3T1024157"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21985122"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21986956"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21988706"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21989542"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www.ibm.com/support/home/docdisplay?lndocid=migr-5099409"}], "sourceIdentifier": "secalert@redhat.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-704"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/ntp-project/ntp/commit/5f295cd05c3c136d39f5b3e500a2d781bdbb59c8"}, "type": "CWE-704"}
| 357
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"* [Bug 1485] Sometimes ntpd crashes",
"* [Bug 2382] Implement LOGTOD using ldexp() instead of shifting.",
"(4.2.7p366) 2013/04/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1866] Disable some debugging output in refclock_oncore.\n(4.2.7p365) 2013/04/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2149] Log an error message if /proc/net/if_inet6 cannot be opened.\n(4.2.7p364) 2013/03/26 Released by Harlan Stenn <stenn@ntp.org>\n* Bump sntp/include/autogen-version.def .\n(4.2.7p363) 2013/03/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2357] sntp/libopts/usage.c sometimes needs -lintl.\n* Upgrade to libopts from 5.17.3pre10.\n(4.2.7p362) 2013/03/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2364] \"sed -i\" is not portable.\n(4.2.7p361) 2013/03/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2357] sntp/libopts/usage.c sometimes needs -lintl.\n* [Bug 2365] \"make check\" fails in libevent.\n(4.2.7p360) 2013/03/15 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade libevent (coverity fixes, etc.).\n* EEXIST is OK for mkdir() in sntp/kod_management.c.\n(4.2.7p359) 2013/03/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2359] Fix send_via_ntp_signd() prototype.\n(4.2.7p358) 2013/02/27 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to autogen-5.17.3pre4 and libopts-38.0.13.\n* [Bug 2357] sntp/libopts/usage.c on NetBSD needs -lintl.\n(4.2.7p357) 2013/02/22 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to autogen-5.17.2pre and libopts-38.0.13.\n(4.2.7p356) 2013/02/19 Released by Harlan Stenn <stenn@ntp.org>\n* Added loc/debian.\n(4.2.7p355) 2013/02/18 Released by Harlan Stenn <stenn@ntp.org>\n* CID 739708: Check return status of fcntl() in refclock_arc.c.\n* CID 739709: Check return status of fcntl() in refclock_datum.c.\n* CID 739710: Check return status of mkdir() in sntp/kod_management.c.\n* CID 739711: Ignore return status of remove() in ntp-keygen.c.\n* CID 739723: Print sizeof as unsigned.\n* CID 971094: Clean up time of check/time of use in check_leap_file().\n(4.2.7p354) 2013/02/10 Released by Harlan Stenn <stenn@ntp.org>\n* CID 97194: Check return from setsockopt().\n* CID 739473,739532: Out-of-bounds access/illegal address computation.\n* CID 739558: Double close.\n* CID 739559: Double close.\n* CID 739713: devmask/recmask copy/paste error.\n* CID 739714: Fix code indentation level.\n* CID 739715: Clean up sockaddr_dump().\n(4.2.7p353) 2013/02/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2326] Check hourly for a new leapfile if the old one expired.\n(4.2.7p352) 2013/01/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2326] Notice when a new leapfile has been installed.\n(4.2.7p351) 2013/01/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2328] Don't apply small time adjustments on Windows versions\n which don't support this.\n(4.2.7p350) 2013/01/21 Released by Harlan Stenn <stenn@ntp.org>\n* Added sntp/loc/netbsd based on info from Christos Zoulas.\n(4.2.7p349) 2013/01/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2321] Fixed Windows build, but autogen update still required.\n(4.2.7p348) 2013/01/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2327] Rename sntp/ag-tpl/:Old to sntp/ag-tpl/Old.\n* Cleanup to ntpsnmpd-opts.def.\n* Cleanup to ntpq.texi.\n* Documentation cleanup to the ntpd, ntpdc, ntpq and ntp-wait\n .def files.\n* In ntp.conf.def, cleanup SEE ALSO, document 'rlimit' options.\n* Add a reference to RFC5907 in the ntpsnmpd documentation.\n(4.2.7p347) 2013/01/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2325] Re-enable mlockall() check under Linux post-1223 fix.\n(4.2.7p346) 2013/01/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1223] reorganize inclusion of sys/resource.h.\n(4.2.7p345) 2013/01/04 Released by Harlan Stenn <stenn@ntp.org>\n* Update several .def files to use autogen-5.17 feature set.\n(4.2.7p344) 2013/01/03 Released by Harlan Stenn <stenn@ntp.org>\n* Refactor and enhance mdoc2texi.\n* Make sure agtexi-file.tpl defines label-str.\n* Cleanup to ntp.conf.def.\n* Upgrade to autogen-5.17 and libopts-37.0.12.\n(4.2.7p343) 2013/01/02 Released by Harlan Stenn <stenn@ntp.org>\n* Update the copyright year.\n(4.2.7p342) 2012/12/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2081 - Backward Incompatible] rawstats now logs everything.\n(4.2.7p341) 2012/12/30 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.7p340) 2012/12/29 Released by Harlan Stenn <stenn@ntp.org>\n* mdoc2texi fixes: trailing punctuation.\n(4.2.7p339) 2012/12/26 Released by Harlan Stenn <stenn@ntp.org>\n* mdoc2texi fixes: parseQuote, closing of list item tables.\n* ntp-wait, ntpd, ntpdc, ntpq, ntpsnmpd autogen documentation updates.\n(4.2.7p338) 2012/12/25 Released by Harlan Stenn <stenn@ntp.org>\n* mdoc2texi fixes: Handle_ArCmFlIc, Handle_Fn, HandleQ.\n* ntp-keygen autogen documentation updates.\n* ntpq autogen docs.\n(4.2.7p337) 2012/12/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1223] More final cleanup for rlimit changes.\n(4.2.7p336) 2012/12/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1223] Final cleanup for rlimit changes.\n(4.2.7p335) 2012/12/18 Released by Harlan Stenn <stenn@ntp.org>\n* Update documentation templates and definitions.\n* Create agtexi-file.tpl .\n(4.2.7p334) 2012/12/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2114] Update tests for sntp's synch distance.\n* Create ntp-keygen.{html,texi}.\n(4.2.7p333) 2012/12/07 Released by Harlan Stenn <stenn@ntp.org>\n* Autogen documentation cleanup.\n(4.2.7p332) 2012/12/06 Released by Harlan Stenn <stenn@ntp.org>\n* sntp documentation cleanup.\n(4.2.7p331) 2012/12/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2114] Correctly calculate sntp's synch distance.\n(4.2.7p330) 2012/12/03 Released by Harlan Stenn <stenn@ntp.org>\n* autogen doc cleanup\n(4.2.7p329) 2012/12/01 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2278] ACTS flag3 mismatch between code and driver18.html.\n* Use an enum for the ACTS state table.\n* html doc reconciliation with DLM's copy.\n(4.2.7p328) 2012/11/30 Released by Harlan Stenn <stenn@ntp.org>\n* html doc reconciliation with DLM's copy.\n(4.2.7p327) 2012/11/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2024] Identify Events in the system status word in decode.html.'\n* [Bug 2040] Provide a command-line option for the identity key bits.\n* Create loc/darwin for Mac OSX\n(4.2.7p326) 2012/11/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1214] 'proto: precision = ...' should be at INFO, not NOTICE.\n* [Bug 2246] Clear sys_leap when voting says to disarm the leap.\n(4.2.7p325) 2012/11/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2202] ntpq.html: there is no \"acv\" billboard.\n* [Bug 2306] keep pps hack for Win32 even if user-mode/loopback\n PPS API is activated on a serial line.\n(4.2.7p324) 2012/11/19 Released by Harlan Stenn <stenn@ntp.org>\n* Reinstate doc fix to authentic.html from Mike T.\n* [Bug 1223] cleanup for rlimit changes.\n* [Bug 2098] Install DLM's HTML documentation.\n* [Bug 2306] Added user-mode/loop-back PPS API provider for Win32\n(4.2.7p323) 2012/11/18 Released by Harlan Stenn <stenn@ntp.org>\n* html/ updates from Dave Mills.\n(4.2.7p322) 2012/11/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1223] Allow configurable values for RLIMIT_STACK and\n RLIMIT_MEMLOCK.\n* [Bug 1320] Log ntpd's initial command-line parameters. (updated fix)\n* [Bug 2120] no sysexits.h under QNX.\n* [Bug 2123] cleanup to html/leap.html.\n(4.2.7p321) 2012/11/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1320] Log ntpd's initial command-line parameters.\n(4.2.7p320) 2012/11/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 969] Clarify ntpdate.html documentation about -u and ntpd.\n* [Bug 1217] libisc/ifiter_sysctl.c:internal_current(): Ignore RTM\n messages with wrong version\n(4.2.7p319) 2012/11/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2296] Fix compile problem with building with old OpenSSL.\n(4.2.7p318) 2012/11/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2301] Remove spurious debug output from ntpq.\n(4.2.7p317) 2012/11/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 922] Allow interspersed -4 and -6 flags on the ntpq command line.\n(4.2.7p316) 2012/10/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2296] Update fix for Bug 2294 to handle --without-crypto.\n(4.2.7p315) 2012/10/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2294] ntpd crashes in FIPS mode.\n(4.2.7p314) 2012/10/23 Released by Harlan Stenn <stenn@ntp.org>\n* Document a tricky malloc() of dns_ctx in sntp.\n(4.2.7p313) 2012/10/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2291] sntp should report why it cannot open file.kod.\n* [Bug 2293] add support for SO_BINTIME, refine support for\n SO_TIMESTAMPNS (bug 1374)\n(4.2.7p312) 2012/10/11 Released by Harlan Stenn <stenn@ntp.org>\n* Clean up testing/debugging of fix for [Bug 938] from sntp/main.c .\n(4.2.7p311) 2012/10/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 938] The argument to the -D flag takes a number, not a string.\n* [Bug 1013] ntpdate's HTML page claims wrong default version.\n* [Bug 1374] Support SO_TIMESTAMPNS.\n(4.2.7p310) 2012/10/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1374] Support SO_TIMESTAMPNS.\n* [Bug 2266] Remove deprecated refclock_trak.c from Windows Makefile\n equivalents.\n* [Bug 2274] Bring libopts/enum.c back to (old) ANSI C compliance.\n(4.2.7p309) 2012/10/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2287] ntpdate returns 0 even if adjtime() call fails.\n(4.2.7p308) 2012/09/29 Released by Harlan Stenn <stenn@ntp.org>\n* CID 97198: Check return from ioctl() calls in refclock_acts.c.\n(4.2.7p307) 2012/09/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1997] Fix sntp broadcast timeouts.\n* [Bug 2234] Fix incorrect ntptrace html documentation.\n* [Bug 2262] Install html docs in $htmldir.\n* Fix typo in html/select.html.\n(4.2.7p306) 2012/09/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 752] ToS cleanup from Mike Tatarinov.\n(4.2.7p305) 2012/09/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 752] Use proper ToS network packet markings for IPv4 and IPv6.\n* [Bug 1232] Convert SHM refclock to use struct timespec.\n* [Bug 2258] Add syslog message about leap insertion.\n* [Bug 2263] broadcast server doesn't work for host with\n OS_MISSES_SPECIFIC_ROUTE_UPDATES.\n* [Bug 2271] Decode refclock types when built with --disable-all-clocks.\n* [Bug 2276] clk_sel240x.c #define's _XOPEN_SOURCE, breaking QNX6.\n* Updates to driver28.html.\n(4.2.7p304) 2012/09/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2264] Cleanup SEL240X Refclock.\n* In refclock_wwv.c rename SECOND to WWV_SEC and MINUTE to WWV_MIN.\n(4.2.7p303) 2012/09/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1232] Add nanosecond support to SHM driver.\n(4.2.7p302) 2012/09/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2160] Log warning about expired leapseconds file.\n(4.2.7p301) 2012/09/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2164] Greater precision needed for ntpq offset report.\n* Clean the man5_MANS in ntpd/ .\n(4.2.7p300) 2012/09/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2262] Install sntp.html into htmldir.\n* [Bug 2270] Install fails due to repeated man5 page names.\n(4.2.7p299) 2012/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* More cleanup to the bootstrap script.\n(4.2.7p298) 2012/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* Handle additional man page sections in the bootstrap script.\n* Remove extraneous parens.\n* Add a missing \"%s\" syslog format string.\n(4.2.7p297) 2012/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* Fix mdoc2man.\n* Distribute ntp.conf.def and ntp.keys.def.\n(4.2.7p296) 2012/08/31 Released by Harlan Stenn <stenn@ntp.org>\n* Begin support for autogen maintaining ntp.conf and ntp.keys docs.\n* Upgrade to autogen-5.16.2 and libopts-36.5.11.\n* Potential bugfix for agtexi-cmd.tpl.\n(4.2.7p295) 2012/08/11 Released by Harlan Stenn <stenn@ntp.org>\n* Look for syslog's facilitynames[].\n(4.2.7p294) 2012/08/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2242] configure fails to detect getifaddrs function on Solaris.\n* [Bug 2249] Bad operator for 'test' in 'make check' of libevent.\n* [Bug 2252] palisade: formats nanosecs to a 6-char field.\n* Attempt to resolve strict-aliasing violation in refclock_tsyncpci.c.\n* Fix && -> & typo in refclock_palisade.c debug statements.\n(4.2.7p293) 2012/08/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2247] (more) Get rid of the TRAK refclock - deprecated since 2006.\n* Documentation cleanup from Mike T.\n* Cleanup kclk_sel240x.o rules in libparse/Makefile.am.\n(4.2.7p292) 2012/08/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1545] Note why we are logging the Version string.\n* [Bug 1872] Remove legacy ppsclock fdpps, #ifdef PPS.\n* [Bug 2075] Fix spelling of 'incompatible'.\n* [Bug 2247] Get rid of the TRAK refclock - deprecated since 2006.\n* Clean up an exit status in ntpq.c.\n(4.2.7p291) 2012/07/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2241] MDNS registration should only happen if requested.\n(4.2.7p290) 2012/07/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1454] Add parse clock support for the SEL-240x GPS products.\n* CID 709185: refclock_chu.c will leak fd==0 (better fix)\n(4.2.7p289) 2012/07/16 Released by Harlan Stenn <stenn@ntp.org>\n* CID 97123: Future-proof possible change to refclock_nmea.c.\n* CID 97377: ntp-keygen.c's followlink() might not NUL-terminate.\n* CID 709185: refclock_chu.c will leak fd==0 (which should be impossible).\n(4.2.7p288) 2012/07/03 Released by Harlan Stenn <stenn@ntp.org>\n* CID 709173: Make sure a libisc function we do not use is called properly.\n(4.2.7p287) 2012/07/03 Released by Harlan Stenn <stenn@ntp.org>\n* Remove 1024 associations-per-server limit from ntpq.\n* Remove blank line between ntpq mreadvar associations.\n(4.2.7p286) 2012/06/28 Released by Harlan Stenn <stenn@ntp.org>\n* CID 97193: check return from sscanf() in ntp_config.c.\n* CID 709169: check return from open(\"/dev/null\", 0) and friends.\n* CID 709207: Initialize \"quality\" for ulink_receive.\n(4.2.7p285) 2012/06/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2227] Enable mrulist access control via \"restrict ... nomrulist\".\n* Automake-1.12 wants us to use AM_PROG_AR.\n* Conditionalize msyslog messages about rejected mode 6 requests due to\n nomodify and nomrulist restrictions under \"logconfig +sysinfo\".\n* Increment sys_restricted in a few rejection paths due to nomodify\n restrictions where previosuly overlooked.\n(4.2.7p284) 2012/06/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2225] libevent configure hangs.\n* Update bundled libevent to git master, post libevent 2.1.1-alpha.\n(4.2.7p283) 2012/06/16 Released by Harlan Stenn <stenn@ntp.org>\n* In sntp/m4/ntp_openssl.m4, Support multiple package names for the\n crypto library. Add legacy support for -Wl,-rpath.\n(4.2.7p282) 2012/06/15 Released by Harlan Stenn <stenn@ntp.org>\n* tickadj may need to be linked with PTHREAD_LIBS.\n(4.2.7p281) 2012/06/14 Released by Harlan Stenn <stenn@ntp.org>\n* U_INT32_MAX cleanup in include/ntp_types.h .\n* When linking, ntp_keygen and tickadj need $(LIBM).\n(4.2.7p280) 2012/06/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2224] Use-after-free in routing socket code after dropping root.\n(4.2.7p279) 2012/06/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2211] findbcastinter(): possibly undefined variable iface used.\n* [Bug 2220] Incorrect check for maximum association id in ntpq.\n(4.2.7p278) 2012/06/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2204] Build with --enable-getifaddrs=glibc fails.\n* [Bug 2178] refclock_tsyncpci.c reach register fails to shift.\n* [Bug 2191] dcfd -Y y2kcheck on CentOS 6.2 x86_64 breaks make check.\n(4.2.7p277) 2012/05/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2193] Building timestruct tests with Clang 3.1 fails.\n(4.2.7p276) 2012/05/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2179] Remove sntp/header.h.\n(4.2.7p275) 2012/04/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1744] Remove obsolete ntpdate/ntptime* items.\n(4.2.7p274) 2012/04/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2174] ntpd rejects source UDP ports less than 123 as bogus.\n(4.2.7p273) 2012/04/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2141] handle_sigio() calls get_systime(), which must be\n reentrant when SIGIO is used. Sanity checks relative to the prior\n get_systime() are disabled in ntpd on systems with signaled I/O, but\n active in sntp and ntpdate.\n* Correct authnumfreekeys accounting broken in 4.2.7p262.\n(4.2.7p272) 2012/04/14 Released by Harlan Stenn <stenn@ntp.org>\n* LCRYPTO is gone - replace with VER_SUFFIX.\n* Change the link order for ntpsntpd.\n* Remove extra 'nlist' check from configure.ac.\n(4.2.7p271) 2012/04/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1122] openssl detection via pkg-config fails when no additional\n -Idir flags are needed.\n* Avoid overwriting user variable LDFLAGS with OpenSSL flags, instead\n they are added to LDFLAGS_NTP.\n(4.2.7p270) 2012/03/26 Released by Harlan Stenn <stenn@ntp.org>\n* Update driver45.html page.\n(4.2.7p269) 2012/03/25 Released by Harlan Stenn <stenn@ntp.org>\n* Clean up configure.ac.\n* Cleanup configure.ac's TSYNC PCI section.\n(4.2.7p268) 2012/03/24 Released by Harlan Stenn <stenn@ntp.org>\n* Update driver45.html page.\n(4.2.7p267) 2012/03/23 Released by Harlan Stenn <stenn@ntp.org>\n* Initial cut at a basic driver45.html page.\n(4.2.7p266) 2012/03/21 Released by Harlan Stenn <stenn@ntp.org>\n* Add refclock_tsyncpci.c (driver 45) supporting Spectracom TSYNC timing\n boards.\n(4.2.7p265) 2012/03/20 Released by Harlan Stenn <stenn@ntp.org>\n* Treat zero counter as indication of precise system time in Windows\n PPSAPI helper function pps_ntp_timestamp_from_counter(), enabling\n PPSAPI providers to use the Windows 8 precise clock directly.\n(4.2.7p264) 2012/03/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2160] Note if leapseconds file is past its prime.\n* Use GetSystemTimePreciseAsFileTime() on Windows 8.\n(4.2.7p263) 2012/03/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2156] clock instability with LOCAL driver, from Miroslav Lichvar.\n* [Bug 2159] Windows ntpd using leapfile erroneous leap second 20120401.\n(4.2.7p262) 2012/02/29 Released by Harlan Stenn <stenn@ntp.org>\n* Improve ntpd scalability for servers with many trusted keys.\n(4.2.7p261) 2012/02/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2048] add the clock variable timecode to SHM refclock.\n(4.2.7p260) 2012/02/24 Released by Harlan Stenn <stenn@ntp.org>\n* Fix the check-scm-rev invocation in several Makefile.am's.\n(4.2.7p259) 2012/02/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2148] ntpd 4.2.7p258 segfault with 0x0100000 bit in NMEA mode.\n* refclock_nmea.c merge cleanup thanks to Juergen Perlinger.\n(4.2.7p258) 2012/02/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2140] Rework of Windows I/O completion port handling to avoid\n garbling serial input in UNIX line discipline emulation.\n* [Bug 2143] NMEA driver: discard data if quality indication not good,\n add statistic counters (mode bit enabled) to clockstats file.\n(4.2.7p257) 2012/02/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2135] defer calls to 'io_input' to main thread under Windows.\n(4.2.7p256) 2012/02/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2131] Set the system variable settimeofday only after clock step.\n* [Bug 2134] --enable-C99-snprintf does not force rpl_snprintf use.\n(4.2.7p255) 2012/01/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 603] Only link with nlist()-related libraries when needed:\n More cleanup.\n(4.2.7p254) 2012/01/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 603] Only link with nlist()-related libraries when needed.\n(4.2.7p253) 2012/01/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2126] Compile error on Windows with libopts from Autogen 5.14.\n* Update one of the license URLs.\n(4.2.7p252) 2012/01/25 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to autogen-5.14 (and libopts-36.1.11).\n(4.2.7p251) 2012/01/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2115] ntptrace should accept both rootdispersion and rootdisp.\n(4.2.7p250) 2012/01/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2113] Warn about ignored extra args in ntpq.\n* Update the copyright year.\n(4.2.7p249) 2012/01/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2111] Remove minpoll delay before iburst for pool and\n manycastclient.\n* Move refclock-specific scheduled timer code under #ifdef REFCLOCK\n and move \"action\" and \"nextaction\" data for same from struct peer to\n struct refclockproc. These provide a way to schedule a callback some\n seconds in the future.\n(4.2.7p248) 2012/01/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2109] \"make clean check\" is broken with gtest available.\n* [Bug 2110] systime.c typo breaks build on microsecond clocks.\n(4.2.7p247) 2012/01/07 Released by Harlan Stenn <stenn@ntp.org>\n* Fix build break triggered by updating deps-ver and libntp/systime.c at\n the same time by explicitly depending systime_s.c on systime.c.\n(4.2.7p246) 2012/01/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2104] ntpdc fault with oversize -c command.\n* [Bug 2106] Fix warnings when using -Wformat-security.\n* Refactor timespecops.h and timevalops.h into inline functions.\n(4.2.7p245) 2011/12/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2100] conversion problem with timespec/timeval <--> l_fp fixed;\n added tests to expose the bug.\n(4.2.7p244) 2011/12/25 Released by Harlan Stenn <stenn@ntp.org>\n* Updates from 4.2.6p5.\n(4.2.7p243) 2011/12/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2095] ntptrace now needs 'rv' instead of 'pstat', reported\n by Michael Tatarinov.\n(4.2.7p242) 2011/12/21 Released by Harlan Stenn <stenn@ntp.org>\n* Include missing html/icons/sitemap.png, reported by Michael Tatarinov.\n* Documentation updates from Dave Mills.\n(4.2.7p241) 2011/12/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2015] Overriding sys_tick should recalculate sys_precision.\n* [Bug 2037] Fuzzed non-interpolated clock may decrease.\n* [Bug 2068] \"tos ceiling\" default and cap changed to 15.\n* Floor peer delay using system precision, as with jitter, reflecting\n inability to measure shorter intervals.\n(4.2.7p240) 2011/12/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2092] clock_select() selection jitter miscalculated.\n* [Bug 2093] Reintroduce smaller stratum factor to system peer metric.\n(4.2.7p239) 2011/12/11 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p238) 2011/12/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2082] from 4.2.6p5-RC3: 3-char refid sent by ntpd 4.2.6p5-RC2\n ends with extra dot.\n* [Bug 2085] from 4.2.6p5-RC3: clock_update() sys_rootdisp calculation\n omits root delay.\n* [Bug 2086] from 4.2.6p5-RC3: get_systime() should not offset by\n sys_residual.\n* [Bug 2087] from 4.2.6p5-RC3: sys_jitter calculation overweights\n sys.peer jitter.\n* from 4.2.6p5-RC3: Ensure NULL peer->dstadr is not accessed in orphan\n parent selection.\n(4.2.7p237) 2011/12/01 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2050] from 4.2.6p5-RC2: Orphan mode stratum counting to infinity.\n* [Bug 2059] from 4.2.6p5-RC2: optional billboard column \"server\" does\n not honor -n.\n* [Bug 2066] from 4.2.6p5-RC2: ntpq lopeers ipv6 \"local\" column overrun.\n* [Bug 2068] from 4.2.6p5-RC2: ntpd sends nonprintable stratum 16 refid\n to ntpq.\n* [Bug 2069] from 4.2.6p5-RC2: broadcastclient, multicastclient spin up\n duplicate ephemeral associations without broadcastdelay.\n* [Bug 2072] from 4.2.6p5-RC2: Orphan parent selection metric needs\n ntohl().\n* [Bug 2073] Correct ntpq billboard's MODE_PASSIVE t from 'u' to 'S'.\n* from 4.2.6p5-RC2: Exclude not-yet-determined sys_refid from use in\n loopback TEST12 (from Dave Mills).\n* from 4.2.6p5-RC2: Never send KoD rate limiting response to MODE_SERVER.\n* Floor calculation of sys_rootdisp at sys_mindisp in clock_update (from\n Dave Mills).\n* Restore 4.2.6 clock_combine() weighting to ntp-dev, reverting to pre-\n 4.2.7p70 method while also avoiding divide-by-zero (from Dave Mills).\n* Round l_fp traffic interval when converting to integer in rate limit\n and KoD calculation.\n(4.2.7p236) 2011/11/16 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p235) 2011/11/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2052] Autokey CRYPTO_ASSOC host@group vallen needs checking.\n(4.2.7p234) 2011/11/07 Released by Harlan Stenn <stenn@ntp.org>\n* Clean up -libm entries regarding libntp.a\n(4.2.7p233) 2011/11/06 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p232) 2011/11/05 Released by Harlan Stenn <stenn@ntp.org>\n* Update the NEWS file so we note the default disable of mode 7 requests.\n* Clean up some bitrotted code in libntp/socket.c.\n(4.2.7p231) 2011/11/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1940] ignore auth key if hex decoding fails.\n* Add ntpq reslist command to query access restrictions, similar to\n ntpdc's reslist.\n(4.2.7p230) 2011/11/01 Released by Harlan Stenn <stenn@ntp.org>\n* Disable mode 7 (ntpdc) query processing in ntpd by default. ntpq is\n believed to provide all functionality ntpdc did, and uses a less-\n fragile protocol that's safer and easier to maintain. If you do find\n some management via ntpdc is needed, you can use \"enable mode7\" in the\n ntpd configuration.\n* Directly limit the number of datagrams in a mrulist response, rather\n than limiting the number of entries returned to indirectly limit the\n datagram count.\n* Documentation updates from Dave Mills.\n(4.2.7p229) 2011/10/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1995] fix wrong use of ZERO() macro in 'ntp_calendar.c'\n(4.2.7p228) 2011/10/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1995] add compile time stamp based era unfolding for\n 'step_systime()' and necessary support to 'ntp-calendar.c'.\n(4.2.7p227) 2011/10/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2036] gcc 2.95.3 preprocessor can't nest #ifdef in macro args.\n* A number of compiler warnings eliminated.\n(4.2.7p226) 2011/10/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2035] ntpq -c mrulist sleeps 1 sec between queries, not 5 msec.\n* Documentation updates from Dave Mills.\n(4.2.7p225) 2011/10/15 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p224) 2011/10/14 Released by Harlan Stenn <stenn@ntp.org>\n* ntpq mrulist shows intermediate counts every five seconds while\n retrieving list, and allows Ctrl-C interruption of the retrieval,\n showing the incomplete list as retrieved. Reduce delay between\n successive mrulist retrieval queries from 30 to 5 msec. Do not\n give up mrulist retrieval when a single query times out.\n(4.2.7p223) 2011/10/12 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p222) 2011/10/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2029] \"make check\" clutters syslog.\n* Log signal description along with number on ntpd exit.\n(4.2.7p221) 2011/10/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2025] Switching between daemon and kernel loops can doubly-\n correct drift\n* [Bug 2028] ntpd -n (nofork) redirects logging to stderr.\n* Documentation updates from Dave Mills.\n(4.2.7p220) 2011/10/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1945] mbg_gps166.h use of _TM_DEFINED conflicts with MS VC.\n* [Bug 1946] parse_start uses open; does not work on Windows.\n* [Bug 1947] Porting parse-based Wharton refclock driver to Windows.\n* [Bug 2024] Remove unused system event code EVNT_CLKHOP.\n(4.2.7p219) 2011/10/04 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p218) 2011/10/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2019] Allow selection of cipher for private key files.\n* Documentation updates from Dave Mills.\n* ntp-keygen private key cipher default now triple-key triple DES CBC.\n* ntp-keygen -M is intended to ignore all other defaults and\n options, so do not attempt to open existing Autokey host certificate\n before generating symmetric keys and terminating.\n* Restore IFF, MV, and GQ identity parameter filename convention to\n ntpkey_<scheme>par_<group/host> in ntpd, matching ntp-keygen.\n* Change some error logging to syslog to ignore logconfig mask, such\n as reporting PPSAPI failure in NMEA and WWVB refclocks.\n* ntp-keygen on Windows XP and later systems will now create links\n expected by ntpd. They are hardlinks on Windows, soft on POSIX.\n* Conditionalize NMEA serial open message under clockevent.\n* Send all peer variables to trappers in report_event().\n(4.2.7p217) 2011/09/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2020] ntp-keygen -s no longer sets host in cert file name.\n* [Backward Incompatible] ntp-keygen -i option long name changed from\n misleading --issuer-name to --ident.\n(4.2.7p216) 2011/09/27 Released by Harlan Stenn <stenn@ntp.org>\n* sntp documentation tag cleanup.\n* mdoc2man improvements.\n(4.2.7p215) 2011/09/24 Released by Harlan Stenn <stenn@ntp.org>\n* Use patched mdoc2man script, from Eric Feng.\n* Sync with ntp-4.2.6p4 (a no-op).\n(4.2.7p214) 2011/09/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1981] Initial offset convergence applies frequency correction 2x\n with kernel discipline.\n* [Bug 2008] Initial offset convergence degraded with 500 PPM adjtime().\n* [Bug 2009] EVNT_NSET adj_systime() mishandled by Windows ntpd.\n(4.2.7p213) 2011/09/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1999] NMEA does not send PMOTG messages any more.\n(4.2.7p212) 2011/09/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2003] from 4.2.6p4-RC3: ntpq_read_assoc_peervars() broken.\n(4.2.7p211) 2011/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* Update libevent to git head (2.1 branch) as of 2.0.14-stable.\n(4.2.7p210) 2011/08/31 Released by Harlan Stenn <stenn@ntp.org>\n* Require -D4 or higher for ntpd SIGALRM debug trace from [Bug 2000].\n(4.2.7p209) 2011/08/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 2000] ntpd worker threads must block signals expected in main\n thread.\n* [Bug 2001] add ntpq -c timerstats like ntpdc -c timerstats.\n* [Bug 2001] from 4.2.6p4-RC3: ntpdc timerstats reports overruns as\n handled.\n* Update sntp tests to track the change of root dispersion to\n synchronization distance.\n(4.2.7p208) 2011/08/24 Released by Harlan Stenn <stenn@ntp.org>\n* Fix the CLOCK_MONOTONIC TRACE() message.\n(4.2.7p207) 2011/08/22 Released by Harlan Stenn <stenn@ntp.org>\n* Restore the original CLOCK_MONOTONIC output format in sntp.\n* Cleanups for ntp-wait-opts.def and ntp.keys.def .\n(4.2.7p206) 2011/08/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1993] ntpd Windows port adj_systime() broken in 4.2.7p203.\n* sntp documentation and behavior improvements suggested by\n Steven Sommars.\n* Have sntp report synchronization distance instead of root dispersion.\n* Clean up ntp-wait-opts.def .\n(4.2.7p205) 2011/08/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1992] util/tg2 doesn't compile, needs libntp.\n(4.2.7p204) 2011/08/16 Released by Harlan Stenn <stenn@ntp.org>\n* Added support for Garmin's $PGRMF sentence to NMEA driver\n* [Bug 1988] Better sntp send failed error message needed.\n* [Bug 1989] sntp manual page sometimes refers to SNTP as a program.\n* [Bug 1990] sntp output should include stratum.\n(4.2.7p203) 2011/08/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1986] Require Visual C++ 2005 or later compilers in Windows port.\n* Actually use long long for (u_)int64 by correcting spelling of\n SIZEOF_LONG_LONG in ntp_types.h.\n* Force .exe minimum Windows version to 0x0400 to allow NT4 in\n vs2005/*.vcproj files.\n* Fix make distcheck with --enable-libevent-regress problem with\n unwritable $srcdir.\n* Correct init_logging()'s def_syslogmask type to u_int32 following\n change of ntp_syslogmask from u_long to u_int32 in p202.\n(4.2.7p202) 2011/08/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1983] --without-sntp build breaks in sntp subdir.\n* [Bug 1984] from 4.2.6p4-RC3: ntp/libisc fails to compile on OS X 10.7.\n* [Bug 1985] from 4.2.6p4-RC3: \"logconfig =allall\" rejected.\n(4.2.7p201) 2011/08/05 Released by Harlan Stenn <stenn@ntp.org>\n* sntp: change -h/--headspace to -g/--gap, and change the default gap\n from 10 to 50ms\n* [Backward Incompatible] from 4.2.6p4: sntp: -l/--filelog ->\n -l/--logfile, to be consistent with ntpd.\n* Documentation updates from Dave Mills.\n* From 4.2.6p4: libopts/file.c fix from Bruce Korb (arg-type=file).\n(4.2.7p200) 2011/08/04 Released by Harlan Stenn <stenn@ntp.org>\n* Sync with 4.2.6p4-RC2.\n(4.2.7p199) 2011/07/29 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p198) 2011/07/28 Released by Harlan Stenn <stenn@ntp.org>\n* remove old binsubdir stuff from SNTP, as NTP_LOCINFO does that now.\n(4.2.7p197) 2011/07/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1975] from 4.2.6p4-RC2: libntp/mktime.c won't work with 64-bit\n time_t\n* [Bug 1976] genLocInfo writes to srcdir break 'make distcheck'.\n* [Bug 1977] Fix flag/description mismatches in ntp-keygen-opts.def.\n* Do not force \"legacy\" when --with-locfile is not given, genLocInfo\n will find the correct default for the system.\n* Fix warnings in ntp_request.c ([Bug 1973] oversight) and sntp/main.c\n (CID 159, apparent overrun due to union, actually correct).\n* Update sntp/loc/solaris to conform to stock locations.\n(4.2.7p196) 2011/07/27 Released by Harlan Stenn <stenn@ntp.org>\n* DEFAULT INSTALLATION DIRECTORY CHANGES ON SOME OSes: to get the old\n behavior, pass --with-locfile=legacy to 'configure'\n* [Bug 1972] from 4.2.6p4-RC2: checking for struct rtattr fails.\n* [Bug 1973] Widen reference clock mode from 8 to 32 bits.\n* Removed sntp/m4/ntp_bindir.m4 - no longer needed.\n* Move loc/ to sntp/loc/ .\n* Move scripts/cvo.sh to sntp/scripts/cvo.sh .\n* Move scripts/genLocInfo to sntp/scripts/genLocInfo .\n* Give NTP_LOCINFO an optional path-to argument.\n* Remove hacks to get NTP_LOCINFO-related data to sntp/ .\n* Move sntp/include/mansec2subst.sed to sntp/scripts/mansec2subst.sed .\n* If no \"more specific\" loc file is found for redhat* or fedora*,\n look for a loc/redhat file.\n* If no \"more specific\" loc file is found and uname says this is Linux,\n look for a loc/linux file.\n* Improve the help text: --with-locfile=XXX .\n* work around solaris /bin/sh issues for genLocInfo.\n(4.2.7p195) 2011/07/25 Released by Harlan Stenn <stenn@ntp.org>\n* Added loc/redhat.\n(4.2.7p194) 2011/07/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1608] from 4.2.6p4-RC2: Parse Refclock driver should honor\n trusttime.\n* Add support for installing programs and scripts to libexec.\n* Added loc/solaris.\n(4.2.7p193) 2011/07/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1970] from 4.2.6p4-RC2: UNLINK_EXPR_SLIST() causes crash if list\n is empty.\n* Update libevent to 2.1 HEAD as of merge of 2.0.13-stable-dev.\n* Match addr_eqprefix() sizeof and memcpy destination to make it clear\n to static analysis that there is no buffer overrun (CID 402).\n(4.2.7p192) 2011/07/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1966] Broken FILES section for ntp.keys.def.\n(4.2.7p191) 2011/07/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1948] Update man page section layout.\n* [Bug 1963] add reset command for ntpq :config, similar to ntpdc's.\n* [Bug 1964] --without-sntp should not build sntp.\n(4.2.7p190) 2011/07/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1961] from 4.2.6p4: html2man update: distribute ntp-wait.html.\n* Require autogen-5.12.\n(4.2.7p189) 2011/07/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1134] from 4.2.6p4-RC1: ntpd fails binding to tentative IPv6\n addresses.\n* [Bug 1790] from 4.2.6p4-RC1: Update config.guess and config.sub to\n detect AIX6.\n(4.2.7p188) 2011/06/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1958] genLocInfo must export PATH.\n* ntp-wait: some versions of ntpd spell \"associd\" differently.\n(4.2.7p187) 2011/06/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1954] Fix typos in [s]bin_PROGRAMS in ntpd/Makefile.am.\n* Implement --with-locfile=filename configure argument. If filename is\n empty we'll look under loc/ for a good fit. If the filename contains\n a / character, it will be treated as a \"normal\" pathname. Otherwise,\n that explicit file will be searched for under loc/ .\n(4.2.7p186) 2011/06/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1950] Control installation of event_rpcgen.py.\n* Update .point-changed-filelist for the new man pages.\n* Update the building of OS-specific programs.\n* Finish conversion to genLocInfo.\n* validate MANTAGFMT in genLocInfo.\n* Documentation update from Dave Mills.\n(4.2.7p185) 2011/06/21 Released by Harlan Stenn <stenn@ntp.org>\n* ntp_locs.m4: handle the case where . is not in the PATH.\n* More genLocInfo cleanup.\n(4.2.7p184) 2011/06/20 Released by Harlan Stenn <stenn@ntp.org>\n* Added ntp_locs.m4.\n* genLocInfo improvements.\n* Add the man page tag \"flavor\" to the loc.* files.\n* Add/distribute genLocInfo.\n(4.2.7p183) 2011/06/19 Released by Harlan Stenn <stenn@ntp.org>\n* Update the autogen include list for scripts/Makefile.am.\n* Added loc.freebsd (and distribute it).\n* Added loc.legacy (and distribute it).\n(4.2.7p182) 2011/06/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1304] Update sntp.html to reflect new implementation.\n* Update .point-changed-filelist .\n* ntpdc documentation fixes.\n* Update ntp-wait autogen docs.\n* Update the ntpd autogen docs.\n* Update the ntpsnmpd autogen docs.\n* Use autogen to produce ntp-keygen docs.\n* Add \"license name\" to ntp.lic for autogen-5.11.10.\n* Prepare for ntp.keys.5.\n(4.2.7p181) 2011/06/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1938] addr_eqprefix() doesn't clear enough storage.\n(4.2.7p180) 2011/06/06 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to libevent-2.0.12.\n* More sntp.1 cleanups.\n* Produce ntpq.1 with the new autogen macros.\n* Remove the deprecated \"detail\" stanza from ntpdc-opts.def.\n(4.2.7p179) 2011/06/03 Released by Harlan Stenn <stenn@ntp.org>\n* Update cmd-doc.tlib to autogen-5.11.10pre5.\n* Upgrade local autoopts templates to 5.11.10pre5.\n(4.2.7p178) 2011/06/02 Released by Harlan Stenn <stenn@ntp.org>\n* Update the std_def_list to include the ntp.lic file.\n* Distribute the ntp.lic file.\n* Add http://ntp.org/license to the ntp.lic file.\n(4.2.7p177) 2011/06/01 Released by Harlan Stenn <stenn@ntp.org>\n* Use the latest autogen's new copyright template code.\n* Clean up the ntp.lic file.\n(4.2.7p176) 2011/05/31 Released by Harlan Stenn <stenn@ntp.org>\n* sntp documentation cleanup.\n* autogen documentation template cleanup.\n(4.2.7p175) 2011/05/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1936] Correctly set IPV6_MULTICAST_LOOP.\n* cmd-doc.tlib cleanup from Bruce Korb.\n* sntp documentation cleanup.\n(4.2.7p174) 2011/05/28 Released by Harlan Stenn <stenn@ntp.org>\n* ntpdc documentation cleanup.\n* sntp documentation cleanup.\n* Don't build libevent with openssl support. Right now, libevent\n doesn't use pkg-config to find openssl's installation location.\n(4.2.7p173) 2011/05/25 Released by Harlan Stenn <stenn@ntp.org>\n* Typo in emalloc.c hides file and line number from emalloc() error msg.\n* parsesolaris.c compile fails on SPARC Solaris with conflicting printf.\n* ntp_util.c compile fails on AIX and OSF with conflicting statsdir.\n(4.2.7p172) 2011/05/24 Released by Harlan Stenn <stenn@ntp.org>\n* Remove hardcoded 1/960 s. fudge for <CR> transmission time at 9600 8n1\n from WWVB/Spectracom driver introduced in 4.2.7p169.\n(4.2.7p171) 2011/05/23 Released by Harlan Stenn <stenn@ntp.org>\n* Eliminate warnings about shadowing global \"basename\" on Linux.\n* Use filegen_config() consistently when changing filegen options.\n* mprintf() should go to stdout, not stderr. DPRINTF() uses mprintf().\n* Repair a few simulator problems (more remain).\n* Documentation updates from Dave Mills.\n(4.2.7p170) 2011/05/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1932] libevent/util_internal.h builtin_expect compile error with\n gcc 2.95.\n* Use 64-bit scalars in LFPTOD() and DTOLFP() on more platforms by\n conditionalizing on HAVE_U_INT64 rather than UINT64_MAX.\n(4.2.7p169) 2011/05/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1933] WWVB/Spectracom driver timestamps LFs, not CRs.\n(4.2.7p168) 2011/05/16 Released by Harlan Stenn <stenn@ntp.org>\n* Convert receive buffer queue from doubly-linked list to FIFO.\n(4.2.7p167) 2011/05/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1927] io_closeclock() should purge pending recvbufs.\n* [Bug 1931] cv always includes fudgetime1, never fudgetime2.\n* Use acts_close() in acts_shutdown() to avoid leaving a stale lockfile\n if unpeered via runtime configuration while the modem is open.\n* Correct acts_close() test of pp->io.fd to see if it is open.\n* 4.2.7p164 documentation updates re: 'tos orphanwait' expanded scope.\n(4.2.7p166) 2011/05/13 Released by Harlan Stenn <stenn@ntp.org>\n* If we have local overrides for autogen template files, use them.\n* Convert more of the sntp-opt.def documentation from man to mdoc.\n(4.2.7p165) 2011/05/11 Released by Harlan Stenn <stenn@ntp.org>\n* Convert snmp docs to mdoc format, which requires autogen 5.11.9.\n* from 4.2.6p4-RC1: Require autogen 5.11.9.\n(4.2.7p164) 2011/05/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 988] Local clock eats up -g option, so ntpd stops with large\n initial time offset.\n* [Bug 1921] LOCAL, ACTS drivers with \"prefer\" excluded from initial\n candidate list.\n* [Bug 1922] \"tos orphanwait\" applied incorrectly at startup.\n* [Bug 1923] orphan parent favored over LOCAL, ACTS drivers.\n* [Bug 1924] Billboard tally codes sometimes do not match operation,\n variables.\n* Change \"pool DNS\" messages from msyslog to debug trace output.\n* Remove unused FLAG_SYSPEER from peer->status.\n* Respect \"tos orphanwait\" at startup. Previously there was an\n unconditional 300 s. startup orphanwait, though other values were\n respected for subsequent orphan wait periods after no_sys_peer events.\n* Apply \"tos orphanwait\" (def. 300 seconds) to LOCAL and ACTS reference\n clock drivers, in addition to orphan parent operation. LOCAL and ACTS\n are not selectable during the orphanwait delay at startup and after\n each no_sys_peer event. This prevents a particular form of clock-\n hopping, such as using LOCAL briefly at startup before remote peers\n are selectable. This fixes the issue reported in [Bug 988].\n* Documentation updates from Dave Mills.\n(4.2.7p163) 2011/05/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1911] missing curly brace in libntp/ntp_rfc2553.c\n(4.2.7p162) 2011/05/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1910] Support the Tristate Ltd. TS-GPSclock-01.\n(4.2.7p161) 2011/05/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1904] 4.2.7p160 Windows build broken (POSIX_SHELL).\n* [Bug 1906] 4.2.7p160 - libtool: compile: cannot determine name of\n library object in ./libevent\n* Share a single sntp/libevent/build-aux directory between all three\n configure scripts.\n* Add missing --enable-local-libevent help to top-level configure.\n(4.2.7p160) 2011/05/01 Released by Harlan Stenn <stenn@ntp.org>\n* from 4.2.6p4-RC1: Upgrade to libopts 35.0.10 from AutoGen 5.11.9pre8.\n* [Bug 1901] Simulator does not set progname.\n(4.2.7p159) 2011/04/28 Released by Harlan Stenn <stenn@ntp.org>\n* Fix a couple of unused variable warnings.\n* cleanup in timespecops.c / timevalops.c\n(4.2.7p158) 2011/04/24 Released by Harlan Stenn <stenn@ntp.org>\n* Update libevent --disable-libevent-regress handling to work when\n building libevent using mingw.\n(4.2.7p157) 2011/04/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1890] 4.2.7p156 segfault in duplicate freeaddrinfo().\n(4.2.7p156) 2011/04/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1851] freeaddrinfo() called after getaddrinfo() fails.\n(4.2.7p155) 2011/04/18 Released by Harlan Stenn <stenn@ntp.org>\n* Fix leak in refclock_datum.c start failure path.\n(4.2.7p154) 2011/04/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1887] DNS fails on 4.2.7p153 using threads.\n(4.2.7p153) 2011/04/16 Released by Harlan Stenn <stenn@ntp.org>\n* A few more Coverity Scan cleanups.\n(4.2.7p152) 2011/04/15 Released by Harlan Stenn <stenn@ntp.org>\n* Update embedded libevent to current 2.1 git HEAD.\n(4.2.7p151) 2011/04/14 Released by Harlan Stenn <stenn@ntp.org>\n* Detect vsnprintf() support for \"%m\" and disable our \"%m\" expansion.\n* Add --enable-c99-sprintf to configure args for -noopenssl variety of\n flock-build to avoid regressions in (v)snprintf() replacement.\n* More msnprintf() unit tests.\n* Coverity Scan error checking fixes.\n* Log failure to fetch time from HOPF_P hardware.\n* Check HOPF_S sscanf() conversion count before converted values.\n(4.2.7p150) 2011/04/13 Released by Harlan Stenn <stenn@ntp.org>\n* Remove never-used, incomplete ports/winnt/ntpd/refclock_trimbledc.[ch]\n* On systems without C99-compliant (v)snprintf(), use C99-snprintf\n replacements (http://www.jhweiss.de/software/snprintf.html)\n* Remove remaining sprintf() calls except refclock_ripencc.c (which is\n kept out of --enable-all-clocks as a result), upstream libs which use\n sprintf() only after careful buffer sizing.\n(4.2.7p149) 2011/04/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1881] describe the {+,-,s} characters in configure --help output.\n(4.2.7p148) 2011/04/09 Released by Harlan Stenn <stenn@ntp.org>\n* Use _mkgmtime() as timegm() in the Windows port, rather than\n libntp/mktime.c's timegm(). Fixed [Bug 1875] on Windows using the old\n asn2ntp() code from before 4.2.7p147.\n* ntp_crypto.c string buffer safety.\n* Remove use of MAXFILENAME in mode 7 (ntpdc) on-wire structs.\n* Change ntpd MAXFILENAME from 128 to 256 to match ntp-keygen.\n* Buffer safety and sign extension fixes (thanks Coverity Scan).\n(4.2.7p147) 2011/04/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1875] 'asn2ntp()' rewritten with 'caltontp()'; 'timegm()'\n substitute likely to crash with 64bit time_t.\n(4.2.7p146) 2011/04/05 Released by Harlan Stenn <stenn@ntp.org>\n* String buffer safety cleanup, converting to strlcpy() and strlcat().\n* Use utmpname() before pututline() so repeated steps do not\n accidentally record into wtmp where utmp was intended.\n* Use setutent() before each pututline() including first.\n(4.2.7p145) 2011/04/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1840] ntp_lists.h FIFO macros buggy.\n(4.2.7p144) 2011/04/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1874] ntpq -c \"rv 0 sys_var_list\" empty.\n(4.2.7p143) 2011/03/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1732] ntpd ties up CPU on disconnected USB refclock.\n* [Bug 1861] tickadj build failure using uClibc.\n* [Bug 1862] in6addr_any test in configure fooled by arm gcc 4.1.3 -O2.\n* Remove kernel line discipline driver code for clk and chu, deprecate\n related LDISC_ flags, and remove associated ntpd code to decode the\n timestamps, remove clktest line discipline test program.\n* Remove \"signal_no_reset: signal 17 had flags 4000000\" logging, as it\n indicates no problem and is interpreted as an error. Previously some\n bits had been ignored one-by-one, but Linux SA_RESTORER definition is\n unavailable to user headers.\n(4.2.7p142) 2011/03/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1844] ntpd 4.2.7p131 NetBSD, --gc-sections links bad executable.\n* Fix \"make distcheck\" break in libevent/sample caused by typo.\n(4.2.7p141) 2011/03/20 Released by Harlan Stenn <stenn@ntp.org>\n* Add \"ntpq -c iostats\" similar to \"ntpdc -c iostats\".\n* Compare entire timestamp to reject duplicates in refclock_pps().\n(4.2.7p140) 2011/03/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1848] ntpd 4.2.7p139 --disable-thread-support does not compile.\n* Add --disable-thread-support to one flock-build variation.\n* One more lock-while-init in lib/isc/task.c to quiet lock analysis.\n(4.2.7p139) 2011/03/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1848] make check ntpd --saveconfigquit clutters syslog.\n(4.2.7p138) 2011/03/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1846] MacOSX: debug symbol not found by propdelay or tickadj.\n(4.2.7p137) 2011/03/07 Released by Harlan Stenn <stenn@ntp.org>\n* Use TRACE() instead of DPRINTF() for libntp and utilities, which\n use the \"debug\" variable regardless of #ifdef DEBUG.\n* Declare debug in libntp instead of each program. Expose extern\n declaration to utilities, libntp, and DEBUG ntpd.\n* Lock under-construction task, taskmgr objects to satisfy Coverity's\n mostly-correct assumptions about which variables are protected by\n which locks.\n(4.2.7p136) 2011/03/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1839] 4.2.7p135 still installs libevent ev*.h headers.\n(4.2.7p135) 2011/03/02 Released by Harlan Stenn <stenn@ntp.org>\n* libevent: When building on systems with CLOCK_MONOTONIC available,\n separate the internal timeline (possibly counting since system boot)\n from the gettimeofday() timeline in event_base cached timevals. Adds\n new event_base_tv_cached() to retrieve cached callback round start\n time on the internal timeline, and changes\n event_based_gettimeofday_cached() to always return times using the\n namesake timeline. This preserves the benefit of using the never-\n stepped monotonic clock for event timeouts while providing clients\n with times consistently using gettimeofday().\n* Correct event_base_gettimeofday_cached() workaround code in\n sntp to work with corrected libevent.\n* Remove sntp l_fp_output() test now that it uses prettydate().\n* [Bug 1839] 4.2.7p131 installs libevent ev*.h headers.\n* Ensure CONFIG_SHELL is not empty before relying on it for #! scripts.\n(4.2.7p134) 2011/02/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1837] Build fails on Win7 due to regedit requiring privilege.\n* Provide fallback definitions for GetAdaptersAddresses() for Windows\n build environments lacking iphlpapi.h.\n* Rename file containing 1.xxxx ChangeSet revision from version to\n scm-rev to avoid invoking GNU make implicit rules attempting to\n compile version.c into version. Problem was with sntp/version.o\n during make distcheck after fix for spurious sntp rebuilds.\n* Add INC_ALIGNED_PTR() macro to align pointers like malloc().\n(4.2.7p133) 2011/02/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1834] ntpdate 4.2.7p131 aborts with assertion failure.\n* Move sntp last in top-level Makefile.am SUBDIRS so that the libevent\n tearoff (if required) and sntp are compiled after the rest.\n* Use a single set of Automake options for each package in configure.ac\n AM_INIT, remove Makefile.am AUTOMAKE_OPTIONS= lines.\n* Correct spurious sntp rebuilds triggered by a make misperception\n sntp/version was out-of-date relative to phony target FRC.version.\n* Do not cache paths to perl, test, or pkg-config, searching the PATH\n at configure time is worth it to pick up tool updates.\n(4.2.7p132) 2011/02/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1832] ntpdate doesn't allow timeout > 2s.\n* [Bug 1833] The checking sem_timedwait() fails without -pthread.\n* ElectricFence was suffering bitrot - remove it. valgrind works well.\n* Enable all relevant automake warnings.\n* Correct Solaris 2.1x PTHREAD_ONCE_INIT extra braces test to avoid\n triggering warnings due to excess braces.\n* Remove libevent-cfg from sntp/Makefile.am.\n* Provide bug report and URL options to Autoconf.\n* Avoid relying on remake rules for routine build/flock-build for\n libevent as for the top-level and sntp subproject.\n(4.2.7p131) 2011/02/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1087] -v/--normalverbose conflicts with -v/--version in sntp.\n* [Bug 1088] sntp should (only) report the time difference without -s/-a.\n* older autoconf sometimes dislikes [].\n* Move \"can't write KoD file\" warning from sntp shutdown to startup.\n* refclock_acts.c cleanup from Dave Mills.\n* Convert sntp to libevent event-driven socket programming. Instead of\n blocking name resolution and querying one NTP server at a time,\n resolve server names and send NTP queries without blocking. Add\n sntp command-line options to adjust timing and optionally wait for all\n servers to respond instead of exiting after the first.\n* Import libevent 2.0.10-stable plus local patches as a tearoff, used\n only if the target system lacks an installed libevent 2.0.9 or later.\n* Move blocking worker and resolver to libntp from ntpd.\n* Use threads rather than forked child processes for blocking worker\n when possible. Override with configure --disable-thread-support.\n* Move init_logging(), change_logfile(), and setup_logfile() from ntpd\n to libntp, use them in sntp.\n* Test --without-sntp in flock-build script's -no-refclocks variety.\n* Avoid invoking config.status twice in a row in build script.\n* Move more m4sh tests needed by libntp to shared .m4 files.\n* Split up ntp_libntp.m4 into smaller, more specific subsets.\n* Enable gcc -Wcast-align, fix many instances of warnings when casting\n a pointer to a more-strictly-aligned underlying type.\n(4.2.7p130) 2011/02/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1811] Update the download location in WHERE-TO-START.\n(4.2.7p129) 2011/02/09 Released by Harlan Stenn <stenn@ntp.org>\n* Add missing \"break;\" to ntp_control.c ctl_putsys() for caliberrs, used\n by ntpq -c kerninfo introduced in 4.2.7p104.\n* Fix leak in ntp_control.c read_mru_list().\n(4.2.7p128) 2011/01/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1799] ntpq mrv crash.\n* [Bug 1801] ntpq mreadvar requires prior association caching.\n(4.2.7p127) 2011/01/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1797] Restore stale timestamp check from the RANGEGATE cleanup.\n(4.2.7p126) 2011/01/27 Released by Harlan Stenn <stenn@ntp.org>\n* Fix unexposed fencepost error in format_time_fraction().\n* Add more unit tests for timeval_tostr() and timespec_tostr().\n(4.2.7p125) 2011/01/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1794] ntpq -c rv missing clk_wander information.\n* [Bug 1795] ntpq readvar does not display last variable.\n(4.2.7p124) 2011/01/25 Released by Harlan Stenn <stenn@ntp.org>\n* sntp/Makefile.am needs any passed-in CFLAGS.\n(4.2.7p123) 2011/01/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1788] tvtots.c tables inaccurate\n(4.2.7p122) 2011/01/22 Released by Harlan Stenn <stenn@ntp.org>\n* ACTS refclock cleanup from Dave Mills.\n* Avoid shadowing the \"group\" global variable.\n(4.2.7p121) 2011/01/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1786] Remove extra semicolon from ntp_proto.c .\n(4.2.7p120) 2011/01/20 Released by Harlan Stenn <stenn@ntp.org>\n* Change new timeval and timespec to string routines to use snprintf()\n rather than hand-crafted conversion, avoid signed int overflow there.\n* Add configure support for SIZEOF_LONG_LONG to enable portable use of\n snprintf() with time_t.\n* Grow ntpd/work_thread.c arrays as needed.\n* Add DEBUG_* variants of ntp_assert.h macros which compile away using\n ./configure --disable-debugging.\n* Fix tvalops.cpp unit test failures for 32-bit builds.\n* Return to a single autoreconf invocation in ./bootstrap script.\n* Fix warnings seen on FreeBSD 9.\n* crypto group changes from Dave Mills.\n* Lose the RANGEGATE check in PPS, from Dave Mills.\n* ACTS refclock cleanup from Dave Mills.\n* Documentation updates from Dave Mills.\n* NMEA driver documentation update from Juergen Perlinger.\n(4.2.7p119) 2011/01/18 Released by Harlan Stenn <stenn@ntp.org>\n* added timespecops.{c,h} and tievalops.{c.h} to libntp and include\n added tspecops.cpp to tests/libntp\n* Correct msyslog.c build break on Solaris 2.9 from #ifdef/#if mixup.\n(4.2.7p118) 2011/01/15 Released by Harlan Stenn <stenn@ntp.org>\n* Simplify the built-sources stuff in sntp/ .\n* Fix check for -lipv6 on HP-UX 11.\n(4.2.7p117) 2011/01/13 Released by Harlan Stenn <stenn@ntp.org>\n* Add configure --without-sntp option to disable building sntp and\n sntp/tests. withsntp=no in the environment changes the default.\n* Build infrastructure cleanup:\n Move m4 directory to sntp/m4.\n Share a single set of genver output between sntp and the top level.\n Share a single set of autogen included .defs in sntp/include.\n Share a single set of build-aux scripts (e.g. config.guess, missing).\n Add ntp_libntp.m4 and ntp_ipv6.m4 to reduce configure.ac duplication.\n Warn and exit build/flock-build if bootstrap needs to be run.\n(4.2.7p116) 2011/01/10 Released by Harlan Stenn <stenn@ntp.org>\n* refclock_nmea.c refactoring by Juergen Perlinger.\n(4.2.7p115) 2011/01/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1780] Windows ntpd 4.2.7p114 crashes in ioctl().\n* [Bug 1781] longlong undefined in sntp handle_pkt() on Debian amd64.\n(4.2.7p114) 2011/01/08 Released by Harlan Stenn <stenn@ntp.org>\n* Fix for openssl pkg-config detection eval failure.\n* Add erealloc_zero(), refactor estrdup(), emalloc(), emalloc_zero() to\n separate tracking callsite file/line from using debug MS C runtime,\n and to reduce code duplication.\n(4.2.7p113) 2011/01/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1776] sntp mishandles -t/--timeout and -a/--authentication.\n* Default to silent make rules, override with make V=1 or ./configure\n --disable-silent-rules.\n* Correct --with-openssl-incdir defaulting with pkg-config.\n* Correct ./build on systems without gtest available.\n* Begin moving some of the low-level socket stuff to libntp.\n(4.2.7p112) 2011/01/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1773] openssl not detected during ./configure.\n* [Bug 1774] Segfaults if cryptostats enabled and built without OpenSSL.\n* Use make V=0 in build script to increase signal/noise ratio.\n(4.2.7p111) 2011/01/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1772] refclock_open() return value check wrong for ACTS.\n* Default --with-openssl-libdir and --with-openssl-incdir to the values\n from pkg-config, falling back on our usual search paths if pkg-config\n is not available or does not have openssl.pc on PKG_CONFIG_PATH.\n* Change refclock_open() to return -1 on failure like open().\n* Update all refclock_open() callers to check for fd <= 0 indicating\n failure, so they work with older and newer refclock_open() and can\n easily backport.\n* Initialize refclockproc.rio.fd to -1, harmonize refclock shutdown\n entrypoints to avoid crashing, particularly if refclock_open() fails.\n* Enable tickadj-like taming of wildly off-spec Windows clock using\n NTPD_TICKADJ_PPM env. var. specifying baseline slew.\n(4.2.7p110) 2011/01/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1771] algorithmic error in 'clocktime()' fixed.\n* Unit tests extended for hard-coded system time.\n* make V=0 and configure --enable-silent-rules supported.\n* setvar modemsetup = ATE0... overrides ACTS driver default.\n* Preserve last timecode in ACTS driver (ntpq -ccv).\n* Tolerate previous ATE1 state when sending ACTS setup.\n* Enable raw tty line discipline in Windows port.\n* Allow tty open/close/open to succeed on Windows port.\n* Enable ACTS and CHU reference clock drivers on Windows.\n(4.2.7p109) 2011/01/02 Released by Harlan Stenn <stenn@ntp.org>\n* Remove nearly all strcpy() and most strcat() from NTP distribution.\n One major pocket remains in ntp_crypto.c. libopts & libisc also have\n (safe) uses of strcpy() and strcat() remaining.\n* Documentation updates from Dave Mills.\n(4.2.7p108) 2011/01/01 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1764] Move Palisade modem control logic to configure.ac.\n* [Bug 1768] TIOCFLUSH undefined in linux for refclock_acts.\n* Autokey multiple identity group improvements from Dave Mills.\n* from 4.2.6p3: Update the copyright year.\n(4.2.7p107) 2010/12/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1764] Palisade driver doesn't build on Linux.\n* [Bug 1766] Oncore clock has offset/high jitter at startup.\n* Move ntp_control.h variable IDs to ntp_control.c, remove their use by\n ntpq. They are implementation details private to ntpd. [Bug 597] was\n caused by ntpq's reliance on these IDs it need not know about.\n* refclock_acts.c updates from Dave Mills.\n(4.2.7p106) 2010/12/30 Released by Harlan Stenn <stenn@ntp.org>\n* from 4.2.6p3: Update genCommitLog for the bk-5 release.\n(4.2.7p105) 2010/12/29 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.7p104) 2010/12/28 Released by Harlan Stenn <stenn@ntp.org>\n* from 4.2.6p3: Create and use scripts/check--help when generating\n .texi files.\n* from 4.2.6p3: Update bk triggers for the bk-5 release.\n* Support for multiple Autokey identity groups from Dave Mills.\n* Documentation updates from Dave Mills.\n* Add ntpq kerninfo, authinfo, and sysinfo commands similar to ntpdc's.\n(4.2.7p103) 2010/12/24 Released by Harlan Stenn <stenn@ntp.org>\n* Add ntpq pstats command similar to ntpdc's.\n* Remove ntpq pstatus command, rv/readvar does the same and more.\n* Documentation updates from Dave Mills.\n(4.2.7p102) 2010/12/23 Released by Harlan Stenn <stenn@ntp.org>\n* Allow ntpq &1 associd use without preceding association-fetching.\n* Documentation updates from Dave Mills.\n(4.2.7p101) 2010/12/22 Released by Harlan Stenn <stenn@ntp.org>\n* from 4.2.6p3-RC12: Upgrade to libopts 34.0.9 from AutoGen 5.11.6pre7.\n* from 4.2.6p3-RC12: Relax minimum Automake version to 1.10 with updated\n libopts.m4.\n(4.2.7p100) 2010/12/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1743] from 4.2.6p3-RC12: Display timezone offset when showing\n time for sntp in the local timezone (documentation updates).\n(4.2.7p99) 2010/12/21 Released by Harlan Stenn <stenn@ntp.org>\n* Add unit tests for msnprintf().\n(4.2.7p98) 2010/12/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1761] clockstuff/clktest-opts.h omitted from tarball.\n* [Bug 1762] from 4.2.6p3-RC12: manycastclient responses interfere.\n* Documentation updates from Dave Mills.\n(4.2.7p97) 2010/12/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1458] from 4.2.6p3-RC12: Can not compile NTP on FreeBSD 4.7.\n* [Bug 1760] from 4.2.6p3-RC12: ntpd Windows interpolation cannot be\n disabled.\n* from 4.2.6p3-RC12: Upgrade to libopts 34.0.9 from AutoGen 5.11.6pre5.\n* Documentation updates from Dave Mills.\n(4.2.7p96) 2010/12/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1758] from 4.2.6p3-RC12: setsockopt IPV6_MULTICAST_IF with wrong\n ifindex.\n* Documentation updates from Dave Mills.\n(4.2.7p95) 2010/12/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1753] 4.2.7p94 faults on startup in newpeer(), strdup(NULL).\n* [Bug 1754] from 4.2.6p3-RC12: --version output should be more verbose.\n* [Bug 1757] from 4.2.6p3-RC12: oncore snprintf(\"%m\") doesn't expand %m.\n* from 4.2.6p3-RC12: Suppress ntp-keygen OpenSSL version display for\n --help, --version, display both build and runtime OpenSSL versions\n when they differ.\n* from 4.2.6p3-RC12: Upgrade to libopts 33.5.8 from AutoGen 5.11.6pre3.\n* Documentation updates from Dave Mills.\n(4.2.7p94) 2010/12/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1751] from 4.2.6p3-RC12: Support for Atari FreeMiNT OS.\n* Documentation updates from Dave Mills.\n(4.2.7p93) 2010/12/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1510] from 4.2.6p3-RC12: Add modes 20/21 for driver 8 to support\n RAWDCF @ 75 baud.\n* [Bug 1741] from 4.2.6p3-RC12: Enable multicast reception on each\n address (Windows).\n* from 4.2.6p3-RC12: Other manycastclient repairs:\n Separate handling of scope ID embedded in many in6_addr from ifindex\n used for IPv6 multicasting ioctls.\n Add INT_PRIVACY endpt bit flag for IPv6 RFC 4941 privacy addresses.\n Enable outbound multicast from only one address per interface in the\n same subnet, and in that case prefer embedded MAC address modified\n EUI-64 IPv6 addresses first, then static, and last RFC 4941 privacy\n addresses.\n Use setsockopt(IP[V6]_MULTICAST_IF) before each send to multicast to\n select the local source address, using the correct socket is not\n enough.\n* \"server ... ident <groupname>\" changes from Dave Mills.\n* Documentation updates from Dave Mills.\n(4.2.7p92) 2010/12/08 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1743] from 4.2.6p3-RC12: Display timezone offset when showing\n time for sntp in the local timezone.\n(4.2.7p91) 2010/12/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1732] ntpd ties up CPU on disconnected USB device.\n* [Bug 1742] form 4.2.6p3-RC12: Fix a typo in an error message in the\n \"build\" script.\n(4.2.7p90) 2010/12/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1738] Windows ntpd has wrong net adapter name.\n* [Bug 1740] ntpdc -c reslist packet count wrongly treated as signed.\n(4.2.7p89) 2010/12/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1736] tos int, bool options broken in 4.2.7p66.\n* from 4.2.6p3-RC12: Clean up the SNTP documentation.\n(4.2.7p88) 2010/12/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1735] 'clocktime()' aborts ntpd on bogus input\n(4.2.7p87) 2010/12/01 Released by Harlan Stenn <stenn@ntp.org>\n* from 4.2.6p3-RC12: Clean up m4 quoting in configure.ac, *.m4 files,\n resolving intermittent AC_LANG_PROGRAM possibly undefined errors.\n(4.2.7p86) 2010/11/29 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p85) 2010/11/24 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p84) 2010/11/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1618] Unreachable code in jjy_start().\n* [Bug 1725] from 4.2.6p3-RC11: ntpd sends multicast from only one\n address.\n* from 4.2.6p3-RC11: Upgrade libopts to 33.3.8.\n* from 4.2.6p3-RC11: Bump minimum Automake version to 1.11, required for\n AM_COND_IF use in LIBOPTS_CHECK.\n* An almost complete rebuild of the initial loopfilter configuration\n process, including the code that determines the interval between\n frequency file updates, from Dave Mills.\n* Documentation updates from Dave Mills.\n* Add ntp-keygen -l/--lifetime to control certificate expiry.\n* JJY driver improvements for Tristate JJY01/02, including changes\n to its clockstats format.\n* Add \"nonvolatile\" ntp.conf directive to control how often the\n driftfile is written.\n(4.2.7p83) 2010/11/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1727] ntp-keygen PLEN, ILEN undeclared --without-crypto.\n* Remove top-level libopts, use sntp/libopts.\n* from 4.2.6p3-RC11: Remove log_msg() and debug_msg() from sntp in favor\n of msyslog().\n* Documentation updates from Dave Mills.\n(4.2.7p82) 2010/11/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1728] from 4.2.6p3-RC11: In ntp_openssl.m4, don't add\n -I/usr/include or -L/usr/lib to CPPFLAGS or LDFLAGS.\n(4.2.7p81) 2010/11/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1681] from 4.2.6p3-RC10: More sntp logging cleanup.\n* [Bug 1683] from 4.2.6p3-RC10: Non-localhost on loopback exempted from\n nic rules.\n* [Bug 1719] Cleanup for ntp-keygen and fix -V crash, from Dave Mills.\n(4.2.7p80) 2010/11/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1574] from 4.2.6p3-RC9: sntp doesn't set tv_usec correctly.\n* [Bug 1681] from 4.2.6p3-RC9: sntp logging cleanup.\n* [Bug 1683] from 4.2.6p3-RC9: Interface binding does not seem to work\n as intended.\n* [Bug 1708] make check fails with googletest 1.4.0.\n* [Bug 1709] from 4.2.6p3-RC9: ntpdate ignores replies with equal\n receive and transmit timestamps.\n* [Bug 1715] sntp utilitiesTest.IPv6Address failed.\n* [Bug 1718] Improve gtest checks in configure.ac.\n(4.2.7p79) 2010/11/07 Released by Harlan Stenn <stenn@ntp.org>\n* Correct frequency estimate with no drift file, from David Mills.\n(4.2.7p78) 2010/11/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1697] filegen implementation should be improved.\n* Refactor calendar functions in terms of new common code.\n* Documentation updates from Dave Mills.\n(4.2.7p77) 2010/11/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1692] packageinfo.sh needs to be \"sourced\" using ./ .\n* [Bug 1695] ntpdate takes longer than necessary.\n(4.2.7p76) 2010/11/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1690] Unit tests fails to build on some systems.\n* [Bug 1691] Use first NMEA sentence each second.\n* Put the sntp tests under sntp/ .\n* ... and only build/run them if we have gtest.\n* Documentation updates from Dave Mills.\n(4.2.7p75) 2010/10/30 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* Include Linus Karlsson's GSoC 2010 testing code.\n(4.2.7p74) 2010/10/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1685] from 4.2.6p3-RC8: NMEA driver mode byte confusion.\n* from 4.2.6p3-RC8: First cut at using scripts/checkChangeLog.\n* Documentation updates from Dave Mills.\n(4.2.7p73) 2010/10/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1680] Fix alignment of clock_select() arrays.\n* refinements to new startup behavior from David Mills.\n* For the bootstrap script, touch .html files last.\n* Add 'make check' test case that would have caught [Bug 1678].\n(4.2.7p72) 2010/10/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1679] Fix test for -lsocket.\n* Clean up missing ;; entries in configure.ac.\n(4.2.7p71) 2010/10/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1676] from 4.2.6p3-RC7: NMEA: $GPGLL did not work after fix\n for Bug 1571.\n* [Bug 1678] \"restrict source\" treated as \"restrict default\".\n* from 4.2.6p3-RC7: Added scripts/checkChangeLog.\n(4.2.7p70) 2010/10/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1571] from 4.2.6p3-RC6: NMEA does not relate data to PPS edge.\n* [Bug 1572] from 4.2.p63-RC6: NMEA time adjustment for GPZDG buggy.\n* [Bug 1675] from 4.2.6p3-RC6: Prohibit includefile remote config.\n* Enable generating ntpd/ntp_keyword.h after keyword-gen.c changes on\n Windows as well as POSIX platforms.\n* Fix from Dave Mills for a rare singularity in clock_combine().\n(4.2.7p69) 2010/10/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1671] Automatic delay calibration is sometimes inaccurate.\n(4.2.7p68) 2010/10/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1669] from 4.2.6p3-RC5: NTP fails to compile on IBM AIX 5.3.\n* [Bug 1670] Fix peer->bias and broadcastdelay.\n* Documentation updates from Dave Mills.\n* Documentation EOL cleanup.\n(4.2.7p67) 2010/10/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1649] from 4.2.6p3-RC5: Require NMEA checksum if $GPRMC or\n previously seen.\n(4.2.7p66) 2010/10/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1277] Provide and use O(1) FIFOs, esp. in the config tree code.\n* Remove unused 'bias' configuration keyword.\n(4.2.7p65) 2010/10/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1584] from 4.2.6p3-RC4: wrong SNMP type for precision,\n resolution.\n* Remove 'calldelay' and 'sign' remnants from parser, ntp_config.c.\n(4.2.7p64) 2010/10/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1584] from 4.2.6p3-RC3: ntpsnmpd OID must be mib-2.197.\n* [Bug 1659] from 4.2.6p3-RC4: Need CLOCK_TRUETIME not CLOCK_TRUE.\n* [Bug 1663] ntpdsim should not open net sockets.\n* [Bug 1665] from 4.2.6p3-RC4: is_anycast() u_int32_t should be u_int32.\n* from 4.2.6p3: ntpsnmpd, libntpq warning cleanup.\n* Remove 'calldelay' and 'sign' keywords (Dave Mills).\n* Documentation updates from Dave Mills.\n(4.2.7p63) 2010/10/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1080] from 4.2.6p3-RC3: ntpd on ipv6 routers very chatty.\n* Documentation nit cleanup.\n* Documentation updates from Dave Mills.\n(4.2.7p62) 2010/10/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 750] from 4.2.6p3-RC3: Non-existing device causes coredump with \n RIPE-NCC driver.\n* [Bug 1567] from 4.2.6p3-RC3: Support Arbiter 1093C Satellite Clock on\n Windows.\n* [Bug 1581] from 4.2.6p3-RC3: printf format string mismatch leftover.\n* [Bug 1659] from 4.2.6p3-RC3: Support Truetime Satellite Clocks on\n Windows. \n* [Bug 1660] from 4.2.6p3-RC3: On some systems, test is in /usr/bin, not\n /bin. \n* [Bug 1661] from 4.2.6p3-RC3: Re-indent refclock_ripencc.c.\n* Lose peer_count from ntp_peer.c and ntp_proto.c (Dave Mills).\n* Documentation updates from Dave Mills.\n(4.2.7p61) 2010/10/06 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation and code cleanup from Dave Mills. No more NTP_MAXASSOC.\n(4.2.7p60) 2010/10/04 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p59) 2010/10/02 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* Variable name cleanup from Dave Mills.\n* [Bug 1657] darwin needs res_9_init, not res_init.\n(4.2.7p58) 2010/09/30 Released by Harlan Stenn <stenn@ntp.org>\n* Clock select bugfix from Dave Mills.\n* [Bug 1554] peer may stay selected as system peer after becoming\n unreachable.\n* [Bug 1644] from 4.2.6p3-RC3: cvo.sh should use lsb_release to identify\n linux distros.\n* [Bug 1646] ntpd crashes with relative path to logfile.\n(4.2.7p57) 2010/09/27 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p56) 2010/09/25 Released by Harlan Stenn <stenn@ntp.org>\n* Clock combining algorithm improvements from Dave Mills.\n* Documentation updates from Dave Mills.\n* [Bug 1642] ntpdsim can't find simulate block in config file.\n* [Bug 1643] from 4.2.6p3-RC3: Range-check the decoding of the RIPE-NCC\n status codes.\n(4.2.7p55) 2010/09/22 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* [Bug 1636] from 4.2.6p3-RC2: segfault after denied remote config.\n(4.2.7p54) 2010/09/21 Released by Harlan Stenn <stenn@ntp.org>\n* More Initial convergence improvements from Dave Mills.\n* Documentation updates from Dave Mills.\n* [Bug 1635] from 4.2.6p3-RC2: \"filegen ... enable\" is not default.\n(4.2.7p53) 2010/09/20 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* More Initial convergence improvements from Dave Mills.\n(4.2.7p52) 2010/09/19 Released by Harlan Stenn <stenn@ntp.org>\n* Initial convergence improvements from Dave Mills.\n(4.2.7p51) 2010/09/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1344] from 4.2.6p3-RC1: ntpd on Windows exits without logging\n cause.\n* [Bug 1629] 4.2.7p50 configure.ac changes invalidate config.cache.\n* [Bug 1630] 4.2.7p50 cannot bootstrap on Autoconf 2.61.\n(4.2.7p50) 2010/09/16 Released by Harlan Stenn <stenn@ntp.org>\n* Cleanup NTP_LIB_M.\n* [Bug 1628] Clean up -lxnet/-lsocket usage for (open)solaris.\n(4.2.7p49) 2010/09/13 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p48) 2010/09/12 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.7p47) 2010/09/11 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* [Bug 1588] finish configure --disable-autokey implementation.\n* [Bug 1616] refclock_acts.c: if (pp->leap == 2) is always false.\n* [Bug 1620] [Backward Incompatible] \"discard minimum\" value should be in\n seconds, not log2 seconds.\n(4.2.7p46) 2010/09/10 Released by Harlan Stenn <stenn@ntp.org>\n* Use AC_SEARCH_LIBS instead of AC_CHECK_LIB for NTP_LIB_M.\n(4.2.7p45) 2010/09/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1578] Consistently use -lm when needed.\n(4.2.7p44) 2010/08/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1573] from 4.2.6p3-beta1: Miscalculation of offset in sntp.\n(4.2.7p43) 2010/08/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1602] Refactor some of the sntp/ directory to facililtate testing.\n(4.2.7p42) 2010/08/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1593] ntpd abort in free() with logconfig syntax error.\n* [Bug 1595] from 4.2.6p3-beta1: empty last line in key file causes\n duplicate key to be added\n* [Bug 1597] from 4.2.6p3-beta1: packet processing ignores RATE KoD packets,\n Because of a bug in string comparison.\n(4.2.7p41) 2010/07/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1581] from 4.2.6p3-beta1: ntp_intres.c size_t printf format\n string mismatch.\n* [Bug 1586] ntpd 4.2.7p40 doesn't write to syslog after fork on QNX.\n* Avoid race with parallel builds using same source directory in\n scripts/genver by using build directory for temporary files.\n* orphanwait documentation updates.\n(4.2.7p40) 2010/07/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1395] ease ntpdate elimination with ntpd -w/--wait-sync\n* [Bug 1396] allow servers on ntpd command line like ntpdate\n(4.2.7p39) 2010/07/09 Released by Harlan Stenn <stenn@ntp.org>\n* Fix typo in driver28.html.\n* [Bug 1581] from 4.2.6p2: size_t printf format string mismatches, IRIG\n string buffers undersized. Mostly backported from earlier ntp-dev\n fixes by Juergen Perlinger.\n(4.2.7p38) 2010/06/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1570] backported to 4.2.6p2-RC7.\n* [Bug 1575] from 4.2.6p2-RC7: use 'snprintf' with LIB_BUFLENGTH in\n inttoa.c, tvtoa.c and utvtoa.c\n* [Bug 1576] backported to 4.2.6p2-RC7.\n* Typo fix in a comment in ntp_proto.c.\n(4.2.7p37) 2010/06/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1576] sys/sysctl.h depends on sys/param.h on OpenBSD.\n(4.2.7p36) 2010/06/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1560] Initial support for orphanwait, from Dave Mills.\n* clock_filter()/reachability fixes from Dave Mills.\n(4.2.7p35) 2010/06/12 Released by Harlan Stenn <stenn@ntp.org>\n* Rewrite of multiprecision macros in 'ntp_fp.h' from J. Perlinger\n <perlinger@ntp.org>\n* [Bug 715] from 4.2.6p2-RC6: libisc Linux IPv6 interface iteration\n drops multicast flags.\n(4.2.7p34) 2010/06/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1570] serial clock drivers get outdated input from kernel tty\n line buffer after startup\n(4.2.7p33) 2010/06/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1561] from 4.2.6p2-RC5: ntpq, ntpdc \"passwd\" prompts for MD5\n password w/SHA1.\n* [Bug 1565] from 4.2.6p2-RC5: sntp/crypto.c compile fails on MacOS over\n vsnprintf().\n* from 4.2.6p2-RC5: Windows port: do not exit in\n ntp_timestamp_from_counter() without first logging the reason.\n(4.2.7p32) 2010/05/19 Released by Harlan Stenn <stenn@ntp.org>\n* Copyright file cleanup from Dave Mills.\n* [Bug 1555] from 4.2.6p2-RC4: sntp illegal C (mixed code and\n declarations).\n* [Bug 1558] pool prototype associations have 0.0.0.0 for remote addr.\n* configure.ac: add --disable-autokey, #define AUTOKEY to enable future\n support for building without Autokey, but with OpenSSL for its digest\n algorithms (hash functions). Code must be modified to use #ifdef\n AUTOKEY instead of #ifdef OPENSSL where appropriate to complete this.\n* include/ntp_crypto.h: make assumption AUTOKEY implies OPENSSL explicit.\n(4.2.7p31) 2010/05/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1325] from 4.2.6p2-RC3: unreachable code sntp recv_bcst_data().\n* [Bug 1459] from 4.2.6p2-RC3: sntp MD5 authentication does not work\n with ntpd.\n* [Bug 1552] from 4.2.6p2-RC3: update and complete broadcast and crypto\n features in sntp.\n* [Bug 1553] from 4.2.6p2-RC3: sntp/configure.ac OpenSSL support.\n* from 4.2.6p2-RC3: Escape unprintable characters in a refid in ntpq -p\n billboard.\n* from 4.2.6p2-RC3: Simplify hash client code by providing OpenSSL\n EVP_*() API when built without OpenSSL. (already in 4.2.7)\n* from 4.2.6p2-RC3: Do not depend on ASCII in sntp.\n(4.2.7p30) 2010/05/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1526] ntpd DNS pipe read EINTR with no network at startup.\n* Update the ChangeLog entries when merging items from -stable.\n(4.2.7p29) 2010/05/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1542] ntpd mrulist response may have incorrect last.older.\n* [Bug 1543] ntpq mrulist must refresh nonce when retrying.\n* [Bug 1544] ntpq mrulist sscanf timestamp format mismatch on 64-bit.\n* Windows compiling hints/winnt.html update from G. Sunil Tej.\n(4.2.7p28) 2010/05/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1512] from 4.2.6p2-RC3: ntpsnmpd should connect to net-snmpd\n via a unix-domain socket by default.\n Provide a command-line 'socket name' option.\n* [Bug 1538] from 4.2.6p2-RC3: update refclock_nmea.c's call to\n getprotobyname().\n* [Bug 1541] from 4.2.6p2-RC3: Fix wrong keyword for \"maxclock\".\n(4.2.7p27) 2010/04/27 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.7p26) 2010/04/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1465] from 4.2.6p2-RC2: Make sure time from TS2100 is not\n invalid (backport from -dev).\n* [Bug 1528] from 4.2.6p2-RC2: Fix EDITLINE_LIBS link order for ntpq\n and ntpdc.\n* [Bug 1531] Require nonce with mrulist requests.\n* [Bug 1532] Remove ntpd support for ntpdc's monlist in favor of ntpq's\n mrulist.\n* [Bug 1534] from 4.2.6p2-RC2: conflicts with VC++ 2010 errno.h.\n* [Bug 1535] from 4.2.6p2-RC2: \"restrict -4 default\" and \"restrict\n -6 default\" ignored.\n(4.2.7p25) 2010/04/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1528] from 4.2.6p2-RC2: Remove --with-arlib from br-flock.\n* [Bug 1503] [Bug 1504] [Bug 1518] [Bug 1522] from 4.2.6p2-RC2:\n all of which were fixed in 4.2.7 previously. \n(4.2.7p24) 2010/04/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1390] Control PPS on the Oncore M12.\n* [Bug 1518] Windows ntpd should lock to one processor more\n conservatively.\n* [Bug 1520] '%u' formats for size_t gives warnings with 64-bit builds.\n* [Bug 1522] Enable range syntax \"trustedkey (301 ... 399)\".\n* Documentation updates for 4.2.7p22 changes and additions, updating\n ntpdc.html, ntpq.html, accopt.html, confopt.html, manyopt.html,\n miscopt.html, and miscopt.txt.\n* accopt.html: non-ntpport doc changes from Dave Mills.\n* Modify full MRU list preemption when full to match \"discard monitor\"\n documentation, by removing exception for count == 1.\n(4.2.7p23) 2010/04/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1516] unpeer by IP address fails, DNS name works.\n* [Bug 1517] ntpq and ntpdc should verify reverse DNS before use.\n ntpq and ntpdc now use the following format for showing purported\n DNS names from IP address \"reverse\" DNS lookups when the DNS name\n does not exist or does not include the original IP address among\n the results: \"192.168.1.2 (fake.dns.local)\".\n(4.2.7p22) 2010/04/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1432] Don't set inheritable flag for linux capabilities.\n* [Bug 1465] Make sure time from TS2100 is not invalid.\n* [Bug 1483] AI_NUMERICSERV undefined in 4.2.7p20.\n* [Bug 1497] fudge is broken by getnetnum() change.\n* [Bug 1503] Auto-enabling of monitor for \"restrict ... limited\" wrong.\n* [Bug 1504] ntpdate tickles ntpd \"discard minimum 1\" rate limit if\n \"restrict ... limited\" is used.\n* ntpdate: stop querying source after KoD packet response, log it.\n* ntpdate: rate limit each server to 2s between packets.\n* From J. N. Perlinger: avoid pointer wraparound warnings in dolfptoa(),\n printf format mismatches with 64-bit size_t.\n* Broadcast client (ephemeral) associations should be demobilized only\n if they are not heard from for 10 consecutive polls, regardless of\n surviving the clock selection. Fix from David Mills.\n* Add \"ntpq -c ifstats\" similar to \"ntpdc -c ifstats\".\n* Add \"ntpq -c sysstats\" similar to \"ntpdc -c sysstats\".\n* Add \"ntpq -c monstats\" to show monlist knobs and stats.\n* Add \"ntpq -c mrulist\" similar to \"ntpdc -c monlist\" but not\n limited to 600 rows, and with filtering and sorting options:\n ntpq -c \"mrulist mincount=2 laddr=192.168.1.2 sort=-avgint\"\n ntpq -c \"mrulist sort=addr\"\n ntpq -c \"mrulist mincount=2 sort=count\"\n ntpq -c \"mrulist sort=-lstint\"\n* Modify internal representation of MRU list to use l_fp fixed-point\n NTP timestamps instead of seconds since startup. This increases the\n resolution and substantially improves accuracy of sorts involving\n timestamps, at the cost of flushing all MRU entries when the clock is\n stepped, to ensure the timestamps can be compared with the current\n get_systime() results.\n* Add ntp.conf \"mru\" directive to configure MRU parameters, such as\n \"mru mindepth 600 maxage 64 maxdepth 5000 maxmem 1024\" or\n \"mru initalloc 0 initmem 16 incalloc 99 incmem 4\". Several pairs are\n equivalent with one in units of MRU entries and its twin in units of\n kilobytes of memory, so the last one used in ntp.conf controls:\n maxdepth/maxmem, initalloc/initmem, incalloc/incmem. With the above\n values, ntpd will preallocate 16kB worth of MRU entries, allocating\n 4kB worth each time more are needed, with a hard limit of 1MB of MRU\n entries. Until there are more than 600 entries none would be reused.\n Then only entries for addresses last seen 64 seconds or longer ago are\n reused.\n* Limit \"ntpdc -c monlist\" response in ntpd to 600 entries, the previous\n overall limit on the MRU list depth which was driven by the monlist\n implementation limit of one request with a single multipacket\n response.\n* New \"pool\" directive implementation modeled on manycastclient.\n* Do not abort on non-ASCII characters in ntp.conf, ignore them.\n* ntpq: increase response reassembly limit from 24 to 32 packets, add\n discussion in comment regarding results with even larger MAXFRAGS.\n* ntpq: handle \"passwd MYPASSWORD\" (without prompting) as with ntpdc.\n* ntpdc: do not examine argument to \"passwd\" if not supplied.\n* configure: remove check for pointer type used with qsort(), we\n require ANSI C which mandates void *.\n* Reset sys_kodsent to 0 in proto_clr_stats().\n* Add sptoa()/sockporttoa() similar to stoa()/socktoa() adding :port.\n* Use memcpy() instead of memmove() when buffers can not overlap.\n* Remove sockaddr_storage from our sockaddr_u union of sockaddr,\n sockaddr_in, and sockaddr_in6, shaving about 100 bytes from its size\n and substantially decreasing MRU entry memory consumption.\n* Extend ntpq readvar (alias rv) to allow fetching up to three named\n variables in one operation: ntpq -c \"rv 0 version offset frequency\".\n* ntpq: use srchost variable to show .POOL. prototype associations'\n hostname instead of address 0.0.0.0.\n* \"restrict source ...\" configures override restrictions for time\n sources, allows tight default restrictions to be used with the pool\n directive (where server addresses are not known in advance).\n* Ignore \"preempt\" modifier on manycastclient and pool prototype\n associations. The resulting associations are preemptible, but the\n prototype must not be.\n* Maintain and use linked list of associations (struct peer) in ntpd,\n avoiding walking 128 hash table entries to iterate over peers.\n* Remove more workarounds unneeded since we require ISO C90 AKA ANSI C:\n - remove fallback implementations for memmove(), memset, strstr().\n - do not test for atexit() or memcpy().\n* Collapse a bunch of code duplication in ntpd/ntp_restrict.c added with\n support for IPv6.\n* Correct some corner case failures in automatically enabling the MRU\n list if any \"restrict ... limited\" is in effect, and in disabling MRU\n maintenance. (ntp_monitor.c, ntp_restrict.c)\n* Reverse the internal sort order of the address restriction lists, but\n preserve the same behavior. This allows removal of special-case code\n related to the default restrictions and more straightforward lookups\n of restrictions for a given address (now, stop on first match).\n* Move ntp_restrict.c MRU doubly-linked list maintenance code into\n ntp_lists.h macros, allowing more duplicated source excision.\n* Repair ntpdate.c to no longer test HAVE_TIMER_SETTIME.\n* Do not reference peer_node/unpeer_node after freeing when built with\n --disable-saveconfig and using DNS.\n(4.2.7p21) 2010/03/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1514] from 4.2.6p1-RC6: Typo in ntp_proto.c: fabs(foo < .4)\n should be fabs(foo) < .4.\n* [Bug 1464] from 4.2.6p1-RC6: synchronization source wrong for\n refclocks ARCRON_MSF (27) and SHM (28).\n* From 4.2.6p1-RC6: Correct Windows port's refclock_open() to\n return 0 on failure not -1.\n* From 4.2.6p1-RC6: Correct CHU, dumbclock, and WWVB drivers to\n check for 0 returned from refclock_open() on failure.\n* From 4.2.6p1-RC6: Correct \"SIMUL=4 ./flock-build -1\" to\n prioritize -1/--one.\n* [Bug 1306] constant conditionals in audio_gain().\n(4.2.7p20) 2010/02/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1483] hostname in ntp.conf \"restrict\" parameter rejected.\n* Use all addresses for each restrict by hostname.\n* Use async DNS to resolve trap directive hostnames.\n(4.2.7p19) 2010/02/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1338] Update the association type codes in ntpq.html.\n* [Bug 1478] from 4.2.6p1-RC5: linking fails: EVP_MD_pkey_type.\n* [Bug 1479] from 4.2.6p1-RC5: not finding readline headers.\n* [Bug 1484] from 4.2.6p1-RC5: ushort is not defined in QNX6.\n(4.2.7p18) 2010/02/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1480] from 4.2.6p1-RC5: snprintf() cleanup caused \n unterminated refclock IDs.\n* Stop using getaddrinfo() to convert numeric address strings to on-wire\n addresses in favor of is_ip_address() alone.\n(4.2.7p17) 2010/02/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1477] from 4.2.6p1-RC5: First non-gmake make in clone\n w/VPATH can't make COPYRIGHT.\n* Attempts to cure CID 108 CID 118 CID 119 TAINTED_SCALAR warnings.\n* Broaden ylwrap workaround VPATH_HACK to all non-GNU make.\n(4.2.7p16) 2010/02/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1474] from 4.2.6p1-RC4: ntp_keygen LCRYPTO after libntp.a.\n* Include 4.2.6p1-RC4: Remove arlib.\n(4.2.7p15) 2010/02/03 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1455] from 4.2.6p1: ntpd does not try /etc/ntp.audio.\n* Include 4.2.6p1: Convert many sprintf() calls to snprintf(), also\n strcpy(), strcat().\n* Include 4.2.6p1: Fix widely cut-n-pasted bug in refclock shutdown\n after failed start.\n* Include 4.2.6p1: Remove some dead code checking for emalloc()\n returning NULL.\n(4.2.7p14) 2010/02/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1338] ntpq displays incorrect association type codes.\n* [Bug 1469] u_int32, int32 changes broke HP-UX 10.20 build.\n* [Bug 1470] from 4.2.6p1: \"make distdir\" compiles keyword-gen.\n* [Bug 1471] CID 120 CID 121 CID 122 is_ip_address() uninit family.\n* [Bug 1472] CID 116 CID 117 minor warnings in new DNS code.\n* [Bug 1473] from 4.2.6p1: \"make distcheck\" version.m4 error.\n(4.2.7p13) 2010/01/31 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1467] from 4.2.6p1: Fix bogus rebuild of sntp/sntp.html.\n(4.2.7p12) 2010/01/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1468] 'make install' broken for root on default NFS mount.\n(4.2.7p11) 2010/01/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 47] Debugging and logging do not work after a fork.\n* [Bug 1010] getaddrinfo() could block and thus should not be called by\n the main thread/process.\n* New async DNS resolver in ntpd allows nonblocking queries anytime,\n instead of only once at startup.\n(4.2.7p10) 2010/01/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1140] from 4.2.6p1-RC5: Clean up debug.html, decode.html,\n and ntpq.html.\n* Include 4.2.6p1-RC3: Use TZ=UTC instead of TZ= when calling date in\n scripts/mkver.in .\n* [Bug 1448] from 4.2.6p1-RC3: Some macros not correctly conditionally\n or absolutely defined on Windows.\n* [Bug 1449] from 4.2.6p1-RC3: ntpsim.h in ntp_config.c should be used\n conditionally.\n* [Bug 1450] from 4.2.6p1-RC3: Option to exclude warnings not\n unconditionally defined on Windows.\n(4.2.7p9) 2010/01/13 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.7p8) 2010/01/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 702] ntpd service logic should use libopts to examine cmdline.\n* [Bug 1451] from 4.2.6p1-RC3: sntp leaks KoD entry updating.\n* [Bug 1453] from 4.2.6p1-RC3: Use $CC in config.cache filename.\n(4.2.7p7) 2009/12/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 620] ntpdc getresponse() esize != *rsize s/b size != *rsize.\n* [Bug 1446] 4.2.7p6 requires autogen, missing ntpd.1, *.texi, *.menu.\n(4.2.7p6) 2009/12/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1443] Remove unnecessary dependencies on ntp_io.h\n* [Bug 1442] Move Windows functions into libntp files\n* [Bug 1127] from 4.2.6p1-RC3: Check the return of X590_verify().\n* [Bug 1439] from 4.2.6p1-RC3: .texi gen after binary is linked.\n* [Bug 1440] from 4.2.6p1-RC3: Update configure.ac to support kfreebsd.\n* [Bug 1445] from 4.2.6p1-RC3: IRIX does not have -lcap or support\n linux capabilities.\n(4.2.7p5) 2009/12/25 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.6p1-RC2\n(4.2.7p4) 2009/12/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1429] ntpd -4 option does not reliably force IPv4 resolution.\n* [Bug 1431] System headers must come before ntp headers in ntp_intres.c .\n(4.2.7p3) 2009/12/22 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1426] scripts/VersionName needs . on the search path.\n* [Bug 1427] quote missing in ./build - shows up on NetBSD.\n* [Bug 1428] Use AC_HEADER_RESOLV to fix breaks from resolv.h\n(4.2.7p2) 2009/12/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1419] ntpdate, ntpdc, sntp, ntpd ignore configure --bindir.\n* [Bug 1421] add util/tg2, a clone of tg that works on Linux, NetBSD, and\n FreeBSD\n(4.2.7p1) 2009/12/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1348] ntpd Windows port should wait for sendto() completion.\n* [Bug 1413] test OpenSSL headers regarding -Wno-strict-prototypes.\n* [Bug 1418] building ntpd/ntpdc/ntpq statically with ssl fails.\n(4.2.7p0) 2009/12/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1412] m4/os_cflags.m4 caches results that depend on $CC.\n* [Bug 1414] Enable \"make distcheck\" success with BSD make.\n(4.2.7) 2009/12/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1407] configure.ac: recent GNU Make -v does not include \"version\".\n---\n(4.2.6p5) 2011/12/24 Released by Harlan Stenn <stenn@ntp.org>",
"No changes from 4.2.6p5-RC3.",
"---\n(4.2.6p5-RC3) 2011/12/08 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 2082] 3-char refid sent by ntpd 4.2.6p5-RC2 ends with extra dot.\n* [Bug 2085] clock_update() sys_rootdisp calculation omits root delay.\n* [Bug 2086] get_systime() should not offset by sys_residual.\n* [Bug 2087] sys_jitter calculation overweights sys.peer jitter.\n* Ensure NULL peer->dstadr is not accessed in orphan parent selection.",
"---\n(4.2.6p5-RC2) 2011/11/30 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 2050] Orphan mode stratum counting to infinity.\n* [Bug 2059] optional billboard column \"server\" does not honor -n.\n* [Bug 2066] ntpq lopeers ipv6 \"local\" column overrun.\n* [Bug 2068] ntpd sends nonprintable stratum 16 refid to ntpq.\n* [Bug 2069] broadcastclient, multicastclient spin up duplicate\n ephemeral associations without broadcastdelay.\n* [Bug 2072] Orphan parent selection metric needs ntohl().\n* Exclude not-yet-determined sys_refid from use in loopback TEST12\n (from David Mills).\n* Never send KoD rate limiting response to MODE_SERVER response.",
"---\n(4.2.6p5-RC1) 2011/10/18 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 2034] Listening address configuration with prefix misapplied.",
"---\n(4.2.6p4) 2011/09/22 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1984] ntp/libisc fails to compile on OS X 10.7 (Lion).\n* [Bug 1985] \"logconfig =allall\" rejected.\n* [Bug 2001] ntpdc timerstats reports overruns as handled.\n* [Bug 2003] libntpq ntpq_read_assoc_peervars() broken.\n* [Backward Incompatible] sntp: -l/--filelog -> -l/--logfile, to be\n consistent with ntpd.\n* libopts/file.c fix from Bruce Korb (arg-type=file).",
"---\n(4.2.6p4-RC2) 2011/08/04 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1608] Parse Refclock driver should honor trusttime.\n* [Bug 1961] html2man update: distribute ntp-wait.html.\n* [Bug 1970] UNLINK_EXPR_SLIST() causes crash if list is empty.\n* [Bug 1972] checking for struct rtattr fails.\n* [Bug 1975] libntp/mktime.c won't work with 64-bit time_t\n* [Bug 1978] [Bug 1134] fix in 4.2.6p4-RC1 doesn't build on older Linux.\n* Backport several fixes for Coverity warnings from ntp-dev.\n* Backport if_nametoindex() check for hpux.",
"---\n(4.2.6p4-RC1) 2011/07/10 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1134] ntpd fails binding to tentative IPv6 addresses.\n* [Bug 1790] Update config.guess and config.sub to detect AIX6.\n* [Bug 1961] html2man needs an update.\n* Update the NEWS file.",
"---\n(4.2.6p4-beta2) 2011/05/25 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1695] ntpdate takes longer than necessary.\n* [Bug 1832] ntpdate doesn't allow timeout > 2s.\n* [Bug 1933] WWVB/Spectracom driver timestamps LFs, not CRs.\n* Backport utility routines from ntp-dev: mprintf(), emalloc_zero().",
"---\n(4.2.6p4-beta1) 2011/05/16 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1554] peer may stay selected as system peer after becoming\n unreachable.\n* [Bug 1921] LOCAL, ACTS drivers with \"prefer\" excluded from initial\n candidate list.\n* [Bug 1923] orphan parent favored over LOCAL, ACTS drivers.\n* [Bug 1924] Billboard tally codes sometimes do not match operation,\n variables.\n* Enable tickadj-like taming of wildly off-spec Windows clock using\n NTPD_TICKADJ_PPM env. var. specifying baseline slew.\n* Upgrade to AutoGen 5.11.9 (and require it).\n* Upgrade to libopts 35.0.10 from AutoGen 5.11.9pre8.",
"---\n(4.2.6p3) 2011/01/03 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1764] Palisade driver doesn't build on Linux\n* Create and use scripts/check--help when generating .texi files.\n* Update bk triggers for the bk-5 release.\n* Update genCommitLog for the bk-5 release.\n* Update the copyright year.",
"---\n(4.2.6p3-RC12) 2010/12/25 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1458] Can not compile NTP on FreeBSD 4.7.\n* [Bug 1510] Add modes 20/21 for driver 8 to support RAWDCF @ 75 baud.\n* [Bug 1618] Unreachable code in jjy_start(). (backport from ntp-dev)\n* [Bug 1719] ntp-keygen -V crash. (backport)\n* [Bug 1740] ntpdc treats many counters as signed. (backport)\n* [Bug 1741] Enable multicast reception on each address (Windows).\n* [Bug 1742] Fix a typo in an error message in the \"build\" script.\n* [Bug 1743] Display timezone offset when showing time for sntp in the\nlocal timezone.\n* [Bug 1751] Support for Atari FreeMiNT OS.\n* [Bug 1754] --version output should be more verbose.\n* [Bug 1757] oncore snprintf(\"%m\") doesn't expand %m.\n* [Bug 1758] setsockopt IPV6_MULTICAST_IF with wrong ifindex.\n* [Bug 1760] ntpd Windows interpolation cannot be disabled.\n* [Bug 1762] manycastclient solicitation responses interfere.\n* Upgrade to libopts 34.0.9 from AutoGen 5.11.6pre7.\n* Relax minimum Automake version to 1.10 with updated libopts.m4.\n* Suppress ntp-keygen OpenSSL version display for --help, --version,\ndisplay both build and runtime OpenSSL versions when they differ.\n* Clean up m4 quoting in configure.ac, *.m4 files, resolving\n intermittent AC_LANG_PROGRAM possibly undefined errors.\n* Clean up the SNTP documentation.\n* Other manycastclient repairs:\n Separate handling of scope ID embedded in many in6_addr from ifindex\n used for IPv6 multicasting ioctls.\n Add INT_PRIVACY endpt bit flag for IPv6 RFC 4941 privacy addresses.\n Enable outbound multicast from only one address per interface in the\n same subnet, and in that case prefer embedded MAC address modified\n EUI-64 IPv6 addresses first, then static, and last RFC 4941 privacy\n addresses.\n Use setsockopt(IP[V6]_MULTICAST_IF) before each send to multicast to\n select the local source address, using the correct socket is not\n enough.",
"---\n(4.2.6p3-RC11) 2010/11/28 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1725] ntpd sends multicast from only one address.\n* [Bug 1728] In ntp_openssl.m4, don't add -I/usr/include or -L/usr/lib\n to CPPFLAGS or LDFLAGS.\n* [Bug 1733] IRIX doesn't have 'head' (affects scripts/checkChangeLog).\n* Remove log_msg() and debug_msg() from sntp in favor of msyslog().\n* Use a single copy of libopts/, in sntp/.\n* Upgrade libopts to 33.3.8.\n* Bump minimum Automake version to 1.11, required for AM_COND_IF\n use in LIBOPTS_CHECK.\n* Improvements to the 'build' script.",
"---\n(4.2.6p3-RC10) 2010/11/14 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1681] More sntp logging cleanup.\n* [Bug 1683] Non-localhost on loopback exempted from nic rules.",
"---\n(4.2.6p3-RC9) 2010/11/10 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1574] sntp:set_time doesn't set tv_usec correctly.\n* [Bug 1681] sntp logging cleanup.\n* [Bug 1683] Interface binding does not seem to work as intended.\n* [Bug 1691] Use first NMEA sentence each second.\n* [Bug 1692] packageinfo.sh needs to be \"sourced\" using ./ .\n* [Bug 1709] ntpdate ignores replies with equal receive and transmit\n timestamps.\n* Backport sntp from -dev",
"---\n(4.2.6p3-RC8) 2010/10/29 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1685] NMEA driver mode byte confusion.\n* First cut at using scripts/checkChangeLog.",
"---\n(4.2.6p3-RC7) 2010/10/25 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1676] NMEA: $GPGLL did not work after fix for Bug 1571.\n* Added scripts/checkChangeLog.",
"---\n(4.2.6p3-RC6) 2010/10/24 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1571] NMEA does not relate data to PPS edge.\n* [Bug 1572] NMEA time adjustment for GPZDG buggy.\n* [Bug 1675] Prohibit includefile remote config.",
"---\n(4.2.6p3-RC5) 2010/10/22 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1649] Require NMEA checksum if $GPRMC or previously seen.\n* [Bug 1669] NTP 4.2.6p2 fails to compile on IBM AIX 5.3.",
"---\n(4.2.6p3-RC4) 2010/10/16 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1584] wrong SNMP type for precision, resolution.\n* [Bug 1659] Need CLOCK_TRUETIME not CLOCK_TRUE.\n* [Bug 1665] is_anycast() u_int32_t should be u_int32.\n* ntpsnmpd, libntpq warning cleanup.",
"---\n(4.2.6p3-RC3) 2010/10/14 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 750] Non-existing device causes coredump with RIPE-NCC driver.\n* [Bug 1080] ntpd on ipv6 routers very chatty.\n* [Bug 1567] Support Arbiter 1093C Satellite Clock on Windows.\n* [Bug 1581] printf format string mismatch leftover.\n* [Bug 1584] ntpsnmpd OID must be mib-2.197.\n* [Bug 1643] Range-check the decoding of the RIPE-NCC status codes.\n* [Bug 1644] cvo.sh should use lsb_release to identify linux distros.\n* [Bug 1659] Support Truetime Satellite Clocks on Windows.\n* [Bug 1660] On some systems, test is in /usr/bin, not /bin.\n* [Bug 1661] Re-indent refclock_ripencc.c.",
"---\n(4.2.6p3-RC2) 2010/09/25 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1635] \"filegen ... enable\" is not default.\n* [Bug 1636] yyparse() segfault after denied filegen remote config.",
"---\n(4.2.6p3-RC1) 2010/09/18 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1344] ntpd on Windows exits without logging cause.",
"---\n(4.2.6p3-beta1) 2010/09/11 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1573] Miscalculation of offset in sntp.\n* [Bug 1595] empty last line in key file causes duplicate key to be added\n* [Bug 1597] packet processing ignores RATE KoD packets, because of\n a bug in string comparison.\n* [Bug 1581] ntp_intres.c size_t printf format string mismatch.",
"---\n(4.2.6p2) 2010/07/09 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1581] size_t printf format string mismatches, IRIG string buffers\n undersized. Mostly backported from earlier ntp-dev fixes by Juergen\n Perlinger.",
"---\n(4.2.6p2-RC7) 2010/06/19 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1570] serial clock drivers get outdated input from kernel tty\n line buffer after startup\n* [Bug 1575] use 'snprintf' with LIB_BUFLENGTH in inttoa.c, tvtoa.c and\n utvtoa.c\n* [Bug 1576] sys/sysctl.h depends on sys/param.h on OpenBSD.",
"---\n(4.2.6p2-RC6) 2010/06/12 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 715] libisc Linux IPv6 interface iteration drops multicast flags.",
"---\n(4.2.6p2-RC5) 2010/06/03 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1561] ntpq, ntpdc \"passwd\" prompts for MD5 password w/SHA1.\n* [Bug 1565] sntp/crypto.c compile fails on MacOS over vsnprintf().\n* Windows port: do not exit in ntp_timestamp_from_counter() without\n first logging the reason.\n* Support \"passwd blah\" syntax in ntpq.",
"---\n(4.2.6p2-RC4) 2010/05/19 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1555] 4.2.6p2-RC3 sntp illegal C (mixed code and declarations).",
"---\n(4.2.6p2-RC3) 2010/05/11 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1325] unreachable code in sntp recv_bcst_data().\n* [Bug 1459] sntp MD5 authentication does not work with ntpd.\n* [Bug 1512] ntpsnmpd should connect to net-snmpd via a unix-domain\n socket by default. Provide a command-line 'socket name' option.\n* [Bug 1538] update refclock_nmea.c's call to getprotobyname().\n* [Bug 1541] Fix wrong keyword for \"maxclock\".\n* [Bug 1552] update and complete broadcast and crypto features in sntp.\n* [Bug 1553] sntp/configure.ac OpenSSL support.\n* Escape unprintable characters in a refid in ntpq -p billboard.\n* Simplify hash client code by providing OpenSSL EVP_*() API when built\n without OpenSSL. (from ntp-dev)\n* Do not depend on ASCII values for ('A' - '0'), ('a' - '0') in sntp.\n* Windows compiling hints/winnt.html update from G. Sunil Tej.",
"---\n(4.2.6p2-RC2) 2010/04/27 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1465] Make sure time from TS2100 is not invalid (backport from\n ntp-dev).\n* [Bug 1528] Fix EDITLINE_LIBS link order for ntpq and ntpdc.\n* [Bug 1534] win32/include/isc/net.h conflicts with VC++ 2010 errno.h.\n* [Bug 1535] \"restrict -4 default\" and \"restrict -6 default\" ignored.\n* Remove --with-arlib from br-flock.",
"---\n(4.2.6p2-RC1) 2010/04/18 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1503] Auto-enabling of monitor for \"restrict ... limited\" wrong.\n* [Bug 1504] ntpdate tickles ntpd \"discard minimum 1\" rate limit if\n \"restrict ... limited\" is used.\n* [Bug 1518] Windows ntpd should lock to one processor more\n conservatively.\n* [Bug 1522] Enable range syntax \"trustedkey (301 ... 399)\".\n* Update html/authopt.html controlkey, requestkey, and trustedkey docs.",
"---\n(4.2.6p1) 2010/04/09 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.6p1-RC6) 2010/03/31 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1514] Typo in ntp_proto.c: fabs(foo < .4) should be fabs(foo) < .4.\n* [Bug 1464] synchronization source wrong for refclocks ARCRON_MSF (27)\n and SHM (28).\n* Correct Windows port's refclock_open() to return 0 on failure not -1.\n* Correct CHU, dumbclock, and WWVB drivers to check for 0 returned from\n refclock_open() on failure.\n* Correct \"SIMUL=4 ./flock-build -1\" to prioritize -1/--one.",
"---\n(4.2.6p1-RC5) 2010/02/09 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1140] Clean up debug.html, decode.html, and ntpq.html.\n* [Bug 1438] Remove dead code from sntp/networking.c.\n* [Bug 1477] 1st non-gmake make in clone w/VPATH can't make COPYRIGHT.\n* [Bug 1478] linking fails with undefined reference EVP_MD_pkey_type.\n* [Bug 1479] Compilation fails because of not finding readline headers.\n* [Bug 1480] snprintf() cleanup caused unterminated refclock IDs.\n* [Bug 1484] ushort is not defined in QNX6.",
"---\n(4.2.6p1-RC4) 2010/02/04 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1455] ntpd does not try /etc/ntp.audio as documented.\n* [Bug 1467] Fix bogus rebuild of sntp/sntp.html\n* [Bug 1470] \"make distdir\" in $srcdir builds keyword-gen, libntp.a.\n* [Bug 1473] \"make distcheck\" before build can't make sntp/version.m4.\n* [Bug 1474] ntp_keygen needs LCRYPTO after libntp.a.\n* Convert many sprintf() calls to snprintf(), also strcpy(), strcat().\n* Fix widely cut-n-pasted bug in refclock shutdown after failed start.\n* Remove some dead code checking for emalloc() returning NULL.\n* Remove arlib.",
"---\n(4.2.6p1-RC3) 2010/01/24 Released by Harlan Stenn <stenn@ntp.org>",
"* Use TZ=UTC instead of TZ= when calling date in scripts/mkver.in .\n* [Bug 1448] Some macros not correctly conditionally or absolutely defined\n on Windows.\n* [Bug 1449] ntpsim.h in ntp_config.c should be used conditionally.\n* [Bug 1450] Option to exclude warnings not unconditionally defined on Windows.\n* [Bug 1127] Properly check the return of X590_verify() - missed one.\n* [Bug 1439] .texi generation must wait until after binary is linked.\n* [Bug 1440] Update configure.ac to support kfreebsd.\n* [Bug 1445] IRIX does not have -lcap or support linux capabilities.\n* [Bug 1451] CID 115: sntp leaks KoD entry when updating existing.\n* [Bug 1453] Use $CC in config.cache filename in ./build script.",
"---\n(4.2.6p1-RC2) 2009/12/25 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1411] Fix status messages in refclock_oncore.c.\n* [Bug 1416] MAXDNAME undefined on Solaris 2.6.\n* [Bug 1419] ntpdate, ntpdc, sntp, ntpd ignore configure --bindir.\n* [Bug 1424] Fix check for rtattr (rtnetlink.h).\n* [Bug 1425] unpeer by association ID sets up for duplicate free().\n* [Bug 1426] scripts/VersionName needs . on the search path.\n* [Bug 1427] quote missing in ./build - shows up on NetBSD.\n* [Bug 1428] Use AC_HEADER_RESOLV to fix breaks from resolv.h\n* [Bug 1429] ntpd -4 option does not reliably force IPv4 resolution.\n* [Bug 1431] System headers must come before ntp headers in ntp_intres.c .\n* [Bug 1434] HP-UX 11 ip_mreq undeclared, _HPUX_SOURCE helps some.\n* [Bug 1435] sntp: Test for -lresolv using the same tests as in ntp.",
"---\n(4.2.6p1-RC1) 2009/12/20 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1409] Put refclock_neoclock4x.c under the NTP COPYRIGHT notice.\n This should allow debian and other distros to add this refclock driver\n in further distro releases.\n Detect R2 hardware releases.\n* [Bug 1412] m4/os_cflags.m4 caches results that depend on $CC.\n* [Bug 1413] test OpenSSL headers regarding -Wno-strict-prototypes.\n* [Bug 1414] Enable \"make distcheck\" success with BSD make.\n* [Bug 1415] Fix Mac OS X link problem.\n* [Bug 1418] building ntpd/ntpdc/ntpq statically with ssl fails.\n* Build infrastructure updates to enable beta releases of ntp-stable.",
"---\n(4.2.6) 2009/12/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Sec 1331] from4.2.4p8: DoS with mode 7 packets - CVE-2009-3563.\n* [Bug 508] Fixed leap second handling for Windows.\n(4.2.5p250-RC) 2009/11/30 Released by Harlan Stenn <stenn@ntp.org>\n* sntp documentation updates.\n* [Bug 761] internal resolver does not seem to honor -4/-6 qualifiers\n* [Bug 1386] Deferred DNS doesn't work on NetBSD\n* [Bug 1391] avoid invoking autogen twice for .c and .h files.\n* [Bug 1397] shmget() refclock_shm failing because of file mode.\n* Pass no_needed to ntp_intres as first part of fixing [Bug 975].\n* Add ./configure --enable-force-defer-DNS to help debugging.\n(4.2.5p249-RC) 2009/11/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1400] An empty KOD DB file causes sntp to coredump.\n* sntp: documentation cleanup.\n* sntp: clean up some error messages.\n* sntp: Use the precision to control how many offset digits are shown.\n* sntp: Show root dispersion.\n* Cleanup from the automake/autoconf upgrades.\n(4.2.5p248-RC) 2009/11/26 Released by Harlan Stenn <stenn@ntp.org>\n* Prepare for the generation of sntp.html.\n* Documentation changes from Dave Mills.\n* [Bug 1387] Storage leak in ntp_intres (minor).\n* [Bug 1389] buffer overflow in refclock_oncore.c\n* [Bug 1391] .texi usage text from installed, not built binaries.\n* [Bug 1392] intres retries duplicate assocations endlessly.\n* Correct *-opts.h dependency so default 'get' action isn't used.\n(4.2.5p247-RC) 2009/11/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1142] nodebug builds shed no light on -d, -D option failure.\n* [Bug 1179] point out the problem with -i/--jaildir and -u/--user when\n they are disabled by configure.\n* [Bug 1308] support systems that lack fork().\n* [Bug 1343] sntp doesn't link on Solaris 7, needs -lresolv.\n(4.2.5p246-RC) 2009/11/17 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to autogen-5.10\n* [Bug 1378] Unnecessary resetting of peers during interface update.\n* [Bug 1382] p245 configure --disable-dependency-tracking won't build.\n* [Bug 1384] ntpq :config core dumped with a blank password.\n(4.2.5p245-RC) 2009/11/14 Released by Harlan Stenn <stenn@ntp.org>\n* Cleanup from Dave Mills.\n* [Bug 1343] sntp illegal C does not compile on Solaris 7.\n* [Bug 1381] Version .deps generated include file dependencies to allow\n known dependency-breaking changes to force .deps to be cleaned,\n triggered by changing the contents of deps-ver and/or sntp/deps-ver.\n(4.2.5p244-RC) 2009/11/12 Released by Harlan Stenn <stenn@ntp.org>\n* keygen.html updates from Dave Mills.\n* [Bug 1003] ntpdc unconfig command doesn't prompt for keyid.\n* [Bug 1376] Enable authenticated ntpq and ntpdc using newly-available\n digest types.\n* ntp-keygen, Autokey OpenSSL build vs. run version mismatch is now a\n non-fatal warning.\n(4.2.5p243-RC) 2009/11/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1226] Fix deferred DNS lookups.\n* new crypto signature cleanup.\n(4.2.5p242-RC) 2009/11/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1363] CID 92 clarify fallthrough case in clk_trimtsip.c\n* [Bug 1366] ioctl(TIOCSCTTY, 0) fails on NetBSD *[0-2].* > 3.99.7.\n* [Bug 1368] typos in libntp --without-crypto case\n* [Bug 1371] deferred DNS lookup failing with INFO_ERR_AUTH.\n* CID 87 dead code in ntpq.c atoascii().\n* Fix authenticated ntpdc, broken in p240.\n* Stub out isc/mem.h, shaving 47k from a MIPS ntpd binary.\n* Shrink keyword scanner FSM entries from 64 to 32 bits apiece.\n* Documention updates from Dave Mills.\n* authkeys.c cleanup from Dave Mills.\n(4.2.5p241-RC) 2009/11/07 Released by Harlan Stenn <stenn@ntp.org>\n* html/authopt.html update from Dave Mills.\n* Remove unused file from sntp/Makefile.am's distribution list.\n* new crypto signature cleanup.\n(4.2.5p240-RC) 2009/11/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1364] clock_gettime() not detected, need -lrt on Debian 5.0.3.\n* Provide all of OpenSSL's signature methods for ntp.keys (FIPS 140-2).\n(4.2.5p239-RC) 2009/10/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1357] bogus assert from refclock_shm.\n* [Bug 1359] Debug message cleanup.\n* CID 101: more pointer/array cleanup.\n* [Bug 1356] core dump from refclock_nmea when can't open /dev/gpsU.\n* [Bug 1358] AIX 4.3 sntp/networking.c IPV6_JOIN_GROUP undeclared.\n* CID 101: pointer/array cleanup.\n(4.2.5p238-RC) 2009/10/27 Released by Harlan Stenn <stenn@ntp.org>\n* Changes from Dave Mills.\n* driver4.html updates from Dave Mills.\n* [Bug 1252] PPSAPI cleanup on ntpd/refclock_wwvb.c.\n* [Bug 1354] libtool error building after bootstrap with Autoconf 2.64.\n* Allow NTP_VPATH_HACK configure test to handle newer gmake versions.\n* CIDs 94-99 make it more clearly impossible for sock_hash() to return\n a negative number.\n* CID 105, 106 ensure ntpdc arrays are not overrun even if callers\n misbehave.\n* CID 113 use va_end() in refclock_true.c true_debug().\n* Get rid of configure tests for __ss_family and __ss_len when the more\n common ss_family and ss_len are present.\n(4.2.5p237-RC) 2009/10/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 610] NMEA support for using PPSAPI on a different device.\n* [Bug 1238] use only fudge time2 to offset NMEA serial timestamp.\n* [Bug 1355] ntp-dev won't compile on OpenBSD 4.6.\n(4.2.5p236-RC) 2009/10/22 Released by Harlan Stenn <stenn@ntp.org>\n* Cleanup from Dave Mills.\n* [Bug 1343] ntpd/ntp_io.c close_fd() does not compile on Solaris 7.\n* [Bug 1353] ntpq \"rv 0 settimeofday\" always shows UNKNOWN on unix.\n* Do not attempt to execute built binaries from ntpd/Makefile when\n cross-compiling (keyword-gen and ntpd --saveconfigquit).\n* sntp/main.c: Remove duplicate global adr_buf[] (also defined in\n networking.c) which Piotr Grudzinski identified breaking his build.\n* Correct in6addr_any test in configure.ac to attempt link too.\n(4.2.5p235-RC) 2009/10/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1343] lib/isc build breaks on systems without IPv6 headers.\n(4.2.5p234-RC) 2009/10/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1339] redux, use unmodified lib/isc/win32/strerror.c and\n move #define strerror... to a header not used by lib/isc code.\n* [Bug 1345] illegal 'grep' option prevents compilation.\n* [Bug 1346] keyword scanner broken where char defaults to unsigned.\n* [Bug 1347] ntpd/complete.conf missing multicastclient test case.\n(4.2.5p233-RC) 2009/10/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1337] cast setsockopt() v4 address pointer to void *.\n* [Bug 1342] ignore|drop one IPv6 address on an interface blocks all\n addresses on that interface.\n* Documentation cleanup and updates.\n(4.2.5p232-RC) 2009/10/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1302] OpenSSL under Windows needs applink support.\n* [Bug 1337] fix incorrect args to setsockopt(fd, IP_MULTICAST_IF,...).\n* [Bug 1339] Fix Windows-only ntp_strerror() infinite recursion.\n* [Bug 1341] NMEA driver requires working PPSAPI #ifdef HAVE_PPSAPI.\n* Construct ntpd keyword scanner finite state machine at compile time\n rather than at runtime, shrink entries from 40+ to 8 bytes.\n* Update documentation for ntpq --old-rv, saveconfig, saveconfigdir,\n ntpd -I -L and -M, and interface/nic rules. (From Dave Hart)\n* [Bug 1337] fix incorrect args to setsockopt(fd, IP_MULTICAST_IF,...)\n(4.2.5p231-RC) 2009/10/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1335] Broadcast client degraded by wildcard default change.\n(4.2.5p230-RC) 2009/10/09 Released by Harlan Stenn <stenn@ntp.org>\n* Start the 4.2.6 Release Candidate cycle.\n* Broadcast and transit phase cleanup from Dave Mills.\n(4.2.5p229) 2009/10/07 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1334] ntpsnmpd undefined reference to `ntpqOptions'.\n* Change ntpsnmpd/Makefile.am include file order to fix FreeBSD build.\n(4.2.5p228) 2009/10/06 Released by Harlan Stenn <stenn@ntp.org>\n* Reclaim syntax tree memory after application in ntpd built with\n configure --disable-saveconfig.\n* [Bug 1135] ntpq uses sizeof(u_long) where sizeof(u_int32) is meant.\n* [Bug 1333] ntpd --interface precedence over --novirtualips lost.\n(4.2.5p227) 2009/10/05 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1135] :config fails with \"Server disallowed request\"\n* [Bug 1330] disallow interface/nic rules when --novirtualips or\n --interface are used.\n* [Bug 1332] ntpq -c 'rv 0 variablename' returns extra stuff.\n* Add test of ntpd --saveconfigquit fidelity using new complete.conf.\n* Documentation updates from Dave Hart/Dave Mills.\n(4.2.5p226) 2009/10/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1318] Allow multiple -g options on ntpd command line.\n* [Bug 1327] ntpq, ntpdc, ntp-keygen -d & -D should work with configure\n --disable-debugging.\n* Add ntpd --saveconfigquit <filename> option for future build-time\n testing of saveconfig fidelity.\n* Clockhop and autokey cleanup from Dave Mills.\n* Documentation updates from Dave Mills.\n(4.2.5p225) 2009/09/30 Released by Harlan Stenn <stenn@ntp.org>\n* authopt documentation changes from Dave Mills/Dave Hart.\n* [Bug 1324] support bracketed IPv6 numeric addresses for restrict.\n(4.2.5p224) 2009/09/29 Released by Harlan Stenn <stenn@ntp.org>\n* Clockhop and documentation fixes from Dave Mills.\n* Remove \"tos maxhop\" ntp.conf knob.\n(4.2.5p223) 2009/09/28 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1321] build doesn't work if . isn't on $PATH.\n* [Bug 1323] Implement \"revoke #\" to match documentation, deprecate\n \"crypto revoke #\".\n(4.2.5p222) 2009/09/27 Released by Harlan Stenn <stenn@ntp.org>\n* Update libisc code using bind-9.6.1-P1.tar.gz, rearrange our copy to\n mirror the upstream layout (lib/isc/...), and merge in NTP-local\n modifications to libisc. There is a new procedure to ease future\n libisc merges using a separate \"upstream\" bk repo. That will enable\n normal bk pull automerge to handle carrying forward any local changes\n and should enable us to take updated libisc snapshots more often.\n* Updated build and flock-build scripts. flock-build --one is a way\n to perform a flock-build compatible solitary build, handy for a repo\n clone's first build on a machine with autoconf, automake, etc.\n* Compiling ntp_parser.y using BSD make correctly places ntp_parser.h\n in the top-level ntpd directory instead of A.*/ntpd.\n* bootstrap script updated to remove potentially stale .deps dirs.\n* Remove unneeded Makefile.am files from the lib/isc/include tree.\n(4.2.5p221) 2009/09/26 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1316] segfault if refclock_nmea can't open file.\n* [Bug 1317] Distribute cvo.sh.\n(4.2.5p220) 2009/09/25 Released by Harlan Stenn <stenn@ntp.org>\n* Rearrange libisc code to match the upstream layout in BIND. This is\n step one of two, changing the layout but keeping our existing libisc.\n(4.2.5p219) 2009/09/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1315] \"interface ignore 0.0.0.0\" is ignored.\n* add implicit \"nic ignore all\" rule before any rules from ntp.conf, so\n \"nic listen eth0\" alone means the same as \"-I eth0\".\n* add wildcard match class for interface/nic rules.\n* fix mistaken carryover of prefixlen from one rule to the next.\n* Ensure IPv6 localhost address ::1 is included in libisc's Windows IPv6\n address enumeration, allowing ntpq and ntpdc's hardcoding to 127.0.0.1 \n on Windows to end.\n(4.2.5p218) 2009/09/21 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1314] saveconfig emits -4 and -6 on when not given.\n* correct parsing and processing of setvar directive.\n* highlight location of ntpq :config syntax errors with ^.\n* clarify (former) NO_ARG, SINGLE_ARG, MULTIPLE_ARG renaming to\n FOLLBY_TOKEN, FOLLBY_STRING, FOLLBY_STRINGS_TO_EOC.\n* parser, saveconfig cleanup to store T_ identifiers in syntax tree.\n(4.2.5p217) 2009/09/20 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1300] reject remote configuration of dangerous items.\n(4.2.5p216) 2009/09/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1312] ntpq/ntpdc MD5 passwords truncated to 8 chars on Suns.\n* CID 10 missing free(up); in refclock_palisade.c error return, again.\n* CID 83 added assertion to demonstrate config_nic_rules() does not\n call strchr(NULL, '/').\n(4.2.5p215) 2009/09/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1292] Workaround last VC6 unsigned __int64 kink.\n(4.2.5p214) 2009/09/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1303] remove top-level \"autokey\" directive.\n* use \"nic listen 192.168.0.0/16\" instead of\n \"nic listen 192.168.0.0 prefixlen 16\".\n(4.2.5p213) 2009/09/16 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1310] fix Thunderbolt mode in refclock_palisade.c\n(4.2.5p212) 2009/09/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 983] add interface [listen | ignore | drop] ... directive.\n* [Bug 1243] MD5auth_setkey zero-fills key from first zero octet.\n* [Bug 1295] leftover fix, do not crash on exit in free_config_trap()\n when \"trap 1.2.3.4\" is used without any further options.\n* [Bug 1311] 4.2.5p211 doesn't build in no-debug mode.\n* document interface (alias nic) and unpeer.\n* Correct syntax error line & column numbers.\n* CID 79: kod_init_kod_db() fails to fclose(db_s) in two error paths.\n* CID 80: attempt to quiet Coverity false positive re: leaking \"reason\"\n in main().\n* Documentation updates from Dave Mills.\n* CID 81: savedconfig leaked in save_config().\n* Make the code agree with the spec and the book (Dave Mills).\n(4.2.5p211) 2009/09/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 663] respect ntpq -c and -p order on command line.\n* [Bug 1292] more VC6 unsigned __int64 workarounds.\n* [Bug 1296] Added Support for Trimble Acutime Gold.\n(4.2.5p210) 2009/09/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1294] Use OPENSSL_INC and OPENSSL_LIB macros for Windows\n and remove unnecessary reference to applink.c for Windows\n* [Bug 1295] trap directive options are not optional.\n* [Bug 1297] yylex() must always set yylval before returning.\n(4.2.5p209) 2009/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1290] Fix to use GETTIMEOFDAY macro\n* [Bug 1289] Update project files for VC6, VS2003, VS2005, VS 2008\n(4.2.5p208) 2009/08/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1293] make configuration dumper ready for release, specifically:\n* rename ntpq dumpcfg command to \"saveconfig\".\n* require authentication for saveconfig.\n* \"restrict ... nomodify\" prevents saveconfig and :config.\n* \"saveconfig .\" shorthand to save to startup configuration file.\n* support strftime() substitution in saveconfig arg to timestamp\n the output filename, for example \"saveconfig %Y%m%d-%H%M%S.conf\".\n* display saveconfig response message from ntpd in ntpq.\n* save output filename in \"savedconfig\" variable, fetched with ntpq -c\n \"rv 0 savedconfig\".\n* document saveconfig in html/ntpq.html.\n* add ./configure --disable-saveconfig to build a smaller ntpd.\n* log saveconfig failures and successes to syslog.\n(4.2.5p207) 2009/08/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1292] Minor Windows source tweaks for VC6-era SDK headers.\n(4.2.5p206) 2009/08/26 Released by Harlan Stenn <stenn@ntp.org>\n* accopt.html typo fixes from Dave Mills.\n* [Bug 1283] default to remembering KoD in sntp.\n* clean up numerous sntp/kod_management.c bugs.\n* use all addresses resolved from each DNS name in sntp.\n(4.2.5p205) 2009/08/18 Released by Harlan Stenn <stenn@ntp.org>\n* accopt.html typo fixes from Dave Mills.\n* [Bug 1285] Log ntpq :config/config-from-file events.\n* [Bug 1286] dumpcfg omits statsdir, mangles filegen.\n(4.2.5p204) 2009/08/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1284] infinite loop in ntpd dumping more than one trustedkey\n(4.2.5p203) 2009/08/16 Released by Harlan Stenn <stenn@ntp.org>\n* Add ntpq -c dumpcfg, Google Summer of Code project of Max Kuehn\n(4.2.5p202) 2009/08/14 Released by Harlan Stenn <stenn@ntp.org>\n* install the binary and man page for sntp.\n(4.2.5p201) 2009/08/13 Released by Harlan Stenn <stenn@ntp.org>\n* sntp: out with the old, in with the new.\n(4.2.5p200) 2009/08/12 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1281] Build ntpd on Windows without big SDK download, burn,\n and install by checking in essentially unchanging messages.mc build\n products to avoid requiring mc.exe, which is not included with VC++\n 2008 EE.\n(4.2.5p199) 2009/08/09 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1279] Cleanup for warnings from Veracode static analysis.\n(4.2.5p198) 2009/08/03 Released by Harlan Stenn <stenn@ntp.org>\n* Upgrade to autogen-5.9.9-pre5.\n(4.2.5p197) 2009/07/30 Released by Harlan Stenn <stenn@ntp.org>\n* The build script now has . at the end of PATH for config.guess.\n(4.2.5p196) 2009/07/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1272] gsoc_sntp IPv6 build problems under HP-UX 10.\n* [Bug 1273] CID 10: Palisade leaks unit struct in error path.\n* [Bug 1274] CID 67: ensure resolve_hosts() output count and pointers\n are consistent.\n* [Bug 1275] CID 45: CID 46: old sntp uses uninitialized guesses[0],\n precs[0].\n* [Bug 1276] CID 52: crypto_xmit() may call crypto_alice[23]()\n with NULL peer.\n(4.2.5p195) 2009/07/27 Released by Harlan Stenn <stenn@ntp.org>\n* cvo.sh: Add support for CentOS, Fedora, Slackware, SuSE, and QNX.\n(4.2.5p194) 2009/07/26 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* Use scripts/cvo.sh in the build script to get better subdir names.\n(4.2.5p193) 2009/07/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1261] CID 34: simulate_server() rbuf.msg_flags uninitialized.\n* [Bug 1262] CID 35: xpkt.mac uninitialized in simulate_server().\n* [Bug 1263] CID 37: CID 38: CID 40: CID 43: multiple refclocks \n uninitialized tm_zone (arc, chronolog, dumbclock, pcf).\n* [Bug 1264] CID 64: gsoc_sntp on_wire() frees wrong ptr receiving KoD.\n* [Bug 1265] CID 65: CID 66: gsoc_sntp on_wire() leaks x_pkt, r_pkt.\n* [Bug 1266] CID 39: datum_pts_start() uninitialized arg.c_ospeed.\n* [Bug 1267] CID 44: old sntp handle_saving() writes stack garbage to\n file when clearing.\n* [Bug 1268] CID 63: resolve_hosts() leaks error message buffer.\n* [Bug 1269] CID 74: use assertion to ensure move_fd() does not return\n negative descriptors.\n* [Bug 1270] CID 70: gsoc_sntp recv_bcst_data mdevadr.ipv6mr_interface\n uninitialized.\n(4.2.5p192) 2009/07/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 965] CID 42: ss_family uninitialized.\n* [Bug 1250] CID 53: kod_init_kod_db() overruns kod_db malloc'd buffer.\n* [Bug 1251] CID 68: search_entry() mishandles dst argument.\n* [Bug 1252] CID 32: Quiet Coverity warning with assertion.\n* [Bug 1253] CID 50: gsoc_sntp/crypto.c auth_init() always returns a \n list with one entry.\n* [Bug 1254] CID 56: tv_to_str() leaks a struct tm each call.\n* [Bug 1255] CID 55: pkt_output() leaks a copy of each packet.\n* [Bug 1256] CID 51: Coverity doesn't recognize our assertion macros as\n terminal.\n* [Bug 1257] CID 57: gsoc_sntp auth_init() fails to fclose(keyfile).\n* [Bug 1258] CID 54: gsoc_sntp resolve_hosts() needs simplification.\n* [Bug 1259] CID 59: gsoc_sntp recv_bcast_data() fails to free(rdata)\n on error paths.\n* [Bug 1260] CID 60: gsoc_sntp recvpkt() fails to free(rdata).\n* Updated to AutoGen-5.9.9pre2.\n(4.2.5p191) 2009/07/21 Released by Harlan Stenn <stenn@ntp.org>\n* Updated to AutoGen-5.9.9pre1.\n(4.2.5p190) 2009/07/20 Released by Harlan Stenn <stenn@ntp.org>\n* Updated to AutoGen-5.9.8.\n* [Bug 1248] RES_MSSNTP typo in ntp_proto.c.\n* [Bug 1246] use a common template for singly-linked lists, convert most\n doubly-linked lists to singly-linked.\n* Log warning about signd blocking when restrict mssntp used.\n(4.2.5p189) 2009/07/16 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation cleanup from Dave Mills.\n(4.2.5p188) 2009/07/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1245] Broken xmt time sent in fast_xmit() of 4.2.5p187.\n(4.2.5p187) 2009/07/11 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1042] multicast listeners IPv4+6 ignore new interfaces.\n* [Bug 1237] Windows serial code treat CR and LF both as line\n terminators.\n* [Bug 1238] use fudge time2 for serial timecode offset in NMEA driver.\n* [Bug 1242] Remove --enable-wintime, symmetric workaround is now\n always enabled.\n* [Bug 1244] NTP_INSIST(fd != maxactivefd) failure in intres child\n* Added restrict keyword \"mssntp\" for Samba4 DC operation, by Dave Mills.\n(4.2.5p186) 2009/07/08 Released by Harlan Stenn <stenn@ntp.org>\n* ntp_proto.c cleanup from Dave Mills.\n(4.2.5p185) 2009/07/01 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* [Bug 1234] convert NMEA driver to use common PPSAPI code.\n* timepps-Solaris.h pps_handle_t changed from pointer to scalar\n* Spectracom refclock added to Windows port of ntpd\n* [Bug 1236] Declaration order fixed.\n* Bracket private ONCORE debug statements with #if 0 rather than #ifdef\n DEBUG\n* Delete ONCORE debug statement that is now handled elsewhere.\n(4.2.5p184) 2009/06/24 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1233] atom refclock fudge time1 sign flipped in 4.2.5p164.\n(4.2.5p183) 2009/06/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1196] setsockopt(SO_EXCLUSIVEADDRUSE) can fail on Windows 2000\n and earlier with WSAINVAL, do not log a complaint in that case.\n* [Bug 1210] ONCORE driver terminates ntpd without logging a reason.\n* [Bug 1218] Correct comment in refclock_oncore on /etc/ntp.oncore*\n configuration file search order.\n* Change ONCORE driver to log using msyslog as well as to any\n clockstats file.\n* [Bug 1231] ntpsnmpd build fails after sockaddr union changes.\n(4.2.5p182) 2009/06/18 Released by Harlan Stenn <stenn@ntp.org>\n* Add missing header dependencies to the ntpdc layout verification.\n* prefer.html updates from Dave Mills.\n* [Bug 1205] Add ntpd --usepcc and --pccfreq options on Windows\n* [Bug 1215] unpeer by association ID\n* [Bug 1225] Broadcast address miscalculated on Windows 4.2.5p180\n* [Bug 1229] autokey segfaults in cert_install().\n* Use a union for structs sockaddr, sockaddr_storage, sockaddr_in, and\n sockaddr_in6 to remove casts and enable type checking. Collapse\n some previously separate IPv4/IPv6 paths into a single codepath.\n(4.2.5p181) 2009/06/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1206] Required compiler changes for Windows\n* [Bug 1084] PPSAPI for ntpd on Windows with DLL backends\n* [Bug 1204] Unix-style refclock device paths on Windows\n* [Bug 1205] partial fix, disable RDTSC use by default on Windows\n* [Bug 1208] decodenetnum() buffer overrun on [ with no ]\n* [Bug 1211] keysdir free()d twice #ifdef DEBUG\n* Enable ONCORE, ARCRON refclocks on Windows (untested)\n(4.2.5p180) 2009/05/29 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1200] Enable IPv6 in Windows port\n* Lose FLAG_FIXPOLL, from Dave Mills.\n(4.2.5p179) 2009/05/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1041] xmt -> aorg timestamp cleanup from Dave Mills,\n reported by Dave Hart.\n* [Bug 1193] Compile error: conflicting types for emalloc.\n* [Bug 1196] VC6 winsock2.h does not define SO_EXCLUSIVEADDRUSE.\n* Leap/expire cleanup from Dave Mills.\n(4.2.5p178) 2009/05/21 Released by Harlan Stenn <stenn@ntp.org>\n* Provide erealloc() and estrdup(), a la emalloc().\n* Improve ntp.conf's parser error messages.\n* [Bug 320] \"restrict default ignore\" does not affect IPv6.\n* [Bug 1192] \"restrict -6 ...\" reports a syntax error.\n(4.2.5p177) 2009/05/18 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p7\n* [Bug 1174] nmea_shutdown assumes that nmea has a unit assigned\n* [Bug 1190] NMEA refclock fudge flag4 1 obscures position in timecode\n* Update NMEA refclock documentation in html/drivers/driver20.html\n(4.2.5p176) 2009/05/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1154] mDNS registration should be done later, repeatedly and only\n if asked for. (second try for fix)\n(4.2.5p175) 2009/05/12 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p7-RC7\n* [Bug 1180] ntpd won't start with more than ~1000 interfaces\n* [Bug 1182] Documentation typos and missing bits.\n* [Bug 1183] COM port support should extend past COM3\n* [Bug 1184] ntpd is deaf when restricted to second IP on the same net\n* Clean up configure.ac NTP_CACHEVERSION interface, display cache\n version when clearing. Fixes a regression.\n(4.2.5p174) 2009/05/09 Released by Harlan Stenn <stenn@ntp.org>\n* Stale leapsecond file fixes from Dave Mills.\n(4.2.5p173) 2009/05/08 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p7-RC6\n(4.2.5p172) 2009/05/06 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1175] Instability in PLL daemon mode.\n* [Bug 1176] refclock_parse.c does not compile without PPSAPI.\n(4.2.5p171) 2009/05/04 Released by Harlan Stenn <stenn@ntp.org>\n* Autokey documentation cleanup from Dave Mills.\n* [Bug 1171] line editing libs found without headers (Solaris 11)\n* [Bug 1173] NMEA refclock fails with Solaris PPSAPI\n* Fix problem linking msntp on Solaris when sntp subdir is configured\n before parent caused by different gethostent library search order.\n* Do not clear config.cache when it is empty.\n(4.2.5p170) 2009/05/02 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1152] adjust PARSE to new refclock_pps logic\n* Include 4.2.4p7-RC5\n* loopfilter FLL/PLL crossover cleanup from Dave Mills.\n* Documentation updates from Dave Mills.\n* ntp-keygen cleanup from Dave Mills.\n* crypto API cleanup from Dave Mills.\n* Add NTP_CACHEVERSION mechanism to ignore incompatible config.cache\n* Enable gcc -Wstrict-overflow for gsoc_sntp as well\n(4.2.5p169) 2009/04/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1171] Note that we never look for -lreadline by default.\n* [Bug 1090] Fix bogus leap seconds in refclock_hpgps.\n(4.2.5p168) 2009/04/29 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p7-RC4\n* [Bug 1169] quiet compiler warnings\n* Re-enable gcc -Wstrict-prototypes when not building with OpenSSL\n* Enable gcc -Wstrict-overflow\n* ntpq/ntpdc emit newline after accepting password on Windows\n* Updates from Dave Mills:\n* ntp-keygen.c: Updates.\n* Fix the error return and syslog function ID in refclock_{param,ppsapi}.\n* Make sure syspoll is within the peer's minpoll/maxpoll bounds.\n* ntp_crypto.c: Use sign_siglen, not len. sign key filename cleanup.\n* Bump NTP_MAXEXTEN from 1024 to 2048, update values for some field lengths.\n* m4/ntp_lineeditlibs.m4: fix warnings from newer Autoconf\n* [Bug 1166] Remove truncation of position (blanking) code in refclock_nmea.c\n(4.2.5p167) 2009/04/26 Released by Harlan Stenn <stenn@ntp.org>\n* Crypto cleanup from Dave Mills.\n(4.2.5p166) 2009/04/25 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1165] Clean up small memory leaks in the config file parser\n* Correct logconfig keyword declaration to MULTIPLE_ARG\n* Enable filename and line number leak reporting on Windows when built\n DEBUG for all the typical C runtime allocators such as calloc,\n malloc, and strdup. Previously only emalloc calls were covered.\n* Add DEBUG-only code to free dynamically allocated memory that would\n otherwise remain allocated at ntpd exit, to allow less forgivable\n leaks to stand out in leaks reported after exit.\n* Ensure termination of strings in ports/winnt/libisc/isc_strerror.c\n and quiet compiler warnings.\n* [Bug 1057] ntpdc unconfig failure\n* [Bug 1161] unpeer AKA unconfig command for ntpq :config\n* PPS and crypto cleanup in ntp_proto.c from Dave Mills.\n(4.2.5p165) 2009/04/23 Released by Harlan Stenn <stenn@ntp.org>\n* WWVB refclock cleanup from Dave Mills.\n* Code cleanup: requested_key -> request_key.\n* [Bug 833] ignore whitespace at end of remote configuration lines\n* [Bug 1033] ntpdc/ntpq crash prompting for keyid on Windows\n* [Bug 1028] Support for W32Time authentication via Samba.\n* quiet ntp_parser.c malloc redeclaration warning\n* Mitigation and PPS/PPSAPI cleanup from Dave Mills.\n* Documentation updates from Dave Mills.\n* timepps-Solaris.h patches from Dave Hart.\n(4.2.5p164) 2009/04/22 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p7-RC3\n* PPS/PPSAPI cleanup from Dave Mills.\n* Documentation updates from Dave Mills.\n* [Bug 1125] C runtime per-thread initialization on Windows\n* [Bug 1152] temporarily disable refclock_parse, refclock_true until\n maintainers can repair build break from pps_sample()\n* [Bug 1153] refclock_nmea should not mix UTC with GPS time\n* [Bug 1159] ntpq overlap diagnostic message test buggy\n(4.2.5p163) 2009/04/10 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.5p162) 2009/04/09 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* Mitigation and PPS cleanup from Dave Mills.\n* Include 4.2.4p7-RC2\n* [Bug 216] New interpolation scheme for Windows eliminates 1ms jitter\n* remove a bunch of #ifdef SYS_WINNT from portable code\n* 64-bit time_t cleanup for building on newer Windows compilers\n* Only set CMOS clock during ntpd exit on Windows if the computer is\n shutting down or restarting.\n* [Bug 1148] NMEA reference clock improvements\n* remove deleted gsoc_sntp/utilities.o from repository so that .o build\n products can be cleaned up without corrupting the repository.\n(4.2.5p161) 2009/03/31 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n(4.2.5p160) 2009/03/30 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1141] refclock_report missing braces cause spurious \"peer event:\n clock clk_unspec\" log entries\n* Include 4.2.4p7-RC1\n(4.2.5p159) 2009/03/28 Released by Harlan Stenn <stenn@ntp.org>\n* \"bias\" changes from Dave Mills.\n(4.2.5p158) 2009/01/30 Released by Harlan Stenn <stenn@ntp.org>\n* Fix [CID 72], a typo introduced at the latest fix to prettydate.c.\n(4.2.5p157) 2009/01/26 Released by Harlan Stenn <stenn@ntp.org>\n* Cleanup/fixes for ntp_proto.c and ntp_crypto.c from Dave Mills.\n(4.2.5p156) 2009/01/19 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1118] Fixed sign extension for 32 bit time_t in caljulian() and prettydate().\n Fixed some compiler warnings about missing prototypes.\n Fixed some other simple compiler warnings.\n* [Bug 1119] [CID 52] Avoid a possible null-dereference in ntp_crypto.c.\n* [Bug 1120] [CID 51] INSIST that peer is non-null before we dereference it.\n* [Bug 1121] [CID 47] double fclose() in ntp-keygen.c.\n(4.2.5p155) 2009/01/18 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* CHU frequency updates.\n* Design assertion fixes for ntp_crypto.c from Dave Mills.\n(4.2.5p154) 2009/01/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 992] support interface event change on Linux from\n Miroslav Lichvar.\n(4.2.5p153) 2009/01/09 Released by Harlan Stenn <stenn@ntp.org>\n* Renamed gsoc_sntp/:fetch-stubs to gsoc_sntp/fetch-stubs to avoid\n file name problems under Windows.\n Removed German umlaut from log msg for 4.2.5p142.\n(4.2.5p152) 2009/01/08 Released by Harlan Stenn <stenn@ntp.org>\n* Include 4.2.4p6: 2009/01/08 Released by Harlan Stenn <stenn@ntp.org>\n(4.2.5p151) 2008/12/23 Released by Harlan Stenn <stenn@ntp.org>\n* Stats file logging cleanup from Dave Mills.\n(4.2.5p150) 2008/12/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1099] Fixed wrong behaviour in sntp's crypto.c.\n* [Bug 1103] Fix 64-bit issues in the new calendar code.\n(4.2.5p149) 2008/12/05 Released by Harlan Stenn <stenn@ntp.org>\n* Fixed mismatches in data types and OID definitions in ntpSnmpSubAgent.c\n* added a premliminary MIB file to ntpsnmpd (ntpv4-mib.mib)\n(4.2.5p148) 2008/12/04 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1070] Fix use of ntpq_parsestring() in ntpsnmpd.\n(4.2.5p147) 2008/11/27 Released by Harlan Stenn <stenn@ntp.org>\n* Update gsoc_sntp's GCC warning code.\n(4.2.5p146) 2008/11/26 Released by Harlan Stenn <stenn@ntp.org>\n* Update Solaris CFLAGS for gsoc_sntp.\n(4.2.5p145) 2008/11/20 Released by Harlan Stenn <stenn@ntp.org>\n* Deal with time.h for sntp under linux.\n* Provide rpl_malloc() for sntp for systems that need it.\n* Handle ss_len and socklen type for sntp.\n* Fixes to the sntp configure.ac script.\n* Provide INET6_ADDRSTRLEN if it is missing.\n* [Bug 1095] overflow in caljulian.c.\n(4.2.5p144) 2008/11/19 Released by Harlan Stenn <stenn@ntp.org>\n* Use int32, not int32_t.\n* Avoid the sched*() functions under OSF - link problems.\n(4.2.5p143) 2008/11/17 Released by Harlan Stenn <stenn@ntp.org>\n* sntp cleanup and fixes.\n(4.2.5p142) 2008/11/16 Released by Harlan Stenn <stenn@ntp.org>\n* Imported GSoC SNTP code from Johannes Maximilian Kuehn.\n(4.2.5p141) 2008/11/13 Released by Harlan Stenn <stenn@ntp.org>\n* New caltontp.c and calyearstart.c from Juergen Perlinger.\n(4.2.5p140) 2008/11/12 Released by Harlan Stenn <stenn@ntp.org>\n* Cleanup lint from the ntp_scanner files.\n* [Bug 1011] gmtime() returns NULL on windows where it would not under Unix.\n* Updated caljulian.c and prettydate.c from Juergen Perlinger.\n(4.2.5p139) 2008/11/11 Released by Harlan Stenn <stenn@ntp.org>\n* Typo fix to driver20.html.\n(4.2.5p138) 2008/11/10 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 474] --disable-ipv6 is broken.\n* IPv6 interfaces were being looked for twice.\n* SHM driver grabs more samples, add clockstats\n* decode.html and driver20.html updates from Dave Mills.\n(4.2.5p137) 2008/11/01 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1069] #undef netsnmp's PACKAGE_* macros.\n* [Bug 1068] Older versions of netsnmp do not have netsnmp_daemonize().\n(4.2.5p136) 2008/10/27 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1078] statsdir configuration parsing is broken.\n(4.2.5p135) 2008/09/23 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1072] clock_update should not allow updates older than sys_epoch.\n(4.2.5p134) 2008/09/17 Released by Harlan Stenn <stenn@ntp.org>\n* Clean up build process for ntpsnmpd.\n(4.2.5p133) 2008/09/16 Released by Harlan Stenn <stenn@ntp.org>\n* Add options processing to ntpsnmpd.\n* [Bug 1062] Check net-snmp headers before deciding to build ntpsnmpd.\n* Clean up the libntpq.a build.\n* Regenerate ntp_parser.[ch] from ntp_parser.y\n(4.2.5p132) 2008/09/15 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1067] Multicast DNS service registration must come after the fork\n on Solaris.\n* [Bug 1066] Error messages should log as errors.\n(4.2.5p131) 2008/09/14 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1065] Re-enable support for the timingstats file.\n(4.2.5p130) 2008/09/13 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1064] Implement --with-net-snmp-config=progname\n* [Bug 1063] ntpSnmpSubagentObject.h is missing from the distribution.\n(4.2.5p129) 2008/09/11 Released by Harlan Stenn <stenn@ntp.org>\n* Quiet some libntpq-related warnings.\n(4.2.5p128) 2008/09/08 Released by Harlan Stenn <stenn@ntp.org>\n* Import Heiko Gerstung's GSoC2008 NTP MIB daemon.\n(4.2.5p127) 2008/09/01 Released by Harlan Stenn <stenn@ntp.org>\n* Regenerate ntpd/ntp_parser.c\n(4.2.5p126) 2008/08/31 Released by Harlan Stenn <stenn@ntp.org>\n* Stop libtool-1.5 from looking for C++ or Fortran.\n* [BUG 610] Documentation update for NMEA reference clock driver.\n* [Bug 828] Fix IPv4/IPv6 address parsing.\n* Changes from Dave Mills:\n Documentation updates.\n Fix a corner case where a frequency update was reported but not set.\n When LEAP_NOTINSYNC->LEAP_NOWARNING, call crypto_update() if we have\n crypto_flags.\n(4.2.5p125) 2008/08/18 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 1052] Add linuxPPS support to ONCORE driver.\n(4.2.5p124) 2008/08/17 Released by Harlan Stenn <stenn@ntp.org>\n* Documentation updates from Dave Mills.\n* Include 4.2.4p5: 2008/08/17 Released by Harlan Stenn <stenn@ntp.org>\n* [Bug 861] leap info was not being transmitted.\n* [Bug 1046] refnumtoa.c is using the wrong header file.\n* [Bug 1047] enable/disable options processing fix.\n* header file cleanup.\n* [Bug 1037] buffer in subroutine was 1 byte short.\n* configure.ac: cleanup, add option for wintime, and lay the groundwork\n for the changes needed for bug 1028.\n* Fixes from Dave Mills: 'bias' and 'interleave' work. Separate\n phase and frequency discipline (for long poll intervals). Update\n TAI function to match current leapsecond processing.\n* Documentation updates from Dave Mills.\n* [Bug 1037] Use all 16 of the MD5 passwords generated by ntp-keygen.\n* Fixed the incorrect edge parameter being passed to time_pps_kcbind in\n NMEA refclock driver.\n* [Bug 399] NMEA refclock driver does not honor time1 offset if flag3 set.\n* [Bug 985] Modifications to NMEA reference clock driver to support Accord\n GPS Clock.\n* poll time updates from Dave Mills.\n* local refclock documentation updates from Dave Mills.\n* [Bug 1022] Fix compilation problems with yesterday's commit.\n* Updates and cleanup from Dave Mills:\n I've now spent eleven months of a sabbatical year - 7 days a week, 6-10\n hours most days - working on NTP. I have carefully reviewed every major\n algorithm, examined its original design and evolution from that design.\n I've trimmed off dead code and briar patches and did zillions of tests\n contrived to expose evil vulnerabilities. The development article is in\n rather good shape and should be ready for prime time.",
" 1. The protostats statistics files have been very useful in exposing\n little twitches and turns when something hiccups, like a broken PPS\n signal. Most of what used to be syslog messages are now repackaged as\n protostats messages with optional syslog as well. These can also be sent\n as traps which might be handy to tiggle a beeper or celltext. These, the\n sysstats files and cryptostats files reveal the ambient health of a busy\n server, monitor traffic and error counts and spot crypto attacks.",
" 2. Close inspection of the clock discipline behavior at long poll\n intervals (36 h) showed it not doing as well as it should. I redesigned\n the FLL loop to improve nominal accuracy from several tens of\n milliseconds to something less than ten milliseconds.",
" 3. Autokey (again). The enhanced error checking was becoming a major\n pain. I found a way to toss out gobs of ugly fat code and replace the\n function with a much simpler and more comprehensive scheme. It resists\n bait-and-switch attacks and quickly detect cases when the protocol is\n not correctly synchronized.",
" 4. The interface code for the kernel PPS signal was not in sync with the\n kernel code itself. Some error checks were duplicated and some\n ineffective. I found none of the PPS-capable drivers, including the atom\n driver, do anything when the prefer peer fails; the kernel PPS signal\n remains in control. The atom driver now disables the kernel PPS when the\n prefer peer comes bum. This is important when the prefer peer is not a\n reference clock but a remote NTP server.",
" 5. The flake restrict bit turned out to be really interesting,\n especially with symmtric modes and of those especially those using\n Autokey. Small changes in the recovery procedures when packets are lost\n now avoid almost all scenarios which previously required protocol resets.",
" 6. I've always been a little uncomfortable when using the clock filter\n with long poll intervals because the samples become less and less\n correlated as the sample age exceeds the Allan intercept. Various\n schemes have been used over the years to cope with this fact. The latest\n one and the one that works the best is to use a modified sort metric\n where the delay is used when the age of the sample is less than the\n intercept and the sum of delay and dispersion above that. The net result\n is that, at small poll intervals the algorithm operates as a minimum\n filter, while at larger poll intervals it morphs to FIFO. Left\n unmodified, a sample could be used when twelve days old. This along with\n the FLL modifications has made a dramatic improvement at large poll\n intervals.",
"- [Backward Incompatible] The 'state' variable is no longer reported or\n available via ntpq output. The following system status bit names\n have been changed:\n - sync_alarm -> leap_alarm\n - sync_atomic -> sync_pps\n - sync_lf_clock -> sync_lf_radio\n - sync_hf_clock -> sync_hf_radio\n - sync_uhf_clock -> sync_uhf_radio\n - sync_local_proto -> sync_local\n - sync_udp/time -> sync_other\n Other names have been changed as well. See the change history for\n libntp/statestr.c for more details.\n Other backward-incompatible changes in ntpq include:\n - assID -> associd\n - rootdispersion -> rootdisp\n - pkt_head -> pkt_neader\n See the change history for other details.",
"* Updates and cleanup from Dave Mills.\n* [Bug 995] Remove spurious ; from ntp-keygen.c.\n* More cleanup and changes from Dave Mills.\n* [Bug 980] Direct help to stdout.\n---\n(4.2.4p8) 2009/12/08 Released by Harlan Stenn <stenn@ntp.org>",
"* [Sec 1331] DoS with mode 7 packets - CVE-2009-3563.",
"---\n(4.2.4p7) 2009/05/18 Released by Harlan Stenn <stenn@ntp.org>",
"* [Sec 1151] Remote exploit if autokey is enabled - CVE-2009-1252.\n* [Bug 1187] Update the copyright date.\n* [Bug 1191] ntpd fails on Win2000 - \"Address already in use\" after fix\n for [Sec 1149].",
"---\n(4.2.4p7-RC7) 2009/05/12 Released by Harlan Stenn <stenn@ntp.org>",
"* ntp.isc.org -> ntp.org cleanup.\n* [Bug 1178] Use prior FORCE_DNSRETRY behavior as needed at runtime,\n add configure --enable-ignore-dns-errors to be even more stubborn",
"---\n(4.2.4p7-RC6) 2009/05/08 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 784] Make --enable-linuxcaps the default when available\n* [Bug 1179] error messages for -u/--user and -i lacking droproot\n* Updated JJY reference clock driver from Takao Abe\n* [Bug 1071] Log a message and exit before trying to use FD_SET with a\n descriptor larger than FD_SETSIZE, which will corrupt memory\n* On corruption of the iface list head in add_interface, log and exit",
"---\n(4.2.4p7-RC5) 2009/05/02 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1172] 4.2.4p7-RC{3,4} fail to build on linux.\n* flock-build script unportable 'set -m' use removed",
"---\n(4.2.4p7-RC4) 2009/04/29 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1167] use gcc -Winit-self only if it is understood",
"---\n(4.2.4p7-RC3) 2009/04/22 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 787] Bug fixes for 64-bit time_t on Windows\n* [Bug 813] Conditional naming of Event\n* [Bug 1147] System errors should be logged to msyslog()\n* [Bug 1155] Fix compile problem on Windows with VS2005\n* [Bug 1156] lock_thread_to_processor() should be declared in header\n* [Bug 1157] quiet OpenSSL warnings, clean up configure.ac\n* [Bug 1158] support for aix6.1\n* [Bug 1160] MacOS X is like BSD regarding F_SETOWN",
"---\n(4.2.4p7-RC2) 2009/04/09 Released by Harlan Stenn <stenn@ntp.org>",
"* [Sec 1144] limited buffer overflow in ntpq. CVE-2009-0159\n* [Sec 1149] use SO_EXCLUSIVEADDRUSE on Windows",
"---\n(4.2.4p7-RC1) 2009/03/30 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1131] UDP sockets should not use SIGPOLL on Solaris.\n* build system email address cleanup\n* [Bug 774] parsesolaris.c does not compile under the new Solaris\n* [Bug 873] Windows serial refclock proper TTY line discipline emulation\n* [Bug 1014] Enable building with VC9 (in Visual Studio 2008,\n Visual C++ 2008, or SDK)\n* [Bug 1117] Deferred interface binding under Windows works only correctly\n if FORCE_DNSRETRY is defined\n* [BUG 1124] Lock QueryPerformanceCounter() client threads to same CPU\n* DPRINTF macro made safer, always evaluates to a statement and will not\n misassociate an else which follows the macro.",
"---\n(4.2.4p6) 2009/01/08 Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 1113] Fixed build errors with recent versions of openSSL. \n* [Sec 1111] Fix incorrect check of EVP_VerifyFinal()'s return value.\n* Update the copyright year.",
"---\n(4.2.4p5) 2008/08/17 Released by Harlan Stenn <stenn@ntp.org>",
"* [BUG 1051] Month off by one in leap second message written to clockstats\n file fixed.\n* [Bug 450] Windows only: Under original Windows NT we must not discard the\n wildcard socket to workaround a bug in NT's getsockname().\n* [Bug 1038] Built-in getpass() function also prompts for password if\n not built with DEBUG.\n* [Bug 841] Obsolete the \"dynamic\" keyword and make deferred binding\n to local interfaces the default.\n Emit a warning if that keyword is used for configuration.\n* [Bug 959] Refclock on Windows not properly releasing recvbuffs.\n* [Bug 993] Fix memory leak when fetching system messages.\n* much cleanup, fixes, and changes from Dave Mills.\n* ntp_control.c: LEAPTAB is a filestamp, not an unsigned. From Dave Mills.\n* ntp_config.c: ntp_minpoll fixes from Dave Mills.\n* ntp-keygen updates from Dave Mills.\n* refresh epoch, throttle, and leap cleanup from Dave Mills.\n* Documentation cleanup from Dave Mills.\n* [Bug 918] Only use a native md5.h if MD5Init() is available.\n* [Bug 979] Provide ntptimeval if it is not otherwise present.\n* [Bug 634] Re-instantiate syslog() and logfiles after the daemon fork.\n* [Bug 952] Use md5 code with a friendlier license.\n* [Bug 977] Fix mismatching #ifdefs for builds without IPv6.\n* [Bug 830] Fix the checking order of the interface options.\n* Clean up the logfile/syslog setup.\n* [Bug 970] Lose obsolete -g flag to ntp-keygen.\n* The -e flag to ntp-keygen can write GQ keys now, too.\n* ntp_proto.c: sys_survivors and hpoll cleanup from Dave Mills.\n* ntp_loopfilter.c: sys_poll cleanup from Dave Mills.\n* refclock_wwv.c: maximum-likelihood digit and DSYNC fixes from Dave Mills.\n* [Bug 967] preemptable associations are lost forever on a step.\n* ntp_config.c: [CID 48] missing \"else\" clause.\n* [Bug 833] ntpq config keyword is quote-mark unfriendly.\n* Rename the ntpq \"config\" keyword to \":config\".\n* Dave Mills shifted some orphan processing.\n* Fix typos in the [Bug 963] patch.\n* bootstrap: squawk if genver fails. Use -f with cp in case Dave does a chown.\n* Remove obsolete simulator command-line options.\n* ntp_request.c: [CID 36] zero sin_zero.\n* [Bug 963] get_systime() is too noisy.\n* [Bug 960] spurious syslog:crypto_setup:spurious crypto command\n* [Bug 964] Change *-*-linux* to *-*-*linux* to allow for uclinux.\n* Changes from Dave Mills:\n - ntp_util.c: cleanup.\n - ntp_timer.c: watch the non-burst packet rate.\n - ntp_request.c: cleanup.\n - ntp_restrict.c: RES_LIMITED cleanup.\n - ntp_proto.c: RES_LIMITED, rate bucktes, counters, overall cleanup.\n - ntp_peer.c: disallow peer_unconfig().\n - ntp_monitor.c: RES_LIMITED cleanup.\n - ntp_loopfilter.c: poll interval cleanup.\n - ntp_crypto.c: volley -> retry. Cleanup TAI leap message.\n - ntp_config: average and minimum are ^2 values.\n - ntpdc: unknownversion is really \"declined\", not \"bad version\".\n - Packet retry cleanup.\n* [Bug 961] refclock_tpro.c:tpro_poll() calls refclock_receive() twice.\n* [Bug 957] Windows only: Let command line parameters from the Windows SCM GUI\n override the standard parameters from the ImagePath registry key.\n* Added HAVE_INT32_T to the Windows config.h to avoid duplicate definitions.\n* Work around a VPATH difference in FreeBSD's 'make' command.\n* Update bugreport URL.\n* Update -I documentation.\n* [Bug 713] Fix bug reporting information.\n* A bug in the application of the negative-sawtooth for 12 channel receivers. \n* The removal of unneeded startup code used for the original LinuxPPS, it now\n conforms to the PPSAPI and does not need special code. \n* ntp-keygen.c: Coverity fixes [CID 33,47].\n* Volley cleanup from Dave Mills.\n* Fuzz cleanup from Dave Mills.\n* [Bug 861] Leap second cleanups from Dave Mills.\n* ntpsim.c: add missing protypes and fix [CID 34], a nit.\n* Upgraded bison at UDel.\n* Update br-flock and flock-build machine lists.\n* [Bug 752] QoS: add parse/config handling code. \n* Fix the #include order in tickadj.c for picky machines.\n* [Bug 752] QoS: On some systems, netinet/ip.h needs netinet/ip_systm.h.\n* [Bug 752] Update the QoS tagging (code only - configuration to follow).\n* Orphan mode and other protocol cleanup from Dave Mills.\n* Documentation cleanup from Dave Mills.\n* [Bug 940] ntp-keygen uses -v. Disallow it as a shortcut for --version.\n* more cleanup to ntp_lineeditlibs.m4.\n* Documentation updates from Dave Mills.\n* -ledit cleanup for ntpdc and ntpq.\n* Association and other cleanup from Dave Mills.\n* NTP_UNREACH changes from Dave Mills.\n* Fix the readline history test.\n* [Bug 931] Require -lreadline to be asked for explicitly.\n* [Bug 764] When looking for -lreadline support, also try using -lncurses.\n* [Bug 909] Fix int32_t errors for ntohl().\n* [Bug 376/214] Enhancements to support multiple if names and IP addresses.\n* [Bug 929] int32_t is undefined on Windows. Casting wrong.\n* [Bug 928] readlink missing braces.\n* [Bug 788] Update macros to support VS 2005.\n* ntpd/ntp_timer.c: add missing sys_tai parameter for debug printf\n* [Bug 917] config parse leaves files open\n* [Bug 912] detect conflicting enable/disable configuration on interfaces\n sharing an IP address\n* [Bug 771] compare scopeid if available for IPv6 addresses\n* Lose obsolete crypto subcommands (Dave Mills).\n* WWV is an HF source, not an LF source (Dave Mills).\n* [Bug 899] Only show -i/--jaildir -u/--user options if we HAVE_DROPROOT.\n* [Bug 916] 'cryptosw' is undefined if built without OpenSSL.\n* [Bug 891] 'restrict' config file keyword does not work (partial fix).\n* [Bug 890] the crypto command seems to be required now.\n* [Bug 915] ntpd cores during processing of x509 certificates.\n* Crypto lint cleanup from Dave Mills.\n* [Bug 897] Check RAND_status() - we may not need a .rnd file.\n* Crypto cleanup from Dave Mills.\n* [Bug 911] Fix error message in cmd_args.c.\n* [Bug 895] Log assertion failures via syslog(), not stderr.\n* Documentation updates from Dave Mills.\n* Crypto cleanup from Dave Mills.\n* [Bug 905] ntp_crypto.c fails to compile without -DDEBUG.\n* Avoid double peer stats logging.\n* ntp-keygen cleanup from Dave Mills.\n* libopts needs to be built after ElectricFence.\n* [Bug 894] Initialize keysdir before calling crypto_setup().\n* Calysto cleanup for ntpq.\n* ntp-keygen -i takes an arg.\n* Cleanup and fixes from Dave Mills.\n* [Bug 887] Fix error in ntp_types.h (for sizeof int != 4).\n* Bug 880 bug fixes for Windows build\n* Improve Calysto support.\n* The \"revoke\" parameter is a crypto command.\n* The driftfile wander threshold is a real number.\n* [Bug 850] Fix the wander threshold parameter on the driftfile command.\n* ntp_io.c: Dead code cleanup - Coverity View 19.\n* Leap file related cleanup from Dave Mills.\n* ntp_peer.c: Set peer->srcadr before (not after) calling set_peerdstadr().\n* Initialize offset in leap_file() - Coverity View 17.\n* Use the correct stratum on KISS codes.\n* Fuzz bits cleanup.\n* Show more digits in some debug printf's.\n* Use drift_file_sw internally to control writing the drift file.\n* Implement the wander_threshold option for the driftfile config keyword.\n* reformat ntp_control.c; do not use c++ // comments.\n* [Bug 629] Undo bug #629 fixes as they cause more problems than were being\n solved\n* Changes from Dave Mills: in/out-bound data rates, leapsecond cleanup,\n driftfile write cleanup, packet buffer length checks, documentation updates.\n* More assertion checks and malloc()->emalloc(), courtesy of Calysto.\n* [Bug 864] Place ntpd service in maintenance mode if using SMF on Solaris\n* [Bug 862] includefile nesting; preserve phonelist on reconfig.\n* [Bug 604] ntpd regularly dies on linux/alpha.\n* more leap second infrastructure fixes from Dave Mills.\n* [Bug 858] recent leapfile changes broke non-OpenSSL builds.\n* Use emalloc() instead of malloc() in refclock_datum.c (Calysto).\n* Start using 'design by contract' assertions.\n* [Bug 767] Fast sync to refclocks wanted.\n* Allow null driftfile.\n* Use YYERROR_VERBOSE for the new parser, and fix related BUILT_SOURCES.\n* [Bug 629] changes to ensure broadcast works including on wildcard addresses\n* [Bug 853] get_node() must return a pointer to maximally-aligned memory.\n* Initial leap file fixes from Dave Mills.\n* [Bug 858] Recent leapfile changes broke without OPENSSL.\n* Use a char for DIR_SEP, not a string.\n* [Bug 850] driftfile parsing changes.\n* driftfile maintenance changes from Dave Mills. Use clock_phi instead of\n stats_write_tolerance.\n* [Bug 828] refid string not being parsed correctly.\n* [Bug 846] Correct includefile parsing.\n* [Bug 827] New parsing code does not handle \"fudge\" correctly.\n* Enable debugging capability in the config parser.\n* [Bug 839] Crypto password not read from ntp.conf.\n* Have autogen produce writable output files.\n* [Bug 825] Correct logconfig -/+ keyword processing.\n* [Bug 828] Correct parsing of \" delimited strings.\n* Cleanup FILE * usage after fclose() in ntp_filegen.c.\n* [Bug 843] Windows Completion port code was incorrectly merged from -stable.\n* [Bug 840] do fudge configuration AFTER peers (thus refclocks) have been\n configured.\n* [Bug 824] Added new parser modules to the Windows project file.\n* [Bug 832] Add libisc/log.c headers to the distribution.\n* [Bug 808] Only write the drift file if we are in state 4.\n* Initial import of libisc/log.c and friends.\n* [Bug 826] Fix redefinition of PI.\n* [Bug 825] ntp_scanner.c needs to #include <config.h> .\n* [Bug 824] New parser code has some build problems with the SIM code.\n* [Bug 817] Use longnames for setting ntp variables on the command-line;\n Allowing '-v' with and without an arg to disambiguate usage is error-prone.\n* [Bug 822] set progname once, early.\n* [Bug 819] remove erroneous #if 0 in Windows completion port code.\n* The new config code missed an #ifdef for building without refclocks.\n* Distribute some files needed by the new config parsing code.\n* [Bug 819] Timeout for WaitForMultipleObjects was 500ms instead of INFINITE\n* Use autogen 5.9.1.\n* Fix clktest command-line arg processing.'\n* Audio documentation updates from Dave Mills.\n* New config file parsing code, from Sachin Kamboj.\n* fuzz bit cleanup from Dave Mills.\n* replay cleanup from Dave Mills.\n* [Bug 542] Tolerate missing directory separator at EO statsdir.\n* [Bug 812] ntpd should drop supplementary groups.\n* [Bug 815] Fix warning compiling 4.2.5p22 under Windows with VC6.\n* [Bug 740] Fix kernel/daemon startup drift anomaly.\n* refclock_wwv.c fixes from Dave Mills.\n* [Bug 810] Fix ntp-keygen documentation.\n* [Bug 787] Bug fixes for 64-bit time_t on Windows.\n* [Bug 796] Clean up duplicate #defines in ntp_control.c.\n* [Bug 569] Use the correct precision for the Leitch CSD-5300.\n* [Bug 795] Moved declaration of variable to top of function.\n* [Bug 798] ntpq [p typo crashes ntpq/ntpdc.\n* [Bug 786] Fix refclock_bancomm.c on Solaris.\n* [Bug 774] parsesolaris.c does not compile under the new Solaris.\n* [Bug 782] Remove P() macros from Windows files.\n* [Bug 778] ntpd fails to lock with drift=+500 when started with drift=-500.\n* [Bug 592] Trimble Thunderbolt GPS support.\n* IRIG, CHU, WWV, WWVB refclock improvements from Dave Mills.\n* [Bug 757] Lose ULONG_CONST().\n* [Bug 756] Require ANSI C (function prototypes).\n* codec (audio) and ICOM changes from Dave Mills.",
"---",
"* [Bug 450] Windows only: Under original Windows NT we must not discard the\n wildcard socket to workaround a bug in NT's getsockname().\n* [Bug 1038] Built-in getpass() function also prompts for password if\n not built with DEBUG.\n* [Bug 841] Obsolete the \"dynamic\" keyword and make deferred binding\n to local interfaces the default.\n Emit a warning if that keyword is used for configuration.\n* [Bug 959] Refclock on Windows not properly releasing recvbuffs.\n* [Bug 993] Fix memory leak when fetching system messages.\n* [Bug 987] Wake up the resolver thread/process when a new interface has\n become available.\n* Correctly apply negative-sawtooth for oncore 12 channel receiver.\n* Startup code for original LinuxPPS removed. LinuxPPS now conforms to\n the PPSAPI.\n* [Bug 1000] allow implicit receive buffer allocation for Windows.\n fixes startup for windows systems with many interfaces.\n reduces dropped packets on network bursts.\n additionally fix timer() starvation during high load.\n* [Bug 990] drop minimum time restriction for interface update interval.\n* [Bug 977] Fix mismatching #ifdefs for builds without IPv6.\n* Update the copyright year.\n* Build system cleanup (make autogen-generated files writable).\n* [Bug 957] Windows only: Let command line parameters from the Windows SCM GUI\n override the standard parameters from the ImagePath registry key.\n* Fixes for ntpdate:\n* [Bug 532] nptdate timeout is too long if several servers are supplied.\n* [Bug 698] timeBeginPeriod is called without timeEndPeriod in some NTP tools.\n* [Bug 857] ntpdate debug mode adjusts system clock when it shouldn't.\n* [Bug 908] ntpdate crashes sometimes.\n* [Bug 982] ntpdate(and ntptimeset) buffer overrun if HAVE_POLL_H isn't set\n (dup of 908).\n* [Bug 997] ntpdate buffer too small and unsafe.\n* ntpdate.c: Under Windows check whether NTP port in use under same conditions\n as under other OSs.\n* ntpdate.c: Fixed some typos and indents (tabs/spaces).",
"(4.2.4p4) Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 902] Fix problems with the -6 flag.\n* Updated include/copyright.def (owner and year).\n* [Bug 878] Avoid ntpdc use of refid value as unterminated string.\n* [Bug 881] Corrected display of pll offset on 64bit systems.\n* [Bug 886] Corrected sign handling on 64bit in ntpdc loopinfo command.\n* [Bug 889] avoid malloc() interrupted by SIGIO risk\n* ntpd/refclock_parse.c: cleanup shutdown while the file descriptor is still\n open.\n* [Bug 885] use emalloc() to get a message at the end of the memory\n unsigned types cannot be less than 0\n default_ai_family is a short\n lose trailing , from enum list\n clarify ntp_restrict.c for easier automated analysis\n* [Bug 884] don't access recv buffers after having them passed to the free\n list.\n* [Bug 882] allow loopback interfaces to share addresses with other\n interfaces.",
"---\n(4.2.4p3) Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 863] unable to stop ntpd on Windows as the handle reference for events\n changed",
"---\n(4.2.4p2) Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 854] Broadcast address was not correctly set for interface addresses\n* [Bug 829] reduce syslog noise, while there fix Enabled/Disable logging\n to reflect the actual configuration.\n* [Bug 795] Moved declaration of variable to top of function.\n* [Bug 789] Fix multicast client crypto authentication and make sure arriving\n multicast packets do not disturb the autokey dance.\n* [Bug 785] improve handling of multicast interfaces\n (multicast routers still need to run a multicast routing software/daemon)\n* ntpd/refclock_parse.c: cleanup shutdown while the file descriptor is still\n open.\n* [Bug 885] use emalloc() to get a message at the end of the memory\n unsigned types cannot be less than 0\n default_ai_family is a short\n lose trailing , from enum list\n* [Bug 884] don't access recv buffers after having them passed to the free list.\n* [Bug 882] allow loopback interfaces to share addresses with other interfaces.\n* [Bug 527] Don't write from source address length to wrong location\n* Upgraded autogen and libopts.\n* [Bug 811] ntpd should not read a .ntprc file.",
"---\n(4.2.4p1) (skipped)",
"---\n(4.2.4p0) Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 793] Update Hans Lambermont's email address in ntpsweep.\n* [Bug 776] Remove unimplemented \"rate\" flag from ntpdate.\n* [Bug 586] Avoid lookups if AI_NUMERICHOST is set.\n* [Bug 770] Fix numeric parameters to ntp-keygen (Alain Guibert).\n* [Bug 768] Fix io_setbclient() error message.\n* [Bug 765] Use net_bind_service capability on linux.\n* [Bug 760] The background resolver must be aware of the 'dynamic' keyword.\n* [Bug 753] make union timestamp anonymous (Philip Prindeville).\n* confopt.html: move description for \"dynamic\" keyword into the right section.\n* pick the right type for the recv*() length argument.",
"---\n(4.2.4) Released by Harlan Stenn <stenn@ntp.org>",
"* monopt.html fixes from Dave Mills.\n* [Bug 452] Do not report kernel PLL/FLL flips.\n* [Bug 746] Expert mouseCLOCK USB v2.0 support added.'\n* driver8.html updates.\n* [Bug 747] Drop <NOBR> tags from ntpdc.html.\n* sntp now uses the returned precision to control decimal places.\n* sntp -u will use an unprivileged port for its queries.\n* [Bug 741] \"burst\" doesn't work with !unfit peers.\n* [Bug 735] Fix a make/gmake VPATH issue on Solaris.\n* [Bug 739] ntpd -x should not take an argument.\n* [Bug 737] Some systems need help providing struct iovec.\n* [Bug 717] Fix libopts compile problem.\n* [Bug 728] parse documentation fixes.\n* [Bug 734] setsockopt(..., IP_MULTICAST_IF, ...) fails on 64-bit platforms.\n* [Bug 732] C-DEX JST2000 patch from Hideo Kuramatsu.\n* [Bug 721] check for __ss_family and __ss_len separately.\n* [Bug 666] ntpq opeers displays jitter rather than dispersion.\n* [Bug 718] Use the recommended type for the saddrlen arg to getsockname().\n* [Bug 715] Fix a multicast issue under Linux.\n* [Bug 690] Fix a Windows DNS lookup buffer overflow.\n* [Bug 670] Resolved a Windows issue with the dynamic interface rescan code.\n* K&R C support is being deprecated.\n* [Bug 714] ntpq -p should conflict with -i, not -c.\n* WWV refclock improvements from Dave Mills.\n* [Bug 708] Use thread affinity only for the clock interpolation thread.\n* [Bug 706] ntpd can be running several times in parallel.\n* [Bug 704] Documentation typos.\n* [Bug 701] coverity: NULL dereference in ntp_peer.c\n* [Bug 695] libopts does not protect against macro collisions.\n* [Bug 693] __adjtimex is independent of ntp_{adj,get}time.\n* [Bug 692] sys_limitrejected was not being incremented.\n* [Bug 691] restrictions() assumption not always valid.\n* [Bug 689] Deprecate HEATH GC-1001 II; the driver never worked.\n* [Bug 688] Fix documentation typos.\n* [Bug 686] Handle leap seconds better under Windows.\n* [Bug 685] Use the Windows multimedia timer.\n* [Bug 684] Only allow debug options if debugging is enabled.\n* [Bug 683] Use the right version string.\n* [Bug 680] Fix the generated version string on Windows.\n* [Bug 678] Use the correct size for control messages.\n* [Bug 677] Do not check uint_t in configure.ac.\n* [Bug 676] Use the right value for msg_namelen.\n* [Bug 675] Make sure ntpd builds without debugging.\n* [Bug 672] Fix cross-platform structure padding/size differences.\n* [Bug 660] New TIMESTAMP code fails tp build on Solaris Express.\n* [Bug 659] libopts does not build under Windows.\n* [Bug 658] HP-UX with cc needs -Wp,-H8166 in CFLAGS.\n* [Bug 656] ntpdate doesn't work with multicast address.\n* [Bug 638] STREAMS_TLI is deprecated - remove it.\n* [Bug 635] Fix tOptions definition.\n* [Bug 628] Fallback to ntp discipline not working for large offsets.\n* [Bug 622] Dynamic interface tracking for ntpd.\n* [Bug 603] Don't link with libelf if it's not needed.\n* [Bug 523] ntpd service under Windows does't shut down properly.\n* [Bug 500] sntp should always be built.\n* [Bug 479] Fix the -P option.\n* [Bug 421] Support the bc637PCI-U card.\n* [Bug 342] Deprecate broken TRAK refclock driver.\n* [Bug 340] Deprecate broken MSF EES refclock driver.\n* [Bug 153] Don't do DNS lookups on address masks.\n* [Bug 143] Fix interrupted system call on HP-UX.\n* [Bug 42] Distribution tarballs should be signed.\n* Support separate PPS devices for PARSE refclocks.\n* [Bug 637, 51?] Dynamic interface scanning can now be done.\n* Options processing now uses GNU AutoGen.",
"---\n(4.2.2p4) Released by Harlan Stenn <stenn@ntp.org>",
"* [Bug 710] compat getnameinfo() has off-by-one error\n* [Bug 690] Buffer overflow in Windows when doing DNS Lookups",
"---\n(4.2.2p3) Released by Harlan Stenn <stenn@ntp.org>",
"* Make the ChangeLog file cleaner and easier to read\n* [Bug 601] ntpq's decodeint uses an extra level of indirection\n* [Bug 657] Different OSes need different sized args for IP_MULTICAST_LOOP\n* release engineering/build changes\n* Documentation fixes\n* Get sntp working under AIX-5",
"---\n(4.2.2p2) (broken)",
"* Get sntp working under AIX-5",
"---\n(4.2.2p1)",
"* [Bug 661] Use environment variable to specify the base path to openssl.\n* Resolve an ambiguity in the copyright notice\n* Added some new documentation files\n* URL cleanup in the documentation\n* [Bug 657]: IP_MULTICAST_LOOP uses a u_char value/size\n* quiet gcc4 complaints\n* more Coverity fixes\n* [Bug 614] manage file descriptors better\n* [Bug 632] update kernel PPS offsets when PPS offset is re-configured\n* [Bug 637] Ignore UP in*addr_any interfaces\n* [Bug 633] Avoid writing files in srcdir\n* release engineering/build changes",
"---\n(4.2.2)",
"* SNTP\n* Many bugfixes\n* Implements the current \"goal state\" of NTPv4\n* Autokey improvements\n* Much better IPv6 support\n* [Bug 360] ntpd loses handles with LAN connection disabled.\n* [Bug 239] Fix intermittent autokey failure with multicast clients.\n* Rewrite of the multicast code\n* New version numbering scheme",
"---\n(4.2.0)",
"* More stuff than I have time to document\n* IPv6 support\n* Bugfixes\n* call-gap filtering\n* wwv and chu refclock improvements\n* OpenSSL integration",
"---\n(4.1.2)",
"* clock state machine bugfix\n* Lose the source port check on incoming packets\n* (x)ntpdc compatibility patch\n* Virtual IP improvements\n* ntp_loopfilter fixes and improvements\n* ntpdc improvements\n* GOES refclock fix\n* JJY driver\n* Jupiter refclock fixes\n* Neoclock4X refclock fixes\n* AIX 5 port\n* bsdi port fixes\n* Cray unicos port upgrade\n* HP MPE/iX port\n* Win/NT port upgrade\n* Dynix PTX port fixes\n* Document conversion from CVS to BK\n* readline support for ntpq",
"---\n(4.1.0)",
"* CERT problem fixed (99k23)",
"* Huff-n-Puff filter\n* Preparation for OpenSSL support\n* Resolver changes/improvements are not backward compatible with mode 7\n requests (which are implementation-specific anyway)\n* leap second stuff\n* manycast should work now\n* ntp-genkeys does new good things.\n* scripts/ntp-close\n* PPS cleanup and improvements\n* readline support for ntpdc\n* Crypto/authentication rewrite\n* WINNT builds with MD5 by default\n* WINNT no longer requires Perl for building with Visual C++ 6.0\n* algorithmic improvements, bugfixes\n* Solaris dosynctodr info update\n* html/pic/* is *lots* smaller\n* New/updated drivers: Forum Graphic GPS, WWV/H, Heath GC-100 II, HOPF\n serial and PCI, ONCORE, ulink331\n* Rewrite of the audio drivers",
"---\n(4.0.99)",
"* Driver updates: CHU, DCF, GPS/VME, Oncore, PCF, Ulink, WWVB, burst\n If you use the ONCORE driver with a HARDPPS kernel module,\n you *must* have a properly specified:\n\tpps <filename> [assert/clear] [hardpps]\n line in the /etc/ntp.conf file.\n* PARSE cleanup\n* PPS cleanup\n* ntpd, ntpq, ntpdate cleanup and fixes\n* NT port improvements\n* AIX, BSDI, DEC OSF, FreeBSD, NetBSD, Reliant, SCO, Solaris port improvements",
"---\n(4.0.98)",
"* Solaris kernel FLL bug is fixed in 106541-07\n* Bug/lint cleanup\n* PPS cleanup\n* ReliantUNIX patches\n* NetInfo support\n* Ultralink driver\n* Trimble OEM Ace-II support\n* DCF77 power choices\n* Oncore improvements",
"---\n(4.0.97)",
"* NT patches\n* AIX,SunOS,IRIX portability\n* NeXT portability\n* ntptimeset utility added\n* cygwin portability patches",
"---\n(4.0.96)",
"* -lnsl, -lsocket, -lgen configuration patches\n* Y2K patches from AT&T\n* Linux portability cruft",
"---\n(4.0.95)",
"* NT port cleanup/replacement\n* a few portability fixes\n* VARITEXT Parse clock added",
"---\n(4.0.94)",
"* PPS updates (including ntp.config options)\n* Lose the old DES stuff in favor of the (optional) RSAREF stuff\n* html cleanup/updates\n* numerous drivers cleaned up\n* numerous portability patches and code cleanup",
"---\n(4.0.93)",
"* Oncore refclock needs PPS or one of two ioctls.\n* Don't make ntptime under Linux. It doesn't compile for too many folks.\n* Autokey cleanup\n* ReliantUnix patches\n* html cleanup\n* tickadj cleanup\n* PARSE cleanup\n* IRIX -n32 cleanup\n* byte order cleanup\n* ntptrace improvements and patches\n* ntpdc improvements and patches\n* PPS cleanup\n* mx4200 cleanup\n* New clock state machine\n* SCO cleanup\n* Skip alias interfaces",
"---\n(4.0.92)",
"* chronolog and dumbclock refclocks\n* SCO updates\n* Cleanup/bugfixes\n* Y2K patches\n* Updated palisade driver\n* Plug memory leak\n* wharton kernel clock\n* Oncore clock upgrades\n* NMEA clock improvements\n* PPS improvements\n* AIX portability patches",
"---\n(4.0.91)",
"* New ONCORE driver\n* New MX4200 driver\n* Palisade improvements\n* config file bugfixes and problem reporting\n* autoconf upgrade and cleanup\n* HP-UX, IRIX lint cleanup\n* AIX portability patches\n* NT cleanup",
"---\n(4.0.90)",
"* Nanoseconds\n* New palisade driver\n* New Oncore driver",
"---\n(4.0.73)",
"* README.hackers added\n* PARSE driver is working again\n* Solaris 2.6 has nasty kernel bugs. DO NOT enable pll!\n* DES is out of the distribution.",
"---\n(4.0.72)",
"* K&R C compiling should work again.\n* IRIG patches.\n* MX4200 driver patches.\n* Jupiter driver added.\n* Palisade driver added. Needs work (ANSI, ntoh/hton, sizeof double, ???)"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1, 163], "buggy_code_start_loc": [1, 159], "filenames": ["ChangeLog", "include/ntp.h"], "fixing_code_end_loc": [3, 162], "fixing_code_start_loc": [2, 159], "message": "The ULOGTOD function in ntp.d in SNTP before 4.2.7p366 does not properly perform type conversions from a precision value to a double, which allows remote attackers to cause a denial of service (infinite loop) via a crafted NTP packet.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:fedoraproject:fedora:21:*:*:*:*:*:*:*", "matchCriteriaId": "56BDB5A0-0839-4A20-A003-B8CD56F48171", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:22:*:*:*:*:*:*:*", "matchCriteriaId": "253C303A-E577-4488-93E6-68A8DD942C38", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:23:*:*:*:*:*:*:*", "matchCriteriaId": "E79AB8DD-C907-4038-A931-1A5A4CFB6A5B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:suse:linux_enterprise_debuginfo:11:sp2:*:*:*:*:*:*", "matchCriteriaId": "D5900A25-FDD7-4900-BF7C-F3ECCB714D2B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:suse:linux_enterprise_debuginfo:11:sp3:*:*:*:*:*:*", "matchCriteriaId": "58D3B6FD-B474-4B09-B644-A8634A629280", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:10:sp4:*:*:ltss:*:*:*", "matchCriteriaId": "35BBD83D-BDC7-4678-BE94-639F59281139", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:11:sp2:*:*:ltss:*:*:*", "matchCriteriaId": "CB6476C7-03F2-4939-AB85-69AA524516D9", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:11:sp3:*:*:ltss:*:*:*", "matchCriteriaId": "B12243B2-D726-404C-ABFF-F1AB51BA1783", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:manager:2.1:*:*:*:*:*:*:*", "matchCriteriaId": "2A33B9F5-E0D1-4A3E-9FFB-5602A25F3227", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:manager_proxy:2.1:*:*:*:*:*:*:*", "matchCriteriaId": "53F0F5A0-70D9-4305-A834-B6FF71E27B30", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:openstack_cloud:5:*:*:*:*:*:*:*", "matchCriteriaId": "88BCD7DC-0FEF-477D-8698-F8D8F1A49D90", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:redhat:enterprise_linux_desktop:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "EE249E1B-A1FD-4E08-AA71-A0E1F10FFE97", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_desktop:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "33C068A4-3780-4EAB-A937-6082DF847564", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_hpc_node:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "C2FAC325-6EEB-466D-9EBA-8ED4DBC9CFBF", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_hpc_node:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "3C84489B-B08C-4854-8A12-D01B6E45CF79", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "9BBCD86A-E6C7-4444-9D74-F861084090F0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "51EF4996-72F4-4FA4-814F-F5991E7A8318", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_workstation:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "E5ED5807-55B7-47C5-97A6-03233F4FBC3A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_workstation:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "825ECE2D-E232-46E0-A047-074B34DB1E97", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:debian:debian_linux:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "16F59A04-14CF-49E2-9973-645477EA09DA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:debian:debian_linux:8.0:*:*:*:*:*:*:*", "matchCriteriaId": "C11E6FB0-C8C0-4527-9AA0-CB9B316F8F43", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:canonical:ubuntu_linux:12.04:*:*:*:lts:*:*:*", "matchCriteriaId": "B6B7CAD7-9D4E-4FDB-88E3-1E583210A01F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:14.04:*:*:*:lts:*:*:*", "matchCriteriaId": "B5A6F2F3-4894-4392-8296-3B8DD2679084", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:15.04:*:*:*:*:*:*:*", "matchCriteriaId": "F38D3B7E-8429-473F-BB31-FC3583EE5A5B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:15.10:*:*:*:*:*:*:*", "matchCriteriaId": "E88A537F-F4D0-46B9-9E37-965233C2A355", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:ntp:ntp:*:p355:*:*:*:*:*:*", "matchCriteriaId": "07FBDFE4-D886-4461-A360-480F50BD12C7", "versionEndExcluding": null, "versionEndIncluding": "4.2.7", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:novell:leap:42.2:*:*:*:*:*:*:*", "matchCriteriaId": "A64AAD2D-38ED-4BA2-A27A-A2716F28D43A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:opensuse:leap:42.1:*:*:*:*:*:*:*", "matchCriteriaId": "4863BE36-D16A-4D75-90D9-FD76DB5B48B7", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:tim_4r-ie_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "E0730ED6-676B-4200-BC07-C0B4531B242C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:tim_4r-ie:-:*:*:*:*:*:*:*", "matchCriteriaId": "0B87B16C-9E9F-448B-9255-B2BB2B8CAD63", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:tim_4r-id_dnp3_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "B8851DB6-6B63-4D78-A100-50F81B4DF75B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:tim_4r-id_dnp3:-:*:*:*:*:*:*:*", "matchCriteriaId": "1A8AC343-6F4F-4CAF-BD09-F8F1D2F6DBB0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:oracle:linux:6:-:*:*:*:*:*:*", "matchCriteriaId": "D7B037A8-72A6-4DFF-94B2-D688A5F6F876", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}], "descriptions": [{"lang": "en", "value": "The ULOGTOD function in ntp.d in SNTP before 4.2.7p366 does not properly perform type conversions from a precision value to a double, which allows remote attackers to cause a denial of service (infinite loop) via a crafted NTP packet."}, {"lang": "es", "value": "La funci\u00f3n ULOGTOD en el archivo ntp.d en SNTP en versiones anteriores a la 4.2.7p366 no realiza apropiadamente las conversiones de tipo de un valor de precisi\u00f3n a uno doble, lo que permite a los atacantes remotos causar una denegaci\u00f3n de servicio (bucle infinito) por medio de un paquete NTP creado."}], "evaluatorComment": null, "id": "CVE-2015-5219", "lastModified": "2023-02-13T00:51:47.453", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 5.0, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:N/AC:L/Au:N/C:N/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2017-07-21T14:29:00.867", "references": [{"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://aix.software.ibm.com/aix/efixes/security/ntp_advisory4.asc"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "http://bk1.ntp.org/ntp-dev/?PAGE=patch&REV=51786731Gr4-NOrTBC_a_uXO4wuGhg"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-November/170926.html"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-October/169167.html"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-September/166992.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://rhn.redhat.com/errata/RHSA-2016-0780.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://rhn.redhat.com/errata/RHSA-2016-2583.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.debian.org/security/2015/dsa-3388"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2015/08/25/3"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.oracle.com/technetwork/topics/security/linuxbulletinapr2016-2952096.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/76473"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.ubuntu.com/usn/USN-2783-1"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking"], "url": "https://bugzilla.redhat.com/show_bug.cgi?id=1255118"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-497656.pdf"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/ntp-project/ntp/commit/5f295cd05c3c136d39f5b3e500a2d781bdbb59c8"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "US Government Resource"], "url": "https://us-cert.cisa.gov/ics/advisories/icsa-21-103-11"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=isg3T1024157"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21985122"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21986956"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21988706"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21989542"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www.ibm.com/support/home/docdisplay?lndocid=migr-5099409"}], "sourceIdentifier": "secalert@redhat.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-704"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/ntp-project/ntp/commit/5f295cd05c3c136d39f5b3e500a2d781bdbb59c8"}, "type": "CWE-704"}
| 357
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * ntp.h - NTP definitions for the masses\n */\n#ifndef NTP_H\n#define NTP_H",
"#include <stddef.h>\n#include <math.h>",
"#include <ntp_fp.h>\n#include <ntp_types.h>\n#include <ntp_lists.h>\n#include <ntp_stdlib.h>\n#include <ntp_crypto.h>\n#include <ntp_random.h>\n#include <ntp_net.h>",
"#include <isc/boolean.h>",
"/*\n * Calendar arithmetic - contributed by G. Healton\n */\n#define YEAR_BREAK 500\t\t/* years < this are tm_year values:\n\t\t\t\t * Break < AnyFourDigitYear && Break >\n\t\t\t\t * Anytm_yearYear */",
"#define YEAR_PIVOT 98\t\t/* 97/98: years < this are year 2000+\n\t\t\t\t * FYI: official UNIX pivot year is\n\t\t\t\t * 68/69 */",
"/*\n * Number of Days since 1 BC Gregorian to 1 January of given year\n */\n#define julian0(year)\t(((year) * 365 ) + ((year) > 0 ? (((year) + 3) \\\n\t\t\t / 4 - ((year - 1) / 100) + ((year - 1) / \\\n\t\t\t 400)) : 0))",
"/*\n * Number of days since start of NTP time to 1 January of given year\n */\n#define ntp0(year)\t(julian0(year) - julian0(1900))",
"/*\n * Number of days since start of UNIX time to 1 January of given year\n */\n#define unix0(year)\t(julian0(year) - julian0(1970))",
"/*\n * LEAP YEAR test for full 4-digit years (e.g, 1999, 2010)\n */\n#define isleap_4(y)\t((y) % 4 == 0 && !((y) % 100 == 0 && !(y % \\\n\t\t\t 400 == 0)))",
"/*\n * LEAP YEAR test for tm_year (struct tm) years (e.g, 99, 110)\n */\n#define isleap_tm(y)\t((y) % 4 == 0 && !((y) % 100 == 0 && !(((y) \\\n\t\t\t + 1900) % 400 == 0)))",
"/*\n * to convert simple two-digit years to tm_year style years:\n *\n *\tif (year < YEAR_PIVOT)\n *\t\tyear += 100;\n *\n * to convert either two-digit OR tm_year years to four-digit years:\n *\n *\tif (year < YEAR_PIVOT)\n *\t\tyear += 100;\n *\n *\tif (year < YEAR_BREAK)\n *\t\tyear += 1900;\n */",
"/*\n * How to get signed characters. On machines where signed char works,\n * use it. On machines where signed char doesn't work, char had better\n * be signed.\n */\n#ifdef NEED_S_CHAR_TYPEDEF\n# if SIZEOF_SIGNED_CHAR\ntypedef signed char s_char;\n# else\ntypedef char s_char;\n# endif\n /* XXX: Why is this sequent bit INSIDE this test? */\n# ifdef sequent\n# undef SO_RCVBUF\n# undef SO_SNDBUF\n# endif\n#endif",
"/*\n * NTP protocol parameters. See section 3.2.6 of the specification.\n */\n#define\tNTP_VERSION\t((u_char)4) /* current version number */\n#define\tNTP_OLDVERSION\t((u_char)1) /* oldest credible version */\n#define\tNTP_PORT\t123\t/* included for non-unix machines */",
"/*\n * Poll interval parameters\n */\n#define NTP_UNREACH\t10\t/* poll unreach threshold */\n#define\tNTP_MINPOLL\t3\t/* log2 min poll interval (8 s) */\n#define NTP_MINDPOLL\t6\t/* log2 default min poll (64 s) */\n#define NTP_MAXDPOLL\t10\t/* log2 default max poll (~17 m) */\n#define\tNTP_MAXPOLL\t17\t/* log2 max poll interval (~36 h) */\n#define\tNTP_RETRY\t3\t/* max packet retries */\n#define\tNTP_MINPKT\t2\t/* guard time (s) */",
"/*\n * Clock filter algorithm tuning parameters\n */\n#define MAXDISPERSE\t16.\t/* max dispersion */\n#define\tNTP_SHIFT\t8\t/* clock filter stages */\n#define NTP_FWEIGHT\t.5\t/* clock filter weight */",
"/*\n * Selection algorithm tuning parameters\n */\n#define\tNTP_MINCLOCK\t3\t/* min survivors */\n#define\tNTP_MAXCLOCK\t10\t/* max candidates */\n#define MINDISPERSE\t.001\t/* min distance */\n#define MAXDISTANCE\t1.5\t/* max root distance (select threshold) */\n#define CLOCK_SGATE\t3.\t/* popcorn spike gate */\n#define HUFFPUFF\t900\t/* huff-n'-puff sample interval (s) */\n#define MAXHOP\t\t2\t/* anti-clockhop threshold */\n#define MAX_TTL\t\t8\t/* max ttl mapping vector size */\n#define\tBEACON\t\t7200\t/* manycast beacon interval */\n#define NTP_MAXEXTEN\t2048\t/* max extension field size */\n#define\tNTP_ORPHWAIT\t300\t/* orphan wair (s) */",
"/*\n * Miscellaneous stuff\n */\n#define NTP_MAXKEY\t65535\t/* max authentication key number */\n#define\tKEY_TYPE_MD5\tNID_md5\t/* MD5 digest NID */\n/*\n * Limits of things\n */\n#define\tMAXFILENAME\t256\t/* max length of file name */\n#define MAXHOSTNAME\t512\t/* max length of host/node name */\n#define NTP_MAXSTRLEN\t256\t/* max string length */",
"/*\n * Operations for jitter calculations (these use doubles).\n *\n * Note that we carefully separate the jitter component from the\n * dispersion component (frequency error plus precision). The frequency\n * error component is computed as CLOCK_PHI times the difference between\n * the epoch of the time measurement and the reference time. The\n * precision component is computed as the square root of the mean of the\n * squares of a zero-mean, uniform distribution of unit maximum\n * amplitude. Whether this makes statistical sense may be arguable.\n */\n#define SQUARE(x) ((x) * (x))\n#define SQRT(x) (sqrt(x))\n#define DIFF(x, y) (SQUARE((x) - (y)))",
"#define LOGTOD(a)\t((a) < 0 ? 1. / (1L << -(a)) : \\\n\t\t\t 1L << (int)(a)) /* log2 to double */",
"#define UNIVAR(x)\t(SQUARE(.28867513 * LOGTOD(x))) /* std uniform distr */",
"#define ULOGTOD(a)\t(1L << (int)(a)) /* ulog2 to double */",
"\n#define\tEVENT_TIMEOUT\t0\t/* one second, that is */",
"\n/*\n * The interface structure is used to hold the addresses and socket\n * numbers of each of the local network addresses we are using.\n * Because \"interface\" is a reserved word in C++ and has so many\n * varied meanings, a change to \"endpt\" (via typedef) is under way.\n * Eventually the struct tag will change from interface to endpt_tag.\n * endpt is unrelated to the select algorithm's struct endpoint.\n */\ntypedef struct interface endpt;\nstruct interface {\n\tendpt *\t\telink;\t\t/* endpt list link */\n\tendpt *\t\tmclink;\t\t/* per-AF_* multicast list */\n\tSOCKET\t\tfd;\t\t/* socket descriptor */\n\tSOCKET\t\tbfd;\t\t/* for receiving broadcasts */\n\tu_int32\t\tifnum;\t\t/* endpt instance count */\n\tsockaddr_u\tsin;\t\t/* unicast address */\n\tsockaddr_u\tmask;\t\t/* subnet mask */\n\tsockaddr_u\tbcast;\t\t/* broadcast address */\n\tchar\t\tname[32];\t/* name of interface */\n\tu_short\t\tfamily;\t\t/* AF_INET/AF_INET6 */\n\tu_short\t\tphase;\t\t/* phase in update cycle */\n\tu_int32\t\tflags;\t\t/* interface flags */\n\tint\t\tlast_ttl;\t/* last TTL specified */\n\tu_int32\t\taddr_refid;\t/* IPv4 addr or IPv6 hash */\n\tint\t\tnum_mcast;\t/* mcast addrs enabled */\n\tu_long\t\tstarttime;\t/* current_time at creation */\n\tvolatile long\treceived;\t/* number of incoming packets */\n\tlong\t\tsent;\t\t/* number of outgoing packets */\n\tlong\t\tnotsent;\t/* number of send failures */\n\tu_int\t\tifindex;\t/* for IPV6_MULTICAST_IF */\n\tisc_boolean_t\tignore_packets; /* listen-read-drop this? */\n\tstruct peer *\tpeers;\t\t/* list of peers using endpt */\n\tu_int\t\tpeercnt;\t/* count of same */\n};",
"/*\n * Flags for interfaces\n */\n#define INT_UP\t\t0x001\t/* Interface is up */\n#define\tINT_PPP\t\t0x002\t/* Point-to-point interface */\n#define\tINT_LOOPBACK\t0x004\t/* the loopback interface */\n#define\tINT_BROADCAST\t0x008\t/* can broadcast out this interface */\n#define INT_MULTICAST\t0x010\t/* can multicast out this interface */\n#define\tINT_BCASTOPEN\t0x020\t/* broadcast receive socket is open */\n#define INT_MCASTOPEN\t0x040\t/* multicasting enabled */\n#define INT_WILDCARD\t0x080\t/* wildcard interface - usually skipped */\n#define INT_MCASTIF\t0x100\t/* bound directly to MCAST address */\n#define INT_PRIVACY\t0x200\t/* RFC 4941 IPv6 privacy address */\n#define INT_BCASTXMIT\t0x400 /* socket setup to allow broadcasts */",
"/*\n * Define flasher bits (tests 1 through 11 in packet procedure)\n * These reveal the state at the last grumble from the peer and are\n * most handy for diagnosing problems, even if not strictly a state\n * variable in the spec. These are recorded in the peer structure.\n *\n * Packet errors\n */\n#define TEST1\t\t0X0001\t/* duplicate packet */\n#define TEST2\t\t0x0002\t/* bogus packet */\n#define TEST3\t\t0x0004\t/* protocol unsynchronized */\n#define TEST4\t\t0x0008\t/* access denied */\n#define TEST5\t\t0x0010\t/* bad authentication */\n#define TEST6\t\t0x0020\t/* bad synch or stratum */\n#define TEST7\t\t0x0040\t/* bad header */\n#define TEST8\t\t0x0080 /* bad autokey */\n#define TEST9\t\t0x0100\t/* bad crypto */\n#define\tPKT_TEST_MASK\t(TEST1 | TEST2 | TEST3 | TEST4 | TEST5 |\\\n\t\t\tTEST6 | TEST7 | TEST8 | TEST9)\n/*\n * Peer errors\n */\n#define TEST10\t\t0x0200\t/* peer bad synch or stratum */\n#define\tTEST11\t\t0x0400\t/* peer distance exceeded */\n#define TEST12\t\t0x0800\t/* peer synchronization loop */\n#define TEST13\t\t0x1000\t/* peer unreacable */\n#define\tPEER_TEST_MASK\t(TEST10 | TEST11 | TEST12 | TEST13)",
"/*\n * The peer structure. Holds state information relating to the guys\n * we are peering with. Most of this stuff is from section 3.2 of the\n * spec.\n */\nstruct peer {\n\tstruct peer *p_link;\t/* link pointer in free & peer lists */\n\tstruct peer *adr_link;\t/* link pointer in address hash */\n\tstruct peer *aid_link;\t/* link pointer in associd hash */\n\tstruct peer *ilink;\t/* list of peers for interface */\n\tsockaddr_u srcadr;\t/* address of remote host */\n\tchar *\thostname;\t/* if non-NULL, remote name */\n\tstruct addrinfo *addrs;\t/* hostname query result */\n\tstruct addrinfo *ai;\t/* position within addrs */\n\tendpt *\tdstadr;\t\t/* local address */\n\tassocid_t associd;\t/* association ID */\n\tu_char\tversion;\t/* version number */\n\tu_char\thmode;\t\t/* local association mode */\n\tu_char\thpoll;\t\t/* local poll interval */\n\tu_char\tminpoll;\t/* min poll interval */\n\tu_char\tmaxpoll;\t/* max poll interval */\n\tu_int\tflags;\t\t/* association flags */\n\tu_char\tcast_flags;\t/* additional flags */\n\tu_char\tlast_event;\t/* last peer error code */\n\tu_char\tnum_events;\t/* number of error events */\n\tu_int32\tttl;\t\t/* ttl/refclock mode */\n\tchar\t*ident;\t\t/* group identifier name */",
"\t/*\n\t * Variables used by reference clock support\n\t */\n#ifdef REFCLOCK\n\tstruct refclockproc *procptr; /* refclock structure pointer */\n\tu_char\trefclktype;\t/* reference clock type */\n\tu_char\trefclkunit;\t/* reference clock unit number */\n\tu_char\tsstclktype;\t/* clock type for system status word */\n#endif /* REFCLOCK */",
"\t/*\n\t * Variables set by received packet\n\t */\n\tu_char\tleap;\t\t/* local leap indicator */\n\tu_char\tpmode;\t\t/* remote association mode */\n\tu_char\tstratum;\t/* remote stratum */\n\tu_char\tppoll;\t\t/* remote poll interval */\n\ts_char\tprecision;\t/* remote clock precision */\n\tdouble\trootdelay;\t/* roundtrip delay to primary source */\n\tdouble\trootdisp;\t/* dispersion to primary source */\n\tu_int32\trefid;\t\t/* remote reference ID */\n\tl_fp\treftime;\t/* update epoch */",
"\t/*\n\t * Variables used by authenticated client\n\t */\n\tkeyid_t keyid;\t\t/* current key ID */\n#ifdef AUTOKEY\n#define clear_to_zero opcode\n\tu_int32\topcode;\t\t/* last request opcode */\n\tassocid_t assoc;\t/* peer association ID */\n\tu_int32\tcrypto;\t\t/* peer status word */\n\tEVP_PKEY *pkey;\t\t/* public key */\n\tconst EVP_MD *digest;\t/* message digest algorithm */\n\tchar\t*subject;\t/* certificate subject name */\n\tchar\t*issuer;\t/* certificate issuer name */\n\tstruct cert_info *xinfo; /* issuer certificate */\n\tkeyid_t\tpkeyid;\t\t/* previous key ID */\n\tkeyid_t\thcookie;\t/* host cookie */\n\tkeyid_t\tpcookie;\t/* peer cookie */\n\tconst struct pkey_info *ident_pkey; /* identity key */\n\tBIGNUM\t*iffval;\t/* identity challenge (IFF, GQ, MV) */\n\tconst BIGNUM *grpkey;\t/* identity challenge key (GQ) */\n\tstruct value cookval;\t/* receive cookie values */\n\tstruct value recval;\t/* receive autokey values */\n\tstruct exten *cmmd;\t/* extension pointer */\n\tu_long\trefresh;\t/* next refresh epoch */",
"\t/*\n\t * Variables used by authenticated server\n\t */\n\tkeyid_t\t*keylist;\t/* session key ID list */\n\tint\tkeynumber;\t/* current key number */\n\tstruct value encrypt;\t/* send encrypt values */\n\tstruct value sndval;\t/* send autokey values */\n#else\t/* !AUTOKEY follows */\n#define clear_to_zero status\n#endif\t/* !AUTOKEY */",
"\t/*\n\t * Ephemeral state variables\n\t */\n\tu_char\tstatus;\t\t/* peer status */\n\tu_char\tnew_status;\t/* under-construction status */\n\tu_char\treach;\t\t/* reachability register */\n\tint\tflash;\t\t/* protocol error test tally bits */\n\tu_long\tepoch;\t\t/* reference epoch */\n\tint\tburst;\t\t/* packets remaining in burst */\n\tint\tretry;\t\t/* retry counter */\n\tint\tflip;\t\t/* interleave mode control */\n\tint\tfilter_nextpt;\t/* index into filter shift register */\n\tdouble\tfilter_delay[NTP_SHIFT]; /* delay shift register */\n\tdouble\tfilter_offset[NTP_SHIFT]; /* offset shift register */\n\tdouble\tfilter_disp[NTP_SHIFT]; /* dispersion shift register */\n\tu_long\tfilter_epoch[NTP_SHIFT]; /* epoch shift register */\n\tu_char\tfilter_order[NTP_SHIFT]; /* filter sort index */\n\tl_fp\trec;\t\t/* receive time stamp */\n\tl_fp\txmt;\t\t/* transmit time stamp */\n\tl_fp\tdst;\t\t/* destination timestamp */\n\tl_fp\taorg;\t\t/* origin timestamp */\n\tl_fp\tborg;\t\t/* alternate origin timestamp */\n\tdouble\toffset;\t\t/* peer clock offset */\n\tdouble\tdelay;\t\t/* peer roundtrip delay */\n\tdouble\tjitter;\t\t/* peer jitter (squares) */\n\tdouble\tdisp;\t\t/* peer dispersion */\n\tdouble\txleave;\t\t/* interleave delay */\n\tdouble\tbias;\t\t/* programmed offset bias */",
"\t/*\n\t * Variables used to correct for packet length and asymmetry.\n\t */\n\tdouble\tt21;\t\t/* outbound packet delay */\n\tint\tt21_bytes;\t/* outbound packet length */\n\tint\tt21_last;\t/* last outbound packet length */\n\tdouble\tr21;\t\t/* outbound data rate */\n\tdouble\tt34;\t\t/* inbound packet delay */\n\tint\tt34_bytes;\t/* inbound packet length */\n\tdouble\tr34;\t\t/* inbound data rate */",
"\t/*\n\t * End of clear-to-zero area\n\t */\n\tu_long\tupdate;\t\t/* receive epoch */\n#define end_clear_to_zero update\n\tint\tunreach;\t/* watchdog counter */\n\tint\tthrottle;\t/* rate control */\n\tu_long\toutdate;\t/* send time last packet */\n\tu_long\tnextdate;\t/* send time next packet */",
"\t/*\n\t * Statistic counters\n\t */\n\tu_long\ttimereset;\t/* time stat counters were reset */\n\tu_long\ttimereceived;\t/* last packet received time */\n\tu_long\ttimereachable;\t/* last reachable/unreachable time */",
"\tu_long\tsent;\t\t/* packets sent */\n\tu_long\treceived;\t/* packets received */\n\tu_long\tprocessed;\t/* packets processed */\n\tu_long\tbadauth;\t/* bad authentication (TEST5) */\n\tu_long\tbogusorg;\t/* bogus origin (TEST2, TEST3) */\n\tu_long\toldpkt;\t\t/* old duplicate (TEST1) */\n\tu_long\tseldisptoolarge; /* bad header (TEST6, TEST7) */\n\tu_long\tselbroken;\t/* KoD received */\n};",
"/*\n * Values for peer.leap, sys_leap\n */\n#define\tLEAP_NOWARNING\t0x0\t/* normal, no leap second warning */\n#define\tLEAP_ADDSECOND\t0x1\t/* last minute of day has 61 seconds */\n#define\tLEAP_DELSECOND\t0x2\t/* last minute of day has 59 seconds */\n#define\tLEAP_NOTINSYNC\t0x3\t/* overload, clock is free running */",
"/*\n * Values for peer mode and packet mode. Only the modes through\n * MODE_BROADCAST and MODE_BCLIENT appear in the transition\n * function. MODE_CONTROL and MODE_PRIVATE can appear in packets,\n * but those never survive to the transition function.\n * is a\n/ */\n#define\tMODE_UNSPEC\t0\t/* unspecified (old version) */\n#define\tMODE_ACTIVE\t1\t/* symmetric active mode */\n#define\tMODE_PASSIVE\t2\t/* symmetric passive mode */\n#define\tMODE_CLIENT\t3\t/* client mode */\n#define\tMODE_SERVER\t4\t/* server mode */\n#define\tMODE_BROADCAST\t5\t/* broadcast mode */\n/*\n * These can appear in packets\n */\n#define\tMODE_CONTROL\t6\t/* control mode */\n#define\tMODE_PRIVATE\t7\t/* private mode */\n/*\n * This is a madeup mode for broadcast client.\n */\n#define\tMODE_BCLIENT\t6\t/* broadcast client mode */",
"/*\n * Values for peer.stratum, sys_stratum\n */\n#define\tSTRATUM_REFCLOCK ((u_char)0) /* default stratum */\n/* A stratum of 0 in the packet is mapped to 16 internally */\n#define\tSTRATUM_PKT_UNSPEC ((u_char)0) /* unspecified in packet */\n#define\tSTRATUM_UNSPEC\t((u_char)16) /* unspecified */",
"/*\n * Values for peer.flags\n */\n#define\tFLAG_CONFIG\t0x0001\t/* association was configured */\n#define\tFLAG_PREEMPT\t0x0002\t/* preemptable association */\n#define\tFLAG_AUTHENTIC\t0x0004\t/* last message was authentic */\n#define\tFLAG_REFCLOCK\t0x0008\t/* this is actually a reference clock */\n#define\tFLAG_BC_VOL\t0x0010\t/* broadcast client volleying */\n#define\tFLAG_PREFER\t0x0020\t/* prefer peer */\n#define\tFLAG_BURST\t0x0040\t/* burst mode */\n#define\tFLAG_PPS\t0x0080\t/* steered by PPS */\n#define\tFLAG_IBURST\t0x0100\t/* initial burst mode */\n#define\tFLAG_NOSELECT\t0x0200\t/* never select */\n#define\tFLAG_TRUE\t0x0400\t/* force truechimer */\n#define\tFLAG_SKEY\t0x0800 /* autokey authentication */\n#define\tFLAG_XLEAVE\t0x1000\t/* interleaved protocol */\n#define\tFLAG_XB\t\t0x2000\t/* interleaved broadcast */\n#define\tFLAG_XBOGUS\t0x4000\t/* interleaved bogus packet */\n#ifdef\tOPENSSL\n#define FLAG_ASSOC\t0x8000\t/* autokey request */\n#endif /* OPENSSL */",
"/*\n * Definitions for the clear() routine. We use memset() to clear\n * the parts of the peer structure which go to zero. These are\n * used to calculate the start address and length of the area.\n */\n#define\tCLEAR_TO_ZERO(p)\t((char *)&((p)->clear_to_zero))\n#define\tEND_CLEAR_TO_ZERO(p)\t((char *)&((p)->end_clear_to_zero))\n#define\tLEN_CLEAR_TO_ZERO\t(END_CLEAR_TO_ZERO((struct peer *)0) \\\n\t\t\t\t - CLEAR_TO_ZERO((struct peer *)0))\n#define CRYPTO_TO_ZERO(p)\t((char *)&((p)->clear_to_zero))\n#define END_CRYPTO_TO_ZERO(p)\t((char *)&((p)->end_clear_to_zero))\n#define LEN_CRYPTO_TO_ZERO\t(END_CRYPTO_TO_ZERO((struct peer *)0) \\\n\t\t\t\t - CRYPTO_TO_ZERO((struct peer *)0))",
"/*\n * Reference clock types. Added as necessary.\n */\n#define\tREFCLK_NONE\t\t0\t/* unknown or missing */\n#define\tREFCLK_LOCALCLOCK\t1\t/* external (e.g., lockclock) */\n#define\tREFCLK_GPS_TRAK\t\t2\t/* TRAK 8810 GPS Receiver */\n#define\tREFCLK_WWV_PST\t\t3\t/* PST/Traconex 1020 WWV/H */\n#define\tREFCLK_SPECTRACOM\t4\t/* Spectracom (generic) Receivers */\n#define\tREFCLK_TRUETIME\t\t5\t/* TrueTime (generic) Receivers */\n#define REFCLK_IRIG_AUDIO\t6\t/* IRIG-B/W audio decoder */\n#define\tREFCLK_CHU_AUDIO\t7\t/* CHU audio demodulator/decoder */\n#define REFCLK_PARSE\t\t8\t/* generic driver (usually DCF77,GPS,MSF) */\n#define\tREFCLK_GPS_MX4200\t9\t/* Magnavox MX4200 GPS */\n#define REFCLK_GPS_AS2201\t10\t/* Austron 2201A GPS */\n#define\tREFCLK_GPS_ARBITER\t11\t/* Arbiter 1088A/B/ GPS */\n#define REFCLK_IRIG_TPRO\t12\t/* KSI/Odetics TPRO-S IRIG */\n#define REFCLK_ATOM_LEITCH\t13\t/* Leitch CSD 5300 Master Clock */\n#define REFCLK_MSF_EES\t\t14\t/* EES M201 MSF Receiver */\n#define\tREFCLK_GPSTM_TRUE\t15\t/* OLD TrueTime GPS/TM-TMD Receiver */\n#define REFCLK_IRIG_BANCOMM\t16\t/* Bancomm GPS/IRIG Interface */\n#define REFCLK_GPS_DATUM\t17\t/* Datum Programmable Time System */\n#define REFCLK_ACTS\t\t18\t/* Generic Auto Computer Time Service */\n#define REFCLK_WWV_HEATH\t19\t/* Heath GC1000 WWV/WWVH Receiver */\n#define REFCLK_GPS_NMEA\t\t20\t/* NMEA based GPS clock */\n#define REFCLK_GPS_VME\t\t21\t/* TrueTime GPS-VME Interface */\n#define REFCLK_ATOM_PPS\t\t22\t/* 1-PPS Clock Discipline */\n#define REFCLK_PTB_ACTS\t\t23\t/* replaced by REFCLK_ACTS */\n#define REFCLK_USNO\t\t24\t/* replaced by REFCLK_ACTS */\n#define REFCLK_GPS_HP\t\t26\t/* HP 58503A Time/Frequency Receiver */\n#define REFCLK_ARCRON_MSF\t27\t/* ARCRON MSF radio clock. */\n#define REFCLK_SHM\t\t28\t/* clock attached thru shared memory */\n#define REFCLK_PALISADE\t\t29\t/* Trimble Navigation Palisade GPS */\n#define REFCLK_ONCORE\t\t30\t/* Motorola UT Oncore GPS */\n#define REFCLK_GPS_JUPITER\t31\t/* Rockwell Jupiter GPS receiver */\n#define REFCLK_CHRONOLOG\t32\t/* Chrono-log K WWVB receiver */\n#define REFCLK_DUMBCLOCK\t33\t/* Dumb localtime clock */\n#define REFCLK_ULINK\t\t34\t/* Ultralink M320 WWVB receiver */\n#define REFCLK_PCF\t\t35\t/* Conrad parallel port radio clock */\n#define REFCLK_WWV_AUDIO\t36\t/* WWV/H audio demodulator/decoder */\n#define REFCLK_FG\t\t37\t/* Forum Graphic GPS */\n#define REFCLK_HOPF_SERIAL\t38\t/* hopf DCF77/GPS serial receiver */\n#define REFCLK_HOPF_PCI\t\t39\t/* hopf DCF77/GPS PCI receiver */\n#define REFCLK_JJY\t\t40\t/* JJY receiver */\n#define\tREFCLK_TT560\t\t41\t/* TrueTime 560 IRIG-B decoder */\n#define REFCLK_ZYFER\t\t42\t/* Zyfer GPStarplus receiver */\n#define REFCLK_RIPENCC\t\t43\t/* RIPE NCC Trimble driver */\n#define REFCLK_NEOCLOCK4X\t44\t/* NeoClock4X DCF77 or TDF receiver */\n#define REFCLK_TSYNCPCI\t45\t/* Spectracom TSYNC PCI timing board */\n#define REFCLK_MAX\t\t45\t/* Spectracom TSYNC PCI timing board */",
"\n/*\n * NTP packet format. The mac field is optional. It isn't really\n * an l_fp either, but for now declaring it that way is convenient.\n * See Appendix A in the specification.\n *\n * Note that all u_fp and l_fp values arrive in network byte order\n * and must be converted (except the mac, which isn't, really).\n */\nstruct pkt {\n\tu_char\tli_vn_mode;\t/* peer leap indicator */\n\tu_char\tstratum;\t/* peer stratum */\n\tu_char\tppoll;\t\t/* peer poll interval */\n\ts_char\tprecision;\t/* peer clock precision */\n\tu_fp\trootdelay;\t/* roundtrip delay to primary source */\n\tu_fp\trootdisp;\t/* dispersion to primary source*/\n\tu_int32\trefid;\t\t/* reference id */\n\tl_fp\treftime;\t/* last update time */\n\tl_fp\torg;\t\t/* originate time stamp */\n\tl_fp\trec;\t\t/* receive time stamp */\n\tl_fp\txmt;\t\t/* transmit time stamp */",
"#define\tLEN_PKT_NOMAC\t(12 * sizeof(u_int32)) /* min header length */\n#define MIN_MAC_LEN\t(1 * sizeof(u_int32))\t/* crypto_NAK */\n#define MAX_MD5_LEN\t(5 * sizeof(u_int32))\t/* MD5 */\n#define\tMAX_MAC_LEN\t(6 * sizeof(u_int32))\t/* SHA */",
"\t/*\n\t * The length of the packet less MAC must be a multiple of 64\n\t * with an RSA modulus and Diffie-Hellman prime of 256 octets\n\t * and maximum host name of 128 octets, the maximum autokey\n\t * command is 152 octets and maximum autokey response is 460\n\t * octets. A packet can contain no more than one command and one\n\t * response, so the maximum total extension field length is 864\n\t * octets. But, to handle humungus certificates, the bank must\n\t * be broke.\n\t */\n#ifdef AUTOKEY\n\tu_int32\texten[NTP_MAXEXTEN / 4]; /* max extension field */\n#else\t/* !AUTOKEY follows */\n\tu_int32\texten[1];\t/* misused */\n#endif\t/* !AUTOKEY */\n\tu_char\tmac[MAX_MAC_LEN]; /* mac */\n};",
"/*\n * Stuff for extracting things from li_vn_mode\n */\n#define\tPKT_MODE(li_vn_mode)\t((u_char)((li_vn_mode) & 0x7))\n#define\tPKT_VERSION(li_vn_mode)\t((u_char)(((li_vn_mode) >> 3) & 0x7))\n#define\tPKT_LEAP(li_vn_mode)\t((u_char)(((li_vn_mode) >> 6) & 0x3))",
"/*\n * Stuff for putting things back into li_vn_mode in packets and vn_mode\n * in ntp_monitor.c's mon_entry.\n */\n#define VN_MODE(v, m)\t\t((((v) & 7) << 3) | ((m) & 0x7))\n#define\tPKT_LI_VN_MODE(l, v, m) ((((l) & 3) << 6) | VN_MODE((v), (m)))",
"\n/*\n * Dealing with stratum. 0 gets mapped to 16 incoming, and back to 0\n * on output.\n */\n#define\tPKT_TO_STRATUM(s)\t((u_char)(((s) == (STRATUM_PKT_UNSPEC)) ?\\\n\t\t\t\t(STRATUM_UNSPEC) : (s)))",
"#define\tSTRATUM_TO_PKT(s)\t((u_char)(((s) == (STRATUM_UNSPEC)) ?\\\n\t\t\t\t(STRATUM_PKT_UNSPEC) : (s)))",
"/*\n * Event codes. Used for reporting errors/events to the control module\n */\n#define\tPEER_EVENT\t0x080\t/* this is a peer event */\n#define CRPT_EVENT\t0x100\t/* this is a crypto event */",
"/*\n * System event codes\n */\n#define\tEVNT_UNSPEC\t0\t/* unspecified */\n#define\tEVNT_NSET\t1\t/* freq not set */\n#define\tEVNT_FSET\t2\t/* freq set */\n#define\tEVNT_SPIK\t3\t/* spike detect */\n#define\tEVNT_FREQ\t4\t/* freq mode */\n#define\tEVNT_SYNC\t5\t/* clock sync */\n#define\tEVNT_SYSRESTART\t6\t/* restart */\n#define\tEVNT_SYSFAULT\t7\t/* panic stop */\n#define\tEVNT_NOPEER\t8\t/* no sys peer */\n#define\tEVNT_ARMED\t9\t/* leap armed */\n#define\tEVNT_DISARMED\t10\t/* leap disarmed */\n#define\tEVNT_LEAP\t11\t/* leap event */\n#define\tEVNT_CLOCKRESET\t12\t/* clock step */\n#define\tEVNT_KERN\t13\t/* kernel event */\n#define\tEVNT_TAI\t14\t/* TAI */\n#define\tEVNT_LEAPVAL\t15\t/* stale leapsecond values */",
"/*\n * Peer event codes\n */\n#define\tPEVNT_MOBIL\t(1 | PEER_EVENT) /* mobilize */\n#define\tPEVNT_DEMOBIL\t(2 | PEER_EVENT) /* demobilize */\n#define\tPEVNT_UNREACH\t(3 | PEER_EVENT) /* unreachable */\n#define\tPEVNT_REACH\t(4 | PEER_EVENT) /* reachable */\n#define\tPEVNT_RESTART\t(5 | PEER_EVENT) /* restart */\n#define\tPEVNT_REPLY\t(6 | PEER_EVENT) /* no reply */\n#define\tPEVNT_RATE\t(7 | PEER_EVENT) /* rate exceeded */\n#define\tPEVNT_DENY\t(8 | PEER_EVENT) /* access denied */\n#define PEVNT_ARMED\t(9 | PEER_EVENT) /* leap armed */\n#define\tPEVNT_NEWPEER\t(10 | PEER_EVENT) /* sys peer */\n#define\tPEVNT_CLOCK\t(11 | PEER_EVENT) /* clock event */\n#define\tPEVNT_AUTH\t(12 | PEER_EVENT) /* bad auth */\n#define\tPEVNT_POPCORN\t(13 | PEER_EVENT) /* popcorn */\n#define\tPEVNT_XLEAVE\t(14 | PEER_EVENT) /* interleave mode */\n#define\tPEVNT_XERR\t(15 | PEER_EVENT) /* interleave error */",
"/*\n * Clock event codes\n */\n#define\tCEVNT_NOMINAL\t0\t/* unspecified */\n#define\tCEVNT_TIMEOUT\t1\t/* no reply */\n#define\tCEVNT_BADREPLY\t2\t/* bad format */\n#define\tCEVNT_FAULT\t3\t/* fault */\n#define\tCEVNT_PROP\t4\t/* bad signal */\n#define\tCEVNT_BADDATE\t5\t/* bad date */\n#define\tCEVNT_BADTIME\t6\t/* bad time */\n#define CEVNT_MAX\tCEVNT_BADTIME",
"/*\n * Very misplaced value. Default port through which we send traps.\n */\n#define\tTRAPPORT\t18447",
"\n/*\n * To speed lookups, peers are hashed by the low order bits of the\n * remote IP address. These definitions relate to that.\n */\n#define\tNTP_HASH_SIZE\t\t128\n#define\tNTP_HASH_MASK\t\t(NTP_HASH_SIZE-1)\n#define\tNTP_HASH_ADDR(src)\t(sock_hash(src) & NTP_HASH_MASK)",
"/*\n * min, min3 and max. Makes it easier to transliterate the spec without\n * thinking about it.\n */\n#define\tmin(a,b)\t(((a) < (b)) ? (a) : (b))\n#define\tmax(a,b)\t(((a) > (b)) ? (a) : (b))\n#define\tmin3(a,b,c)\tmin(min((a),(b)), (c))",
"\n/*\n * Configuration items. These are for the protocol module (proto_config())\n */\n#define\tPROTO_BROADCLIENT\t1\n#define\tPROTO_PRECISION\t\t2\t/* (not used) */\n#define\tPROTO_AUTHENTICATE\t3\n#define\tPROTO_BROADDELAY\t4\n#define\tPROTO_AUTHDELAY\t\t5\t/* (not used) */\n#define PROTO_MULTICAST_ADD\t6\n#define PROTO_MULTICAST_DEL\t7\n#define PROTO_NTP\t\t8\n#define PROTO_KERNEL\t\t9\n#define PROTO_MONITOR\t\t10\n#define PROTO_FILEGEN\t\t11\n#define\tPROTO_PPS\t\t12\n#define PROTO_CAL\t\t13\n#define PROTO_MINCLOCK\t\t14\n#define\tPROTO_MAXCLOCK\t\t15\n#define PROTO_MINSANE\t\t16\n#define PROTO_FLOOR\t\t17\n#define PROTO_CEILING\t\t18\n#define PROTO_COHORT\t\t19\n#define PROTO_CALLDELAY\t\t20\n#define PROTO_MINDISP\t\t21\n#define PROTO_MAXDIST\t\t22\n\t/* available\t\t23 */\n#define\tPROTO_MAXHOP\t\t24\n#define\tPROTO_BEACON\t\t25\n#define\tPROTO_ORPHAN\t\t26\n#define\tPROTO_ORPHWAIT\t\t27\n#define\tPROTO_MODE7\t\t28",
"/*\n * Configuration items for the loop filter\n */\n#define\tLOOP_DRIFTINIT\t\t1\t/* iniitialize frequency */\n#define\tLOOP_KERN_CLEAR\t\t2\t/* set initial frequency offset */\n#define LOOP_MAX\t\t3\t/* set step offset */\n#define LOOP_PANIC\t\t4\t/* set panic offseet */\n#define LOOP_PHI\t\t5\t/* set dispersion rate */\n#define LOOP_MINSTEP\t\t6\t/* set step timeout */\n#define LOOP_MINPOLL\t\t7\t/* set min poll interval (log2 s) */\n#define LOOP_ALLAN\t\t8\t/* set minimum Allan intercept */\n#define LOOP_HUFFPUFF\t\t9\t/* set huff-n'-puff filter length */\n#define LOOP_FREQ\t\t10\t/* set initial frequency */\n#define LOOP_CODEC\t\t11\t/* set audio codec frequency */\n#define\tLOOP_LEAP\t\t12\t/* insert leap after second 23:59 */\n#define\tLOOP_TICK\t\t13\t/* sim. low precision clock */",
"/*\n * Configuration items for the stats printer\n */\n#define\tSTATS_FREQ_FILE\t\t1\t/* configure drift file */\n#define STATS_STATSDIR\t\t2\t/* directory prefix for stats files */\n#define\tSTATS_PID_FILE\t\t3\t/* configure ntpd PID file */\n#define\tSTATS_LEAP_FILE\t\t4\t/* configure ntpd leapseconds file */",
"#define MJD_1900\t\t15020\t/* MJD for 1 Jan 1900 */",
"/*\n * Default parameters. We use these in the absence of something better.\n */\n#define INADDR_NTP\t0xe0000101\t/* NTP multicast address 224.0.1.1 */",
"/*\n * Structure used optionally for monitoring when this is turned on.\n */\ntypedef struct mon_data\tmon_entry;\nstruct mon_data {\n\tmon_entry *\thash_next;\t/* next structure in hash list */\n\tDECL_DLIST_LINK(mon_entry, mru);/* MRU list link pointers */\n\tstruct interface * lcladr;\t/* address on which this arrived */\n\tl_fp\t\tfirst;\t\t/* first time seen */\n\tl_fp\t\tlast;\t\t/* last time seen */\n\tint\t\tleak;\t\t/* leaky bucket accumulator */\n\tint\t\tcount;\t\t/* total packet count */\n\tu_short\t\tflags;\t\t/* restrict flags */\n\tu_char\t\tvn_mode;\t/* packet mode & version */\n\tu_char\t\tcast_flags;\t/* flags MDF_?CAST */\n\tsockaddr_u\trmtadr;\t\t/* address of remote host */\n};",
"/*\n * Values for cast_flags in mon_entry and struct peer. mon_entry uses\n * only the first three, MDF_UCAST, MDF_MCAST, and MDF_BCAST.\n */\n#define\tMDF_UCAST\t0x01\t/* unicast client */\n#define\tMDF_MCAST\t0x02\t/* multicast server */\n#define\tMDF_BCAST\t0x04\t/* broadcast server */\n#define\tMDF_POOL\t0x08\t/* pool client solicitor */\n#define MDF_ACAST\t0x10\t/* manycast client solicitor */\n#define\tMDF_BCLNT\t0x20\t/* eph. broadcast/multicast client */\n#define MDF_UCLNT\t0x40\t/* preemptible manycast or pool client */\n/*\n * In the context of struct peer in ntpd, three of the cast_flags bits\n * represent configured associations which never receive packets, and\n * whose reach is always 0: MDF_BCAST, MDF_MCAST, and MDF_ACAST. The\n * last can be argued as responses are received, but those responses do\n * not affect the MDF_ACAST association's reach register, rather they\n * (may) result in mobilizing ephemeral MDF_ACLNT associations.\n */\n#define MDF_TXONLY_MASK\t(MDF_BCAST | MDF_MCAST | MDF_ACAST | MDF_POOL)\n/*\n * manycastclient-like solicitor association cast_flags bits\n */\n#define MDF_SOLICIT_MASK\t(MDF_ACAST | MDF_POOL)\n/*\n * Values used with mon_enabled to indicate reason for enabling monitoring\n */\n#define MON_OFF\t\t0x00\t\t/* no monitoring */\n#define MON_ON\t\t0x01\t\t/* monitoring explicitly enabled */\n#define MON_RES\t\t0x02\t\t/* implicit monitoring for RES_LIMITED */\n/*\n * Structure used for restrictlist entries\n */\ntypedef struct res_addr4_tag {\n\tu_int32\t\taddr;\t\t/* IPv4 addr (host order) */\n\tu_int32\t\tmask;\t\t/* IPv4 mask (host order) */\n} res_addr4;",
"typedef struct res_addr6_tag {\n\tstruct in6_addr addr;\t\t/* IPv6 addr (net order) */\n\tstruct in6_addr mask;\t\t/* IPv6 mask (net order) */\n} res_addr6;",
"typedef struct restrict_u_tag\trestrict_u;\nstruct restrict_u_tag {\n\trestrict_u *\t\tlink;\t/* link to next entry */\n\tu_int32\t\t\tcount;\t/* number of packets matched */\n\tu_short\t\t\tflags;\t/* accesslist flags */\n\tu_short\t\t\tmflags;\t/* match flags */\n\tu_long\t\t\texpire;\t/* valid until time */\n\tunion {\t\t\t\t/* variant starting here */\n\t\tres_addr4 v4;\n\t\tres_addr6 v6;\n\t} u;\n};\n#define\tV4_SIZEOF_RESTRICT_U\t(offsetof(restrict_u, u)\t\\\n\t\t\t\t + sizeof(res_addr4))\n#define\tV6_SIZEOF_RESTRICT_U\t(offsetof(restrict_u, u)\t\\\n\t\t\t\t + sizeof(res_addr6))",
"/*\n * Access flags\n */\n#define\tRES_IGNORE\t\t0x0001\t/* ignore packet */\n#define\tRES_DONTSERVE\t\t0x0002\t/* access denied */\n#define\tRES_DONTTRUST\t\t0x0004\t/* authentication required */\n#define\tRES_VERSION\t\t0x0008\t/* version mismatch */\n#define\tRES_NOPEER\t\t0x0010\t/* new association denied */\n#define RES_LIMITED\t\t0x0020\t/* packet rate exceeded */\n#define RES_FLAGS\t\t(RES_IGNORE | RES_DONTSERVE |\\\n\t\t\t\t RES_DONTTRUST | RES_VERSION |\\\n\t\t\t\t RES_NOPEER | RES_LIMITED)",
"#define\tRES_NOQUERY\t\t0x0040\t/* mode 6/7 packet denied */\n#define\tRES_NOMODIFY\t\t0x0080\t/* mode 6/7 modify denied */\n#define\tRES_NOTRAP\t\t0x0100\t/* mode 6/7 set trap denied */\n#define\tRES_LPTRAP\t\t0x0200\t/* mode 6/7 low priority trap */",
"#define\tRES_KOD\t\t\t0x0400\t/* send kiss of death packet */\n#define\tRES_MSSNTP\t\t0x0800\t/* enable MS-SNTP authentication */\n#define\tRES_FLAKE\t\t0x1000\t/* flakeway - drop 10% */\n#define\tRES_NOMRULIST\t\t0x2000\t/* mode 6 mrulist denied */",
"#define\tRES_ALLFLAGS\t\t(RES_FLAGS | RES_NOQUERY |\t\\\n\t\t\t\t RES_NOMODIFY | RES_NOTRAP |\t\\\n\t\t\t\t RES_LPTRAP | RES_KOD |\t\t\\\n\t\t\t\t RES_MSSNTP | RES_FLAKE |\t\\\n\t\t\t\t RES_NOMRULIST)",
"/*\n * Match flags\n */\n#define\tRESM_INTERFACE\t\t0x1000\t/* this is an interface */\n#define\tRESM_NTPONLY\t\t0x2000\t/* match source port 123 */\n#define RESM_SOURCE\t\t0x4000\t/* from \"restrict source\" */",
"/*\n * Restriction configuration ops\n */\n#define\tRESTRICT_FLAGS\t\t1\t/* add flags to restrict entry */\n#define\tRESTRICT_UNFLAG\t\t2\t/* remove flags from restrict entry */\n#define\tRESTRICT_REMOVE\t\t3\t/* remove a restrict entry */\n#define\tRESTRICT_REMOVEIF\t4\t/* remove an interface restrict entry */",
"/*\n * Endpoint structure for the select algorithm\n */\nstruct endpoint {\n\tdouble\tval;\t\t\t/* offset of endpoint */\n\tint\ttype;\t\t\t/* interval entry/exit */\n};",
"/*\n * Association matching AM[] return codes\n */\n#define AM_ERR\t\t-1\t\t/* error */\n#define AM_NOMATCH\t0\t\t/* no match */\n#define AM_PROCPKT\t1\t\t/* server/symmetric packet */\t\n#define AM_BCST\t\t2\t\t/* broadcast packet */\t\n#define AM_FXMIT\t3\t\t/* client packet */\n#define AM_MANYCAST\t4\t\t/* manycast or pool */\n#define AM_NEWPASS\t5\t\t/* new passive */\n#define AM_NEWBCL\t6\t\t/* new broadcast */\n#define\tAM_POSSBCL\t7\t\t/* discard broadcast */",
"/* NetInfo configuration locations */\n#ifdef HAVE_NETINFO\n#define NETINFO_CONFIG_DIR \"/config/ntp\"\n#endif",
"/* ntpq -c mrulist rows per request limit in ntpd */\n#define MRU_ROW_LIMIT\t256\n/* similar datagrams per response limit for ntpd */\n#define MRU_FRAGS_LIMIT\t128\n#endif /* NTP_H */"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1, 163], "buggy_code_start_loc": [1, 159], "filenames": ["ChangeLog", "include/ntp.h"], "fixing_code_end_loc": [3, 162], "fixing_code_start_loc": [2, 159], "message": "The ULOGTOD function in ntp.d in SNTP before 4.2.7p366 does not properly perform type conversions from a precision value to a double, which allows remote attackers to cause a denial of service (infinite loop) via a crafted NTP packet.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:fedoraproject:fedora:21:*:*:*:*:*:*:*", "matchCriteriaId": "56BDB5A0-0839-4A20-A003-B8CD56F48171", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:22:*:*:*:*:*:*:*", "matchCriteriaId": "253C303A-E577-4488-93E6-68A8DD942C38", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:23:*:*:*:*:*:*:*", "matchCriteriaId": "E79AB8DD-C907-4038-A931-1A5A4CFB6A5B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:suse:linux_enterprise_debuginfo:11:sp2:*:*:*:*:*:*", "matchCriteriaId": "D5900A25-FDD7-4900-BF7C-F3ECCB714D2B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:suse:linux_enterprise_debuginfo:11:sp3:*:*:*:*:*:*", "matchCriteriaId": "58D3B6FD-B474-4B09-B644-A8634A629280", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:10:sp4:*:*:ltss:*:*:*", "matchCriteriaId": "35BBD83D-BDC7-4678-BE94-639F59281139", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:11:sp2:*:*:ltss:*:*:*", "matchCriteriaId": "CB6476C7-03F2-4939-AB85-69AA524516D9", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:11:sp3:*:*:ltss:*:*:*", "matchCriteriaId": "B12243B2-D726-404C-ABFF-F1AB51BA1783", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:manager:2.1:*:*:*:*:*:*:*", "matchCriteriaId": "2A33B9F5-E0D1-4A3E-9FFB-5602A25F3227", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:manager_proxy:2.1:*:*:*:*:*:*:*", "matchCriteriaId": "53F0F5A0-70D9-4305-A834-B6FF71E27B30", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:openstack_cloud:5:*:*:*:*:*:*:*", "matchCriteriaId": "88BCD7DC-0FEF-477D-8698-F8D8F1A49D90", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:redhat:enterprise_linux_desktop:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "EE249E1B-A1FD-4E08-AA71-A0E1F10FFE97", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_desktop:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "33C068A4-3780-4EAB-A937-6082DF847564", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_hpc_node:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "C2FAC325-6EEB-466D-9EBA-8ED4DBC9CFBF", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_hpc_node:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "3C84489B-B08C-4854-8A12-D01B6E45CF79", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "9BBCD86A-E6C7-4444-9D74-F861084090F0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "51EF4996-72F4-4FA4-814F-F5991E7A8318", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_workstation:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "E5ED5807-55B7-47C5-97A6-03233F4FBC3A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_workstation:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "825ECE2D-E232-46E0-A047-074B34DB1E97", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:debian:debian_linux:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "16F59A04-14CF-49E2-9973-645477EA09DA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:debian:debian_linux:8.0:*:*:*:*:*:*:*", "matchCriteriaId": "C11E6FB0-C8C0-4527-9AA0-CB9B316F8F43", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:canonical:ubuntu_linux:12.04:*:*:*:lts:*:*:*", "matchCriteriaId": "B6B7CAD7-9D4E-4FDB-88E3-1E583210A01F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:14.04:*:*:*:lts:*:*:*", "matchCriteriaId": "B5A6F2F3-4894-4392-8296-3B8DD2679084", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:15.04:*:*:*:*:*:*:*", "matchCriteriaId": "F38D3B7E-8429-473F-BB31-FC3583EE5A5B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:15.10:*:*:*:*:*:*:*", "matchCriteriaId": "E88A537F-F4D0-46B9-9E37-965233C2A355", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:ntp:ntp:*:p355:*:*:*:*:*:*", "matchCriteriaId": "07FBDFE4-D886-4461-A360-480F50BD12C7", "versionEndExcluding": null, "versionEndIncluding": "4.2.7", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:novell:leap:42.2:*:*:*:*:*:*:*", "matchCriteriaId": "A64AAD2D-38ED-4BA2-A27A-A2716F28D43A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:opensuse:leap:42.1:*:*:*:*:*:*:*", "matchCriteriaId": "4863BE36-D16A-4D75-90D9-FD76DB5B48B7", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:tim_4r-ie_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "E0730ED6-676B-4200-BC07-C0B4531B242C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:tim_4r-ie:-:*:*:*:*:*:*:*", "matchCriteriaId": "0B87B16C-9E9F-448B-9255-B2BB2B8CAD63", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:tim_4r-id_dnp3_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "B8851DB6-6B63-4D78-A100-50F81B4DF75B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:tim_4r-id_dnp3:-:*:*:*:*:*:*:*", "matchCriteriaId": "1A8AC343-6F4F-4CAF-BD09-F8F1D2F6DBB0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:oracle:linux:6:-:*:*:*:*:*:*", "matchCriteriaId": "D7B037A8-72A6-4DFF-94B2-D688A5F6F876", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}], "descriptions": [{"lang": "en", "value": "The ULOGTOD function in ntp.d in SNTP before 4.2.7p366 does not properly perform type conversions from a precision value to a double, which allows remote attackers to cause a denial of service (infinite loop) via a crafted NTP packet."}, {"lang": "es", "value": "La funci\u00f3n ULOGTOD en el archivo ntp.d en SNTP en versiones anteriores a la 4.2.7p366 no realiza apropiadamente las conversiones de tipo de un valor de precisi\u00f3n a uno doble, lo que permite a los atacantes remotos causar una denegaci\u00f3n de servicio (bucle infinito) por medio de un paquete NTP creado."}], "evaluatorComment": null, "id": "CVE-2015-5219", "lastModified": "2023-02-13T00:51:47.453", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 5.0, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:N/AC:L/Au:N/C:N/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2017-07-21T14:29:00.867", "references": [{"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://aix.software.ibm.com/aix/efixes/security/ntp_advisory4.asc"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "http://bk1.ntp.org/ntp-dev/?PAGE=patch&REV=51786731Gr4-NOrTBC_a_uXO4wuGhg"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-November/170926.html"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-October/169167.html"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-September/166992.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://rhn.redhat.com/errata/RHSA-2016-0780.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://rhn.redhat.com/errata/RHSA-2016-2583.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.debian.org/security/2015/dsa-3388"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2015/08/25/3"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.oracle.com/technetwork/topics/security/linuxbulletinapr2016-2952096.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/76473"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.ubuntu.com/usn/USN-2783-1"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking"], "url": "https://bugzilla.redhat.com/show_bug.cgi?id=1255118"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-497656.pdf"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/ntp-project/ntp/commit/5f295cd05c3c136d39f5b3e500a2d781bdbb59c8"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "US Government Resource"], "url": "https://us-cert.cisa.gov/ics/advisories/icsa-21-103-11"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=isg3T1024157"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21985122"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21986956"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21988706"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21989542"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www.ibm.com/support/home/docdisplay?lndocid=migr-5099409"}], "sourceIdentifier": "secalert@redhat.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-704"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/ntp-project/ntp/commit/5f295cd05c3c136d39f5b3e500a2d781bdbb59c8"}, "type": "CWE-704"}
| 357
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * ntp.h - NTP definitions for the masses\n */\n#ifndef NTP_H\n#define NTP_H",
"#include <stddef.h>\n#include <math.h>",
"#include <ntp_fp.h>\n#include <ntp_types.h>\n#include <ntp_lists.h>\n#include <ntp_stdlib.h>\n#include <ntp_crypto.h>\n#include <ntp_random.h>\n#include <ntp_net.h>",
"#include <isc/boolean.h>",
"/*\n * Calendar arithmetic - contributed by G. Healton\n */\n#define YEAR_BREAK 500\t\t/* years < this are tm_year values:\n\t\t\t\t * Break < AnyFourDigitYear && Break >\n\t\t\t\t * Anytm_yearYear */",
"#define YEAR_PIVOT 98\t\t/* 97/98: years < this are year 2000+\n\t\t\t\t * FYI: official UNIX pivot year is\n\t\t\t\t * 68/69 */",
"/*\n * Number of Days since 1 BC Gregorian to 1 January of given year\n */\n#define julian0(year)\t(((year) * 365 ) + ((year) > 0 ? (((year) + 3) \\\n\t\t\t / 4 - ((year - 1) / 100) + ((year - 1) / \\\n\t\t\t 400)) : 0))",
"/*\n * Number of days since start of NTP time to 1 January of given year\n */\n#define ntp0(year)\t(julian0(year) - julian0(1900))",
"/*\n * Number of days since start of UNIX time to 1 January of given year\n */\n#define unix0(year)\t(julian0(year) - julian0(1970))",
"/*\n * LEAP YEAR test for full 4-digit years (e.g, 1999, 2010)\n */\n#define isleap_4(y)\t((y) % 4 == 0 && !((y) % 100 == 0 && !(y % \\\n\t\t\t 400 == 0)))",
"/*\n * LEAP YEAR test for tm_year (struct tm) years (e.g, 99, 110)\n */\n#define isleap_tm(y)\t((y) % 4 == 0 && !((y) % 100 == 0 && !(((y) \\\n\t\t\t + 1900) % 400 == 0)))",
"/*\n * to convert simple two-digit years to tm_year style years:\n *\n *\tif (year < YEAR_PIVOT)\n *\t\tyear += 100;\n *\n * to convert either two-digit OR tm_year years to four-digit years:\n *\n *\tif (year < YEAR_PIVOT)\n *\t\tyear += 100;\n *\n *\tif (year < YEAR_BREAK)\n *\t\tyear += 1900;\n */",
"/*\n * How to get signed characters. On machines where signed char works,\n * use it. On machines where signed char doesn't work, char had better\n * be signed.\n */\n#ifdef NEED_S_CHAR_TYPEDEF\n# if SIZEOF_SIGNED_CHAR\ntypedef signed char s_char;\n# else\ntypedef char s_char;\n# endif\n /* XXX: Why is this sequent bit INSIDE this test? */\n# ifdef sequent\n# undef SO_RCVBUF\n# undef SO_SNDBUF\n# endif\n#endif",
"/*\n * NTP protocol parameters. See section 3.2.6 of the specification.\n */\n#define\tNTP_VERSION\t((u_char)4) /* current version number */\n#define\tNTP_OLDVERSION\t((u_char)1) /* oldest credible version */\n#define\tNTP_PORT\t123\t/* included for non-unix machines */",
"/*\n * Poll interval parameters\n */\n#define NTP_UNREACH\t10\t/* poll unreach threshold */\n#define\tNTP_MINPOLL\t3\t/* log2 min poll interval (8 s) */\n#define NTP_MINDPOLL\t6\t/* log2 default min poll (64 s) */\n#define NTP_MAXDPOLL\t10\t/* log2 default max poll (~17 m) */\n#define\tNTP_MAXPOLL\t17\t/* log2 max poll interval (~36 h) */\n#define\tNTP_RETRY\t3\t/* max packet retries */\n#define\tNTP_MINPKT\t2\t/* guard time (s) */",
"/*\n * Clock filter algorithm tuning parameters\n */\n#define MAXDISPERSE\t16.\t/* max dispersion */\n#define\tNTP_SHIFT\t8\t/* clock filter stages */\n#define NTP_FWEIGHT\t.5\t/* clock filter weight */",
"/*\n * Selection algorithm tuning parameters\n */\n#define\tNTP_MINCLOCK\t3\t/* min survivors */\n#define\tNTP_MAXCLOCK\t10\t/* max candidates */\n#define MINDISPERSE\t.001\t/* min distance */\n#define MAXDISTANCE\t1.5\t/* max root distance (select threshold) */\n#define CLOCK_SGATE\t3.\t/* popcorn spike gate */\n#define HUFFPUFF\t900\t/* huff-n'-puff sample interval (s) */\n#define MAXHOP\t\t2\t/* anti-clockhop threshold */\n#define MAX_TTL\t\t8\t/* max ttl mapping vector size */\n#define\tBEACON\t\t7200\t/* manycast beacon interval */\n#define NTP_MAXEXTEN\t2048\t/* max extension field size */\n#define\tNTP_ORPHWAIT\t300\t/* orphan wair (s) */",
"/*\n * Miscellaneous stuff\n */\n#define NTP_MAXKEY\t65535\t/* max authentication key number */\n#define\tKEY_TYPE_MD5\tNID_md5\t/* MD5 digest NID */\n/*\n * Limits of things\n */\n#define\tMAXFILENAME\t256\t/* max length of file name */\n#define MAXHOSTNAME\t512\t/* max length of host/node name */\n#define NTP_MAXSTRLEN\t256\t/* max string length */",
"/*\n * Operations for jitter calculations (these use doubles).\n *\n * Note that we carefully separate the jitter component from the\n * dispersion component (frequency error plus precision). The frequency\n * error component is computed as CLOCK_PHI times the difference between\n * the epoch of the time measurement and the reference time. The\n * precision component is computed as the square root of the mean of the\n * squares of a zero-mean, uniform distribution of unit maximum\n * amplitude. Whether this makes statistical sense may be arguable.\n */\n#define SQUARE(x) ((x) * (x))\n#define SQRT(x) (sqrt(x))\n#define DIFF(x, y) (SQUARE((x) - (y)))",
"#define LOGTOD(a)\tldexp(1., (int)(a)) /* log2 to double */",
"#define UNIVAR(x)\t(SQUARE(.28867513 * LOGTOD(x))) /* std uniform distr */",
"#define ULOGTOD(a)\tldexp(1., (int)(a)) /* ulog2 to double */",
"\n#define\tEVENT_TIMEOUT\t0\t/* one second, that is */",
"\n/*\n * The interface structure is used to hold the addresses and socket\n * numbers of each of the local network addresses we are using.\n * Because \"interface\" is a reserved word in C++ and has so many\n * varied meanings, a change to \"endpt\" (via typedef) is under way.\n * Eventually the struct tag will change from interface to endpt_tag.\n * endpt is unrelated to the select algorithm's struct endpoint.\n */\ntypedef struct interface endpt;\nstruct interface {\n\tendpt *\t\telink;\t\t/* endpt list link */\n\tendpt *\t\tmclink;\t\t/* per-AF_* multicast list */\n\tSOCKET\t\tfd;\t\t/* socket descriptor */\n\tSOCKET\t\tbfd;\t\t/* for receiving broadcasts */\n\tu_int32\t\tifnum;\t\t/* endpt instance count */\n\tsockaddr_u\tsin;\t\t/* unicast address */\n\tsockaddr_u\tmask;\t\t/* subnet mask */\n\tsockaddr_u\tbcast;\t\t/* broadcast address */\n\tchar\t\tname[32];\t/* name of interface */\n\tu_short\t\tfamily;\t\t/* AF_INET/AF_INET6 */\n\tu_short\t\tphase;\t\t/* phase in update cycle */\n\tu_int32\t\tflags;\t\t/* interface flags */\n\tint\t\tlast_ttl;\t/* last TTL specified */\n\tu_int32\t\taddr_refid;\t/* IPv4 addr or IPv6 hash */\n\tint\t\tnum_mcast;\t/* mcast addrs enabled */\n\tu_long\t\tstarttime;\t/* current_time at creation */\n\tvolatile long\treceived;\t/* number of incoming packets */\n\tlong\t\tsent;\t\t/* number of outgoing packets */\n\tlong\t\tnotsent;\t/* number of send failures */\n\tu_int\t\tifindex;\t/* for IPV6_MULTICAST_IF */\n\tisc_boolean_t\tignore_packets; /* listen-read-drop this? */\n\tstruct peer *\tpeers;\t\t/* list of peers using endpt */\n\tu_int\t\tpeercnt;\t/* count of same */\n};",
"/*\n * Flags for interfaces\n */\n#define INT_UP\t\t0x001\t/* Interface is up */\n#define\tINT_PPP\t\t0x002\t/* Point-to-point interface */\n#define\tINT_LOOPBACK\t0x004\t/* the loopback interface */\n#define\tINT_BROADCAST\t0x008\t/* can broadcast out this interface */\n#define INT_MULTICAST\t0x010\t/* can multicast out this interface */\n#define\tINT_BCASTOPEN\t0x020\t/* broadcast receive socket is open */\n#define INT_MCASTOPEN\t0x040\t/* multicasting enabled */\n#define INT_WILDCARD\t0x080\t/* wildcard interface - usually skipped */\n#define INT_MCASTIF\t0x100\t/* bound directly to MCAST address */\n#define INT_PRIVACY\t0x200\t/* RFC 4941 IPv6 privacy address */\n#define INT_BCASTXMIT\t0x400 /* socket setup to allow broadcasts */",
"/*\n * Define flasher bits (tests 1 through 11 in packet procedure)\n * These reveal the state at the last grumble from the peer and are\n * most handy for diagnosing problems, even if not strictly a state\n * variable in the spec. These are recorded in the peer structure.\n *\n * Packet errors\n */\n#define TEST1\t\t0X0001\t/* duplicate packet */\n#define TEST2\t\t0x0002\t/* bogus packet */\n#define TEST3\t\t0x0004\t/* protocol unsynchronized */\n#define TEST4\t\t0x0008\t/* access denied */\n#define TEST5\t\t0x0010\t/* bad authentication */\n#define TEST6\t\t0x0020\t/* bad synch or stratum */\n#define TEST7\t\t0x0040\t/* bad header */\n#define TEST8\t\t0x0080 /* bad autokey */\n#define TEST9\t\t0x0100\t/* bad crypto */\n#define\tPKT_TEST_MASK\t(TEST1 | TEST2 | TEST3 | TEST4 | TEST5 |\\\n\t\t\tTEST6 | TEST7 | TEST8 | TEST9)\n/*\n * Peer errors\n */\n#define TEST10\t\t0x0200\t/* peer bad synch or stratum */\n#define\tTEST11\t\t0x0400\t/* peer distance exceeded */\n#define TEST12\t\t0x0800\t/* peer synchronization loop */\n#define TEST13\t\t0x1000\t/* peer unreacable */\n#define\tPEER_TEST_MASK\t(TEST10 | TEST11 | TEST12 | TEST13)",
"/*\n * The peer structure. Holds state information relating to the guys\n * we are peering with. Most of this stuff is from section 3.2 of the\n * spec.\n */\nstruct peer {\n\tstruct peer *p_link;\t/* link pointer in free & peer lists */\n\tstruct peer *adr_link;\t/* link pointer in address hash */\n\tstruct peer *aid_link;\t/* link pointer in associd hash */\n\tstruct peer *ilink;\t/* list of peers for interface */\n\tsockaddr_u srcadr;\t/* address of remote host */\n\tchar *\thostname;\t/* if non-NULL, remote name */\n\tstruct addrinfo *addrs;\t/* hostname query result */\n\tstruct addrinfo *ai;\t/* position within addrs */\n\tendpt *\tdstadr;\t\t/* local address */\n\tassocid_t associd;\t/* association ID */\n\tu_char\tversion;\t/* version number */\n\tu_char\thmode;\t\t/* local association mode */\n\tu_char\thpoll;\t\t/* local poll interval */\n\tu_char\tminpoll;\t/* min poll interval */\n\tu_char\tmaxpoll;\t/* max poll interval */\n\tu_int\tflags;\t\t/* association flags */\n\tu_char\tcast_flags;\t/* additional flags */\n\tu_char\tlast_event;\t/* last peer error code */\n\tu_char\tnum_events;\t/* number of error events */\n\tu_int32\tttl;\t\t/* ttl/refclock mode */\n\tchar\t*ident;\t\t/* group identifier name */",
"\t/*\n\t * Variables used by reference clock support\n\t */\n#ifdef REFCLOCK\n\tstruct refclockproc *procptr; /* refclock structure pointer */\n\tu_char\trefclktype;\t/* reference clock type */\n\tu_char\trefclkunit;\t/* reference clock unit number */\n\tu_char\tsstclktype;\t/* clock type for system status word */\n#endif /* REFCLOCK */",
"\t/*\n\t * Variables set by received packet\n\t */\n\tu_char\tleap;\t\t/* local leap indicator */\n\tu_char\tpmode;\t\t/* remote association mode */\n\tu_char\tstratum;\t/* remote stratum */\n\tu_char\tppoll;\t\t/* remote poll interval */\n\ts_char\tprecision;\t/* remote clock precision */\n\tdouble\trootdelay;\t/* roundtrip delay to primary source */\n\tdouble\trootdisp;\t/* dispersion to primary source */\n\tu_int32\trefid;\t\t/* remote reference ID */\n\tl_fp\treftime;\t/* update epoch */",
"\t/*\n\t * Variables used by authenticated client\n\t */\n\tkeyid_t keyid;\t\t/* current key ID */\n#ifdef AUTOKEY\n#define clear_to_zero opcode\n\tu_int32\topcode;\t\t/* last request opcode */\n\tassocid_t assoc;\t/* peer association ID */\n\tu_int32\tcrypto;\t\t/* peer status word */\n\tEVP_PKEY *pkey;\t\t/* public key */\n\tconst EVP_MD *digest;\t/* message digest algorithm */\n\tchar\t*subject;\t/* certificate subject name */\n\tchar\t*issuer;\t/* certificate issuer name */\n\tstruct cert_info *xinfo; /* issuer certificate */\n\tkeyid_t\tpkeyid;\t\t/* previous key ID */\n\tkeyid_t\thcookie;\t/* host cookie */\n\tkeyid_t\tpcookie;\t/* peer cookie */\n\tconst struct pkey_info *ident_pkey; /* identity key */\n\tBIGNUM\t*iffval;\t/* identity challenge (IFF, GQ, MV) */\n\tconst BIGNUM *grpkey;\t/* identity challenge key (GQ) */\n\tstruct value cookval;\t/* receive cookie values */\n\tstruct value recval;\t/* receive autokey values */\n\tstruct exten *cmmd;\t/* extension pointer */\n\tu_long\trefresh;\t/* next refresh epoch */",
"\t/*\n\t * Variables used by authenticated server\n\t */\n\tkeyid_t\t*keylist;\t/* session key ID list */\n\tint\tkeynumber;\t/* current key number */\n\tstruct value encrypt;\t/* send encrypt values */\n\tstruct value sndval;\t/* send autokey values */\n#else\t/* !AUTOKEY follows */\n#define clear_to_zero status\n#endif\t/* !AUTOKEY */",
"\t/*\n\t * Ephemeral state variables\n\t */\n\tu_char\tstatus;\t\t/* peer status */\n\tu_char\tnew_status;\t/* under-construction status */\n\tu_char\treach;\t\t/* reachability register */\n\tint\tflash;\t\t/* protocol error test tally bits */\n\tu_long\tepoch;\t\t/* reference epoch */\n\tint\tburst;\t\t/* packets remaining in burst */\n\tint\tretry;\t\t/* retry counter */\n\tint\tflip;\t\t/* interleave mode control */\n\tint\tfilter_nextpt;\t/* index into filter shift register */\n\tdouble\tfilter_delay[NTP_SHIFT]; /* delay shift register */\n\tdouble\tfilter_offset[NTP_SHIFT]; /* offset shift register */\n\tdouble\tfilter_disp[NTP_SHIFT]; /* dispersion shift register */\n\tu_long\tfilter_epoch[NTP_SHIFT]; /* epoch shift register */\n\tu_char\tfilter_order[NTP_SHIFT]; /* filter sort index */\n\tl_fp\trec;\t\t/* receive time stamp */\n\tl_fp\txmt;\t\t/* transmit time stamp */\n\tl_fp\tdst;\t\t/* destination timestamp */\n\tl_fp\taorg;\t\t/* origin timestamp */\n\tl_fp\tborg;\t\t/* alternate origin timestamp */\n\tdouble\toffset;\t\t/* peer clock offset */\n\tdouble\tdelay;\t\t/* peer roundtrip delay */\n\tdouble\tjitter;\t\t/* peer jitter (squares) */\n\tdouble\tdisp;\t\t/* peer dispersion */\n\tdouble\txleave;\t\t/* interleave delay */\n\tdouble\tbias;\t\t/* programmed offset bias */",
"\t/*\n\t * Variables used to correct for packet length and asymmetry.\n\t */\n\tdouble\tt21;\t\t/* outbound packet delay */\n\tint\tt21_bytes;\t/* outbound packet length */\n\tint\tt21_last;\t/* last outbound packet length */\n\tdouble\tr21;\t\t/* outbound data rate */\n\tdouble\tt34;\t\t/* inbound packet delay */\n\tint\tt34_bytes;\t/* inbound packet length */\n\tdouble\tr34;\t\t/* inbound data rate */",
"\t/*\n\t * End of clear-to-zero area\n\t */\n\tu_long\tupdate;\t\t/* receive epoch */\n#define end_clear_to_zero update\n\tint\tunreach;\t/* watchdog counter */\n\tint\tthrottle;\t/* rate control */\n\tu_long\toutdate;\t/* send time last packet */\n\tu_long\tnextdate;\t/* send time next packet */",
"\t/*\n\t * Statistic counters\n\t */\n\tu_long\ttimereset;\t/* time stat counters were reset */\n\tu_long\ttimereceived;\t/* last packet received time */\n\tu_long\ttimereachable;\t/* last reachable/unreachable time */",
"\tu_long\tsent;\t\t/* packets sent */\n\tu_long\treceived;\t/* packets received */\n\tu_long\tprocessed;\t/* packets processed */\n\tu_long\tbadauth;\t/* bad authentication (TEST5) */\n\tu_long\tbogusorg;\t/* bogus origin (TEST2, TEST3) */\n\tu_long\toldpkt;\t\t/* old duplicate (TEST1) */\n\tu_long\tseldisptoolarge; /* bad header (TEST6, TEST7) */\n\tu_long\tselbroken;\t/* KoD received */\n};",
"/*\n * Values for peer.leap, sys_leap\n */\n#define\tLEAP_NOWARNING\t0x0\t/* normal, no leap second warning */\n#define\tLEAP_ADDSECOND\t0x1\t/* last minute of day has 61 seconds */\n#define\tLEAP_DELSECOND\t0x2\t/* last minute of day has 59 seconds */\n#define\tLEAP_NOTINSYNC\t0x3\t/* overload, clock is free running */",
"/*\n * Values for peer mode and packet mode. Only the modes through\n * MODE_BROADCAST and MODE_BCLIENT appear in the transition\n * function. MODE_CONTROL and MODE_PRIVATE can appear in packets,\n * but those never survive to the transition function.\n * is a\n/ */\n#define\tMODE_UNSPEC\t0\t/* unspecified (old version) */\n#define\tMODE_ACTIVE\t1\t/* symmetric active mode */\n#define\tMODE_PASSIVE\t2\t/* symmetric passive mode */\n#define\tMODE_CLIENT\t3\t/* client mode */\n#define\tMODE_SERVER\t4\t/* server mode */\n#define\tMODE_BROADCAST\t5\t/* broadcast mode */\n/*\n * These can appear in packets\n */\n#define\tMODE_CONTROL\t6\t/* control mode */\n#define\tMODE_PRIVATE\t7\t/* private mode */\n/*\n * This is a madeup mode for broadcast client.\n */\n#define\tMODE_BCLIENT\t6\t/* broadcast client mode */",
"/*\n * Values for peer.stratum, sys_stratum\n */\n#define\tSTRATUM_REFCLOCK ((u_char)0) /* default stratum */\n/* A stratum of 0 in the packet is mapped to 16 internally */\n#define\tSTRATUM_PKT_UNSPEC ((u_char)0) /* unspecified in packet */\n#define\tSTRATUM_UNSPEC\t((u_char)16) /* unspecified */",
"/*\n * Values for peer.flags\n */\n#define\tFLAG_CONFIG\t0x0001\t/* association was configured */\n#define\tFLAG_PREEMPT\t0x0002\t/* preemptable association */\n#define\tFLAG_AUTHENTIC\t0x0004\t/* last message was authentic */\n#define\tFLAG_REFCLOCK\t0x0008\t/* this is actually a reference clock */\n#define\tFLAG_BC_VOL\t0x0010\t/* broadcast client volleying */\n#define\tFLAG_PREFER\t0x0020\t/* prefer peer */\n#define\tFLAG_BURST\t0x0040\t/* burst mode */\n#define\tFLAG_PPS\t0x0080\t/* steered by PPS */\n#define\tFLAG_IBURST\t0x0100\t/* initial burst mode */\n#define\tFLAG_NOSELECT\t0x0200\t/* never select */\n#define\tFLAG_TRUE\t0x0400\t/* force truechimer */\n#define\tFLAG_SKEY\t0x0800 /* autokey authentication */\n#define\tFLAG_XLEAVE\t0x1000\t/* interleaved protocol */\n#define\tFLAG_XB\t\t0x2000\t/* interleaved broadcast */\n#define\tFLAG_XBOGUS\t0x4000\t/* interleaved bogus packet */\n#ifdef\tOPENSSL\n#define FLAG_ASSOC\t0x8000\t/* autokey request */\n#endif /* OPENSSL */",
"/*\n * Definitions for the clear() routine. We use memset() to clear\n * the parts of the peer structure which go to zero. These are\n * used to calculate the start address and length of the area.\n */\n#define\tCLEAR_TO_ZERO(p)\t((char *)&((p)->clear_to_zero))\n#define\tEND_CLEAR_TO_ZERO(p)\t((char *)&((p)->end_clear_to_zero))\n#define\tLEN_CLEAR_TO_ZERO\t(END_CLEAR_TO_ZERO((struct peer *)0) \\\n\t\t\t\t - CLEAR_TO_ZERO((struct peer *)0))\n#define CRYPTO_TO_ZERO(p)\t((char *)&((p)->clear_to_zero))\n#define END_CRYPTO_TO_ZERO(p)\t((char *)&((p)->end_clear_to_zero))\n#define LEN_CRYPTO_TO_ZERO\t(END_CRYPTO_TO_ZERO((struct peer *)0) \\\n\t\t\t\t - CRYPTO_TO_ZERO((struct peer *)0))",
"/*\n * Reference clock types. Added as necessary.\n */\n#define\tREFCLK_NONE\t\t0\t/* unknown or missing */\n#define\tREFCLK_LOCALCLOCK\t1\t/* external (e.g., lockclock) */\n#define\tREFCLK_GPS_TRAK\t\t2\t/* TRAK 8810 GPS Receiver */\n#define\tREFCLK_WWV_PST\t\t3\t/* PST/Traconex 1020 WWV/H */\n#define\tREFCLK_SPECTRACOM\t4\t/* Spectracom (generic) Receivers */\n#define\tREFCLK_TRUETIME\t\t5\t/* TrueTime (generic) Receivers */\n#define REFCLK_IRIG_AUDIO\t6\t/* IRIG-B/W audio decoder */\n#define\tREFCLK_CHU_AUDIO\t7\t/* CHU audio demodulator/decoder */\n#define REFCLK_PARSE\t\t8\t/* generic driver (usually DCF77,GPS,MSF) */\n#define\tREFCLK_GPS_MX4200\t9\t/* Magnavox MX4200 GPS */\n#define REFCLK_GPS_AS2201\t10\t/* Austron 2201A GPS */\n#define\tREFCLK_GPS_ARBITER\t11\t/* Arbiter 1088A/B/ GPS */\n#define REFCLK_IRIG_TPRO\t12\t/* KSI/Odetics TPRO-S IRIG */\n#define REFCLK_ATOM_LEITCH\t13\t/* Leitch CSD 5300 Master Clock */\n#define REFCLK_MSF_EES\t\t14\t/* EES M201 MSF Receiver */\n#define\tREFCLK_GPSTM_TRUE\t15\t/* OLD TrueTime GPS/TM-TMD Receiver */\n#define REFCLK_IRIG_BANCOMM\t16\t/* Bancomm GPS/IRIG Interface */\n#define REFCLK_GPS_DATUM\t17\t/* Datum Programmable Time System */\n#define REFCLK_ACTS\t\t18\t/* Generic Auto Computer Time Service */\n#define REFCLK_WWV_HEATH\t19\t/* Heath GC1000 WWV/WWVH Receiver */\n#define REFCLK_GPS_NMEA\t\t20\t/* NMEA based GPS clock */\n#define REFCLK_GPS_VME\t\t21\t/* TrueTime GPS-VME Interface */\n#define REFCLK_ATOM_PPS\t\t22\t/* 1-PPS Clock Discipline */\n#define REFCLK_PTB_ACTS\t\t23\t/* replaced by REFCLK_ACTS */\n#define REFCLK_USNO\t\t24\t/* replaced by REFCLK_ACTS */\n#define REFCLK_GPS_HP\t\t26\t/* HP 58503A Time/Frequency Receiver */\n#define REFCLK_ARCRON_MSF\t27\t/* ARCRON MSF radio clock. */\n#define REFCLK_SHM\t\t28\t/* clock attached thru shared memory */\n#define REFCLK_PALISADE\t\t29\t/* Trimble Navigation Palisade GPS */\n#define REFCLK_ONCORE\t\t30\t/* Motorola UT Oncore GPS */\n#define REFCLK_GPS_JUPITER\t31\t/* Rockwell Jupiter GPS receiver */\n#define REFCLK_CHRONOLOG\t32\t/* Chrono-log K WWVB receiver */\n#define REFCLK_DUMBCLOCK\t33\t/* Dumb localtime clock */\n#define REFCLK_ULINK\t\t34\t/* Ultralink M320 WWVB receiver */\n#define REFCLK_PCF\t\t35\t/* Conrad parallel port radio clock */\n#define REFCLK_WWV_AUDIO\t36\t/* WWV/H audio demodulator/decoder */\n#define REFCLK_FG\t\t37\t/* Forum Graphic GPS */\n#define REFCLK_HOPF_SERIAL\t38\t/* hopf DCF77/GPS serial receiver */\n#define REFCLK_HOPF_PCI\t\t39\t/* hopf DCF77/GPS PCI receiver */\n#define REFCLK_JJY\t\t40\t/* JJY receiver */\n#define\tREFCLK_TT560\t\t41\t/* TrueTime 560 IRIG-B decoder */\n#define REFCLK_ZYFER\t\t42\t/* Zyfer GPStarplus receiver */\n#define REFCLK_RIPENCC\t\t43\t/* RIPE NCC Trimble driver */\n#define REFCLK_NEOCLOCK4X\t44\t/* NeoClock4X DCF77 or TDF receiver */\n#define REFCLK_TSYNCPCI\t45\t/* Spectracom TSYNC PCI timing board */\n#define REFCLK_MAX\t\t45\t/* Spectracom TSYNC PCI timing board */",
"\n/*\n * NTP packet format. The mac field is optional. It isn't really\n * an l_fp either, but for now declaring it that way is convenient.\n * See Appendix A in the specification.\n *\n * Note that all u_fp and l_fp values arrive in network byte order\n * and must be converted (except the mac, which isn't, really).\n */\nstruct pkt {\n\tu_char\tli_vn_mode;\t/* peer leap indicator */\n\tu_char\tstratum;\t/* peer stratum */\n\tu_char\tppoll;\t\t/* peer poll interval */\n\ts_char\tprecision;\t/* peer clock precision */\n\tu_fp\trootdelay;\t/* roundtrip delay to primary source */\n\tu_fp\trootdisp;\t/* dispersion to primary source*/\n\tu_int32\trefid;\t\t/* reference id */\n\tl_fp\treftime;\t/* last update time */\n\tl_fp\torg;\t\t/* originate time stamp */\n\tl_fp\trec;\t\t/* receive time stamp */\n\tl_fp\txmt;\t\t/* transmit time stamp */",
"#define\tLEN_PKT_NOMAC\t(12 * sizeof(u_int32)) /* min header length */\n#define MIN_MAC_LEN\t(1 * sizeof(u_int32))\t/* crypto_NAK */\n#define MAX_MD5_LEN\t(5 * sizeof(u_int32))\t/* MD5 */\n#define\tMAX_MAC_LEN\t(6 * sizeof(u_int32))\t/* SHA */",
"\t/*\n\t * The length of the packet less MAC must be a multiple of 64\n\t * with an RSA modulus and Diffie-Hellman prime of 256 octets\n\t * and maximum host name of 128 octets, the maximum autokey\n\t * command is 152 octets and maximum autokey response is 460\n\t * octets. A packet can contain no more than one command and one\n\t * response, so the maximum total extension field length is 864\n\t * octets. But, to handle humungus certificates, the bank must\n\t * be broke.\n\t */\n#ifdef AUTOKEY\n\tu_int32\texten[NTP_MAXEXTEN / 4]; /* max extension field */\n#else\t/* !AUTOKEY follows */\n\tu_int32\texten[1];\t/* misused */\n#endif\t/* !AUTOKEY */\n\tu_char\tmac[MAX_MAC_LEN]; /* mac */\n};",
"/*\n * Stuff for extracting things from li_vn_mode\n */\n#define\tPKT_MODE(li_vn_mode)\t((u_char)((li_vn_mode) & 0x7))\n#define\tPKT_VERSION(li_vn_mode)\t((u_char)(((li_vn_mode) >> 3) & 0x7))\n#define\tPKT_LEAP(li_vn_mode)\t((u_char)(((li_vn_mode) >> 6) & 0x3))",
"/*\n * Stuff for putting things back into li_vn_mode in packets and vn_mode\n * in ntp_monitor.c's mon_entry.\n */\n#define VN_MODE(v, m)\t\t((((v) & 7) << 3) | ((m) & 0x7))\n#define\tPKT_LI_VN_MODE(l, v, m) ((((l) & 3) << 6) | VN_MODE((v), (m)))",
"\n/*\n * Dealing with stratum. 0 gets mapped to 16 incoming, and back to 0\n * on output.\n */\n#define\tPKT_TO_STRATUM(s)\t((u_char)(((s) == (STRATUM_PKT_UNSPEC)) ?\\\n\t\t\t\t(STRATUM_UNSPEC) : (s)))",
"#define\tSTRATUM_TO_PKT(s)\t((u_char)(((s) == (STRATUM_UNSPEC)) ?\\\n\t\t\t\t(STRATUM_PKT_UNSPEC) : (s)))",
"/*\n * Event codes. Used for reporting errors/events to the control module\n */\n#define\tPEER_EVENT\t0x080\t/* this is a peer event */\n#define CRPT_EVENT\t0x100\t/* this is a crypto event */",
"/*\n * System event codes\n */\n#define\tEVNT_UNSPEC\t0\t/* unspecified */\n#define\tEVNT_NSET\t1\t/* freq not set */\n#define\tEVNT_FSET\t2\t/* freq set */\n#define\tEVNT_SPIK\t3\t/* spike detect */\n#define\tEVNT_FREQ\t4\t/* freq mode */\n#define\tEVNT_SYNC\t5\t/* clock sync */\n#define\tEVNT_SYSRESTART\t6\t/* restart */\n#define\tEVNT_SYSFAULT\t7\t/* panic stop */\n#define\tEVNT_NOPEER\t8\t/* no sys peer */\n#define\tEVNT_ARMED\t9\t/* leap armed */\n#define\tEVNT_DISARMED\t10\t/* leap disarmed */\n#define\tEVNT_LEAP\t11\t/* leap event */\n#define\tEVNT_CLOCKRESET\t12\t/* clock step */\n#define\tEVNT_KERN\t13\t/* kernel event */\n#define\tEVNT_TAI\t14\t/* TAI */\n#define\tEVNT_LEAPVAL\t15\t/* stale leapsecond values */",
"/*\n * Peer event codes\n */\n#define\tPEVNT_MOBIL\t(1 | PEER_EVENT) /* mobilize */\n#define\tPEVNT_DEMOBIL\t(2 | PEER_EVENT) /* demobilize */\n#define\tPEVNT_UNREACH\t(3 | PEER_EVENT) /* unreachable */\n#define\tPEVNT_REACH\t(4 | PEER_EVENT) /* reachable */\n#define\tPEVNT_RESTART\t(5 | PEER_EVENT) /* restart */\n#define\tPEVNT_REPLY\t(6 | PEER_EVENT) /* no reply */\n#define\tPEVNT_RATE\t(7 | PEER_EVENT) /* rate exceeded */\n#define\tPEVNT_DENY\t(8 | PEER_EVENT) /* access denied */\n#define PEVNT_ARMED\t(9 | PEER_EVENT) /* leap armed */\n#define\tPEVNT_NEWPEER\t(10 | PEER_EVENT) /* sys peer */\n#define\tPEVNT_CLOCK\t(11 | PEER_EVENT) /* clock event */\n#define\tPEVNT_AUTH\t(12 | PEER_EVENT) /* bad auth */\n#define\tPEVNT_POPCORN\t(13 | PEER_EVENT) /* popcorn */\n#define\tPEVNT_XLEAVE\t(14 | PEER_EVENT) /* interleave mode */\n#define\tPEVNT_XERR\t(15 | PEER_EVENT) /* interleave error */",
"/*\n * Clock event codes\n */\n#define\tCEVNT_NOMINAL\t0\t/* unspecified */\n#define\tCEVNT_TIMEOUT\t1\t/* no reply */\n#define\tCEVNT_BADREPLY\t2\t/* bad format */\n#define\tCEVNT_FAULT\t3\t/* fault */\n#define\tCEVNT_PROP\t4\t/* bad signal */\n#define\tCEVNT_BADDATE\t5\t/* bad date */\n#define\tCEVNT_BADTIME\t6\t/* bad time */\n#define CEVNT_MAX\tCEVNT_BADTIME",
"/*\n * Very misplaced value. Default port through which we send traps.\n */\n#define\tTRAPPORT\t18447",
"\n/*\n * To speed lookups, peers are hashed by the low order bits of the\n * remote IP address. These definitions relate to that.\n */\n#define\tNTP_HASH_SIZE\t\t128\n#define\tNTP_HASH_MASK\t\t(NTP_HASH_SIZE-1)\n#define\tNTP_HASH_ADDR(src)\t(sock_hash(src) & NTP_HASH_MASK)",
"/*\n * min, min3 and max. Makes it easier to transliterate the spec without\n * thinking about it.\n */\n#define\tmin(a,b)\t(((a) < (b)) ? (a) : (b))\n#define\tmax(a,b)\t(((a) > (b)) ? (a) : (b))\n#define\tmin3(a,b,c)\tmin(min((a),(b)), (c))",
"\n/*\n * Configuration items. These are for the protocol module (proto_config())\n */\n#define\tPROTO_BROADCLIENT\t1\n#define\tPROTO_PRECISION\t\t2\t/* (not used) */\n#define\tPROTO_AUTHENTICATE\t3\n#define\tPROTO_BROADDELAY\t4\n#define\tPROTO_AUTHDELAY\t\t5\t/* (not used) */\n#define PROTO_MULTICAST_ADD\t6\n#define PROTO_MULTICAST_DEL\t7\n#define PROTO_NTP\t\t8\n#define PROTO_KERNEL\t\t9\n#define PROTO_MONITOR\t\t10\n#define PROTO_FILEGEN\t\t11\n#define\tPROTO_PPS\t\t12\n#define PROTO_CAL\t\t13\n#define PROTO_MINCLOCK\t\t14\n#define\tPROTO_MAXCLOCK\t\t15\n#define PROTO_MINSANE\t\t16\n#define PROTO_FLOOR\t\t17\n#define PROTO_CEILING\t\t18\n#define PROTO_COHORT\t\t19\n#define PROTO_CALLDELAY\t\t20\n#define PROTO_MINDISP\t\t21\n#define PROTO_MAXDIST\t\t22\n\t/* available\t\t23 */\n#define\tPROTO_MAXHOP\t\t24\n#define\tPROTO_BEACON\t\t25\n#define\tPROTO_ORPHAN\t\t26\n#define\tPROTO_ORPHWAIT\t\t27\n#define\tPROTO_MODE7\t\t28",
"/*\n * Configuration items for the loop filter\n */\n#define\tLOOP_DRIFTINIT\t\t1\t/* iniitialize frequency */\n#define\tLOOP_KERN_CLEAR\t\t2\t/* set initial frequency offset */\n#define LOOP_MAX\t\t3\t/* set step offset */\n#define LOOP_PANIC\t\t4\t/* set panic offseet */\n#define LOOP_PHI\t\t5\t/* set dispersion rate */\n#define LOOP_MINSTEP\t\t6\t/* set step timeout */\n#define LOOP_MINPOLL\t\t7\t/* set min poll interval (log2 s) */\n#define LOOP_ALLAN\t\t8\t/* set minimum Allan intercept */\n#define LOOP_HUFFPUFF\t\t9\t/* set huff-n'-puff filter length */\n#define LOOP_FREQ\t\t10\t/* set initial frequency */\n#define LOOP_CODEC\t\t11\t/* set audio codec frequency */\n#define\tLOOP_LEAP\t\t12\t/* insert leap after second 23:59 */\n#define\tLOOP_TICK\t\t13\t/* sim. low precision clock */",
"/*\n * Configuration items for the stats printer\n */\n#define\tSTATS_FREQ_FILE\t\t1\t/* configure drift file */\n#define STATS_STATSDIR\t\t2\t/* directory prefix for stats files */\n#define\tSTATS_PID_FILE\t\t3\t/* configure ntpd PID file */\n#define\tSTATS_LEAP_FILE\t\t4\t/* configure ntpd leapseconds file */",
"#define MJD_1900\t\t15020\t/* MJD for 1 Jan 1900 */",
"/*\n * Default parameters. We use these in the absence of something better.\n */\n#define INADDR_NTP\t0xe0000101\t/* NTP multicast address 224.0.1.1 */",
"/*\n * Structure used optionally for monitoring when this is turned on.\n */\ntypedef struct mon_data\tmon_entry;\nstruct mon_data {\n\tmon_entry *\thash_next;\t/* next structure in hash list */\n\tDECL_DLIST_LINK(mon_entry, mru);/* MRU list link pointers */\n\tstruct interface * lcladr;\t/* address on which this arrived */\n\tl_fp\t\tfirst;\t\t/* first time seen */\n\tl_fp\t\tlast;\t\t/* last time seen */\n\tint\t\tleak;\t\t/* leaky bucket accumulator */\n\tint\t\tcount;\t\t/* total packet count */\n\tu_short\t\tflags;\t\t/* restrict flags */\n\tu_char\t\tvn_mode;\t/* packet mode & version */\n\tu_char\t\tcast_flags;\t/* flags MDF_?CAST */\n\tsockaddr_u\trmtadr;\t\t/* address of remote host */\n};",
"/*\n * Values for cast_flags in mon_entry and struct peer. mon_entry uses\n * only the first three, MDF_UCAST, MDF_MCAST, and MDF_BCAST.\n */\n#define\tMDF_UCAST\t0x01\t/* unicast client */\n#define\tMDF_MCAST\t0x02\t/* multicast server */\n#define\tMDF_BCAST\t0x04\t/* broadcast server */\n#define\tMDF_POOL\t0x08\t/* pool client solicitor */\n#define MDF_ACAST\t0x10\t/* manycast client solicitor */\n#define\tMDF_BCLNT\t0x20\t/* eph. broadcast/multicast client */\n#define MDF_UCLNT\t0x40\t/* preemptible manycast or pool client */\n/*\n * In the context of struct peer in ntpd, three of the cast_flags bits\n * represent configured associations which never receive packets, and\n * whose reach is always 0: MDF_BCAST, MDF_MCAST, and MDF_ACAST. The\n * last can be argued as responses are received, but those responses do\n * not affect the MDF_ACAST association's reach register, rather they\n * (may) result in mobilizing ephemeral MDF_ACLNT associations.\n */\n#define MDF_TXONLY_MASK\t(MDF_BCAST | MDF_MCAST | MDF_ACAST | MDF_POOL)\n/*\n * manycastclient-like solicitor association cast_flags bits\n */\n#define MDF_SOLICIT_MASK\t(MDF_ACAST | MDF_POOL)\n/*\n * Values used with mon_enabled to indicate reason for enabling monitoring\n */\n#define MON_OFF\t\t0x00\t\t/* no monitoring */\n#define MON_ON\t\t0x01\t\t/* monitoring explicitly enabled */\n#define MON_RES\t\t0x02\t\t/* implicit monitoring for RES_LIMITED */\n/*\n * Structure used for restrictlist entries\n */\ntypedef struct res_addr4_tag {\n\tu_int32\t\taddr;\t\t/* IPv4 addr (host order) */\n\tu_int32\t\tmask;\t\t/* IPv4 mask (host order) */\n} res_addr4;",
"typedef struct res_addr6_tag {\n\tstruct in6_addr addr;\t\t/* IPv6 addr (net order) */\n\tstruct in6_addr mask;\t\t/* IPv6 mask (net order) */\n} res_addr6;",
"typedef struct restrict_u_tag\trestrict_u;\nstruct restrict_u_tag {\n\trestrict_u *\t\tlink;\t/* link to next entry */\n\tu_int32\t\t\tcount;\t/* number of packets matched */\n\tu_short\t\t\tflags;\t/* accesslist flags */\n\tu_short\t\t\tmflags;\t/* match flags */\n\tu_long\t\t\texpire;\t/* valid until time */\n\tunion {\t\t\t\t/* variant starting here */\n\t\tres_addr4 v4;\n\t\tres_addr6 v6;\n\t} u;\n};\n#define\tV4_SIZEOF_RESTRICT_U\t(offsetof(restrict_u, u)\t\\\n\t\t\t\t + sizeof(res_addr4))\n#define\tV6_SIZEOF_RESTRICT_U\t(offsetof(restrict_u, u)\t\\\n\t\t\t\t + sizeof(res_addr6))",
"/*\n * Access flags\n */\n#define\tRES_IGNORE\t\t0x0001\t/* ignore packet */\n#define\tRES_DONTSERVE\t\t0x0002\t/* access denied */\n#define\tRES_DONTTRUST\t\t0x0004\t/* authentication required */\n#define\tRES_VERSION\t\t0x0008\t/* version mismatch */\n#define\tRES_NOPEER\t\t0x0010\t/* new association denied */\n#define RES_LIMITED\t\t0x0020\t/* packet rate exceeded */\n#define RES_FLAGS\t\t(RES_IGNORE | RES_DONTSERVE |\\\n\t\t\t\t RES_DONTTRUST | RES_VERSION |\\\n\t\t\t\t RES_NOPEER | RES_LIMITED)",
"#define\tRES_NOQUERY\t\t0x0040\t/* mode 6/7 packet denied */\n#define\tRES_NOMODIFY\t\t0x0080\t/* mode 6/7 modify denied */\n#define\tRES_NOTRAP\t\t0x0100\t/* mode 6/7 set trap denied */\n#define\tRES_LPTRAP\t\t0x0200\t/* mode 6/7 low priority trap */",
"#define\tRES_KOD\t\t\t0x0400\t/* send kiss of death packet */\n#define\tRES_MSSNTP\t\t0x0800\t/* enable MS-SNTP authentication */\n#define\tRES_FLAKE\t\t0x1000\t/* flakeway - drop 10% */\n#define\tRES_NOMRULIST\t\t0x2000\t/* mode 6 mrulist denied */",
"#define\tRES_ALLFLAGS\t\t(RES_FLAGS | RES_NOQUERY |\t\\\n\t\t\t\t RES_NOMODIFY | RES_NOTRAP |\t\\\n\t\t\t\t RES_LPTRAP | RES_KOD |\t\t\\\n\t\t\t\t RES_MSSNTP | RES_FLAKE |\t\\\n\t\t\t\t RES_NOMRULIST)",
"/*\n * Match flags\n */\n#define\tRESM_INTERFACE\t\t0x1000\t/* this is an interface */\n#define\tRESM_NTPONLY\t\t0x2000\t/* match source port 123 */\n#define RESM_SOURCE\t\t0x4000\t/* from \"restrict source\" */",
"/*\n * Restriction configuration ops\n */\n#define\tRESTRICT_FLAGS\t\t1\t/* add flags to restrict entry */\n#define\tRESTRICT_UNFLAG\t\t2\t/* remove flags from restrict entry */\n#define\tRESTRICT_REMOVE\t\t3\t/* remove a restrict entry */\n#define\tRESTRICT_REMOVEIF\t4\t/* remove an interface restrict entry */",
"/*\n * Endpoint structure for the select algorithm\n */\nstruct endpoint {\n\tdouble\tval;\t\t\t/* offset of endpoint */\n\tint\ttype;\t\t\t/* interval entry/exit */\n};",
"/*\n * Association matching AM[] return codes\n */\n#define AM_ERR\t\t-1\t\t/* error */\n#define AM_NOMATCH\t0\t\t/* no match */\n#define AM_PROCPKT\t1\t\t/* server/symmetric packet */\t\n#define AM_BCST\t\t2\t\t/* broadcast packet */\t\n#define AM_FXMIT\t3\t\t/* client packet */\n#define AM_MANYCAST\t4\t\t/* manycast or pool */\n#define AM_NEWPASS\t5\t\t/* new passive */\n#define AM_NEWBCL\t6\t\t/* new broadcast */\n#define\tAM_POSSBCL\t7\t\t/* discard broadcast */",
"/* NetInfo configuration locations */\n#ifdef HAVE_NETINFO\n#define NETINFO_CONFIG_DIR \"/config/ntp\"\n#endif",
"/* ntpq -c mrulist rows per request limit in ntpd */\n#define MRU_ROW_LIMIT\t256\n/* similar datagrams per response limit for ntpd */\n#define MRU_FRAGS_LIMIT\t128\n#endif /* NTP_H */"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1, 163], "buggy_code_start_loc": [1, 159], "filenames": ["ChangeLog", "include/ntp.h"], "fixing_code_end_loc": [3, 162], "fixing_code_start_loc": [2, 159], "message": "The ULOGTOD function in ntp.d in SNTP before 4.2.7p366 does not properly perform type conversions from a precision value to a double, which allows remote attackers to cause a denial of service (infinite loop) via a crafted NTP packet.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:fedoraproject:fedora:21:*:*:*:*:*:*:*", "matchCriteriaId": "56BDB5A0-0839-4A20-A003-B8CD56F48171", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:22:*:*:*:*:*:*:*", "matchCriteriaId": "253C303A-E577-4488-93E6-68A8DD942C38", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:23:*:*:*:*:*:*:*", "matchCriteriaId": "E79AB8DD-C907-4038-A931-1A5A4CFB6A5B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:suse:linux_enterprise_debuginfo:11:sp2:*:*:*:*:*:*", "matchCriteriaId": "D5900A25-FDD7-4900-BF7C-F3ECCB714D2B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:suse:linux_enterprise_debuginfo:11:sp3:*:*:*:*:*:*", "matchCriteriaId": "58D3B6FD-B474-4B09-B644-A8634A629280", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:10:sp4:*:*:ltss:*:*:*", "matchCriteriaId": "35BBD83D-BDC7-4678-BE94-639F59281139", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:11:sp2:*:*:ltss:*:*:*", "matchCriteriaId": "CB6476C7-03F2-4939-AB85-69AA524516D9", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:linux_enterprise_server:11:sp3:*:*:ltss:*:*:*", "matchCriteriaId": "B12243B2-D726-404C-ABFF-F1AB51BA1783", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:manager:2.1:*:*:*:*:*:*:*", "matchCriteriaId": "2A33B9F5-E0D1-4A3E-9FFB-5602A25F3227", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:manager_proxy:2.1:*:*:*:*:*:*:*", "matchCriteriaId": "53F0F5A0-70D9-4305-A834-B6FF71E27B30", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:suse:openstack_cloud:5:*:*:*:*:*:*:*", "matchCriteriaId": "88BCD7DC-0FEF-477D-8698-F8D8F1A49D90", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:redhat:enterprise_linux_desktop:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "EE249E1B-A1FD-4E08-AA71-A0E1F10FFE97", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_desktop:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "33C068A4-3780-4EAB-A937-6082DF847564", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_hpc_node:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "C2FAC325-6EEB-466D-9EBA-8ED4DBC9CFBF", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_hpc_node:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "3C84489B-B08C-4854-8A12-D01B6E45CF79", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "9BBCD86A-E6C7-4444-9D74-F861084090F0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "51EF4996-72F4-4FA4-814F-F5991E7A8318", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_workstation:6.0:*:*:*:*:*:*:*", "matchCriteriaId": "E5ED5807-55B7-47C5-97A6-03233F4FBC3A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_workstation:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "825ECE2D-E232-46E0-A047-074B34DB1E97", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:debian:debian_linux:7.0:*:*:*:*:*:*:*", "matchCriteriaId": "16F59A04-14CF-49E2-9973-645477EA09DA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:debian:debian_linux:8.0:*:*:*:*:*:*:*", "matchCriteriaId": "C11E6FB0-C8C0-4527-9AA0-CB9B316F8F43", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:canonical:ubuntu_linux:12.04:*:*:*:lts:*:*:*", "matchCriteriaId": "B6B7CAD7-9D4E-4FDB-88E3-1E583210A01F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:14.04:*:*:*:lts:*:*:*", "matchCriteriaId": "B5A6F2F3-4894-4392-8296-3B8DD2679084", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:15.04:*:*:*:*:*:*:*", "matchCriteriaId": "F38D3B7E-8429-473F-BB31-FC3583EE5A5B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:15.10:*:*:*:*:*:*:*", "matchCriteriaId": "E88A537F-F4D0-46B9-9E37-965233C2A355", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:ntp:ntp:*:p355:*:*:*:*:*:*", "matchCriteriaId": "07FBDFE4-D886-4461-A360-480F50BD12C7", "versionEndExcluding": null, "versionEndIncluding": "4.2.7", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:novell:leap:42.2:*:*:*:*:*:*:*", "matchCriteriaId": "A64AAD2D-38ED-4BA2-A27A-A2716F28D43A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:opensuse:leap:42.1:*:*:*:*:*:*:*", "matchCriteriaId": "4863BE36-D16A-4D75-90D9-FD76DB5B48B7", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:tim_4r-ie_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "E0730ED6-676B-4200-BC07-C0B4531B242C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:tim_4r-ie:-:*:*:*:*:*:*:*", "matchCriteriaId": "0B87B16C-9E9F-448B-9255-B2BB2B8CAD63", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:tim_4r-id_dnp3_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "B8851DB6-6B63-4D78-A100-50F81B4DF75B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:tim_4r-id_dnp3:-:*:*:*:*:*:*:*", "matchCriteriaId": "1A8AC343-6F4F-4CAF-BD09-F8F1D2F6DBB0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:oracle:linux:6:-:*:*:*:*:*:*", "matchCriteriaId": "D7B037A8-72A6-4DFF-94B2-D688A5F6F876", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}], "descriptions": [{"lang": "en", "value": "The ULOGTOD function in ntp.d in SNTP before 4.2.7p366 does not properly perform type conversions from a precision value to a double, which allows remote attackers to cause a denial of service (infinite loop) via a crafted NTP packet."}, {"lang": "es", "value": "La funci\u00f3n ULOGTOD en el archivo ntp.d en SNTP en versiones anteriores a la 4.2.7p366 no realiza apropiadamente las conversiones de tipo de un valor de precisi\u00f3n a uno doble, lo que permite a los atacantes remotos causar una denegaci\u00f3n de servicio (bucle infinito) por medio de un paquete NTP creado."}], "evaluatorComment": null, "id": "CVE-2015-5219", "lastModified": "2023-02-13T00:51:47.453", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 5.0, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:N/AC:L/Au:N/C:N/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2017-07-21T14:29:00.867", "references": [{"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://aix.software.ibm.com/aix/efixes/security/ntp_advisory4.asc"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "http://bk1.ntp.org/ntp-dev/?PAGE=patch&REV=51786731Gr4-NOrTBC_a_uXO4wuGhg"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-November/170926.html"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-October/169167.html"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://lists.fedoraproject.org/pipermail/package-announce/2015-September/166992.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://rhn.redhat.com/errata/RHSA-2016-0780.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://rhn.redhat.com/errata/RHSA-2016-2583.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.debian.org/security/2015/dsa-3388"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2015/08/25/3"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.oracle.com/technetwork/topics/security/linuxbulletinapr2016-2952096.html"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/76473"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://www.ubuntu.com/usn/USN-2783-1"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking"], "url": "https://bugzilla.redhat.com/show_bug.cgi?id=1255118"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-497656.pdf"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/ntp-project/ntp/commit/5f295cd05c3c136d39f5b3e500a2d781bdbb59c8"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "US Government Resource"], "url": "https://us-cert.cisa.gov/ics/advisories/icsa-21-103-11"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=isg3T1024157"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21985122"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21986956"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21988706"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www-01.ibm.com/support/docview.wss?uid=swg21989542"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "https://www.ibm.com/support/home/docdisplay?lndocid=migr-5099409"}], "sourceIdentifier": "secalert@redhat.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-704"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/ntp-project/ntp/commit/5f295cd05c3c136d39f5b3e500a2d781bdbb59c8"}, "type": "CWE-704"}
| 357
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Copyright IBM Corp. 1999, 2010\n *\n * Author(s):\tHartmut Penner <hp@de.ibm.com>\n *\t\tMartin Schwidefsky <schwidefsky@de.ibm.com>\n *\t\tRob van der Heij <rvdhei@iae.nl>\n *\t\tHeiko Carstens <heiko.carstens@de.ibm.com>\n *\n */",
"#include <linux/init.h>\n#include <linux/linkage.h>\n#include <asm/asm-offsets.h>\n#include <asm/thread_info.h>\n#include <asm/page.h>",
"__HEAD\nENTRY(startup_continue)\n\tlarl\t%r1,sched_clock_base_cc\n\tmvc\t0(8,%r1),__LC_LAST_UPDATE_CLOCK\n\tlarl\t%r13,.LPG1\t\t# get base\n\tlctlg\t%c0,%c15,.Lctl-.LPG1(%r13)\t# load control registers\n\tlg\t%r12,.Lparmaddr-.LPG1(%r13)\t# pointer to parameter area\n\t\t\t\t\t# move IPL device to lowcore\n\tlghi\t%r0,__LC_PASTE\n\tstg\t%r0,__LC_VDSO_PER_CPU\n#\n# Setup stack\n#\n\tlarl\t%r15,init_thread_union\n\tstg\t%r15,__LC_THREAD_INFO\t# cache thread info in lowcore\n\tlg\t%r14,__TI_task(%r15)\t# cache current in lowcore\n\tstg\t%r14,__LC_CURRENT\n\taghi\t%r15,1<<(PAGE_SHIFT+THREAD_ORDER) # init_task_union + THREAD_SIZE\n\tstg\t%r15,__LC_KERNEL_STACK\t# set end of kernel stack\n\taghi\t%r15,-160\n#\n# Save ipl parameters, clear bss memory, initialize storage key for kernel pages,\n# and create a kernel NSS if the SAVESYS= parm is defined\n#\n\tbrasl\t%r14,startup_init\n\tlpswe\t.Lentry-.LPG1(13)\t# jump to _stext in primary-space,\n\t\t\t\t\t# virtual and never return ...\n\t.align\t16\n.LPG1:\n.Lentry:.quad\t0x0000000180000000,_stext\n.Lctl:\t.quad\t0x04040000\t\t# cr0: AFP registers & secondary space\n\t.quad\t0\t\t\t# cr1: primary space segment table\n\t.quad\t.Lduct\t\t\t# cr2: dispatchable unit control table\n\t.quad\t0\t\t\t# cr3: instruction authorization\n\t.quad\t0\t\t\t# cr4: instruction authorization\n\t.quad\t.Lduct\t\t\t# cr5: primary-aste origin\n\t.quad\t0\t\t\t# cr6:\tI/O interrupts\n\t.quad\t0\t\t\t# cr7:\tsecondary space segment table\n\t.quad\t0\t\t\t# cr8:\taccess registers translation\n\t.quad\t0\t\t\t# cr9:\ttracing off\n\t.quad\t0\t\t\t# cr10: tracing off\n\t.quad\t0\t\t\t# cr11: tracing off\n\t.quad\t0\t\t\t# cr12: tracing off\n\t.quad\t0\t\t\t# cr13: home space segment table\n\t.quad\t0xc0000000\t\t# cr14: machine check handling off",
"\t.quad\t0\t\t\t# cr15: linkage stack operations",
".Lpcmsk:.quad\t0x0000000180000000\n.L4malign:.quad 0xffffffffffc00000\n.Lscan2g:.quad\t0x80000000 + 0x20000 - 8\t# 2GB + 128K - 8\n.Lnop:\t.long\t0x07000700\n.Lparmaddr:\n\t.quad\tPARMAREA\n\t.align\t64",
".Lduct: .long\t0,0,0,0,.Lduald,0,0,0",
"\t.long\t0,0,0,0,0,0,0,0",
"",
"\t.align\t128\n.Lduald:.rept\t8\n\t.long\t0x80000000,0,0,0\t# invalid access-list entries\n\t.endr",
"",
"\nENTRY(_ehead)",
"\t.org\t0x100000 - 0x11000\t# head.o ends at 0x11000\n#\n# startup-code, running in absolute addressing mode\n#\nENTRY(_stext)\n\tbasr\t%r13,0\t\t\t# get base\n.LPG3:\n# check control registers\n\tstctg\t%c0,%c15,0(%r15)\n\toi\t6(%r15),0x60\t\t# enable sigp emergency & external call\n\toi\t4(%r15),0x10\t\t# switch on low address proctection\n\tlctlg\t%c0,%c15,0(%r15)",
"\tlam\t0,15,.Laregs-.LPG3(%r13)\t# load acrs needed by uaccess\n\tbrasl\t%r14,start_kernel\t# go to C code\n#\n# We returned from start_kernel ?!? PANIK\n#\n\tbasr\t%r13,0\n\tlpswe\t.Ldw-.(%r13)\t\t# load disabled wait psw",
"\t.align\t8\n.Ldw:\t.quad\t0x0002000180000000,0x0000000000000000\n.Laregs:.long\t0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
] |
[
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [75], "buggy_code_start_loc": [62], "filenames": ["arch/s390/kernel/head64.S"], "fixing_code_end_loc": [79], "fixing_code_start_loc": [62], "message": "arch/s390/kernel/head64.S in the Linux kernel before 3.13.5 on the s390 platform does not properly handle attempted use of the linkage stack, which allows local users to cause a denial of service (system crash) by executing a crafted instruction.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "3E693631-6574-496A-9CD3-B980B67CACBB", "versionEndExcluding": "3.13.5", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "arch/s390/kernel/head64.S in the Linux kernel before 3.13.5 on the s390 platform does not properly handle attempted use of the linkage stack, which allows local users to cause a denial of service (system crash) by executing a crafted instruction."}, {"lang": "es", "value": "arch/s390/kernel/head64.S en el kernel de Linux anterior a 3.13.5 en la plataforma s390 no maneja debidamente intentos de uso de la pila de vinculaci\u00f3n, lo que permite a usuarios locales causar una denegaci\u00f3n de servicio (ca\u00edda de sistema) mediante la ejecuci\u00f3n de una instrucci\u00f3n manipulada."}], "evaluatorComment": null, "id": "CVE-2014-2039", "lastModified": "2023-02-13T00:38:40.030", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 4.9, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:L/AC:L/Au:N/C:N/I:N/A:C", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 6.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": null}, "published": "2014-02-28T06:18:54.633", "references": [{"source": "secalert@redhat.com", "tags": null, "url": "http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git%3Ba=commit%3Bh=8d7f6690cedb83456edd41c9bd583783f0703bf0"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://linux.oracle.com/errata/ELSA-2014-0771.html"}, {"source": "secalert@redhat.com", "tags": ["Release Notes", "Vendor Advisory"], "url": "http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.13.5"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2014/02/20/14"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/65700"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Third Party Advisory"], "url": "https://bugzilla.redhat.com/show_bug.cgi?id=1067558"}, {"source": "secalert@redhat.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/8d7f6690cedb83456edd41c9bd583783f0703bf0"}], "sourceIdentifier": "secalert@redhat.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-20"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/8d7f6690cedb83456edd41c9bd583783f0703bf0"}, "type": "CWE-20"}
| 358
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Copyright IBM Corp. 1999, 2010\n *\n * Author(s):\tHartmut Penner <hp@de.ibm.com>\n *\t\tMartin Schwidefsky <schwidefsky@de.ibm.com>\n *\t\tRob van der Heij <rvdhei@iae.nl>\n *\t\tHeiko Carstens <heiko.carstens@de.ibm.com>\n *\n */",
"#include <linux/init.h>\n#include <linux/linkage.h>\n#include <asm/asm-offsets.h>\n#include <asm/thread_info.h>\n#include <asm/page.h>",
"__HEAD\nENTRY(startup_continue)\n\tlarl\t%r1,sched_clock_base_cc\n\tmvc\t0(8,%r1),__LC_LAST_UPDATE_CLOCK\n\tlarl\t%r13,.LPG1\t\t# get base\n\tlctlg\t%c0,%c15,.Lctl-.LPG1(%r13)\t# load control registers\n\tlg\t%r12,.Lparmaddr-.LPG1(%r13)\t# pointer to parameter area\n\t\t\t\t\t# move IPL device to lowcore\n\tlghi\t%r0,__LC_PASTE\n\tstg\t%r0,__LC_VDSO_PER_CPU\n#\n# Setup stack\n#\n\tlarl\t%r15,init_thread_union\n\tstg\t%r15,__LC_THREAD_INFO\t# cache thread info in lowcore\n\tlg\t%r14,__TI_task(%r15)\t# cache current in lowcore\n\tstg\t%r14,__LC_CURRENT\n\taghi\t%r15,1<<(PAGE_SHIFT+THREAD_ORDER) # init_task_union + THREAD_SIZE\n\tstg\t%r15,__LC_KERNEL_STACK\t# set end of kernel stack\n\taghi\t%r15,-160\n#\n# Save ipl parameters, clear bss memory, initialize storage key for kernel pages,\n# and create a kernel NSS if the SAVESYS= parm is defined\n#\n\tbrasl\t%r14,startup_init\n\tlpswe\t.Lentry-.LPG1(13)\t# jump to _stext in primary-space,\n\t\t\t\t\t# virtual and never return ...\n\t.align\t16\n.LPG1:\n.Lentry:.quad\t0x0000000180000000,_stext\n.Lctl:\t.quad\t0x04040000\t\t# cr0: AFP registers & secondary space\n\t.quad\t0\t\t\t# cr1: primary space segment table\n\t.quad\t.Lduct\t\t\t# cr2: dispatchable unit control table\n\t.quad\t0\t\t\t# cr3: instruction authorization\n\t.quad\t0\t\t\t# cr4: instruction authorization\n\t.quad\t.Lduct\t\t\t# cr5: primary-aste origin\n\t.quad\t0\t\t\t# cr6:\tI/O interrupts\n\t.quad\t0\t\t\t# cr7:\tsecondary space segment table\n\t.quad\t0\t\t\t# cr8:\taccess registers translation\n\t.quad\t0\t\t\t# cr9:\ttracing off\n\t.quad\t0\t\t\t# cr10: tracing off\n\t.quad\t0\t\t\t# cr11: tracing off\n\t.quad\t0\t\t\t# cr12: tracing off\n\t.quad\t0\t\t\t# cr13: home space segment table\n\t.quad\t0xc0000000\t\t# cr14: machine check handling off",
"\t.quad\t.Llinkage_stack\t\t# cr15: linkage stack operations",
".Lpcmsk:.quad\t0x0000000180000000\n.L4malign:.quad 0xffffffffffc00000\n.Lscan2g:.quad\t0x80000000 + 0x20000 - 8\t# 2GB + 128K - 8\n.Lnop:\t.long\t0x07000700\n.Lparmaddr:\n\t.quad\tPARMAREA\n\t.align\t64",
".Lduct: .long\t0,.Laste,.Laste,0,.Lduald,0,0,0",
"\t.long\t0,0,0,0,0,0,0,0",
".Laste:\t.quad\t0,0xffffffffffffffff,0,0,0,0,0,0",
"\t.align\t128\n.Lduald:.rept\t8\n\t.long\t0x80000000,0,0,0\t# invalid access-list entries\n\t.endr",
".Llinkage_stack:\n\t.long\t0,0,0x89000000,0,0,0,0x8a000000,0",
"\nENTRY(_ehead)",
"\t.org\t0x100000 - 0x11000\t# head.o ends at 0x11000\n#\n# startup-code, running in absolute addressing mode\n#\nENTRY(_stext)\n\tbasr\t%r13,0\t\t\t# get base\n.LPG3:\n# check control registers\n\tstctg\t%c0,%c15,0(%r15)\n\toi\t6(%r15),0x60\t\t# enable sigp emergency & external call\n\toi\t4(%r15),0x10\t\t# switch on low address proctection\n\tlctlg\t%c0,%c15,0(%r15)",
"\tlam\t0,15,.Laregs-.LPG3(%r13)\t# load acrs needed by uaccess\n\tbrasl\t%r14,start_kernel\t# go to C code\n#\n# We returned from start_kernel ?!? PANIK\n#\n\tbasr\t%r13,0\n\tlpswe\t.Ldw-.(%r13)\t\t# load disabled wait psw",
"\t.align\t8\n.Ldw:\t.quad\t0x0002000180000000,0x0000000000000000\n.Laregs:.long\t0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [75], "buggy_code_start_loc": [62], "filenames": ["arch/s390/kernel/head64.S"], "fixing_code_end_loc": [79], "fixing_code_start_loc": [62], "message": "arch/s390/kernel/head64.S in the Linux kernel before 3.13.5 on the s390 platform does not properly handle attempted use of the linkage stack, which allows local users to cause a denial of service (system crash) by executing a crafted instruction.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "3E693631-6574-496A-9CD3-B980B67CACBB", "versionEndExcluding": "3.13.5", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "arch/s390/kernel/head64.S in the Linux kernel before 3.13.5 on the s390 platform does not properly handle attempted use of the linkage stack, which allows local users to cause a denial of service (system crash) by executing a crafted instruction."}, {"lang": "es", "value": "arch/s390/kernel/head64.S en el kernel de Linux anterior a 3.13.5 en la plataforma s390 no maneja debidamente intentos de uso de la pila de vinculaci\u00f3n, lo que permite a usuarios locales causar una denegaci\u00f3n de servicio (ca\u00edda de sistema) mediante la ejecuci\u00f3n de una instrucci\u00f3n manipulada."}], "evaluatorComment": null, "id": "CVE-2014-2039", "lastModified": "2023-02-13T00:38:40.030", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 4.9, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:L/AC:L/Au:N/C:N/I:N/A:C", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 6.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": null}, "published": "2014-02-28T06:18:54.633", "references": [{"source": "secalert@redhat.com", "tags": null, "url": "http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git%3Ba=commit%3Bh=8d7f6690cedb83456edd41c9bd583783f0703bf0"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://linux.oracle.com/errata/ELSA-2014-0771.html"}, {"source": "secalert@redhat.com", "tags": ["Release Notes", "Vendor Advisory"], "url": "http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.13.5"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2014/02/20/14"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/65700"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Third Party Advisory"], "url": "https://bugzilla.redhat.com/show_bug.cgi?id=1067558"}, {"source": "secalert@redhat.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/8d7f6690cedb83456edd41c9bd583783f0703bf0"}], "sourceIdentifier": "secalert@redhat.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-20"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/8d7f6690cedb83456edd41c9bd583783f0703bf0"}, "type": "CWE-20"}
| 358
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.",
"Licensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at",
" http://www.apache.org/licenses/LICENSE-2.0",
"Unless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n==============================================================================*/",
"// See docs in ../ops/random_ops.cc.",
"#define EIGEN_USE_THREADS",
"#include <algorithm>\n#include <cmath>\n#include <memory>",
"#include \"tensorflow/core/framework/op_kernel.h\"\n#include \"tensorflow/core/framework/register_types.h\"\n#include \"tensorflow/core/framework/tensor.h\"\n#include \"tensorflow/core/framework/tensor_shape.h\"\n#include \"tensorflow/core/framework/tensor_util.h\"\n#include \"tensorflow/core/kernels/random_op_cpu.h\"\n#include \"tensorflow/core/lib/hash/crc32c.h\"\n#include \"tensorflow/core/lib/random/random_distributions.h\"\n#include \"tensorflow/core/lib/random/simple_philox.h\"\n#include \"tensorflow/core/platform/logging.h\"\n#include \"tensorflow/core/util/guarded_philox_random.h\"\n#include \"tensorflow/core/util/work_sharder.h\"",
"#if EIGEN_COMP_GNUC && __cplusplus > 199711L\n#define DISABLE_FLOAT_EQUALITY_WARNING \\\n _Pragma(\"GCC diagnostic push\") \\\n _Pragma(\"GCC diagnostic ignored \\\"-Wfloat-equal\\\"\")\n#define ENABLE_FLOAT_EQUALITY_WARNING _Pragma(\"GCC diagnostic pop\")\n#else\n#define DISABLE_FLOAT_EQUALITY_WARNING\n#define ENABLE_FLOAT_EQUALITY_WARNING\n#endif",
"namespace tensorflow {",
"typedef Eigen::ThreadPoolDevice CPUDevice;\ntypedef Eigen::GpuDevice GPUDevice;",
"namespace {",
"static Status AllocateOutputWithShape(OpKernelContext* ctx, const Tensor& shape,\n int index, Tensor** output) {\n TensorShape tensor_shape;\n TF_RETURN_IF_ERROR(tensor::MakeShape(shape, &tensor_shape));\n return ctx->allocate_output(index, tensor_shape, output);\n}",
"// For now, use the same interface as RandomOp, so we can choose either one\n// at the run-time.\ntemplate <typename Device, class Distribution>\nclass PhiloxRandomOp : public OpKernel {\n public:\n typedef typename Distribution::ResultElementType T;\n explicit PhiloxRandomOp(OpKernelConstruction* ctx) : OpKernel(ctx) {\n OP_REQUIRES_OK(ctx, generator_.Init(ctx));\n }",
" void Compute(OpKernelContext* ctx) override {\n const Tensor& shape = ctx->input(0);\n Tensor* output;\n OP_REQUIRES_OK(ctx, AllocateOutputWithShape(ctx, shape, 0, &output));\n auto output_flat = output->flat<T>();\n functor::FillPhiloxRandom<Device, Distribution>()(\n ctx, ctx->eigen_device<Device>(), /*key=*/nullptr, /*counter=*/nullptr,\n // Multiplier 256 is the same as in FillPhiloxRandomTask; do not change\n // it just here.\n generator_.ReserveRandomOutputs(output_flat.size(), 256),\n output_flat.data(), output_flat.size(), Distribution());\n }",
" private:\n GuardedPhiloxRandom generator_;\n};",
"template <typename Device, class IntType>\nclass RandomUniformIntOp : public OpKernel {\n public:\n explicit RandomUniformIntOp(OpKernelConstruction* ctx) : OpKernel(ctx) {\n OP_REQUIRES_OK(ctx, generator_.Init(ctx));\n }",
" void Compute(OpKernelContext* ctx) override {\n const Tensor& shape = ctx->input(0);\n const Tensor& minval = ctx->input(1);\n const Tensor& maxval = ctx->input(2);\n OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(minval.shape()),\n errors::InvalidArgument(\"minval must be 0-D, got shape \",\n minval.shape().DebugString()));\n OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(maxval.shape()),\n errors::InvalidArgument(\"maxval must be 0-D, got shape \",\n maxval.shape().DebugString()));",
" // Allocate output, and exit early if possible\n Tensor* output;\n OP_REQUIRES_OK(ctx, AllocateOutputWithShape(ctx, shape, 0, &output));\n if (output->NumElements() == 0) return;",
" // Verify that minval < maxval. This check intentionally happens after the\n // early exit for empty output. Zero impossible things are fine.\n IntType lo = minval.scalar<IntType>()();\n IntType hi = maxval.scalar<IntType>()();\n OP_REQUIRES(\n ctx, lo < hi,\n errors::InvalidArgument(\"Need minval < maxval, got \", lo, \" >= \", hi));",
" // Build distribution\n typedef random::UniformDistribution<random::PhiloxRandom, IntType>\n Distribution;\n Distribution dist(lo, hi);",
" auto output_flat = output->flat<IntType>();\n functor::FillPhiloxRandom<Device, Distribution>()(\n ctx, ctx->eigen_device<Device>(), /*key=*/nullptr, /*counter=*/nullptr,\n // Multiplier 256 is the same as in FillPhiloxRandomTask; do not change\n // it just here.\n generator_.ReserveRandomOutputs(output_flat.size(), 256),\n output_flat.data(), output_flat.size(), dist);\n }",
" private:\n GuardedPhiloxRandom generator_;\n};",
"// Samples from one or more gamma distributions. All internal computations are\n// done with double precision for numerical stability.\ntemplate <typename T>\nclass RandomGammaOp : public OpKernel {\n public:\n explicit RandomGammaOp(OpKernelConstruction* context) : OpKernel(context) {\n OP_REQUIRES_OK(context, generator_.Init(context));\n }",
" void Compute(OpKernelContext* ctx) override {\n const Tensor& shape_t = ctx->input(0);\n const Tensor& alpha_t = ctx->input(1);",
" OP_REQUIRES(ctx,\n TensorShapeUtils::IsVector(shape_t.shape()) &&\n (shape_t.dtype() == DataType::DT_INT32 ||\n shape_t.dtype() == DataType::DT_INT64),\n errors::InvalidArgument(\n \"shape must be a vector of {int32,int64}, got shape: \",\n shape_t.DebugString()));\n TensorShape samples_shape;\n if (shape_t.dtype() == DataType::DT_INT32) {\n auto vec = shape_t.flat<int32>();\n OP_REQUIRES_OK(ctx, TensorShapeUtils::MakeShape(vec.data(), vec.size(),\n &samples_shape));\n } else if (shape_t.dtype() == DataType::DT_INT64) {\n auto vec = shape_t.flat<int64_t>();\n OP_REQUIRES_OK(ctx, TensorShapeUtils::MakeShape(vec.data(), vec.size(),\n &samples_shape));\n }\n const int64_t samples_per_alpha = samples_shape.num_elements();\n",
" samples_shape.AppendShape(alpha_t.shape());",
" // Allocate output samples.\n Tensor* samples_t = nullptr;\n OP_REQUIRES_OK(ctx, ctx->allocate_output(0, samples_shape, &samples_t));",
" if (samples_shape.num_elements() == 0) return;",
" using random::PhiloxRandom;",
" typedef random::NormalDistribution<PhiloxRandom, double> Normal;\n typedef random::UniformDistribution<PhiloxRandom, double> Uniform;\n#define UNIFORM(X) \\\n if (uniform_remaining == 0) { \\\n uniform_remaining = Uniform::kResultElementCount; \\\n uniform_result = uniform(&gen); \\\n } \\\n uniform_remaining--; \\\n double X = uniform_result[uniform_remaining]",
" // Each attempt is 95+% successful, and requires 1-2 normal + 1 uniform\n static constexpr int kReservedSamplesPerOutput = 256;",
" const auto alpha_flat = alpha_t.flat<T>().data();\n const int64_t num_alphas = alpha_t.NumElements();\n OP_REQUIRES(ctx, num_alphas > 0,\n errors::InvalidArgument(\n \"Input alpha should have non-zero element count, got: \",\n num_alphas));\n auto samples_flat = samples_t->flat<T>().data();\n PhiloxRandom rng = generator_.ReserveRandomOutputs(\n samples_per_alpha * num_alphas, kReservedSamplesPerOutput);",
" // We partition work first across alphas then across samples-per-alpha to\n // avoid a couple flops which can be done on a per-alpha basis.",
" auto DoWork = [samples_per_alpha, num_alphas, &rng, samples_flat,\n alpha_flat](int64_t start_output, int64_t limit_output) {\n using Eigen::numext::exp;\n using Eigen::numext::log;\n using Eigen::numext::log1p;\n using Eigen::numext::pow;",
" // Capturing \"rng\" by-value would only make a copy for the _shared_\n // lambda. Since we want to let each worker have its own copy, we pass\n // \"rng\" by reference and explicitly do a copy assignment.",
" Normal normal;\n Uniform uniform;\n typename Normal::ResultType norm_result;\n typename Uniform::ResultType uniform_result;\n for (int64_t output_idx = start_output; output_idx < limit_output;\n /* output_idx incremented within inner loop below */) {\n int64_t alpha_idx = output_idx / samples_per_alpha;",
" // Instead of +alpha_idx for each sample, we offset the pointer once.\n T* const samples_alpha_offset = samples_flat + alpha_idx;",
" // Several calculations can be done on a per-alpha basis.\n const double alpha = static_cast<double>(alpha_flat[alpha_idx]);",
" DISABLE_FLOAT_EQUALITY_WARNING\n if (alpha == static_cast<double>(1.0)) {\n ENABLE_FLOAT_EQUALITY_WARNING\n // Sample from an exponential distribution.\n for (int64_t sample_idx = output_idx % samples_per_alpha;\n sample_idx < samples_per_alpha && output_idx < limit_output;\n sample_idx++, output_idx++) {\n // As we want data stable regardless of sharding\n // (including eventually on GPU), we skip on a per-sample basis.\n PhiloxRandom gen = rng;\n gen.Skip(kReservedSamplesPerOutput * output_idx);\n int16_t uniform_remaining = 0;\n UNIFORM(u);\n const double res = -log1p(-u);\n samples_alpha_offset[sample_idx * num_alphas] = static_cast<T>(res);\n } // for (sample_idx)\n } else { // if alpha != 1.0\n // Transformation-rejection from pairs of uniform and normal random\n // variables. http://dl.acm.org/citation.cfm?id=358414\n //\n // The algorithm has an acceptance rate of ~95% for small alpha (~1),\n // and higher accept rates for higher alpha, so runtime is\n // O(NumAlphas * NumSamples * k) with k ~ 1 / 0.95.\n //\n // For alpha<1, we add one to d=alpha-1/3, and multiply the final\n // result by uniform()^(1/alpha)\n const bool alpha_less_than_one = alpha < 1;\n const double d = alpha + (alpha_less_than_one ? 2.0 / 3 : -1.0 / 3);\n const double c = 1.0 / 3 / sqrt(d);",
" // Compute the rest of the samples for the current alpha value.\n for (int64_t sample_idx = output_idx % samples_per_alpha;\n sample_idx < samples_per_alpha && output_idx < limit_output;\n sample_idx++, output_idx++) {\n // Since each sample may use a variable number of normal/uniform\n // samples, and we want data stable regardless of sharding\n // (including eventually on GPU), we skip on a per-sample basis.\n PhiloxRandom gen = rng;\n gen.Skip(kReservedSamplesPerOutput * output_idx);\n int16_t norm_remaining = 0;\n int16_t uniform_remaining = 0;",
" // Keep trying until we don't reject a sample. In practice, we will\n // only reject ~5% at worst, for low alpha near 1.\n while (true) {\n if (norm_remaining == 0) {\n norm_remaining = Normal::kResultElementCount;\n norm_result = normal(&gen);\n }\n norm_remaining--;\n const double x = norm_result[norm_remaining];\n double v = 1 + c * x;\n if (v <= 0) {\n continue;\n }\n v = v * v * v;\n UNIFORM(u);\n // The first option in the if is a \"squeeze\" short-circuit to\n // dodge the two logs. Magic constant sourced from the paper\n // linked above. Upward of .91 of the area covered by the log\n // inequality is covered by the squeeze as well (larger coverage\n // for smaller values of alpha).\n if ((u < 1 - 0.0331 * (x * x) * (x * x)) ||\n (log(u) < 0.5 * x * x + d * (1 - v + log(v)))) {\n double res = d * v;\n if (alpha_less_than_one) {\n UNIFORM(b);\n res *= pow(b, 1 / alpha);\n }\n samples_alpha_offset[sample_idx * num_alphas] =\n static_cast<T>(res);\n break;\n }\n } // while: true\n } // for: sample_idx\n } // if (alpha == 1.0)\n } // for: output_idx\n }; // DoWork\n#undef UNIFORM\n // Two calls to log only occur for ~10% of samples reaching the log line.\n // 2 x 100 (64-bit cycles per log) x 0.10 = ~20.\n // Other ops: sqrt, +, *, /, %... something like 15 of these, at 3-6 cycles\n // each = ~60.\n // All of this /0.95 due to the rejection possibility = ~85.\n static const int kElementCost = 85 + 2 * Normal::kElementCost +\n Uniform::kElementCost +\n 3 * PhiloxRandom::kElementCost;\n auto worker_threads = *(ctx->device()->tensorflow_cpu_worker_threads());\n Shard(worker_threads.num_threads, worker_threads.workers,\n num_alphas * samples_per_alpha, kElementCost, DoWork);\n }",
" private:\n GuardedPhiloxRandom generator_;",
" TF_DISALLOW_COPY_AND_ASSIGN(RandomGammaOp);\n};",
"} // namespace",
"#define REGISTER(TYPE) \\\n template struct functor::FillPhiloxRandom< \\\n CPUDevice, random::UniformDistribution<random::PhiloxRandom, TYPE>>; \\\n template struct functor::FillPhiloxRandom< \\\n CPUDevice, random::NormalDistribution<random::PhiloxRandom, TYPE>>; \\\n template struct functor::FillPhiloxRandom< \\\n CPUDevice, \\\n random::TruncatedNormalDistribution< \\\n random::SingleSampleAdapter<random::PhiloxRandom>, TYPE>>; \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomUniform\") \\\n .Device(DEVICE_CPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp<CPUDevice, random::UniformDistribution< \\\n random::PhiloxRandom, TYPE>>); \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomStandardNormal\") \\\n .Device(DEVICE_CPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp<CPUDevice, \\\n random::NormalDistribution<random::PhiloxRandom, TYPE>>); \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"TruncatedNormal\") \\\n .Device(DEVICE_CPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp< \\\n CPUDevice, \\\n random::TruncatedNormalDistribution< \\\n random::SingleSampleAdapter<random::PhiloxRandom>, TYPE>>); \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomGamma\").Device(DEVICE_CPU).TypeConstraint<TYPE>(\"T\"), \\\n RandomGammaOp<TYPE>)",
"#define REGISTER_FULL_INT(IntType) \\\n template struct functor::FillPhiloxRandom< \\\n CPUDevice, \\\n random::UniformFullIntDistribution<random::PhiloxRandom, IntType>>",
"#define REGISTER_INT(IntType) \\\n REGISTER_FULL_INT(IntType); \\\n template struct functor::FillPhiloxRandom< \\\n CPUDevice, random::UniformDistribution<random::PhiloxRandom, IntType>>; \\\n REGISTER_KERNEL_BUILDER(Name(\"RandomUniformInt\") \\\n .Device(DEVICE_CPU) \\\n .HostMemory(\"shape\") \\\n .HostMemory(\"minval\") \\\n .HostMemory(\"maxval\") \\\n .TypeConstraint<IntType>(\"Tout\"), \\\n RandomUniformIntOp<CPUDevice, IntType>);",
"TF_CALL_half(REGISTER);\nTF_CALL_bfloat16(REGISTER);\nTF_CALL_float(REGISTER);\nTF_CALL_double(REGISTER);\nTF_CALL_int32(REGISTER_INT);\nTF_CALL_int64(REGISTER_INT);\nTF_CALL_uint32(REGISTER_FULL_INT);\nTF_CALL_uint64(REGISTER_FULL_INT);",
"#undef REGISTER\n#undef REGISTER_INT\n#undef REGISTER_FULL_INT",
"#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM",
"#define REGISTER(TYPE) \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomUniform\") \\\n .Device(DEVICE_GPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<int32>(\"T\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp<GPUDevice, random::UniformDistribution< \\\n random::PhiloxRandom, TYPE>>); \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomStandardNormal\") \\\n .Device(DEVICE_GPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<int32>(\"T\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp<GPUDevice, \\\n random::NormalDistribution<random::PhiloxRandom, TYPE>>); \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"TruncatedNormal\") \\\n .Device(DEVICE_GPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<int32>(\"T\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp< \\\n GPUDevice, \\\n random::TruncatedNormalDistribution< \\\n random::SingleSampleAdapter<random::PhiloxRandom>, TYPE>>);",
"#define REGISTER_FULL_INT(IntType) \\\n template struct functor::FillPhiloxRandom< \\\n GPUDevice, \\\n random::UniformFullIntDistribution<random::PhiloxRandom, IntType>>",
"#define REGISTER_INT(IntType) \\\n REGISTER_FULL_INT(IntType); \\\n template struct functor::FillPhiloxRandom< \\\n GPUDevice, random::UniformDistribution<random::PhiloxRandom, IntType>>; \\\n REGISTER_KERNEL_BUILDER(Name(\"RandomUniformInt\") \\\n .Device(DEVICE_GPU) \\\n .HostMemory(\"shape\") \\\n .HostMemory(\"minval\") \\\n .HostMemory(\"maxval\") \\\n .TypeConstraint<int32>(\"T\") \\\n .TypeConstraint<IntType>(\"Tout\"), \\\n RandomUniformIntOp<GPUDevice, IntType>);",
"TF_CALL_half(REGISTER);\nTF_CALL_float(REGISTER);\nTF_CALL_double(REGISTER);\nTF_CALL_int32(REGISTER_INT);\nTF_CALL_int64(REGISTER_INT);\nTF_CALL_uint32(REGISTER_FULL_INT);\nTF_CALL_uint64(REGISTER_FULL_INT);",
"#undef REGISTER\n#undef REGISTER_INT\n#undef REGISTER_FULL_INT",
"#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM",
"\n} // end namespace tensorflow"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [170, 301, 218, 173], "buggy_code_start_loc": [169, 299, 18, 19], "filenames": ["tensorflow/core/kernels/random_op.cc", "tensorflow/core/kernels/random_poisson_op.cc", "tensorflow/python/kernel_tests/random/random_gamma_test.py", "tensorflow/python/kernel_tests/random/random_poisson_test.py"], "fixing_code_end_loc": [170, 301, 232, 183], "fixing_code_start_loc": [169, 299, 19, 20], "message": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "C6622D95-1C86-45C5-AB55-E6EEEA0996DF", "versionEndExcluding": "2.7.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "0F9D273D-02DC-441E-AA91-EAC8DEAA4B44", "versionEndExcluding": "2.8.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.8.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "FE4F8A81-6CC2-4F7F-9602-C170FDD926E7", "versionEndExcluding": "2.9.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.9.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc0:*:*:*:*:*:*", "matchCriteriaId": "1DBFBCE2-0A01-4575-BE45-6775ABFB8B28", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc1:*:*:*:*:*:*", "matchCriteriaId": "89806CF9-E423-4CA6-A01A-8175C260CB24", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc2:*:*:*:*:*:*", "matchCriteriaId": "F2B80690-A257-4E16-BD27-9AE045BC56ED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc3:*:*:*:*:*:*", "matchCriteriaId": "F335F9A4-5AB8-4E53-BC18-E01F7C653E5E", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue."}, {"lang": "es", "value": "TensorFlow es una plataforma de c\u00f3digo abierto para el aprendizaje autom\u00e1tico. Cuando \"RandomPoissonV2\" recibe formas y tasas de entrada grandes, da un fallo de \"CHECK\" que puede desencadenar un ataque de denegaci\u00f3n de servicio. Hemos parcheado el problema en el commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3 de GitHub. La correcci\u00f3n ser\u00e1 incluida en TensorFlow versi\u00f3n 2.10.0. Tambi\u00e9n seleccionaremos este compromiso en TensorFlow versi\u00f3n 2.9.1, TensorFlow versi\u00f3n 2.8.1, y TensorFlow versi\u00f3n 2.7.2, ya que estos tambi\u00e9n est\u00e1n afectados y todav\u00eda est\u00e1n en el rango admitido. No se presentan mitigaciones conocidas para este problema"}], "evaluatorComment": null, "id": "CVE-2022-36003", "lastModified": "2022-09-20T14:42:50.067", "metrics": {"cvssMetricV2": null, "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 5.9, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 2.2, "impactScore": 3.6, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-09-16T23:15:10.823", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cv2p-32v3-vhwq"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-617"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, "type": "CWE-617"}
| 359
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.",
"Licensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at",
" http://www.apache.org/licenses/LICENSE-2.0",
"Unless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n==============================================================================*/",
"// See docs in ../ops/random_ops.cc.",
"#define EIGEN_USE_THREADS",
"#include <algorithm>\n#include <cmath>\n#include <memory>",
"#include \"tensorflow/core/framework/op_kernel.h\"\n#include \"tensorflow/core/framework/register_types.h\"\n#include \"tensorflow/core/framework/tensor.h\"\n#include \"tensorflow/core/framework/tensor_shape.h\"\n#include \"tensorflow/core/framework/tensor_util.h\"\n#include \"tensorflow/core/kernels/random_op_cpu.h\"\n#include \"tensorflow/core/lib/hash/crc32c.h\"\n#include \"tensorflow/core/lib/random/random_distributions.h\"\n#include \"tensorflow/core/lib/random/simple_philox.h\"\n#include \"tensorflow/core/platform/logging.h\"\n#include \"tensorflow/core/util/guarded_philox_random.h\"\n#include \"tensorflow/core/util/work_sharder.h\"",
"#if EIGEN_COMP_GNUC && __cplusplus > 199711L\n#define DISABLE_FLOAT_EQUALITY_WARNING \\\n _Pragma(\"GCC diagnostic push\") \\\n _Pragma(\"GCC diagnostic ignored \\\"-Wfloat-equal\\\"\")\n#define ENABLE_FLOAT_EQUALITY_WARNING _Pragma(\"GCC diagnostic pop\")\n#else\n#define DISABLE_FLOAT_EQUALITY_WARNING\n#define ENABLE_FLOAT_EQUALITY_WARNING\n#endif",
"namespace tensorflow {",
"typedef Eigen::ThreadPoolDevice CPUDevice;\ntypedef Eigen::GpuDevice GPUDevice;",
"namespace {",
"static Status AllocateOutputWithShape(OpKernelContext* ctx, const Tensor& shape,\n int index, Tensor** output) {\n TensorShape tensor_shape;\n TF_RETURN_IF_ERROR(tensor::MakeShape(shape, &tensor_shape));\n return ctx->allocate_output(index, tensor_shape, output);\n}",
"// For now, use the same interface as RandomOp, so we can choose either one\n// at the run-time.\ntemplate <typename Device, class Distribution>\nclass PhiloxRandomOp : public OpKernel {\n public:\n typedef typename Distribution::ResultElementType T;\n explicit PhiloxRandomOp(OpKernelConstruction* ctx) : OpKernel(ctx) {\n OP_REQUIRES_OK(ctx, generator_.Init(ctx));\n }",
" void Compute(OpKernelContext* ctx) override {\n const Tensor& shape = ctx->input(0);\n Tensor* output;\n OP_REQUIRES_OK(ctx, AllocateOutputWithShape(ctx, shape, 0, &output));\n auto output_flat = output->flat<T>();\n functor::FillPhiloxRandom<Device, Distribution>()(\n ctx, ctx->eigen_device<Device>(), /*key=*/nullptr, /*counter=*/nullptr,\n // Multiplier 256 is the same as in FillPhiloxRandomTask; do not change\n // it just here.\n generator_.ReserveRandomOutputs(output_flat.size(), 256),\n output_flat.data(), output_flat.size(), Distribution());\n }",
" private:\n GuardedPhiloxRandom generator_;\n};",
"template <typename Device, class IntType>\nclass RandomUniformIntOp : public OpKernel {\n public:\n explicit RandomUniformIntOp(OpKernelConstruction* ctx) : OpKernel(ctx) {\n OP_REQUIRES_OK(ctx, generator_.Init(ctx));\n }",
" void Compute(OpKernelContext* ctx) override {\n const Tensor& shape = ctx->input(0);\n const Tensor& minval = ctx->input(1);\n const Tensor& maxval = ctx->input(2);\n OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(minval.shape()),\n errors::InvalidArgument(\"minval must be 0-D, got shape \",\n minval.shape().DebugString()));\n OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(maxval.shape()),\n errors::InvalidArgument(\"maxval must be 0-D, got shape \",\n maxval.shape().DebugString()));",
" // Allocate output, and exit early if possible\n Tensor* output;\n OP_REQUIRES_OK(ctx, AllocateOutputWithShape(ctx, shape, 0, &output));\n if (output->NumElements() == 0) return;",
" // Verify that minval < maxval. This check intentionally happens after the\n // early exit for empty output. Zero impossible things are fine.\n IntType lo = minval.scalar<IntType>()();\n IntType hi = maxval.scalar<IntType>()();\n OP_REQUIRES(\n ctx, lo < hi,\n errors::InvalidArgument(\"Need minval < maxval, got \", lo, \" >= \", hi));",
" // Build distribution\n typedef random::UniformDistribution<random::PhiloxRandom, IntType>\n Distribution;\n Distribution dist(lo, hi);",
" auto output_flat = output->flat<IntType>();\n functor::FillPhiloxRandom<Device, Distribution>()(\n ctx, ctx->eigen_device<Device>(), /*key=*/nullptr, /*counter=*/nullptr,\n // Multiplier 256 is the same as in FillPhiloxRandomTask; do not change\n // it just here.\n generator_.ReserveRandomOutputs(output_flat.size(), 256),\n output_flat.data(), output_flat.size(), dist);\n }",
" private:\n GuardedPhiloxRandom generator_;\n};",
"// Samples from one or more gamma distributions. All internal computations are\n// done with double precision for numerical stability.\ntemplate <typename T>\nclass RandomGammaOp : public OpKernel {\n public:\n explicit RandomGammaOp(OpKernelConstruction* context) : OpKernel(context) {\n OP_REQUIRES_OK(context, generator_.Init(context));\n }",
" void Compute(OpKernelContext* ctx) override {\n const Tensor& shape_t = ctx->input(0);\n const Tensor& alpha_t = ctx->input(1);",
" OP_REQUIRES(ctx,\n TensorShapeUtils::IsVector(shape_t.shape()) &&\n (shape_t.dtype() == DataType::DT_INT32 ||\n shape_t.dtype() == DataType::DT_INT64),\n errors::InvalidArgument(\n \"shape must be a vector of {int32,int64}, got shape: \",\n shape_t.DebugString()));\n TensorShape samples_shape;\n if (shape_t.dtype() == DataType::DT_INT32) {\n auto vec = shape_t.flat<int32>();\n OP_REQUIRES_OK(ctx, TensorShapeUtils::MakeShape(vec.data(), vec.size(),\n &samples_shape));\n } else if (shape_t.dtype() == DataType::DT_INT64) {\n auto vec = shape_t.flat<int64_t>();\n OP_REQUIRES_OK(ctx, TensorShapeUtils::MakeShape(vec.data(), vec.size(),\n &samples_shape));\n }\n const int64_t samples_per_alpha = samples_shape.num_elements();\n",
" OP_REQUIRES_OK(ctx, samples_shape.AppendShapeWithStatus(alpha_t.shape()));",
" // Allocate output samples.\n Tensor* samples_t = nullptr;\n OP_REQUIRES_OK(ctx, ctx->allocate_output(0, samples_shape, &samples_t));",
" if (samples_shape.num_elements() == 0) return;",
" using random::PhiloxRandom;",
" typedef random::NormalDistribution<PhiloxRandom, double> Normal;\n typedef random::UniformDistribution<PhiloxRandom, double> Uniform;\n#define UNIFORM(X) \\\n if (uniform_remaining == 0) { \\\n uniform_remaining = Uniform::kResultElementCount; \\\n uniform_result = uniform(&gen); \\\n } \\\n uniform_remaining--; \\\n double X = uniform_result[uniform_remaining]",
" // Each attempt is 95+% successful, and requires 1-2 normal + 1 uniform\n static constexpr int kReservedSamplesPerOutput = 256;",
" const auto alpha_flat = alpha_t.flat<T>().data();\n const int64_t num_alphas = alpha_t.NumElements();\n OP_REQUIRES(ctx, num_alphas > 0,\n errors::InvalidArgument(\n \"Input alpha should have non-zero element count, got: \",\n num_alphas));\n auto samples_flat = samples_t->flat<T>().data();\n PhiloxRandom rng = generator_.ReserveRandomOutputs(\n samples_per_alpha * num_alphas, kReservedSamplesPerOutput);",
" // We partition work first across alphas then across samples-per-alpha to\n // avoid a couple flops which can be done on a per-alpha basis.",
" auto DoWork = [samples_per_alpha, num_alphas, &rng, samples_flat,\n alpha_flat](int64_t start_output, int64_t limit_output) {\n using Eigen::numext::exp;\n using Eigen::numext::log;\n using Eigen::numext::log1p;\n using Eigen::numext::pow;",
" // Capturing \"rng\" by-value would only make a copy for the _shared_\n // lambda. Since we want to let each worker have its own copy, we pass\n // \"rng\" by reference and explicitly do a copy assignment.",
" Normal normal;\n Uniform uniform;\n typename Normal::ResultType norm_result;\n typename Uniform::ResultType uniform_result;\n for (int64_t output_idx = start_output; output_idx < limit_output;\n /* output_idx incremented within inner loop below */) {\n int64_t alpha_idx = output_idx / samples_per_alpha;",
" // Instead of +alpha_idx for each sample, we offset the pointer once.\n T* const samples_alpha_offset = samples_flat + alpha_idx;",
" // Several calculations can be done on a per-alpha basis.\n const double alpha = static_cast<double>(alpha_flat[alpha_idx]);",
" DISABLE_FLOAT_EQUALITY_WARNING\n if (alpha == static_cast<double>(1.0)) {\n ENABLE_FLOAT_EQUALITY_WARNING\n // Sample from an exponential distribution.\n for (int64_t sample_idx = output_idx % samples_per_alpha;\n sample_idx < samples_per_alpha && output_idx < limit_output;\n sample_idx++, output_idx++) {\n // As we want data stable regardless of sharding\n // (including eventually on GPU), we skip on a per-sample basis.\n PhiloxRandom gen = rng;\n gen.Skip(kReservedSamplesPerOutput * output_idx);\n int16_t uniform_remaining = 0;\n UNIFORM(u);\n const double res = -log1p(-u);\n samples_alpha_offset[sample_idx * num_alphas] = static_cast<T>(res);\n } // for (sample_idx)\n } else { // if alpha != 1.0\n // Transformation-rejection from pairs of uniform and normal random\n // variables. http://dl.acm.org/citation.cfm?id=358414\n //\n // The algorithm has an acceptance rate of ~95% for small alpha (~1),\n // and higher accept rates for higher alpha, so runtime is\n // O(NumAlphas * NumSamples * k) with k ~ 1 / 0.95.\n //\n // For alpha<1, we add one to d=alpha-1/3, and multiply the final\n // result by uniform()^(1/alpha)\n const bool alpha_less_than_one = alpha < 1;\n const double d = alpha + (alpha_less_than_one ? 2.0 / 3 : -1.0 / 3);\n const double c = 1.0 / 3 / sqrt(d);",
" // Compute the rest of the samples for the current alpha value.\n for (int64_t sample_idx = output_idx % samples_per_alpha;\n sample_idx < samples_per_alpha && output_idx < limit_output;\n sample_idx++, output_idx++) {\n // Since each sample may use a variable number of normal/uniform\n // samples, and we want data stable regardless of sharding\n // (including eventually on GPU), we skip on a per-sample basis.\n PhiloxRandom gen = rng;\n gen.Skip(kReservedSamplesPerOutput * output_idx);\n int16_t norm_remaining = 0;\n int16_t uniform_remaining = 0;",
" // Keep trying until we don't reject a sample. In practice, we will\n // only reject ~5% at worst, for low alpha near 1.\n while (true) {\n if (norm_remaining == 0) {\n norm_remaining = Normal::kResultElementCount;\n norm_result = normal(&gen);\n }\n norm_remaining--;\n const double x = norm_result[norm_remaining];\n double v = 1 + c * x;\n if (v <= 0) {\n continue;\n }\n v = v * v * v;\n UNIFORM(u);\n // The first option in the if is a \"squeeze\" short-circuit to\n // dodge the two logs. Magic constant sourced from the paper\n // linked above. Upward of .91 of the area covered by the log\n // inequality is covered by the squeeze as well (larger coverage\n // for smaller values of alpha).\n if ((u < 1 - 0.0331 * (x * x) * (x * x)) ||\n (log(u) < 0.5 * x * x + d * (1 - v + log(v)))) {\n double res = d * v;\n if (alpha_less_than_one) {\n UNIFORM(b);\n res *= pow(b, 1 / alpha);\n }\n samples_alpha_offset[sample_idx * num_alphas] =\n static_cast<T>(res);\n break;\n }\n } // while: true\n } // for: sample_idx\n } // if (alpha == 1.0)\n } // for: output_idx\n }; // DoWork\n#undef UNIFORM\n // Two calls to log only occur for ~10% of samples reaching the log line.\n // 2 x 100 (64-bit cycles per log) x 0.10 = ~20.\n // Other ops: sqrt, +, *, /, %... something like 15 of these, at 3-6 cycles\n // each = ~60.\n // All of this /0.95 due to the rejection possibility = ~85.\n static const int kElementCost = 85 + 2 * Normal::kElementCost +\n Uniform::kElementCost +\n 3 * PhiloxRandom::kElementCost;\n auto worker_threads = *(ctx->device()->tensorflow_cpu_worker_threads());\n Shard(worker_threads.num_threads, worker_threads.workers,\n num_alphas * samples_per_alpha, kElementCost, DoWork);\n }",
" private:\n GuardedPhiloxRandom generator_;",
" TF_DISALLOW_COPY_AND_ASSIGN(RandomGammaOp);\n};",
"} // namespace",
"#define REGISTER(TYPE) \\\n template struct functor::FillPhiloxRandom< \\\n CPUDevice, random::UniformDistribution<random::PhiloxRandom, TYPE>>; \\\n template struct functor::FillPhiloxRandom< \\\n CPUDevice, random::NormalDistribution<random::PhiloxRandom, TYPE>>; \\\n template struct functor::FillPhiloxRandom< \\\n CPUDevice, \\\n random::TruncatedNormalDistribution< \\\n random::SingleSampleAdapter<random::PhiloxRandom>, TYPE>>; \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomUniform\") \\\n .Device(DEVICE_CPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp<CPUDevice, random::UniformDistribution< \\\n random::PhiloxRandom, TYPE>>); \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomStandardNormal\") \\\n .Device(DEVICE_CPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp<CPUDevice, \\\n random::NormalDistribution<random::PhiloxRandom, TYPE>>); \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"TruncatedNormal\") \\\n .Device(DEVICE_CPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp< \\\n CPUDevice, \\\n random::TruncatedNormalDistribution< \\\n random::SingleSampleAdapter<random::PhiloxRandom>, TYPE>>); \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomGamma\").Device(DEVICE_CPU).TypeConstraint<TYPE>(\"T\"), \\\n RandomGammaOp<TYPE>)",
"#define REGISTER_FULL_INT(IntType) \\\n template struct functor::FillPhiloxRandom< \\\n CPUDevice, \\\n random::UniformFullIntDistribution<random::PhiloxRandom, IntType>>",
"#define REGISTER_INT(IntType) \\\n REGISTER_FULL_INT(IntType); \\\n template struct functor::FillPhiloxRandom< \\\n CPUDevice, random::UniformDistribution<random::PhiloxRandom, IntType>>; \\\n REGISTER_KERNEL_BUILDER(Name(\"RandomUniformInt\") \\\n .Device(DEVICE_CPU) \\\n .HostMemory(\"shape\") \\\n .HostMemory(\"minval\") \\\n .HostMemory(\"maxval\") \\\n .TypeConstraint<IntType>(\"Tout\"), \\\n RandomUniformIntOp<CPUDevice, IntType>);",
"TF_CALL_half(REGISTER);\nTF_CALL_bfloat16(REGISTER);\nTF_CALL_float(REGISTER);\nTF_CALL_double(REGISTER);\nTF_CALL_int32(REGISTER_INT);\nTF_CALL_int64(REGISTER_INT);\nTF_CALL_uint32(REGISTER_FULL_INT);\nTF_CALL_uint64(REGISTER_FULL_INT);",
"#undef REGISTER\n#undef REGISTER_INT\n#undef REGISTER_FULL_INT",
"#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM",
"#define REGISTER(TYPE) \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomUniform\") \\\n .Device(DEVICE_GPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<int32>(\"T\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp<GPUDevice, random::UniformDistribution< \\\n random::PhiloxRandom, TYPE>>); \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomStandardNormal\") \\\n .Device(DEVICE_GPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<int32>(\"T\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp<GPUDevice, \\\n random::NormalDistribution<random::PhiloxRandom, TYPE>>); \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"TruncatedNormal\") \\\n .Device(DEVICE_GPU) \\\n .HostMemory(\"shape\") \\\n .TypeConstraint<int32>(\"T\") \\\n .TypeConstraint<TYPE>(\"dtype\"), \\\n PhiloxRandomOp< \\\n GPUDevice, \\\n random::TruncatedNormalDistribution< \\\n random::SingleSampleAdapter<random::PhiloxRandom>, TYPE>>);",
"#define REGISTER_FULL_INT(IntType) \\\n template struct functor::FillPhiloxRandom< \\\n GPUDevice, \\\n random::UniformFullIntDistribution<random::PhiloxRandom, IntType>>",
"#define REGISTER_INT(IntType) \\\n REGISTER_FULL_INT(IntType); \\\n template struct functor::FillPhiloxRandom< \\\n GPUDevice, random::UniformDistribution<random::PhiloxRandom, IntType>>; \\\n REGISTER_KERNEL_BUILDER(Name(\"RandomUniformInt\") \\\n .Device(DEVICE_GPU) \\\n .HostMemory(\"shape\") \\\n .HostMemory(\"minval\") \\\n .HostMemory(\"maxval\") \\\n .TypeConstraint<int32>(\"T\") \\\n .TypeConstraint<IntType>(\"Tout\"), \\\n RandomUniformIntOp<GPUDevice, IntType>);",
"TF_CALL_half(REGISTER);\nTF_CALL_float(REGISTER);\nTF_CALL_double(REGISTER);\nTF_CALL_int32(REGISTER_INT);\nTF_CALL_int64(REGISTER_INT);\nTF_CALL_uint32(REGISTER_FULL_INT);\nTF_CALL_uint64(REGISTER_FULL_INT);",
"#undef REGISTER\n#undef REGISTER_INT\n#undef REGISTER_FULL_INT",
"#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM",
"\n} // end namespace tensorflow"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [170, 301, 218, 173], "buggy_code_start_loc": [169, 299, 18, 19], "filenames": ["tensorflow/core/kernels/random_op.cc", "tensorflow/core/kernels/random_poisson_op.cc", "tensorflow/python/kernel_tests/random/random_gamma_test.py", "tensorflow/python/kernel_tests/random/random_poisson_test.py"], "fixing_code_end_loc": [170, 301, 232, 183], "fixing_code_start_loc": [169, 299, 19, 20], "message": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "C6622D95-1C86-45C5-AB55-E6EEEA0996DF", "versionEndExcluding": "2.7.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "0F9D273D-02DC-441E-AA91-EAC8DEAA4B44", "versionEndExcluding": "2.8.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.8.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "FE4F8A81-6CC2-4F7F-9602-C170FDD926E7", "versionEndExcluding": "2.9.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.9.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc0:*:*:*:*:*:*", "matchCriteriaId": "1DBFBCE2-0A01-4575-BE45-6775ABFB8B28", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc1:*:*:*:*:*:*", "matchCriteriaId": "89806CF9-E423-4CA6-A01A-8175C260CB24", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc2:*:*:*:*:*:*", "matchCriteriaId": "F2B80690-A257-4E16-BD27-9AE045BC56ED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc3:*:*:*:*:*:*", "matchCriteriaId": "F335F9A4-5AB8-4E53-BC18-E01F7C653E5E", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue."}, {"lang": "es", "value": "TensorFlow es una plataforma de c\u00f3digo abierto para el aprendizaje autom\u00e1tico. Cuando \"RandomPoissonV2\" recibe formas y tasas de entrada grandes, da un fallo de \"CHECK\" que puede desencadenar un ataque de denegaci\u00f3n de servicio. Hemos parcheado el problema en el commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3 de GitHub. La correcci\u00f3n ser\u00e1 incluida en TensorFlow versi\u00f3n 2.10.0. Tambi\u00e9n seleccionaremos este compromiso en TensorFlow versi\u00f3n 2.9.1, TensorFlow versi\u00f3n 2.8.1, y TensorFlow versi\u00f3n 2.7.2, ya que estos tambi\u00e9n est\u00e1n afectados y todav\u00eda est\u00e1n en el rango admitido. No se presentan mitigaciones conocidas para este problema"}], "evaluatorComment": null, "id": "CVE-2022-36003", "lastModified": "2022-09-20T14:42:50.067", "metrics": {"cvssMetricV2": null, "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 5.9, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 2.2, "impactScore": 3.6, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-09-16T23:15:10.823", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cv2p-32v3-vhwq"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-617"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, "type": "CWE-617"}
| 359
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.",
"Licensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at",
" http://www.apache.org/licenses/LICENSE-2.0",
"Unless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n==============================================================================*/",
"// See docs in ../ops/random_ops.cc.",
"#define EIGEN_USE_THREADS",
"#include \"tensorflow/core/kernels/random_poisson_op.h\"",
"#include <algorithm>\n#include <cmath>\n#include <limits>\n#include <memory>",
"#include \"tensorflow/core/framework/op_kernel.h\"\n#include \"tensorflow/core/framework/register_types.h\"\n#include \"tensorflow/core/framework/tensor.h\"\n#include \"tensorflow/core/framework/tensor_shape.h\"\n#include \"tensorflow/core/framework/tensor_util.h\"\n#include \"tensorflow/core/lib/random/random_distributions.h\"\n#include \"tensorflow/core/lib/random/simple_philox.h\"\n#include \"tensorflow/core/util/guarded_philox_random.h\"\n#include \"tensorflow/core/util/work_sharder.h\"",
"#if EIGEN_COMP_GNUC && __cplusplus > 199711L\n#define DISABLE_FLOAT_EQUALITY_WARNING \\\n _Pragma(\"GCC diagnostic push\") \\\n _Pragma(\"GCC diagnostic ignored \\\"-Wfloat-equal\\\"\")\n#define ENABLE_FLOAT_EQUALITY_WARNING _Pragma(\"GCC diagnostic pop\")\n#else\n#define DISABLE_FLOAT_EQUALITY_WARNING\n#define ENABLE_FLOAT_EQUALITY_WARNING\n#endif",
"#define UNIFORM(X) \\\n if (uniform_remaining == 0) { \\\n uniform_remaining = Uniform::kResultElementCount; \\\n uniform_result = uniform(&gen); \\\n } \\\n uniform_remaining--; \\\n CT X = uniform_result[uniform_remaining]",
"namespace tensorflow {\nnamespace {",
"static constexpr int kReservedSamplesPerOutput = 256;",
"typedef Eigen::ThreadPoolDevice CPUDevice;",
"template <typename T>\nstruct PoissonComputeType {\n typedef double ComputeType;\n};",
"} // namespace",
"namespace functor {",
"template <typename T, typename U>\nstruct PoissonFunctor<CPUDevice, T, U> {\n void operator()(OpKernelContext* ctx, const CPUDevice& d, const T* rate_flat,\n int num_rate, int num_samples,\n const random::PhiloxRandom& rng, U* samples_flat) {\n // Two different algorithms are employed, depending on the size of\n // rate.\n // If rate < 10, we use an algorithm attributed to Knuth:\n // Seminumerical Algorithms. Art of Computer Programming, Volume 2.\n //\n // This algorithm runs in O(rate) time, and will require O(rate)\n // uniform variates.\n //\n // If rate >= 10 we use a transformation-rejection algorithm from\n // pairs of uniform random variables due to Hormann.\n // http://www.sciencedirect.com/science/article/pii/0167668793909974\n //\n // The algorithm has an acceptance rate of ~89% for the smallest rate\n // (~10),\n // and higher accept rates for higher rate, so runtime is\n // O(NumRate * NumSamples * k) with k ~ 1 / 0.89.\n //\n // We partition work first across rates then across\n // samples-per-rate to\n // avoid a couple flops which can be done on a per-rate basis.",
" typedef random::UniformDistribution<random::PhiloxRandom, CT> Uniform;",
" auto DoWork = [num_samples, num_rate, &rng, samples_flat, rate_flat](\n int64_t start_output, int64_t limit_output) {\n // Capturing \"rng\" by value would only make a copy for the _shared_\n // lambda. Since we want to let each worker have its own copy, we pass\n // \"rng\" by reference and explicitly do a copy assignment.",
" Uniform uniform;\n typename Uniform::ResultType uniform_result;\n for (int64_t output_idx = start_output; output_idx < limit_output;\n /* output_idx incremented within inner loop below */) {\n const int64_t rate_idx = output_idx / num_samples;",
" // Several calculations can be done on a per-rate basis.\n const CT rate = CT(rate_flat[rate_idx]);",
" auto samples_rate_output = samples_flat + rate_idx;",
" if (rate < CT(10)) {\n // Knuth's algorithm for generating Poisson random variates.\n // Given a Poisson process, the time between events is exponentially\n // distributed. If we have a Poisson process with rate lambda, then,\n // the time between events is distributed Exp(lambda). If X ~\n // Uniform(0, 1), then Y ~ Exp(lambda), where Y = -log(X) / lambda.\n // Thus to simulate a Poisson draw, we can draw X_i ~ Exp(lambda),\n // and N ~ Poisson(lambda), where N is the least number such that\n // \\sum_i^N X_i > 1.\n const CT exp_neg_rate = Eigen::numext::exp(-rate);",
" // Compute the rest of the samples for the current rate value.\n for (int64_t sample_idx = output_idx % num_samples;\n sample_idx < num_samples && output_idx < limit_output;\n sample_idx++, output_idx++) {\n random::PhiloxRandom gen = rng;\n gen.Skip(kReservedSamplesPerOutput * output_idx);\n int16_t uniform_remaining = 0;",
" CT prod = 1;\n CT x = 0;",
" // Keep trying until we surpass e^(-rate). This will take\n // expected time proportional to rate.\n while (true) {\n UNIFORM(u);\n prod = prod * u;\n if (prod <= exp_neg_rate &&\n x <= CT(Eigen::NumTraits<U>::highest())) {\n samples_rate_output[sample_idx * num_rate] = U(x);\n break;\n }\n x += 1;\n }\n }\n continue;\n }\n if (Eigen::numext::isinf(rate) && rate > CT(0)) {\n // Fill the rest of the samples for the current rate value.\n for (int64_t sample_idx = output_idx % num_samples;\n sample_idx < num_samples && output_idx < limit_output;\n sample_idx++, output_idx++) {\n U k = Eigen::NumTraits<U>::infinity();\n samples_rate_output[sample_idx * num_rate] = k;\n }\n continue;\n }\n // Transformed rejection due to Hormann.\n //\n // Given a CDF F(x), and G(x), a dominating distribution chosen such\n // that it is close to the inverse CDF F^-1(x), compute the following\n // steps:\n //\n // 1) Generate U and V, two independent random variates. Set U = U - 0.5\n // (this step isn't strictly necessary, but is done to make some\n // calculations symmetric and convenient. Henceforth, G is defined on\n // [-0.5, 0.5]).\n //\n // 2) If V <= alpha * F'(G(U)) * G'(U), return floor(G(U)), else return\n // to step 1. alpha is the acceptance probability of the rejection\n // algorithm.\n //\n // For more details on transformed rejection, see:\n // http://citeseer.ist.psu.edu/viewdoc/citations;jsessionid=1BEB35946CC807879F55D42512E5490C?doi=10.1.1.48.3054.\n //\n // The dominating distribution in this case:\n //\n // G(u) = (2 * a / (2 - |u|) + b) * u + c",
" using Eigen::numext::log;\n const CT log_rate = log(rate);",
" // Constants used to define the dominating distribution. Names taken\n // from Hormann's paper. Constants were chosen to define the tightest\n // G(u) for the inverse Poisson CDF.\n const CT b = CT(0.931) + CT(2.53) * Eigen::numext::sqrt(rate);\n const CT a = CT(-0.059) + CT(0.02483) * b;",
" // This is the inverse acceptance rate. At a minimum (when rate = 10),\n // this corresponds to ~75% acceptance. As the rate becomes larger, this\n // approaches ~89%.\n const CT inv_alpha = CT(1.1239) + CT(1.1328) / (b - CT(3.4));",
" // Compute the rest of the samples for the current rate value.\n for (int64_t sample_idx = output_idx % num_samples;\n sample_idx < num_samples && output_idx < limit_output;\n sample_idx++, output_idx++) {\n random::PhiloxRandom gen = rng;\n gen.Skip(kReservedSamplesPerOutput * output_idx);\n int16_t uniform_remaining = 0;",
" while (true) {\n UNIFORM(u);\n u -= CT(0.5);\n UNIFORM(v);",
" CT u_shifted = CT(0.5) - Eigen::numext::abs(u);\n CT k = Eigen::numext::floor((CT(2) * a / u_shifted + b) * u + rate +\n CT(0.43));",
" if (k > CT(Eigen::NumTraits<U>::highest())) {\n // retry in case of overflow.\n continue;\n }",
" // When alpha * f(G(U)) * G'(U) is close to 1, it is possible to\n // find a rectangle (-u_r, u_r) x (0, v_r) under the curve, such\n // that if v <= v_r and |u| <= u_r, then we can accept.\n // Here v_r = 0.9227 - 3.6224 / (b - 2) and u_r = 0.43.\n if (u_shifted >= CT(0.07) &&\n v <= CT(0.9277) - CT(3.6224) / (b - CT(2))) {\n samples_rate_output[sample_idx * num_rate] = U(k);\n break;\n }",
" if (k < 0 || (u_shifted < CT(0.013) && v > u_shifted)) {\n continue;\n }",
" // The expression below is equivalent to the computation of step 2)\n // in transformed rejection (v <= alpha * F'(G(u)) * G'(u)).\n CT s = log(v * inv_alpha / (a / (u_shifted * u_shifted) + b));\n CT t = -rate + k * log_rate - Eigen::numext::lgamma(k + 1);\n if (s <= t) {\n samples_rate_output[sample_idx * num_rate] = U(k);\n break;\n }\n }\n }\n }\n };",
" // This will depend on rate.\n // For rate < 10, on average, O(rate) calls to uniform are\n // needed, with that\n // many multiplies. ~10 uniform calls on average with ~25 cost op calls.\n //\n // Very roughly, for rate >= 10, the single call to log + call to\n // lgamma\n // occur for ~60 percent of samples.\n // 2 x 100 (64-bit cycles per log) * 0.62 = ~124\n // Additionally, there are ~10 other ops (+, *, /, ...) at 3-6 cycles each:\n // 40 * .62 = ~25.\n //\n // Finally, there are several other ops that are done every loop along with\n // 2 uniform generations along with 5 other ops at 3-6 cycles each.\n // ~15 / .89 = ~16\n //\n // In total this should be ~165 + 2 * Uniform::kElementCost.\n // We assume that half the tensor has rate < 10, so on average 6\n // uniform's\n // will be needed. We will upper bound the other op cost by the one for\n // rate > 10.\n static const int kElementCost = 165 + 6 * Uniform::kElementCost +\n 6 * random::PhiloxRandom::kElementCost;\n auto worker_threads = *(ctx->device()->tensorflow_cpu_worker_threads());\n Shard(worker_threads.num_threads, worker_threads.workers,\n num_rate * num_samples, kElementCost, DoWork);\n }",
" private:\n typedef typename PoissonComputeType<T>::ComputeType CT;\n};",
"} // namespace functor",
"namespace {",
"// Samples from one or more Poisson distributions.\ntemplate <typename T, typename U>\nclass RandomPoissonOp : public OpKernel {\n public:\n explicit RandomPoissonOp(OpKernelConstruction* context) : OpKernel(context) {\n OP_REQUIRES_OK(context, generator_.Init(context));\n }",
" void Compute(OpKernelContext* ctx) override {\n const Tensor& shape_t = ctx->input(0);\n const Tensor& rate_t = ctx->input(1);",
" TensorShape samples_shape;\n OP_REQUIRES_OK(ctx, tensor::MakeShape(shape_t, &samples_shape));\n const int64_t num_samples = samples_shape.num_elements();",
"\n samples_shape.AppendShape(rate_t.shape());",
" // Allocate output samples.\n Tensor* samples_t = nullptr;\n OP_REQUIRES_OK(ctx, ctx->allocate_output(0, samples_shape, &samples_t));\n if (num_samples == 0) return;",
" const auto rate_flat = rate_t.flat<T>().data();\n const int64_t num_rate = rate_t.NumElements();\n auto samples_flat = samples_t->flat<U>().data();\n random::PhiloxRandom rng = generator_.ReserveRandomOutputs(\n num_samples * num_rate, kReservedSamplesPerOutput);",
" functor::PoissonFunctor<CPUDevice, T, U>()(\n ctx, ctx->eigen_device<CPUDevice>(), rate_flat, num_rate, num_samples,\n rng, samples_flat);\n }",
" private:\n GuardedPhiloxRandom generator_;",
" TF_DISALLOW_COPY_AND_ASSIGN(RandomPoissonOp);\n};\n} // namespace",
"#undef UNIFORM",
"#define REGISTER(TYPE) \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomPoisson\").Device(DEVICE_CPU).TypeConstraint<TYPE>(\"dtype\"), \\\n RandomPoissonOp<TYPE, TYPE>);",
"TF_CALL_half(REGISTER);\nTF_CALL_float(REGISTER);\nTF_CALL_double(REGISTER);",
"#define REGISTER_V2(RTYPE, OTYPE) \\\n template struct functor::PoissonFunctor<CPUDevice, RTYPE, OTYPE>; \\\n REGISTER_KERNEL_BUILDER(Name(\"RandomPoissonV2\") \\\n .Device(DEVICE_CPU) \\\n .TypeConstraint<RTYPE>(\"R\") \\\n .TypeConstraint<OTYPE>(\"dtype\"), \\\n RandomPoissonOp<RTYPE, OTYPE>);",
"#define REGISTER_ALL(RTYPE) \\\n REGISTER_V2(RTYPE, Eigen::half); \\\n REGISTER_V2(RTYPE, float); \\\n REGISTER_V2(RTYPE, double); \\\n REGISTER_V2(RTYPE, int32); \\\n REGISTER_V2(RTYPE, int64_t);",
"REGISTER_ALL(Eigen::half);\nREGISTER_ALL(float);\nREGISTER_ALL(double);\nREGISTER_ALL(int32);\nREGISTER_ALL(int64_t);",
"#undef REGISTER_ALL\n#undef REGISTER_V2\n#undef REGISTER",
"} // end namespace tensorflow"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [170, 301, 218, 173], "buggy_code_start_loc": [169, 299, 18, 19], "filenames": ["tensorflow/core/kernels/random_op.cc", "tensorflow/core/kernels/random_poisson_op.cc", "tensorflow/python/kernel_tests/random/random_gamma_test.py", "tensorflow/python/kernel_tests/random/random_poisson_test.py"], "fixing_code_end_loc": [170, 301, 232, 183], "fixing_code_start_loc": [169, 299, 19, 20], "message": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "C6622D95-1C86-45C5-AB55-E6EEEA0996DF", "versionEndExcluding": "2.7.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "0F9D273D-02DC-441E-AA91-EAC8DEAA4B44", "versionEndExcluding": "2.8.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.8.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "FE4F8A81-6CC2-4F7F-9602-C170FDD926E7", "versionEndExcluding": "2.9.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.9.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc0:*:*:*:*:*:*", "matchCriteriaId": "1DBFBCE2-0A01-4575-BE45-6775ABFB8B28", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc1:*:*:*:*:*:*", "matchCriteriaId": "89806CF9-E423-4CA6-A01A-8175C260CB24", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc2:*:*:*:*:*:*", "matchCriteriaId": "F2B80690-A257-4E16-BD27-9AE045BC56ED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc3:*:*:*:*:*:*", "matchCriteriaId": "F335F9A4-5AB8-4E53-BC18-E01F7C653E5E", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue."}, {"lang": "es", "value": "TensorFlow es una plataforma de c\u00f3digo abierto para el aprendizaje autom\u00e1tico. Cuando \"RandomPoissonV2\" recibe formas y tasas de entrada grandes, da un fallo de \"CHECK\" que puede desencadenar un ataque de denegaci\u00f3n de servicio. Hemos parcheado el problema en el commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3 de GitHub. La correcci\u00f3n ser\u00e1 incluida en TensorFlow versi\u00f3n 2.10.0. Tambi\u00e9n seleccionaremos este compromiso en TensorFlow versi\u00f3n 2.9.1, TensorFlow versi\u00f3n 2.8.1, y TensorFlow versi\u00f3n 2.7.2, ya que estos tambi\u00e9n est\u00e1n afectados y todav\u00eda est\u00e1n en el rango admitido. No se presentan mitigaciones conocidas para este problema"}], "evaluatorComment": null, "id": "CVE-2022-36003", "lastModified": "2022-09-20T14:42:50.067", "metrics": {"cvssMetricV2": null, "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 5.9, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 2.2, "impactScore": 3.6, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-09-16T23:15:10.823", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cv2p-32v3-vhwq"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-617"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, "type": "CWE-617"}
| 359
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.",
"Licensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at",
" http://www.apache.org/licenses/LICENSE-2.0",
"Unless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n==============================================================================*/",
"// See docs in ../ops/random_ops.cc.",
"#define EIGEN_USE_THREADS",
"#include \"tensorflow/core/kernels/random_poisson_op.h\"",
"#include <algorithm>\n#include <cmath>\n#include <limits>\n#include <memory>",
"#include \"tensorflow/core/framework/op_kernel.h\"\n#include \"tensorflow/core/framework/register_types.h\"\n#include \"tensorflow/core/framework/tensor.h\"\n#include \"tensorflow/core/framework/tensor_shape.h\"\n#include \"tensorflow/core/framework/tensor_util.h\"\n#include \"tensorflow/core/lib/random/random_distributions.h\"\n#include \"tensorflow/core/lib/random/simple_philox.h\"\n#include \"tensorflow/core/util/guarded_philox_random.h\"\n#include \"tensorflow/core/util/work_sharder.h\"",
"#if EIGEN_COMP_GNUC && __cplusplus > 199711L\n#define DISABLE_FLOAT_EQUALITY_WARNING \\\n _Pragma(\"GCC diagnostic push\") \\\n _Pragma(\"GCC diagnostic ignored \\\"-Wfloat-equal\\\"\")\n#define ENABLE_FLOAT_EQUALITY_WARNING _Pragma(\"GCC diagnostic pop\")\n#else\n#define DISABLE_FLOAT_EQUALITY_WARNING\n#define ENABLE_FLOAT_EQUALITY_WARNING\n#endif",
"#define UNIFORM(X) \\\n if (uniform_remaining == 0) { \\\n uniform_remaining = Uniform::kResultElementCount; \\\n uniform_result = uniform(&gen); \\\n } \\\n uniform_remaining--; \\\n CT X = uniform_result[uniform_remaining]",
"namespace tensorflow {\nnamespace {",
"static constexpr int kReservedSamplesPerOutput = 256;",
"typedef Eigen::ThreadPoolDevice CPUDevice;",
"template <typename T>\nstruct PoissonComputeType {\n typedef double ComputeType;\n};",
"} // namespace",
"namespace functor {",
"template <typename T, typename U>\nstruct PoissonFunctor<CPUDevice, T, U> {\n void operator()(OpKernelContext* ctx, const CPUDevice& d, const T* rate_flat,\n int num_rate, int num_samples,\n const random::PhiloxRandom& rng, U* samples_flat) {\n // Two different algorithms are employed, depending on the size of\n // rate.\n // If rate < 10, we use an algorithm attributed to Knuth:\n // Seminumerical Algorithms. Art of Computer Programming, Volume 2.\n //\n // This algorithm runs in O(rate) time, and will require O(rate)\n // uniform variates.\n //\n // If rate >= 10 we use a transformation-rejection algorithm from\n // pairs of uniform random variables due to Hormann.\n // http://www.sciencedirect.com/science/article/pii/0167668793909974\n //\n // The algorithm has an acceptance rate of ~89% for the smallest rate\n // (~10),\n // and higher accept rates for higher rate, so runtime is\n // O(NumRate * NumSamples * k) with k ~ 1 / 0.89.\n //\n // We partition work first across rates then across\n // samples-per-rate to\n // avoid a couple flops which can be done on a per-rate basis.",
" typedef random::UniformDistribution<random::PhiloxRandom, CT> Uniform;",
" auto DoWork = [num_samples, num_rate, &rng, samples_flat, rate_flat](\n int64_t start_output, int64_t limit_output) {\n // Capturing \"rng\" by value would only make a copy for the _shared_\n // lambda. Since we want to let each worker have its own copy, we pass\n // \"rng\" by reference and explicitly do a copy assignment.",
" Uniform uniform;\n typename Uniform::ResultType uniform_result;\n for (int64_t output_idx = start_output; output_idx < limit_output;\n /* output_idx incremented within inner loop below */) {\n const int64_t rate_idx = output_idx / num_samples;",
" // Several calculations can be done on a per-rate basis.\n const CT rate = CT(rate_flat[rate_idx]);",
" auto samples_rate_output = samples_flat + rate_idx;",
" if (rate < CT(10)) {\n // Knuth's algorithm for generating Poisson random variates.\n // Given a Poisson process, the time between events is exponentially\n // distributed. If we have a Poisson process with rate lambda, then,\n // the time between events is distributed Exp(lambda). If X ~\n // Uniform(0, 1), then Y ~ Exp(lambda), where Y = -log(X) / lambda.\n // Thus to simulate a Poisson draw, we can draw X_i ~ Exp(lambda),\n // and N ~ Poisson(lambda), where N is the least number such that\n // \\sum_i^N X_i > 1.\n const CT exp_neg_rate = Eigen::numext::exp(-rate);",
" // Compute the rest of the samples for the current rate value.\n for (int64_t sample_idx = output_idx % num_samples;\n sample_idx < num_samples && output_idx < limit_output;\n sample_idx++, output_idx++) {\n random::PhiloxRandom gen = rng;\n gen.Skip(kReservedSamplesPerOutput * output_idx);\n int16_t uniform_remaining = 0;",
" CT prod = 1;\n CT x = 0;",
" // Keep trying until we surpass e^(-rate). This will take\n // expected time proportional to rate.\n while (true) {\n UNIFORM(u);\n prod = prod * u;\n if (prod <= exp_neg_rate &&\n x <= CT(Eigen::NumTraits<U>::highest())) {\n samples_rate_output[sample_idx * num_rate] = U(x);\n break;\n }\n x += 1;\n }\n }\n continue;\n }\n if (Eigen::numext::isinf(rate) && rate > CT(0)) {\n // Fill the rest of the samples for the current rate value.\n for (int64_t sample_idx = output_idx % num_samples;\n sample_idx < num_samples && output_idx < limit_output;\n sample_idx++, output_idx++) {\n U k = Eigen::NumTraits<U>::infinity();\n samples_rate_output[sample_idx * num_rate] = k;\n }\n continue;\n }\n // Transformed rejection due to Hormann.\n //\n // Given a CDF F(x), and G(x), a dominating distribution chosen such\n // that it is close to the inverse CDF F^-1(x), compute the following\n // steps:\n //\n // 1) Generate U and V, two independent random variates. Set U = U - 0.5\n // (this step isn't strictly necessary, but is done to make some\n // calculations symmetric and convenient. Henceforth, G is defined on\n // [-0.5, 0.5]).\n //\n // 2) If V <= alpha * F'(G(U)) * G'(U), return floor(G(U)), else return\n // to step 1. alpha is the acceptance probability of the rejection\n // algorithm.\n //\n // For more details on transformed rejection, see:\n // http://citeseer.ist.psu.edu/viewdoc/citations;jsessionid=1BEB35946CC807879F55D42512E5490C?doi=10.1.1.48.3054.\n //\n // The dominating distribution in this case:\n //\n // G(u) = (2 * a / (2 - |u|) + b) * u + c",
" using Eigen::numext::log;\n const CT log_rate = log(rate);",
" // Constants used to define the dominating distribution. Names taken\n // from Hormann's paper. Constants were chosen to define the tightest\n // G(u) for the inverse Poisson CDF.\n const CT b = CT(0.931) + CT(2.53) * Eigen::numext::sqrt(rate);\n const CT a = CT(-0.059) + CT(0.02483) * b;",
" // This is the inverse acceptance rate. At a minimum (when rate = 10),\n // this corresponds to ~75% acceptance. As the rate becomes larger, this\n // approaches ~89%.\n const CT inv_alpha = CT(1.1239) + CT(1.1328) / (b - CT(3.4));",
" // Compute the rest of the samples for the current rate value.\n for (int64_t sample_idx = output_idx % num_samples;\n sample_idx < num_samples && output_idx < limit_output;\n sample_idx++, output_idx++) {\n random::PhiloxRandom gen = rng;\n gen.Skip(kReservedSamplesPerOutput * output_idx);\n int16_t uniform_remaining = 0;",
" while (true) {\n UNIFORM(u);\n u -= CT(0.5);\n UNIFORM(v);",
" CT u_shifted = CT(0.5) - Eigen::numext::abs(u);\n CT k = Eigen::numext::floor((CT(2) * a / u_shifted + b) * u + rate +\n CT(0.43));",
" if (k > CT(Eigen::NumTraits<U>::highest())) {\n // retry in case of overflow.\n continue;\n }",
" // When alpha * f(G(U)) * G'(U) is close to 1, it is possible to\n // find a rectangle (-u_r, u_r) x (0, v_r) under the curve, such\n // that if v <= v_r and |u| <= u_r, then we can accept.\n // Here v_r = 0.9227 - 3.6224 / (b - 2) and u_r = 0.43.\n if (u_shifted >= CT(0.07) &&\n v <= CT(0.9277) - CT(3.6224) / (b - CT(2))) {\n samples_rate_output[sample_idx * num_rate] = U(k);\n break;\n }",
" if (k < 0 || (u_shifted < CT(0.013) && v > u_shifted)) {\n continue;\n }",
" // The expression below is equivalent to the computation of step 2)\n // in transformed rejection (v <= alpha * F'(G(u)) * G'(u)).\n CT s = log(v * inv_alpha / (a / (u_shifted * u_shifted) + b));\n CT t = -rate + k * log_rate - Eigen::numext::lgamma(k + 1);\n if (s <= t) {\n samples_rate_output[sample_idx * num_rate] = U(k);\n break;\n }\n }\n }\n }\n };",
" // This will depend on rate.\n // For rate < 10, on average, O(rate) calls to uniform are\n // needed, with that\n // many multiplies. ~10 uniform calls on average with ~25 cost op calls.\n //\n // Very roughly, for rate >= 10, the single call to log + call to\n // lgamma\n // occur for ~60 percent of samples.\n // 2 x 100 (64-bit cycles per log) * 0.62 = ~124\n // Additionally, there are ~10 other ops (+, *, /, ...) at 3-6 cycles each:\n // 40 * .62 = ~25.\n //\n // Finally, there are several other ops that are done every loop along with\n // 2 uniform generations along with 5 other ops at 3-6 cycles each.\n // ~15 / .89 = ~16\n //\n // In total this should be ~165 + 2 * Uniform::kElementCost.\n // We assume that half the tensor has rate < 10, so on average 6\n // uniform's\n // will be needed. We will upper bound the other op cost by the one for\n // rate > 10.\n static const int kElementCost = 165 + 6 * Uniform::kElementCost +\n 6 * random::PhiloxRandom::kElementCost;\n auto worker_threads = *(ctx->device()->tensorflow_cpu_worker_threads());\n Shard(worker_threads.num_threads, worker_threads.workers,\n num_rate * num_samples, kElementCost, DoWork);\n }",
" private:\n typedef typename PoissonComputeType<T>::ComputeType CT;\n};",
"} // namespace functor",
"namespace {",
"// Samples from one or more Poisson distributions.\ntemplate <typename T, typename U>\nclass RandomPoissonOp : public OpKernel {\n public:\n explicit RandomPoissonOp(OpKernelConstruction* context) : OpKernel(context) {\n OP_REQUIRES_OK(context, generator_.Init(context));\n }",
" void Compute(OpKernelContext* ctx) override {\n const Tensor& shape_t = ctx->input(0);\n const Tensor& rate_t = ctx->input(1);",
" TensorShape samples_shape;\n OP_REQUIRES_OK(ctx, tensor::MakeShape(shape_t, &samples_shape));\n const int64_t num_samples = samples_shape.num_elements();",
" OP_REQUIRES_OK(ctx, samples_shape.AppendShapeWithStatus(rate_t.shape()));\n",
" // Allocate output samples.\n Tensor* samples_t = nullptr;\n OP_REQUIRES_OK(ctx, ctx->allocate_output(0, samples_shape, &samples_t));\n if (num_samples == 0) return;",
" const auto rate_flat = rate_t.flat<T>().data();\n const int64_t num_rate = rate_t.NumElements();\n auto samples_flat = samples_t->flat<U>().data();\n random::PhiloxRandom rng = generator_.ReserveRandomOutputs(\n num_samples * num_rate, kReservedSamplesPerOutput);",
" functor::PoissonFunctor<CPUDevice, T, U>()(\n ctx, ctx->eigen_device<CPUDevice>(), rate_flat, num_rate, num_samples,\n rng, samples_flat);\n }",
" private:\n GuardedPhiloxRandom generator_;",
" TF_DISALLOW_COPY_AND_ASSIGN(RandomPoissonOp);\n};\n} // namespace",
"#undef UNIFORM",
"#define REGISTER(TYPE) \\\n REGISTER_KERNEL_BUILDER( \\\n Name(\"RandomPoisson\").Device(DEVICE_CPU).TypeConstraint<TYPE>(\"dtype\"), \\\n RandomPoissonOp<TYPE, TYPE>);",
"TF_CALL_half(REGISTER);\nTF_CALL_float(REGISTER);\nTF_CALL_double(REGISTER);",
"#define REGISTER_V2(RTYPE, OTYPE) \\\n template struct functor::PoissonFunctor<CPUDevice, RTYPE, OTYPE>; \\\n REGISTER_KERNEL_BUILDER(Name(\"RandomPoissonV2\") \\\n .Device(DEVICE_CPU) \\\n .TypeConstraint<RTYPE>(\"R\") \\\n .TypeConstraint<OTYPE>(\"dtype\"), \\\n RandomPoissonOp<RTYPE, OTYPE>);",
"#define REGISTER_ALL(RTYPE) \\\n REGISTER_V2(RTYPE, Eigen::half); \\\n REGISTER_V2(RTYPE, float); \\\n REGISTER_V2(RTYPE, double); \\\n REGISTER_V2(RTYPE, int32); \\\n REGISTER_V2(RTYPE, int64_t);",
"REGISTER_ALL(Eigen::half);\nREGISTER_ALL(float);\nREGISTER_ALL(double);\nREGISTER_ALL(int32);\nREGISTER_ALL(int64_t);",
"#undef REGISTER_ALL\n#undef REGISTER_V2\n#undef REGISTER",
"} // end namespace tensorflow"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [170, 301, 218, 173], "buggy_code_start_loc": [169, 299, 18, 19], "filenames": ["tensorflow/core/kernels/random_op.cc", "tensorflow/core/kernels/random_poisson_op.cc", "tensorflow/python/kernel_tests/random/random_gamma_test.py", "tensorflow/python/kernel_tests/random/random_poisson_test.py"], "fixing_code_end_loc": [170, 301, 232, 183], "fixing_code_start_loc": [169, 299, 19, 20], "message": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "C6622D95-1C86-45C5-AB55-E6EEEA0996DF", "versionEndExcluding": "2.7.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "0F9D273D-02DC-441E-AA91-EAC8DEAA4B44", "versionEndExcluding": "2.8.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.8.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "FE4F8A81-6CC2-4F7F-9602-C170FDD926E7", "versionEndExcluding": "2.9.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.9.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc0:*:*:*:*:*:*", "matchCriteriaId": "1DBFBCE2-0A01-4575-BE45-6775ABFB8B28", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc1:*:*:*:*:*:*", "matchCriteriaId": "89806CF9-E423-4CA6-A01A-8175C260CB24", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc2:*:*:*:*:*:*", "matchCriteriaId": "F2B80690-A257-4E16-BD27-9AE045BC56ED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc3:*:*:*:*:*:*", "matchCriteriaId": "F335F9A4-5AB8-4E53-BC18-E01F7C653E5E", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue."}, {"lang": "es", "value": "TensorFlow es una plataforma de c\u00f3digo abierto para el aprendizaje autom\u00e1tico. Cuando \"RandomPoissonV2\" recibe formas y tasas de entrada grandes, da un fallo de \"CHECK\" que puede desencadenar un ataque de denegaci\u00f3n de servicio. Hemos parcheado el problema en el commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3 de GitHub. La correcci\u00f3n ser\u00e1 incluida en TensorFlow versi\u00f3n 2.10.0. Tambi\u00e9n seleccionaremos este compromiso en TensorFlow versi\u00f3n 2.9.1, TensorFlow versi\u00f3n 2.8.1, y TensorFlow versi\u00f3n 2.7.2, ya que estos tambi\u00e9n est\u00e1n afectados y todav\u00eda est\u00e1n en el rango admitido. No se presentan mitigaciones conocidas para este problema"}], "evaluatorComment": null, "id": "CVE-2022-36003", "lastModified": "2022-09-20T14:42:50.067", "metrics": {"cvssMetricV2": null, "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 5.9, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 2.2, "impactScore": 3.6, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-09-16T23:15:10.823", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cv2p-32v3-vhwq"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-617"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, "type": "CWE-617"}
| 359
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# Copyright 2016 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\"\"\"Tests for tensorflow.ops.random_ops.random_gamma.\"\"\"",
"import numpy as np\n",
"",
"from tensorflow.python.framework import dtypes",
"",
"from tensorflow.python.framework import ops\nfrom tensorflow.python.framework import random_seed\nfrom tensorflow.python.framework import test_util\nfrom tensorflow.python.kernel_tests.random import util\nfrom tensorflow.python.ops import array_ops\nfrom tensorflow.python.ops import math_ops\nfrom tensorflow.python.ops import random_ops\nfrom tensorflow.python.platform import test\nfrom tensorflow.python.platform import tf_logging",
"\nclass RandomGammaTest(test.TestCase):\n \"\"\"This is a medium test due to the moments computation taking some time.\"\"\"",
" def setUp(self):\n np.random.seed(137)\n random_seed.set_random_seed(137)",
" def _Sampler(self, num, alpha, beta, dtype, use_gpu=True, seed=None):",
" def func():\n with self.session(use_gpu=use_gpu, graph=ops.Graph()) as sess:\n rng = random_ops.random_gamma(\n [num], alpha, beta=beta, dtype=dtype, seed=seed)\n ret = np.empty([10, num])\n for i in range(10):\n ret[i, :] = self.evaluate(rng)\n return ret",
" return func",
" def testNpDtypes(self):\n self.evaluate(random_ops.random_gamma(\n [5], alpha=np.ones([2, 1, 3]), beta=np.ones([3]), dtype=np.float32))",
" def testEmptySamplingNoError(self):\n self.evaluate(random_ops.random_gamma(\n [5], alpha=np.ones([2, 0, 3]), beta=np.ones([3]), dtype=dtypes.float32))",
" @test_util.run_deprecated_v1\n def testMomentsFloat32(self):\n self._testMoments(dtypes.float32)",
" @test_util.run_deprecated_v1\n def testMomentsFloat64(self):\n self._testMoments(dtypes.float64)",
" def _testMoments(self, dt):\n try:\n from scipy import stats # pylint: disable=g-import-not-at-top\n except ImportError as e:\n tf_logging.warn(\"Cannot test moments: %s\" % e)\n return",
" # The moments test is a z-value test. This is the largest z-value\n # we want to tolerate. Since the z-test approximates a unit normal\n # distribution, it should almost definitely never exceed 6.\n z_limit = 6.0",
" for stride in 0, 1, 4, 17:\n alphas = [0.2, 1.0, 3.0]\n if dt == dtypes.float64:\n alphas = [0.01] + alphas\n for alpha in alphas:\n for scale in 9, 17:\n # Gamma moments only defined for values less than the scale param.\n max_moment = min(6, scale // 2)\n sampler = self._Sampler(20000, alpha, 1 / scale, dt, seed=12345)\n z_scores = util.test_moment_matching(\n sampler(),\n max_moment,\n stats.gamma(alpha, scale=scale),\n stride=stride,\n )\n self.assertAllLess(z_scores, z_limit)",
" def _testZeroDensity(self, alpha):\n \"\"\"Zero isn't in the support of the gamma distribution.",
" But quantized floating point math has its limits.\n TODO(bjp): Implement log-gamma sampler for small-shape distributions.",
" Args:\n alpha: float shape value to test\n \"\"\"\n try:\n from scipy import stats # pylint: disable=g-import-not-at-top\n except ImportError as e:\n tf_logging.warn(\"Cannot test zero density proportions: %s\" % e)\n return\n allowable_zeros = {\n dtypes.float16: stats.gamma(alpha).cdf(np.finfo(np.float16).tiny),\n dtypes.float32: stats.gamma(alpha).cdf(np.finfo(np.float32).tiny),\n dtypes.float64: stats.gamma(alpha).cdf(np.finfo(np.float64).tiny)\n }\n failures = []\n for dt in dtypes.float16, dtypes.float32, dtypes.float64:\n sampler = self._Sampler(10000, alpha, 1.0, dt, seed=12345)\n x = sampler()\n allowable = allowable_zeros[dt] * x.size\n allowable = allowable * 2 if allowable < 10 else allowable * 1.05\n if np.sum(x <= 0) > allowable:\n failures += [dt]\n self.assertEqual([], failures)",
" def testNonZeroSmallShape(self):\n self._testZeroDensity(0.01)",
" def testNonZeroSmallishShape(self):\n self._testZeroDensity(0.35)",
" # Asserts that different trials (1000 samples per trial) is unlikely\n # to see the same sequence of values. Will catch buggy\n # implementations which uses the same random number seed.\n def testDistinct(self):\n for dt in dtypes.float16, dtypes.float32, dtypes.float64:\n sampler = self._Sampler(1000, 2.0, 1.0, dt)\n x = sampler()\n y = sampler()\n # Number of different samples.\n count = (x == y).sum()\n count_limit = 20 if dt == dtypes.float16 else 10\n self.assertLess(count, count_limit)",
" # Checks that the CPU and GPU implementation returns the same results,\n # given the same random seed\n @test_util.run_deprecated_v1\n def testCPUGPUMatch(self):\n for dt in dtypes.float16, dtypes.float32, dtypes.float64:\n results = {}\n for use_gpu in [False, True]:\n sampler = self._Sampler(1000, 0.0, 1.0, dt, use_gpu=use_gpu, seed=12345)\n results[use_gpu] = sampler()\n if dt == dtypes.float16:\n self.assertAllClose(results[False], results[True], rtol=1e-3, atol=1e-3)\n else:\n self.assertAllClose(results[False], results[True], rtol=1e-6, atol=1e-6)",
" def testSeed(self):\n for dt in dtypes.float16, dtypes.float32, dtypes.float64:\n sx = self._Sampler(1000, 0.0, 1.0, dt, seed=345)\n sy = self._Sampler(1000, 0.0, 1.0, dt, seed=345)\n self.assertAllEqual(sx(), sy())",
" @test_util.run_deprecated_v1\n def testNoCSE(self):\n \"\"\"CSE = constant subexpression eliminator.",
" SetIsStateful() should prevent two identical random ops from getting\n merged.\n \"\"\"\n for dtype in dtypes.float16, dtypes.float32, dtypes.float64:\n with self.cached_session():\n rnd1 = random_ops.random_gamma([24], 2.0, dtype=dtype)\n rnd2 = random_ops.random_gamma([24], 2.0, dtype=dtype)\n diff = rnd2 - rnd1\n self.assertGreater(np.linalg.norm(diff.eval()), 0.1)",
" @test_util.run_deprecated_v1\n def testShape(self):\n # Fully known shape.\n rnd = random_ops.random_gamma([150], 2.0)\n self.assertEqual([150], rnd.get_shape().as_list())\n rnd = random_ops.random_gamma([150], 2.0, beta=[3.0, 4.0])\n self.assertEqual([150, 2], rnd.get_shape().as_list())\n rnd = random_ops.random_gamma([150], array_ops.ones([1, 2, 3]))\n self.assertEqual([150, 1, 2, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_gamma([20, 30], array_ops.ones([1, 2, 3]))\n self.assertEqual([20, 30, 1, 2, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_gamma(\n [123], array_ops.placeholder(\n dtypes.float32, shape=(2,)))\n self.assertEqual([123, 2], rnd.get_shape().as_list())\n # Partially known shape.\n rnd = random_ops.random_gamma(\n array_ops.placeholder(\n dtypes.int32, shape=(1,)), array_ops.ones([7, 3]))\n self.assertEqual([None, 7, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_gamma(\n array_ops.placeholder(\n dtypes.int32, shape=(3,)), array_ops.ones([9, 6]))\n self.assertEqual([None, None, None, 9, 6], rnd.get_shape().as_list())\n # Unknown shape.\n rnd = random_ops.random_gamma(\n array_ops.placeholder(dtypes.int32),\n array_ops.placeholder(dtypes.float32))\n self.assertIs(None, rnd.get_shape().ndims)\n rnd = random_ops.random_gamma([50], array_ops.placeholder(dtypes.float32))\n self.assertIs(None, rnd.get_shape().ndims)",
" @test_util.run_deprecated_v1\n def testPositive(self):\n n = int(10e3)\n for dt in [dtypes.float16, dtypes.float32, dtypes.float64]:\n with self.cached_session():\n x = random_ops.random_gamma(shape=[n], alpha=0.001, dtype=dt, seed=0)\n self.assertEqual(0, math_ops.reduce_sum(math_ops.cast(\n math_ops.less_equal(x, 0.), dtype=dtypes.int64)).eval())\n",
"",
"\nif __name__ == \"__main__\":\n test.main()"
] |
[
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [170, 301, 218, 173], "buggy_code_start_loc": [169, 299, 18, 19], "filenames": ["tensorflow/core/kernels/random_op.cc", "tensorflow/core/kernels/random_poisson_op.cc", "tensorflow/python/kernel_tests/random/random_gamma_test.py", "tensorflow/python/kernel_tests/random/random_poisson_test.py"], "fixing_code_end_loc": [170, 301, 232, 183], "fixing_code_start_loc": [169, 299, 19, 20], "message": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "C6622D95-1C86-45C5-AB55-E6EEEA0996DF", "versionEndExcluding": "2.7.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "0F9D273D-02DC-441E-AA91-EAC8DEAA4B44", "versionEndExcluding": "2.8.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.8.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "FE4F8A81-6CC2-4F7F-9602-C170FDD926E7", "versionEndExcluding": "2.9.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.9.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc0:*:*:*:*:*:*", "matchCriteriaId": "1DBFBCE2-0A01-4575-BE45-6775ABFB8B28", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc1:*:*:*:*:*:*", "matchCriteriaId": "89806CF9-E423-4CA6-A01A-8175C260CB24", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc2:*:*:*:*:*:*", "matchCriteriaId": "F2B80690-A257-4E16-BD27-9AE045BC56ED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc3:*:*:*:*:*:*", "matchCriteriaId": "F335F9A4-5AB8-4E53-BC18-E01F7C653E5E", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue."}, {"lang": "es", "value": "TensorFlow es una plataforma de c\u00f3digo abierto para el aprendizaje autom\u00e1tico. Cuando \"RandomPoissonV2\" recibe formas y tasas de entrada grandes, da un fallo de \"CHECK\" que puede desencadenar un ataque de denegaci\u00f3n de servicio. Hemos parcheado el problema en el commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3 de GitHub. La correcci\u00f3n ser\u00e1 incluida en TensorFlow versi\u00f3n 2.10.0. Tambi\u00e9n seleccionaremos este compromiso en TensorFlow versi\u00f3n 2.9.1, TensorFlow versi\u00f3n 2.8.1, y TensorFlow versi\u00f3n 2.7.2, ya que estos tambi\u00e9n est\u00e1n afectados y todav\u00eda est\u00e1n en el rango admitido. No se presentan mitigaciones conocidas para este problema"}], "evaluatorComment": null, "id": "CVE-2022-36003", "lastModified": "2022-09-20T14:42:50.067", "metrics": {"cvssMetricV2": null, "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 5.9, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 2.2, "impactScore": 3.6, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-09-16T23:15:10.823", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cv2p-32v3-vhwq"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-617"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, "type": "CWE-617"}
| 359
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# Copyright 2016 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\"\"\"Tests for tensorflow.ops.random_ops.random_gamma.\"\"\"",
"import numpy as np\n",
"from tensorflow.python.eager import context\nfrom tensorflow.python.framework import constant_op",
"from tensorflow.python.framework import dtypes",
"from tensorflow.python.framework import errors",
"from tensorflow.python.framework import ops\nfrom tensorflow.python.framework import random_seed\nfrom tensorflow.python.framework import test_util\nfrom tensorflow.python.kernel_tests.random import util\nfrom tensorflow.python.ops import array_ops\nfrom tensorflow.python.ops import math_ops\nfrom tensorflow.python.ops import random_ops\nfrom tensorflow.python.platform import test\nfrom tensorflow.python.platform import tf_logging",
"\nclass RandomGammaTest(test.TestCase):\n \"\"\"This is a medium test due to the moments computation taking some time.\"\"\"",
" def setUp(self):\n np.random.seed(137)\n random_seed.set_random_seed(137)",
" def _Sampler(self, num, alpha, beta, dtype, use_gpu=True, seed=None):",
" def func():\n with self.session(use_gpu=use_gpu, graph=ops.Graph()) as sess:\n rng = random_ops.random_gamma(\n [num], alpha, beta=beta, dtype=dtype, seed=seed)\n ret = np.empty([10, num])\n for i in range(10):\n ret[i, :] = self.evaluate(rng)\n return ret",
" return func",
" def testNpDtypes(self):\n self.evaluate(random_ops.random_gamma(\n [5], alpha=np.ones([2, 1, 3]), beta=np.ones([3]), dtype=np.float32))",
" def testEmptySamplingNoError(self):\n self.evaluate(random_ops.random_gamma(\n [5], alpha=np.ones([2, 0, 3]), beta=np.ones([3]), dtype=dtypes.float32))",
" @test_util.run_deprecated_v1\n def testMomentsFloat32(self):\n self._testMoments(dtypes.float32)",
" @test_util.run_deprecated_v1\n def testMomentsFloat64(self):\n self._testMoments(dtypes.float64)",
" def _testMoments(self, dt):\n try:\n from scipy import stats # pylint: disable=g-import-not-at-top\n except ImportError as e:\n tf_logging.warn(\"Cannot test moments: %s\" % e)\n return",
" # The moments test is a z-value test. This is the largest z-value\n # we want to tolerate. Since the z-test approximates a unit normal\n # distribution, it should almost definitely never exceed 6.\n z_limit = 6.0",
" for stride in 0, 1, 4, 17:\n alphas = [0.2, 1.0, 3.0]\n if dt == dtypes.float64:\n alphas = [0.01] + alphas\n for alpha in alphas:\n for scale in 9, 17:\n # Gamma moments only defined for values less than the scale param.\n max_moment = min(6, scale // 2)\n sampler = self._Sampler(20000, alpha, 1 / scale, dt, seed=12345)\n z_scores = util.test_moment_matching(\n sampler(),\n max_moment,\n stats.gamma(alpha, scale=scale),\n stride=stride,\n )\n self.assertAllLess(z_scores, z_limit)",
" def _testZeroDensity(self, alpha):\n \"\"\"Zero isn't in the support of the gamma distribution.",
" But quantized floating point math has its limits.\n TODO(bjp): Implement log-gamma sampler for small-shape distributions.",
" Args:\n alpha: float shape value to test\n \"\"\"\n try:\n from scipy import stats # pylint: disable=g-import-not-at-top\n except ImportError as e:\n tf_logging.warn(\"Cannot test zero density proportions: %s\" % e)\n return\n allowable_zeros = {\n dtypes.float16: stats.gamma(alpha).cdf(np.finfo(np.float16).tiny),\n dtypes.float32: stats.gamma(alpha).cdf(np.finfo(np.float32).tiny),\n dtypes.float64: stats.gamma(alpha).cdf(np.finfo(np.float64).tiny)\n }\n failures = []\n for dt in dtypes.float16, dtypes.float32, dtypes.float64:\n sampler = self._Sampler(10000, alpha, 1.0, dt, seed=12345)\n x = sampler()\n allowable = allowable_zeros[dt] * x.size\n allowable = allowable * 2 if allowable < 10 else allowable * 1.05\n if np.sum(x <= 0) > allowable:\n failures += [dt]\n self.assertEqual([], failures)",
" def testNonZeroSmallShape(self):\n self._testZeroDensity(0.01)",
" def testNonZeroSmallishShape(self):\n self._testZeroDensity(0.35)",
" # Asserts that different trials (1000 samples per trial) is unlikely\n # to see the same sequence of values. Will catch buggy\n # implementations which uses the same random number seed.\n def testDistinct(self):\n for dt in dtypes.float16, dtypes.float32, dtypes.float64:\n sampler = self._Sampler(1000, 2.0, 1.0, dt)\n x = sampler()\n y = sampler()\n # Number of different samples.\n count = (x == y).sum()\n count_limit = 20 if dt == dtypes.float16 else 10\n self.assertLess(count, count_limit)",
" # Checks that the CPU and GPU implementation returns the same results,\n # given the same random seed\n @test_util.run_deprecated_v1\n def testCPUGPUMatch(self):\n for dt in dtypes.float16, dtypes.float32, dtypes.float64:\n results = {}\n for use_gpu in [False, True]:\n sampler = self._Sampler(1000, 0.0, 1.0, dt, use_gpu=use_gpu, seed=12345)\n results[use_gpu] = sampler()\n if dt == dtypes.float16:\n self.assertAllClose(results[False], results[True], rtol=1e-3, atol=1e-3)\n else:\n self.assertAllClose(results[False], results[True], rtol=1e-6, atol=1e-6)",
" def testSeed(self):\n for dt in dtypes.float16, dtypes.float32, dtypes.float64:\n sx = self._Sampler(1000, 0.0, 1.0, dt, seed=345)\n sy = self._Sampler(1000, 0.0, 1.0, dt, seed=345)\n self.assertAllEqual(sx(), sy())",
" @test_util.run_deprecated_v1\n def testNoCSE(self):\n \"\"\"CSE = constant subexpression eliminator.",
" SetIsStateful() should prevent two identical random ops from getting\n merged.\n \"\"\"\n for dtype in dtypes.float16, dtypes.float32, dtypes.float64:\n with self.cached_session():\n rnd1 = random_ops.random_gamma([24], 2.0, dtype=dtype)\n rnd2 = random_ops.random_gamma([24], 2.0, dtype=dtype)\n diff = rnd2 - rnd1\n self.assertGreater(np.linalg.norm(diff.eval()), 0.1)",
" @test_util.run_deprecated_v1\n def testShape(self):\n # Fully known shape.\n rnd = random_ops.random_gamma([150], 2.0)\n self.assertEqual([150], rnd.get_shape().as_list())\n rnd = random_ops.random_gamma([150], 2.0, beta=[3.0, 4.0])\n self.assertEqual([150, 2], rnd.get_shape().as_list())\n rnd = random_ops.random_gamma([150], array_ops.ones([1, 2, 3]))\n self.assertEqual([150, 1, 2, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_gamma([20, 30], array_ops.ones([1, 2, 3]))\n self.assertEqual([20, 30, 1, 2, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_gamma(\n [123], array_ops.placeholder(\n dtypes.float32, shape=(2,)))\n self.assertEqual([123, 2], rnd.get_shape().as_list())\n # Partially known shape.\n rnd = random_ops.random_gamma(\n array_ops.placeholder(\n dtypes.int32, shape=(1,)), array_ops.ones([7, 3]))\n self.assertEqual([None, 7, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_gamma(\n array_ops.placeholder(\n dtypes.int32, shape=(3,)), array_ops.ones([9, 6]))\n self.assertEqual([None, None, None, 9, 6], rnd.get_shape().as_list())\n # Unknown shape.\n rnd = random_ops.random_gamma(\n array_ops.placeholder(dtypes.int32),\n array_ops.placeholder(dtypes.float32))\n self.assertIs(None, rnd.get_shape().ndims)\n rnd = random_ops.random_gamma([50], array_ops.placeholder(dtypes.float32))\n self.assertIs(None, rnd.get_shape().ndims)",
" @test_util.run_deprecated_v1\n def testPositive(self):\n n = int(10e3)\n for dt in [dtypes.float16, dtypes.float32, dtypes.float64]:\n with self.cached_session():\n x = random_ops.random_gamma(shape=[n], alpha=0.001, dtype=dt, seed=0)\n self.assertEqual(0, math_ops.reduce_sum(math_ops.cast(\n math_ops.less_equal(x, 0.), dtype=dtypes.int64)).eval())\n",
" def testSizeTooLarge(self):\n # Grappler asserts on size overflow, so this error is only caught when\n # running eagerly.\n if context.executing_eagerly():\n with self.assertRaisesRegex((ValueError, errors.InvalidArgumentError),\n \"overflow\"):\n rate = constant_op.constant(1.0, shape=(4, 4, 4, 4, 4))\n self.evaluate(\n random_ops.random_gamma(\n shape=[46902, 51188, 34063, 59195], alpha=rate))",
"\nif __name__ == \"__main__\":\n test.main()"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [170, 301, 218, 173], "buggy_code_start_loc": [169, 299, 18, 19], "filenames": ["tensorflow/core/kernels/random_op.cc", "tensorflow/core/kernels/random_poisson_op.cc", "tensorflow/python/kernel_tests/random/random_gamma_test.py", "tensorflow/python/kernel_tests/random/random_poisson_test.py"], "fixing_code_end_loc": [170, 301, 232, 183], "fixing_code_start_loc": [169, 299, 19, 20], "message": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "C6622D95-1C86-45C5-AB55-E6EEEA0996DF", "versionEndExcluding": "2.7.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "0F9D273D-02DC-441E-AA91-EAC8DEAA4B44", "versionEndExcluding": "2.8.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.8.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "FE4F8A81-6CC2-4F7F-9602-C170FDD926E7", "versionEndExcluding": "2.9.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.9.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc0:*:*:*:*:*:*", "matchCriteriaId": "1DBFBCE2-0A01-4575-BE45-6775ABFB8B28", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc1:*:*:*:*:*:*", "matchCriteriaId": "89806CF9-E423-4CA6-A01A-8175C260CB24", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc2:*:*:*:*:*:*", "matchCriteriaId": "F2B80690-A257-4E16-BD27-9AE045BC56ED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc3:*:*:*:*:*:*", "matchCriteriaId": "F335F9A4-5AB8-4E53-BC18-E01F7C653E5E", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue."}, {"lang": "es", "value": "TensorFlow es una plataforma de c\u00f3digo abierto para el aprendizaje autom\u00e1tico. Cuando \"RandomPoissonV2\" recibe formas y tasas de entrada grandes, da un fallo de \"CHECK\" que puede desencadenar un ataque de denegaci\u00f3n de servicio. Hemos parcheado el problema en el commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3 de GitHub. La correcci\u00f3n ser\u00e1 incluida en TensorFlow versi\u00f3n 2.10.0. Tambi\u00e9n seleccionaremos este compromiso en TensorFlow versi\u00f3n 2.9.1, TensorFlow versi\u00f3n 2.8.1, y TensorFlow versi\u00f3n 2.7.2, ya que estos tambi\u00e9n est\u00e1n afectados y todav\u00eda est\u00e1n en el rango admitido. No se presentan mitigaciones conocidas para este problema"}], "evaluatorComment": null, "id": "CVE-2022-36003", "lastModified": "2022-09-20T14:42:50.067", "metrics": {"cvssMetricV2": null, "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 5.9, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 2.2, "impactScore": 3.6, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-09-16T23:15:10.823", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cv2p-32v3-vhwq"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-617"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, "type": "CWE-617"}
| 359
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# Copyright 2016 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\"\"\"Tests for tensorflow.ops.random_ops.random_poisson.\"\"\"\nimport numpy as np",
"from tensorflow.python.framework import constant_op\nfrom tensorflow.python.framework import dtypes",
"",
"from tensorflow.python.framework import ops\nfrom tensorflow.python.framework import test_util\nfrom tensorflow.python.kernel_tests.random import util\nfrom tensorflow.python.ops import array_ops\nfrom tensorflow.python.ops import random_ops\nfrom tensorflow.python.platform import test\nfrom tensorflow.python.platform import tf_logging",
"# All supported dtypes for random_poisson().\n_SUPPORTED_DTYPES = (dtypes.float16, dtypes.float32, dtypes.float64,\n dtypes.int32, dtypes.int64)",
"\nclass RandomPoissonTest(test.TestCase):\n \"\"\"This is a large test due to the moments computation taking some time.\"\"\"",
" def _Sampler(self, num, lam, dtype, use_gpu, seed=None):",
" def func():\n with self.session(use_gpu=use_gpu, graph=ops.Graph()) as sess:\n rng = random_ops.random_poisson(lam, [num], dtype=dtype, seed=seed)\n ret = np.empty([10, num])\n for i in range(10):\n ret[i, :] = self.evaluate(rng)\n return ret",
" return func",
" def testMoments(self):\n try:\n from scipy import stats # pylint: disable=g-import-not-at-top\n except ImportError as e:\n tf_logging.warn(\"Cannot test moments: %s\", e)\n return",
" # The moments test is a z-value test. This is the largest z-value\n # we want to tolerate. Since the z-test approximates a unit normal\n # distribution, it should almost definitely never exceed 6.\n z_limit = 6.0\n for dt in _SUPPORTED_DTYPES:\n # Test when lam < 10 and when lam >= 10\n for stride in 0, 4, 10:\n for lam in (3., 20):\n max_moment = 5\n sampler = self._Sampler(10000, lam, dt, use_gpu=False, seed=12345)\n z_scores = util.test_moment_matching(\n sampler(),\n max_moment,\n stats.poisson(lam),\n stride=stride,\n )\n self.assertAllLess(z_scores, z_limit)",
" # Checks that the CPU and GPU implementation returns the same results,\n # given the same random seed\n @test_util.run_deprecated_v1\n def testCPUGPUMatch(self):\n for dt in _SUPPORTED_DTYPES:\n results = {}\n for use_gpu in [False, True]:\n sampler = self._Sampler(1000, 1.0, dt, use_gpu=use_gpu, seed=12345)\n results[use_gpu] = sampler()\n if dt == dtypes.float16:\n self.assertAllClose(results[False], results[True], rtol=1e-3, atol=1e-3)\n else:\n self.assertAllClose(results[False], results[True], rtol=1e-6, atol=1e-6)",
" @test_util.run_deprecated_v1\n def testSeed(self):\n for dt in dtypes.float16, dtypes.float32, dtypes.float64:\n sx = self._Sampler(1000, 1.0, dt, use_gpu=True, seed=345)\n sy = self._Sampler(1000, 1.0, dt, use_gpu=True, seed=345)\n self.assertAllEqual(sx(), sy())",
" @test_util.run_deprecated_v1\n def testNoCSE(self):\n \"\"\"CSE = constant subexpression eliminator.",
" SetIsStateful() should prevent two identical random ops from getting\n merged.\n \"\"\"\n for dtype in dtypes.float16, dtypes.float32, dtypes.float64:\n with self.cached_session():\n rnd1 = random_ops.random_poisson(2.0, [24], dtype=dtype)\n rnd2 = random_ops.random_poisson(2.0, [24], dtype=dtype)\n diff = rnd2 - rnd1\n # Since these are all positive integers, the norm will\n # be at least 1 if they are different.\n self.assertGreaterEqual(np.linalg.norm(diff.eval()), 1)",
" def testZeroShape(self):\n with self.cached_session():\n rnd = random_ops.random_poisson([], [], seed=12345)\n self.assertEqual([0], rnd.get_shape().as_list())\n self.assertAllClose(np.array([], dtype=np.float32), self.evaluate(rnd))",
" @test_util.run_deprecated_v1\n def testShape(self):\n # Fully known shape\n rnd = random_ops.random_poisson(2.0, [150], seed=12345)\n self.assertEqual([150], rnd.get_shape().as_list())\n rnd = random_ops.random_poisson(\n lam=array_ops.ones([1, 2, 3]),\n shape=[150],\n seed=12345)\n self.assertEqual([150, 1, 2, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_poisson(\n lam=array_ops.ones([1, 2, 3]),\n shape=[20, 30],\n seed=12345)\n self.assertEqual([20, 30, 1, 2, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_poisson(\n lam=array_ops.placeholder(dtypes.float32, shape=(2,)),\n shape=[12],\n seed=12345)\n self.assertEqual([12, 2], rnd.get_shape().as_list())\n # Partially known shape.\n rnd = random_ops.random_poisson(\n lam=array_ops.ones([7, 3]),\n shape=array_ops.placeholder(dtypes.int32, shape=(1,)),\n seed=12345)\n self.assertEqual([None, 7, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_poisson(\n lam=array_ops.ones([9, 6]),\n shape=array_ops.placeholder(dtypes.int32, shape=(3,)),\n seed=12345)\n self.assertEqual([None, None, None, 9, 6], rnd.get_shape().as_list())\n # Unknown shape.\n rnd = random_ops.random_poisson(\n lam=array_ops.placeholder(dtypes.float32),\n shape=array_ops.placeholder(dtypes.int32),\n seed=12345)\n self.assertIs(None, rnd.get_shape().ndims)\n rnd = random_ops.random_poisson(\n lam=array_ops.placeholder(dtypes.float32),\n shape=[50],\n seed=12345)\n self.assertIs(None, rnd.get_shape().ndims)",
" @test_util.run_deprecated_v1\n def testDTypeCombinationsV2(self):\n \"\"\"Tests random_poisson_v2() for all supported dtype combinations.\"\"\"\n with self.cached_session():\n for lam_dt in _SUPPORTED_DTYPES:\n for out_dt in _SUPPORTED_DTYPES:\n random_ops.random_poisson(\n constant_op.constant([1], dtype=lam_dt), [10],\n dtype=out_dt).eval()",
" @test_util.run_deprecated_v1\n def testInfRate(self):\n sample = random_ops.random_poisson(shape=[2], lam=np.inf)\n self.assertAllEqual([np.inf, np.inf], self.evaluate(sample))\n",
"",
"\nif __name__ == \"__main__\":\n test.main()"
] |
[
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [170, 301, 218, 173], "buggy_code_start_loc": [169, 299, 18, 19], "filenames": ["tensorflow/core/kernels/random_op.cc", "tensorflow/core/kernels/random_poisson_op.cc", "tensorflow/python/kernel_tests/random/random_gamma_test.py", "tensorflow/python/kernel_tests/random/random_poisson_test.py"], "fixing_code_end_loc": [170, 301, 232, 183], "fixing_code_start_loc": [169, 299, 19, 20], "message": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "C6622D95-1C86-45C5-AB55-E6EEEA0996DF", "versionEndExcluding": "2.7.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "0F9D273D-02DC-441E-AA91-EAC8DEAA4B44", "versionEndExcluding": "2.8.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.8.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "FE4F8A81-6CC2-4F7F-9602-C170FDD926E7", "versionEndExcluding": "2.9.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.9.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc0:*:*:*:*:*:*", "matchCriteriaId": "1DBFBCE2-0A01-4575-BE45-6775ABFB8B28", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc1:*:*:*:*:*:*", "matchCriteriaId": "89806CF9-E423-4CA6-A01A-8175C260CB24", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc2:*:*:*:*:*:*", "matchCriteriaId": "F2B80690-A257-4E16-BD27-9AE045BC56ED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc3:*:*:*:*:*:*", "matchCriteriaId": "F335F9A4-5AB8-4E53-BC18-E01F7C653E5E", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue."}, {"lang": "es", "value": "TensorFlow es una plataforma de c\u00f3digo abierto para el aprendizaje autom\u00e1tico. Cuando \"RandomPoissonV2\" recibe formas y tasas de entrada grandes, da un fallo de \"CHECK\" que puede desencadenar un ataque de denegaci\u00f3n de servicio. Hemos parcheado el problema en el commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3 de GitHub. La correcci\u00f3n ser\u00e1 incluida en TensorFlow versi\u00f3n 2.10.0. Tambi\u00e9n seleccionaremos este compromiso en TensorFlow versi\u00f3n 2.9.1, TensorFlow versi\u00f3n 2.8.1, y TensorFlow versi\u00f3n 2.7.2, ya que estos tambi\u00e9n est\u00e1n afectados y todav\u00eda est\u00e1n en el rango admitido. No se presentan mitigaciones conocidas para este problema"}], "evaluatorComment": null, "id": "CVE-2022-36003", "lastModified": "2022-09-20T14:42:50.067", "metrics": {"cvssMetricV2": null, "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 5.9, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 2.2, "impactScore": 3.6, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-09-16T23:15:10.823", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cv2p-32v3-vhwq"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-617"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, "type": "CWE-617"}
| 359
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# Copyright 2016 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\"\"\"Tests for tensorflow.ops.random_ops.random_poisson.\"\"\"\nimport numpy as np",
"from tensorflow.python.framework import constant_op\nfrom tensorflow.python.framework import dtypes",
"from tensorflow.python.framework import errors",
"from tensorflow.python.framework import ops\nfrom tensorflow.python.framework import test_util\nfrom tensorflow.python.kernel_tests.random import util\nfrom tensorflow.python.ops import array_ops\nfrom tensorflow.python.ops import random_ops\nfrom tensorflow.python.platform import test\nfrom tensorflow.python.platform import tf_logging",
"# All supported dtypes for random_poisson().\n_SUPPORTED_DTYPES = (dtypes.float16, dtypes.float32, dtypes.float64,\n dtypes.int32, dtypes.int64)",
"\nclass RandomPoissonTest(test.TestCase):\n \"\"\"This is a large test due to the moments computation taking some time.\"\"\"",
" def _Sampler(self, num, lam, dtype, use_gpu, seed=None):",
" def func():\n with self.session(use_gpu=use_gpu, graph=ops.Graph()) as sess:\n rng = random_ops.random_poisson(lam, [num], dtype=dtype, seed=seed)\n ret = np.empty([10, num])\n for i in range(10):\n ret[i, :] = self.evaluate(rng)\n return ret",
" return func",
" def testMoments(self):\n try:\n from scipy import stats # pylint: disable=g-import-not-at-top\n except ImportError as e:\n tf_logging.warn(\"Cannot test moments: %s\", e)\n return",
" # The moments test is a z-value test. This is the largest z-value\n # we want to tolerate. Since the z-test approximates a unit normal\n # distribution, it should almost definitely never exceed 6.\n z_limit = 6.0\n for dt in _SUPPORTED_DTYPES:\n # Test when lam < 10 and when lam >= 10\n for stride in 0, 4, 10:\n for lam in (3., 20):\n max_moment = 5\n sampler = self._Sampler(10000, lam, dt, use_gpu=False, seed=12345)\n z_scores = util.test_moment_matching(\n sampler(),\n max_moment,\n stats.poisson(lam),\n stride=stride,\n )\n self.assertAllLess(z_scores, z_limit)",
" # Checks that the CPU and GPU implementation returns the same results,\n # given the same random seed\n @test_util.run_deprecated_v1\n def testCPUGPUMatch(self):\n for dt in _SUPPORTED_DTYPES:\n results = {}\n for use_gpu in [False, True]:\n sampler = self._Sampler(1000, 1.0, dt, use_gpu=use_gpu, seed=12345)\n results[use_gpu] = sampler()\n if dt == dtypes.float16:\n self.assertAllClose(results[False], results[True], rtol=1e-3, atol=1e-3)\n else:\n self.assertAllClose(results[False], results[True], rtol=1e-6, atol=1e-6)",
" @test_util.run_deprecated_v1\n def testSeed(self):\n for dt in dtypes.float16, dtypes.float32, dtypes.float64:\n sx = self._Sampler(1000, 1.0, dt, use_gpu=True, seed=345)\n sy = self._Sampler(1000, 1.0, dt, use_gpu=True, seed=345)\n self.assertAllEqual(sx(), sy())",
" @test_util.run_deprecated_v1\n def testNoCSE(self):\n \"\"\"CSE = constant subexpression eliminator.",
" SetIsStateful() should prevent two identical random ops from getting\n merged.\n \"\"\"\n for dtype in dtypes.float16, dtypes.float32, dtypes.float64:\n with self.cached_session():\n rnd1 = random_ops.random_poisson(2.0, [24], dtype=dtype)\n rnd2 = random_ops.random_poisson(2.0, [24], dtype=dtype)\n diff = rnd2 - rnd1\n # Since these are all positive integers, the norm will\n # be at least 1 if they are different.\n self.assertGreaterEqual(np.linalg.norm(diff.eval()), 1)",
" def testZeroShape(self):\n with self.cached_session():\n rnd = random_ops.random_poisson([], [], seed=12345)\n self.assertEqual([0], rnd.get_shape().as_list())\n self.assertAllClose(np.array([], dtype=np.float32), self.evaluate(rnd))",
" @test_util.run_deprecated_v1\n def testShape(self):\n # Fully known shape\n rnd = random_ops.random_poisson(2.0, [150], seed=12345)\n self.assertEqual([150], rnd.get_shape().as_list())\n rnd = random_ops.random_poisson(\n lam=array_ops.ones([1, 2, 3]),\n shape=[150],\n seed=12345)\n self.assertEqual([150, 1, 2, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_poisson(\n lam=array_ops.ones([1, 2, 3]),\n shape=[20, 30],\n seed=12345)\n self.assertEqual([20, 30, 1, 2, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_poisson(\n lam=array_ops.placeholder(dtypes.float32, shape=(2,)),\n shape=[12],\n seed=12345)\n self.assertEqual([12, 2], rnd.get_shape().as_list())\n # Partially known shape.\n rnd = random_ops.random_poisson(\n lam=array_ops.ones([7, 3]),\n shape=array_ops.placeholder(dtypes.int32, shape=(1,)),\n seed=12345)\n self.assertEqual([None, 7, 3], rnd.get_shape().as_list())\n rnd = random_ops.random_poisson(\n lam=array_ops.ones([9, 6]),\n shape=array_ops.placeholder(dtypes.int32, shape=(3,)),\n seed=12345)\n self.assertEqual([None, None, None, 9, 6], rnd.get_shape().as_list())\n # Unknown shape.\n rnd = random_ops.random_poisson(\n lam=array_ops.placeholder(dtypes.float32),\n shape=array_ops.placeholder(dtypes.int32),\n seed=12345)\n self.assertIs(None, rnd.get_shape().ndims)\n rnd = random_ops.random_poisson(\n lam=array_ops.placeholder(dtypes.float32),\n shape=[50],\n seed=12345)\n self.assertIs(None, rnd.get_shape().ndims)",
" @test_util.run_deprecated_v1\n def testDTypeCombinationsV2(self):\n \"\"\"Tests random_poisson_v2() for all supported dtype combinations.\"\"\"\n with self.cached_session():\n for lam_dt in _SUPPORTED_DTYPES:\n for out_dt in _SUPPORTED_DTYPES:\n random_ops.random_poisson(\n constant_op.constant([1], dtype=lam_dt), [10],\n dtype=out_dt).eval()",
" @test_util.run_deprecated_v1\n def testInfRate(self):\n sample = random_ops.random_poisson(shape=[2], lam=np.inf)\n self.assertAllEqual([np.inf, np.inf], self.evaluate(sample))\n",
" def testSizeTooLarge(self):\n with self.assertRaisesRegex((ValueError, errors.InvalidArgumentError),\n \"overflow\"):\n rate = constant_op.constant(1.0, shape=(4, 4, 4, 4, 4))\n self.evaluate(\n random_ops.random_poisson(\n shape=[46902, 51188, 34063, 59195], lam=rate))\n",
"\nif __name__ == \"__main__\":\n test.main()"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [170, 301, 218, 173], "buggy_code_start_loc": [169, 299, 18, 19], "filenames": ["tensorflow/core/kernels/random_op.cc", "tensorflow/core/kernels/random_poisson_op.cc", "tensorflow/python/kernel_tests/random/random_gamma_test.py", "tensorflow/python/kernel_tests/random/random_poisson_test.py"], "fixing_code_end_loc": [170, 301, 232, 183], "fixing_code_start_loc": [169, 299, 19, 20], "message": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "C6622D95-1C86-45C5-AB55-E6EEEA0996DF", "versionEndExcluding": "2.7.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "0F9D273D-02DC-441E-AA91-EAC8DEAA4B44", "versionEndExcluding": "2.8.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.8.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "FE4F8A81-6CC2-4F7F-9602-C170FDD926E7", "versionEndExcluding": "2.9.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.9.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc0:*:*:*:*:*:*", "matchCriteriaId": "1DBFBCE2-0A01-4575-BE45-6775ABFB8B28", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc1:*:*:*:*:*:*", "matchCriteriaId": "89806CF9-E423-4CA6-A01A-8175C260CB24", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc2:*:*:*:*:*:*", "matchCriteriaId": "F2B80690-A257-4E16-BD27-9AE045BC56ED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.10:rc3:*:*:*:*:*:*", "matchCriteriaId": "F335F9A4-5AB8-4E53-BC18-E01F7C653E5E", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "TensorFlow is an open source platform for machine learning. When `RandomPoissonV2` receives large input shape and rates, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue."}, {"lang": "es", "value": "TensorFlow es una plataforma de c\u00f3digo abierto para el aprendizaje autom\u00e1tico. Cuando \"RandomPoissonV2\" recibe formas y tasas de entrada grandes, da un fallo de \"CHECK\" que puede desencadenar un ataque de denegaci\u00f3n de servicio. Hemos parcheado el problema en el commit 552bfced6ce4809db5f3ca305f60ff80dd40c5a3 de GitHub. La correcci\u00f3n ser\u00e1 incluida en TensorFlow versi\u00f3n 2.10.0. Tambi\u00e9n seleccionaremos este compromiso en TensorFlow versi\u00f3n 2.9.1, TensorFlow versi\u00f3n 2.8.1, y TensorFlow versi\u00f3n 2.7.2, ya que estos tambi\u00e9n est\u00e1n afectados y todav\u00eda est\u00e1n en el rango admitido. No se presentan mitigaciones conocidas para este problema"}], "evaluatorComment": null, "id": "CVE-2022-36003", "lastModified": "2022-09-20T14:42:50.067", "metrics": {"cvssMetricV2": null, "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 5.9, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 2.2, "impactScore": 3.6, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-09-16T23:15:10.823", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cv2p-32v3-vhwq"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-617"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/tensorflow/tensorflow/commit/552bfced6ce4809db5f3ca305f60ff80dd40c5a3"}, "type": "CWE-617"}
| 359
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"// SPDX-License-Identifier: GPL-2.0\n/*\n * Crypto user configuration API.\n *\n * Copyright (C) 2017-2018 Corentin Labbe <clabbe@baylibre.com>\n *\n */",
"#include <linux/crypto.h>\n#include <linux/cryptouser.h>\n#include <linux/sched.h>\n#include <net/netlink.h>\n#include <net/sock.h>\n#include <crypto/internal/skcipher.h>\n#include <crypto/internal/rng.h>\n#include <crypto/akcipher.h>\n#include <crypto/kpp.h>\n#include <crypto/internal/cryptouser.h>",
"#include \"internal.h\"",
"#define null_terminated(x)\t(strnlen(x, sizeof(x)) < sizeof(x))",
"struct crypto_dump_info {\n\tstruct sk_buff *in_skb;\n\tstruct sk_buff *out_skb;\n\tu32 nlmsg_seq;\n\tu16 nlmsg_flags;\n};",
"static int crypto_report_aead(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_aead raead;",
"\tmemset(&raead, 0, sizeof(raead));",
"\tstrscpy(raead.type, \"aead\", sizeof(raead.type));",
"\traead.stat_encrypt_cnt = atomic64_read(&alg->stats.aead.encrypt_cnt);\n\traead.stat_encrypt_tlen = atomic64_read(&alg->stats.aead.encrypt_tlen);\n\traead.stat_decrypt_cnt = atomic64_read(&alg->stats.aead.decrypt_cnt);\n\traead.stat_decrypt_tlen = atomic64_read(&alg->stats.aead.decrypt_tlen);\n\traead.stat_err_cnt = atomic64_read(&alg->stats.aead.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_AEAD, sizeof(raead), &raead);\n}",
"static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_cipher rcipher;",
"\tmemset(&rcipher, 0, sizeof(rcipher));",
"\tstrscpy(rcipher.type, \"cipher\", sizeof(rcipher.type));",
"\trcipher.stat_encrypt_cnt = atomic64_read(&alg->stats.cipher.encrypt_cnt);\n\trcipher.stat_encrypt_tlen = atomic64_read(&alg->stats.cipher.encrypt_tlen);\n\trcipher.stat_decrypt_cnt = atomic64_read(&alg->stats.cipher.decrypt_cnt);\n\trcipher.stat_decrypt_tlen = atomic64_read(&alg->stats.cipher.decrypt_tlen);\n\trcipher.stat_err_cnt = atomic64_read(&alg->stats.cipher.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_CIPHER, sizeof(rcipher), &rcipher);\n}",
"static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_compress rcomp;",
"\tmemset(&rcomp, 0, sizeof(rcomp));",
"\tstrscpy(rcomp.type, \"compression\", sizeof(rcomp.type));\n\trcomp.stat_compress_cnt = atomic64_read(&alg->stats.compress.compress_cnt);\n\trcomp.stat_compress_tlen = atomic64_read(&alg->stats.compress.compress_tlen);\n\trcomp.stat_decompress_cnt = atomic64_read(&alg->stats.compress.decompress_cnt);\n\trcomp.stat_decompress_tlen = atomic64_read(&alg->stats.compress.decompress_tlen);\n\trcomp.stat_err_cnt = atomic64_read(&alg->stats.compress.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_COMPRESS, sizeof(rcomp), &rcomp);\n}",
"static int crypto_report_acomp(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_compress racomp;",
"\tmemset(&racomp, 0, sizeof(racomp));",
"\tstrscpy(racomp.type, \"acomp\", sizeof(racomp.type));\n\tracomp.stat_compress_cnt = atomic64_read(&alg->stats.compress.compress_cnt);\n\tracomp.stat_compress_tlen = atomic64_read(&alg->stats.compress.compress_tlen);\n\tracomp.stat_decompress_cnt = atomic64_read(&alg->stats.compress.decompress_cnt);\n\tracomp.stat_decompress_tlen = atomic64_read(&alg->stats.compress.decompress_tlen);\n\tracomp.stat_err_cnt = atomic64_read(&alg->stats.compress.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_ACOMP, sizeof(racomp), &racomp);\n}",
"static int crypto_report_akcipher(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_akcipher rakcipher;",
"\tmemset(&rakcipher, 0, sizeof(rakcipher));",
"\tstrscpy(rakcipher.type, \"akcipher\", sizeof(rakcipher.type));\n\trakcipher.stat_encrypt_cnt = atomic64_read(&alg->stats.akcipher.encrypt_cnt);\n\trakcipher.stat_encrypt_tlen = atomic64_read(&alg->stats.akcipher.encrypt_tlen);\n\trakcipher.stat_decrypt_cnt = atomic64_read(&alg->stats.akcipher.decrypt_cnt);\n\trakcipher.stat_decrypt_tlen = atomic64_read(&alg->stats.akcipher.decrypt_tlen);\n\trakcipher.stat_sign_cnt = atomic64_read(&alg->stats.akcipher.sign_cnt);\n\trakcipher.stat_verify_cnt = atomic64_read(&alg->stats.akcipher.verify_cnt);\n\trakcipher.stat_err_cnt = atomic64_read(&alg->stats.akcipher.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_AKCIPHER,\n\t\t sizeof(rakcipher), &rakcipher);\n}",
"static int crypto_report_kpp(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_kpp rkpp;",
"\tmemset(&rkpp, 0, sizeof(rkpp));",
"\tstrscpy(rkpp.type, \"kpp\", sizeof(rkpp.type));",
"\trkpp.stat_setsecret_cnt = atomic64_read(&alg->stats.kpp.setsecret_cnt);\n\trkpp.stat_generate_public_key_cnt = atomic64_read(&alg->stats.kpp.generate_public_key_cnt);\n\trkpp.stat_compute_shared_secret_cnt = atomic64_read(&alg->stats.kpp.compute_shared_secret_cnt);\n\trkpp.stat_err_cnt = atomic64_read(&alg->stats.kpp.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_KPP, sizeof(rkpp), &rkpp);\n}",
"static int crypto_report_ahash(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_hash rhash;",
"\tmemset(&rhash, 0, sizeof(rhash));",
"\tstrscpy(rhash.type, \"ahash\", sizeof(rhash.type));",
"\trhash.stat_hash_cnt = atomic64_read(&alg->stats.hash.hash_cnt);\n\trhash.stat_hash_tlen = atomic64_read(&alg->stats.hash.hash_tlen);\n\trhash.stat_err_cnt = atomic64_read(&alg->stats.hash.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash);\n}",
"static int crypto_report_shash(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_hash rhash;",
"\tmemset(&rhash, 0, sizeof(rhash));",
"\tstrscpy(rhash.type, \"shash\", sizeof(rhash.type));",
"\trhash.stat_hash_cnt = atomic64_read(&alg->stats.hash.hash_cnt);\n\trhash.stat_hash_tlen = atomic64_read(&alg->stats.hash.hash_tlen);\n\trhash.stat_err_cnt = atomic64_read(&alg->stats.hash.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash);\n}",
"static int crypto_report_rng(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_rng rrng;",
"\tmemset(&rrng, 0, sizeof(rrng));",
"\tstrscpy(rrng.type, \"rng\", sizeof(rrng.type));",
"\trrng.stat_generate_cnt = atomic64_read(&alg->stats.rng.generate_cnt);\n\trrng.stat_generate_tlen = atomic64_read(&alg->stats.rng.generate_tlen);\n\trrng.stat_seed_cnt = atomic64_read(&alg->stats.rng.seed_cnt);\n\trrng.stat_err_cnt = atomic64_read(&alg->stats.rng.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_RNG, sizeof(rrng), &rrng);\n}",
"static int crypto_reportstat_one(struct crypto_alg *alg,\n\t\t\t\t struct crypto_user_alg *ualg,\n\t\t\t\t struct sk_buff *skb)\n{\n\tmemset(ualg, 0, sizeof(*ualg));",
"\tstrscpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name));\n\tstrscpy(ualg->cru_driver_name, alg->cra_driver_name,\n\t\tsizeof(ualg->cru_driver_name));\n\tstrscpy(ualg->cru_module_name, module_name(alg->cra_module),\n\t\tsizeof(ualg->cru_module_name));",
"\tualg->cru_type = 0;\n\tualg->cru_mask = 0;\n\tualg->cru_flags = alg->cra_flags;\n\tualg->cru_refcnt = refcount_read(&alg->cra_refcnt);",
"\tif (nla_put_u32(skb, CRYPTOCFGA_PRIORITY_VAL, alg->cra_priority))\n\t\tgoto nla_put_failure;\n\tif (alg->cra_flags & CRYPTO_ALG_LARVAL) {\n\t\tstruct crypto_stat_larval rl;",
"\t\tmemset(&rl, 0, sizeof(rl));\n\t\tstrscpy(rl.type, \"larval\", sizeof(rl.type));\n\t\tif (nla_put(skb, CRYPTOCFGA_STAT_LARVAL, sizeof(rl), &rl))\n\t\t\tgoto nla_put_failure;\n\t\tgoto out;\n\t}",
"\tswitch (alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL)) {\n\tcase CRYPTO_ALG_TYPE_AEAD:\n\t\tif (crypto_report_aead(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_SKCIPHER:\n\t\tif (crypto_report_cipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_BLKCIPHER:\n\t\tif (crypto_report_cipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_CIPHER:\n\t\tif (crypto_report_cipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_COMPRESS:\n\t\tif (crypto_report_comp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_ACOMPRESS:\n\t\tif (crypto_report_acomp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_SCOMPRESS:\n\t\tif (crypto_report_acomp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_AKCIPHER:\n\t\tif (crypto_report_akcipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_KPP:\n\t\tif (crypto_report_kpp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_AHASH:\n\t\tif (crypto_report_ahash(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_HASH:\n\t\tif (crypto_report_shash(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_RNG:\n\t\tif (crypto_report_rng(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tdefault:\n\t\tpr_err(\"ERROR: Unhandled alg %d in %s\\n\",\n\t\t alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL),\n\t\t __func__);\n\t}",
"out:\n\treturn 0;",
"nla_put_failure:\n\treturn -EMSGSIZE;\n}",
"static int crypto_reportstat_alg(struct crypto_alg *alg,\n\t\t\t\t struct crypto_dump_info *info)\n{\n\tstruct sk_buff *in_skb = info->in_skb;\n\tstruct sk_buff *skb = info->out_skb;\n\tstruct nlmsghdr *nlh;\n\tstruct crypto_user_alg *ualg;\n\tint err = 0;",
"\tnlh = nlmsg_put(skb, NETLINK_CB(in_skb).portid, info->nlmsg_seq,\n\t\t\tCRYPTO_MSG_GETSTAT, sizeof(*ualg), info->nlmsg_flags);\n\tif (!nlh) {\n\t\terr = -EMSGSIZE;\n\t\tgoto out;\n\t}",
"\tualg = nlmsg_data(nlh);",
"\terr = crypto_reportstat_one(alg, ualg, skb);\n\tif (err) {\n\t\tnlmsg_cancel(skb, nlh);\n\t\tgoto out;\n\t}",
"\tnlmsg_end(skb, nlh);",
"out:\n\treturn err;\n}",
"int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,\n\t\t struct nlattr **attrs)\n{\n\tstruct net *net = sock_net(in_skb->sk);\n\tstruct crypto_user_alg *p = nlmsg_data(in_nlh);\n\tstruct crypto_alg *alg;\n\tstruct sk_buff *skb;\n\tstruct crypto_dump_info info;\n\tint err;",
"\tif (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))\n\t\treturn -EINVAL;",
"\talg = crypto_alg_match(p, 0);\n\tif (!alg)\n\t\treturn -ENOENT;",
"\terr = -ENOMEM;\n\tskb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);\n\tif (!skb)\n\t\tgoto drop_alg;",
"\tinfo.in_skb = in_skb;\n\tinfo.out_skb = skb;\n\tinfo.nlmsg_seq = in_nlh->nlmsg_seq;\n\tinfo.nlmsg_flags = 0;",
"\terr = crypto_reportstat_alg(alg, &info);",
"drop_alg:\n\tcrypto_mod_put(alg);\n",
"\tif (err)",
"\t\treturn err;",
"",
"\n\treturn nlmsg_unicast(net->crypto_nlsk, skb, NETLINK_CB(in_skb).portid);\n}",
"MODULE_LICENSE(\"GPL\");"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [332], "buggy_code_start_loc": [331], "filenames": ["crypto/crypto_user_stat.c"], "fixing_code_end_loc": [335], "fixing_code_start_loc": [331], "message": "A memory leak in the crypto_reportstat() function in crypto/crypto_user_stat.c in the Linux kernel through 5.3.11 allows attackers to cause a denial of service (memory consumption) by triggering crypto_reportstat_alg() failures, aka CID-c03b04dcdba1.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "22BF102C-6F4F-4F6F-BDC4-CA17FDC10DF5", "versionEndExcluding": "5.3.16", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "4.20", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "989D0C5E-C0BF-49D8-86E2-91A93238FD1E", "versionEndExcluding": "5.4.3", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "5.4", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:5.5:rc1:*:*:*:*:*:*", "matchCriteriaId": "17CCD88F-373D-4BB5-B62E-8B55B05E2C31", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:fedoraproject:fedora:30:*:*:*:*:*:*:*", "matchCriteriaId": "97A4B8DF-58DA-4AB6-A1F9-331B36409BA3", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:31:*:*:*:*:*:*:*", "matchCriteriaId": "80F0FA5D-8D3B-4C0E-81E2-87998286AF33", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*", "matchCriteriaId": "23A7C53F-B80F-4E6A-AFA9-58EEA84BE11D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:19.10:*:*:*:*:*:*:*", "matchCriteriaId": "A31C8344-3E02-4EB8-8BD8-4C84B7959624", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:netapp:active_iq_unified_manager:-:*:*:*:*:vmware_vsphere:*:*", "matchCriteriaId": "3A756737-1CC4-42C2-A4DF-E1C893B4E2D5", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:data_availability_services:-:*:*:*:*:*:*:*", "matchCriteriaId": "0EF46487-B64A-454E-AECC-D74B83170ACD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:e-series_santricity_os_controller:*:*:*:*:*:*:*:*", "matchCriteriaId": "BD1E9594-C46F-40D1-8BC2-6B16635B55C4", "versionEndExcluding": null, "versionEndIncluding": "11.60.3", "versionStartExcluding": null, "versionStartIncluding": "11.0.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:hci_management_node:-:*:*:*:*:*:*:*", "matchCriteriaId": "A3C19813-E823-456A-B1CE-EC0684CE1953", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:solidfire:-:*:*:*:*:*:*:*", "matchCriteriaId": "A6E9EF0C-AFA8-4F7B-9FDC-1E0F7C26E737", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:steelstore_cloud_integrated_storage:-:*:*:*:*:*:*:*", "matchCriteriaId": "E94F7F59-1785-493F-91A7-5F5EA5E87E4D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:h:netapp:hci_compute_node:-:*:*:*:*:*:*:*", "matchCriteriaId": "AD7447BC-F315-4298-A822-549942FC118B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:h:netapp:hci_storage_node:-:*:*:*:*:*:*:*", "matchCriteriaId": "02DEB4FB-A21D-4CB1-B522-EEE5093E8521", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:broadcom:fabric_operating_system:-:*:*:*:*:*:*:*", "matchCriteriaId": "046FB51E-B768-44D3-AEB5-D857145CA840", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:netapp:aff_a700s_firmware:-:*:*:*:*:*:*:*", "matchCriteriaId": "952F55C9-7E7C-4539-9D08-E736B3488569", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:netapp:aff_a700s:-:*:*:*:*:*:*:*", "matchCriteriaId": "9FED1B0D-F901-413A-85D9-05D4C427570D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:netapp:fas8300_firmware:-:*:*:*:*:*:*:*", "matchCriteriaId": "89706810-031B-49F0-B353-FD27FD7B2776", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:netapp:fas8300:-:*:*:*:*:*:*:*", "matchCriteriaId": "03BCC59D-C782-4149-B6DC-5DDAFAB48F2D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:netapp:fas8700_firmware:-:*:*:*:*:*:*:*", "matchCriteriaId": "FDD1E822-1EA6-4E62-A58B-2378149D20DC", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:netapp:fas8700:-:*:*:*:*:*:*:*", "matchCriteriaId": "E07EAE5F-B1B5-4FDA-9B50-8CB1D2AFC5A0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:netapp:aff_a400_firmware:-:*:*:*:*:*:*:*", "matchCriteriaId": "56FD9B9A-BBE5-4CA5-B9F9-B16E1FE738C8", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:netapp:aff_a400:-:*:*:*:*:*:*:*", "matchCriteriaId": "F3E70A56-DBA8-45C7-8C49-1A036501156F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:netapp:h610s_firmware:-:*:*:*:*:*:*:*", "matchCriteriaId": "FD7CFE0E-9D1E-4495-B302-89C3096FC0DF", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:netapp:h610s:-:*:*:*:*:*:*:*", "matchCriteriaId": "F63A3FA7-AAED-4A9D-9FDE-6195302DA0F6", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}], "descriptions": [{"lang": "en", "value": "A memory leak in the crypto_reportstat() function in crypto/crypto_user_stat.c in the Linux kernel through 5.3.11 allows attackers to cause a denial of service (memory consumption) by triggering crypto_reportstat_alg() failures, aka CID-c03b04dcdba1."}, {"lang": "es", "value": "Una p\u00e9rdida de memoria en la funci\u00f3n crypto_reportstat() en el archivo crypto/crypto_user_stat.c en el kernel de Linux versiones hasta 5.3.11, permite a atacantes causar una denegaci\u00f3n de servicio (consumo de memoria) al desencadenar fallos de la funci\u00f3n crypto_reportstat_alg(), tambi\u00e9n se conoce como CID-c03b04dcdba1."}], "evaluatorComment": null, "id": "CVE-2019-19050", "lastModified": "2021-06-22T14:47:56.090", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 7.8, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:N/AC:L/Au:N/C:N/I:N/A:C", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2019-11-18T06:15:11.700", "references": [{"source": "cve@mitre.org", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/156455/Kernel-Live-Patch-Security-Notice-LSN-0063-1.html"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/c03b04dcdba1da39903e23cc4d072abf8f68f2dd"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/O3PSDE6PTOTVBK2YTKB2TFQP2SUBVSNF/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PY7LJMSPAGRIKABJPDKQDTXYW3L5RX2T/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://security.netapp.com/advisory/ntap-20191205-0001/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://usn.ubuntu.com/4258-1/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://usn.ubuntu.com/4284-1/"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-401"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/c03b04dcdba1da39903e23cc4d072abf8f68f2dd"}, "type": "CWE-401"}
| 360
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"// SPDX-License-Identifier: GPL-2.0\n/*\n * Crypto user configuration API.\n *\n * Copyright (C) 2017-2018 Corentin Labbe <clabbe@baylibre.com>\n *\n */",
"#include <linux/crypto.h>\n#include <linux/cryptouser.h>\n#include <linux/sched.h>\n#include <net/netlink.h>\n#include <net/sock.h>\n#include <crypto/internal/skcipher.h>\n#include <crypto/internal/rng.h>\n#include <crypto/akcipher.h>\n#include <crypto/kpp.h>\n#include <crypto/internal/cryptouser.h>",
"#include \"internal.h\"",
"#define null_terminated(x)\t(strnlen(x, sizeof(x)) < sizeof(x))",
"struct crypto_dump_info {\n\tstruct sk_buff *in_skb;\n\tstruct sk_buff *out_skb;\n\tu32 nlmsg_seq;\n\tu16 nlmsg_flags;\n};",
"static int crypto_report_aead(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_aead raead;",
"\tmemset(&raead, 0, sizeof(raead));",
"\tstrscpy(raead.type, \"aead\", sizeof(raead.type));",
"\traead.stat_encrypt_cnt = atomic64_read(&alg->stats.aead.encrypt_cnt);\n\traead.stat_encrypt_tlen = atomic64_read(&alg->stats.aead.encrypt_tlen);\n\traead.stat_decrypt_cnt = atomic64_read(&alg->stats.aead.decrypt_cnt);\n\traead.stat_decrypt_tlen = atomic64_read(&alg->stats.aead.decrypt_tlen);\n\traead.stat_err_cnt = atomic64_read(&alg->stats.aead.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_AEAD, sizeof(raead), &raead);\n}",
"static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_cipher rcipher;",
"\tmemset(&rcipher, 0, sizeof(rcipher));",
"\tstrscpy(rcipher.type, \"cipher\", sizeof(rcipher.type));",
"\trcipher.stat_encrypt_cnt = atomic64_read(&alg->stats.cipher.encrypt_cnt);\n\trcipher.stat_encrypt_tlen = atomic64_read(&alg->stats.cipher.encrypt_tlen);\n\trcipher.stat_decrypt_cnt = atomic64_read(&alg->stats.cipher.decrypt_cnt);\n\trcipher.stat_decrypt_tlen = atomic64_read(&alg->stats.cipher.decrypt_tlen);\n\trcipher.stat_err_cnt = atomic64_read(&alg->stats.cipher.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_CIPHER, sizeof(rcipher), &rcipher);\n}",
"static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_compress rcomp;",
"\tmemset(&rcomp, 0, sizeof(rcomp));",
"\tstrscpy(rcomp.type, \"compression\", sizeof(rcomp.type));\n\trcomp.stat_compress_cnt = atomic64_read(&alg->stats.compress.compress_cnt);\n\trcomp.stat_compress_tlen = atomic64_read(&alg->stats.compress.compress_tlen);\n\trcomp.stat_decompress_cnt = atomic64_read(&alg->stats.compress.decompress_cnt);\n\trcomp.stat_decompress_tlen = atomic64_read(&alg->stats.compress.decompress_tlen);\n\trcomp.stat_err_cnt = atomic64_read(&alg->stats.compress.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_COMPRESS, sizeof(rcomp), &rcomp);\n}",
"static int crypto_report_acomp(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_compress racomp;",
"\tmemset(&racomp, 0, sizeof(racomp));",
"\tstrscpy(racomp.type, \"acomp\", sizeof(racomp.type));\n\tracomp.stat_compress_cnt = atomic64_read(&alg->stats.compress.compress_cnt);\n\tracomp.stat_compress_tlen = atomic64_read(&alg->stats.compress.compress_tlen);\n\tracomp.stat_decompress_cnt = atomic64_read(&alg->stats.compress.decompress_cnt);\n\tracomp.stat_decompress_tlen = atomic64_read(&alg->stats.compress.decompress_tlen);\n\tracomp.stat_err_cnt = atomic64_read(&alg->stats.compress.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_ACOMP, sizeof(racomp), &racomp);\n}",
"static int crypto_report_akcipher(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_akcipher rakcipher;",
"\tmemset(&rakcipher, 0, sizeof(rakcipher));",
"\tstrscpy(rakcipher.type, \"akcipher\", sizeof(rakcipher.type));\n\trakcipher.stat_encrypt_cnt = atomic64_read(&alg->stats.akcipher.encrypt_cnt);\n\trakcipher.stat_encrypt_tlen = atomic64_read(&alg->stats.akcipher.encrypt_tlen);\n\trakcipher.stat_decrypt_cnt = atomic64_read(&alg->stats.akcipher.decrypt_cnt);\n\trakcipher.stat_decrypt_tlen = atomic64_read(&alg->stats.akcipher.decrypt_tlen);\n\trakcipher.stat_sign_cnt = atomic64_read(&alg->stats.akcipher.sign_cnt);\n\trakcipher.stat_verify_cnt = atomic64_read(&alg->stats.akcipher.verify_cnt);\n\trakcipher.stat_err_cnt = atomic64_read(&alg->stats.akcipher.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_AKCIPHER,\n\t\t sizeof(rakcipher), &rakcipher);\n}",
"static int crypto_report_kpp(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_kpp rkpp;",
"\tmemset(&rkpp, 0, sizeof(rkpp));",
"\tstrscpy(rkpp.type, \"kpp\", sizeof(rkpp.type));",
"\trkpp.stat_setsecret_cnt = atomic64_read(&alg->stats.kpp.setsecret_cnt);\n\trkpp.stat_generate_public_key_cnt = atomic64_read(&alg->stats.kpp.generate_public_key_cnt);\n\trkpp.stat_compute_shared_secret_cnt = atomic64_read(&alg->stats.kpp.compute_shared_secret_cnt);\n\trkpp.stat_err_cnt = atomic64_read(&alg->stats.kpp.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_KPP, sizeof(rkpp), &rkpp);\n}",
"static int crypto_report_ahash(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_hash rhash;",
"\tmemset(&rhash, 0, sizeof(rhash));",
"\tstrscpy(rhash.type, \"ahash\", sizeof(rhash.type));",
"\trhash.stat_hash_cnt = atomic64_read(&alg->stats.hash.hash_cnt);\n\trhash.stat_hash_tlen = atomic64_read(&alg->stats.hash.hash_tlen);\n\trhash.stat_err_cnt = atomic64_read(&alg->stats.hash.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash);\n}",
"static int crypto_report_shash(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_hash rhash;",
"\tmemset(&rhash, 0, sizeof(rhash));",
"\tstrscpy(rhash.type, \"shash\", sizeof(rhash.type));",
"\trhash.stat_hash_cnt = atomic64_read(&alg->stats.hash.hash_cnt);\n\trhash.stat_hash_tlen = atomic64_read(&alg->stats.hash.hash_tlen);\n\trhash.stat_err_cnt = atomic64_read(&alg->stats.hash.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash);\n}",
"static int crypto_report_rng(struct sk_buff *skb, struct crypto_alg *alg)\n{\n\tstruct crypto_stat_rng rrng;",
"\tmemset(&rrng, 0, sizeof(rrng));",
"\tstrscpy(rrng.type, \"rng\", sizeof(rrng.type));",
"\trrng.stat_generate_cnt = atomic64_read(&alg->stats.rng.generate_cnt);\n\trrng.stat_generate_tlen = atomic64_read(&alg->stats.rng.generate_tlen);\n\trrng.stat_seed_cnt = atomic64_read(&alg->stats.rng.seed_cnt);\n\trrng.stat_err_cnt = atomic64_read(&alg->stats.rng.err_cnt);",
"\treturn nla_put(skb, CRYPTOCFGA_STAT_RNG, sizeof(rrng), &rrng);\n}",
"static int crypto_reportstat_one(struct crypto_alg *alg,\n\t\t\t\t struct crypto_user_alg *ualg,\n\t\t\t\t struct sk_buff *skb)\n{\n\tmemset(ualg, 0, sizeof(*ualg));",
"\tstrscpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name));\n\tstrscpy(ualg->cru_driver_name, alg->cra_driver_name,\n\t\tsizeof(ualg->cru_driver_name));\n\tstrscpy(ualg->cru_module_name, module_name(alg->cra_module),\n\t\tsizeof(ualg->cru_module_name));",
"\tualg->cru_type = 0;\n\tualg->cru_mask = 0;\n\tualg->cru_flags = alg->cra_flags;\n\tualg->cru_refcnt = refcount_read(&alg->cra_refcnt);",
"\tif (nla_put_u32(skb, CRYPTOCFGA_PRIORITY_VAL, alg->cra_priority))\n\t\tgoto nla_put_failure;\n\tif (alg->cra_flags & CRYPTO_ALG_LARVAL) {\n\t\tstruct crypto_stat_larval rl;",
"\t\tmemset(&rl, 0, sizeof(rl));\n\t\tstrscpy(rl.type, \"larval\", sizeof(rl.type));\n\t\tif (nla_put(skb, CRYPTOCFGA_STAT_LARVAL, sizeof(rl), &rl))\n\t\t\tgoto nla_put_failure;\n\t\tgoto out;\n\t}",
"\tswitch (alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL)) {\n\tcase CRYPTO_ALG_TYPE_AEAD:\n\t\tif (crypto_report_aead(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_SKCIPHER:\n\t\tif (crypto_report_cipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_BLKCIPHER:\n\t\tif (crypto_report_cipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_CIPHER:\n\t\tif (crypto_report_cipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_COMPRESS:\n\t\tif (crypto_report_comp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_ACOMPRESS:\n\t\tif (crypto_report_acomp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_SCOMPRESS:\n\t\tif (crypto_report_acomp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_AKCIPHER:\n\t\tif (crypto_report_akcipher(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_KPP:\n\t\tif (crypto_report_kpp(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_AHASH:\n\t\tif (crypto_report_ahash(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_HASH:\n\t\tif (crypto_report_shash(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tcase CRYPTO_ALG_TYPE_RNG:\n\t\tif (crypto_report_rng(skb, alg))\n\t\t\tgoto nla_put_failure;\n\t\tbreak;\n\tdefault:\n\t\tpr_err(\"ERROR: Unhandled alg %d in %s\\n\",\n\t\t alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL),\n\t\t __func__);\n\t}",
"out:\n\treturn 0;",
"nla_put_failure:\n\treturn -EMSGSIZE;\n}",
"static int crypto_reportstat_alg(struct crypto_alg *alg,\n\t\t\t\t struct crypto_dump_info *info)\n{\n\tstruct sk_buff *in_skb = info->in_skb;\n\tstruct sk_buff *skb = info->out_skb;\n\tstruct nlmsghdr *nlh;\n\tstruct crypto_user_alg *ualg;\n\tint err = 0;",
"\tnlh = nlmsg_put(skb, NETLINK_CB(in_skb).portid, info->nlmsg_seq,\n\t\t\tCRYPTO_MSG_GETSTAT, sizeof(*ualg), info->nlmsg_flags);\n\tif (!nlh) {\n\t\terr = -EMSGSIZE;\n\t\tgoto out;\n\t}",
"\tualg = nlmsg_data(nlh);",
"\terr = crypto_reportstat_one(alg, ualg, skb);\n\tif (err) {\n\t\tnlmsg_cancel(skb, nlh);\n\t\tgoto out;\n\t}",
"\tnlmsg_end(skb, nlh);",
"out:\n\treturn err;\n}",
"int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,\n\t\t struct nlattr **attrs)\n{\n\tstruct net *net = sock_net(in_skb->sk);\n\tstruct crypto_user_alg *p = nlmsg_data(in_nlh);\n\tstruct crypto_alg *alg;\n\tstruct sk_buff *skb;\n\tstruct crypto_dump_info info;\n\tint err;",
"\tif (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))\n\t\treturn -EINVAL;",
"\talg = crypto_alg_match(p, 0);\n\tif (!alg)\n\t\treturn -ENOENT;",
"\terr = -ENOMEM;\n\tskb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);\n\tif (!skb)\n\t\tgoto drop_alg;",
"\tinfo.in_skb = in_skb;\n\tinfo.out_skb = skb;\n\tinfo.nlmsg_seq = in_nlh->nlmsg_seq;\n\tinfo.nlmsg_flags = 0;",
"\terr = crypto_reportstat_alg(alg, &info);",
"drop_alg:\n\tcrypto_mod_put(alg);\n",
"\tif (err) {\n\t\tkfree_skb(skb);",
"\t\treturn err;",
"\t}",
"\n\treturn nlmsg_unicast(net->crypto_nlsk, skb, NETLINK_CB(in_skb).portid);\n}",
"MODULE_LICENSE(\"GPL\");"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [332], "buggy_code_start_loc": [331], "filenames": ["crypto/crypto_user_stat.c"], "fixing_code_end_loc": [335], "fixing_code_start_loc": [331], "message": "A memory leak in the crypto_reportstat() function in crypto/crypto_user_stat.c in the Linux kernel through 5.3.11 allows attackers to cause a denial of service (memory consumption) by triggering crypto_reportstat_alg() failures, aka CID-c03b04dcdba1.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "22BF102C-6F4F-4F6F-BDC4-CA17FDC10DF5", "versionEndExcluding": "5.3.16", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "4.20", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "989D0C5E-C0BF-49D8-86E2-91A93238FD1E", "versionEndExcluding": "5.4.3", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "5.4", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:5.5:rc1:*:*:*:*:*:*", "matchCriteriaId": "17CCD88F-373D-4BB5-B62E-8B55B05E2C31", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:fedoraproject:fedora:30:*:*:*:*:*:*:*", "matchCriteriaId": "97A4B8DF-58DA-4AB6-A1F9-331B36409BA3", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:31:*:*:*:*:*:*:*", "matchCriteriaId": "80F0FA5D-8D3B-4C0E-81E2-87998286AF33", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*", "matchCriteriaId": "23A7C53F-B80F-4E6A-AFA9-58EEA84BE11D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:19.10:*:*:*:*:*:*:*", "matchCriteriaId": "A31C8344-3E02-4EB8-8BD8-4C84B7959624", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:netapp:active_iq_unified_manager:-:*:*:*:*:vmware_vsphere:*:*", "matchCriteriaId": "3A756737-1CC4-42C2-A4DF-E1C893B4E2D5", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:data_availability_services:-:*:*:*:*:*:*:*", "matchCriteriaId": "0EF46487-B64A-454E-AECC-D74B83170ACD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:e-series_santricity_os_controller:*:*:*:*:*:*:*:*", "matchCriteriaId": "BD1E9594-C46F-40D1-8BC2-6B16635B55C4", "versionEndExcluding": null, "versionEndIncluding": "11.60.3", "versionStartExcluding": null, "versionStartIncluding": "11.0.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:hci_management_node:-:*:*:*:*:*:*:*", "matchCriteriaId": "A3C19813-E823-456A-B1CE-EC0684CE1953", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:solidfire:-:*:*:*:*:*:*:*", "matchCriteriaId": "A6E9EF0C-AFA8-4F7B-9FDC-1E0F7C26E737", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:steelstore_cloud_integrated_storage:-:*:*:*:*:*:*:*", "matchCriteriaId": "E94F7F59-1785-493F-91A7-5F5EA5E87E4D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:h:netapp:hci_compute_node:-:*:*:*:*:*:*:*", "matchCriteriaId": "AD7447BC-F315-4298-A822-549942FC118B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:h:netapp:hci_storage_node:-:*:*:*:*:*:*:*", "matchCriteriaId": "02DEB4FB-A21D-4CB1-B522-EEE5093E8521", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:broadcom:fabric_operating_system:-:*:*:*:*:*:*:*", "matchCriteriaId": "046FB51E-B768-44D3-AEB5-D857145CA840", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:netapp:aff_a700s_firmware:-:*:*:*:*:*:*:*", "matchCriteriaId": "952F55C9-7E7C-4539-9D08-E736B3488569", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:netapp:aff_a700s:-:*:*:*:*:*:*:*", "matchCriteriaId": "9FED1B0D-F901-413A-85D9-05D4C427570D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:netapp:fas8300_firmware:-:*:*:*:*:*:*:*", "matchCriteriaId": "89706810-031B-49F0-B353-FD27FD7B2776", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:netapp:fas8300:-:*:*:*:*:*:*:*", "matchCriteriaId": "03BCC59D-C782-4149-B6DC-5DDAFAB48F2D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:netapp:fas8700_firmware:-:*:*:*:*:*:*:*", "matchCriteriaId": "FDD1E822-1EA6-4E62-A58B-2378149D20DC", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:netapp:fas8700:-:*:*:*:*:*:*:*", "matchCriteriaId": "E07EAE5F-B1B5-4FDA-9B50-8CB1D2AFC5A0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:netapp:aff_a400_firmware:-:*:*:*:*:*:*:*", "matchCriteriaId": "56FD9B9A-BBE5-4CA5-B9F9-B16E1FE738C8", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:netapp:aff_a400:-:*:*:*:*:*:*:*", "matchCriteriaId": "F3E70A56-DBA8-45C7-8C49-1A036501156F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:netapp:h610s_firmware:-:*:*:*:*:*:*:*", "matchCriteriaId": "FD7CFE0E-9D1E-4495-B302-89C3096FC0DF", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:netapp:h610s:-:*:*:*:*:*:*:*", "matchCriteriaId": "F63A3FA7-AAED-4A9D-9FDE-6195302DA0F6", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}], "descriptions": [{"lang": "en", "value": "A memory leak in the crypto_reportstat() function in crypto/crypto_user_stat.c in the Linux kernel through 5.3.11 allows attackers to cause a denial of service (memory consumption) by triggering crypto_reportstat_alg() failures, aka CID-c03b04dcdba1."}, {"lang": "es", "value": "Una p\u00e9rdida de memoria en la funci\u00f3n crypto_reportstat() en el archivo crypto/crypto_user_stat.c en el kernel de Linux versiones hasta 5.3.11, permite a atacantes causar una denegaci\u00f3n de servicio (consumo de memoria) al desencadenar fallos de la funci\u00f3n crypto_reportstat_alg(), tambi\u00e9n se conoce como CID-c03b04dcdba1."}], "evaluatorComment": null, "id": "CVE-2019-19050", "lastModified": "2021-06-22T14:47:56.090", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 7.8, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:N/AC:L/Au:N/C:N/I:N/A:C", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2019-11-18T06:15:11.700", "references": [{"source": "cve@mitre.org", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://packetstormsecurity.com/files/156455/Kernel-Live-Patch-Security-Notice-LSN-0063-1.html"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/c03b04dcdba1da39903e23cc4d072abf8f68f2dd"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/O3PSDE6PTOTVBK2YTKB2TFQP2SUBVSNF/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PY7LJMSPAGRIKABJPDKQDTXYW3L5RX2T/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://security.netapp.com/advisory/ntap-20191205-0001/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://usn.ubuntu.com/4258-1/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://usn.ubuntu.com/4284-1/"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-401"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/c03b04dcdba1da39903e23cc4d072abf8f68f2dd"}, "type": "CWE-401"}
| 360
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Copyright (C) 2000-2002 Constantin Kaplinsky. All Rights Reserved.\n * Copyright (C) 2000 Tridia Corporation. All Rights Reserved.\n * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.\n *\n * This is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this software; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\n * USA.\n */",
"/*\n * rfbproto.c - functions to deal with client side of RFB protocol.\n */",
"#ifdef __STRICT_ANSI__\n#define _BSD_SOURCE\n#define _POSIX_SOURCE\n#define _XOPEN_SOURCE 600\n#endif\n#ifndef WIN32\n#include <unistd.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <pwd.h>\n#endif\n#include <errno.h>\n#include <rfb/rfbclient.h>\n#ifdef WIN32\n#undef socklen_t\n#endif\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n#include <zlib.h>\n#ifdef __CHECKER__\n#undef Z_NULL\n#define Z_NULL NULL\n#endif\n#endif",
"#ifndef _MSC_VER\n/* Strings.h is not available in MSVC */\n#include <strings.h>\n#endif",
"#include <stdarg.h>\n#include <time.h>",
"#include \"crypto.h\"",
"#include \"sasl.h\"\n#ifdef LIBVNCSERVER_HAVE_LZO\n#include <lzo/lzo1x.h>\n#else\n#include \"minilzo.h\"\n#endif\n#include \"tls.h\"\n",
"",
"\n/*\n * rfbClientLog prints a time-stamped message to the log file (stderr).\n */",
"rfbBool rfbEnableClientLogging=TRUE;",
"static void\nrfbDefaultClientLog(const char *format, ...)\n{\n va_list args;\n char buf[256];\n time_t log_clock;",
" if(!rfbEnableClientLogging)\n return;",
" va_start(args, format);",
" time(&log_clock);\n strftime(buf, 255, \"%d/%m/%Y %X \", localtime(&log_clock));\n fprintf(stderr, \"%s\", buf);",
" vfprintf(stderr, format, args);\n fflush(stderr);",
" va_end(args);\n}",
"rfbClientLogProc rfbClientLog=rfbDefaultClientLog;\nrfbClientLogProc rfbClientErr=rfbDefaultClientLog;",
"/* extensions */",
"rfbClientProtocolExtension* rfbClientExtensions = NULL;",
"void rfbClientRegisterExtension(rfbClientProtocolExtension* e)\n{\n\te->next = rfbClientExtensions;\n\trfbClientExtensions = e;\n}",
"/* client data */",
"void rfbClientSetClientData(rfbClient* client, void* tag, void* data)\n{\n\trfbClientData* clientData = client->clientData;",
"\twhile(clientData && clientData->tag != tag)\n\t\tclientData = clientData->next;\n\tif(clientData == NULL) {\n\t\tclientData = calloc(sizeof(rfbClientData), 1);\n\t\tclientData->next = client->clientData;\n\t\tclient->clientData = clientData;\n\t\tclientData->tag = tag;\n\t}",
"\tclientData->data = data;\n}",
"void* rfbClientGetClientData(rfbClient* client, void* tag)\n{\n\trfbClientData* clientData = client->clientData;",
"\twhile(clientData) {\n\t\tif(clientData->tag == tag)\n\t\t\treturn clientData->data;\n\t\tclientData = clientData->next;\n\t}",
"\treturn NULL;\n}",
"static rfbBool HandleRRE8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleRRE16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleRRE32(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleCoRRE8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleCoRRE16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleCoRRE32(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleHextile8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleHextile16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleHextile32(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltra8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltra16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltra32(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltraZip8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltraZip16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltraZip32(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE15(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE24(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE24Up(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE24Down(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE32(rfbClient* client, int rx, int ry, int rw, int rh);\n#ifdef LIBVNCSERVER_HAVE_LIBZ\nstatic rfbBool HandleZlib8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZlib16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZlib32(rfbClient* client, int rx, int ry, int rw, int rh);\n#ifdef LIBVNCSERVER_HAVE_LIBJPEG\nstatic rfbBool HandleTight8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTight16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTight32(rfbClient* client, int rx, int ry, int rw, int rh);",
"static long ReadCompactLen (rfbClient* client);\n#endif\nstatic rfbBool HandleZRLE8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE15(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE24(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE24Up(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE24Down(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE32(rfbClient* client, int rx, int ry, int rw, int rh);\n#endif",
"/*\n * Server Capability Functions\n */\nrfbBool\nSupportsClient2Server(rfbClient* client, int messageType)\n{\n return (client->supportedMessages.client2server[((messageType & 0xFF)/8)] & (1<<(messageType % 8)) ? TRUE : FALSE);\n}",
"rfbBool\nSupportsServer2Client(rfbClient* client, int messageType)\n{\n return (client->supportedMessages.server2client[((messageType & 0xFF)/8)] & (1<<(messageType % 8)) ? TRUE : FALSE);\n}",
"void\nSetClient2Server(rfbClient* client, int messageType)\n{\n client->supportedMessages.client2server[((messageType & 0xFF)/8)] |= (1<<(messageType % 8));\n}",
"void\nSetServer2Client(rfbClient* client, int messageType)\n{\n client->supportedMessages.server2client[((messageType & 0xFF)/8)] |= (1<<(messageType % 8));\n}",
"void\nClearClient2Server(rfbClient* client, int messageType)\n{\n client->supportedMessages.client2server[((messageType & 0xFF)/8)] &= ~(1<<(messageType % 8));\n}",
"void\nClearServer2Client(rfbClient* client, int messageType)\n{\n client->supportedMessages.server2client[((messageType & 0xFF)/8)] &= ~(1<<(messageType % 8));\n}",
"\nvoid\nDefaultSupportedMessages(rfbClient* client)\n{\n memset((char *)&client->supportedMessages,0,sizeof(client->supportedMessages));",
" /* Default client supported messages (universal RFB 3.3 protocol) */\n SetClient2Server(client, rfbSetPixelFormat);\n /* SetClient2Server(client, rfbFixColourMapEntries); Not currently supported */\n SetClient2Server(client, rfbSetEncodings);\n SetClient2Server(client, rfbFramebufferUpdateRequest);\n SetClient2Server(client, rfbKeyEvent);\n SetClient2Server(client, rfbPointerEvent);\n SetClient2Server(client, rfbClientCutText);\n /* technically, we only care what we can *send* to the server\n * but, we set Server2Client Just in case it ever becomes useful\n */\n SetServer2Client(client, rfbFramebufferUpdate);\n SetServer2Client(client, rfbSetColourMapEntries);\n SetServer2Client(client, rfbBell);\n SetServer2Client(client, rfbServerCutText);\n}",
"void\nDefaultSupportedMessagesUltraVNC(rfbClient* client)\n{\n DefaultSupportedMessages(client);\n SetClient2Server(client, rfbFileTransfer);\n SetClient2Server(client, rfbSetScale);\n SetClient2Server(client, rfbSetServerInput);\n SetClient2Server(client, rfbSetSW);\n SetClient2Server(client, rfbTextChat);\n SetClient2Server(client, rfbPalmVNCSetScaleFactor);\n /* technically, we only care what we can *send* to the server */\n SetServer2Client(client, rfbResizeFrameBuffer);\n SetServer2Client(client, rfbPalmVNCReSizeFrameBuffer);\n SetServer2Client(client, rfbFileTransfer);\n SetServer2Client(client, rfbTextChat);\n}",
"\nvoid\nDefaultSupportedMessagesTightVNC(rfbClient* client)\n{\n DefaultSupportedMessages(client);\n SetClient2Server(client, rfbFileTransfer);\n SetClient2Server(client, rfbSetServerInput);\n SetClient2Server(client, rfbSetSW);\n /* SetClient2Server(client, rfbTextChat); */\n /* technically, we only care what we can *send* to the server */\n SetServer2Client(client, rfbFileTransfer);\n SetServer2Client(client, rfbTextChat);\n}",
"#ifndef WIN32\nstatic rfbBool\nIsUnixSocket(const char *name)\n{\n struct stat sb;\n if(stat(name, &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFSOCK)\n return TRUE;\n return FALSE;\n}\n#endif",
"/*\n * ConnectToRFBServer.\n */",
"rfbBool\nConnectToRFBServer(rfbClient* client,const char *hostname, int port)\n{\n if (client->serverPort==-1) {\n /* serverHost is a file recorded by vncrec. */\n const char* magic=\"vncLog0.0\";\n char buffer[10];\n rfbVNCRec* rec = (rfbVNCRec*)malloc(sizeof(rfbVNCRec));\n client->vncRec = rec;",
" rec->file = fopen(client->serverHost,\"rb\");\n rec->tv.tv_sec = 0;\n rec->readTimestamp = FALSE;\n rec->doNotSleep = FALSE;\n \n if (!rec->file) {\n rfbClientLog(\"Could not open %s.\\n\",client->serverHost);\n return FALSE;\n }\n setbuf(rec->file,NULL);",
" if (fread(buffer,1,strlen(magic),rec->file) != strlen(magic) || strncmp(buffer,magic,strlen(magic))) {\n rfbClientLog(\"File %s was not recorded by vncrec.\\n\",client->serverHost);\n fclose(rec->file);\n return FALSE;\n }\n client->sock = RFB_INVALID_SOCKET;\n return TRUE;\n }",
"#ifndef WIN32\n if(IsUnixSocket(hostname))\n /* serverHost is a UNIX socket. */\n client->sock = ConnectClientToUnixSockWithTimeout(hostname, client->connectTimeout);\n else\n#endif\n {\n#ifdef LIBVNCSERVER_IPv6\n client->sock = ConnectClientToTcpAddr6WithTimeout(hostname, port, client->connectTimeout);\n#else\n unsigned int host;",
" /* serverHost is a hostname */\n if (!StringToIPAddr(hostname, &host)) {\n rfbClientLog(\"Couldn't convert '%s' to host address\\n\", hostname);\n return FALSE;\n }\n client->sock = ConnectClientToTcpAddrWithTimeout(host, port, client->connectTimeout);\n#endif\n }",
" if (client->sock == RFB_INVALID_SOCKET) {\n rfbClientLog(\"Unable to connect to VNC server\\n\");\n return FALSE;\n }",
" if(client->QoS_DSCP && !SetDSCP(client->sock, client->QoS_DSCP))\n return FALSE;",
" return TRUE;\n}",
"/*\n * ConnectToRFBRepeater.\n */",
"rfbBool ConnectToRFBRepeater(rfbClient* client,const char *repeaterHost, int repeaterPort, const char *destHost, int destPort)\n{\n rfbProtocolVersionMsg pv;\n int major,minor;\n char tmphost[250];",
"#ifdef LIBVNCSERVER_IPv6\n client->sock = ConnectClientToTcpAddr6WithTimeout(repeaterHost, repeaterPort, client->connectTimeout);\n#else\n unsigned int host;\n if (!StringToIPAddr(repeaterHost, &host)) {\n rfbClientLog(\"Couldn't convert '%s' to host address\\n\", repeaterHost);\n return FALSE;\n }",
" client->sock = ConnectClientToTcpAddrWithTimeout(host, repeaterPort, client->connectTimeout);\n#endif",
" if (client->sock == RFB_INVALID_SOCKET) {\n rfbClientLog(\"Unable to connect to VNC repeater\\n\");\n return FALSE;\n }",
" if (!ReadFromRFBServer(client, pv, sz_rfbProtocolVersionMsg))\n return FALSE;\n pv[sz_rfbProtocolVersionMsg] = 0;",
" /* UltraVNC repeater always report version 000.000 to identify itself */\n if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2 || major != 0 || minor != 0) {\n rfbClientLog(\"Not a valid VNC repeater (%s)\\n\",pv);\n return FALSE;\n }",
" rfbClientLog(\"Connected to VNC repeater, using protocol version %d.%d\\n\", major, minor);",
" memset(tmphost, 0, sizeof(tmphost));\n if(snprintf(tmphost, sizeof(tmphost), \"%s:%d\", destHost, destPort) >= (int)sizeof(tmphost))\n return FALSE; /* output truncated */\n if (!WriteToRFBServer(client, tmphost, sizeof(tmphost)))\n return FALSE;",
" return TRUE;\n}",
"extern void rfbClientEncryptBytes(unsigned char* bytes, char* passwd);\nextern void rfbClientEncryptBytes2(unsigned char *where, const int length, unsigned char *key);",
"static void\nReadReason(rfbClient* client)\n{\n uint32_t reasonLen;\n char *reason;",
" if (!ReadFromRFBServer(client, (char *)&reasonLen, 4)) return;\n reasonLen = rfbClientSwap32IfLE(reasonLen);\n if(reasonLen > 1<<20) {\n rfbClientLog(\"VNC connection failed, but sent reason length of %u exceeds limit of 1MB\",(unsigned int)reasonLen);\n return;\n }\n reason = malloc(reasonLen+1);\n if (!ReadFromRFBServer(client, reason, reasonLen)) { free(reason); return; }\n reason[reasonLen]=0;\n rfbClientLog(\"VNC connection failed: %s\\n\",reason);\n free(reason);\n}",
"rfbBool\nrfbHandleAuthResult(rfbClient* client)\n{\n uint32_t authResult=0;",
" if (!ReadFromRFBServer(client, (char *)&authResult, 4)) return FALSE;",
" authResult = rfbClientSwap32IfLE(authResult);",
" switch (authResult) {\n case rfbVncAuthOK:\n rfbClientLog(\"VNC authentication succeeded\\n\");\n return TRUE;\n break;\n case rfbVncAuthFailed:\n if (client->major==3 && client->minor>7)\n {\n /* we have an error following */\n ReadReason(client);\n return FALSE;\n }\n rfbClientLog(\"VNC authentication failed\\n\");\n return FALSE;\n case rfbVncAuthTooMany:\n rfbClientLog(\"VNC authentication failed - too many tries\\n\");\n return FALSE;\n }",
" rfbClientLog(\"Unknown VNC authentication result: %d\\n\",\n (int)authResult);\n return FALSE;\n}",
"\nstatic rfbBool\nReadSupportedSecurityType(rfbClient* client, uint32_t *result, rfbBool subAuth)\n{\n uint8_t count=0;\n uint8_t loop=0;\n uint8_t flag=0;\n rfbBool extAuthHandler;\n uint8_t tAuth[256];\n char buf1[500],buf2[10];\n uint32_t authScheme;\n rfbClientProtocolExtension* e;",
" if (!ReadFromRFBServer(client, (char *)&count, 1)) return FALSE;",
" if (count==0)\n {\n rfbClientLog(\"List of security types is ZERO, expecting an error to follow\\n\");\n ReadReason(client);\n return FALSE;\n }",
" rfbClientLog(\"We have %d security types to read\\n\", count);\n authScheme=0;\n /* now, we have a list of available security types to read ( uint8_t[] ) */\n for (loop=0;loop<count;loop++)\n {\n if (!ReadFromRFBServer(client, (char *)&tAuth[loop], 1)) return FALSE;\n rfbClientLog(\"%d) Received security type %d\\n\", loop, tAuth[loop]);\n if (flag) continue;\n extAuthHandler=FALSE;\n for (e = rfbClientExtensions; e; e = e->next) {\n if (!e->handleAuthentication) continue;\n uint32_t const* secType;\n for (secType = e->securityTypes; secType && *secType; secType++) {\n if (tAuth[loop]==*secType) {\n extAuthHandler=TRUE;\n }\n }\n }\n if (tAuth[loop]==rfbVncAuth || tAuth[loop]==rfbNoAuth ||\n\t\t\textAuthHandler ||\n#if defined(LIBVNCSERVER_HAVE_GNUTLS) || defined(LIBVNCSERVER_HAVE_LIBSSL)\n tAuth[loop]==rfbVeNCrypt ||\n#endif\n#ifdef LIBVNCSERVER_HAVE_SASL\n tAuth[loop]==rfbSASL ||\n#endif /* LIBVNCSERVER_HAVE_SASL */\n (tAuth[loop]==rfbARD && client->GetCredential) ||\n (!subAuth && (tAuth[loop]==rfbTLS || (tAuth[loop]==rfbVeNCrypt && client->GetCredential))))\n {\n if (!subAuth && client->clientAuthSchemes)\n {\n int i;\n for (i=0;client->clientAuthSchemes[i];i++)\n {\n if (client->clientAuthSchemes[i]==(uint32_t)tAuth[loop])\n {\n flag++;\n authScheme=tAuth[loop];\n break;\n }\n }\n }\n else\n {\n flag++;\n authScheme=tAuth[loop];\n }\n if (flag)\n {\n rfbClientLog(\"Selecting security type %d (%d/%d in the list)\\n\", authScheme, loop, count);\n /* send back a single byte indicating which security type to use */\n if (!WriteToRFBServer(client, (char *)&tAuth[loop], 1)) return FALSE;\n }\n }\n }\n if (authScheme==0)\n {\n memset(buf1, 0, sizeof(buf1));\n for (loop=0;loop<count;loop++)\n {\n if (strlen(buf1)>=sizeof(buf1)-1) break;\n snprintf(buf2, sizeof(buf2), (loop>0 ? \", %d\" : \"%d\"), (int)tAuth[loop]);\n strncat(buf1, buf2, sizeof(buf1)-strlen(buf1)-1);\n }\n rfbClientLog(\"Unknown authentication scheme from VNC server: %s\\n\",\n buf1);\n return FALSE;\n }\n *result = authScheme;\n return TRUE;\n}",
"static rfbBool\nHandleVncAuth(rfbClient *client)\n{\n uint8_t challenge[CHALLENGESIZE];\n char *passwd=NULL;\n int i;",
" if (!ReadFromRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE;",
" if (client->serverPort!=-1) { /* if not playing a vncrec file */\n if (client->GetPassword)\n passwd = client->GetPassword(client);",
" if ((!passwd) || (strlen(passwd) == 0)) {\n rfbClientLog(\"Reading password failed\\n\");\n return FALSE;\n }\n if (strlen(passwd) > 8) {\n passwd[8] = '\\0';\n }",
" rfbClientEncryptBytes(challenge, passwd);",
" /* Lose the password from memory */\n for (i = strlen(passwd); i >= 0; i--) {\n passwd[i] = '\\0';\n }\n free(passwd);",
" if (!WriteToRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE;\n }",
" /* Handle the SecurityResult message */\n if (!rfbHandleAuthResult(client)) return FALSE;",
" return TRUE;\n}",
"static void\nFreeUserCredential(rfbCredential *cred)\n{\n if (cred->userCredential.username) free(cred->userCredential.username);\n if (cred->userCredential.password) free(cred->userCredential.password);\n free(cred);\n}",
"static rfbBool\nHandlePlainAuth(rfbClient *client)\n{\n uint32_t ulen, ulensw;\n uint32_t plen, plensw;\n rfbCredential *cred;",
" if (!client->GetCredential)\n {\n rfbClientLog(\"GetCredential callback is not set.\\n\");\n return FALSE;\n }\n cred = client->GetCredential(client, rfbCredentialTypeUser);\n if (!cred)\n {\n rfbClientLog(\"Reading credential failed\\n\");\n return FALSE;\n }",
" ulen = (cred->userCredential.username ? strlen(cred->userCredential.username) : 0);\n ulensw = rfbClientSwap32IfLE(ulen);\n plen = (cred->userCredential.password ? strlen(cred->userCredential.password) : 0);\n plensw = rfbClientSwap32IfLE(plen);\n if (!WriteToRFBServer(client, (char *)&ulensw, 4) ||\n !WriteToRFBServer(client, (char *)&plensw, 4))\n {\n FreeUserCredential(cred);\n return FALSE;\n }\n if (ulen > 0)\n {\n if (!WriteToRFBServer(client, cred->userCredential.username, ulen))\n {\n FreeUserCredential(cred);\n return FALSE;\n }\n }\n if (plen > 0)\n {\n if (!WriteToRFBServer(client, cred->userCredential.password, plen))\n {\n FreeUserCredential(cred);\n return FALSE;\n }\n }",
" FreeUserCredential(cred);",
" /* Handle the SecurityResult message */\n if (!rfbHandleAuthResult(client)) return FALSE;",
" return TRUE;\n}",
"/* Simple 64bit big integer arithmetic implementation */\n/* (x + y) % m, works even if (x + y) > 64bit */\n#define rfbAddM64(x,y,m) ((x+y)%m+(x+y<x?(((uint64_t)-1)%m+1)%m:0))\n/* (x * y) % m */\nstatic uint64_t\nrfbMulM64(uint64_t x, uint64_t y, uint64_t m)\n{\n uint64_t r;\n for(r=0;x>0;x>>=1)\n {\n if (x&1) r=rfbAddM64(r,y,m);\n y=rfbAddM64(y,y,m);\n }\n return r;\n}\n/* (x ^ y) % m */\nstatic uint64_t\nrfbPowM64(uint64_t b, uint64_t e, uint64_t m)\n{\n uint64_t r;\n for(r=1;e>0;e>>=1)\n {\n if(e&1) r=rfbMulM64(r,b,m);\n b=rfbMulM64(b,b,m);\n }\n return r;\n}",
"static rfbBool\nHandleMSLogonAuth(rfbClient *client)\n{\n uint64_t gen, mod, resp, priv, pub, key;\n uint8_t username[256], password[64];\n rfbCredential *cred;",
" if (!ReadFromRFBServer(client, (char *)&gen, 8)) return FALSE;\n if (!ReadFromRFBServer(client, (char *)&mod, 8)) return FALSE;\n if (!ReadFromRFBServer(client, (char *)&resp, 8)) return FALSE;\n gen = rfbClientSwap64IfLE(gen);\n mod = rfbClientSwap64IfLE(mod);\n resp = rfbClientSwap64IfLE(resp);",
" if (!client->GetCredential)\n {\n rfbClientLog(\"GetCredential callback is not set.\\n\");\n return FALSE;\n }\n rfbClientLog(\"WARNING! MSLogon security type has very low password encryption! \"\\\n \"Use it only with SSH tunnel or trusted network.\\n\");\n cred = client->GetCredential(client, rfbCredentialTypeUser);\n if (!cred)\n {\n rfbClientLog(\"Reading credential failed\\n\");\n return FALSE;\n }",
" memset(username, 0, sizeof(username));\n strncpy((char *)username, cred->userCredential.username, sizeof(username)-1);\n memset(password, 0, sizeof(password));\n strncpy((char *)password, cred->userCredential.password, sizeof(password)-1);\n FreeUserCredential(cred);",
" srand(time(NULL));\n priv = ((uint64_t)rand())<<32;\n priv |= (uint64_t)rand();",
" pub = rfbPowM64(gen, priv, mod);\n key = rfbPowM64(resp, priv, mod);\n pub = rfbClientSwap64IfLE(pub);\n key = rfbClientSwap64IfLE(key);",
" rfbClientEncryptBytes2(username, sizeof(username), (unsigned char *)&key);\n rfbClientEncryptBytes2(password, sizeof(password), (unsigned char *)&key);",
" if (!WriteToRFBServer(client, (char *)&pub, 8)) return FALSE;\n if (!WriteToRFBServer(client, (char *)username, sizeof(username))) return FALSE;\n if (!WriteToRFBServer(client, (char *)password, sizeof(password))) return FALSE;",
" /* Handle the SecurityResult message */\n if (!rfbHandleAuthResult(client)) return FALSE;",
" return TRUE;\n}",
"\nstatic rfbBool\nHandleARDAuth(rfbClient *client)\n{\n uint8_t gen[2], len[2];\n size_t keylen;\n uint8_t *mod = NULL, *resp = NULL, *priv = NULL, *pub = NULL, *key = NULL, *shared = NULL;\n uint8_t userpass[128], ciphertext[128];\n int ciphertext_len;\n int passwordLen, usernameLen;\n rfbCredential *cred = NULL;\n rfbBool result = FALSE;",
" /* Step 1: Read the authentication material from the socket.\n A two-byte generator value, a two-byte key length value. */\n if (!ReadFromRFBServer(client, (char *)gen, 2)) {\n rfbClientErr(\"HandleARDAuth: reading generator value failed\\n\");\n goto out;\n }\n if (!ReadFromRFBServer(client, (char *)len, 2)) {\n rfbClientErr(\"HandleARDAuth: reading key length failed\\n\");\n goto out;\n }\n keylen = 256*len[0]+len[1]; /* convert from char[] to int */",
" mod = (uint8_t*)malloc(keylen*5); /* the block actually contains mod, resp, pub, priv and key */\n if (!mod)\n goto out;",
" resp = mod+keylen;\n pub = resp+keylen;\n priv = pub+keylen;\n key = priv+keylen;",
" /* Step 1: Read the authentication material from the socket.\n The prime modulus (keylen bytes) and the peer's generated public key (keylen bytes). */\n if (!ReadFromRFBServer(client, (char *)mod, keylen)) {\n rfbClientErr(\"HandleARDAuth: reading prime modulus failed\\n\");\n goto out;\n }\n if (!ReadFromRFBServer(client, (char *)resp, keylen)) {\n rfbClientErr(\"HandleARDAuth: reading peer's generated public key failed\\n\");\n goto out;\n }",
" /* Step 2: Generate own Diffie-Hellman public-private key pair. */\n if(!dh_generate_keypair(priv, pub, gen, 2, mod, keylen)) {\n rfbClientErr(\"HandleARDAuth: generating keypair failed\\n\");\n goto out;\n }",
" /* Step 3: Perform Diffie-Hellman key agreement, using the generator (gen),\n prime (mod), and the peer's public key. The output will be a shared\n secret known to both us and the peer. */\n if(!dh_compute_shared_key(key, priv, resp, mod, keylen)) {\n rfbClientErr(\"HandleARDAuth: creating shared key failed\\n\");\n goto out;\n }",
" /* Step 4: Perform an MD5 hash of the shared secret.\n This 128-bit (16-byte) value will be used as the AES key. */\n shared = malloc(MD5_HASH_SIZE);\n if(!hash_md5(shared, key, keylen)) {\n rfbClientErr(\"HandleARDAuth: hashing shared key failed\\n\");\n goto out;\n }",
" /* Step 5: Pack the username and password into a 128-byte\n plaintext \"userpass\" structure: { username[64], password[64] }.\n Null-terminate each. Fill the unused bytes with random characters\n so that the encryption output is less predictable. */\n if(!client->GetCredential) {\n rfbClientErr(\"HandleARDAuth: GetCredential callback is not set\\n\");\n goto out;\n }\n cred = client->GetCredential(client, rfbCredentialTypeUser);\n if(!cred) {\n rfbClientErr(\"HandleARDAuth: reading credential failed\\n\");\n goto out;\n }\n passwordLen = strlen(cred->userCredential.password)+1;\n usernameLen = strlen(cred->userCredential.username)+1;\n if (passwordLen > sizeof(userpass)/2)\n passwordLen = sizeof(userpass)/2;\n if (usernameLen > sizeof(userpass)/2)\n usernameLen = sizeof(userpass)/2;\n random_bytes(userpass, sizeof(userpass));\n memcpy(userpass, cred->userCredential.username, usernameLen);\n memcpy(userpass+sizeof(userpass)/2, cred->userCredential.password, passwordLen);",
" /* Step 6: Encrypt the plaintext credentials with the 128-bit MD5 hash\n from step 4, using the AES 128-bit symmetric cipher in electronic\n codebook (ECB) mode. Use no further padding for this block cipher. */\n if(!encrypt_aes128ecb(ciphertext, &ciphertext_len, shared, userpass, sizeof(userpass))) {\n rfbClientErr(\"HandleARDAuth: encrypting credentials failed\\n\");\n goto out;\n }",
" /* Step 7: Write the ciphertext from step 6 to the stream.\n Write the generated DH public key to the stream. */\n if (!WriteToRFBServer(client, (char *)ciphertext, sizeof(ciphertext)))\n goto out;\n if (!WriteToRFBServer(client, (char *)pub, keylen))\n goto out;",
" /* Handle the SecurityResult message */\n if (!rfbHandleAuthResult(client))\n goto out;",
" result = TRUE;",
" out:\n if (cred)\n FreeUserCredential(cred);",
" free(mod);\n free(shared);",
" return result;\n}",
"",
"/*\n * SetClientAuthSchemes.\n */",
"void\nSetClientAuthSchemes(rfbClient* client,const uint32_t *authSchemes, int size)\n{\n int i;",
" if (client->clientAuthSchemes)\n {\n free(client->clientAuthSchemes);\n client->clientAuthSchemes = NULL;\n }\n if (authSchemes)\n {\n if (size<0)\n {\n /* If size<0 we assume the passed-in list is also 0-terminate, so we\n * calculate the size here */\n for (size=0;authSchemes[size];size++) ;\n }\n client->clientAuthSchemes = (uint32_t*)malloc(sizeof(uint32_t)*(size+1));\n for (i=0;i<size;i++)\n client->clientAuthSchemes[i] = authSchemes[i];\n client->clientAuthSchemes[size] = 0;\n }\n}",
"/*\n * InitialiseRFBConnection.\n */",
"rfbBool\nInitialiseRFBConnection(rfbClient* client)\n{\n rfbProtocolVersionMsg pv;\n int major,minor;\n uint32_t authScheme;\n uint32_t subAuthScheme;\n rfbClientInitMsg ci;",
" /* if the connection is immediately closed, don't report anything, so\n that pmw's monitor can make test connections */",
" if (client->listenSpecified)\n errorMessageOnReadFailure = FALSE;",
" if (!ReadFromRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE;\n pv[sz_rfbProtocolVersionMsg]=0;",
" errorMessageOnReadFailure = TRUE;",
" pv[sz_rfbProtocolVersionMsg] = 0;",
" if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2) {\n rfbClientLog(\"Not a valid VNC server (%s)\\n\",pv);\n return FALSE;\n }",
"\n DefaultSupportedMessages(client);\n client->major = major;\n client->minor = minor;",
" /* fall back to viewer supported version */\n if ((major==rfbProtocolMajorVersion) && (minor>rfbProtocolMinorVersion))\n client->minor = rfbProtocolMinorVersion;",
" /* UltraVNC uses minor codes 4 and 6 for the server */\n if (major==3 && (minor==4 || minor==6)) {\n rfbClientLog(\"UltraVNC server detected, enabling UltraVNC specific messages\\n\",pv);\n DefaultSupportedMessagesUltraVNC(client);\n }",
" /* UltraVNC Single Click uses minor codes 14 and 16 for the server */\n if (major==3 && (minor==14 || minor==16)) {\n minor = minor - 10;\n client->minor = minor;\n rfbClientLog(\"UltraVNC Single Click server detected, enabling UltraVNC specific messages\\n\",pv);\n DefaultSupportedMessagesUltraVNC(client);\n }",
" /* TightVNC uses minor codes 5 for the server */\n if (major==3 && minor==5) {\n rfbClientLog(\"TightVNC server detected, enabling TightVNC specific messages\\n\",pv);\n DefaultSupportedMessagesTightVNC(client);\n }",
" /* we do not support > RFB3.8 */\n if ((major==3 && minor>8) || major>3)\n {\n client->major=3;\n client->minor=8;\n }",
" rfbClientLog(\"VNC server supports protocol version %d.%d (viewer %d.%d)\\n\",\n\t major, minor, rfbProtocolMajorVersion, rfbProtocolMinorVersion);",
" sprintf(pv,rfbProtocolVersionFormat,client->major,client->minor);",
" if (!WriteToRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE;",
"\n /* 3.7 and onwards sends a # of security types first */\n if (client->major==3 && client->minor > 6)\n {\n if (!ReadSupportedSecurityType(client, &authScheme, FALSE)) return FALSE;\n }\n else\n {\n if (!ReadFromRFBServer(client, (char *)&authScheme, 4)) return FALSE;\n authScheme = rfbClientSwap32IfLE(authScheme);\n }\n \n rfbClientLog(\"Selected Security Scheme %d\\n\", authScheme);\n client->authScheme = authScheme;\n \n switch (authScheme) {",
" case rfbConnFailed:\n ReadReason(client);\n return FALSE;",
" case rfbNoAuth:\n rfbClientLog(\"No authentication needed\\n\");",
" /* 3.8 and upwards sends a Security Result for rfbNoAuth */\n if ((client->major==3 && client->minor > 7) || client->major>3)\n if (!rfbHandleAuthResult(client)) return FALSE; ",
" break;",
" case rfbVncAuth:\n if (!HandleVncAuth(client)) return FALSE;\n break;",
"#ifdef LIBVNCSERVER_HAVE_SASL\n case rfbSASL:\n if (!HandleSASLAuth(client)) return FALSE;\n break;\n#endif /* LIBVNCSERVER_HAVE_SASL */",
" case rfbMSLogon:\n if (!HandleMSLogonAuth(client)) return FALSE;\n break;",
" case rfbARD:\n if (!HandleARDAuth(client)) return FALSE;\n break;",
" case rfbTLS:\n if (!HandleAnonTLSAuth(client)) return FALSE;\n /* After the TLS session is established, sub auth types are expected.\n * Note that all following reading/writing are through the TLS session from here.\n */\n if (!ReadSupportedSecurityType(client, &subAuthScheme, TRUE)) return FALSE;\n client->subAuthScheme = subAuthScheme;",
" switch (subAuthScheme) {",
" case rfbConnFailed:\n ReadReason(client);\n return FALSE;",
" case rfbNoAuth:\n rfbClientLog(\"No sub authentication needed\\n\");\n /* 3.8 and upwards sends a Security Result for rfbNoAuth */\n if ((client->major==3 && client->minor > 7) || client->major>3)\n if (!rfbHandleAuthResult(client)) return FALSE;\n break;",
" case rfbVncAuth:\n if (!HandleVncAuth(client)) return FALSE;\n break;",
"#ifdef LIBVNCSERVER_HAVE_SASL\n case rfbSASL:\n if (!HandleSASLAuth(client)) return FALSE;\n break;\n#endif /* LIBVNCSERVER_HAVE_SASL */",
" default:\n rfbClientLog(\"Unknown sub authentication scheme from VNC server: %d\\n\",\n (int)subAuthScheme);\n return FALSE;\n }",
" break;",
" case rfbVeNCrypt:\n if (!HandleVeNCryptAuth(client)) return FALSE;",
" switch (client->subAuthScheme) {",
" case rfbVeNCryptTLSNone:\n case rfbVeNCryptX509None:\n rfbClientLog(\"No sub authentication needed\\n\");\n if (!rfbHandleAuthResult(client)) return FALSE;\n break;",
" case rfbVeNCryptTLSVNC:\n case rfbVeNCryptX509VNC:\n if (!HandleVncAuth(client)) return FALSE;\n break;",
" case rfbVeNCryptTLSPlain:\n case rfbVeNCryptX509Plain:\n if (!HandlePlainAuth(client)) return FALSE;\n break;",
"#ifdef LIBVNCSERVER_HAVE_SASL\n case rfbVeNCryptX509SASL:\n case rfbVeNCryptTLSSASL:\n if (!HandleSASLAuth(client)) return FALSE;\n break;\n#endif /* LIBVNCSERVER_HAVE_SASL */",
" default:\n rfbClientLog(\"Unknown sub authentication scheme from VNC server: %d\\n\",\n client->subAuthScheme);\n return FALSE;\n }",
" break;",
" default:\n {\n rfbBool authHandled=FALSE;\n rfbClientProtocolExtension* e;\n for (e = rfbClientExtensions; e; e = e->next) {\n uint32_t const* secType;\n if (!e->handleAuthentication) continue;\n for (secType = e->securityTypes; secType && *secType; secType++) {\n if (authScheme==*secType) {\n if (!e->handleAuthentication(client, authScheme)) return FALSE;\n if (!rfbHandleAuthResult(client)) return FALSE;\n authHandled=TRUE;\n }\n }\n }\n if (authHandled) break;\n }\n rfbClientLog(\"Unknown authentication scheme from VNC server: %d\\n\",\n\t (int)authScheme);\n return FALSE;\n }",
" ci.shared = (client->appData.shareDesktop ? 1 : 0);",
" if (!WriteToRFBServer(client, (char *)&ci, sz_rfbClientInitMsg)) return FALSE;",
" if (!ReadFromRFBServer(client, (char *)&client->si, sz_rfbServerInitMsg)) return FALSE;",
" client->si.framebufferWidth = rfbClientSwap16IfLE(client->si.framebufferWidth);\n client->si.framebufferHeight = rfbClientSwap16IfLE(client->si.framebufferHeight);\n client->si.format.redMax = rfbClientSwap16IfLE(client->si.format.redMax);\n client->si.format.greenMax = rfbClientSwap16IfLE(client->si.format.greenMax);\n client->si.format.blueMax = rfbClientSwap16IfLE(client->si.format.blueMax);\n client->si.nameLength = rfbClientSwap32IfLE(client->si.nameLength);",
" if (client->si.nameLength > 1<<20) {\n rfbClientErr(\"Too big desktop name length sent by server: %u B > 1 MB\\n\", (unsigned int)client->si.nameLength);\n return FALSE;\n }",
" client->desktopName = malloc(client->si.nameLength + 1);\n if (!client->desktopName) {\n rfbClientLog(\"Error allocating memory for desktop name, %lu bytes\\n\",\n (unsigned long)client->si.nameLength);\n return FALSE;\n }",
" if (!ReadFromRFBServer(client, client->desktopName, client->si.nameLength)) return FALSE;",
" client->desktopName[client->si.nameLength] = 0;",
" rfbClientLog(\"Desktop name \\\"%s\\\"\\n\",client->desktopName);",
" rfbClientLog(\"Connected to VNC server, using protocol version %d.%d\\n\",\n\t client->major, client->minor);",
" rfbClientLog(\"VNC server default format:\\n\");\n PrintPixelFormat(&client->si.format);",
" return TRUE;\n}",
"\n/*\n * SetFormatAndEncodings.\n */",
"rfbBool\nSetFormatAndEncodings(rfbClient* client)\n{\n rfbSetPixelFormatMsg spf;\n char buf[sz_rfbSetEncodingsMsg + MAX_ENCODINGS * 4];",
" rfbSetEncodingsMsg *se = (rfbSetEncodingsMsg *)buf;\n uint32_t *encs = (uint32_t *)(&buf[sz_rfbSetEncodingsMsg]);\n int len = 0;\n rfbBool requestCompressLevel = FALSE;\n rfbBool requestQualityLevel = FALSE;\n rfbBool requestLastRectEncoding = FALSE;\n rfbClientProtocolExtension* e;",
" if (!SupportsClient2Server(client, rfbSetPixelFormat)) return TRUE;",
" spf.type = rfbSetPixelFormat;\n spf.pad1 = 0;\n spf.pad2 = 0;\n spf.format = client->format;\n spf.format.redMax = rfbClientSwap16IfLE(spf.format.redMax);\n spf.format.greenMax = rfbClientSwap16IfLE(spf.format.greenMax);\n spf.format.blueMax = rfbClientSwap16IfLE(spf.format.blueMax);",
" if (!WriteToRFBServer(client, (char *)&spf, sz_rfbSetPixelFormatMsg))\n return FALSE;",
"\n if (!SupportsClient2Server(client, rfbSetEncodings)) return TRUE;",
" se->type = rfbSetEncodings;\n se->pad = 0;\n se->nEncodings = 0;",
" if (client->appData.encodingsString) {\n const char *encStr = client->appData.encodingsString;\n int encStrLen;\n do {\n const char *nextEncStr = strchr(encStr, ' ');\n if (nextEncStr) {\n\tencStrLen = nextEncStr - encStr;\n\tnextEncStr++;\n } else {\n\tencStrLen = strlen(encStr);\n }",
" if (strncasecmp(encStr,\"raw\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRaw);\n } else if (strncasecmp(encStr,\"copyrect\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCopyRect);\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n#ifdef LIBVNCSERVER_HAVE_LIBJPEG\n } else if (strncasecmp(encStr,\"tight\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTight);\n\trequestLastRectEncoding = TRUE;\n\tif (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9)\n\t requestCompressLevel = TRUE;\n\tif (client->appData.enableJPEG)\n\t requestQualityLevel = TRUE;\n#endif\n#endif\n } else if (strncasecmp(encStr,\"hextile\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingHextile);\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n } else if (strncasecmp(encStr,\"zlib\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlib);\n\tif (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9)\n\t requestCompressLevel = TRUE;\n } else if (strncasecmp(encStr,\"zlibhex\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlibHex);\n\tif (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9)\n\t requestCompressLevel = TRUE;\n } else if (strncasecmp(encStr,\"trle\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTRLE);\n } else if (strncasecmp(encStr,\"zrle\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZRLE);\n } else if (strncasecmp(encStr,\"zywrle\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZYWRLE);\n\trequestQualityLevel = TRUE;\n#endif\n } else if ((strncasecmp(encStr,\"ultra\",encStrLen) == 0) || (strncasecmp(encStr,\"ultrazip\",encStrLen) == 0)) {\n /* There are 2 encodings used in 'ultra' */\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltra);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltraZip);\n } else if (strncasecmp(encStr,\"corre\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCoRRE);\n } else if (strncasecmp(encStr,\"rre\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRRE);\n } else {\n\trfbClientLog(\"Unknown encoding '%.*s'\\n\",encStrLen,encStr);\n }",
" encStr = nextEncStr;\n } while (encStr && se->nEncodings < MAX_ENCODINGS);",
" if (se->nEncodings < MAX_ENCODINGS && requestCompressLevel) {\n encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.compressLevel +\n\t\t\t\t\t rfbEncodingCompressLevel0);\n }",
" if (se->nEncodings < MAX_ENCODINGS && requestQualityLevel) {\n if (client->appData.qualityLevel < 0 || client->appData.qualityLevel > 9)\n client->appData.qualityLevel = 5;\n encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.qualityLevel +\n\t\t\t\t\t rfbEncodingQualityLevel0);\n }\n }\n else {\n if (SameMachine(client->sock)) {\n /* TODO:\n if (!tunnelSpecified) {\n */\n rfbClientLog(\"Same machine: preferring raw encoding\\n\");\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRaw);\n /*\n } else {\n\trfbClientLog(\"Tunneling active: preferring tight encoding\\n\");\n }\n */\n }",
" encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCopyRect);\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n#ifdef LIBVNCSERVER_HAVE_LIBJPEG\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTight);\n requestLastRectEncoding = TRUE;\n#endif\n#endif\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingHextile);\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlib);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZRLE);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZYWRLE);\n#endif\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltra);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltraZip);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCoRRE);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRRE);",
" if (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9) {\n encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.compressLevel +\n\t\t\t\t\t rfbEncodingCompressLevel0);\n } else /* if (!tunnelSpecified) */ {\n /* If -tunnel option was provided, we assume that server machine is\n\t not in the local network so we use default compression level for\n\t tight encoding instead of fast compression. Thus we are\n\t requesting level 1 compression only if tunneling is not used. */\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCompressLevel1);\n }",
" if (client->appData.enableJPEG) {\n if (client->appData.qualityLevel < 0 || client->appData.qualityLevel > 9)\n\tclient->appData.qualityLevel = 5;\n encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.qualityLevel +\n\t\t\t\t\t rfbEncodingQualityLevel0);\n }\n }",
"",
" /* Remote Cursor Support (local to viewer) */\n if (client->appData.useRemoteCursor) {\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingXCursor);\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRichCursor);\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingPointerPos);\n }",
" /* Keyboard State Encodings */\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingKeyboardLedState);",
" /* New Frame Buffer Size */\n if (se->nEncodings < MAX_ENCODINGS && client->canHandleNewFBSize)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingNewFBSize);",
" /* Last Rect */\n if (se->nEncodings < MAX_ENCODINGS && requestLastRectEncoding)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingLastRect);",
" /* Server Capabilities */\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingSupportedMessages);\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingSupportedEncodings);\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingServerIdentity);",
" /* xvp */\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingXvp);",
" /* client extensions */\n for(e = rfbClientExtensions; e; e = e->next)\n if(e->encodings) {\n int* enc;\n for(enc = e->encodings; *enc; enc++)\n if(se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(*enc);\n }",
" len = sz_rfbSetEncodingsMsg + se->nEncodings * 4;",
" se->nEncodings = rfbClientSwap16IfLE(se->nEncodings);",
" if (!WriteToRFBServer(client, buf, len)) return FALSE;",
" return TRUE;\n}",
"\n/*\n * SendIncrementalFramebufferUpdateRequest.\n */",
"rfbBool\nSendIncrementalFramebufferUpdateRequest(rfbClient* client)\n{\n\treturn SendFramebufferUpdateRequest(client,\n\t\t\tclient->updateRect.x, client->updateRect.y,\n\t\t\tclient->updateRect.w, client->updateRect.h, TRUE);\n}",
"\n/*\n * SendFramebufferUpdateRequest.\n */",
"rfbBool\nSendFramebufferUpdateRequest(rfbClient* client, int x, int y, int w, int h, rfbBool incremental)\n{\n rfbFramebufferUpdateRequestMsg fur;",
" if (!SupportsClient2Server(client, rfbFramebufferUpdateRequest)) return TRUE;\n \n fur.type = rfbFramebufferUpdateRequest;\n fur.incremental = incremental ? 1 : 0;\n fur.x = rfbClientSwap16IfLE(x);\n fur.y = rfbClientSwap16IfLE(y);\n fur.w = rfbClientSwap16IfLE(w);\n fur.h = rfbClientSwap16IfLE(h);",
" if (!WriteToRFBServer(client, (char *)&fur, sz_rfbFramebufferUpdateRequestMsg))\n return FALSE;",
" return TRUE;\n}",
"\n/*\n * SendScaleSetting.\n */\nrfbBool\nSendScaleSetting(rfbClient* client,int scaleSetting)\n{\n rfbSetScaleMsg ssm;",
" ssm.scale = scaleSetting;\n ssm.pad = 0;\n \n /* favor UltraVNC SetScale if both are supported */\n if (SupportsClient2Server(client, rfbSetScale)) {\n ssm.type = rfbSetScale;\n if (!WriteToRFBServer(client, (char *)&ssm, sz_rfbSetScaleMsg))\n return FALSE;\n }\n \n if (SupportsClient2Server(client, rfbPalmVNCSetScaleFactor)) {\n ssm.type = rfbPalmVNCSetScaleFactor;\n if (!WriteToRFBServer(client, (char *)&ssm, sz_rfbSetScaleMsg))\n return FALSE;\n }",
" return TRUE;\n}",
"/*\n * TextChatFunctions (UltraVNC)\n * Extremely bandwidth friendly method of communicating with a user\n * (Think HelpDesk type applications)\n */",
"rfbBool TextChatSend(rfbClient* client, char *text)\n{\n rfbTextChatMsg chat;\n int count = strlen(text);",
" if (!SupportsClient2Server(client, rfbTextChat)) return TRUE;\n chat.type = rfbTextChat;\n chat.pad1 = 0;\n chat.pad2 = 0;\n chat.length = (uint32_t)count;\n chat.length = rfbClientSwap32IfLE(chat.length);",
" if (!WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg))\n return FALSE;",
" if (count>0) {\n if (!WriteToRFBServer(client, text, count))\n return FALSE;\n }\n return TRUE;\n}",
"rfbBool TextChatOpen(rfbClient* client)\n{\n rfbTextChatMsg chat;",
" if (!SupportsClient2Server(client, rfbTextChat)) return TRUE;\n chat.type = rfbTextChat;\n chat.pad1 = 0;\n chat.pad2 = 0;\n chat.length = rfbClientSwap32IfLE(rfbTextChatOpen);\n return (WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg) ? TRUE : FALSE);\n}",
"rfbBool TextChatClose(rfbClient* client)\n{\n rfbTextChatMsg chat;\n if (!SupportsClient2Server(client, rfbTextChat)) return TRUE;\n chat.type = rfbTextChat;\n chat.pad1 = 0;\n chat.pad2 = 0;\n chat.length = rfbClientSwap32IfLE(rfbTextChatClose);\n return (WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg) ? TRUE : FALSE);\n}",
"rfbBool TextChatFinish(rfbClient* client)\n{\n rfbTextChatMsg chat;\n if (!SupportsClient2Server(client, rfbTextChat)) return TRUE;\n chat.type = rfbTextChat;\n chat.pad1 = 0;\n chat.pad2 = 0;\n chat.length = rfbClientSwap32IfLE(rfbTextChatFinished);\n return (WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg) ? TRUE : FALSE);\n}",
"/*\n * UltraVNC Server Input Disable\n * Apparently, the remote client can *prevent* the local user from interacting with the display\n * I would think this is extremely helpful when used in a HelpDesk situation\n */\nrfbBool PermitServerInput(rfbClient* client, int enabled)\n{\n rfbSetServerInputMsg msg;",
" if (!SupportsClient2Server(client, rfbSetServerInput)) return TRUE;\n /* enabled==1, then server input from local keyboard is disabled */\n msg.type = rfbSetServerInput;\n msg.status = (enabled ? 1 : 0);\n msg.pad = 0;\n return (WriteToRFBServer(client, (char *)&msg, sz_rfbSetServerInputMsg) ? TRUE : FALSE);\n}",
"\n/*\n * send xvp client message\n * A client supporting the xvp extension sends this to request that the server initiate\n * a clean shutdown, clean reboot or abrupt reset of the system whose framebuffer the\n * client is displaying.\n *\n * only version 1 is defined in the protocol specs\n *\n * possible values for code are:\n * rfbXvp_Shutdown\n * rfbXvp_Reboot\n * rfbXvp_Reset\n */",
"rfbBool SendXvpMsg(rfbClient* client, uint8_t version, uint8_t code)\n{\n rfbXvpMsg xvp;",
" if (!SupportsClient2Server(client, rfbXvp)) return TRUE;\n xvp.type = rfbXvp;\n xvp.pad = 0;\n xvp.version = version;\n xvp.code = code;",
" if (!WriteToRFBServer(client, (char *)&xvp, sz_rfbXvpMsg))\n return FALSE;",
" return TRUE;\n}",
"\n/*\n * SendPointerEvent.\n */",
"rfbBool\nSendPointerEvent(rfbClient* client,int x, int y, int buttonMask)\n{\n rfbPointerEventMsg pe;",
" if (!SupportsClient2Server(client, rfbPointerEvent)) return TRUE;",
" pe.type = rfbPointerEvent;\n pe.buttonMask = buttonMask;\n if (x < 0) x = 0;\n if (y < 0) y = 0;",
" pe.x = rfbClientSwap16IfLE(x);\n pe.y = rfbClientSwap16IfLE(y);\n return WriteToRFBServer(client, (char *)&pe, sz_rfbPointerEventMsg);\n}",
"\n/*\n * SendKeyEvent.\n */",
"rfbBool\nSendKeyEvent(rfbClient* client, uint32_t key, rfbBool down)\n{\n rfbKeyEventMsg ke;",
" if (!SupportsClient2Server(client, rfbKeyEvent)) return TRUE;",
" memset(&ke, 0, sizeof(ke));\n ke.type = rfbKeyEvent;\n ke.down = down ? 1 : 0;\n ke.key = rfbClientSwap32IfLE(key);\n return WriteToRFBServer(client, (char *)&ke, sz_rfbKeyEventMsg);\n}",
"\n/*\n * SendClientCutText.\n */",
"rfbBool\nSendClientCutText(rfbClient* client, char *str, int len)\n{\n rfbClientCutTextMsg cct;",
" if (!SupportsClient2Server(client, rfbClientCutText)) return TRUE;",
" memset(&cct, 0, sizeof(cct));\n cct.type = rfbClientCutText;\n cct.length = rfbClientSwap32IfLE(len);\n return (WriteToRFBServer(client, (char *)&cct, sz_rfbClientCutTextMsg) &&\n\t WriteToRFBServer(client, str, len));\n}",
"",
"/*\n * HandleRFBServerMessage.\n */",
"rfbBool\nHandleRFBServerMessage(rfbClient* client)\n{\n rfbServerToClientMsg msg;",
" if (client->serverPort==-1)\n client->vncRec->readTimestamp = TRUE;\n if (!ReadFromRFBServer(client, (char *)&msg, 1))\n return FALSE;",
" switch (msg.type) {",
" case rfbSetColourMapEntries:\n {\n /* TODO:\n int i;\n uint16_t rgb[3];\n XColor xc;",
" if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n\t\t\t sz_rfbSetColourMapEntriesMsg - 1))\n return FALSE;",
" msg.scme.firstColour = rfbClientSwap16IfLE(msg.scme.firstColour);\n msg.scme.nColours = rfbClientSwap16IfLE(msg.scme.nColours);",
" for (i = 0; i < msg.scme.nColours; i++) {\n if (!ReadFromRFBServer(client, (char *)rgb, 6))\n\treturn FALSE;\n xc.pixel = msg.scme.firstColour + i;\n xc.red = rfbClientSwap16IfLE(rgb[0]);\n xc.green = rfbClientSwap16IfLE(rgb[1]);\n xc.blue = rfbClientSwap16IfLE(rgb[2]);\n xc.flags = DoRed|DoGreen|DoBlue;\n XStoreColor(dpy, cmap, &xc);\n }\n */",
" break;\n }",
" case rfbFramebufferUpdate:\n {\n rfbFramebufferUpdateRectHeader rect;\n int linesToRead;\n int bytesPerLine;\n int i;",
" if (!ReadFromRFBServer(client, ((char *)&msg.fu) + 1,\n\t\t\t sz_rfbFramebufferUpdateMsg - 1))\n return FALSE;",
" msg.fu.nRects = rfbClientSwap16IfLE(msg.fu.nRects);",
" for (i = 0; i < msg.fu.nRects; i++) {\n if (!ReadFromRFBServer(client, (char *)&rect, sz_rfbFramebufferUpdateRectHeader))\n\treturn FALSE;",
" rect.encoding = rfbClientSwap32IfLE(rect.encoding);\n if (rect.encoding == rfbEncodingLastRect)\n\tbreak;",
" rect.r.x = rfbClientSwap16IfLE(rect.r.x);\n rect.r.y = rfbClientSwap16IfLE(rect.r.y);\n rect.r.w = rfbClientSwap16IfLE(rect.r.w);\n rect.r.h = rfbClientSwap16IfLE(rect.r.h);",
"\n if (rect.encoding == rfbEncodingXCursor ||\n\t rect.encoding == rfbEncodingRichCursor) {",
"\tif (!HandleCursorShape(client,\n\t\t\t rect.r.x, rect.r.y, rect.r.w, rect.r.h,\n\t\t\t rect.encoding)) {\n\t return FALSE;\n\t}\n\tcontinue;\n }",
" if (rect.encoding == rfbEncodingPointerPos) {\n\tif (!client->HandleCursorPos(client,rect.r.x, rect.r.y)) {\n\t return FALSE;\n\t}\n\tcontinue;\n }\n \n if (rect.encoding == rfbEncodingKeyboardLedState) {\n /* OK! We have received a keyboard state message!!! */\n client->KeyboardLedStateEnabled = 1;\n if (client->HandleKeyboardLedState!=NULL)\n client->HandleKeyboardLedState(client, rect.r.x, 0);\n /* stash it for the future */\n client->CurrentKeyboardLedState = rect.r.x;\n continue;\n }",
" if (rect.encoding == rfbEncodingNewFBSize) {\n\tclient->width = rect.r.w;\n\tclient->height = rect.r.h;\n\tclient->updateRect.x = client->updateRect.y = 0;\n\tclient->updateRect.w = client->width;\n\tclient->updateRect.h = client->height;\n\tif (!client->MallocFrameBuffer(client))\n\t return FALSE;\n\tSendFramebufferUpdateRequest(client, 0, 0, rect.r.w, rect.r.h, FALSE);\n\trfbClientLog(\"Got new framebuffer size: %dx%d\\n\", rect.r.w, rect.r.h);\n\tcontinue;\n }",
" /* rect.r.w=byte count */\n if (rect.encoding == rfbEncodingSupportedMessages) {\n int loop;\n if (!ReadFromRFBServer(client, (char *)&client->supportedMessages, sz_rfbSupportedMessages))\n return FALSE;",
" /* msgs is two sets of bit flags of supported messages client2server[] and server2client[] */\n /* currently ignored by this library */",
" rfbClientLog(\"client2server supported messages (bit flags)\\n\");\n for (loop=0;loop<32;loop+=8)\n rfbClientLog(\"%02X: %04x %04x %04x %04x - %04x %04x %04x %04x\\n\", loop,\n client->supportedMessages.client2server[loop], client->supportedMessages.client2server[loop+1],\n client->supportedMessages.client2server[loop+2], client->supportedMessages.client2server[loop+3],\n client->supportedMessages.client2server[loop+4], client->supportedMessages.client2server[loop+5],\n client->supportedMessages.client2server[loop+6], client->supportedMessages.client2server[loop+7]);",
" rfbClientLog(\"server2client supported messages (bit flags)\\n\");\n for (loop=0;loop<32;loop+=8)\n rfbClientLog(\"%02X: %04x %04x %04x %04x - %04x %04x %04x %04x\\n\", loop,\n client->supportedMessages.server2client[loop], client->supportedMessages.server2client[loop+1],\n client->supportedMessages.server2client[loop+2], client->supportedMessages.server2client[loop+3],\n client->supportedMessages.server2client[loop+4], client->supportedMessages.server2client[loop+5],\n client->supportedMessages.server2client[loop+6], client->supportedMessages.server2client[loop+7]);\n continue;\n }",
" /* rect.r.w=byte count, rect.r.h=# of encodings */\n if (rect.encoding == rfbEncodingSupportedEncodings) {\n char *buffer;\n buffer = malloc(rect.r.w);\n if (!ReadFromRFBServer(client, buffer, rect.r.w))\n {\n free(buffer);\n return FALSE;\n }",
" /* buffer now contains rect.r.h # of uint32_t encodings that the server supports */\n /* currently ignored by this library */\n free(buffer);\n continue;\n }",
" /* rect.r.w=byte count */\n if (rect.encoding == rfbEncodingServerIdentity) {\n char *buffer;\n buffer = malloc(rect.r.w+1);\n if (!ReadFromRFBServer(client, buffer, rect.r.w))\n {\n free(buffer);\n return FALSE;\n }\n buffer[rect.r.w]=0; /* null terminate, just in case */\n rfbClientLog(\"Connected to Server \\\"%s\\\"\\n\", buffer);\n free(buffer);\n continue;\n }",
" /* rfbEncodingUltraZip is a collection of subrects. x = # of subrects, and h is always 0 */\n if (rect.encoding != rfbEncodingUltraZip)\n {\n if ((rect.r.x + rect.r.w > client->width) ||\n\t (rect.r.y + rect.r.h > client->height))\n\t {\n\t rfbClientLog(\"Rect too large: %dx%d at (%d, %d)\\n\",\n\t \t rect.r.w, rect.r.h, rect.r.x, rect.r.y);\n\t return FALSE;\n }",
" /* UltraVNC with scaling, will send rectangles with a zero W or H\n *\n if ((rect.encoding != rfbEncodingTight) && \n (rect.r.h * rect.r.w == 0))\n {\n\t rfbClientLog(\"Zero size rect - ignoring (encoding=%d (0x%08x) %dx, %dy, %dw, %dh)\\n\", rect.encoding, rect.encoding, rect.r.x, rect.r.y, rect.r.w, rect.r.h);\n\t continue;\n }\n */\n \n /* If RichCursor encoding is used, we should prevent collisions\n\t between framebuffer updates and cursor drawing operations. */\n client->SoftCursorLockArea(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h);\n }",
" switch (rect.encoding) {",
" case rfbEncodingRaw: {\n\tint y=rect.r.y, h=rect.r.h;",
"\tbytesPerLine = rect.r.w * client->format.bitsPerPixel / 8;\n\t/* RealVNC 4.x-5.x on OSX can induce bytesPerLine==0, \n\t usually during GPU accel. */\n\t/* Regardless of cause, do not divide by zero. */\n\tlinesToRead = bytesPerLine ? (RFB_BUFFER_SIZE / bytesPerLine) : 0;",
"\twhile (linesToRead && h > 0) {\n\t if (linesToRead > h)\n\t linesToRead = h;",
"\t if (!ReadFromRFBServer(client, client->buffer,bytesPerLine * linesToRead))\n\t return FALSE;",
"\t client->GotBitmap(client, (uint8_t *)client->buffer,\n\t\t\t rect.r.x, y, rect.r.w,linesToRead);",
"\t h -= linesToRead;\n\t y += linesToRead;",
"\t}\n\tbreak;\n } ",
" case rfbEncodingCopyRect:\n {\n\trfbCopyRect cr;",
"\tif (!ReadFromRFBServer(client, (char *)&cr, sz_rfbCopyRect))\n\t return FALSE;",
"\tcr.srcX = rfbClientSwap16IfLE(cr.srcX);\n\tcr.srcY = rfbClientSwap16IfLE(cr.srcY);",
"\t/* If RichCursor encoding is used, we should extend our\n\t \"cursor lock area\" (previously set to destination\n\t rectangle) to the source rectangle as well. */\n\tclient->SoftCursorLockArea(client,\n\t\t\t\t cr.srcX, cr.srcY, rect.r.w, rect.r.h);",
" client->GotCopyRect(client, cr.srcX, cr.srcY, rect.r.w, rect.r.h,\n rect.r.x, rect.r.y);",
"\tbreak;\n }",
" case rfbEncodingRRE:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleRRE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (!HandleRRE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 32:\n\t if (!HandleRRE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\tbreak;\n }",
" case rfbEncodingCoRRE:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleCoRRE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (!HandleCoRRE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 32:\n\t if (!HandleCoRRE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\tbreak;\n }",
" case rfbEncodingHextile:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleHextile8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (!HandleHextile16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 32:\n\t if (!HandleHextile32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\tbreak;\n }",
" case rfbEncodingUltra:\n {\n switch (client->format.bitsPerPixel) {\n case 8:\n if (!HandleUltra8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n case 16:\n if (!HandleUltra16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n case 32:\n if (!HandleUltra32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n }\n break;\n }\n case rfbEncodingUltraZip:\n {\n switch (client->format.bitsPerPixel) {\n case 8:\n if (!HandleUltraZip8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n case 16:\n if (!HandleUltraZip16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n case 32:\n if (!HandleUltraZip32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n }\n break;\n }",
" case rfbEncodingTRLE:\n\t {\n switch (client->format.bitsPerPixel) {\n case 8:\n if (!HandleTRLE8(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n return FALSE;\n break;\n case 16:\n if (client->si.format.greenMax > 0x1F) {\n if (!HandleTRLE16(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n return FALSE;\n } else {\n if (!HandleTRLE15(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n return FALSE;\n }\n break;\n case 32: {\n uint32_t maxColor =\n (client->format.redMax << client->format.redShift) |\n (client->format.greenMax << client->format.greenShift) |\n (client->format.blueMax << client->format.blueShift);\n if ((client->format.bigEndian && (maxColor & 0xff) == 0) ||\n (!client->format.bigEndian && (maxColor & 0xff000000) == 0)) {\n if (!HandleTRLE24(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n return FALSE;\n } else if (!client->format.bigEndian && (maxColor & 0xff) == 0) {\n if (!HandleTRLE24Up(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n return FALSE;\n } else if (client->format.bigEndian && (maxColor & 0xff000000) == 0) {\n if (!HandleTRLE24Down(client, rect.r.x, rect.r.y, rect.r.w,\n rect.r.h))\n return FALSE;\n } else if (!HandleTRLE32(client, rect.r.x, rect.r.y, rect.r.w,\n rect.r.h))\n return FALSE;\n break;\n }\n }\n break;\n }",
"#ifdef LIBVNCSERVER_HAVE_LIBZ\n case rfbEncodingZlib:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleZlib8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (!HandleZlib16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 32:\n\t if (!HandleZlib32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\tbreak;\n }",
"#ifdef LIBVNCSERVER_HAVE_LIBJPEG\n case rfbEncodingTight:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleTight8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (!HandleTight16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 32:\n\t if (!HandleTight32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\tbreak;\n }\n#endif\n case rfbEncodingZRLE:\n\t/* Fail safe for ZYWRLE unsupport VNC server. */\n\tclient->appData.qualityLevel = 9;\n\t/* fall through */\n case rfbEncodingZYWRLE:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleZRLE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (client->si.format.greenMax > 0x1F) {\n\t if (!HandleZRLE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t } else {\n\t if (!HandleZRLE15(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t }\n\t break;\n\tcase 32:\n\t{\n\t uint32_t maxColor=(client->format.redMax<<client->format.redShift)|\n\t\t(client->format.greenMax<<client->format.greenShift)|\n\t\t(client->format.blueMax<<client->format.blueShift);\n\t if ((client->format.bigEndian && (maxColor&0xff)==0) ||\n\t (!client->format.bigEndian && (maxColor&0xff000000)==0)) {\n\t if (!HandleZRLE24(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t } else if (!client->format.bigEndian && (maxColor&0xff)==0) {\n\t if (!HandleZRLE24Up(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t } else if (client->format.bigEndian && (maxColor&0xff000000)==0) {\n\t if (!HandleZRLE24Down(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t } else if (!HandleZRLE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\t}\n\tbreak;\n }",
"#endif",
" default:\n\t {\n\t rfbBool handled = FALSE;\n\t rfbClientProtocolExtension* e;",
"\t for(e = rfbClientExtensions; !handled && e; e = e->next)\n\t if(e->handleEncoding && e->handleEncoding(client, &rect))\n\t handled = TRUE;",
"\t if(!handled) {\n\t rfbClientLog(\"Unknown rect encoding %d\\n\",\n\t\t (int)rect.encoding);\n\t return FALSE;\n\t }\n\t }\n }",
" /* Now we may discard \"soft cursor locks\". */\n client->SoftCursorUnlockScreen(client);",
" client->GotFrameBufferUpdate(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h);\n }",
" if (!SendIncrementalFramebufferUpdateRequest(client))\n return FALSE;",
" if (client->FinishedFrameBufferUpdate)\n client->FinishedFrameBufferUpdate(client);",
" break;\n }",
" case rfbBell:\n {\n client->Bell(client);",
" break;\n }",
" case rfbServerCutText:\n {\n char *buffer;",
" if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n\t\t\t sz_rfbServerCutTextMsg - 1))\n return FALSE;",
" msg.sct.length = rfbClientSwap32IfLE(msg.sct.length);",
" if (msg.sct.length > 1<<20) {\n\t rfbClientErr(\"Ignoring too big cut text length sent by server: %u B > 1 MB\\n\", (unsigned int)msg.sct.length);\n\t return FALSE;\n } ",
" buffer = malloc(msg.sct.length+1);",
" if (!ReadFromRFBServer(client, buffer, msg.sct.length)) {\n free(buffer);\n return FALSE;\n }",
" buffer[msg.sct.length] = 0;",
" if (client->GotXCutText)\n client->GotXCutText(client, buffer, msg.sct.length);",
" free(buffer);",
" break;\n }",
" case rfbTextChat:\n {\n char *buffer=NULL;\n if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n sz_rfbTextChatMsg- 1))\n return FALSE;\n msg.tc.length = rfbClientSwap32IfLE(msg.sct.length);\n switch(msg.tc.length) {\n case rfbTextChatOpen:\n rfbClientLog(\"Received TextChat Open\\n\");\n if (client->HandleTextChat!=NULL)\n client->HandleTextChat(client, (int)rfbTextChatOpen, NULL);\n break;\n case rfbTextChatClose:\n rfbClientLog(\"Received TextChat Close\\n\");\n if (client->HandleTextChat!=NULL)\n client->HandleTextChat(client, (int)rfbTextChatClose, NULL);\n break;\n case rfbTextChatFinished:\n rfbClientLog(\"Received TextChat Finished\\n\");\n if (client->HandleTextChat!=NULL)\n client->HandleTextChat(client, (int)rfbTextChatFinished, NULL);\n break;\n default:",
"",
" buffer=malloc(msg.tc.length+1);\n if (!ReadFromRFBServer(client, buffer, msg.tc.length))\n {\n free(buffer);\n return FALSE;\n }\n /* Null Terminate <just in case> */\n buffer[msg.tc.length]=0;\n rfbClientLog(\"Received TextChat \\\"%s\\\"\\n\", buffer);\n if (client->HandleTextChat!=NULL)\n client->HandleTextChat(client, (int)msg.tc.length, buffer);\n free(buffer);\n break;\n }\n break;\n }",
" case rfbXvp:\n {\n if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n sz_rfbXvpMsg -1))\n return FALSE;",
" SetClient2Server(client, rfbXvp);\n /* technically, we only care what we can *send* to the server\n * but, we set Server2Client Just in case it ever becomes useful\n */\n SetServer2Client(client, rfbXvp);",
" if(client->HandleXvpMsg)\n client->HandleXvpMsg(client, msg.xvp.version, msg.xvp.code);",
" break;\n }",
" case rfbResizeFrameBuffer:\n {\n if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n sz_rfbResizeFrameBufferMsg -1))\n return FALSE;\n client->width = rfbClientSwap16IfLE(msg.rsfb.framebufferWidth);\n client->height = rfbClientSwap16IfLE(msg.rsfb.framebufferHeigth);\n client->updateRect.x = client->updateRect.y = 0;\n client->updateRect.w = client->width;\n client->updateRect.h = client->height;\n if (!client->MallocFrameBuffer(client))\n return FALSE;",
" SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE);\n rfbClientLog(\"Got new framebuffer size: %dx%d\\n\", client->width, client->height);\n break;\n }",
" case rfbPalmVNCReSizeFrameBuffer:\n {\n if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n sz_rfbPalmVNCReSizeFrameBufferMsg -1))\n return FALSE;\n client->width = rfbClientSwap16IfLE(msg.prsfb.buffer_w);\n client->height = rfbClientSwap16IfLE(msg.prsfb.buffer_h);\n client->updateRect.x = client->updateRect.y = 0;\n client->updateRect.w = client->width;\n client->updateRect.h = client->height;\n if (!client->MallocFrameBuffer(client))\n return FALSE;\n SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE);\n rfbClientLog(\"Got new framebuffer size: %dx%d\\n\", client->width, client->height);\n break;\n }",
" default:\n {\n rfbBool handled = FALSE;\n rfbClientProtocolExtension* e;",
" for(e = rfbClientExtensions; !handled && e; e = e->next)\n\tif(e->handleMessage && e->handleMessage(client, &msg))\n\t handled = TRUE;",
" if(!handled) {\n\tchar buffer[256];\n\trfbClientLog(\"Unknown message type %d from VNC server\\n\",msg.type);\n\tReadFromRFBServer(client, buffer, 256);\n\treturn FALSE;\n }\n }\n }",
" return TRUE;\n}",
"\n#define GET_PIXEL8(pix, ptr) ((pix) = *(ptr)++)",
"#define GET_PIXEL16(pix, ptr) (((uint8_t*)&(pix))[0] = *(ptr)++, \\\n\t\t\t ((uint8_t*)&(pix))[1] = *(ptr)++)",
"#define GET_PIXEL32(pix, ptr) (((uint8_t*)&(pix))[0] = *(ptr)++, \\\n\t\t\t ((uint8_t*)&(pix))[1] = *(ptr)++, \\\n\t\t\t ((uint8_t*)&(pix))[2] = *(ptr)++, \\\n\t\t\t ((uint8_t*)&(pix))[3] = *(ptr)++)",
"/* CONCAT2 concatenates its two arguments. CONCAT2E does the same but also\n expands its arguments if they are macros */",
"#define CONCAT2(a,b) a##b\n#define CONCAT2E(a,b) CONCAT2(a,b)\n#define CONCAT3(a,b,c) a##b##c\n#define CONCAT3E(a,b,c) CONCAT3(a,b,c)",
"#define BPP 8\n#include \"rre.c\"\n#include \"corre.c\"\n#include \"hextile.c\"\n#include \"ultra.c\"\n#include \"zlib.c\"\n#include \"tight.c\"\n#include \"trle.c\"\n#include \"zrle.c\"\n#undef BPP\n#define BPP 16\n#include \"rre.c\"\n#include \"corre.c\"\n#include \"hextile.c\"\n#include \"ultra.c\"\n#include \"zlib.c\"\n#include \"tight.c\"\n#include \"trle.c\"\n#include \"zrle.c\"\n#define REALBPP 15\n#include \"trle.c\"\n#define REALBPP 15\n#include \"zrle.c\"\n#undef BPP\n#define BPP 32\n#include \"rre.c\"\n#include \"corre.c\"\n#include \"hextile.c\"\n#include \"ultra.c\"\n#include \"zlib.c\"\n#include \"tight.c\"\n#include \"trle.c\"\n#include \"zrle.c\"\n#define REALBPP 24\n#include \"trle.c\"\n#define REALBPP 24\n#include \"zrle.c\"\n#define REALBPP 24\n#define UNCOMP 8\n#include \"trle.c\"\n#define REALBPP 24\n#define UNCOMP 8\n#include \"zrle.c\"\n#define REALBPP 24\n#define UNCOMP -8\n#include \"trle.c\"\n#define REALBPP 24\n#define UNCOMP -8\n#include \"zrle.c\"\n#undef BPP",
"\n/*\n * PrintPixelFormat.\n */",
"void\nPrintPixelFormat(rfbPixelFormat *format)\n{\n if (format->bitsPerPixel == 1) {\n rfbClientLog(\" Single bit per pixel.\\n\");\n rfbClientLog(\n\t \" %s significant bit in each byte is leftmost on the screen.\\n\",\n\t (format->bigEndian ? \"Most\" : \"Least\"));\n } else {\n rfbClientLog(\" %d bits per pixel.\\n\",format->bitsPerPixel);\n if (format->bitsPerPixel != 8) {\n rfbClientLog(\" %s significant byte first in each pixel.\\n\",\n\t (format->bigEndian ? \"Most\" : \"Least\"));\n }\n if (format->trueColour) {\n rfbClientLog(\" TRUE colour: max red %d green %d blue %d\"\n\t\t \", shift red %d green %d blue %d\\n\",\n\t\t format->redMax, format->greenMax, format->blueMax,\n\t\t format->redShift, format->greenShift, format->blueShift);\n } else {\n rfbClientLog(\" Colour map (not true colour).\\n\");\n }\n }\n}",
"/* avoid name clashes with LibVNCServer */",
"#define rfbEncryptBytes rfbClientEncryptBytes\n#define rfbEncryptBytes2 rfbClientEncryptBytes2\n#define rfbDes rfbClientDes\n#define rfbDesKey rfbClientDesKey\n#define rfbUseKey rfbClientUseKey",
"#include \"vncauth.c\""
] |
[
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [2161], "buggy_code_start_loc": [67], "filenames": ["libvncclient/rfbproto.c"], "fixing_code_end_loc": [2165], "fixing_code_start_loc": [68], "message": "An issue was discovered in LibVNCServer before 0.9.13. libvncclient/rfbproto.c does not limit TextChat size.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:libvnc_project:libvncserver:*:*:*:*:*:*:*:*", "matchCriteriaId": "DEF1BF44-78B8-44E3-9A5A-29AB8111322B", "versionEndExcluding": "0.9.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:canonical:ubuntu_linux:14.04:*:*:*:lts:*:*:*", "matchCriteriaId": "B5A6F2F3-4894-4392-8296-3B8DD2679084", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:esm:*:*:*", "matchCriteriaId": "7A5301BF-1402-4BE0-A0F8-69FBE79BC6D6", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*", "matchCriteriaId": "F7016A2A-8365-4F1A-89A2-7A19F2BCAE5B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*", "matchCriteriaId": "23A7C53F-B80F-4E6A-AFA9-58EEA84BE11D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:18.10:*:*:*:*:*:*:*", "matchCriteriaId": "07C312A0-CD2C-4B9C-B064-6409B25C278F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:debian:debian_linux:8.0:*:*:*:*:*:*:*", "matchCriteriaId": "C11E6FB0-C8C0-4527-9AA0-CB9B316F8F43", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*", "matchCriteriaId": "DEECE5FC-CACF-4496-A3E7-164736409252", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc1500_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "3A664216-EEA0-423F-8E11-59C746FDEEFE", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc1500:-:*:*:*:*:*:*:*", "matchCriteriaId": "9596C8CD-B03F-4E9D-82AB-0986FDD1B47C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc1500_pro_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "CD78291E-48D8-4718-AE14-BDF93BD557D7", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc1500_pro:-:*:*:*:*:*:*:*", "matchCriteriaId": "5BB898D3-07A3-42A1-8F1B-53C3B005982D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc1900_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "AD1209DE-2724-493D-8276-1BE959BFE6BF", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc1900:-:*:*:*:*:*:*:*", "matchCriteriaId": "6A9143A6-A93A-45CA-8A1F-6EE30647B54A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc1900_pro_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "92F7FC17-F19F-4BD6-9704-49B67D22B532", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc1900_pro:-:*:*:*:*:*:*:*", "matchCriteriaId": "3D34BD13-4E71-48A2-851D-AE7CE2A03C28", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc2200_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "FE4A6F13-385B-4A13-B8D8-3BBC4E9D5B67", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc2200:-:*:*:*:*:*:*:*", "matchCriteriaId": "3E63E423-7450-4043-B33B-3FFF5BBE1CB2", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc2200_pro_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "71A51CA4-1A62-47BC-99A3-4DC9F3986FF5", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc2200_pro:-:*:*:*:*:*:*:*", "matchCriteriaId": "CD278558-AB0E-4FC1-9E5B-6B57D29CB86A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}], "descriptions": [{"lang": "en", "value": "An issue was discovered in LibVNCServer before 0.9.13. libvncclient/rfbproto.c does not limit TextChat size."}, {"lang": "es", "value": "Se detect\u00f3 un problema en LibVNCServer versiones anteriores a 0.9.13. La biblioteca libvncclient/rfbproto.c no limita el tama\u00f1o de TextChat"}], "evaluatorComment": null, "id": "CVE-2020-14405", "lastModified": "2022-03-09T22:18:37.957", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "PARTIAL", "baseScore": 4.0, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:N/AC:L/Au:S/C:N/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2020-06-17T16:15:12.337", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-390195.pdf"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/LibVNC/libvncserver/commit/8937203441ee241c4ace85da687b7d6633a12365"}, {"source": "cve@mitre.org", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/LibVNC/libvncserver/compare/LibVNCServer-0.9.12...LibVNCServer-0.9.13"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2020/06/msg00035.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2020/08/msg00045.html"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://usn.ubuntu.com/4434-1/"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-770"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/LibVNC/libvncserver/commit/8937203441ee241c4ace85da687b7d6633a12365"}, "type": "CWE-770"}
| 361
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Copyright (C) 2000-2002 Constantin Kaplinsky. All Rights Reserved.\n * Copyright (C) 2000 Tridia Corporation. All Rights Reserved.\n * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.\n *\n * This is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this software; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\n * USA.\n */",
"/*\n * rfbproto.c - functions to deal with client side of RFB protocol.\n */",
"#ifdef __STRICT_ANSI__\n#define _BSD_SOURCE\n#define _POSIX_SOURCE\n#define _XOPEN_SOURCE 600\n#endif\n#ifndef WIN32\n#include <unistd.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <pwd.h>\n#endif\n#include <errno.h>\n#include <rfb/rfbclient.h>\n#ifdef WIN32\n#undef socklen_t\n#endif\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n#include <zlib.h>\n#ifdef __CHECKER__\n#undef Z_NULL\n#define Z_NULL NULL\n#endif\n#endif",
"#ifndef _MSC_VER\n/* Strings.h is not available in MSVC */\n#include <strings.h>\n#endif",
"#include <stdarg.h>\n#include <time.h>",
"#include \"crypto.h\"",
"#include \"sasl.h\"\n#ifdef LIBVNCSERVER_HAVE_LZO\n#include <lzo/lzo1x.h>\n#else\n#include \"minilzo.h\"\n#endif\n#include \"tls.h\"\n",
"#define MAX_TEXTCHAT_SIZE 10485760 /* 10MB */",
"\n/*\n * rfbClientLog prints a time-stamped message to the log file (stderr).\n */",
"rfbBool rfbEnableClientLogging=TRUE;",
"static void\nrfbDefaultClientLog(const char *format, ...)\n{\n va_list args;\n char buf[256];\n time_t log_clock;",
" if(!rfbEnableClientLogging)\n return;",
" va_start(args, format);",
" time(&log_clock);\n strftime(buf, 255, \"%d/%m/%Y %X \", localtime(&log_clock));\n fprintf(stderr, \"%s\", buf);",
" vfprintf(stderr, format, args);\n fflush(stderr);",
" va_end(args);\n}",
"rfbClientLogProc rfbClientLog=rfbDefaultClientLog;\nrfbClientLogProc rfbClientErr=rfbDefaultClientLog;",
"/* extensions */",
"rfbClientProtocolExtension* rfbClientExtensions = NULL;",
"void rfbClientRegisterExtension(rfbClientProtocolExtension* e)\n{\n\te->next = rfbClientExtensions;\n\trfbClientExtensions = e;\n}",
"/* client data */",
"void rfbClientSetClientData(rfbClient* client, void* tag, void* data)\n{\n\trfbClientData* clientData = client->clientData;",
"\twhile(clientData && clientData->tag != tag)\n\t\tclientData = clientData->next;\n\tif(clientData == NULL) {\n\t\tclientData = calloc(sizeof(rfbClientData), 1);\n\t\tclientData->next = client->clientData;\n\t\tclient->clientData = clientData;\n\t\tclientData->tag = tag;\n\t}",
"\tclientData->data = data;\n}",
"void* rfbClientGetClientData(rfbClient* client, void* tag)\n{\n\trfbClientData* clientData = client->clientData;",
"\twhile(clientData) {\n\t\tif(clientData->tag == tag)\n\t\t\treturn clientData->data;\n\t\tclientData = clientData->next;\n\t}",
"\treturn NULL;\n}",
"static rfbBool HandleRRE8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleRRE16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleRRE32(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleCoRRE8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleCoRRE16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleCoRRE32(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleHextile8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleHextile16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleHextile32(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltra8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltra16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltra32(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltraZip8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltraZip16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleUltraZip32(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE15(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE24(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE24Up(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE24Down(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTRLE32(rfbClient* client, int rx, int ry, int rw, int rh);\n#ifdef LIBVNCSERVER_HAVE_LIBZ\nstatic rfbBool HandleZlib8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZlib16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZlib32(rfbClient* client, int rx, int ry, int rw, int rh);\n#ifdef LIBVNCSERVER_HAVE_LIBJPEG\nstatic rfbBool HandleTight8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTight16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleTight32(rfbClient* client, int rx, int ry, int rw, int rh);",
"static long ReadCompactLen (rfbClient* client);\n#endif\nstatic rfbBool HandleZRLE8(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE15(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE16(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE24(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE24Up(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE24Down(rfbClient* client, int rx, int ry, int rw, int rh);\nstatic rfbBool HandleZRLE32(rfbClient* client, int rx, int ry, int rw, int rh);\n#endif",
"/*\n * Server Capability Functions\n */\nrfbBool\nSupportsClient2Server(rfbClient* client, int messageType)\n{\n return (client->supportedMessages.client2server[((messageType & 0xFF)/8)] & (1<<(messageType % 8)) ? TRUE : FALSE);\n}",
"rfbBool\nSupportsServer2Client(rfbClient* client, int messageType)\n{\n return (client->supportedMessages.server2client[((messageType & 0xFF)/8)] & (1<<(messageType % 8)) ? TRUE : FALSE);\n}",
"void\nSetClient2Server(rfbClient* client, int messageType)\n{\n client->supportedMessages.client2server[((messageType & 0xFF)/8)] |= (1<<(messageType % 8));\n}",
"void\nSetServer2Client(rfbClient* client, int messageType)\n{\n client->supportedMessages.server2client[((messageType & 0xFF)/8)] |= (1<<(messageType % 8));\n}",
"void\nClearClient2Server(rfbClient* client, int messageType)\n{\n client->supportedMessages.client2server[((messageType & 0xFF)/8)] &= ~(1<<(messageType % 8));\n}",
"void\nClearServer2Client(rfbClient* client, int messageType)\n{\n client->supportedMessages.server2client[((messageType & 0xFF)/8)] &= ~(1<<(messageType % 8));\n}",
"\nvoid\nDefaultSupportedMessages(rfbClient* client)\n{\n memset((char *)&client->supportedMessages,0,sizeof(client->supportedMessages));",
" /* Default client supported messages (universal RFB 3.3 protocol) */\n SetClient2Server(client, rfbSetPixelFormat);\n /* SetClient2Server(client, rfbFixColourMapEntries); Not currently supported */\n SetClient2Server(client, rfbSetEncodings);\n SetClient2Server(client, rfbFramebufferUpdateRequest);\n SetClient2Server(client, rfbKeyEvent);\n SetClient2Server(client, rfbPointerEvent);\n SetClient2Server(client, rfbClientCutText);\n /* technically, we only care what we can *send* to the server\n * but, we set Server2Client Just in case it ever becomes useful\n */\n SetServer2Client(client, rfbFramebufferUpdate);\n SetServer2Client(client, rfbSetColourMapEntries);\n SetServer2Client(client, rfbBell);\n SetServer2Client(client, rfbServerCutText);\n}",
"void\nDefaultSupportedMessagesUltraVNC(rfbClient* client)\n{\n DefaultSupportedMessages(client);\n SetClient2Server(client, rfbFileTransfer);\n SetClient2Server(client, rfbSetScale);\n SetClient2Server(client, rfbSetServerInput);\n SetClient2Server(client, rfbSetSW);\n SetClient2Server(client, rfbTextChat);\n SetClient2Server(client, rfbPalmVNCSetScaleFactor);\n /* technically, we only care what we can *send* to the server */\n SetServer2Client(client, rfbResizeFrameBuffer);\n SetServer2Client(client, rfbPalmVNCReSizeFrameBuffer);\n SetServer2Client(client, rfbFileTransfer);\n SetServer2Client(client, rfbTextChat);\n}",
"\nvoid\nDefaultSupportedMessagesTightVNC(rfbClient* client)\n{\n DefaultSupportedMessages(client);\n SetClient2Server(client, rfbFileTransfer);\n SetClient2Server(client, rfbSetServerInput);\n SetClient2Server(client, rfbSetSW);\n /* SetClient2Server(client, rfbTextChat); */\n /* technically, we only care what we can *send* to the server */\n SetServer2Client(client, rfbFileTransfer);\n SetServer2Client(client, rfbTextChat);\n}",
"#ifndef WIN32\nstatic rfbBool\nIsUnixSocket(const char *name)\n{\n struct stat sb;\n if(stat(name, &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFSOCK)\n return TRUE;\n return FALSE;\n}\n#endif",
"/*\n * ConnectToRFBServer.\n */",
"rfbBool\nConnectToRFBServer(rfbClient* client,const char *hostname, int port)\n{\n if (client->serverPort==-1) {\n /* serverHost is a file recorded by vncrec. */\n const char* magic=\"vncLog0.0\";\n char buffer[10];\n rfbVNCRec* rec = (rfbVNCRec*)malloc(sizeof(rfbVNCRec));\n client->vncRec = rec;",
" rec->file = fopen(client->serverHost,\"rb\");\n rec->tv.tv_sec = 0;\n rec->readTimestamp = FALSE;\n rec->doNotSleep = FALSE;\n \n if (!rec->file) {\n rfbClientLog(\"Could not open %s.\\n\",client->serverHost);\n return FALSE;\n }\n setbuf(rec->file,NULL);",
" if (fread(buffer,1,strlen(magic),rec->file) != strlen(magic) || strncmp(buffer,magic,strlen(magic))) {\n rfbClientLog(\"File %s was not recorded by vncrec.\\n\",client->serverHost);\n fclose(rec->file);\n return FALSE;\n }\n client->sock = RFB_INVALID_SOCKET;\n return TRUE;\n }",
"#ifndef WIN32\n if(IsUnixSocket(hostname))\n /* serverHost is a UNIX socket. */\n client->sock = ConnectClientToUnixSockWithTimeout(hostname, client->connectTimeout);\n else\n#endif\n {\n#ifdef LIBVNCSERVER_IPv6\n client->sock = ConnectClientToTcpAddr6WithTimeout(hostname, port, client->connectTimeout);\n#else\n unsigned int host;",
" /* serverHost is a hostname */\n if (!StringToIPAddr(hostname, &host)) {\n rfbClientLog(\"Couldn't convert '%s' to host address\\n\", hostname);\n return FALSE;\n }\n client->sock = ConnectClientToTcpAddrWithTimeout(host, port, client->connectTimeout);\n#endif\n }",
" if (client->sock == RFB_INVALID_SOCKET) {\n rfbClientLog(\"Unable to connect to VNC server\\n\");\n return FALSE;\n }",
" if(client->QoS_DSCP && !SetDSCP(client->sock, client->QoS_DSCP))\n return FALSE;",
" return TRUE;\n}",
"/*\n * ConnectToRFBRepeater.\n */",
"rfbBool ConnectToRFBRepeater(rfbClient* client,const char *repeaterHost, int repeaterPort, const char *destHost, int destPort)\n{\n rfbProtocolVersionMsg pv;\n int major,minor;\n char tmphost[250];",
"#ifdef LIBVNCSERVER_IPv6\n client->sock = ConnectClientToTcpAddr6WithTimeout(repeaterHost, repeaterPort, client->connectTimeout);\n#else\n unsigned int host;\n if (!StringToIPAddr(repeaterHost, &host)) {\n rfbClientLog(\"Couldn't convert '%s' to host address\\n\", repeaterHost);\n return FALSE;\n }",
" client->sock = ConnectClientToTcpAddrWithTimeout(host, repeaterPort, client->connectTimeout);\n#endif",
" if (client->sock == RFB_INVALID_SOCKET) {\n rfbClientLog(\"Unable to connect to VNC repeater\\n\");\n return FALSE;\n }",
" if (!ReadFromRFBServer(client, pv, sz_rfbProtocolVersionMsg))\n return FALSE;\n pv[sz_rfbProtocolVersionMsg] = 0;",
" /* UltraVNC repeater always report version 000.000 to identify itself */\n if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2 || major != 0 || minor != 0) {\n rfbClientLog(\"Not a valid VNC repeater (%s)\\n\",pv);\n return FALSE;\n }",
" rfbClientLog(\"Connected to VNC repeater, using protocol version %d.%d\\n\", major, minor);",
" memset(tmphost, 0, sizeof(tmphost));\n if(snprintf(tmphost, sizeof(tmphost), \"%s:%d\", destHost, destPort) >= (int)sizeof(tmphost))\n return FALSE; /* output truncated */\n if (!WriteToRFBServer(client, tmphost, sizeof(tmphost)))\n return FALSE;",
" return TRUE;\n}",
"extern void rfbClientEncryptBytes(unsigned char* bytes, char* passwd);\nextern void rfbClientEncryptBytes2(unsigned char *where, const int length, unsigned char *key);",
"static void\nReadReason(rfbClient* client)\n{\n uint32_t reasonLen;\n char *reason;",
" if (!ReadFromRFBServer(client, (char *)&reasonLen, 4)) return;\n reasonLen = rfbClientSwap32IfLE(reasonLen);\n if(reasonLen > 1<<20) {\n rfbClientLog(\"VNC connection failed, but sent reason length of %u exceeds limit of 1MB\",(unsigned int)reasonLen);\n return;\n }\n reason = malloc(reasonLen+1);\n if (!ReadFromRFBServer(client, reason, reasonLen)) { free(reason); return; }\n reason[reasonLen]=0;\n rfbClientLog(\"VNC connection failed: %s\\n\",reason);\n free(reason);\n}",
"rfbBool\nrfbHandleAuthResult(rfbClient* client)\n{\n uint32_t authResult=0;",
" if (!ReadFromRFBServer(client, (char *)&authResult, 4)) return FALSE;",
" authResult = rfbClientSwap32IfLE(authResult);",
" switch (authResult) {\n case rfbVncAuthOK:\n rfbClientLog(\"VNC authentication succeeded\\n\");\n return TRUE;\n break;\n case rfbVncAuthFailed:\n if (client->major==3 && client->minor>7)\n {\n /* we have an error following */\n ReadReason(client);\n return FALSE;\n }\n rfbClientLog(\"VNC authentication failed\\n\");\n return FALSE;\n case rfbVncAuthTooMany:\n rfbClientLog(\"VNC authentication failed - too many tries\\n\");\n return FALSE;\n }",
" rfbClientLog(\"Unknown VNC authentication result: %d\\n\",\n (int)authResult);\n return FALSE;\n}",
"\nstatic rfbBool\nReadSupportedSecurityType(rfbClient* client, uint32_t *result, rfbBool subAuth)\n{\n uint8_t count=0;\n uint8_t loop=0;\n uint8_t flag=0;\n rfbBool extAuthHandler;\n uint8_t tAuth[256];\n char buf1[500],buf2[10];\n uint32_t authScheme;\n rfbClientProtocolExtension* e;",
" if (!ReadFromRFBServer(client, (char *)&count, 1)) return FALSE;",
" if (count==0)\n {\n rfbClientLog(\"List of security types is ZERO, expecting an error to follow\\n\");\n ReadReason(client);\n return FALSE;\n }",
" rfbClientLog(\"We have %d security types to read\\n\", count);\n authScheme=0;\n /* now, we have a list of available security types to read ( uint8_t[] ) */\n for (loop=0;loop<count;loop++)\n {\n if (!ReadFromRFBServer(client, (char *)&tAuth[loop], 1)) return FALSE;\n rfbClientLog(\"%d) Received security type %d\\n\", loop, tAuth[loop]);\n if (flag) continue;\n extAuthHandler=FALSE;\n for (e = rfbClientExtensions; e; e = e->next) {\n if (!e->handleAuthentication) continue;\n uint32_t const* secType;\n for (secType = e->securityTypes; secType && *secType; secType++) {\n if (tAuth[loop]==*secType) {\n extAuthHandler=TRUE;\n }\n }\n }\n if (tAuth[loop]==rfbVncAuth || tAuth[loop]==rfbNoAuth ||\n\t\t\textAuthHandler ||\n#if defined(LIBVNCSERVER_HAVE_GNUTLS) || defined(LIBVNCSERVER_HAVE_LIBSSL)\n tAuth[loop]==rfbVeNCrypt ||\n#endif\n#ifdef LIBVNCSERVER_HAVE_SASL\n tAuth[loop]==rfbSASL ||\n#endif /* LIBVNCSERVER_HAVE_SASL */\n (tAuth[loop]==rfbARD && client->GetCredential) ||\n (!subAuth && (tAuth[loop]==rfbTLS || (tAuth[loop]==rfbVeNCrypt && client->GetCredential))))\n {\n if (!subAuth && client->clientAuthSchemes)\n {\n int i;\n for (i=0;client->clientAuthSchemes[i];i++)\n {\n if (client->clientAuthSchemes[i]==(uint32_t)tAuth[loop])\n {\n flag++;\n authScheme=tAuth[loop];\n break;\n }\n }\n }\n else\n {\n flag++;\n authScheme=tAuth[loop];\n }\n if (flag)\n {\n rfbClientLog(\"Selecting security type %d (%d/%d in the list)\\n\", authScheme, loop, count);\n /* send back a single byte indicating which security type to use */\n if (!WriteToRFBServer(client, (char *)&tAuth[loop], 1)) return FALSE;\n }\n }\n }\n if (authScheme==0)\n {\n memset(buf1, 0, sizeof(buf1));\n for (loop=0;loop<count;loop++)\n {\n if (strlen(buf1)>=sizeof(buf1)-1) break;\n snprintf(buf2, sizeof(buf2), (loop>0 ? \", %d\" : \"%d\"), (int)tAuth[loop]);\n strncat(buf1, buf2, sizeof(buf1)-strlen(buf1)-1);\n }\n rfbClientLog(\"Unknown authentication scheme from VNC server: %s\\n\",\n buf1);\n return FALSE;\n }\n *result = authScheme;\n return TRUE;\n}",
"static rfbBool\nHandleVncAuth(rfbClient *client)\n{\n uint8_t challenge[CHALLENGESIZE];\n char *passwd=NULL;\n int i;",
" if (!ReadFromRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE;",
" if (client->serverPort!=-1) { /* if not playing a vncrec file */\n if (client->GetPassword)\n passwd = client->GetPassword(client);",
" if ((!passwd) || (strlen(passwd) == 0)) {\n rfbClientLog(\"Reading password failed\\n\");\n return FALSE;\n }\n if (strlen(passwd) > 8) {\n passwd[8] = '\\0';\n }",
" rfbClientEncryptBytes(challenge, passwd);",
" /* Lose the password from memory */\n for (i = strlen(passwd); i >= 0; i--) {\n passwd[i] = '\\0';\n }\n free(passwd);",
" if (!WriteToRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE;\n }",
" /* Handle the SecurityResult message */\n if (!rfbHandleAuthResult(client)) return FALSE;",
" return TRUE;\n}",
"static void\nFreeUserCredential(rfbCredential *cred)\n{\n if (cred->userCredential.username) free(cred->userCredential.username);\n if (cred->userCredential.password) free(cred->userCredential.password);\n free(cred);\n}",
"static rfbBool\nHandlePlainAuth(rfbClient *client)\n{\n uint32_t ulen, ulensw;\n uint32_t plen, plensw;\n rfbCredential *cred;",
" if (!client->GetCredential)\n {\n rfbClientLog(\"GetCredential callback is not set.\\n\");\n return FALSE;\n }\n cred = client->GetCredential(client, rfbCredentialTypeUser);\n if (!cred)\n {\n rfbClientLog(\"Reading credential failed\\n\");\n return FALSE;\n }",
" ulen = (cred->userCredential.username ? strlen(cred->userCredential.username) : 0);\n ulensw = rfbClientSwap32IfLE(ulen);\n plen = (cred->userCredential.password ? strlen(cred->userCredential.password) : 0);\n plensw = rfbClientSwap32IfLE(plen);\n if (!WriteToRFBServer(client, (char *)&ulensw, 4) ||\n !WriteToRFBServer(client, (char *)&plensw, 4))\n {\n FreeUserCredential(cred);\n return FALSE;\n }\n if (ulen > 0)\n {\n if (!WriteToRFBServer(client, cred->userCredential.username, ulen))\n {\n FreeUserCredential(cred);\n return FALSE;\n }\n }\n if (plen > 0)\n {\n if (!WriteToRFBServer(client, cred->userCredential.password, plen))\n {\n FreeUserCredential(cred);\n return FALSE;\n }\n }",
" FreeUserCredential(cred);",
" /* Handle the SecurityResult message */\n if (!rfbHandleAuthResult(client)) return FALSE;",
" return TRUE;\n}",
"/* Simple 64bit big integer arithmetic implementation */\n/* (x + y) % m, works even if (x + y) > 64bit */\n#define rfbAddM64(x,y,m) ((x+y)%m+(x+y<x?(((uint64_t)-1)%m+1)%m:0))\n/* (x * y) % m */\nstatic uint64_t\nrfbMulM64(uint64_t x, uint64_t y, uint64_t m)\n{\n uint64_t r;\n for(r=0;x>0;x>>=1)\n {\n if (x&1) r=rfbAddM64(r,y,m);\n y=rfbAddM64(y,y,m);\n }\n return r;\n}\n/* (x ^ y) % m */\nstatic uint64_t\nrfbPowM64(uint64_t b, uint64_t e, uint64_t m)\n{\n uint64_t r;\n for(r=1;e>0;e>>=1)\n {\n if(e&1) r=rfbMulM64(r,b,m);\n b=rfbMulM64(b,b,m);\n }\n return r;\n}",
"static rfbBool\nHandleMSLogonAuth(rfbClient *client)\n{\n uint64_t gen, mod, resp, priv, pub, key;\n uint8_t username[256], password[64];\n rfbCredential *cred;",
" if (!ReadFromRFBServer(client, (char *)&gen, 8)) return FALSE;\n if (!ReadFromRFBServer(client, (char *)&mod, 8)) return FALSE;\n if (!ReadFromRFBServer(client, (char *)&resp, 8)) return FALSE;\n gen = rfbClientSwap64IfLE(gen);\n mod = rfbClientSwap64IfLE(mod);\n resp = rfbClientSwap64IfLE(resp);",
" if (!client->GetCredential)\n {\n rfbClientLog(\"GetCredential callback is not set.\\n\");\n return FALSE;\n }\n rfbClientLog(\"WARNING! MSLogon security type has very low password encryption! \"\\\n \"Use it only with SSH tunnel or trusted network.\\n\");\n cred = client->GetCredential(client, rfbCredentialTypeUser);\n if (!cred)\n {\n rfbClientLog(\"Reading credential failed\\n\");\n return FALSE;\n }",
" memset(username, 0, sizeof(username));\n strncpy((char *)username, cred->userCredential.username, sizeof(username)-1);\n memset(password, 0, sizeof(password));\n strncpy((char *)password, cred->userCredential.password, sizeof(password)-1);\n FreeUserCredential(cred);",
" srand(time(NULL));\n priv = ((uint64_t)rand())<<32;\n priv |= (uint64_t)rand();",
" pub = rfbPowM64(gen, priv, mod);\n key = rfbPowM64(resp, priv, mod);\n pub = rfbClientSwap64IfLE(pub);\n key = rfbClientSwap64IfLE(key);",
" rfbClientEncryptBytes2(username, sizeof(username), (unsigned char *)&key);\n rfbClientEncryptBytes2(password, sizeof(password), (unsigned char *)&key);",
" if (!WriteToRFBServer(client, (char *)&pub, 8)) return FALSE;\n if (!WriteToRFBServer(client, (char *)username, sizeof(username))) return FALSE;\n if (!WriteToRFBServer(client, (char *)password, sizeof(password))) return FALSE;",
" /* Handle the SecurityResult message */\n if (!rfbHandleAuthResult(client)) return FALSE;",
" return TRUE;\n}",
"\nstatic rfbBool\nHandleARDAuth(rfbClient *client)\n{\n uint8_t gen[2], len[2];\n size_t keylen;\n uint8_t *mod = NULL, *resp = NULL, *priv = NULL, *pub = NULL, *key = NULL, *shared = NULL;\n uint8_t userpass[128], ciphertext[128];\n int ciphertext_len;\n int passwordLen, usernameLen;\n rfbCredential *cred = NULL;\n rfbBool result = FALSE;",
" /* Step 1: Read the authentication material from the socket.\n A two-byte generator value, a two-byte key length value. */\n if (!ReadFromRFBServer(client, (char *)gen, 2)) {\n rfbClientErr(\"HandleARDAuth: reading generator value failed\\n\");\n goto out;\n }\n if (!ReadFromRFBServer(client, (char *)len, 2)) {\n rfbClientErr(\"HandleARDAuth: reading key length failed\\n\");\n goto out;\n }\n keylen = 256*len[0]+len[1]; /* convert from char[] to int */",
" mod = (uint8_t*)malloc(keylen*5); /* the block actually contains mod, resp, pub, priv and key */\n if (!mod)\n goto out;",
" resp = mod+keylen;\n pub = resp+keylen;\n priv = pub+keylen;\n key = priv+keylen;",
" /* Step 1: Read the authentication material from the socket.\n The prime modulus (keylen bytes) and the peer's generated public key (keylen bytes). */\n if (!ReadFromRFBServer(client, (char *)mod, keylen)) {\n rfbClientErr(\"HandleARDAuth: reading prime modulus failed\\n\");\n goto out;\n }\n if (!ReadFromRFBServer(client, (char *)resp, keylen)) {\n rfbClientErr(\"HandleARDAuth: reading peer's generated public key failed\\n\");\n goto out;\n }",
" /* Step 2: Generate own Diffie-Hellman public-private key pair. */\n if(!dh_generate_keypair(priv, pub, gen, 2, mod, keylen)) {\n rfbClientErr(\"HandleARDAuth: generating keypair failed\\n\");\n goto out;\n }",
" /* Step 3: Perform Diffie-Hellman key agreement, using the generator (gen),\n prime (mod), and the peer's public key. The output will be a shared\n secret known to both us and the peer. */\n if(!dh_compute_shared_key(key, priv, resp, mod, keylen)) {\n rfbClientErr(\"HandleARDAuth: creating shared key failed\\n\");\n goto out;\n }",
" /* Step 4: Perform an MD5 hash of the shared secret.\n This 128-bit (16-byte) value will be used as the AES key. */\n shared = malloc(MD5_HASH_SIZE);\n if(!hash_md5(shared, key, keylen)) {\n rfbClientErr(\"HandleARDAuth: hashing shared key failed\\n\");\n goto out;\n }",
" /* Step 5: Pack the username and password into a 128-byte\n plaintext \"userpass\" structure: { username[64], password[64] }.\n Null-terminate each. Fill the unused bytes with random characters\n so that the encryption output is less predictable. */\n if(!client->GetCredential) {\n rfbClientErr(\"HandleARDAuth: GetCredential callback is not set\\n\");\n goto out;\n }\n cred = client->GetCredential(client, rfbCredentialTypeUser);\n if(!cred) {\n rfbClientErr(\"HandleARDAuth: reading credential failed\\n\");\n goto out;\n }\n passwordLen = strlen(cred->userCredential.password)+1;\n usernameLen = strlen(cred->userCredential.username)+1;\n if (passwordLen > sizeof(userpass)/2)\n passwordLen = sizeof(userpass)/2;\n if (usernameLen > sizeof(userpass)/2)\n usernameLen = sizeof(userpass)/2;\n random_bytes(userpass, sizeof(userpass));\n memcpy(userpass, cred->userCredential.username, usernameLen);\n memcpy(userpass+sizeof(userpass)/2, cred->userCredential.password, passwordLen);",
" /* Step 6: Encrypt the plaintext credentials with the 128-bit MD5 hash\n from step 4, using the AES 128-bit symmetric cipher in electronic\n codebook (ECB) mode. Use no further padding for this block cipher. */\n if(!encrypt_aes128ecb(ciphertext, &ciphertext_len, shared, userpass, sizeof(userpass))) {\n rfbClientErr(\"HandleARDAuth: encrypting credentials failed\\n\");\n goto out;\n }",
" /* Step 7: Write the ciphertext from step 6 to the stream.\n Write the generated DH public key to the stream. */\n if (!WriteToRFBServer(client, (char *)ciphertext, sizeof(ciphertext)))\n goto out;\n if (!WriteToRFBServer(client, (char *)pub, keylen))\n goto out;",
" /* Handle the SecurityResult message */\n if (!rfbHandleAuthResult(client))\n goto out;",
" result = TRUE;",
" out:\n if (cred)\n FreeUserCredential(cred);",
" free(mod);\n free(shared);",
" return result;\n}",
"",
"/*\n * SetClientAuthSchemes.\n */",
"void\nSetClientAuthSchemes(rfbClient* client,const uint32_t *authSchemes, int size)\n{\n int i;",
" if (client->clientAuthSchemes)\n {\n free(client->clientAuthSchemes);\n client->clientAuthSchemes = NULL;\n }\n if (authSchemes)\n {\n if (size<0)\n {\n /* If size<0 we assume the passed-in list is also 0-terminate, so we\n * calculate the size here */\n for (size=0;authSchemes[size];size++) ;\n }\n client->clientAuthSchemes = (uint32_t*)malloc(sizeof(uint32_t)*(size+1));\n for (i=0;i<size;i++)\n client->clientAuthSchemes[i] = authSchemes[i];\n client->clientAuthSchemes[size] = 0;\n }\n}",
"/*\n * InitialiseRFBConnection.\n */",
"rfbBool\nInitialiseRFBConnection(rfbClient* client)\n{\n rfbProtocolVersionMsg pv;\n int major,minor;\n uint32_t authScheme;\n uint32_t subAuthScheme;\n rfbClientInitMsg ci;",
" /* if the connection is immediately closed, don't report anything, so\n that pmw's monitor can make test connections */",
" if (client->listenSpecified)\n errorMessageOnReadFailure = FALSE;",
" if (!ReadFromRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE;\n pv[sz_rfbProtocolVersionMsg]=0;",
" errorMessageOnReadFailure = TRUE;",
" pv[sz_rfbProtocolVersionMsg] = 0;",
" if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2) {\n rfbClientLog(\"Not a valid VNC server (%s)\\n\",pv);\n return FALSE;\n }",
"\n DefaultSupportedMessages(client);\n client->major = major;\n client->minor = minor;",
" /* fall back to viewer supported version */\n if ((major==rfbProtocolMajorVersion) && (minor>rfbProtocolMinorVersion))\n client->minor = rfbProtocolMinorVersion;",
" /* UltraVNC uses minor codes 4 and 6 for the server */\n if (major==3 && (minor==4 || minor==6)) {\n rfbClientLog(\"UltraVNC server detected, enabling UltraVNC specific messages\\n\",pv);\n DefaultSupportedMessagesUltraVNC(client);\n }",
" /* UltraVNC Single Click uses minor codes 14 and 16 for the server */\n if (major==3 && (minor==14 || minor==16)) {\n minor = minor - 10;\n client->minor = minor;\n rfbClientLog(\"UltraVNC Single Click server detected, enabling UltraVNC specific messages\\n\",pv);\n DefaultSupportedMessagesUltraVNC(client);\n }",
" /* TightVNC uses minor codes 5 for the server */\n if (major==3 && minor==5) {\n rfbClientLog(\"TightVNC server detected, enabling TightVNC specific messages\\n\",pv);\n DefaultSupportedMessagesTightVNC(client);\n }",
" /* we do not support > RFB3.8 */\n if ((major==3 && minor>8) || major>3)\n {\n client->major=3;\n client->minor=8;\n }",
" rfbClientLog(\"VNC server supports protocol version %d.%d (viewer %d.%d)\\n\",\n\t major, minor, rfbProtocolMajorVersion, rfbProtocolMinorVersion);",
" sprintf(pv,rfbProtocolVersionFormat,client->major,client->minor);",
" if (!WriteToRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE;",
"\n /* 3.7 and onwards sends a # of security types first */\n if (client->major==3 && client->minor > 6)\n {\n if (!ReadSupportedSecurityType(client, &authScheme, FALSE)) return FALSE;\n }\n else\n {\n if (!ReadFromRFBServer(client, (char *)&authScheme, 4)) return FALSE;\n authScheme = rfbClientSwap32IfLE(authScheme);\n }\n \n rfbClientLog(\"Selected Security Scheme %d\\n\", authScheme);\n client->authScheme = authScheme;\n \n switch (authScheme) {",
" case rfbConnFailed:\n ReadReason(client);\n return FALSE;",
" case rfbNoAuth:\n rfbClientLog(\"No authentication needed\\n\");",
" /* 3.8 and upwards sends a Security Result for rfbNoAuth */\n if ((client->major==3 && client->minor > 7) || client->major>3)\n if (!rfbHandleAuthResult(client)) return FALSE; ",
" break;",
" case rfbVncAuth:\n if (!HandleVncAuth(client)) return FALSE;\n break;",
"#ifdef LIBVNCSERVER_HAVE_SASL\n case rfbSASL:\n if (!HandleSASLAuth(client)) return FALSE;\n break;\n#endif /* LIBVNCSERVER_HAVE_SASL */",
" case rfbMSLogon:\n if (!HandleMSLogonAuth(client)) return FALSE;\n break;",
" case rfbARD:\n if (!HandleARDAuth(client)) return FALSE;\n break;",
" case rfbTLS:\n if (!HandleAnonTLSAuth(client)) return FALSE;\n /* After the TLS session is established, sub auth types are expected.\n * Note that all following reading/writing are through the TLS session from here.\n */\n if (!ReadSupportedSecurityType(client, &subAuthScheme, TRUE)) return FALSE;\n client->subAuthScheme = subAuthScheme;",
" switch (subAuthScheme) {",
" case rfbConnFailed:\n ReadReason(client);\n return FALSE;",
" case rfbNoAuth:\n rfbClientLog(\"No sub authentication needed\\n\");\n /* 3.8 and upwards sends a Security Result for rfbNoAuth */\n if ((client->major==3 && client->minor > 7) || client->major>3)\n if (!rfbHandleAuthResult(client)) return FALSE;\n break;",
" case rfbVncAuth:\n if (!HandleVncAuth(client)) return FALSE;\n break;",
"#ifdef LIBVNCSERVER_HAVE_SASL\n case rfbSASL:\n if (!HandleSASLAuth(client)) return FALSE;\n break;\n#endif /* LIBVNCSERVER_HAVE_SASL */",
" default:\n rfbClientLog(\"Unknown sub authentication scheme from VNC server: %d\\n\",\n (int)subAuthScheme);\n return FALSE;\n }",
" break;",
" case rfbVeNCrypt:\n if (!HandleVeNCryptAuth(client)) return FALSE;",
" switch (client->subAuthScheme) {",
" case rfbVeNCryptTLSNone:\n case rfbVeNCryptX509None:\n rfbClientLog(\"No sub authentication needed\\n\");\n if (!rfbHandleAuthResult(client)) return FALSE;\n break;",
" case rfbVeNCryptTLSVNC:\n case rfbVeNCryptX509VNC:\n if (!HandleVncAuth(client)) return FALSE;\n break;",
" case rfbVeNCryptTLSPlain:\n case rfbVeNCryptX509Plain:\n if (!HandlePlainAuth(client)) return FALSE;\n break;",
"#ifdef LIBVNCSERVER_HAVE_SASL\n case rfbVeNCryptX509SASL:\n case rfbVeNCryptTLSSASL:\n if (!HandleSASLAuth(client)) return FALSE;\n break;\n#endif /* LIBVNCSERVER_HAVE_SASL */",
" default:\n rfbClientLog(\"Unknown sub authentication scheme from VNC server: %d\\n\",\n client->subAuthScheme);\n return FALSE;\n }",
" break;",
" default:\n {\n rfbBool authHandled=FALSE;\n rfbClientProtocolExtension* e;\n for (e = rfbClientExtensions; e; e = e->next) {\n uint32_t const* secType;\n if (!e->handleAuthentication) continue;\n for (secType = e->securityTypes; secType && *secType; secType++) {\n if (authScheme==*secType) {\n if (!e->handleAuthentication(client, authScheme)) return FALSE;\n if (!rfbHandleAuthResult(client)) return FALSE;\n authHandled=TRUE;\n }\n }\n }\n if (authHandled) break;\n }\n rfbClientLog(\"Unknown authentication scheme from VNC server: %d\\n\",\n\t (int)authScheme);\n return FALSE;\n }",
" ci.shared = (client->appData.shareDesktop ? 1 : 0);",
" if (!WriteToRFBServer(client, (char *)&ci, sz_rfbClientInitMsg)) return FALSE;",
" if (!ReadFromRFBServer(client, (char *)&client->si, sz_rfbServerInitMsg)) return FALSE;",
" client->si.framebufferWidth = rfbClientSwap16IfLE(client->si.framebufferWidth);\n client->si.framebufferHeight = rfbClientSwap16IfLE(client->si.framebufferHeight);\n client->si.format.redMax = rfbClientSwap16IfLE(client->si.format.redMax);\n client->si.format.greenMax = rfbClientSwap16IfLE(client->si.format.greenMax);\n client->si.format.blueMax = rfbClientSwap16IfLE(client->si.format.blueMax);\n client->si.nameLength = rfbClientSwap32IfLE(client->si.nameLength);",
" if (client->si.nameLength > 1<<20) {\n rfbClientErr(\"Too big desktop name length sent by server: %u B > 1 MB\\n\", (unsigned int)client->si.nameLength);\n return FALSE;\n }",
" client->desktopName = malloc(client->si.nameLength + 1);\n if (!client->desktopName) {\n rfbClientLog(\"Error allocating memory for desktop name, %lu bytes\\n\",\n (unsigned long)client->si.nameLength);\n return FALSE;\n }",
" if (!ReadFromRFBServer(client, client->desktopName, client->si.nameLength)) return FALSE;",
" client->desktopName[client->si.nameLength] = 0;",
" rfbClientLog(\"Desktop name \\\"%s\\\"\\n\",client->desktopName);",
" rfbClientLog(\"Connected to VNC server, using protocol version %d.%d\\n\",\n\t client->major, client->minor);",
" rfbClientLog(\"VNC server default format:\\n\");\n PrintPixelFormat(&client->si.format);",
" return TRUE;\n}",
"\n/*\n * SetFormatAndEncodings.\n */",
"rfbBool\nSetFormatAndEncodings(rfbClient* client)\n{\n rfbSetPixelFormatMsg spf;\n char buf[sz_rfbSetEncodingsMsg + MAX_ENCODINGS * 4];",
" rfbSetEncodingsMsg *se = (rfbSetEncodingsMsg *)buf;\n uint32_t *encs = (uint32_t *)(&buf[sz_rfbSetEncodingsMsg]);\n int len = 0;\n rfbBool requestCompressLevel = FALSE;\n rfbBool requestQualityLevel = FALSE;\n rfbBool requestLastRectEncoding = FALSE;\n rfbClientProtocolExtension* e;",
" if (!SupportsClient2Server(client, rfbSetPixelFormat)) return TRUE;",
" spf.type = rfbSetPixelFormat;\n spf.pad1 = 0;\n spf.pad2 = 0;\n spf.format = client->format;\n spf.format.redMax = rfbClientSwap16IfLE(spf.format.redMax);\n spf.format.greenMax = rfbClientSwap16IfLE(spf.format.greenMax);\n spf.format.blueMax = rfbClientSwap16IfLE(spf.format.blueMax);",
" if (!WriteToRFBServer(client, (char *)&spf, sz_rfbSetPixelFormatMsg))\n return FALSE;",
"\n if (!SupportsClient2Server(client, rfbSetEncodings)) return TRUE;",
" se->type = rfbSetEncodings;\n se->pad = 0;\n se->nEncodings = 0;",
" if (client->appData.encodingsString) {\n const char *encStr = client->appData.encodingsString;\n int encStrLen;\n do {\n const char *nextEncStr = strchr(encStr, ' ');\n if (nextEncStr) {\n\tencStrLen = nextEncStr - encStr;\n\tnextEncStr++;\n } else {\n\tencStrLen = strlen(encStr);\n }",
" if (strncasecmp(encStr,\"raw\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRaw);\n } else if (strncasecmp(encStr,\"copyrect\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCopyRect);\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n#ifdef LIBVNCSERVER_HAVE_LIBJPEG\n } else if (strncasecmp(encStr,\"tight\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTight);\n\trequestLastRectEncoding = TRUE;\n\tif (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9)\n\t requestCompressLevel = TRUE;\n\tif (client->appData.enableJPEG)\n\t requestQualityLevel = TRUE;\n#endif\n#endif\n } else if (strncasecmp(encStr,\"hextile\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingHextile);\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n } else if (strncasecmp(encStr,\"zlib\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlib);\n\tif (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9)\n\t requestCompressLevel = TRUE;\n } else if (strncasecmp(encStr,\"zlibhex\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlibHex);\n\tif (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9)\n\t requestCompressLevel = TRUE;\n } else if (strncasecmp(encStr,\"trle\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTRLE);\n } else if (strncasecmp(encStr,\"zrle\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZRLE);\n } else if (strncasecmp(encStr,\"zywrle\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZYWRLE);\n\trequestQualityLevel = TRUE;\n#endif\n } else if ((strncasecmp(encStr,\"ultra\",encStrLen) == 0) || (strncasecmp(encStr,\"ultrazip\",encStrLen) == 0)) {\n /* There are 2 encodings used in 'ultra' */\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltra);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltraZip);\n } else if (strncasecmp(encStr,\"corre\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCoRRE);\n } else if (strncasecmp(encStr,\"rre\",encStrLen) == 0) {\n\tencs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRRE);\n } else {\n\trfbClientLog(\"Unknown encoding '%.*s'\\n\",encStrLen,encStr);\n }",
" encStr = nextEncStr;\n } while (encStr && se->nEncodings < MAX_ENCODINGS);",
" if (se->nEncodings < MAX_ENCODINGS && requestCompressLevel) {\n encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.compressLevel +\n\t\t\t\t\t rfbEncodingCompressLevel0);\n }",
" if (se->nEncodings < MAX_ENCODINGS && requestQualityLevel) {\n if (client->appData.qualityLevel < 0 || client->appData.qualityLevel > 9)\n client->appData.qualityLevel = 5;\n encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.qualityLevel +\n\t\t\t\t\t rfbEncodingQualityLevel0);\n }\n }\n else {\n if (SameMachine(client->sock)) {\n /* TODO:\n if (!tunnelSpecified) {\n */\n rfbClientLog(\"Same machine: preferring raw encoding\\n\");\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRaw);\n /*\n } else {\n\trfbClientLog(\"Tunneling active: preferring tight encoding\\n\");\n }\n */\n }",
" encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCopyRect);\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n#ifdef LIBVNCSERVER_HAVE_LIBJPEG\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTight);\n requestLastRectEncoding = TRUE;\n#endif\n#endif\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingHextile);\n#ifdef LIBVNCSERVER_HAVE_LIBZ\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZlib);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZRLE);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingZYWRLE);\n#endif\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltra);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingUltraZip);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCoRRE);\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRRE);",
" if (client->appData.compressLevel >= 0 && client->appData.compressLevel <= 9) {\n encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.compressLevel +\n\t\t\t\t\t rfbEncodingCompressLevel0);\n } else /* if (!tunnelSpecified) */ {\n /* If -tunnel option was provided, we assume that server machine is\n\t not in the local network so we use default compression level for\n\t tight encoding instead of fast compression. Thus we are\n\t requesting level 1 compression only if tunneling is not used. */\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCompressLevel1);\n }",
" if (client->appData.enableJPEG) {\n if (client->appData.qualityLevel < 0 || client->appData.qualityLevel > 9)\n\tclient->appData.qualityLevel = 5;\n encs[se->nEncodings++] = rfbClientSwap32IfLE(client->appData.qualityLevel +\n\t\t\t\t\t rfbEncodingQualityLevel0);\n }\n }",
"",
" /* Remote Cursor Support (local to viewer) */\n if (client->appData.useRemoteCursor) {\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingXCursor);\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRichCursor);\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingPointerPos);\n }",
" /* Keyboard State Encodings */\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingKeyboardLedState);",
" /* New Frame Buffer Size */\n if (se->nEncodings < MAX_ENCODINGS && client->canHandleNewFBSize)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingNewFBSize);",
" /* Last Rect */\n if (se->nEncodings < MAX_ENCODINGS && requestLastRectEncoding)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingLastRect);",
" /* Server Capabilities */\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingSupportedMessages);\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingSupportedEncodings);\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingServerIdentity);",
" /* xvp */\n if (se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingXvp);",
" /* client extensions */\n for(e = rfbClientExtensions; e; e = e->next)\n if(e->encodings) {\n int* enc;\n for(enc = e->encodings; *enc; enc++)\n if(se->nEncodings < MAX_ENCODINGS)\n encs[se->nEncodings++] = rfbClientSwap32IfLE(*enc);\n }",
" len = sz_rfbSetEncodingsMsg + se->nEncodings * 4;",
" se->nEncodings = rfbClientSwap16IfLE(se->nEncodings);",
" if (!WriteToRFBServer(client, buf, len)) return FALSE;",
" return TRUE;\n}",
"\n/*\n * SendIncrementalFramebufferUpdateRequest.\n */",
"rfbBool\nSendIncrementalFramebufferUpdateRequest(rfbClient* client)\n{\n\treturn SendFramebufferUpdateRequest(client,\n\t\t\tclient->updateRect.x, client->updateRect.y,\n\t\t\tclient->updateRect.w, client->updateRect.h, TRUE);\n}",
"\n/*\n * SendFramebufferUpdateRequest.\n */",
"rfbBool\nSendFramebufferUpdateRequest(rfbClient* client, int x, int y, int w, int h, rfbBool incremental)\n{\n rfbFramebufferUpdateRequestMsg fur;",
" if (!SupportsClient2Server(client, rfbFramebufferUpdateRequest)) return TRUE;\n \n fur.type = rfbFramebufferUpdateRequest;\n fur.incremental = incremental ? 1 : 0;\n fur.x = rfbClientSwap16IfLE(x);\n fur.y = rfbClientSwap16IfLE(y);\n fur.w = rfbClientSwap16IfLE(w);\n fur.h = rfbClientSwap16IfLE(h);",
" if (!WriteToRFBServer(client, (char *)&fur, sz_rfbFramebufferUpdateRequestMsg))\n return FALSE;",
" return TRUE;\n}",
"\n/*\n * SendScaleSetting.\n */\nrfbBool\nSendScaleSetting(rfbClient* client,int scaleSetting)\n{\n rfbSetScaleMsg ssm;",
" ssm.scale = scaleSetting;\n ssm.pad = 0;\n \n /* favor UltraVNC SetScale if both are supported */\n if (SupportsClient2Server(client, rfbSetScale)) {\n ssm.type = rfbSetScale;\n if (!WriteToRFBServer(client, (char *)&ssm, sz_rfbSetScaleMsg))\n return FALSE;\n }\n \n if (SupportsClient2Server(client, rfbPalmVNCSetScaleFactor)) {\n ssm.type = rfbPalmVNCSetScaleFactor;\n if (!WriteToRFBServer(client, (char *)&ssm, sz_rfbSetScaleMsg))\n return FALSE;\n }",
" return TRUE;\n}",
"/*\n * TextChatFunctions (UltraVNC)\n * Extremely bandwidth friendly method of communicating with a user\n * (Think HelpDesk type applications)\n */",
"rfbBool TextChatSend(rfbClient* client, char *text)\n{\n rfbTextChatMsg chat;\n int count = strlen(text);",
" if (!SupportsClient2Server(client, rfbTextChat)) return TRUE;\n chat.type = rfbTextChat;\n chat.pad1 = 0;\n chat.pad2 = 0;\n chat.length = (uint32_t)count;\n chat.length = rfbClientSwap32IfLE(chat.length);",
" if (!WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg))\n return FALSE;",
" if (count>0) {\n if (!WriteToRFBServer(client, text, count))\n return FALSE;\n }\n return TRUE;\n}",
"rfbBool TextChatOpen(rfbClient* client)\n{\n rfbTextChatMsg chat;",
" if (!SupportsClient2Server(client, rfbTextChat)) return TRUE;\n chat.type = rfbTextChat;\n chat.pad1 = 0;\n chat.pad2 = 0;\n chat.length = rfbClientSwap32IfLE(rfbTextChatOpen);\n return (WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg) ? TRUE : FALSE);\n}",
"rfbBool TextChatClose(rfbClient* client)\n{\n rfbTextChatMsg chat;\n if (!SupportsClient2Server(client, rfbTextChat)) return TRUE;\n chat.type = rfbTextChat;\n chat.pad1 = 0;\n chat.pad2 = 0;\n chat.length = rfbClientSwap32IfLE(rfbTextChatClose);\n return (WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg) ? TRUE : FALSE);\n}",
"rfbBool TextChatFinish(rfbClient* client)\n{\n rfbTextChatMsg chat;\n if (!SupportsClient2Server(client, rfbTextChat)) return TRUE;\n chat.type = rfbTextChat;\n chat.pad1 = 0;\n chat.pad2 = 0;\n chat.length = rfbClientSwap32IfLE(rfbTextChatFinished);\n return (WriteToRFBServer(client, (char *)&chat, sz_rfbTextChatMsg) ? TRUE : FALSE);\n}",
"/*\n * UltraVNC Server Input Disable\n * Apparently, the remote client can *prevent* the local user from interacting with the display\n * I would think this is extremely helpful when used in a HelpDesk situation\n */\nrfbBool PermitServerInput(rfbClient* client, int enabled)\n{\n rfbSetServerInputMsg msg;",
" if (!SupportsClient2Server(client, rfbSetServerInput)) return TRUE;\n /* enabled==1, then server input from local keyboard is disabled */\n msg.type = rfbSetServerInput;\n msg.status = (enabled ? 1 : 0);\n msg.pad = 0;\n return (WriteToRFBServer(client, (char *)&msg, sz_rfbSetServerInputMsg) ? TRUE : FALSE);\n}",
"\n/*\n * send xvp client message\n * A client supporting the xvp extension sends this to request that the server initiate\n * a clean shutdown, clean reboot or abrupt reset of the system whose framebuffer the\n * client is displaying.\n *\n * only version 1 is defined in the protocol specs\n *\n * possible values for code are:\n * rfbXvp_Shutdown\n * rfbXvp_Reboot\n * rfbXvp_Reset\n */",
"rfbBool SendXvpMsg(rfbClient* client, uint8_t version, uint8_t code)\n{\n rfbXvpMsg xvp;",
" if (!SupportsClient2Server(client, rfbXvp)) return TRUE;\n xvp.type = rfbXvp;\n xvp.pad = 0;\n xvp.version = version;\n xvp.code = code;",
" if (!WriteToRFBServer(client, (char *)&xvp, sz_rfbXvpMsg))\n return FALSE;",
" return TRUE;\n}",
"\n/*\n * SendPointerEvent.\n */",
"rfbBool\nSendPointerEvent(rfbClient* client,int x, int y, int buttonMask)\n{\n rfbPointerEventMsg pe;",
" if (!SupportsClient2Server(client, rfbPointerEvent)) return TRUE;",
" pe.type = rfbPointerEvent;\n pe.buttonMask = buttonMask;\n if (x < 0) x = 0;\n if (y < 0) y = 0;",
" pe.x = rfbClientSwap16IfLE(x);\n pe.y = rfbClientSwap16IfLE(y);\n return WriteToRFBServer(client, (char *)&pe, sz_rfbPointerEventMsg);\n}",
"\n/*\n * SendKeyEvent.\n */",
"rfbBool\nSendKeyEvent(rfbClient* client, uint32_t key, rfbBool down)\n{\n rfbKeyEventMsg ke;",
" if (!SupportsClient2Server(client, rfbKeyEvent)) return TRUE;",
" memset(&ke, 0, sizeof(ke));\n ke.type = rfbKeyEvent;\n ke.down = down ? 1 : 0;\n ke.key = rfbClientSwap32IfLE(key);\n return WriteToRFBServer(client, (char *)&ke, sz_rfbKeyEventMsg);\n}",
"\n/*\n * SendClientCutText.\n */",
"rfbBool\nSendClientCutText(rfbClient* client, char *str, int len)\n{\n rfbClientCutTextMsg cct;",
" if (!SupportsClient2Server(client, rfbClientCutText)) return TRUE;",
" memset(&cct, 0, sizeof(cct));\n cct.type = rfbClientCutText;\n cct.length = rfbClientSwap32IfLE(len);\n return (WriteToRFBServer(client, (char *)&cct, sz_rfbClientCutTextMsg) &&\n\t WriteToRFBServer(client, str, len));\n}",
"",
"/*\n * HandleRFBServerMessage.\n */",
"rfbBool\nHandleRFBServerMessage(rfbClient* client)\n{\n rfbServerToClientMsg msg;",
" if (client->serverPort==-1)\n client->vncRec->readTimestamp = TRUE;\n if (!ReadFromRFBServer(client, (char *)&msg, 1))\n return FALSE;",
" switch (msg.type) {",
" case rfbSetColourMapEntries:\n {\n /* TODO:\n int i;\n uint16_t rgb[3];\n XColor xc;",
" if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n\t\t\t sz_rfbSetColourMapEntriesMsg - 1))\n return FALSE;",
" msg.scme.firstColour = rfbClientSwap16IfLE(msg.scme.firstColour);\n msg.scme.nColours = rfbClientSwap16IfLE(msg.scme.nColours);",
" for (i = 0; i < msg.scme.nColours; i++) {\n if (!ReadFromRFBServer(client, (char *)rgb, 6))\n\treturn FALSE;\n xc.pixel = msg.scme.firstColour + i;\n xc.red = rfbClientSwap16IfLE(rgb[0]);\n xc.green = rfbClientSwap16IfLE(rgb[1]);\n xc.blue = rfbClientSwap16IfLE(rgb[2]);\n xc.flags = DoRed|DoGreen|DoBlue;\n XStoreColor(dpy, cmap, &xc);\n }\n */",
" break;\n }",
" case rfbFramebufferUpdate:\n {\n rfbFramebufferUpdateRectHeader rect;\n int linesToRead;\n int bytesPerLine;\n int i;",
" if (!ReadFromRFBServer(client, ((char *)&msg.fu) + 1,\n\t\t\t sz_rfbFramebufferUpdateMsg - 1))\n return FALSE;",
" msg.fu.nRects = rfbClientSwap16IfLE(msg.fu.nRects);",
" for (i = 0; i < msg.fu.nRects; i++) {\n if (!ReadFromRFBServer(client, (char *)&rect, sz_rfbFramebufferUpdateRectHeader))\n\treturn FALSE;",
" rect.encoding = rfbClientSwap32IfLE(rect.encoding);\n if (rect.encoding == rfbEncodingLastRect)\n\tbreak;",
" rect.r.x = rfbClientSwap16IfLE(rect.r.x);\n rect.r.y = rfbClientSwap16IfLE(rect.r.y);\n rect.r.w = rfbClientSwap16IfLE(rect.r.w);\n rect.r.h = rfbClientSwap16IfLE(rect.r.h);",
"\n if (rect.encoding == rfbEncodingXCursor ||\n\t rect.encoding == rfbEncodingRichCursor) {",
"\tif (!HandleCursorShape(client,\n\t\t\t rect.r.x, rect.r.y, rect.r.w, rect.r.h,\n\t\t\t rect.encoding)) {\n\t return FALSE;\n\t}\n\tcontinue;\n }",
" if (rect.encoding == rfbEncodingPointerPos) {\n\tif (!client->HandleCursorPos(client,rect.r.x, rect.r.y)) {\n\t return FALSE;\n\t}\n\tcontinue;\n }\n \n if (rect.encoding == rfbEncodingKeyboardLedState) {\n /* OK! We have received a keyboard state message!!! */\n client->KeyboardLedStateEnabled = 1;\n if (client->HandleKeyboardLedState!=NULL)\n client->HandleKeyboardLedState(client, rect.r.x, 0);\n /* stash it for the future */\n client->CurrentKeyboardLedState = rect.r.x;\n continue;\n }",
" if (rect.encoding == rfbEncodingNewFBSize) {\n\tclient->width = rect.r.w;\n\tclient->height = rect.r.h;\n\tclient->updateRect.x = client->updateRect.y = 0;\n\tclient->updateRect.w = client->width;\n\tclient->updateRect.h = client->height;\n\tif (!client->MallocFrameBuffer(client))\n\t return FALSE;\n\tSendFramebufferUpdateRequest(client, 0, 0, rect.r.w, rect.r.h, FALSE);\n\trfbClientLog(\"Got new framebuffer size: %dx%d\\n\", rect.r.w, rect.r.h);\n\tcontinue;\n }",
" /* rect.r.w=byte count */\n if (rect.encoding == rfbEncodingSupportedMessages) {\n int loop;\n if (!ReadFromRFBServer(client, (char *)&client->supportedMessages, sz_rfbSupportedMessages))\n return FALSE;",
" /* msgs is two sets of bit flags of supported messages client2server[] and server2client[] */\n /* currently ignored by this library */",
" rfbClientLog(\"client2server supported messages (bit flags)\\n\");\n for (loop=0;loop<32;loop+=8)\n rfbClientLog(\"%02X: %04x %04x %04x %04x - %04x %04x %04x %04x\\n\", loop,\n client->supportedMessages.client2server[loop], client->supportedMessages.client2server[loop+1],\n client->supportedMessages.client2server[loop+2], client->supportedMessages.client2server[loop+3],\n client->supportedMessages.client2server[loop+4], client->supportedMessages.client2server[loop+5],\n client->supportedMessages.client2server[loop+6], client->supportedMessages.client2server[loop+7]);",
" rfbClientLog(\"server2client supported messages (bit flags)\\n\");\n for (loop=0;loop<32;loop+=8)\n rfbClientLog(\"%02X: %04x %04x %04x %04x - %04x %04x %04x %04x\\n\", loop,\n client->supportedMessages.server2client[loop], client->supportedMessages.server2client[loop+1],\n client->supportedMessages.server2client[loop+2], client->supportedMessages.server2client[loop+3],\n client->supportedMessages.server2client[loop+4], client->supportedMessages.server2client[loop+5],\n client->supportedMessages.server2client[loop+6], client->supportedMessages.server2client[loop+7]);\n continue;\n }",
" /* rect.r.w=byte count, rect.r.h=# of encodings */\n if (rect.encoding == rfbEncodingSupportedEncodings) {\n char *buffer;\n buffer = malloc(rect.r.w);\n if (!ReadFromRFBServer(client, buffer, rect.r.w))\n {\n free(buffer);\n return FALSE;\n }",
" /* buffer now contains rect.r.h # of uint32_t encodings that the server supports */\n /* currently ignored by this library */\n free(buffer);\n continue;\n }",
" /* rect.r.w=byte count */\n if (rect.encoding == rfbEncodingServerIdentity) {\n char *buffer;\n buffer = malloc(rect.r.w+1);\n if (!ReadFromRFBServer(client, buffer, rect.r.w))\n {\n free(buffer);\n return FALSE;\n }\n buffer[rect.r.w]=0; /* null terminate, just in case */\n rfbClientLog(\"Connected to Server \\\"%s\\\"\\n\", buffer);\n free(buffer);\n continue;\n }",
" /* rfbEncodingUltraZip is a collection of subrects. x = # of subrects, and h is always 0 */\n if (rect.encoding != rfbEncodingUltraZip)\n {\n if ((rect.r.x + rect.r.w > client->width) ||\n\t (rect.r.y + rect.r.h > client->height))\n\t {\n\t rfbClientLog(\"Rect too large: %dx%d at (%d, %d)\\n\",\n\t \t rect.r.w, rect.r.h, rect.r.x, rect.r.y);\n\t return FALSE;\n }",
" /* UltraVNC with scaling, will send rectangles with a zero W or H\n *\n if ((rect.encoding != rfbEncodingTight) && \n (rect.r.h * rect.r.w == 0))\n {\n\t rfbClientLog(\"Zero size rect - ignoring (encoding=%d (0x%08x) %dx, %dy, %dw, %dh)\\n\", rect.encoding, rect.encoding, rect.r.x, rect.r.y, rect.r.w, rect.r.h);\n\t continue;\n }\n */\n \n /* If RichCursor encoding is used, we should prevent collisions\n\t between framebuffer updates and cursor drawing operations. */\n client->SoftCursorLockArea(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h);\n }",
" switch (rect.encoding) {",
" case rfbEncodingRaw: {\n\tint y=rect.r.y, h=rect.r.h;",
"\tbytesPerLine = rect.r.w * client->format.bitsPerPixel / 8;\n\t/* RealVNC 4.x-5.x on OSX can induce bytesPerLine==0, \n\t usually during GPU accel. */\n\t/* Regardless of cause, do not divide by zero. */\n\tlinesToRead = bytesPerLine ? (RFB_BUFFER_SIZE / bytesPerLine) : 0;",
"\twhile (linesToRead && h > 0) {\n\t if (linesToRead > h)\n\t linesToRead = h;",
"\t if (!ReadFromRFBServer(client, client->buffer,bytesPerLine * linesToRead))\n\t return FALSE;",
"\t client->GotBitmap(client, (uint8_t *)client->buffer,\n\t\t\t rect.r.x, y, rect.r.w,linesToRead);",
"\t h -= linesToRead;\n\t y += linesToRead;",
"\t}\n\tbreak;\n } ",
" case rfbEncodingCopyRect:\n {\n\trfbCopyRect cr;",
"\tif (!ReadFromRFBServer(client, (char *)&cr, sz_rfbCopyRect))\n\t return FALSE;",
"\tcr.srcX = rfbClientSwap16IfLE(cr.srcX);\n\tcr.srcY = rfbClientSwap16IfLE(cr.srcY);",
"\t/* If RichCursor encoding is used, we should extend our\n\t \"cursor lock area\" (previously set to destination\n\t rectangle) to the source rectangle as well. */\n\tclient->SoftCursorLockArea(client,\n\t\t\t\t cr.srcX, cr.srcY, rect.r.w, rect.r.h);",
" client->GotCopyRect(client, cr.srcX, cr.srcY, rect.r.w, rect.r.h,\n rect.r.x, rect.r.y);",
"\tbreak;\n }",
" case rfbEncodingRRE:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleRRE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (!HandleRRE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 32:\n\t if (!HandleRRE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\tbreak;\n }",
" case rfbEncodingCoRRE:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleCoRRE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (!HandleCoRRE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 32:\n\t if (!HandleCoRRE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\tbreak;\n }",
" case rfbEncodingHextile:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleHextile8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (!HandleHextile16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 32:\n\t if (!HandleHextile32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\tbreak;\n }",
" case rfbEncodingUltra:\n {\n switch (client->format.bitsPerPixel) {\n case 8:\n if (!HandleUltra8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n case 16:\n if (!HandleUltra16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n case 32:\n if (!HandleUltra32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n }\n break;\n }\n case rfbEncodingUltraZip:\n {\n switch (client->format.bitsPerPixel) {\n case 8:\n if (!HandleUltraZip8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n case 16:\n if (!HandleUltraZip16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n case 32:\n if (!HandleUltraZip32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n return FALSE;\n break;\n }\n break;\n }",
" case rfbEncodingTRLE:\n\t {\n switch (client->format.bitsPerPixel) {\n case 8:\n if (!HandleTRLE8(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n return FALSE;\n break;\n case 16:\n if (client->si.format.greenMax > 0x1F) {\n if (!HandleTRLE16(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n return FALSE;\n } else {\n if (!HandleTRLE15(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n return FALSE;\n }\n break;\n case 32: {\n uint32_t maxColor =\n (client->format.redMax << client->format.redShift) |\n (client->format.greenMax << client->format.greenShift) |\n (client->format.blueMax << client->format.blueShift);\n if ((client->format.bigEndian && (maxColor & 0xff) == 0) ||\n (!client->format.bigEndian && (maxColor & 0xff000000) == 0)) {\n if (!HandleTRLE24(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n return FALSE;\n } else if (!client->format.bigEndian && (maxColor & 0xff) == 0) {\n if (!HandleTRLE24Up(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h))\n return FALSE;\n } else if (client->format.bigEndian && (maxColor & 0xff000000) == 0) {\n if (!HandleTRLE24Down(client, rect.r.x, rect.r.y, rect.r.w,\n rect.r.h))\n return FALSE;\n } else if (!HandleTRLE32(client, rect.r.x, rect.r.y, rect.r.w,\n rect.r.h))\n return FALSE;\n break;\n }\n }\n break;\n }",
"#ifdef LIBVNCSERVER_HAVE_LIBZ\n case rfbEncodingZlib:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleZlib8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (!HandleZlib16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 32:\n\t if (!HandleZlib32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\tbreak;\n }",
"#ifdef LIBVNCSERVER_HAVE_LIBJPEG\n case rfbEncodingTight:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleTight8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (!HandleTight16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 32:\n\t if (!HandleTight32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\tbreak;\n }\n#endif\n case rfbEncodingZRLE:\n\t/* Fail safe for ZYWRLE unsupport VNC server. */\n\tclient->appData.qualityLevel = 9;\n\t/* fall through */\n case rfbEncodingZYWRLE:\n {\n\tswitch (client->format.bitsPerPixel) {\n\tcase 8:\n\t if (!HandleZRLE8(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\tcase 16:\n\t if (client->si.format.greenMax > 0x1F) {\n\t if (!HandleZRLE16(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t } else {\n\t if (!HandleZRLE15(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t }\n\t break;\n\tcase 32:\n\t{\n\t uint32_t maxColor=(client->format.redMax<<client->format.redShift)|\n\t\t(client->format.greenMax<<client->format.greenShift)|\n\t\t(client->format.blueMax<<client->format.blueShift);\n\t if ((client->format.bigEndian && (maxColor&0xff)==0) ||\n\t (!client->format.bigEndian && (maxColor&0xff000000)==0)) {\n\t if (!HandleZRLE24(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t } else if (!client->format.bigEndian && (maxColor&0xff)==0) {\n\t if (!HandleZRLE24Up(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t } else if (client->format.bigEndian && (maxColor&0xff000000)==0) {\n\t if (!HandleZRLE24Down(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t } else if (!HandleZRLE32(client, rect.r.x,rect.r.y,rect.r.w,rect.r.h))\n\t return FALSE;\n\t break;\n\t}\n\t}\n\tbreak;\n }",
"#endif",
" default:\n\t {\n\t rfbBool handled = FALSE;\n\t rfbClientProtocolExtension* e;",
"\t for(e = rfbClientExtensions; !handled && e; e = e->next)\n\t if(e->handleEncoding && e->handleEncoding(client, &rect))\n\t handled = TRUE;",
"\t if(!handled) {\n\t rfbClientLog(\"Unknown rect encoding %d\\n\",\n\t\t (int)rect.encoding);\n\t return FALSE;\n\t }\n\t }\n }",
" /* Now we may discard \"soft cursor locks\". */\n client->SoftCursorUnlockScreen(client);",
" client->GotFrameBufferUpdate(client, rect.r.x, rect.r.y, rect.r.w, rect.r.h);\n }",
" if (!SendIncrementalFramebufferUpdateRequest(client))\n return FALSE;",
" if (client->FinishedFrameBufferUpdate)\n client->FinishedFrameBufferUpdate(client);",
" break;\n }",
" case rfbBell:\n {\n client->Bell(client);",
" break;\n }",
" case rfbServerCutText:\n {\n char *buffer;",
" if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n\t\t\t sz_rfbServerCutTextMsg - 1))\n return FALSE;",
" msg.sct.length = rfbClientSwap32IfLE(msg.sct.length);",
" if (msg.sct.length > 1<<20) {\n\t rfbClientErr(\"Ignoring too big cut text length sent by server: %u B > 1 MB\\n\", (unsigned int)msg.sct.length);\n\t return FALSE;\n } ",
" buffer = malloc(msg.sct.length+1);",
" if (!ReadFromRFBServer(client, buffer, msg.sct.length)) {\n free(buffer);\n return FALSE;\n }",
" buffer[msg.sct.length] = 0;",
" if (client->GotXCutText)\n client->GotXCutText(client, buffer, msg.sct.length);",
" free(buffer);",
" break;\n }",
" case rfbTextChat:\n {\n char *buffer=NULL;\n if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n sz_rfbTextChatMsg- 1))\n return FALSE;\n msg.tc.length = rfbClientSwap32IfLE(msg.sct.length);\n switch(msg.tc.length) {\n case rfbTextChatOpen:\n rfbClientLog(\"Received TextChat Open\\n\");\n if (client->HandleTextChat!=NULL)\n client->HandleTextChat(client, (int)rfbTextChatOpen, NULL);\n break;\n case rfbTextChatClose:\n rfbClientLog(\"Received TextChat Close\\n\");\n if (client->HandleTextChat!=NULL)\n client->HandleTextChat(client, (int)rfbTextChatClose, NULL);\n break;\n case rfbTextChatFinished:\n rfbClientLog(\"Received TextChat Finished\\n\");\n if (client->HandleTextChat!=NULL)\n client->HandleTextChat(client, (int)rfbTextChatFinished, NULL);\n break;\n default:",
"\t if(msg.tc.length > MAX_TEXTCHAT_SIZE)\n\t return FALSE;",
" buffer=malloc(msg.tc.length+1);\n if (!ReadFromRFBServer(client, buffer, msg.tc.length))\n {\n free(buffer);\n return FALSE;\n }\n /* Null Terminate <just in case> */\n buffer[msg.tc.length]=0;\n rfbClientLog(\"Received TextChat \\\"%s\\\"\\n\", buffer);\n if (client->HandleTextChat!=NULL)\n client->HandleTextChat(client, (int)msg.tc.length, buffer);\n free(buffer);\n break;\n }\n break;\n }",
" case rfbXvp:\n {\n if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n sz_rfbXvpMsg -1))\n return FALSE;",
" SetClient2Server(client, rfbXvp);\n /* technically, we only care what we can *send* to the server\n * but, we set Server2Client Just in case it ever becomes useful\n */\n SetServer2Client(client, rfbXvp);",
" if(client->HandleXvpMsg)\n client->HandleXvpMsg(client, msg.xvp.version, msg.xvp.code);",
" break;\n }",
" case rfbResizeFrameBuffer:\n {\n if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n sz_rfbResizeFrameBufferMsg -1))\n return FALSE;\n client->width = rfbClientSwap16IfLE(msg.rsfb.framebufferWidth);\n client->height = rfbClientSwap16IfLE(msg.rsfb.framebufferHeigth);\n client->updateRect.x = client->updateRect.y = 0;\n client->updateRect.w = client->width;\n client->updateRect.h = client->height;\n if (!client->MallocFrameBuffer(client))\n return FALSE;",
" SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE);\n rfbClientLog(\"Got new framebuffer size: %dx%d\\n\", client->width, client->height);\n break;\n }",
" case rfbPalmVNCReSizeFrameBuffer:\n {\n if (!ReadFromRFBServer(client, ((char *)&msg) + 1,\n sz_rfbPalmVNCReSizeFrameBufferMsg -1))\n return FALSE;\n client->width = rfbClientSwap16IfLE(msg.prsfb.buffer_w);\n client->height = rfbClientSwap16IfLE(msg.prsfb.buffer_h);\n client->updateRect.x = client->updateRect.y = 0;\n client->updateRect.w = client->width;\n client->updateRect.h = client->height;\n if (!client->MallocFrameBuffer(client))\n return FALSE;\n SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE);\n rfbClientLog(\"Got new framebuffer size: %dx%d\\n\", client->width, client->height);\n break;\n }",
" default:\n {\n rfbBool handled = FALSE;\n rfbClientProtocolExtension* e;",
" for(e = rfbClientExtensions; !handled && e; e = e->next)\n\tif(e->handleMessage && e->handleMessage(client, &msg))\n\t handled = TRUE;",
" if(!handled) {\n\tchar buffer[256];\n\trfbClientLog(\"Unknown message type %d from VNC server\\n\",msg.type);\n\tReadFromRFBServer(client, buffer, 256);\n\treturn FALSE;\n }\n }\n }",
" return TRUE;\n}",
"\n#define GET_PIXEL8(pix, ptr) ((pix) = *(ptr)++)",
"#define GET_PIXEL16(pix, ptr) (((uint8_t*)&(pix))[0] = *(ptr)++, \\\n\t\t\t ((uint8_t*)&(pix))[1] = *(ptr)++)",
"#define GET_PIXEL32(pix, ptr) (((uint8_t*)&(pix))[0] = *(ptr)++, \\\n\t\t\t ((uint8_t*)&(pix))[1] = *(ptr)++, \\\n\t\t\t ((uint8_t*)&(pix))[2] = *(ptr)++, \\\n\t\t\t ((uint8_t*)&(pix))[3] = *(ptr)++)",
"/* CONCAT2 concatenates its two arguments. CONCAT2E does the same but also\n expands its arguments if they are macros */",
"#define CONCAT2(a,b) a##b\n#define CONCAT2E(a,b) CONCAT2(a,b)\n#define CONCAT3(a,b,c) a##b##c\n#define CONCAT3E(a,b,c) CONCAT3(a,b,c)",
"#define BPP 8\n#include \"rre.c\"\n#include \"corre.c\"\n#include \"hextile.c\"\n#include \"ultra.c\"\n#include \"zlib.c\"\n#include \"tight.c\"\n#include \"trle.c\"\n#include \"zrle.c\"\n#undef BPP\n#define BPP 16\n#include \"rre.c\"\n#include \"corre.c\"\n#include \"hextile.c\"\n#include \"ultra.c\"\n#include \"zlib.c\"\n#include \"tight.c\"\n#include \"trle.c\"\n#include \"zrle.c\"\n#define REALBPP 15\n#include \"trle.c\"\n#define REALBPP 15\n#include \"zrle.c\"\n#undef BPP\n#define BPP 32\n#include \"rre.c\"\n#include \"corre.c\"\n#include \"hextile.c\"\n#include \"ultra.c\"\n#include \"zlib.c\"\n#include \"tight.c\"\n#include \"trle.c\"\n#include \"zrle.c\"\n#define REALBPP 24\n#include \"trle.c\"\n#define REALBPP 24\n#include \"zrle.c\"\n#define REALBPP 24\n#define UNCOMP 8\n#include \"trle.c\"\n#define REALBPP 24\n#define UNCOMP 8\n#include \"zrle.c\"\n#define REALBPP 24\n#define UNCOMP -8\n#include \"trle.c\"\n#define REALBPP 24\n#define UNCOMP -8\n#include \"zrle.c\"\n#undef BPP",
"\n/*\n * PrintPixelFormat.\n */",
"void\nPrintPixelFormat(rfbPixelFormat *format)\n{\n if (format->bitsPerPixel == 1) {\n rfbClientLog(\" Single bit per pixel.\\n\");\n rfbClientLog(\n\t \" %s significant bit in each byte is leftmost on the screen.\\n\",\n\t (format->bigEndian ? \"Most\" : \"Least\"));\n } else {\n rfbClientLog(\" %d bits per pixel.\\n\",format->bitsPerPixel);\n if (format->bitsPerPixel != 8) {\n rfbClientLog(\" %s significant byte first in each pixel.\\n\",\n\t (format->bigEndian ? \"Most\" : \"Least\"));\n }\n if (format->trueColour) {\n rfbClientLog(\" TRUE colour: max red %d green %d blue %d\"\n\t\t \", shift red %d green %d blue %d\\n\",\n\t\t format->redMax, format->greenMax, format->blueMax,\n\t\t format->redShift, format->greenShift, format->blueShift);\n } else {\n rfbClientLog(\" Colour map (not true colour).\\n\");\n }\n }\n}",
"/* avoid name clashes with LibVNCServer */",
"#define rfbEncryptBytes rfbClientEncryptBytes\n#define rfbEncryptBytes2 rfbClientEncryptBytes2\n#define rfbDes rfbClientDes\n#define rfbDesKey rfbClientDesKey\n#define rfbUseKey rfbClientUseKey",
"#include \"vncauth.c\""
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [2161], "buggy_code_start_loc": [67], "filenames": ["libvncclient/rfbproto.c"], "fixing_code_end_loc": [2165], "fixing_code_start_loc": [68], "message": "An issue was discovered in LibVNCServer before 0.9.13. libvncclient/rfbproto.c does not limit TextChat size.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:libvnc_project:libvncserver:*:*:*:*:*:*:*:*", "matchCriteriaId": "DEF1BF44-78B8-44E3-9A5A-29AB8111322B", "versionEndExcluding": "0.9.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:canonical:ubuntu_linux:14.04:*:*:*:lts:*:*:*", "matchCriteriaId": "B5A6F2F3-4894-4392-8296-3B8DD2679084", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:esm:*:*:*", "matchCriteriaId": "7A5301BF-1402-4BE0-A0F8-69FBE79BC6D6", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*", "matchCriteriaId": "F7016A2A-8365-4F1A-89A2-7A19F2BCAE5B", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*", "matchCriteriaId": "23A7C53F-B80F-4E6A-AFA9-58EEA84BE11D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:canonical:ubuntu_linux:18.10:*:*:*:*:*:*:*", "matchCriteriaId": "07C312A0-CD2C-4B9C-B064-6409B25C278F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:debian:debian_linux:8.0:*:*:*:*:*:*:*", "matchCriteriaId": "C11E6FB0-C8C0-4527-9AA0-CB9B316F8F43", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*", "matchCriteriaId": "DEECE5FC-CACF-4496-A3E7-164736409252", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc1500_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "3A664216-EEA0-423F-8E11-59C746FDEEFE", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc1500:-:*:*:*:*:*:*:*", "matchCriteriaId": "9596C8CD-B03F-4E9D-82AB-0986FDD1B47C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc1500_pro_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "CD78291E-48D8-4718-AE14-BDF93BD557D7", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc1500_pro:-:*:*:*:*:*:*:*", "matchCriteriaId": "5BB898D3-07A3-42A1-8F1B-53C3B005982D", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc1900_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "AD1209DE-2724-493D-8276-1BE959BFE6BF", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc1900:-:*:*:*:*:*:*:*", "matchCriteriaId": "6A9143A6-A93A-45CA-8A1F-6EE30647B54A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc1900_pro_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "92F7FC17-F19F-4BD6-9704-49B67D22B532", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc1900_pro:-:*:*:*:*:*:*:*", "matchCriteriaId": "3D34BD13-4E71-48A2-851D-AE7CE2A03C28", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc2200_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "FE4A6F13-385B-4A13-B8D8-3BBC4E9D5B67", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc2200:-:*:*:*:*:*:*:*", "matchCriteriaId": "3E63E423-7450-4043-B33B-3FFF5BBE1CB2", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:siemens:simatic_itc2200_pro_firmware:*:*:*:*:*:*:*:*", "matchCriteriaId": "71A51CA4-1A62-47BC-99A3-4DC9F3986FF5", "versionEndExcluding": "3.2.1.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.0.0.0", "vulnerable": true}], "negate": false, "operator": "OR"}, {"cpeMatch": [{"criteria": "cpe:2.3:h:siemens:simatic_itc2200_pro:-:*:*:*:*:*:*:*", "matchCriteriaId": "CD278558-AB0E-4FC1-9E5B-6B57D29CB86A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": false}], "negate": false, "operator": "OR"}], "operator": "AND"}], "descriptions": [{"lang": "en", "value": "An issue was discovered in LibVNCServer before 0.9.13. libvncclient/rfbproto.c does not limit TextChat size."}, {"lang": "es", "value": "Se detect\u00f3 un problema en LibVNCServer versiones anteriores a 0.9.13. La biblioteca libvncclient/rfbproto.c no limita el tama\u00f1o de TextChat"}], "evaluatorComment": null, "id": "CVE-2020-14405", "lastModified": "2022-03-09T22:18:37.957", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "PARTIAL", "baseScore": 4.0, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:N/AC:L/Au:S/C:N/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2020-06-17T16:15:12.337", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://cert-portal.siemens.com/productcert/pdf/ssa-390195.pdf"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/LibVNC/libvncserver/commit/8937203441ee241c4ace85da687b7d6633a12365"}, {"source": "cve@mitre.org", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/LibVNC/libvncserver/compare/LibVNCServer-0.9.12...LibVNCServer-0.9.13"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2020/06/msg00035.html"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2020/08/msg00045.html"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://usn.ubuntu.com/4434-1/"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-770"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/LibVNC/libvncserver/commit/8937203441ee241c4ace85da687b7d6633a12365"}, "type": "CWE-770"}
| 361
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * FarSync WAN driver for Linux (2.6.x kernel version)\n *\n * Actually sync driver for X.21, V.35 and V.24 on FarSync T-series cards\n *\n * Copyright (C) 2001-2004 FarSite Communications Ltd.\n * www.farsite.co.uk\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License\n * as published by the Free Software Foundation; either version\n * 2 of the License, or (at your option) any later version.\n *\n * Author: R.J.Dunlop <bob.dunlop@farsite.co.uk>\n * Maintainer: Kevin Curtis <kevin.curtis@farsite.co.uk>\n */",
"#define pr_fmt(fmt) KBUILD_MODNAME \": \" fmt",
"#include <linux/module.h>\n#include <linux/kernel.h>\n#include <linux/version.h>\n#include <linux/pci.h>\n#include <linux/sched.h>\n#include <linux/slab.h>\n#include <linux/ioport.h>\n#include <linux/init.h>\n#include <linux/interrupt.h>\n#include <linux/if.h>\n#include <linux/hdlc.h>\n#include <asm/io.h>\n#include <asm/uaccess.h>",
"#include \"farsync.h\"",
"/*\n * Module info\n */\nMODULE_AUTHOR(\"R.J.Dunlop <bob.dunlop@farsite.co.uk>\");\nMODULE_DESCRIPTION(\"FarSync T-Series WAN driver. FarSite Communications Ltd.\");\nMODULE_LICENSE(\"GPL\");",
"/* Driver configuration and global parameters\n * ==========================================\n */",
"/* Number of ports (per card) and cards supported\n */\n#define FST_MAX_PORTS 4\n#define FST_MAX_CARDS 32",
"/* Default parameters for the link\n */\n#define FST_TX_QUEUE_LEN 100\t/* At 8Mbps a longer queue length is\n\t\t\t\t\t * useful */\n#define FST_TXQ_DEPTH 16\t/* This one is for the buffering\n\t\t\t\t\t * of frames on the way down to the card\n\t\t\t\t\t * so that we can keep the card busy\n\t\t\t\t\t * and maximise throughput\n\t\t\t\t\t */\n#define FST_HIGH_WATER_MARK 12\t/* Point at which we flow control\n\t\t\t\t\t * network layer */\n#define FST_LOW_WATER_MARK 8\t/* Point at which we remove flow\n\t\t\t\t\t * control from network layer */\n#define FST_MAX_MTU 8000\t/* Huge but possible */\n#define FST_DEF_MTU 1500\t/* Common sane value */",
"#define FST_TX_TIMEOUT (2*HZ)",
"#ifdef ARPHRD_RAWHDLC\n#define ARPHRD_MYTYPE ARPHRD_RAWHDLC\t/* Raw frames */\n#else\n#define ARPHRD_MYTYPE ARPHRD_HDLC\t/* Cisco-HDLC (keepalives etc) */\n#endif",
"/*\n * Modules parameters and associated variables\n */\nstatic int fst_txq_low = FST_LOW_WATER_MARK;\nstatic int fst_txq_high = FST_HIGH_WATER_MARK;\nstatic int fst_max_reads = 7;\nstatic int fst_excluded_cards = 0;\nstatic int fst_excluded_list[FST_MAX_CARDS];",
"module_param(fst_txq_low, int, 0);\nmodule_param(fst_txq_high, int, 0);\nmodule_param(fst_max_reads, int, 0);\nmodule_param(fst_excluded_cards, int, 0);\nmodule_param_array(fst_excluded_list, int, NULL, 0);",
"/* Card shared memory layout\n * =========================\n */\n#pragma pack(1)",
"/* This information is derived in part from the FarSite FarSync Smc.h\n * file. Unfortunately various name clashes and the non-portability of the\n * bit field declarations in that file have meant that I have chosen to\n * recreate the information here.\n *\n * The SMC (Shared Memory Configuration) has a version number that is\n * incremented every time there is a significant change. This number can\n * be used to check that we have not got out of step with the firmware\n * contained in the .CDE files.\n */\n#define SMC_VERSION 24",
"#define FST_MEMSIZE 0x100000\t/* Size of card memory (1Mb) */",
"#define SMC_BASE 0x00002000L\t/* Base offset of the shared memory window main\n\t\t\t\t * configuration structure */\n#define BFM_BASE 0x00010000L\t/* Base offset of the shared memory window DMA\n\t\t\t\t * buffers */",
"#define LEN_TX_BUFFER 8192\t/* Size of packet buffers */\n#define LEN_RX_BUFFER 8192",
"#define LEN_SMALL_TX_BUFFER 256\t/* Size of obsolete buffs used for DOS diags */\n#define LEN_SMALL_RX_BUFFER 256",
"#define NUM_TX_BUFFER 2\t\t/* Must be power of 2. Fixed by firmware */\n#define NUM_RX_BUFFER 8",
"/* Interrupt retry time in milliseconds */\n#define INT_RETRY_TIME 2",
"/* The Am186CH/CC processors support a SmartDMA mode using circular pools\n * of buffer descriptors. The structure is almost identical to that used\n * in the LANCE Ethernet controllers. Details available as PDF from the\n * AMD web site: http://www.amd.com/products/epd/processors/\\\n * 2.16bitcont/3.am186cxfa/a21914/21914.pdf\n */\nstruct txdesc {\t\t\t/* Transmit descriptor */\n\tvolatile u16 ladr;\t/* Low order address of packet. This is a\n\t\t\t\t * linear address in the Am186 memory space\n\t\t\t\t */\n\tvolatile u8 hadr;\t/* High order address. Low 4 bits only, high 4\n\t\t\t\t * bits must be zero\n\t\t\t\t */\n\tvolatile u8 bits;\t/* Status and config */\n\tvolatile u16 bcnt;\t/* 2s complement of packet size in low 15 bits.\n\t\t\t\t * Transmit terminal count interrupt enable in\n\t\t\t\t * top bit.\n\t\t\t\t */\n\tu16 unused;\t\t/* Not used in Tx */\n};",
"struct rxdesc {\t\t\t/* Receive descriptor */\n\tvolatile u16 ladr;\t/* Low order address of packet */\n\tvolatile u8 hadr;\t/* High order address */\n\tvolatile u8 bits;\t/* Status and config */\n\tvolatile u16 bcnt;\t/* 2s complement of buffer size in low 15 bits.\n\t\t\t\t * Receive terminal count interrupt enable in\n\t\t\t\t * top bit.\n\t\t\t\t */\n\tvolatile u16 mcnt;\t/* Message byte count (15 bits) */\n};",
"/* Convert a length into the 15 bit 2's complement */\n/* #define cnv_bcnt(len) (( ~(len) + 1 ) & 0x7FFF ) */\n/* Since we need to set the high bit to enable the completion interrupt this\n * can be made a lot simpler\n */\n#define cnv_bcnt(len) (-(len))",
"/* Status and config bits for the above */\n#define DMA_OWN 0x80\t/* SmartDMA owns the descriptor */\n#define TX_STP 0x02\t/* Tx: start of packet */\n#define TX_ENP 0x01\t/* Tx: end of packet */\n#define RX_ERR 0x40\t/* Rx: error (OR of next 4 bits) */\n#define RX_FRAM 0x20\t/* Rx: framing error */\n#define RX_OFLO 0x10\t/* Rx: overflow error */\n#define RX_CRC 0x08\t/* Rx: CRC error */\n#define RX_HBUF 0x04\t/* Rx: buffer error */\n#define RX_STP 0x02\t/* Rx: start of packet */\n#define RX_ENP 0x01\t/* Rx: end of packet */",
"/* Interrupts from the card are caused by various events which are presented\n * in a circular buffer as several events may be processed on one physical int\n */\n#define MAX_CIRBUFF 32",
"struct cirbuff {\n\tu8 rdindex;\t\t/* read, then increment and wrap */\n\tu8 wrindex;\t\t/* write, then increment and wrap */\n\tu8 evntbuff[MAX_CIRBUFF];\n};",
"/* Interrupt event codes.\n * Where appropriate the two low order bits indicate the port number\n */\n#define CTLA_CHG 0x18\t/* Control signal changed */\n#define CTLB_CHG 0x19\n#define CTLC_CHG 0x1A\n#define CTLD_CHG 0x1B",
"#define INIT_CPLT 0x20\t/* Initialisation complete */\n#define INIT_FAIL 0x21\t/* Initialisation failed */",
"#define ABTA_SENT 0x24\t/* Abort sent */\n#define ABTB_SENT 0x25\n#define ABTC_SENT 0x26\n#define ABTD_SENT 0x27",
"#define TXA_UNDF 0x28\t/* Transmission underflow */\n#define TXB_UNDF 0x29\n#define TXC_UNDF 0x2A\n#define TXD_UNDF 0x2B",
"#define F56_INT 0x2C\n#define M32_INT 0x2D",
"#define TE1_ALMA 0x30",
"/* Port physical configuration. See farsync.h for field values */\nstruct port_cfg {\n\tu16 lineInterface;\t/* Physical interface type */\n\tu8 x25op;\t\t/* Unused at present */\n\tu8 internalClock;\t/* 1 => internal clock, 0 => external */\n\tu8 transparentMode;\t/* 1 => on, 0 => off */\n\tu8 invertClock;\t\t/* 0 => normal, 1 => inverted */\n\tu8 padBytes[6];\t\t/* Padding */\n\tu32 lineSpeed;\t\t/* Speed in bps */\n};",
"/* TE1 port physical configuration */\nstruct su_config {\n\tu32 dataRate;\n\tu8 clocking;\n\tu8 framing;\n\tu8 structure;\n\tu8 interface;\n\tu8 coding;\n\tu8 lineBuildOut;\n\tu8 equalizer;\n\tu8 transparentMode;\n\tu8 loopMode;\n\tu8 range;\n\tu8 txBufferMode;\n\tu8 rxBufferMode;\n\tu8 startingSlot;\n\tu8 losThreshold;\n\tu8 enableIdleCode;\n\tu8 idleCode;\n\tu8 spare[44];\n};",
"/* TE1 Status */\nstruct su_status {\n\tu32 receiveBufferDelay;\n\tu32 framingErrorCount;\n\tu32 codeViolationCount;\n\tu32 crcErrorCount;\n\tu32 lineAttenuation;\n\tu8 portStarted;\n\tu8 lossOfSignal;\n\tu8 receiveRemoteAlarm;\n\tu8 alarmIndicationSignal;\n\tu8 spare[40];\n};",
"/* Finally sling all the above together into the shared memory structure.\n * Sorry it's a hodge podge of arrays, structures and unused bits, it's been\n * evolving under NT for some time so I guess we're stuck with it.\n * The structure starts at offset SMC_BASE.\n * See farsync.h for some field values.\n */\nstruct fst_shared {\n\t/* DMA descriptor rings */\n\tstruct rxdesc rxDescrRing[FST_MAX_PORTS][NUM_RX_BUFFER];\n\tstruct txdesc txDescrRing[FST_MAX_PORTS][NUM_TX_BUFFER];",
"\t/* Obsolete small buffers */\n\tu8 smallRxBuffer[FST_MAX_PORTS][NUM_RX_BUFFER][LEN_SMALL_RX_BUFFER];\n\tu8 smallTxBuffer[FST_MAX_PORTS][NUM_TX_BUFFER][LEN_SMALL_TX_BUFFER];",
"\tu8 taskStatus;\t\t/* 0x00 => initialising, 0x01 => running,\n\t\t\t\t * 0xFF => halted\n\t\t\t\t */",
"\tu8 interruptHandshake;\t/* Set to 0x01 by adapter to signal interrupt,\n\t\t\t\t * set to 0xEE by host to acknowledge interrupt\n\t\t\t\t */",
"\tu16 smcVersion;\t\t/* Must match SMC_VERSION */",
"\tu32 smcFirmwareVersion;\t/* 0xIIVVRRBB where II = product ID, VV = major\n\t\t\t\t * version, RR = revision and BB = build\n\t\t\t\t */",
"\tu16 txa_done;\t\t/* Obsolete completion flags */\n\tu16 rxa_done;\n\tu16 txb_done;\n\tu16 rxb_done;\n\tu16 txc_done;\n\tu16 rxc_done;\n\tu16 txd_done;\n\tu16 rxd_done;",
"\tu16 mailbox[4];\t\t/* Diagnostics mailbox. Not used */",
"\tstruct cirbuff interruptEvent;\t/* interrupt causes */",
"\tu32 v24IpSts[FST_MAX_PORTS];\t/* V.24 control input status */\n\tu32 v24OpSts[FST_MAX_PORTS];\t/* V.24 control output status */",
"\tstruct port_cfg portConfig[FST_MAX_PORTS];",
"\tu16 clockStatus[FST_MAX_PORTS];\t/* lsb: 0=> present, 1=> absent */",
"\tu16 cableStatus;\t/* lsb: 0=> present, 1=> absent */",
"\tu16 txDescrIndex[FST_MAX_PORTS];\t/* transmit descriptor ring index */\n\tu16 rxDescrIndex[FST_MAX_PORTS];\t/* receive descriptor ring index */",
"\tu16 portMailbox[FST_MAX_PORTS][2];\t/* command, modifier */\n\tu16 cardMailbox[4];\t/* Not used */",
"\t/* Number of times the card thinks the host has\n\t * missed an interrupt by not acknowledging\n\t * within 2mS (I guess NT has problems)\n\t */\n\tu32 interruptRetryCount;",
"\t/* Driver private data used as an ID. We'll not\n\t * use this as I'd rather keep such things\n\t * in main memory rather than on the PCI bus\n\t */\n\tu32 portHandle[FST_MAX_PORTS];",
"\t/* Count of Tx underflows for stats */\n\tu32 transmitBufferUnderflow[FST_MAX_PORTS];",
"\t/* Debounced V.24 control input status */\n\tu32 v24DebouncedSts[FST_MAX_PORTS];",
"\t/* Adapter debounce timers. Don't touch */\n\tu32 ctsTimer[FST_MAX_PORTS];\n\tu32 ctsTimerRun[FST_MAX_PORTS];\n\tu32 dcdTimer[FST_MAX_PORTS];\n\tu32 dcdTimerRun[FST_MAX_PORTS];",
"\tu32 numberOfPorts;\t/* Number of ports detected at startup */",
"\tu16 _reserved[64];",
"\tu16 cardMode;\t\t/* Bit-mask to enable features:\n\t\t\t\t * Bit 0: 1 enables LED identify mode\n\t\t\t\t */",
"\tu16 portScheduleOffset;",
"\tstruct su_config suConfig;\t/* TE1 Bits */\n\tstruct su_status suStatus;",
"\tu32 endOfSmcSignature;\t/* endOfSmcSignature MUST be the last member of\n\t\t\t\t * the structure and marks the end of shared\n\t\t\t\t * memory. Adapter code initializes it as\n\t\t\t\t * END_SIG.\n\t\t\t\t */\n};",
"/* endOfSmcSignature value */\n#define END_SIG 0x12345678",
"/* Mailbox values. (portMailbox) */\n#define NOP 0\t/* No operation */\n#define ACK 1\t/* Positive acknowledgement to PC driver */\n#define NAK 2\t/* Negative acknowledgement to PC driver */\n#define STARTPORT 3\t/* Start an HDLC port */\n#define STOPPORT 4\t/* Stop an HDLC port */\n#define ABORTTX 5\t/* Abort the transmitter for a port */\n#define SETV24O 6\t/* Set V24 outputs */",
"/* PLX Chip Register Offsets */\n#define CNTRL_9052 0x50\t/* Control Register */\n#define CNTRL_9054 0x6c\t/* Control Register */",
"#define INTCSR_9052 0x4c\t/* Interrupt control/status register */\n#define INTCSR_9054 0x68\t/* Interrupt control/status register */",
"/* 9054 DMA Registers */\n/*\n * Note that we will be using DMA Channel 0 for copying rx data\n * and Channel 1 for copying tx data\n */\n#define DMAMODE0 0x80\n#define DMAPADR0 0x84\n#define DMALADR0 0x88\n#define DMASIZ0 0x8c\n#define DMADPR0 0x90\n#define DMAMODE1 0x94\n#define DMAPADR1 0x98\n#define DMALADR1 0x9c\n#define DMASIZ1 0xa0\n#define DMADPR1 0xa4\n#define DMACSR0 0xa8\n#define DMACSR1 0xa9\n#define DMAARB 0xac\n#define DMATHR 0xb0\n#define DMADAC0 0xb4\n#define DMADAC1 0xb8\n#define DMAMARBR 0xac",
"#define FST_MIN_DMA_LEN 64\n#define FST_RX_DMA_INT 0x01\n#define FST_TX_DMA_INT 0x02\n#define FST_CARD_INT 0x04",
"/* Larger buffers are positioned in memory at offset BFM_BASE */\nstruct buf_window {\n\tu8 txBuffer[FST_MAX_PORTS][NUM_TX_BUFFER][LEN_TX_BUFFER];\n\tu8 rxBuffer[FST_MAX_PORTS][NUM_RX_BUFFER][LEN_RX_BUFFER];\n};",
"/* Calculate offset of a buffer object within the shared memory window */\n#define BUF_OFFSET(X) (BFM_BASE + offsetof(struct buf_window, X))",
"#pragma pack()",
"/* Device driver private information\n * =================================\n */\n/* Per port (line or channel) information\n */\nstruct fst_port_info {\n struct net_device *dev; /* Device struct - must be first */\n\tstruct fst_card_info *card;\t/* Card we're associated with */\n\tint index;\t\t/* Port index on the card */\n\tint hwif;\t\t/* Line hardware (lineInterface copy) */\n\tint run;\t\t/* Port is running */\n\tint mode;\t\t/* Normal or FarSync raw */\n\tint rxpos;\t\t/* Next Rx buffer to use */\n\tint txpos;\t\t/* Next Tx buffer to use */\n\tint txipos;\t\t/* Next Tx buffer to check for free */\n\tint start;\t\t/* Indication of start/stop to network */\n\t/*\n\t * A sixteen entry transmit queue\n\t */\n\tint txqs;\t\t/* index to get next buffer to tx */\n\tint txqe;\t\t/* index to queue next packet */\n\tstruct sk_buff *txq[FST_TXQ_DEPTH];\t/* The queue */\n\tint rxqdepth;\n};",
"/* Per card information\n */\nstruct fst_card_info {\n\tchar __iomem *mem;\t/* Card memory mapped to kernel space */\n\tchar __iomem *ctlmem;\t/* Control memory for PCI cards */\n\tunsigned int phys_mem;\t/* Physical memory window address */\n\tunsigned int phys_ctlmem;\t/* Physical control memory address */\n\tunsigned int irq;\t/* Interrupt request line number */\n\tunsigned int nports;\t/* Number of serial ports */\n\tunsigned int type;\t/* Type index of card */\n\tunsigned int state;\t/* State of card */\n\tspinlock_t card_lock;\t/* Lock for SMP access */\n\tunsigned short pci_conf;\t/* PCI card config in I/O space */\n\t/* Per port info */\n\tstruct fst_port_info ports[FST_MAX_PORTS];\n\tstruct pci_dev *device;\t/* Information about the pci device */\n\tint card_no;\t\t/* Inst of the card on the system */\n\tint family;\t\t/* TxP or TxU */\n\tint dmarx_in_progress;\n\tint dmatx_in_progress;\n\tunsigned long int_count;\n\tunsigned long int_time_ave;\n\tvoid *rx_dma_handle_host;\n\tdma_addr_t rx_dma_handle_card;\n\tvoid *tx_dma_handle_host;\n\tdma_addr_t tx_dma_handle_card;\n\tstruct sk_buff *dma_skb_rx;\n\tstruct fst_port_info *dma_port_rx;\n\tstruct fst_port_info *dma_port_tx;\n\tint dma_len_rx;\n\tint dma_len_tx;\n\tint dma_txpos;\n\tint dma_rxpos;\n};",
"/* Convert an HDLC device pointer into a port info pointer and similar */\n#define dev_to_port(D) (dev_to_hdlc(D)->priv)\n#define port_to_dev(P) ((P)->dev)",
"\n/*\n * Shared memory window access macros\n *\n * We have a nice memory based structure above, which could be directly\n * mapped on i386 but might not work on other architectures unless we use\n * the readb,w,l and writeb,w,l macros. Unfortunately these macros take\n * physical offsets so we have to convert. The only saving grace is that\n * this should all collapse back to a simple indirection eventually.\n */\n#define WIN_OFFSET(X) ((long)&(((struct fst_shared *)SMC_BASE)->X))",
"#define FST_RDB(C,E) readb ((C)->mem + WIN_OFFSET(E))\n#define FST_RDW(C,E) readw ((C)->mem + WIN_OFFSET(E))\n#define FST_RDL(C,E) readl ((C)->mem + WIN_OFFSET(E))",
"#define FST_WRB(C,E,B) writeb ((B), (C)->mem + WIN_OFFSET(E))\n#define FST_WRW(C,E,W) writew ((W), (C)->mem + WIN_OFFSET(E))\n#define FST_WRL(C,E,L) writel ((L), (C)->mem + WIN_OFFSET(E))",
"/*\n * Debug support\n */\n#if FST_DEBUG",
"static int fst_debug_mask = { FST_DEBUG };",
"/* Most common debug activity is to print something if the corresponding bit\n * is set in the debug mask. Note: this uses a non-ANSI extension in GCC to\n * support variable numbers of macro parameters. The inverted if prevents us\n * eating someone else's else clause.\n */\n#define dbg(F, fmt, args...)\t\t\t\t\t\\\ndo {\t\t\t\t\t\t\t\t\\\n\tif (fst_debug_mask & (F))\t\t\t\t\\\n\t\tprintk(KERN_DEBUG pr_fmt(fmt), ##args);\t\t\\\n} while (0)\n#else\n#define dbg(F, fmt, args...)\t\t\t\t\t\\\ndo {\t\t\t\t\t\t\t\t\\\n\tif (0)\t\t\t\t\t\t\t\\\n\t\tprintk(KERN_DEBUG pr_fmt(fmt), ##args);\t\t\\\n} while (0)\n#endif",
"/*\n * PCI ID lookup table\n */\nstatic DEFINE_PCI_DEVICE_TABLE(fst_pci_dev_id) = {\n\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T2P, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_T2P},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T4P, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_T4P},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T1U, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_T1U},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T2U, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_T2U},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T4U, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_T4U},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_TE1, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_TE1},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_TE1C, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_TE1},\n\t{0,}\t\t\t/* End */\n};",
"MODULE_DEVICE_TABLE(pci, fst_pci_dev_id);",
"/*\n * Device Driver Work Queues\n *\n * So that we don't spend too much time processing events in the \n * Interrupt Service routine, we will declare a work queue per Card \n * and make the ISR schedule a task in the queue for later execution.\n * In the 2.4 Kernel we used to use the immediate queue for BH's\n * Now that they are gone, tasklets seem to be much better than work \n * queues.\n */",
"static void do_bottom_half_tx(struct fst_card_info *card);\nstatic void do_bottom_half_rx(struct fst_card_info *card);\nstatic void fst_process_tx_work_q(unsigned long work_q);\nstatic void fst_process_int_work_q(unsigned long work_q);",
"static DECLARE_TASKLET(fst_tx_task, fst_process_tx_work_q, 0);\nstatic DECLARE_TASKLET(fst_int_task, fst_process_int_work_q, 0);",
"static struct fst_card_info *fst_card_array[FST_MAX_CARDS];\nstatic spinlock_t fst_work_q_lock;\nstatic u64 fst_work_txq;\nstatic u64 fst_work_intq;",
"static void\nfst_q_work_item(u64 * queue, int card_index)\n{\n\tunsigned long flags;\n\tu64 mask;",
"\t/*\n\t * Grab the queue exclusively\n\t */\n\tspin_lock_irqsave(&fst_work_q_lock, flags);",
"\t/*\n\t * Making an entry in the queue is simply a matter of setting\n\t * a bit for the card indicating that there is work to do in the\n\t * bottom half for the card. Note the limitation of 64 cards.\n\t * That ought to be enough\n\t */\n\tmask = (u64)1 << card_index;\n\t*queue |= mask;\n\tspin_unlock_irqrestore(&fst_work_q_lock, flags);\n}",
"static void\nfst_process_tx_work_q(unsigned long /*void **/work_q)\n{\n\tunsigned long flags;\n\tu64 work_txq;\n\tint i;",
"\t/*\n\t * Grab the queue exclusively\n\t */\n\tdbg(DBG_TX, \"fst_process_tx_work_q\\n\");\n\tspin_lock_irqsave(&fst_work_q_lock, flags);\n\twork_txq = fst_work_txq;\n\tfst_work_txq = 0;\n\tspin_unlock_irqrestore(&fst_work_q_lock, flags);",
"\t/*\n\t * Call the bottom half for each card with work waiting\n\t */\n\tfor (i = 0; i < FST_MAX_CARDS; i++) {\n\t\tif (work_txq & 0x01) {\n\t\t\tif (fst_card_array[i] != NULL) {\n\t\t\t\tdbg(DBG_TX, \"Calling tx bh for card %d\\n\", i);\n\t\t\t\tdo_bottom_half_tx(fst_card_array[i]);\n\t\t\t}\n\t\t}\n\t\twork_txq = work_txq >> 1;\n\t}\n}",
"static void\nfst_process_int_work_q(unsigned long /*void **/work_q)\n{\n\tunsigned long flags;\n\tu64 work_intq;\n\tint i;",
"\t/*\n\t * Grab the queue exclusively\n\t */\n\tdbg(DBG_INTR, \"fst_process_int_work_q\\n\");\n\tspin_lock_irqsave(&fst_work_q_lock, flags);\n\twork_intq = fst_work_intq;\n\tfst_work_intq = 0;\n\tspin_unlock_irqrestore(&fst_work_q_lock, flags);",
"\t/*\n\t * Call the bottom half for each card with work waiting\n\t */\n\tfor (i = 0; i < FST_MAX_CARDS; i++) {\n\t\tif (work_intq & 0x01) {\n\t\t\tif (fst_card_array[i] != NULL) {\n\t\t\t\tdbg(DBG_INTR,\n\t\t\t\t \"Calling rx & tx bh for card %d\\n\", i);\n\t\t\t\tdo_bottom_half_rx(fst_card_array[i]);\n\t\t\t\tdo_bottom_half_tx(fst_card_array[i]);\n\t\t\t}\n\t\t}\n\t\twork_intq = work_intq >> 1;\n\t}\n}",
"/* Card control functions\n * ======================\n */\n/* Place the processor in reset state\n *\n * Used to be a simple write to card control space but a glitch in the latest\n * AMD Am186CH processor means that we now have to do it by asserting and de-\n * asserting the PLX chip PCI Adapter Software Reset. Bit 30 in CNTRL register\n * at offset 9052_CNTRL. Note the updates for the TXU.\n */\nstatic inline void\nfst_cpureset(struct fst_card_info *card)\n{\n\tunsigned char interrupt_line_register;\n\tunsigned long j = jiffies + 1;\n\tunsigned int regval;",
"\tif (card->family == FST_FAMILY_TXU) {\n\t\tif (pci_read_config_byte\n\t\t (card->device, PCI_INTERRUPT_LINE, &interrupt_line_register)) {\n\t\t\tdbg(DBG_ASS,\n\t\t\t \"Error in reading interrupt line register\\n\");\n\t\t}\n\t\t/*\n\t\t * Assert PLX software reset and Am186 hardware reset\n\t\t * and then deassert the PLX software reset but 186 still in reset\n\t\t */\n\t\toutw(0x440f, card->pci_conf + CNTRL_9054 + 2);\n\t\toutw(0x040f, card->pci_conf + CNTRL_9054 + 2);\n\t\t/*\n\t\t * We are delaying here to allow the 9054 to reset itself\n\t\t */\n\t\tj = jiffies + 1;\n\t\twhile (jiffies < j)\n\t\t\t/* Do nothing */ ;\n\t\toutw(0x240f, card->pci_conf + CNTRL_9054 + 2);\n\t\t/*\n\t\t * We are delaying here to allow the 9054 to reload its eeprom\n\t\t */\n\t\tj = jiffies + 1;\n\t\twhile (jiffies < j)\n\t\t\t/* Do nothing */ ;\n\t\toutw(0x040f, card->pci_conf + CNTRL_9054 + 2);",
"\t\tif (pci_write_config_byte\n\t\t (card->device, PCI_INTERRUPT_LINE, interrupt_line_register)) {\n\t\t\tdbg(DBG_ASS,\n\t\t\t \"Error in writing interrupt line register\\n\");\n\t\t}",
"\t} else {\n\t\tregval = inl(card->pci_conf + CNTRL_9052);",
"\t\toutl(regval | 0x40000000, card->pci_conf + CNTRL_9052);\n\t\toutl(regval & ~0x40000000, card->pci_conf + CNTRL_9052);\n\t}\n}",
"/* Release the processor from reset\n */\nstatic inline void\nfst_cpurelease(struct fst_card_info *card)\n{\n\tif (card->family == FST_FAMILY_TXU) {\n\t\t/*\n\t\t * Force posted writes to complete\n\t\t */\n\t\t(void) readb(card->mem);",
"\t\t/*\n\t\t * Release LRESET DO = 1\n\t\t * Then release Local Hold, DO = 1\n\t\t */\n\t\toutw(0x040e, card->pci_conf + CNTRL_9054 + 2);\n\t\toutw(0x040f, card->pci_conf + CNTRL_9054 + 2);\n\t} else {\n\t\t(void) readb(card->ctlmem);\n\t}\n}",
"/* Clear the cards interrupt flag\n */\nstatic inline void\nfst_clear_intr(struct fst_card_info *card)\n{\n\tif (card->family == FST_FAMILY_TXU) {\n\t\t(void) readb(card->ctlmem);\n\t} else {\n\t\t/* Poke the appropriate PLX chip register (same as enabling interrupts)\n\t\t */\n\t\toutw(0x0543, card->pci_conf + INTCSR_9052);\n\t}\n}",
"/* Enable card interrupts\n */\nstatic inline void\nfst_enable_intr(struct fst_card_info *card)\n{\n\tif (card->family == FST_FAMILY_TXU) {\n\t\toutl(0x0f0c0900, card->pci_conf + INTCSR_9054);\n\t} else {\n\t\toutw(0x0543, card->pci_conf + INTCSR_9052);\n\t}\n}",
"/* Disable card interrupts\n */\nstatic inline void\nfst_disable_intr(struct fst_card_info *card)\n{\n\tif (card->family == FST_FAMILY_TXU) {\n\t\toutl(0x00000000, card->pci_conf + INTCSR_9054);\n\t} else {\n\t\toutw(0x0000, card->pci_conf + INTCSR_9052);\n\t}\n}",
"/* Process the result of trying to pass a received frame up the stack\n */\nstatic void\nfst_process_rx_status(int rx_status, char *name)\n{\n\tswitch (rx_status) {\n\tcase NET_RX_SUCCESS:\n\t\t{\n\t\t\t/*\n\t\t\t * Nothing to do here\n\t\t\t */\n\t\t\tbreak;\n\t\t}\n\tcase NET_RX_DROP:\n\t\t{\n\t\t\tdbg(DBG_ASS, \"%s: Received packet dropped\\n\", name);\n\t\t\tbreak;\n\t\t}\n\t}\n}",
"/* Initilaise DMA for PLX 9054\n */\nstatic inline void\nfst_init_dma(struct fst_card_info *card)\n{\n\t/*\n\t * This is only required for the PLX 9054\n\t */\n\tif (card->family == FST_FAMILY_TXU) {\n\t pci_set_master(card->device);\n\t\toutl(0x00020441, card->pci_conf + DMAMODE0);\n\t\toutl(0x00020441, card->pci_conf + DMAMODE1);\n\t\toutl(0x0, card->pci_conf + DMATHR);\n\t}\n}",
"/* Tx dma complete interrupt\n */\nstatic void\nfst_tx_dma_complete(struct fst_card_info *card, struct fst_port_info *port,\n\t\t int len, int txpos)\n{\n\tstruct net_device *dev = port_to_dev(port);",
"\t/*\n\t * Everything is now set, just tell the card to go\n\t */\n\tdbg(DBG_TX, \"fst_tx_dma_complete\\n\");\n\tFST_WRB(card, txDescrRing[port->index][txpos].bits,\n\t\tDMA_OWN | TX_STP | TX_ENP);\n\tdev->stats.tx_packets++;\n\tdev->stats.tx_bytes += len;\n\tdev->trans_start = jiffies;\n}",
"/*\n * Mark it for our own raw sockets interface\n */\nstatic __be16 farsync_type_trans(struct sk_buff *skb, struct net_device *dev)\n{\n\tskb->dev = dev;\n\tskb_reset_mac_header(skb);\n\tskb->pkt_type = PACKET_HOST;\n\treturn htons(ETH_P_CUST);\n}",
"/* Rx dma complete interrupt\n */\nstatic void\nfst_rx_dma_complete(struct fst_card_info *card, struct fst_port_info *port,\n\t\t int len, struct sk_buff *skb, int rxp)\n{\n\tstruct net_device *dev = port_to_dev(port);\n\tint pi;\n\tint rx_status;",
"\tdbg(DBG_TX, \"fst_rx_dma_complete\\n\");\n\tpi = port->index;\n\tmemcpy(skb_put(skb, len), card->rx_dma_handle_host, len);",
"\t/* Reset buffer descriptor */\n\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);",
"\t/* Update stats */\n\tdev->stats.rx_packets++;\n\tdev->stats.rx_bytes += len;",
"\t/* Push upstream */\n\tdbg(DBG_RX, \"Pushing the frame up the stack\\n\");\n\tif (port->mode == FST_RAW)\n\t\tskb->protocol = farsync_type_trans(skb, dev);\n\telse\n\t\tskb->protocol = hdlc_type_trans(skb, dev);\n\trx_status = netif_rx(skb);\n\tfst_process_rx_status(rx_status, port_to_dev(port)->name);\n\tif (rx_status == NET_RX_DROP)\n\t\tdev->stats.rx_dropped++;\n}",
"/*\n * Receive a frame through the DMA\n */\nstatic inline void\nfst_rx_dma(struct fst_card_info *card, dma_addr_t skb,\n\t dma_addr_t mem, int len)\n{\n\t/*\n\t * This routine will setup the DMA and start it\n\t */",
"\tdbg(DBG_RX, \"In fst_rx_dma %lx %lx %d\\n\",\n\t (unsigned long) skb, (unsigned long) mem, len);\n\tif (card->dmarx_in_progress) {\n\t\tdbg(DBG_ASS, \"In fst_rx_dma while dma in progress\\n\");\n\t}",
"\toutl(skb, card->pci_conf + DMAPADR0);\t/* Copy to here */\n\toutl(mem, card->pci_conf + DMALADR0);\t/* from here */\n\toutl(len, card->pci_conf + DMASIZ0);\t/* for this length */\n\toutl(0x00000000c, card->pci_conf + DMADPR0);\t/* In this direction */",
"\t/*\n\t * We use the dmarx_in_progress flag to flag the channel as busy\n\t */\n\tcard->dmarx_in_progress = 1;\n\toutb(0x03, card->pci_conf + DMACSR0);\t/* Start the transfer */\n}",
"/*\n * Send a frame through the DMA\n */\nstatic inline void\nfst_tx_dma(struct fst_card_info *card, unsigned char *skb,\n\t unsigned char *mem, int len)\n{\n\t/*\n\t * This routine will setup the DMA and start it.\n\t */",
"\tdbg(DBG_TX, \"In fst_tx_dma %p %p %d\\n\", skb, mem, len);\n\tif (card->dmatx_in_progress) {\n\t\tdbg(DBG_ASS, \"In fst_tx_dma while dma in progress\\n\");\n\t}",
"\toutl((unsigned long) skb, card->pci_conf + DMAPADR1);\t/* Copy from here */\n\toutl((unsigned long) mem, card->pci_conf + DMALADR1);\t/* to here */\n\toutl(len, card->pci_conf + DMASIZ1);\t/* for this length */\n\toutl(0x000000004, card->pci_conf + DMADPR1);\t/* In this direction */",
"\t/*\n\t * We use the dmatx_in_progress to flag the channel as busy\n\t */\n\tcard->dmatx_in_progress = 1;\n\toutb(0x03, card->pci_conf + DMACSR1);\t/* Start the transfer */\n}",
"/* Issue a Mailbox command for a port.\n * Note we issue them on a fire and forget basis, not expecting to see an\n * error and not waiting for completion.\n */\nstatic void\nfst_issue_cmd(struct fst_port_info *port, unsigned short cmd)\n{\n\tstruct fst_card_info *card;\n\tunsigned short mbval;\n\tunsigned long flags;\n\tint safety;",
"\tcard = port->card;\n\tspin_lock_irqsave(&card->card_lock, flags);\n\tmbval = FST_RDW(card, portMailbox[port->index][0]);",
"\tsafety = 0;\n\t/* Wait for any previous command to complete */\n\twhile (mbval > NAK) {\n\t\tspin_unlock_irqrestore(&card->card_lock, flags);\n\t\tschedule_timeout_uninterruptible(1);\n\t\tspin_lock_irqsave(&card->card_lock, flags);",
"\t\tif (++safety > 2000) {\n\t\t\tpr_err(\"Mailbox safety timeout\\n\");\n\t\t\tbreak;\n\t\t}",
"\t\tmbval = FST_RDW(card, portMailbox[port->index][0]);\n\t}\n\tif (safety > 0) {\n\t\tdbg(DBG_CMD, \"Mailbox clear after %d jiffies\\n\", safety);\n\t}\n\tif (mbval == NAK) {\n\t\tdbg(DBG_CMD, \"issue_cmd: previous command was NAK'd\\n\");\n\t}",
"\tFST_WRW(card, portMailbox[port->index][0], cmd);",
"\tif (cmd == ABORTTX || cmd == STARTPORT) {\n\t\tport->txpos = 0;\n\t\tport->txipos = 0;\n\t\tport->start = 0;\n\t}",
"\tspin_unlock_irqrestore(&card->card_lock, flags);\n}",
"/* Port output signals control\n */\nstatic inline void\nfst_op_raise(struct fst_port_info *port, unsigned int outputs)\n{\n\toutputs |= FST_RDL(port->card, v24OpSts[port->index]);\n\tFST_WRL(port->card, v24OpSts[port->index], outputs);",
"\tif (port->run)\n\t\tfst_issue_cmd(port, SETV24O);\n}",
"static inline void\nfst_op_lower(struct fst_port_info *port, unsigned int outputs)\n{\n\toutputs = ~outputs & FST_RDL(port->card, v24OpSts[port->index]);\n\tFST_WRL(port->card, v24OpSts[port->index], outputs);",
"\tif (port->run)\n\t\tfst_issue_cmd(port, SETV24O);\n}",
"/*\n * Setup port Rx buffers\n */\nstatic void\nfst_rx_config(struct fst_port_info *port)\n{\n\tint i;\n\tint pi;\n\tunsigned int offset;\n\tunsigned long flags;\n\tstruct fst_card_info *card;",
"\tpi = port->index;\n\tcard = port->card;\n\tspin_lock_irqsave(&card->card_lock, flags);\n\tfor (i = 0; i < NUM_RX_BUFFER; i++) {\n\t\toffset = BUF_OFFSET(rxBuffer[pi][i][0]);",
"\t\tFST_WRW(card, rxDescrRing[pi][i].ladr, (u16) offset);\n\t\tFST_WRB(card, rxDescrRing[pi][i].hadr, (u8) (offset >> 16));\n\t\tFST_WRW(card, rxDescrRing[pi][i].bcnt, cnv_bcnt(LEN_RX_BUFFER));\n\t\tFST_WRW(card, rxDescrRing[pi][i].mcnt, LEN_RX_BUFFER);\n\t\tFST_WRB(card, rxDescrRing[pi][i].bits, DMA_OWN);\n\t}\n\tport->rxpos = 0;\n\tspin_unlock_irqrestore(&card->card_lock, flags);\n}",
"/*\n * Setup port Tx buffers\n */\nstatic void\nfst_tx_config(struct fst_port_info *port)\n{\n\tint i;\n\tint pi;\n\tunsigned int offset;\n\tunsigned long flags;\n\tstruct fst_card_info *card;",
"\tpi = port->index;\n\tcard = port->card;\n\tspin_lock_irqsave(&card->card_lock, flags);\n\tfor (i = 0; i < NUM_TX_BUFFER; i++) {\n\t\toffset = BUF_OFFSET(txBuffer[pi][i][0]);",
"\t\tFST_WRW(card, txDescrRing[pi][i].ladr, (u16) offset);\n\t\tFST_WRB(card, txDescrRing[pi][i].hadr, (u8) (offset >> 16));\n\t\tFST_WRW(card, txDescrRing[pi][i].bcnt, 0);\n\t\tFST_WRB(card, txDescrRing[pi][i].bits, 0);\n\t}\n\tport->txpos = 0;\n\tport->txipos = 0;\n\tport->start = 0;\n\tspin_unlock_irqrestore(&card->card_lock, flags);\n}",
"/* TE1 Alarm change interrupt event\n */\nstatic void\nfst_intr_te1_alarm(struct fst_card_info *card, struct fst_port_info *port)\n{\n\tu8 los;\n\tu8 rra;\n\tu8 ais;",
"\tlos = FST_RDB(card, suStatus.lossOfSignal);\n\trra = FST_RDB(card, suStatus.receiveRemoteAlarm);\n\tais = FST_RDB(card, suStatus.alarmIndicationSignal);",
"\tif (los) {\n\t\t/*\n\t\t * Lost the link\n\t\t */\n\t\tif (netif_carrier_ok(port_to_dev(port))) {\n\t\t\tdbg(DBG_INTR, \"Net carrier off\\n\");\n\t\t\tnetif_carrier_off(port_to_dev(port));\n\t\t}\n\t} else {\n\t\t/*\n\t\t * Link available\n\t\t */\n\t\tif (!netif_carrier_ok(port_to_dev(port))) {\n\t\t\tdbg(DBG_INTR, \"Net carrier on\\n\");\n\t\t\tnetif_carrier_on(port_to_dev(port));\n\t\t}\n\t}",
"\tif (los)\n\t\tdbg(DBG_INTR, \"Assert LOS Alarm\\n\");\n\telse\n\t\tdbg(DBG_INTR, \"De-assert LOS Alarm\\n\");\n\tif (rra)\n\t\tdbg(DBG_INTR, \"Assert RRA Alarm\\n\");\n\telse\n\t\tdbg(DBG_INTR, \"De-assert RRA Alarm\\n\");",
"\tif (ais)\n\t\tdbg(DBG_INTR, \"Assert AIS Alarm\\n\");\n\telse\n\t\tdbg(DBG_INTR, \"De-assert AIS Alarm\\n\");\n}",
"/* Control signal change interrupt event\n */\nstatic void\nfst_intr_ctlchg(struct fst_card_info *card, struct fst_port_info *port)\n{\n\tint signals;",
"\tsignals = FST_RDL(card, v24DebouncedSts[port->index]);",
"\tif (signals & (((port->hwif == X21) || (port->hwif == X21D))\n\t\t ? IPSTS_INDICATE : IPSTS_DCD)) {\n\t\tif (!netif_carrier_ok(port_to_dev(port))) {\n\t\t\tdbg(DBG_INTR, \"DCD active\\n\");\n\t\t\tnetif_carrier_on(port_to_dev(port));\n\t\t}\n\t} else {\n\t\tif (netif_carrier_ok(port_to_dev(port))) {\n\t\t\tdbg(DBG_INTR, \"DCD lost\\n\");\n\t\t\tnetif_carrier_off(port_to_dev(port));\n\t\t}\n\t}\n}",
"/* Log Rx Errors\n */\nstatic void\nfst_log_rx_error(struct fst_card_info *card, struct fst_port_info *port,\n\t\t unsigned char dmabits, int rxp, unsigned short len)\n{\n\tstruct net_device *dev = port_to_dev(port);",
"\t/*\n\t * Increment the appropriate error counter\n\t */\n\tdev->stats.rx_errors++;\n\tif (dmabits & RX_OFLO) {\n\t\tdev->stats.rx_fifo_errors++;\n\t\tdbg(DBG_ASS, \"Rx fifo error on card %d port %d buffer %d\\n\",\n\t\t card->card_no, port->index, rxp);\n\t}\n\tif (dmabits & RX_CRC) {\n\t\tdev->stats.rx_crc_errors++;\n\t\tdbg(DBG_ASS, \"Rx crc error on card %d port %d\\n\",\n\t\t card->card_no, port->index);\n\t}\n\tif (dmabits & RX_FRAM) {\n\t\tdev->stats.rx_frame_errors++;\n\t\tdbg(DBG_ASS, \"Rx frame error on card %d port %d\\n\",\n\t\t card->card_no, port->index);\n\t}\n\tif (dmabits == (RX_STP | RX_ENP)) {\n\t\tdev->stats.rx_length_errors++;\n\t\tdbg(DBG_ASS, \"Rx length error (%d) on card %d port %d\\n\",\n\t\t len, card->card_no, port->index);\n\t}\n}",
"/* Rx Error Recovery\n */\nstatic void\nfst_recover_rx_error(struct fst_card_info *card, struct fst_port_info *port,\n\t\t unsigned char dmabits, int rxp, unsigned short len)\n{\n\tint i;\n\tint pi;",
"\tpi = port->index;\n\t/* \n\t * Discard buffer descriptors until we see the start of the\n\t * next frame. Note that for long frames this could be in\n\t * a subsequent interrupt. \n\t */\n\ti = 0;\n\twhile ((dmabits & (DMA_OWN | RX_STP)) == 0) {\n\t\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);\n\t\trxp = (rxp+1) % NUM_RX_BUFFER;\n\t\tif (++i > NUM_RX_BUFFER) {\n\t\t\tdbg(DBG_ASS, \"intr_rx: Discarding more bufs\"\n\t\t\t \" than we have\\n\");\n\t\t\tbreak;\n\t\t}\n\t\tdmabits = FST_RDB(card, rxDescrRing[pi][rxp].bits);\n\t\tdbg(DBG_ASS, \"DMA Bits of next buffer was %x\\n\", dmabits);\n\t}\n\tdbg(DBG_ASS, \"There were %d subsequent buffers in error\\n\", i);",
"\t/* Discard the terminal buffer */\n\tif (!(dmabits & DMA_OWN)) {\n\t\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);\n\t\trxp = (rxp+1) % NUM_RX_BUFFER;\n\t}\n\tport->rxpos = rxp;\n\treturn;",
"}",
"/* Rx complete interrupt\n */\nstatic void\nfst_intr_rx(struct fst_card_info *card, struct fst_port_info *port)\n{\n\tunsigned char dmabits;\n\tint pi;\n\tint rxp;\n\tint rx_status;\n\tunsigned short len;\n\tstruct sk_buff *skb;\n\tstruct net_device *dev = port_to_dev(port);",
"\t/* Check we have a buffer to process */\n\tpi = port->index;\n\trxp = port->rxpos;\n\tdmabits = FST_RDB(card, rxDescrRing[pi][rxp].bits);\n\tif (dmabits & DMA_OWN) {\n\t\tdbg(DBG_RX | DBG_INTR, \"intr_rx: No buffer port %d pos %d\\n\",\n\t\t pi, rxp);\n\t\treturn;\n\t}\n\tif (card->dmarx_in_progress) {\n\t\treturn;\n\t}",
"\t/* Get buffer length */\n\tlen = FST_RDW(card, rxDescrRing[pi][rxp].mcnt);\n\t/* Discard the CRC */\n\tlen -= 2;\n\tif (len == 0) {\n\t\t/*\n\t\t * This seems to happen on the TE1 interface sometimes\n\t\t * so throw the frame away and log the event.\n\t\t */\n\t\tpr_err(\"Frame received with 0 length. Card %d Port %d\\n\",\n\t\t card->card_no, port->index);\n\t\t/* Return descriptor to card */\n\t\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);",
"\t\trxp = (rxp+1) % NUM_RX_BUFFER;\n\t\tport->rxpos = rxp;\n\t\treturn;\n\t}",
"\t/* Check buffer length and for other errors. We insist on one packet\n\t * in one buffer. This simplifies things greatly and since we've\n\t * allocated 8K it shouldn't be a real world limitation\n\t */\n\tdbg(DBG_RX, \"intr_rx: %d,%d: flags %x len %d\\n\", pi, rxp, dmabits, len);\n\tif (dmabits != (RX_STP | RX_ENP) || len > LEN_RX_BUFFER - 2) {\n\t\tfst_log_rx_error(card, port, dmabits, rxp, len);\n\t\tfst_recover_rx_error(card, port, dmabits, rxp, len);\n\t\treturn;\n\t}",
"\t/* Allocate SKB */\n\tif ((skb = dev_alloc_skb(len)) == NULL) {\n\t\tdbg(DBG_RX, \"intr_rx: can't allocate buffer\\n\");",
"\t\tdev->stats.rx_dropped++;",
"\t\t/* Return descriptor to card */\n\t\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);",
"\t\trxp = (rxp+1) % NUM_RX_BUFFER;\n\t\tport->rxpos = rxp;\n\t\treturn;\n\t}",
"\t/*\n\t * We know the length we need to receive, len.\n\t * It's not worth using the DMA for reads of less than\n\t * FST_MIN_DMA_LEN\n\t */",
"\tif ((len < FST_MIN_DMA_LEN) || (card->family == FST_FAMILY_TXP)) {\n\t\tmemcpy_fromio(skb_put(skb, len),\n\t\t\t card->mem + BUF_OFFSET(rxBuffer[pi][rxp][0]),\n\t\t\t len);",
"\t\t/* Reset buffer descriptor */\n\t\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);",
"\t\t/* Update stats */\n\t\tdev->stats.rx_packets++;\n\t\tdev->stats.rx_bytes += len;",
"\t\t/* Push upstream */\n\t\tdbg(DBG_RX, \"Pushing frame up the stack\\n\");\n\t\tif (port->mode == FST_RAW)\n\t\t\tskb->protocol = farsync_type_trans(skb, dev);\n\t\telse\n\t\t\tskb->protocol = hdlc_type_trans(skb, dev);\n\t\trx_status = netif_rx(skb);\n\t\tfst_process_rx_status(rx_status, port_to_dev(port)->name);\n\t\tif (rx_status == NET_RX_DROP)\n\t\t\tdev->stats.rx_dropped++;\n\t} else {\n\t\tcard->dma_skb_rx = skb;\n\t\tcard->dma_port_rx = port;\n\t\tcard->dma_len_rx = len;\n\t\tcard->dma_rxpos = rxp;\n\t\tfst_rx_dma(card, card->rx_dma_handle_card,\n\t\t\t BUF_OFFSET(rxBuffer[pi][rxp][0]), len);\n\t}\n\tif (rxp != port->rxpos) {\n\t\tdbg(DBG_ASS, \"About to increment rxpos by more than 1\\n\");\n\t\tdbg(DBG_ASS, \"rxp = %d rxpos = %d\\n\", rxp, port->rxpos);\n\t}\n\trxp = (rxp+1) % NUM_RX_BUFFER;\n\tport->rxpos = rxp;\n}",
"/*\n * The bottom halfs to the ISR\n *\n */",
"static void\ndo_bottom_half_tx(struct fst_card_info *card)\n{\n\tstruct fst_port_info *port;\n\tint pi;\n\tint txq_length;\n\tstruct sk_buff *skb;\n\tunsigned long flags;\n\tstruct net_device *dev;",
"\t/*\n\t * Find a free buffer for the transmit\n\t * Step through each port on this card\n\t */",
"\tdbg(DBG_TX, \"do_bottom_half_tx\\n\");\n\tfor (pi = 0, port = card->ports; pi < card->nports; pi++, port++) {\n\t\tif (!port->run)\n\t\t\tcontinue;",
"\t\tdev = port_to_dev(port);\n\t\twhile (!(FST_RDB(card, txDescrRing[pi][port->txpos].bits) &\n\t\t\t DMA_OWN) &&\n\t\t !(card->dmatx_in_progress)) {\n\t\t\t/*\n\t\t\t * There doesn't seem to be a txdone event per-se\n\t\t\t * We seem to have to deduce it, by checking the DMA_OWN\n\t\t\t * bit on the next buffer we think we can use\n\t\t\t */\n\t\t\tspin_lock_irqsave(&card->card_lock, flags);\n\t\t\tif ((txq_length = port->txqe - port->txqs) < 0) {\n\t\t\t\t/*\n\t\t\t\t * This is the case where one has wrapped and the\n\t\t\t\t * maths gives us a negative number\n\t\t\t\t */\n\t\t\t\ttxq_length = txq_length + FST_TXQ_DEPTH;\n\t\t\t}\n\t\t\tspin_unlock_irqrestore(&card->card_lock, flags);\n\t\t\tif (txq_length > 0) {\n\t\t\t\t/*\n\t\t\t\t * There is something to send\n\t\t\t\t */\n\t\t\t\tspin_lock_irqsave(&card->card_lock, flags);\n\t\t\t\tskb = port->txq[port->txqs];\n\t\t\t\tport->txqs++;\n\t\t\t\tif (port->txqs == FST_TXQ_DEPTH) {\n\t\t\t\t\tport->txqs = 0;\n\t\t\t\t}\n\t\t\t\tspin_unlock_irqrestore(&card->card_lock, flags);\n\t\t\t\t/*\n\t\t\t\t * copy the data and set the required indicators on the\n\t\t\t\t * card.\n\t\t\t\t */\n\t\t\t\tFST_WRW(card, txDescrRing[pi][port->txpos].bcnt,\n\t\t\t\t\tcnv_bcnt(skb->len));\n\t\t\t\tif ((skb->len < FST_MIN_DMA_LEN) ||\n\t\t\t\t (card->family == FST_FAMILY_TXP)) {\n\t\t\t\t\t/* Enqueue the packet with normal io */\n\t\t\t\t\tmemcpy_toio(card->mem +\n\t\t\t\t\t\t BUF_OFFSET(txBuffer[pi]\n\t\t\t\t\t\t\t [port->\n\t\t\t\t\t\t\t\ttxpos][0]),\n\t\t\t\t\t\t skb->data, skb->len);\n\t\t\t\t\tFST_WRB(card,\n\t\t\t\t\t\ttxDescrRing[pi][port->txpos].\n\t\t\t\t\t\tbits,\n\t\t\t\t\t\tDMA_OWN | TX_STP | TX_ENP);\n\t\t\t\t\tdev->stats.tx_packets++;\n\t\t\t\t\tdev->stats.tx_bytes += skb->len;\n\t\t\t\t\tdev->trans_start = jiffies;\n\t\t\t\t} else {\n\t\t\t\t\t/* Or do it through dma */\n\t\t\t\t\tmemcpy(card->tx_dma_handle_host,\n\t\t\t\t\t skb->data, skb->len);\n\t\t\t\t\tcard->dma_port_tx = port;\n\t\t\t\t\tcard->dma_len_tx = skb->len;\n\t\t\t\t\tcard->dma_txpos = port->txpos;\n\t\t\t\t\tfst_tx_dma(card,\n\t\t\t\t\t\t (char *) card->\n\t\t\t\t\t\t tx_dma_handle_card,\n\t\t\t\t\t\t (char *)\n\t\t\t\t\t\t BUF_OFFSET(txBuffer[pi]\n\t\t\t\t\t\t\t [port->txpos][0]),\n\t\t\t\t\t\t skb->len);\n\t\t\t\t}\n\t\t\t\tif (++port->txpos >= NUM_TX_BUFFER)\n\t\t\t\t\tport->txpos = 0;\n\t\t\t\t/*\n\t\t\t\t * If we have flow control on, can we now release it?\n\t\t\t\t */\n\t\t\t\tif (port->start) {\n\t\t\t\t\tif (txq_length < fst_txq_low) {\n\t\t\t\t\t\tnetif_wake_queue(port_to_dev\n\t\t\t\t\t\t\t\t (port));\n\t\t\t\t\t\tport->start = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdev_kfree_skb(skb);\n\t\t\t} else {\n\t\t\t\t/*\n\t\t\t\t * Nothing to send so break out of the while loop\n\t\t\t\t */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}",
"static void\ndo_bottom_half_rx(struct fst_card_info *card)\n{\n\tstruct fst_port_info *port;\n\tint pi;\n\tint rx_count = 0;",
"\t/* Check for rx completions on all ports on this card */\n\tdbg(DBG_RX, \"do_bottom_half_rx\\n\");\n\tfor (pi = 0, port = card->ports; pi < card->nports; pi++, port++) {\n\t\tif (!port->run)\n\t\t\tcontinue;",
"\t\twhile (!(FST_RDB(card, rxDescrRing[pi][port->rxpos].bits)\n\t\t\t & DMA_OWN) && !(card->dmarx_in_progress)) {\n\t\t\tif (rx_count > fst_max_reads) {\n\t\t\t\t/*\n\t\t\t\t * Don't spend forever in receive processing\n\t\t\t\t * Schedule another event\n\t\t\t\t */\n\t\t\t\tfst_q_work_item(&fst_work_intq, card->card_no);\n\t\t\t\ttasklet_schedule(&fst_int_task);\n\t\t\t\tbreak;\t/* Leave the loop */\n\t\t\t}\n\t\t\tfst_intr_rx(card, port);\n\t\t\trx_count++;\n\t\t}\n\t}\n}",
"/*\n * The interrupt service routine\n * Dev_id is our fst_card_info pointer\n */\nstatic irqreturn_t\nfst_intr(int dummy, void *dev_id)\n{\n\tstruct fst_card_info *card = dev_id;\n\tstruct fst_port_info *port;\n\tint rdidx;\t\t/* Event buffer indices */\n\tint wridx;\n\tint event;\t\t/* Actual event for processing */\n\tunsigned int dma_intcsr = 0;\n\tunsigned int do_card_interrupt;\n\tunsigned int int_retry_count;",
"\t/*\n\t * Check to see if the interrupt was for this card\n\t * return if not\n\t * Note that the call to clear the interrupt is important\n\t */\n\tdbg(DBG_INTR, \"intr: %d %p\\n\", card->irq, card);\n\tif (card->state != FST_RUNNING) {\n\t\tpr_err(\"Interrupt received for card %d in a non running state (%d)\\n\",\n\t\t card->card_no, card->state);",
"\t\t/* \n\t\t * It is possible to really be running, i.e. we have re-loaded\n\t\t * a running card\n\t\t * Clear and reprime the interrupt source \n\t\t */\n\t\tfst_clear_intr(card);\n\t\treturn IRQ_HANDLED;\n\t}",
"\t/* Clear and reprime the interrupt source */\n\tfst_clear_intr(card);",
"\t/*\n\t * Is the interrupt for this card (handshake == 1)\n\t */\n\tdo_card_interrupt = 0;\n\tif (FST_RDB(card, interruptHandshake) == 1) {\n\t\tdo_card_interrupt += FST_CARD_INT;\n\t\t/* Set the software acknowledge */\n\t\tFST_WRB(card, interruptHandshake, 0xEE);\n\t}\n\tif (card->family == FST_FAMILY_TXU) {\n\t\t/*\n\t\t * Is it a DMA Interrupt\n\t\t */\n\t\tdma_intcsr = inl(card->pci_conf + INTCSR_9054);\n\t\tif (dma_intcsr & 0x00200000) {\n\t\t\t/*\n\t\t\t * DMA Channel 0 (Rx transfer complete)\n\t\t\t */\n\t\t\tdbg(DBG_RX, \"DMA Rx xfer complete\\n\");\n\t\t\toutb(0x8, card->pci_conf + DMACSR0);\n\t\t\tfst_rx_dma_complete(card, card->dma_port_rx,\n\t\t\t\t\t card->dma_len_rx, card->dma_skb_rx,\n\t\t\t\t\t card->dma_rxpos);\n\t\t\tcard->dmarx_in_progress = 0;\n\t\t\tdo_card_interrupt += FST_RX_DMA_INT;\n\t\t}\n\t\tif (dma_intcsr & 0x00400000) {\n\t\t\t/*\n\t\t\t * DMA Channel 1 (Tx transfer complete)\n\t\t\t */\n\t\t\tdbg(DBG_TX, \"DMA Tx xfer complete\\n\");\n\t\t\toutb(0x8, card->pci_conf + DMACSR1);\n\t\t\tfst_tx_dma_complete(card, card->dma_port_tx,\n\t\t\t\t\t card->dma_len_tx, card->dma_txpos);\n\t\t\tcard->dmatx_in_progress = 0;\n\t\t\tdo_card_interrupt += FST_TX_DMA_INT;\n\t\t}\n\t}",
"\t/*\n\t * Have we been missing Interrupts\n\t */\n\tint_retry_count = FST_RDL(card, interruptRetryCount);\n\tif (int_retry_count) {\n\t\tdbg(DBG_ASS, \"Card %d int_retry_count is %d\\n\",\n\t\t card->card_no, int_retry_count);\n\t\tFST_WRL(card, interruptRetryCount, 0);\n\t}",
"\tif (!do_card_interrupt) {\n\t\treturn IRQ_HANDLED;\n\t}",
"\t/* Scehdule the bottom half of the ISR */\n\tfst_q_work_item(&fst_work_intq, card->card_no);\n\ttasklet_schedule(&fst_int_task);",
"\t/* Drain the event queue */\n\trdidx = FST_RDB(card, interruptEvent.rdindex) & 0x1f;\n\twridx = FST_RDB(card, interruptEvent.wrindex) & 0x1f;\n\twhile (rdidx != wridx) {\n\t\tevent = FST_RDB(card, interruptEvent.evntbuff[rdidx]);\n\t\tport = &card->ports[event & 0x03];",
"\t\tdbg(DBG_INTR, \"Processing Interrupt event: %x\\n\", event);",
"\t\tswitch (event) {\n\t\tcase TE1_ALMA:\n\t\t\tdbg(DBG_INTR, \"TE1 Alarm intr\\n\");\n\t\t\tif (port->run)\n\t\t\t\tfst_intr_te1_alarm(card, port);\n\t\t\tbreak;",
"\t\tcase CTLA_CHG:\n\t\tcase CTLB_CHG:\n\t\tcase CTLC_CHG:\n\t\tcase CTLD_CHG:\n\t\t\tif (port->run)\n\t\t\t\tfst_intr_ctlchg(card, port);\n\t\t\tbreak;",
"\t\tcase ABTA_SENT:\n\t\tcase ABTB_SENT:\n\t\tcase ABTC_SENT:\n\t\tcase ABTD_SENT:\n\t\t\tdbg(DBG_TX, \"Abort complete port %d\\n\", port->index);\n\t\t\tbreak;",
"\t\tcase TXA_UNDF:\n\t\tcase TXB_UNDF:\n\t\tcase TXC_UNDF:\n\t\tcase TXD_UNDF:\n\t\t\t/* Difficult to see how we'd get this given that we\n\t\t\t * always load up the entire packet for DMA.\n\t\t\t */\n\t\t\tdbg(DBG_TX, \"Tx underflow port %d\\n\", port->index);\n\t\t\tport_to_dev(port)->stats.tx_errors++;\n\t\t\tport_to_dev(port)->stats.tx_fifo_errors++;\n\t\t\tdbg(DBG_ASS, \"Tx underflow on card %d port %d\\n\",\n\t\t\t card->card_no, port->index);\n\t\t\tbreak;",
"\t\tcase INIT_CPLT:\n\t\t\tdbg(DBG_INIT, \"Card init OK intr\\n\");\n\t\t\tbreak;",
"\t\tcase INIT_FAIL:\n\t\t\tdbg(DBG_INIT, \"Card init FAILED intr\\n\");\n\t\t\tcard->state = FST_IFAILED;\n\t\t\tbreak;",
"\t\tdefault:\n\t\t\tpr_err(\"intr: unknown card event %d. ignored\\n\", event);\n\t\t\tbreak;\n\t\t}",
"\t\t/* Bump and wrap the index */\n\t\tif (++rdidx >= MAX_CIRBUFF)\n\t\t\trdidx = 0;\n\t}\n\tFST_WRB(card, interruptEvent.rdindex, rdidx);\n return IRQ_HANDLED;\n}",
"/* Check that the shared memory configuration is one that we can handle\n * and that some basic parameters are correct\n */\nstatic void\ncheck_started_ok(struct fst_card_info *card)\n{\n\tint i;",
"\t/* Check structure version and end marker */\n\tif (FST_RDW(card, smcVersion) != SMC_VERSION) {\n\t\tpr_err(\"Bad shared memory version %d expected %d\\n\",\n\t\t FST_RDW(card, smcVersion), SMC_VERSION);\n\t\tcard->state = FST_BADVERSION;\n\t\treturn;\n\t}\n\tif (FST_RDL(card, endOfSmcSignature) != END_SIG) {\n\t\tpr_err(\"Missing shared memory signature\\n\");\n\t\tcard->state = FST_BADVERSION;\n\t\treturn;\n\t}\n\t/* Firmware status flag, 0x00 = initialising, 0x01 = OK, 0xFF = fail */\n\tif ((i = FST_RDB(card, taskStatus)) == 0x01) {\n\t\tcard->state = FST_RUNNING;\n\t} else if (i == 0xFF) {\n\t\tpr_err(\"Firmware initialisation failed. Card halted\\n\");\n\t\tcard->state = FST_HALTED;\n\t\treturn;\n\t} else if (i != 0x00) {\n\t\tpr_err(\"Unknown firmware status 0x%x\\n\", i);\n\t\tcard->state = FST_HALTED;\n\t\treturn;\n\t}",
"\t/* Finally check the number of ports reported by firmware against the\n\t * number we assumed at card detection. Should never happen with\n\t * existing firmware etc so we just report it for the moment.\n\t */\n\tif (FST_RDL(card, numberOfPorts) != card->nports) {\n\t\tpr_warn(\"Port count mismatch on card %d. Firmware thinks %d we say %d\\n\",\n\t\t\tcard->card_no,\n\t\t\tFST_RDL(card, numberOfPorts), card->nports);\n\t}\n}",
"static int\nset_conf_from_info(struct fst_card_info *card, struct fst_port_info *port,\n\t\t struct fstioc_info *info)\n{\n\tint err;\n\tunsigned char my_framing;",
"\t/* Set things according to the user set valid flags \n\t * Several of the old options have been invalidated/replaced by the \n\t * generic hdlc package.\n\t */\n\terr = 0;\n\tif (info->valid & FSTVAL_PROTO) {\n\t\tif (info->proto == FST_RAW)\n\t\t\tport->mode = FST_RAW;\n\t\telse\n\t\t\tport->mode = FST_GEN_HDLC;\n\t}",
"\tif (info->valid & FSTVAL_CABLE)\n\t\terr = -EINVAL;",
"\tif (info->valid & FSTVAL_SPEED)\n\t\terr = -EINVAL;",
"\tif (info->valid & FSTVAL_PHASE)\n\t\tFST_WRB(card, portConfig[port->index].invertClock,\n\t\t\tinfo->invertClock);\n\tif (info->valid & FSTVAL_MODE)\n\t\tFST_WRW(card, cardMode, info->cardMode);\n\tif (info->valid & FSTVAL_TE1) {\n\t\tFST_WRL(card, suConfig.dataRate, info->lineSpeed);\n\t\tFST_WRB(card, suConfig.clocking, info->clockSource);\n\t\tmy_framing = FRAMING_E1;\n\t\tif (info->framing == E1)\n\t\t\tmy_framing = FRAMING_E1;\n\t\tif (info->framing == T1)\n\t\t\tmy_framing = FRAMING_T1;\n\t\tif (info->framing == J1)\n\t\t\tmy_framing = FRAMING_J1;\n\t\tFST_WRB(card, suConfig.framing, my_framing);\n\t\tFST_WRB(card, suConfig.structure, info->structure);\n\t\tFST_WRB(card, suConfig.interface, info->interface);\n\t\tFST_WRB(card, suConfig.coding, info->coding);\n\t\tFST_WRB(card, suConfig.lineBuildOut, info->lineBuildOut);\n\t\tFST_WRB(card, suConfig.equalizer, info->equalizer);\n\t\tFST_WRB(card, suConfig.transparentMode, info->transparentMode);\n\t\tFST_WRB(card, suConfig.loopMode, info->loopMode);\n\t\tFST_WRB(card, suConfig.range, info->range);\n\t\tFST_WRB(card, suConfig.txBufferMode, info->txBufferMode);\n\t\tFST_WRB(card, suConfig.rxBufferMode, info->rxBufferMode);\n\t\tFST_WRB(card, suConfig.startingSlot, info->startingSlot);\n\t\tFST_WRB(card, suConfig.losThreshold, info->losThreshold);\n\t\tif (info->idleCode)\n\t\t\tFST_WRB(card, suConfig.enableIdleCode, 1);\n\t\telse\n\t\t\tFST_WRB(card, suConfig.enableIdleCode, 0);\n\t\tFST_WRB(card, suConfig.idleCode, info->idleCode);\n#if FST_DEBUG\n\t\tif (info->valid & FSTVAL_TE1) {\n\t\t\tprintk(\"Setting TE1 data\\n\");\n\t\t\tprintk(\"Line Speed = %d\\n\", info->lineSpeed);\n\t\t\tprintk(\"Start slot = %d\\n\", info->startingSlot);\n\t\t\tprintk(\"Clock source = %d\\n\", info->clockSource);\n\t\t\tprintk(\"Framing = %d\\n\", my_framing);\n\t\t\tprintk(\"Structure = %d\\n\", info->structure);\n\t\t\tprintk(\"interface = %d\\n\", info->interface);\n\t\t\tprintk(\"Coding = %d\\n\", info->coding);\n\t\t\tprintk(\"Line build out = %d\\n\", info->lineBuildOut);\n\t\t\tprintk(\"Equaliser = %d\\n\", info->equalizer);\n\t\t\tprintk(\"Transparent mode = %d\\n\",\n\t\t\t info->transparentMode);\n\t\t\tprintk(\"Loop mode = %d\\n\", info->loopMode);\n\t\t\tprintk(\"Range = %d\\n\", info->range);\n\t\t\tprintk(\"Tx Buffer mode = %d\\n\", info->txBufferMode);\n\t\t\tprintk(\"Rx Buffer mode = %d\\n\", info->rxBufferMode);\n\t\t\tprintk(\"LOS Threshold = %d\\n\", info->losThreshold);\n\t\t\tprintk(\"Idle Code = %d\\n\", info->idleCode);\n\t\t}\n#endif\n\t}\n#if FST_DEBUG\n\tif (info->valid & FSTVAL_DEBUG) {\n\t\tfst_debug_mask = info->debug;\n\t}\n#endif",
"\treturn err;\n}",
"static void\ngather_conf_info(struct fst_card_info *card, struct fst_port_info *port,\n\t\t struct fstioc_info *info)\n{\n\tint i;",
"\tmemset(info, 0, sizeof (struct fstioc_info));",
"\ti = port->index;\n\tinfo->kernelVersion = LINUX_VERSION_CODE;\n\tinfo->nports = card->nports;\n\tinfo->type = card->type;\n\tinfo->state = card->state;\n\tinfo->proto = FST_GEN_HDLC;\n\tinfo->index = i;\n#if FST_DEBUG\n\tinfo->debug = fst_debug_mask;\n#endif",
"\t/* Only mark information as valid if card is running.\n\t * Copy the data anyway in case it is useful for diagnostics\n\t */\n\tinfo->valid = ((card->state == FST_RUNNING) ? FSTVAL_ALL : FSTVAL_CARD)\n#if FST_DEBUG\n\t | FSTVAL_DEBUG\n#endif\n\t ;",
"\tinfo->lineInterface = FST_RDW(card, portConfig[i].lineInterface);\n\tinfo->internalClock = FST_RDB(card, portConfig[i].internalClock);\n\tinfo->lineSpeed = FST_RDL(card, portConfig[i].lineSpeed);\n\tinfo->invertClock = FST_RDB(card, portConfig[i].invertClock);\n\tinfo->v24IpSts = FST_RDL(card, v24IpSts[i]);\n\tinfo->v24OpSts = FST_RDL(card, v24OpSts[i]);\n\tinfo->clockStatus = FST_RDW(card, clockStatus[i]);\n\tinfo->cableStatus = FST_RDW(card, cableStatus);\n\tinfo->cardMode = FST_RDW(card, cardMode);\n\tinfo->smcFirmwareVersion = FST_RDL(card, smcFirmwareVersion);",
"\t/*\n\t * The T2U can report cable presence for both A or B\n\t * in bits 0 and 1 of cableStatus. See which port we are and \n\t * do the mapping.\n\t */\n\tif (card->family == FST_FAMILY_TXU) {\n\t\tif (port->index == 0) {\n\t\t\t/*\n\t\t\t * Port A\n\t\t\t */\n\t\t\tinfo->cableStatus = info->cableStatus & 1;\n\t\t} else {\n\t\t\t/*\n\t\t\t * Port B\n\t\t\t */\n\t\t\tinfo->cableStatus = info->cableStatus >> 1;\n\t\t\tinfo->cableStatus = info->cableStatus & 1;\n\t\t}\n\t}\n\t/*\n\t * Some additional bits if we are TE1\n\t */\n\tif (card->type == FST_TYPE_TE1) {\n\t\tinfo->lineSpeed = FST_RDL(card, suConfig.dataRate);\n\t\tinfo->clockSource = FST_RDB(card, suConfig.clocking);\n\t\tinfo->framing = FST_RDB(card, suConfig.framing);\n\t\tinfo->structure = FST_RDB(card, suConfig.structure);\n\t\tinfo->interface = FST_RDB(card, suConfig.interface);\n\t\tinfo->coding = FST_RDB(card, suConfig.coding);\n\t\tinfo->lineBuildOut = FST_RDB(card, suConfig.lineBuildOut);\n\t\tinfo->equalizer = FST_RDB(card, suConfig.equalizer);\n\t\tinfo->loopMode = FST_RDB(card, suConfig.loopMode);\n\t\tinfo->range = FST_RDB(card, suConfig.range);\n\t\tinfo->txBufferMode = FST_RDB(card, suConfig.txBufferMode);\n\t\tinfo->rxBufferMode = FST_RDB(card, suConfig.rxBufferMode);\n\t\tinfo->startingSlot = FST_RDB(card, suConfig.startingSlot);\n\t\tinfo->losThreshold = FST_RDB(card, suConfig.losThreshold);\n\t\tif (FST_RDB(card, suConfig.enableIdleCode))\n\t\t\tinfo->idleCode = FST_RDB(card, suConfig.idleCode);\n\t\telse\n\t\t\tinfo->idleCode = 0;\n\t\tinfo->receiveBufferDelay =\n\t\t FST_RDL(card, suStatus.receiveBufferDelay);\n\t\tinfo->framingErrorCount =\n\t\t FST_RDL(card, suStatus.framingErrorCount);\n\t\tinfo->codeViolationCount =\n\t\t FST_RDL(card, suStatus.codeViolationCount);\n\t\tinfo->crcErrorCount = FST_RDL(card, suStatus.crcErrorCount);\n\t\tinfo->lineAttenuation = FST_RDL(card, suStatus.lineAttenuation);\n\t\tinfo->lossOfSignal = FST_RDB(card, suStatus.lossOfSignal);\n\t\tinfo->receiveRemoteAlarm =\n\t\t FST_RDB(card, suStatus.receiveRemoteAlarm);\n\t\tinfo->alarmIndicationSignal =\n\t\t FST_RDB(card, suStatus.alarmIndicationSignal);\n\t}\n}",
"static int\nfst_set_iface(struct fst_card_info *card, struct fst_port_info *port,\n\t struct ifreq *ifr)\n{\n\tsync_serial_settings sync;\n\tint i;",
"\tif (ifr->ifr_settings.size != sizeof (sync)) {\n\t\treturn -ENOMEM;\n\t}",
"\tif (copy_from_user\n\t (&sync, ifr->ifr_settings.ifs_ifsu.sync, sizeof (sync))) {\n\t\treturn -EFAULT;\n\t}",
"\tif (sync.loopback)\n\t\treturn -EINVAL;",
"\ti = port->index;",
"\tswitch (ifr->ifr_settings.type) {\n\tcase IF_IFACE_V35:\n\t\tFST_WRW(card, portConfig[i].lineInterface, V35);\n\t\tport->hwif = V35;\n\t\tbreak;",
"\tcase IF_IFACE_V24:\n\t\tFST_WRW(card, portConfig[i].lineInterface, V24);\n\t\tport->hwif = V24;\n\t\tbreak;",
"\tcase IF_IFACE_X21:\n\t\tFST_WRW(card, portConfig[i].lineInterface, X21);\n\t\tport->hwif = X21;\n\t\tbreak;",
"\tcase IF_IFACE_X21D:\n\t\tFST_WRW(card, portConfig[i].lineInterface, X21D);\n\t\tport->hwif = X21D;\n\t\tbreak;",
"\tcase IF_IFACE_T1:\n\t\tFST_WRW(card, portConfig[i].lineInterface, T1);\n\t\tport->hwif = T1;\n\t\tbreak;",
"\tcase IF_IFACE_E1:\n\t\tFST_WRW(card, portConfig[i].lineInterface, E1);\n\t\tport->hwif = E1;\n\t\tbreak;",
"\tcase IF_IFACE_SYNC_SERIAL:\n\t\tbreak;",
"\tdefault:\n\t\treturn -EINVAL;\n\t}",
"\tswitch (sync.clock_type) {\n\tcase CLOCK_EXT:\n\t\tFST_WRB(card, portConfig[i].internalClock, EXTCLK);\n\t\tbreak;",
"\tcase CLOCK_INT:\n\t\tFST_WRB(card, portConfig[i].internalClock, INTCLK);\n\t\tbreak;",
"\tdefault:\n\t\treturn -EINVAL;\n\t}\n\tFST_WRL(card, portConfig[i].lineSpeed, sync.clock_rate);\n\treturn 0;\n}",
"static int\nfst_get_iface(struct fst_card_info *card, struct fst_port_info *port,\n\t struct ifreq *ifr)\n{\n\tsync_serial_settings sync;\n\tint i;",
"\t/* First check what line type is set, we'll default to reporting X.21\n\t * if nothing is set as IF_IFACE_SYNC_SERIAL implies it can't be\n\t * changed\n\t */\n\tswitch (port->hwif) {\n\tcase E1:\n\t\tifr->ifr_settings.type = IF_IFACE_E1;\n\t\tbreak;\n\tcase T1:\n\t\tifr->ifr_settings.type = IF_IFACE_T1;\n\t\tbreak;\n\tcase V35:\n\t\tifr->ifr_settings.type = IF_IFACE_V35;\n\t\tbreak;\n\tcase V24:\n\t\tifr->ifr_settings.type = IF_IFACE_V24;\n\t\tbreak;\n\tcase X21D:\n\t\tifr->ifr_settings.type = IF_IFACE_X21D;\n\t\tbreak;\n\tcase X21:\n\tdefault:\n\t\tifr->ifr_settings.type = IF_IFACE_X21;\n\t\tbreak;\n\t}\n\tif (ifr->ifr_settings.size == 0) {\n\t\treturn 0;\t/* only type requested */\n\t}\n\tif (ifr->ifr_settings.size < sizeof (sync)) {\n\t\treturn -ENOMEM;\n\t}",
"\ti = port->index;",
"",
"\tsync.clock_rate = FST_RDL(card, portConfig[i].lineSpeed);\n\t/* Lucky card and linux use same encoding here */\n\tsync.clock_type = FST_RDB(card, portConfig[i].internalClock) ==\n\t INTCLK ? CLOCK_INT : CLOCK_EXT;\n\tsync.loopback = 0;",
"\tif (copy_to_user(ifr->ifr_settings.ifs_ifsu.sync, &sync, sizeof (sync))) {\n\t\treturn -EFAULT;\n\t}",
"\tifr->ifr_settings.size = sizeof (sync);\n\treturn 0;\n}",
"static int\nfst_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)\n{\n\tstruct fst_card_info *card;\n\tstruct fst_port_info *port;\n\tstruct fstioc_write wrthdr;\n\tstruct fstioc_info info;\n\tunsigned long flags;\n\tvoid *buf;",
"\tdbg(DBG_IOCTL, \"ioctl: %x, %p\\n\", cmd, ifr->ifr_data);",
"\tport = dev_to_port(dev);\n\tcard = port->card;",
"\tif (!capable(CAP_NET_ADMIN))\n\t\treturn -EPERM;",
"\tswitch (cmd) {\n\tcase FSTCPURESET:\n\t\tfst_cpureset(card);\n\t\tcard->state = FST_RESET;\n\t\treturn 0;",
"\tcase FSTCPURELEASE:\n\t\tfst_cpurelease(card);\n\t\tcard->state = FST_STARTING;\n\t\treturn 0;",
"\tcase FSTWRITE:\t\t/* Code write (download) */",
"\t\t/* First copy in the header with the length and offset of data\n\t\t * to write\n\t\t */\n\t\tif (ifr->ifr_data == NULL) {\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (copy_from_user(&wrthdr, ifr->ifr_data,\n\t\t\t\t sizeof (struct fstioc_write))) {\n\t\t\treturn -EFAULT;\n\t\t}",
"\t\t/* Sanity check the parameters. We don't support partial writes\n\t\t * when going over the top\n\t\t */\n\t\tif (wrthdr.size > FST_MEMSIZE || wrthdr.offset > FST_MEMSIZE ||\n\t\t wrthdr.size + wrthdr.offset > FST_MEMSIZE) {\n\t\t\treturn -ENXIO;\n\t\t}",
"\t\t/* Now copy the data to the card. */",
"\t\tbuf = memdup_user(ifr->ifr_data + sizeof(struct fstioc_write),\n\t\t\t\t wrthdr.size);\n\t\tif (IS_ERR(buf))\n\t\t\treturn PTR_ERR(buf);",
"\t\tmemcpy_toio(card->mem + wrthdr.offset, buf, wrthdr.size);\n\t\tkfree(buf);",
"\t\t/* Writes to the memory of a card in the reset state constitute\n\t\t * a download\n\t\t */\n\t\tif (card->state == FST_RESET) {\n\t\t\tcard->state = FST_DOWNLOAD;\n\t\t}\n\t\treturn 0;",
"\tcase FSTGETCONF:",
"\t\t/* If card has just been started check the shared memory config\n\t\t * version and marker\n\t\t */\n\t\tif (card->state == FST_STARTING) {\n\t\t\tcheck_started_ok(card);",
"\t\t\t/* If everything checked out enable card interrupts */\n\t\t\tif (card->state == FST_RUNNING) {\n\t\t\t\tspin_lock_irqsave(&card->card_lock, flags);\n\t\t\t\tfst_enable_intr(card);\n\t\t\t\tFST_WRB(card, interruptHandshake, 0xEE);\n\t\t\t\tspin_unlock_irqrestore(&card->card_lock, flags);\n\t\t\t}\n\t\t}",
"\t\tif (ifr->ifr_data == NULL) {\n\t\t\treturn -EINVAL;\n\t\t}",
"\t\tgather_conf_info(card, port, &info);",
"\t\tif (copy_to_user(ifr->ifr_data, &info, sizeof (info))) {\n\t\t\treturn -EFAULT;\n\t\t}\n\t\treturn 0;",
"\tcase FSTSETCONF:",
"\t\t/*\n\t\t * Most of the settings have been moved to the generic ioctls\n\t\t * this just covers debug and board ident now\n\t\t */",
"\t\tif (card->state != FST_RUNNING) {\n\t\t\tpr_err(\"Attempt to configure card %d in non-running state (%d)\\n\",\n\t\t\t card->card_no, card->state);\n\t\t\treturn -EIO;\n\t\t}\n\t\tif (copy_from_user(&info, ifr->ifr_data, sizeof (info))) {\n\t\t\treturn -EFAULT;\n\t\t}",
"\t\treturn set_conf_from_info(card, port, &info);",
"\tcase SIOCWANDEV:\n\t\tswitch (ifr->ifr_settings.type) {\n\t\tcase IF_GET_IFACE:\n\t\t\treturn fst_get_iface(card, port, ifr);",
"\t\tcase IF_IFACE_SYNC_SERIAL:\n\t\tcase IF_IFACE_V35:\n\t\tcase IF_IFACE_V24:\n\t\tcase IF_IFACE_X21:\n\t\tcase IF_IFACE_X21D:\n\t\tcase IF_IFACE_T1:\n\t\tcase IF_IFACE_E1:\n\t\t\treturn fst_set_iface(card, port, ifr);",
"\t\tcase IF_PROTO_RAW:\n\t\t\tport->mode = FST_RAW;\n\t\t\treturn 0;",
"\t\tcase IF_GET_PROTO:\n\t\t\tif (port->mode == FST_RAW) {\n\t\t\t\tifr->ifr_settings.type = IF_PROTO_RAW;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn hdlc_ioctl(dev, ifr, cmd);",
"\t\tdefault:\n\t\t\tport->mode = FST_GEN_HDLC;\n\t\t\tdbg(DBG_IOCTL, \"Passing this type to hdlc %x\\n\",\n\t\t\t ifr->ifr_settings.type);\n\t\t\treturn hdlc_ioctl(dev, ifr, cmd);\n\t\t}",
"\tdefault:\n\t\t/* Not one of ours. Pass through to HDLC package */\n\t\treturn hdlc_ioctl(dev, ifr, cmd);\n\t}\n}",
"static void\nfst_openport(struct fst_port_info *port)\n{\n\tint signals;\n\tint txq_length;",
"\t/* Only init things if card is actually running. This allows open to\n\t * succeed for downloads etc.\n\t */\n\tif (port->card->state == FST_RUNNING) {\n\t\tif (port->run) {\n\t\t\tdbg(DBG_OPEN, \"open: found port already running\\n\");",
"\t\t\tfst_issue_cmd(port, STOPPORT);\n\t\t\tport->run = 0;\n\t\t}",
"\t\tfst_rx_config(port);\n\t\tfst_tx_config(port);\n\t\tfst_op_raise(port, OPSTS_RTS | OPSTS_DTR);",
"\t\tfst_issue_cmd(port, STARTPORT);\n\t\tport->run = 1;",
"\t\tsignals = FST_RDL(port->card, v24DebouncedSts[port->index]);\n\t\tif (signals & (((port->hwif == X21) || (port->hwif == X21D))\n\t\t\t ? IPSTS_INDICATE : IPSTS_DCD))\n\t\t\tnetif_carrier_on(port_to_dev(port));\n\t\telse\n\t\t\tnetif_carrier_off(port_to_dev(port));",
"\t\ttxq_length = port->txqe - port->txqs;\n\t\tport->txqe = 0;\n\t\tport->txqs = 0;\n\t}",
"}",
"static void\nfst_closeport(struct fst_port_info *port)\n{\n\tif (port->card->state == FST_RUNNING) {\n\t\tif (port->run) {\n\t\t\tport->run = 0;\n\t\t\tfst_op_lower(port, OPSTS_RTS | OPSTS_DTR);",
"\t\t\tfst_issue_cmd(port, STOPPORT);\n\t\t} else {\n\t\t\tdbg(DBG_OPEN, \"close: port not running\\n\");\n\t\t}\n\t}\n}",
"static int\nfst_open(struct net_device *dev)\n{\n\tint err;\n\tstruct fst_port_info *port;",
"\tport = dev_to_port(dev);\n\tif (!try_module_get(THIS_MODULE))\n return -EBUSY;",
"\tif (port->mode != FST_RAW) {\n\t\terr = hdlc_open(dev);\n\t\tif (err) {\n\t\t\tmodule_put(THIS_MODULE);\n\t\t\treturn err;\n\t\t}\n\t}",
"\tfst_openport(port);\n\tnetif_wake_queue(dev);\n\treturn 0;\n}",
"static int\nfst_close(struct net_device *dev)\n{\n\tstruct fst_port_info *port;\n\tstruct fst_card_info *card;\n\tunsigned char tx_dma_done;\n\tunsigned char rx_dma_done;",
"\tport = dev_to_port(dev);\n\tcard = port->card;",
"\ttx_dma_done = inb(card->pci_conf + DMACSR1);\n\trx_dma_done = inb(card->pci_conf + DMACSR0);\n\tdbg(DBG_OPEN,\n\t \"Port Close: tx_dma_in_progress = %d (%x) rx_dma_in_progress = %d (%x)\\n\",\n\t card->dmatx_in_progress, tx_dma_done, card->dmarx_in_progress,\n\t rx_dma_done);",
"\tnetif_stop_queue(dev);\n\tfst_closeport(dev_to_port(dev));\n\tif (port->mode != FST_RAW) {\n\t\thdlc_close(dev);\n\t}\n\tmodule_put(THIS_MODULE);\n\treturn 0;\n}",
"static int\nfst_attach(struct net_device *dev, unsigned short encoding, unsigned short parity)\n{\n\t/*\n\t * Setting currently fixed in FarSync card so we check and forget\n\t */\n\tif (encoding != ENCODING_NRZ || parity != PARITY_CRC16_PR1_CCITT)\n\t\treturn -EINVAL;\n\treturn 0;\n}",
"static void\nfst_tx_timeout(struct net_device *dev)\n{\n\tstruct fst_port_info *port;\n\tstruct fst_card_info *card;",
"\tport = dev_to_port(dev);\n\tcard = port->card;\n\tdev->stats.tx_errors++;\n\tdev->stats.tx_aborted_errors++;\n\tdbg(DBG_ASS, \"Tx timeout card %d port %d\\n\",\n\t card->card_no, port->index);\n\tfst_issue_cmd(port, ABORTTX);",
"\tdev->trans_start = jiffies;\n\tnetif_wake_queue(dev);\n\tport->start = 0;\n}",
"static netdev_tx_t\nfst_start_xmit(struct sk_buff *skb, struct net_device *dev)\n{\n\tstruct fst_card_info *card;\n\tstruct fst_port_info *port;\n\tunsigned long flags;\n\tint txq_length;",
"\tport = dev_to_port(dev);\n\tcard = port->card;\n\tdbg(DBG_TX, \"fst_start_xmit: length = %d\\n\", skb->len);",
"\t/* Drop packet with error if we don't have carrier */\n\tif (!netif_carrier_ok(dev)) {\n\t\tdev_kfree_skb(skb);\n\t\tdev->stats.tx_errors++;\n\t\tdev->stats.tx_carrier_errors++;\n\t\tdbg(DBG_ASS,\n\t\t \"Tried to transmit but no carrier on card %d port %d\\n\",\n\t\t card->card_no, port->index);\n\t\treturn NETDEV_TX_OK;\n\t}",
"\t/* Drop it if it's too big! MTU failure ? */\n\tif (skb->len > LEN_TX_BUFFER) {\n\t\tdbg(DBG_ASS, \"Packet too large %d vs %d\\n\", skb->len,\n\t\t LEN_TX_BUFFER);\n\t\tdev_kfree_skb(skb);\n\t\tdev->stats.tx_errors++;\n\t\treturn NETDEV_TX_OK;\n\t}",
"\t/*\n\t * We are always going to queue the packet\n\t * so that the bottom half is the only place we tx from\n\t * Check there is room in the port txq\n\t */\n\tspin_lock_irqsave(&card->card_lock, flags);\n\tif ((txq_length = port->txqe - port->txqs) < 0) {\n\t\t/*\n\t\t * This is the case where the next free has wrapped but the\n\t\t * last used hasn't\n\t\t */\n\t\ttxq_length = txq_length + FST_TXQ_DEPTH;\n\t}\n\tspin_unlock_irqrestore(&card->card_lock, flags);\n\tif (txq_length > fst_txq_high) {\n\t\t/*\n\t\t * We have got enough buffers in the pipeline. Ask the network\n\t\t * layer to stop sending frames down\n\t\t */\n\t\tnetif_stop_queue(dev);\n\t\tport->start = 1;\t/* I'm using this to signal stop sent up */\n\t}",
"\tif (txq_length == FST_TXQ_DEPTH - 1) {\n\t\t/*\n\t\t * This shouldn't have happened but such is life\n\t\t */\n\t\tdev_kfree_skb(skb);\n\t\tdev->stats.tx_errors++;\n\t\tdbg(DBG_ASS, \"Tx queue overflow card %d port %d\\n\",\n\t\t card->card_no, port->index);\n\t\treturn NETDEV_TX_OK;\n\t}",
"\t/*\n\t * queue the buffer\n\t */\n\tspin_lock_irqsave(&card->card_lock, flags);\n\tport->txq[port->txqe] = skb;\n\tport->txqe++;\n\tif (port->txqe == FST_TXQ_DEPTH)\n\t\tport->txqe = 0;\n\tspin_unlock_irqrestore(&card->card_lock, flags);",
"\t/* Scehdule the bottom half which now does transmit processing */\n\tfst_q_work_item(&fst_work_txq, card->card_no);\n\ttasklet_schedule(&fst_tx_task);",
"\treturn NETDEV_TX_OK;\n}",
"/*\n * Card setup having checked hardware resources.\n * Should be pretty bizarre if we get an error here (kernel memory\n * exhaustion is one possibility). If we do see a problem we report it\n * via a printk and leave the corresponding interface and all that follow\n * disabled.\n */\nstatic char *type_strings[] = {\n\t\"no hardware\",\t\t/* Should never be seen */\n\t\"FarSync T2P\",\n\t\"FarSync T4P\",\n\t\"FarSync T1U\",\n\t\"FarSync T2U\",\n\t\"FarSync T4U\",\n\t\"FarSync TE1\"\n};",
"static void\nfst_init_card(struct fst_card_info *card)\n{\n\tint i;\n\tint err;",
"\t/* We're working on a number of ports based on the card ID. If the\n\t * firmware detects something different later (should never happen)\n\t * we'll have to revise it in some way then.\n\t */\n\tfor (i = 0; i < card->nports; i++) {\n err = register_hdlc_device(card->ports[i].dev);\n if (err < 0) {\n\t\t\tint j;\n\t\t\tpr_err(\"Cannot register HDLC device for port %d (errno %d)\\n\",\n\t\t\t i, -err);\n\t\t\tfor (j = i; j < card->nports; j++) {\n\t\t\t\tfree_netdev(card->ports[j].dev);\n\t\t\t\tcard->ports[j].dev = NULL;\n\t\t\t}\n card->nports = i;\n break;\n }\n\t}",
"\tpr_info(\"%s-%s: %s IRQ%d, %d ports\\n\",\n\t\tport_to_dev(&card->ports[0])->name,\n\t\tport_to_dev(&card->ports[card->nports - 1])->name,\n\t\ttype_strings[card->type], card->irq, card->nports);\n}",
"static const struct net_device_ops fst_ops = {\n\t.ndo_open = fst_open,\n\t.ndo_stop = fst_close,\n\t.ndo_change_mtu = hdlc_change_mtu,\n\t.ndo_start_xmit = hdlc_start_xmit,\n\t.ndo_do_ioctl = fst_ioctl,\n\t.ndo_tx_timeout = fst_tx_timeout,\n};",
"/*\n * Initialise card when detected.\n * Returns 0 to indicate success, or errno otherwise.\n */\nstatic int\nfst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)\n{\n\tstatic int no_of_cards_added = 0;\n\tstruct fst_card_info *card;\n\tint err = 0;\n\tint i;",
"\tprintk_once(KERN_INFO\n\t\t pr_fmt(\"FarSync WAN driver \" FST_USER_VERSION\n\t\t\t \" (c) 2001-2004 FarSite Communications Ltd.\\n\"));\n#if FST_DEBUG\n\tdbg(DBG_ASS, \"The value of debug mask is %x\\n\", fst_debug_mask);\n#endif\n\t/*\n\t * We are going to be clever and allow certain cards not to be\n\t * configured. An exclude list can be provided in /etc/modules.conf\n\t */\n\tif (fst_excluded_cards != 0) {\n\t\t/*\n\t\t * There are cards to exclude\n\t\t *\n\t\t */\n\t\tfor (i = 0; i < fst_excluded_cards; i++) {\n\t\t\tif ((pdev->devfn) >> 3 == fst_excluded_list[i]) {\n\t\t\t\tpr_info(\"FarSync PCI device %d not assigned\\n\",\n\t\t\t\t\t(pdev->devfn) >> 3);\n\t\t\t\treturn -EBUSY;\n\t\t\t}\n\t\t}\n\t}",
"\t/* Allocate driver private data */\n\tcard = kzalloc(sizeof(struct fst_card_info), GFP_KERNEL);\n\tif (card == NULL)\n\t\treturn -ENOMEM;",
"\t/* Try to enable the device */\n\tif ((err = pci_enable_device(pdev)) != 0) {\n\t\tpr_err(\"Failed to enable card. Err %d\\n\", -err);\n\t\tkfree(card);\n\t\treturn err;\n\t}",
"\tif ((err = pci_request_regions(pdev, \"FarSync\")) !=0) {\n\t\tpr_err(\"Failed to allocate regions. Err %d\\n\", -err);\n\t\tpci_disable_device(pdev);\n\t\tkfree(card);\n\t return err;\n\t}",
"\t/* Get virtual addresses of memory regions */\n\tcard->pci_conf = pci_resource_start(pdev, 1);\n\tcard->phys_mem = pci_resource_start(pdev, 2);\n\tcard->phys_ctlmem = pci_resource_start(pdev, 3);\n\tif ((card->mem = ioremap(card->phys_mem, FST_MEMSIZE)) == NULL) {\n\t\tpr_err(\"Physical memory remap failed\\n\");\n\t\tpci_release_regions(pdev);\n\t\tpci_disable_device(pdev);\n\t\tkfree(card);\n\t\treturn -ENODEV;\n\t}\n\tif ((card->ctlmem = ioremap(card->phys_ctlmem, 0x10)) == NULL) {\n\t\tpr_err(\"Control memory remap failed\\n\");\n\t\tpci_release_regions(pdev);\n\t\tpci_disable_device(pdev);\n\t\tiounmap(card->mem);\n\t\tkfree(card);\n\t\treturn -ENODEV;\n\t}\n\tdbg(DBG_PCI, \"kernel mem %p, ctlmem %p\\n\", card->mem, card->ctlmem);",
"\t/* Register the interrupt handler */\n\tif (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) {\n\t\tpr_err(\"Unable to register interrupt %d\\n\", card->irq);\n\t\tpci_release_regions(pdev);\n\t\tpci_disable_device(pdev);\n\t\tiounmap(card->ctlmem);\n\t\tiounmap(card->mem);\n\t\tkfree(card);\n\t\treturn -ENODEV;\n\t}",
"\t/* Record info we need */\n\tcard->irq = pdev->irq;\n\tcard->type = ent->driver_data;\n\tcard->family = ((ent->driver_data == FST_TYPE_T2P) ||\n\t\t\t(ent->driver_data == FST_TYPE_T4P))\n\t ? FST_FAMILY_TXP : FST_FAMILY_TXU;\n\tif ((ent->driver_data == FST_TYPE_T1U) ||\n\t (ent->driver_data == FST_TYPE_TE1))\n\t\tcard->nports = 1;\n\telse\n\t\tcard->nports = ((ent->driver_data == FST_TYPE_T2P) ||\n\t\t\t\t(ent->driver_data == FST_TYPE_T2U)) ? 2 : 4;",
"\tcard->state = FST_UNINIT;\n spin_lock_init ( &card->card_lock );",
" for ( i = 0 ; i < card->nports ; i++ ) {\n\t\tstruct net_device *dev = alloc_hdlcdev(&card->ports[i]);\n\t\thdlc_device *hdlc;\n\t\tif (!dev) {\n\t\t\twhile (i--)\n\t\t\t\tfree_netdev(card->ports[i].dev);\n\t\t\tpr_err(\"FarSync: out of memory\\n\");\n free_irq(card->irq, card);\n pci_release_regions(pdev);\n pci_disable_device(pdev);\n iounmap(card->ctlmem);\n iounmap(card->mem);\n kfree(card);\n return -ENODEV;\n\t\t}\n\t\tcard->ports[i].dev = dev;\n card->ports[i].card = card;\n card->ports[i].index = i;\n card->ports[i].run = 0;",
"\t\thdlc = dev_to_hdlc(dev);",
" /* Fill in the net device info */\n\t\t/* Since this is a PCI setup this is purely\n\t\t * informational. Give them the buffer addresses\n\t\t * and basic card I/O.\n\t\t */\n dev->mem_start = card->phys_mem\n + BUF_OFFSET ( txBuffer[i][0][0]);\n dev->mem_end = card->phys_mem\n + BUF_OFFSET ( txBuffer[i][NUM_TX_BUFFER][0]);\n dev->base_addr = card->pci_conf;\n dev->irq = card->irq;",
"\t\tdev->netdev_ops = &fst_ops;\n\t\tdev->tx_queue_len = FST_TX_QUEUE_LEN;\n\t\tdev->watchdog_timeo = FST_TX_TIMEOUT;\n hdlc->attach = fst_attach;\n hdlc->xmit = fst_start_xmit;\n\t}",
"\tcard->device = pdev;",
"\tdbg(DBG_PCI, \"type %d nports %d irq %d\\n\", card->type,\n\t card->nports, card->irq);\n\tdbg(DBG_PCI, \"conf %04x mem %08x ctlmem %08x\\n\",\n\t card->pci_conf, card->phys_mem, card->phys_ctlmem);",
"\t/* Reset the card's processor */\n\tfst_cpureset(card);\n\tcard->state = FST_RESET;",
"\t/* Initialise DMA (if required) */\n\tfst_init_dma(card);",
"\t/* Record driver data for later use */\n\tpci_set_drvdata(pdev, card);",
"\t/* Remainder of card setup */\n\tfst_card_array[no_of_cards_added] = card;\n\tcard->card_no = no_of_cards_added++;\t/* Record instance and bump it */\n\tfst_init_card(card);\n\tif (card->family == FST_FAMILY_TXU) {\n\t\t/*\n\t\t * Allocate a dma buffer for transmit and receives\n\t\t */\n\t\tcard->rx_dma_handle_host =\n\t\t pci_alloc_consistent(card->device, FST_MAX_MTU,\n\t\t\t\t\t &card->rx_dma_handle_card);\n\t\tif (card->rx_dma_handle_host == NULL) {\n\t\t\tpr_err(\"Could not allocate rx dma buffer\\n\");\n\t\t\tfst_disable_intr(card);\n\t\t\tpci_release_regions(pdev);\n\t\t\tpci_disable_device(pdev);\n\t\t\tiounmap(card->ctlmem);\n\t\t\tiounmap(card->mem);\n\t\t\tkfree(card);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t\tcard->tx_dma_handle_host =\n\t\t pci_alloc_consistent(card->device, FST_MAX_MTU,\n\t\t\t\t\t &card->tx_dma_handle_card);\n\t\tif (card->tx_dma_handle_host == NULL) {\n\t\t\tpr_err(\"Could not allocate tx dma buffer\\n\");\n\t\t\tfst_disable_intr(card);\n\t\t\tpci_release_regions(pdev);\n\t\t\tpci_disable_device(pdev);\n\t\t\tiounmap(card->ctlmem);\n\t\t\tiounmap(card->mem);\n\t\t\tkfree(card);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t}\n\treturn 0;\t\t/* Success */\n}",
"/*\n * Cleanup and close down a card\n */\nstatic void\nfst_remove_one(struct pci_dev *pdev)\n{\n\tstruct fst_card_info *card;\n\tint i;",
"\tcard = pci_get_drvdata(pdev);",
"\tfor (i = 0; i < card->nports; i++) {\n\t\tstruct net_device *dev = port_to_dev(&card->ports[i]);\n\t\tunregister_hdlc_device(dev);\n\t}",
"\tfst_disable_intr(card);\n\tfree_irq(card->irq, card);",
"\tiounmap(card->ctlmem);\n\tiounmap(card->mem);\n\tpci_release_regions(pdev);\n\tif (card->family == FST_FAMILY_TXU) {\n\t\t/*\n\t\t * Free dma buffers\n\t\t */\n\t\tpci_free_consistent(card->device, FST_MAX_MTU,\n\t\t\t\t card->rx_dma_handle_host,\n\t\t\t\t card->rx_dma_handle_card);\n\t\tpci_free_consistent(card->device, FST_MAX_MTU,\n\t\t\t\t card->tx_dma_handle_host,\n\t\t\t\t card->tx_dma_handle_card);\n\t}\n\tfst_card_array[card->card_no] = NULL;\n}",
"static struct pci_driver fst_driver = {\n .name\t\t= FST_NAME,\n .id_table\t= fst_pci_dev_id,\n .probe\t\t= fst_add_one,\n .remove\t= fst_remove_one,\n .suspend\t= NULL,\n .resume\t= NULL,\n};",
"static int __init\nfst_init(void)\n{\n\tint i;",
"\tfor (i = 0; i < FST_MAX_CARDS; i++)\n\t\tfst_card_array[i] = NULL;\n\tspin_lock_init(&fst_work_q_lock);\n\treturn pci_register_driver(&fst_driver);\n}",
"static void __exit\nfst_cleanup_module(void)\n{\n\tpr_info(\"FarSync WAN driver unloading\\n\");\n\tpci_unregister_driver(&fst_driver);\n}",
"module_init(fst_init);\nmodule_exit(fst_cleanup_module);"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1974], "buggy_code_start_loc": [1974], "filenames": ["drivers/net/wan/farsync.c"], "fixing_code_end_loc": [1976], "fixing_code_start_loc": [1975], "message": "The fst_get_iface function in drivers/net/wan/farsync.c in the Linux kernel before 3.11.7 does not properly initialize a certain data structure, which allows local users to obtain sensitive information from kernel memory by leveraging the CAP_NET_ADMIN capability for an SIOCWANDEV ioctl call.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "C3D55C7B-D6AF-4DB4-8CCC-3BFC8C15F45D", "versionEndExcluding": null, "versionEndIncluding": "3.11.6", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11:*:*:*:*:*:*:*", "matchCriteriaId": "639E3A57-A9E7-40E6-8929-81CCC0060EFB", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11.1:*:*:*:*:*:*:*", "matchCriteriaId": "07012ADD-F521-40A8-B067-E87C2238A3D2", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11.2:*:*:*:*:*:*:*", "matchCriteriaId": "3F5FF393-3F89-4274-B82B-F671358072ED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11.3:*:*:*:*:*:*:*", "matchCriteriaId": "E348698F-54D1-4F5E-B701-CFAF50881E0A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11.4:*:*:*:*:*:*:*", "matchCriteriaId": "932205D9-3514-4289-9B55-C7A169276930", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11.5:*:*:*:*:*:*:*", "matchCriteriaId": "2ECB2D33-F517-480F-8A6F-99D9D6C49596", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "The fst_get_iface function in drivers/net/wan/farsync.c in the Linux kernel before 3.11.7 does not properly initialize a certain data structure, which allows local users to obtain sensitive information from kernel memory by leveraging the CAP_NET_ADMIN capability for an SIOCWANDEV ioctl call."}, {"lang": "es", "value": "La funci\u00f3n fst_get_iface en drivers/net/wan/farsync.c del kernel Linux anteriores a 3.11.7 no inicializa apropiadamente cierta estructura de datos, lo cual permite a usuarios locales obtener informaci\u00f3n sensible de la memoria dle kernel, aprovechando la funcionalidad CAP_NET_ADMIN para una llamada SIOCWANDEV ioctl."}], "evaluatorComment": null, "id": "CVE-2014-1444", "lastModified": "2017-08-29T01:34:24.950", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 1.7, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:L/AC:L/Au:S/C:P/I:N/A:N", "version": "2.0"}, "exploitabilityScore": 3.1, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": null}, "published": "2014-01-18T22:55:03.257", "references": [{"source": "cve@mitre.org", "tags": null, "url": "http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=96b340406724d87e4621284ebac5e059d67b2194"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.11.7"}, {"source": "cve@mitre.org", "tags": ["Patch"], "url": "http://www.openwall.com/lists/oss-security/2014/01/15/3"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/64952"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.ubuntu.com/usn/USN-2128-1"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.ubuntu.com/usn/USN-2129-1"}, {"source": "cve@mitre.org", "tags": null, "url": "https://bugzilla.redhat.com/show_bug.cgi?id=1053610"}, {"source": "cve@mitre.org", "tags": null, "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/90443"}, {"source": "cve@mitre.org", "tags": ["Patch"], "url": "https://github.com/torvalds/linux/commit/96b340406724d87e4621284ebac5e059d67b2194"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-399"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/96b340406724d87e4621284ebac5e059d67b2194"}, "type": "CWE-399"}
| 362
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * FarSync WAN driver for Linux (2.6.x kernel version)\n *\n * Actually sync driver for X.21, V.35 and V.24 on FarSync T-series cards\n *\n * Copyright (C) 2001-2004 FarSite Communications Ltd.\n * www.farsite.co.uk\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License\n * as published by the Free Software Foundation; either version\n * 2 of the License, or (at your option) any later version.\n *\n * Author: R.J.Dunlop <bob.dunlop@farsite.co.uk>\n * Maintainer: Kevin Curtis <kevin.curtis@farsite.co.uk>\n */",
"#define pr_fmt(fmt) KBUILD_MODNAME \": \" fmt",
"#include <linux/module.h>\n#include <linux/kernel.h>\n#include <linux/version.h>\n#include <linux/pci.h>\n#include <linux/sched.h>\n#include <linux/slab.h>\n#include <linux/ioport.h>\n#include <linux/init.h>\n#include <linux/interrupt.h>\n#include <linux/if.h>\n#include <linux/hdlc.h>\n#include <asm/io.h>\n#include <asm/uaccess.h>",
"#include \"farsync.h\"",
"/*\n * Module info\n */\nMODULE_AUTHOR(\"R.J.Dunlop <bob.dunlop@farsite.co.uk>\");\nMODULE_DESCRIPTION(\"FarSync T-Series WAN driver. FarSite Communications Ltd.\");\nMODULE_LICENSE(\"GPL\");",
"/* Driver configuration and global parameters\n * ==========================================\n */",
"/* Number of ports (per card) and cards supported\n */\n#define FST_MAX_PORTS 4\n#define FST_MAX_CARDS 32",
"/* Default parameters for the link\n */\n#define FST_TX_QUEUE_LEN 100\t/* At 8Mbps a longer queue length is\n\t\t\t\t\t * useful */\n#define FST_TXQ_DEPTH 16\t/* This one is for the buffering\n\t\t\t\t\t * of frames on the way down to the card\n\t\t\t\t\t * so that we can keep the card busy\n\t\t\t\t\t * and maximise throughput\n\t\t\t\t\t */\n#define FST_HIGH_WATER_MARK 12\t/* Point at which we flow control\n\t\t\t\t\t * network layer */\n#define FST_LOW_WATER_MARK 8\t/* Point at which we remove flow\n\t\t\t\t\t * control from network layer */\n#define FST_MAX_MTU 8000\t/* Huge but possible */\n#define FST_DEF_MTU 1500\t/* Common sane value */",
"#define FST_TX_TIMEOUT (2*HZ)",
"#ifdef ARPHRD_RAWHDLC\n#define ARPHRD_MYTYPE ARPHRD_RAWHDLC\t/* Raw frames */\n#else\n#define ARPHRD_MYTYPE ARPHRD_HDLC\t/* Cisco-HDLC (keepalives etc) */\n#endif",
"/*\n * Modules parameters and associated variables\n */\nstatic int fst_txq_low = FST_LOW_WATER_MARK;\nstatic int fst_txq_high = FST_HIGH_WATER_MARK;\nstatic int fst_max_reads = 7;\nstatic int fst_excluded_cards = 0;\nstatic int fst_excluded_list[FST_MAX_CARDS];",
"module_param(fst_txq_low, int, 0);\nmodule_param(fst_txq_high, int, 0);\nmodule_param(fst_max_reads, int, 0);\nmodule_param(fst_excluded_cards, int, 0);\nmodule_param_array(fst_excluded_list, int, NULL, 0);",
"/* Card shared memory layout\n * =========================\n */\n#pragma pack(1)",
"/* This information is derived in part from the FarSite FarSync Smc.h\n * file. Unfortunately various name clashes and the non-portability of the\n * bit field declarations in that file have meant that I have chosen to\n * recreate the information here.\n *\n * The SMC (Shared Memory Configuration) has a version number that is\n * incremented every time there is a significant change. This number can\n * be used to check that we have not got out of step with the firmware\n * contained in the .CDE files.\n */\n#define SMC_VERSION 24",
"#define FST_MEMSIZE 0x100000\t/* Size of card memory (1Mb) */",
"#define SMC_BASE 0x00002000L\t/* Base offset of the shared memory window main\n\t\t\t\t * configuration structure */\n#define BFM_BASE 0x00010000L\t/* Base offset of the shared memory window DMA\n\t\t\t\t * buffers */",
"#define LEN_TX_BUFFER 8192\t/* Size of packet buffers */\n#define LEN_RX_BUFFER 8192",
"#define LEN_SMALL_TX_BUFFER 256\t/* Size of obsolete buffs used for DOS diags */\n#define LEN_SMALL_RX_BUFFER 256",
"#define NUM_TX_BUFFER 2\t\t/* Must be power of 2. Fixed by firmware */\n#define NUM_RX_BUFFER 8",
"/* Interrupt retry time in milliseconds */\n#define INT_RETRY_TIME 2",
"/* The Am186CH/CC processors support a SmartDMA mode using circular pools\n * of buffer descriptors. The structure is almost identical to that used\n * in the LANCE Ethernet controllers. Details available as PDF from the\n * AMD web site: http://www.amd.com/products/epd/processors/\\\n * 2.16bitcont/3.am186cxfa/a21914/21914.pdf\n */\nstruct txdesc {\t\t\t/* Transmit descriptor */\n\tvolatile u16 ladr;\t/* Low order address of packet. This is a\n\t\t\t\t * linear address in the Am186 memory space\n\t\t\t\t */\n\tvolatile u8 hadr;\t/* High order address. Low 4 bits only, high 4\n\t\t\t\t * bits must be zero\n\t\t\t\t */\n\tvolatile u8 bits;\t/* Status and config */\n\tvolatile u16 bcnt;\t/* 2s complement of packet size in low 15 bits.\n\t\t\t\t * Transmit terminal count interrupt enable in\n\t\t\t\t * top bit.\n\t\t\t\t */\n\tu16 unused;\t\t/* Not used in Tx */\n};",
"struct rxdesc {\t\t\t/* Receive descriptor */\n\tvolatile u16 ladr;\t/* Low order address of packet */\n\tvolatile u8 hadr;\t/* High order address */\n\tvolatile u8 bits;\t/* Status and config */\n\tvolatile u16 bcnt;\t/* 2s complement of buffer size in low 15 bits.\n\t\t\t\t * Receive terminal count interrupt enable in\n\t\t\t\t * top bit.\n\t\t\t\t */\n\tvolatile u16 mcnt;\t/* Message byte count (15 bits) */\n};",
"/* Convert a length into the 15 bit 2's complement */\n/* #define cnv_bcnt(len) (( ~(len) + 1 ) & 0x7FFF ) */\n/* Since we need to set the high bit to enable the completion interrupt this\n * can be made a lot simpler\n */\n#define cnv_bcnt(len) (-(len))",
"/* Status and config bits for the above */\n#define DMA_OWN 0x80\t/* SmartDMA owns the descriptor */\n#define TX_STP 0x02\t/* Tx: start of packet */\n#define TX_ENP 0x01\t/* Tx: end of packet */\n#define RX_ERR 0x40\t/* Rx: error (OR of next 4 bits) */\n#define RX_FRAM 0x20\t/* Rx: framing error */\n#define RX_OFLO 0x10\t/* Rx: overflow error */\n#define RX_CRC 0x08\t/* Rx: CRC error */\n#define RX_HBUF 0x04\t/* Rx: buffer error */\n#define RX_STP 0x02\t/* Rx: start of packet */\n#define RX_ENP 0x01\t/* Rx: end of packet */",
"/* Interrupts from the card are caused by various events which are presented\n * in a circular buffer as several events may be processed on one physical int\n */\n#define MAX_CIRBUFF 32",
"struct cirbuff {\n\tu8 rdindex;\t\t/* read, then increment and wrap */\n\tu8 wrindex;\t\t/* write, then increment and wrap */\n\tu8 evntbuff[MAX_CIRBUFF];\n};",
"/* Interrupt event codes.\n * Where appropriate the two low order bits indicate the port number\n */\n#define CTLA_CHG 0x18\t/* Control signal changed */\n#define CTLB_CHG 0x19\n#define CTLC_CHG 0x1A\n#define CTLD_CHG 0x1B",
"#define INIT_CPLT 0x20\t/* Initialisation complete */\n#define INIT_FAIL 0x21\t/* Initialisation failed */",
"#define ABTA_SENT 0x24\t/* Abort sent */\n#define ABTB_SENT 0x25\n#define ABTC_SENT 0x26\n#define ABTD_SENT 0x27",
"#define TXA_UNDF 0x28\t/* Transmission underflow */\n#define TXB_UNDF 0x29\n#define TXC_UNDF 0x2A\n#define TXD_UNDF 0x2B",
"#define F56_INT 0x2C\n#define M32_INT 0x2D",
"#define TE1_ALMA 0x30",
"/* Port physical configuration. See farsync.h for field values */\nstruct port_cfg {\n\tu16 lineInterface;\t/* Physical interface type */\n\tu8 x25op;\t\t/* Unused at present */\n\tu8 internalClock;\t/* 1 => internal clock, 0 => external */\n\tu8 transparentMode;\t/* 1 => on, 0 => off */\n\tu8 invertClock;\t\t/* 0 => normal, 1 => inverted */\n\tu8 padBytes[6];\t\t/* Padding */\n\tu32 lineSpeed;\t\t/* Speed in bps */\n};",
"/* TE1 port physical configuration */\nstruct su_config {\n\tu32 dataRate;\n\tu8 clocking;\n\tu8 framing;\n\tu8 structure;\n\tu8 interface;\n\tu8 coding;\n\tu8 lineBuildOut;\n\tu8 equalizer;\n\tu8 transparentMode;\n\tu8 loopMode;\n\tu8 range;\n\tu8 txBufferMode;\n\tu8 rxBufferMode;\n\tu8 startingSlot;\n\tu8 losThreshold;\n\tu8 enableIdleCode;\n\tu8 idleCode;\n\tu8 spare[44];\n};",
"/* TE1 Status */\nstruct su_status {\n\tu32 receiveBufferDelay;\n\tu32 framingErrorCount;\n\tu32 codeViolationCount;\n\tu32 crcErrorCount;\n\tu32 lineAttenuation;\n\tu8 portStarted;\n\tu8 lossOfSignal;\n\tu8 receiveRemoteAlarm;\n\tu8 alarmIndicationSignal;\n\tu8 spare[40];\n};",
"/* Finally sling all the above together into the shared memory structure.\n * Sorry it's a hodge podge of arrays, structures and unused bits, it's been\n * evolving under NT for some time so I guess we're stuck with it.\n * The structure starts at offset SMC_BASE.\n * See farsync.h for some field values.\n */\nstruct fst_shared {\n\t/* DMA descriptor rings */\n\tstruct rxdesc rxDescrRing[FST_MAX_PORTS][NUM_RX_BUFFER];\n\tstruct txdesc txDescrRing[FST_MAX_PORTS][NUM_TX_BUFFER];",
"\t/* Obsolete small buffers */\n\tu8 smallRxBuffer[FST_MAX_PORTS][NUM_RX_BUFFER][LEN_SMALL_RX_BUFFER];\n\tu8 smallTxBuffer[FST_MAX_PORTS][NUM_TX_BUFFER][LEN_SMALL_TX_BUFFER];",
"\tu8 taskStatus;\t\t/* 0x00 => initialising, 0x01 => running,\n\t\t\t\t * 0xFF => halted\n\t\t\t\t */",
"\tu8 interruptHandshake;\t/* Set to 0x01 by adapter to signal interrupt,\n\t\t\t\t * set to 0xEE by host to acknowledge interrupt\n\t\t\t\t */",
"\tu16 smcVersion;\t\t/* Must match SMC_VERSION */",
"\tu32 smcFirmwareVersion;\t/* 0xIIVVRRBB where II = product ID, VV = major\n\t\t\t\t * version, RR = revision and BB = build\n\t\t\t\t */",
"\tu16 txa_done;\t\t/* Obsolete completion flags */\n\tu16 rxa_done;\n\tu16 txb_done;\n\tu16 rxb_done;\n\tu16 txc_done;\n\tu16 rxc_done;\n\tu16 txd_done;\n\tu16 rxd_done;",
"\tu16 mailbox[4];\t\t/* Diagnostics mailbox. Not used */",
"\tstruct cirbuff interruptEvent;\t/* interrupt causes */",
"\tu32 v24IpSts[FST_MAX_PORTS];\t/* V.24 control input status */\n\tu32 v24OpSts[FST_MAX_PORTS];\t/* V.24 control output status */",
"\tstruct port_cfg portConfig[FST_MAX_PORTS];",
"\tu16 clockStatus[FST_MAX_PORTS];\t/* lsb: 0=> present, 1=> absent */",
"\tu16 cableStatus;\t/* lsb: 0=> present, 1=> absent */",
"\tu16 txDescrIndex[FST_MAX_PORTS];\t/* transmit descriptor ring index */\n\tu16 rxDescrIndex[FST_MAX_PORTS];\t/* receive descriptor ring index */",
"\tu16 portMailbox[FST_MAX_PORTS][2];\t/* command, modifier */\n\tu16 cardMailbox[4];\t/* Not used */",
"\t/* Number of times the card thinks the host has\n\t * missed an interrupt by not acknowledging\n\t * within 2mS (I guess NT has problems)\n\t */\n\tu32 interruptRetryCount;",
"\t/* Driver private data used as an ID. We'll not\n\t * use this as I'd rather keep such things\n\t * in main memory rather than on the PCI bus\n\t */\n\tu32 portHandle[FST_MAX_PORTS];",
"\t/* Count of Tx underflows for stats */\n\tu32 transmitBufferUnderflow[FST_MAX_PORTS];",
"\t/* Debounced V.24 control input status */\n\tu32 v24DebouncedSts[FST_MAX_PORTS];",
"\t/* Adapter debounce timers. Don't touch */\n\tu32 ctsTimer[FST_MAX_PORTS];\n\tu32 ctsTimerRun[FST_MAX_PORTS];\n\tu32 dcdTimer[FST_MAX_PORTS];\n\tu32 dcdTimerRun[FST_MAX_PORTS];",
"\tu32 numberOfPorts;\t/* Number of ports detected at startup */",
"\tu16 _reserved[64];",
"\tu16 cardMode;\t\t/* Bit-mask to enable features:\n\t\t\t\t * Bit 0: 1 enables LED identify mode\n\t\t\t\t */",
"\tu16 portScheduleOffset;",
"\tstruct su_config suConfig;\t/* TE1 Bits */\n\tstruct su_status suStatus;",
"\tu32 endOfSmcSignature;\t/* endOfSmcSignature MUST be the last member of\n\t\t\t\t * the structure and marks the end of shared\n\t\t\t\t * memory. Adapter code initializes it as\n\t\t\t\t * END_SIG.\n\t\t\t\t */\n};",
"/* endOfSmcSignature value */\n#define END_SIG 0x12345678",
"/* Mailbox values. (portMailbox) */\n#define NOP 0\t/* No operation */\n#define ACK 1\t/* Positive acknowledgement to PC driver */\n#define NAK 2\t/* Negative acknowledgement to PC driver */\n#define STARTPORT 3\t/* Start an HDLC port */\n#define STOPPORT 4\t/* Stop an HDLC port */\n#define ABORTTX 5\t/* Abort the transmitter for a port */\n#define SETV24O 6\t/* Set V24 outputs */",
"/* PLX Chip Register Offsets */\n#define CNTRL_9052 0x50\t/* Control Register */\n#define CNTRL_9054 0x6c\t/* Control Register */",
"#define INTCSR_9052 0x4c\t/* Interrupt control/status register */\n#define INTCSR_9054 0x68\t/* Interrupt control/status register */",
"/* 9054 DMA Registers */\n/*\n * Note that we will be using DMA Channel 0 for copying rx data\n * and Channel 1 for copying tx data\n */\n#define DMAMODE0 0x80\n#define DMAPADR0 0x84\n#define DMALADR0 0x88\n#define DMASIZ0 0x8c\n#define DMADPR0 0x90\n#define DMAMODE1 0x94\n#define DMAPADR1 0x98\n#define DMALADR1 0x9c\n#define DMASIZ1 0xa0\n#define DMADPR1 0xa4\n#define DMACSR0 0xa8\n#define DMACSR1 0xa9\n#define DMAARB 0xac\n#define DMATHR 0xb0\n#define DMADAC0 0xb4\n#define DMADAC1 0xb8\n#define DMAMARBR 0xac",
"#define FST_MIN_DMA_LEN 64\n#define FST_RX_DMA_INT 0x01\n#define FST_TX_DMA_INT 0x02\n#define FST_CARD_INT 0x04",
"/* Larger buffers are positioned in memory at offset BFM_BASE */\nstruct buf_window {\n\tu8 txBuffer[FST_MAX_PORTS][NUM_TX_BUFFER][LEN_TX_BUFFER];\n\tu8 rxBuffer[FST_MAX_PORTS][NUM_RX_BUFFER][LEN_RX_BUFFER];\n};",
"/* Calculate offset of a buffer object within the shared memory window */\n#define BUF_OFFSET(X) (BFM_BASE + offsetof(struct buf_window, X))",
"#pragma pack()",
"/* Device driver private information\n * =================================\n */\n/* Per port (line or channel) information\n */\nstruct fst_port_info {\n struct net_device *dev; /* Device struct - must be first */\n\tstruct fst_card_info *card;\t/* Card we're associated with */\n\tint index;\t\t/* Port index on the card */\n\tint hwif;\t\t/* Line hardware (lineInterface copy) */\n\tint run;\t\t/* Port is running */\n\tint mode;\t\t/* Normal or FarSync raw */\n\tint rxpos;\t\t/* Next Rx buffer to use */\n\tint txpos;\t\t/* Next Tx buffer to use */\n\tint txipos;\t\t/* Next Tx buffer to check for free */\n\tint start;\t\t/* Indication of start/stop to network */\n\t/*\n\t * A sixteen entry transmit queue\n\t */\n\tint txqs;\t\t/* index to get next buffer to tx */\n\tint txqe;\t\t/* index to queue next packet */\n\tstruct sk_buff *txq[FST_TXQ_DEPTH];\t/* The queue */\n\tint rxqdepth;\n};",
"/* Per card information\n */\nstruct fst_card_info {\n\tchar __iomem *mem;\t/* Card memory mapped to kernel space */\n\tchar __iomem *ctlmem;\t/* Control memory for PCI cards */\n\tunsigned int phys_mem;\t/* Physical memory window address */\n\tunsigned int phys_ctlmem;\t/* Physical control memory address */\n\tunsigned int irq;\t/* Interrupt request line number */\n\tunsigned int nports;\t/* Number of serial ports */\n\tunsigned int type;\t/* Type index of card */\n\tunsigned int state;\t/* State of card */\n\tspinlock_t card_lock;\t/* Lock for SMP access */\n\tunsigned short pci_conf;\t/* PCI card config in I/O space */\n\t/* Per port info */\n\tstruct fst_port_info ports[FST_MAX_PORTS];\n\tstruct pci_dev *device;\t/* Information about the pci device */\n\tint card_no;\t\t/* Inst of the card on the system */\n\tint family;\t\t/* TxP or TxU */\n\tint dmarx_in_progress;\n\tint dmatx_in_progress;\n\tunsigned long int_count;\n\tunsigned long int_time_ave;\n\tvoid *rx_dma_handle_host;\n\tdma_addr_t rx_dma_handle_card;\n\tvoid *tx_dma_handle_host;\n\tdma_addr_t tx_dma_handle_card;\n\tstruct sk_buff *dma_skb_rx;\n\tstruct fst_port_info *dma_port_rx;\n\tstruct fst_port_info *dma_port_tx;\n\tint dma_len_rx;\n\tint dma_len_tx;\n\tint dma_txpos;\n\tint dma_rxpos;\n};",
"/* Convert an HDLC device pointer into a port info pointer and similar */\n#define dev_to_port(D) (dev_to_hdlc(D)->priv)\n#define port_to_dev(P) ((P)->dev)",
"\n/*\n * Shared memory window access macros\n *\n * We have a nice memory based structure above, which could be directly\n * mapped on i386 but might not work on other architectures unless we use\n * the readb,w,l and writeb,w,l macros. Unfortunately these macros take\n * physical offsets so we have to convert. The only saving grace is that\n * this should all collapse back to a simple indirection eventually.\n */\n#define WIN_OFFSET(X) ((long)&(((struct fst_shared *)SMC_BASE)->X))",
"#define FST_RDB(C,E) readb ((C)->mem + WIN_OFFSET(E))\n#define FST_RDW(C,E) readw ((C)->mem + WIN_OFFSET(E))\n#define FST_RDL(C,E) readl ((C)->mem + WIN_OFFSET(E))",
"#define FST_WRB(C,E,B) writeb ((B), (C)->mem + WIN_OFFSET(E))\n#define FST_WRW(C,E,W) writew ((W), (C)->mem + WIN_OFFSET(E))\n#define FST_WRL(C,E,L) writel ((L), (C)->mem + WIN_OFFSET(E))",
"/*\n * Debug support\n */\n#if FST_DEBUG",
"static int fst_debug_mask = { FST_DEBUG };",
"/* Most common debug activity is to print something if the corresponding bit\n * is set in the debug mask. Note: this uses a non-ANSI extension in GCC to\n * support variable numbers of macro parameters. The inverted if prevents us\n * eating someone else's else clause.\n */\n#define dbg(F, fmt, args...)\t\t\t\t\t\\\ndo {\t\t\t\t\t\t\t\t\\\n\tif (fst_debug_mask & (F))\t\t\t\t\\\n\t\tprintk(KERN_DEBUG pr_fmt(fmt), ##args);\t\t\\\n} while (0)\n#else\n#define dbg(F, fmt, args...)\t\t\t\t\t\\\ndo {\t\t\t\t\t\t\t\t\\\n\tif (0)\t\t\t\t\t\t\t\\\n\t\tprintk(KERN_DEBUG pr_fmt(fmt), ##args);\t\t\\\n} while (0)\n#endif",
"/*\n * PCI ID lookup table\n */\nstatic DEFINE_PCI_DEVICE_TABLE(fst_pci_dev_id) = {\n\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T2P, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_T2P},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T4P, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_T4P},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T1U, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_T1U},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T2U, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_T2U},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T4U, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_T4U},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_TE1, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_TE1},",
"\t{PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_TE1C, PCI_ANY_ID, \n\t PCI_ANY_ID, 0, 0, FST_TYPE_TE1},\n\t{0,}\t\t\t/* End */\n};",
"MODULE_DEVICE_TABLE(pci, fst_pci_dev_id);",
"/*\n * Device Driver Work Queues\n *\n * So that we don't spend too much time processing events in the \n * Interrupt Service routine, we will declare a work queue per Card \n * and make the ISR schedule a task in the queue for later execution.\n * In the 2.4 Kernel we used to use the immediate queue for BH's\n * Now that they are gone, tasklets seem to be much better than work \n * queues.\n */",
"static void do_bottom_half_tx(struct fst_card_info *card);\nstatic void do_bottom_half_rx(struct fst_card_info *card);\nstatic void fst_process_tx_work_q(unsigned long work_q);\nstatic void fst_process_int_work_q(unsigned long work_q);",
"static DECLARE_TASKLET(fst_tx_task, fst_process_tx_work_q, 0);\nstatic DECLARE_TASKLET(fst_int_task, fst_process_int_work_q, 0);",
"static struct fst_card_info *fst_card_array[FST_MAX_CARDS];\nstatic spinlock_t fst_work_q_lock;\nstatic u64 fst_work_txq;\nstatic u64 fst_work_intq;",
"static void\nfst_q_work_item(u64 * queue, int card_index)\n{\n\tunsigned long flags;\n\tu64 mask;",
"\t/*\n\t * Grab the queue exclusively\n\t */\n\tspin_lock_irqsave(&fst_work_q_lock, flags);",
"\t/*\n\t * Making an entry in the queue is simply a matter of setting\n\t * a bit for the card indicating that there is work to do in the\n\t * bottom half for the card. Note the limitation of 64 cards.\n\t * That ought to be enough\n\t */\n\tmask = (u64)1 << card_index;\n\t*queue |= mask;\n\tspin_unlock_irqrestore(&fst_work_q_lock, flags);\n}",
"static void\nfst_process_tx_work_q(unsigned long /*void **/work_q)\n{\n\tunsigned long flags;\n\tu64 work_txq;\n\tint i;",
"\t/*\n\t * Grab the queue exclusively\n\t */\n\tdbg(DBG_TX, \"fst_process_tx_work_q\\n\");\n\tspin_lock_irqsave(&fst_work_q_lock, flags);\n\twork_txq = fst_work_txq;\n\tfst_work_txq = 0;\n\tspin_unlock_irqrestore(&fst_work_q_lock, flags);",
"\t/*\n\t * Call the bottom half for each card with work waiting\n\t */\n\tfor (i = 0; i < FST_MAX_CARDS; i++) {\n\t\tif (work_txq & 0x01) {\n\t\t\tif (fst_card_array[i] != NULL) {\n\t\t\t\tdbg(DBG_TX, \"Calling tx bh for card %d\\n\", i);\n\t\t\t\tdo_bottom_half_tx(fst_card_array[i]);\n\t\t\t}\n\t\t}\n\t\twork_txq = work_txq >> 1;\n\t}\n}",
"static void\nfst_process_int_work_q(unsigned long /*void **/work_q)\n{\n\tunsigned long flags;\n\tu64 work_intq;\n\tint i;",
"\t/*\n\t * Grab the queue exclusively\n\t */\n\tdbg(DBG_INTR, \"fst_process_int_work_q\\n\");\n\tspin_lock_irqsave(&fst_work_q_lock, flags);\n\twork_intq = fst_work_intq;\n\tfst_work_intq = 0;\n\tspin_unlock_irqrestore(&fst_work_q_lock, flags);",
"\t/*\n\t * Call the bottom half for each card with work waiting\n\t */\n\tfor (i = 0; i < FST_MAX_CARDS; i++) {\n\t\tif (work_intq & 0x01) {\n\t\t\tif (fst_card_array[i] != NULL) {\n\t\t\t\tdbg(DBG_INTR,\n\t\t\t\t \"Calling rx & tx bh for card %d\\n\", i);\n\t\t\t\tdo_bottom_half_rx(fst_card_array[i]);\n\t\t\t\tdo_bottom_half_tx(fst_card_array[i]);\n\t\t\t}\n\t\t}\n\t\twork_intq = work_intq >> 1;\n\t}\n}",
"/* Card control functions\n * ======================\n */\n/* Place the processor in reset state\n *\n * Used to be a simple write to card control space but a glitch in the latest\n * AMD Am186CH processor means that we now have to do it by asserting and de-\n * asserting the PLX chip PCI Adapter Software Reset. Bit 30 in CNTRL register\n * at offset 9052_CNTRL. Note the updates for the TXU.\n */\nstatic inline void\nfst_cpureset(struct fst_card_info *card)\n{\n\tunsigned char interrupt_line_register;\n\tunsigned long j = jiffies + 1;\n\tunsigned int regval;",
"\tif (card->family == FST_FAMILY_TXU) {\n\t\tif (pci_read_config_byte\n\t\t (card->device, PCI_INTERRUPT_LINE, &interrupt_line_register)) {\n\t\t\tdbg(DBG_ASS,\n\t\t\t \"Error in reading interrupt line register\\n\");\n\t\t}\n\t\t/*\n\t\t * Assert PLX software reset and Am186 hardware reset\n\t\t * and then deassert the PLX software reset but 186 still in reset\n\t\t */\n\t\toutw(0x440f, card->pci_conf + CNTRL_9054 + 2);\n\t\toutw(0x040f, card->pci_conf + CNTRL_9054 + 2);\n\t\t/*\n\t\t * We are delaying here to allow the 9054 to reset itself\n\t\t */\n\t\tj = jiffies + 1;\n\t\twhile (jiffies < j)\n\t\t\t/* Do nothing */ ;\n\t\toutw(0x240f, card->pci_conf + CNTRL_9054 + 2);\n\t\t/*\n\t\t * We are delaying here to allow the 9054 to reload its eeprom\n\t\t */\n\t\tj = jiffies + 1;\n\t\twhile (jiffies < j)\n\t\t\t/* Do nothing */ ;\n\t\toutw(0x040f, card->pci_conf + CNTRL_9054 + 2);",
"\t\tif (pci_write_config_byte\n\t\t (card->device, PCI_INTERRUPT_LINE, interrupt_line_register)) {\n\t\t\tdbg(DBG_ASS,\n\t\t\t \"Error in writing interrupt line register\\n\");\n\t\t}",
"\t} else {\n\t\tregval = inl(card->pci_conf + CNTRL_9052);",
"\t\toutl(regval | 0x40000000, card->pci_conf + CNTRL_9052);\n\t\toutl(regval & ~0x40000000, card->pci_conf + CNTRL_9052);\n\t}\n}",
"/* Release the processor from reset\n */\nstatic inline void\nfst_cpurelease(struct fst_card_info *card)\n{\n\tif (card->family == FST_FAMILY_TXU) {\n\t\t/*\n\t\t * Force posted writes to complete\n\t\t */\n\t\t(void) readb(card->mem);",
"\t\t/*\n\t\t * Release LRESET DO = 1\n\t\t * Then release Local Hold, DO = 1\n\t\t */\n\t\toutw(0x040e, card->pci_conf + CNTRL_9054 + 2);\n\t\toutw(0x040f, card->pci_conf + CNTRL_9054 + 2);\n\t} else {\n\t\t(void) readb(card->ctlmem);\n\t}\n}",
"/* Clear the cards interrupt flag\n */\nstatic inline void\nfst_clear_intr(struct fst_card_info *card)\n{\n\tif (card->family == FST_FAMILY_TXU) {\n\t\t(void) readb(card->ctlmem);\n\t} else {\n\t\t/* Poke the appropriate PLX chip register (same as enabling interrupts)\n\t\t */\n\t\toutw(0x0543, card->pci_conf + INTCSR_9052);\n\t}\n}",
"/* Enable card interrupts\n */\nstatic inline void\nfst_enable_intr(struct fst_card_info *card)\n{\n\tif (card->family == FST_FAMILY_TXU) {\n\t\toutl(0x0f0c0900, card->pci_conf + INTCSR_9054);\n\t} else {\n\t\toutw(0x0543, card->pci_conf + INTCSR_9052);\n\t}\n}",
"/* Disable card interrupts\n */\nstatic inline void\nfst_disable_intr(struct fst_card_info *card)\n{\n\tif (card->family == FST_FAMILY_TXU) {\n\t\toutl(0x00000000, card->pci_conf + INTCSR_9054);\n\t} else {\n\t\toutw(0x0000, card->pci_conf + INTCSR_9052);\n\t}\n}",
"/* Process the result of trying to pass a received frame up the stack\n */\nstatic void\nfst_process_rx_status(int rx_status, char *name)\n{\n\tswitch (rx_status) {\n\tcase NET_RX_SUCCESS:\n\t\t{\n\t\t\t/*\n\t\t\t * Nothing to do here\n\t\t\t */\n\t\t\tbreak;\n\t\t}\n\tcase NET_RX_DROP:\n\t\t{\n\t\t\tdbg(DBG_ASS, \"%s: Received packet dropped\\n\", name);\n\t\t\tbreak;\n\t\t}\n\t}\n}",
"/* Initilaise DMA for PLX 9054\n */\nstatic inline void\nfst_init_dma(struct fst_card_info *card)\n{\n\t/*\n\t * This is only required for the PLX 9054\n\t */\n\tif (card->family == FST_FAMILY_TXU) {\n\t pci_set_master(card->device);\n\t\toutl(0x00020441, card->pci_conf + DMAMODE0);\n\t\toutl(0x00020441, card->pci_conf + DMAMODE1);\n\t\toutl(0x0, card->pci_conf + DMATHR);\n\t}\n}",
"/* Tx dma complete interrupt\n */\nstatic void\nfst_tx_dma_complete(struct fst_card_info *card, struct fst_port_info *port,\n\t\t int len, int txpos)\n{\n\tstruct net_device *dev = port_to_dev(port);",
"\t/*\n\t * Everything is now set, just tell the card to go\n\t */\n\tdbg(DBG_TX, \"fst_tx_dma_complete\\n\");\n\tFST_WRB(card, txDescrRing[port->index][txpos].bits,\n\t\tDMA_OWN | TX_STP | TX_ENP);\n\tdev->stats.tx_packets++;\n\tdev->stats.tx_bytes += len;\n\tdev->trans_start = jiffies;\n}",
"/*\n * Mark it for our own raw sockets interface\n */\nstatic __be16 farsync_type_trans(struct sk_buff *skb, struct net_device *dev)\n{\n\tskb->dev = dev;\n\tskb_reset_mac_header(skb);\n\tskb->pkt_type = PACKET_HOST;\n\treturn htons(ETH_P_CUST);\n}",
"/* Rx dma complete interrupt\n */\nstatic void\nfst_rx_dma_complete(struct fst_card_info *card, struct fst_port_info *port,\n\t\t int len, struct sk_buff *skb, int rxp)\n{\n\tstruct net_device *dev = port_to_dev(port);\n\tint pi;\n\tint rx_status;",
"\tdbg(DBG_TX, \"fst_rx_dma_complete\\n\");\n\tpi = port->index;\n\tmemcpy(skb_put(skb, len), card->rx_dma_handle_host, len);",
"\t/* Reset buffer descriptor */\n\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);",
"\t/* Update stats */\n\tdev->stats.rx_packets++;\n\tdev->stats.rx_bytes += len;",
"\t/* Push upstream */\n\tdbg(DBG_RX, \"Pushing the frame up the stack\\n\");\n\tif (port->mode == FST_RAW)\n\t\tskb->protocol = farsync_type_trans(skb, dev);\n\telse\n\t\tskb->protocol = hdlc_type_trans(skb, dev);\n\trx_status = netif_rx(skb);\n\tfst_process_rx_status(rx_status, port_to_dev(port)->name);\n\tif (rx_status == NET_RX_DROP)\n\t\tdev->stats.rx_dropped++;\n}",
"/*\n * Receive a frame through the DMA\n */\nstatic inline void\nfst_rx_dma(struct fst_card_info *card, dma_addr_t skb,\n\t dma_addr_t mem, int len)\n{\n\t/*\n\t * This routine will setup the DMA and start it\n\t */",
"\tdbg(DBG_RX, \"In fst_rx_dma %lx %lx %d\\n\",\n\t (unsigned long) skb, (unsigned long) mem, len);\n\tif (card->dmarx_in_progress) {\n\t\tdbg(DBG_ASS, \"In fst_rx_dma while dma in progress\\n\");\n\t}",
"\toutl(skb, card->pci_conf + DMAPADR0);\t/* Copy to here */\n\toutl(mem, card->pci_conf + DMALADR0);\t/* from here */\n\toutl(len, card->pci_conf + DMASIZ0);\t/* for this length */\n\toutl(0x00000000c, card->pci_conf + DMADPR0);\t/* In this direction */",
"\t/*\n\t * We use the dmarx_in_progress flag to flag the channel as busy\n\t */\n\tcard->dmarx_in_progress = 1;\n\toutb(0x03, card->pci_conf + DMACSR0);\t/* Start the transfer */\n}",
"/*\n * Send a frame through the DMA\n */\nstatic inline void\nfst_tx_dma(struct fst_card_info *card, unsigned char *skb,\n\t unsigned char *mem, int len)\n{\n\t/*\n\t * This routine will setup the DMA and start it.\n\t */",
"\tdbg(DBG_TX, \"In fst_tx_dma %p %p %d\\n\", skb, mem, len);\n\tif (card->dmatx_in_progress) {\n\t\tdbg(DBG_ASS, \"In fst_tx_dma while dma in progress\\n\");\n\t}",
"\toutl((unsigned long) skb, card->pci_conf + DMAPADR1);\t/* Copy from here */\n\toutl((unsigned long) mem, card->pci_conf + DMALADR1);\t/* to here */\n\toutl(len, card->pci_conf + DMASIZ1);\t/* for this length */\n\toutl(0x000000004, card->pci_conf + DMADPR1);\t/* In this direction */",
"\t/*\n\t * We use the dmatx_in_progress to flag the channel as busy\n\t */\n\tcard->dmatx_in_progress = 1;\n\toutb(0x03, card->pci_conf + DMACSR1);\t/* Start the transfer */\n}",
"/* Issue a Mailbox command for a port.\n * Note we issue them on a fire and forget basis, not expecting to see an\n * error and not waiting for completion.\n */\nstatic void\nfst_issue_cmd(struct fst_port_info *port, unsigned short cmd)\n{\n\tstruct fst_card_info *card;\n\tunsigned short mbval;\n\tunsigned long flags;\n\tint safety;",
"\tcard = port->card;\n\tspin_lock_irqsave(&card->card_lock, flags);\n\tmbval = FST_RDW(card, portMailbox[port->index][0]);",
"\tsafety = 0;\n\t/* Wait for any previous command to complete */\n\twhile (mbval > NAK) {\n\t\tspin_unlock_irqrestore(&card->card_lock, flags);\n\t\tschedule_timeout_uninterruptible(1);\n\t\tspin_lock_irqsave(&card->card_lock, flags);",
"\t\tif (++safety > 2000) {\n\t\t\tpr_err(\"Mailbox safety timeout\\n\");\n\t\t\tbreak;\n\t\t}",
"\t\tmbval = FST_RDW(card, portMailbox[port->index][0]);\n\t}\n\tif (safety > 0) {\n\t\tdbg(DBG_CMD, \"Mailbox clear after %d jiffies\\n\", safety);\n\t}\n\tif (mbval == NAK) {\n\t\tdbg(DBG_CMD, \"issue_cmd: previous command was NAK'd\\n\");\n\t}",
"\tFST_WRW(card, portMailbox[port->index][0], cmd);",
"\tif (cmd == ABORTTX || cmd == STARTPORT) {\n\t\tport->txpos = 0;\n\t\tport->txipos = 0;\n\t\tport->start = 0;\n\t}",
"\tspin_unlock_irqrestore(&card->card_lock, flags);\n}",
"/* Port output signals control\n */\nstatic inline void\nfst_op_raise(struct fst_port_info *port, unsigned int outputs)\n{\n\toutputs |= FST_RDL(port->card, v24OpSts[port->index]);\n\tFST_WRL(port->card, v24OpSts[port->index], outputs);",
"\tif (port->run)\n\t\tfst_issue_cmd(port, SETV24O);\n}",
"static inline void\nfst_op_lower(struct fst_port_info *port, unsigned int outputs)\n{\n\toutputs = ~outputs & FST_RDL(port->card, v24OpSts[port->index]);\n\tFST_WRL(port->card, v24OpSts[port->index], outputs);",
"\tif (port->run)\n\t\tfst_issue_cmd(port, SETV24O);\n}",
"/*\n * Setup port Rx buffers\n */\nstatic void\nfst_rx_config(struct fst_port_info *port)\n{\n\tint i;\n\tint pi;\n\tunsigned int offset;\n\tunsigned long flags;\n\tstruct fst_card_info *card;",
"\tpi = port->index;\n\tcard = port->card;\n\tspin_lock_irqsave(&card->card_lock, flags);\n\tfor (i = 0; i < NUM_RX_BUFFER; i++) {\n\t\toffset = BUF_OFFSET(rxBuffer[pi][i][0]);",
"\t\tFST_WRW(card, rxDescrRing[pi][i].ladr, (u16) offset);\n\t\tFST_WRB(card, rxDescrRing[pi][i].hadr, (u8) (offset >> 16));\n\t\tFST_WRW(card, rxDescrRing[pi][i].bcnt, cnv_bcnt(LEN_RX_BUFFER));\n\t\tFST_WRW(card, rxDescrRing[pi][i].mcnt, LEN_RX_BUFFER);\n\t\tFST_WRB(card, rxDescrRing[pi][i].bits, DMA_OWN);\n\t}\n\tport->rxpos = 0;\n\tspin_unlock_irqrestore(&card->card_lock, flags);\n}",
"/*\n * Setup port Tx buffers\n */\nstatic void\nfst_tx_config(struct fst_port_info *port)\n{\n\tint i;\n\tint pi;\n\tunsigned int offset;\n\tunsigned long flags;\n\tstruct fst_card_info *card;",
"\tpi = port->index;\n\tcard = port->card;\n\tspin_lock_irqsave(&card->card_lock, flags);\n\tfor (i = 0; i < NUM_TX_BUFFER; i++) {\n\t\toffset = BUF_OFFSET(txBuffer[pi][i][0]);",
"\t\tFST_WRW(card, txDescrRing[pi][i].ladr, (u16) offset);\n\t\tFST_WRB(card, txDescrRing[pi][i].hadr, (u8) (offset >> 16));\n\t\tFST_WRW(card, txDescrRing[pi][i].bcnt, 0);\n\t\tFST_WRB(card, txDescrRing[pi][i].bits, 0);\n\t}\n\tport->txpos = 0;\n\tport->txipos = 0;\n\tport->start = 0;\n\tspin_unlock_irqrestore(&card->card_lock, flags);\n}",
"/* TE1 Alarm change interrupt event\n */\nstatic void\nfst_intr_te1_alarm(struct fst_card_info *card, struct fst_port_info *port)\n{\n\tu8 los;\n\tu8 rra;\n\tu8 ais;",
"\tlos = FST_RDB(card, suStatus.lossOfSignal);\n\trra = FST_RDB(card, suStatus.receiveRemoteAlarm);\n\tais = FST_RDB(card, suStatus.alarmIndicationSignal);",
"\tif (los) {\n\t\t/*\n\t\t * Lost the link\n\t\t */\n\t\tif (netif_carrier_ok(port_to_dev(port))) {\n\t\t\tdbg(DBG_INTR, \"Net carrier off\\n\");\n\t\t\tnetif_carrier_off(port_to_dev(port));\n\t\t}\n\t} else {\n\t\t/*\n\t\t * Link available\n\t\t */\n\t\tif (!netif_carrier_ok(port_to_dev(port))) {\n\t\t\tdbg(DBG_INTR, \"Net carrier on\\n\");\n\t\t\tnetif_carrier_on(port_to_dev(port));\n\t\t}\n\t}",
"\tif (los)\n\t\tdbg(DBG_INTR, \"Assert LOS Alarm\\n\");\n\telse\n\t\tdbg(DBG_INTR, \"De-assert LOS Alarm\\n\");\n\tif (rra)\n\t\tdbg(DBG_INTR, \"Assert RRA Alarm\\n\");\n\telse\n\t\tdbg(DBG_INTR, \"De-assert RRA Alarm\\n\");",
"\tif (ais)\n\t\tdbg(DBG_INTR, \"Assert AIS Alarm\\n\");\n\telse\n\t\tdbg(DBG_INTR, \"De-assert AIS Alarm\\n\");\n}",
"/* Control signal change interrupt event\n */\nstatic void\nfst_intr_ctlchg(struct fst_card_info *card, struct fst_port_info *port)\n{\n\tint signals;",
"\tsignals = FST_RDL(card, v24DebouncedSts[port->index]);",
"\tif (signals & (((port->hwif == X21) || (port->hwif == X21D))\n\t\t ? IPSTS_INDICATE : IPSTS_DCD)) {\n\t\tif (!netif_carrier_ok(port_to_dev(port))) {\n\t\t\tdbg(DBG_INTR, \"DCD active\\n\");\n\t\t\tnetif_carrier_on(port_to_dev(port));\n\t\t}\n\t} else {\n\t\tif (netif_carrier_ok(port_to_dev(port))) {\n\t\t\tdbg(DBG_INTR, \"DCD lost\\n\");\n\t\t\tnetif_carrier_off(port_to_dev(port));\n\t\t}\n\t}\n}",
"/* Log Rx Errors\n */\nstatic void\nfst_log_rx_error(struct fst_card_info *card, struct fst_port_info *port,\n\t\t unsigned char dmabits, int rxp, unsigned short len)\n{\n\tstruct net_device *dev = port_to_dev(port);",
"\t/*\n\t * Increment the appropriate error counter\n\t */\n\tdev->stats.rx_errors++;\n\tif (dmabits & RX_OFLO) {\n\t\tdev->stats.rx_fifo_errors++;\n\t\tdbg(DBG_ASS, \"Rx fifo error on card %d port %d buffer %d\\n\",\n\t\t card->card_no, port->index, rxp);\n\t}\n\tif (dmabits & RX_CRC) {\n\t\tdev->stats.rx_crc_errors++;\n\t\tdbg(DBG_ASS, \"Rx crc error on card %d port %d\\n\",\n\t\t card->card_no, port->index);\n\t}\n\tif (dmabits & RX_FRAM) {\n\t\tdev->stats.rx_frame_errors++;\n\t\tdbg(DBG_ASS, \"Rx frame error on card %d port %d\\n\",\n\t\t card->card_no, port->index);\n\t}\n\tif (dmabits == (RX_STP | RX_ENP)) {\n\t\tdev->stats.rx_length_errors++;\n\t\tdbg(DBG_ASS, \"Rx length error (%d) on card %d port %d\\n\",\n\t\t len, card->card_no, port->index);\n\t}\n}",
"/* Rx Error Recovery\n */\nstatic void\nfst_recover_rx_error(struct fst_card_info *card, struct fst_port_info *port,\n\t\t unsigned char dmabits, int rxp, unsigned short len)\n{\n\tint i;\n\tint pi;",
"\tpi = port->index;\n\t/* \n\t * Discard buffer descriptors until we see the start of the\n\t * next frame. Note that for long frames this could be in\n\t * a subsequent interrupt. \n\t */\n\ti = 0;\n\twhile ((dmabits & (DMA_OWN | RX_STP)) == 0) {\n\t\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);\n\t\trxp = (rxp+1) % NUM_RX_BUFFER;\n\t\tif (++i > NUM_RX_BUFFER) {\n\t\t\tdbg(DBG_ASS, \"intr_rx: Discarding more bufs\"\n\t\t\t \" than we have\\n\");\n\t\t\tbreak;\n\t\t}\n\t\tdmabits = FST_RDB(card, rxDescrRing[pi][rxp].bits);\n\t\tdbg(DBG_ASS, \"DMA Bits of next buffer was %x\\n\", dmabits);\n\t}\n\tdbg(DBG_ASS, \"There were %d subsequent buffers in error\\n\", i);",
"\t/* Discard the terminal buffer */\n\tif (!(dmabits & DMA_OWN)) {\n\t\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);\n\t\trxp = (rxp+1) % NUM_RX_BUFFER;\n\t}\n\tport->rxpos = rxp;\n\treturn;",
"}",
"/* Rx complete interrupt\n */\nstatic void\nfst_intr_rx(struct fst_card_info *card, struct fst_port_info *port)\n{\n\tunsigned char dmabits;\n\tint pi;\n\tint rxp;\n\tint rx_status;\n\tunsigned short len;\n\tstruct sk_buff *skb;\n\tstruct net_device *dev = port_to_dev(port);",
"\t/* Check we have a buffer to process */\n\tpi = port->index;\n\trxp = port->rxpos;\n\tdmabits = FST_RDB(card, rxDescrRing[pi][rxp].bits);\n\tif (dmabits & DMA_OWN) {\n\t\tdbg(DBG_RX | DBG_INTR, \"intr_rx: No buffer port %d pos %d\\n\",\n\t\t pi, rxp);\n\t\treturn;\n\t}\n\tif (card->dmarx_in_progress) {\n\t\treturn;\n\t}",
"\t/* Get buffer length */\n\tlen = FST_RDW(card, rxDescrRing[pi][rxp].mcnt);\n\t/* Discard the CRC */\n\tlen -= 2;\n\tif (len == 0) {\n\t\t/*\n\t\t * This seems to happen on the TE1 interface sometimes\n\t\t * so throw the frame away and log the event.\n\t\t */\n\t\tpr_err(\"Frame received with 0 length. Card %d Port %d\\n\",\n\t\t card->card_no, port->index);\n\t\t/* Return descriptor to card */\n\t\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);",
"\t\trxp = (rxp+1) % NUM_RX_BUFFER;\n\t\tport->rxpos = rxp;\n\t\treturn;\n\t}",
"\t/* Check buffer length and for other errors. We insist on one packet\n\t * in one buffer. This simplifies things greatly and since we've\n\t * allocated 8K it shouldn't be a real world limitation\n\t */\n\tdbg(DBG_RX, \"intr_rx: %d,%d: flags %x len %d\\n\", pi, rxp, dmabits, len);\n\tif (dmabits != (RX_STP | RX_ENP) || len > LEN_RX_BUFFER - 2) {\n\t\tfst_log_rx_error(card, port, dmabits, rxp, len);\n\t\tfst_recover_rx_error(card, port, dmabits, rxp, len);\n\t\treturn;\n\t}",
"\t/* Allocate SKB */\n\tif ((skb = dev_alloc_skb(len)) == NULL) {\n\t\tdbg(DBG_RX, \"intr_rx: can't allocate buffer\\n\");",
"\t\tdev->stats.rx_dropped++;",
"\t\t/* Return descriptor to card */\n\t\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);",
"\t\trxp = (rxp+1) % NUM_RX_BUFFER;\n\t\tport->rxpos = rxp;\n\t\treturn;\n\t}",
"\t/*\n\t * We know the length we need to receive, len.\n\t * It's not worth using the DMA for reads of less than\n\t * FST_MIN_DMA_LEN\n\t */",
"\tif ((len < FST_MIN_DMA_LEN) || (card->family == FST_FAMILY_TXP)) {\n\t\tmemcpy_fromio(skb_put(skb, len),\n\t\t\t card->mem + BUF_OFFSET(rxBuffer[pi][rxp][0]),\n\t\t\t len);",
"\t\t/* Reset buffer descriptor */\n\t\tFST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN);",
"\t\t/* Update stats */\n\t\tdev->stats.rx_packets++;\n\t\tdev->stats.rx_bytes += len;",
"\t\t/* Push upstream */\n\t\tdbg(DBG_RX, \"Pushing frame up the stack\\n\");\n\t\tif (port->mode == FST_RAW)\n\t\t\tskb->protocol = farsync_type_trans(skb, dev);\n\t\telse\n\t\t\tskb->protocol = hdlc_type_trans(skb, dev);\n\t\trx_status = netif_rx(skb);\n\t\tfst_process_rx_status(rx_status, port_to_dev(port)->name);\n\t\tif (rx_status == NET_RX_DROP)\n\t\t\tdev->stats.rx_dropped++;\n\t} else {\n\t\tcard->dma_skb_rx = skb;\n\t\tcard->dma_port_rx = port;\n\t\tcard->dma_len_rx = len;\n\t\tcard->dma_rxpos = rxp;\n\t\tfst_rx_dma(card, card->rx_dma_handle_card,\n\t\t\t BUF_OFFSET(rxBuffer[pi][rxp][0]), len);\n\t}\n\tif (rxp != port->rxpos) {\n\t\tdbg(DBG_ASS, \"About to increment rxpos by more than 1\\n\");\n\t\tdbg(DBG_ASS, \"rxp = %d rxpos = %d\\n\", rxp, port->rxpos);\n\t}\n\trxp = (rxp+1) % NUM_RX_BUFFER;\n\tport->rxpos = rxp;\n}",
"/*\n * The bottom halfs to the ISR\n *\n */",
"static void\ndo_bottom_half_tx(struct fst_card_info *card)\n{\n\tstruct fst_port_info *port;\n\tint pi;\n\tint txq_length;\n\tstruct sk_buff *skb;\n\tunsigned long flags;\n\tstruct net_device *dev;",
"\t/*\n\t * Find a free buffer for the transmit\n\t * Step through each port on this card\n\t */",
"\tdbg(DBG_TX, \"do_bottom_half_tx\\n\");\n\tfor (pi = 0, port = card->ports; pi < card->nports; pi++, port++) {\n\t\tif (!port->run)\n\t\t\tcontinue;",
"\t\tdev = port_to_dev(port);\n\t\twhile (!(FST_RDB(card, txDescrRing[pi][port->txpos].bits) &\n\t\t\t DMA_OWN) &&\n\t\t !(card->dmatx_in_progress)) {\n\t\t\t/*\n\t\t\t * There doesn't seem to be a txdone event per-se\n\t\t\t * We seem to have to deduce it, by checking the DMA_OWN\n\t\t\t * bit on the next buffer we think we can use\n\t\t\t */\n\t\t\tspin_lock_irqsave(&card->card_lock, flags);\n\t\t\tif ((txq_length = port->txqe - port->txqs) < 0) {\n\t\t\t\t/*\n\t\t\t\t * This is the case where one has wrapped and the\n\t\t\t\t * maths gives us a negative number\n\t\t\t\t */\n\t\t\t\ttxq_length = txq_length + FST_TXQ_DEPTH;\n\t\t\t}\n\t\t\tspin_unlock_irqrestore(&card->card_lock, flags);\n\t\t\tif (txq_length > 0) {\n\t\t\t\t/*\n\t\t\t\t * There is something to send\n\t\t\t\t */\n\t\t\t\tspin_lock_irqsave(&card->card_lock, flags);\n\t\t\t\tskb = port->txq[port->txqs];\n\t\t\t\tport->txqs++;\n\t\t\t\tif (port->txqs == FST_TXQ_DEPTH) {\n\t\t\t\t\tport->txqs = 0;\n\t\t\t\t}\n\t\t\t\tspin_unlock_irqrestore(&card->card_lock, flags);\n\t\t\t\t/*\n\t\t\t\t * copy the data and set the required indicators on the\n\t\t\t\t * card.\n\t\t\t\t */\n\t\t\t\tFST_WRW(card, txDescrRing[pi][port->txpos].bcnt,\n\t\t\t\t\tcnv_bcnt(skb->len));\n\t\t\t\tif ((skb->len < FST_MIN_DMA_LEN) ||\n\t\t\t\t (card->family == FST_FAMILY_TXP)) {\n\t\t\t\t\t/* Enqueue the packet with normal io */\n\t\t\t\t\tmemcpy_toio(card->mem +\n\t\t\t\t\t\t BUF_OFFSET(txBuffer[pi]\n\t\t\t\t\t\t\t [port->\n\t\t\t\t\t\t\t\ttxpos][0]),\n\t\t\t\t\t\t skb->data, skb->len);\n\t\t\t\t\tFST_WRB(card,\n\t\t\t\t\t\ttxDescrRing[pi][port->txpos].\n\t\t\t\t\t\tbits,\n\t\t\t\t\t\tDMA_OWN | TX_STP | TX_ENP);\n\t\t\t\t\tdev->stats.tx_packets++;\n\t\t\t\t\tdev->stats.tx_bytes += skb->len;\n\t\t\t\t\tdev->trans_start = jiffies;\n\t\t\t\t} else {\n\t\t\t\t\t/* Or do it through dma */\n\t\t\t\t\tmemcpy(card->tx_dma_handle_host,\n\t\t\t\t\t skb->data, skb->len);\n\t\t\t\t\tcard->dma_port_tx = port;\n\t\t\t\t\tcard->dma_len_tx = skb->len;\n\t\t\t\t\tcard->dma_txpos = port->txpos;\n\t\t\t\t\tfst_tx_dma(card,\n\t\t\t\t\t\t (char *) card->\n\t\t\t\t\t\t tx_dma_handle_card,\n\t\t\t\t\t\t (char *)\n\t\t\t\t\t\t BUF_OFFSET(txBuffer[pi]\n\t\t\t\t\t\t\t [port->txpos][0]),\n\t\t\t\t\t\t skb->len);\n\t\t\t\t}\n\t\t\t\tif (++port->txpos >= NUM_TX_BUFFER)\n\t\t\t\t\tport->txpos = 0;\n\t\t\t\t/*\n\t\t\t\t * If we have flow control on, can we now release it?\n\t\t\t\t */\n\t\t\t\tif (port->start) {\n\t\t\t\t\tif (txq_length < fst_txq_low) {\n\t\t\t\t\t\tnetif_wake_queue(port_to_dev\n\t\t\t\t\t\t\t\t (port));\n\t\t\t\t\t\tport->start = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdev_kfree_skb(skb);\n\t\t\t} else {\n\t\t\t\t/*\n\t\t\t\t * Nothing to send so break out of the while loop\n\t\t\t\t */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}",
"static void\ndo_bottom_half_rx(struct fst_card_info *card)\n{\n\tstruct fst_port_info *port;\n\tint pi;\n\tint rx_count = 0;",
"\t/* Check for rx completions on all ports on this card */\n\tdbg(DBG_RX, \"do_bottom_half_rx\\n\");\n\tfor (pi = 0, port = card->ports; pi < card->nports; pi++, port++) {\n\t\tif (!port->run)\n\t\t\tcontinue;",
"\t\twhile (!(FST_RDB(card, rxDescrRing[pi][port->rxpos].bits)\n\t\t\t & DMA_OWN) && !(card->dmarx_in_progress)) {\n\t\t\tif (rx_count > fst_max_reads) {\n\t\t\t\t/*\n\t\t\t\t * Don't spend forever in receive processing\n\t\t\t\t * Schedule another event\n\t\t\t\t */\n\t\t\t\tfst_q_work_item(&fst_work_intq, card->card_no);\n\t\t\t\ttasklet_schedule(&fst_int_task);\n\t\t\t\tbreak;\t/* Leave the loop */\n\t\t\t}\n\t\t\tfst_intr_rx(card, port);\n\t\t\trx_count++;\n\t\t}\n\t}\n}",
"/*\n * The interrupt service routine\n * Dev_id is our fst_card_info pointer\n */\nstatic irqreturn_t\nfst_intr(int dummy, void *dev_id)\n{\n\tstruct fst_card_info *card = dev_id;\n\tstruct fst_port_info *port;\n\tint rdidx;\t\t/* Event buffer indices */\n\tint wridx;\n\tint event;\t\t/* Actual event for processing */\n\tunsigned int dma_intcsr = 0;\n\tunsigned int do_card_interrupt;\n\tunsigned int int_retry_count;",
"\t/*\n\t * Check to see if the interrupt was for this card\n\t * return if not\n\t * Note that the call to clear the interrupt is important\n\t */\n\tdbg(DBG_INTR, \"intr: %d %p\\n\", card->irq, card);\n\tif (card->state != FST_RUNNING) {\n\t\tpr_err(\"Interrupt received for card %d in a non running state (%d)\\n\",\n\t\t card->card_no, card->state);",
"\t\t/* \n\t\t * It is possible to really be running, i.e. we have re-loaded\n\t\t * a running card\n\t\t * Clear and reprime the interrupt source \n\t\t */\n\t\tfst_clear_intr(card);\n\t\treturn IRQ_HANDLED;\n\t}",
"\t/* Clear and reprime the interrupt source */\n\tfst_clear_intr(card);",
"\t/*\n\t * Is the interrupt for this card (handshake == 1)\n\t */\n\tdo_card_interrupt = 0;\n\tif (FST_RDB(card, interruptHandshake) == 1) {\n\t\tdo_card_interrupt += FST_CARD_INT;\n\t\t/* Set the software acknowledge */\n\t\tFST_WRB(card, interruptHandshake, 0xEE);\n\t}\n\tif (card->family == FST_FAMILY_TXU) {\n\t\t/*\n\t\t * Is it a DMA Interrupt\n\t\t */\n\t\tdma_intcsr = inl(card->pci_conf + INTCSR_9054);\n\t\tif (dma_intcsr & 0x00200000) {\n\t\t\t/*\n\t\t\t * DMA Channel 0 (Rx transfer complete)\n\t\t\t */\n\t\t\tdbg(DBG_RX, \"DMA Rx xfer complete\\n\");\n\t\t\toutb(0x8, card->pci_conf + DMACSR0);\n\t\t\tfst_rx_dma_complete(card, card->dma_port_rx,\n\t\t\t\t\t card->dma_len_rx, card->dma_skb_rx,\n\t\t\t\t\t card->dma_rxpos);\n\t\t\tcard->dmarx_in_progress = 0;\n\t\t\tdo_card_interrupt += FST_RX_DMA_INT;\n\t\t}\n\t\tif (dma_intcsr & 0x00400000) {\n\t\t\t/*\n\t\t\t * DMA Channel 1 (Tx transfer complete)\n\t\t\t */\n\t\t\tdbg(DBG_TX, \"DMA Tx xfer complete\\n\");\n\t\t\toutb(0x8, card->pci_conf + DMACSR1);\n\t\t\tfst_tx_dma_complete(card, card->dma_port_tx,\n\t\t\t\t\t card->dma_len_tx, card->dma_txpos);\n\t\t\tcard->dmatx_in_progress = 0;\n\t\t\tdo_card_interrupt += FST_TX_DMA_INT;\n\t\t}\n\t}",
"\t/*\n\t * Have we been missing Interrupts\n\t */\n\tint_retry_count = FST_RDL(card, interruptRetryCount);\n\tif (int_retry_count) {\n\t\tdbg(DBG_ASS, \"Card %d int_retry_count is %d\\n\",\n\t\t card->card_no, int_retry_count);\n\t\tFST_WRL(card, interruptRetryCount, 0);\n\t}",
"\tif (!do_card_interrupt) {\n\t\treturn IRQ_HANDLED;\n\t}",
"\t/* Scehdule the bottom half of the ISR */\n\tfst_q_work_item(&fst_work_intq, card->card_no);\n\ttasklet_schedule(&fst_int_task);",
"\t/* Drain the event queue */\n\trdidx = FST_RDB(card, interruptEvent.rdindex) & 0x1f;\n\twridx = FST_RDB(card, interruptEvent.wrindex) & 0x1f;\n\twhile (rdidx != wridx) {\n\t\tevent = FST_RDB(card, interruptEvent.evntbuff[rdidx]);\n\t\tport = &card->ports[event & 0x03];",
"\t\tdbg(DBG_INTR, \"Processing Interrupt event: %x\\n\", event);",
"\t\tswitch (event) {\n\t\tcase TE1_ALMA:\n\t\t\tdbg(DBG_INTR, \"TE1 Alarm intr\\n\");\n\t\t\tif (port->run)\n\t\t\t\tfst_intr_te1_alarm(card, port);\n\t\t\tbreak;",
"\t\tcase CTLA_CHG:\n\t\tcase CTLB_CHG:\n\t\tcase CTLC_CHG:\n\t\tcase CTLD_CHG:\n\t\t\tif (port->run)\n\t\t\t\tfst_intr_ctlchg(card, port);\n\t\t\tbreak;",
"\t\tcase ABTA_SENT:\n\t\tcase ABTB_SENT:\n\t\tcase ABTC_SENT:\n\t\tcase ABTD_SENT:\n\t\t\tdbg(DBG_TX, \"Abort complete port %d\\n\", port->index);\n\t\t\tbreak;",
"\t\tcase TXA_UNDF:\n\t\tcase TXB_UNDF:\n\t\tcase TXC_UNDF:\n\t\tcase TXD_UNDF:\n\t\t\t/* Difficult to see how we'd get this given that we\n\t\t\t * always load up the entire packet for DMA.\n\t\t\t */\n\t\t\tdbg(DBG_TX, \"Tx underflow port %d\\n\", port->index);\n\t\t\tport_to_dev(port)->stats.tx_errors++;\n\t\t\tport_to_dev(port)->stats.tx_fifo_errors++;\n\t\t\tdbg(DBG_ASS, \"Tx underflow on card %d port %d\\n\",\n\t\t\t card->card_no, port->index);\n\t\t\tbreak;",
"\t\tcase INIT_CPLT:\n\t\t\tdbg(DBG_INIT, \"Card init OK intr\\n\");\n\t\t\tbreak;",
"\t\tcase INIT_FAIL:\n\t\t\tdbg(DBG_INIT, \"Card init FAILED intr\\n\");\n\t\t\tcard->state = FST_IFAILED;\n\t\t\tbreak;",
"\t\tdefault:\n\t\t\tpr_err(\"intr: unknown card event %d. ignored\\n\", event);\n\t\t\tbreak;\n\t\t}",
"\t\t/* Bump and wrap the index */\n\t\tif (++rdidx >= MAX_CIRBUFF)\n\t\t\trdidx = 0;\n\t}\n\tFST_WRB(card, interruptEvent.rdindex, rdidx);\n return IRQ_HANDLED;\n}",
"/* Check that the shared memory configuration is one that we can handle\n * and that some basic parameters are correct\n */\nstatic void\ncheck_started_ok(struct fst_card_info *card)\n{\n\tint i;",
"\t/* Check structure version and end marker */\n\tif (FST_RDW(card, smcVersion) != SMC_VERSION) {\n\t\tpr_err(\"Bad shared memory version %d expected %d\\n\",\n\t\t FST_RDW(card, smcVersion), SMC_VERSION);\n\t\tcard->state = FST_BADVERSION;\n\t\treturn;\n\t}\n\tif (FST_RDL(card, endOfSmcSignature) != END_SIG) {\n\t\tpr_err(\"Missing shared memory signature\\n\");\n\t\tcard->state = FST_BADVERSION;\n\t\treturn;\n\t}\n\t/* Firmware status flag, 0x00 = initialising, 0x01 = OK, 0xFF = fail */\n\tif ((i = FST_RDB(card, taskStatus)) == 0x01) {\n\t\tcard->state = FST_RUNNING;\n\t} else if (i == 0xFF) {\n\t\tpr_err(\"Firmware initialisation failed. Card halted\\n\");\n\t\tcard->state = FST_HALTED;\n\t\treturn;\n\t} else if (i != 0x00) {\n\t\tpr_err(\"Unknown firmware status 0x%x\\n\", i);\n\t\tcard->state = FST_HALTED;\n\t\treturn;\n\t}",
"\t/* Finally check the number of ports reported by firmware against the\n\t * number we assumed at card detection. Should never happen with\n\t * existing firmware etc so we just report it for the moment.\n\t */\n\tif (FST_RDL(card, numberOfPorts) != card->nports) {\n\t\tpr_warn(\"Port count mismatch on card %d. Firmware thinks %d we say %d\\n\",\n\t\t\tcard->card_no,\n\t\t\tFST_RDL(card, numberOfPorts), card->nports);\n\t}\n}",
"static int\nset_conf_from_info(struct fst_card_info *card, struct fst_port_info *port,\n\t\t struct fstioc_info *info)\n{\n\tint err;\n\tunsigned char my_framing;",
"\t/* Set things according to the user set valid flags \n\t * Several of the old options have been invalidated/replaced by the \n\t * generic hdlc package.\n\t */\n\terr = 0;\n\tif (info->valid & FSTVAL_PROTO) {\n\t\tif (info->proto == FST_RAW)\n\t\t\tport->mode = FST_RAW;\n\t\telse\n\t\t\tport->mode = FST_GEN_HDLC;\n\t}",
"\tif (info->valid & FSTVAL_CABLE)\n\t\terr = -EINVAL;",
"\tif (info->valid & FSTVAL_SPEED)\n\t\terr = -EINVAL;",
"\tif (info->valid & FSTVAL_PHASE)\n\t\tFST_WRB(card, portConfig[port->index].invertClock,\n\t\t\tinfo->invertClock);\n\tif (info->valid & FSTVAL_MODE)\n\t\tFST_WRW(card, cardMode, info->cardMode);\n\tif (info->valid & FSTVAL_TE1) {\n\t\tFST_WRL(card, suConfig.dataRate, info->lineSpeed);\n\t\tFST_WRB(card, suConfig.clocking, info->clockSource);\n\t\tmy_framing = FRAMING_E1;\n\t\tif (info->framing == E1)\n\t\t\tmy_framing = FRAMING_E1;\n\t\tif (info->framing == T1)\n\t\t\tmy_framing = FRAMING_T1;\n\t\tif (info->framing == J1)\n\t\t\tmy_framing = FRAMING_J1;\n\t\tFST_WRB(card, suConfig.framing, my_framing);\n\t\tFST_WRB(card, suConfig.structure, info->structure);\n\t\tFST_WRB(card, suConfig.interface, info->interface);\n\t\tFST_WRB(card, suConfig.coding, info->coding);\n\t\tFST_WRB(card, suConfig.lineBuildOut, info->lineBuildOut);\n\t\tFST_WRB(card, suConfig.equalizer, info->equalizer);\n\t\tFST_WRB(card, suConfig.transparentMode, info->transparentMode);\n\t\tFST_WRB(card, suConfig.loopMode, info->loopMode);\n\t\tFST_WRB(card, suConfig.range, info->range);\n\t\tFST_WRB(card, suConfig.txBufferMode, info->txBufferMode);\n\t\tFST_WRB(card, suConfig.rxBufferMode, info->rxBufferMode);\n\t\tFST_WRB(card, suConfig.startingSlot, info->startingSlot);\n\t\tFST_WRB(card, suConfig.losThreshold, info->losThreshold);\n\t\tif (info->idleCode)\n\t\t\tFST_WRB(card, suConfig.enableIdleCode, 1);\n\t\telse\n\t\t\tFST_WRB(card, suConfig.enableIdleCode, 0);\n\t\tFST_WRB(card, suConfig.idleCode, info->idleCode);\n#if FST_DEBUG\n\t\tif (info->valid & FSTVAL_TE1) {\n\t\t\tprintk(\"Setting TE1 data\\n\");\n\t\t\tprintk(\"Line Speed = %d\\n\", info->lineSpeed);\n\t\t\tprintk(\"Start slot = %d\\n\", info->startingSlot);\n\t\t\tprintk(\"Clock source = %d\\n\", info->clockSource);\n\t\t\tprintk(\"Framing = %d\\n\", my_framing);\n\t\t\tprintk(\"Structure = %d\\n\", info->structure);\n\t\t\tprintk(\"interface = %d\\n\", info->interface);\n\t\t\tprintk(\"Coding = %d\\n\", info->coding);\n\t\t\tprintk(\"Line build out = %d\\n\", info->lineBuildOut);\n\t\t\tprintk(\"Equaliser = %d\\n\", info->equalizer);\n\t\t\tprintk(\"Transparent mode = %d\\n\",\n\t\t\t info->transparentMode);\n\t\t\tprintk(\"Loop mode = %d\\n\", info->loopMode);\n\t\t\tprintk(\"Range = %d\\n\", info->range);\n\t\t\tprintk(\"Tx Buffer mode = %d\\n\", info->txBufferMode);\n\t\t\tprintk(\"Rx Buffer mode = %d\\n\", info->rxBufferMode);\n\t\t\tprintk(\"LOS Threshold = %d\\n\", info->losThreshold);\n\t\t\tprintk(\"Idle Code = %d\\n\", info->idleCode);\n\t\t}\n#endif\n\t}\n#if FST_DEBUG\n\tif (info->valid & FSTVAL_DEBUG) {\n\t\tfst_debug_mask = info->debug;\n\t}\n#endif",
"\treturn err;\n}",
"static void\ngather_conf_info(struct fst_card_info *card, struct fst_port_info *port,\n\t\t struct fstioc_info *info)\n{\n\tint i;",
"\tmemset(info, 0, sizeof (struct fstioc_info));",
"\ti = port->index;\n\tinfo->kernelVersion = LINUX_VERSION_CODE;\n\tinfo->nports = card->nports;\n\tinfo->type = card->type;\n\tinfo->state = card->state;\n\tinfo->proto = FST_GEN_HDLC;\n\tinfo->index = i;\n#if FST_DEBUG\n\tinfo->debug = fst_debug_mask;\n#endif",
"\t/* Only mark information as valid if card is running.\n\t * Copy the data anyway in case it is useful for diagnostics\n\t */\n\tinfo->valid = ((card->state == FST_RUNNING) ? FSTVAL_ALL : FSTVAL_CARD)\n#if FST_DEBUG\n\t | FSTVAL_DEBUG\n#endif\n\t ;",
"\tinfo->lineInterface = FST_RDW(card, portConfig[i].lineInterface);\n\tinfo->internalClock = FST_RDB(card, portConfig[i].internalClock);\n\tinfo->lineSpeed = FST_RDL(card, portConfig[i].lineSpeed);\n\tinfo->invertClock = FST_RDB(card, portConfig[i].invertClock);\n\tinfo->v24IpSts = FST_RDL(card, v24IpSts[i]);\n\tinfo->v24OpSts = FST_RDL(card, v24OpSts[i]);\n\tinfo->clockStatus = FST_RDW(card, clockStatus[i]);\n\tinfo->cableStatus = FST_RDW(card, cableStatus);\n\tinfo->cardMode = FST_RDW(card, cardMode);\n\tinfo->smcFirmwareVersion = FST_RDL(card, smcFirmwareVersion);",
"\t/*\n\t * The T2U can report cable presence for both A or B\n\t * in bits 0 and 1 of cableStatus. See which port we are and \n\t * do the mapping.\n\t */\n\tif (card->family == FST_FAMILY_TXU) {\n\t\tif (port->index == 0) {\n\t\t\t/*\n\t\t\t * Port A\n\t\t\t */\n\t\t\tinfo->cableStatus = info->cableStatus & 1;\n\t\t} else {\n\t\t\t/*\n\t\t\t * Port B\n\t\t\t */\n\t\t\tinfo->cableStatus = info->cableStatus >> 1;\n\t\t\tinfo->cableStatus = info->cableStatus & 1;\n\t\t}\n\t}\n\t/*\n\t * Some additional bits if we are TE1\n\t */\n\tif (card->type == FST_TYPE_TE1) {\n\t\tinfo->lineSpeed = FST_RDL(card, suConfig.dataRate);\n\t\tinfo->clockSource = FST_RDB(card, suConfig.clocking);\n\t\tinfo->framing = FST_RDB(card, suConfig.framing);\n\t\tinfo->structure = FST_RDB(card, suConfig.structure);\n\t\tinfo->interface = FST_RDB(card, suConfig.interface);\n\t\tinfo->coding = FST_RDB(card, suConfig.coding);\n\t\tinfo->lineBuildOut = FST_RDB(card, suConfig.lineBuildOut);\n\t\tinfo->equalizer = FST_RDB(card, suConfig.equalizer);\n\t\tinfo->loopMode = FST_RDB(card, suConfig.loopMode);\n\t\tinfo->range = FST_RDB(card, suConfig.range);\n\t\tinfo->txBufferMode = FST_RDB(card, suConfig.txBufferMode);\n\t\tinfo->rxBufferMode = FST_RDB(card, suConfig.rxBufferMode);\n\t\tinfo->startingSlot = FST_RDB(card, suConfig.startingSlot);\n\t\tinfo->losThreshold = FST_RDB(card, suConfig.losThreshold);\n\t\tif (FST_RDB(card, suConfig.enableIdleCode))\n\t\t\tinfo->idleCode = FST_RDB(card, suConfig.idleCode);\n\t\telse\n\t\t\tinfo->idleCode = 0;\n\t\tinfo->receiveBufferDelay =\n\t\t FST_RDL(card, suStatus.receiveBufferDelay);\n\t\tinfo->framingErrorCount =\n\t\t FST_RDL(card, suStatus.framingErrorCount);\n\t\tinfo->codeViolationCount =\n\t\t FST_RDL(card, suStatus.codeViolationCount);\n\t\tinfo->crcErrorCount = FST_RDL(card, suStatus.crcErrorCount);\n\t\tinfo->lineAttenuation = FST_RDL(card, suStatus.lineAttenuation);\n\t\tinfo->lossOfSignal = FST_RDB(card, suStatus.lossOfSignal);\n\t\tinfo->receiveRemoteAlarm =\n\t\t FST_RDB(card, suStatus.receiveRemoteAlarm);\n\t\tinfo->alarmIndicationSignal =\n\t\t FST_RDB(card, suStatus.alarmIndicationSignal);\n\t}\n}",
"static int\nfst_set_iface(struct fst_card_info *card, struct fst_port_info *port,\n\t struct ifreq *ifr)\n{\n\tsync_serial_settings sync;\n\tint i;",
"\tif (ifr->ifr_settings.size != sizeof (sync)) {\n\t\treturn -ENOMEM;\n\t}",
"\tif (copy_from_user\n\t (&sync, ifr->ifr_settings.ifs_ifsu.sync, sizeof (sync))) {\n\t\treturn -EFAULT;\n\t}",
"\tif (sync.loopback)\n\t\treturn -EINVAL;",
"\ti = port->index;",
"\tswitch (ifr->ifr_settings.type) {\n\tcase IF_IFACE_V35:\n\t\tFST_WRW(card, portConfig[i].lineInterface, V35);\n\t\tport->hwif = V35;\n\t\tbreak;",
"\tcase IF_IFACE_V24:\n\t\tFST_WRW(card, portConfig[i].lineInterface, V24);\n\t\tport->hwif = V24;\n\t\tbreak;",
"\tcase IF_IFACE_X21:\n\t\tFST_WRW(card, portConfig[i].lineInterface, X21);\n\t\tport->hwif = X21;\n\t\tbreak;",
"\tcase IF_IFACE_X21D:\n\t\tFST_WRW(card, portConfig[i].lineInterface, X21D);\n\t\tport->hwif = X21D;\n\t\tbreak;",
"\tcase IF_IFACE_T1:\n\t\tFST_WRW(card, portConfig[i].lineInterface, T1);\n\t\tport->hwif = T1;\n\t\tbreak;",
"\tcase IF_IFACE_E1:\n\t\tFST_WRW(card, portConfig[i].lineInterface, E1);\n\t\tport->hwif = E1;\n\t\tbreak;",
"\tcase IF_IFACE_SYNC_SERIAL:\n\t\tbreak;",
"\tdefault:\n\t\treturn -EINVAL;\n\t}",
"\tswitch (sync.clock_type) {\n\tcase CLOCK_EXT:\n\t\tFST_WRB(card, portConfig[i].internalClock, EXTCLK);\n\t\tbreak;",
"\tcase CLOCK_INT:\n\t\tFST_WRB(card, portConfig[i].internalClock, INTCLK);\n\t\tbreak;",
"\tdefault:\n\t\treturn -EINVAL;\n\t}\n\tFST_WRL(card, portConfig[i].lineSpeed, sync.clock_rate);\n\treturn 0;\n}",
"static int\nfst_get_iface(struct fst_card_info *card, struct fst_port_info *port,\n\t struct ifreq *ifr)\n{\n\tsync_serial_settings sync;\n\tint i;",
"\t/* First check what line type is set, we'll default to reporting X.21\n\t * if nothing is set as IF_IFACE_SYNC_SERIAL implies it can't be\n\t * changed\n\t */\n\tswitch (port->hwif) {\n\tcase E1:\n\t\tifr->ifr_settings.type = IF_IFACE_E1;\n\t\tbreak;\n\tcase T1:\n\t\tifr->ifr_settings.type = IF_IFACE_T1;\n\t\tbreak;\n\tcase V35:\n\t\tifr->ifr_settings.type = IF_IFACE_V35;\n\t\tbreak;\n\tcase V24:\n\t\tifr->ifr_settings.type = IF_IFACE_V24;\n\t\tbreak;\n\tcase X21D:\n\t\tifr->ifr_settings.type = IF_IFACE_X21D;\n\t\tbreak;\n\tcase X21:\n\tdefault:\n\t\tifr->ifr_settings.type = IF_IFACE_X21;\n\t\tbreak;\n\t}\n\tif (ifr->ifr_settings.size == 0) {\n\t\treturn 0;\t/* only type requested */\n\t}\n\tif (ifr->ifr_settings.size < sizeof (sync)) {\n\t\treturn -ENOMEM;\n\t}",
"\ti = port->index;",
"\tmemset(&sync, 0, sizeof(sync));",
"\tsync.clock_rate = FST_RDL(card, portConfig[i].lineSpeed);\n\t/* Lucky card and linux use same encoding here */\n\tsync.clock_type = FST_RDB(card, portConfig[i].internalClock) ==\n\t INTCLK ? CLOCK_INT : CLOCK_EXT;\n\tsync.loopback = 0;",
"\tif (copy_to_user(ifr->ifr_settings.ifs_ifsu.sync, &sync, sizeof (sync))) {\n\t\treturn -EFAULT;\n\t}",
"\tifr->ifr_settings.size = sizeof (sync);\n\treturn 0;\n}",
"static int\nfst_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)\n{\n\tstruct fst_card_info *card;\n\tstruct fst_port_info *port;\n\tstruct fstioc_write wrthdr;\n\tstruct fstioc_info info;\n\tunsigned long flags;\n\tvoid *buf;",
"\tdbg(DBG_IOCTL, \"ioctl: %x, %p\\n\", cmd, ifr->ifr_data);",
"\tport = dev_to_port(dev);\n\tcard = port->card;",
"\tif (!capable(CAP_NET_ADMIN))\n\t\treturn -EPERM;",
"\tswitch (cmd) {\n\tcase FSTCPURESET:\n\t\tfst_cpureset(card);\n\t\tcard->state = FST_RESET;\n\t\treturn 0;",
"\tcase FSTCPURELEASE:\n\t\tfst_cpurelease(card);\n\t\tcard->state = FST_STARTING;\n\t\treturn 0;",
"\tcase FSTWRITE:\t\t/* Code write (download) */",
"\t\t/* First copy in the header with the length and offset of data\n\t\t * to write\n\t\t */\n\t\tif (ifr->ifr_data == NULL) {\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tif (copy_from_user(&wrthdr, ifr->ifr_data,\n\t\t\t\t sizeof (struct fstioc_write))) {\n\t\t\treturn -EFAULT;\n\t\t}",
"\t\t/* Sanity check the parameters. We don't support partial writes\n\t\t * when going over the top\n\t\t */\n\t\tif (wrthdr.size > FST_MEMSIZE || wrthdr.offset > FST_MEMSIZE ||\n\t\t wrthdr.size + wrthdr.offset > FST_MEMSIZE) {\n\t\t\treturn -ENXIO;\n\t\t}",
"\t\t/* Now copy the data to the card. */",
"\t\tbuf = memdup_user(ifr->ifr_data + sizeof(struct fstioc_write),\n\t\t\t\t wrthdr.size);\n\t\tif (IS_ERR(buf))\n\t\t\treturn PTR_ERR(buf);",
"\t\tmemcpy_toio(card->mem + wrthdr.offset, buf, wrthdr.size);\n\t\tkfree(buf);",
"\t\t/* Writes to the memory of a card in the reset state constitute\n\t\t * a download\n\t\t */\n\t\tif (card->state == FST_RESET) {\n\t\t\tcard->state = FST_DOWNLOAD;\n\t\t}\n\t\treturn 0;",
"\tcase FSTGETCONF:",
"\t\t/* If card has just been started check the shared memory config\n\t\t * version and marker\n\t\t */\n\t\tif (card->state == FST_STARTING) {\n\t\t\tcheck_started_ok(card);",
"\t\t\t/* If everything checked out enable card interrupts */\n\t\t\tif (card->state == FST_RUNNING) {\n\t\t\t\tspin_lock_irqsave(&card->card_lock, flags);\n\t\t\t\tfst_enable_intr(card);\n\t\t\t\tFST_WRB(card, interruptHandshake, 0xEE);\n\t\t\t\tspin_unlock_irqrestore(&card->card_lock, flags);\n\t\t\t}\n\t\t}",
"\t\tif (ifr->ifr_data == NULL) {\n\t\t\treturn -EINVAL;\n\t\t}",
"\t\tgather_conf_info(card, port, &info);",
"\t\tif (copy_to_user(ifr->ifr_data, &info, sizeof (info))) {\n\t\t\treturn -EFAULT;\n\t\t}\n\t\treturn 0;",
"\tcase FSTSETCONF:",
"\t\t/*\n\t\t * Most of the settings have been moved to the generic ioctls\n\t\t * this just covers debug and board ident now\n\t\t */",
"\t\tif (card->state != FST_RUNNING) {\n\t\t\tpr_err(\"Attempt to configure card %d in non-running state (%d)\\n\",\n\t\t\t card->card_no, card->state);\n\t\t\treturn -EIO;\n\t\t}\n\t\tif (copy_from_user(&info, ifr->ifr_data, sizeof (info))) {\n\t\t\treturn -EFAULT;\n\t\t}",
"\t\treturn set_conf_from_info(card, port, &info);",
"\tcase SIOCWANDEV:\n\t\tswitch (ifr->ifr_settings.type) {\n\t\tcase IF_GET_IFACE:\n\t\t\treturn fst_get_iface(card, port, ifr);",
"\t\tcase IF_IFACE_SYNC_SERIAL:\n\t\tcase IF_IFACE_V35:\n\t\tcase IF_IFACE_V24:\n\t\tcase IF_IFACE_X21:\n\t\tcase IF_IFACE_X21D:\n\t\tcase IF_IFACE_T1:\n\t\tcase IF_IFACE_E1:\n\t\t\treturn fst_set_iface(card, port, ifr);",
"\t\tcase IF_PROTO_RAW:\n\t\t\tport->mode = FST_RAW;\n\t\t\treturn 0;",
"\t\tcase IF_GET_PROTO:\n\t\t\tif (port->mode == FST_RAW) {\n\t\t\t\tifr->ifr_settings.type = IF_PROTO_RAW;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn hdlc_ioctl(dev, ifr, cmd);",
"\t\tdefault:\n\t\t\tport->mode = FST_GEN_HDLC;\n\t\t\tdbg(DBG_IOCTL, \"Passing this type to hdlc %x\\n\",\n\t\t\t ifr->ifr_settings.type);\n\t\t\treturn hdlc_ioctl(dev, ifr, cmd);\n\t\t}",
"\tdefault:\n\t\t/* Not one of ours. Pass through to HDLC package */\n\t\treturn hdlc_ioctl(dev, ifr, cmd);\n\t}\n}",
"static void\nfst_openport(struct fst_port_info *port)\n{\n\tint signals;\n\tint txq_length;",
"\t/* Only init things if card is actually running. This allows open to\n\t * succeed for downloads etc.\n\t */\n\tif (port->card->state == FST_RUNNING) {\n\t\tif (port->run) {\n\t\t\tdbg(DBG_OPEN, \"open: found port already running\\n\");",
"\t\t\tfst_issue_cmd(port, STOPPORT);\n\t\t\tport->run = 0;\n\t\t}",
"\t\tfst_rx_config(port);\n\t\tfst_tx_config(port);\n\t\tfst_op_raise(port, OPSTS_RTS | OPSTS_DTR);",
"\t\tfst_issue_cmd(port, STARTPORT);\n\t\tport->run = 1;",
"\t\tsignals = FST_RDL(port->card, v24DebouncedSts[port->index]);\n\t\tif (signals & (((port->hwif == X21) || (port->hwif == X21D))\n\t\t\t ? IPSTS_INDICATE : IPSTS_DCD))\n\t\t\tnetif_carrier_on(port_to_dev(port));\n\t\telse\n\t\t\tnetif_carrier_off(port_to_dev(port));",
"\t\ttxq_length = port->txqe - port->txqs;\n\t\tport->txqe = 0;\n\t\tport->txqs = 0;\n\t}",
"}",
"static void\nfst_closeport(struct fst_port_info *port)\n{\n\tif (port->card->state == FST_RUNNING) {\n\t\tif (port->run) {\n\t\t\tport->run = 0;\n\t\t\tfst_op_lower(port, OPSTS_RTS | OPSTS_DTR);",
"\t\t\tfst_issue_cmd(port, STOPPORT);\n\t\t} else {\n\t\t\tdbg(DBG_OPEN, \"close: port not running\\n\");\n\t\t}\n\t}\n}",
"static int\nfst_open(struct net_device *dev)\n{\n\tint err;\n\tstruct fst_port_info *port;",
"\tport = dev_to_port(dev);\n\tif (!try_module_get(THIS_MODULE))\n return -EBUSY;",
"\tif (port->mode != FST_RAW) {\n\t\terr = hdlc_open(dev);\n\t\tif (err) {\n\t\t\tmodule_put(THIS_MODULE);\n\t\t\treturn err;\n\t\t}\n\t}",
"\tfst_openport(port);\n\tnetif_wake_queue(dev);\n\treturn 0;\n}",
"static int\nfst_close(struct net_device *dev)\n{\n\tstruct fst_port_info *port;\n\tstruct fst_card_info *card;\n\tunsigned char tx_dma_done;\n\tunsigned char rx_dma_done;",
"\tport = dev_to_port(dev);\n\tcard = port->card;",
"\ttx_dma_done = inb(card->pci_conf + DMACSR1);\n\trx_dma_done = inb(card->pci_conf + DMACSR0);\n\tdbg(DBG_OPEN,\n\t \"Port Close: tx_dma_in_progress = %d (%x) rx_dma_in_progress = %d (%x)\\n\",\n\t card->dmatx_in_progress, tx_dma_done, card->dmarx_in_progress,\n\t rx_dma_done);",
"\tnetif_stop_queue(dev);\n\tfst_closeport(dev_to_port(dev));\n\tif (port->mode != FST_RAW) {\n\t\thdlc_close(dev);\n\t}\n\tmodule_put(THIS_MODULE);\n\treturn 0;\n}",
"static int\nfst_attach(struct net_device *dev, unsigned short encoding, unsigned short parity)\n{\n\t/*\n\t * Setting currently fixed in FarSync card so we check and forget\n\t */\n\tif (encoding != ENCODING_NRZ || parity != PARITY_CRC16_PR1_CCITT)\n\t\treturn -EINVAL;\n\treturn 0;\n}",
"static void\nfst_tx_timeout(struct net_device *dev)\n{\n\tstruct fst_port_info *port;\n\tstruct fst_card_info *card;",
"\tport = dev_to_port(dev);\n\tcard = port->card;\n\tdev->stats.tx_errors++;\n\tdev->stats.tx_aborted_errors++;\n\tdbg(DBG_ASS, \"Tx timeout card %d port %d\\n\",\n\t card->card_no, port->index);\n\tfst_issue_cmd(port, ABORTTX);",
"\tdev->trans_start = jiffies;\n\tnetif_wake_queue(dev);\n\tport->start = 0;\n}",
"static netdev_tx_t\nfst_start_xmit(struct sk_buff *skb, struct net_device *dev)\n{\n\tstruct fst_card_info *card;\n\tstruct fst_port_info *port;\n\tunsigned long flags;\n\tint txq_length;",
"\tport = dev_to_port(dev);\n\tcard = port->card;\n\tdbg(DBG_TX, \"fst_start_xmit: length = %d\\n\", skb->len);",
"\t/* Drop packet with error if we don't have carrier */\n\tif (!netif_carrier_ok(dev)) {\n\t\tdev_kfree_skb(skb);\n\t\tdev->stats.tx_errors++;\n\t\tdev->stats.tx_carrier_errors++;\n\t\tdbg(DBG_ASS,\n\t\t \"Tried to transmit but no carrier on card %d port %d\\n\",\n\t\t card->card_no, port->index);\n\t\treturn NETDEV_TX_OK;\n\t}",
"\t/* Drop it if it's too big! MTU failure ? */\n\tif (skb->len > LEN_TX_BUFFER) {\n\t\tdbg(DBG_ASS, \"Packet too large %d vs %d\\n\", skb->len,\n\t\t LEN_TX_BUFFER);\n\t\tdev_kfree_skb(skb);\n\t\tdev->stats.tx_errors++;\n\t\treturn NETDEV_TX_OK;\n\t}",
"\t/*\n\t * We are always going to queue the packet\n\t * so that the bottom half is the only place we tx from\n\t * Check there is room in the port txq\n\t */\n\tspin_lock_irqsave(&card->card_lock, flags);\n\tif ((txq_length = port->txqe - port->txqs) < 0) {\n\t\t/*\n\t\t * This is the case where the next free has wrapped but the\n\t\t * last used hasn't\n\t\t */\n\t\ttxq_length = txq_length + FST_TXQ_DEPTH;\n\t}\n\tspin_unlock_irqrestore(&card->card_lock, flags);\n\tif (txq_length > fst_txq_high) {\n\t\t/*\n\t\t * We have got enough buffers in the pipeline. Ask the network\n\t\t * layer to stop sending frames down\n\t\t */\n\t\tnetif_stop_queue(dev);\n\t\tport->start = 1;\t/* I'm using this to signal stop sent up */\n\t}",
"\tif (txq_length == FST_TXQ_DEPTH - 1) {\n\t\t/*\n\t\t * This shouldn't have happened but such is life\n\t\t */\n\t\tdev_kfree_skb(skb);\n\t\tdev->stats.tx_errors++;\n\t\tdbg(DBG_ASS, \"Tx queue overflow card %d port %d\\n\",\n\t\t card->card_no, port->index);\n\t\treturn NETDEV_TX_OK;\n\t}",
"\t/*\n\t * queue the buffer\n\t */\n\tspin_lock_irqsave(&card->card_lock, flags);\n\tport->txq[port->txqe] = skb;\n\tport->txqe++;\n\tif (port->txqe == FST_TXQ_DEPTH)\n\t\tport->txqe = 0;\n\tspin_unlock_irqrestore(&card->card_lock, flags);",
"\t/* Scehdule the bottom half which now does transmit processing */\n\tfst_q_work_item(&fst_work_txq, card->card_no);\n\ttasklet_schedule(&fst_tx_task);",
"\treturn NETDEV_TX_OK;\n}",
"/*\n * Card setup having checked hardware resources.\n * Should be pretty bizarre if we get an error here (kernel memory\n * exhaustion is one possibility). If we do see a problem we report it\n * via a printk and leave the corresponding interface and all that follow\n * disabled.\n */\nstatic char *type_strings[] = {\n\t\"no hardware\",\t\t/* Should never be seen */\n\t\"FarSync T2P\",\n\t\"FarSync T4P\",\n\t\"FarSync T1U\",\n\t\"FarSync T2U\",\n\t\"FarSync T4U\",\n\t\"FarSync TE1\"\n};",
"static void\nfst_init_card(struct fst_card_info *card)\n{\n\tint i;\n\tint err;",
"\t/* We're working on a number of ports based on the card ID. If the\n\t * firmware detects something different later (should never happen)\n\t * we'll have to revise it in some way then.\n\t */\n\tfor (i = 0; i < card->nports; i++) {\n err = register_hdlc_device(card->ports[i].dev);\n if (err < 0) {\n\t\t\tint j;\n\t\t\tpr_err(\"Cannot register HDLC device for port %d (errno %d)\\n\",\n\t\t\t i, -err);\n\t\t\tfor (j = i; j < card->nports; j++) {\n\t\t\t\tfree_netdev(card->ports[j].dev);\n\t\t\t\tcard->ports[j].dev = NULL;\n\t\t\t}\n card->nports = i;\n break;\n }\n\t}",
"\tpr_info(\"%s-%s: %s IRQ%d, %d ports\\n\",\n\t\tport_to_dev(&card->ports[0])->name,\n\t\tport_to_dev(&card->ports[card->nports - 1])->name,\n\t\ttype_strings[card->type], card->irq, card->nports);\n}",
"static const struct net_device_ops fst_ops = {\n\t.ndo_open = fst_open,\n\t.ndo_stop = fst_close,\n\t.ndo_change_mtu = hdlc_change_mtu,\n\t.ndo_start_xmit = hdlc_start_xmit,\n\t.ndo_do_ioctl = fst_ioctl,\n\t.ndo_tx_timeout = fst_tx_timeout,\n};",
"/*\n * Initialise card when detected.\n * Returns 0 to indicate success, or errno otherwise.\n */\nstatic int\nfst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)\n{\n\tstatic int no_of_cards_added = 0;\n\tstruct fst_card_info *card;\n\tint err = 0;\n\tint i;",
"\tprintk_once(KERN_INFO\n\t\t pr_fmt(\"FarSync WAN driver \" FST_USER_VERSION\n\t\t\t \" (c) 2001-2004 FarSite Communications Ltd.\\n\"));\n#if FST_DEBUG\n\tdbg(DBG_ASS, \"The value of debug mask is %x\\n\", fst_debug_mask);\n#endif\n\t/*\n\t * We are going to be clever and allow certain cards not to be\n\t * configured. An exclude list can be provided in /etc/modules.conf\n\t */\n\tif (fst_excluded_cards != 0) {\n\t\t/*\n\t\t * There are cards to exclude\n\t\t *\n\t\t */\n\t\tfor (i = 0; i < fst_excluded_cards; i++) {\n\t\t\tif ((pdev->devfn) >> 3 == fst_excluded_list[i]) {\n\t\t\t\tpr_info(\"FarSync PCI device %d not assigned\\n\",\n\t\t\t\t\t(pdev->devfn) >> 3);\n\t\t\t\treturn -EBUSY;\n\t\t\t}\n\t\t}\n\t}",
"\t/* Allocate driver private data */\n\tcard = kzalloc(sizeof(struct fst_card_info), GFP_KERNEL);\n\tif (card == NULL)\n\t\treturn -ENOMEM;",
"\t/* Try to enable the device */\n\tif ((err = pci_enable_device(pdev)) != 0) {\n\t\tpr_err(\"Failed to enable card. Err %d\\n\", -err);\n\t\tkfree(card);\n\t\treturn err;\n\t}",
"\tif ((err = pci_request_regions(pdev, \"FarSync\")) !=0) {\n\t\tpr_err(\"Failed to allocate regions. Err %d\\n\", -err);\n\t\tpci_disable_device(pdev);\n\t\tkfree(card);\n\t return err;\n\t}",
"\t/* Get virtual addresses of memory regions */\n\tcard->pci_conf = pci_resource_start(pdev, 1);\n\tcard->phys_mem = pci_resource_start(pdev, 2);\n\tcard->phys_ctlmem = pci_resource_start(pdev, 3);\n\tif ((card->mem = ioremap(card->phys_mem, FST_MEMSIZE)) == NULL) {\n\t\tpr_err(\"Physical memory remap failed\\n\");\n\t\tpci_release_regions(pdev);\n\t\tpci_disable_device(pdev);\n\t\tkfree(card);\n\t\treturn -ENODEV;\n\t}\n\tif ((card->ctlmem = ioremap(card->phys_ctlmem, 0x10)) == NULL) {\n\t\tpr_err(\"Control memory remap failed\\n\");\n\t\tpci_release_regions(pdev);\n\t\tpci_disable_device(pdev);\n\t\tiounmap(card->mem);\n\t\tkfree(card);\n\t\treturn -ENODEV;\n\t}\n\tdbg(DBG_PCI, \"kernel mem %p, ctlmem %p\\n\", card->mem, card->ctlmem);",
"\t/* Register the interrupt handler */\n\tif (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) {\n\t\tpr_err(\"Unable to register interrupt %d\\n\", card->irq);\n\t\tpci_release_regions(pdev);\n\t\tpci_disable_device(pdev);\n\t\tiounmap(card->ctlmem);\n\t\tiounmap(card->mem);\n\t\tkfree(card);\n\t\treturn -ENODEV;\n\t}",
"\t/* Record info we need */\n\tcard->irq = pdev->irq;\n\tcard->type = ent->driver_data;\n\tcard->family = ((ent->driver_data == FST_TYPE_T2P) ||\n\t\t\t(ent->driver_data == FST_TYPE_T4P))\n\t ? FST_FAMILY_TXP : FST_FAMILY_TXU;\n\tif ((ent->driver_data == FST_TYPE_T1U) ||\n\t (ent->driver_data == FST_TYPE_TE1))\n\t\tcard->nports = 1;\n\telse\n\t\tcard->nports = ((ent->driver_data == FST_TYPE_T2P) ||\n\t\t\t\t(ent->driver_data == FST_TYPE_T2U)) ? 2 : 4;",
"\tcard->state = FST_UNINIT;\n spin_lock_init ( &card->card_lock );",
" for ( i = 0 ; i < card->nports ; i++ ) {\n\t\tstruct net_device *dev = alloc_hdlcdev(&card->ports[i]);\n\t\thdlc_device *hdlc;\n\t\tif (!dev) {\n\t\t\twhile (i--)\n\t\t\t\tfree_netdev(card->ports[i].dev);\n\t\t\tpr_err(\"FarSync: out of memory\\n\");\n free_irq(card->irq, card);\n pci_release_regions(pdev);\n pci_disable_device(pdev);\n iounmap(card->ctlmem);\n iounmap(card->mem);\n kfree(card);\n return -ENODEV;\n\t\t}\n\t\tcard->ports[i].dev = dev;\n card->ports[i].card = card;\n card->ports[i].index = i;\n card->ports[i].run = 0;",
"\t\thdlc = dev_to_hdlc(dev);",
" /* Fill in the net device info */\n\t\t/* Since this is a PCI setup this is purely\n\t\t * informational. Give them the buffer addresses\n\t\t * and basic card I/O.\n\t\t */\n dev->mem_start = card->phys_mem\n + BUF_OFFSET ( txBuffer[i][0][0]);\n dev->mem_end = card->phys_mem\n + BUF_OFFSET ( txBuffer[i][NUM_TX_BUFFER][0]);\n dev->base_addr = card->pci_conf;\n dev->irq = card->irq;",
"\t\tdev->netdev_ops = &fst_ops;\n\t\tdev->tx_queue_len = FST_TX_QUEUE_LEN;\n\t\tdev->watchdog_timeo = FST_TX_TIMEOUT;\n hdlc->attach = fst_attach;\n hdlc->xmit = fst_start_xmit;\n\t}",
"\tcard->device = pdev;",
"\tdbg(DBG_PCI, \"type %d nports %d irq %d\\n\", card->type,\n\t card->nports, card->irq);\n\tdbg(DBG_PCI, \"conf %04x mem %08x ctlmem %08x\\n\",\n\t card->pci_conf, card->phys_mem, card->phys_ctlmem);",
"\t/* Reset the card's processor */\n\tfst_cpureset(card);\n\tcard->state = FST_RESET;",
"\t/* Initialise DMA (if required) */\n\tfst_init_dma(card);",
"\t/* Record driver data for later use */\n\tpci_set_drvdata(pdev, card);",
"\t/* Remainder of card setup */\n\tfst_card_array[no_of_cards_added] = card;\n\tcard->card_no = no_of_cards_added++;\t/* Record instance and bump it */\n\tfst_init_card(card);\n\tif (card->family == FST_FAMILY_TXU) {\n\t\t/*\n\t\t * Allocate a dma buffer for transmit and receives\n\t\t */\n\t\tcard->rx_dma_handle_host =\n\t\t pci_alloc_consistent(card->device, FST_MAX_MTU,\n\t\t\t\t\t &card->rx_dma_handle_card);\n\t\tif (card->rx_dma_handle_host == NULL) {\n\t\t\tpr_err(\"Could not allocate rx dma buffer\\n\");\n\t\t\tfst_disable_intr(card);\n\t\t\tpci_release_regions(pdev);\n\t\t\tpci_disable_device(pdev);\n\t\t\tiounmap(card->ctlmem);\n\t\t\tiounmap(card->mem);\n\t\t\tkfree(card);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t\tcard->tx_dma_handle_host =\n\t\t pci_alloc_consistent(card->device, FST_MAX_MTU,\n\t\t\t\t\t &card->tx_dma_handle_card);\n\t\tif (card->tx_dma_handle_host == NULL) {\n\t\t\tpr_err(\"Could not allocate tx dma buffer\\n\");\n\t\t\tfst_disable_intr(card);\n\t\t\tpci_release_regions(pdev);\n\t\t\tpci_disable_device(pdev);\n\t\t\tiounmap(card->ctlmem);\n\t\t\tiounmap(card->mem);\n\t\t\tkfree(card);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t}\n\treturn 0;\t\t/* Success */\n}",
"/*\n * Cleanup and close down a card\n */\nstatic void\nfst_remove_one(struct pci_dev *pdev)\n{\n\tstruct fst_card_info *card;\n\tint i;",
"\tcard = pci_get_drvdata(pdev);",
"\tfor (i = 0; i < card->nports; i++) {\n\t\tstruct net_device *dev = port_to_dev(&card->ports[i]);\n\t\tunregister_hdlc_device(dev);\n\t}",
"\tfst_disable_intr(card);\n\tfree_irq(card->irq, card);",
"\tiounmap(card->ctlmem);\n\tiounmap(card->mem);\n\tpci_release_regions(pdev);\n\tif (card->family == FST_FAMILY_TXU) {\n\t\t/*\n\t\t * Free dma buffers\n\t\t */\n\t\tpci_free_consistent(card->device, FST_MAX_MTU,\n\t\t\t\t card->rx_dma_handle_host,\n\t\t\t\t card->rx_dma_handle_card);\n\t\tpci_free_consistent(card->device, FST_MAX_MTU,\n\t\t\t\t card->tx_dma_handle_host,\n\t\t\t\t card->tx_dma_handle_card);\n\t}\n\tfst_card_array[card->card_no] = NULL;\n}",
"static struct pci_driver fst_driver = {\n .name\t\t= FST_NAME,\n .id_table\t= fst_pci_dev_id,\n .probe\t\t= fst_add_one,\n .remove\t= fst_remove_one,\n .suspend\t= NULL,\n .resume\t= NULL,\n};",
"static int __init\nfst_init(void)\n{\n\tint i;",
"\tfor (i = 0; i < FST_MAX_CARDS; i++)\n\t\tfst_card_array[i] = NULL;\n\tspin_lock_init(&fst_work_q_lock);\n\treturn pci_register_driver(&fst_driver);\n}",
"static void __exit\nfst_cleanup_module(void)\n{\n\tpr_info(\"FarSync WAN driver unloading\\n\");\n\tpci_unregister_driver(&fst_driver);\n}",
"module_init(fst_init);\nmodule_exit(fst_cleanup_module);"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1974], "buggy_code_start_loc": [1974], "filenames": ["drivers/net/wan/farsync.c"], "fixing_code_end_loc": [1976], "fixing_code_start_loc": [1975], "message": "The fst_get_iface function in drivers/net/wan/farsync.c in the Linux kernel before 3.11.7 does not properly initialize a certain data structure, which allows local users to obtain sensitive information from kernel memory by leveraging the CAP_NET_ADMIN capability for an SIOCWANDEV ioctl call.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "C3D55C7B-D6AF-4DB4-8CCC-3BFC8C15F45D", "versionEndExcluding": null, "versionEndIncluding": "3.11.6", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11:*:*:*:*:*:*:*", "matchCriteriaId": "639E3A57-A9E7-40E6-8929-81CCC0060EFB", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11.1:*:*:*:*:*:*:*", "matchCriteriaId": "07012ADD-F521-40A8-B067-E87C2238A3D2", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11.2:*:*:*:*:*:*:*", "matchCriteriaId": "3F5FF393-3F89-4274-B82B-F671358072ED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11.3:*:*:*:*:*:*:*", "matchCriteriaId": "E348698F-54D1-4F5E-B701-CFAF50881E0A", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11.4:*:*:*:*:*:*:*", "matchCriteriaId": "932205D9-3514-4289-9B55-C7A169276930", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:3.11.5:*:*:*:*:*:*:*", "matchCriteriaId": "2ECB2D33-F517-480F-8A6F-99D9D6C49596", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "The fst_get_iface function in drivers/net/wan/farsync.c in the Linux kernel before 3.11.7 does not properly initialize a certain data structure, which allows local users to obtain sensitive information from kernel memory by leveraging the CAP_NET_ADMIN capability for an SIOCWANDEV ioctl call."}, {"lang": "es", "value": "La funci\u00f3n fst_get_iface en drivers/net/wan/farsync.c del kernel Linux anteriores a 3.11.7 no inicializa apropiadamente cierta estructura de datos, lo cual permite a usuarios locales obtener informaci\u00f3n sensible de la memoria dle kernel, aprovechando la funcionalidad CAP_NET_ADMIN para una llamada SIOCWANDEV ioctl."}], "evaluatorComment": null, "id": "CVE-2014-1444", "lastModified": "2017-08-29T01:34:24.950", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 1.7, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:L/AC:L/Au:S/C:P/I:N/A:N", "version": "2.0"}, "exploitabilityScore": 3.1, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": null}, "published": "2014-01-18T22:55:03.257", "references": [{"source": "cve@mitre.org", "tags": null, "url": "http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=96b340406724d87e4621284ebac5e059d67b2194"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.11.7"}, {"source": "cve@mitre.org", "tags": ["Patch"], "url": "http://www.openwall.com/lists/oss-security/2014/01/15/3"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/64952"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.ubuntu.com/usn/USN-2128-1"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.ubuntu.com/usn/USN-2129-1"}, {"source": "cve@mitre.org", "tags": null, "url": "https://bugzilla.redhat.com/show_bug.cgi?id=1053610"}, {"source": "cve@mitre.org", "tags": null, "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/90443"}, {"source": "cve@mitre.org", "tags": ["Patch"], "url": "https://github.com/torvalds/linux/commit/96b340406724d87e4621284ebac5e059d67b2194"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-399"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/96b340406724d87e4621284ebac5e059d67b2194"}, "type": "CWE-399"}
| 362
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"using System;\r\nusing System.Linq;\r\nusing System.Web.UI.WebControls;\r\nusing System.Web.UI.HtmlControls;\r\nusing System.Xml;\r\nusing System.Xml.Linq;\r\nusing Umbraco.Core;\r\nusing Umbraco.Core.IO;\r\n\r\nnamespace umbraco.presentation.umbraco.dialogs\r\n{\r\n\t/// <summary>\r\n\t/// Summary description for importDocumentType.\r\n\t/// </summary>\r\n\tpublic class importDocumentType : BasePages.UmbracoEnsuredPage\r\n\t{\r\n\t public importDocumentType()\r\n\t {\r\n\r\n CurrentApp = BusinessLogic.DefaultApps.settings.ToString();\r\n\r\n\t }\r\n\t\tprotected Literal FeedBackMessage;\r\n\t\tprotected Literal jsShowWindow;\r\n\t\tprotected Panel Wizard;\r\n\t\tprotected HtmlTable Table1;\r\n\t\tprotected HtmlInputHidden tempFile;\r\n\t\tprotected HtmlInputFile documentTypeFile;\r\n\t\tprotected Button submit;\r\n\t\tprotected Panel Confirm;\r\n\t\tprotected Literal dtName;\r\n\t\tprotected Literal dtAlias;\r\n\t\tprotected Button import;\r\n\t\tprotected Literal dtNameConfirm;\r\n\t\tprotected Panel done;\r\n\t\tprivate string tempFileName = \"\";\r\n\r\n\t\tprivate void Page_Load(object sender, EventArgs e)\r\n\t\t{\r\n\t\t\tif (!IsPostBack) \r\n\t\t\t{\r\n\t\t\t\tsubmit.Text = ui.Text(\"import\");\r\n\t\t\t\timport.Text = ui.Text(\"import\");\r\n\t\t\t} \r\n\t\t}\r\n\r\n\t\t#region Web Form Designer generated code\r\n\t\toverride protected void OnInit(EventArgs e)\r\n\t\t{\r\n\t\t\t//\r\n\t\t\t// CODEGEN: This call is required by the ASP.NET Web Form Designer.\r\n\t\t\t//\r\n\t\t\tInitializeComponent();\r\n\t\t\tbase.OnInit(e);\r\n\t\t}\r\n\t\t\r\n\t\t/// <summary>\r\n\t\t/// Required method for Designer support - do not modify\r\n\t\t/// the contents of this method with the code editor.\r\n\t\t/// </summary>\r\n\t\tprivate void InitializeComponent()\r\n\t\t{ \r\n\t\t\tthis.submit.Click += new System.EventHandler(this.submit_Click);\r\n\t\t\tthis.import.Click += new System.EventHandler(this.import_Click);\r\n\t\t\tthis.Load += new System.EventHandler(this.Page_Load);\r\n\r\n\t\t}\r\n\t\t#endregion\r\n\r\n\t\tprivate void import_Click(object sender, EventArgs e)\r\n\t\t{\r\n var xd = new XmlDocument();\r",
"",
" xd.Load(tempFile.Value);\r\n\r\n\t\t var userId = base.getUser().Id;\r",
"\r",
" var element = XElement.Parse(xd.InnerXml);\r\n\t\t var importContentTypes = ApplicationContext.Current.Services.PackagingService.ImportContentTypes(element, userId);\r\n\t\t var contentType = importContentTypes.FirstOrDefault();\r\n\t\t if (contentType != null)\r\n\t\t dtNameConfirm.Text = contentType.Name;\r\n\r\n // Try to clean up the temporary file.\r\n try\r\n {\r\n System.IO.File.Delete(tempFile.Value);\r\n }\r\n catch(Exception ex)\r\n {\r\n Umbraco.Core.Logging.LogHelper.Error(typeof(importDocumentType), \"Error cleaning up temporary udt file in App_Data: \" + ex.Message, ex);\r\n }\r\n\r\n\t\t Wizard.Visible = false;\r\n\t\t\tConfirm.Visible = false;\r\n\t\t\tdone.Visible = true;\r\n\t\t}\r\n\r\n\t\tprivate void submit_Click(object sender, EventArgs e)\r\n\t\t{\r\n\t\t\ttempFileName = \"justDelete_\" + Guid.NewGuid().ToString() + \".udt\";\r\n\t\t\tvar fileName = IOHelper.MapPath(SystemDirectories.Data + \"/\" + tempFileName);\r\n\t\t\ttempFile.Value = fileName;\r\n\r\n\t\t\tdocumentTypeFile.PostedFile.SaveAs(fileName);\r\n\r\n\t\t\tvar xd = new XmlDocument();\r",
"\t\t\txd.Load(fileName);\r",
"\t\t\tdtName.Text = xd.DocumentElement.SelectSingleNode(\"//DocumentType/Info/Name\").FirstChild.Value;\r\n\t\t\tdtAlias.Text = xd.DocumentElement.SelectSingleNode(\"//DocumentType/Info/Alias\").FirstChild.Value;\r\n\r\n\t\t\tWizard.Visible = false;\r\n\t\t\tdone.Visible = false;\r\n\t\t\tConfirm.Visible = true;\r\n\t\t}\r\n\t}\r\n}"
] |
[
1,
0,
1,
0,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [108], "buggy_code_start_loc": [72], "filenames": ["src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/importDocumenttype.aspx.cs"], "fixing_code_end_loc": [110], "fixing_code_start_loc": [73], "message": "XML external entity (XXE) vulnerability in Umbraco CMS before 7.7.3 allows attackers to obtain sensitive information by reading files on the server or sending TCP requests to intranet hosts (aka SSRF), related to Umbraco.Web/umbraco.presentation/umbraco/dialogs/importDocumenttype.aspx.cs.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:umbraco:umbraco_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "ED6DB680-A447-45E3-9DA7-F1B4FB25C557", "versionEndExcluding": null, "versionEndIncluding": "7.7.2", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "XML external entity (XXE) vulnerability in Umbraco CMS before 7.7.3 allows attackers to obtain sensitive information by reading files on the server or sending TCP requests to intranet hosts (aka SSRF), related to Umbraco.Web/umbraco.presentation/umbraco/dialogs/importDocumenttype.aspx.cs."}, {"lang": "es", "value": "Vulnerabilidad XEE (XML External Entity) en Umbraco CMS en versiones anteriores 7.7.3 permite que atacantes obtengan informaci\u00f3n sensible leyendo archivos en el servidor o enviando peticiones TCP a hosts de la intranet (tambi\u00e9n conocido como SSRF). Esto est\u00e1 relacionado con Umbraco.Web/umbraco.presentation/umbraco/dialogs/importDocumenttype.aspx.cs."}], "evaluatorComment": null, "id": "CVE-2017-15280", "lastModified": "2017-10-25T12:53:37.937", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:N/AC:M/Au:N/C:P/I:N/A:N", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": true}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "NONE", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N", "version": "3.0"}, "exploitabilityScore": 1.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-10-12T08:29:00.510", "references": [{"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Vendor Advisory"], "url": "http://issues.umbraco.org/issue/U4-10506"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/umbraco/Umbraco-CMS/commit/5dde2efe0d2b3a47d17439e03acabb7ea2befb64"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-611"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/umbraco/Umbraco-CMS/commit/5dde2efe0d2b3a47d17439e03acabb7ea2befb64"}, "type": "CWE-611"}
| 363
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"using System;\r\nusing System.Linq;\r\nusing System.Web.UI.WebControls;\r\nusing System.Web.UI.HtmlControls;\r\nusing System.Xml;\r\nusing System.Xml.Linq;\r\nusing Umbraco.Core;\r\nusing Umbraco.Core.IO;\r\n\r\nnamespace umbraco.presentation.umbraco.dialogs\r\n{\r\n\t/// <summary>\r\n\t/// Summary description for importDocumentType.\r\n\t/// </summary>\r\n\tpublic class importDocumentType : BasePages.UmbracoEnsuredPage\r\n\t{\r\n\t public importDocumentType()\r\n\t {\r\n\r\n CurrentApp = BusinessLogic.DefaultApps.settings.ToString();\r\n\r\n\t }\r\n\t\tprotected Literal FeedBackMessage;\r\n\t\tprotected Literal jsShowWindow;\r\n\t\tprotected Panel Wizard;\r\n\t\tprotected HtmlTable Table1;\r\n\t\tprotected HtmlInputHidden tempFile;\r\n\t\tprotected HtmlInputFile documentTypeFile;\r\n\t\tprotected Button submit;\r\n\t\tprotected Panel Confirm;\r\n\t\tprotected Literal dtName;\r\n\t\tprotected Literal dtAlias;\r\n\t\tprotected Button import;\r\n\t\tprotected Literal dtNameConfirm;\r\n\t\tprotected Panel done;\r\n\t\tprivate string tempFileName = \"\";\r\n\r\n\t\tprivate void Page_Load(object sender, EventArgs e)\r\n\t\t{\r\n\t\t\tif (!IsPostBack) \r\n\t\t\t{\r\n\t\t\t\tsubmit.Text = ui.Text(\"import\");\r\n\t\t\t\timport.Text = ui.Text(\"import\");\r\n\t\t\t} \r\n\t\t}\r\n\r\n\t\t#region Web Form Designer generated code\r\n\t\toverride protected void OnInit(EventArgs e)\r\n\t\t{\r\n\t\t\t//\r\n\t\t\t// CODEGEN: This call is required by the ASP.NET Web Form Designer.\r\n\t\t\t//\r\n\t\t\tInitializeComponent();\r\n\t\t\tbase.OnInit(e);\r\n\t\t}\r\n\t\t\r\n\t\t/// <summary>\r\n\t\t/// Required method for Designer support - do not modify\r\n\t\t/// the contents of this method with the code editor.\r\n\t\t/// </summary>\r\n\t\tprivate void InitializeComponent()\r\n\t\t{ \r\n\t\t\tthis.submit.Click += new System.EventHandler(this.submit_Click);\r\n\t\t\tthis.import.Click += new System.EventHandler(this.import_Click);\r\n\t\t\tthis.Load += new System.EventHandler(this.Page_Load);\r\n\r\n\t\t}\r\n\t\t#endregion\r\n\r\n\t\tprivate void import_Click(object sender, EventArgs e)\r\n\t\t{\r\n var xd = new XmlDocument();\r",
"\t\t xd.XmlResolver = null;\r",
" xd.Load(tempFile.Value);\r\n\r\n\t\t var userId = base.getUser().Id;\r",
" \r",
" var element = XElement.Parse(xd.InnerXml);\r\n\t\t var importContentTypes = ApplicationContext.Current.Services.PackagingService.ImportContentTypes(element, userId);\r\n\t\t var contentType = importContentTypes.FirstOrDefault();\r\n\t\t if (contentType != null)\r\n\t\t dtNameConfirm.Text = contentType.Name;\r\n\r\n // Try to clean up the temporary file.\r\n try\r\n {\r\n System.IO.File.Delete(tempFile.Value);\r\n }\r\n catch(Exception ex)\r\n {\r\n Umbraco.Core.Logging.LogHelper.Error(typeof(importDocumentType), \"Error cleaning up temporary udt file in App_Data: \" + ex.Message, ex);\r\n }\r\n\r\n\t\t Wizard.Visible = false;\r\n\t\t\tConfirm.Visible = false;\r\n\t\t\tdone.Visible = true;\r\n\t\t}\r\n\r\n\t\tprivate void submit_Click(object sender, EventArgs e)\r\n\t\t{\r\n\t\t\ttempFileName = \"justDelete_\" + Guid.NewGuid().ToString() + \".udt\";\r\n\t\t\tvar fileName = IOHelper.MapPath(SystemDirectories.Data + \"/\" + tempFileName);\r\n\t\t\ttempFile.Value = fileName;\r\n\r\n\t\t\tdocumentTypeFile.PostedFile.SaveAs(fileName);\r\n\r\n\t\t\tvar xd = new XmlDocument();\r",
"\t\t xd.XmlResolver = null;\n xd.Load(fileName);\r",
"\t\t\tdtName.Text = xd.DocumentElement.SelectSingleNode(\"//DocumentType/Info/Name\").FirstChild.Value;\r\n\t\t\tdtAlias.Text = xd.DocumentElement.SelectSingleNode(\"//DocumentType/Info/Alias\").FirstChild.Value;\r\n\r\n\t\t\tWizard.Visible = false;\r\n\t\t\tdone.Visible = false;\r\n\t\t\tConfirm.Visible = true;\r\n\t\t}\r\n\t}\r\n}"
] |
[
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [108], "buggy_code_start_loc": [72], "filenames": ["src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/importDocumenttype.aspx.cs"], "fixing_code_end_loc": [110], "fixing_code_start_loc": [73], "message": "XML external entity (XXE) vulnerability in Umbraco CMS before 7.7.3 allows attackers to obtain sensitive information by reading files on the server or sending TCP requests to intranet hosts (aka SSRF), related to Umbraco.Web/umbraco.presentation/umbraco/dialogs/importDocumenttype.aspx.cs.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:umbraco:umbraco_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "ED6DB680-A447-45E3-9DA7-F1B4FB25C557", "versionEndExcluding": null, "versionEndIncluding": "7.7.2", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "XML external entity (XXE) vulnerability in Umbraco CMS before 7.7.3 allows attackers to obtain sensitive information by reading files on the server or sending TCP requests to intranet hosts (aka SSRF), related to Umbraco.Web/umbraco.presentation/umbraco/dialogs/importDocumenttype.aspx.cs."}, {"lang": "es", "value": "Vulnerabilidad XEE (XML External Entity) en Umbraco CMS en versiones anteriores 7.7.3 permite que atacantes obtengan informaci\u00f3n sensible leyendo archivos en el servidor o enviando peticiones TCP a hosts de la intranet (tambi\u00e9n conocido como SSRF). Esto est\u00e1 relacionado con Umbraco.Web/umbraco.presentation/umbraco/dialogs/importDocumenttype.aspx.cs."}], "evaluatorComment": null, "id": "CVE-2017-15280", "lastModified": "2017-10-25T12:53:37.937", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:N/AC:M/Au:N/C:P/I:N/A:N", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": true}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "NONE", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N", "version": "3.0"}, "exploitabilityScore": 1.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-10-12T08:29:00.510", "references": [{"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Vendor Advisory"], "url": "http://issues.umbraco.org/issue/U4-10506"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/umbraco/Umbraco-CMS/commit/5dde2efe0d2b3a47d17439e03acabb7ea2befb64"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-611"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/umbraco/Umbraco-CMS/commit/5dde2efe0d2b3a47d17439e03acabb7ea2befb64"}, "type": "CWE-611"}
| 363
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Utility functions for x86 operand and address decoding\n *\n * Copyright (C) Intel Corporation 2017\n */\n#include <linux/kernel.h>\n#include <linux/string.h>\n#include <linux/ratelimit.h>\n#include <linux/mmu_context.h>\n#include <asm/desc_defs.h>\n#include <asm/desc.h>\n#include <asm/inat.h>\n#include <asm/insn.h>\n#include <asm/insn-eval.h>\n#include <asm/ldt.h>\n#include <asm/vm86.h>",
"#undef pr_fmt\n#define pr_fmt(fmt) \"insn: \" fmt",
"enum reg_type {\n\tREG_TYPE_RM = 0,\n\tREG_TYPE_INDEX,\n\tREG_TYPE_BASE,\n};",
"/**\n * is_string_insn() - Determine if instruction is a string instruction\n * @insn:\tInstruction containing the opcode to inspect\n *\n * Returns:\n *\n * true if the instruction, determined by the opcode, is any of the\n * string instructions as defined in the Intel Software Development manual.\n * False otherwise.\n */\nstatic bool is_string_insn(struct insn *insn)\n{\n\tinsn_get_opcode(insn);",
"\t/* All string instructions have a 1-byte opcode. */\n\tif (insn->opcode.nbytes != 1)\n\t\treturn false;",
"\tswitch (insn->opcode.bytes[0]) {\n\tcase 0x6c ... 0x6f:\t/* INS, OUTS */\n\tcase 0xa4 ... 0xa7:\t/* MOVS, CMPS */\n\tcase 0xaa ... 0xaf:\t/* STOS, LODS, SCAS */\n\t\treturn true;\n\tdefault:\n\t\treturn false;\n\t}\n}",
"/**\n * get_seg_reg_override_idx() - obtain segment register override index\n * @insn:\tValid instruction with segment override prefixes\n *\n * Inspect the instruction prefixes in @insn and find segment overrides, if any.\n *\n * Returns:\n *\n * A constant identifying the segment register to use, among CS, SS, DS,\n * ES, FS, or GS. INAT_SEG_REG_DEFAULT is returned if no segment override\n * prefixes were found.\n *\n * -EINVAL in case of error.\n */\nstatic int get_seg_reg_override_idx(struct insn *insn)\n{\n\tint idx = INAT_SEG_REG_DEFAULT;\n\tint num_overrides = 0, i;",
"\tinsn_get_prefixes(insn);",
"\t/* Look for any segment override prefixes. */\n\tfor (i = 0; i < insn->prefixes.nbytes; i++) {\n\t\tinsn_attr_t attr;",
"\t\tattr = inat_get_opcode_attribute(insn->prefixes.bytes[i]);\n\t\tswitch (attr) {\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_CS):\n\t\t\tidx = INAT_SEG_REG_CS;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_SS):\n\t\t\tidx = INAT_SEG_REG_SS;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_DS):\n\t\t\tidx = INAT_SEG_REG_DS;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_ES):\n\t\t\tidx = INAT_SEG_REG_ES;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_FS):\n\t\t\tidx = INAT_SEG_REG_FS;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_GS):\n\t\t\tidx = INAT_SEG_REG_GS;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\t/* No default action needed. */\n\t\t}\n\t}",
"\t/* More than one segment override prefix leads to undefined behavior. */\n\tif (num_overrides > 1)\n\t\treturn -EINVAL;",
"\treturn idx;\n}",
"/**\n * check_seg_overrides() - check if segment override prefixes are allowed\n * @insn:\tValid instruction with segment override prefixes\n * @regoff:\tOperand offset, in pt_regs, for which the check is performed\n *\n * For a particular register used in register-indirect addressing, determine if\n * segment override prefixes can be used. Specifically, no overrides are allowed\n * for rDI if used with a string instruction.\n *\n * Returns:\n *\n * True if segment override prefixes can be used with the register indicated\n * in @regoff. False if otherwise.\n */\nstatic bool check_seg_overrides(struct insn *insn, int regoff)\n{\n\tif (regoff == offsetof(struct pt_regs, di) && is_string_insn(insn))\n\t\treturn false;",
"\treturn true;\n}",
"/**\n * resolve_default_seg() - resolve default segment register index for an operand\n * @insn:\tInstruction with opcode and address size. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @off:\tOperand offset, in pt_regs, for which resolution is needed\n *\n * Resolve the default segment register index associated with the instruction\n * operand register indicated by @off. Such index is resolved based on defaults\n * described in the Intel Software Development Manual.\n *\n * Returns:\n *\n * If in protected mode, a constant identifying the segment register to use,\n * among CS, SS, ES or DS. If in long mode, INAT_SEG_REG_IGNORE.\n *\n * -EINVAL in case of error.\n */\nstatic int resolve_default_seg(struct insn *insn, struct pt_regs *regs, int off)\n{\n\tif (user_64bit_mode(regs))\n\t\treturn INAT_SEG_REG_IGNORE;\n\t/*\n\t * Resolve the default segment register as described in Section 3.7.4\n\t * of the Intel Software Development Manual Vol. 1:\n\t *\n\t * + DS for all references involving r[ABCD]X, and rSI.\n\t * + If used in a string instruction, ES for rDI. Otherwise, DS.\n\t * + AX, CX and DX are not valid register operands in 16-bit address\n\t * encodings but are valid for 32-bit and 64-bit encodings.\n\t * + -EDOM is reserved to identify for cases in which no register\n\t * is used (i.e., displacement-only addressing). Use DS.\n\t * + SS for rSP or rBP.\n\t * + CS for rIP.\n\t */",
"\tswitch (off) {\n\tcase offsetof(struct pt_regs, ax):\n\tcase offsetof(struct pt_regs, cx):\n\tcase offsetof(struct pt_regs, dx):\n\t\t/* Need insn to verify address size. */\n\t\tif (insn->addr_bytes == 2)\n\t\t\treturn -EINVAL;",
"\t\t/* fall through */",
"\tcase -EDOM:\n\tcase offsetof(struct pt_regs, bx):\n\tcase offsetof(struct pt_regs, si):\n\t\treturn INAT_SEG_REG_DS;",
"\tcase offsetof(struct pt_regs, di):\n\t\tif (is_string_insn(insn))\n\t\t\treturn INAT_SEG_REG_ES;\n\t\treturn INAT_SEG_REG_DS;",
"\tcase offsetof(struct pt_regs, bp):\n\tcase offsetof(struct pt_regs, sp):\n\t\treturn INAT_SEG_REG_SS;",
"\tcase offsetof(struct pt_regs, ip):\n\t\treturn INAT_SEG_REG_CS;",
"\tdefault:\n\t\treturn -EINVAL;\n\t}\n}",
"/**\n * resolve_seg_reg() - obtain segment register index\n * @insn:\tInstruction with operands\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tOperand offset, in pt_regs, used to deterimine segment register\n *\n * Determine the segment register associated with the operands and, if\n * applicable, prefixes and the instruction pointed by @insn.\n *\n * The segment register associated to an operand used in register-indirect\n * addressing depends on:\n *\n * a) Whether running in long mode (in such a case segments are ignored, except\n * if FS or GS are used).\n *\n * b) Whether segment override prefixes can be used. Certain instructions and\n * registers do not allow override prefixes.\n *\n * c) Whether segment overrides prefixes are found in the instruction prefixes.\n *\n * d) If there are not segment override prefixes or they cannot be used, the\n * default segment register associated with the operand register is used.\n *\n * The function checks first if segment override prefixes can be used with the\n * operand indicated by @regoff. If allowed, obtain such overridden segment\n * register index. Lastly, if not prefixes were found or cannot be used, resolve\n * the segment register index to use based on the defaults described in the\n * Intel documentation. In long mode, all segment register indexes will be\n * ignored, except if overrides were found for FS or GS. All these operations\n * are done using helper functions.\n *\n * The operand register, @regoff, is represented as the offset from the base of\n * pt_regs.\n *\n * As stated, the main use of this function is to determine the segment register\n * index based on the instruction, its operands and prefixes. Hence, @insn\n * must be valid. However, if @regoff indicates rIP, we don't need to inspect\n * @insn at all as in this case CS is used in all cases. This case is checked\n * before proceeding further.\n *\n * Please note that this function does not return the value in the segment\n * register (i.e., the segment selector) but our defined index. The segment\n * selector needs to be obtained using get_segment_selector() and passing the\n * segment register index resolved by this function.\n *\n * Returns:\n *\n * An index identifying the segment register to use, among CS, SS, DS,\n * ES, FS, or GS. INAT_SEG_REG_IGNORE is returned if running in long mode.\n *\n * -EINVAL in case of error.\n */\nstatic int resolve_seg_reg(struct insn *insn, struct pt_regs *regs, int regoff)\n{\n\tint idx;",
"\t/*\n\t * In the unlikely event of having to resolve the segment register\n\t * index for rIP, do it first. Segment override prefixes should not\n\t * be used. Hence, it is not necessary to inspect the instruction,\n\t * which may be invalid at this point.\n\t */\n\tif (regoff == offsetof(struct pt_regs, ip)) {\n\t\tif (user_64bit_mode(regs))\n\t\t\treturn INAT_SEG_REG_IGNORE;\n\t\telse\n\t\t\treturn INAT_SEG_REG_CS;\n\t}",
"\tif (!insn)\n\t\treturn -EINVAL;",
"\tif (!check_seg_overrides(insn, regoff))\n\t\treturn resolve_default_seg(insn, regs, regoff);",
"\tidx = get_seg_reg_override_idx(insn);\n\tif (idx < 0)\n\t\treturn idx;",
"\tif (idx == INAT_SEG_REG_DEFAULT)\n\t\treturn resolve_default_seg(insn, regs, regoff);",
"\t/*\n\t * In long mode, segment override prefixes are ignored, except for\n\t * overrides for FS and GS.\n\t */\n\tif (user_64bit_mode(regs)) {\n\t\tif (idx != INAT_SEG_REG_FS &&\n\t\t idx != INAT_SEG_REG_GS)\n\t\t\tidx = INAT_SEG_REG_IGNORE;\n\t}",
"\treturn idx;\n}",
"/**\n * get_segment_selector() - obtain segment selector\n * @regs:\t\tRegister values as seen when entering kernel mode\n * @seg_reg_idx:\tSegment register index to use\n *\n * Obtain the segment selector from any of the CS, SS, DS, ES, FS, GS segment\n * registers. In CONFIG_X86_32, the segment is obtained from either pt_regs or\n * kernel_vm86_regs as applicable. In CONFIG_X86_64, CS and SS are obtained\n * from pt_regs. DS, ES, FS and GS are obtained by reading the actual CPU\n * registers. This done for only for completeness as in CONFIG_X86_64 segment\n * registers are ignored.\n *\n * Returns:\n *\n * Value of the segment selector, including null when running in\n * long mode.\n *\n * -EINVAL on error.\n */\nstatic short get_segment_selector(struct pt_regs *regs, int seg_reg_idx)\n{\n#ifdef CONFIG_X86_64\n\tunsigned short sel;",
"\tswitch (seg_reg_idx) {\n\tcase INAT_SEG_REG_IGNORE:\n\t\treturn 0;\n\tcase INAT_SEG_REG_CS:\n\t\treturn (unsigned short)(regs->cs & 0xffff);\n\tcase INAT_SEG_REG_SS:\n\t\treturn (unsigned short)(regs->ss & 0xffff);\n\tcase INAT_SEG_REG_DS:\n\t\tsavesegment(ds, sel);\n\t\treturn sel;\n\tcase INAT_SEG_REG_ES:\n\t\tsavesegment(es, sel);\n\t\treturn sel;\n\tcase INAT_SEG_REG_FS:\n\t\tsavesegment(fs, sel);\n\t\treturn sel;\n\tcase INAT_SEG_REG_GS:\n\t\tsavesegment(gs, sel);\n\t\treturn sel;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n#else /* CONFIG_X86_32 */\n\tstruct kernel_vm86_regs *vm86regs = (struct kernel_vm86_regs *)regs;",
"\tif (v8086_mode(regs)) {\n\t\tswitch (seg_reg_idx) {\n\t\tcase INAT_SEG_REG_CS:\n\t\t\treturn (unsigned short)(regs->cs & 0xffff);\n\t\tcase INAT_SEG_REG_SS:\n\t\t\treturn (unsigned short)(regs->ss & 0xffff);\n\t\tcase INAT_SEG_REG_DS:\n\t\t\treturn vm86regs->ds;\n\t\tcase INAT_SEG_REG_ES:\n\t\t\treturn vm86regs->es;\n\t\tcase INAT_SEG_REG_FS:\n\t\t\treturn vm86regs->fs;\n\t\tcase INAT_SEG_REG_GS:\n\t\t\treturn vm86regs->gs;\n\t\tcase INAT_SEG_REG_IGNORE:\n\t\t\t/* fall through */\n\t\tdefault:\n\t\t\treturn -EINVAL;\n\t\t}\n\t}",
"\tswitch (seg_reg_idx) {\n\tcase INAT_SEG_REG_CS:\n\t\treturn (unsigned short)(regs->cs & 0xffff);\n\tcase INAT_SEG_REG_SS:\n\t\treturn (unsigned short)(regs->ss & 0xffff);\n\tcase INAT_SEG_REG_DS:\n\t\treturn (unsigned short)(regs->ds & 0xffff);\n\tcase INAT_SEG_REG_ES:\n\t\treturn (unsigned short)(regs->es & 0xffff);\n\tcase INAT_SEG_REG_FS:\n\t\treturn (unsigned short)(regs->fs & 0xffff);\n\tcase INAT_SEG_REG_GS:\n\t\t/*\n\t\t * GS may or may not be in regs as per CONFIG_X86_32_LAZY_GS.\n\t\t * The macro below takes care of both cases.\n\t\t */\n\t\treturn get_user_gs(regs);\n\tcase INAT_SEG_REG_IGNORE:\n\t\t/* fall through */\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n#endif /* CONFIG_X86_64 */\n}",
"static int get_reg_offset(struct insn *insn, struct pt_regs *regs,\n\t\t\t enum reg_type type)\n{\n\tint regno = 0;",
"\tstatic const int regoff[] = {\n\t\toffsetof(struct pt_regs, ax),\n\t\toffsetof(struct pt_regs, cx),\n\t\toffsetof(struct pt_regs, dx),\n\t\toffsetof(struct pt_regs, bx),\n\t\toffsetof(struct pt_regs, sp),\n\t\toffsetof(struct pt_regs, bp),\n\t\toffsetof(struct pt_regs, si),\n\t\toffsetof(struct pt_regs, di),\n#ifdef CONFIG_X86_64\n\t\toffsetof(struct pt_regs, r8),\n\t\toffsetof(struct pt_regs, r9),\n\t\toffsetof(struct pt_regs, r10),\n\t\toffsetof(struct pt_regs, r11),\n\t\toffsetof(struct pt_regs, r12),\n\t\toffsetof(struct pt_regs, r13),\n\t\toffsetof(struct pt_regs, r14),\n\t\toffsetof(struct pt_regs, r15),\n#endif\n\t};\n\tint nr_registers = ARRAY_SIZE(regoff);\n\t/*\n\t * Don't possibly decode a 32-bit instructions as\n\t * reading a 64-bit-only register.\n\t */\n\tif (IS_ENABLED(CONFIG_X86_64) && !insn->x86_64)\n\t\tnr_registers -= 8;",
"\tswitch (type) {\n\tcase REG_TYPE_RM:\n\t\tregno = X86_MODRM_RM(insn->modrm.value);",
"\t\t/*\n\t\t * ModRM.mod == 0 and ModRM.rm == 5 means a 32-bit displacement\n\t\t * follows the ModRM byte.\n\t\t */\n\t\tif (!X86_MODRM_MOD(insn->modrm.value) && regno == 5)\n\t\t\treturn -EDOM;",
"\t\tif (X86_REX_B(insn->rex_prefix.value))\n\t\t\tregno += 8;\n\t\tbreak;",
"\tcase REG_TYPE_INDEX:\n\t\tregno = X86_SIB_INDEX(insn->sib.value);\n\t\tif (X86_REX_X(insn->rex_prefix.value))\n\t\t\tregno += 8;",
"\t\t/*\n\t\t * If ModRM.mod != 3 and SIB.index = 4 the scale*index\n\t\t * portion of the address computation is null. This is\n\t\t * true only if REX.X is 0. In such a case, the SIB index\n\t\t * is used in the address computation.\n\t\t */\n\t\tif (X86_MODRM_MOD(insn->modrm.value) != 3 && regno == 4)\n\t\t\treturn -EDOM;\n\t\tbreak;",
"\tcase REG_TYPE_BASE:\n\t\tregno = X86_SIB_BASE(insn->sib.value);\n\t\t/*\n\t\t * If ModRM.mod is 0 and SIB.base == 5, the base of the\n\t\t * register-indirect addressing is 0. In this case, a\n\t\t * 32-bit displacement follows the SIB byte.\n\t\t */\n\t\tif (!X86_MODRM_MOD(insn->modrm.value) && regno == 5)\n\t\t\treturn -EDOM;",
"\t\tif (X86_REX_B(insn->rex_prefix.value))\n\t\t\tregno += 8;\n\t\tbreak;",
"\tdefault:\n\t\tpr_err_ratelimited(\"invalid register type: %d\\n\", type);\n\t\treturn -EINVAL;\n\t}",
"\tif (regno >= nr_registers) {\n\t\tWARN_ONCE(1, \"decoded an instruction with an invalid register\");\n\t\treturn -EINVAL;\n\t}\n\treturn regoff[regno];\n}",
"/**\n * get_reg_offset_16() - Obtain offset of register indicated by instruction\n * @insn:\tInstruction containing ModRM byte\n * @regs:\tRegister values as seen when entering kernel mode\n * @offs1:\tOffset of the first operand register\n * @offs2:\tOffset of the second opeand register, if applicable\n *\n * Obtain the offset, in pt_regs, of the registers indicated by the ModRM byte\n * in @insn. This function is to be used with 16-bit address encodings. The\n * @offs1 and @offs2 will be written with the offset of the two registers\n * indicated by the instruction. In cases where any of the registers is not\n * referenced by the instruction, the value will be set to -EDOM.\n *\n * Returns:\n *\n * 0 on success, -EINVAL on error.\n */\nstatic int get_reg_offset_16(struct insn *insn, struct pt_regs *regs,\n\t\t\t int *offs1, int *offs2)\n{\n\t/*\n\t * 16-bit addressing can use one or two registers. Specifics of\n\t * encodings are given in Table 2-1. \"16-Bit Addressing Forms with the\n\t * ModR/M Byte\" of the Intel Software Development Manual.\n\t */\n\tstatic const int regoff1[] = {\n\t\toffsetof(struct pt_regs, bx),\n\t\toffsetof(struct pt_regs, bx),\n\t\toffsetof(struct pt_regs, bp),\n\t\toffsetof(struct pt_regs, bp),\n\t\toffsetof(struct pt_regs, si),\n\t\toffsetof(struct pt_regs, di),\n\t\toffsetof(struct pt_regs, bp),\n\t\toffsetof(struct pt_regs, bx),\n\t};",
"\tstatic const int regoff2[] = {\n\t\toffsetof(struct pt_regs, si),\n\t\toffsetof(struct pt_regs, di),\n\t\toffsetof(struct pt_regs, si),\n\t\toffsetof(struct pt_regs, di),\n\t\t-EDOM,\n\t\t-EDOM,\n\t\t-EDOM,\n\t\t-EDOM,\n\t};",
"\tif (!offs1 || !offs2)\n\t\treturn -EINVAL;",
"\t/* Operand is a register, use the generic function. */\n\tif (X86_MODRM_MOD(insn->modrm.value) == 3) {\n\t\t*offs1 = insn_get_modrm_rm_off(insn, regs);\n\t\t*offs2 = -EDOM;\n\t\treturn 0;\n\t}",
"\t*offs1 = regoff1[X86_MODRM_RM(insn->modrm.value)];\n\t*offs2 = regoff2[X86_MODRM_RM(insn->modrm.value)];",
"\t/*\n\t * If ModRM.mod is 0 and ModRM.rm is 110b, then we use displacement-\n\t * only addressing. This means that no registers are involved in\n\t * computing the effective address. Thus, ensure that the first\n\t * register offset is invalild. The second register offset is already\n\t * invalid under the aforementioned conditions.\n\t */\n\tif ((X86_MODRM_MOD(insn->modrm.value) == 0) &&\n\t (X86_MODRM_RM(insn->modrm.value) == 6))\n\t\t*offs1 = -EDOM;",
"\treturn 0;\n}",
"/**",
" * get_desc() - Obtain pointer to a segment descriptor",
" * @sel:\tSegment selector\n *\n * Given a segment selector, obtain a pointer to the segment descriptor.\n * Both global and local descriptor tables are supported.\n *\n * Returns:\n *",
" * Pointer to segment descriptor on success.",
" *\n * NULL on error.\n */",
"static struct desc_struct *get_desc(unsigned short sel)",
"{\n\tstruct desc_ptr gdt_desc = {0, 0};\n\tunsigned long desc_base;",
"#ifdef CONFIG_MODIFY_LDT_SYSCALL\n\tif ((sel & SEGMENT_TI_MASK) == SEGMENT_LDT) {",
"\t\tstruct desc_struct *desc = NULL;",
"\t\tstruct ldt_struct *ldt;",
"\t\t/* Bits [15:3] contain the index of the desired entry. */\n\t\tsel >>= 3;",
"\t\tmutex_lock(¤t->active_mm->context.lock);\n\t\tldt = current->active_mm->context.ldt;",
"\t\tif (ldt && sel < ldt->nr_entries)\n\t\t\tdesc = &ldt->entries[sel];",
"\n\t\tmutex_unlock(¤t->active_mm->context.lock);\n",
"\t\treturn desc;",
"\t}\n#endif\n\tnative_store_gdt(&gdt_desc);",
"\t/*\n\t * Segment descriptors have a size of 8 bytes. Thus, the index is\n\t * multiplied by 8 to obtain the memory offset of the desired descriptor\n\t * from the base of the GDT. As bits [15:3] of the segment selector\n\t * contain the index, it can be regarded as multiplied by 8 already.\n\t * All that remains is to clear bits [2:0].\n\t */\n\tdesc_base = sel & ~(SEGMENT_RPL_MASK | SEGMENT_TI_MASK);",
"\tif (desc_base > gdt_desc.size)",
"\t\treturn NULL;",
"\treturn (struct desc_struct *)(gdt_desc.address + desc_base);",
"}",
"/**\n * insn_get_seg_base() - Obtain base address of segment descriptor.\n * @regs:\t\tRegister values as seen when entering kernel mode\n * @seg_reg_idx:\tIndex of the segment register pointing to seg descriptor\n *\n * Obtain the base address of the segment as indicated by the segment descriptor\n * pointed by the segment selector. The segment selector is obtained from the\n * input segment register index @seg_reg_idx.\n *\n * Returns:\n *\n * In protected mode, base address of the segment. Zero in long mode,\n * except when FS or GS are used. In virtual-8086 mode, the segment\n * selector shifted 4 bits to the right.\n *\n * -1L in case of error.\n */\nunsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx)\n{",
"\tstruct desc_struct *desc;",
"\tshort sel;",
"\tsel = get_segment_selector(regs, seg_reg_idx);\n\tif (sel < 0)\n\t\treturn -1L;",
"\tif (v8086_mode(regs))\n\t\t/*\n\t\t * Base is simply the segment selector shifted 4\n\t\t * bits to the right.\n\t\t */\n\t\treturn (unsigned long)(sel << 4);",
"\tif (user_64bit_mode(regs)) {\n\t\t/*\n\t\t * Only FS or GS will have a base address, the rest of\n\t\t * the segments' bases are forced to 0.\n\t\t */\n\t\tunsigned long base;",
"\t\tif (seg_reg_idx == INAT_SEG_REG_FS)\n\t\t\trdmsrl(MSR_FS_BASE, base);\n\t\telse if (seg_reg_idx == INAT_SEG_REG_GS)\n\t\t\t/*\n\t\t\t * swapgs was called at the kernel entry point. Thus,\n\t\t\t * MSR_KERNEL_GS_BASE will have the user-space GS base.\n\t\t\t */\n\t\t\trdmsrl(MSR_KERNEL_GS_BASE, base);\n\t\telse\n\t\t\tbase = 0;\n\t\treturn base;\n\t}",
"\t/* In protected mode the segment selector cannot be null. */\n\tif (!sel)\n\t\treturn -1L;\n",
"\tdesc = get_desc(sel);\n\tif (!desc)",
"\t\treturn -1L;\n",
"\treturn get_desc_base(desc);",
"}",
"/**\n * get_seg_limit() - Obtain the limit of a segment descriptor\n * @regs:\t\tRegister values as seen when entering kernel mode\n * @seg_reg_idx:\tIndex of the segment register pointing to seg descriptor\n *\n * Obtain the limit of the segment as indicated by the segment descriptor\n * pointed by the segment selector. The segment selector is obtained from the\n * input segment register index @seg_reg_idx.\n *\n * Returns:\n *\n * In protected mode, the limit of the segment descriptor in bytes.\n * In long mode and virtual-8086 mode, segment limits are not enforced. Thus,\n * limit is returned as -1L to imply a limit-less segment.\n *\n * Zero is returned on error.\n */\nstatic unsigned long get_seg_limit(struct pt_regs *regs, int seg_reg_idx)\n{",
"\tstruct desc_struct *desc;",
"\tunsigned long limit;\n\tshort sel;",
"\tsel = get_segment_selector(regs, seg_reg_idx);\n\tif (sel < 0)\n\t\treturn 0;",
"\tif (user_64bit_mode(regs) || v8086_mode(regs))\n\t\treturn -1L;",
"\tif (!sel)\n\t\treturn 0;\n",
"\tdesc = get_desc(sel);\n\tif (!desc)",
"\t\treturn 0;",
"\t/*\n\t * If the granularity bit is set, the limit is given in multiples\n\t * of 4096. This also means that the 12 least significant bits are\n\t * not tested when checking the segment limits. In practice,\n\t * this means that the segment ends in (limit << 12) + 0xfff.\n\t */",
"\tlimit = get_desc_limit(desc);\n\tif (desc->g)",
"\t\tlimit = (limit << 12) + 0xfff;",
"\treturn limit;\n}",
"/**\n * insn_get_code_seg_params() - Obtain code segment parameters\n * @regs:\tStructure with register values as seen when entering kernel mode\n *\n * Obtain address and operand sizes of the code segment. It is obtained from the\n * selector contained in the CS register in regs. In protected mode, the default\n * address is determined by inspecting the L and D bits of the segment\n * descriptor. In virtual-8086 mode, the default is always two bytes for both\n * address and operand sizes.\n *\n * Returns:\n *\n * An int containing ORed-in default parameters on success.\n *\n * -EINVAL on error.\n */\nint insn_get_code_seg_params(struct pt_regs *regs)\n{",
"\tstruct desc_struct *desc;",
"\tshort sel;",
"\tif (v8086_mode(regs))\n\t\t/* Address and operand size are both 16-bit. */\n\t\treturn INSN_CODE_SEG_PARAMS(2, 2);",
"\tsel = get_segment_selector(regs, INAT_SEG_REG_CS);\n\tif (sel < 0)\n\t\treturn sel;\n",
"\tdesc = get_desc(sel);\n\tif (!desc)",
"\t\treturn -EINVAL;",
"\t/*\n\t * The most significant byte of the Type field of the segment descriptor\n\t * determines whether a segment contains data or code. If this is a data\n\t * segment, return error.\n\t */",
"\tif (!(desc->type & BIT(3)))\n\t\treturn -EINVAL;",
"\tswitch ((desc->l << 1) | desc->d) {",
"\tcase 0: /*\n\t\t * Legacy mode. CS.L=0, CS.D=0. Address and operand size are\n\t\t * both 16-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(2, 2);\n\tcase 1: /*\n\t\t * Legacy mode. CS.L=0, CS.D=1. Address and operand size are\n\t\t * both 32-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(4, 4);\n\tcase 2: /*\n\t\t * IA-32e 64-bit mode. CS.L=1, CS.D=0. Address size is 64-bit;\n\t\t * operand size is 32-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(4, 8);\n\tcase 3: /* Invalid setting. CS.L=1, CS.D=1 */\n\t\t/* fall through */\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n}",
"/**\n * insn_get_modrm_rm_off() - Obtain register in r/m part of the ModRM byte\n * @insn:\tInstruction containing the ModRM byte\n * @regs:\tRegister values as seen when entering kernel mode\n *\n * Returns:\n *\n * The register indicated by the r/m part of the ModRM byte. The\n * register is obtained as an offset from the base of pt_regs. In specific\n * cases, the returned value can be -EDOM to indicate that the particular value\n * of ModRM does not refer to a register and shall be ignored.\n */\nint insn_get_modrm_rm_off(struct insn *insn, struct pt_regs *regs)\n{\n\treturn get_reg_offset(insn, regs, REG_TYPE_RM);\n}",
"/**\n * get_seg_base_limit() - obtain base address and limit of a segment\n * @insn:\tInstruction. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tOperand offset, in pt_regs, used to resolve segment descriptor\n * @base:\tObtained segment base\n * @limit:\tObtained segment limit\n *\n * Obtain the base address and limit of the segment associated with the operand\n * @regoff and, if any or allowed, override prefixes in @insn. This function is\n * different from insn_get_seg_base() as the latter does not resolve the segment\n * associated with the instruction operand. If a limit is not needed (e.g.,\n * when running in long mode), @limit can be NULL.\n *\n * Returns:\n *\n * 0 on success. @base and @limit will contain the base address and of the\n * resolved segment, respectively.\n *\n * -EINVAL on error.\n */\nstatic int get_seg_base_limit(struct insn *insn, struct pt_regs *regs,\n\t\t\t int regoff, unsigned long *base,\n\t\t\t unsigned long *limit)\n{\n\tint seg_reg_idx;",
"\tif (!base)\n\t\treturn -EINVAL;",
"\tseg_reg_idx = resolve_seg_reg(insn, regs, regoff);\n\tif (seg_reg_idx < 0)\n\t\treturn seg_reg_idx;",
"\t*base = insn_get_seg_base(regs, seg_reg_idx);\n\tif (*base == -1L)\n\t\treturn -EINVAL;",
"\tif (!limit)\n\t\treturn 0;",
"\t*limit = get_seg_limit(regs, seg_reg_idx);\n\tif (!(*limit))\n\t\treturn -EINVAL;",
"\treturn 0;\n}",
"/**\n * get_eff_addr_reg() - Obtain effective address from register operand\n * @insn:\tInstruction. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tObtained operand offset, in pt_regs, with the effective address\n * @eff_addr:\tObtained effective address\n *\n * Obtain the effective address stored in the register operand as indicated by\n * the ModRM byte. This function is to be used only with register addressing\n * (i.e., ModRM.mod is 3). The effective address is saved in @eff_addr. The\n * register operand, as an offset from the base of pt_regs, is saved in @regoff;\n * such offset can then be used to resolve the segment associated with the\n * operand. This function can be used with any of the supported address sizes\n * in x86.\n *\n * Returns:\n *\n * 0 on success. @eff_addr will have the effective address stored in the\n * operand indicated by ModRM. @regoff will have such operand as an offset from\n * the base of pt_regs.\n *\n * -EINVAL on error.\n */\nstatic int get_eff_addr_reg(struct insn *insn, struct pt_regs *regs,\n\t\t\t int *regoff, long *eff_addr)\n{\n\tinsn_get_modrm(insn);",
"\tif (!insn->modrm.nbytes)\n\t\treturn -EINVAL;",
"\tif (X86_MODRM_MOD(insn->modrm.value) != 3)\n\t\treturn -EINVAL;",
"\t*regoff = get_reg_offset(insn, regs, REG_TYPE_RM);\n\tif (*regoff < 0)\n\t\treturn -EINVAL;",
"\t/* Ignore bytes that are outside the address size. */\n\tif (insn->addr_bytes == 2)\n\t\t*eff_addr = regs_get_register(regs, *regoff) & 0xffff;\n\telse if (insn->addr_bytes == 4)\n\t\t*eff_addr = regs_get_register(regs, *regoff) & 0xffffffff;\n\telse /* 64-bit address */\n\t\t*eff_addr = regs_get_register(regs, *regoff);",
"\treturn 0;\n}",
"/**\n * get_eff_addr_modrm() - Obtain referenced effective address via ModRM\n * @insn:\tInstruction. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tObtained operand offset, in pt_regs, associated with segment\n * @eff_addr:\tObtained effective address\n *\n * Obtain the effective address referenced by the ModRM byte of @insn. After\n * identifying the registers involved in the register-indirect memory reference,\n * its value is obtained from the operands in @regs. The computed address is\n * stored @eff_addr. Also, the register operand that indicates the associated\n * segment is stored in @regoff, this parameter can later be used to determine\n * such segment.\n *\n * Returns:\n *\n * 0 on success. @eff_addr will have the referenced effective address. @regoff\n * will have a register, as an offset from the base of pt_regs, that can be used\n * to resolve the associated segment.\n *\n * -EINVAL on error.\n */\nstatic int get_eff_addr_modrm(struct insn *insn, struct pt_regs *regs,\n\t\t\t int *regoff, long *eff_addr)\n{\n\tlong tmp;",
"\tif (insn->addr_bytes != 8 && insn->addr_bytes != 4)\n\t\treturn -EINVAL;",
"\tinsn_get_modrm(insn);",
"\tif (!insn->modrm.nbytes)\n\t\treturn -EINVAL;",
"\tif (X86_MODRM_MOD(insn->modrm.value) > 2)\n\t\treturn -EINVAL;",
"\t*regoff = get_reg_offset(insn, regs, REG_TYPE_RM);",
"\t/*\n\t * -EDOM means that we must ignore the address_offset. In such a case,\n\t * in 64-bit mode the effective address relative to the rIP of the\n\t * following instruction.\n\t */\n\tif (*regoff == -EDOM) {\n\t\tif (user_64bit_mode(regs))\n\t\t\ttmp = regs->ip + insn->length;\n\t\telse\n\t\t\ttmp = 0;\n\t} else if (*regoff < 0) {\n\t\treturn -EINVAL;\n\t} else {\n\t\ttmp = regs_get_register(regs, *regoff);\n\t}",
"\tif (insn->addr_bytes == 4) {\n\t\tint addr32 = (int)(tmp & 0xffffffff) + insn->displacement.value;",
"\t\t*eff_addr = addr32 & 0xffffffff;\n\t} else {\n\t\t*eff_addr = tmp + insn->displacement.value;\n\t}",
"\treturn 0;\n}",
"/**\n * get_eff_addr_modrm_16() - Obtain referenced effective address via ModRM\n * @insn:\tInstruction. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tObtained operand offset, in pt_regs, associated with segment\n * @eff_addr:\tObtained effective address\n *\n * Obtain the 16-bit effective address referenced by the ModRM byte of @insn.\n * After identifying the registers involved in the register-indirect memory\n * reference, its value is obtained from the operands in @regs. The computed\n * address is stored @eff_addr. Also, the register operand that indicates\n * the associated segment is stored in @regoff, this parameter can later be used\n * to determine such segment.\n *\n * Returns:\n *\n * 0 on success. @eff_addr will have the referenced effective address. @regoff\n * will have a register, as an offset from the base of pt_regs, that can be used\n * to resolve the associated segment.\n *\n * -EINVAL on error.\n */\nstatic int get_eff_addr_modrm_16(struct insn *insn, struct pt_regs *regs,\n\t\t\t\t int *regoff, short *eff_addr)\n{\n\tint addr_offset1, addr_offset2, ret;\n\tshort addr1 = 0, addr2 = 0, displacement;",
"\tif (insn->addr_bytes != 2)\n\t\treturn -EINVAL;",
"\tinsn_get_modrm(insn);",
"\tif (!insn->modrm.nbytes)\n\t\treturn -EINVAL;",
"\tif (X86_MODRM_MOD(insn->modrm.value) > 2)\n\t\treturn -EINVAL;",
"\tret = get_reg_offset_16(insn, regs, &addr_offset1, &addr_offset2);\n\tif (ret < 0)\n\t\treturn -EINVAL;",
"\t/*\n\t * Don't fail on invalid offset values. They might be invalid because\n\t * they cannot be used for this particular value of ModRM. Instead, use\n\t * them in the computation only if they contain a valid value.\n\t */\n\tif (addr_offset1 != -EDOM)\n\t\taddr1 = regs_get_register(regs, addr_offset1) & 0xffff;",
"\tif (addr_offset2 != -EDOM)\n\t\taddr2 = regs_get_register(regs, addr_offset2) & 0xffff;",
"\tdisplacement = insn->displacement.value & 0xffff;\n\t*eff_addr = addr1 + addr2 + displacement;",
"\t/*\n\t * The first operand register could indicate to use of either SS or DS\n\t * registers to obtain the segment selector. The second operand\n\t * register can only indicate the use of DS. Thus, the first operand\n\t * will be used to obtain the segment selector.\n\t */\n\t*regoff = addr_offset1;",
"\treturn 0;\n}",
"/**\n * get_eff_addr_sib() - Obtain referenced effective address via SIB\n * @insn:\tInstruction. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tObtained operand offset, in pt_regs, associated with segment\n * @eff_addr:\tObtained effective address\n *\n * Obtain the effective address referenced by the SIB byte of @insn. After\n * identifying the registers involved in the indexed, register-indirect memory\n * reference, its value is obtained from the operands in @regs. The computed\n * address is stored @eff_addr. Also, the register operand that indicates the\n * associated segment is stored in @regoff, this parameter can later be used to\n * determine such segment.\n *\n * Returns:\n *\n * 0 on success. @eff_addr will have the referenced effective address.\n * @base_offset will have a register, as an offset from the base of pt_regs,\n * that can be used to resolve the associated segment.\n *\n * -EINVAL on error.\n */\nstatic int get_eff_addr_sib(struct insn *insn, struct pt_regs *regs,\n\t\t\t int *base_offset, long *eff_addr)\n{\n\tlong base, indx;\n\tint indx_offset;",
"\tif (insn->addr_bytes != 8 && insn->addr_bytes != 4)\n\t\treturn -EINVAL;",
"\tinsn_get_modrm(insn);",
"\tif (!insn->modrm.nbytes)\n\t\treturn -EINVAL;",
"\tif (X86_MODRM_MOD(insn->modrm.value) > 2)\n\t\treturn -EINVAL;",
"\tinsn_get_sib(insn);",
"\tif (!insn->sib.nbytes)\n\t\treturn -EINVAL;",
"\t*base_offset = get_reg_offset(insn, regs, REG_TYPE_BASE);\n\tindx_offset = get_reg_offset(insn, regs, REG_TYPE_INDEX);",
"\t/*\n\t * Negative values in the base and index offset means an error when\n\t * decoding the SIB byte. Except -EDOM, which means that the registers\n\t * should not be used in the address computation.\n\t */\n\tif (*base_offset == -EDOM)\n\t\tbase = 0;\n\telse if (*base_offset < 0)\n\t\treturn -EINVAL;\n\telse\n\t\tbase = regs_get_register(regs, *base_offset);",
"\tif (indx_offset == -EDOM)\n\t\tindx = 0;\n\telse if (indx_offset < 0)\n\t\treturn -EINVAL;\n\telse\n\t\tindx = regs_get_register(regs, indx_offset);",
"\tif (insn->addr_bytes == 4) {\n\t\tint addr32, base32, idx32;",
"\t\tbase32 = base & 0xffffffff;\n\t\tidx32 = indx & 0xffffffff;",
"\t\taddr32 = base32 + idx32 * (1 << X86_SIB_SCALE(insn->sib.value));\n\t\taddr32 += insn->displacement.value;",
"\t\t*eff_addr = addr32 & 0xffffffff;\n\t} else {\n\t\t*eff_addr = base + indx * (1 << X86_SIB_SCALE(insn->sib.value));\n\t\t*eff_addr += insn->displacement.value;\n\t}",
"\treturn 0;\n}",
"/**\n * get_addr_ref_16() - Obtain the 16-bit address referred by instruction\n * @insn:\tInstruction containing ModRM byte and displacement\n * @regs:\tRegister values as seen when entering kernel mode\n *\n * This function is to be used with 16-bit address encodings. Obtain the memory\n * address referred by the instruction's ModRM and displacement bytes. Also, the\n * segment used as base is determined by either any segment override prefixes in\n * @insn or the default segment of the registers involved in the address\n * computation. In protected mode, segment limits are enforced.\n *\n * Returns:\n *\n * Linear address referenced by the instruction operands on success.\n *\n * -1L on error.\n */\nstatic void __user *get_addr_ref_16(struct insn *insn, struct pt_regs *regs)\n{\n\tunsigned long linear_addr = -1L, seg_base, seg_limit;\n\tint ret, regoff;\n\tshort eff_addr;\n\tlong tmp;",
"\tinsn_get_modrm(insn);\n\tinsn_get_displacement(insn);",
"\tif (insn->addr_bytes != 2)\n\t\tgoto out;",
"\tif (X86_MODRM_MOD(insn->modrm.value) == 3) {\n\t\tret = get_eff_addr_reg(insn, regs, ®off, &tmp);\n\t\tif (ret)\n\t\t\tgoto out;",
"\t\teff_addr = tmp;\n\t} else {\n\t\tret = get_eff_addr_modrm_16(insn, regs, ®off, &eff_addr);\n\t\tif (ret)\n\t\t\tgoto out;\n\t}",
"\tret = get_seg_base_limit(insn, regs, regoff, &seg_base, &seg_limit);\n\tif (ret)\n\t\tgoto out;",
"\t/*\n\t * Before computing the linear address, make sure the effective address\n\t * is within the limits of the segment. In virtual-8086 mode, segment\n\t * limits are not enforced. In such a case, the segment limit is -1L to\n\t * reflect this fact.\n\t */\n\tif ((unsigned long)(eff_addr & 0xffff) > seg_limit)\n\t\tgoto out;",
"\tlinear_addr = (unsigned long)(eff_addr & 0xffff) + seg_base;",
"\t/* Limit linear address to 20 bits */\n\tif (v8086_mode(regs))\n\t\tlinear_addr &= 0xfffff;",
"out:\n\treturn (void __user *)linear_addr;\n}",
"/**\n * get_addr_ref_32() - Obtain a 32-bit linear address\n * @insn:\tInstruction with ModRM, SIB bytes and displacement\n * @regs:\tRegister values as seen when entering kernel mode\n *\n * This function is to be used with 32-bit address encodings to obtain the\n * linear memory address referred by the instruction's ModRM, SIB,\n * displacement bytes and segment base address, as applicable. If in protected\n * mode, segment limits are enforced.\n *\n * Returns:\n *\n * Linear address referenced by instruction and registers on success.\n *\n * -1L on error.\n */\nstatic void __user *get_addr_ref_32(struct insn *insn, struct pt_regs *regs)\n{\n\tunsigned long linear_addr = -1L, seg_base, seg_limit;\n\tint eff_addr, regoff;\n\tlong tmp;\n\tint ret;",
"\tif (insn->addr_bytes != 4)\n\t\tgoto out;",
"\tif (X86_MODRM_MOD(insn->modrm.value) == 3) {\n\t\tret = get_eff_addr_reg(insn, regs, ®off, &tmp);\n\t\tif (ret)\n\t\t\tgoto out;",
"\t\teff_addr = tmp;",
"\t} else {\n\t\tif (insn->sib.nbytes) {\n\t\t\tret = get_eff_addr_sib(insn, regs, ®off, &tmp);\n\t\t\tif (ret)\n\t\t\t\tgoto out;",
"\t\t\teff_addr = tmp;\n\t\t} else {\n\t\t\tret = get_eff_addr_modrm(insn, regs, ®off, &tmp);\n\t\t\tif (ret)\n\t\t\t\tgoto out;",
"\t\t\teff_addr = tmp;\n\t\t}\n\t}",
"\tret = get_seg_base_limit(insn, regs, regoff, &seg_base, &seg_limit);\n\tif (ret)\n\t\tgoto out;",
"\t/*\n\t * In protected mode, before computing the linear address, make sure\n\t * the effective address is within the limits of the segment.\n\t * 32-bit addresses can be used in long and virtual-8086 modes if an\n\t * address override prefix is used. In such cases, segment limits are\n\t * not enforced. When in virtual-8086 mode, the segment limit is -1L\n\t * to reflect this situation.\n\t *\n\t * After computed, the effective address is treated as an unsigned\n\t * quantity.\n\t */\n\tif (!user_64bit_mode(regs) && ((unsigned int)eff_addr > seg_limit))\n\t\tgoto out;",
"\t/*\n\t * Even though 32-bit address encodings are allowed in virtual-8086\n\t * mode, the address range is still limited to [0x-0xffff].\n\t */\n\tif (v8086_mode(regs) && (eff_addr & ~0xffff))\n\t\tgoto out;",
"\t/*\n\t * Data type long could be 64 bits in size. Ensure that our 32-bit\n\t * effective address is not sign-extended when computing the linear\n\t * address.\n\t */\n\tlinear_addr = (unsigned long)(eff_addr & 0xffffffff) + seg_base;",
"\t/* Limit linear address to 20 bits */\n\tif (v8086_mode(regs))\n\t\tlinear_addr &= 0xfffff;",
"out:\n\treturn (void __user *)linear_addr;\n}",
"/**\n * get_addr_ref_64() - Obtain a 64-bit linear address\n * @insn:\tInstruction struct with ModRM and SIB bytes and displacement\n * @regs:\tStructure with register values as seen when entering kernel mode\n *\n * This function is to be used with 64-bit address encodings to obtain the\n * linear memory address referred by the instruction's ModRM, SIB,\n * displacement bytes and segment base address, as applicable.\n *\n * Returns:\n *\n * Linear address referenced by instruction and registers on success.\n *\n * -1L on error.\n */\n#ifndef CONFIG_X86_64\nstatic void __user *get_addr_ref_64(struct insn *insn, struct pt_regs *regs)\n{\n\treturn (void __user *)-1L;\n}\n#else\nstatic void __user *get_addr_ref_64(struct insn *insn, struct pt_regs *regs)\n{\n\tunsigned long linear_addr = -1L, seg_base;\n\tint regoff, ret;\n\tlong eff_addr;",
"\tif (insn->addr_bytes != 8)\n\t\tgoto out;",
"\tif (X86_MODRM_MOD(insn->modrm.value) == 3) {\n\t\tret = get_eff_addr_reg(insn, regs, ®off, &eff_addr);\n\t\tif (ret)\n\t\t\tgoto out;",
"\t} else {\n\t\tif (insn->sib.nbytes) {\n\t\t\tret = get_eff_addr_sib(insn, regs, ®off, &eff_addr);\n\t\t\tif (ret)\n\t\t\t\tgoto out;\n\t\t} else {\n\t\t\tret = get_eff_addr_modrm(insn, regs, ®off, &eff_addr);\n\t\t\tif (ret)\n\t\t\t\tgoto out;\n\t\t}",
"\t}",
"\tret = get_seg_base_limit(insn, regs, regoff, &seg_base, NULL);\n\tif (ret)\n\t\tgoto out;",
"\tlinear_addr = (unsigned long)eff_addr + seg_base;",
"out:\n\treturn (void __user *)linear_addr;\n}\n#endif /* CONFIG_X86_64 */",
"/**\n * insn_get_addr_ref() - Obtain the linear address referred by instruction\n * @insn:\tInstruction structure containing ModRM byte and displacement\n * @regs:\tStructure with register values as seen when entering kernel mode\n *\n * Obtain the linear address referred by the instruction's ModRM, SIB and\n * displacement bytes, and segment base, as applicable. In protected mode,\n * segment limits are enforced.\n *\n * Returns:\n *\n * Linear address referenced by instruction and registers on success.\n *\n * -1L on error.\n */\nvoid __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs)\n{\n\tif (!insn || !regs)\n\t\treturn (void __user *)-1L;",
"\tswitch (insn->addr_bytes) {\n\tcase 2:\n\t\treturn get_addr_ref_16(insn, regs);\n\tcase 4:\n\t\treturn get_addr_ref_32(insn, regs);\n\tcase 8:\n\t\treturn get_addr_ref_64(insn, regs);\n\tdefault:\n\t\treturn (void __user *)-1L;\n\t}\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
0,
1,
0,
1,
1,
1,
0,
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [768], "buggy_code_start_loc": [560], "filenames": ["arch/x86/lib/insn-eval.c"], "fixing_code_end_loc": [769], "fixing_code_start_loc": [560], "message": "In arch/x86/lib/insn-eval.c in the Linux kernel before 5.1.9, there is a use-after-free for access to an LDT entry because of a race condition between modify_ldt() and a #BR exception for an MPX bounds violation.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "E567EFE6-8F22-4645-838E-9B381F951463", "versionEndExcluding": "5.1.9", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "In arch/x86/lib/insn-eval.c in the Linux kernel before 5.1.9, there is a use-after-free for access to an LDT entry because of a race condition between modify_ldt() and a #BR exception for an MPX bounds violation."}, {"lang": "es", "value": "En arch/x86/lib/insn-eval.c en el kernel de Linux en versiones anteriores a la 5.1.9, hay un uso de memoria previamente liberada para acceder a una entrada LDT debido a una condici\u00f3n de carrera entre modify_ldt () y una excepci\u00f3n #BR para una violaci\u00f3n de los l\u00edmites de MPX."}], "evaluatorComment": null, "id": "CVE-2019-13233", "lastModified": "2019-07-20T12:15:13.477", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 4.4, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:L/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 3.4, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 7.0, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 1.0, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2019-07-04T13:15:11.000", "references": [{"source": "cve@mitre.org", "tags": null, "url": "http://lists.opensuse.org/opensuse-security-announce/2019-07/msg00025.html"}, {"source": "cve@mitre.org", "tags": null, "url": "http://packetstormsecurity.com/files/154408/Kernel-Live-Patch-Security-Notice-LSN-0055-1.html"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2019:3309"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2019:3517"}, {"source": "cve@mitre.org", "tags": ["Exploit", "Mailing List", "Patch", "Third Party Advisory"], "url": "https://bugs.chromium.org/p/project-zero/issues/detail?id=1879"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Release Notes", "Vendor Advisory"], "url": "https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.1.9"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Vendor Advisory"], "url": "https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=de9f869616dd95e95c00bdd6b0fcd3421e8a4323"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/de9f869616dd95e95c00bdd6b0fcd3421e8a4323"}, {"source": "cve@mitre.org", "tags": null, "url": "https://seclists.org/bugtraq/2019/Aug/13"}, {"source": "cve@mitre.org", "tags": null, "url": "https://security.netapp.com/advisory/ntap-20190806-0001/"}, {"source": "cve@mitre.org", "tags": null, "url": "https://support.f5.com/csp/article/K13331647?utm_source=f5support&utm_medium=RSS"}, {"source": "cve@mitre.org", "tags": null, "url": "https://usn.ubuntu.com/4093-1/"}, {"source": "cve@mitre.org", "tags": null, "url": "https://usn.ubuntu.com/4094-1/"}, {"source": "cve@mitre.org", "tags": null, "url": "https://usn.ubuntu.com/4117-1/"}, {"source": "cve@mitre.org", "tags": null, "url": "https://usn.ubuntu.com/4118-1/"}, {"source": "cve@mitre.org", "tags": null, "url": "https://www.debian.org/security/2019/dsa-4495"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-362"}, {"lang": "en", "value": "CWE-416"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/de9f869616dd95e95c00bdd6b0fcd3421e8a4323"}, "type": "CWE-362"}
| 364
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Utility functions for x86 operand and address decoding\n *\n * Copyright (C) Intel Corporation 2017\n */\n#include <linux/kernel.h>\n#include <linux/string.h>\n#include <linux/ratelimit.h>\n#include <linux/mmu_context.h>\n#include <asm/desc_defs.h>\n#include <asm/desc.h>\n#include <asm/inat.h>\n#include <asm/insn.h>\n#include <asm/insn-eval.h>\n#include <asm/ldt.h>\n#include <asm/vm86.h>",
"#undef pr_fmt\n#define pr_fmt(fmt) \"insn: \" fmt",
"enum reg_type {\n\tREG_TYPE_RM = 0,\n\tREG_TYPE_INDEX,\n\tREG_TYPE_BASE,\n};",
"/**\n * is_string_insn() - Determine if instruction is a string instruction\n * @insn:\tInstruction containing the opcode to inspect\n *\n * Returns:\n *\n * true if the instruction, determined by the opcode, is any of the\n * string instructions as defined in the Intel Software Development manual.\n * False otherwise.\n */\nstatic bool is_string_insn(struct insn *insn)\n{\n\tinsn_get_opcode(insn);",
"\t/* All string instructions have a 1-byte opcode. */\n\tif (insn->opcode.nbytes != 1)\n\t\treturn false;",
"\tswitch (insn->opcode.bytes[0]) {\n\tcase 0x6c ... 0x6f:\t/* INS, OUTS */\n\tcase 0xa4 ... 0xa7:\t/* MOVS, CMPS */\n\tcase 0xaa ... 0xaf:\t/* STOS, LODS, SCAS */\n\t\treturn true;\n\tdefault:\n\t\treturn false;\n\t}\n}",
"/**\n * get_seg_reg_override_idx() - obtain segment register override index\n * @insn:\tValid instruction with segment override prefixes\n *\n * Inspect the instruction prefixes in @insn and find segment overrides, if any.\n *\n * Returns:\n *\n * A constant identifying the segment register to use, among CS, SS, DS,\n * ES, FS, or GS. INAT_SEG_REG_DEFAULT is returned if no segment override\n * prefixes were found.\n *\n * -EINVAL in case of error.\n */\nstatic int get_seg_reg_override_idx(struct insn *insn)\n{\n\tint idx = INAT_SEG_REG_DEFAULT;\n\tint num_overrides = 0, i;",
"\tinsn_get_prefixes(insn);",
"\t/* Look for any segment override prefixes. */\n\tfor (i = 0; i < insn->prefixes.nbytes; i++) {\n\t\tinsn_attr_t attr;",
"\t\tattr = inat_get_opcode_attribute(insn->prefixes.bytes[i]);\n\t\tswitch (attr) {\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_CS):\n\t\t\tidx = INAT_SEG_REG_CS;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_SS):\n\t\t\tidx = INAT_SEG_REG_SS;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_DS):\n\t\t\tidx = INAT_SEG_REG_DS;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_ES):\n\t\t\tidx = INAT_SEG_REG_ES;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_FS):\n\t\t\tidx = INAT_SEG_REG_FS;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\tcase INAT_MAKE_PREFIX(INAT_PFX_GS):\n\t\t\tidx = INAT_SEG_REG_GS;\n\t\t\tnum_overrides++;\n\t\t\tbreak;\n\t\t/* No default action needed. */\n\t\t}\n\t}",
"\t/* More than one segment override prefix leads to undefined behavior. */\n\tif (num_overrides > 1)\n\t\treturn -EINVAL;",
"\treturn idx;\n}",
"/**\n * check_seg_overrides() - check if segment override prefixes are allowed\n * @insn:\tValid instruction with segment override prefixes\n * @regoff:\tOperand offset, in pt_regs, for which the check is performed\n *\n * For a particular register used in register-indirect addressing, determine if\n * segment override prefixes can be used. Specifically, no overrides are allowed\n * for rDI if used with a string instruction.\n *\n * Returns:\n *\n * True if segment override prefixes can be used with the register indicated\n * in @regoff. False if otherwise.\n */\nstatic bool check_seg_overrides(struct insn *insn, int regoff)\n{\n\tif (regoff == offsetof(struct pt_regs, di) && is_string_insn(insn))\n\t\treturn false;",
"\treturn true;\n}",
"/**\n * resolve_default_seg() - resolve default segment register index for an operand\n * @insn:\tInstruction with opcode and address size. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @off:\tOperand offset, in pt_regs, for which resolution is needed\n *\n * Resolve the default segment register index associated with the instruction\n * operand register indicated by @off. Such index is resolved based on defaults\n * described in the Intel Software Development Manual.\n *\n * Returns:\n *\n * If in protected mode, a constant identifying the segment register to use,\n * among CS, SS, ES or DS. If in long mode, INAT_SEG_REG_IGNORE.\n *\n * -EINVAL in case of error.\n */\nstatic int resolve_default_seg(struct insn *insn, struct pt_regs *regs, int off)\n{\n\tif (user_64bit_mode(regs))\n\t\treturn INAT_SEG_REG_IGNORE;\n\t/*\n\t * Resolve the default segment register as described in Section 3.7.4\n\t * of the Intel Software Development Manual Vol. 1:\n\t *\n\t * + DS for all references involving r[ABCD]X, and rSI.\n\t * + If used in a string instruction, ES for rDI. Otherwise, DS.\n\t * + AX, CX and DX are not valid register operands in 16-bit address\n\t * encodings but are valid for 32-bit and 64-bit encodings.\n\t * + -EDOM is reserved to identify for cases in which no register\n\t * is used (i.e., displacement-only addressing). Use DS.\n\t * + SS for rSP or rBP.\n\t * + CS for rIP.\n\t */",
"\tswitch (off) {\n\tcase offsetof(struct pt_regs, ax):\n\tcase offsetof(struct pt_regs, cx):\n\tcase offsetof(struct pt_regs, dx):\n\t\t/* Need insn to verify address size. */\n\t\tif (insn->addr_bytes == 2)\n\t\t\treturn -EINVAL;",
"\t\t/* fall through */",
"\tcase -EDOM:\n\tcase offsetof(struct pt_regs, bx):\n\tcase offsetof(struct pt_regs, si):\n\t\treturn INAT_SEG_REG_DS;",
"\tcase offsetof(struct pt_regs, di):\n\t\tif (is_string_insn(insn))\n\t\t\treturn INAT_SEG_REG_ES;\n\t\treturn INAT_SEG_REG_DS;",
"\tcase offsetof(struct pt_regs, bp):\n\tcase offsetof(struct pt_regs, sp):\n\t\treturn INAT_SEG_REG_SS;",
"\tcase offsetof(struct pt_regs, ip):\n\t\treturn INAT_SEG_REG_CS;",
"\tdefault:\n\t\treturn -EINVAL;\n\t}\n}",
"/**\n * resolve_seg_reg() - obtain segment register index\n * @insn:\tInstruction with operands\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tOperand offset, in pt_regs, used to deterimine segment register\n *\n * Determine the segment register associated with the operands and, if\n * applicable, prefixes and the instruction pointed by @insn.\n *\n * The segment register associated to an operand used in register-indirect\n * addressing depends on:\n *\n * a) Whether running in long mode (in such a case segments are ignored, except\n * if FS or GS are used).\n *\n * b) Whether segment override prefixes can be used. Certain instructions and\n * registers do not allow override prefixes.\n *\n * c) Whether segment overrides prefixes are found in the instruction prefixes.\n *\n * d) If there are not segment override prefixes or they cannot be used, the\n * default segment register associated with the operand register is used.\n *\n * The function checks first if segment override prefixes can be used with the\n * operand indicated by @regoff. If allowed, obtain such overridden segment\n * register index. Lastly, if not prefixes were found or cannot be used, resolve\n * the segment register index to use based on the defaults described in the\n * Intel documentation. In long mode, all segment register indexes will be\n * ignored, except if overrides were found for FS or GS. All these operations\n * are done using helper functions.\n *\n * The operand register, @regoff, is represented as the offset from the base of\n * pt_regs.\n *\n * As stated, the main use of this function is to determine the segment register\n * index based on the instruction, its operands and prefixes. Hence, @insn\n * must be valid. However, if @regoff indicates rIP, we don't need to inspect\n * @insn at all as in this case CS is used in all cases. This case is checked\n * before proceeding further.\n *\n * Please note that this function does not return the value in the segment\n * register (i.e., the segment selector) but our defined index. The segment\n * selector needs to be obtained using get_segment_selector() and passing the\n * segment register index resolved by this function.\n *\n * Returns:\n *\n * An index identifying the segment register to use, among CS, SS, DS,\n * ES, FS, or GS. INAT_SEG_REG_IGNORE is returned if running in long mode.\n *\n * -EINVAL in case of error.\n */\nstatic int resolve_seg_reg(struct insn *insn, struct pt_regs *regs, int regoff)\n{\n\tint idx;",
"\t/*\n\t * In the unlikely event of having to resolve the segment register\n\t * index for rIP, do it first. Segment override prefixes should not\n\t * be used. Hence, it is not necessary to inspect the instruction,\n\t * which may be invalid at this point.\n\t */\n\tif (regoff == offsetof(struct pt_regs, ip)) {\n\t\tif (user_64bit_mode(regs))\n\t\t\treturn INAT_SEG_REG_IGNORE;\n\t\telse\n\t\t\treturn INAT_SEG_REG_CS;\n\t}",
"\tif (!insn)\n\t\treturn -EINVAL;",
"\tif (!check_seg_overrides(insn, regoff))\n\t\treturn resolve_default_seg(insn, regs, regoff);",
"\tidx = get_seg_reg_override_idx(insn);\n\tif (idx < 0)\n\t\treturn idx;",
"\tif (idx == INAT_SEG_REG_DEFAULT)\n\t\treturn resolve_default_seg(insn, regs, regoff);",
"\t/*\n\t * In long mode, segment override prefixes are ignored, except for\n\t * overrides for FS and GS.\n\t */\n\tif (user_64bit_mode(regs)) {\n\t\tif (idx != INAT_SEG_REG_FS &&\n\t\t idx != INAT_SEG_REG_GS)\n\t\t\tidx = INAT_SEG_REG_IGNORE;\n\t}",
"\treturn idx;\n}",
"/**\n * get_segment_selector() - obtain segment selector\n * @regs:\t\tRegister values as seen when entering kernel mode\n * @seg_reg_idx:\tSegment register index to use\n *\n * Obtain the segment selector from any of the CS, SS, DS, ES, FS, GS segment\n * registers. In CONFIG_X86_32, the segment is obtained from either pt_regs or\n * kernel_vm86_regs as applicable. In CONFIG_X86_64, CS and SS are obtained\n * from pt_regs. DS, ES, FS and GS are obtained by reading the actual CPU\n * registers. This done for only for completeness as in CONFIG_X86_64 segment\n * registers are ignored.\n *\n * Returns:\n *\n * Value of the segment selector, including null when running in\n * long mode.\n *\n * -EINVAL on error.\n */\nstatic short get_segment_selector(struct pt_regs *regs, int seg_reg_idx)\n{\n#ifdef CONFIG_X86_64\n\tunsigned short sel;",
"\tswitch (seg_reg_idx) {\n\tcase INAT_SEG_REG_IGNORE:\n\t\treturn 0;\n\tcase INAT_SEG_REG_CS:\n\t\treturn (unsigned short)(regs->cs & 0xffff);\n\tcase INAT_SEG_REG_SS:\n\t\treturn (unsigned short)(regs->ss & 0xffff);\n\tcase INAT_SEG_REG_DS:\n\t\tsavesegment(ds, sel);\n\t\treturn sel;\n\tcase INAT_SEG_REG_ES:\n\t\tsavesegment(es, sel);\n\t\treturn sel;\n\tcase INAT_SEG_REG_FS:\n\t\tsavesegment(fs, sel);\n\t\treturn sel;\n\tcase INAT_SEG_REG_GS:\n\t\tsavesegment(gs, sel);\n\t\treturn sel;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n#else /* CONFIG_X86_32 */\n\tstruct kernel_vm86_regs *vm86regs = (struct kernel_vm86_regs *)regs;",
"\tif (v8086_mode(regs)) {\n\t\tswitch (seg_reg_idx) {\n\t\tcase INAT_SEG_REG_CS:\n\t\t\treturn (unsigned short)(regs->cs & 0xffff);\n\t\tcase INAT_SEG_REG_SS:\n\t\t\treturn (unsigned short)(regs->ss & 0xffff);\n\t\tcase INAT_SEG_REG_DS:\n\t\t\treturn vm86regs->ds;\n\t\tcase INAT_SEG_REG_ES:\n\t\t\treturn vm86regs->es;\n\t\tcase INAT_SEG_REG_FS:\n\t\t\treturn vm86regs->fs;\n\t\tcase INAT_SEG_REG_GS:\n\t\t\treturn vm86regs->gs;\n\t\tcase INAT_SEG_REG_IGNORE:\n\t\t\t/* fall through */\n\t\tdefault:\n\t\t\treturn -EINVAL;\n\t\t}\n\t}",
"\tswitch (seg_reg_idx) {\n\tcase INAT_SEG_REG_CS:\n\t\treturn (unsigned short)(regs->cs & 0xffff);\n\tcase INAT_SEG_REG_SS:\n\t\treturn (unsigned short)(regs->ss & 0xffff);\n\tcase INAT_SEG_REG_DS:\n\t\treturn (unsigned short)(regs->ds & 0xffff);\n\tcase INAT_SEG_REG_ES:\n\t\treturn (unsigned short)(regs->es & 0xffff);\n\tcase INAT_SEG_REG_FS:\n\t\treturn (unsigned short)(regs->fs & 0xffff);\n\tcase INAT_SEG_REG_GS:\n\t\t/*\n\t\t * GS may or may not be in regs as per CONFIG_X86_32_LAZY_GS.\n\t\t * The macro below takes care of both cases.\n\t\t */\n\t\treturn get_user_gs(regs);\n\tcase INAT_SEG_REG_IGNORE:\n\t\t/* fall through */\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n#endif /* CONFIG_X86_64 */\n}",
"static int get_reg_offset(struct insn *insn, struct pt_regs *regs,\n\t\t\t enum reg_type type)\n{\n\tint regno = 0;",
"\tstatic const int regoff[] = {\n\t\toffsetof(struct pt_regs, ax),\n\t\toffsetof(struct pt_regs, cx),\n\t\toffsetof(struct pt_regs, dx),\n\t\toffsetof(struct pt_regs, bx),\n\t\toffsetof(struct pt_regs, sp),\n\t\toffsetof(struct pt_regs, bp),\n\t\toffsetof(struct pt_regs, si),\n\t\toffsetof(struct pt_regs, di),\n#ifdef CONFIG_X86_64\n\t\toffsetof(struct pt_regs, r8),\n\t\toffsetof(struct pt_regs, r9),\n\t\toffsetof(struct pt_regs, r10),\n\t\toffsetof(struct pt_regs, r11),\n\t\toffsetof(struct pt_regs, r12),\n\t\toffsetof(struct pt_regs, r13),\n\t\toffsetof(struct pt_regs, r14),\n\t\toffsetof(struct pt_regs, r15),\n#endif\n\t};\n\tint nr_registers = ARRAY_SIZE(regoff);\n\t/*\n\t * Don't possibly decode a 32-bit instructions as\n\t * reading a 64-bit-only register.\n\t */\n\tif (IS_ENABLED(CONFIG_X86_64) && !insn->x86_64)\n\t\tnr_registers -= 8;",
"\tswitch (type) {\n\tcase REG_TYPE_RM:\n\t\tregno = X86_MODRM_RM(insn->modrm.value);",
"\t\t/*\n\t\t * ModRM.mod == 0 and ModRM.rm == 5 means a 32-bit displacement\n\t\t * follows the ModRM byte.\n\t\t */\n\t\tif (!X86_MODRM_MOD(insn->modrm.value) && regno == 5)\n\t\t\treturn -EDOM;",
"\t\tif (X86_REX_B(insn->rex_prefix.value))\n\t\t\tregno += 8;\n\t\tbreak;",
"\tcase REG_TYPE_INDEX:\n\t\tregno = X86_SIB_INDEX(insn->sib.value);\n\t\tif (X86_REX_X(insn->rex_prefix.value))\n\t\t\tregno += 8;",
"\t\t/*\n\t\t * If ModRM.mod != 3 and SIB.index = 4 the scale*index\n\t\t * portion of the address computation is null. This is\n\t\t * true only if REX.X is 0. In such a case, the SIB index\n\t\t * is used in the address computation.\n\t\t */\n\t\tif (X86_MODRM_MOD(insn->modrm.value) != 3 && regno == 4)\n\t\t\treturn -EDOM;\n\t\tbreak;",
"\tcase REG_TYPE_BASE:\n\t\tregno = X86_SIB_BASE(insn->sib.value);\n\t\t/*\n\t\t * If ModRM.mod is 0 and SIB.base == 5, the base of the\n\t\t * register-indirect addressing is 0. In this case, a\n\t\t * 32-bit displacement follows the SIB byte.\n\t\t */\n\t\tif (!X86_MODRM_MOD(insn->modrm.value) && regno == 5)\n\t\t\treturn -EDOM;",
"\t\tif (X86_REX_B(insn->rex_prefix.value))\n\t\t\tregno += 8;\n\t\tbreak;",
"\tdefault:\n\t\tpr_err_ratelimited(\"invalid register type: %d\\n\", type);\n\t\treturn -EINVAL;\n\t}",
"\tif (regno >= nr_registers) {\n\t\tWARN_ONCE(1, \"decoded an instruction with an invalid register\");\n\t\treturn -EINVAL;\n\t}\n\treturn regoff[regno];\n}",
"/**\n * get_reg_offset_16() - Obtain offset of register indicated by instruction\n * @insn:\tInstruction containing ModRM byte\n * @regs:\tRegister values as seen when entering kernel mode\n * @offs1:\tOffset of the first operand register\n * @offs2:\tOffset of the second opeand register, if applicable\n *\n * Obtain the offset, in pt_regs, of the registers indicated by the ModRM byte\n * in @insn. This function is to be used with 16-bit address encodings. The\n * @offs1 and @offs2 will be written with the offset of the two registers\n * indicated by the instruction. In cases where any of the registers is not\n * referenced by the instruction, the value will be set to -EDOM.\n *\n * Returns:\n *\n * 0 on success, -EINVAL on error.\n */\nstatic int get_reg_offset_16(struct insn *insn, struct pt_regs *regs,\n\t\t\t int *offs1, int *offs2)\n{\n\t/*\n\t * 16-bit addressing can use one or two registers. Specifics of\n\t * encodings are given in Table 2-1. \"16-Bit Addressing Forms with the\n\t * ModR/M Byte\" of the Intel Software Development Manual.\n\t */\n\tstatic const int regoff1[] = {\n\t\toffsetof(struct pt_regs, bx),\n\t\toffsetof(struct pt_regs, bx),\n\t\toffsetof(struct pt_regs, bp),\n\t\toffsetof(struct pt_regs, bp),\n\t\toffsetof(struct pt_regs, si),\n\t\toffsetof(struct pt_regs, di),\n\t\toffsetof(struct pt_regs, bp),\n\t\toffsetof(struct pt_regs, bx),\n\t};",
"\tstatic const int regoff2[] = {\n\t\toffsetof(struct pt_regs, si),\n\t\toffsetof(struct pt_regs, di),\n\t\toffsetof(struct pt_regs, si),\n\t\toffsetof(struct pt_regs, di),\n\t\t-EDOM,\n\t\t-EDOM,\n\t\t-EDOM,\n\t\t-EDOM,\n\t};",
"\tif (!offs1 || !offs2)\n\t\treturn -EINVAL;",
"\t/* Operand is a register, use the generic function. */\n\tif (X86_MODRM_MOD(insn->modrm.value) == 3) {\n\t\t*offs1 = insn_get_modrm_rm_off(insn, regs);\n\t\t*offs2 = -EDOM;\n\t\treturn 0;\n\t}",
"\t*offs1 = regoff1[X86_MODRM_RM(insn->modrm.value)];\n\t*offs2 = regoff2[X86_MODRM_RM(insn->modrm.value)];",
"\t/*\n\t * If ModRM.mod is 0 and ModRM.rm is 110b, then we use displacement-\n\t * only addressing. This means that no registers are involved in\n\t * computing the effective address. Thus, ensure that the first\n\t * register offset is invalild. The second register offset is already\n\t * invalid under the aforementioned conditions.\n\t */\n\tif ((X86_MODRM_MOD(insn->modrm.value) == 0) &&\n\t (X86_MODRM_RM(insn->modrm.value) == 6))\n\t\t*offs1 = -EDOM;",
"\treturn 0;\n}",
"/**",
" * get_desc() - Obtain contents of a segment descriptor\n * @out:\tSegment descriptor contents on success",
" * @sel:\tSegment selector\n *\n * Given a segment selector, obtain a pointer to the segment descriptor.\n * Both global and local descriptor tables are supported.\n *\n * Returns:\n *",
" * True on success, false on failure.",
" *\n * NULL on error.\n */",
"static bool get_desc(struct desc_struct *out, unsigned short sel)",
"{\n\tstruct desc_ptr gdt_desc = {0, 0};\n\tunsigned long desc_base;",
"#ifdef CONFIG_MODIFY_LDT_SYSCALL\n\tif ((sel & SEGMENT_TI_MASK) == SEGMENT_LDT) {",
"\t\tbool success = false;",
"\t\tstruct ldt_struct *ldt;",
"\t\t/* Bits [15:3] contain the index of the desired entry. */\n\t\tsel >>= 3;",
"\t\tmutex_lock(¤t->active_mm->context.lock);\n\t\tldt = current->active_mm->context.ldt;",
"\t\tif (ldt && sel < ldt->nr_entries) {\n\t\t\t*out = ldt->entries[sel];\n\t\t\tsuccess = true;\n\t\t}",
"\n\t\tmutex_unlock(¤t->active_mm->context.lock);\n",
"\t\treturn success;",
"\t}\n#endif\n\tnative_store_gdt(&gdt_desc);",
"\t/*\n\t * Segment descriptors have a size of 8 bytes. Thus, the index is\n\t * multiplied by 8 to obtain the memory offset of the desired descriptor\n\t * from the base of the GDT. As bits [15:3] of the segment selector\n\t * contain the index, it can be regarded as multiplied by 8 already.\n\t * All that remains is to clear bits [2:0].\n\t */\n\tdesc_base = sel & ~(SEGMENT_RPL_MASK | SEGMENT_TI_MASK);",
"\tif (desc_base > gdt_desc.size)",
"\t\treturn false;",
"\t*out = *(struct desc_struct *)(gdt_desc.address + desc_base);\n\treturn true;",
"}",
"/**\n * insn_get_seg_base() - Obtain base address of segment descriptor.\n * @regs:\t\tRegister values as seen when entering kernel mode\n * @seg_reg_idx:\tIndex of the segment register pointing to seg descriptor\n *\n * Obtain the base address of the segment as indicated by the segment descriptor\n * pointed by the segment selector. The segment selector is obtained from the\n * input segment register index @seg_reg_idx.\n *\n * Returns:\n *\n * In protected mode, base address of the segment. Zero in long mode,\n * except when FS or GS are used. In virtual-8086 mode, the segment\n * selector shifted 4 bits to the right.\n *\n * -1L in case of error.\n */\nunsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx)\n{",
"\tstruct desc_struct desc;",
"\tshort sel;",
"\tsel = get_segment_selector(regs, seg_reg_idx);\n\tif (sel < 0)\n\t\treturn -1L;",
"\tif (v8086_mode(regs))\n\t\t/*\n\t\t * Base is simply the segment selector shifted 4\n\t\t * bits to the right.\n\t\t */\n\t\treturn (unsigned long)(sel << 4);",
"\tif (user_64bit_mode(regs)) {\n\t\t/*\n\t\t * Only FS or GS will have a base address, the rest of\n\t\t * the segments' bases are forced to 0.\n\t\t */\n\t\tunsigned long base;",
"\t\tif (seg_reg_idx == INAT_SEG_REG_FS)\n\t\t\trdmsrl(MSR_FS_BASE, base);\n\t\telse if (seg_reg_idx == INAT_SEG_REG_GS)\n\t\t\t/*\n\t\t\t * swapgs was called at the kernel entry point. Thus,\n\t\t\t * MSR_KERNEL_GS_BASE will have the user-space GS base.\n\t\t\t */\n\t\t\trdmsrl(MSR_KERNEL_GS_BASE, base);\n\t\telse\n\t\t\tbase = 0;\n\t\treturn base;\n\t}",
"\t/* In protected mode the segment selector cannot be null. */\n\tif (!sel)\n\t\treturn -1L;\n",
"\tif (!get_desc(&desc, sel))",
"\t\treturn -1L;\n",
"\treturn get_desc_base(&desc);",
"}",
"/**\n * get_seg_limit() - Obtain the limit of a segment descriptor\n * @regs:\t\tRegister values as seen when entering kernel mode\n * @seg_reg_idx:\tIndex of the segment register pointing to seg descriptor\n *\n * Obtain the limit of the segment as indicated by the segment descriptor\n * pointed by the segment selector. The segment selector is obtained from the\n * input segment register index @seg_reg_idx.\n *\n * Returns:\n *\n * In protected mode, the limit of the segment descriptor in bytes.\n * In long mode and virtual-8086 mode, segment limits are not enforced. Thus,\n * limit is returned as -1L to imply a limit-less segment.\n *\n * Zero is returned on error.\n */\nstatic unsigned long get_seg_limit(struct pt_regs *regs, int seg_reg_idx)\n{",
"\tstruct desc_struct desc;",
"\tunsigned long limit;\n\tshort sel;",
"\tsel = get_segment_selector(regs, seg_reg_idx);\n\tif (sel < 0)\n\t\treturn 0;",
"\tif (user_64bit_mode(regs) || v8086_mode(regs))\n\t\treturn -1L;",
"\tif (!sel)\n\t\treturn 0;\n",
"\tif (!get_desc(&desc, sel))",
"\t\treturn 0;",
"\t/*\n\t * If the granularity bit is set, the limit is given in multiples\n\t * of 4096. This also means that the 12 least significant bits are\n\t * not tested when checking the segment limits. In practice,\n\t * this means that the segment ends in (limit << 12) + 0xfff.\n\t */",
"\tlimit = get_desc_limit(&desc);\n\tif (desc.g)",
"\t\tlimit = (limit << 12) + 0xfff;",
"\treturn limit;\n}",
"/**\n * insn_get_code_seg_params() - Obtain code segment parameters\n * @regs:\tStructure with register values as seen when entering kernel mode\n *\n * Obtain address and operand sizes of the code segment. It is obtained from the\n * selector contained in the CS register in regs. In protected mode, the default\n * address is determined by inspecting the L and D bits of the segment\n * descriptor. In virtual-8086 mode, the default is always two bytes for both\n * address and operand sizes.\n *\n * Returns:\n *\n * An int containing ORed-in default parameters on success.\n *\n * -EINVAL on error.\n */\nint insn_get_code_seg_params(struct pt_regs *regs)\n{",
"\tstruct desc_struct desc;",
"\tshort sel;",
"\tif (v8086_mode(regs))\n\t\t/* Address and operand size are both 16-bit. */\n\t\treturn INSN_CODE_SEG_PARAMS(2, 2);",
"\tsel = get_segment_selector(regs, INAT_SEG_REG_CS);\n\tif (sel < 0)\n\t\treturn sel;\n",
"\tif (!get_desc(&desc, sel))",
"\t\treturn -EINVAL;",
"\t/*\n\t * The most significant byte of the Type field of the segment descriptor\n\t * determines whether a segment contains data or code. If this is a data\n\t * segment, return error.\n\t */",
"\tif (!(desc.type & BIT(3)))\n\t\treturn -EINVAL;",
"\tswitch ((desc.l << 1) | desc.d) {",
"\tcase 0: /*\n\t\t * Legacy mode. CS.L=0, CS.D=0. Address and operand size are\n\t\t * both 16-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(2, 2);\n\tcase 1: /*\n\t\t * Legacy mode. CS.L=0, CS.D=1. Address and operand size are\n\t\t * both 32-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(4, 4);\n\tcase 2: /*\n\t\t * IA-32e 64-bit mode. CS.L=1, CS.D=0. Address size is 64-bit;\n\t\t * operand size is 32-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(4, 8);\n\tcase 3: /* Invalid setting. CS.L=1, CS.D=1 */\n\t\t/* fall through */\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n}",
"/**\n * insn_get_modrm_rm_off() - Obtain register in r/m part of the ModRM byte\n * @insn:\tInstruction containing the ModRM byte\n * @regs:\tRegister values as seen when entering kernel mode\n *\n * Returns:\n *\n * The register indicated by the r/m part of the ModRM byte. The\n * register is obtained as an offset from the base of pt_regs. In specific\n * cases, the returned value can be -EDOM to indicate that the particular value\n * of ModRM does not refer to a register and shall be ignored.\n */\nint insn_get_modrm_rm_off(struct insn *insn, struct pt_regs *regs)\n{\n\treturn get_reg_offset(insn, regs, REG_TYPE_RM);\n}",
"/**\n * get_seg_base_limit() - obtain base address and limit of a segment\n * @insn:\tInstruction. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tOperand offset, in pt_regs, used to resolve segment descriptor\n * @base:\tObtained segment base\n * @limit:\tObtained segment limit\n *\n * Obtain the base address and limit of the segment associated with the operand\n * @regoff and, if any or allowed, override prefixes in @insn. This function is\n * different from insn_get_seg_base() as the latter does not resolve the segment\n * associated with the instruction operand. If a limit is not needed (e.g.,\n * when running in long mode), @limit can be NULL.\n *\n * Returns:\n *\n * 0 on success. @base and @limit will contain the base address and of the\n * resolved segment, respectively.\n *\n * -EINVAL on error.\n */\nstatic int get_seg_base_limit(struct insn *insn, struct pt_regs *regs,\n\t\t\t int regoff, unsigned long *base,\n\t\t\t unsigned long *limit)\n{\n\tint seg_reg_idx;",
"\tif (!base)\n\t\treturn -EINVAL;",
"\tseg_reg_idx = resolve_seg_reg(insn, regs, regoff);\n\tif (seg_reg_idx < 0)\n\t\treturn seg_reg_idx;",
"\t*base = insn_get_seg_base(regs, seg_reg_idx);\n\tif (*base == -1L)\n\t\treturn -EINVAL;",
"\tif (!limit)\n\t\treturn 0;",
"\t*limit = get_seg_limit(regs, seg_reg_idx);\n\tif (!(*limit))\n\t\treturn -EINVAL;",
"\treturn 0;\n}",
"/**\n * get_eff_addr_reg() - Obtain effective address from register operand\n * @insn:\tInstruction. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tObtained operand offset, in pt_regs, with the effective address\n * @eff_addr:\tObtained effective address\n *\n * Obtain the effective address stored in the register operand as indicated by\n * the ModRM byte. This function is to be used only with register addressing\n * (i.e., ModRM.mod is 3). The effective address is saved in @eff_addr. The\n * register operand, as an offset from the base of pt_regs, is saved in @regoff;\n * such offset can then be used to resolve the segment associated with the\n * operand. This function can be used with any of the supported address sizes\n * in x86.\n *\n * Returns:\n *\n * 0 on success. @eff_addr will have the effective address stored in the\n * operand indicated by ModRM. @regoff will have such operand as an offset from\n * the base of pt_regs.\n *\n * -EINVAL on error.\n */\nstatic int get_eff_addr_reg(struct insn *insn, struct pt_regs *regs,\n\t\t\t int *regoff, long *eff_addr)\n{\n\tinsn_get_modrm(insn);",
"\tif (!insn->modrm.nbytes)\n\t\treturn -EINVAL;",
"\tif (X86_MODRM_MOD(insn->modrm.value) != 3)\n\t\treturn -EINVAL;",
"\t*regoff = get_reg_offset(insn, regs, REG_TYPE_RM);\n\tif (*regoff < 0)\n\t\treturn -EINVAL;",
"\t/* Ignore bytes that are outside the address size. */\n\tif (insn->addr_bytes == 2)\n\t\t*eff_addr = regs_get_register(regs, *regoff) & 0xffff;\n\telse if (insn->addr_bytes == 4)\n\t\t*eff_addr = regs_get_register(regs, *regoff) & 0xffffffff;\n\telse /* 64-bit address */\n\t\t*eff_addr = regs_get_register(regs, *regoff);",
"\treturn 0;\n}",
"/**\n * get_eff_addr_modrm() - Obtain referenced effective address via ModRM\n * @insn:\tInstruction. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tObtained operand offset, in pt_regs, associated with segment\n * @eff_addr:\tObtained effective address\n *\n * Obtain the effective address referenced by the ModRM byte of @insn. After\n * identifying the registers involved in the register-indirect memory reference,\n * its value is obtained from the operands in @regs. The computed address is\n * stored @eff_addr. Also, the register operand that indicates the associated\n * segment is stored in @regoff, this parameter can later be used to determine\n * such segment.\n *\n * Returns:\n *\n * 0 on success. @eff_addr will have the referenced effective address. @regoff\n * will have a register, as an offset from the base of pt_regs, that can be used\n * to resolve the associated segment.\n *\n * -EINVAL on error.\n */\nstatic int get_eff_addr_modrm(struct insn *insn, struct pt_regs *regs,\n\t\t\t int *regoff, long *eff_addr)\n{\n\tlong tmp;",
"\tif (insn->addr_bytes != 8 && insn->addr_bytes != 4)\n\t\treturn -EINVAL;",
"\tinsn_get_modrm(insn);",
"\tif (!insn->modrm.nbytes)\n\t\treturn -EINVAL;",
"\tif (X86_MODRM_MOD(insn->modrm.value) > 2)\n\t\treturn -EINVAL;",
"\t*regoff = get_reg_offset(insn, regs, REG_TYPE_RM);",
"\t/*\n\t * -EDOM means that we must ignore the address_offset. In such a case,\n\t * in 64-bit mode the effective address relative to the rIP of the\n\t * following instruction.\n\t */\n\tif (*regoff == -EDOM) {\n\t\tif (user_64bit_mode(regs))\n\t\t\ttmp = regs->ip + insn->length;\n\t\telse\n\t\t\ttmp = 0;\n\t} else if (*regoff < 0) {\n\t\treturn -EINVAL;\n\t} else {\n\t\ttmp = regs_get_register(regs, *regoff);\n\t}",
"\tif (insn->addr_bytes == 4) {\n\t\tint addr32 = (int)(tmp & 0xffffffff) + insn->displacement.value;",
"\t\t*eff_addr = addr32 & 0xffffffff;\n\t} else {\n\t\t*eff_addr = tmp + insn->displacement.value;\n\t}",
"\treturn 0;\n}",
"/**\n * get_eff_addr_modrm_16() - Obtain referenced effective address via ModRM\n * @insn:\tInstruction. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tObtained operand offset, in pt_regs, associated with segment\n * @eff_addr:\tObtained effective address\n *\n * Obtain the 16-bit effective address referenced by the ModRM byte of @insn.\n * After identifying the registers involved in the register-indirect memory\n * reference, its value is obtained from the operands in @regs. The computed\n * address is stored @eff_addr. Also, the register operand that indicates\n * the associated segment is stored in @regoff, this parameter can later be used\n * to determine such segment.\n *\n * Returns:\n *\n * 0 on success. @eff_addr will have the referenced effective address. @regoff\n * will have a register, as an offset from the base of pt_regs, that can be used\n * to resolve the associated segment.\n *\n * -EINVAL on error.\n */\nstatic int get_eff_addr_modrm_16(struct insn *insn, struct pt_regs *regs,\n\t\t\t\t int *regoff, short *eff_addr)\n{\n\tint addr_offset1, addr_offset2, ret;\n\tshort addr1 = 0, addr2 = 0, displacement;",
"\tif (insn->addr_bytes != 2)\n\t\treturn -EINVAL;",
"\tinsn_get_modrm(insn);",
"\tif (!insn->modrm.nbytes)\n\t\treturn -EINVAL;",
"\tif (X86_MODRM_MOD(insn->modrm.value) > 2)\n\t\treturn -EINVAL;",
"\tret = get_reg_offset_16(insn, regs, &addr_offset1, &addr_offset2);\n\tif (ret < 0)\n\t\treturn -EINVAL;",
"\t/*\n\t * Don't fail on invalid offset values. They might be invalid because\n\t * they cannot be used for this particular value of ModRM. Instead, use\n\t * them in the computation only if they contain a valid value.\n\t */\n\tif (addr_offset1 != -EDOM)\n\t\taddr1 = regs_get_register(regs, addr_offset1) & 0xffff;",
"\tif (addr_offset2 != -EDOM)\n\t\taddr2 = regs_get_register(regs, addr_offset2) & 0xffff;",
"\tdisplacement = insn->displacement.value & 0xffff;\n\t*eff_addr = addr1 + addr2 + displacement;",
"\t/*\n\t * The first operand register could indicate to use of either SS or DS\n\t * registers to obtain the segment selector. The second operand\n\t * register can only indicate the use of DS. Thus, the first operand\n\t * will be used to obtain the segment selector.\n\t */\n\t*regoff = addr_offset1;",
"\treturn 0;\n}",
"/**\n * get_eff_addr_sib() - Obtain referenced effective address via SIB\n * @insn:\tInstruction. Must be valid.\n * @regs:\tRegister values as seen when entering kernel mode\n * @regoff:\tObtained operand offset, in pt_regs, associated with segment\n * @eff_addr:\tObtained effective address\n *\n * Obtain the effective address referenced by the SIB byte of @insn. After\n * identifying the registers involved in the indexed, register-indirect memory\n * reference, its value is obtained from the operands in @regs. The computed\n * address is stored @eff_addr. Also, the register operand that indicates the\n * associated segment is stored in @regoff, this parameter can later be used to\n * determine such segment.\n *\n * Returns:\n *\n * 0 on success. @eff_addr will have the referenced effective address.\n * @base_offset will have a register, as an offset from the base of pt_regs,\n * that can be used to resolve the associated segment.\n *\n * -EINVAL on error.\n */\nstatic int get_eff_addr_sib(struct insn *insn, struct pt_regs *regs,\n\t\t\t int *base_offset, long *eff_addr)\n{\n\tlong base, indx;\n\tint indx_offset;",
"\tif (insn->addr_bytes != 8 && insn->addr_bytes != 4)\n\t\treturn -EINVAL;",
"\tinsn_get_modrm(insn);",
"\tif (!insn->modrm.nbytes)\n\t\treturn -EINVAL;",
"\tif (X86_MODRM_MOD(insn->modrm.value) > 2)\n\t\treturn -EINVAL;",
"\tinsn_get_sib(insn);",
"\tif (!insn->sib.nbytes)\n\t\treturn -EINVAL;",
"\t*base_offset = get_reg_offset(insn, regs, REG_TYPE_BASE);\n\tindx_offset = get_reg_offset(insn, regs, REG_TYPE_INDEX);",
"\t/*\n\t * Negative values in the base and index offset means an error when\n\t * decoding the SIB byte. Except -EDOM, which means that the registers\n\t * should not be used in the address computation.\n\t */\n\tif (*base_offset == -EDOM)\n\t\tbase = 0;\n\telse if (*base_offset < 0)\n\t\treturn -EINVAL;\n\telse\n\t\tbase = regs_get_register(regs, *base_offset);",
"\tif (indx_offset == -EDOM)\n\t\tindx = 0;\n\telse if (indx_offset < 0)\n\t\treturn -EINVAL;\n\telse\n\t\tindx = regs_get_register(regs, indx_offset);",
"\tif (insn->addr_bytes == 4) {\n\t\tint addr32, base32, idx32;",
"\t\tbase32 = base & 0xffffffff;\n\t\tidx32 = indx & 0xffffffff;",
"\t\taddr32 = base32 + idx32 * (1 << X86_SIB_SCALE(insn->sib.value));\n\t\taddr32 += insn->displacement.value;",
"\t\t*eff_addr = addr32 & 0xffffffff;\n\t} else {\n\t\t*eff_addr = base + indx * (1 << X86_SIB_SCALE(insn->sib.value));\n\t\t*eff_addr += insn->displacement.value;\n\t}",
"\treturn 0;\n}",
"/**\n * get_addr_ref_16() - Obtain the 16-bit address referred by instruction\n * @insn:\tInstruction containing ModRM byte and displacement\n * @regs:\tRegister values as seen when entering kernel mode\n *\n * This function is to be used with 16-bit address encodings. Obtain the memory\n * address referred by the instruction's ModRM and displacement bytes. Also, the\n * segment used as base is determined by either any segment override prefixes in\n * @insn or the default segment of the registers involved in the address\n * computation. In protected mode, segment limits are enforced.\n *\n * Returns:\n *\n * Linear address referenced by the instruction operands on success.\n *\n * -1L on error.\n */\nstatic void __user *get_addr_ref_16(struct insn *insn, struct pt_regs *regs)\n{\n\tunsigned long linear_addr = -1L, seg_base, seg_limit;\n\tint ret, regoff;\n\tshort eff_addr;\n\tlong tmp;",
"\tinsn_get_modrm(insn);\n\tinsn_get_displacement(insn);",
"\tif (insn->addr_bytes != 2)\n\t\tgoto out;",
"\tif (X86_MODRM_MOD(insn->modrm.value) == 3) {\n\t\tret = get_eff_addr_reg(insn, regs, ®off, &tmp);\n\t\tif (ret)\n\t\t\tgoto out;",
"\t\teff_addr = tmp;\n\t} else {\n\t\tret = get_eff_addr_modrm_16(insn, regs, ®off, &eff_addr);\n\t\tif (ret)\n\t\t\tgoto out;\n\t}",
"\tret = get_seg_base_limit(insn, regs, regoff, &seg_base, &seg_limit);\n\tif (ret)\n\t\tgoto out;",
"\t/*\n\t * Before computing the linear address, make sure the effective address\n\t * is within the limits of the segment. In virtual-8086 mode, segment\n\t * limits are not enforced. In such a case, the segment limit is -1L to\n\t * reflect this fact.\n\t */\n\tif ((unsigned long)(eff_addr & 0xffff) > seg_limit)\n\t\tgoto out;",
"\tlinear_addr = (unsigned long)(eff_addr & 0xffff) + seg_base;",
"\t/* Limit linear address to 20 bits */\n\tif (v8086_mode(regs))\n\t\tlinear_addr &= 0xfffff;",
"out:\n\treturn (void __user *)linear_addr;\n}",
"/**\n * get_addr_ref_32() - Obtain a 32-bit linear address\n * @insn:\tInstruction with ModRM, SIB bytes and displacement\n * @regs:\tRegister values as seen when entering kernel mode\n *\n * This function is to be used with 32-bit address encodings to obtain the\n * linear memory address referred by the instruction's ModRM, SIB,\n * displacement bytes and segment base address, as applicable. If in protected\n * mode, segment limits are enforced.\n *\n * Returns:\n *\n * Linear address referenced by instruction and registers on success.\n *\n * -1L on error.\n */\nstatic void __user *get_addr_ref_32(struct insn *insn, struct pt_regs *regs)\n{\n\tunsigned long linear_addr = -1L, seg_base, seg_limit;\n\tint eff_addr, regoff;\n\tlong tmp;\n\tint ret;",
"\tif (insn->addr_bytes != 4)\n\t\tgoto out;",
"\tif (X86_MODRM_MOD(insn->modrm.value) == 3) {\n\t\tret = get_eff_addr_reg(insn, regs, ®off, &tmp);\n\t\tif (ret)\n\t\t\tgoto out;",
"\t\teff_addr = tmp;",
"\t} else {\n\t\tif (insn->sib.nbytes) {\n\t\t\tret = get_eff_addr_sib(insn, regs, ®off, &tmp);\n\t\t\tif (ret)\n\t\t\t\tgoto out;",
"\t\t\teff_addr = tmp;\n\t\t} else {\n\t\t\tret = get_eff_addr_modrm(insn, regs, ®off, &tmp);\n\t\t\tif (ret)\n\t\t\t\tgoto out;",
"\t\t\teff_addr = tmp;\n\t\t}\n\t}",
"\tret = get_seg_base_limit(insn, regs, regoff, &seg_base, &seg_limit);\n\tif (ret)\n\t\tgoto out;",
"\t/*\n\t * In protected mode, before computing the linear address, make sure\n\t * the effective address is within the limits of the segment.\n\t * 32-bit addresses can be used in long and virtual-8086 modes if an\n\t * address override prefix is used. In such cases, segment limits are\n\t * not enforced. When in virtual-8086 mode, the segment limit is -1L\n\t * to reflect this situation.\n\t *\n\t * After computed, the effective address is treated as an unsigned\n\t * quantity.\n\t */\n\tif (!user_64bit_mode(regs) && ((unsigned int)eff_addr > seg_limit))\n\t\tgoto out;",
"\t/*\n\t * Even though 32-bit address encodings are allowed in virtual-8086\n\t * mode, the address range is still limited to [0x-0xffff].\n\t */\n\tif (v8086_mode(regs) && (eff_addr & ~0xffff))\n\t\tgoto out;",
"\t/*\n\t * Data type long could be 64 bits in size. Ensure that our 32-bit\n\t * effective address is not sign-extended when computing the linear\n\t * address.\n\t */\n\tlinear_addr = (unsigned long)(eff_addr & 0xffffffff) + seg_base;",
"\t/* Limit linear address to 20 bits */\n\tif (v8086_mode(regs))\n\t\tlinear_addr &= 0xfffff;",
"out:\n\treturn (void __user *)linear_addr;\n}",
"/**\n * get_addr_ref_64() - Obtain a 64-bit linear address\n * @insn:\tInstruction struct with ModRM and SIB bytes and displacement\n * @regs:\tStructure with register values as seen when entering kernel mode\n *\n * This function is to be used with 64-bit address encodings to obtain the\n * linear memory address referred by the instruction's ModRM, SIB,\n * displacement bytes and segment base address, as applicable.\n *\n * Returns:\n *\n * Linear address referenced by instruction and registers on success.\n *\n * -1L on error.\n */\n#ifndef CONFIG_X86_64\nstatic void __user *get_addr_ref_64(struct insn *insn, struct pt_regs *regs)\n{\n\treturn (void __user *)-1L;\n}\n#else\nstatic void __user *get_addr_ref_64(struct insn *insn, struct pt_regs *regs)\n{\n\tunsigned long linear_addr = -1L, seg_base;\n\tint regoff, ret;\n\tlong eff_addr;",
"\tif (insn->addr_bytes != 8)\n\t\tgoto out;",
"\tif (X86_MODRM_MOD(insn->modrm.value) == 3) {\n\t\tret = get_eff_addr_reg(insn, regs, ®off, &eff_addr);\n\t\tif (ret)\n\t\t\tgoto out;",
"\t} else {\n\t\tif (insn->sib.nbytes) {\n\t\t\tret = get_eff_addr_sib(insn, regs, ®off, &eff_addr);\n\t\t\tif (ret)\n\t\t\t\tgoto out;\n\t\t} else {\n\t\t\tret = get_eff_addr_modrm(insn, regs, ®off, &eff_addr);\n\t\t\tif (ret)\n\t\t\t\tgoto out;\n\t\t}",
"\t}",
"\tret = get_seg_base_limit(insn, regs, regoff, &seg_base, NULL);\n\tif (ret)\n\t\tgoto out;",
"\tlinear_addr = (unsigned long)eff_addr + seg_base;",
"out:\n\treturn (void __user *)linear_addr;\n}\n#endif /* CONFIG_X86_64 */",
"/**\n * insn_get_addr_ref() - Obtain the linear address referred by instruction\n * @insn:\tInstruction structure containing ModRM byte and displacement\n * @regs:\tStructure with register values as seen when entering kernel mode\n *\n * Obtain the linear address referred by the instruction's ModRM, SIB and\n * displacement bytes, and segment base, as applicable. In protected mode,\n * segment limits are enforced.\n *\n * Returns:\n *\n * Linear address referenced by instruction and registers on success.\n *\n * -1L on error.\n */\nvoid __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs)\n{\n\tif (!insn || !regs)\n\t\treturn (void __user *)-1L;",
"\tswitch (insn->addr_bytes) {\n\tcase 2:\n\t\treturn get_addr_ref_16(insn, regs);\n\tcase 4:\n\t\treturn get_addr_ref_32(insn, regs);\n\tcase 8:\n\t\treturn get_addr_ref_64(insn, regs);\n\tdefault:\n\t\treturn (void __user *)-1L;\n\t}\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [768], "buggy_code_start_loc": [560], "filenames": ["arch/x86/lib/insn-eval.c"], "fixing_code_end_loc": [769], "fixing_code_start_loc": [560], "message": "In arch/x86/lib/insn-eval.c in the Linux kernel before 5.1.9, there is a use-after-free for access to an LDT entry because of a race condition between modify_ldt() and a #BR exception for an MPX bounds violation.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "E567EFE6-8F22-4645-838E-9B381F951463", "versionEndExcluding": "5.1.9", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "In arch/x86/lib/insn-eval.c in the Linux kernel before 5.1.9, there is a use-after-free for access to an LDT entry because of a race condition between modify_ldt() and a #BR exception for an MPX bounds violation."}, {"lang": "es", "value": "En arch/x86/lib/insn-eval.c en el kernel de Linux en versiones anteriores a la 5.1.9, hay un uso de memoria previamente liberada para acceder a una entrada LDT debido a una condici\u00f3n de carrera entre modify_ldt () y una excepci\u00f3n #BR para una violaci\u00f3n de los l\u00edmites de MPX."}], "evaluatorComment": null, "id": "CVE-2019-13233", "lastModified": "2019-07-20T12:15:13.477", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 4.4, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:L/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 3.4, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 7.0, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 1.0, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2019-07-04T13:15:11.000", "references": [{"source": "cve@mitre.org", "tags": null, "url": "http://lists.opensuse.org/opensuse-security-announce/2019-07/msg00025.html"}, {"source": "cve@mitre.org", "tags": null, "url": "http://packetstormsecurity.com/files/154408/Kernel-Live-Patch-Security-Notice-LSN-0055-1.html"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2019:3309"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2019:3517"}, {"source": "cve@mitre.org", "tags": ["Exploit", "Mailing List", "Patch", "Third Party Advisory"], "url": "https://bugs.chromium.org/p/project-zero/issues/detail?id=1879"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Release Notes", "Vendor Advisory"], "url": "https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.1.9"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Vendor Advisory"], "url": "https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=de9f869616dd95e95c00bdd6b0fcd3421e8a4323"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/de9f869616dd95e95c00bdd6b0fcd3421e8a4323"}, {"source": "cve@mitre.org", "tags": null, "url": "https://seclists.org/bugtraq/2019/Aug/13"}, {"source": "cve@mitre.org", "tags": null, "url": "https://security.netapp.com/advisory/ntap-20190806-0001/"}, {"source": "cve@mitre.org", "tags": null, "url": "https://support.f5.com/csp/article/K13331647?utm_source=f5support&utm_medium=RSS"}, {"source": "cve@mitre.org", "tags": null, "url": "https://usn.ubuntu.com/4093-1/"}, {"source": "cve@mitre.org", "tags": null, "url": "https://usn.ubuntu.com/4094-1/"}, {"source": "cve@mitre.org", "tags": null, "url": "https://usn.ubuntu.com/4117-1/"}, {"source": "cve@mitre.org", "tags": null, "url": "https://usn.ubuntu.com/4118-1/"}, {"source": "cve@mitre.org", "tags": null, "url": "https://www.debian.org/security/2019/dsa-4495"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-362"}, {"lang": "en", "value": "CWE-416"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/de9f869616dd95e95c00bdd6b0fcd3421e8a4323"}, "type": "CWE-362"}
| 364
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/**\n * Message and Reminder Center UI\n *\n * @Package OpenEMR\n * @link http://www.open-emr.org\n * @author OpenEMR Support LLC\n * @author Roberto Vasquez <robertogagliotta@gmail.com>\n * @author Rod Roark <rod@sunsetsystems.com>\n * @author Brady Miller <brady.g.miller@gmail.com>\n * @author Ray Magauran <magauran@medfetch.com>\n * @author Tyler Wrenn <tyler@tylerwrenn.com>\n * @copyright Copyright (c) 2010 OpenEMR Support LLC\n * @copyright Copyright (c) 2017 MedEXBank.com\n * @copyright Copyright (c) 2018-2019 Brady Miller <brady.g.miller@gmail.com>\n * @copyright Copyright (c) 2020 Tyler Wrenn <tyler@tylerwrenn.com>\n * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3\n */",
"require_once(\"../../globals.php\");\nrequire_once(\"$srcdir/pnotes.inc\");\nrequire_once(\"$srcdir/patient.inc\");\nrequire_once(\"$srcdir/options.inc.php\");\nrequire_once(\"$srcdir/gprelations.inc.php\");\nrequire_once \"$srcdir/user.inc\";\nrequire_once(\"$srcdir/MedEx/API.php\");",
"use OpenEMR\\Common\\Acl\\AclMain;\nuse OpenEMR\\Common\\Csrf\\CsrfUtils;\nuse OpenEMR\\Common\\Logging\\EventAuditLogger;\nuse OpenEMR\\Core\\Header;\nuse OpenEMR\\OeUI\\OemrUI;",
"//Gets validation rules from Page Validation list.\n$collectthis = collectValidationPageRules(\"/interface/main/messages/messages.php\");\nif (empty($collectthis)) {\n $collectthis = \"{}\";\n} else {\n $collectthis = json_sanitize($collectthis[array_keys($collectthis)[0]][\"rules\"]);\n}",
"$MedEx = new MedExApi\\MedEx('MedExBank.com');",
"if ($GLOBALS['medex_enable'] == '1') {\n if ($_REQUEST['SMS_bot']) {\n $result = $MedEx->login('');\n $MedEx->display->SMS_bot($result);\n exit();\n }\n $logged_in = $MedEx->login();\n} else {\n $logged_in = null;\n}",
"$setting_bootstrap_submenu = prevSetting('', 'setting_bootstrap_submenu', 'setting_bootstrap_submenu', ' ');\n//use $uspfx as the first variable for page/script specific user settings instead of '' (which is like a global but you have to request it).\n$uspfx = substr(__FILE__, strlen($webserver_root)) . '.';\n$rcb_selectors = prevSetting($uspfx, 'rcb_selectors', 'rcb_selectors', 'block');\n$rcb_facility = prevSetting($uspfx, 'form_facility', 'form_facility', '');\n$rcb_provider = prevSetting($uspfx, 'form_provider', 'form_provider', $_SESSION['authUserID']);",
"if (\n (array_key_exists('setting_bootstrap_submenu', $_POST)) ||\n (array_key_exists('rcb_selectors', $_POST))\n) {\n // These are not form elements. We only ever change them via ajax, so exit now.\n exit();\n}\n?>\n<!DOCTYPE html>\n<html>\n<head>\n <?php\n //validation library\n $use_validate_js = 1;\n require_once($GLOBALS['srcdir'] . \"/validation/validation_script.js.php\");\n ?>\n <meta charset=\"utf-8\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n <meta name=\"description\" content=\"MedEx Bank\" />\n <meta name=\"author\" content=\"OpenEMR: MedExBank\" />\n <?php Header::setupHeader(['datetime-picker', 'opener', 'moment', 'select2']); ?>\n <link rel=\"stylesheet\" href=\"<?php echo $webroot; ?>/interface/main/messages/css/reminder_style.css?v=<?php echo $v_js_includes; ?>\">",
" <script>\n var xljs1 = '<?php echo xla('Preferences updated successfully'); ?>';\n var format_date_moment_js = '<?php echo attr(DateFormatRead(\"validateJS\")); ?>';\n <?php require_once \"$srcdir/restoreSession.php\"; ?>\n </script>",
" <script src=\"<?php echo $GLOBALS['web_root']; ?>/interface/main/messages/js/reminder_appts.js?v=<?php echo $v_js_includes; ?>\"></script>\n <style>\n @media only screen and (max-width: 768px) {\n [class*=\"col-\"] {\n width: 100%;\n text-align: left !important;\n }",
" .icon-bar {\n background-color: var(--danger);\n }\n }\n </style>",
"<?php\nif (($GLOBALS['medex_enable'] == '1') && (empty($_REQUEST['nomenu'])) && ($GLOBALS['disable_rcb'] != '1')) {\n $MedEx->display->navigation($logged_in);\n echo \"<br /><br /><br />\";\n}",
"if (!empty($_REQUEST['go'])) { ?>\n <?php\n if (($_REQUEST['go'] == \"setup\") && (!$logged_in)) {\n echo \"<title>\" . xlt('MedEx Setup') . \"</title>\";\n $stage = $_REQUEST['stage'];\n if (!is_numeric($stage)) {",
" echo \"<br /><span class='title'>$stage \" . xlt('Warning') . \": \" . xlt('This is not a valid request') . \".</span>\";",
" } else {\n $MedEx->setup->MedExBank($stage);\n }\n } elseif ($_REQUEST['go'] == \"addRecall\") {\n echo \"<title>\" . xlt('New Recall') . \"</title>\";\n $MedEx->display->display_add_recall();\n } elseif ($_REQUEST['go'] == 'Recalls') {\n echo \"<title>\" . xlt('Recall Board') . \"</title>\";\n $MedEx->display->display_recalls($logged_in);\n } elseif ((($_REQUEST['go'] == \"setup\") || ($_REQUEST['go'] == 'Preferences')) && ($logged_in)) {\n echo \"<title>MedEx: \" . xlt('Preferences') . \"</title>\";\n $MedEx->display->preferences();\n } elseif ($_REQUEST['go'] == 'icons') {\n echo \"<title>MedEx: \" . xlt('Icons') . \"Ⓒ</title>\";\n $MedEx->display->icon_template();\n } elseif ($_REQUEST['go'] == 'SMS_bot') {\n echo \"<title>MedEx: SMS BotⒸ</title>\";\n $MedEx->display->SMS_bot($logged_in);\n exit;\n } else {\n echo \"<title>\" . xlt('MedEx Setup') . \"</title>\";\n echo xlt('Warning: Navigation error. Please refresh this page.');\n }\n} else {\n //original message.php stuff",
" if ($GLOBALS['enable_help'] == 1) {\n $help_icon = '<a class=\"float-right oe-help-redirect\" data-target=\"#myModal\" data-toggle=\"modal\" href=\"#\" id=\"help-href\" name=\"help-href\" style=\"color: var(--gray)\" title=\"' . xla(\"Click to view Help\") . '\"><i class=\"fa fa-question-circle\" aria-hidden=\"true\"></i></a>';\n } elseif ($GLOBALS['enable_help'] == 2) {\n $help_icon = '<a class=\"float-right oe-help-redirect\" data-target=\"#myModal\" data-toggle=\"modal\" href=\"#\" id=\"help-href\" name=\"help-href\" style=\"color: var(--gray300) !important\" title=\"' . xla(\"To enable help - Go to Administration > Globals > Features > Enable Help Modal\") . '\"><i class=\"fa fa-question-circle\" aria-hidden=\"true\"></i></a>';\n } elseif ($GLOBALS['enable_help'] == 0) {\n $help_icon = '';\n }\n $heading_caption = xlt('Messages') . ', ' . xlt('Reminders');\n if ($GLOBALS['disable_rcb'] != '1') {\n $heading_caption .= ', ' . xlt('Recalls');\n }",
" $arrOeUiSettings = array(\n 'heading_title' => $heading_caption,\n 'include_patient_name' => false,// use only in appropriate pages\n 'expandable' => false,\n 'expandable_files' => array(\"\"),//all file names need suffix _xpd\n 'action' => \"\",//conceal, reveal, search, reset, link or back\n 'action_title' => \"\",\n 'action_href' => \"\",//only for actions - reset, link or back\n 'show_help_icon' => true,\n 'help_file_name' => \"message_center_help.php\"\n );\n $oemr_ui = new OemrUI($arrOeUiSettings);",
" echo \"<title>\" . xlt('Message Center') . \"</title>\";\n ?>\n</head>\n<body class='body_top'>\n <div id=\"container_div\" class=\"<?php echo attr($oemr_ui->oeContainer()); ?>\">\n <div class=\"row\">\n <div class=\"col-sm-12\">\n <div class=\"clearfix\">\n <?php echo $oemr_ui->pageHeading() . \"\\r\\n\"; ?>\n </div>\n </div>\n </div>\n <div class=\"container-fluid mb-3\">\n <ul class=\"nav nav-pills\">\n <li class=\"nav-item\" id='li-mess'>\n <a href='#' class=\"active nav-link font-weight-bold\" id='messages-li'><?php echo xlt('Messages'); ?></a>\n </li>\n <li class=\"nav-item\" id='li-remi'>\n <a href='#' id='reminders-li' class=\"nav-link font-weight-bold\"><?php echo xlt('Reminders'); ?></a>\n </li>\n <?php if ($GLOBALS['disable_rcb'] != '1') { ?>\n <li class=\"nav-item\" id='li-reca'>\n <a href='#' id='recalls-li' class=\"nav-link font-weight-bold\"><?php echo xlt('Recalls'); ?></a>\n </li>\n <?php }?>\n <?php if ($logged_in) { ?>\n <li class=\"nav-item\" id='li-sms'>\n <a href='#' id='sms-li' class=\"nav-link font-weight-bold\"><?php echo xlt('SMS Zone'); ?></a>\n </li>\n <?php }?>\n </ul>\n </div>\n <div class=\"row\" id=\"messages-div\">\n <div class=\"col-sm-12\">\n <div class=\"jumbotron jumbotron-fluid py-3\">\n <div class=\"col-sm-12 col-md-12 col-lg-12\">\n <?php\n // Check to see if the user has Admin rights, and if so, allow access to See All.\n $showall = isset($_GET['show_all']) ? $_GET['show_all'] : \"\";\n if ($showall == \"yes\") {\n $show_all = $showall;\n } else {\n $show_all = \"no\";\n }\n // Collect active variable and applicable html code for links\n $form_active = (isset($_REQUEST['form_active']) ? $_REQUEST['form_active'] : false);\n $form_inactive = (isset($_REQUEST['form_inactive']) ? $_REQUEST['form_inactive'] : false);\n if ($form_active) {\n $active = '1';\n $activity_string_html = 'form_active=1';\n } elseif ($form_inactive) {\n $active = '0';\n $activity_string_html = 'form_inactive=1';\n } else {\n $active = 'all';\n $activity_string_html = '';\n }\n //collect the task setting\n $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : \"\";\n if (AclMain::aclCheckCore('admin', 'super')) {\n if ($show_all == 'yes') {\n $showall = \"yes\";\n $lnkvar = \"messages.php?show_all=no&\" . $activity_string_html;\n $lnkattributes = \"name='Just Mine' onclick='top.restoreSession()'\";\n $otherstuff = \"<i id='just-mine-tooltip' class='fa fa-user fa-lg text-body' aria-hidden='true'></i>\";\n $messages = xl('All Messages');\n } else {\n $showall = \"no\";\n $lnkvar = \"messages.php?show_all=yes&\" . $activity_string_html;\n $lnkattributes = \"name='See All' onclick='top.restoreSession()'\";\n $otherstuff = \"<i id='see-all-tooltip' class='fa fa-users fa-lg text-body' aria-hidden='true'></i>\";\n $messages = xl('My Messages');\n }\n } else {\n $messages = xlt('My Messages');\n }\n ?>\n <div class=\"oe-margin-b-20\">\n <span class=\"title\"><?php echo text($messages); ?></span>\n <a class='more' href=\"<?php echo $lnkvar ?? ''; ?>\" <?php echo $lnkattributes ?? ''; ?>><?php echo $otherstuff ?? ''; ?></a>\n </div>\n <div class=\"oe-margin-b-10\">\n <?php\n //show the activity links\n if (empty($task) || $task == \"add\" || $task == \"delete\") { ?>\n <?php if ($active == \"all\") { ?>\n <span class=\"font-weight-bold\"><?php echo xlt('All Messages'); ?></span>\n <?php } else { ?>\n <a href=\"messages.php\" class=\"link btn btn-secondary\" onclick=\"top.restoreSession()\"><?php echo xlt('Show All'); ?></a>\n <?php } ?>\n |\n <?php if ($active == '1') { ?>\n <span class=\"font-weight-bold\"><?php echo xlt('Active Messages'); ?></span>\n <?php } else { ?>\n <a href=\"messages.php?form_active=1\" class=\"link btn btn-secondary\" onclick=\"top.restoreSession()\"><?php echo xlt('Show Active'); ?></a>\n <?php } ?>\n |\n <?php if ($active == '0') { ?>\n <span class=\"font-weight-bold\"><?php echo xlt('Inactive Messages'); ?></span>\n <?php } else { ?>\n <a href=\"messages.php?form_inactive=1\" class=\"link btn btn-secondary\" onclick=\"top.restoreSession()\"><?php echo xlt('Show Inactive'); ?></a>\n <?php } ?>\n <?php } ?>\n </div>\n <?php\n $note = '';\n $noteid = '';\n $title = '';\n $form_message_status = '';\n $reply_to = '';\n $patientname = '';\n switch ($task) {\n case \"add\":\n // Add a new message for a specific patient; the message is documented in Patient Notes.\n // Add a new message; it's treated as a new note in Patient Notes.\n $note = $_POST['note'];\n $noteid = $_POST['noteid'];\n $form_note_type = $_POST['form_note_type'];\n $form_message_status = $_POST['form_message_status'];\n $reply_to = explode(';', rtrim($_POST['reply_to'], ';'));\n $assigned_to_list = explode(';', $_POST['assigned_to']);\n $datetime = isset($_POST['form_datetime']) ? DateTimeToYYYYMMDDHHMMSS($_POST['form_datetime']) : '';\n foreach ($assigned_to_list as $assigned_to) {\n if ($noteid && $assigned_to != '-patient-') {\n updatePnote($noteid, $note, $form_note_type, $assigned_to, $form_message_status, $datetime);\n $noteid = '';\n } else {\n if ($noteid && $assigned_to == '-patient-') {\n // When $assigned_to == '-patient-' we don't update the current note, but\n // instead create a new one with the current note's body prepended and\n // attributed to the patient. This seems to be all for the patient portal.\n $row = getPnoteById($noteid);\n if (!$row) {\n die(\"getPnoteById() did not find id '\" . text($noteid) . \"'\");\n }\n $pres = sqlQuery(\"SELECT lname, fname \" .\n \"FROM patient_data WHERE pid = ?\", array($reply_to[0]));\n $patientname = $pres['lname'] . \", \" . $pres['fname'];\n $note .= \"\\n\\n$patientname on \" . $row['date'] . \" wrote:\\n\\n\";\n $note .= $row['body'];\n }\n // There's no note ID, and/or it's assigned to the patient.\n // In these cases a new note is created.\n foreach ($reply_to as $patient) {\n addPnote($patient, $note, $userauthorized, '1', $form_note_type, $assigned_to, $datetime, $form_message_status);\n }\n }\n }\n break;\n case \"savePatient\":\n case \"save\":\n // Update alert.\n $noteid = $_POST['noteid'];\n $form_message_status = $_POST['form_message_status'];\n $reply_to = $_POST['reply_to'];\n if ($task == \"save\") {\n updatePnoteMessageStatus($noteid, $form_message_status);\n } else {\n updatePnotePatient($noteid, $reply_to);\n }\n $task = \"edit\";\n $note = $_POST['note'];\n $title = $_POST['form_note_type'];\n $reply_to = $_POST['reply_to'];\n break;\n case \"edit\":\n if ($noteid == \"\") {\n $noteid = $_GET['noteid'];\n }\n // Update the message if it already exists; it's appended to an existing note in Patient Notes.\n $result = getPnoteById($noteid);\n if ($result) {\n if ($title == \"\") {\n $title = $result['title'];\n }\n $body = $result['body'];\n // if our reply-to is 0 it breaks multi patient select and other functionality\n // this most likely didn't break before due to php implicit type conversion of 0 to \"\"\n if ($reply_to == \"\" && $result['pid'] != 0) {\n $reply_to = $result['pid'];\n }\n $form_message_status = $result['message_status'];\n $datetime = $result['date'];\n }\n break;\n case \"delete\":\n // Delete selected message(s) from the Messages box (only).\n $delete_id = $_POST['delete_id'];\n for ($i = 0; $i < count($delete_id); $i++) {\n deletePnote($delete_id[$i]);\n EventAuditLogger::instance()->newEvent(\"delete\", $_SESSION['authUser'], $_SESSION['authProvider'], 1, \"pnotes: id \" . $delete_id[$i]);\n }\n break;\n }\n // This is for sorting the records.\n $sort = array(\"users.lname\", \"patient_data.lname\", \"pnotes.title\", \"pnotes.date\", \"pnotes.message_status\");\n $sortby = (isset($_REQUEST['sortby']) && ($_REQUEST['sortby'] != \"\")) ? $_REQUEST['sortby'] : $sort[3];\n $sortorder = (isset($_REQUEST['sortorder']) && ($_REQUEST['sortorder'] != \"\")) ? $_REQUEST['sortorder'] : \"desc\";\n $begin = isset($_REQUEST['begin']) ? $_REQUEST['begin'] : 0;",
" if ($task == \"addnew\" or $task == \"edit\") {\n // Display the Messages page layout.\n echo \"<form name='form_patient' id='new_note'\n class='form-horizontal'\n action=\\\"messages.php?showall=\" . attr_url($showall) . \"&sortby=\" . attr_url($sortby) . \"&sortorder=\" . attr_url($sortorder) . \"&begin=\" . attr_url($begin) . \"&$activity_string_html\\\"\n method='post'>\n <input type='hidden' name='noteid' id='noteid' value='\" . attr($noteid) . \"' />\n <input type='hidden' name='task' id='task' value='add' />\";\n if ($task == \"addnew\") {\n $message_legend = xl('Create New Message');\n $onclick = \"onclick=multi_sel_patient()\";\n } elseif ($task == \"edit\") {\n $message_legend = xl('Add To Existing Message');\n $onclick = \"\";\n }",
" ?>\n <div class='col-md-12'>\n <div class=\"jumbotron jumbotron-fluid py-3\">\n <h4><?php echo text($message_legend); ?></h4>\n <div class=\"row\">\n <div class=\"col-12 oe-custom-line\">\n <div class=\"row\">\n <div class=\"col-6 col-md-3\">\n <label for=\"form_note_type\"><?php echo xlt('Type'); ?>:</label>\n <?php\n if ($title == \"\") {\n $title = \"Unassigned\";\n }\n // Added 6/2009 by BM to incorporate the patient notes into the list_options listings.\n generate_form_field(array('data_type' => 1, 'field_id' => 'note_type', 'list_id' => 'note_type', 'empty_title' => 'SKIP', 'order_by' => 'title', 'class' => 'form-control'), $title);\n ?>\n </div>\n <div class=\"col-6 col-md-3\">\n <label for=\"form_message_status\"><?php echo xlt('Status'); ?>:</label>\n <?php\n if ($form_message_status == \"\") {\n $form_message_status = 'New';\n }\n generate_form_field(array('data_type' => 1, 'field_id' => 'message_status', 'list_id' => 'message_status', 'empty_title' => 'SKIP', 'order_by' => 'title', 'class' => 'form-control'), $form_message_status); ?>\n </div>\n <div class=\"col-6 col-md-4\">\n <?php\n if ($task != \"addnew\" && $result['pid'] != 0) { ?>\n <a class=\"patLink\" onclick=\"goPid('<?php echo attr(addslashes($result['pid'])); ?>')\" title='<?php echo xla('Click me to Open Patient Dashboard') ?>'><?php echo xlt('Patient'); ?>:</a><label for=\"form_patient\"> </label>\n <?php\n } else { ?>\n <span class='font-weight-bold <?php echo($task == \"addnew\" ? \"text-danger\" : \"\") ?>'><?php echo xlt('Patient'); ?>:</span></a><label for=\"form_patient\"></label>\n <?php\n }",
" if ($reply_to) {\n $prow = sqlQuery(\"SELECT lname, fname,pid, pubpid, DOB \" .\n \"FROM patient_data WHERE pid = ?\", array($reply_to));\n $patientname = $prow['lname'] . \", \" . $prow['fname'];\n }\n if ($task == \"addnew\" || $result['pid'] == 0) {\n $cursor = \"oe-cursor-add\";\n $background = \"oe-patient-background\";\n } elseif ($task == \"edit\") {\n $cursor = \"oe-cursor-stop\";\n $background = '';\n }\n ?>\n <input type='text' id='form_patient' name='form_patient' class='form-control <?php echo $cursor . \" \" . $background;?>' onclick=\"multi_sel_patient()\" placeholder='<?php echo xla(\"Click to add patient\"); ?>' value='<?php echo attr($patientname); ?>' readonly />\n <input type='hidden' class=\"form-control\" name='reply_to' id='reply_to' value='<?php echo attr($reply_to); ?>'/>\n </div>\n <div class=\"col-6 col-md-2 d-flex flex-wrap\">\n <?php\n if ($task == \"addnew\" || $result['pid'] == 0) {\n echo \"<label class='oe-empty-label' for='clear_patients'></label>\";\n echo '<button type=\"button\" id=\"clear_patients\" class=\"btn btn-secondary btn-undo float-left flip\" value=\"' . xla('Clear') . '\">' . xlt(\"Clear\") . '</button>';\n } ?>\n </div>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-12 oe-custom-line\">\n <div class=\"row\">\n <?php if ($GLOBALS['messages_due_date']) { ?>\n <div class=\"col-6 col-sm-2\">\n <label for=\"form_note_type\"><?php echo xlt('Due date'); ?>:</label>\n <?php generate_form_field(array('data_type' => 4, 'field_id' => 'datetime', 'edit_options' => 'F'), empty($datetime) ? date('Y-m-d H:i') : $datetime) ?>\n </div>\n <?php } ?>\n <div class=\"col-6 col-sm-4 d-flex align-items-end flex-wrap\">\n <label for=\"assigned_to_text\"><?php echo xlt('To{{Destination}}'); ?>:</label>\n <input type='text' name='assigned_to_text' class='form-control oe-cursor-stop' id='assigned_to_text' readonly='readonly' value='' placeholder='<?php echo xla(\"SELECT Users FROM The Dropdown LIST\"); ?>' />\n <input type='hidden' name='assigned_to' id='assigned_to' />\n </div>\n <div class=\"col-6 col-sm-4\">\n <label class=\"oe-empty-label\" for=\"users\"></label>\n <select name='users' id='users' class='form-control' onchange='addtolist(this);'>\n <?php\n echo \"<option value='--'\";\n echo \">\" . xlt('Select User');\n echo \"</option>\\n\";\n $ures = sqlStatement(\"SELECT username, fname, lname FROM users \" .\n \"WHERE username != '' AND active = 1 AND \" .\n \"( info IS NULL OR info NOT LIKE '%Inactive%' ) \" .\n \"ORDER BY lname, fname\");\n while ($urow = sqlFetchArray($ures)) {\n echo \" <option value='\" . attr($urow['username']) . \"'\";\n echo \">\" . text($urow['lname']);\n if ($urow['fname']) {\n echo \", \" . text($urow['fname']);\n }\n echo \"</option>\\n\";\n }\n ?>\n </select>\n </div>\n <div class=\"col-6 col-sm-2 d-flex align-items-end flex-wrap\">\n <label class=\"oe-empty-label\" for=\"users\"></label>\n <button type=\"button\" name=\"clear_user\" id=\"clear_user\" class=\"btn btn-secondary btn-undo float-left flip\" value=\"<?php echo xla('Clear'); ?>\"><?php echo xlt('Clear'); ?></button>\n </div>\n </div>\n <div class='col-12 oe-margin-t-3'>\n <?php\n if ($noteid) {\n include \"templates/linked_documents.php\";",
" // Get the related procedure order IDs if any.\n $tmp = sqlStatement(\n \"SELECT id1 FROM gprelations WHERE \" .\n \"type1 = ? AND type2 = ? AND id2 = ?\",\n array('2', '6', $noteid)\n );\n if (sqlNumRows($tmp)) {\n echo \" <tr>\\n\";\n echo \" <td class='text'><span class='font-weight-bold'>\" . xlt('Linked procedure order') . \":</span>\\n\";\n while ($gprow = sqlFetchArray($tmp)) {\n echo \" <a href='\";\n echo $GLOBALS['webroot'] . \"/interface/orders/single_order_results.php?orderid=\";\n echo attr_url($gprow['id1']);\n echo \"' target='_blank' onclick='top.restoreSession()'>\";\n echo text($gprow['id1']);\n echo \"</a>\\n\";\n }\n echo \" </td>\\n\";\n echo \" </tr>\\n\";\n }\n }\n ?>\n </div>\n </div>\n <!-- <div class=\"row\"> -->\n <div class='col-12'>\n <?php",
" if ($noteid) {\n $body = preg_replace('/(:\\d{2}\\s\\()' . $result['pid'] . '(\\sto\\s)/', '${1}' . $patientname . '${2}', $body);\n $body = preg_replace('/(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}\\s\\([^)(]+\\s)(to)(\\s[^)(]+\\))/', '${1}' . xl('to{{Destination}}') . '${3}', $body);\n $body = pnoteConvertLinks(nl2br(text(oeFormatPatientNote($body))));\n echo \"<div style='height: 120px; resize: vertical;' class='border overflow-auto text oe-margin-t-3 p-2 mb-2 w-100'>\" . $body . \"</div>\";\n }",
" ?>\n <textarea name='note' id='note' class='form-control oe-margin-t-3 p-1' rows=\"5\"><?php echo nl2br(text($note)); ?></textarea>\n </div>\n <div class=\"col-12 position-override oe-margin-t-10\">\n <?php if ($noteid) { ?>\n <!-- This is for displaying an existing note. -->\n <button type=\"button\" class=\"btn btn-primary btn-send-msg\" id=\"newnote\" value=\"<?php echo xla('Send message'); ?>\"><?php echo xlt('Send message'); ?></button>\n <button type=\"button\" class=\"btn btn-primary btn-print\" id=\"printnote\" value=\"<?php echo xla('Print message'); ?>\"><?php echo xlt('Print message'); ?></button>\n <button type=\"button\" class=\"btn btn-secondary btn-cancel\" id=\"cancel\" value=\"<?php echo xla('Cancel'); ?>\"><?php echo xlt('Cancel'); ?></button>\n <?php } else { ?>\n <!-- This is for displaying a new note. -->\n <button type=\"button\" class=\"btn btn-primary btn-send-msg\" id=\"newnote\" value=\"<?php echo xla('Send message'); ?>\"><?php echo xlt('Send message'); ?></button>\n <button type=\"button\" class=\"btn btn-cancel btn-secondary\" id=\"cancel\" value=\"<?php echo xla('Cancel'); ?>\"><?php echo xlt('Cancel'); ?></button>\n <?php }\n ?>\n </div>\n <!-- </div> -->\n </div>\n </div>\n </form>\n <?php\n } else {\n for ($i = 0; $i < count($sort); $i++) {\n $sortlink[$i] = \"<a class='arrowhead' href=\\\"messages.php?show_all=\" . attr($showall) . \"&sortby=\" . attr($sort[$i]) . \"&sortorder=asc&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\" alt=\\\"\" . xla('Sort Up') . \"\\\"><i class='fa fa-sort-down fa-lg' aria-hidden='true'></i></a>\";\n }\n for ($i = 0; $i < count($sort); $i++) {\n if ($sortby == $sort[$i]) {\n switch ($sortorder) {\n case \"asc\":\n $sortlink[$i] = \"<a class='arrowhead' href=\\\"messages.php?show_all=\" . attr($showall) . \"&sortby=\" . attr($sortby) . \"&sortorder=desc&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\" alt=\\\"\" . xla('Sort Up') . \"\\\"><i class='fa fa-sort-up fa-lg' aria-hidden='true'></i></a>\";\n break;\n case \"desc\":\n $sortlink[$i] = \"<a class='arrowhead' href=\\\"messages.php?show_all=\" . attr($showall) . \"&sortby=\" . attr($sortby) . \"&sortorder=asc&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\" alt=\\\"\" . xla('Sort Down') . \"\\\"><i class='fa fa-sort-down fa-lg' aria-hidden='true'></i></a>\";\n break;\n } break;\n }\n }\n // Manage page numbering and display beneath the Messages table.\n $listnumber = 25;\n $total = getPnotesByUser($active, $show_all, $_SESSION['authUser'], true);\n if ($begin == \"\" or $begin == 0) {\n $begin = 0;\n }\n $prev = $begin - $listnumber;\n $next = $begin + $listnumber;\n $start = $begin + 1;\n $end = $listnumber + $start - 1;",
" $chevron_icon_left = $_SESSION['language_direction'] == 'ltr' ? 'fa-chevron-circle-left' : 'fa-chevron-circle-right';\n $chevron_icon_right = $_SESSION['language_direction'] == 'ltr' ? 'fa-chevron-circle-right' : 'fa-chevron-circle-left';",
" if ($end >= $total) {\n $end = $total;\n }\n if ($end < $start) {\n $start = 0;\n }\n if ($prev >= 0) {\n $prevlink = \"<a href=\\\"messages.php?show_all=\" . attr($showall) . \"&sortby=\" . attr($sortby) . \"&sortorder=\" . attr($sortorder) . \"&begin=\" . attr($prev) . \"&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\"><i class=\\\"fa \" . $chevron_icon_left . \" chevron_color\\\" aria-hidden=\\\"true\\\"></i></a>\";\n } else {\n $prevlink = \"<i class=\\\"fa \" . $chevron_icon_left . \" text-muted\\\" aria-hidden=\\\"true\\\" title=\\\"\" . xla(\"On first page\") . \"\\\"></i>\";\n }",
" if ($next < $total) {\n $nextlink = \"<a href=\\\"messages.php?show_all=\" . attr($showall) . \"&sortby=\" . attr($sortby) . \"&sortorder=\" . attr($sortorder) . \"&begin=\" . attr($next) . \"&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\"><i class=\\\"fa . $chevron_icon_right . chevron_color\\\" aria-hidden=\\\"true\\\"></i></a>\";\n } else {\n $nextlink = \"<i class=\\\"fa \" . $chevron_icon_right . \" text-muted\\\" aria-hidden=\\\"true\\\" title=\\\"\" . xla(\"On first page\") . \"\\\"></i>\";\n }\n // Display the Messages table header.\n echo \"\n <table class=\\\"w-100\\\">\n <tr>\n <td>\n <form name='MessageList' id='MessageList' action=\\\"messages.php?showall=\" . attr($showall) . \"&sortby=\" . attr($sortby) . \"&sortorder=\" . attr($sortorder) . \"&begin=\" . attr($begin) . \"&$activity_string_html\\\" method='post'>\n <table class='table table-sm table-hover w-100'>\n <input type='hidden' name='task' value='delete' />\n <thead class='table-primary'>\n <tr height='24'>\n <th align='center' width='25'><input type='checkbox' id='checkAll' onclick='selectAll()'></th>\n <th width='20%' class='font-weight-bold'> \" . xlt('From') . \" $sortlink[0]</th>\n <th width='20%' class='font-weight-bold'> \" . xlt('Patient') . \" $sortlink[1]</th>\n <th class='font-weight-bold'> \" . xlt('Type') . \" $sortlink[2]</th>\n <th width='15%' class='font-weight-bold'> \" . xlt($GLOBALS['messages_due_date'] ? 'Due date' : 'Date') . \" $sortlink[3]</th>\n <th width='15%' class='font-weight-bold'> \" . xlt('Status') . \" $sortlink[4]</th>\n </tr>\n </thead>\";\n // Display the Messages table body.\n $count = 0;\n $result = getPnotesByUser($active, $show_all, $_SESSION['authUser'], false, $sortby, $sortorder, $begin, $listnumber);\n while ($myrow = sqlFetchArray($result)) {\n $name = $myrow['user'];\n $name = $myrow['users_lname'];\n if ($myrow['users_fname']) {\n $name .= \", \" . $myrow['users_fname'];\n }\n $patient = $myrow['pid'];\n if ($patient > 0) {\n $patient = $myrow['patient_data_lname'];\n if ($myrow['patient_data_fname']) {\n $patient .= \", \" . $myrow['patient_data_fname'];\n }\n } else {\n $patient = \"* \" . xl('Patient must be set manually') . \" *\";\n }\n $count++;\n echo \"\n <tr id=\\\"row\" . attr($count) . \"\\\" height='24'>\n <td align='center'>\n <input type='checkbox' id=\\\"check\" . attr($count) . \"\\\" name=\\\"delete_id[]\\\" value=\\\"\" .\n attr($myrow['id']) . \"\\\" onclick=\\\"if(this.checked==true){ selectRow('row\" . attr(addslashes($count)) . \"'); }else{ deselectRow('row\" . attr(addslashes($count)) . \"'); }\\\"></td>\n <td>\n <div>\" . text($name) . \"</div>\n </td>\n <td>\n <div><a href=\\\"messages.php?showall=\" . attr_url($showall) . \"&sortby=\" . attr_url($sortby) . \"&sortorder=\" . attr_url($sortorder) . \"&begin=\" . attr_url($begin) . \"&task=edit¬eid=\" .\n attr_url($myrow['id']) . \"&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\">\" .\n text($patient) . \"</a></div>\n </td>\n <td>\n <div>\" .\n xlt($myrow['title']) . \"</div>\n <td>\n <div>\" . text(oeFormatDateTime($myrow['date'])) . \"</div>\n </td>\n <td>\n <div>\" . text(getListItemTitle('message_status', $myrow['message_status'])) . \"</div>\n </td>\n </tr>\";\n }\n // Display the Messages table footer.",
" echo \" </table>\n </form>\n <div class='row oe-margin-t-10'>",
" <div class=\\\"col-12 col-md-12 col-lg-12\\\"><a href=\\\"messages.php?showall=\" . attr_url($showall) . \"&sortby=\" . attr_url($sortby) . \"&sortorder=\" . attr_url($sortorder) . \"&begin=\" . attr_url($begin) . \"&task=addnew&$activity_string_html\\\" class=\\\"btn btn-primary btn-add\\\" onclick=\\\"top.restoreSession()\\\">\" .\n xlt('Add New{{Message}}') . \"</a> <a href=\\\"javascript:confirmDeleteSelected()\\\" class=\\\"btn btn-danger btn-delete\\\" onclick=\\\"top.restoreSession()\\\">\" .\n xlt('Delete') . \"</a>\";",
" if ($GLOBALS['phimail_enable']) {\n echo \" <a href='trusted-messages.php' onclick='top.restoreSession()' class='btn btn-secondary btn-mail'>\" . xlt(\"Compose Trusted Direct Message\") . \"</a>\";\n echo \" <button class='btn btn-secondary btn-refresh trusted-messages-force-check'>\" . xlt(\"Check New Trusted Messages\") . \"</button>\";\n }\n echo \"\n <div class=\\\"text-right\\\">$prevlink \" . text($end) . \" \" . xlt('of') . \" \" . text($total) . \" $nextlink</div>\n </div>\n </div>\n </td>\n </tr>\n </table>\n <br />\";\n ?>",
" <script>\n // This is to confirm delete action.\n function confirmDeleteSelected() {\n var int_checked = 0;\n var elem = document.forms.namedItem(\"MessageList\").getElementsByTagName(\"input\");",
" for (i=0; i < elem.length; i++){\n if(elem[i].checked == true){\n int_checked = ++int_checked;\n }\n }\n if (int_checked > 0){\n if (confirm(\"<?php echo xls('Do you really want to delete the selection?'); ?>\")) {\n document.MessageList.submit();\n }\n } else {\n alert(\"<?php echo xls('Please select message(s) to delete'); ?>\");\n }\n }",
"\n // This is to allow selection of all items in Messages table for deletion.\n function selectAll() {\n if (document.getElementById(\"checkAll\").checked === true) {\n document.getElementById(\"checkAll\").checked = true;<?php\n for ($i = 1; $i <= $count; $i++) {\n echo \"document.getElementById(\\\"check$i\\\").checked=true; document.getElementById(\\\"row$i\\\").style.background='var(--gray200)'; \";\n } ?>\n } else {\n document.getElementById(\"checkAll\").checked = false;<?php\n for ($i = 1; $i <= $count; $i++) {\n echo \"document.getElementById(\\\"check$i\\\").checked=false; document.getElementById(\\\"row$i\\\").style.background='var(--light)'; \";\n } ?>\n }\n }",
" // The two functions below are for managing row styles in Messages table.\n function selectRow(row) {\n document.getElementById(row).style.background = \"var(--gray200)\";\n }",
" function deselectRow(row) {\n document.getElementById(row).style.background = \"var(--light)\";\n }\n </script>\n <?php\n }\n ?>\n </div>\n </div>\n </div>\n </div><!--end of messages div-->\n <div class=\"row oe-display\" id=\"reminders-div\">\n <div class=\"col-sm-12\">\n <div class=\"jumbotron jumbotron-fluid py-3\">\n <div class=\"col-sm-12 col-md-12 col-lg-12\">\n <div class=\"oe-margin-b-10\">\n <span class=\"title\"><?php echo xlt('Reminders'); ?></span>\n </div>\n <?php\n // TajEmo Work by CB 2012/01/11 02:51:25 PM adding dated reminders\n // I am asuming that at this point security checks have been performed\n //require_once '../dated_reminders/dated_reminders.php';\n require_once '../dated_reminders/dated_reminders.php';\n ?>\n </div>\n </div>\n </div>\n </div><!--end of reminders div-->\n <div class=\"row oe-display\" id=\"recalls-div\">\n <div class=\"col-sm-12\">\n <div class=\"jumbotron jumbotron-fluid py-3\">\n <?php if ($GLOBALS['disable_rcb'] != '1') { ?>\n <div class=\"col-sm-6 col-md-6 col-lg-6\">\n <div class=\"dr_container\">\n <span class=\"title\"><?php echo xlt('Recalls'); ?></span>\n <br/><br/>\n <button class=\"btn btn-primary btn-add\" onclick=\"goReminderRecall('addRecall');\"><?php echo xlt('New Recall'); ?></button>\n <a class=\"btn btn-secondary btn-transmit\" onclick=\"goReminderRecall('Recalls');\"><span><?php echo xlt('Recall Board'); ?></span></a>\n \n </div>\n </div>\n <?php } ?>\n </div>\n </div>\n </div><!--end of recalls div-->\n <div class=\"row oe-display\" id=\"sms-div\">\n <div class=\"col-sm-12\">\n <div class=\"jumbotron jumbotron-fluid py-3\">\n <?php if ($logged_in) { ?>\n <div class=\"col-sm-4 col-md-4 col-lg-4\">\n <span class=\"title\"><?php echo xlt('SMS Zone'); ?></span>\n <br/><br/>\n <form id=\"smsForm\" class=\"input-group\">\n <select id=\"SMS_patient\" type=\"text\" class=\"form-control m-0 w-100\" placeholder=\"<?php echo xla(\"Patient Name\"); ?>\" > </select>\n <span class=\"input-group-addon\" onclick=\"SMS_direct();\"><i class=\"fas fa-phone\"></i></span>\n <input type=\"hidden\" id=\"sms_pid\" />\n <input type=\"hidden\" id=\"sms_mobile\" value=\"\" />\n <input type=\"hidden\" id=\"sms_allow\" value=\"\" />\n </form>\n </div>\n <?php } ?>\n </div>\n </div>\n </div><!--end of sms div-->\n </div><!--end of container div-->\n <?php $oemr_ui->oeBelowContainerDiv();?>\n <?php\n //home of the help modal ;)\n //$GLOBALS['enable_help'] = 0; // Please comment out line if you want help modal to function on this page\n if ($GLOBALS['enable_help'] == 1) {\n echo \"<script>var helpFile = 'message_center_help.php'</script>\";\n //help_modal.php lives in interface, set path accordingly\n require \"../../help_modal.php\";\n }\n ?>\n <script>\n var collectvalidation = <?php echo $collectthis; ?>;",
" $(function () {\n var webRoot = <?php echo js_escape($GLOBALS['web_root']); ?>;\n $(\"#reminders-div\").hide();\n $(\"#recalls-div\").hide();\n $(\"#sms-div\").hide();\n $(\"#messages-li\").click(function(){\n $(\"#messages-div\").show(250);\n $(\"#reminders-div\").hide(250);\n $(\"#recalls-div\").hide(250);\n $(\"#sms-div\").hide(250);\n $(\"#messages-li\").addClass(\"active\");\n $(\"#reminders-li\").removeClass(\"active\");\n $(\"#recalls-li\").removeClass(\"active\");\n $(\"#sms-li\").removeClass(\"active\");",
" });\n $(\"#reminders-li\").click(function(){\n $(\"#messages-div\").hide(250);\n $(\"#reminders-div\").show(250);\n $(\"#recalls-div\").hide(250);\n $(\"#sms-div\").hide(250);\n $(\"#reminders-li\").addClass(\"active\");\n $(\"#messages-li\").removeClass(\"active\");\n $(\"#recalls-li\").removeClass(\"active\");\n $(\"#sms-li\").removeClass(\"active\");\n });\n $(\"#recalls-li\").click(function(){\n $(\"#messages-div\").hide(250);\n $(\"#reminders-div\").hide(250);\n $(\"#recalls-div\").show(250);\n $(\"#sms-div\").hide(250);\n $(\"#reminders-li\").removeClass(\"active\");\n $(\"#messages-li\").removeClass(\"active\");\n $(\"#recalls-li\").addClass(\"active\");\n $(\"#sms-li\").removeClass(\"active\");\n });\n $(\"#sms-li\").click(function(){\n $(\"#messages-div\").hide(250);\n $(\"#reminders-div\").hide(250);\n $(\"#recalls-div\").hide(250);\n $(\"#sms-div\").show(250);\n $(\"#reminders-li\").removeClass(\"active\");\n $(\"#messages-li\").removeClass(\"active\");\n $(\"#recalls-li\").removeClass(\"active\");\n $(\"#sms-li\").addClass(\"active\");\n });",
" $('.datetimepicker').datetimepicker({\n <?php $datetimepicker_timepicker = true; ?>\n <?php $datetimepicker_showseconds = false; ?>\n <?php $datetimepicker_formatInput = true; ?>\n <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>\n ,minDate : 0 //only future\n })",
" <?php if ($GLOBALS['phimail_enable']) : ?>\n $('.trusted-messages-force-check').click(function() {\n window.top.restoreSession();\n request = new FormData;\n request.append(\"ajax\", \"1\");\n request.append(\"csrf_token_form\", <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>);\n request.append(\"background_service\", \"phimail\");\n request.append(\"background_force\", \"1\");\n fetch(webRoot + \"/library/ajax/execute_background_services.php\", {\n method: 'POST',\n credentials: 'same-origin',\n body: request\n }).then((response) => {\n if (response.status !== 200) {\n console.log('Background Service refresh failed. Status Code: ' + response.status);\n } else {\n // we've refreshed give them time to reload the page\n setTimeout(function() {\n window.location.reload();\n }, 500);\n }\n }).catch(function(error) {\n console.log('Background Service refresh failed: ', error);\n alert(window.xl(\"Check new messages failed. Check the server logs for more information.\"));\n });\n });\n <?php endif; ?>",
" });\n $(function () {\n $( \"ul.navbar-nav\" ).children().click(function(){\n $(\".collapse\").collapse('hide');\n });\n });\n $(function () {\n $('#see-all-tooltip').attr({\"title\": <?php echo xlj('Click to show messages for all users'); ?>, \"data-toggle\":\"tooltip\", \"data-placement\":\"bottom\"}).tooltip();\n $('#just-mine-tooltip').attr({\"title\": <?php echo xlj('Click to show messages for only the current user'); ?>, \"data-toggle\":\"tooltip\", \"data-placement\":\"bottom\"}).tooltip();\n });\n $(function () {\n var f = $(\"#smsForm\");\n $(\"#SMS_patient\").select2({\n ajax: {\n url: \"save.php\",\n dataType: 'json',\n data: function(params) {\n return {\n go: \"sms_search\",\n term: params.term\n };\n },\n processResults: function(data) {\n return {\n results: $.map(data, function(item, index) {\n return {\n text: item.value,\n id: index,\n value: item.Label + ' ' + item.mobile,\n pid: item.pid,\n mobile: item.mobile,\n allow: item.allow\n }\n })\n };\n },\n cache: true\n }\n })",
" $('#SMS_patient').on('select2:select', function (e) {\n e.preventDefault();\n $(\"#SMS_patient\").val(e.params.data.value);\n $(\"#sms_pid\").val(e.params.data.pid);\n $(\"#sms_mobile\").val(e.params.data.mobile);\n $(\"#sms_allow\").val(e.params.data.allow);\n });\n })",
" $(function () {",
" $(\"#newnote\").click(function (event) {\n NewNote(event);\n });",
" $(\"#printnote\").click(function () {\n PrintNote();\n });",
" var obj = $(\"#form_message_status\");\n obj.onchange = function () {\n SaveNote();\n };",
" $(\"#cancel\").click(function () {\n CancelNote();\n });",
" $(\"#form_patient\").focus();",
" //clear button in messages\n $(\"#clear_user\").click(function(){\n $(\"#assigned_to_text\").val(\"<?php echo xls('Select Users From The Dropdown List'); ?>\");\n $(\"#assigned_to\").val(\"\");\n $(\"#users\").val(\"--\");\n });",
" //clear inputs of patients\n $(\"#clear_patients\").click(function(){\n $(\"#reply_to\").val(\"\");\n $(\"#form_patient\").val(\"\");\n });\n });",
" var NewNote = function (event) {\n top.restoreSession();\n if(document.getElementById(\"form_message_status\").value !== 'Done'){\n collectvalidation.assigned_to = {\n presence: {message: \"<?php echo xls('Recipient required unless status is Done'); ?>\"}\n }\n }\n else{\n delete collectvalidation.assigned_to;\n }",
" $('#newnote').attr('disabled', true);",
" var submit = submitme(1, event, 'new_note', collectvalidation);\n if(!submit){\n $('#newnote').attr('disabled', false);\n }\n else {\n $(\"#new_note\").submit();\n }\n };\n var PrintNote = function () {\n <?php if ($noteid) { ?>\n top.restoreSession();\n window.open('../../patient_file/summary/pnotes_print.php?noteid=' + <?php echo js_url($noteid); ?>, '_blank', 'resizable=1,scrollbars=1,width=600,height=500');\n <?php } ?>",
" };",
" var SaveNote = function () {\n <?php if ($noteid) { ?>\n top.restoreSession();\n $(\"#task\").val(\"save\");\n $(\"#new_note\").submit();\n <?php } ?>\n };",
" var CancelNote = function () {\n top.restoreSession();\n $(\"#task\").val(\"\");\n $(\"#new_note\").submit();\n };",
" // This is for callback by the find-patient popup.\n function setpatient(pid, lname, fname, dob) {\n var f = document.getElementById('new_note');\n f.form_patient.value += lname + ', ' + fname + '; ';\n f.reply_to.value += pid + ';';\n <?php if ($noteid) { ?>\n //used when direct messaging service inserts a pnote with indeterminate patient\n //to allow the user to assign the message to a patient.\n top.restoreSession();\n $(\"#task\").val(\"savePatient\");\n $(\"#new_note\").submit();\n <?php } ?>\n }",
" // This is for callback by the multi_patients_finder popup.\n function setMultiPatients(patientsList) {\n var f = document.getElementById('new_note');\n f.form_patient.value='';\n f.reply_to.value='';\n $.each(patientsList, function (key, patient) {\n f.form_patient.value += patient.lname + ', ' + patient.fname + '; ';\n f.reply_to.value += patient.pid + ';';\n })",
" <?php if ($noteid) { ?>\n //used when direct messaging service inserts a pnote with indeterminate patient\n //to allow the user to assign the message to a patient.\n top.restoreSession();\n $(\"#task\").val(\"savePatient\");\n $(\"#new_note\").submit();\n <?php } ?>\n }",
" // This invokes the find-patient popup.\n function sel_patient() {\n dlgopen('../../main/calendar/find_patient_popup.php', '_blank', 625, 400);\n }",
" function multi_sel_patient() {\n $('#reply_to').trigger('click');\n var url = '../../main/finder/multi_patients_finder.php'\n // for edit selected list\n if ($('#reply_to').val() !== '') {\n url = url + '?patients=' + $('#reply_to').val() + '&csrf_token_form=<?php echo attr_url(CsrfUtils::collectCsrfToken()); ?>';\n }\n dlgopen(url, '_blank', 625, 400);\n }",
" function addtolist(sel) {\n $('#assigned_to').trigger(\"click\");\n var itemtext = document.getElementById('assigned_to_text');\n var item = document.getElementById('assigned_to');\n if (sel.value !== '--') {\n if (item.value) {\n if (item.value.indexOf(sel.value) === -1) {\n itemtext.value = itemtext.value + ' ; ' + sel.options[sel.selectedIndex].text;\n item.value = item.value + ';' + sel.value;\n }\n } else {\n itemtext.value = sel.options[sel.selectedIndex].text;\n item.value = sel.value;\n }\n }\n }",
" function SMS_direct() {\n var pid = $(\"#sms_pid\").val();\n var m = $(\"#sms_mobile\").val();\n var allow = $(\"#sms_allow\").val();\n if ((pid === '') || (m === '')) {\n alert('<?php echo xls(\"MedEx needs a valid mobile number to send SMS messages...\"); ?>');\n } else if (allow === 'NO') {\n alert('<?php echo xls(\"This patient does not allow SMS messaging!\"); ?>');\n } else {\n top.restoreSession();\n window.open('messages.php?nomenu=1&go=SMS_bot&pid=' + encodeURIComponent(pid) + '&m=' + encodeURIComponent(m), 'SMS_bot', 'width=370,height=600,resizable=0');\n }\n }\n </script>\n <?php\n}\n?>\n</body>\n</html>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [119, 252, 57, 694], "buggy_code_start_loc": [118, 251, 56, 683], "filenames": ["interface/main/messages/messages.php", "interface/main/messages/save.php", "interface/patient_file/front_payment_cc.php", "library/classes/TreeMenu.php"], "fixing_code_end_loc": [119, 252, 57, 694], "fixing_code_start_loc": [118, 251, 56, 683], "message": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:open-emr:openemr:*:*:*:*:*:*:*:*", "matchCriteriaId": "C397DED6-5350-43A0-B65D-FB92E8587CED", "versionEndExcluding": "7.0.0.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2."}], "evaluatorComment": null, "id": "CVE-2022-4503", "lastModified": "2022-12-16T15:11:19.380", "metrics": {"cvssMetricV2": null, "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:N", "version": "3.0"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-12-15T01:15:10.937", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/4cba644c-a2f5-4ed7-af5d-f2cab1895e13"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, "type": "CWE-79"}
| 365
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/**\n * Message and Reminder Center UI\n *\n * @Package OpenEMR\n * @link http://www.open-emr.org\n * @author OpenEMR Support LLC\n * @author Roberto Vasquez <robertogagliotta@gmail.com>\n * @author Rod Roark <rod@sunsetsystems.com>\n * @author Brady Miller <brady.g.miller@gmail.com>\n * @author Ray Magauran <magauran@medfetch.com>\n * @author Tyler Wrenn <tyler@tylerwrenn.com>\n * @copyright Copyright (c) 2010 OpenEMR Support LLC\n * @copyright Copyright (c) 2017 MedEXBank.com\n * @copyright Copyright (c) 2018-2019 Brady Miller <brady.g.miller@gmail.com>\n * @copyright Copyright (c) 2020 Tyler Wrenn <tyler@tylerwrenn.com>\n * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3\n */",
"require_once(\"../../globals.php\");\nrequire_once(\"$srcdir/pnotes.inc\");\nrequire_once(\"$srcdir/patient.inc\");\nrequire_once(\"$srcdir/options.inc.php\");\nrequire_once(\"$srcdir/gprelations.inc.php\");\nrequire_once \"$srcdir/user.inc\";\nrequire_once(\"$srcdir/MedEx/API.php\");",
"use OpenEMR\\Common\\Acl\\AclMain;\nuse OpenEMR\\Common\\Csrf\\CsrfUtils;\nuse OpenEMR\\Common\\Logging\\EventAuditLogger;\nuse OpenEMR\\Core\\Header;\nuse OpenEMR\\OeUI\\OemrUI;",
"//Gets validation rules from Page Validation list.\n$collectthis = collectValidationPageRules(\"/interface/main/messages/messages.php\");\nif (empty($collectthis)) {\n $collectthis = \"{}\";\n} else {\n $collectthis = json_sanitize($collectthis[array_keys($collectthis)[0]][\"rules\"]);\n}",
"$MedEx = new MedExApi\\MedEx('MedExBank.com');",
"if ($GLOBALS['medex_enable'] == '1') {\n if ($_REQUEST['SMS_bot']) {\n $result = $MedEx->login('');\n $MedEx->display->SMS_bot($result);\n exit();\n }\n $logged_in = $MedEx->login();\n} else {\n $logged_in = null;\n}",
"$setting_bootstrap_submenu = prevSetting('', 'setting_bootstrap_submenu', 'setting_bootstrap_submenu', ' ');\n//use $uspfx as the first variable for page/script specific user settings instead of '' (which is like a global but you have to request it).\n$uspfx = substr(__FILE__, strlen($webserver_root)) . '.';\n$rcb_selectors = prevSetting($uspfx, 'rcb_selectors', 'rcb_selectors', 'block');\n$rcb_facility = prevSetting($uspfx, 'form_facility', 'form_facility', '');\n$rcb_provider = prevSetting($uspfx, 'form_provider', 'form_provider', $_SESSION['authUserID']);",
"if (\n (array_key_exists('setting_bootstrap_submenu', $_POST)) ||\n (array_key_exists('rcb_selectors', $_POST))\n) {\n // These are not form elements. We only ever change them via ajax, so exit now.\n exit();\n}\n?>\n<!DOCTYPE html>\n<html>\n<head>\n <?php\n //validation library\n $use_validate_js = 1;\n require_once($GLOBALS['srcdir'] . \"/validation/validation_script.js.php\");\n ?>\n <meta charset=\"utf-8\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n <meta name=\"description\" content=\"MedEx Bank\" />\n <meta name=\"author\" content=\"OpenEMR: MedExBank\" />\n <?php Header::setupHeader(['datetime-picker', 'opener', 'moment', 'select2']); ?>\n <link rel=\"stylesheet\" href=\"<?php echo $webroot; ?>/interface/main/messages/css/reminder_style.css?v=<?php echo $v_js_includes; ?>\">",
" <script>\n var xljs1 = '<?php echo xla('Preferences updated successfully'); ?>';\n var format_date_moment_js = '<?php echo attr(DateFormatRead(\"validateJS\")); ?>';\n <?php require_once \"$srcdir/restoreSession.php\"; ?>\n </script>",
" <script src=\"<?php echo $GLOBALS['web_root']; ?>/interface/main/messages/js/reminder_appts.js?v=<?php echo $v_js_includes; ?>\"></script>\n <style>\n @media only screen and (max-width: 768px) {\n [class*=\"col-\"] {\n width: 100%;\n text-align: left !important;\n }",
" .icon-bar {\n background-color: var(--danger);\n }\n }\n </style>",
"<?php\nif (($GLOBALS['medex_enable'] == '1') && (empty($_REQUEST['nomenu'])) && ($GLOBALS['disable_rcb'] != '1')) {\n $MedEx->display->navigation($logged_in);\n echo \"<br /><br /><br />\";\n}",
"if (!empty($_REQUEST['go'])) { ?>\n <?php\n if (($_REQUEST['go'] == \"setup\") && (!$logged_in)) {\n echo \"<title>\" . xlt('MedEx Setup') . \"</title>\";\n $stage = $_REQUEST['stage'];\n if (!is_numeric($stage)) {",
" echo \"<br /><span class='title'>\" . text($stage) . \" \" . xlt('Warning') . \": \" . xlt('This is not a valid request') . \".</span>\";",
" } else {\n $MedEx->setup->MedExBank($stage);\n }\n } elseif ($_REQUEST['go'] == \"addRecall\") {\n echo \"<title>\" . xlt('New Recall') . \"</title>\";\n $MedEx->display->display_add_recall();\n } elseif ($_REQUEST['go'] == 'Recalls') {\n echo \"<title>\" . xlt('Recall Board') . \"</title>\";\n $MedEx->display->display_recalls($logged_in);\n } elseif ((($_REQUEST['go'] == \"setup\") || ($_REQUEST['go'] == 'Preferences')) && ($logged_in)) {\n echo \"<title>MedEx: \" . xlt('Preferences') . \"</title>\";\n $MedEx->display->preferences();\n } elseif ($_REQUEST['go'] == 'icons') {\n echo \"<title>MedEx: \" . xlt('Icons') . \"Ⓒ</title>\";\n $MedEx->display->icon_template();\n } elseif ($_REQUEST['go'] == 'SMS_bot') {\n echo \"<title>MedEx: SMS BotⒸ</title>\";\n $MedEx->display->SMS_bot($logged_in);\n exit;\n } else {\n echo \"<title>\" . xlt('MedEx Setup') . \"</title>\";\n echo xlt('Warning: Navigation error. Please refresh this page.');\n }\n} else {\n //original message.php stuff",
" if ($GLOBALS['enable_help'] == 1) {\n $help_icon = '<a class=\"float-right oe-help-redirect\" data-target=\"#myModal\" data-toggle=\"modal\" href=\"#\" id=\"help-href\" name=\"help-href\" style=\"color: var(--gray)\" title=\"' . xla(\"Click to view Help\") . '\"><i class=\"fa fa-question-circle\" aria-hidden=\"true\"></i></a>';\n } elseif ($GLOBALS['enable_help'] == 2) {\n $help_icon = '<a class=\"float-right oe-help-redirect\" data-target=\"#myModal\" data-toggle=\"modal\" href=\"#\" id=\"help-href\" name=\"help-href\" style=\"color: var(--gray300) !important\" title=\"' . xla(\"To enable help - Go to Administration > Globals > Features > Enable Help Modal\") . '\"><i class=\"fa fa-question-circle\" aria-hidden=\"true\"></i></a>';\n } elseif ($GLOBALS['enable_help'] == 0) {\n $help_icon = '';\n }\n $heading_caption = xlt('Messages') . ', ' . xlt('Reminders');\n if ($GLOBALS['disable_rcb'] != '1') {\n $heading_caption .= ', ' . xlt('Recalls');\n }",
" $arrOeUiSettings = array(\n 'heading_title' => $heading_caption,\n 'include_patient_name' => false,// use only in appropriate pages\n 'expandable' => false,\n 'expandable_files' => array(\"\"),//all file names need suffix _xpd\n 'action' => \"\",//conceal, reveal, search, reset, link or back\n 'action_title' => \"\",\n 'action_href' => \"\",//only for actions - reset, link or back\n 'show_help_icon' => true,\n 'help_file_name' => \"message_center_help.php\"\n );\n $oemr_ui = new OemrUI($arrOeUiSettings);",
" echo \"<title>\" . xlt('Message Center') . \"</title>\";\n ?>\n</head>\n<body class='body_top'>\n <div id=\"container_div\" class=\"<?php echo attr($oemr_ui->oeContainer()); ?>\">\n <div class=\"row\">\n <div class=\"col-sm-12\">\n <div class=\"clearfix\">\n <?php echo $oemr_ui->pageHeading() . \"\\r\\n\"; ?>\n </div>\n </div>\n </div>\n <div class=\"container-fluid mb-3\">\n <ul class=\"nav nav-pills\">\n <li class=\"nav-item\" id='li-mess'>\n <a href='#' class=\"active nav-link font-weight-bold\" id='messages-li'><?php echo xlt('Messages'); ?></a>\n </li>\n <li class=\"nav-item\" id='li-remi'>\n <a href='#' id='reminders-li' class=\"nav-link font-weight-bold\"><?php echo xlt('Reminders'); ?></a>\n </li>\n <?php if ($GLOBALS['disable_rcb'] != '1') { ?>\n <li class=\"nav-item\" id='li-reca'>\n <a href='#' id='recalls-li' class=\"nav-link font-weight-bold\"><?php echo xlt('Recalls'); ?></a>\n </li>\n <?php }?>\n <?php if ($logged_in) { ?>\n <li class=\"nav-item\" id='li-sms'>\n <a href='#' id='sms-li' class=\"nav-link font-weight-bold\"><?php echo xlt('SMS Zone'); ?></a>\n </li>\n <?php }?>\n </ul>\n </div>\n <div class=\"row\" id=\"messages-div\">\n <div class=\"col-sm-12\">\n <div class=\"jumbotron jumbotron-fluid py-3\">\n <div class=\"col-sm-12 col-md-12 col-lg-12\">\n <?php\n // Check to see if the user has Admin rights, and if so, allow access to See All.\n $showall = isset($_GET['show_all']) ? $_GET['show_all'] : \"\";\n if ($showall == \"yes\") {\n $show_all = $showall;\n } else {\n $show_all = \"no\";\n }\n // Collect active variable and applicable html code for links\n $form_active = (isset($_REQUEST['form_active']) ? $_REQUEST['form_active'] : false);\n $form_inactive = (isset($_REQUEST['form_inactive']) ? $_REQUEST['form_inactive'] : false);\n if ($form_active) {\n $active = '1';\n $activity_string_html = 'form_active=1';\n } elseif ($form_inactive) {\n $active = '0';\n $activity_string_html = 'form_inactive=1';\n } else {\n $active = 'all';\n $activity_string_html = '';\n }\n //collect the task setting\n $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : \"\";\n if (AclMain::aclCheckCore('admin', 'super')) {\n if ($show_all == 'yes') {\n $showall = \"yes\";\n $lnkvar = \"messages.php?show_all=no&\" . $activity_string_html;\n $lnkattributes = \"name='Just Mine' onclick='top.restoreSession()'\";\n $otherstuff = \"<i id='just-mine-tooltip' class='fa fa-user fa-lg text-body' aria-hidden='true'></i>\";\n $messages = xl('All Messages');\n } else {\n $showall = \"no\";\n $lnkvar = \"messages.php?show_all=yes&\" . $activity_string_html;\n $lnkattributes = \"name='See All' onclick='top.restoreSession()'\";\n $otherstuff = \"<i id='see-all-tooltip' class='fa fa-users fa-lg text-body' aria-hidden='true'></i>\";\n $messages = xl('My Messages');\n }\n } else {\n $messages = xlt('My Messages');\n }\n ?>\n <div class=\"oe-margin-b-20\">\n <span class=\"title\"><?php echo text($messages); ?></span>\n <a class='more' href=\"<?php echo $lnkvar ?? ''; ?>\" <?php echo $lnkattributes ?? ''; ?>><?php echo $otherstuff ?? ''; ?></a>\n </div>\n <div class=\"oe-margin-b-10\">\n <?php\n //show the activity links\n if (empty($task) || $task == \"add\" || $task == \"delete\") { ?>\n <?php if ($active == \"all\") { ?>\n <span class=\"font-weight-bold\"><?php echo xlt('All Messages'); ?></span>\n <?php } else { ?>\n <a href=\"messages.php\" class=\"link btn btn-secondary\" onclick=\"top.restoreSession()\"><?php echo xlt('Show All'); ?></a>\n <?php } ?>\n |\n <?php if ($active == '1') { ?>\n <span class=\"font-weight-bold\"><?php echo xlt('Active Messages'); ?></span>\n <?php } else { ?>\n <a href=\"messages.php?form_active=1\" class=\"link btn btn-secondary\" onclick=\"top.restoreSession()\"><?php echo xlt('Show Active'); ?></a>\n <?php } ?>\n |\n <?php if ($active == '0') { ?>\n <span class=\"font-weight-bold\"><?php echo xlt('Inactive Messages'); ?></span>\n <?php } else { ?>\n <a href=\"messages.php?form_inactive=1\" class=\"link btn btn-secondary\" onclick=\"top.restoreSession()\"><?php echo xlt('Show Inactive'); ?></a>\n <?php } ?>\n <?php } ?>\n </div>\n <?php\n $note = '';\n $noteid = '';\n $title = '';\n $form_message_status = '';\n $reply_to = '';\n $patientname = '';\n switch ($task) {\n case \"add\":\n // Add a new message for a specific patient; the message is documented in Patient Notes.\n // Add a new message; it's treated as a new note in Patient Notes.\n $note = $_POST['note'];\n $noteid = $_POST['noteid'];\n $form_note_type = $_POST['form_note_type'];\n $form_message_status = $_POST['form_message_status'];\n $reply_to = explode(';', rtrim($_POST['reply_to'], ';'));\n $assigned_to_list = explode(';', $_POST['assigned_to']);\n $datetime = isset($_POST['form_datetime']) ? DateTimeToYYYYMMDDHHMMSS($_POST['form_datetime']) : '';\n foreach ($assigned_to_list as $assigned_to) {\n if ($noteid && $assigned_to != '-patient-') {\n updatePnote($noteid, $note, $form_note_type, $assigned_to, $form_message_status, $datetime);\n $noteid = '';\n } else {\n if ($noteid && $assigned_to == '-patient-') {\n // When $assigned_to == '-patient-' we don't update the current note, but\n // instead create a new one with the current note's body prepended and\n // attributed to the patient. This seems to be all for the patient portal.\n $row = getPnoteById($noteid);\n if (!$row) {\n die(\"getPnoteById() did not find id '\" . text($noteid) . \"'\");\n }\n $pres = sqlQuery(\"SELECT lname, fname \" .\n \"FROM patient_data WHERE pid = ?\", array($reply_to[0]));\n $patientname = $pres['lname'] . \", \" . $pres['fname'];\n $note .= \"\\n\\n$patientname on \" . $row['date'] . \" wrote:\\n\\n\";\n $note .= $row['body'];\n }\n // There's no note ID, and/or it's assigned to the patient.\n // In these cases a new note is created.\n foreach ($reply_to as $patient) {\n addPnote($patient, $note, $userauthorized, '1', $form_note_type, $assigned_to, $datetime, $form_message_status);\n }\n }\n }\n break;\n case \"savePatient\":\n case \"save\":\n // Update alert.\n $noteid = $_POST['noteid'];\n $form_message_status = $_POST['form_message_status'];\n $reply_to = $_POST['reply_to'];\n if ($task == \"save\") {\n updatePnoteMessageStatus($noteid, $form_message_status);\n } else {\n updatePnotePatient($noteid, $reply_to);\n }\n $task = \"edit\";\n $note = $_POST['note'];\n $title = $_POST['form_note_type'];\n $reply_to = $_POST['reply_to'];\n break;\n case \"edit\":\n if ($noteid == \"\") {\n $noteid = $_GET['noteid'];\n }\n // Update the message if it already exists; it's appended to an existing note in Patient Notes.\n $result = getPnoteById($noteid);\n if ($result) {\n if ($title == \"\") {\n $title = $result['title'];\n }\n $body = $result['body'];\n // if our reply-to is 0 it breaks multi patient select and other functionality\n // this most likely didn't break before due to php implicit type conversion of 0 to \"\"\n if ($reply_to == \"\" && $result['pid'] != 0) {\n $reply_to = $result['pid'];\n }\n $form_message_status = $result['message_status'];\n $datetime = $result['date'];\n }\n break;\n case \"delete\":\n // Delete selected message(s) from the Messages box (only).\n $delete_id = $_POST['delete_id'];\n for ($i = 0; $i < count($delete_id); $i++) {\n deletePnote($delete_id[$i]);\n EventAuditLogger::instance()->newEvent(\"delete\", $_SESSION['authUser'], $_SESSION['authProvider'], 1, \"pnotes: id \" . $delete_id[$i]);\n }\n break;\n }\n // This is for sorting the records.\n $sort = array(\"users.lname\", \"patient_data.lname\", \"pnotes.title\", \"pnotes.date\", \"pnotes.message_status\");\n $sortby = (isset($_REQUEST['sortby']) && ($_REQUEST['sortby'] != \"\")) ? $_REQUEST['sortby'] : $sort[3];\n $sortorder = (isset($_REQUEST['sortorder']) && ($_REQUEST['sortorder'] != \"\")) ? $_REQUEST['sortorder'] : \"desc\";\n $begin = isset($_REQUEST['begin']) ? $_REQUEST['begin'] : 0;",
" if ($task == \"addnew\" or $task == \"edit\") {\n // Display the Messages page layout.\n echo \"<form name='form_patient' id='new_note'\n class='form-horizontal'\n action=\\\"messages.php?showall=\" . attr_url($showall) . \"&sortby=\" . attr_url($sortby) . \"&sortorder=\" . attr_url($sortorder) . \"&begin=\" . attr_url($begin) . \"&$activity_string_html\\\"\n method='post'>\n <input type='hidden' name='noteid' id='noteid' value='\" . attr($noteid) . \"' />\n <input type='hidden' name='task' id='task' value='add' />\";\n if ($task == \"addnew\") {\n $message_legend = xl('Create New Message');\n $onclick = \"onclick=multi_sel_patient()\";\n } elseif ($task == \"edit\") {\n $message_legend = xl('Add To Existing Message');\n $onclick = \"\";\n }",
" ?>\n <div class='col-md-12'>\n <div class=\"jumbotron jumbotron-fluid py-3\">\n <h4><?php echo text($message_legend); ?></h4>\n <div class=\"row\">\n <div class=\"col-12 oe-custom-line\">\n <div class=\"row\">\n <div class=\"col-6 col-md-3\">\n <label for=\"form_note_type\"><?php echo xlt('Type'); ?>:</label>\n <?php\n if ($title == \"\") {\n $title = \"Unassigned\";\n }\n // Added 6/2009 by BM to incorporate the patient notes into the list_options listings.\n generate_form_field(array('data_type' => 1, 'field_id' => 'note_type', 'list_id' => 'note_type', 'empty_title' => 'SKIP', 'order_by' => 'title', 'class' => 'form-control'), $title);\n ?>\n </div>\n <div class=\"col-6 col-md-3\">\n <label for=\"form_message_status\"><?php echo xlt('Status'); ?>:</label>\n <?php\n if ($form_message_status == \"\") {\n $form_message_status = 'New';\n }\n generate_form_field(array('data_type' => 1, 'field_id' => 'message_status', 'list_id' => 'message_status', 'empty_title' => 'SKIP', 'order_by' => 'title', 'class' => 'form-control'), $form_message_status); ?>\n </div>\n <div class=\"col-6 col-md-4\">\n <?php\n if ($task != \"addnew\" && $result['pid'] != 0) { ?>\n <a class=\"patLink\" onclick=\"goPid('<?php echo attr(addslashes($result['pid'])); ?>')\" title='<?php echo xla('Click me to Open Patient Dashboard') ?>'><?php echo xlt('Patient'); ?>:</a><label for=\"form_patient\"> </label>\n <?php\n } else { ?>\n <span class='font-weight-bold <?php echo($task == \"addnew\" ? \"text-danger\" : \"\") ?>'><?php echo xlt('Patient'); ?>:</span></a><label for=\"form_patient\"></label>\n <?php\n }",
" if ($reply_to) {\n $prow = sqlQuery(\"SELECT lname, fname,pid, pubpid, DOB \" .\n \"FROM patient_data WHERE pid = ?\", array($reply_to));\n $patientname = $prow['lname'] . \", \" . $prow['fname'];\n }\n if ($task == \"addnew\" || $result['pid'] == 0) {\n $cursor = \"oe-cursor-add\";\n $background = \"oe-patient-background\";\n } elseif ($task == \"edit\") {\n $cursor = \"oe-cursor-stop\";\n $background = '';\n }\n ?>\n <input type='text' id='form_patient' name='form_patient' class='form-control <?php echo $cursor . \" \" . $background;?>' onclick=\"multi_sel_patient()\" placeholder='<?php echo xla(\"Click to add patient\"); ?>' value='<?php echo attr($patientname); ?>' readonly />\n <input type='hidden' class=\"form-control\" name='reply_to' id='reply_to' value='<?php echo attr($reply_to); ?>'/>\n </div>\n <div class=\"col-6 col-md-2 d-flex flex-wrap\">\n <?php\n if ($task == \"addnew\" || $result['pid'] == 0) {\n echo \"<label class='oe-empty-label' for='clear_patients'></label>\";\n echo '<button type=\"button\" id=\"clear_patients\" class=\"btn btn-secondary btn-undo float-left flip\" value=\"' . xla('Clear') . '\">' . xlt(\"Clear\") . '</button>';\n } ?>\n </div>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-12 oe-custom-line\">\n <div class=\"row\">\n <?php if ($GLOBALS['messages_due_date']) { ?>\n <div class=\"col-6 col-sm-2\">\n <label for=\"form_note_type\"><?php echo xlt('Due date'); ?>:</label>\n <?php generate_form_field(array('data_type' => 4, 'field_id' => 'datetime', 'edit_options' => 'F'), empty($datetime) ? date('Y-m-d H:i') : $datetime) ?>\n </div>\n <?php } ?>\n <div class=\"col-6 col-sm-4 d-flex align-items-end flex-wrap\">\n <label for=\"assigned_to_text\"><?php echo xlt('To{{Destination}}'); ?>:</label>\n <input type='text' name='assigned_to_text' class='form-control oe-cursor-stop' id='assigned_to_text' readonly='readonly' value='' placeholder='<?php echo xla(\"SELECT Users FROM The Dropdown LIST\"); ?>' />\n <input type='hidden' name='assigned_to' id='assigned_to' />\n </div>\n <div class=\"col-6 col-sm-4\">\n <label class=\"oe-empty-label\" for=\"users\"></label>\n <select name='users' id='users' class='form-control' onchange='addtolist(this);'>\n <?php\n echo \"<option value='--'\";\n echo \">\" . xlt('Select User');\n echo \"</option>\\n\";\n $ures = sqlStatement(\"SELECT username, fname, lname FROM users \" .\n \"WHERE username != '' AND active = 1 AND \" .\n \"( info IS NULL OR info NOT LIKE '%Inactive%' ) \" .\n \"ORDER BY lname, fname\");\n while ($urow = sqlFetchArray($ures)) {\n echo \" <option value='\" . attr($urow['username']) . \"'\";\n echo \">\" . text($urow['lname']);\n if ($urow['fname']) {\n echo \", \" . text($urow['fname']);\n }\n echo \"</option>\\n\";\n }\n ?>\n </select>\n </div>\n <div class=\"col-6 col-sm-2 d-flex align-items-end flex-wrap\">\n <label class=\"oe-empty-label\" for=\"users\"></label>\n <button type=\"button\" name=\"clear_user\" id=\"clear_user\" class=\"btn btn-secondary btn-undo float-left flip\" value=\"<?php echo xla('Clear'); ?>\"><?php echo xlt('Clear'); ?></button>\n </div>\n </div>\n <div class='col-12 oe-margin-t-3'>\n <?php\n if ($noteid) {\n include \"templates/linked_documents.php\";",
" // Get the related procedure order IDs if any.\n $tmp = sqlStatement(\n \"SELECT id1 FROM gprelations WHERE \" .\n \"type1 = ? AND type2 = ? AND id2 = ?\",\n array('2', '6', $noteid)\n );\n if (sqlNumRows($tmp)) {\n echo \" <tr>\\n\";\n echo \" <td class='text'><span class='font-weight-bold'>\" . xlt('Linked procedure order') . \":</span>\\n\";\n while ($gprow = sqlFetchArray($tmp)) {\n echo \" <a href='\";\n echo $GLOBALS['webroot'] . \"/interface/orders/single_order_results.php?orderid=\";\n echo attr_url($gprow['id1']);\n echo \"' target='_blank' onclick='top.restoreSession()'>\";\n echo text($gprow['id1']);\n echo \"</a>\\n\";\n }\n echo \" </td>\\n\";\n echo \" </tr>\\n\";\n }\n }\n ?>\n </div>\n </div>\n <!-- <div class=\"row\"> -->\n <div class='col-12'>\n <?php",
" if ($noteid) {\n $body = preg_replace('/(:\\d{2}\\s\\()' . $result['pid'] . '(\\sto\\s)/', '${1}' . $patientname . '${2}', $body);\n $body = preg_replace('/(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}\\s\\([^)(]+\\s)(to)(\\s[^)(]+\\))/', '${1}' . xl('to{{Destination}}') . '${3}', $body);\n $body = pnoteConvertLinks(nl2br(text(oeFormatPatientNote($body))));\n echo \"<div style='height: 120px; resize: vertical;' class='border overflow-auto text oe-margin-t-3 p-2 mb-2 w-100'>\" . $body . \"</div>\";\n }",
" ?>\n <textarea name='note' id='note' class='form-control oe-margin-t-3 p-1' rows=\"5\"><?php echo nl2br(text($note)); ?></textarea>\n </div>\n <div class=\"col-12 position-override oe-margin-t-10\">\n <?php if ($noteid) { ?>\n <!-- This is for displaying an existing note. -->\n <button type=\"button\" class=\"btn btn-primary btn-send-msg\" id=\"newnote\" value=\"<?php echo xla('Send message'); ?>\"><?php echo xlt('Send message'); ?></button>\n <button type=\"button\" class=\"btn btn-primary btn-print\" id=\"printnote\" value=\"<?php echo xla('Print message'); ?>\"><?php echo xlt('Print message'); ?></button>\n <button type=\"button\" class=\"btn btn-secondary btn-cancel\" id=\"cancel\" value=\"<?php echo xla('Cancel'); ?>\"><?php echo xlt('Cancel'); ?></button>\n <?php } else { ?>\n <!-- This is for displaying a new note. -->\n <button type=\"button\" class=\"btn btn-primary btn-send-msg\" id=\"newnote\" value=\"<?php echo xla('Send message'); ?>\"><?php echo xlt('Send message'); ?></button>\n <button type=\"button\" class=\"btn btn-cancel btn-secondary\" id=\"cancel\" value=\"<?php echo xla('Cancel'); ?>\"><?php echo xlt('Cancel'); ?></button>\n <?php }\n ?>\n </div>\n <!-- </div> -->\n </div>\n </div>\n </form>\n <?php\n } else {\n for ($i = 0; $i < count($sort); $i++) {\n $sortlink[$i] = \"<a class='arrowhead' href=\\\"messages.php?show_all=\" . attr($showall) . \"&sortby=\" . attr($sort[$i]) . \"&sortorder=asc&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\" alt=\\\"\" . xla('Sort Up') . \"\\\"><i class='fa fa-sort-down fa-lg' aria-hidden='true'></i></a>\";\n }\n for ($i = 0; $i < count($sort); $i++) {\n if ($sortby == $sort[$i]) {\n switch ($sortorder) {\n case \"asc\":\n $sortlink[$i] = \"<a class='arrowhead' href=\\\"messages.php?show_all=\" . attr($showall) . \"&sortby=\" . attr($sortby) . \"&sortorder=desc&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\" alt=\\\"\" . xla('Sort Up') . \"\\\"><i class='fa fa-sort-up fa-lg' aria-hidden='true'></i></a>\";\n break;\n case \"desc\":\n $sortlink[$i] = \"<a class='arrowhead' href=\\\"messages.php?show_all=\" . attr($showall) . \"&sortby=\" . attr($sortby) . \"&sortorder=asc&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\" alt=\\\"\" . xla('Sort Down') . \"\\\"><i class='fa fa-sort-down fa-lg' aria-hidden='true'></i></a>\";\n break;\n } break;\n }\n }\n // Manage page numbering and display beneath the Messages table.\n $listnumber = 25;\n $total = getPnotesByUser($active, $show_all, $_SESSION['authUser'], true);\n if ($begin == \"\" or $begin == 0) {\n $begin = 0;\n }\n $prev = $begin - $listnumber;\n $next = $begin + $listnumber;\n $start = $begin + 1;\n $end = $listnumber + $start - 1;",
" $chevron_icon_left = $_SESSION['language_direction'] == 'ltr' ? 'fa-chevron-circle-left' : 'fa-chevron-circle-right';\n $chevron_icon_right = $_SESSION['language_direction'] == 'ltr' ? 'fa-chevron-circle-right' : 'fa-chevron-circle-left';",
" if ($end >= $total) {\n $end = $total;\n }\n if ($end < $start) {\n $start = 0;\n }\n if ($prev >= 0) {\n $prevlink = \"<a href=\\\"messages.php?show_all=\" . attr($showall) . \"&sortby=\" . attr($sortby) . \"&sortorder=\" . attr($sortorder) . \"&begin=\" . attr($prev) . \"&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\"><i class=\\\"fa \" . $chevron_icon_left . \" chevron_color\\\" aria-hidden=\\\"true\\\"></i></a>\";\n } else {\n $prevlink = \"<i class=\\\"fa \" . $chevron_icon_left . \" text-muted\\\" aria-hidden=\\\"true\\\" title=\\\"\" . xla(\"On first page\") . \"\\\"></i>\";\n }",
" if ($next < $total) {\n $nextlink = \"<a href=\\\"messages.php?show_all=\" . attr($showall) . \"&sortby=\" . attr($sortby) . \"&sortorder=\" . attr($sortorder) . \"&begin=\" . attr($next) . \"&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\"><i class=\\\"fa . $chevron_icon_right . chevron_color\\\" aria-hidden=\\\"true\\\"></i></a>\";\n } else {\n $nextlink = \"<i class=\\\"fa \" . $chevron_icon_right . \" text-muted\\\" aria-hidden=\\\"true\\\" title=\\\"\" . xla(\"On first page\") . \"\\\"></i>\";\n }\n // Display the Messages table header.\n echo \"\n <table class=\\\"w-100\\\">\n <tr>\n <td>\n <form name='MessageList' id='MessageList' action=\\\"messages.php?showall=\" . attr($showall) . \"&sortby=\" . attr($sortby) . \"&sortorder=\" . attr($sortorder) . \"&begin=\" . attr($begin) . \"&$activity_string_html\\\" method='post'>\n <table class='table table-sm table-hover w-100'>\n <input type='hidden' name='task' value='delete' />\n <thead class='table-primary'>\n <tr height='24'>\n <th align='center' width='25'><input type='checkbox' id='checkAll' onclick='selectAll()'></th>\n <th width='20%' class='font-weight-bold'> \" . xlt('From') . \" $sortlink[0]</th>\n <th width='20%' class='font-weight-bold'> \" . xlt('Patient') . \" $sortlink[1]</th>\n <th class='font-weight-bold'> \" . xlt('Type') . \" $sortlink[2]</th>\n <th width='15%' class='font-weight-bold'> \" . xlt($GLOBALS['messages_due_date'] ? 'Due date' : 'Date') . \" $sortlink[3]</th>\n <th width='15%' class='font-weight-bold'> \" . xlt('Status') . \" $sortlink[4]</th>\n </tr>\n </thead>\";\n // Display the Messages table body.\n $count = 0;\n $result = getPnotesByUser($active, $show_all, $_SESSION['authUser'], false, $sortby, $sortorder, $begin, $listnumber);\n while ($myrow = sqlFetchArray($result)) {\n $name = $myrow['user'];\n $name = $myrow['users_lname'];\n if ($myrow['users_fname']) {\n $name .= \", \" . $myrow['users_fname'];\n }\n $patient = $myrow['pid'];\n if ($patient > 0) {\n $patient = $myrow['patient_data_lname'];\n if ($myrow['patient_data_fname']) {\n $patient .= \", \" . $myrow['patient_data_fname'];\n }\n } else {\n $patient = \"* \" . xl('Patient must be set manually') . \" *\";\n }\n $count++;\n echo \"\n <tr id=\\\"row\" . attr($count) . \"\\\" height='24'>\n <td align='center'>\n <input type='checkbox' id=\\\"check\" . attr($count) . \"\\\" name=\\\"delete_id[]\\\" value=\\\"\" .\n attr($myrow['id']) . \"\\\" onclick=\\\"if(this.checked==true){ selectRow('row\" . attr(addslashes($count)) . \"'); }else{ deselectRow('row\" . attr(addslashes($count)) . \"'); }\\\"></td>\n <td>\n <div>\" . text($name) . \"</div>\n </td>\n <td>\n <div><a href=\\\"messages.php?showall=\" . attr_url($showall) . \"&sortby=\" . attr_url($sortby) . \"&sortorder=\" . attr_url($sortorder) . \"&begin=\" . attr_url($begin) . \"&task=edit¬eid=\" .\n attr_url($myrow['id']) . \"&$activity_string_html\\\" onclick=\\\"top.restoreSession()\\\">\" .\n text($patient) . \"</a></div>\n </td>\n <td>\n <div>\" .\n xlt($myrow['title']) . \"</div>\n <td>\n <div>\" . text(oeFormatDateTime($myrow['date'])) . \"</div>\n </td>\n <td>\n <div>\" . text(getListItemTitle('message_status', $myrow['message_status'])) . \"</div>\n </td>\n </tr>\";\n }\n // Display the Messages table footer.",
" echo \" </table>\n </form>\n <div class='row oe-margin-t-10'>",
" <div class=\\\"col-12 col-md-12 col-lg-12\\\"><a href=\\\"messages.php?showall=\" . attr_url($showall) . \"&sortby=\" . attr_url($sortby) . \"&sortorder=\" . attr_url($sortorder) . \"&begin=\" . attr_url($begin) . \"&task=addnew&$activity_string_html\\\" class=\\\"btn btn-primary btn-add\\\" onclick=\\\"top.restoreSession()\\\">\" .\n xlt('Add New{{Message}}') . \"</a> <a href=\\\"javascript:confirmDeleteSelected()\\\" class=\\\"btn btn-danger btn-delete\\\" onclick=\\\"top.restoreSession()\\\">\" .\n xlt('Delete') . \"</a>\";",
" if ($GLOBALS['phimail_enable']) {\n echo \" <a href='trusted-messages.php' onclick='top.restoreSession()' class='btn btn-secondary btn-mail'>\" . xlt(\"Compose Trusted Direct Message\") . \"</a>\";\n echo \" <button class='btn btn-secondary btn-refresh trusted-messages-force-check'>\" . xlt(\"Check New Trusted Messages\") . \"</button>\";\n }\n echo \"\n <div class=\\\"text-right\\\">$prevlink \" . text($end) . \" \" . xlt('of') . \" \" . text($total) . \" $nextlink</div>\n </div>\n </div>\n </td>\n </tr>\n </table>\n <br />\";\n ?>",
" <script>\n // This is to confirm delete action.\n function confirmDeleteSelected() {\n var int_checked = 0;\n var elem = document.forms.namedItem(\"MessageList\").getElementsByTagName(\"input\");",
" for (i=0; i < elem.length; i++){\n if(elem[i].checked == true){\n int_checked = ++int_checked;\n }\n }\n if (int_checked > 0){\n if (confirm(\"<?php echo xls('Do you really want to delete the selection?'); ?>\")) {\n document.MessageList.submit();\n }\n } else {\n alert(\"<?php echo xls('Please select message(s) to delete'); ?>\");\n }\n }",
"\n // This is to allow selection of all items in Messages table for deletion.\n function selectAll() {\n if (document.getElementById(\"checkAll\").checked === true) {\n document.getElementById(\"checkAll\").checked = true;<?php\n for ($i = 1; $i <= $count; $i++) {\n echo \"document.getElementById(\\\"check$i\\\").checked=true; document.getElementById(\\\"row$i\\\").style.background='var(--gray200)'; \";\n } ?>\n } else {\n document.getElementById(\"checkAll\").checked = false;<?php\n for ($i = 1; $i <= $count; $i++) {\n echo \"document.getElementById(\\\"check$i\\\").checked=false; document.getElementById(\\\"row$i\\\").style.background='var(--light)'; \";\n } ?>\n }\n }",
" // The two functions below are for managing row styles in Messages table.\n function selectRow(row) {\n document.getElementById(row).style.background = \"var(--gray200)\";\n }",
" function deselectRow(row) {\n document.getElementById(row).style.background = \"var(--light)\";\n }\n </script>\n <?php\n }\n ?>\n </div>\n </div>\n </div>\n </div><!--end of messages div-->\n <div class=\"row oe-display\" id=\"reminders-div\">\n <div class=\"col-sm-12\">\n <div class=\"jumbotron jumbotron-fluid py-3\">\n <div class=\"col-sm-12 col-md-12 col-lg-12\">\n <div class=\"oe-margin-b-10\">\n <span class=\"title\"><?php echo xlt('Reminders'); ?></span>\n </div>\n <?php\n // TajEmo Work by CB 2012/01/11 02:51:25 PM adding dated reminders\n // I am asuming that at this point security checks have been performed\n //require_once '../dated_reminders/dated_reminders.php';\n require_once '../dated_reminders/dated_reminders.php';\n ?>\n </div>\n </div>\n </div>\n </div><!--end of reminders div-->\n <div class=\"row oe-display\" id=\"recalls-div\">\n <div class=\"col-sm-12\">\n <div class=\"jumbotron jumbotron-fluid py-3\">\n <?php if ($GLOBALS['disable_rcb'] != '1') { ?>\n <div class=\"col-sm-6 col-md-6 col-lg-6\">\n <div class=\"dr_container\">\n <span class=\"title\"><?php echo xlt('Recalls'); ?></span>\n <br/><br/>\n <button class=\"btn btn-primary btn-add\" onclick=\"goReminderRecall('addRecall');\"><?php echo xlt('New Recall'); ?></button>\n <a class=\"btn btn-secondary btn-transmit\" onclick=\"goReminderRecall('Recalls');\"><span><?php echo xlt('Recall Board'); ?></span></a>\n \n </div>\n </div>\n <?php } ?>\n </div>\n </div>\n </div><!--end of recalls div-->\n <div class=\"row oe-display\" id=\"sms-div\">\n <div class=\"col-sm-12\">\n <div class=\"jumbotron jumbotron-fluid py-3\">\n <?php if ($logged_in) { ?>\n <div class=\"col-sm-4 col-md-4 col-lg-4\">\n <span class=\"title\"><?php echo xlt('SMS Zone'); ?></span>\n <br/><br/>\n <form id=\"smsForm\" class=\"input-group\">\n <select id=\"SMS_patient\" type=\"text\" class=\"form-control m-0 w-100\" placeholder=\"<?php echo xla(\"Patient Name\"); ?>\" > </select>\n <span class=\"input-group-addon\" onclick=\"SMS_direct();\"><i class=\"fas fa-phone\"></i></span>\n <input type=\"hidden\" id=\"sms_pid\" />\n <input type=\"hidden\" id=\"sms_mobile\" value=\"\" />\n <input type=\"hidden\" id=\"sms_allow\" value=\"\" />\n </form>\n </div>\n <?php } ?>\n </div>\n </div>\n </div><!--end of sms div-->\n </div><!--end of container div-->\n <?php $oemr_ui->oeBelowContainerDiv();?>\n <?php\n //home of the help modal ;)\n //$GLOBALS['enable_help'] = 0; // Please comment out line if you want help modal to function on this page\n if ($GLOBALS['enable_help'] == 1) {\n echo \"<script>var helpFile = 'message_center_help.php'</script>\";\n //help_modal.php lives in interface, set path accordingly\n require \"../../help_modal.php\";\n }\n ?>\n <script>\n var collectvalidation = <?php echo $collectthis; ?>;",
" $(function () {\n var webRoot = <?php echo js_escape($GLOBALS['web_root']); ?>;\n $(\"#reminders-div\").hide();\n $(\"#recalls-div\").hide();\n $(\"#sms-div\").hide();\n $(\"#messages-li\").click(function(){\n $(\"#messages-div\").show(250);\n $(\"#reminders-div\").hide(250);\n $(\"#recalls-div\").hide(250);\n $(\"#sms-div\").hide(250);\n $(\"#messages-li\").addClass(\"active\");\n $(\"#reminders-li\").removeClass(\"active\");\n $(\"#recalls-li\").removeClass(\"active\");\n $(\"#sms-li\").removeClass(\"active\");",
" });\n $(\"#reminders-li\").click(function(){\n $(\"#messages-div\").hide(250);\n $(\"#reminders-div\").show(250);\n $(\"#recalls-div\").hide(250);\n $(\"#sms-div\").hide(250);\n $(\"#reminders-li\").addClass(\"active\");\n $(\"#messages-li\").removeClass(\"active\");\n $(\"#recalls-li\").removeClass(\"active\");\n $(\"#sms-li\").removeClass(\"active\");\n });\n $(\"#recalls-li\").click(function(){\n $(\"#messages-div\").hide(250);\n $(\"#reminders-div\").hide(250);\n $(\"#recalls-div\").show(250);\n $(\"#sms-div\").hide(250);\n $(\"#reminders-li\").removeClass(\"active\");\n $(\"#messages-li\").removeClass(\"active\");\n $(\"#recalls-li\").addClass(\"active\");\n $(\"#sms-li\").removeClass(\"active\");\n });\n $(\"#sms-li\").click(function(){\n $(\"#messages-div\").hide(250);\n $(\"#reminders-div\").hide(250);\n $(\"#recalls-div\").hide(250);\n $(\"#sms-div\").show(250);\n $(\"#reminders-li\").removeClass(\"active\");\n $(\"#messages-li\").removeClass(\"active\");\n $(\"#recalls-li\").removeClass(\"active\");\n $(\"#sms-li\").addClass(\"active\");\n });",
" $('.datetimepicker').datetimepicker({\n <?php $datetimepicker_timepicker = true; ?>\n <?php $datetimepicker_showseconds = false; ?>\n <?php $datetimepicker_formatInput = true; ?>\n <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>\n ,minDate : 0 //only future\n })",
" <?php if ($GLOBALS['phimail_enable']) : ?>\n $('.trusted-messages-force-check').click(function() {\n window.top.restoreSession();\n request = new FormData;\n request.append(\"ajax\", \"1\");\n request.append(\"csrf_token_form\", <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>);\n request.append(\"background_service\", \"phimail\");\n request.append(\"background_force\", \"1\");\n fetch(webRoot + \"/library/ajax/execute_background_services.php\", {\n method: 'POST',\n credentials: 'same-origin',\n body: request\n }).then((response) => {\n if (response.status !== 200) {\n console.log('Background Service refresh failed. Status Code: ' + response.status);\n } else {\n // we've refreshed give them time to reload the page\n setTimeout(function() {\n window.location.reload();\n }, 500);\n }\n }).catch(function(error) {\n console.log('Background Service refresh failed: ', error);\n alert(window.xl(\"Check new messages failed. Check the server logs for more information.\"));\n });\n });\n <?php endif; ?>",
" });\n $(function () {\n $( \"ul.navbar-nav\" ).children().click(function(){\n $(\".collapse\").collapse('hide');\n });\n });\n $(function () {\n $('#see-all-tooltip').attr({\"title\": <?php echo xlj('Click to show messages for all users'); ?>, \"data-toggle\":\"tooltip\", \"data-placement\":\"bottom\"}).tooltip();\n $('#just-mine-tooltip').attr({\"title\": <?php echo xlj('Click to show messages for only the current user'); ?>, \"data-toggle\":\"tooltip\", \"data-placement\":\"bottom\"}).tooltip();\n });\n $(function () {\n var f = $(\"#smsForm\");\n $(\"#SMS_patient\").select2({\n ajax: {\n url: \"save.php\",\n dataType: 'json',\n data: function(params) {\n return {\n go: \"sms_search\",\n term: params.term\n };\n },\n processResults: function(data) {\n return {\n results: $.map(data, function(item, index) {\n return {\n text: item.value,\n id: index,\n value: item.Label + ' ' + item.mobile,\n pid: item.pid,\n mobile: item.mobile,\n allow: item.allow\n }\n })\n };\n },\n cache: true\n }\n })",
" $('#SMS_patient').on('select2:select', function (e) {\n e.preventDefault();\n $(\"#SMS_patient\").val(e.params.data.value);\n $(\"#sms_pid\").val(e.params.data.pid);\n $(\"#sms_mobile\").val(e.params.data.mobile);\n $(\"#sms_allow\").val(e.params.data.allow);\n });\n })",
" $(function () {",
" $(\"#newnote\").click(function (event) {\n NewNote(event);\n });",
" $(\"#printnote\").click(function () {\n PrintNote();\n });",
" var obj = $(\"#form_message_status\");\n obj.onchange = function () {\n SaveNote();\n };",
" $(\"#cancel\").click(function () {\n CancelNote();\n });",
" $(\"#form_patient\").focus();",
" //clear button in messages\n $(\"#clear_user\").click(function(){\n $(\"#assigned_to_text\").val(\"<?php echo xls('Select Users From The Dropdown List'); ?>\");\n $(\"#assigned_to\").val(\"\");\n $(\"#users\").val(\"--\");\n });",
" //clear inputs of patients\n $(\"#clear_patients\").click(function(){\n $(\"#reply_to\").val(\"\");\n $(\"#form_patient\").val(\"\");\n });\n });",
" var NewNote = function (event) {\n top.restoreSession();\n if(document.getElementById(\"form_message_status\").value !== 'Done'){\n collectvalidation.assigned_to = {\n presence: {message: \"<?php echo xls('Recipient required unless status is Done'); ?>\"}\n }\n }\n else{\n delete collectvalidation.assigned_to;\n }",
" $('#newnote').attr('disabled', true);",
" var submit = submitme(1, event, 'new_note', collectvalidation);\n if(!submit){\n $('#newnote').attr('disabled', false);\n }\n else {\n $(\"#new_note\").submit();\n }\n };\n var PrintNote = function () {\n <?php if ($noteid) { ?>\n top.restoreSession();\n window.open('../../patient_file/summary/pnotes_print.php?noteid=' + <?php echo js_url($noteid); ?>, '_blank', 'resizable=1,scrollbars=1,width=600,height=500');\n <?php } ?>",
" };",
" var SaveNote = function () {\n <?php if ($noteid) { ?>\n top.restoreSession();\n $(\"#task\").val(\"save\");\n $(\"#new_note\").submit();\n <?php } ?>\n };",
" var CancelNote = function () {\n top.restoreSession();\n $(\"#task\").val(\"\");\n $(\"#new_note\").submit();\n };",
" // This is for callback by the find-patient popup.\n function setpatient(pid, lname, fname, dob) {\n var f = document.getElementById('new_note');\n f.form_patient.value += lname + ', ' + fname + '; ';\n f.reply_to.value += pid + ';';\n <?php if ($noteid) { ?>\n //used when direct messaging service inserts a pnote with indeterminate patient\n //to allow the user to assign the message to a patient.\n top.restoreSession();\n $(\"#task\").val(\"savePatient\");\n $(\"#new_note\").submit();\n <?php } ?>\n }",
" // This is for callback by the multi_patients_finder popup.\n function setMultiPatients(patientsList) {\n var f = document.getElementById('new_note');\n f.form_patient.value='';\n f.reply_to.value='';\n $.each(patientsList, function (key, patient) {\n f.form_patient.value += patient.lname + ', ' + patient.fname + '; ';\n f.reply_to.value += patient.pid + ';';\n })",
" <?php if ($noteid) { ?>\n //used when direct messaging service inserts a pnote with indeterminate patient\n //to allow the user to assign the message to a patient.\n top.restoreSession();\n $(\"#task\").val(\"savePatient\");\n $(\"#new_note\").submit();\n <?php } ?>\n }",
" // This invokes the find-patient popup.\n function sel_patient() {\n dlgopen('../../main/calendar/find_patient_popup.php', '_blank', 625, 400);\n }",
" function multi_sel_patient() {\n $('#reply_to').trigger('click');\n var url = '../../main/finder/multi_patients_finder.php'\n // for edit selected list\n if ($('#reply_to').val() !== '') {\n url = url + '?patients=' + $('#reply_to').val() + '&csrf_token_form=<?php echo attr_url(CsrfUtils::collectCsrfToken()); ?>';\n }\n dlgopen(url, '_blank', 625, 400);\n }",
" function addtolist(sel) {\n $('#assigned_to').trigger(\"click\");\n var itemtext = document.getElementById('assigned_to_text');\n var item = document.getElementById('assigned_to');\n if (sel.value !== '--') {\n if (item.value) {\n if (item.value.indexOf(sel.value) === -1) {\n itemtext.value = itemtext.value + ' ; ' + sel.options[sel.selectedIndex].text;\n item.value = item.value + ';' + sel.value;\n }\n } else {\n itemtext.value = sel.options[sel.selectedIndex].text;\n item.value = sel.value;\n }\n }\n }",
" function SMS_direct() {\n var pid = $(\"#sms_pid\").val();\n var m = $(\"#sms_mobile\").val();\n var allow = $(\"#sms_allow\").val();\n if ((pid === '') || (m === '')) {\n alert('<?php echo xls(\"MedEx needs a valid mobile number to send SMS messages...\"); ?>');\n } else if (allow === 'NO') {\n alert('<?php echo xls(\"This patient does not allow SMS messaging!\"); ?>');\n } else {\n top.restoreSession();\n window.open('messages.php?nomenu=1&go=SMS_bot&pid=' + encodeURIComponent(pid) + '&m=' + encodeURIComponent(m), 'SMS_bot', 'width=370,height=600,resizable=0');\n }\n }\n </script>\n <?php\n}\n?>\n</body>\n</html>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [119, 252, 57, 694], "buggy_code_start_loc": [118, 251, 56, 683], "filenames": ["interface/main/messages/messages.php", "interface/main/messages/save.php", "interface/patient_file/front_payment_cc.php", "library/classes/TreeMenu.php"], "fixing_code_end_loc": [119, 252, 57, 694], "fixing_code_start_loc": [118, 251, 56, 683], "message": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:open-emr:openemr:*:*:*:*:*:*:*:*", "matchCriteriaId": "C397DED6-5350-43A0-B65D-FB92E8587CED", "versionEndExcluding": "7.0.0.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2."}], "evaluatorComment": null, "id": "CVE-2022-4503", "lastModified": "2022-12-16T15:11:19.380", "metrics": {"cvssMetricV2": null, "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:N", "version": "3.0"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-12-15T01:15:10.937", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/4cba644c-a2f5-4ed7-af5d-f2cab1895e13"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, "type": "CWE-79"}
| 365
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/**\n * /interface/main/messages/save.php\n *\n * @package MedEx\n * @link http://www.MedExBank.com\n * @author MedEx <support@MedExBank.com>\n * @copyright Copyright (c) 2017 MedEx <support@MedExBank.com>\n * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3\n */",
"require_once \"../../globals.php\";\nrequire_once \"$srcdir/lists.inc\";\nrequire_once \"$srcdir/forms.inc\";\nrequire_once \"$srcdir/patient.inc\";\nrequire_once \"$srcdir/MedEx/API.php\";",
"use OpenEMR\\Common\\Acl\\AclMain;\nuse OpenEMR\\Common\\Session\\SessionUtil;",
"$MedEx = new MedExApi\\MedEx('MedExBank.com');\nif ($_REQUEST['go'] == 'sms_search') {\n $param = \"%\" . $_GET['term'] . \"%\";\n $query = \"SELECT * FROM patient_data WHERE fname LIKE ? OR lname LIKE ?\";\n $result = sqlStatement($query, array($param, $param));\n while ($frow = sqlFetchArray($result)) {\n $data['Label'] = 'Name';\n $data['value'] = text($frow['fname'] . \" \" . $frow['lname']);\n $data['pid'] = text($frow['pid']);\n $data['mobile'] = text($frow['phone_cell']);\n $data['allow'] = text($frow['hipaa_allowsms']);\n $sql = \"SELECT * FROM `medex_outgoing` where msg_pid=? ORDER BY `medex_outgoing`.`msg_uid` DESC LIMIT 1\";\n $data['sql'] = $sql;\n $result2 = sqlQuery($sql, array($frow['pid']));\n $data['msg_last_updated'] = $result2['msg_date'];\n $data['medex_uid'] = $result2['medex_uid'];\n $results[] = $data;\n }",
" echo json_encode($results);\n exit;\n}\n//you need admin privileges to update this.\nif ($_REQUEST['go'] == 'Preferences') {\n if (AclMain::aclCheckCore('admin', 'super')) {\n $sql = \"UPDATE `medex_prefs` SET `ME_facilities`=?,`ME_providers`=?,`ME_hipaa_default_override`=?,\n\t\t\t`PHONE_country_code`=? ,`MSGS_default_yes`=?,\n\t\t\t`POSTCARDS_local`=?,`POSTCARDS_remote`=?,\n\t\t\t`LABELS_local`=?,`LABELS_choice`=?,\n\t\t\t`combine_time`=?, postcard_top=?\";",
" $facilities = implode(\"|\", $_REQUEST['facilities']);\n $providers = implode(\"|\", $_REQUEST['providers']);\n $HIPAA = ($_REQUEST['ME_hipaa_default_override'] ? $_REQUEST['ME_hipaa_default_override'] : '');\n $MSGS = ($_REQUEST['MSGS_default_yes'] ? $_REQUEST['MSGS_default_yes'] : '');\n $country_code = ($_REQUEST['PHONE_country_code'] ? $_REQUEST['PHONE_country_code'] : '1');",
" $myValues = array($facilities, $providers, $HIPAA, $country_code, $MSGS, $_REQUEST['POSTCARDS_local'], $_REQUEST['POSTCARDS_remote'], $_REQUEST['LABELS_local'], $_REQUEST['chart_label_type'], $_REQUEST['combine_time'], $_REQUEST['postcard_top']);",
" $_GLOBALS['chart_label_type'] = $_REQUEST['chart_label_type'];\n sqlStatement('UPDATE `globals` SET gl_value = ? WHERE gl_name LIKE \"chart_label_type\" ', array($_REQUEST['chart_label_type']));",
" $query = \"UPDATE `background_services` SET `active`='1',`execute_interval`=?, `require_once`='/library/MedEx/MedEx_background.php' WHERE `name`='MedEx'\";\n sqlQuery($query, array($_POST['execute_interval']));",
" $result['output'] = sqlQuery($sql, $myValues);\n if ($result['output'] == false) {\n $result['success'] = \"medex_prefs updated\";\n }\n $result = $MedEx->login('1');\n echo json_encode($result);\n }\n exit;\n}\nif ($_REQUEST['MedEx'] == \"start\") {\n if (AclMain::aclCheckCore('admin', 'super')) {\n $query = \"SELECT * FROM users WHERE id = ?\";\n $user_data = sqlQuery($query, array($_SESSION['authUserID']));\n $query = \"SELECT * FROM facility WHERE primary_business_entity='1' LIMIT 1\";\n $facility = sqlFetchArray(sqlStatement($query));",
" $data['firstname'] = $user_data['fname'];\n $data['lastname'] = $user_data['lname'];\n $data['username'] = $_SESSION['authUser'];\n $data['password'] = $_REQUEST['new_password'];\n $data['email'] = $_REQUEST['new_email'];\n $data['telephone'] = $facility['phone'];\n $data['fax'] = $facility['fax'];\n $data['company'] = $facility['name'];\n $data['address_1'] = $facility['street'];\n $data['city'] = $facility['city'];\n $data['state'] = $facility['state'];\n $data['postcode'] = $facility['postal_code'];\n $data['country'] = $facility['country_code'];\n $data['sender_name'] = $user_data['fname'] . \" \" . $user_data['lname'];\n $data['sender_email'] = $facility['email'];\n $data['callerid'] = $facility['phone'];\n $data['MedEx'] = \"1\";\n $data['ipaddress'] = $_SERVER['REMOTE_ADDR'];",
" $prefix = 'http://';\n if ($_SERVER[\"SSL_TLS_SNI\"]) {\n $prefix = \"https://\";\n }\n $data['website_url'] = $prefix . $_SERVER['HTTP_HOST'] . $web_root;\n $practice_logo = \"$OE_SITE_DIR/images/practice_logo.gif\";\n if (!file_exists($practice_logo)) {\n $data['logo_url'] = $prefix . $_SERVER['HTTP_HOST'] . $web_root . \"/sites/\" . $_SESSION[\"site_id\"] . \"/images/practice_logo.gif\";\n } else {\n $data['logo_url'] = $prefix . $_SERVER['HTTP_HOST'] . $GLOBALS['images_static_relative'] . \"/menu-logo.png\";\n }\n $response = $MedEx->setup->autoReg($data);\n if (($response['API_key'] > '') && ($response['customer_id'] > '')) {\n sqlQuery(\"DELETE FROM medex_prefs\");\n $runQuery = \"SELECT * FROM facility ORDER BY name\";\n $fetch = sqlStatement($runQuery);\n while ($frow = sqlFetchArray($fetch)) {\n $facilities[] = $frow['id'];\n }\n $runQuery = \"SELECT * FROM users WHERE username != '' AND active = '1' AND authorized = '1'\";\n $prove = sqlStatement($runQuery);\n while ($prow = sqlFetchArray($prove)) {\n $providers[] = $prow['id'];\n }\n $facilities = implode(\"|\", $facilities);\n $providers = implode(\"|\", $providers);\n $sqlINSERT = \"INSERT INTO `medex_prefs` (\n\t\t\t\t\t\t\t\tMedEx_id,ME_api_key,ME_username,\n\t\t\t\t\t\t\t\tME_facilities,ME_providers,ME_hipaa_default_override,MSGS_default_yes,\n\t\t\t\t\t\t\t\tPHONE_country_code,LABELS_local,LABELS_choice)\n\t\t\t\t\t\t\tVALUES (?,?,?,?,?,?,?,?,?,?)\";\n sqlStatement($sqlINSERT, array($response['customer_id'], $response['API_key'], $_POST['new_email'], $facilities, $providers, \"1\", \"1\", \"1\", \"1\", \"5160\"));\n $query = \"UPDATE `background_services` SET `active`='1',`execute_interval`='5', `require_once`='/library/MedEx/MedEx_background.php' WHERE `name`='MedEx'\";\n sqlQuery($query);\n $info = $MedEx->login('2');",
" if ($info['token']) {\n $info['show'] = xlt(\"Sign-up successful for\") . \" \" . $data['company'] . \".<br />\" . xlt(\"Proceeding to Preferences\") . \".<br />\" . xlt(\"If this page does not refresh, reload the Messages page manually\") . \".<br />\";\n //get js to reroute user to preferences.\n echo json_encode($info);\n }\n } else {\n $response_prob = array();\n $response_prob['show'] = xlt(\"We ran into some problems connecting your EHR to the MedEx servers\") . \".<br >\n\t\t\t\t\" . xlt('Most often this is due to a Username/Password mismatch') . \"<br />\"\n . xlt('Run Setup again or contact support for assistance') .\n \" <a href='https://medexbank.com/cart/upload/'>MedEx Bank</a>.<br />\";\n echo json_encode($response_prob);\n sqlQuery(\"UPDATE `background_services` SET `active`='0' WHERE `name`='MedEx'\");\n }\n //then redirect user to preferences with a success message!\n } else {\n echo xlt(\"Sorry you are not privileged enough. Enrollment is limited to Adminstrator accounts.\");\n }\n exit;\n}",
"if (($_REQUEST['pid']) && ($_REQUEST['action'] == \"new_recall\")) {\n $query = \"SELECT * FROM patient_data WHERE pid=?\";\n $result = sqlQuery($query, array($_REQUEST['pid']));\n $result['age'] = $MedEx->events->getAge($result['DOB']);\n // uuid is binary and will break json_encode in binary form (not needed, so will remove it from $result array)\n unset($result['uuid']);",
" /**\n * Did the clinician create a PLAN at the last visit?\n * To do an in office test, and get paid for it,\n * we must have an order (and a report of the findings).\n * If the practice is using the eye form then uncomment the 5 lines below.\n * It provides the PLAN and orders for next visit.\n * As forms mature, there should be a uniform way to find the PLAN?\n * And when that day comes we'll put it here...\n * The other option is to use Visit Categories here. Maybe both? Consensus?\n */\n $query = \"SELECT ORDER_DETAILS FROM form_eye_mag_orders WHERE pid=? AND ORDER_DATE_PLACED < NOW() ORDER BY ORDER_DATE_PLACED DESC LIMIT 1\";\n $result2 = sqlQuery($query, array($_REQUEST['pid']));\n if (!empty($result2)) {\n $result['PLAN'] = $result2['ORDER_DETAILS'];\n }",
" $query = \"SELECT * FROM openemr_postcalendar_events WHERE pc_pid =? ORDER BY pc_eventDate DESC LIMIT 1\";\n $result2 = sqlQuery($query, array($_REQUEST['pid']));\n if ($result2) { //if they were never actually scheduled this would be blank\n $result['DOLV'] = oeFormatShortDate($result2['pc_eventDate']);\n $result['provider'] = $result2['pc_aid'];\n $result['facility'] = $result2['pc_facility'];\n }\n /**\n * Is there an existing Recall in place already????\n * If so we need to use that info...\n */\n $query = \"SELECT * from medex_recalls where r_pid=?\";\n $result3 = sqlQuery($query, array($_REQUEST['pid']));\n if ($result3) {\n $result['recall_date'] = $result3['r_eventDate'];\n $result['PLAN'] = $result3['r_reason'];\n $result['facility'] = $result3['r_facility'];\n $result['provider'] = $result3['r_provider'];\n }\n echo json_encode($result);\n exit;\n}",
"if (($_REQUEST['action'] == 'addRecall') || ($_REQUEST['add_new'])) {\n $result = $MedEx->events->save_recall($_REQUEST);\n echo json_encode('saved');\n exit;\n}",
"if (($_REQUEST['action'] == 'delete_Recall') && ($_REQUEST['pid'])) {\n $MedEx->events->delete_recall();\n echo json_encode('deleted');\n exit;\n}",
"// Clear the pidList session whenever this page is loaded.\n// $_SESSION['pidList'] will hold array of patient ids\n// which is then used to print 'postcards' and 'Address Labels'\n// Thanks Terry!\nSessionUtil::unsetSession('pidList');\n$pid_list = array();",
"if ($_REQUEST['action'] == \"process\") {\n $new_pid = json_decode($_POST['parameter'], true);\n $new_pc_eid = json_decode($_POST['pc_eid'], true);",
" if (($_POST['item'] == \"phone\") || (($_POST['item'] == \"notes\") && ($_POST['msg_notes'] > ''))) {\n $sql = \"INSERT INTO medex_outgoing (msg_pc_eid, msg_type, msg_reply, msg_extra_text) VALUES (?,?,?,?)\";\n sqlQuery($sql, array('recall_' . $new_pid[0], $_POST['item'], $_SESSION['authUserID'], $_POST['msg_notes']));\n return \"done\";\n }\n $pc_eidList = json_decode($_POST['pc_eid'], true);\n $pidList = json_decode($_POST['parameter'], true);\n $sessionSetArray['pc_eidList'] = $pc_eidList[0];\n $sessionSetArray['pidList'] = $pidList;\n SessionUtil::setSession($sessionSetArray);",
" if ($_POST['item'] == \"postcards\") {\n foreach ($pidList as $pid) {\n $sql = \"INSERT INTO medex_outgoing (msg_pc_eid, msg_type, msg_reply, msg_extra_text) VALUES (?,?,?,?)\";\n sqlQuery($sql, array('recall_' . $pid, $_POST['item'], $_SESSION['authUserID'], 'Postcard printed locally'));\n }\n }\n if ($_POST['item'] == \"labels\") {\n foreach ($pidList as $pid) {\n $sql = \"INSERT INTO medex_outgoing (msg_pc_eid, msg_type, msg_reply, msg_extra_text) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE msg_extra_text='Label repeat'\";\n sqlQuery($sql, array('recall_' . $pid, $_POST['item'], $_SESSION['authUserID'], 'Label printed locally'));\n }\n }",
" echo json_encode($pidList);",
" exit;\n}\nif ($_REQUEST['go'] == \"Messages\") {\n if ($_REQUEST['msg_id']) {\n $result = updateMessage($_REQUEST['msg_id']);\n echo json_encode($result);\n exit;\n }\n}\nexit;"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [119, 252, 57, 694], "buggy_code_start_loc": [118, 251, 56, 683], "filenames": ["interface/main/messages/messages.php", "interface/main/messages/save.php", "interface/patient_file/front_payment_cc.php", "library/classes/TreeMenu.php"], "fixing_code_end_loc": [119, 252, 57, 694], "fixing_code_start_loc": [118, 251, 56, 683], "message": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:open-emr:openemr:*:*:*:*:*:*:*:*", "matchCriteriaId": "C397DED6-5350-43A0-B65D-FB92E8587CED", "versionEndExcluding": "7.0.0.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2."}], "evaluatorComment": null, "id": "CVE-2022-4503", "lastModified": "2022-12-16T15:11:19.380", "metrics": {"cvssMetricV2": null, "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:N", "version": "3.0"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-12-15T01:15:10.937", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/4cba644c-a2f5-4ed7-af5d-f2cab1895e13"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, "type": "CWE-79"}
| 365
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/**\n * /interface/main/messages/save.php\n *\n * @package MedEx\n * @link http://www.MedExBank.com\n * @author MedEx <support@MedExBank.com>\n * @copyright Copyright (c) 2017 MedEx <support@MedExBank.com>\n * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3\n */",
"require_once \"../../globals.php\";\nrequire_once \"$srcdir/lists.inc\";\nrequire_once \"$srcdir/forms.inc\";\nrequire_once \"$srcdir/patient.inc\";\nrequire_once \"$srcdir/MedEx/API.php\";",
"use OpenEMR\\Common\\Acl\\AclMain;\nuse OpenEMR\\Common\\Session\\SessionUtil;",
"$MedEx = new MedExApi\\MedEx('MedExBank.com');\nif ($_REQUEST['go'] == 'sms_search') {\n $param = \"%\" . $_GET['term'] . \"%\";\n $query = \"SELECT * FROM patient_data WHERE fname LIKE ? OR lname LIKE ?\";\n $result = sqlStatement($query, array($param, $param));\n while ($frow = sqlFetchArray($result)) {\n $data['Label'] = 'Name';\n $data['value'] = text($frow['fname'] . \" \" . $frow['lname']);\n $data['pid'] = text($frow['pid']);\n $data['mobile'] = text($frow['phone_cell']);\n $data['allow'] = text($frow['hipaa_allowsms']);\n $sql = \"SELECT * FROM `medex_outgoing` where msg_pid=? ORDER BY `medex_outgoing`.`msg_uid` DESC LIMIT 1\";\n $data['sql'] = $sql;\n $result2 = sqlQuery($sql, array($frow['pid']));\n $data['msg_last_updated'] = $result2['msg_date'];\n $data['medex_uid'] = $result2['medex_uid'];\n $results[] = $data;\n }",
" echo json_encode($results);\n exit;\n}\n//you need admin privileges to update this.\nif ($_REQUEST['go'] == 'Preferences') {\n if (AclMain::aclCheckCore('admin', 'super')) {\n $sql = \"UPDATE `medex_prefs` SET `ME_facilities`=?,`ME_providers`=?,`ME_hipaa_default_override`=?,\n\t\t\t`PHONE_country_code`=? ,`MSGS_default_yes`=?,\n\t\t\t`POSTCARDS_local`=?,`POSTCARDS_remote`=?,\n\t\t\t`LABELS_local`=?,`LABELS_choice`=?,\n\t\t\t`combine_time`=?, postcard_top=?\";",
" $facilities = implode(\"|\", $_REQUEST['facilities']);\n $providers = implode(\"|\", $_REQUEST['providers']);\n $HIPAA = ($_REQUEST['ME_hipaa_default_override'] ? $_REQUEST['ME_hipaa_default_override'] : '');\n $MSGS = ($_REQUEST['MSGS_default_yes'] ? $_REQUEST['MSGS_default_yes'] : '');\n $country_code = ($_REQUEST['PHONE_country_code'] ? $_REQUEST['PHONE_country_code'] : '1');",
" $myValues = array($facilities, $providers, $HIPAA, $country_code, $MSGS, $_REQUEST['POSTCARDS_local'], $_REQUEST['POSTCARDS_remote'], $_REQUEST['LABELS_local'], $_REQUEST['chart_label_type'], $_REQUEST['combine_time'], $_REQUEST['postcard_top']);",
" $_GLOBALS['chart_label_type'] = $_REQUEST['chart_label_type'];\n sqlStatement('UPDATE `globals` SET gl_value = ? WHERE gl_name LIKE \"chart_label_type\" ', array($_REQUEST['chart_label_type']));",
" $query = \"UPDATE `background_services` SET `active`='1',`execute_interval`=?, `require_once`='/library/MedEx/MedEx_background.php' WHERE `name`='MedEx'\";\n sqlQuery($query, array($_POST['execute_interval']));",
" $result['output'] = sqlQuery($sql, $myValues);\n if ($result['output'] == false) {\n $result['success'] = \"medex_prefs updated\";\n }\n $result = $MedEx->login('1');\n echo json_encode($result);\n }\n exit;\n}\nif ($_REQUEST['MedEx'] == \"start\") {\n if (AclMain::aclCheckCore('admin', 'super')) {\n $query = \"SELECT * FROM users WHERE id = ?\";\n $user_data = sqlQuery($query, array($_SESSION['authUserID']));\n $query = \"SELECT * FROM facility WHERE primary_business_entity='1' LIMIT 1\";\n $facility = sqlFetchArray(sqlStatement($query));",
" $data['firstname'] = $user_data['fname'];\n $data['lastname'] = $user_data['lname'];\n $data['username'] = $_SESSION['authUser'];\n $data['password'] = $_REQUEST['new_password'];\n $data['email'] = $_REQUEST['new_email'];\n $data['telephone'] = $facility['phone'];\n $data['fax'] = $facility['fax'];\n $data['company'] = $facility['name'];\n $data['address_1'] = $facility['street'];\n $data['city'] = $facility['city'];\n $data['state'] = $facility['state'];\n $data['postcode'] = $facility['postal_code'];\n $data['country'] = $facility['country_code'];\n $data['sender_name'] = $user_data['fname'] . \" \" . $user_data['lname'];\n $data['sender_email'] = $facility['email'];\n $data['callerid'] = $facility['phone'];\n $data['MedEx'] = \"1\";\n $data['ipaddress'] = $_SERVER['REMOTE_ADDR'];",
" $prefix = 'http://';\n if ($_SERVER[\"SSL_TLS_SNI\"]) {\n $prefix = \"https://\";\n }\n $data['website_url'] = $prefix . $_SERVER['HTTP_HOST'] . $web_root;\n $practice_logo = \"$OE_SITE_DIR/images/practice_logo.gif\";\n if (!file_exists($practice_logo)) {\n $data['logo_url'] = $prefix . $_SERVER['HTTP_HOST'] . $web_root . \"/sites/\" . $_SESSION[\"site_id\"] . \"/images/practice_logo.gif\";\n } else {\n $data['logo_url'] = $prefix . $_SERVER['HTTP_HOST'] . $GLOBALS['images_static_relative'] . \"/menu-logo.png\";\n }\n $response = $MedEx->setup->autoReg($data);\n if (($response['API_key'] > '') && ($response['customer_id'] > '')) {\n sqlQuery(\"DELETE FROM medex_prefs\");\n $runQuery = \"SELECT * FROM facility ORDER BY name\";\n $fetch = sqlStatement($runQuery);\n while ($frow = sqlFetchArray($fetch)) {\n $facilities[] = $frow['id'];\n }\n $runQuery = \"SELECT * FROM users WHERE username != '' AND active = '1' AND authorized = '1'\";\n $prove = sqlStatement($runQuery);\n while ($prow = sqlFetchArray($prove)) {\n $providers[] = $prow['id'];\n }\n $facilities = implode(\"|\", $facilities);\n $providers = implode(\"|\", $providers);\n $sqlINSERT = \"INSERT INTO `medex_prefs` (\n\t\t\t\t\t\t\t\tMedEx_id,ME_api_key,ME_username,\n\t\t\t\t\t\t\t\tME_facilities,ME_providers,ME_hipaa_default_override,MSGS_default_yes,\n\t\t\t\t\t\t\t\tPHONE_country_code,LABELS_local,LABELS_choice)\n\t\t\t\t\t\t\tVALUES (?,?,?,?,?,?,?,?,?,?)\";\n sqlStatement($sqlINSERT, array($response['customer_id'], $response['API_key'], $_POST['new_email'], $facilities, $providers, \"1\", \"1\", \"1\", \"1\", \"5160\"));\n $query = \"UPDATE `background_services` SET `active`='1',`execute_interval`='5', `require_once`='/library/MedEx/MedEx_background.php' WHERE `name`='MedEx'\";\n sqlQuery($query);\n $info = $MedEx->login('2');",
" if ($info['token']) {\n $info['show'] = xlt(\"Sign-up successful for\") . \" \" . $data['company'] . \".<br />\" . xlt(\"Proceeding to Preferences\") . \".<br />\" . xlt(\"If this page does not refresh, reload the Messages page manually\") . \".<br />\";\n //get js to reroute user to preferences.\n echo json_encode($info);\n }\n } else {\n $response_prob = array();\n $response_prob['show'] = xlt(\"We ran into some problems connecting your EHR to the MedEx servers\") . \".<br >\n\t\t\t\t\" . xlt('Most often this is due to a Username/Password mismatch') . \"<br />\"\n . xlt('Run Setup again or contact support for assistance') .\n \" <a href='https://medexbank.com/cart/upload/'>MedEx Bank</a>.<br />\";\n echo json_encode($response_prob);\n sqlQuery(\"UPDATE `background_services` SET `active`='0' WHERE `name`='MedEx'\");\n }\n //then redirect user to preferences with a success message!\n } else {\n echo xlt(\"Sorry you are not privileged enough. Enrollment is limited to Adminstrator accounts.\");\n }\n exit;\n}",
"if (($_REQUEST['pid']) && ($_REQUEST['action'] == \"new_recall\")) {\n $query = \"SELECT * FROM patient_data WHERE pid=?\";\n $result = sqlQuery($query, array($_REQUEST['pid']));\n $result['age'] = $MedEx->events->getAge($result['DOB']);\n // uuid is binary and will break json_encode in binary form (not needed, so will remove it from $result array)\n unset($result['uuid']);",
" /**\n * Did the clinician create a PLAN at the last visit?\n * To do an in office test, and get paid for it,\n * we must have an order (and a report of the findings).\n * If the practice is using the eye form then uncomment the 5 lines below.\n * It provides the PLAN and orders for next visit.\n * As forms mature, there should be a uniform way to find the PLAN?\n * And when that day comes we'll put it here...\n * The other option is to use Visit Categories here. Maybe both? Consensus?\n */\n $query = \"SELECT ORDER_DETAILS FROM form_eye_mag_orders WHERE pid=? AND ORDER_DATE_PLACED < NOW() ORDER BY ORDER_DATE_PLACED DESC LIMIT 1\";\n $result2 = sqlQuery($query, array($_REQUEST['pid']));\n if (!empty($result2)) {\n $result['PLAN'] = $result2['ORDER_DETAILS'];\n }",
" $query = \"SELECT * FROM openemr_postcalendar_events WHERE pc_pid =? ORDER BY pc_eventDate DESC LIMIT 1\";\n $result2 = sqlQuery($query, array($_REQUEST['pid']));\n if ($result2) { //if they were never actually scheduled this would be blank\n $result['DOLV'] = oeFormatShortDate($result2['pc_eventDate']);\n $result['provider'] = $result2['pc_aid'];\n $result['facility'] = $result2['pc_facility'];\n }\n /**\n * Is there an existing Recall in place already????\n * If so we need to use that info...\n */\n $query = \"SELECT * from medex_recalls where r_pid=?\";\n $result3 = sqlQuery($query, array($_REQUEST['pid']));\n if ($result3) {\n $result['recall_date'] = $result3['r_eventDate'];\n $result['PLAN'] = $result3['r_reason'];\n $result['facility'] = $result3['r_facility'];\n $result['provider'] = $result3['r_provider'];\n }\n echo json_encode($result);\n exit;\n}",
"if (($_REQUEST['action'] == 'addRecall') || ($_REQUEST['add_new'])) {\n $result = $MedEx->events->save_recall($_REQUEST);\n echo json_encode('saved');\n exit;\n}",
"if (($_REQUEST['action'] == 'delete_Recall') && ($_REQUEST['pid'])) {\n $MedEx->events->delete_recall();\n echo json_encode('deleted');\n exit;\n}",
"// Clear the pidList session whenever this page is loaded.\n// $_SESSION['pidList'] will hold array of patient ids\n// which is then used to print 'postcards' and 'Address Labels'\n// Thanks Terry!\nSessionUtil::unsetSession('pidList');\n$pid_list = array();",
"if ($_REQUEST['action'] == \"process\") {\n $new_pid = json_decode($_POST['parameter'], true);\n $new_pc_eid = json_decode($_POST['pc_eid'], true);",
" if (($_POST['item'] == \"phone\") || (($_POST['item'] == \"notes\") && ($_POST['msg_notes'] > ''))) {\n $sql = \"INSERT INTO medex_outgoing (msg_pc_eid, msg_type, msg_reply, msg_extra_text) VALUES (?,?,?,?)\";\n sqlQuery($sql, array('recall_' . $new_pid[0], $_POST['item'], $_SESSION['authUserID'], $_POST['msg_notes']));\n return \"done\";\n }\n $pc_eidList = json_decode($_POST['pc_eid'], true);\n $pidList = json_decode($_POST['parameter'], true);\n $sessionSetArray['pc_eidList'] = $pc_eidList[0];\n $sessionSetArray['pidList'] = $pidList;\n SessionUtil::setSession($sessionSetArray);",
" if ($_POST['item'] == \"postcards\") {\n foreach ($pidList as $pid) {\n $sql = \"INSERT INTO medex_outgoing (msg_pc_eid, msg_type, msg_reply, msg_extra_text) VALUES (?,?,?,?)\";\n sqlQuery($sql, array('recall_' . $pid, $_POST['item'], $_SESSION['authUserID'], 'Postcard printed locally'));\n }\n }\n if ($_POST['item'] == \"labels\") {\n foreach ($pidList as $pid) {\n $sql = \"INSERT INTO medex_outgoing (msg_pc_eid, msg_type, msg_reply, msg_extra_text) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE msg_extra_text='Label repeat'\";\n sqlQuery($sql, array('recall_' . $pid, $_POST['item'], $_SESSION['authUserID'], 'Label printed locally'));\n }\n }",
" echo text(json_encode($pidList));",
" exit;\n}\nif ($_REQUEST['go'] == \"Messages\") {\n if ($_REQUEST['msg_id']) {\n $result = updateMessage($_REQUEST['msg_id']);\n echo json_encode($result);\n exit;\n }\n}\nexit;"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [119, 252, 57, 694], "buggy_code_start_loc": [118, 251, 56, 683], "filenames": ["interface/main/messages/messages.php", "interface/main/messages/save.php", "interface/patient_file/front_payment_cc.php", "library/classes/TreeMenu.php"], "fixing_code_end_loc": [119, 252, 57, 694], "fixing_code_start_loc": [118, 251, 56, 683], "message": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:open-emr:openemr:*:*:*:*:*:*:*:*", "matchCriteriaId": "C397DED6-5350-43A0-B65D-FB92E8587CED", "versionEndExcluding": "7.0.0.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2."}], "evaluatorComment": null, "id": "CVE-2022-4503", "lastModified": "2022-12-16T15:11:19.380", "metrics": {"cvssMetricV2": null, "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:N", "version": "3.0"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-12-15T01:15:10.937", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/4cba644c-a2f5-4ed7-af5d-f2cab1895e13"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, "type": "CWE-79"}
| 365
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/**\n * Front Payment CC and Terminal Readers support.\n *\n * @package OpenEMR\n * @link http://www.open-emr.org\n * @author Jerry Padgett <sjpadgett@gmail.com>\n * @copyright Copyright (c) 2021 Jerry Padgett <sjpadgett@gmail.com>\n * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3\n */",
"$ignoreAuth = false;\nrequire_once(__DIR__ . \"/../globals.php\");",
"use OpenEMR\\Billing\\PaymentGateway;\nuse OpenEMR\\Common\\Crypto\\CryptoGen;\nuse Stripe\\Customer;\nuse Stripe\\PaymentIntent;\nuse Stripe\\Stripe;\nuse Stripe\\Terminal\\ConnectionToken;\nuse Stripe\\Terminal\\Location;",
"if ($_POST['mode'] == 'AuthorizeNet') {\n $form_pid = $_POST['form_pid'];\n $pay = new PaymentGateway(\"AuthorizeNetApi_Api\");\n $transaction['amount'] = $_POST['payment'];\n $transaction['currency'] = \"USD\";\n $transaction['opaqueDataDescriptor'] = $_POST['dataDescriptor'];\n $transaction['opaqueDataValue'] = $_POST['dataValue'];\n try {\n $response = $pay->submitPaymentToken($transaction);\n if (is_string($response)) {\n echo $response;\n exit();\n }\n $r = $response->getParsedData();\n $cc = array();\n $cc[\"cardHolderName\"] = $_POST[\"cardHolderName\"];\n $cc['status'] = $response->isSuccessful() ? \"ok\" : \"failed\";\n $cc['authCode'] = $r->transactionResponse->authCode;\n $cc['transId'] = $r->transactionResponse->transId;\n $cc['cardNumber'] = $r->transactionResponse->accountNumber;\n $cc['cc_type'] = $r->transactionResponse->accountType;\n $cc['zip'] = $_POST[\"zip\"];\n $ccaudit = json_encode($cc);\n } catch (\\Exception $ex) {\n return $ex->getMessage();\n }",
" if (!$response->isSuccessful()) {\n echo $response->getMessage();\n exit();\n }\n",
" echo $ccaudit;",
" exit();\n}",
"if ($_POST['mode'] == 'Stripe') {\n $pd = sqlQuery(\"SELECT \" .\n \"p.fname, p.mname, p.lname, p.pubpid, p.pid, i.copay \" .\n \"FROM patient_data AS p \" .\n \"LEFT OUTER JOIN insurance_data AS i ON \" .\n \"i.pid = p.pid AND i.type = 'primary' \" .\n \"WHERE p.pid = ? ORDER BY i.date DESC LIMIT 1\", array($pid));\n $pay = new PaymentGateway(\"Stripe\");\n $transaction['amount'] = $_POST['payment'];\n $transaction['currency'] = \"USD\";\n $transaction['token'] = $_POST['stripeToken'];\n $transaction['description'] = $pd['lname'] . ' ' . $pd['fname'] . ' ' . $pd['mname'];\n $transaction['metadata'] = [\n 'Patient' => $pd['lname'] . ' ' . $pd['fname'] . ' ' . $pd['mname'],\n 'MRN' => $pd['pubpid'],\n 'Invoice Items (date encounter)' => $_POST['encs'],\n 'Invoice Total' => $transaction['amount']\n ];\n try {\n $response = $pay->submitPaymentToken($transaction);\n if (is_string($response)) {\n echo $response;\n exit();\n }\n $r = $response->getSource();\n $cc = array();\n $cc[\"cardHolderName\"] = $_POST[\"cardHolderName\"];\n $cc['status'] = $response->isSuccessful() ? \"ok\" : \"failed\";\n $cc['authCode'] = $r['fingerprint'];\n $cc['transId'] = $response->getTransactionReference();\n $cc['cardNumber'] = \"******** \" . $r['last4'];\n $cc['cc_type'] = $r['brand'];\n $cc['zip'] = $r->address_zip;\n $ccaudit = json_encode($cc);\n } catch (\\Exception $ex) {\n echo $ex->getMessage();\n }",
" if (!$response->isSuccessful()) {\n echo $response;\n exit();\n }",
" echo $ccaudit;\n exit();\n}",
"if ($_GET['mode'] == 'terminal_token') {\n $cryptoGen = new CryptoGen();\n $apiKey = $cryptoGen->decryptStandard($GLOBALS['gateway_api_key']);\n Stripe::setApiKey($apiKey);",
" header('Content-Type: application/json');",
" try {\n $connectionToken = ConnectionToken::create();\n echo json_encode(array('secret' => $connectionToken->secret), JSON_THROW_ON_ERROR);\n } catch (\\Exception $e) {\n http_response_code(500);\n echo json_encode(['error' => $e->getMessage()], JSON_THROW_ON_ERROR);\n }\n}\nif ($_GET['mode'] == 'cancel_intent') {\n $cryptoGen = new CryptoGen();\n $apiKey = $cryptoGen->decryptStandard($GLOBALS['gateway_api_key']);\n Stripe::setApiKey($apiKey);",
" header('Content-Type: application/json');",
" try {\n $json_str = file_get_contents('php://input');\n $json_obj = json_decode($json_str);",
" $intent = PaymentIntent::retrieve($json_obj->id);\n $rtn = $intent->cancel();",
" echo json_encode(['status' => (string)$rtn->status]);\n } catch (\\Exception $e) {\n http_response_code(500);\n echo json_encode(['error' => $e->getMessage()]);\n }\n}",
"if ($_GET['mode'] == 'terminal_capture') {\n $cryptoGen = new CryptoGen();\n $apiKey = $cryptoGen->decryptStandard($GLOBALS['gateway_api_key']);\n Stripe::setApiKey($apiKey);",
" header('Content-Type: application/json');",
" try {\n // retrieve JSON from POST body\n $json_str = file_get_contents('php://input');\n $json_obj = json_decode($json_str);",
" $intent = PaymentIntent::retrieve($json_obj->id);\n $intent = $intent->capture();",
" echo json_encode($intent);\n } catch (\\Exception $e) {\n http_response_code(500);\n echo json_encode(['error' => $e->getMessage()], JSON_THROW_ON_ERROR);\n }\n}",
"if ($_GET['mode'] == 'terminal_create') {\n $cryptoGen = new CryptoGen();\n $apiKey = $cryptoGen->decryptStandard($GLOBALS['gateway_api_key']);\n Stripe::setApiKey($apiKey);",
" header('Content-Type: application/json');",
" try {\n $json_str = file_get_contents('php://input');\n $json_obj = json_decode($json_str);\n $pd = sqlQuery(\"SELECT \" .\n \"p.fname, p.mname, p.lname, p.pubpid,p.pid, p.email, i.copay \" .\n \"FROM patient_data AS p \" .\n \"LEFT OUTER JOIN insurance_data AS i ON \" .\n \"i.pid = p.pid AND i.type = 'primary' \" .\n \"WHERE p.pid = ? ORDER BY i.date DESC LIMIT 1\", array($pid));",
" $intent = PaymentIntent::create([\n 'amount' => $json_obj->amount,\n 'currency' => 'usd',\n 'payment_method_types' => ['card_present'],\n 'capture_method' => 'manual',\n 'description' => $pd['lname'] . ' ' . $pd['fname'] . ' ' . $pd['mname'],\n 'metadata' => [\n 'Patient' => $pd['lname'] . ' ' . $pd['fname'] . ' ' . $pd['mname'],\n 'MRN' => $pd['pubpid'],\n 'Invoice Items (date encounter)' => $json_obj->encs,\n 'Invoice Total' => number_format(($json_obj->amount / 100), 2, '.', '')\n ]\n ]);\n echo json_encode(array('client_secret' => $intent->client_secret), JSON_THROW_ON_ERROR);\n } catch (\\Exception $e) {\n http_response_code(500);\n echo json_encode(['error' => $e->getMessage()], JSON_THROW_ON_ERROR);\n }\n}"
] |
[
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [119, 252, 57, 694], "buggy_code_start_loc": [118, 251, 56, 683], "filenames": ["interface/main/messages/messages.php", "interface/main/messages/save.php", "interface/patient_file/front_payment_cc.php", "library/classes/TreeMenu.php"], "fixing_code_end_loc": [119, 252, 57, 694], "fixing_code_start_loc": [118, 251, 56, 683], "message": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:open-emr:openemr:*:*:*:*:*:*:*:*", "matchCriteriaId": "C397DED6-5350-43A0-B65D-FB92E8587CED", "versionEndExcluding": "7.0.0.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2."}], "evaluatorComment": null, "id": "CVE-2022-4503", "lastModified": "2022-12-16T15:11:19.380", "metrics": {"cvssMetricV2": null, "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:N", "version": "3.0"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-12-15T01:15:10.937", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/4cba644c-a2f5-4ed7-af5d-f2cab1895e13"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, "type": "CWE-79"}
| 365
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/**\n * Front Payment CC and Terminal Readers support.\n *\n * @package OpenEMR\n * @link http://www.open-emr.org\n * @author Jerry Padgett <sjpadgett@gmail.com>\n * @copyright Copyright (c) 2021 Jerry Padgett <sjpadgett@gmail.com>\n * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3\n */",
"$ignoreAuth = false;\nrequire_once(__DIR__ . \"/../globals.php\");",
"use OpenEMR\\Billing\\PaymentGateway;\nuse OpenEMR\\Common\\Crypto\\CryptoGen;\nuse Stripe\\Customer;\nuse Stripe\\PaymentIntent;\nuse Stripe\\Stripe;\nuse Stripe\\Terminal\\ConnectionToken;\nuse Stripe\\Terminal\\Location;",
"if ($_POST['mode'] == 'AuthorizeNet') {\n $form_pid = $_POST['form_pid'];\n $pay = new PaymentGateway(\"AuthorizeNetApi_Api\");\n $transaction['amount'] = $_POST['payment'];\n $transaction['currency'] = \"USD\";\n $transaction['opaqueDataDescriptor'] = $_POST['dataDescriptor'];\n $transaction['opaqueDataValue'] = $_POST['dataValue'];\n try {\n $response = $pay->submitPaymentToken($transaction);\n if (is_string($response)) {\n echo $response;\n exit();\n }\n $r = $response->getParsedData();\n $cc = array();\n $cc[\"cardHolderName\"] = $_POST[\"cardHolderName\"];\n $cc['status'] = $response->isSuccessful() ? \"ok\" : \"failed\";\n $cc['authCode'] = $r->transactionResponse->authCode;\n $cc['transId'] = $r->transactionResponse->transId;\n $cc['cardNumber'] = $r->transactionResponse->accountNumber;\n $cc['cc_type'] = $r->transactionResponse->accountType;\n $cc['zip'] = $_POST[\"zip\"];\n $ccaudit = json_encode($cc);\n } catch (\\Exception $ex) {\n return $ex->getMessage();\n }",
" if (!$response->isSuccessful()) {\n echo $response->getMessage();\n exit();\n }\n",
" echo text($ccaudit);",
" exit();\n}",
"if ($_POST['mode'] == 'Stripe') {\n $pd = sqlQuery(\"SELECT \" .\n \"p.fname, p.mname, p.lname, p.pubpid, p.pid, i.copay \" .\n \"FROM patient_data AS p \" .\n \"LEFT OUTER JOIN insurance_data AS i ON \" .\n \"i.pid = p.pid AND i.type = 'primary' \" .\n \"WHERE p.pid = ? ORDER BY i.date DESC LIMIT 1\", array($pid));\n $pay = new PaymentGateway(\"Stripe\");\n $transaction['amount'] = $_POST['payment'];\n $transaction['currency'] = \"USD\";\n $transaction['token'] = $_POST['stripeToken'];\n $transaction['description'] = $pd['lname'] . ' ' . $pd['fname'] . ' ' . $pd['mname'];\n $transaction['metadata'] = [\n 'Patient' => $pd['lname'] . ' ' . $pd['fname'] . ' ' . $pd['mname'],\n 'MRN' => $pd['pubpid'],\n 'Invoice Items (date encounter)' => $_POST['encs'],\n 'Invoice Total' => $transaction['amount']\n ];\n try {\n $response = $pay->submitPaymentToken($transaction);\n if (is_string($response)) {\n echo $response;\n exit();\n }\n $r = $response->getSource();\n $cc = array();\n $cc[\"cardHolderName\"] = $_POST[\"cardHolderName\"];\n $cc['status'] = $response->isSuccessful() ? \"ok\" : \"failed\";\n $cc['authCode'] = $r['fingerprint'];\n $cc['transId'] = $response->getTransactionReference();\n $cc['cardNumber'] = \"******** \" . $r['last4'];\n $cc['cc_type'] = $r['brand'];\n $cc['zip'] = $r->address_zip;\n $ccaudit = json_encode($cc);\n } catch (\\Exception $ex) {\n echo $ex->getMessage();\n }",
" if (!$response->isSuccessful()) {\n echo $response;\n exit();\n }",
" echo $ccaudit;\n exit();\n}",
"if ($_GET['mode'] == 'terminal_token') {\n $cryptoGen = new CryptoGen();\n $apiKey = $cryptoGen->decryptStandard($GLOBALS['gateway_api_key']);\n Stripe::setApiKey($apiKey);",
" header('Content-Type: application/json');",
" try {\n $connectionToken = ConnectionToken::create();\n echo json_encode(array('secret' => $connectionToken->secret), JSON_THROW_ON_ERROR);\n } catch (\\Exception $e) {\n http_response_code(500);\n echo json_encode(['error' => $e->getMessage()], JSON_THROW_ON_ERROR);\n }\n}\nif ($_GET['mode'] == 'cancel_intent') {\n $cryptoGen = new CryptoGen();\n $apiKey = $cryptoGen->decryptStandard($GLOBALS['gateway_api_key']);\n Stripe::setApiKey($apiKey);",
" header('Content-Type: application/json');",
" try {\n $json_str = file_get_contents('php://input');\n $json_obj = json_decode($json_str);",
" $intent = PaymentIntent::retrieve($json_obj->id);\n $rtn = $intent->cancel();",
" echo json_encode(['status' => (string)$rtn->status]);\n } catch (\\Exception $e) {\n http_response_code(500);\n echo json_encode(['error' => $e->getMessage()]);\n }\n}",
"if ($_GET['mode'] == 'terminal_capture') {\n $cryptoGen = new CryptoGen();\n $apiKey = $cryptoGen->decryptStandard($GLOBALS['gateway_api_key']);\n Stripe::setApiKey($apiKey);",
" header('Content-Type: application/json');",
" try {\n // retrieve JSON from POST body\n $json_str = file_get_contents('php://input');\n $json_obj = json_decode($json_str);",
" $intent = PaymentIntent::retrieve($json_obj->id);\n $intent = $intent->capture();",
" echo json_encode($intent);\n } catch (\\Exception $e) {\n http_response_code(500);\n echo json_encode(['error' => $e->getMessage()], JSON_THROW_ON_ERROR);\n }\n}",
"if ($_GET['mode'] == 'terminal_create') {\n $cryptoGen = new CryptoGen();\n $apiKey = $cryptoGen->decryptStandard($GLOBALS['gateway_api_key']);\n Stripe::setApiKey($apiKey);",
" header('Content-Type: application/json');",
" try {\n $json_str = file_get_contents('php://input');\n $json_obj = json_decode($json_str);\n $pd = sqlQuery(\"SELECT \" .\n \"p.fname, p.mname, p.lname, p.pubpid,p.pid, p.email, i.copay \" .\n \"FROM patient_data AS p \" .\n \"LEFT OUTER JOIN insurance_data AS i ON \" .\n \"i.pid = p.pid AND i.type = 'primary' \" .\n \"WHERE p.pid = ? ORDER BY i.date DESC LIMIT 1\", array($pid));",
" $intent = PaymentIntent::create([\n 'amount' => $json_obj->amount,\n 'currency' => 'usd',\n 'payment_method_types' => ['card_present'],\n 'capture_method' => 'manual',\n 'description' => $pd['lname'] . ' ' . $pd['fname'] . ' ' . $pd['mname'],\n 'metadata' => [\n 'Patient' => $pd['lname'] . ' ' . $pd['fname'] . ' ' . $pd['mname'],\n 'MRN' => $pd['pubpid'],\n 'Invoice Items (date encounter)' => $json_obj->encs,\n 'Invoice Total' => number_format(($json_obj->amount / 100), 2, '.', '')\n ]\n ]);\n echo json_encode(array('client_secret' => $intent->client_secret), JSON_THROW_ON_ERROR);\n } catch (\\Exception $e) {\n http_response_code(500);\n echo json_encode(['error' => $e->getMessage()], JSON_THROW_ON_ERROR);\n }\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [119, 252, 57, 694], "buggy_code_start_loc": [118, 251, 56, 683], "filenames": ["interface/main/messages/messages.php", "interface/main/messages/save.php", "interface/patient_file/front_payment_cc.php", "library/classes/TreeMenu.php"], "fixing_code_end_loc": [119, 252, 57, 694], "fixing_code_start_loc": [118, 251, 56, 683], "message": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:open-emr:openemr:*:*:*:*:*:*:*:*", "matchCriteriaId": "C397DED6-5350-43A0-B65D-FB92E8587CED", "versionEndExcluding": "7.0.0.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2."}], "evaluatorComment": null, "id": "CVE-2022-4503", "lastModified": "2022-12-16T15:11:19.380", "metrics": {"cvssMetricV2": null, "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:N", "version": "3.0"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-12-15T01:15:10.937", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/4cba644c-a2f5-4ed7-af5d-f2cab1895e13"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, "type": "CWE-79"}
| 365
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"// +-----------------------------------------------------------------------+\n// | Copyright (c) 2002-2003, Richard Heyes, Harald Radi |\n// | All rights reserved. |\n// | |\n// | Redistribution and use in source and binary forms, with or without |\n// | modification, are permitted provided that the following conditions |\n// | are met: |\n// | |\n// | o Redistributions of source code must retain the above copyright |\n// | notice, this list of conditions and the following disclaimer. |\n// | o Redistributions in binary form must reproduce the above copyright |\n// | notice, this list of conditions and the following disclaimer in the |\n// | documentation and/or other materials provided with the distribution.|\n// | o The names of the authors may not be used to endorse or promote |\n// | products derived from this software without specific prior written |\n// | permission. |\n// | |\n// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |\n// | \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |\n// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |\n// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |\n// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |\n// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |\n// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |\n// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |\n// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |\n// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |\n// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |\n// | |\n// +-----------------------------------------------------------------------+\n// | Author: Richard Heyes <richard@phpguru.org> |\n// | Harald Radi <harald.radi@nme.at> |\n// +-----------------------------------------------------------------------+\n//\n// $Id$",
"/**\n* HTML_TreeMenu Class\n*\n* A simple couple of PHP classes and some not so simple\n* Jabbascript which produces a tree menu. In IE this menu\n* is dynamic, with branches being collapsable. In IE5+ the\n* status of the collapsed/open branches persists across page\n* refreshes.In any other browser the tree is static. Code is\n* based on work of Harald Radi.\n*\n* Usage.\n*\n* After installing the package, copy the example php script to\n* your servers document root. Also place the TreeMenu.js and the\n* images folder in the same place. Running the script should\n* then produce the tree.\n*\n* Thanks go to Chip Chapin (http://www.chipchapin.com) for many\n* excellent ideas and improvements.\n*\n* @author Richard Heyes <richard@php.net>\n* @author Harald Radi <harald.radi@nme.at>\n* @access public\n* @package HTML_TreeMenu\n*/",
"class HTML_TreeMenu\n{\n /**\n * Indexed array of subnodes\n * @var array\n */\n var $items;",
" /**\n * Constructor\n *\n * @access public\n */\n function __construct()\n {\n // Not much to do here :(\n }",
" /**\n * This function adds an item to the the tree.\n *\n * @access public\n * @param object $node The node to add. This object should be\n * a HTML_TreeNode object.\n * @return object Returns a reference to the new node inside\n * the tree.\n */\n function &addItem(&$node)\n {\n $this->items[] = &$node;\n return $this->items[count($this->items) - 1];\n }",
" /**\n * Import method for creating HTML_TreeMenu objects/structures\n * out of existing tree objects/structures. Currently supported\n * are Wolfram Kriesings' PEAR Tree class, and Richard Heyes' (me!)\n * Tree class (available here: http://www.phpguru.org/). This\n * method is intended to be used statically, eg:\n * $treeMenu = &HTML_TreeMenu::createFromStructure($myTreeStructureObj);\n *\n * @param array $params An array of parameters that determine\n * how the import happens. This can consist of:\n * structure => The tree structure\n * type => The type of the structure, currently\n * can be either 'heyes' or 'kriesing'\n * nodeOptions => Default options for each node\n *\n * @return object The resulting HTML_TreeMenu object\n */\n function createFromStructure($params)\n {\n if (!isset($params['nodeOptions'])) {\n $params['nodeOptions'] = array();\n }",
" switch (@$params['type']) {",
" /**\n * Wolfram Kriesings' PEAR Tree class\n */\n case 'kriesing':\n $className = strtolower(get_class($params['structure']->dataSourceClass));\n $isXMLStruct = strpos($className, '_xml') !== false ? true : false;",
" // Get the entire tree, the $nodes are sorted like in the tree view\n // from top to bottom, so we can easily put them in the nodes\n $nodes = $params['structure']->getNode();",
" // Make a new menu and fill it with the values from the tree\n $treeMenu = new HTML_TreeMenu();\n $curNode[0] = &$treeMenu; // we need the current node as the reference to the",
" foreach ($nodes as $aNode) {\n $events = array();\n $data = array();",
" // In an XML, all the attributes are saved in an array, but since they might be\n // used as the parameters, we simply extract them here if we handle an XML-structure\n if ($isXMLStruct && sizeof($aNode['attributes'])) {\n foreach ($aNode['attributes'] as $key => $val) {\n if (!$aNode[$key]) { // dont overwrite existing values\n $aNode[$key] = $val;\n }\n }\n }",
" // Process all the data that are saved in $aNode and put them in the data and/or events array\n foreach ($aNode as $key => $val) {\n if (!is_array($val)) {\n // Dont get the recursive data in here! they are always arrays\n if (substr($key, 0, 2) == 'on') { // get the events\n $events[$key] = $val;\n }",
" // I put it in data too, so in case an options starts with 'on' its also passed to the node ... not too cool i know\n $data[$key] = $val;\n }\n }",
" // Normally the text is in 'name' in the Tree class, so we check both but 'text' is used if found\n $data['text'] = $aNode['text'] ? $aNode['text'] : $aNode['name'];",
" // Add the item to the proper node\n $thisNode = &$curNode[$aNode['level']]->addItem(new HTML_TreeNode($data, $events));\n $curNode[$aNode['level'] + 1] = &$thisNode;\n }\n break;",
" /**\n * Richard Heyes' (me!) second (array based) Tree class\n */\n case 'heyes_array':\n // Need to create a HTML_TreeMenu object ?\n if (!isset($params['treeMenu'])) {\n $treeMenu = new HTML_TreeMenu();\n $parentID = 0;\n } else {\n $treeMenu = &$params['treeMenu'];\n $parentID = $params['parentID'];\n }",
" // Loop thru the trees nodes\n foreach ($params['structure']->getChildren($parentID) as $nodeID) {\n $data = $params['structure']->getData($nodeID);\n $parentNode = &$treeMenu->addItem(new HTML_TreeNode(array_merge($params['nodeOptions'], $data)));",
" // Recurse ?\n if ($params['structure']->hasChildren($nodeID)) {\n $recurseParams['type'] = 'heyes_array';\n $recurseParams['parentID'] = $nodeID;\n $recurseParams['nodeOptions'] = $params['nodeOptions'];\n $recurseParams['structure'] = &$params['structure'];\n $recurseParams['treeMenu'] = &$parentNode;\n HTML_TreeMenu::createFromStructure($recurseParams);\n }\n }\n break;",
" /**\n * Richard Heyes' (me!) original OO based Tree class\n */\n case 'heyes':\n default:\n // Need to create a HTML_TreeMenu object ?\n if (!isset($params['treeMenu'])) {\n $treeMenu = new HTML_TreeMenu();\n } else {\n $treeMenu = &$params['treeMenu'];\n }",
" // Loop thru the trees nodes\n foreach ($params['structure']->nodes->nodes as $node) {\n $tag = $node->getTag();\n $parentNode = &$treeMenu->addItem(new HTML_TreeNode(array_merge($params['nodeOptions'], $tag)));",
" // Recurse ?\n if (!empty($node->nodes->nodes)) {\n $recurseParams['structure'] = $node;\n $recurseParams['nodeOptions'] = $params['nodeOptions'];\n $recurseParams['treeMenu'] = &$parentNode;\n HTML_TreeMenu::createFromStructure($recurseParams);\n }\n }\n break;\n }",
" return $treeMenu;\n }",
" /**\n * Creates a treeMenu from XML. The structure of your XML should be\n * like so:\n *\n * <treemenu>\n * <node text=\"First node\" icon=\"folder.gif\" expandedIcon=\"folder-expanded.gif\" />\n * <node text=\"Second node\" icon=\"folder.gif\" expandedIcon=\"folder-expanded.gif\">\n * <node text=\"Sub node\" icon=\"folder.gif\" expandedIcon=\"folder-expanded.gif\" />\n * </node>\n * <node text=\"Third node\" icon=\"folder.gif\" expandedIcon=\"folder-expanded.gif\">\n * </treemenu>\n *\n * Any of the options you can supply to the HTML_TreeNode constructor can be supplied as\n * attributes to the <node> tag. If there are no subnodes for a particular node, you can\n * use the XML shortcut <node ... /> instead of <node ... ></node>. The $xml argument can\n * be either the XML as a string, or an pre-created XML_Tree object. Also, this method\n * REQUIRES my own Tree class to work (http://phpguru.org/tree.html). If this has not\n * been include()ed or require()ed this method will die().\n *\n * @param mixed $xml This can be either a string containing the XML, or an XML_Tree object\n * (the PEAR::XML_Tree package).\n * @return object The HTML_TreeMenu object\n */\n function createFromXML($xml)\n {\n if (!class_exists('Tree')) {\n die('Could not find Tree class');\n }",
" // Supplied $xml is a string\n if (is_string($xml)) {\n require_once('XML/Tree.php');\n $xmlTree = new XML_Tree();\n $xmlTree->getTreeFromString($xml);",
" // Supplied $xml is an XML_Tree object\n } else {\n $xmlTree = $xml;\n }",
" // Now process the XML_Tree object, setting the XML attributes\n // to be the tag data (with out the XML tag name or contents).\n $treeStructure = Tree::createFromXMLTree($xmlTree, true);\n $treeStructure->nodes->traverse(create_function('&$node', '$tagData = $node->getTag(); $node->setTag($tagData[\"attributes\"]);'));",
"\n return HTML_TreeMenu::createFromStructure(array('structure' => $treeStructure));\n }\n} // HTML_TreeMenu",
"\n/**\n* HTML_TreeNode class\n*\n* This class is supplementary to the above and provides a way to\n* add nodes to the tree. A node can have other nodes added to it.\n*\n* @author Richard Heyes <richard@php.net>\n* @author Harald Radi <harald.radi@nme.at>\n* @access public\n* @package HTML_TreeMenu\n*/\nclass HTML_TreeNode\n{\n /**\n * The text for this node.\n * @var string\n */\n var $text;",
" /**\n * The link for this node.\n * @var string\n */\n var $link;",
" /**\n * The icon for this node.\n * @var string\n */\n var $icon;",
" /**\n * The icon to show when expanded for this node.\n * @var string\n */\n var $expandedIcon;",
" /**\n * The css class for this node\n * @var string\n */\n var $cssClass;",
" /**\n * The link target for this node\n * @var string\n */\n var $linkTarget;",
" /**\n * Indexed array of subnodes\n * @var array\n */\n var $items;",
" /**\n * Whether this node is expanded or not\n * @var bool\n */\n var $expanded;",
" /**\n * Whether this node is dynamic or not\n * @var bool\n */\n var $isDynamic;",
" /**\n * Should this node be made visible?\n * @var bool\n */\n var $ensureVisible;",
" /**\n * The parent node. Null if top level\n * @var object\n */\n var $parent;",
" /**\n * Unique ID of this node\n * @var int\n */\n //commented out because it was causing Documents page to not show\n //because of this redeclaration of $parent. I do not know what the\n // author's intention was in using this name twice or if it was a mistake\n //var $parent;",
" /**\n * Javascript event handlers;\n * @var array\n */\n var $events;",
" var $id;",
" /**\n * Constructor\n *\n * @access public\n * @param array $options An array of options which you can pass to change\n * the way this node looks/acts. This can consist of:\n * o text The title of the node, defaults to blank\n * o link The link for the node, defaults to blank\n * o icon The icon for the node, defaults to blank\n * o expandedIcon The icon to show when the node is expanded\n * o cssClass The CSS class for this node, defaults to blank\n * o expanded The default expanded status of this node, defaults to false\n * This doesn't affect non dynamic presentation types\n * o linkTarget Target for the links. Defaults to linkTarget of the\n * HTML_TreeMenu_Presentation.\n * o isDynamic If this node is dynamic or not. Only affects\n * certain presentation types.\n * o ensureVisible If true this node will be made visible despite the expanded\n * settings, and client side persistence. Will not affect\n * some presentation styles, such as Listbox. Default is false\n * @param array $events An array of javascript events and the corresponding event handlers.\n * Additionally to the standard javascript events you can specify handlers\n * for the 'onexpand', 'oncollapse' and 'ontoggle' events which will be fired\n * whenever a node is collapsed and/or expanded.\n */\n function __construct($options = array(), $events = array())\n {\n $this->text = '';\n $this->link = '';\n $this->icon = '';\n $this->expandedIcon = '';\n $this->cssClass = '';\n $this->expanded = false;\n $this->isDynamic = true;\n $this->ensureVisible = false;\n $this->linkTarget = null;\n $this->id = null;",
" $this->parent = null;\n $this->events = $events;",
" foreach ($options as $option => $value) {\n $this->$option = $value;\n }\n }",
" /**\n * Allows setting of various parameters after the initial\n * constructor call. Possible options you can set are:\n * o text\n * o link\n * o icon\n * o cssClass\n * o expanded\n * o isDynamic\n * o ensureVisible\n * ie The same options as in the constructor\n *\n * @access public\n * @param string $option Option to set\n * @param string $value Value to set the option to\n */\n function setOption($option, $value)\n {\n $this->$option = $value;\n }",
" /**\n * Adds a new subnode to this node.\n *\n * @access public\n * @param object $node The new node\n */\n function &addItem(&$node)\n {\n $node->parent = &$this;\n $this->items[] = &$node;",
" /**\n * If the subnode has ensureVisible set it needs\n * to be handled, and all parents set accordingly.\n */\n if ($node->ensureVisible) {\n $this->_ensureVisible();\n }",
" return $this->items[count($this->items) - 1];\n }",
" /**\n * Private function to handle ensureVisible stuff\n *\n * @access private\n */\n function _ensureVisible()\n {\n $this->ensureVisible = true;\n $this->expanded = true;",
" if (!is_null($this->parent)) {\n $this->parent->_ensureVisible();\n }\n }\n} // HTML_TreeNode",
"\n/**\n* HTML_TreeMenu_Presentation class\n*\n* Base class for other presentation classes to\n* inherit from.\n*/\nclass HTML_TreeMenu_Presentation\n{\n /**\n * The TreeMenu structure\n * @var object\n */\n var $menu;",
" /**\n * Base constructor simply sets the menu object\n *\n * @param object $structure The menu structure\n */\n function __construct(&$structure)\n {\n $this->menu = &$structure;\n }",
" /**\n * Prints the HTML generated by the toHTML() method.\n * toHTML() must therefore be defined by the derived\n * class.\n *\n * @access public\n * @param array Options to set. Any options taken by\n * the presentation class can be specified\n * here.\n */\n function printMenu($options = array())\n {\n foreach ($options as $option => $value) {\n $this->$option = $value;\n }",
" echo $this->toHTML();\n }\n}",
"\n/**\n* HTML_TreeMenu_DHTML class\n*\n* This class is a presentation class for the tree structure\n* created using the TreeMenu/TreeNode. It presents the\n* traditional tree, static for browsers that can't handle\n* the DHTML.\n*/\nclass HTML_TreeMenu_DHTML extends HTML_TreeMenu_Presentation\n{\n /**\n * Dynamic status of the treemenu. If true (default) this has no effect. If\n * false it will override all dynamic status vars and set the menu to be\n * fully expanded an non-dynamic.\n */\n var $isDynamic;",
" /**\n * Path to the images\n * @var string\n */\n var $images;",
" /**\n * Target for the links generated\n * @var string\n */\n var $linkTarget;",
" /**\n * Whether to use clientside persistence or not\n * @var bool\n */\n var $userPersistence;",
" /**\n * The default CSS class for the nodes\n */\n var $defaultClass;",
" /**\n * Whether to skip first level branch images\n * @var bool\n */\n var $noTopLevelImages;",
" var $maxDepth;\n var $usePersistence;",
" /**\n * Constructor, takes the tree structure as\n * an argument and an array of options which\n * can consist of:\n * o images - The path to the images folder. Defaults to \"images\"\n * o linkTarget - The target for the link. Defaults to \"_self\"\n * o defaultClass - The default CSS class to apply to a node. Default is none.\n * o usePersistence - Whether to use clientside persistence. This persistence\n * is achieved using cookies. Default is true.\n * o noTopLevelImages - Whether to skip displaying the first level of images if\n * there is multiple top level branches.\n * o maxDepth - The maximum depth of indentation. Useful for ensuring\n * deeply nested trees don't go way off to the right of your\n * page etc. Defaults to no limit.\n *\n * And also a boolean for whether the entire tree is dynamic or not.\n * This overrides any perNode dynamic settings.\n *\n * @param object $structure The menu structure\n * @param array $options Array of options\n * @param bool $isDynamic Whether the tree is dynamic or not\n */\n function __construct(&$structure, $options = array(), $isDynamic = true)\n {\n parent::__construct($structure);\n $this->isDynamic = $isDynamic;",
" // Defaults\n $this->images = 'public/images';\n $this->maxDepth = 0; // No limit\n $this->linkTarget = '_self';\n $this->defaultClass = '';\n $this->usePersistence = true;\n $this->noTopLevelImages = false;",
" foreach ($options as $option => $value) {\n $this->$option = $value;\n }\n }",
" /**\n * Returns the HTML for the menu. This method can be\n * used instead of printMenu() to use the menu system\n * with a template system.\n *\n * @access public\n * @return string The HTML for the menu\n */\n function toHTML()\n {\n static $count = 0;\n $menuObj = 'objTreeMenu_' . ++$count;",
" $html = \"\\n\";\n $html .= '<script>' . \"\\n\\t\";\n $html .= sprintf(\n '%s = new TreeMenu(\"%s\", \"%s\", \"%s\", \"%s\", %s, %s);',\n $menuObj,\n $this->images,\n $menuObj,\n $this->linkTarget,\n $this->defaultClass,\n $this->usePersistence ? 'true' : 'false',\n $this->noTopLevelImages ? 'true' : 'false'\n );",
" $html .= \"\\n\";",
" /**\n * Loop through subnodes\n */\n if (isset($this->menu->items)) {\n for ($i = 0; $i < count($this->menu->items); $i++) {\n $html .= $this->_nodeToHTML($this->menu->items[$i], $menuObj);\n }\n }",
" $html .= sprintf(\"\\n\\t%s.drawMenu();\", $menuObj);\n $html .= sprintf(\"\\n\\t%s.writeOutput();\", $menuObj);",
" if ($this->usePersistence && $this->isDynamic) {\n $html .= sprintf(\"\\n\\t%s.resetBranches();\", $menuObj);\n }",
" $html .= \"\\n</script>\";",
" return $html;\n }",
" /**\n * Prints a node of the menu\n *\n * @access private\n */\n function _nodeToHTML($nodeObj, $prefix, $return = 'newNode', $currentDepth = 0, $maxDepthPrefix = null)\n {\n $prefix = empty($maxDepthPrefix) ? $prefix : $maxDepthPrefix;",
" $expanded = $this->isDynamic ? ($nodeObj->expanded ? 'true' : 'false') : 'true';\n $isDynamic = $this->isDynamic ? ($nodeObj->isDynamic ? 'true' : 'false') : 'false';\n $html = sprintf(",
" \"\\t %s = %s.addItem(new TreeNode('%s', %s, %s, %s, %s, '%s', '%s', %s));\\n\",",
" $return,\n $prefix,",
" attr($nodeObj->text),\n !empty($nodeObj->icon) ? \"'\" . $nodeObj->icon . \"'\" : 'null',\n !empty($nodeObj->link) ? \"'\" . attr($nodeObj->link) . \"'\" : 'null',",
" $expanded,\n $isDynamic,\n $nodeObj->cssClass,\n $nodeObj->linkTarget,",
" !empty($nodeObj->expandedIcon) ? \"'\" . $nodeObj->expandedIcon . \"'\" : 'null'",
" );",
" foreach ($nodeObj->events as $event => $handler) {\n $html .= sprintf(\n \"\\t %s.setEvent('%s', '%s');\\n\",\n $return,\n $event,\n str_replace(array(\"\\r\", \"\\n\", \"'\"), array('\\r', '\\n', \"\\'\"), $handler)\n );\n }",
" if ($this->maxDepth > 0 and $currentDepth == $this->maxDepth) {\n $maxDepthPrefix = $prefix;\n }",
" /**\n * Loop through subnodes\n */\n if (!empty($nodeObj->items)) {\n for ($i = 0; $i < count($nodeObj->items); $i++) {\n $html .= $this->_nodeToHTML($nodeObj->items[$i], $return, $return . '_' . ($i + 1), $currentDepth + 1, $maxDepthPrefix);\n }\n }",
" return $html;\n }\n} // End class HTML_TreeMenu_DHTML",
"\n/**\n* HTML_TreeMenu_Listbox class\n*\n* This class presents the menu as a listbox\n*/\nclass HTML_TreeMenu_Listbox extends HTML_TreeMenu_Presentation\n{\n /**\n * The text that is displayed in the first option\n * @var string\n */\n var $promoText;",
" /**\n * The character used for indentation\n * @var string\n */\n var $indentChar;",
" /**\n * How many of the indent chars to use\n * per indentation level\n * @var integer\n */\n var $indentNum;",
" /**\n * Target for the links generated\n * @var string\n */\n var $linkTarget;",
" var $submitText;",
" /**\n * Constructor\n *\n * @param object $structure The menu structure\n * @param array $options Options whic affect the display of the listbox.\n * These can consist of:\n * o promoText The text that appears at the the top of the listbox\n * Defaults to \"Select...\"\n * o indentChar The character to use for indenting the nodes\n * Defaults to \" \"\n * o indentNum How many of the indentChars to use per indentation level\n * Defaults to 2\n * o linkTarget Target for the links. Defaults to \"_self\"\n * o submitText Text for the submit button. Defaults to \"Go\"\n */\n function __construct($structure, $options = array())\n {\n parent::__construct($structure);",
" $this->promoText = null;\n $this->indentChar = ' ';\n $this->indentNum = 2;\n $this->linkTarget = '_self';\n $this->submitText = 'Go';",
" foreach ($options as $option => $value) {\n $this->$option = $value;\n }\n }",
" /**\n * Returns the HTML generated\n */\n function toHTML()\n {\n static $count = 0;\n $nodeHTML = '';",
" /**\n * Loop through subnodes\n */\n if (isset($this->menu->items)) {\n for ($i = 0; $i < count($this->menu->items); $i++) {\n $nodeHTML .= $this->_nodeToHTML($this->menu->items[$i]);\n }\n }",
" if ($this->promoText) {\n return sprintf('<option value=\"\">%s</option>%s', text($this->promoText ?? ''), $nodeHTML);\n } else {\n return $nodeHTML;\n }\n }",
" /**\n * Returns HTML for a single node\n *\n * @access private\n */\n function _nodeToHTML($node, $prefix = '')\n {\n $html = sprintf('<option value=\"%s\">%s%s</option>', attr($node->id), $prefix, text($node->text));",
" /**\n * Loop through subnodes\n */\n if (isset($node->items)) {\n for ($i = 0; $i < count($node->items); $i++) {\n $html .= $this->_nodeToHTML($node->items[$i], $prefix . str_repeat($this->indentChar, $this->indentNum));\n }\n }",
" return $html;\n }\n} // End class HTML_TreeMenu_Listbox"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [119, 252, 57, 694], "buggy_code_start_loc": [118, 251, 56, 683], "filenames": ["interface/main/messages/messages.php", "interface/main/messages/save.php", "interface/patient_file/front_payment_cc.php", "library/classes/TreeMenu.php"], "fixing_code_end_loc": [119, 252, 57, 694], "fixing_code_start_loc": [118, 251, 56, 683], "message": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:open-emr:openemr:*:*:*:*:*:*:*:*", "matchCriteriaId": "C397DED6-5350-43A0-B65D-FB92E8587CED", "versionEndExcluding": "7.0.0.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2."}], "evaluatorComment": null, "id": "CVE-2022-4503", "lastModified": "2022-12-16T15:11:19.380", "metrics": {"cvssMetricV2": null, "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:N", "version": "3.0"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-12-15T01:15:10.937", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/4cba644c-a2f5-4ed7-af5d-f2cab1895e13"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, "type": "CWE-79"}
| 365
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"// +-----------------------------------------------------------------------+\n// | Copyright (c) 2002-2003, Richard Heyes, Harald Radi |\n// | All rights reserved. |\n// | |\n// | Redistribution and use in source and binary forms, with or without |\n// | modification, are permitted provided that the following conditions |\n// | are met: |\n// | |\n// | o Redistributions of source code must retain the above copyright |\n// | notice, this list of conditions and the following disclaimer. |\n// | o Redistributions in binary form must reproduce the above copyright |\n// | notice, this list of conditions and the following disclaimer in the |\n// | documentation and/or other materials provided with the distribution.|\n// | o The names of the authors may not be used to endorse or promote |\n// | products derived from this software without specific prior written |\n// | permission. |\n// | |\n// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |\n// | \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |\n// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |\n// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |\n// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |\n// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |\n// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |\n// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |\n// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |\n// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |\n// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |\n// | |\n// +-----------------------------------------------------------------------+\n// | Author: Richard Heyes <richard@phpguru.org> |\n// | Harald Radi <harald.radi@nme.at> |\n// +-----------------------------------------------------------------------+\n//\n// $Id$",
"/**\n* HTML_TreeMenu Class\n*\n* A simple couple of PHP classes and some not so simple\n* Jabbascript which produces a tree menu. In IE this menu\n* is dynamic, with branches being collapsable. In IE5+ the\n* status of the collapsed/open branches persists across page\n* refreshes.In any other browser the tree is static. Code is\n* based on work of Harald Radi.\n*\n* Usage.\n*\n* After installing the package, copy the example php script to\n* your servers document root. Also place the TreeMenu.js and the\n* images folder in the same place. Running the script should\n* then produce the tree.\n*\n* Thanks go to Chip Chapin (http://www.chipchapin.com) for many\n* excellent ideas and improvements.\n*\n* @author Richard Heyes <richard@php.net>\n* @author Harald Radi <harald.radi@nme.at>\n* @access public\n* @package HTML_TreeMenu\n*/",
"class HTML_TreeMenu\n{\n /**\n * Indexed array of subnodes\n * @var array\n */\n var $items;",
" /**\n * Constructor\n *\n * @access public\n */\n function __construct()\n {\n // Not much to do here :(\n }",
" /**\n * This function adds an item to the the tree.\n *\n * @access public\n * @param object $node The node to add. This object should be\n * a HTML_TreeNode object.\n * @return object Returns a reference to the new node inside\n * the tree.\n */\n function &addItem(&$node)\n {\n $this->items[] = &$node;\n return $this->items[count($this->items) - 1];\n }",
" /**\n * Import method for creating HTML_TreeMenu objects/structures\n * out of existing tree objects/structures. Currently supported\n * are Wolfram Kriesings' PEAR Tree class, and Richard Heyes' (me!)\n * Tree class (available here: http://www.phpguru.org/). This\n * method is intended to be used statically, eg:\n * $treeMenu = &HTML_TreeMenu::createFromStructure($myTreeStructureObj);\n *\n * @param array $params An array of parameters that determine\n * how the import happens. This can consist of:\n * structure => The tree structure\n * type => The type of the structure, currently\n * can be either 'heyes' or 'kriesing'\n * nodeOptions => Default options for each node\n *\n * @return object The resulting HTML_TreeMenu object\n */\n function createFromStructure($params)\n {\n if (!isset($params['nodeOptions'])) {\n $params['nodeOptions'] = array();\n }",
" switch (@$params['type']) {",
" /**\n * Wolfram Kriesings' PEAR Tree class\n */\n case 'kriesing':\n $className = strtolower(get_class($params['structure']->dataSourceClass));\n $isXMLStruct = strpos($className, '_xml') !== false ? true : false;",
" // Get the entire tree, the $nodes are sorted like in the tree view\n // from top to bottom, so we can easily put them in the nodes\n $nodes = $params['structure']->getNode();",
" // Make a new menu and fill it with the values from the tree\n $treeMenu = new HTML_TreeMenu();\n $curNode[0] = &$treeMenu; // we need the current node as the reference to the",
" foreach ($nodes as $aNode) {\n $events = array();\n $data = array();",
" // In an XML, all the attributes are saved in an array, but since they might be\n // used as the parameters, we simply extract them here if we handle an XML-structure\n if ($isXMLStruct && sizeof($aNode['attributes'])) {\n foreach ($aNode['attributes'] as $key => $val) {\n if (!$aNode[$key]) { // dont overwrite existing values\n $aNode[$key] = $val;\n }\n }\n }",
" // Process all the data that are saved in $aNode and put them in the data and/or events array\n foreach ($aNode as $key => $val) {\n if (!is_array($val)) {\n // Dont get the recursive data in here! they are always arrays\n if (substr($key, 0, 2) == 'on') { // get the events\n $events[$key] = $val;\n }",
" // I put it in data too, so in case an options starts with 'on' its also passed to the node ... not too cool i know\n $data[$key] = $val;\n }\n }",
" // Normally the text is in 'name' in the Tree class, so we check both but 'text' is used if found\n $data['text'] = $aNode['text'] ? $aNode['text'] : $aNode['name'];",
" // Add the item to the proper node\n $thisNode = &$curNode[$aNode['level']]->addItem(new HTML_TreeNode($data, $events));\n $curNode[$aNode['level'] + 1] = &$thisNode;\n }\n break;",
" /**\n * Richard Heyes' (me!) second (array based) Tree class\n */\n case 'heyes_array':\n // Need to create a HTML_TreeMenu object ?\n if (!isset($params['treeMenu'])) {\n $treeMenu = new HTML_TreeMenu();\n $parentID = 0;\n } else {\n $treeMenu = &$params['treeMenu'];\n $parentID = $params['parentID'];\n }",
" // Loop thru the trees nodes\n foreach ($params['structure']->getChildren($parentID) as $nodeID) {\n $data = $params['structure']->getData($nodeID);\n $parentNode = &$treeMenu->addItem(new HTML_TreeNode(array_merge($params['nodeOptions'], $data)));",
" // Recurse ?\n if ($params['structure']->hasChildren($nodeID)) {\n $recurseParams['type'] = 'heyes_array';\n $recurseParams['parentID'] = $nodeID;\n $recurseParams['nodeOptions'] = $params['nodeOptions'];\n $recurseParams['structure'] = &$params['structure'];\n $recurseParams['treeMenu'] = &$parentNode;\n HTML_TreeMenu::createFromStructure($recurseParams);\n }\n }\n break;",
" /**\n * Richard Heyes' (me!) original OO based Tree class\n */\n case 'heyes':\n default:\n // Need to create a HTML_TreeMenu object ?\n if (!isset($params['treeMenu'])) {\n $treeMenu = new HTML_TreeMenu();\n } else {\n $treeMenu = &$params['treeMenu'];\n }",
" // Loop thru the trees nodes\n foreach ($params['structure']->nodes->nodes as $node) {\n $tag = $node->getTag();\n $parentNode = &$treeMenu->addItem(new HTML_TreeNode(array_merge($params['nodeOptions'], $tag)));",
" // Recurse ?\n if (!empty($node->nodes->nodes)) {\n $recurseParams['structure'] = $node;\n $recurseParams['nodeOptions'] = $params['nodeOptions'];\n $recurseParams['treeMenu'] = &$parentNode;\n HTML_TreeMenu::createFromStructure($recurseParams);\n }\n }\n break;\n }",
" return $treeMenu;\n }",
" /**\n * Creates a treeMenu from XML. The structure of your XML should be\n * like so:\n *\n * <treemenu>\n * <node text=\"First node\" icon=\"folder.gif\" expandedIcon=\"folder-expanded.gif\" />\n * <node text=\"Second node\" icon=\"folder.gif\" expandedIcon=\"folder-expanded.gif\">\n * <node text=\"Sub node\" icon=\"folder.gif\" expandedIcon=\"folder-expanded.gif\" />\n * </node>\n * <node text=\"Third node\" icon=\"folder.gif\" expandedIcon=\"folder-expanded.gif\">\n * </treemenu>\n *\n * Any of the options you can supply to the HTML_TreeNode constructor can be supplied as\n * attributes to the <node> tag. If there are no subnodes for a particular node, you can\n * use the XML shortcut <node ... /> instead of <node ... ></node>. The $xml argument can\n * be either the XML as a string, or an pre-created XML_Tree object. Also, this method\n * REQUIRES my own Tree class to work (http://phpguru.org/tree.html). If this has not\n * been include()ed or require()ed this method will die().\n *\n * @param mixed $xml This can be either a string containing the XML, or an XML_Tree object\n * (the PEAR::XML_Tree package).\n * @return object The HTML_TreeMenu object\n */\n function createFromXML($xml)\n {\n if (!class_exists('Tree')) {\n die('Could not find Tree class');\n }",
" // Supplied $xml is a string\n if (is_string($xml)) {\n require_once('XML/Tree.php');\n $xmlTree = new XML_Tree();\n $xmlTree->getTreeFromString($xml);",
" // Supplied $xml is an XML_Tree object\n } else {\n $xmlTree = $xml;\n }",
" // Now process the XML_Tree object, setting the XML attributes\n // to be the tag data (with out the XML tag name or contents).\n $treeStructure = Tree::createFromXMLTree($xmlTree, true);\n $treeStructure->nodes->traverse(create_function('&$node', '$tagData = $node->getTag(); $node->setTag($tagData[\"attributes\"]);'));",
"\n return HTML_TreeMenu::createFromStructure(array('structure' => $treeStructure));\n }\n} // HTML_TreeMenu",
"\n/**\n* HTML_TreeNode class\n*\n* This class is supplementary to the above and provides a way to\n* add nodes to the tree. A node can have other nodes added to it.\n*\n* @author Richard Heyes <richard@php.net>\n* @author Harald Radi <harald.radi@nme.at>\n* @access public\n* @package HTML_TreeMenu\n*/\nclass HTML_TreeNode\n{\n /**\n * The text for this node.\n * @var string\n */\n var $text;",
" /**\n * The link for this node.\n * @var string\n */\n var $link;",
" /**\n * The icon for this node.\n * @var string\n */\n var $icon;",
" /**\n * The icon to show when expanded for this node.\n * @var string\n */\n var $expandedIcon;",
" /**\n * The css class for this node\n * @var string\n */\n var $cssClass;",
" /**\n * The link target for this node\n * @var string\n */\n var $linkTarget;",
" /**\n * Indexed array of subnodes\n * @var array\n */\n var $items;",
" /**\n * Whether this node is expanded or not\n * @var bool\n */\n var $expanded;",
" /**\n * Whether this node is dynamic or not\n * @var bool\n */\n var $isDynamic;",
" /**\n * Should this node be made visible?\n * @var bool\n */\n var $ensureVisible;",
" /**\n * The parent node. Null if top level\n * @var object\n */\n var $parent;",
" /**\n * Unique ID of this node\n * @var int\n */\n //commented out because it was causing Documents page to not show\n //because of this redeclaration of $parent. I do not know what the\n // author's intention was in using this name twice or if it was a mistake\n //var $parent;",
" /**\n * Javascript event handlers;\n * @var array\n */\n var $events;",
" var $id;",
" /**\n * Constructor\n *\n * @access public\n * @param array $options An array of options which you can pass to change\n * the way this node looks/acts. This can consist of:\n * o text The title of the node, defaults to blank\n * o link The link for the node, defaults to blank\n * o icon The icon for the node, defaults to blank\n * o expandedIcon The icon to show when the node is expanded\n * o cssClass The CSS class for this node, defaults to blank\n * o expanded The default expanded status of this node, defaults to false\n * This doesn't affect non dynamic presentation types\n * o linkTarget Target for the links. Defaults to linkTarget of the\n * HTML_TreeMenu_Presentation.\n * o isDynamic If this node is dynamic or not. Only affects\n * certain presentation types.\n * o ensureVisible If true this node will be made visible despite the expanded\n * settings, and client side persistence. Will not affect\n * some presentation styles, such as Listbox. Default is false\n * @param array $events An array of javascript events and the corresponding event handlers.\n * Additionally to the standard javascript events you can specify handlers\n * for the 'onexpand', 'oncollapse' and 'ontoggle' events which will be fired\n * whenever a node is collapsed and/or expanded.\n */\n function __construct($options = array(), $events = array())\n {\n $this->text = '';\n $this->link = '';\n $this->icon = '';\n $this->expandedIcon = '';\n $this->cssClass = '';\n $this->expanded = false;\n $this->isDynamic = true;\n $this->ensureVisible = false;\n $this->linkTarget = null;\n $this->id = null;",
" $this->parent = null;\n $this->events = $events;",
" foreach ($options as $option => $value) {\n $this->$option = $value;\n }\n }",
" /**\n * Allows setting of various parameters after the initial\n * constructor call. Possible options you can set are:\n * o text\n * o link\n * o icon\n * o cssClass\n * o expanded\n * o isDynamic\n * o ensureVisible\n * ie The same options as in the constructor\n *\n * @access public\n * @param string $option Option to set\n * @param string $value Value to set the option to\n */\n function setOption($option, $value)\n {\n $this->$option = $value;\n }",
" /**\n * Adds a new subnode to this node.\n *\n * @access public\n * @param object $node The new node\n */\n function &addItem(&$node)\n {\n $node->parent = &$this;\n $this->items[] = &$node;",
" /**\n * If the subnode has ensureVisible set it needs\n * to be handled, and all parents set accordingly.\n */\n if ($node->ensureVisible) {\n $this->_ensureVisible();\n }",
" return $this->items[count($this->items) - 1];\n }",
" /**\n * Private function to handle ensureVisible stuff\n *\n * @access private\n */\n function _ensureVisible()\n {\n $this->ensureVisible = true;\n $this->expanded = true;",
" if (!is_null($this->parent)) {\n $this->parent->_ensureVisible();\n }\n }\n} // HTML_TreeNode",
"\n/**\n* HTML_TreeMenu_Presentation class\n*\n* Base class for other presentation classes to\n* inherit from.\n*/\nclass HTML_TreeMenu_Presentation\n{\n /**\n * The TreeMenu structure\n * @var object\n */\n var $menu;",
" /**\n * Base constructor simply sets the menu object\n *\n * @param object $structure The menu structure\n */\n function __construct(&$structure)\n {\n $this->menu = &$structure;\n }",
" /**\n * Prints the HTML generated by the toHTML() method.\n * toHTML() must therefore be defined by the derived\n * class.\n *\n * @access public\n * @param array Options to set. Any options taken by\n * the presentation class can be specified\n * here.\n */\n function printMenu($options = array())\n {\n foreach ($options as $option => $value) {\n $this->$option = $value;\n }",
" echo $this->toHTML();\n }\n}",
"\n/**\n* HTML_TreeMenu_DHTML class\n*\n* This class is a presentation class for the tree structure\n* created using the TreeMenu/TreeNode. It presents the\n* traditional tree, static for browsers that can't handle\n* the DHTML.\n*/\nclass HTML_TreeMenu_DHTML extends HTML_TreeMenu_Presentation\n{\n /**\n * Dynamic status of the treemenu. If true (default) this has no effect. If\n * false it will override all dynamic status vars and set the menu to be\n * fully expanded an non-dynamic.\n */\n var $isDynamic;",
" /**\n * Path to the images\n * @var string\n */\n var $images;",
" /**\n * Target for the links generated\n * @var string\n */\n var $linkTarget;",
" /**\n * Whether to use clientside persistence or not\n * @var bool\n */\n var $userPersistence;",
" /**\n * The default CSS class for the nodes\n */\n var $defaultClass;",
" /**\n * Whether to skip first level branch images\n * @var bool\n */\n var $noTopLevelImages;",
" var $maxDepth;\n var $usePersistence;",
" /**\n * Constructor, takes the tree structure as\n * an argument and an array of options which\n * can consist of:\n * o images - The path to the images folder. Defaults to \"images\"\n * o linkTarget - The target for the link. Defaults to \"_self\"\n * o defaultClass - The default CSS class to apply to a node. Default is none.\n * o usePersistence - Whether to use clientside persistence. This persistence\n * is achieved using cookies. Default is true.\n * o noTopLevelImages - Whether to skip displaying the first level of images if\n * there is multiple top level branches.\n * o maxDepth - The maximum depth of indentation. Useful for ensuring\n * deeply nested trees don't go way off to the right of your\n * page etc. Defaults to no limit.\n *\n * And also a boolean for whether the entire tree is dynamic or not.\n * This overrides any perNode dynamic settings.\n *\n * @param object $structure The menu structure\n * @param array $options Array of options\n * @param bool $isDynamic Whether the tree is dynamic or not\n */\n function __construct(&$structure, $options = array(), $isDynamic = true)\n {\n parent::__construct($structure);\n $this->isDynamic = $isDynamic;",
" // Defaults\n $this->images = 'public/images';\n $this->maxDepth = 0; // No limit\n $this->linkTarget = '_self';\n $this->defaultClass = '';\n $this->usePersistence = true;\n $this->noTopLevelImages = false;",
" foreach ($options as $option => $value) {\n $this->$option = $value;\n }\n }",
" /**\n * Returns the HTML for the menu. This method can be\n * used instead of printMenu() to use the menu system\n * with a template system.\n *\n * @access public\n * @return string The HTML for the menu\n */\n function toHTML()\n {\n static $count = 0;\n $menuObj = 'objTreeMenu_' . ++$count;",
" $html = \"\\n\";\n $html .= '<script>' . \"\\n\\t\";\n $html .= sprintf(\n '%s = new TreeMenu(\"%s\", \"%s\", \"%s\", \"%s\", %s, %s);',\n $menuObj,\n $this->images,\n $menuObj,\n $this->linkTarget,\n $this->defaultClass,\n $this->usePersistence ? 'true' : 'false',\n $this->noTopLevelImages ? 'true' : 'false'\n );",
" $html .= \"\\n\";",
" /**\n * Loop through subnodes\n */\n if (isset($this->menu->items)) {\n for ($i = 0; $i < count($this->menu->items); $i++) {\n $html .= $this->_nodeToHTML($this->menu->items[$i], $menuObj);\n }\n }",
" $html .= sprintf(\"\\n\\t%s.drawMenu();\", $menuObj);\n $html .= sprintf(\"\\n\\t%s.writeOutput();\", $menuObj);",
" if ($this->usePersistence && $this->isDynamic) {\n $html .= sprintf(\"\\n\\t%s.resetBranches();\", $menuObj);\n }",
" $html .= \"\\n</script>\";",
" return $html;\n }",
" /**\n * Prints a node of the menu\n *\n * @access private\n */\n function _nodeToHTML($nodeObj, $prefix, $return = 'newNode', $currentDepth = 0, $maxDepthPrefix = null)\n {\n $prefix = empty($maxDepthPrefix) ? $prefix : $maxDepthPrefix;",
" $expanded = $this->isDynamic ? ($nodeObj->expanded ? 'true' : 'false') : 'true';\n $isDynamic = $this->isDynamic ? ($nodeObj->isDynamic ? 'true' : 'false') : 'false';\n $html = sprintf(",
" \"\\t %s = %s.addItem(new TreeNode(jsAttr(%s), jsAttr(%s), jsAttr(%s), %s, %s, '%s', '%s', jsAttr(%s)));\\n\",",
" $return,\n $prefix,",
" js_escape($nodeObj->text),\n !empty($nodeObj->icon) ? js_escape($nodeObj->icon) : 'null',\n !empty($nodeObj->link) ? js_escape($nodeObj->link) : 'null',",
" $expanded,\n $isDynamic,\n $nodeObj->cssClass,\n $nodeObj->linkTarget,",
" !empty($nodeObj->expandedIcon) ? js_escape($nodeObj->expandedIcon) : 'null'",
" );",
" foreach ($nodeObj->events as $event => $handler) {\n $html .= sprintf(\n \"\\t %s.setEvent('%s', '%s');\\n\",\n $return,\n $event,\n str_replace(array(\"\\r\", \"\\n\", \"'\"), array('\\r', '\\n', \"\\'\"), $handler)\n );\n }",
" if ($this->maxDepth > 0 and $currentDepth == $this->maxDepth) {\n $maxDepthPrefix = $prefix;\n }",
" /**\n * Loop through subnodes\n */\n if (!empty($nodeObj->items)) {\n for ($i = 0; $i < count($nodeObj->items); $i++) {\n $html .= $this->_nodeToHTML($nodeObj->items[$i], $return, $return . '_' . ($i + 1), $currentDepth + 1, $maxDepthPrefix);\n }\n }",
" return $html;\n }\n} // End class HTML_TreeMenu_DHTML",
"\n/**\n* HTML_TreeMenu_Listbox class\n*\n* This class presents the menu as a listbox\n*/\nclass HTML_TreeMenu_Listbox extends HTML_TreeMenu_Presentation\n{\n /**\n * The text that is displayed in the first option\n * @var string\n */\n var $promoText;",
" /**\n * The character used for indentation\n * @var string\n */\n var $indentChar;",
" /**\n * How many of the indent chars to use\n * per indentation level\n * @var integer\n */\n var $indentNum;",
" /**\n * Target for the links generated\n * @var string\n */\n var $linkTarget;",
" var $submitText;",
" /**\n * Constructor\n *\n * @param object $structure The menu structure\n * @param array $options Options whic affect the display of the listbox.\n * These can consist of:\n * o promoText The text that appears at the the top of the listbox\n * Defaults to \"Select...\"\n * o indentChar The character to use for indenting the nodes\n * Defaults to \" \"\n * o indentNum How many of the indentChars to use per indentation level\n * Defaults to 2\n * o linkTarget Target for the links. Defaults to \"_self\"\n * o submitText Text for the submit button. Defaults to \"Go\"\n */\n function __construct($structure, $options = array())\n {\n parent::__construct($structure);",
" $this->promoText = null;\n $this->indentChar = ' ';\n $this->indentNum = 2;\n $this->linkTarget = '_self';\n $this->submitText = 'Go';",
" foreach ($options as $option => $value) {\n $this->$option = $value;\n }\n }",
" /**\n * Returns the HTML generated\n */\n function toHTML()\n {\n static $count = 0;\n $nodeHTML = '';",
" /**\n * Loop through subnodes\n */\n if (isset($this->menu->items)) {\n for ($i = 0; $i < count($this->menu->items); $i++) {\n $nodeHTML .= $this->_nodeToHTML($this->menu->items[$i]);\n }\n }",
" if ($this->promoText) {\n return sprintf('<option value=\"\">%s</option>%s', text($this->promoText ?? ''), $nodeHTML);\n } else {\n return $nodeHTML;\n }\n }",
" /**\n * Returns HTML for a single node\n *\n * @access private\n */\n function _nodeToHTML($node, $prefix = '')\n {\n $html = sprintf('<option value=\"%s\">%s%s</option>', attr($node->id), $prefix, text($node->text));",
" /**\n * Loop through subnodes\n */\n if (isset($node->items)) {\n for ($i = 0; $i < count($node->items); $i++) {\n $html .= $this->_nodeToHTML($node->items[$i], $prefix . str_repeat($this->indentChar, $this->indentNum));\n }\n }",
" return $html;\n }\n} // End class HTML_TreeMenu_Listbox"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [119, 252, 57, 694], "buggy_code_start_loc": [118, 251, 56, 683], "filenames": ["interface/main/messages/messages.php", "interface/main/messages/save.php", "interface/patient_file/front_payment_cc.php", "library/classes/TreeMenu.php"], "fixing_code_end_loc": [119, 252, 57, 694], "fixing_code_start_loc": [118, 251, 56, 683], "message": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:open-emr:openemr:*:*:*:*:*:*:*:*", "matchCriteriaId": "C397DED6-5350-43A0-B65D-FB92E8587CED", "versionEndExcluding": "7.0.0.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Cross-site Scripting (XSS) - Generic in GitHub repository openemr/openemr prior to 7.0.0.2."}], "evaluatorComment": null, "id": "CVE-2022-4503", "lastModified": "2022-12-16T15:11:19.380", "metrics": {"cvssMetricV2": null, "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:N", "version": "3.0"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-12-15T01:15:10.937", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/4cba644c-a2f5-4ed7-af5d-f2cab1895e13"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/openemr/openemr/commit/37d7ed4855763fc588485f05b2e9cc0944f71879"}, "type": "CWE-79"}
| 365
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# This file is automatically @generated by Cargo.\n# It is not intended for manual editing.\nversion = 3",
"[[package]]\nname = \"Simple-Wayland-HotKey-Daemon\"\nversion = \"1.1.7\"\ndependencies = [\n \"clap\",\n \"env_logger\",\n \"evdev\",\n \"itertools\",\n \"log\",\n \"nix\",\n \"signal-hook\",\n \"signal-hook-tokio\",\n \"sysinfo\",\n \"tokio\",\n \"tokio-stream\",\n]",
"[[package]]\nname = \"aho-corasick\"\nversion = \"0.7.18\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f\"\ndependencies = [\n \"memchr\",\n]",
"[[package]]\nname = \"atty\"\nversion = \"0.2.14\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8\"\ndependencies = [\n \"hermit-abi\",\n \"libc\",\n \"winapi\",\n]",
"[[package]]\nname = \"autocfg\"\nversion = \"1.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa\"",
"[[package]]\nname = \"bitflags\"\nversion = \"1.3.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a\"",
"[[package]]\nname = \"bitvec\"\nversion = \"1.0.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"1489fcb93a5bb47da0462ca93ad252ad6af2145cce58d10d46a83931ba9f016b\"\ndependencies = [\n \"funty\",\n \"radium\",\n \"tap\",\n \"wyz\",\n]",
"[[package]]\nname = \"bytes\"\nversion = \"1.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8\"",
"[[package]]\nname = \"cc\"\nversion = \"1.0.73\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11\"",
"[[package]]\nname = \"cfg-if\"\nversion = \"1.0.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd\"",
"[[package]]\nname = \"clap\"\nversion = \"3.1.6\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123\"\ndependencies = [\n \"atty\",\n \"bitflags\",\n \"indexmap\",\n \"os_str_bytes\",\n \"strsim\",\n \"termcolor\",\n \"textwrap\",\n]",
"[[package]]\nname = \"core-foundation-sys\"\nversion = \"0.8.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc\"",
"[[package]]\nname = \"crossbeam-channel\"",
"version = \"0.5.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa\"",
"dependencies = [\n \"cfg-if\",\n \"crossbeam-utils\",\n]",
"[[package]]\nname = \"crossbeam-deque\"\nversion = \"0.8.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e\"\ndependencies = [\n \"cfg-if\",\n \"crossbeam-epoch\",\n \"crossbeam-utils\",\n]",
"[[package]]\nname = \"crossbeam-epoch\"",
"version = \"0.9.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9\"\ndependencies = [",
" \"cfg-if\",\n \"crossbeam-utils\",\n \"lazy_static\",\n \"memoffset\",\n \"scopeguard\",\n]",
"[[package]]\nname = \"crossbeam-utils\"",
"version = \"0.8.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6\"",
"dependencies = [\n \"cfg-if\",\n \"lazy_static\",\n]",
"[[package]]\nname = \"either\"\nversion = \"1.6.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457\"",
"[[package]]\nname = \"env_logger\"\nversion = \"0.9.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3\"\ndependencies = [\n \"atty\",\n \"humantime\",\n \"log\",\n \"regex\",\n \"termcolor\",\n]",
"[[package]]\nname = \"evdev\"\nversion = \"0.11.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"21eef104bd659ef808f1f84bed9a924e1aebcdd066845b377cd3b52cc497bb9f\"\ndependencies = [\n \"bitvec\",\n \"futures-core\",\n \"libc\",\n \"nix\",\n \"tokio\",\n]",
"[[package]]\nname = \"funty\"\nversion = \"2.0.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c\"",
"[[package]]\nname = \"futures-core\"\nversion = \"0.3.21\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3\"",
"[[package]]\nname = \"hashbrown\"\nversion = \"0.11.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e\"",
"[[package]]\nname = \"hermit-abi\"\nversion = \"0.1.19\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33\"\ndependencies = [\n \"libc\",\n]",
"[[package]]\nname = \"humantime\"\nversion = \"2.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4\"",
"[[package]]\nname = \"indexmap\"\nversion = \"1.8.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223\"\ndependencies = [\n \"autocfg\",\n \"hashbrown\",\n]",
"[[package]]\nname = \"itertools\"\nversion = \"0.10.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3\"\ndependencies = [\n \"either\",\n]",
"[[package]]\nname = \"lazy_static\"\nversion = \"1.4.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646\"",
"[[package]]\nname = \"libc\"",
"version = \"0.2.119\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4\"",
"\n[[package]]\nname = \"lock_api\"\nversion = \"0.4.6\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b\"\ndependencies = [\n \"scopeguard\",\n]",
"[[package]]\nname = \"log\"",
"version = \"0.4.14\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710\"",
"dependencies = [\n \"cfg-if\",\n]",
"[[package]]\nname = \"memchr\"\nversion = \"2.4.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a\"",
"[[package]]\nname = \"memoffset\"\nversion = \"0.6.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce\"\ndependencies = [\n \"autocfg\",\n]",
"[[package]]\nname = \"mio\"",
"version = \"0.8.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"7ba42135c6a5917b9db9cd7b293e5409e1c6b041e6f9825e92e55a894c63b6f8\"",
"dependencies = [\n \"libc\",\n \"log\",\n \"miow\",\n \"ntapi\",\n \"wasi\",\n \"winapi\",\n]",
"[[package]]\nname = \"miow\"\nversion = \"0.3.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21\"\ndependencies = [\n \"winapi\",\n]",
"[[package]]\nname = \"nix\"\nversion = \"0.23.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6\"\ndependencies = [\n \"bitflags\",\n \"cc\",\n \"cfg-if\",\n \"libc\",\n \"memoffset\",\n]",
"[[package]]\nname = \"ntapi\"\nversion = \"0.3.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f\"\ndependencies = [\n \"winapi\",\n]",
"[[package]]\nname = \"num_cpus\"\nversion = \"1.13.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1\"\ndependencies = [\n \"hermit-abi\",\n \"libc\",\n]",
"[[package]]\nname = \"once_cell\"\nversion = \"1.10.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9\"",
"[[package]]\nname = \"os_str_bytes\"\nversion = \"6.0.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64\"\ndependencies = [\n \"memchr\",\n]",
"[[package]]\nname = \"parking_lot\"\nversion = \"0.12.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58\"\ndependencies = [\n \"lock_api\",\n \"parking_lot_core\",\n]",
"[[package]]\nname = \"parking_lot_core\"\nversion = \"0.9.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954\"\ndependencies = [\n \"cfg-if\",\n \"libc\",\n \"redox_syscall\",\n \"smallvec\",\n \"windows-sys\",\n]",
"[[package]]\nname = \"pin-project-lite\"\nversion = \"0.2.8\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c\"",
"[[package]]\nname = \"proc-macro2\"\nversion = \"1.0.36\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029\"\ndependencies = [\n \"unicode-xid\",\n]",
"[[package]]\nname = \"quote\"",
"version = \"1.0.15\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145\"",
"dependencies = [\n \"proc-macro2\",\n]",
"[[package]]\nname = \"radium\"\nversion = \"0.7.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09\"",
"[[package]]\nname = \"rayon\"\nversion = \"1.5.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90\"\ndependencies = [\n \"autocfg\",\n \"crossbeam-deque\",\n \"either\",\n \"rayon-core\",\n]",
"[[package]]\nname = \"rayon-core\"\nversion = \"1.9.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e\"\ndependencies = [\n \"crossbeam-channel\",\n \"crossbeam-deque\",\n \"crossbeam-utils\",\n \"lazy_static\",\n \"num_cpus\",\n]",
"[[package]]\nname = \"redox_syscall\"",
"version = \"0.2.11\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c\"",
"dependencies = [\n \"bitflags\",\n]",
"[[package]]\nname = \"regex\"\nversion = \"1.5.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286\"\ndependencies = [\n \"aho-corasick\",\n \"memchr\",\n \"regex-syntax\",\n]",
"[[package]]\nname = \"regex-syntax\"\nversion = \"0.6.25\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b\"",
"[[package]]\nname = \"scopeguard\"\nversion = \"1.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd\"",
"[[package]]\nname = \"signal-hook\"\nversion = \"0.3.13\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d\"\ndependencies = [\n \"libc\",\n \"signal-hook-registry\",\n]",
"[[package]]\nname = \"signal-hook-registry\"\nversion = \"1.4.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0\"\ndependencies = [\n \"libc\",\n]",
"[[package]]\nname = \"signal-hook-tokio\"\nversion = \"0.3.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"213241f76fb1e37e27de3b6aa1b068a2c333233b59cca6634f634b80a27ecf1e\"\ndependencies = [\n \"futures-core\",\n \"libc\",\n \"signal-hook\",\n \"tokio\",\n]",
"[[package]]\nname = \"smallvec\"\nversion = \"1.8.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83\"",
"[[package]]\nname = \"socket2\"\nversion = \"0.4.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0\"\ndependencies = [\n \"libc\",\n \"winapi\",\n]",
"[[package]]\nname = \"strsim\"\nversion = \"0.10.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623\"",
"[[package]]\nname = \"syn\"",
"version = \"1.0.86\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b\"",
"dependencies = [\n \"proc-macro2\",\n \"quote\",\n \"unicode-xid\",\n]",
"[[package]]\nname = \"sysinfo\"\nversion = \"0.23.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"07fa4c84a5305909b0eedfcc8d1f2fafdbede645bb700a45ecaafe681a0ac5d6\"\ndependencies = [\n \"cfg-if\",\n \"core-foundation-sys\",\n \"libc\",\n \"ntapi\",\n \"once_cell\",\n \"rayon\",\n \"winapi\",\n]",
"[[package]]\nname = \"tap\"\nversion = \"1.0.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369\"",
"[[package]]\nname = \"termcolor\"\nversion = \"1.1.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755\"\ndependencies = [\n \"winapi-util\",\n]",
"[[package]]\nname = \"textwrap\"\nversion = \"0.15.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb\"",
"[[package]]\nname = \"tokio\"\nversion = \"1.17.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee\"\ndependencies = [\n \"bytes\",\n \"libc\",\n \"memchr\",\n \"mio\",\n \"num_cpus\",\n \"once_cell\",\n \"parking_lot\",\n \"pin-project-lite\",\n \"signal-hook-registry\",\n \"socket2\",\n \"tokio-macros\",\n \"winapi\",\n]",
"[[package]]\nname = \"tokio-macros\"\nversion = \"1.7.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7\"\ndependencies = [\n \"proc-macro2\",\n \"quote\",\n \"syn\",\n]",
"[[package]]\nname = \"tokio-stream\"\nversion = \"0.1.8\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3\"\ndependencies = [\n \"futures-core\",\n \"pin-project-lite\",\n \"tokio\",\n]",
"[[package]]\nname = \"unicode-xid\"\nversion = \"0.2.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3\"",
"[[package]]\nname = \"wasi\"\nversion = \"0.11.0+wasi-snapshot-preview1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423\"",
"[[package]]\nname = \"winapi\"\nversion = \"0.3.9\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419\"\ndependencies = [\n \"winapi-i686-pc-windows-gnu\",\n \"winapi-x86_64-pc-windows-gnu\",\n]",
"[[package]]\nname = \"winapi-i686-pc-windows-gnu\"\nversion = \"0.4.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6\"",
"[[package]]\nname = \"winapi-util\"\nversion = \"0.1.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178\"\ndependencies = [\n \"winapi\",\n]",
"[[package]]\nname = \"winapi-x86_64-pc-windows-gnu\"\nversion = \"0.4.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f\"",
"[[package]]\nname = \"windows-sys\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6\"\ndependencies = [\n \"windows_aarch64_msvc\",\n \"windows_i686_gnu\",\n \"windows_i686_msvc\",\n \"windows_x86_64_gnu\",\n \"windows_x86_64_msvc\",\n]",
"[[package]]\nname = \"windows_aarch64_msvc\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5\"",
"[[package]]\nname = \"windows_i686_gnu\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615\"",
"[[package]]\nname = \"windows_i686_msvc\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172\"",
"[[package]]\nname = \"windows_x86_64_gnu\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc\"",
"[[package]]\nname = \"windows_x86_64_msvc\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316\"",
"[[package]]\nname = \"wyz\"\nversion = \"0.5.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e\"\ndependencies = [\n \"tap\",\n]"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [516, 31, 401], "buggy_code_start_loc": [107, 25, 87], "filenames": ["Cargo.lock", "Cargo.toml", "src/daemon.rs"], "fixing_code_end_loc": [517, 32, 414], "fixing_code_start_loc": [107, 26, 88], "message": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device).", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:waycrate:swhkd:1.1.5:*:*:*:*:*:*:*", "matchCriteriaId": "6C4A9210-751B-49B0-8AD4-CDDA0593D448", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device)."}, {"lang": "es", "value": "SWHKD versi\u00f3n 1.1.5 permite un an\u00e1lisis no seguro por medio de la opci\u00f3n -c. Puede producirse un filtrado de informaci\u00f3n, pero se presenta una simple denegaci\u00f3n de servicio (agotamiento de memoria) al intentar analizar un archivo grande o infinito (como un dispositivo de bloques o caracteres)"}], "evaluatorComment": null, "id": "CVE-2022-27819", "lastModified": "2022-04-14T13:13:12.250", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 4.0, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:N/AC:H/Au:N/C:P/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 4.9, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": true}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.0, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-04-07T02:15:07.257", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2022/04/14/1"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, {"source": "cve@mitre.org", "tags": ["Release Notes"], "url": "https://github.com/waycrate/swhkd/releases"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-400"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, "type": "CWE-400"}
| 366
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# This file is automatically @generated by Cargo.\n# It is not intended for manual editing.\nversion = 3",
"[[package]]\nname = \"Simple-Wayland-HotKey-Daemon\"\nversion = \"1.1.7\"\ndependencies = [\n \"clap\",\n \"env_logger\",\n \"evdev\",\n \"itertools\",\n \"log\",\n \"nix\",\n \"signal-hook\",\n \"signal-hook-tokio\",\n \"sysinfo\",\n \"tokio\",\n \"tokio-stream\",\n]",
"[[package]]\nname = \"aho-corasick\"\nversion = \"0.7.18\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f\"\ndependencies = [\n \"memchr\",\n]",
"[[package]]\nname = \"atty\"\nversion = \"0.2.14\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8\"\ndependencies = [\n \"hermit-abi\",\n \"libc\",\n \"winapi\",\n]",
"[[package]]\nname = \"autocfg\"\nversion = \"1.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa\"",
"[[package]]\nname = \"bitflags\"\nversion = \"1.3.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a\"",
"[[package]]\nname = \"bitvec\"\nversion = \"1.0.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"1489fcb93a5bb47da0462ca93ad252ad6af2145cce58d10d46a83931ba9f016b\"\ndependencies = [\n \"funty\",\n \"radium\",\n \"tap\",\n \"wyz\",\n]",
"[[package]]\nname = \"bytes\"\nversion = \"1.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8\"",
"[[package]]\nname = \"cc\"\nversion = \"1.0.73\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11\"",
"[[package]]\nname = \"cfg-if\"\nversion = \"1.0.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd\"",
"[[package]]\nname = \"clap\"\nversion = \"3.1.6\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123\"\ndependencies = [\n \"atty\",\n \"bitflags\",\n \"indexmap\",\n \"os_str_bytes\",\n \"strsim\",\n \"termcolor\",\n \"textwrap\",\n]",
"[[package]]\nname = \"core-foundation-sys\"\nversion = \"0.8.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc\"",
"[[package]]\nname = \"crossbeam-channel\"",
"version = \"0.5.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53\"",
"dependencies = [\n \"cfg-if\",\n \"crossbeam-utils\",\n]",
"[[package]]\nname = \"crossbeam-deque\"\nversion = \"0.8.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e\"\ndependencies = [\n \"cfg-if\",\n \"crossbeam-epoch\",\n \"crossbeam-utils\",\n]",
"[[package]]\nname = \"crossbeam-epoch\"",
"version = \"0.9.8\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c\"\ndependencies = [\n \"autocfg\",",
" \"cfg-if\",\n \"crossbeam-utils\",\n \"lazy_static\",\n \"memoffset\",\n \"scopeguard\",\n]",
"[[package]]\nname = \"crossbeam-utils\"",
"version = \"0.8.8\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38\"",
"dependencies = [\n \"cfg-if\",\n \"lazy_static\",\n]",
"[[package]]\nname = \"either\"\nversion = \"1.6.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457\"",
"[[package]]\nname = \"env_logger\"\nversion = \"0.9.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3\"\ndependencies = [\n \"atty\",\n \"humantime\",\n \"log\",\n \"regex\",\n \"termcolor\",\n]",
"[[package]]\nname = \"evdev\"\nversion = \"0.11.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"21eef104bd659ef808f1f84bed9a924e1aebcdd066845b377cd3b52cc497bb9f\"\ndependencies = [\n \"bitvec\",\n \"futures-core\",\n \"libc\",\n \"nix\",\n \"tokio\",\n]",
"[[package]]\nname = \"funty\"\nversion = \"2.0.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c\"",
"[[package]]\nname = \"futures-core\"\nversion = \"0.3.21\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3\"",
"[[package]]\nname = \"hashbrown\"\nversion = \"0.11.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e\"",
"[[package]]\nname = \"hermit-abi\"\nversion = \"0.1.19\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33\"\ndependencies = [\n \"libc\",\n]",
"[[package]]\nname = \"humantime\"\nversion = \"2.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4\"",
"[[package]]\nname = \"indexmap\"\nversion = \"1.8.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223\"\ndependencies = [\n \"autocfg\",\n \"hashbrown\",\n]",
"[[package]]\nname = \"itertools\"\nversion = \"0.10.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3\"\ndependencies = [\n \"either\",\n]",
"[[package]]\nname = \"lazy_static\"\nversion = \"1.4.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646\"",
"[[package]]\nname = \"libc\"",
"version = \"0.2.121\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f\"",
"\n[[package]]\nname = \"lock_api\"\nversion = \"0.4.6\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b\"\ndependencies = [\n \"scopeguard\",\n]",
"[[package]]\nname = \"log\"",
"version = \"0.4.16\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8\"",
"dependencies = [\n \"cfg-if\",\n]",
"[[package]]\nname = \"memchr\"\nversion = \"2.4.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a\"",
"[[package]]\nname = \"memoffset\"\nversion = \"0.6.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce\"\ndependencies = [\n \"autocfg\",\n]",
"[[package]]\nname = \"mio\"",
"version = \"0.8.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9\"",
"dependencies = [\n \"libc\",\n \"log\",\n \"miow\",\n \"ntapi\",\n \"wasi\",\n \"winapi\",\n]",
"[[package]]\nname = \"miow\"\nversion = \"0.3.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21\"\ndependencies = [\n \"winapi\",\n]",
"[[package]]\nname = \"nix\"\nversion = \"0.23.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6\"\ndependencies = [\n \"bitflags\",\n \"cc\",\n \"cfg-if\",\n \"libc\",\n \"memoffset\",\n]",
"[[package]]\nname = \"ntapi\"\nversion = \"0.3.7\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f\"\ndependencies = [\n \"winapi\",\n]",
"[[package]]\nname = \"num_cpus\"\nversion = \"1.13.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1\"\ndependencies = [\n \"hermit-abi\",\n \"libc\",\n]",
"[[package]]\nname = \"once_cell\"\nversion = \"1.10.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9\"",
"[[package]]\nname = \"os_str_bytes\"\nversion = \"6.0.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64\"\ndependencies = [\n \"memchr\",\n]",
"[[package]]\nname = \"parking_lot\"\nversion = \"0.12.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58\"\ndependencies = [\n \"lock_api\",\n \"parking_lot_core\",\n]",
"[[package]]\nname = \"parking_lot_core\"\nversion = \"0.9.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954\"\ndependencies = [\n \"cfg-if\",\n \"libc\",\n \"redox_syscall\",\n \"smallvec\",\n \"windows-sys\",\n]",
"[[package]]\nname = \"pin-project-lite\"\nversion = \"0.2.8\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c\"",
"[[package]]\nname = \"proc-macro2\"\nversion = \"1.0.36\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029\"\ndependencies = [\n \"unicode-xid\",\n]",
"[[package]]\nname = \"quote\"",
"version = \"1.0.16\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57\"",
"dependencies = [\n \"proc-macro2\",\n]",
"[[package]]\nname = \"radium\"\nversion = \"0.7.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09\"",
"[[package]]\nname = \"rayon\"\nversion = \"1.5.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90\"\ndependencies = [\n \"autocfg\",\n \"crossbeam-deque\",\n \"either\",\n \"rayon-core\",\n]",
"[[package]]\nname = \"rayon-core\"\nversion = \"1.9.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e\"\ndependencies = [\n \"crossbeam-channel\",\n \"crossbeam-deque\",\n \"crossbeam-utils\",\n \"lazy_static\",\n \"num_cpus\",\n]",
"[[package]]\nname = \"redox_syscall\"",
"version = \"0.2.12\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0\"",
"dependencies = [\n \"bitflags\",\n]",
"[[package]]\nname = \"regex\"\nversion = \"1.5.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286\"\ndependencies = [\n \"aho-corasick\",\n \"memchr\",\n \"regex-syntax\",\n]",
"[[package]]\nname = \"regex-syntax\"\nversion = \"0.6.25\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b\"",
"[[package]]\nname = \"scopeguard\"\nversion = \"1.1.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd\"",
"[[package]]\nname = \"signal-hook\"\nversion = \"0.3.13\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d\"\ndependencies = [\n \"libc\",\n \"signal-hook-registry\",\n]",
"[[package]]\nname = \"signal-hook-registry\"\nversion = \"1.4.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0\"\ndependencies = [\n \"libc\",\n]",
"[[package]]\nname = \"signal-hook-tokio\"\nversion = \"0.3.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"213241f76fb1e37e27de3b6aa1b068a2c333233b59cca6634f634b80a27ecf1e\"\ndependencies = [\n \"futures-core\",\n \"libc\",\n \"signal-hook\",\n \"tokio\",\n]",
"[[package]]\nname = \"smallvec\"\nversion = \"1.8.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83\"",
"[[package]]\nname = \"socket2\"\nversion = \"0.4.4\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0\"\ndependencies = [\n \"libc\",\n \"winapi\",\n]",
"[[package]]\nname = \"strsim\"\nversion = \"0.10.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623\"",
"[[package]]\nname = \"syn\"",
"version = \"1.0.89\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54\"",
"dependencies = [\n \"proc-macro2\",\n \"quote\",\n \"unicode-xid\",\n]",
"[[package]]\nname = \"sysinfo\"\nversion = \"0.23.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"07fa4c84a5305909b0eedfcc8d1f2fafdbede645bb700a45ecaafe681a0ac5d6\"\ndependencies = [\n \"cfg-if\",\n \"core-foundation-sys\",\n \"libc\",\n \"ntapi\",\n \"once_cell\",\n \"rayon\",\n \"winapi\",\n]",
"[[package]]\nname = \"tap\"\nversion = \"1.0.1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369\"",
"[[package]]\nname = \"termcolor\"\nversion = \"1.1.3\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755\"\ndependencies = [\n \"winapi-util\",\n]",
"[[package]]\nname = \"textwrap\"\nversion = \"0.15.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb\"",
"[[package]]\nname = \"tokio\"\nversion = \"1.17.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee\"\ndependencies = [\n \"bytes\",\n \"libc\",\n \"memchr\",\n \"mio\",\n \"num_cpus\",\n \"once_cell\",\n \"parking_lot\",\n \"pin-project-lite\",\n \"signal-hook-registry\",\n \"socket2\",\n \"tokio-macros\",\n \"winapi\",\n]",
"[[package]]\nname = \"tokio-macros\"\nversion = \"1.7.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7\"\ndependencies = [\n \"proc-macro2\",\n \"quote\",\n \"syn\",\n]",
"[[package]]\nname = \"tokio-stream\"\nversion = \"0.1.8\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3\"\ndependencies = [\n \"futures-core\",\n \"pin-project-lite\",\n \"tokio\",\n]",
"[[package]]\nname = \"unicode-xid\"\nversion = \"0.2.2\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3\"",
"[[package]]\nname = \"wasi\"\nversion = \"0.11.0+wasi-snapshot-preview1\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423\"",
"[[package]]\nname = \"winapi\"\nversion = \"0.3.9\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419\"\ndependencies = [\n \"winapi-i686-pc-windows-gnu\",\n \"winapi-x86_64-pc-windows-gnu\",\n]",
"[[package]]\nname = \"winapi-i686-pc-windows-gnu\"\nversion = \"0.4.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6\"",
"[[package]]\nname = \"winapi-util\"\nversion = \"0.1.5\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178\"\ndependencies = [\n \"winapi\",\n]",
"[[package]]\nname = \"winapi-x86_64-pc-windows-gnu\"\nversion = \"0.4.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f\"",
"[[package]]\nname = \"windows-sys\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6\"\ndependencies = [\n \"windows_aarch64_msvc\",\n \"windows_i686_gnu\",\n \"windows_i686_msvc\",\n \"windows_x86_64_gnu\",\n \"windows_x86_64_msvc\",\n]",
"[[package]]\nname = \"windows_aarch64_msvc\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5\"",
"[[package]]\nname = \"windows_i686_gnu\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615\"",
"[[package]]\nname = \"windows_i686_msvc\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172\"",
"[[package]]\nname = \"windows_x86_64_gnu\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc\"",
"[[package]]\nname = \"windows_x86_64_msvc\"\nversion = \"0.32.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316\"",
"[[package]]\nname = \"wyz\"\nversion = \"0.5.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e\"\ndependencies = [\n \"tap\",\n]"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [516, 31, 401], "buggy_code_start_loc": [107, 25, 87], "filenames": ["Cargo.lock", "Cargo.toml", "src/daemon.rs"], "fixing_code_end_loc": [517, 32, 414], "fixing_code_start_loc": [107, 26, 88], "message": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device).", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:waycrate:swhkd:1.1.5:*:*:*:*:*:*:*", "matchCriteriaId": "6C4A9210-751B-49B0-8AD4-CDDA0593D448", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device)."}, {"lang": "es", "value": "SWHKD versi\u00f3n 1.1.5 permite un an\u00e1lisis no seguro por medio de la opci\u00f3n -c. Puede producirse un filtrado de informaci\u00f3n, pero se presenta una simple denegaci\u00f3n de servicio (agotamiento de memoria) al intentar analizar un archivo grande o infinito (como un dispositivo de bloques o caracteres)"}], "evaluatorComment": null, "id": "CVE-2022-27819", "lastModified": "2022-04-14T13:13:12.250", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 4.0, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:N/AC:H/Au:N/C:P/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 4.9, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": true}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.0, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-04-07T02:15:07.257", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2022/04/14/1"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, {"source": "cve@mitre.org", "tags": ["Release Notes"], "url": "https://github.com/waycrate/swhkd/releases"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-400"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, "type": "CWE-400"}
| 366
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"[package]\ndescription = \"Sxhkd clone for Wayland (works on TYY and X11 too)\"\nedition = \"2021\"\nkeywords = [\"wayland\", \"hotkey\", \"evdev\"]\nlicense = \"BSD-2-Clause\"\nname = \"Simple-Wayland-HotKey-Daemon\"\nrepository = \"https://git.sr.ht/~shinyzenith/swhkd\"\nversion = \"1.1.7\"\nauthors = [\n\t\"Shinyzenith <aakashsensharma@gmail.com>\\n\",\n\t\"Angelo Fallaria <ba.fallaria@gmail.com>\\n\",\n\t\"EdenQwQ <lsahlm1eden@gmail.com>\\n\"\n]\nexclude = [\n \"CODE_OF_CONDUCT.md\",\n \"CONTRIBUTING.md\",\n\t\"contrib/*\",\n\t\"docs/*\",\n\t\"release.sh\",\n]",
"[dependencies]\nclap = \"3.1.6\"\nenv_logger = \"0.9.0\"\nevdev = { version = \"0.11.4\", features = [\"tokio\"] }",
"",
"log = \"0.4.14\"\nnix = \"0.23.1\"",
"sysinfo = \"0.23.5\"\nitertools = \"0.10.3\"",
"signal-hook = \"0.3.13\"\nsignal-hook-tokio = { version = \"0.3.1\", features = [\"futures-v0_3\"] }",
"",
"tokio = { version = \"1.17.0\", features = [\"full\"] }\ntokio-stream = \"0.1.8\"",
"[[bin]]\nname = \"swhkd\"\npath = \"src/daemon.rs\"",
"[[bin]]\nname = \"swhks\"\npath = \"src/server.rs\"",
"[profile.release]\nopt-level = 'z' # Optimize for size.\ncodegen-units = 1 # Reduce number of codegen units to increase optimizations.\nstrip = true # Strip symbols from binary*"
] |
[
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [516, 31, 401], "buggy_code_start_loc": [107, 25, 87], "filenames": ["Cargo.lock", "Cargo.toml", "src/daemon.rs"], "fixing_code_end_loc": [517, 32, 414], "fixing_code_start_loc": [107, 26, 88], "message": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device).", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:waycrate:swhkd:1.1.5:*:*:*:*:*:*:*", "matchCriteriaId": "6C4A9210-751B-49B0-8AD4-CDDA0593D448", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device)."}, {"lang": "es", "value": "SWHKD versi\u00f3n 1.1.5 permite un an\u00e1lisis no seguro por medio de la opci\u00f3n -c. Puede producirse un filtrado de informaci\u00f3n, pero se presenta una simple denegaci\u00f3n de servicio (agotamiento de memoria) al intentar analizar un archivo grande o infinito (como un dispositivo de bloques o caracteres)"}], "evaluatorComment": null, "id": "CVE-2022-27819", "lastModified": "2022-04-14T13:13:12.250", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 4.0, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:N/AC:H/Au:N/C:P/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 4.9, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": true}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.0, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-04-07T02:15:07.257", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2022/04/14/1"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, {"source": "cve@mitre.org", "tags": ["Release Notes"], "url": "https://github.com/waycrate/swhkd/releases"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-400"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, "type": "CWE-400"}
| 366
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"[package]\ndescription = \"Sxhkd clone for Wayland (works on TYY and X11 too)\"\nedition = \"2021\"\nkeywords = [\"wayland\", \"hotkey\", \"evdev\"]\nlicense = \"BSD-2-Clause\"\nname = \"Simple-Wayland-HotKey-Daemon\"\nrepository = \"https://git.sr.ht/~shinyzenith/swhkd\"\nversion = \"1.1.7\"\nauthors = [\n\t\"Shinyzenith <aakashsensharma@gmail.com>\\n\",\n\t\"Angelo Fallaria <ba.fallaria@gmail.com>\\n\",\n\t\"EdenQwQ <lsahlm1eden@gmail.com>\\n\"\n]\nexclude = [\n \"CODE_OF_CONDUCT.md\",\n \"CONTRIBUTING.md\",\n\t\"contrib/*\",\n\t\"docs/*\",\n\t\"release.sh\",\n]",
"[dependencies]\nclap = \"3.1.6\"\nenv_logger = \"0.9.0\"\nevdev = { version = \"0.11.4\", features = [\"tokio\"] }",
"itertools = \"0.10.3\"",
"log = \"0.4.14\"\nnix = \"0.23.1\"",
"",
"signal-hook = \"0.3.13\"\nsignal-hook-tokio = { version = \"0.3.1\", features = [\"futures-v0_3\"] }",
"sysinfo = \"0.23.5\"",
"tokio = { version = \"1.17.0\", features = [\"full\"] }\ntokio-stream = \"0.1.8\"",
"[[bin]]\nname = \"swhkd\"\npath = \"src/daemon.rs\"",
"[[bin]]\nname = \"swhks\"\npath = \"src/server.rs\"",
"[profile.release]\nopt-level = 'z' # Optimize for size.\ncodegen-units = 1 # Reduce number of codegen units to increase optimizations.\nstrip = true # Strip symbols from binary*"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [516, 31, 401], "buggy_code_start_loc": [107, 25, 87], "filenames": ["Cargo.lock", "Cargo.toml", "src/daemon.rs"], "fixing_code_end_loc": [517, 32, 414], "fixing_code_start_loc": [107, 26, 88], "message": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device).", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:waycrate:swhkd:1.1.5:*:*:*:*:*:*:*", "matchCriteriaId": "6C4A9210-751B-49B0-8AD4-CDDA0593D448", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device)."}, {"lang": "es", "value": "SWHKD versi\u00f3n 1.1.5 permite un an\u00e1lisis no seguro por medio de la opci\u00f3n -c. Puede producirse un filtrado de informaci\u00f3n, pero se presenta una simple denegaci\u00f3n de servicio (agotamiento de memoria) al intentar analizar un archivo grande o infinito (como un dispositivo de bloques o caracteres)"}], "evaluatorComment": null, "id": "CVE-2022-27819", "lastModified": "2022-04-14T13:13:12.250", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 4.0, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:N/AC:H/Au:N/C:P/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 4.9, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": true}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.0, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-04-07T02:15:07.257", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2022/04/14/1"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, {"source": "cve@mitre.org", "tags": ["Release Notes"], "url": "https://github.com/waycrate/swhkd/releases"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-400"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, "type": "CWE-400"}
| 366
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"use clap::{arg, Command};\nuse evdev::{AttributeSet, Device, InputEventKind, Key};\nuse nix::unistd::{Group, Uid};\nuse signal_hook_tokio::Signals;\nuse std::{\n collections::{HashMap, HashSet},\n env, fs,\n io::prelude::*,\n os::unix::net::UnixStream,\n path::Path,\n process::{exit, id},\n};\nuse sysinfo::{ProcessExt, System, SystemExt};\nuse tokio::select;\nuse tokio::time::Duration;\nuse tokio::time::{sleep, Instant};\nuse tokio_stream::{StreamExt, StreamMap};",
"use signal_hook::consts::signal::*;",
"mod config;\nuse crate::config::Value;\nmod uinput;",
"#[cfg(test)]\nmod tests;",
"struct KeyboardState {\n state_modifiers: HashSet<config::Modifier>,\n state_keysyms: AttributeSet<evdev::Key>,\n}",
"impl KeyboardState {\n fn new() -> KeyboardState {\n KeyboardState { state_modifiers: HashSet::new(), state_keysyms: AttributeSet::new() }\n }\n}",
"#[tokio::main]\nasync fn main() -> Result<(), Box<dyn std::error::Error>> {\n let args = set_command_line_args().get_matches();\n env::set_var(\"RUST_LOG\", \"swhkd=warn\");",
" if args.is_present(\"debug\") {\n env::set_var(\"RUST_LOG\", \"swhkd=trace\");\n }",
" env_logger::init();\n log::trace!(\"Logger initialized.\");",
" let pidfile: String = String::from(\"/tmp/swhkd.pid\");\n if Path::new(&pidfile).exists() {\n log::trace!(\"Reading {} file and checking for running instances.\", pidfile);\n let swhkd_pid = match fs::read_to_string(&pidfile) {\n Ok(swhkd_pid) => swhkd_pid,\n Err(e) => {\n log::error!(\"Unable to read {} to check all running instances\", e);\n exit(1);\n }\n };\n log::debug!(\"Previous PID: {}\", swhkd_pid);",
" let mut sys = System::new_all();\n sys.refresh_all();\n for (pid, process) in sys.processes() {\n if pid.to_string() == swhkd_pid && process.exe() == env::current_exe().unwrap() {\n log::error!(\"Swhkd is already running!\");\n log::error!(\"pid of existing swhkd process: {}\", pid.to_string());\n log::error!(\"To close the existing swhkd process, run `sudo killall swhkd`\");\n exit(1);\n }\n }\n }",
" match fs::write(&pidfile, id().to_string()) {\n Ok(_) => {}\n Err(e) => {\n log::error!(\"Unable to write to {}: {}\", pidfile, e);\n exit(1);\n }\n }",
" if check_user_permissions().is_err() {\n exit(1);\n }",
" let load_config = || {",
"",
" let config_file_path: std::path::PathBuf = if args.is_present(\"config\") {\n Path::new(args.value_of(\"config\").unwrap()).to_path_buf()\n } else {\n fetch_xdg_config_path()\n };",
" log::debug!(\"Using config file path: {:#?}\", config_file_path);",
" if !config_file_path.exists() {\n log::error!(\"{:#?} doesn't exist\", config_file_path);\n exit(1);\n }",
" let hotkeys = match config::load(&config_file_path) {\n Err(e) => {\n log::error!(\"Config Error: {}\", e);\n exit(1);\n }\n Ok(out) => out,\n };",
" for hotkey in &hotkeys {\n log::debug!(\"hotkey: {:#?}\", hotkey);\n }",
" hotkeys\n };",
" let mut hotkeys = load_config();",
"",
" log::trace!(\"Attempting to find all keyboard file descriptors.\");\n let keyboard_devices: Vec<Device> =\n evdev::enumerate().filter(check_device_is_keyboard).collect();",
" let mut uinput_device = match uinput::create_uinput_device() {\n Ok(dev) => dev,\n Err(e) => {\n log::error!(\"Err: {:#?}\", e);\n exit(1);\n }\n };",
" if keyboard_devices.is_empty() {\n log::error!(\"No valid keyboard device was detected!\");\n exit(1);\n }\n log::debug!(\"{} Keyboard device(s) detected.\", keyboard_devices.len());",
" let modifiers_map: HashMap<Key, config::Modifier> = HashMap::from([\n (Key::KEY_LEFTMETA, config::Modifier::Super),\n (Key::KEY_RIGHTMETA, config::Modifier::Super),\n (Key::KEY_LEFTMETA, config::Modifier::Super),\n (Key::KEY_RIGHTMETA, config::Modifier::Super),\n (Key::KEY_LEFTALT, config::Modifier::Alt),\n (Key::KEY_RIGHTALT, config::Modifier::Alt),\n (Key::KEY_LEFTCTRL, config::Modifier::Control),\n (Key::KEY_RIGHTCTRL, config::Modifier::Control),\n (Key::KEY_LEFTSHIFT, config::Modifier::Shift),\n (Key::KEY_RIGHTSHIFT, config::Modifier::Shift),\n ]);",
" let repeat_cooldown_duration: u64 = if args.is_present(\"cooldown\") {\n args.value_of(\"cooldown\").unwrap().parse::<u64>().unwrap()\n } else {\n 250\n };",
" let mut signals = Signals::new(&[\n SIGUSR1, SIGUSR2, SIGHUP, SIGABRT, SIGBUS, SIGCHLD, SIGCONT, SIGINT, SIGPIPE, SIGQUIT,\n SIGSYS, SIGTERM, SIGTRAP, SIGTSTP, SIGVTALRM, SIGXCPU, SIGXFSZ,\n ])?;",
" let mut execution_is_paused = false;\n let mut last_hotkey: Option<config::Hotkey> = None;\n let mut pending_release: bool = false;\n let mut keyboard_states: Vec<KeyboardState> = Vec::new();\n let mut keyboard_stream_map = StreamMap::new();",
" for (i, mut device) in keyboard_devices.into_iter().enumerate() {\n let _ = device.grab();\n keyboard_stream_map.insert(i, device.into_event_stream()?);\n keyboard_states.push(KeyboardState::new());\n }",
" // The initial sleep duration is never read because last_hotkey is initialized to None\n let hotkey_repeat_timer = sleep(Duration::from_millis(0));\n tokio::pin!(hotkey_repeat_timer);",
" loop {\n select! {\n _ = &mut hotkey_repeat_timer, if &last_hotkey.is_some() => {\n let hotkey = last_hotkey.clone().unwrap();\n if hotkey.keybinding.on_release {\n continue;\n }\n send_command(hotkey.clone());\n hotkey_repeat_timer.as_mut().reset(Instant::now() + Duration::from_millis(repeat_cooldown_duration));\n }",
" Some(signal) = signals.next() => {\n match signal {\n SIGUSR1 => {\n execution_is_paused = true;\n for mut device in evdev::enumerate().filter(check_device_is_keyboard) {\n let _ = device.ungrab();\n }\n }",
" SIGUSR2 => {\n execution_is_paused = false;\n for mut device in evdev::enumerate().filter(check_device_is_keyboard) {\n let _ = device.grab();\n }\n }",
" SIGHUP => {\n hotkeys = load_config();\n }",
" SIGINT => {\n for mut device in evdev::enumerate().filter(check_device_is_keyboard) {\n let _ = device.ungrab();\n }\n log::warn!(\"Received SIGINT signal, exiting...\");\n exit(1);\n }",
" _ => {\n for mut device in evdev::enumerate().filter(check_device_is_keyboard) {\n let _ = device.ungrab();\n }",
" log::warn!(\"Received signal: {:#?}\", signal);\n log::warn!(\"Exiting...\");\n exit(1);\n }\n }\n }",
" Some((i, Ok(event))) = keyboard_stream_map.next() => {\n let keyboard_state = &mut keyboard_states[i];",
" let key = match event.kind() {\n InputEventKind::Key(keycode) => keycode,\n _ => continue\n };",
" match event.value() {\n // Key press\n 1 => {\n if let Some(modifier) = modifiers_map.get(&key) {\n keyboard_state.state_modifiers.insert(*modifier);\n } else {\n keyboard_state.state_keysyms.insert(key);\n }\n }",
" // Key release\n 0 => {\n if last_hotkey.is_some() && pending_release {\n pending_release = false;\n send_command(last_hotkey.clone().unwrap());\n last_hotkey = None;\n }\n if let Some(modifier) = modifiers_map.get(&key) {\n if let Some(hotkey) = &last_hotkey {\n if hotkey.modifiers().contains(modifier) {\n last_hotkey = None;\n }\n }\n keyboard_state.state_modifiers.remove(modifier);\n } else if keyboard_state.state_keysyms.contains(key) {\n if let Some(hotkey) = &last_hotkey {\n if key == hotkey.keysym() {\n last_hotkey = None;\n }\n }\n keyboard_state.state_keysyms.remove(key);\n }\n }",
" _ => {}\n }",
" let possible_hotkeys: Vec<&config::Hotkey> = hotkeys.iter()\n .filter(|hotkey| hotkey.modifiers().len() == keyboard_state.state_modifiers.len())\n .collect();",
" let event_in_hotkeys = hotkeys.iter().any(|hotkey| {\n hotkey.keysym().code() == event.code() &&\n keyboard_state.state_modifiers\n .iter()\n .all(|x| hotkey.modifiers().contains(x)) &&\n keyboard_state.state_modifiers.len() == hotkey.modifiers().len()\n && !hotkey.is_send()\n });",
" // Don't emit event to virtual device if it's from a valid hotkey\n if !event_in_hotkeys {\n uinput_device.emit(&[event]).unwrap();\n }",
" if execution_is_paused || possible_hotkeys.is_empty() || last_hotkey.is_some() {\n continue;\n }",
" log::debug!(\"state_modifiers: {:#?}\", keyboard_state.state_modifiers);\n log::debug!(\"state_keysyms: {:#?}\", keyboard_state.state_keysyms);\n log::debug!(\"hotkey: {:#?}\", possible_hotkeys);",
" for hotkey in possible_hotkeys {\n // this should check if state_modifiers and hotkey.modifiers have the same elements\n if keyboard_state.state_modifiers.iter().all(|x| hotkey.modifiers().contains(x))\n && keyboard_state.state_modifiers.len() == hotkey.modifiers().len()\n && keyboard_state.state_keysyms.contains(hotkey.keysym())\n {\n last_hotkey = Some(hotkey.clone());\n if pending_release { break; }\n if hotkey.is_on_release() {\n pending_release = true;\n break;\n }\n send_command(hotkey.clone());\n hotkey_repeat_timer.as_mut().reset(Instant::now() + Duration::from_millis(repeat_cooldown_duration));\n break;\n }\n }\n }\n }\n }\n}",
"fn sock_send(command: &str) -> std::io::Result<()> {\n let mut stream = UnixStream::connect(\"/tmp/swhkd.sock\")?;\n stream.write_all(command.as_bytes())?;\n Ok(())\n}",
"fn send_command(hotkey: config::Hotkey) {\n log::info!(\"Hotkey pressed: {:#?}\", hotkey);\n if let Err(e) = sock_send(&hotkey.command) {\n log::error!(\"Failed to send command to swhks through IPC.\");\n log::error!(\"Please make sure that swhks is running.\");\n log::error!(\"Err: {:#?}\", e)\n }\n}",
"pub fn check_user_permissions() -> Result<(), ()> {\n if !Uid::current().is_root() {\n let groups = nix::unistd::getgroups();\n for (_, groups) in groups.iter().enumerate() {\n for group in groups {\n let group = Group::from_gid(*group);\n if group.unwrap().unwrap().name == \"input\" {\n log::error!(\"Note: INVOKING USER IS IN INPUT GROUP!!!!\");\n log::error!(\"THIS IS A HUGE SECURITY RISK!!!!\");\n }\n }\n }\n log::error!(\"Consider using `pkexec swhkd ...`\");\n Err(())\n } else {\n log::warn!(\"Running swhkd as root!\");\n Ok(())\n }\n}",
"pub fn check_device_is_keyboard(device: &Device) -> bool {\n if device.supported_keys().map_or(false, |keys| keys.contains(Key::KEY_ENTER)) {\n if device.name() == Some(\"swhkd virtual output\") {\n return false;\n }\n log::debug!(\"Keyboard: {}\", device.name().unwrap(),);\n true\n } else {\n log::trace!(\"Other: {}\", device.name().unwrap(),);\n false\n }\n}",
"pub fn set_command_line_args() -> Command<'static> {\n let app = Command::new(\"swhkd\")\n .version(env!(\"CARGO_PKG_VERSION\"))\n .author(env!(\"CARGO_PKG_AUTHORS\"))\n .about(\"Simple Wayland HotKey Daemon\")\n .arg(\n arg!(-c --config <CONFIG_FILE_PATH>)\n .required(false)\n .takes_value(true)\n .help(\"Set a custom config file path.\"),\n )\n .arg(\n arg!(-C --cooldown <COOLDOWN_IN_MS>)\n .required(false)\n .takes_value(true)\n .help(\"Set a custom repeat cooldown duration. Default is 250ms.\"),\n )\n .arg(arg!(-d - -debug).required(false).help(\"Enable debug mode.\"));\n app\n}",
"pub fn fetch_xdg_config_path() -> std::path::PathBuf {\n let config_file_path: std::path::PathBuf = match env::var(\"XDG_CONFIG_HOME\") {\n Ok(val) => {\n log::debug!(\"XDG_CONFIG_HOME exists: {:#?}\", val);\n Path::new(&val).join(\"swhkd/swhkdrc\")\n }\n Err(_) => {\n log::error!(\"XDG_CONFIG_HOME has not been set.\");\n Path::new(\"/etc/swhkd/swhkdrc\").to_path_buf()\n }\n };\n config_file_path\n}",
""
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0
] |
PreciseBugs
|
{"buggy_code_end_loc": [516, 31, 401], "buggy_code_start_loc": [107, 25, 87], "filenames": ["Cargo.lock", "Cargo.toml", "src/daemon.rs"], "fixing_code_end_loc": [517, 32, 414], "fixing_code_start_loc": [107, 26, 88], "message": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device).", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:waycrate:swhkd:1.1.5:*:*:*:*:*:*:*", "matchCriteriaId": "6C4A9210-751B-49B0-8AD4-CDDA0593D448", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device)."}, {"lang": "es", "value": "SWHKD versi\u00f3n 1.1.5 permite un an\u00e1lisis no seguro por medio de la opci\u00f3n -c. Puede producirse un filtrado de informaci\u00f3n, pero se presenta una simple denegaci\u00f3n de servicio (agotamiento de memoria) al intentar analizar un archivo grande o infinito (como un dispositivo de bloques o caracteres)"}], "evaluatorComment": null, "id": "CVE-2022-27819", "lastModified": "2022-04-14T13:13:12.250", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 4.0, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:N/AC:H/Au:N/C:P/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 4.9, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": true}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.0, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-04-07T02:15:07.257", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2022/04/14/1"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, {"source": "cve@mitre.org", "tags": ["Release Notes"], "url": "https://github.com/waycrate/swhkd/releases"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-400"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, "type": "CWE-400"}
| 366
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"use clap::{arg, Command};\nuse evdev::{AttributeSet, Device, InputEventKind, Key};\nuse nix::unistd::{Group, Uid};\nuse signal_hook_tokio::Signals;\nuse std::{\n collections::{HashMap, HashSet},\n env, fs,\n io::prelude::*,\n os::unix::net::UnixStream,\n path::Path,\n process::{exit, id},\n};\nuse sysinfo::{ProcessExt, System, SystemExt};\nuse tokio::select;\nuse tokio::time::Duration;\nuse tokio::time::{sleep, Instant};\nuse tokio_stream::{StreamExt, StreamMap};",
"use signal_hook::consts::signal::*;",
"mod config;\nuse crate::config::Value;\nmod uinput;",
"#[cfg(test)]\nmod tests;",
"struct KeyboardState {\n state_modifiers: HashSet<config::Modifier>,\n state_keysyms: AttributeSet<evdev::Key>,\n}",
"impl KeyboardState {\n fn new() -> KeyboardState {\n KeyboardState { state_modifiers: HashSet::new(), state_keysyms: AttributeSet::new() }\n }\n}",
"#[tokio::main]\nasync fn main() -> Result<(), Box<dyn std::error::Error>> {\n let args = set_command_line_args().get_matches();\n env::set_var(\"RUST_LOG\", \"swhkd=warn\");",
" if args.is_present(\"debug\") {\n env::set_var(\"RUST_LOG\", \"swhkd=trace\");\n }",
" env_logger::init();\n log::trace!(\"Logger initialized.\");",
" let pidfile: String = String::from(\"/tmp/swhkd.pid\");\n if Path::new(&pidfile).exists() {\n log::trace!(\"Reading {} file and checking for running instances.\", pidfile);\n let swhkd_pid = match fs::read_to_string(&pidfile) {\n Ok(swhkd_pid) => swhkd_pid,\n Err(e) => {\n log::error!(\"Unable to read {} to check all running instances\", e);\n exit(1);\n }\n };\n log::debug!(\"Previous PID: {}\", swhkd_pid);",
" let mut sys = System::new_all();\n sys.refresh_all();\n for (pid, process) in sys.processes() {\n if pid.to_string() == swhkd_pid && process.exe() == env::current_exe().unwrap() {\n log::error!(\"Swhkd is already running!\");\n log::error!(\"pid of existing swhkd process: {}\", pid.to_string());\n log::error!(\"To close the existing swhkd process, run `sudo killall swhkd`\");\n exit(1);\n }\n }\n }",
" match fs::write(&pidfile, id().to_string()) {\n Ok(_) => {}\n Err(e) => {\n log::error!(\"Unable to write to {}: {}\", pidfile, e);\n exit(1);\n }\n }",
" if check_user_permissions().is_err() {\n exit(1);\n }",
" let load_config = || {",
" seteuid(env::var(\"PKEXEC_UID\").unwrap().parse::<u32>().unwrap()); // Dropping privileges to invoking user.",
" let config_file_path: std::path::PathBuf = if args.is_present(\"config\") {\n Path::new(args.value_of(\"config\").unwrap()).to_path_buf()\n } else {\n fetch_xdg_config_path()\n };",
" log::debug!(\"Using config file path: {:#?}\", config_file_path);",
" if !config_file_path.exists() {\n log::error!(\"{:#?} doesn't exist\", config_file_path);\n exit(1);\n }",
" let hotkeys = match config::load(&config_file_path) {\n Err(e) => {\n log::error!(\"Config Error: {}\", e);\n exit(1);\n }\n Ok(out) => out,\n };",
" for hotkey in &hotkeys {\n log::debug!(\"hotkey: {:#?}\", hotkey);\n }",
" hotkeys\n };",
" let mut hotkeys = load_config();",
" seteuid(0); // Escalating back to root after reading config file.",
" log::trace!(\"Attempting to find all keyboard file descriptors.\");\n let keyboard_devices: Vec<Device> =\n evdev::enumerate().filter(check_device_is_keyboard).collect();",
" let mut uinput_device = match uinput::create_uinput_device() {\n Ok(dev) => dev,\n Err(e) => {\n log::error!(\"Err: {:#?}\", e);\n exit(1);\n }\n };",
" if keyboard_devices.is_empty() {\n log::error!(\"No valid keyboard device was detected!\");\n exit(1);\n }\n log::debug!(\"{} Keyboard device(s) detected.\", keyboard_devices.len());",
" let modifiers_map: HashMap<Key, config::Modifier> = HashMap::from([\n (Key::KEY_LEFTMETA, config::Modifier::Super),\n (Key::KEY_RIGHTMETA, config::Modifier::Super),\n (Key::KEY_LEFTMETA, config::Modifier::Super),\n (Key::KEY_RIGHTMETA, config::Modifier::Super),\n (Key::KEY_LEFTALT, config::Modifier::Alt),\n (Key::KEY_RIGHTALT, config::Modifier::Alt),\n (Key::KEY_LEFTCTRL, config::Modifier::Control),\n (Key::KEY_RIGHTCTRL, config::Modifier::Control),\n (Key::KEY_LEFTSHIFT, config::Modifier::Shift),\n (Key::KEY_RIGHTSHIFT, config::Modifier::Shift),\n ]);",
" let repeat_cooldown_duration: u64 = if args.is_present(\"cooldown\") {\n args.value_of(\"cooldown\").unwrap().parse::<u64>().unwrap()\n } else {\n 250\n };",
" let mut signals = Signals::new(&[\n SIGUSR1, SIGUSR2, SIGHUP, SIGABRT, SIGBUS, SIGCHLD, SIGCONT, SIGINT, SIGPIPE, SIGQUIT,\n SIGSYS, SIGTERM, SIGTRAP, SIGTSTP, SIGVTALRM, SIGXCPU, SIGXFSZ,\n ])?;",
" let mut execution_is_paused = false;\n let mut last_hotkey: Option<config::Hotkey> = None;\n let mut pending_release: bool = false;\n let mut keyboard_states: Vec<KeyboardState> = Vec::new();\n let mut keyboard_stream_map = StreamMap::new();",
" for (i, mut device) in keyboard_devices.into_iter().enumerate() {\n let _ = device.grab();\n keyboard_stream_map.insert(i, device.into_event_stream()?);\n keyboard_states.push(KeyboardState::new());\n }",
" // The initial sleep duration is never read because last_hotkey is initialized to None\n let hotkey_repeat_timer = sleep(Duration::from_millis(0));\n tokio::pin!(hotkey_repeat_timer);",
" loop {\n select! {\n _ = &mut hotkey_repeat_timer, if &last_hotkey.is_some() => {\n let hotkey = last_hotkey.clone().unwrap();\n if hotkey.keybinding.on_release {\n continue;\n }\n send_command(hotkey.clone());\n hotkey_repeat_timer.as_mut().reset(Instant::now() + Duration::from_millis(repeat_cooldown_duration));\n }",
" Some(signal) = signals.next() => {\n match signal {\n SIGUSR1 => {\n execution_is_paused = true;\n for mut device in evdev::enumerate().filter(check_device_is_keyboard) {\n let _ = device.ungrab();\n }\n }",
" SIGUSR2 => {\n execution_is_paused = false;\n for mut device in evdev::enumerate().filter(check_device_is_keyboard) {\n let _ = device.grab();\n }\n }",
" SIGHUP => {\n hotkeys = load_config();\n }",
" SIGINT => {\n for mut device in evdev::enumerate().filter(check_device_is_keyboard) {\n let _ = device.ungrab();\n }\n log::warn!(\"Received SIGINT signal, exiting...\");\n exit(1);\n }",
" _ => {\n for mut device in evdev::enumerate().filter(check_device_is_keyboard) {\n let _ = device.ungrab();\n }",
" log::warn!(\"Received signal: {:#?}\", signal);\n log::warn!(\"Exiting...\");\n exit(1);\n }\n }\n }",
" Some((i, Ok(event))) = keyboard_stream_map.next() => {\n let keyboard_state = &mut keyboard_states[i];",
" let key = match event.kind() {\n InputEventKind::Key(keycode) => keycode,\n _ => continue\n };",
" match event.value() {\n // Key press\n 1 => {\n if let Some(modifier) = modifiers_map.get(&key) {\n keyboard_state.state_modifiers.insert(*modifier);\n } else {\n keyboard_state.state_keysyms.insert(key);\n }\n }",
" // Key release\n 0 => {\n if last_hotkey.is_some() && pending_release {\n pending_release = false;\n send_command(last_hotkey.clone().unwrap());\n last_hotkey = None;\n }\n if let Some(modifier) = modifiers_map.get(&key) {\n if let Some(hotkey) = &last_hotkey {\n if hotkey.modifiers().contains(modifier) {\n last_hotkey = None;\n }\n }\n keyboard_state.state_modifiers.remove(modifier);\n } else if keyboard_state.state_keysyms.contains(key) {\n if let Some(hotkey) = &last_hotkey {\n if key == hotkey.keysym() {\n last_hotkey = None;\n }\n }\n keyboard_state.state_keysyms.remove(key);\n }\n }",
" _ => {}\n }",
" let possible_hotkeys: Vec<&config::Hotkey> = hotkeys.iter()\n .filter(|hotkey| hotkey.modifiers().len() == keyboard_state.state_modifiers.len())\n .collect();",
" let event_in_hotkeys = hotkeys.iter().any(|hotkey| {\n hotkey.keysym().code() == event.code() &&\n keyboard_state.state_modifiers\n .iter()\n .all(|x| hotkey.modifiers().contains(x)) &&\n keyboard_state.state_modifiers.len() == hotkey.modifiers().len()\n && !hotkey.is_send()\n });",
" // Don't emit event to virtual device if it's from a valid hotkey\n if !event_in_hotkeys {\n uinput_device.emit(&[event]).unwrap();\n }",
" if execution_is_paused || possible_hotkeys.is_empty() || last_hotkey.is_some() {\n continue;\n }",
" log::debug!(\"state_modifiers: {:#?}\", keyboard_state.state_modifiers);\n log::debug!(\"state_keysyms: {:#?}\", keyboard_state.state_keysyms);\n log::debug!(\"hotkey: {:#?}\", possible_hotkeys);",
" for hotkey in possible_hotkeys {\n // this should check if state_modifiers and hotkey.modifiers have the same elements\n if keyboard_state.state_modifiers.iter().all(|x| hotkey.modifiers().contains(x))\n && keyboard_state.state_modifiers.len() == hotkey.modifiers().len()\n && keyboard_state.state_keysyms.contains(hotkey.keysym())\n {\n last_hotkey = Some(hotkey.clone());\n if pending_release { break; }\n if hotkey.is_on_release() {\n pending_release = true;\n break;\n }\n send_command(hotkey.clone());\n hotkey_repeat_timer.as_mut().reset(Instant::now() + Duration::from_millis(repeat_cooldown_duration));\n break;\n }\n }\n }\n }\n }\n}",
"fn sock_send(command: &str) -> std::io::Result<()> {\n let mut stream = UnixStream::connect(\"/tmp/swhkd.sock\")?;\n stream.write_all(command.as_bytes())?;\n Ok(())\n}",
"fn send_command(hotkey: config::Hotkey) {\n log::info!(\"Hotkey pressed: {:#?}\", hotkey);\n if let Err(e) = sock_send(&hotkey.command) {\n log::error!(\"Failed to send command to swhks through IPC.\");\n log::error!(\"Please make sure that swhks is running.\");\n log::error!(\"Err: {:#?}\", e)\n }\n}",
"pub fn check_user_permissions() -> Result<(), ()> {\n if !Uid::current().is_root() {\n let groups = nix::unistd::getgroups();\n for (_, groups) in groups.iter().enumerate() {\n for group in groups {\n let group = Group::from_gid(*group);\n if group.unwrap().unwrap().name == \"input\" {\n log::error!(\"Note: INVOKING USER IS IN INPUT GROUP!!!!\");\n log::error!(\"THIS IS A HUGE SECURITY RISK!!!!\");\n }\n }\n }\n log::error!(\"Consider using `pkexec swhkd ...`\");\n Err(())\n } else {\n log::warn!(\"Running swhkd as root!\");\n Ok(())\n }\n}",
"pub fn check_device_is_keyboard(device: &Device) -> bool {\n if device.supported_keys().map_or(false, |keys| keys.contains(Key::KEY_ENTER)) {\n if device.name() == Some(\"swhkd virtual output\") {\n return false;\n }\n log::debug!(\"Keyboard: {}\", device.name().unwrap(),);\n true\n } else {\n log::trace!(\"Other: {}\", device.name().unwrap(),);\n false\n }\n}",
"pub fn set_command_line_args() -> Command<'static> {\n let app = Command::new(\"swhkd\")\n .version(env!(\"CARGO_PKG_VERSION\"))\n .author(env!(\"CARGO_PKG_AUTHORS\"))\n .about(\"Simple Wayland HotKey Daemon\")\n .arg(\n arg!(-c --config <CONFIG_FILE_PATH>)\n .required(false)\n .takes_value(true)\n .help(\"Set a custom config file path.\"),\n )\n .arg(\n arg!(-C --cooldown <COOLDOWN_IN_MS>)\n .required(false)\n .takes_value(true)\n .help(\"Set a custom repeat cooldown duration. Default is 250ms.\"),\n )\n .arg(arg!(-d - -debug).required(false).help(\"Enable debug mode.\"));\n app\n}",
"pub fn fetch_xdg_config_path() -> std::path::PathBuf {\n let config_file_path: std::path::PathBuf = match env::var(\"XDG_CONFIG_HOME\") {\n Ok(val) => {\n log::debug!(\"XDG_CONFIG_HOME exists: {:#?}\", val);\n Path::new(&val).join(\"swhkd/swhkdrc\")\n }\n Err(_) => {\n log::error!(\"XDG_CONFIG_HOME has not been set.\");\n Path::new(\"/etc/swhkd/swhkdrc\").to_path_buf()\n }\n };\n config_file_path\n}",
"\npub fn seteuid(uid: u32) {\n let uid = nix::unistd::Uid::from_raw(uid);\n match nix::unistd::seteuid(uid) {\n Ok(_) => log::debug!(\"Dropping privileges...\"),\n Err(e) => {\n log::error!(\"Failed to set UID: {:#?}\", e);\n exit(1);\n }\n }\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [516, 31, 401], "buggy_code_start_loc": [107, 25, 87], "filenames": ["Cargo.lock", "Cargo.toml", "src/daemon.rs"], "fixing_code_end_loc": [517, 32, 414], "fixing_code_start_loc": [107, 26, 88], "message": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device).", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:waycrate:swhkd:1.1.5:*:*:*:*:*:*:*", "matchCriteriaId": "6C4A9210-751B-49B0-8AD4-CDDA0593D448", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "SWHKD 1.1.5 allows unsafe parsing via the -c option. An information leak might occur but there is a simple denial of service (memory exhaustion) upon an attempt to parse a large or infinite file (such as a block or character device)."}, {"lang": "es", "value": "SWHKD versi\u00f3n 1.1.5 permite un an\u00e1lisis no seguro por medio de la opci\u00f3n -c. Puede producirse un filtrado de informaci\u00f3n, pero se presenta una simple denegaci\u00f3n de servicio (agotamiento de memoria) al intentar analizar un archivo grande o infinito (como un dispositivo de bloques o caracteres)"}], "evaluatorComment": null, "id": "CVE-2022-27819", "lastModified": "2022-04-14T13:13:12.250", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 4.0, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:N/AC:H/Au:N/C:P/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 4.9, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": true}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.0, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-04-07T02:15:07.257", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2022/04/14/1"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, {"source": "cve@mitre.org", "tags": ["Release Notes"], "url": "https://github.com/waycrate/swhkd/releases"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-400"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/waycrate/swhkd/commit/b4e6dc76f4845ab03104187a42ac6d1bbc1e0021"}, "type": "CWE-400"}
| 366
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n *\tAn async IO implementation for Linux\n *\tWritten by Benjamin LaHaise <bcrl@kvack.org>\n *\n *\tImplements an efficient asynchronous io interface.\n *\n *\tCopyright 2000, 2001, 2002 Red Hat, Inc. All Rights Reserved.\n *\n *\tSee ../COPYING for licensing terms.\n */\n#include <linux/kernel.h>\n#include <linux/init.h>\n#include <linux/errno.h>\n#include <linux/time.h>\n#include <linux/aio_abi.h>\n#include <linux/module.h>\n#include <linux/syscalls.h>\n#include <linux/backing-dev.h>\n#include <linux/uio.h>",
"#define DEBUG 0",
"#include <linux/sched.h>\n#include <linux/fs.h>\n#include <linux/file.h>\n#include <linux/mm.h>\n#include <linux/mman.h>\n#include <linux/mmu_context.h>\n#include <linux/slab.h>\n#include <linux/timer.h>\n#include <linux/aio.h>\n#include <linux/highmem.h>\n#include <linux/workqueue.h>\n#include <linux/security.h>\n#include <linux/eventfd.h>\n#include <linux/blkdev.h>\n#include <linux/compat.h>",
"#include <asm/kmap_types.h>\n#include <asm/uaccess.h>",
"#if DEBUG > 1\n#define dprintk\t\tprintk\n#else\n#define dprintk(x...)\tdo { ; } while (0)\n#endif",
"/*------ sysctl variables----*/\nstatic DEFINE_SPINLOCK(aio_nr_lock);\nunsigned long aio_nr;\t\t/* current system wide number of aio requests */\nunsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */\n/*----end sysctl variables---*/",
"static struct kmem_cache\t*kiocb_cachep;\nstatic struct kmem_cache\t*kioctx_cachep;",
"static struct workqueue_struct *aio_wq;",
"/* Used for rare fput completion. */\nstatic void aio_fput_routine(struct work_struct *);\nstatic DECLARE_WORK(fput_work, aio_fput_routine);",
"static DEFINE_SPINLOCK(fput_lock);\nstatic LIST_HEAD(fput_head);",
"static void aio_kick_handler(struct work_struct *);\nstatic void aio_queue_work(struct kioctx *);",
"/* aio_setup\n *\tCreates the slab caches used by the aio routines, panic on\n *\tfailure as this is done early during the boot sequence.\n */\nstatic int __init aio_setup(void)\n{\n\tkiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC);\n\tkioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC);",
"\taio_wq = alloc_workqueue(\"aio\", 0, 1);\t/* used to limit concurrency */\n\tBUG_ON(!aio_wq);",
"\tpr_debug(\"aio_setup: sizeof(struct page) = %d\\n\", (int)sizeof(struct page));",
"\treturn 0;\n}\n__initcall(aio_setup);",
"static void aio_free_ring(struct kioctx *ctx)\n{\n\tstruct aio_ring_info *info = &ctx->ring_info;\n\tlong i;",
"\tfor (i=0; i<info->nr_pages; i++)\n\t\tput_page(info->ring_pages[i]);",
"\tif (info->mmap_size) {\n\t\tdown_write(&ctx->mm->mmap_sem);\n\t\tdo_munmap(ctx->mm, info->mmap_base, info->mmap_size);\n\t\tup_write(&ctx->mm->mmap_sem);\n\t}",
"\tif (info->ring_pages && info->ring_pages != info->internal_pages)\n\t\tkfree(info->ring_pages);\n\tinfo->ring_pages = NULL;\n\tinfo->nr = 0;\n}",
"static int aio_setup_ring(struct kioctx *ctx)\n{\n\tstruct aio_ring *ring;\n\tstruct aio_ring_info *info = &ctx->ring_info;\n\tunsigned nr_events = ctx->max_reqs;\n\tunsigned long size;\n\tint nr_pages;",
"\t/* Compensate for the ring buffer's head/tail overlap entry */\n\tnr_events += 2;\t/* 1 is required, 2 for good luck */",
"\tsize = sizeof(struct aio_ring);\n\tsize += sizeof(struct io_event) * nr_events;\n\tnr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;",
"\tif (nr_pages < 0)\n\t\treturn -EINVAL;",
"\tnr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);",
"\tinfo->nr = 0;\n\tinfo->ring_pages = info->internal_pages;\n\tif (nr_pages > AIO_RING_PAGES) {\n\t\tinfo->ring_pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);\n\t\tif (!info->ring_pages)\n\t\t\treturn -ENOMEM;\n\t}",
"\tinfo->mmap_size = nr_pages * PAGE_SIZE;\n\tdprintk(\"attempting mmap of %lu bytes\\n\", info->mmap_size);\n\tdown_write(&ctx->mm->mmap_sem);\n\tinfo->mmap_base = do_mmap(NULL, 0, info->mmap_size, \n\t\t\t\t PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE,\n\t\t\t\t 0);\n\tif (IS_ERR((void *)info->mmap_base)) {\n\t\tup_write(&ctx->mm->mmap_sem);\n\t\tinfo->mmap_size = 0;\n\t\taio_free_ring(ctx);\n\t\treturn -EAGAIN;\n\t}",
"\tdprintk(\"mmap address: 0x%08lx\\n\", info->mmap_base);\n\tinfo->nr_pages = get_user_pages(current, ctx->mm,\n\t\t\t\t\tinfo->mmap_base, nr_pages, \n\t\t\t\t\t1, 0, info->ring_pages, NULL);\n\tup_write(&ctx->mm->mmap_sem);",
"\tif (unlikely(info->nr_pages != nr_pages)) {\n\t\taio_free_ring(ctx);\n\t\treturn -EAGAIN;\n\t}",
"\tctx->user_id = info->mmap_base;",
"\tinfo->nr = nr_events;\t\t/* trusted copy */",
"\tring = kmap_atomic(info->ring_pages[0], KM_USER0);\n\tring->nr = nr_events;\t/* user copy */\n\tring->id = ctx->user_id;\n\tring->head = ring->tail = 0;\n\tring->magic = AIO_RING_MAGIC;\n\tring->compat_features = AIO_RING_COMPAT_FEATURES;\n\tring->incompat_features = AIO_RING_INCOMPAT_FEATURES;\n\tring->header_length = sizeof(struct aio_ring);\n\tkunmap_atomic(ring, KM_USER0);",
"\treturn 0;\n}",
"\n/* aio_ring_event: returns a pointer to the event at the given index from\n * kmap_atomic(, km). Release the pointer with put_aio_ring_event();\n */\n#define AIO_EVENTS_PER_PAGE\t(PAGE_SIZE / sizeof(struct io_event))\n#define AIO_EVENTS_FIRST_PAGE\t((PAGE_SIZE - sizeof(struct aio_ring)) / sizeof(struct io_event))\n#define AIO_EVENTS_OFFSET\t(AIO_EVENTS_PER_PAGE - AIO_EVENTS_FIRST_PAGE)",
"#define aio_ring_event(info, nr, km) ({\t\t\t\t\t\\\n\tunsigned pos = (nr) + AIO_EVENTS_OFFSET;\t\t\t\\\n\tstruct io_event *__event;\t\t\t\t\t\\\n\t__event = kmap_atomic(\t\t\t\t\t\t\\\n\t\t\t(info)->ring_pages[pos / AIO_EVENTS_PER_PAGE], km); \\\n\t__event += pos % AIO_EVENTS_PER_PAGE;\t\t\t\t\\\n\t__event;\t\t\t\t\t\t\t\\\n})",
"#define put_aio_ring_event(event, km) do {\t\\\n\tstruct io_event *__event = (event);\t\\\n\t(void)__event;\t\t\t\t\\\n\tkunmap_atomic((void *)((unsigned long)__event & PAGE_MASK), km); \\\n} while(0)",
"static void ctx_rcu_free(struct rcu_head *head)\n{\n\tstruct kioctx *ctx = container_of(head, struct kioctx, rcu_head);\n\tunsigned nr_events = ctx->max_reqs;",
"\tkmem_cache_free(kioctx_cachep, ctx);",
"\tif (nr_events) {\n\t\tspin_lock(&aio_nr_lock);\n\t\tBUG_ON(aio_nr - nr_events > aio_nr);\n\t\taio_nr -= nr_events;\n\t\tspin_unlock(&aio_nr_lock);\n\t}\n}",
"/* __put_ioctx\n *\tCalled when the last user of an aio context has gone away,\n *\tand the struct needs to be freed.\n */\nstatic void __put_ioctx(struct kioctx *ctx)\n{\n\tBUG_ON(ctx->reqs_active);",
"\tcancel_delayed_work(&ctx->wq);\n\tcancel_work_sync(&ctx->wq.work);\n\taio_free_ring(ctx);\n\tmmdrop(ctx->mm);\n\tctx->mm = NULL;\n\tpr_debug(\"__put_ioctx: freeing %p\\n\", ctx);\n\tcall_rcu(&ctx->rcu_head, ctx_rcu_free);\n}",
"static inline void get_ioctx(struct kioctx *kioctx)\n{\n\tBUG_ON(atomic_read(&kioctx->users) <= 0);\n\tatomic_inc(&kioctx->users);\n}",
"static inline int try_get_ioctx(struct kioctx *kioctx)\n{\n\treturn atomic_inc_not_zero(&kioctx->users);\n}",
"static inline void put_ioctx(struct kioctx *kioctx)\n{\n\tBUG_ON(atomic_read(&kioctx->users) <= 0);\n\tif (unlikely(atomic_dec_and_test(&kioctx->users)))\n\t\t__put_ioctx(kioctx);\n}",
"/* ioctx_alloc\n *\tAllocates and initializes an ioctx. Returns an ERR_PTR if it failed.\n */\nstatic struct kioctx *ioctx_alloc(unsigned nr_events)\n{\n\tstruct mm_struct *mm;\n\tstruct kioctx *ctx;\n\tint did_sync = 0;",
"\t/* Prevent overflows */\n\tif ((nr_events > (0x10000000U / sizeof(struct io_event))) ||\n\t (nr_events > (0x10000000U / sizeof(struct kiocb)))) {\n\t\tpr_debug(\"ENOMEM: nr_events too high\\n\");\n\t\treturn ERR_PTR(-EINVAL);\n\t}",
"\tif ((unsigned long)nr_events > aio_max_nr)\n\t\treturn ERR_PTR(-EAGAIN);",
"\tctx = kmem_cache_zalloc(kioctx_cachep, GFP_KERNEL);\n\tif (!ctx)\n\t\treturn ERR_PTR(-ENOMEM);",
"\tctx->max_reqs = nr_events;\n\tmm = ctx->mm = current->mm;\n\tatomic_inc(&mm->mm_count);",
"\tatomic_set(&ctx->users, 1);\n\tspin_lock_init(&ctx->ctx_lock);\n\tspin_lock_init(&ctx->ring_info.ring_lock);\n\tinit_waitqueue_head(&ctx->wait);",
"\tINIT_LIST_HEAD(&ctx->active_reqs);\n\tINIT_LIST_HEAD(&ctx->run_list);\n\tINIT_DELAYED_WORK(&ctx->wq, aio_kick_handler);",
"\tif (aio_setup_ring(ctx) < 0)\n\t\tgoto out_freectx;",
"\t/* limit the number of system wide aios */\n\tdo {\n\t\tspin_lock_bh(&aio_nr_lock);\n\t\tif (aio_nr + nr_events > aio_max_nr ||\n\t\t aio_nr + nr_events < aio_nr)\n\t\t\tctx->max_reqs = 0;\n\t\telse\n\t\t\taio_nr += ctx->max_reqs;\n\t\tspin_unlock_bh(&aio_nr_lock);\n\t\tif (ctx->max_reqs || did_sync)\n\t\t\tbreak;",
"\t\t/* wait for rcu callbacks to have completed before giving up */\n\t\tsynchronize_rcu();\n\t\tdid_sync = 1;\n\t\tctx->max_reqs = nr_events;\n\t} while (1);",
"\tif (ctx->max_reqs == 0)\n\t\tgoto out_cleanup;",
"\t/* now link into global list. */\n\tspin_lock(&mm->ioctx_lock);\n\thlist_add_head_rcu(&ctx->list, &mm->ioctx_list);\n\tspin_unlock(&mm->ioctx_lock);",
"\tdprintk(\"aio: allocated ioctx %p[%ld]: mm=%p mask=0x%x\\n\",\n\t\tctx, ctx->user_id, current->mm, ctx->ring_info.nr);\n\treturn ctx;",
"out_cleanup:\n\t__put_ioctx(ctx);\n\treturn ERR_PTR(-EAGAIN);",
"out_freectx:\n\tmmdrop(mm);\n\tkmem_cache_free(kioctx_cachep, ctx);\n\tctx = ERR_PTR(-ENOMEM);",
"\tdprintk(\"aio: error allocating ioctx %p\\n\", ctx);\n\treturn ctx;\n}",
"/* aio_cancel_all\n *\tCancels all outstanding aio requests on an aio context. Used \n *\twhen the processes owning a context have all exited to encourage \n *\tthe rapid destruction of the kioctx.\n */\nstatic void aio_cancel_all(struct kioctx *ctx)\n{\n\tint (*cancel)(struct kiocb *, struct io_event *);\n\tstruct io_event res;\n\tspin_lock_irq(&ctx->ctx_lock);\n\tctx->dead = 1;\n\twhile (!list_empty(&ctx->active_reqs)) {\n\t\tstruct list_head *pos = ctx->active_reqs.next;\n\t\tstruct kiocb *iocb = list_kiocb(pos);\n\t\tlist_del_init(&iocb->ki_list);\n\t\tcancel = iocb->ki_cancel;\n\t\tkiocbSetCancelled(iocb);\n\t\tif (cancel) {\n\t\t\tiocb->ki_users++;\n\t\t\tspin_unlock_irq(&ctx->ctx_lock);\n\t\t\tcancel(iocb, &res);\n\t\t\tspin_lock_irq(&ctx->ctx_lock);\n\t\t}\n\t}\n\tspin_unlock_irq(&ctx->ctx_lock);\n}",
"static void wait_for_all_aios(struct kioctx *ctx)\n{\n\tstruct task_struct *tsk = current;\n\tDECLARE_WAITQUEUE(wait, tsk);",
"\tspin_lock_irq(&ctx->ctx_lock);\n\tif (!ctx->reqs_active)\n\t\tgoto out;",
"\tadd_wait_queue(&ctx->wait, &wait);\n\tset_task_state(tsk, TASK_UNINTERRUPTIBLE);\n\twhile (ctx->reqs_active) {\n\t\tspin_unlock_irq(&ctx->ctx_lock);\n\t\tio_schedule();\n\t\tset_task_state(tsk, TASK_UNINTERRUPTIBLE);\n\t\tspin_lock_irq(&ctx->ctx_lock);\n\t}\n\t__set_task_state(tsk, TASK_RUNNING);\n\tremove_wait_queue(&ctx->wait, &wait);",
"out:\n\tspin_unlock_irq(&ctx->ctx_lock);\n}",
"/* wait_on_sync_kiocb:\n *\tWaits on the given sync kiocb to complete.\n */\nssize_t wait_on_sync_kiocb(struct kiocb *iocb)\n{\n\twhile (iocb->ki_users) {\n\t\tset_current_state(TASK_UNINTERRUPTIBLE);\n\t\tif (!iocb->ki_users)\n\t\t\tbreak;\n\t\tio_schedule();\n\t}\n\t__set_current_state(TASK_RUNNING);\n\treturn iocb->ki_user_data;\n}\nEXPORT_SYMBOL(wait_on_sync_kiocb);",
"/* exit_aio: called when the last user of mm goes away. At this point, \n * there is no way for any new requests to be submited or any of the \n * io_* syscalls to be called on the context. However, there may be \n * outstanding requests which hold references to the context; as they \n * go away, they will call put_ioctx and release any pinned memory\n * associated with the request (held via struct page * references).\n */\nvoid exit_aio(struct mm_struct *mm)\n{\n\tstruct kioctx *ctx;",
"\twhile (!hlist_empty(&mm->ioctx_list)) {\n\t\tctx = hlist_entry(mm->ioctx_list.first, struct kioctx, list);\n\t\thlist_del_rcu(&ctx->list);",
"\t\taio_cancel_all(ctx);",
"\t\twait_for_all_aios(ctx);\n\t\t/*\n\t\t * Ensure we don't leave the ctx on the aio_wq\n\t\t */\n\t\tcancel_work_sync(&ctx->wq.work);",
"\t\tif (1 != atomic_read(&ctx->users))\n\t\t\tprintk(KERN_DEBUG\n\t\t\t\t\"exit_aio:ioctx still alive: %d %d %d\\n\",\n\t\t\t\tatomic_read(&ctx->users), ctx->dead,\n\t\t\t\tctx->reqs_active);\n\t\tput_ioctx(ctx);\n\t}\n}",
"/* aio_get_req\n *\tAllocate a slot for an aio request. Increments the users count\n * of the kioctx so that the kioctx stays around until all requests are\n * complete. Returns NULL if no requests are free.\n *\n * Returns with kiocb->users set to 2. The io submit code path holds\n * an extra reference while submitting the i/o.\n * This prevents races between the aio code path referencing the\n * req (after submitting it) and aio_complete() freeing the req.\n */\nstatic struct kiocb *__aio_get_req(struct kioctx *ctx)\n{\n\tstruct kiocb *req = NULL;",
"\treq = kmem_cache_alloc(kiocb_cachep, GFP_KERNEL);\n\tif (unlikely(!req))\n\t\treturn NULL;",
"\treq->ki_flags = 0;\n\treq->ki_users = 2;\n\treq->ki_key = 0;\n\treq->ki_ctx = ctx;\n\treq->ki_cancel = NULL;\n\treq->ki_retry = NULL;\n\treq->ki_dtor = NULL;\n\treq->private = NULL;\n\treq->ki_iovec = NULL;\n\tINIT_LIST_HEAD(&req->ki_run_list);\n\treq->ki_eventfd = NULL;",
"\treturn req;\n}",
"/*\n * struct kiocb's are allocated in batches to reduce the number of\n * times the ctx lock is acquired and released.\n */\n#define KIOCB_BATCH_SIZE\t32L\nstruct kiocb_batch {\n\tstruct list_head head;\n\tlong count; /* number of requests left to allocate */\n};",
"static void kiocb_batch_init(struct kiocb_batch *batch, long total)\n{\n\tINIT_LIST_HEAD(&batch->head);\n\tbatch->count = total;\n}\n",
"static void kiocb_batch_free(struct kiocb_batch *batch)",
"{\n\tstruct kiocb *req, *n;\n",
"",
"\tlist_for_each_entry_safe(req, n, &batch->head, ki_batch) {\n\t\tlist_del(&req->ki_batch);",
"",
"\t\tkmem_cache_free(kiocb_cachep, req);",
"\t}",
"}",
"/*\n * Allocate a batch of kiocbs. This avoids taking and dropping the\n * context lock a lot during setup.\n */\nstatic int kiocb_batch_refill(struct kioctx *ctx, struct kiocb_batch *batch)\n{\n\tunsigned short allocated, to_alloc;\n\tlong avail;\n\tbool called_fput = false;\n\tstruct kiocb *req, *n;\n\tstruct aio_ring *ring;",
"\tto_alloc = min(batch->count, KIOCB_BATCH_SIZE);\n\tfor (allocated = 0; allocated < to_alloc; allocated++) {\n\t\treq = __aio_get_req(ctx);\n\t\tif (!req)\n\t\t\t/* allocation failed, go with what we've got */\n\t\t\tbreak;\n\t\tlist_add(&req->ki_batch, &batch->head);\n\t}",
"\tif (allocated == 0)\n\t\tgoto out;",
"retry:\n\tspin_lock_irq(&ctx->ctx_lock);\n\tring = kmap_atomic(ctx->ring_info.ring_pages[0]);",
"\tavail = aio_ring_avail(&ctx->ring_info, ring) - ctx->reqs_active;\n\tBUG_ON(avail < 0);\n\tif (avail == 0 && !called_fput) {\n\t\t/*\n\t\t * Handle a potential starvation case. It is possible that\n\t\t * we hold the last reference on a struct file, causing us\n\t\t * to delay the final fput to non-irq context. In this case,\n\t\t * ctx->reqs_active is artificially high. Calling the fput\n\t\t * routine here may free up a slot in the event completion\n\t\t * ring, allowing this allocation to succeed.\n\t\t */\n\t\tkunmap_atomic(ring);\n\t\tspin_unlock_irq(&ctx->ctx_lock);\n\t\taio_fput_routine(NULL);\n\t\tcalled_fput = true;\n\t\tgoto retry;\n\t}",
"\tif (avail < allocated) {\n\t\t/* Trim back the number of requests. */\n\t\tlist_for_each_entry_safe(req, n, &batch->head, ki_batch) {\n\t\t\tlist_del(&req->ki_batch);\n\t\t\tkmem_cache_free(kiocb_cachep, req);\n\t\t\tif (--allocated <= avail)\n\t\t\t\tbreak;\n\t\t}\n\t}",
"\tbatch->count -= allocated;\n\tlist_for_each_entry(req, &batch->head, ki_batch) {\n\t\tlist_add(&req->ki_list, &ctx->active_reqs);\n\t\tctx->reqs_active++;\n\t}",
"\tkunmap_atomic(ring);\n\tspin_unlock_irq(&ctx->ctx_lock);",
"out:\n\treturn allocated;\n}",
"static inline struct kiocb *aio_get_req(struct kioctx *ctx,\n\t\t\t\t\tstruct kiocb_batch *batch)\n{\n\tstruct kiocb *req;",
"\tif (list_empty(&batch->head))\n\t\tif (kiocb_batch_refill(ctx, batch) == 0)\n\t\t\treturn NULL;\n\treq = list_first_entry(&batch->head, struct kiocb, ki_batch);\n\tlist_del(&req->ki_batch);\n\treturn req;\n}",
"static inline void really_put_req(struct kioctx *ctx, struct kiocb *req)\n{\n\tassert_spin_locked(&ctx->ctx_lock);",
"\tif (req->ki_eventfd != NULL)\n\t\teventfd_ctx_put(req->ki_eventfd);\n\tif (req->ki_dtor)\n\t\treq->ki_dtor(req);\n\tif (req->ki_iovec != &req->ki_inline_vec)\n\t\tkfree(req->ki_iovec);\n\tkmem_cache_free(kiocb_cachep, req);\n\tctx->reqs_active--;",
"\tif (unlikely(!ctx->reqs_active && ctx->dead))\n\t\twake_up_all(&ctx->wait);\n}",
"static void aio_fput_routine(struct work_struct *data)\n{\n\tspin_lock_irq(&fput_lock);\n\twhile (likely(!list_empty(&fput_head))) {\n\t\tstruct kiocb *req = list_kiocb(fput_head.next);\n\t\tstruct kioctx *ctx = req->ki_ctx;",
"\t\tlist_del(&req->ki_list);\n\t\tspin_unlock_irq(&fput_lock);",
"\t\t/* Complete the fput(s) */\n\t\tif (req->ki_filp != NULL)\n\t\t\tfput(req->ki_filp);",
"\t\t/* Link the iocb into the context's free list */\n\t\tspin_lock_irq(&ctx->ctx_lock);\n\t\treally_put_req(ctx, req);\n\t\tspin_unlock_irq(&ctx->ctx_lock);",
"\t\tput_ioctx(ctx);\n\t\tspin_lock_irq(&fput_lock);\n\t}\n\tspin_unlock_irq(&fput_lock);\n}",
"/* __aio_put_req\n *\tReturns true if this put was the last user of the request.\n */\nstatic int __aio_put_req(struct kioctx *ctx, struct kiocb *req)\n{\n\tdprintk(KERN_DEBUG \"aio_put(%p): f_count=%ld\\n\",\n\t\treq, atomic_long_read(&req->ki_filp->f_count));",
"\tassert_spin_locked(&ctx->ctx_lock);",
"\treq->ki_users--;\n\tBUG_ON(req->ki_users < 0);\n\tif (likely(req->ki_users))\n\t\treturn 0;\n\tlist_del(&req->ki_list);\t\t/* remove from active_reqs */\n\treq->ki_cancel = NULL;\n\treq->ki_retry = NULL;",
"\t/*\n\t * Try to optimize the aio and eventfd file* puts, by avoiding to\n\t * schedule work in case it is not final fput() time. In normal cases,\n\t * we would not be holding the last reference to the file*, so\n\t * this function will be executed w/out any aio kthread wakeup.\n\t */\n\tif (unlikely(!fput_atomic(req->ki_filp))) {\n\t\tget_ioctx(ctx);\n\t\tspin_lock(&fput_lock);\n\t\tlist_add(&req->ki_list, &fput_head);\n\t\tspin_unlock(&fput_lock);\n\t\tschedule_work(&fput_work);\n\t} else {\n\t\treq->ki_filp = NULL;\n\t\treally_put_req(ctx, req);\n\t}\n\treturn 1;\n}",
"/* aio_put_req\n *\tReturns true if this put was the last user of the kiocb,\n *\tfalse if the request is still in use.\n */\nint aio_put_req(struct kiocb *req)\n{\n\tstruct kioctx *ctx = req->ki_ctx;\n\tint ret;\n\tspin_lock_irq(&ctx->ctx_lock);\n\tret = __aio_put_req(ctx, req);\n\tspin_unlock_irq(&ctx->ctx_lock);\n\treturn ret;\n}\nEXPORT_SYMBOL(aio_put_req);",
"static struct kioctx *lookup_ioctx(unsigned long ctx_id)\n{\n\tstruct mm_struct *mm = current->mm;\n\tstruct kioctx *ctx, *ret = NULL;\n\tstruct hlist_node *n;",
"\trcu_read_lock();",
"\thlist_for_each_entry_rcu(ctx, n, &mm->ioctx_list, list) {\n\t\t/*\n\t\t * RCU protects us against accessing freed memory but\n\t\t * we have to be careful not to get a reference when the\n\t\t * reference count already dropped to 0 (ctx->dead test\n\t\t * is unreliable because of races).\n\t\t */\n\t\tif (ctx->user_id == ctx_id && !ctx->dead && try_get_ioctx(ctx)){\n\t\t\tret = ctx;\n\t\t\tbreak;\n\t\t}\n\t}",
"\trcu_read_unlock();\n\treturn ret;\n}",
"/*\n * Queue up a kiocb to be retried. Assumes that the kiocb\n * has already been marked as kicked, and places it on\n * the retry run list for the corresponding ioctx, if it\n * isn't already queued. Returns 1 if it actually queued\n * the kiocb (to tell the caller to activate the work\n * queue to process it), or 0, if it found that it was\n * already queued.\n */\nstatic inline int __queue_kicked_iocb(struct kiocb *iocb)\n{\n\tstruct kioctx *ctx = iocb->ki_ctx;",
"\tassert_spin_locked(&ctx->ctx_lock);",
"\tif (list_empty(&iocb->ki_run_list)) {\n\t\tlist_add_tail(&iocb->ki_run_list,\n\t\t\t&ctx->run_list);\n\t\treturn 1;\n\t}\n\treturn 0;\n}",
"/* aio_run_iocb\n *\tThis is the core aio execution routine. It is\n *\tinvoked both for initial i/o submission and\n *\tsubsequent retries via the aio_kick_handler.\n *\tExpects to be invoked with iocb->ki_ctx->lock\n *\talready held. The lock is released and reacquired\n *\tas needed during processing.\n *\n * Calls the iocb retry method (already setup for the\n * iocb on initial submission) for operation specific\n * handling, but takes care of most of common retry\n * execution details for a given iocb. The retry method\n * needs to be non-blocking as far as possible, to avoid\n * holding up other iocbs waiting to be serviced by the\n * retry kernel thread.\n *\n * The trickier parts in this code have to do with\n * ensuring that only one retry instance is in progress\n * for a given iocb at any time. Providing that guarantee\n * simplifies the coding of individual aio operations as\n * it avoids various potential races.\n */\nstatic ssize_t aio_run_iocb(struct kiocb *iocb)\n{\n\tstruct kioctx\t*ctx = iocb->ki_ctx;\n\tssize_t (*retry)(struct kiocb *);\n\tssize_t ret;",
"\tif (!(retry = iocb->ki_retry)) {\n\t\tprintk(\"aio_run_iocb: iocb->ki_retry = NULL\\n\");\n\t\treturn 0;\n\t}",
"\t/*\n\t * We don't want the next retry iteration for this\n\t * operation to start until this one has returned and\n\t * updated the iocb state. However, wait_queue functions\n\t * can trigger a kick_iocb from interrupt context in the\n\t * meantime, indicating that data is available for the next\n\t * iteration. We want to remember that and enable the\n\t * next retry iteration _after_ we are through with\n\t * this one.\n\t *\n\t * So, in order to be able to register a \"kick\", but\n\t * prevent it from being queued now, we clear the kick\n\t * flag, but make the kick code *think* that the iocb is\n\t * still on the run list until we are actually done.\n\t * When we are done with this iteration, we check if\n\t * the iocb was kicked in the meantime and if so, queue\n\t * it up afresh.\n\t */",
"\tkiocbClearKicked(iocb);",
"\t/*\n\t * This is so that aio_complete knows it doesn't need to\n\t * pull the iocb off the run list (We can't just call\n\t * INIT_LIST_HEAD because we don't want a kick_iocb to\n\t * queue this on the run list yet)\n\t */\n\tiocb->ki_run_list.next = iocb->ki_run_list.prev = NULL;\n\tspin_unlock_irq(&ctx->ctx_lock);",
"\t/* Quit retrying if the i/o has been cancelled */\n\tif (kiocbIsCancelled(iocb)) {\n\t\tret = -EINTR;\n\t\taio_complete(iocb, ret, 0);\n\t\t/* must not access the iocb after this */\n\t\tgoto out;\n\t}",
"\t/*\n\t * Now we are all set to call the retry method in async\n\t * context.\n\t */\n\tret = retry(iocb);",
"\tif (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) {\n\t\t/*\n\t\t * There's no easy way to restart the syscall since other AIO's\n\t\t * may be already running. Just fail this IO with EINTR.\n\t\t */\n\t\tif (unlikely(ret == -ERESTARTSYS || ret == -ERESTARTNOINTR ||\n\t\t\t ret == -ERESTARTNOHAND || ret == -ERESTART_RESTARTBLOCK))\n\t\t\tret = -EINTR;\n\t\taio_complete(iocb, ret, 0);\n\t}\nout:\n\tspin_lock_irq(&ctx->ctx_lock);",
"\tif (-EIOCBRETRY == ret) {\n\t\t/*\n\t\t * OK, now that we are done with this iteration\n\t\t * and know that there is more left to go,\n\t\t * this is where we let go so that a subsequent\n\t\t * \"kick\" can start the next iteration\n\t\t */",
"\t\t/* will make __queue_kicked_iocb succeed from here on */\n\t\tINIT_LIST_HEAD(&iocb->ki_run_list);\n\t\t/* we must queue the next iteration ourselves, if it\n\t\t * has already been kicked */\n\t\tif (kiocbIsKicked(iocb)) {\n\t\t\t__queue_kicked_iocb(iocb);",
"\t\t\t/*\n\t\t\t * __queue_kicked_iocb will always return 1 here, because\n\t\t\t * iocb->ki_run_list is empty at this point so it should\n\t\t\t * be safe to unconditionally queue the context into the\n\t\t\t * work queue.\n\t\t\t */\n\t\t\taio_queue_work(ctx);\n\t\t}\n\t}\n\treturn ret;\n}",
"/*\n * __aio_run_iocbs:\n * \tProcess all pending retries queued on the ioctx\n * \trun list.\n * Assumes it is operating within the aio issuer's mm\n * context.\n */\nstatic int __aio_run_iocbs(struct kioctx *ctx)\n{\n\tstruct kiocb *iocb;\n\tstruct list_head run_list;",
"\tassert_spin_locked(&ctx->ctx_lock);",
"\tlist_replace_init(&ctx->run_list, &run_list);\n\twhile (!list_empty(&run_list)) {\n\t\tiocb = list_entry(run_list.next, struct kiocb,\n\t\t\tki_run_list);\n\t\tlist_del(&iocb->ki_run_list);\n\t\t/*\n\t\t * Hold an extra reference while retrying i/o.\n\t\t */\n\t\tiocb->ki_users++; /* grab extra reference */\n\t\taio_run_iocb(iocb);\n\t\t__aio_put_req(ctx, iocb);\n \t}\n\tif (!list_empty(&ctx->run_list))\n\t\treturn 1;\n\treturn 0;\n}",
"static void aio_queue_work(struct kioctx * ctx)\n{\n\tunsigned long timeout;\n\t/*\n\t * if someone is waiting, get the work started right\n\t * away, otherwise, use a longer delay\n\t */\n\tsmp_mb();\n\tif (waitqueue_active(&ctx->wait))\n\t\ttimeout = 1;\n\telse\n\t\ttimeout = HZ/10;\n\tqueue_delayed_work(aio_wq, &ctx->wq, timeout);\n}",
"/*\n * aio_run_all_iocbs:\n *\tProcess all pending retries queued on the ioctx\n *\trun list, and keep running them until the list\n *\tstays empty.\n * Assumes it is operating within the aio issuer's mm context.\n */\nstatic inline void aio_run_all_iocbs(struct kioctx *ctx)\n{\n\tspin_lock_irq(&ctx->ctx_lock);\n\twhile (__aio_run_iocbs(ctx))\n\t\t;\n\tspin_unlock_irq(&ctx->ctx_lock);\n}",
"/*\n * aio_kick_handler:\n * \tWork queue handler triggered to process pending\n * \tretries on an ioctx. Takes on the aio issuer's\n *\tmm context before running the iocbs, so that\n *\tcopy_xxx_user operates on the issuer's address\n * space.\n * Run on aiod's context.\n */\nstatic void aio_kick_handler(struct work_struct *work)\n{\n\tstruct kioctx *ctx = container_of(work, struct kioctx, wq.work);\n\tmm_segment_t oldfs = get_fs();\n\tstruct mm_struct *mm;\n\tint requeue;",
"\tset_fs(USER_DS);\n\tuse_mm(ctx->mm);\n\tspin_lock_irq(&ctx->ctx_lock);\n\trequeue =__aio_run_iocbs(ctx);\n\tmm = ctx->mm;\n\tspin_unlock_irq(&ctx->ctx_lock);\n \tunuse_mm(mm);\n\tset_fs(oldfs);\n\t/*\n\t * we're in a worker thread already, don't use queue_delayed_work,\n\t */\n\tif (requeue)\n\t\tqueue_delayed_work(aio_wq, &ctx->wq, 0);\n}",
"\n/*\n * Called by kick_iocb to queue the kiocb for retry\n * and if required activate the aio work queue to process\n * it\n */\nstatic void try_queue_kicked_iocb(struct kiocb *iocb)\n{\n \tstruct kioctx\t*ctx = iocb->ki_ctx;\n\tunsigned long flags;\n\tint run = 0;",
"\tspin_lock_irqsave(&ctx->ctx_lock, flags);\n\t/* set this inside the lock so that we can't race with aio_run_iocb()\n\t * testing it and putting the iocb on the run list under the lock */\n\tif (!kiocbTryKick(iocb))\n\t\trun = __queue_kicked_iocb(iocb);\n\tspin_unlock_irqrestore(&ctx->ctx_lock, flags);\n\tif (run)\n\t\taio_queue_work(ctx);\n}",
"/*\n * kick_iocb:\n * Called typically from a wait queue callback context\n * to trigger a retry of the iocb.\n * The retry is usually executed by aio workqueue\n * threads (See aio_kick_handler).\n */\nvoid kick_iocb(struct kiocb *iocb)\n{\n\t/* sync iocbs are easy: they can only ever be executing from a \n\t * single context. */\n\tif (is_sync_kiocb(iocb)) {\n\t\tkiocbSetKicked(iocb);\n\t wake_up_process(iocb->ki_obj.tsk);\n\t\treturn;\n\t}",
"\ttry_queue_kicked_iocb(iocb);\n}\nEXPORT_SYMBOL(kick_iocb);",
"/* aio_complete\n *\tCalled when the io request on the given iocb is complete.\n *\tReturns true if this is the last user of the request. The \n *\tonly other user of the request can be the cancellation code.\n */\nint aio_complete(struct kiocb *iocb, long res, long res2)\n{\n\tstruct kioctx\t*ctx = iocb->ki_ctx;\n\tstruct aio_ring_info\t*info;\n\tstruct aio_ring\t*ring;\n\tstruct io_event\t*event;\n\tunsigned long\tflags;\n\tunsigned long\ttail;\n\tint\t\tret;",
"\t/*\n\t * Special case handling for sync iocbs:\n\t * - events go directly into the iocb for fast handling\n\t * - the sync task with the iocb in its stack holds the single iocb\n\t * ref, no other paths have a way to get another ref\n\t * - the sync task helpfully left a reference to itself in the iocb\n\t */\n\tif (is_sync_kiocb(iocb)) {\n\t\tBUG_ON(iocb->ki_users != 1);\n\t\tiocb->ki_user_data = res;\n\t\tiocb->ki_users = 0;\n\t\twake_up_process(iocb->ki_obj.tsk);\n\t\treturn 1;\n\t}",
"\tinfo = &ctx->ring_info;",
"\t/* add a completion event to the ring buffer.\n\t * must be done holding ctx->ctx_lock to prevent\n\t * other code from messing with the tail\n\t * pointer since we might be called from irq\n\t * context.\n\t */\n\tspin_lock_irqsave(&ctx->ctx_lock, flags);",
"\tif (iocb->ki_run_list.prev && !list_empty(&iocb->ki_run_list))\n\t\tlist_del_init(&iocb->ki_run_list);",
"\t/*\n\t * cancelled requests don't get events, userland was given one\n\t * when the event got cancelled.\n\t */\n\tif (kiocbIsCancelled(iocb))\n\t\tgoto put_rq;",
"\tring = kmap_atomic(info->ring_pages[0], KM_IRQ1);",
"\ttail = info->tail;\n\tevent = aio_ring_event(info, tail, KM_IRQ0);\n\tif (++tail >= info->nr)\n\t\ttail = 0;",
"\tevent->obj = (u64)(unsigned long)iocb->ki_obj.user;\n\tevent->data = iocb->ki_user_data;\n\tevent->res = res;\n\tevent->res2 = res2;",
"\tdprintk(\"aio_complete: %p[%lu]: %p: %p %Lx %lx %lx\\n\",\n\t\tctx, tail, iocb, iocb->ki_obj.user, iocb->ki_user_data,\n\t\tres, res2);",
"\t/* after flagging the request as done, we\n\t * must never even look at it again\n\t */\n\tsmp_wmb();\t/* make event visible before updating tail */",
"\tinfo->tail = tail;\n\tring->tail = tail;",
"\tput_aio_ring_event(event, KM_IRQ0);\n\tkunmap_atomic(ring, KM_IRQ1);",
"\tpr_debug(\"added to ring %p at [%lu]\\n\", iocb, tail);",
"\t/*\n\t * Check if the user asked us to deliver the result through an\n\t * eventfd. The eventfd_signal() function is safe to be called\n\t * from IRQ context.\n\t */\n\tif (iocb->ki_eventfd != NULL)\n\t\teventfd_signal(iocb->ki_eventfd, 1);",
"put_rq:\n\t/* everything turned out well, dispose of the aiocb. */\n\tret = __aio_put_req(ctx, iocb);",
"\t/*\n\t * We have to order our ring_info tail store above and test\n\t * of the wait list below outside the wait lock. This is\n\t * like in wake_up_bit() where clearing a bit has to be\n\t * ordered with the unlocked test.\n\t */\n\tsmp_mb();",
"\tif (waitqueue_active(&ctx->wait))\n\t\twake_up(&ctx->wait);",
"\tspin_unlock_irqrestore(&ctx->ctx_lock, flags);\n\treturn ret;\n}\nEXPORT_SYMBOL(aio_complete);",
"/* aio_read_evt\n *\tPull an event off of the ioctx's event ring. Returns the number of \n *\tevents fetched (0 or 1 ;-)\n *\tFIXME: make this use cmpxchg.\n *\tTODO: make the ringbuffer user mmap()able (requires FIXME).\n */\nstatic int aio_read_evt(struct kioctx *ioctx, struct io_event *ent)\n{\n\tstruct aio_ring_info *info = &ioctx->ring_info;\n\tstruct aio_ring *ring;\n\tunsigned long head;\n\tint ret = 0;",
"\tring = kmap_atomic(info->ring_pages[0], KM_USER0);\n\tdprintk(\"in aio_read_evt h%lu t%lu m%lu\\n\",\n\t\t (unsigned long)ring->head, (unsigned long)ring->tail,\n\t\t (unsigned long)ring->nr);",
"\tif (ring->head == ring->tail)\n\t\tgoto out;",
"\tspin_lock(&info->ring_lock);",
"\thead = ring->head % info->nr;\n\tif (head != ring->tail) {\n\t\tstruct io_event *evp = aio_ring_event(info, head, KM_USER1);\n\t\t*ent = *evp;\n\t\thead = (head + 1) % info->nr;\n\t\tsmp_mb(); /* finish reading the event before updatng the head */\n\t\tring->head = head;\n\t\tret = 1;\n\t\tput_aio_ring_event(evp, KM_USER1);\n\t}\n\tspin_unlock(&info->ring_lock);",
"out:\n\tkunmap_atomic(ring, KM_USER0);\n\tdprintk(\"leaving aio_read_evt: %d h%lu t%lu\\n\", ret,\n\t\t (unsigned long)ring->head, (unsigned long)ring->tail);\n\treturn ret;\n}",
"struct aio_timeout {\n\tstruct timer_list\ttimer;\n\tint\t\t\ttimed_out;\n\tstruct task_struct\t*p;\n};",
"static void timeout_func(unsigned long data)\n{\n\tstruct aio_timeout *to = (struct aio_timeout *)data;",
"\tto->timed_out = 1;\n\twake_up_process(to->p);\n}",
"static inline void init_timeout(struct aio_timeout *to)\n{\n\tsetup_timer_on_stack(&to->timer, timeout_func, (unsigned long) to);\n\tto->timed_out = 0;\n\tto->p = current;\n}",
"static inline void set_timeout(long start_jiffies, struct aio_timeout *to,\n\t\t\t const struct timespec *ts)\n{\n\tto->timer.expires = start_jiffies + timespec_to_jiffies(ts);\n\tif (time_after(to->timer.expires, jiffies))\n\t\tadd_timer(&to->timer);\n\telse\n\t\tto->timed_out = 1;\n}",
"static inline void clear_timeout(struct aio_timeout *to)\n{\n\tdel_singleshot_timer_sync(&to->timer);\n}",
"static int read_events(struct kioctx *ctx,\n\t\t\tlong min_nr, long nr,\n\t\t\tstruct io_event __user *event,\n\t\t\tstruct timespec __user *timeout)\n{\n\tlong\t\t\tstart_jiffies = jiffies;\n\tstruct task_struct\t*tsk = current;\n\tDECLARE_WAITQUEUE(wait, tsk);\n\tint\t\t\tret;\n\tint\t\t\ti = 0;\n\tstruct io_event\t\tent;\n\tstruct aio_timeout\tto;\n\tint\t\t\tretry = 0;",
"\t/* needed to zero any padding within an entry (there shouldn't be \n\t * any, but C is fun!\n\t */\n\tmemset(&ent, 0, sizeof(ent));\nretry:\n\tret = 0;\n\twhile (likely(i < nr)) {\n\t\tret = aio_read_evt(ctx, &ent);\n\t\tif (unlikely(ret <= 0))\n\t\t\tbreak;",
"\t\tdprintk(\"read event: %Lx %Lx %Lx %Lx\\n\",\n\t\t\tent.data, ent.obj, ent.res, ent.res2);",
"\t\t/* Could we split the check in two? */\n\t\tret = -EFAULT;\n\t\tif (unlikely(copy_to_user(event, &ent, sizeof(ent)))) {\n\t\t\tdprintk(\"aio: lost an event due to EFAULT.\\n\");\n\t\t\tbreak;\n\t\t}\n\t\tret = 0;",
"\t\t/* Good, event copied to userland, update counts. */\n\t\tevent ++;\n\t\ti ++;\n\t}",
"\tif (min_nr <= i)\n\t\treturn i;\n\tif (ret)\n\t\treturn ret;",
"\t/* End fast path */",
"\t/* racey check, but it gets redone */\n\tif (!retry && unlikely(!list_empty(&ctx->run_list))) {\n\t\tretry = 1;\n\t\taio_run_all_iocbs(ctx);\n\t\tgoto retry;\n\t}",
"\tinit_timeout(&to);\n\tif (timeout) {\n\t\tstruct timespec\tts;\n\t\tret = -EFAULT;\n\t\tif (unlikely(copy_from_user(&ts, timeout, sizeof(ts))))\n\t\t\tgoto out;",
"\t\tset_timeout(start_jiffies, &to, &ts);\n\t}",
"\twhile (likely(i < nr)) {\n\t\tadd_wait_queue_exclusive(&ctx->wait, &wait);\n\t\tdo {\n\t\t\tset_task_state(tsk, TASK_INTERRUPTIBLE);\n\t\t\tret = aio_read_evt(ctx, &ent);\n\t\t\tif (ret)\n\t\t\t\tbreak;\n\t\t\tif (min_nr <= i)\n\t\t\t\tbreak;\n\t\t\tif (unlikely(ctx->dead)) {\n\t\t\t\tret = -EINVAL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (to.timed_out)\t/* Only check after read evt */\n\t\t\t\tbreak;\n\t\t\t/* Try to only show up in io wait if there are ops\n\t\t\t * in flight */\n\t\t\tif (ctx->reqs_active)\n\t\t\t\tio_schedule();\n\t\t\telse\n\t\t\t\tschedule();\n\t\t\tif (signal_pending(tsk)) {\n\t\t\t\tret = -EINTR;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t/*ret = aio_read_evt(ctx, &ent);*/\n\t\t} while (1) ;",
"\t\tset_task_state(tsk, TASK_RUNNING);\n\t\tremove_wait_queue(&ctx->wait, &wait);",
"\t\tif (unlikely(ret <= 0))\n\t\t\tbreak;",
"\t\tret = -EFAULT;\n\t\tif (unlikely(copy_to_user(event, &ent, sizeof(ent)))) {\n\t\t\tdprintk(\"aio: lost an event due to EFAULT.\\n\");\n\t\t\tbreak;\n\t\t}",
"\t\t/* Good, event copied to userland, update counts. */\n\t\tevent ++;\n\t\ti ++;\n\t}",
"\tif (timeout)\n\t\tclear_timeout(&to);\nout:\n\tdestroy_timer_on_stack(&to.timer);\n\treturn i ? i : ret;\n}",
"/* Take an ioctx and remove it from the list of ioctx's. Protects \n * against races with itself via ->dead.\n */\nstatic void io_destroy(struct kioctx *ioctx)\n{\n\tstruct mm_struct *mm = current->mm;\n\tint was_dead;",
"\t/* delete the entry from the list is someone else hasn't already */\n\tspin_lock(&mm->ioctx_lock);\n\twas_dead = ioctx->dead;\n\tioctx->dead = 1;\n\thlist_del_rcu(&ioctx->list);\n\tspin_unlock(&mm->ioctx_lock);",
"\tdprintk(\"aio_release(%p)\\n\", ioctx);\n\tif (likely(!was_dead))\n\t\tput_ioctx(ioctx);\t/* twice for the list */",
"\taio_cancel_all(ioctx);\n\twait_for_all_aios(ioctx);",
"\t/*\n\t * Wake up any waiters. The setting of ctx->dead must be seen\n\t * by other CPUs at this point. Right now, we rely on the\n\t * locking done by the above calls to ensure this consistency.\n\t */\n\twake_up_all(&ioctx->wait);\n\tput_ioctx(ioctx);\t/* once for the lookup */\n}",
"/* sys_io_setup:\n *\tCreate an aio_context capable of receiving at least nr_events.\n *\tctxp must not point to an aio_context that already exists, and\n *\tmust be initialized to 0 prior to the call. On successful\n *\tcreation of the aio_context, *ctxp is filled in with the resulting \n *\thandle. May fail with -EINVAL if *ctxp is not initialized,\n *\tif the specified nr_events exceeds internal limits. May fail \n *\twith -EAGAIN if the specified nr_events exceeds the user's limit \n *\tof available events. May fail with -ENOMEM if insufficient kernel\n *\tresources are available. May fail with -EFAULT if an invalid\n *\tpointer is passed for ctxp. Will fail with -ENOSYS if not\n *\timplemented.\n */\nSYSCALL_DEFINE2(io_setup, unsigned, nr_events, aio_context_t __user *, ctxp)\n{\n\tstruct kioctx *ioctx = NULL;\n\tunsigned long ctx;\n\tlong ret;",
"\tret = get_user(ctx, ctxp);\n\tif (unlikely(ret))\n\t\tgoto out;",
"\tret = -EINVAL;\n\tif (unlikely(ctx || nr_events == 0)) {\n\t\tpr_debug(\"EINVAL: io_setup: ctx %lu nr_events %u\\n\",\n\t\t ctx, nr_events);\n\t\tgoto out;\n\t}",
"\tioctx = ioctx_alloc(nr_events);\n\tret = PTR_ERR(ioctx);\n\tif (!IS_ERR(ioctx)) {\n\t\tret = put_user(ioctx->user_id, ctxp);\n\t\tif (!ret)\n\t\t\treturn 0;",
"\t\tget_ioctx(ioctx); /* io_destroy() expects us to hold a ref */\n\t\tio_destroy(ioctx);\n\t}",
"out:\n\treturn ret;\n}",
"/* sys_io_destroy:\n *\tDestroy the aio_context specified. May cancel any outstanding \n *\tAIOs and block on completion. Will fail with -ENOSYS if not\n *\timplemented. May fail with -EINVAL if the context pointed to\n *\tis invalid.\n */\nSYSCALL_DEFINE1(io_destroy, aio_context_t, ctx)\n{\n\tstruct kioctx *ioctx = lookup_ioctx(ctx);\n\tif (likely(NULL != ioctx)) {\n\t\tio_destroy(ioctx);\n\t\treturn 0;\n\t}\n\tpr_debug(\"EINVAL: io_destroy: invalid context id\\n\");\n\treturn -EINVAL;\n}",
"static void aio_advance_iovec(struct kiocb *iocb, ssize_t ret)\n{\n\tstruct iovec *iov = &iocb->ki_iovec[iocb->ki_cur_seg];",
"\tBUG_ON(ret <= 0);",
"\twhile (iocb->ki_cur_seg < iocb->ki_nr_segs && ret > 0) {\n\t\tssize_t this = min((ssize_t)iov->iov_len, ret);\n\t\tiov->iov_base += this;\n\t\tiov->iov_len -= this;\n\t\tiocb->ki_left -= this;\n\t\tret -= this;\n\t\tif (iov->iov_len == 0) {\n\t\t\tiocb->ki_cur_seg++;\n\t\t\tiov++;\n\t\t}\n\t}",
"\t/* the caller should not have done more io than what fit in\n\t * the remaining iovecs */\n\tBUG_ON(ret > 0 && iocb->ki_left == 0);\n}",
"static ssize_t aio_rw_vect_retry(struct kiocb *iocb)\n{\n\tstruct file *file = iocb->ki_filp;\n\tstruct address_space *mapping = file->f_mapping;\n\tstruct inode *inode = mapping->host;\n\tssize_t (*rw_op)(struct kiocb *, const struct iovec *,\n\t\t\t unsigned long, loff_t);\n\tssize_t ret = 0;\n\tunsigned short opcode;",
"\tif ((iocb->ki_opcode == IOCB_CMD_PREADV) ||\n\t\t(iocb->ki_opcode == IOCB_CMD_PREAD)) {\n\t\trw_op = file->f_op->aio_read;\n\t\topcode = IOCB_CMD_PREADV;\n\t} else {\n\t\trw_op = file->f_op->aio_write;\n\t\topcode = IOCB_CMD_PWRITEV;\n\t}",
"\t/* This matches the pread()/pwrite() logic */\n\tif (iocb->ki_pos < 0)\n\t\treturn -EINVAL;",
"\tdo {\n\t\tret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg],\n\t\t\t iocb->ki_nr_segs - iocb->ki_cur_seg,\n\t\t\t iocb->ki_pos);\n\t\tif (ret > 0)\n\t\t\taio_advance_iovec(iocb, ret);",
"\t/* retry all partial writes. retry partial reads as long as its a\n\t * regular file. */\n\t} while (ret > 0 && iocb->ki_left > 0 &&\n\t\t (opcode == IOCB_CMD_PWRITEV ||\n\t\t (!S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode))));",
"\t/* This means we must have transferred all that we could */\n\t/* No need to retry anymore */\n\tif ((ret == 0) || (iocb->ki_left == 0))\n\t\tret = iocb->ki_nbytes - iocb->ki_left;",
"\t/* If we managed to write some out we return that, rather than\n\t * the eventual error. */\n\tif (opcode == IOCB_CMD_PWRITEV\n\t && ret < 0 && ret != -EIOCBQUEUED && ret != -EIOCBRETRY\n\t && iocb->ki_nbytes - iocb->ki_left)\n\t\tret = iocb->ki_nbytes - iocb->ki_left;",
"\treturn ret;\n}",
"static ssize_t aio_fdsync(struct kiocb *iocb)\n{\n\tstruct file *file = iocb->ki_filp;\n\tssize_t ret = -EINVAL;",
"\tif (file->f_op->aio_fsync)\n\t\tret = file->f_op->aio_fsync(iocb, 1);\n\treturn ret;\n}",
"static ssize_t aio_fsync(struct kiocb *iocb)\n{\n\tstruct file *file = iocb->ki_filp;\n\tssize_t ret = -EINVAL;",
"\tif (file->f_op->aio_fsync)\n\t\tret = file->f_op->aio_fsync(iocb, 0);\n\treturn ret;\n}",
"static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)\n{\n\tssize_t ret;",
"#ifdef CONFIG_COMPAT\n\tif (compat)\n\t\tret = compat_rw_copy_check_uvector(type,\n\t\t\t\t(struct compat_iovec __user *)kiocb->ki_buf,\n\t\t\t\tkiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,\n\t\t\t\t&kiocb->ki_iovec, 1);\n\telse\n#endif\n\t\tret = rw_copy_check_uvector(type,\n\t\t\t\t(struct iovec __user *)kiocb->ki_buf,\n\t\t\t\tkiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,\n\t\t\t\t&kiocb->ki_iovec, 1);\n\tif (ret < 0)\n\t\tgoto out;",
"\tkiocb->ki_nr_segs = kiocb->ki_nbytes;\n\tkiocb->ki_cur_seg = 0;\n\t/* ki_nbytes/left now reflect bytes instead of segs */\n\tkiocb->ki_nbytes = ret;\n\tkiocb->ki_left = ret;",
"\tret = 0;\nout:\n\treturn ret;\n}",
"static ssize_t aio_setup_single_vector(struct kiocb *kiocb)\n{\n\tkiocb->ki_iovec = &kiocb->ki_inline_vec;\n\tkiocb->ki_iovec->iov_base = kiocb->ki_buf;\n\tkiocb->ki_iovec->iov_len = kiocb->ki_left;\n\tkiocb->ki_nr_segs = 1;\n\tkiocb->ki_cur_seg = 0;\n\treturn 0;\n}",
"/*\n * aio_setup_iocb:\n *\tPerforms the initial checks and aio retry method\n *\tsetup for the kiocb at the time of io submission.\n */\nstatic ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat)\n{\n\tstruct file *file = kiocb->ki_filp;\n\tssize_t ret = 0;",
"\tswitch (kiocb->ki_opcode) {\n\tcase IOCB_CMD_PREAD:\n\t\tret = -EBADF;\n\t\tif (unlikely(!(file->f_mode & FMODE_READ)))\n\t\t\tbreak;\n\t\tret = -EFAULT;\n\t\tif (unlikely(!access_ok(VERIFY_WRITE, kiocb->ki_buf,\n\t\t\tkiocb->ki_left)))\n\t\t\tbreak;\n\t\tret = security_file_permission(file, MAY_READ);\n\t\tif (unlikely(ret))\n\t\t\tbreak;\n\t\tret = aio_setup_single_vector(kiocb);\n\t\tif (ret)\n\t\t\tbreak;\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_read)\n\t\t\tkiocb->ki_retry = aio_rw_vect_retry;\n\t\tbreak;\n\tcase IOCB_CMD_PWRITE:\n\t\tret = -EBADF;\n\t\tif (unlikely(!(file->f_mode & FMODE_WRITE)))\n\t\t\tbreak;\n\t\tret = -EFAULT;\n\t\tif (unlikely(!access_ok(VERIFY_READ, kiocb->ki_buf,\n\t\t\tkiocb->ki_left)))\n\t\t\tbreak;\n\t\tret = security_file_permission(file, MAY_WRITE);\n\t\tif (unlikely(ret))\n\t\t\tbreak;\n\t\tret = aio_setup_single_vector(kiocb);\n\t\tif (ret)\n\t\t\tbreak;\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_write)\n\t\t\tkiocb->ki_retry = aio_rw_vect_retry;\n\t\tbreak;\n\tcase IOCB_CMD_PREADV:\n\t\tret = -EBADF;\n\t\tif (unlikely(!(file->f_mode & FMODE_READ)))\n\t\t\tbreak;\n\t\tret = security_file_permission(file, MAY_READ);\n\t\tif (unlikely(ret))\n\t\t\tbreak;\n\t\tret = aio_setup_vectored_rw(READ, kiocb, compat);\n\t\tif (ret)\n\t\t\tbreak;\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_read)\n\t\t\tkiocb->ki_retry = aio_rw_vect_retry;\n\t\tbreak;\n\tcase IOCB_CMD_PWRITEV:\n\t\tret = -EBADF;\n\t\tif (unlikely(!(file->f_mode & FMODE_WRITE)))\n\t\t\tbreak;\n\t\tret = security_file_permission(file, MAY_WRITE);\n\t\tif (unlikely(ret))\n\t\t\tbreak;\n\t\tret = aio_setup_vectored_rw(WRITE, kiocb, compat);\n\t\tif (ret)\n\t\t\tbreak;\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_write)\n\t\t\tkiocb->ki_retry = aio_rw_vect_retry;\n\t\tbreak;\n\tcase IOCB_CMD_FDSYNC:\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_fsync)\n\t\t\tkiocb->ki_retry = aio_fdsync;\n\t\tbreak;\n\tcase IOCB_CMD_FSYNC:\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_fsync)\n\t\t\tkiocb->ki_retry = aio_fsync;\n\t\tbreak;\n\tdefault:\n\t\tdprintk(\"EINVAL: io_submit: no operation provided\\n\");\n\t\tret = -EINVAL;\n\t}",
"\tif (!kiocb->ki_retry)\n\t\treturn ret;",
"\treturn 0;\n}",
"static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,\n\t\t\t struct iocb *iocb, struct kiocb_batch *batch,\n\t\t\t bool compat)\n{\n\tstruct kiocb *req;\n\tstruct file *file;\n\tssize_t ret;",
"\t/* enforce forwards compatibility on users */\n\tif (unlikely(iocb->aio_reserved1 || iocb->aio_reserved2)) {\n\t\tpr_debug(\"EINVAL: io_submit: reserve field set\\n\");\n\t\treturn -EINVAL;\n\t}",
"\t/* prevent overflows */\n\tif (unlikely(\n\t (iocb->aio_buf != (unsigned long)iocb->aio_buf) ||\n\t (iocb->aio_nbytes != (size_t)iocb->aio_nbytes) ||\n\t ((ssize_t)iocb->aio_nbytes < 0)\n\t )) {\n\t\tpr_debug(\"EINVAL: io_submit: overflow check\\n\");\n\t\treturn -EINVAL;\n\t}",
"\tfile = fget(iocb->aio_fildes);\n\tif (unlikely(!file))\n\t\treturn -EBADF;",
"\treq = aio_get_req(ctx, batch); /* returns with 2 references to req */\n\tif (unlikely(!req)) {\n\t\tfput(file);\n\t\treturn -EAGAIN;\n\t}\n\treq->ki_filp = file;\n\tif (iocb->aio_flags & IOCB_FLAG_RESFD) {\n\t\t/*\n\t\t * If the IOCB_FLAG_RESFD flag of aio_flags is set, get an\n\t\t * instance of the file* now. The file descriptor must be\n\t\t * an eventfd() fd, and will be signaled for each completed\n\t\t * event using the eventfd_signal() function.\n\t\t */\n\t\treq->ki_eventfd = eventfd_ctx_fdget((int) iocb->aio_resfd);\n\t\tif (IS_ERR(req->ki_eventfd)) {\n\t\t\tret = PTR_ERR(req->ki_eventfd);\n\t\t\treq->ki_eventfd = NULL;\n\t\t\tgoto out_put_req;\n\t\t}\n\t}",
"\tret = put_user(req->ki_key, &user_iocb->aio_key);\n\tif (unlikely(ret)) {\n\t\tdprintk(\"EFAULT: aio_key\\n\");\n\t\tgoto out_put_req;\n\t}",
"\treq->ki_obj.user = user_iocb;\n\treq->ki_user_data = iocb->aio_data;\n\treq->ki_pos = iocb->aio_offset;",
"\treq->ki_buf = (char __user *)(unsigned long)iocb->aio_buf;\n\treq->ki_left = req->ki_nbytes = iocb->aio_nbytes;\n\treq->ki_opcode = iocb->aio_lio_opcode;",
"\tret = aio_setup_iocb(req, compat);",
"\tif (ret)\n\t\tgoto out_put_req;",
"\tspin_lock_irq(&ctx->ctx_lock);\n\t/*\n\t * We could have raced with io_destroy() and are currently holding a\n\t * reference to ctx which should be destroyed. We cannot submit IO\n\t * since ctx gets freed as soon as io_submit() puts its reference. The\n\t * check here is reliable: io_destroy() sets ctx->dead before waiting\n\t * for outstanding IO and the barrier between these two is realized by\n\t * unlock of mm->ioctx_lock and lock of ctx->ctx_lock. Analogously we\n\t * increment ctx->reqs_active before checking for ctx->dead and the\n\t * barrier is realized by unlock and lock of ctx->ctx_lock. Thus if we\n\t * don't see ctx->dead set here, io_destroy() waits for our IO to\n\t * finish.\n\t */\n\tif (ctx->dead) {\n\t\tspin_unlock_irq(&ctx->ctx_lock);\n\t\tret = -EINVAL;\n\t\tgoto out_put_req;\n\t}\n\taio_run_iocb(req);\n\tif (!list_empty(&ctx->run_list)) {\n\t\t/* drain the run list */\n\t\twhile (__aio_run_iocbs(ctx))\n\t\t\t;\n\t}\n\tspin_unlock_irq(&ctx->ctx_lock);",
"\taio_put_req(req);\t/* drop extra ref to req */\n\treturn 0;",
"out_put_req:\n\taio_put_req(req);\t/* drop extra ref to req */\n\taio_put_req(req);\t/* drop i/o ref to req */\n\treturn ret;\n}",
"long do_io_submit(aio_context_t ctx_id, long nr,\n\t\t struct iocb __user *__user *iocbpp, bool compat)\n{\n\tstruct kioctx *ctx;\n\tlong ret = 0;\n\tint i = 0;\n\tstruct blk_plug plug;\n\tstruct kiocb_batch batch;",
"\tif (unlikely(nr < 0))\n\t\treturn -EINVAL;",
"\tif (unlikely(nr > LONG_MAX/sizeof(*iocbpp)))\n\t\tnr = LONG_MAX/sizeof(*iocbpp);",
"\tif (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(*iocbpp)))))\n\t\treturn -EFAULT;",
"\tctx = lookup_ioctx(ctx_id);\n\tif (unlikely(!ctx)) {\n\t\tpr_debug(\"EINVAL: io_submit: invalid context id\\n\");\n\t\treturn -EINVAL;\n\t}",
"\tkiocb_batch_init(&batch, nr);",
"\tblk_start_plug(&plug);",
"\t/*\n\t * AKPM: should this return a partial result if some of the IOs were\n\t * successfully submitted?\n\t */\n\tfor (i=0; i<nr; i++) {\n\t\tstruct iocb __user *user_iocb;\n\t\tstruct iocb tmp;",
"\t\tif (unlikely(__get_user(user_iocb, iocbpp + i))) {\n\t\t\tret = -EFAULT;\n\t\t\tbreak;\n\t\t}",
"\t\tif (unlikely(copy_from_user(&tmp, user_iocb, sizeof(tmp)))) {\n\t\t\tret = -EFAULT;\n\t\t\tbreak;\n\t\t}",
"\t\tret = io_submit_one(ctx, user_iocb, &tmp, &batch, compat);\n\t\tif (ret)\n\t\t\tbreak;\n\t}\n\tblk_finish_plug(&plug);\n",
"\tkiocb_batch_free(&batch);",
"\tput_ioctx(ctx);\n\treturn i ? i : ret;\n}",
"/* sys_io_submit:\n *\tQueue the nr iocbs pointed to by iocbpp for processing. Returns\n *\tthe number of iocbs queued. May return -EINVAL if the aio_context\n *\tspecified by ctx_id is invalid, if nr is < 0, if the iocb at\n *\t*iocbpp[0] is not properly initialized, if the operation specified\n *\tis invalid for the file descriptor in the iocb. May fail with\n *\t-EFAULT if any of the data structures point to invalid data. May\n *\tfail with -EBADF if the file descriptor specified in the first\n *\tiocb is invalid. May fail with -EAGAIN if insufficient resources\n *\tare available to queue any iocbs. Will return 0 if nr is 0. Will\n *\tfail with -ENOSYS if not implemented.\n */\nSYSCALL_DEFINE3(io_submit, aio_context_t, ctx_id, long, nr,\n\t\tstruct iocb __user * __user *, iocbpp)\n{\n\treturn do_io_submit(ctx_id, nr, iocbpp, 0);\n}",
"/* lookup_kiocb\n *\tFinds a given iocb for cancellation.\n */\nstatic struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb,\n\t\t\t\t u32 key)\n{\n\tstruct list_head *pos;",
"\tassert_spin_locked(&ctx->ctx_lock);",
"\t/* TODO: use a hash or array, this sucks. */\n\tlist_for_each(pos, &ctx->active_reqs) {\n\t\tstruct kiocb *kiocb = list_kiocb(pos);\n\t\tif (kiocb->ki_obj.user == iocb && kiocb->ki_key == key)\n\t\t\treturn kiocb;\n\t}\n\treturn NULL;\n}",
"/* sys_io_cancel:\n *\tAttempts to cancel an iocb previously passed to io_submit. If\n *\tthe operation is successfully cancelled, the resulting event is\n *\tcopied into the memory pointed to by result without being placed\n *\tinto the completion queue and 0 is returned. May fail with\n *\t-EFAULT if any of the data structures pointed to are invalid.\n *\tMay fail with -EINVAL if aio_context specified by ctx_id is\n *\tinvalid. May fail with -EAGAIN if the iocb specified was not\n *\tcancelled. Will fail with -ENOSYS if not implemented.\n */\nSYSCALL_DEFINE3(io_cancel, aio_context_t, ctx_id, struct iocb __user *, iocb,\n\t\tstruct io_event __user *, result)\n{\n\tint (*cancel)(struct kiocb *iocb, struct io_event *res);\n\tstruct kioctx *ctx;\n\tstruct kiocb *kiocb;\n\tu32 key;\n\tint ret;",
"\tret = get_user(key, &iocb->aio_key);\n\tif (unlikely(ret))\n\t\treturn -EFAULT;",
"\tctx = lookup_ioctx(ctx_id);\n\tif (unlikely(!ctx))\n\t\treturn -EINVAL;",
"\tspin_lock_irq(&ctx->ctx_lock);\n\tret = -EAGAIN;\n\tkiocb = lookup_kiocb(ctx, iocb, key);\n\tif (kiocb && kiocb->ki_cancel) {\n\t\tcancel = kiocb->ki_cancel;\n\t\tkiocb->ki_users ++;\n\t\tkiocbSetCancelled(kiocb);\n\t} else\n\t\tcancel = NULL;\n\tspin_unlock_irq(&ctx->ctx_lock);",
"\tif (NULL != cancel) {\n\t\tstruct io_event tmp;\n\t\tpr_debug(\"calling cancel\\n\");\n\t\tmemset(&tmp, 0, sizeof(tmp));\n\t\ttmp.obj = (u64)(unsigned long)kiocb->ki_obj.user;\n\t\ttmp.data = kiocb->ki_user_data;\n\t\tret = cancel(kiocb, &tmp);\n\t\tif (!ret) {\n\t\t\t/* Cancellation succeeded -- copy the result\n\t\t\t * into the user's buffer.\n\t\t\t */\n\t\t\tif (copy_to_user(result, &tmp, sizeof(tmp)))\n\t\t\t\tret = -EFAULT;\n\t\t}\n\t} else\n\t\tret = -EINVAL;",
"\tput_ioctx(ctx);",
"\treturn ret;\n}",
"/* io_getevents:\n *\tAttempts to read at least min_nr events and up to nr events from\n *\tthe completion queue for the aio_context specified by ctx_id. If\n *\tit succeeds, the number of read events is returned. May fail with\n *\t-EINVAL if ctx_id is invalid, if min_nr is out of range, if nr is\n *\tout of range, if timeout is out of range. May fail with -EFAULT\n *\tif any of the memory specified is invalid. May return 0 or\n *\t< min_nr if the timeout specified by timeout has elapsed\n *\tbefore sufficient events are available, where timeout == NULL\n *\tspecifies an infinite timeout. Note that the timeout pointed to by\n *\ttimeout is relative and will be updated if not NULL and the\n *\toperation blocks. Will fail with -ENOSYS if not implemented.\n */\nSYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id,\n\t\tlong, min_nr,\n\t\tlong, nr,\n\t\tstruct io_event __user *, events,\n\t\tstruct timespec __user *, timeout)\n{\n\tstruct kioctx *ioctx = lookup_ioctx(ctx_id);\n\tlong ret = -EINVAL;",
"\tif (likely(ioctx)) {\n\t\tif (likely(min_nr <= nr && min_nr >= 0))\n\t\t\tret = read_events(ioctx, min_nr, nr, events, timeout);\n\t\tput_ioctx(ioctx);\n\t}",
"\tasmlinkage_protect(5, ret, ctx_id, min_nr, nr, events, timeout);\n\treturn ret;\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1746], "buggy_code_start_loc": [479], "filenames": ["fs/aio.c"], "fixing_code_end_loc": [1753], "fixing_code_start_loc": [479], "message": "The kiocb_batch_free function in fs/aio.c in the Linux kernel before 3.2.2 allows local users to cause a denial of service (OOPS) via vectors that trigger incorrect iocb management.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "D5AEDA47-7122-4C1A-A764-32500A089909", "versionEndExcluding": "3.2.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "The kiocb_batch_free function in fs/aio.c in the Linux kernel before 3.2.2 allows local users to cause a denial of service (OOPS) via vectors that trigger incorrect iocb management."}, {"lang": "es", "value": "La funci\u00f3n kiocb_batch_free en fs/aio.c en el kernel de Linux antes de v3.2.2 permite a usuarios locales provocar una denegaci\u00f3n de servicio a trav\u00e9s de vectores que provocan una gesti\u00f3n incorrecta de IOCB."}], "evaluatorComment": null, "id": "CVE-2012-0058", "lastModified": "2020-07-29T16:56:55.787", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 4.9, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:L/AC:L/Au:N/C:N/I:N/A:C", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 6.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2012-05-17T11:00:36.227", "references": [{"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://marc.info/?l=bugtraq&m=139447903326211&w=2"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Patch", "Vendor Advisory"], "url": "http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.2.2"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2012/01/18/7"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securitytracker.com/id?1027085"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Third Party Advisory"], "url": "https://bugzilla.redhat.com/show_bug.cgi?id=782696"}, {"source": "secalert@redhat.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/802f43594d6e4d2ac61086d239153c17873a0428"}], "sourceIdentifier": "secalert@redhat.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-400"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/802f43594d6e4d2ac61086d239153c17873a0428"}, "type": "CWE-400"}
| 367
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n *\tAn async IO implementation for Linux\n *\tWritten by Benjamin LaHaise <bcrl@kvack.org>\n *\n *\tImplements an efficient asynchronous io interface.\n *\n *\tCopyright 2000, 2001, 2002 Red Hat, Inc. All Rights Reserved.\n *\n *\tSee ../COPYING for licensing terms.\n */\n#include <linux/kernel.h>\n#include <linux/init.h>\n#include <linux/errno.h>\n#include <linux/time.h>\n#include <linux/aio_abi.h>\n#include <linux/module.h>\n#include <linux/syscalls.h>\n#include <linux/backing-dev.h>\n#include <linux/uio.h>",
"#define DEBUG 0",
"#include <linux/sched.h>\n#include <linux/fs.h>\n#include <linux/file.h>\n#include <linux/mm.h>\n#include <linux/mman.h>\n#include <linux/mmu_context.h>\n#include <linux/slab.h>\n#include <linux/timer.h>\n#include <linux/aio.h>\n#include <linux/highmem.h>\n#include <linux/workqueue.h>\n#include <linux/security.h>\n#include <linux/eventfd.h>\n#include <linux/blkdev.h>\n#include <linux/compat.h>",
"#include <asm/kmap_types.h>\n#include <asm/uaccess.h>",
"#if DEBUG > 1\n#define dprintk\t\tprintk\n#else\n#define dprintk(x...)\tdo { ; } while (0)\n#endif",
"/*------ sysctl variables----*/\nstatic DEFINE_SPINLOCK(aio_nr_lock);\nunsigned long aio_nr;\t\t/* current system wide number of aio requests */\nunsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */\n/*----end sysctl variables---*/",
"static struct kmem_cache\t*kiocb_cachep;\nstatic struct kmem_cache\t*kioctx_cachep;",
"static struct workqueue_struct *aio_wq;",
"/* Used for rare fput completion. */\nstatic void aio_fput_routine(struct work_struct *);\nstatic DECLARE_WORK(fput_work, aio_fput_routine);",
"static DEFINE_SPINLOCK(fput_lock);\nstatic LIST_HEAD(fput_head);",
"static void aio_kick_handler(struct work_struct *);\nstatic void aio_queue_work(struct kioctx *);",
"/* aio_setup\n *\tCreates the slab caches used by the aio routines, panic on\n *\tfailure as this is done early during the boot sequence.\n */\nstatic int __init aio_setup(void)\n{\n\tkiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC);\n\tkioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC);",
"\taio_wq = alloc_workqueue(\"aio\", 0, 1);\t/* used to limit concurrency */\n\tBUG_ON(!aio_wq);",
"\tpr_debug(\"aio_setup: sizeof(struct page) = %d\\n\", (int)sizeof(struct page));",
"\treturn 0;\n}\n__initcall(aio_setup);",
"static void aio_free_ring(struct kioctx *ctx)\n{\n\tstruct aio_ring_info *info = &ctx->ring_info;\n\tlong i;",
"\tfor (i=0; i<info->nr_pages; i++)\n\t\tput_page(info->ring_pages[i]);",
"\tif (info->mmap_size) {\n\t\tdown_write(&ctx->mm->mmap_sem);\n\t\tdo_munmap(ctx->mm, info->mmap_base, info->mmap_size);\n\t\tup_write(&ctx->mm->mmap_sem);\n\t}",
"\tif (info->ring_pages && info->ring_pages != info->internal_pages)\n\t\tkfree(info->ring_pages);\n\tinfo->ring_pages = NULL;\n\tinfo->nr = 0;\n}",
"static int aio_setup_ring(struct kioctx *ctx)\n{\n\tstruct aio_ring *ring;\n\tstruct aio_ring_info *info = &ctx->ring_info;\n\tunsigned nr_events = ctx->max_reqs;\n\tunsigned long size;\n\tint nr_pages;",
"\t/* Compensate for the ring buffer's head/tail overlap entry */\n\tnr_events += 2;\t/* 1 is required, 2 for good luck */",
"\tsize = sizeof(struct aio_ring);\n\tsize += sizeof(struct io_event) * nr_events;\n\tnr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;",
"\tif (nr_pages < 0)\n\t\treturn -EINVAL;",
"\tnr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);",
"\tinfo->nr = 0;\n\tinfo->ring_pages = info->internal_pages;\n\tif (nr_pages > AIO_RING_PAGES) {\n\t\tinfo->ring_pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);\n\t\tif (!info->ring_pages)\n\t\t\treturn -ENOMEM;\n\t}",
"\tinfo->mmap_size = nr_pages * PAGE_SIZE;\n\tdprintk(\"attempting mmap of %lu bytes\\n\", info->mmap_size);\n\tdown_write(&ctx->mm->mmap_sem);\n\tinfo->mmap_base = do_mmap(NULL, 0, info->mmap_size, \n\t\t\t\t PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE,\n\t\t\t\t 0);\n\tif (IS_ERR((void *)info->mmap_base)) {\n\t\tup_write(&ctx->mm->mmap_sem);\n\t\tinfo->mmap_size = 0;\n\t\taio_free_ring(ctx);\n\t\treturn -EAGAIN;\n\t}",
"\tdprintk(\"mmap address: 0x%08lx\\n\", info->mmap_base);\n\tinfo->nr_pages = get_user_pages(current, ctx->mm,\n\t\t\t\t\tinfo->mmap_base, nr_pages, \n\t\t\t\t\t1, 0, info->ring_pages, NULL);\n\tup_write(&ctx->mm->mmap_sem);",
"\tif (unlikely(info->nr_pages != nr_pages)) {\n\t\taio_free_ring(ctx);\n\t\treturn -EAGAIN;\n\t}",
"\tctx->user_id = info->mmap_base;",
"\tinfo->nr = nr_events;\t\t/* trusted copy */",
"\tring = kmap_atomic(info->ring_pages[0], KM_USER0);\n\tring->nr = nr_events;\t/* user copy */\n\tring->id = ctx->user_id;\n\tring->head = ring->tail = 0;\n\tring->magic = AIO_RING_MAGIC;\n\tring->compat_features = AIO_RING_COMPAT_FEATURES;\n\tring->incompat_features = AIO_RING_INCOMPAT_FEATURES;\n\tring->header_length = sizeof(struct aio_ring);\n\tkunmap_atomic(ring, KM_USER0);",
"\treturn 0;\n}",
"\n/* aio_ring_event: returns a pointer to the event at the given index from\n * kmap_atomic(, km). Release the pointer with put_aio_ring_event();\n */\n#define AIO_EVENTS_PER_PAGE\t(PAGE_SIZE / sizeof(struct io_event))\n#define AIO_EVENTS_FIRST_PAGE\t((PAGE_SIZE - sizeof(struct aio_ring)) / sizeof(struct io_event))\n#define AIO_EVENTS_OFFSET\t(AIO_EVENTS_PER_PAGE - AIO_EVENTS_FIRST_PAGE)",
"#define aio_ring_event(info, nr, km) ({\t\t\t\t\t\\\n\tunsigned pos = (nr) + AIO_EVENTS_OFFSET;\t\t\t\\\n\tstruct io_event *__event;\t\t\t\t\t\\\n\t__event = kmap_atomic(\t\t\t\t\t\t\\\n\t\t\t(info)->ring_pages[pos / AIO_EVENTS_PER_PAGE], km); \\\n\t__event += pos % AIO_EVENTS_PER_PAGE;\t\t\t\t\\\n\t__event;\t\t\t\t\t\t\t\\\n})",
"#define put_aio_ring_event(event, km) do {\t\\\n\tstruct io_event *__event = (event);\t\\\n\t(void)__event;\t\t\t\t\\\n\tkunmap_atomic((void *)((unsigned long)__event & PAGE_MASK), km); \\\n} while(0)",
"static void ctx_rcu_free(struct rcu_head *head)\n{\n\tstruct kioctx *ctx = container_of(head, struct kioctx, rcu_head);\n\tunsigned nr_events = ctx->max_reqs;",
"\tkmem_cache_free(kioctx_cachep, ctx);",
"\tif (nr_events) {\n\t\tspin_lock(&aio_nr_lock);\n\t\tBUG_ON(aio_nr - nr_events > aio_nr);\n\t\taio_nr -= nr_events;\n\t\tspin_unlock(&aio_nr_lock);\n\t}\n}",
"/* __put_ioctx\n *\tCalled when the last user of an aio context has gone away,\n *\tand the struct needs to be freed.\n */\nstatic void __put_ioctx(struct kioctx *ctx)\n{\n\tBUG_ON(ctx->reqs_active);",
"\tcancel_delayed_work(&ctx->wq);\n\tcancel_work_sync(&ctx->wq.work);\n\taio_free_ring(ctx);\n\tmmdrop(ctx->mm);\n\tctx->mm = NULL;\n\tpr_debug(\"__put_ioctx: freeing %p\\n\", ctx);\n\tcall_rcu(&ctx->rcu_head, ctx_rcu_free);\n}",
"static inline void get_ioctx(struct kioctx *kioctx)\n{\n\tBUG_ON(atomic_read(&kioctx->users) <= 0);\n\tatomic_inc(&kioctx->users);\n}",
"static inline int try_get_ioctx(struct kioctx *kioctx)\n{\n\treturn atomic_inc_not_zero(&kioctx->users);\n}",
"static inline void put_ioctx(struct kioctx *kioctx)\n{\n\tBUG_ON(atomic_read(&kioctx->users) <= 0);\n\tif (unlikely(atomic_dec_and_test(&kioctx->users)))\n\t\t__put_ioctx(kioctx);\n}",
"/* ioctx_alloc\n *\tAllocates and initializes an ioctx. Returns an ERR_PTR if it failed.\n */\nstatic struct kioctx *ioctx_alloc(unsigned nr_events)\n{\n\tstruct mm_struct *mm;\n\tstruct kioctx *ctx;\n\tint did_sync = 0;",
"\t/* Prevent overflows */\n\tif ((nr_events > (0x10000000U / sizeof(struct io_event))) ||\n\t (nr_events > (0x10000000U / sizeof(struct kiocb)))) {\n\t\tpr_debug(\"ENOMEM: nr_events too high\\n\");\n\t\treturn ERR_PTR(-EINVAL);\n\t}",
"\tif ((unsigned long)nr_events > aio_max_nr)\n\t\treturn ERR_PTR(-EAGAIN);",
"\tctx = kmem_cache_zalloc(kioctx_cachep, GFP_KERNEL);\n\tif (!ctx)\n\t\treturn ERR_PTR(-ENOMEM);",
"\tctx->max_reqs = nr_events;\n\tmm = ctx->mm = current->mm;\n\tatomic_inc(&mm->mm_count);",
"\tatomic_set(&ctx->users, 1);\n\tspin_lock_init(&ctx->ctx_lock);\n\tspin_lock_init(&ctx->ring_info.ring_lock);\n\tinit_waitqueue_head(&ctx->wait);",
"\tINIT_LIST_HEAD(&ctx->active_reqs);\n\tINIT_LIST_HEAD(&ctx->run_list);\n\tINIT_DELAYED_WORK(&ctx->wq, aio_kick_handler);",
"\tif (aio_setup_ring(ctx) < 0)\n\t\tgoto out_freectx;",
"\t/* limit the number of system wide aios */\n\tdo {\n\t\tspin_lock_bh(&aio_nr_lock);\n\t\tif (aio_nr + nr_events > aio_max_nr ||\n\t\t aio_nr + nr_events < aio_nr)\n\t\t\tctx->max_reqs = 0;\n\t\telse\n\t\t\taio_nr += ctx->max_reqs;\n\t\tspin_unlock_bh(&aio_nr_lock);\n\t\tif (ctx->max_reqs || did_sync)\n\t\t\tbreak;",
"\t\t/* wait for rcu callbacks to have completed before giving up */\n\t\tsynchronize_rcu();\n\t\tdid_sync = 1;\n\t\tctx->max_reqs = nr_events;\n\t} while (1);",
"\tif (ctx->max_reqs == 0)\n\t\tgoto out_cleanup;",
"\t/* now link into global list. */\n\tspin_lock(&mm->ioctx_lock);\n\thlist_add_head_rcu(&ctx->list, &mm->ioctx_list);\n\tspin_unlock(&mm->ioctx_lock);",
"\tdprintk(\"aio: allocated ioctx %p[%ld]: mm=%p mask=0x%x\\n\",\n\t\tctx, ctx->user_id, current->mm, ctx->ring_info.nr);\n\treturn ctx;",
"out_cleanup:\n\t__put_ioctx(ctx);\n\treturn ERR_PTR(-EAGAIN);",
"out_freectx:\n\tmmdrop(mm);\n\tkmem_cache_free(kioctx_cachep, ctx);\n\tctx = ERR_PTR(-ENOMEM);",
"\tdprintk(\"aio: error allocating ioctx %p\\n\", ctx);\n\treturn ctx;\n}",
"/* aio_cancel_all\n *\tCancels all outstanding aio requests on an aio context. Used \n *\twhen the processes owning a context have all exited to encourage \n *\tthe rapid destruction of the kioctx.\n */\nstatic void aio_cancel_all(struct kioctx *ctx)\n{\n\tint (*cancel)(struct kiocb *, struct io_event *);\n\tstruct io_event res;\n\tspin_lock_irq(&ctx->ctx_lock);\n\tctx->dead = 1;\n\twhile (!list_empty(&ctx->active_reqs)) {\n\t\tstruct list_head *pos = ctx->active_reqs.next;\n\t\tstruct kiocb *iocb = list_kiocb(pos);\n\t\tlist_del_init(&iocb->ki_list);\n\t\tcancel = iocb->ki_cancel;\n\t\tkiocbSetCancelled(iocb);\n\t\tif (cancel) {\n\t\t\tiocb->ki_users++;\n\t\t\tspin_unlock_irq(&ctx->ctx_lock);\n\t\t\tcancel(iocb, &res);\n\t\t\tspin_lock_irq(&ctx->ctx_lock);\n\t\t}\n\t}\n\tspin_unlock_irq(&ctx->ctx_lock);\n}",
"static void wait_for_all_aios(struct kioctx *ctx)\n{\n\tstruct task_struct *tsk = current;\n\tDECLARE_WAITQUEUE(wait, tsk);",
"\tspin_lock_irq(&ctx->ctx_lock);\n\tif (!ctx->reqs_active)\n\t\tgoto out;",
"\tadd_wait_queue(&ctx->wait, &wait);\n\tset_task_state(tsk, TASK_UNINTERRUPTIBLE);\n\twhile (ctx->reqs_active) {\n\t\tspin_unlock_irq(&ctx->ctx_lock);\n\t\tio_schedule();\n\t\tset_task_state(tsk, TASK_UNINTERRUPTIBLE);\n\t\tspin_lock_irq(&ctx->ctx_lock);\n\t}\n\t__set_task_state(tsk, TASK_RUNNING);\n\tremove_wait_queue(&ctx->wait, &wait);",
"out:\n\tspin_unlock_irq(&ctx->ctx_lock);\n}",
"/* wait_on_sync_kiocb:\n *\tWaits on the given sync kiocb to complete.\n */\nssize_t wait_on_sync_kiocb(struct kiocb *iocb)\n{\n\twhile (iocb->ki_users) {\n\t\tset_current_state(TASK_UNINTERRUPTIBLE);\n\t\tif (!iocb->ki_users)\n\t\t\tbreak;\n\t\tio_schedule();\n\t}\n\t__set_current_state(TASK_RUNNING);\n\treturn iocb->ki_user_data;\n}\nEXPORT_SYMBOL(wait_on_sync_kiocb);",
"/* exit_aio: called when the last user of mm goes away. At this point, \n * there is no way for any new requests to be submited or any of the \n * io_* syscalls to be called on the context. However, there may be \n * outstanding requests which hold references to the context; as they \n * go away, they will call put_ioctx and release any pinned memory\n * associated with the request (held via struct page * references).\n */\nvoid exit_aio(struct mm_struct *mm)\n{\n\tstruct kioctx *ctx;",
"\twhile (!hlist_empty(&mm->ioctx_list)) {\n\t\tctx = hlist_entry(mm->ioctx_list.first, struct kioctx, list);\n\t\thlist_del_rcu(&ctx->list);",
"\t\taio_cancel_all(ctx);",
"\t\twait_for_all_aios(ctx);\n\t\t/*\n\t\t * Ensure we don't leave the ctx on the aio_wq\n\t\t */\n\t\tcancel_work_sync(&ctx->wq.work);",
"\t\tif (1 != atomic_read(&ctx->users))\n\t\t\tprintk(KERN_DEBUG\n\t\t\t\t\"exit_aio:ioctx still alive: %d %d %d\\n\",\n\t\t\t\tatomic_read(&ctx->users), ctx->dead,\n\t\t\t\tctx->reqs_active);\n\t\tput_ioctx(ctx);\n\t}\n}",
"/* aio_get_req\n *\tAllocate a slot for an aio request. Increments the users count\n * of the kioctx so that the kioctx stays around until all requests are\n * complete. Returns NULL if no requests are free.\n *\n * Returns with kiocb->users set to 2. The io submit code path holds\n * an extra reference while submitting the i/o.\n * This prevents races between the aio code path referencing the\n * req (after submitting it) and aio_complete() freeing the req.\n */\nstatic struct kiocb *__aio_get_req(struct kioctx *ctx)\n{\n\tstruct kiocb *req = NULL;",
"\treq = kmem_cache_alloc(kiocb_cachep, GFP_KERNEL);\n\tif (unlikely(!req))\n\t\treturn NULL;",
"\treq->ki_flags = 0;\n\treq->ki_users = 2;\n\treq->ki_key = 0;\n\treq->ki_ctx = ctx;\n\treq->ki_cancel = NULL;\n\treq->ki_retry = NULL;\n\treq->ki_dtor = NULL;\n\treq->private = NULL;\n\treq->ki_iovec = NULL;\n\tINIT_LIST_HEAD(&req->ki_run_list);\n\treq->ki_eventfd = NULL;",
"\treturn req;\n}",
"/*\n * struct kiocb's are allocated in batches to reduce the number of\n * times the ctx lock is acquired and released.\n */\n#define KIOCB_BATCH_SIZE\t32L\nstruct kiocb_batch {\n\tstruct list_head head;\n\tlong count; /* number of requests left to allocate */\n};",
"static void kiocb_batch_init(struct kiocb_batch *batch, long total)\n{\n\tINIT_LIST_HEAD(&batch->head);\n\tbatch->count = total;\n}\n",
"static void kiocb_batch_free(struct kioctx *ctx, struct kiocb_batch *batch)",
"{\n\tstruct kiocb *req, *n;\n",
"\tif (list_empty(&batch->head))\n\t\treturn;",
"\tspin_lock_irq(&ctx->ctx_lock);",
"\tlist_for_each_entry_safe(req, n, &batch->head, ki_batch) {\n\t\tlist_del(&req->ki_batch);",
"\t\tlist_del(&req->ki_list);",
"\t\tkmem_cache_free(kiocb_cachep, req);",
"\t\tctx->reqs_active--;\n\t}\n\tspin_unlock_irq(&ctx->ctx_lock);",
"}",
"/*\n * Allocate a batch of kiocbs. This avoids taking and dropping the\n * context lock a lot during setup.\n */\nstatic int kiocb_batch_refill(struct kioctx *ctx, struct kiocb_batch *batch)\n{\n\tunsigned short allocated, to_alloc;\n\tlong avail;\n\tbool called_fput = false;\n\tstruct kiocb *req, *n;\n\tstruct aio_ring *ring;",
"\tto_alloc = min(batch->count, KIOCB_BATCH_SIZE);\n\tfor (allocated = 0; allocated < to_alloc; allocated++) {\n\t\treq = __aio_get_req(ctx);\n\t\tif (!req)\n\t\t\t/* allocation failed, go with what we've got */\n\t\t\tbreak;\n\t\tlist_add(&req->ki_batch, &batch->head);\n\t}",
"\tif (allocated == 0)\n\t\tgoto out;",
"retry:\n\tspin_lock_irq(&ctx->ctx_lock);\n\tring = kmap_atomic(ctx->ring_info.ring_pages[0]);",
"\tavail = aio_ring_avail(&ctx->ring_info, ring) - ctx->reqs_active;\n\tBUG_ON(avail < 0);\n\tif (avail == 0 && !called_fput) {\n\t\t/*\n\t\t * Handle a potential starvation case. It is possible that\n\t\t * we hold the last reference on a struct file, causing us\n\t\t * to delay the final fput to non-irq context. In this case,\n\t\t * ctx->reqs_active is artificially high. Calling the fput\n\t\t * routine here may free up a slot in the event completion\n\t\t * ring, allowing this allocation to succeed.\n\t\t */\n\t\tkunmap_atomic(ring);\n\t\tspin_unlock_irq(&ctx->ctx_lock);\n\t\taio_fput_routine(NULL);\n\t\tcalled_fput = true;\n\t\tgoto retry;\n\t}",
"\tif (avail < allocated) {\n\t\t/* Trim back the number of requests. */\n\t\tlist_for_each_entry_safe(req, n, &batch->head, ki_batch) {\n\t\t\tlist_del(&req->ki_batch);\n\t\t\tkmem_cache_free(kiocb_cachep, req);\n\t\t\tif (--allocated <= avail)\n\t\t\t\tbreak;\n\t\t}\n\t}",
"\tbatch->count -= allocated;\n\tlist_for_each_entry(req, &batch->head, ki_batch) {\n\t\tlist_add(&req->ki_list, &ctx->active_reqs);\n\t\tctx->reqs_active++;\n\t}",
"\tkunmap_atomic(ring);\n\tspin_unlock_irq(&ctx->ctx_lock);",
"out:\n\treturn allocated;\n}",
"static inline struct kiocb *aio_get_req(struct kioctx *ctx,\n\t\t\t\t\tstruct kiocb_batch *batch)\n{\n\tstruct kiocb *req;",
"\tif (list_empty(&batch->head))\n\t\tif (kiocb_batch_refill(ctx, batch) == 0)\n\t\t\treturn NULL;\n\treq = list_first_entry(&batch->head, struct kiocb, ki_batch);\n\tlist_del(&req->ki_batch);\n\treturn req;\n}",
"static inline void really_put_req(struct kioctx *ctx, struct kiocb *req)\n{\n\tassert_spin_locked(&ctx->ctx_lock);",
"\tif (req->ki_eventfd != NULL)\n\t\teventfd_ctx_put(req->ki_eventfd);\n\tif (req->ki_dtor)\n\t\treq->ki_dtor(req);\n\tif (req->ki_iovec != &req->ki_inline_vec)\n\t\tkfree(req->ki_iovec);\n\tkmem_cache_free(kiocb_cachep, req);\n\tctx->reqs_active--;",
"\tif (unlikely(!ctx->reqs_active && ctx->dead))\n\t\twake_up_all(&ctx->wait);\n}",
"static void aio_fput_routine(struct work_struct *data)\n{\n\tspin_lock_irq(&fput_lock);\n\twhile (likely(!list_empty(&fput_head))) {\n\t\tstruct kiocb *req = list_kiocb(fput_head.next);\n\t\tstruct kioctx *ctx = req->ki_ctx;",
"\t\tlist_del(&req->ki_list);\n\t\tspin_unlock_irq(&fput_lock);",
"\t\t/* Complete the fput(s) */\n\t\tif (req->ki_filp != NULL)\n\t\t\tfput(req->ki_filp);",
"\t\t/* Link the iocb into the context's free list */\n\t\tspin_lock_irq(&ctx->ctx_lock);\n\t\treally_put_req(ctx, req);\n\t\tspin_unlock_irq(&ctx->ctx_lock);",
"\t\tput_ioctx(ctx);\n\t\tspin_lock_irq(&fput_lock);\n\t}\n\tspin_unlock_irq(&fput_lock);\n}",
"/* __aio_put_req\n *\tReturns true if this put was the last user of the request.\n */\nstatic int __aio_put_req(struct kioctx *ctx, struct kiocb *req)\n{\n\tdprintk(KERN_DEBUG \"aio_put(%p): f_count=%ld\\n\",\n\t\treq, atomic_long_read(&req->ki_filp->f_count));",
"\tassert_spin_locked(&ctx->ctx_lock);",
"\treq->ki_users--;\n\tBUG_ON(req->ki_users < 0);\n\tif (likely(req->ki_users))\n\t\treturn 0;\n\tlist_del(&req->ki_list);\t\t/* remove from active_reqs */\n\treq->ki_cancel = NULL;\n\treq->ki_retry = NULL;",
"\t/*\n\t * Try to optimize the aio and eventfd file* puts, by avoiding to\n\t * schedule work in case it is not final fput() time. In normal cases,\n\t * we would not be holding the last reference to the file*, so\n\t * this function will be executed w/out any aio kthread wakeup.\n\t */\n\tif (unlikely(!fput_atomic(req->ki_filp))) {\n\t\tget_ioctx(ctx);\n\t\tspin_lock(&fput_lock);\n\t\tlist_add(&req->ki_list, &fput_head);\n\t\tspin_unlock(&fput_lock);\n\t\tschedule_work(&fput_work);\n\t} else {\n\t\treq->ki_filp = NULL;\n\t\treally_put_req(ctx, req);\n\t}\n\treturn 1;\n}",
"/* aio_put_req\n *\tReturns true if this put was the last user of the kiocb,\n *\tfalse if the request is still in use.\n */\nint aio_put_req(struct kiocb *req)\n{\n\tstruct kioctx *ctx = req->ki_ctx;\n\tint ret;\n\tspin_lock_irq(&ctx->ctx_lock);\n\tret = __aio_put_req(ctx, req);\n\tspin_unlock_irq(&ctx->ctx_lock);\n\treturn ret;\n}\nEXPORT_SYMBOL(aio_put_req);",
"static struct kioctx *lookup_ioctx(unsigned long ctx_id)\n{\n\tstruct mm_struct *mm = current->mm;\n\tstruct kioctx *ctx, *ret = NULL;\n\tstruct hlist_node *n;",
"\trcu_read_lock();",
"\thlist_for_each_entry_rcu(ctx, n, &mm->ioctx_list, list) {\n\t\t/*\n\t\t * RCU protects us against accessing freed memory but\n\t\t * we have to be careful not to get a reference when the\n\t\t * reference count already dropped to 0 (ctx->dead test\n\t\t * is unreliable because of races).\n\t\t */\n\t\tif (ctx->user_id == ctx_id && !ctx->dead && try_get_ioctx(ctx)){\n\t\t\tret = ctx;\n\t\t\tbreak;\n\t\t}\n\t}",
"\trcu_read_unlock();\n\treturn ret;\n}",
"/*\n * Queue up a kiocb to be retried. Assumes that the kiocb\n * has already been marked as kicked, and places it on\n * the retry run list for the corresponding ioctx, if it\n * isn't already queued. Returns 1 if it actually queued\n * the kiocb (to tell the caller to activate the work\n * queue to process it), or 0, if it found that it was\n * already queued.\n */\nstatic inline int __queue_kicked_iocb(struct kiocb *iocb)\n{\n\tstruct kioctx *ctx = iocb->ki_ctx;",
"\tassert_spin_locked(&ctx->ctx_lock);",
"\tif (list_empty(&iocb->ki_run_list)) {\n\t\tlist_add_tail(&iocb->ki_run_list,\n\t\t\t&ctx->run_list);\n\t\treturn 1;\n\t}\n\treturn 0;\n}",
"/* aio_run_iocb\n *\tThis is the core aio execution routine. It is\n *\tinvoked both for initial i/o submission and\n *\tsubsequent retries via the aio_kick_handler.\n *\tExpects to be invoked with iocb->ki_ctx->lock\n *\talready held. The lock is released and reacquired\n *\tas needed during processing.\n *\n * Calls the iocb retry method (already setup for the\n * iocb on initial submission) for operation specific\n * handling, but takes care of most of common retry\n * execution details for a given iocb. The retry method\n * needs to be non-blocking as far as possible, to avoid\n * holding up other iocbs waiting to be serviced by the\n * retry kernel thread.\n *\n * The trickier parts in this code have to do with\n * ensuring that only one retry instance is in progress\n * for a given iocb at any time. Providing that guarantee\n * simplifies the coding of individual aio operations as\n * it avoids various potential races.\n */\nstatic ssize_t aio_run_iocb(struct kiocb *iocb)\n{\n\tstruct kioctx\t*ctx = iocb->ki_ctx;\n\tssize_t (*retry)(struct kiocb *);\n\tssize_t ret;",
"\tif (!(retry = iocb->ki_retry)) {\n\t\tprintk(\"aio_run_iocb: iocb->ki_retry = NULL\\n\");\n\t\treturn 0;\n\t}",
"\t/*\n\t * We don't want the next retry iteration for this\n\t * operation to start until this one has returned and\n\t * updated the iocb state. However, wait_queue functions\n\t * can trigger a kick_iocb from interrupt context in the\n\t * meantime, indicating that data is available for the next\n\t * iteration. We want to remember that and enable the\n\t * next retry iteration _after_ we are through with\n\t * this one.\n\t *\n\t * So, in order to be able to register a \"kick\", but\n\t * prevent it from being queued now, we clear the kick\n\t * flag, but make the kick code *think* that the iocb is\n\t * still on the run list until we are actually done.\n\t * When we are done with this iteration, we check if\n\t * the iocb was kicked in the meantime and if so, queue\n\t * it up afresh.\n\t */",
"\tkiocbClearKicked(iocb);",
"\t/*\n\t * This is so that aio_complete knows it doesn't need to\n\t * pull the iocb off the run list (We can't just call\n\t * INIT_LIST_HEAD because we don't want a kick_iocb to\n\t * queue this on the run list yet)\n\t */\n\tiocb->ki_run_list.next = iocb->ki_run_list.prev = NULL;\n\tspin_unlock_irq(&ctx->ctx_lock);",
"\t/* Quit retrying if the i/o has been cancelled */\n\tif (kiocbIsCancelled(iocb)) {\n\t\tret = -EINTR;\n\t\taio_complete(iocb, ret, 0);\n\t\t/* must not access the iocb after this */\n\t\tgoto out;\n\t}",
"\t/*\n\t * Now we are all set to call the retry method in async\n\t * context.\n\t */\n\tret = retry(iocb);",
"\tif (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) {\n\t\t/*\n\t\t * There's no easy way to restart the syscall since other AIO's\n\t\t * may be already running. Just fail this IO with EINTR.\n\t\t */\n\t\tif (unlikely(ret == -ERESTARTSYS || ret == -ERESTARTNOINTR ||\n\t\t\t ret == -ERESTARTNOHAND || ret == -ERESTART_RESTARTBLOCK))\n\t\t\tret = -EINTR;\n\t\taio_complete(iocb, ret, 0);\n\t}\nout:\n\tspin_lock_irq(&ctx->ctx_lock);",
"\tif (-EIOCBRETRY == ret) {\n\t\t/*\n\t\t * OK, now that we are done with this iteration\n\t\t * and know that there is more left to go,\n\t\t * this is where we let go so that a subsequent\n\t\t * \"kick\" can start the next iteration\n\t\t */",
"\t\t/* will make __queue_kicked_iocb succeed from here on */\n\t\tINIT_LIST_HEAD(&iocb->ki_run_list);\n\t\t/* we must queue the next iteration ourselves, if it\n\t\t * has already been kicked */\n\t\tif (kiocbIsKicked(iocb)) {\n\t\t\t__queue_kicked_iocb(iocb);",
"\t\t\t/*\n\t\t\t * __queue_kicked_iocb will always return 1 here, because\n\t\t\t * iocb->ki_run_list is empty at this point so it should\n\t\t\t * be safe to unconditionally queue the context into the\n\t\t\t * work queue.\n\t\t\t */\n\t\t\taio_queue_work(ctx);\n\t\t}\n\t}\n\treturn ret;\n}",
"/*\n * __aio_run_iocbs:\n * \tProcess all pending retries queued on the ioctx\n * \trun list.\n * Assumes it is operating within the aio issuer's mm\n * context.\n */\nstatic int __aio_run_iocbs(struct kioctx *ctx)\n{\n\tstruct kiocb *iocb;\n\tstruct list_head run_list;",
"\tassert_spin_locked(&ctx->ctx_lock);",
"\tlist_replace_init(&ctx->run_list, &run_list);\n\twhile (!list_empty(&run_list)) {\n\t\tiocb = list_entry(run_list.next, struct kiocb,\n\t\t\tki_run_list);\n\t\tlist_del(&iocb->ki_run_list);\n\t\t/*\n\t\t * Hold an extra reference while retrying i/o.\n\t\t */\n\t\tiocb->ki_users++; /* grab extra reference */\n\t\taio_run_iocb(iocb);\n\t\t__aio_put_req(ctx, iocb);\n \t}\n\tif (!list_empty(&ctx->run_list))\n\t\treturn 1;\n\treturn 0;\n}",
"static void aio_queue_work(struct kioctx * ctx)\n{\n\tunsigned long timeout;\n\t/*\n\t * if someone is waiting, get the work started right\n\t * away, otherwise, use a longer delay\n\t */\n\tsmp_mb();\n\tif (waitqueue_active(&ctx->wait))\n\t\ttimeout = 1;\n\telse\n\t\ttimeout = HZ/10;\n\tqueue_delayed_work(aio_wq, &ctx->wq, timeout);\n}",
"/*\n * aio_run_all_iocbs:\n *\tProcess all pending retries queued on the ioctx\n *\trun list, and keep running them until the list\n *\tstays empty.\n * Assumes it is operating within the aio issuer's mm context.\n */\nstatic inline void aio_run_all_iocbs(struct kioctx *ctx)\n{\n\tspin_lock_irq(&ctx->ctx_lock);\n\twhile (__aio_run_iocbs(ctx))\n\t\t;\n\tspin_unlock_irq(&ctx->ctx_lock);\n}",
"/*\n * aio_kick_handler:\n * \tWork queue handler triggered to process pending\n * \tretries on an ioctx. Takes on the aio issuer's\n *\tmm context before running the iocbs, so that\n *\tcopy_xxx_user operates on the issuer's address\n * space.\n * Run on aiod's context.\n */\nstatic void aio_kick_handler(struct work_struct *work)\n{\n\tstruct kioctx *ctx = container_of(work, struct kioctx, wq.work);\n\tmm_segment_t oldfs = get_fs();\n\tstruct mm_struct *mm;\n\tint requeue;",
"\tset_fs(USER_DS);\n\tuse_mm(ctx->mm);\n\tspin_lock_irq(&ctx->ctx_lock);\n\trequeue =__aio_run_iocbs(ctx);\n\tmm = ctx->mm;\n\tspin_unlock_irq(&ctx->ctx_lock);\n \tunuse_mm(mm);\n\tset_fs(oldfs);\n\t/*\n\t * we're in a worker thread already, don't use queue_delayed_work,\n\t */\n\tif (requeue)\n\t\tqueue_delayed_work(aio_wq, &ctx->wq, 0);\n}",
"\n/*\n * Called by kick_iocb to queue the kiocb for retry\n * and if required activate the aio work queue to process\n * it\n */\nstatic void try_queue_kicked_iocb(struct kiocb *iocb)\n{\n \tstruct kioctx\t*ctx = iocb->ki_ctx;\n\tunsigned long flags;\n\tint run = 0;",
"\tspin_lock_irqsave(&ctx->ctx_lock, flags);\n\t/* set this inside the lock so that we can't race with aio_run_iocb()\n\t * testing it and putting the iocb on the run list under the lock */\n\tif (!kiocbTryKick(iocb))\n\t\trun = __queue_kicked_iocb(iocb);\n\tspin_unlock_irqrestore(&ctx->ctx_lock, flags);\n\tif (run)\n\t\taio_queue_work(ctx);\n}",
"/*\n * kick_iocb:\n * Called typically from a wait queue callback context\n * to trigger a retry of the iocb.\n * The retry is usually executed by aio workqueue\n * threads (See aio_kick_handler).\n */\nvoid kick_iocb(struct kiocb *iocb)\n{\n\t/* sync iocbs are easy: they can only ever be executing from a \n\t * single context. */\n\tif (is_sync_kiocb(iocb)) {\n\t\tkiocbSetKicked(iocb);\n\t wake_up_process(iocb->ki_obj.tsk);\n\t\treturn;\n\t}",
"\ttry_queue_kicked_iocb(iocb);\n}\nEXPORT_SYMBOL(kick_iocb);",
"/* aio_complete\n *\tCalled when the io request on the given iocb is complete.\n *\tReturns true if this is the last user of the request. The \n *\tonly other user of the request can be the cancellation code.\n */\nint aio_complete(struct kiocb *iocb, long res, long res2)\n{\n\tstruct kioctx\t*ctx = iocb->ki_ctx;\n\tstruct aio_ring_info\t*info;\n\tstruct aio_ring\t*ring;\n\tstruct io_event\t*event;\n\tunsigned long\tflags;\n\tunsigned long\ttail;\n\tint\t\tret;",
"\t/*\n\t * Special case handling for sync iocbs:\n\t * - events go directly into the iocb for fast handling\n\t * - the sync task with the iocb in its stack holds the single iocb\n\t * ref, no other paths have a way to get another ref\n\t * - the sync task helpfully left a reference to itself in the iocb\n\t */\n\tif (is_sync_kiocb(iocb)) {\n\t\tBUG_ON(iocb->ki_users != 1);\n\t\tiocb->ki_user_data = res;\n\t\tiocb->ki_users = 0;\n\t\twake_up_process(iocb->ki_obj.tsk);\n\t\treturn 1;\n\t}",
"\tinfo = &ctx->ring_info;",
"\t/* add a completion event to the ring buffer.\n\t * must be done holding ctx->ctx_lock to prevent\n\t * other code from messing with the tail\n\t * pointer since we might be called from irq\n\t * context.\n\t */\n\tspin_lock_irqsave(&ctx->ctx_lock, flags);",
"\tif (iocb->ki_run_list.prev && !list_empty(&iocb->ki_run_list))\n\t\tlist_del_init(&iocb->ki_run_list);",
"\t/*\n\t * cancelled requests don't get events, userland was given one\n\t * when the event got cancelled.\n\t */\n\tif (kiocbIsCancelled(iocb))\n\t\tgoto put_rq;",
"\tring = kmap_atomic(info->ring_pages[0], KM_IRQ1);",
"\ttail = info->tail;\n\tevent = aio_ring_event(info, tail, KM_IRQ0);\n\tif (++tail >= info->nr)\n\t\ttail = 0;",
"\tevent->obj = (u64)(unsigned long)iocb->ki_obj.user;\n\tevent->data = iocb->ki_user_data;\n\tevent->res = res;\n\tevent->res2 = res2;",
"\tdprintk(\"aio_complete: %p[%lu]: %p: %p %Lx %lx %lx\\n\",\n\t\tctx, tail, iocb, iocb->ki_obj.user, iocb->ki_user_data,\n\t\tres, res2);",
"\t/* after flagging the request as done, we\n\t * must never even look at it again\n\t */\n\tsmp_wmb();\t/* make event visible before updating tail */",
"\tinfo->tail = tail;\n\tring->tail = tail;",
"\tput_aio_ring_event(event, KM_IRQ0);\n\tkunmap_atomic(ring, KM_IRQ1);",
"\tpr_debug(\"added to ring %p at [%lu]\\n\", iocb, tail);",
"\t/*\n\t * Check if the user asked us to deliver the result through an\n\t * eventfd. The eventfd_signal() function is safe to be called\n\t * from IRQ context.\n\t */\n\tif (iocb->ki_eventfd != NULL)\n\t\teventfd_signal(iocb->ki_eventfd, 1);",
"put_rq:\n\t/* everything turned out well, dispose of the aiocb. */\n\tret = __aio_put_req(ctx, iocb);",
"\t/*\n\t * We have to order our ring_info tail store above and test\n\t * of the wait list below outside the wait lock. This is\n\t * like in wake_up_bit() where clearing a bit has to be\n\t * ordered with the unlocked test.\n\t */\n\tsmp_mb();",
"\tif (waitqueue_active(&ctx->wait))\n\t\twake_up(&ctx->wait);",
"\tspin_unlock_irqrestore(&ctx->ctx_lock, flags);\n\treturn ret;\n}\nEXPORT_SYMBOL(aio_complete);",
"/* aio_read_evt\n *\tPull an event off of the ioctx's event ring. Returns the number of \n *\tevents fetched (0 or 1 ;-)\n *\tFIXME: make this use cmpxchg.\n *\tTODO: make the ringbuffer user mmap()able (requires FIXME).\n */\nstatic int aio_read_evt(struct kioctx *ioctx, struct io_event *ent)\n{\n\tstruct aio_ring_info *info = &ioctx->ring_info;\n\tstruct aio_ring *ring;\n\tunsigned long head;\n\tint ret = 0;",
"\tring = kmap_atomic(info->ring_pages[0], KM_USER0);\n\tdprintk(\"in aio_read_evt h%lu t%lu m%lu\\n\",\n\t\t (unsigned long)ring->head, (unsigned long)ring->tail,\n\t\t (unsigned long)ring->nr);",
"\tif (ring->head == ring->tail)\n\t\tgoto out;",
"\tspin_lock(&info->ring_lock);",
"\thead = ring->head % info->nr;\n\tif (head != ring->tail) {\n\t\tstruct io_event *evp = aio_ring_event(info, head, KM_USER1);\n\t\t*ent = *evp;\n\t\thead = (head + 1) % info->nr;\n\t\tsmp_mb(); /* finish reading the event before updatng the head */\n\t\tring->head = head;\n\t\tret = 1;\n\t\tput_aio_ring_event(evp, KM_USER1);\n\t}\n\tspin_unlock(&info->ring_lock);",
"out:\n\tkunmap_atomic(ring, KM_USER0);\n\tdprintk(\"leaving aio_read_evt: %d h%lu t%lu\\n\", ret,\n\t\t (unsigned long)ring->head, (unsigned long)ring->tail);\n\treturn ret;\n}",
"struct aio_timeout {\n\tstruct timer_list\ttimer;\n\tint\t\t\ttimed_out;\n\tstruct task_struct\t*p;\n};",
"static void timeout_func(unsigned long data)\n{\n\tstruct aio_timeout *to = (struct aio_timeout *)data;",
"\tto->timed_out = 1;\n\twake_up_process(to->p);\n}",
"static inline void init_timeout(struct aio_timeout *to)\n{\n\tsetup_timer_on_stack(&to->timer, timeout_func, (unsigned long) to);\n\tto->timed_out = 0;\n\tto->p = current;\n}",
"static inline void set_timeout(long start_jiffies, struct aio_timeout *to,\n\t\t\t const struct timespec *ts)\n{\n\tto->timer.expires = start_jiffies + timespec_to_jiffies(ts);\n\tif (time_after(to->timer.expires, jiffies))\n\t\tadd_timer(&to->timer);\n\telse\n\t\tto->timed_out = 1;\n}",
"static inline void clear_timeout(struct aio_timeout *to)\n{\n\tdel_singleshot_timer_sync(&to->timer);\n}",
"static int read_events(struct kioctx *ctx,\n\t\t\tlong min_nr, long nr,\n\t\t\tstruct io_event __user *event,\n\t\t\tstruct timespec __user *timeout)\n{\n\tlong\t\t\tstart_jiffies = jiffies;\n\tstruct task_struct\t*tsk = current;\n\tDECLARE_WAITQUEUE(wait, tsk);\n\tint\t\t\tret;\n\tint\t\t\ti = 0;\n\tstruct io_event\t\tent;\n\tstruct aio_timeout\tto;\n\tint\t\t\tretry = 0;",
"\t/* needed to zero any padding within an entry (there shouldn't be \n\t * any, but C is fun!\n\t */\n\tmemset(&ent, 0, sizeof(ent));\nretry:\n\tret = 0;\n\twhile (likely(i < nr)) {\n\t\tret = aio_read_evt(ctx, &ent);\n\t\tif (unlikely(ret <= 0))\n\t\t\tbreak;",
"\t\tdprintk(\"read event: %Lx %Lx %Lx %Lx\\n\",\n\t\t\tent.data, ent.obj, ent.res, ent.res2);",
"\t\t/* Could we split the check in two? */\n\t\tret = -EFAULT;\n\t\tif (unlikely(copy_to_user(event, &ent, sizeof(ent)))) {\n\t\t\tdprintk(\"aio: lost an event due to EFAULT.\\n\");\n\t\t\tbreak;\n\t\t}\n\t\tret = 0;",
"\t\t/* Good, event copied to userland, update counts. */\n\t\tevent ++;\n\t\ti ++;\n\t}",
"\tif (min_nr <= i)\n\t\treturn i;\n\tif (ret)\n\t\treturn ret;",
"\t/* End fast path */",
"\t/* racey check, but it gets redone */\n\tif (!retry && unlikely(!list_empty(&ctx->run_list))) {\n\t\tretry = 1;\n\t\taio_run_all_iocbs(ctx);\n\t\tgoto retry;\n\t}",
"\tinit_timeout(&to);\n\tif (timeout) {\n\t\tstruct timespec\tts;\n\t\tret = -EFAULT;\n\t\tif (unlikely(copy_from_user(&ts, timeout, sizeof(ts))))\n\t\t\tgoto out;",
"\t\tset_timeout(start_jiffies, &to, &ts);\n\t}",
"\twhile (likely(i < nr)) {\n\t\tadd_wait_queue_exclusive(&ctx->wait, &wait);\n\t\tdo {\n\t\t\tset_task_state(tsk, TASK_INTERRUPTIBLE);\n\t\t\tret = aio_read_evt(ctx, &ent);\n\t\t\tif (ret)\n\t\t\t\tbreak;\n\t\t\tif (min_nr <= i)\n\t\t\t\tbreak;\n\t\t\tif (unlikely(ctx->dead)) {\n\t\t\t\tret = -EINVAL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (to.timed_out)\t/* Only check after read evt */\n\t\t\t\tbreak;\n\t\t\t/* Try to only show up in io wait if there are ops\n\t\t\t * in flight */\n\t\t\tif (ctx->reqs_active)\n\t\t\t\tio_schedule();\n\t\t\telse\n\t\t\t\tschedule();\n\t\t\tif (signal_pending(tsk)) {\n\t\t\t\tret = -EINTR;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t/*ret = aio_read_evt(ctx, &ent);*/\n\t\t} while (1) ;",
"\t\tset_task_state(tsk, TASK_RUNNING);\n\t\tremove_wait_queue(&ctx->wait, &wait);",
"\t\tif (unlikely(ret <= 0))\n\t\t\tbreak;",
"\t\tret = -EFAULT;\n\t\tif (unlikely(copy_to_user(event, &ent, sizeof(ent)))) {\n\t\t\tdprintk(\"aio: lost an event due to EFAULT.\\n\");\n\t\t\tbreak;\n\t\t}",
"\t\t/* Good, event copied to userland, update counts. */\n\t\tevent ++;\n\t\ti ++;\n\t}",
"\tif (timeout)\n\t\tclear_timeout(&to);\nout:\n\tdestroy_timer_on_stack(&to.timer);\n\treturn i ? i : ret;\n}",
"/* Take an ioctx and remove it from the list of ioctx's. Protects \n * against races with itself via ->dead.\n */\nstatic void io_destroy(struct kioctx *ioctx)\n{\n\tstruct mm_struct *mm = current->mm;\n\tint was_dead;",
"\t/* delete the entry from the list is someone else hasn't already */\n\tspin_lock(&mm->ioctx_lock);\n\twas_dead = ioctx->dead;\n\tioctx->dead = 1;\n\thlist_del_rcu(&ioctx->list);\n\tspin_unlock(&mm->ioctx_lock);",
"\tdprintk(\"aio_release(%p)\\n\", ioctx);\n\tif (likely(!was_dead))\n\t\tput_ioctx(ioctx);\t/* twice for the list */",
"\taio_cancel_all(ioctx);\n\twait_for_all_aios(ioctx);",
"\t/*\n\t * Wake up any waiters. The setting of ctx->dead must be seen\n\t * by other CPUs at this point. Right now, we rely on the\n\t * locking done by the above calls to ensure this consistency.\n\t */\n\twake_up_all(&ioctx->wait);\n\tput_ioctx(ioctx);\t/* once for the lookup */\n}",
"/* sys_io_setup:\n *\tCreate an aio_context capable of receiving at least nr_events.\n *\tctxp must not point to an aio_context that already exists, and\n *\tmust be initialized to 0 prior to the call. On successful\n *\tcreation of the aio_context, *ctxp is filled in with the resulting \n *\thandle. May fail with -EINVAL if *ctxp is not initialized,\n *\tif the specified nr_events exceeds internal limits. May fail \n *\twith -EAGAIN if the specified nr_events exceeds the user's limit \n *\tof available events. May fail with -ENOMEM if insufficient kernel\n *\tresources are available. May fail with -EFAULT if an invalid\n *\tpointer is passed for ctxp. Will fail with -ENOSYS if not\n *\timplemented.\n */\nSYSCALL_DEFINE2(io_setup, unsigned, nr_events, aio_context_t __user *, ctxp)\n{\n\tstruct kioctx *ioctx = NULL;\n\tunsigned long ctx;\n\tlong ret;",
"\tret = get_user(ctx, ctxp);\n\tif (unlikely(ret))\n\t\tgoto out;",
"\tret = -EINVAL;\n\tif (unlikely(ctx || nr_events == 0)) {\n\t\tpr_debug(\"EINVAL: io_setup: ctx %lu nr_events %u\\n\",\n\t\t ctx, nr_events);\n\t\tgoto out;\n\t}",
"\tioctx = ioctx_alloc(nr_events);\n\tret = PTR_ERR(ioctx);\n\tif (!IS_ERR(ioctx)) {\n\t\tret = put_user(ioctx->user_id, ctxp);\n\t\tif (!ret)\n\t\t\treturn 0;",
"\t\tget_ioctx(ioctx); /* io_destroy() expects us to hold a ref */\n\t\tio_destroy(ioctx);\n\t}",
"out:\n\treturn ret;\n}",
"/* sys_io_destroy:\n *\tDestroy the aio_context specified. May cancel any outstanding \n *\tAIOs and block on completion. Will fail with -ENOSYS if not\n *\timplemented. May fail with -EINVAL if the context pointed to\n *\tis invalid.\n */\nSYSCALL_DEFINE1(io_destroy, aio_context_t, ctx)\n{\n\tstruct kioctx *ioctx = lookup_ioctx(ctx);\n\tif (likely(NULL != ioctx)) {\n\t\tio_destroy(ioctx);\n\t\treturn 0;\n\t}\n\tpr_debug(\"EINVAL: io_destroy: invalid context id\\n\");\n\treturn -EINVAL;\n}",
"static void aio_advance_iovec(struct kiocb *iocb, ssize_t ret)\n{\n\tstruct iovec *iov = &iocb->ki_iovec[iocb->ki_cur_seg];",
"\tBUG_ON(ret <= 0);",
"\twhile (iocb->ki_cur_seg < iocb->ki_nr_segs && ret > 0) {\n\t\tssize_t this = min((ssize_t)iov->iov_len, ret);\n\t\tiov->iov_base += this;\n\t\tiov->iov_len -= this;\n\t\tiocb->ki_left -= this;\n\t\tret -= this;\n\t\tif (iov->iov_len == 0) {\n\t\t\tiocb->ki_cur_seg++;\n\t\t\tiov++;\n\t\t}\n\t}",
"\t/* the caller should not have done more io than what fit in\n\t * the remaining iovecs */\n\tBUG_ON(ret > 0 && iocb->ki_left == 0);\n}",
"static ssize_t aio_rw_vect_retry(struct kiocb *iocb)\n{\n\tstruct file *file = iocb->ki_filp;\n\tstruct address_space *mapping = file->f_mapping;\n\tstruct inode *inode = mapping->host;\n\tssize_t (*rw_op)(struct kiocb *, const struct iovec *,\n\t\t\t unsigned long, loff_t);\n\tssize_t ret = 0;\n\tunsigned short opcode;",
"\tif ((iocb->ki_opcode == IOCB_CMD_PREADV) ||\n\t\t(iocb->ki_opcode == IOCB_CMD_PREAD)) {\n\t\trw_op = file->f_op->aio_read;\n\t\topcode = IOCB_CMD_PREADV;\n\t} else {\n\t\trw_op = file->f_op->aio_write;\n\t\topcode = IOCB_CMD_PWRITEV;\n\t}",
"\t/* This matches the pread()/pwrite() logic */\n\tif (iocb->ki_pos < 0)\n\t\treturn -EINVAL;",
"\tdo {\n\t\tret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg],\n\t\t\t iocb->ki_nr_segs - iocb->ki_cur_seg,\n\t\t\t iocb->ki_pos);\n\t\tif (ret > 0)\n\t\t\taio_advance_iovec(iocb, ret);",
"\t/* retry all partial writes. retry partial reads as long as its a\n\t * regular file. */\n\t} while (ret > 0 && iocb->ki_left > 0 &&\n\t\t (opcode == IOCB_CMD_PWRITEV ||\n\t\t (!S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode))));",
"\t/* This means we must have transferred all that we could */\n\t/* No need to retry anymore */\n\tif ((ret == 0) || (iocb->ki_left == 0))\n\t\tret = iocb->ki_nbytes - iocb->ki_left;",
"\t/* If we managed to write some out we return that, rather than\n\t * the eventual error. */\n\tif (opcode == IOCB_CMD_PWRITEV\n\t && ret < 0 && ret != -EIOCBQUEUED && ret != -EIOCBRETRY\n\t && iocb->ki_nbytes - iocb->ki_left)\n\t\tret = iocb->ki_nbytes - iocb->ki_left;",
"\treturn ret;\n}",
"static ssize_t aio_fdsync(struct kiocb *iocb)\n{\n\tstruct file *file = iocb->ki_filp;\n\tssize_t ret = -EINVAL;",
"\tif (file->f_op->aio_fsync)\n\t\tret = file->f_op->aio_fsync(iocb, 1);\n\treturn ret;\n}",
"static ssize_t aio_fsync(struct kiocb *iocb)\n{\n\tstruct file *file = iocb->ki_filp;\n\tssize_t ret = -EINVAL;",
"\tif (file->f_op->aio_fsync)\n\t\tret = file->f_op->aio_fsync(iocb, 0);\n\treturn ret;\n}",
"static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)\n{\n\tssize_t ret;",
"#ifdef CONFIG_COMPAT\n\tif (compat)\n\t\tret = compat_rw_copy_check_uvector(type,\n\t\t\t\t(struct compat_iovec __user *)kiocb->ki_buf,\n\t\t\t\tkiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,\n\t\t\t\t&kiocb->ki_iovec, 1);\n\telse\n#endif\n\t\tret = rw_copy_check_uvector(type,\n\t\t\t\t(struct iovec __user *)kiocb->ki_buf,\n\t\t\t\tkiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,\n\t\t\t\t&kiocb->ki_iovec, 1);\n\tif (ret < 0)\n\t\tgoto out;",
"\tkiocb->ki_nr_segs = kiocb->ki_nbytes;\n\tkiocb->ki_cur_seg = 0;\n\t/* ki_nbytes/left now reflect bytes instead of segs */\n\tkiocb->ki_nbytes = ret;\n\tkiocb->ki_left = ret;",
"\tret = 0;\nout:\n\treturn ret;\n}",
"static ssize_t aio_setup_single_vector(struct kiocb *kiocb)\n{\n\tkiocb->ki_iovec = &kiocb->ki_inline_vec;\n\tkiocb->ki_iovec->iov_base = kiocb->ki_buf;\n\tkiocb->ki_iovec->iov_len = kiocb->ki_left;\n\tkiocb->ki_nr_segs = 1;\n\tkiocb->ki_cur_seg = 0;\n\treturn 0;\n}",
"/*\n * aio_setup_iocb:\n *\tPerforms the initial checks and aio retry method\n *\tsetup for the kiocb at the time of io submission.\n */\nstatic ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat)\n{\n\tstruct file *file = kiocb->ki_filp;\n\tssize_t ret = 0;",
"\tswitch (kiocb->ki_opcode) {\n\tcase IOCB_CMD_PREAD:\n\t\tret = -EBADF;\n\t\tif (unlikely(!(file->f_mode & FMODE_READ)))\n\t\t\tbreak;\n\t\tret = -EFAULT;\n\t\tif (unlikely(!access_ok(VERIFY_WRITE, kiocb->ki_buf,\n\t\t\tkiocb->ki_left)))\n\t\t\tbreak;\n\t\tret = security_file_permission(file, MAY_READ);\n\t\tif (unlikely(ret))\n\t\t\tbreak;\n\t\tret = aio_setup_single_vector(kiocb);\n\t\tif (ret)\n\t\t\tbreak;\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_read)\n\t\t\tkiocb->ki_retry = aio_rw_vect_retry;\n\t\tbreak;\n\tcase IOCB_CMD_PWRITE:\n\t\tret = -EBADF;\n\t\tif (unlikely(!(file->f_mode & FMODE_WRITE)))\n\t\t\tbreak;\n\t\tret = -EFAULT;\n\t\tif (unlikely(!access_ok(VERIFY_READ, kiocb->ki_buf,\n\t\t\tkiocb->ki_left)))\n\t\t\tbreak;\n\t\tret = security_file_permission(file, MAY_WRITE);\n\t\tif (unlikely(ret))\n\t\t\tbreak;\n\t\tret = aio_setup_single_vector(kiocb);\n\t\tif (ret)\n\t\t\tbreak;\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_write)\n\t\t\tkiocb->ki_retry = aio_rw_vect_retry;\n\t\tbreak;\n\tcase IOCB_CMD_PREADV:\n\t\tret = -EBADF;\n\t\tif (unlikely(!(file->f_mode & FMODE_READ)))\n\t\t\tbreak;\n\t\tret = security_file_permission(file, MAY_READ);\n\t\tif (unlikely(ret))\n\t\t\tbreak;\n\t\tret = aio_setup_vectored_rw(READ, kiocb, compat);\n\t\tif (ret)\n\t\t\tbreak;\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_read)\n\t\t\tkiocb->ki_retry = aio_rw_vect_retry;\n\t\tbreak;\n\tcase IOCB_CMD_PWRITEV:\n\t\tret = -EBADF;\n\t\tif (unlikely(!(file->f_mode & FMODE_WRITE)))\n\t\t\tbreak;\n\t\tret = security_file_permission(file, MAY_WRITE);\n\t\tif (unlikely(ret))\n\t\t\tbreak;\n\t\tret = aio_setup_vectored_rw(WRITE, kiocb, compat);\n\t\tif (ret)\n\t\t\tbreak;\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_write)\n\t\t\tkiocb->ki_retry = aio_rw_vect_retry;\n\t\tbreak;\n\tcase IOCB_CMD_FDSYNC:\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_fsync)\n\t\t\tkiocb->ki_retry = aio_fdsync;\n\t\tbreak;\n\tcase IOCB_CMD_FSYNC:\n\t\tret = -EINVAL;\n\t\tif (file->f_op->aio_fsync)\n\t\t\tkiocb->ki_retry = aio_fsync;\n\t\tbreak;\n\tdefault:\n\t\tdprintk(\"EINVAL: io_submit: no operation provided\\n\");\n\t\tret = -EINVAL;\n\t}",
"\tif (!kiocb->ki_retry)\n\t\treturn ret;",
"\treturn 0;\n}",
"static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,\n\t\t\t struct iocb *iocb, struct kiocb_batch *batch,\n\t\t\t bool compat)\n{\n\tstruct kiocb *req;\n\tstruct file *file;\n\tssize_t ret;",
"\t/* enforce forwards compatibility on users */\n\tif (unlikely(iocb->aio_reserved1 || iocb->aio_reserved2)) {\n\t\tpr_debug(\"EINVAL: io_submit: reserve field set\\n\");\n\t\treturn -EINVAL;\n\t}",
"\t/* prevent overflows */\n\tif (unlikely(\n\t (iocb->aio_buf != (unsigned long)iocb->aio_buf) ||\n\t (iocb->aio_nbytes != (size_t)iocb->aio_nbytes) ||\n\t ((ssize_t)iocb->aio_nbytes < 0)\n\t )) {\n\t\tpr_debug(\"EINVAL: io_submit: overflow check\\n\");\n\t\treturn -EINVAL;\n\t}",
"\tfile = fget(iocb->aio_fildes);\n\tif (unlikely(!file))\n\t\treturn -EBADF;",
"\treq = aio_get_req(ctx, batch); /* returns with 2 references to req */\n\tif (unlikely(!req)) {\n\t\tfput(file);\n\t\treturn -EAGAIN;\n\t}\n\treq->ki_filp = file;\n\tif (iocb->aio_flags & IOCB_FLAG_RESFD) {\n\t\t/*\n\t\t * If the IOCB_FLAG_RESFD flag of aio_flags is set, get an\n\t\t * instance of the file* now. The file descriptor must be\n\t\t * an eventfd() fd, and will be signaled for each completed\n\t\t * event using the eventfd_signal() function.\n\t\t */\n\t\treq->ki_eventfd = eventfd_ctx_fdget((int) iocb->aio_resfd);\n\t\tif (IS_ERR(req->ki_eventfd)) {\n\t\t\tret = PTR_ERR(req->ki_eventfd);\n\t\t\treq->ki_eventfd = NULL;\n\t\t\tgoto out_put_req;\n\t\t}\n\t}",
"\tret = put_user(req->ki_key, &user_iocb->aio_key);\n\tif (unlikely(ret)) {\n\t\tdprintk(\"EFAULT: aio_key\\n\");\n\t\tgoto out_put_req;\n\t}",
"\treq->ki_obj.user = user_iocb;\n\treq->ki_user_data = iocb->aio_data;\n\treq->ki_pos = iocb->aio_offset;",
"\treq->ki_buf = (char __user *)(unsigned long)iocb->aio_buf;\n\treq->ki_left = req->ki_nbytes = iocb->aio_nbytes;\n\treq->ki_opcode = iocb->aio_lio_opcode;",
"\tret = aio_setup_iocb(req, compat);",
"\tif (ret)\n\t\tgoto out_put_req;",
"\tspin_lock_irq(&ctx->ctx_lock);\n\t/*\n\t * We could have raced with io_destroy() and are currently holding a\n\t * reference to ctx which should be destroyed. We cannot submit IO\n\t * since ctx gets freed as soon as io_submit() puts its reference. The\n\t * check here is reliable: io_destroy() sets ctx->dead before waiting\n\t * for outstanding IO and the barrier between these two is realized by\n\t * unlock of mm->ioctx_lock and lock of ctx->ctx_lock. Analogously we\n\t * increment ctx->reqs_active before checking for ctx->dead and the\n\t * barrier is realized by unlock and lock of ctx->ctx_lock. Thus if we\n\t * don't see ctx->dead set here, io_destroy() waits for our IO to\n\t * finish.\n\t */\n\tif (ctx->dead) {\n\t\tspin_unlock_irq(&ctx->ctx_lock);\n\t\tret = -EINVAL;\n\t\tgoto out_put_req;\n\t}\n\taio_run_iocb(req);\n\tif (!list_empty(&ctx->run_list)) {\n\t\t/* drain the run list */\n\t\twhile (__aio_run_iocbs(ctx))\n\t\t\t;\n\t}\n\tspin_unlock_irq(&ctx->ctx_lock);",
"\taio_put_req(req);\t/* drop extra ref to req */\n\treturn 0;",
"out_put_req:\n\taio_put_req(req);\t/* drop extra ref to req */\n\taio_put_req(req);\t/* drop i/o ref to req */\n\treturn ret;\n}",
"long do_io_submit(aio_context_t ctx_id, long nr,\n\t\t struct iocb __user *__user *iocbpp, bool compat)\n{\n\tstruct kioctx *ctx;\n\tlong ret = 0;\n\tint i = 0;\n\tstruct blk_plug plug;\n\tstruct kiocb_batch batch;",
"\tif (unlikely(nr < 0))\n\t\treturn -EINVAL;",
"\tif (unlikely(nr > LONG_MAX/sizeof(*iocbpp)))\n\t\tnr = LONG_MAX/sizeof(*iocbpp);",
"\tif (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(*iocbpp)))))\n\t\treturn -EFAULT;",
"\tctx = lookup_ioctx(ctx_id);\n\tif (unlikely(!ctx)) {\n\t\tpr_debug(\"EINVAL: io_submit: invalid context id\\n\");\n\t\treturn -EINVAL;\n\t}",
"\tkiocb_batch_init(&batch, nr);",
"\tblk_start_plug(&plug);",
"\t/*\n\t * AKPM: should this return a partial result if some of the IOs were\n\t * successfully submitted?\n\t */\n\tfor (i=0; i<nr; i++) {\n\t\tstruct iocb __user *user_iocb;\n\t\tstruct iocb tmp;",
"\t\tif (unlikely(__get_user(user_iocb, iocbpp + i))) {\n\t\t\tret = -EFAULT;\n\t\t\tbreak;\n\t\t}",
"\t\tif (unlikely(copy_from_user(&tmp, user_iocb, sizeof(tmp)))) {\n\t\t\tret = -EFAULT;\n\t\t\tbreak;\n\t\t}",
"\t\tret = io_submit_one(ctx, user_iocb, &tmp, &batch, compat);\n\t\tif (ret)\n\t\t\tbreak;\n\t}\n\tblk_finish_plug(&plug);\n",
"\tkiocb_batch_free(ctx, &batch);",
"\tput_ioctx(ctx);\n\treturn i ? i : ret;\n}",
"/* sys_io_submit:\n *\tQueue the nr iocbs pointed to by iocbpp for processing. Returns\n *\tthe number of iocbs queued. May return -EINVAL if the aio_context\n *\tspecified by ctx_id is invalid, if nr is < 0, if the iocb at\n *\t*iocbpp[0] is not properly initialized, if the operation specified\n *\tis invalid for the file descriptor in the iocb. May fail with\n *\t-EFAULT if any of the data structures point to invalid data. May\n *\tfail with -EBADF if the file descriptor specified in the first\n *\tiocb is invalid. May fail with -EAGAIN if insufficient resources\n *\tare available to queue any iocbs. Will return 0 if nr is 0. Will\n *\tfail with -ENOSYS if not implemented.\n */\nSYSCALL_DEFINE3(io_submit, aio_context_t, ctx_id, long, nr,\n\t\tstruct iocb __user * __user *, iocbpp)\n{\n\treturn do_io_submit(ctx_id, nr, iocbpp, 0);\n}",
"/* lookup_kiocb\n *\tFinds a given iocb for cancellation.\n */\nstatic struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb,\n\t\t\t\t u32 key)\n{\n\tstruct list_head *pos;",
"\tassert_spin_locked(&ctx->ctx_lock);",
"\t/* TODO: use a hash or array, this sucks. */\n\tlist_for_each(pos, &ctx->active_reqs) {\n\t\tstruct kiocb *kiocb = list_kiocb(pos);\n\t\tif (kiocb->ki_obj.user == iocb && kiocb->ki_key == key)\n\t\t\treturn kiocb;\n\t}\n\treturn NULL;\n}",
"/* sys_io_cancel:\n *\tAttempts to cancel an iocb previously passed to io_submit. If\n *\tthe operation is successfully cancelled, the resulting event is\n *\tcopied into the memory pointed to by result without being placed\n *\tinto the completion queue and 0 is returned. May fail with\n *\t-EFAULT if any of the data structures pointed to are invalid.\n *\tMay fail with -EINVAL if aio_context specified by ctx_id is\n *\tinvalid. May fail with -EAGAIN if the iocb specified was not\n *\tcancelled. Will fail with -ENOSYS if not implemented.\n */\nSYSCALL_DEFINE3(io_cancel, aio_context_t, ctx_id, struct iocb __user *, iocb,\n\t\tstruct io_event __user *, result)\n{\n\tint (*cancel)(struct kiocb *iocb, struct io_event *res);\n\tstruct kioctx *ctx;\n\tstruct kiocb *kiocb;\n\tu32 key;\n\tint ret;",
"\tret = get_user(key, &iocb->aio_key);\n\tif (unlikely(ret))\n\t\treturn -EFAULT;",
"\tctx = lookup_ioctx(ctx_id);\n\tif (unlikely(!ctx))\n\t\treturn -EINVAL;",
"\tspin_lock_irq(&ctx->ctx_lock);\n\tret = -EAGAIN;\n\tkiocb = lookup_kiocb(ctx, iocb, key);\n\tif (kiocb && kiocb->ki_cancel) {\n\t\tcancel = kiocb->ki_cancel;\n\t\tkiocb->ki_users ++;\n\t\tkiocbSetCancelled(kiocb);\n\t} else\n\t\tcancel = NULL;\n\tspin_unlock_irq(&ctx->ctx_lock);",
"\tif (NULL != cancel) {\n\t\tstruct io_event tmp;\n\t\tpr_debug(\"calling cancel\\n\");\n\t\tmemset(&tmp, 0, sizeof(tmp));\n\t\ttmp.obj = (u64)(unsigned long)kiocb->ki_obj.user;\n\t\ttmp.data = kiocb->ki_user_data;\n\t\tret = cancel(kiocb, &tmp);\n\t\tif (!ret) {\n\t\t\t/* Cancellation succeeded -- copy the result\n\t\t\t * into the user's buffer.\n\t\t\t */\n\t\t\tif (copy_to_user(result, &tmp, sizeof(tmp)))\n\t\t\t\tret = -EFAULT;\n\t\t}\n\t} else\n\t\tret = -EINVAL;",
"\tput_ioctx(ctx);",
"\treturn ret;\n}",
"/* io_getevents:\n *\tAttempts to read at least min_nr events and up to nr events from\n *\tthe completion queue for the aio_context specified by ctx_id. If\n *\tit succeeds, the number of read events is returned. May fail with\n *\t-EINVAL if ctx_id is invalid, if min_nr is out of range, if nr is\n *\tout of range, if timeout is out of range. May fail with -EFAULT\n *\tif any of the memory specified is invalid. May return 0 or\n *\t< min_nr if the timeout specified by timeout has elapsed\n *\tbefore sufficient events are available, where timeout == NULL\n *\tspecifies an infinite timeout. Note that the timeout pointed to by\n *\ttimeout is relative and will be updated if not NULL and the\n *\toperation blocks. Will fail with -ENOSYS if not implemented.\n */\nSYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id,\n\t\tlong, min_nr,\n\t\tlong, nr,\n\t\tstruct io_event __user *, events,\n\t\tstruct timespec __user *, timeout)\n{\n\tstruct kioctx *ioctx = lookup_ioctx(ctx_id);\n\tlong ret = -EINVAL;",
"\tif (likely(ioctx)) {\n\t\tif (likely(min_nr <= nr && min_nr >= 0))\n\t\t\tret = read_events(ioctx, min_nr, nr, events, timeout);\n\t\tput_ioctx(ioctx);\n\t}",
"\tasmlinkage_protect(5, ret, ctx_id, min_nr, nr, events, timeout);\n\treturn ret;\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1746], "buggy_code_start_loc": [479], "filenames": ["fs/aio.c"], "fixing_code_end_loc": [1753], "fixing_code_start_loc": [479], "message": "The kiocb_batch_free function in fs/aio.c in the Linux kernel before 3.2.2 allows local users to cause a denial of service (OOPS) via vectors that trigger incorrect iocb management.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "D5AEDA47-7122-4C1A-A764-32500A089909", "versionEndExcluding": "3.2.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "The kiocb_batch_free function in fs/aio.c in the Linux kernel before 3.2.2 allows local users to cause a denial of service (OOPS) via vectors that trigger incorrect iocb management."}, {"lang": "es", "value": "La funci\u00f3n kiocb_batch_free en fs/aio.c en el kernel de Linux antes de v3.2.2 permite a usuarios locales provocar una denegaci\u00f3n de servicio a trav\u00e9s de vectores que provocan una gesti\u00f3n incorrecta de IOCB."}], "evaluatorComment": null, "id": "CVE-2012-0058", "lastModified": "2020-07-29T16:56:55.787", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 4.9, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:L/AC:L/Au:N/C:N/I:N/A:C", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 6.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2012-05-17T11:00:36.227", "references": [{"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://marc.info/?l=bugtraq&m=139447903326211&w=2"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Patch", "Vendor Advisory"], "url": "http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.2.2"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2012/01/18/7"}, {"source": "secalert@redhat.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securitytracker.com/id?1027085"}, {"source": "secalert@redhat.com", "tags": ["Issue Tracking", "Third Party Advisory"], "url": "https://bugzilla.redhat.com/show_bug.cgi?id=782696"}, {"source": "secalert@redhat.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/802f43594d6e4d2ac61086d239153c17873a0428"}], "sourceIdentifier": "secalert@redhat.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-400"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/802f43594d6e4d2ac61086d239153c17873a0428"}, "type": "CWE-400"}
| 367
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"#encoding=utf-8\n# test for flask",
"import MySQLdb\nimport time\nfrom flask import Flask\nfrom flask import render_template\nfrom flask import request, jsonify",
"\nCOLOR_CHART = [\"#F7464A\",\"#46BFBD\",\"#FDB45C\",\"#949FB1\",\"#C7604C\",\\\n\t\t\t\t\"#4D5360\",\"#7D4F6D\",\"#9D9B7F\",\"#21323D\",\"#1874CD\",\\\n\t\t\t\t\"#218868\",\"#8E8E38\"]\nconn=MySQLdb.connect(host=\"localhost\",user=\"root\",passwd=\"\",db=\"db_vote_web\",charset=\"utf8\")\napp = Flask(__name__)",
"\ndef parse_req():\n\ttitle = request.form[\"title\"]\n\tn = len(request.form)-1\n\tl_dsc = []\n\tfor i in range(1,n):\n\t\tl_dsc.append(request.form[\"opt\"+str(i)])\n\treturn title, n-1, l_dsc",
"@app.route('/')\ndef hello_world():\n return render_template(\"index.html\")",
"@app.route('/error')\ndef error():\n return render_template(\"error.html\")",
"@app.route('/create', methods=['POST'])\ndef create_poll():\n\ttry:\n\t\tcursor = conn.cursor() \n\t\tuid = request.remote_addr",
"\t\timport pdb\n\t\tpdb.set_trace()",
"\t\tvid = str(int(time.time()*100))\n\t\ttitle, optn, l_dsc = parse_req()\n\t\toptdsc = '|'.join(l_dsc)\n\t\toptnum = '|'.join(['0']*optn)\n\t\tsql = \"insert into t_vote_info(FUid, FVoteId, FTitle, FOptionNum, \\\n\t\t\t\tFOptionDesc, FOptionVoteNum, FState, FCreateTime, FEndTime) \\",
"\t\t\t\tvalues(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",%d,\\\"%s\\\",\\\"%s\\\",0,now(),now()+interval 1 day);\" ",
"\t\tparam = (uid, vid, title, optn, optdsc, optnum) ",
"\t\tres = cursor.execute(sql%param)",
"\t\tconn.commit()\n\t\tcursor.close()\n\texcept Exception,e:\n\t\treturn jsonify({\"return_code\":21, \"return_msg\":str(e), \"p_id\":0})\n\treturn jsonify({\"p_id\":vid})",
"@app.route('/poll', methods=['POST','GET'])\ndef do_poll():\n\tif \"p_id\" in request.args:\n\t\tp_id = request.args['p_id']\n\t\tcursor = conn.cursor()",
"\t\tsql_s = \"select FTitle, FOptionDesc from t_vote_info where FVoteId=%s;\"%p_id\n\t\tres = cursor.execute(sql_s)",
"\t\tr = cursor.fetchone()\n\t\tcursor.close()\n\t\ttitle = r[0]\n\t\topts_desc = r[1].split('|')\n\t\treturn render_template(\"poll.html\", title=title, opts=opts_desc)",
"\tif \"p_id\" not in request.form:\n\t\treturn render_template(\"poll.html\")\n\tif \"opt_idx\" not in request.form:\n\t\treturn render_template(\"poll.html\")",
"\to_id = int(request.form['opt_idx'])-1\n\tp_id = request.form['p_id']\n\ttry:\n\t\tcursor = conn.cursor()",
"\t\tsql_s = \"select FOptionVoteNum from t_vote_info where FVoteId=%s;\"%p_id\n\t\tres = cursor.execute(sql_s)",
"\t\topt_pre = cursor.fetchone()[0].split('|')\n\t\topt_pre[o_id] = str(int(opt_pre[o_id])+1)\n\t\topt_new = '|'.join(opt_pre)",
"\t\tsql_u = \"update t_vote_info set FOptionVoteNum=\\\"%s\\\" where FVoteId=\\\"%s\\\";\"%(opt_new,p_id)\n\t\tres = cursor.execute(sql_u)",
"\t\tconn.commit()\n\t\tcursor.close()\n\texcept Exception,e:\n\t\tcursor.close()\n\t\treturn jsonify({\"result_code\":\"-1\", \"result_msg\":\"error\", \"p_id\":0})\n\treturn jsonify({\"result_code\":\"0\", \"result_msg\":\"success\", \"p_id\":p_id})",
"@app.route('/show')\ndef show_poll():\n\ttitle = \"error\"\n\tif \"p_id\" not in request.args:\n\t\treturn render_template(\"show.html\", title=title)\n\tp_id = request.args['p_id']\n\trows = []\n\ttry:\n\t\tcursor = conn.cursor()",
"\t\tsql_s = \"select FTitle,FOptionDesc,FOptionVoteNum,FState,FEndTime from t_vote_info where FVoteId=%s;\"%p_id\n\t\tres = cursor.execute(sql_s)",
"\t\tr = cursor.fetchone()\n\t\tcursor.close()\n\t\ttitle = r[0]\n\t\topts_desc = r[1].split('|')\n\t\topts_num = r[2].split('|')\n\t\topts_col = COLOR_CHART[:len(opts_desc)]\n\t\tfor i in range(len(opts_desc)):\n\t\t\trows.append([opts_desc[i], opts_num[i], opts_col[i]])\n\texcept Exception,e:\n\t\treturn render_template(\"show.html\", title=title)\n\t#poll_id = request.args['p_id']\n\treturn render_template(\"show.html\", title=title, opts=rows)",
"@app.route('/refresh', methods=['POST'])\ndef show_refresh():\n\tif \"p_id\" not in request.form:\n\t\treturn jsonify({\"result_code\":\"-1\", \"result_msg\":\"refresh error\"})\n\tp_id = request.form['p_id']\n\trows = []\n\ttry:\n\t\tcursor = conn.cursor()",
"\t\tsql_s = \"select FTitle,FOptionDesc,FOptionVoteNum,FState,FEndTime from t_vote_info where FVoteId=%s;\"%p_id\n\t\tres = cursor.execute(sql_s)",
"\t\tr = cursor.fetchone()\n\t\tcursor.close()\n\t\ttitle = r[0]\n\t\topts_desc = r[1].split('|')\n\t\topts_num = r[2].split('|')\n\t\topts_col = COLOR_CHART[:len(opts_desc)]\n\t\tfor i in range(len(opts_desc)):\n\t\t\trows.append({\"label\":opts_desc[i], \"value\":int(opts_num[i]), \"color\":opts_col[i]})\n\t\treturn jsonify({\"result_code\":\"0\", \"result_msg\":\"success\", \"rows\":rows})\n\texcept Exception,e:\n\t\treturn jsonify({\"result_code\":\"-1\", \"result_msg\":\"refresh error\"})",
"\nif __name__ == '__main__':\n app.debug = True\n app.run()\n conn.close()"
] |
[
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
0,
1,
0,
1,
1,
0,
1,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [126, 65], "buggy_code_start_loc": [39, 28], "filenames": ["app.py", "templates/show.html"], "fixing_code_end_loc": [124, 66], "fixing_code_start_loc": [38, 28], "message": "A vulnerability was found in mapoor voteapp. It has been rated as critical. Affected by this issue is the function create_poll/do_poll/show_poll/show_refresh of the file app.py. The manipulation leads to sql injection. The name of the patch is b290c21a0d8bcdbd55db860afd3cadec97388e72. It is recommended to apply a patch to fix this issue. VDB-217790 is the identifier assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:voteapp_project:voteapp:*:*:*:*:*:*:*:*", "matchCriteriaId": "182EB143-B57B-4E00-8D49-0F2791E54600", "versionEndExcluding": "2014-12-30", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability was found in mapoor voteapp. It has been rated as critical. Affected by this issue is the function create_poll/do_poll/show_poll/show_refresh of the file app.py. The manipulation leads to sql injection. The name of the patch is b290c21a0d8bcdbd55db860afd3cadec97388e72. It is recommended to apply a patch to fix this issue. VDB-217790 is the identifier assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2014-125073", "lastModified": "2023-01-14T21:28:10.233", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "SINGLE", "availabilityImpact": "PARTIAL", "baseScore": 5.2, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:S/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 5.1, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 2.1, "impactScore": 3.4, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-10T16:15:10.657", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/mapoor/voteapp/commit/b290c21a0d8bcdbd55db860afd3cadec97388e72"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217790"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217790"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "cna@vuldb.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/mapoor/voteapp/commit/b290c21a0d8bcdbd55db860afd3cadec97388e72"}, "type": "CWE-89"}
| 368
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"#encoding=utf-8\n# test for flask",
"import MySQLdb\nimport time\nfrom flask import Flask\nfrom flask import render_template\nfrom flask import request, jsonify",
"\nCOLOR_CHART = [\"#F7464A\",\"#46BFBD\",\"#FDB45C\",\"#949FB1\",\"#C7604C\",\\\n\t\t\t\t\"#4D5360\",\"#7D4F6D\",\"#9D9B7F\",\"#21323D\",\"#1874CD\",\\\n\t\t\t\t\"#218868\",\"#8E8E38\"]\nconn=MySQLdb.connect(host=\"localhost\",user=\"root\",passwd=\"\",db=\"db_vote_web\",charset=\"utf8\")\napp = Flask(__name__)",
"\ndef parse_req():\n\ttitle = request.form[\"title\"]\n\tn = len(request.form)-1\n\tl_dsc = []\n\tfor i in range(1,n):\n\t\tl_dsc.append(request.form[\"opt\"+str(i)])\n\treturn title, n-1, l_dsc",
"@app.route('/')\ndef hello_world():\n return render_template(\"index.html\")",
"@app.route('/error')\ndef error():\n return render_template(\"error.html\")",
"@app.route('/create', methods=['POST'])\ndef create_poll():\n\ttry:\n\t\tcursor = conn.cursor() \n\t\tuid = request.remote_addr",
"",
"\t\tvid = str(int(time.time()*100))\n\t\ttitle, optn, l_dsc = parse_req()\n\t\toptdsc = '|'.join(l_dsc)\n\t\toptnum = '|'.join(['0']*optn)\n\t\tsql = \"insert into t_vote_info(FUid, FVoteId, FTitle, FOptionNum, \\\n\t\t\t\tFOptionDesc, FOptionVoteNum, FState, FCreateTime, FEndTime) \\",
"\t\t\t\tvalues(%s,%s,%s,%s,%s,%s,0,now(),now()+interval 1 day);\" ",
"\t\tparam = (uid, vid, title, optn, optdsc, optnum) ",
"\t\tres = cursor.execute(sql, param)",
"\t\tconn.commit()\n\t\tcursor.close()\n\texcept Exception,e:\n\t\treturn jsonify({\"return_code\":21, \"return_msg\":str(e), \"p_id\":0})\n\treturn jsonify({\"p_id\":vid})",
"@app.route('/poll', methods=['POST','GET'])\ndef do_poll():\n\tif \"p_id\" in request.args:\n\t\tp_id = request.args['p_id']\n\t\tcursor = conn.cursor()",
"\t\tsql_s = \"select FTitle, FOptionDesc from t_vote_info where FVoteId=%s;\"\n\t\tres = cursor.execute(sql_s, (p_id,))",
"\t\tr = cursor.fetchone()\n\t\tcursor.close()\n\t\ttitle = r[0]\n\t\topts_desc = r[1].split('|')\n\t\treturn render_template(\"poll.html\", title=title, opts=opts_desc)",
"\tif \"p_id\" not in request.form:\n\t\treturn render_template(\"poll.html\")\n\tif \"opt_idx\" not in request.form:\n\t\treturn render_template(\"poll.html\")",
"\to_id = int(request.form['opt_idx'])-1\n\tp_id = request.form['p_id']\n\ttry:\n\t\tcursor = conn.cursor()",
"\t\tsql_s = \"select FOptionVoteNum from t_vote_info where FVoteId=%s;\"\n\t\tres = cursor.execute(sql_s, (p_id,))",
"\t\topt_pre = cursor.fetchone()[0].split('|')\n\t\topt_pre[o_id] = str(int(opt_pre[o_id])+1)\n\t\topt_new = '|'.join(opt_pre)",
"\t\tsql_u = \"update t_vote_info set FOptionVoteNum=%s where FVoteId=%s;\"\n\t\tres = cursor.execute(sql_u, (opt_new,p_id))",
"\t\tconn.commit()\n\t\tcursor.close()\n\texcept Exception,e:\n\t\tcursor.close()\n\t\treturn jsonify({\"result_code\":\"-1\", \"result_msg\":\"error\", \"p_id\":0})\n\treturn jsonify({\"result_code\":\"0\", \"result_msg\":\"success\", \"p_id\":p_id})",
"@app.route('/show')\ndef show_poll():\n\ttitle = \"error\"\n\tif \"p_id\" not in request.args:\n\t\treturn render_template(\"show.html\", title=title)\n\tp_id = request.args['p_id']\n\trows = []\n\ttry:\n\t\tcursor = conn.cursor()",
"\t\tsql_s = \"select FTitle,FOptionDesc,FOptionVoteNum,FState,FEndTime from t_vote_info where FVoteId=%s;\"\n\t\tres = cursor.execute(sql_s, (p_id,))",
"\t\tr = cursor.fetchone()\n\t\tcursor.close()\n\t\ttitle = r[0]\n\t\topts_desc = r[1].split('|')\n\t\topts_num = r[2].split('|')\n\t\topts_col = COLOR_CHART[:len(opts_desc)]\n\t\tfor i in range(len(opts_desc)):\n\t\t\trows.append([opts_desc[i], opts_num[i], opts_col[i]])\n\texcept Exception,e:\n\t\treturn render_template(\"show.html\", title=title)\n\t#poll_id = request.args['p_id']\n\treturn render_template(\"show.html\", title=title, opts=rows)",
"@app.route('/refresh', methods=['POST'])\ndef show_refresh():\n\tif \"p_id\" not in request.form:\n\t\treturn jsonify({\"result_code\":\"-1\", \"result_msg\":\"refresh error\"})\n\tp_id = request.form['p_id']\n\trows = []\n\ttry:\n\t\tcursor = conn.cursor()",
"\t\tsql_s = \"select FTitle,FOptionDesc,FOptionVoteNum,FState,FEndTime from t_vote_info where FVoteId=%s;\"\n\t\tres = cursor.execute(sql_s, (p_id,))",
"\t\tr = cursor.fetchone()\n\t\tcursor.close()\n\t\ttitle = r[0]\n\t\topts_desc = r[1].split('|')\n\t\topts_num = r[2].split('|')\n\t\topts_col = COLOR_CHART[:len(opts_desc)]\n\t\tfor i in range(len(opts_desc)):\n\t\t\trows.append({\"label\":opts_desc[i], \"value\":int(opts_num[i]), \"color\":opts_col[i]})\n\t\treturn jsonify({\"result_code\":\"0\", \"result_msg\":\"success\", \"rows\":rows})\n\texcept Exception,e:\n\t\treturn jsonify({\"result_code\":\"-1\", \"result_msg\":\"refresh error\"})",
"\nif __name__ == '__main__':\n app.debug = True\n app.run()\n conn.close()"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [126, 65], "buggy_code_start_loc": [39, 28], "filenames": ["app.py", "templates/show.html"], "fixing_code_end_loc": [124, 66], "fixing_code_start_loc": [38, 28], "message": "A vulnerability was found in mapoor voteapp. It has been rated as critical. Affected by this issue is the function create_poll/do_poll/show_poll/show_refresh of the file app.py. The manipulation leads to sql injection. The name of the patch is b290c21a0d8bcdbd55db860afd3cadec97388e72. It is recommended to apply a patch to fix this issue. VDB-217790 is the identifier assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:voteapp_project:voteapp:*:*:*:*:*:*:*:*", "matchCriteriaId": "182EB143-B57B-4E00-8D49-0F2791E54600", "versionEndExcluding": "2014-12-30", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability was found in mapoor voteapp. It has been rated as critical. Affected by this issue is the function create_poll/do_poll/show_poll/show_refresh of the file app.py. The manipulation leads to sql injection. The name of the patch is b290c21a0d8bcdbd55db860afd3cadec97388e72. It is recommended to apply a patch to fix this issue. VDB-217790 is the identifier assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2014-125073", "lastModified": "2023-01-14T21:28:10.233", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "SINGLE", "availabilityImpact": "PARTIAL", "baseScore": 5.2, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:S/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 5.1, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 2.1, "impactScore": 3.4, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-10T16:15:10.657", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/mapoor/voteapp/commit/b290c21a0d8bcdbd55db860afd3cadec97388e72"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217790"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217790"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "cna@vuldb.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/mapoor/voteapp/commit/b290c21a0d8bcdbd55db860afd3cadec97388e72"}, "type": "CWE-89"}
| 368
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<!DOCTYPE html>\n<html>\n <head>\n <title></title>\n <link rel=\"stylesheet\" href=\"static/uikit/css/uikit.min.css\" />\n <script src=\"static/uikit/js/jquery-1.11.1.min.js\"></script>\n <script src=\"static/uikit/js/uikit.min.js\"></script>\n <script src=\"static/uikit/js/Chart.min.js\"></script>\n </head>\n <body>\n <div class=\"uk-width-large-1-1 uk-container uk-container-center\">\n <div class=\"uk-width-large-1-1 uk-margin-large-top\"> </div>\n <form class=\"uk-form\">\n <legend> <h1 class=\"uk-text-primary\"> {{ title }} </h1> </legend>\n <div>\n <canvas id=\"myChart\" width=\"400\" height=\"400\"></canvas>\n </div>\n </form>",
" <script>\n$(document).ready(function(){\n var ctx = $(\"#myChart\").get(0).getContext(\"2d\"); \n var data = [\n {% for item in opts %}\n {label: \"{{ item[0] }}\", value: {{ item[1] }}, color:\"{{ item[2] }}\"},\n {% endfor %}\n ];",
" var myPieChart = new Chart(ctx).Pie(data,{animationSteps: 60});",
" \n function diff_rows(old_, new_){\n n_o = old_.length;\n n_n = new_.length;\n if(n_o != n_n)\n return 1;\n for (var i = n_o - 1; i >= 0; i--) {\n for (var j = n_n - 1; j >= 0; j--) {\n if(old_[i].color != new_[j].color)\n continue;\n if(old_[i].value != new_[j].value)\n return 1;\n };\n };\n return 0;\n };",
" timeout = [3,4,6,9,14,22,35,56,90,145];\n idx_timeout = 0;",
" function refresh(myChart){",
" var p_id = location.search.substring(1).split('=')[1];\n var p_ajax = {\n type: \"POST\",\n dataType: \"json\",\n url: \"/refresh\",\n data: {\"p_id\":p_id},\n ret: 0,\n success: function(d){\n rows = d.rows;\n if (diff_rows(data, rows) == 1){\n data = rows;",
" myChart.destroy();\n myPieChart = new Chart(ctx).Pie(data,{animation: false});",
" this.ret = 1;\n }",
" this.ret = 0;",
" },\n error: function(e,b,c){\n alert(\"ajax error function.\");\n },\n complete: function(){\n if (this.ret != 0) idx_timeout=0; else idx_timeout++;\n if (idx_timeout >= timeout.length) return;\n setTimeout(refresh, timeout[idx_timeout]*1000);\n }\n };\n $.ajax(p_ajax);\n };",
" setTimeout(refresh, 3000);\n});\n </script>\n </div>\n </body>\n</html>"
] |
[
1,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [126, 65], "buggy_code_start_loc": [39, 28], "filenames": ["app.py", "templates/show.html"], "fixing_code_end_loc": [124, 66], "fixing_code_start_loc": [38, 28], "message": "A vulnerability was found in mapoor voteapp. It has been rated as critical. Affected by this issue is the function create_poll/do_poll/show_poll/show_refresh of the file app.py. The manipulation leads to sql injection. The name of the patch is b290c21a0d8bcdbd55db860afd3cadec97388e72. It is recommended to apply a patch to fix this issue. VDB-217790 is the identifier assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:voteapp_project:voteapp:*:*:*:*:*:*:*:*", "matchCriteriaId": "182EB143-B57B-4E00-8D49-0F2791E54600", "versionEndExcluding": "2014-12-30", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability was found in mapoor voteapp. It has been rated as critical. Affected by this issue is the function create_poll/do_poll/show_poll/show_refresh of the file app.py. The manipulation leads to sql injection. The name of the patch is b290c21a0d8bcdbd55db860afd3cadec97388e72. It is recommended to apply a patch to fix this issue. VDB-217790 is the identifier assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2014-125073", "lastModified": "2023-01-14T21:28:10.233", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "SINGLE", "availabilityImpact": "PARTIAL", "baseScore": 5.2, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:S/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 5.1, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 2.1, "impactScore": 3.4, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-10T16:15:10.657", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/mapoor/voteapp/commit/b290c21a0d8bcdbd55db860afd3cadec97388e72"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217790"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217790"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "cna@vuldb.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/mapoor/voteapp/commit/b290c21a0d8bcdbd55db860afd3cadec97388e72"}, "type": "CWE-89"}
| 368
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<!DOCTYPE html>\n<html>\n <head>\n <title></title>\n <link rel=\"stylesheet\" href=\"static/uikit/css/uikit.min.css\" />\n <script src=\"static/uikit/js/jquery-1.11.1.min.js\"></script>\n <script src=\"static/uikit/js/uikit.min.js\"></script>\n <script src=\"static/uikit/js/Chart.min.js\"></script>\n </head>\n <body>\n <div class=\"uk-width-large-1-1 uk-container uk-container-center\">\n <div class=\"uk-width-large-1-1 uk-margin-large-top\"> </div>\n <form class=\"uk-form\">\n <legend> <h1 class=\"uk-text-primary\"> {{ title }} </h1> </legend>\n <div>\n <canvas id=\"myChart\" width=\"400\" height=\"400\"></canvas>\n </div>\n </form>",
" <script>\n$(document).ready(function(){\n var ctx = $(\"#myChart\").get(0).getContext(\"2d\"); \n var data = [\n {% for item in opts %}\n {label: \"{{ item[0] }}\", value: {{ item[1] }}, color:\"{{ item[2] }}\"},\n {% endfor %}\n ];",
" var pie_chart = new Chart(ctx).Pie(data,{animationSteps: 60});",
" \n function diff_rows(old_, new_){\n n_o = old_.length;\n n_n = new_.length;\n if(n_o != n_n)\n return 1;\n for (var i = n_o - 1; i >= 0; i--) {\n for (var j = n_n - 1; j >= 0; j--) {\n if(old_[i].color != new_[j].color)\n continue;\n if(old_[i].value != new_[j].value)\n return 1;\n };\n };\n return 0;\n };",
" timeout = [3,4,6,9,14,22,35,56,90,145];\n idx_timeout = 0;",
" function refresh(){",
" var p_id = location.search.substring(1).split('=')[1];\n var p_ajax = {\n type: \"POST\",\n dataType: \"json\",\n url: \"/refresh\",\n data: {\"p_id\":p_id},\n ret: 0,\n success: function(d){\n rows = d.rows;\n if (diff_rows(data, rows) == 1){\n data = rows;",
" pie_chart.destroy();\n pie_chart = new Chart(ctx).Pie(data,{animation: false});",
" this.ret = 1;\n }",
" else\n this.ret = 0;",
" },\n error: function(e,b,c){\n alert(\"ajax error function.\");\n },\n complete: function(){\n if (this.ret != 0) idx_timeout=0; else idx_timeout++;\n if (idx_timeout >= timeout.length) return;\n setTimeout(refresh, timeout[idx_timeout]*1000);\n }\n };\n $.ajax(p_ajax);\n };",
" setTimeout(refresh, 3000);\n});\n </script>\n </div>\n </body>\n</html>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [126, 65], "buggy_code_start_loc": [39, 28], "filenames": ["app.py", "templates/show.html"], "fixing_code_end_loc": [124, 66], "fixing_code_start_loc": [38, 28], "message": "A vulnerability was found in mapoor voteapp. It has been rated as critical. Affected by this issue is the function create_poll/do_poll/show_poll/show_refresh of the file app.py. The manipulation leads to sql injection. The name of the patch is b290c21a0d8bcdbd55db860afd3cadec97388e72. It is recommended to apply a patch to fix this issue. VDB-217790 is the identifier assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:voteapp_project:voteapp:*:*:*:*:*:*:*:*", "matchCriteriaId": "182EB143-B57B-4E00-8D49-0F2791E54600", "versionEndExcluding": "2014-12-30", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability was found in mapoor voteapp. It has been rated as critical. Affected by this issue is the function create_poll/do_poll/show_poll/show_refresh of the file app.py. The manipulation leads to sql injection. The name of the patch is b290c21a0d8bcdbd55db860afd3cadec97388e72. It is recommended to apply a patch to fix this issue. VDB-217790 is the identifier assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2014-125073", "lastModified": "2023-01-14T21:28:10.233", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "SINGLE", "availabilityImpact": "PARTIAL", "baseScore": 5.2, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:S/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 5.1, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 2.1, "impactScore": 3.4, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-10T16:15:10.657", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/mapoor/voteapp/commit/b290c21a0d8bcdbd55db860afd3cadec97388e72"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217790"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217790"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "cna@vuldb.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/mapoor/voteapp/commit/b290c21a0d8bcdbd55db860afd3cadec97388e72"}, "type": "CWE-89"}
| 368
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\n##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * This is the class expRatingController\n *\n * @package Core\n * @subpackage Controllers\n */",
"class expRatingController extends expController {\n public $base_class = 'expRating';",
" static function displayname() { return gt(\"Ratings Manager\"); }\n static function description() { return gt(\"This module is for managing ratings on records\"); }\n static function hasSources() { return false; }",
"\t",
"\tfunction __construct($src=null, $params=array()) {\n global $user;\n\t parent::__construct($src, $params);\n $this->remove_permissions = ($user->isLoggedIn())?array('update','create'):array();\n }",
" /**\n * Update rating...handled via ajax\n */\n function update() {\n global $db, $user;",
" \t",
" $this->params['id'] = $db->selectValue('content_expRatings','expratings_id',\"content_id='\".$this->params['content_id'].\"' AND content_type='\".$this->params['content_type'].\"' AND subtype='\".$this->params['subtype'].\"' AND poster='\".$user->id.\"'\");\n $msg = gt('Thank you for your rating');\n $rating = new expRating($this->params);\n if (!empty($rating->id)) $msg = gt('Your rating has been adjusted');\n // save the rating\n $rating->update($this->params);",
" // attach the rating to the datatype it belongs to (blog, news, etc..);\n $obj = new stdClass();\n\t\t$obj->content_type = $this->params['content_type'];\n\t\t$obj->content_id = $this->params['content_id'];\n\t\t$obj->expratings_id = $rating->id;\n\t\t$obj->poster = $rating->poster;\n\t\tif(isset($this->params['subtype'])) $obj->subtype = $this->params['subtype'];\n\t\t$db->insertObject($obj, $rating->attachable_table);",
" $ar = new expAjaxReply(200,$msg);\n $ar->send();",
"\t\t",
" // flash('message', $msg);\n // expHistory::back();\n\t}",
"\t",
"}",
"?>"
] |
[
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
1,
0,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [67], "buggy_code_start_loc": [31], "filenames": ["framework/modules/core/controllers/expRatingController.php"], "fixing_code_end_loc": [69], "fixing_code_start_loc": [31], "message": "Multiple SQL injection vulnerabilities in the update method in framework/modules/core/controllers/expRatingController.php in Exponent CMS 2.4.0 allow remote authenticated users to execute arbitrary SQL commands via the (1) content_type or (2) subtype parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:2.4.0:*:*:*:*:*:*:*", "matchCriteriaId": "CFEAA82F-83B2-49B8-B860-2F18C3C66321", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Multiple SQL injection vulnerabilities in the update method in framework/modules/core/controllers/expRatingController.php in Exponent CMS 2.4.0 allow remote authenticated users to execute arbitrary SQL commands via the (1) content_type or (2) subtype parameter."}, {"lang": "es", "value": "M\u00faltiples vulnerabilidades de inyecci\u00f3n SQL en el m\u00e9todo de actualizaci\u00f3n en framework/modules/core/controllers/expRatingController.php en Exponent CMS 2.4.0 permiten a usuarios remotos autenticados ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro (1) content_type o (2) subtype."}], "evaluatorComment": null, "id": "CVE-2016-9242", "lastModified": "2016-11-29T18:23:30.043", "metrics": {"cvssMetricV2": [{"acInsufInfo": true, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "PARTIAL", "baseScore": 6.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:S/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 8.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2016-11-07T11:59:01.533", "references": [{"source": "cve@mitre.org", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/94194"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/6172f67620ac13fc2f4e9d650c61937d48e9ecb9"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/6172f67620ac13fc2f4e9d650c61937d48e9ecb9"}, "type": "CWE-89"}
| 369
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\n##################################################\n#\n# Copyright (c) 2004-2016 OIC Group, Inc.\n#\n# This file is part of Exponent\n#\n# Exponent is free software; you can redistribute\n# it and/or modify it under the terms of the GNU\n# General Public License as published by the Free\n# Software Foundation; either version 2 of the\n# License, or (at your option) any later version.\n#\n# GPL: http://www.gnu.org/licenses/gpl.txt\n#\n##################################################",
"/**\n * This is the class expRatingController\n *\n * @package Core\n * @subpackage Controllers\n */",
"class expRatingController extends expController {\n public $base_class = 'expRating';",
" static function displayname() { return gt(\"Ratings Manager\"); }\n static function description() { return gt(\"This module is for managing ratings on records\"); }\n static function hasSources() { return false; }",
"",
"\tfunction __construct($src=null, $params=array()) {\n global $user;\n\t parent::__construct($src, $params);\n $this->remove_permissions = ($user->isLoggedIn())?array('update','create'):array();\n }",
" /**\n * Update rating...handled via ajax\n */\n function update() {\n global $db, $user;",
"\n $this->params['content_type'] = preg_replace(\"/[^[:alnum:][:space:]]/u\", '', $this->params['content_type']);\n $this->params['subtype'] = preg_replace(\"/[^[:alnum:][:space:]]/u\", '', $this->params['subtype']);",
" $this->params['id'] = $db->selectValue('content_expRatings','expratings_id',\"content_id='\".$this->params['content_id'].\"' AND content_type='\".$this->params['content_type'].\"' AND subtype='\".$this->params['subtype'].\"' AND poster='\".$user->id.\"'\");\n $msg = gt('Thank you for your rating');\n $rating = new expRating($this->params);\n if (!empty($rating->id)) $msg = gt('Your rating has been adjusted');\n // save the rating\n $rating->update($this->params);",
" // attach the rating to the datatype it belongs to (blog, news, etc..);\n $obj = new stdClass();\n\t\t$obj->content_type = $this->params['content_type'];\n\t\t$obj->content_id = $this->params['content_id'];\n\t\t$obj->expratings_id = $rating->id;\n\t\t$obj->poster = $rating->poster;\n\t\tif(isset($this->params['subtype'])) $obj->subtype = $this->params['subtype'];\n\t\t$db->insertObject($obj, $rating->attachable_table);",
" $ar = new expAjaxReply(200,$msg);\n $ar->send();",
"",
" // flash('message', $msg);\n // expHistory::back();\n\t}",
"",
"}",
"?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [67], "buggy_code_start_loc": [31], "filenames": ["framework/modules/core/controllers/expRatingController.php"], "fixing_code_end_loc": [69], "fixing_code_start_loc": [31], "message": "Multiple SQL injection vulnerabilities in the update method in framework/modules/core/controllers/expRatingController.php in Exponent CMS 2.4.0 allow remote authenticated users to execute arbitrary SQL commands via the (1) content_type or (2) subtype parameter.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:exponentcms:exponent_cms:2.4.0:*:*:*:*:*:*:*", "matchCriteriaId": "CFEAA82F-83B2-49B8-B860-2F18C3C66321", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Multiple SQL injection vulnerabilities in the update method in framework/modules/core/controllers/expRatingController.php in Exponent CMS 2.4.0 allow remote authenticated users to execute arbitrary SQL commands via the (1) content_type or (2) subtype parameter."}, {"lang": "es", "value": "M\u00faltiples vulnerabilidades de inyecci\u00f3n SQL en el m\u00e9todo de actualizaci\u00f3n en framework/modules/core/controllers/expRatingController.php en Exponent CMS 2.4.0 permiten a usuarios remotos autenticados ejecutar comandos SQL arbitrarios a trav\u00e9s del par\u00e1metro (1) content_type o (2) subtype."}], "evaluatorComment": null, "id": "CVE-2016-9242", "lastModified": "2016-11-29T18:23:30.043", "metrics": {"cvssMetricV2": [{"acInsufInfo": true, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "PARTIAL", "baseScore": 6.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:S/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 8.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2016-11-07T11:59:01.533", "references": [{"source": "cve@mitre.org", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/94194"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/exponentcms/exponent-cms/commit/6172f67620ac13fc2f4e9d650c61937d48e9ecb9"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/exponentcms/exponent-cms/commit/6172f67620ac13fc2f4e9d650c61937d48e9ecb9"}, "type": "CWE-89"}
| 369
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * INET\t\tAn implementation of the TCP/IP protocol suite for the LINUX\n *\t\toperating system. INET is implemented using the BSD Socket\n *\t\tinterface as the means of communication with the user level.\n *\n *\t\tImplementation of the Transmission Control Protocol(TCP).\n *\n * Authors:\tRoss Biro\n *\t\tFred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>\n *\t\tMark Evans, <evansmp@uhura.aston.ac.uk>\n *\t\tCorey Minyard <wf-rch!minyard@relay.EU.net>\n *\t\tFlorian La Roche, <flla@stud.uni-sb.de>\n *\t\tCharles Hedrick, <hedrick@klinzhai.rutgers.edu>\n *\t\tLinus Torvalds, <torvalds@cs.helsinki.fi>\n *\t\tAlan Cox, <gw4pts@gw4pts.ampr.org>\n *\t\tMatthew Dillon, <dillon@apollo.west.oic.com>\n *\t\tArnt Gulbrandsen, <agulbra@nvg.unit.no>\n *\t\tJorge Cwik, <jorge@laser.satlink.net>\n *\n * Fixes:\n *\t\tAlan Cox\t:\tNumerous verify_area() calls\n *\t\tAlan Cox\t:\tSet the ACK bit on a reset\n *\t\tAlan Cox\t:\tStopped it crashing if it closed while\n *\t\t\t\t\tsk->inuse=1 and was trying to connect\n *\t\t\t\t\t(tcp_err()).\n *\t\tAlan Cox\t:\tAll icmp error handling was broken\n *\t\t\t\t\tpointers passed where wrong and the\n *\t\t\t\t\tsocket was looked up backwards. Nobody\n *\t\t\t\t\ttested any icmp error code obviously.\n *\t\tAlan Cox\t:\ttcp_err() now handled properly. It\n *\t\t\t\t\twakes people on errors. poll\n *\t\t\t\t\tbehaves and the icmp error race\n *\t\t\t\t\thas gone by moving it into sock.c\n *\t\tAlan Cox\t:\ttcp_send_reset() fixed to work for\n *\t\t\t\t\teverything not just packets for\n *\t\t\t\t\tunknown sockets.\n *\t\tAlan Cox\t:\ttcp option processing.\n *\t\tAlan Cox\t:\tReset tweaked (still not 100%) [Had\n *\t\t\t\t\tsyn rule wrong]\n *\t\tHerp Rosmanith :\tMore reset fixes\n *\t\tAlan Cox\t:\tNo longer acks invalid rst frames.\n *\t\t\t\t\tAcking any kind of RST is right out.\n *\t\tAlan Cox\t:\tSets an ignore me flag on an rst\n *\t\t\t\t\treceive otherwise odd bits of prattle\n *\t\t\t\t\tescape still\n *\t\tAlan Cox\t:\tFixed another acking RST frame bug.\n *\t\t\t\t\tShould stop LAN workplace lockups.\n *\t\tAlan Cox\t: \tSome tidyups using the new skb list\n *\t\t\t\t\tfacilities\n *\t\tAlan Cox\t:\tsk->keepopen now seems to work\n *\t\tAlan Cox\t:\tPulls options out correctly on accepts\n *\t\tAlan Cox\t:\tFixed assorted sk->rqueue->next errors\n *\t\tAlan Cox\t:\tPSH doesn't end a TCP read. Switched a\n *\t\t\t\t\tbit to skb ops.\n *\t\tAlan Cox\t:\tTidied tcp_data to avoid a potential\n *\t\t\t\t\tnasty.\n *\t\tAlan Cox\t:\tAdded some better commenting, as the\n *\t\t\t\t\ttcp is hard to follow\n *\t\tAlan Cox\t:\tRemoved incorrect check for 20 * psh\n *\tMichael O'Reilly\t:\tack < copied bug fix.\n *\tJohannes Stille\t\t:\tMisc tcp fixes (not all in yet).\n *\t\tAlan Cox\t:\tFIN with no memory -> CRASH\n *\t\tAlan Cox\t:\tAdded socket option proto entries.\n *\t\t\t\t\tAlso added awareness of them to accept.\n *\t\tAlan Cox\t:\tAdded TCP options (SOL_TCP)\n *\t\tAlan Cox\t:\tSwitched wakeup calls to callbacks,\n *\t\t\t\t\tso the kernel can layer network\n *\t\t\t\t\tsockets.\n *\t\tAlan Cox\t:\tUse ip_tos/ip_ttl settings.\n *\t\tAlan Cox\t:\tHandle FIN (more) properly (we hope).\n *\t\tAlan Cox\t:\tRST frames sent on unsynchronised\n *\t\t\t\t\tstate ack error.\n *\t\tAlan Cox\t:\tPut in missing check for SYN bit.\n *\t\tAlan Cox\t:\tAdded tcp_select_window() aka NET2E\n *\t\t\t\t\twindow non shrink trick.\n *\t\tAlan Cox\t:\tAdded a couple of small NET2E timer\n *\t\t\t\t\tfixes\n *\t\tCharles Hedrick :\tTCP fixes\n *\t\tToomas Tamm\t:\tTCP window fixes\n *\t\tAlan Cox\t:\tSmall URG fix to rlogin ^C ack fight\n *\t\tCharles Hedrick\t:\tRewrote most of it to actually work\n *\t\tLinus\t\t:\tRewrote tcp_read() and URG handling\n *\t\t\t\t\tcompletely\n *\t\tGerhard Koerting:\tFixed some missing timer handling\n *\t\tMatthew Dillon :\tReworked TCP machine states as per RFC\n *\t\tGerhard Koerting:\tPC/TCP workarounds\n *\t\tAdam Caldwell\t:\tAssorted timer/timing errors\n *\t\tMatthew Dillon\t:\tFixed another RST bug\n *\t\tAlan Cox\t:\tMove to kernel side addressing changes.\n *\t\tAlan Cox\t:\tBeginning work on TCP fastpathing\n *\t\t\t\t\t(not yet usable)\n *\t\tArnt Gulbrandsen:\tTurbocharged tcp_check() routine.\n *\t\tAlan Cox\t:\tTCP fast path debugging\n *\t\tAlan Cox\t:\tWindow clamping\n *\t\tMichael Riepe\t:\tBug in tcp_check()\n *\t\tMatt Dillon\t:\tMore TCP improvements and RST bug fixes\n *\t\tMatt Dillon\t:\tYet more small nasties remove from the\n *\t\t\t\t\tTCP code (Be very nice to this man if\n *\t\t\t\t\ttcp finally works 100%) 8)\n *\t\tAlan Cox\t:\tBSD accept semantics.\n *\t\tAlan Cox\t:\tReset on closedown bug.\n *\tPeter De Schrijver\t:\tENOTCONN check missing in tcp_sendto().\n *\t\tMichael Pall\t:\tHandle poll() after URG properly in\n *\t\t\t\t\tall cases.\n *\t\tMichael Pall\t:\tUndo the last fix in tcp_read_urg()\n *\t\t\t\t\t(multi URG PUSH broke rlogin).\n *\t\tMichael Pall\t:\tFix the multi URG PUSH problem in\n *\t\t\t\t\ttcp_readable(), poll() after URG\n *\t\t\t\t\tworks now.\n *\t\tMichael Pall\t:\trecv(...,MSG_OOB) never blocks in the\n *\t\t\t\t\tBSD api.\n *\t\tAlan Cox\t:\tChanged the semantics of sk->socket to\n *\t\t\t\t\tfix a race and a signal problem with\n *\t\t\t\t\taccept() and async I/O.\n *\t\tAlan Cox\t:\tRelaxed the rules on tcp_sendto().\n *\t\tYury Shevchuk\t:\tReally fixed accept() blocking problem.\n *\t\tCraig I. Hagan :\tAllow for BSD compatible TIME_WAIT for\n *\t\t\t\t\tclients/servers which listen in on\n *\t\t\t\t\tfixed ports.\n *\t\tAlan Cox\t:\tCleaned the above up and shrank it to\n *\t\t\t\t\ta sensible code size.\n *\t\tAlan Cox\t:\tSelf connect lockup fix.\n *\t\tAlan Cox\t:\tNo connect to multicast.\n *\t\tRoss Biro\t:\tClose unaccepted children on master\n *\t\t\t\t\tsocket close.\n *\t\tAlan Cox\t:\tReset tracing code.\n *\t\tAlan Cox\t:\tSpurious resets on shutdown.\n *\t\tAlan Cox\t:\tGiant 15 minute/60 second timer error\n *\t\tAlan Cox\t:\tSmall whoops in polling before an\n *\t\t\t\t\taccept.\n *\t\tAlan Cox\t:\tKept the state trace facility since\n *\t\t\t\t\tit's handy for debugging.\n *\t\tAlan Cox\t:\tMore reset handler fixes.\n *\t\tAlan Cox\t:\tStarted rewriting the code based on\n *\t\t\t\t\tthe RFC's for other useful protocol\n *\t\t\t\t\treferences see: Comer, KA9Q NOS, and\n *\t\t\t\t\tfor a reference on the difference\n *\t\t\t\t\tbetween specifications and how BSD\n *\t\t\t\t\tworks see the 4.4lite source.\n *\t\tA.N.Kuznetsov\t:\tDon't time wait on completion of tidy\n *\t\t\t\t\tclose.\n *\t\tLinus Torvalds\t:\tFin/Shutdown & copied_seq changes.\n *\t\tLinus Torvalds\t:\tFixed BSD port reuse to work first syn\n *\t\tAlan Cox\t:\tReimplemented timers as per the RFC\n *\t\t\t\t\tand using multiple timers for sanity.\n *\t\tAlan Cox\t:\tSmall bug fixes, and a lot of new\n *\t\t\t\t\tcomments.\n *\t\tAlan Cox\t:\tFixed dual reader crash by locking\n *\t\t\t\t\tthe buffers (much like datagram.c)\n *\t\tAlan Cox\t:\tFixed stuck sockets in probe. A probe\n *\t\t\t\t\tnow gets fed up of retrying without\n *\t\t\t\t\t(even a no space) answer.\n *\t\tAlan Cox\t:\tExtracted closing code better\n *\t\tAlan Cox\t:\tFixed the closing state machine to\n *\t\t\t\t\tresemble the RFC.\n *\t\tAlan Cox\t:\tMore 'per spec' fixes.\n *\t\tJorge Cwik\t:\tEven faster checksumming.\n *\t\tAlan Cox\t:\ttcp_data() doesn't ack illegal PSH\n *\t\t\t\t\tonly frames. At least one pc tcp stack\n *\t\t\t\t\tgenerates them.\n *\t\tAlan Cox\t:\tCache last socket.\n *\t\tAlan Cox\t:\tPer route irtt.\n *\t\tMatt Day\t:\tpoll()->select() match BSD precisely on error\n *\t\tAlan Cox\t:\tNew buffers\n *\t\tMarc Tamsky\t:\tVarious sk->prot->retransmits and\n *\t\t\t\t\tsk->retransmits misupdating fixed.\n *\t\t\t\t\tFixed tcp_write_timeout: stuck close,\n *\t\t\t\t\tand TCP syn retries gets used now.\n *\t\tMark Yarvis\t:\tIn tcp_read_wakeup(), don't send an\n *\t\t\t\t\tack if state is TCP_CLOSED.\n *\t\tAlan Cox\t:\tLook up device on a retransmit - routes may\n *\t\t\t\t\tchange. Doesn't yet cope with MSS shrink right\n *\t\t\t\t\tbut it's a start!\n *\t\tMarc Tamsky\t:\tClosing in closing fixes.\n *\t\tMike Shaver\t:\tRFC1122 verifications.\n *\t\tAlan Cox\t:\trcv_saddr errors.\n *\t\tAlan Cox\t:\tBlock double connect().\n *\t\tAlan Cox\t:\tSmall hooks for enSKIP.\n *\t\tAlexey Kuznetsov:\tPath MTU discovery.\n *\t\tAlan Cox\t:\tSupport soft errors.\n *\t\tAlan Cox\t:\tFix MTU discovery pathological case\n *\t\t\t\t\twhen the remote claims no mtu!\n *\t\tMarc Tamsky\t:\tTCP_CLOSE fix.\n *\t\tColin (G3TNE)\t:\tSend a reset on syn ack replies in\n *\t\t\t\t\twindow but wrong (fixes NT lpd problems)\n *\t\tPedro Roque\t:\tBetter TCP window handling, delayed ack.\n *\t\tJoerg Reuter\t:\tNo modification of locked buffers in\n *\t\t\t\t\ttcp_do_retransmit()\n *\t\tEric Schenk\t:\tChanged receiver side silly window\n *\t\t\t\t\tavoidance algorithm to BSD style\n *\t\t\t\t\talgorithm. This doubles throughput\n *\t\t\t\t\tagainst machines running Solaris,\n *\t\t\t\t\tand seems to result in general\n *\t\t\t\t\timprovement.\n *\tStefan Magdalinski\t:\tadjusted tcp_readable() to fix FIONREAD\n *\tWilly Konynenberg\t:\tTransparent proxying support.\n *\tMike McLagan\t\t:\tRouting by source\n *\t\tKeith Owens\t:\tDo proper merging with partial SKB's in\n *\t\t\t\t\ttcp_do_sendmsg to avoid burstiness.\n *\t\tEric Schenk\t:\tFix fast close down bug with\n *\t\t\t\t\tshutdown() followed by close().\n *\t\tAndi Kleen \t:\tMake poll agree with SIGIO\n *\tSalvatore Sanfilippo\t:\tSupport SO_LINGER with linger == 1 and\n *\t\t\t\t\tlingertime == 0 (RFC 793 ABORT Call)\n *\tHirokazu Takahashi\t:\tUse copy_from_user() instead of\n *\t\t\t\t\tcsum_and_copy_from_user() if possible.\n *\n *\t\tThis program is free software; you can redistribute it and/or\n *\t\tmodify it under the terms of the GNU General Public License\n *\t\tas published by the Free Software Foundation; either version\n *\t\t2 of the License, or(at your option) any later version.\n *\n * Description of States:\n *\n *\tTCP_SYN_SENT\t\tsent a connection request, waiting for ack\n *\n *\tTCP_SYN_RECV\t\treceived a connection request, sent ack,\n *\t\t\t\twaiting for final ack in three-way handshake.\n *\n *\tTCP_ESTABLISHED\t\tconnection established\n *\n *\tTCP_FIN_WAIT1\t\tour side has shutdown, waiting to complete\n *\t\t\t\ttransmission of remaining buffered data\n *\n *\tTCP_FIN_WAIT2\t\tall buffered data sent, waiting for remote\n *\t\t\t\tto shutdown\n *\n *\tTCP_CLOSING\t\tboth sides have shutdown but we still have\n *\t\t\t\tdata we have to finish sending\n *\n *\tTCP_TIME_WAIT\t\ttimeout to catch resent junk before entering\n *\t\t\t\tclosed, can only be entered from FIN_WAIT2\n *\t\t\t\tor CLOSING. Required because the other end\n *\t\t\t\tmay not have gotten our last ACK causing it\n *\t\t\t\tto retransmit the data packet (which we ignore)\n *\n *\tTCP_CLOSE_WAIT\t\tremote side has shutdown and is waiting for\n *\t\t\t\tus to finish writing our data and to shutdown\n *\t\t\t\t(we have to close() to move on to LAST_ACK)\n *\n *\tTCP_LAST_ACK\t\tout side has shutdown after remote has\n *\t\t\t\tshutdown. There may still be data in our\n *\t\t\t\tbuffer that we have to finish sending\n *\n *\tTCP_CLOSE\t\tsocket is finished\n */",
"#define pr_fmt(fmt) \"TCP: \" fmt",
"#include <crypto/hash.h>\n#include <linux/kernel.h>\n#include <linux/module.h>\n#include <linux/types.h>\n#include <linux/fcntl.h>\n#include <linux/poll.h>\n#include <linux/inet_diag.h>\n#include <linux/init.h>\n#include <linux/fs.h>\n#include <linux/skbuff.h>\n#include <linux/scatterlist.h>\n#include <linux/splice.h>\n#include <linux/net.h>\n#include <linux/socket.h>\n#include <linux/random.h>\n#include <linux/bootmem.h>\n#include <linux/highmem.h>\n#include <linux/swap.h>\n#include <linux/cache.h>\n#include <linux/err.h>\n#include <linux/time.h>\n#include <linux/slab.h>",
"#include <net/icmp.h>\n#include <net/inet_common.h>\n#include <net/tcp.h>\n#include <net/xfrm.h>\n#include <net/ip.h>\n#include <net/sock.h>",
"#include <linux/uaccess.h>\n#include <asm/ioctls.h>\n#include <net/busy_poll.h>",
"int sysctl_tcp_min_tso_segs __read_mostly = 2;",
"int sysctl_tcp_autocorking __read_mostly = 1;",
"struct percpu_counter tcp_orphan_count;\nEXPORT_SYMBOL_GPL(tcp_orphan_count);",
"long sysctl_tcp_mem[3] __read_mostly;\nint sysctl_tcp_wmem[3] __read_mostly;\nint sysctl_tcp_rmem[3] __read_mostly;",
"EXPORT_SYMBOL(sysctl_tcp_mem);\nEXPORT_SYMBOL(sysctl_tcp_rmem);\nEXPORT_SYMBOL(sysctl_tcp_wmem);",
"atomic_long_t tcp_memory_allocated;\t/* Current allocated memory. */\nEXPORT_SYMBOL(tcp_memory_allocated);",
"/*\n * Current number of TCP sockets.\n */\nstruct percpu_counter tcp_sockets_allocated;\nEXPORT_SYMBOL(tcp_sockets_allocated);",
"/*\n * TCP splice context\n */\nstruct tcp_splice_state {\n\tstruct pipe_inode_info *pipe;\n\tsize_t len;\n\tunsigned int flags;\n};",
"/*\n * Pressure flag: try to collapse.\n * Technical note: it is used by multiple contexts non atomically.\n * All the __sk_mem_schedule() is of this nature: accounting\n * is strict, actions are advisory and have some latency.\n */\nint tcp_memory_pressure __read_mostly;\nEXPORT_SYMBOL(tcp_memory_pressure);",
"void tcp_enter_memory_pressure(struct sock *sk)\n{\n\tif (!tcp_memory_pressure) {\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMEMORYPRESSURES);\n\t\ttcp_memory_pressure = 1;\n\t}\n}\nEXPORT_SYMBOL(tcp_enter_memory_pressure);",
"/* Convert seconds to retransmits based on initial and max timeout */\nstatic u8 secs_to_retrans(int seconds, int timeout, int rto_max)\n{\n\tu8 res = 0;",
"\tif (seconds > 0) {\n\t\tint period = timeout;",
"\t\tres = 1;\n\t\twhile (seconds > period && res < 255) {\n\t\t\tres++;\n\t\t\ttimeout <<= 1;\n\t\t\tif (timeout > rto_max)\n\t\t\t\ttimeout = rto_max;\n\t\t\tperiod += timeout;\n\t\t}\n\t}\n\treturn res;\n}",
"/* Convert retransmits to seconds based on initial and max timeout */\nstatic int retrans_to_secs(u8 retrans, int timeout, int rto_max)\n{\n\tint period = 0;",
"\tif (retrans > 0) {\n\t\tperiod = timeout;\n\t\twhile (--retrans) {\n\t\t\ttimeout <<= 1;\n\t\t\tif (timeout > rto_max)\n\t\t\t\ttimeout = rto_max;\n\t\t\tperiod += timeout;\n\t\t}\n\t}\n\treturn period;\n}",
"/* Address-family independent initialization for a tcp_sock.\n *\n * NOTE: A lot of things set to zero explicitly by call to\n * sk_alloc() so need not be done here.\n */\nvoid tcp_init_sock(struct sock *sk)\n{\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct tcp_sock *tp = tcp_sk(sk);",
"\ttp->out_of_order_queue = RB_ROOT;\n\ttcp_init_xmit_timers(sk);\n\ttcp_prequeue_init(tp);\n\tINIT_LIST_HEAD(&tp->tsq_node);",
"\ticsk->icsk_rto = TCP_TIMEOUT_INIT;\n\ttp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);\n\tminmax_reset(&tp->rtt_min, tcp_time_stamp, ~0U);",
"\t/* So many TCP implementations out there (incorrectly) count the\n\t * initial SYN frame in their delayed-ACK and congestion control\n\t * algorithms that we must have the following bandaid to talk\n\t * efficiently to them. -DaveM\n\t */\n\ttp->snd_cwnd = TCP_INIT_CWND;",
"\t/* There's a bubble in the pipe until at least the first ACK. */\n\ttp->app_limited = ~0U;",
"\t/* See draft-stevens-tcpca-spec-01 for discussion of the\n\t * initialization of these values.\n\t */\n\ttp->snd_ssthresh = TCP_INFINITE_SSTHRESH;\n\ttp->snd_cwnd_clamp = ~0;\n\ttp->mss_cache = TCP_MSS_DEFAULT;",
"\ttp->reordering = sock_net(sk)->ipv4.sysctl_tcp_reordering;\n\ttcp_assign_congestion_control(sk);",
"\ttp->tsoffset = 0;",
"\tsk->sk_state = TCP_CLOSE;",
"\tsk->sk_write_space = sk_stream_write_space;\n\tsock_set_flag(sk, SOCK_USE_WRITE_QUEUE);",
"\ticsk->icsk_sync_mss = tcp_sync_mss;",
"\tsk->sk_sndbuf = sysctl_tcp_wmem[1];\n\tsk->sk_rcvbuf = sysctl_tcp_rmem[1];",
"\tsk_sockets_allocated_inc(sk);\n}\nEXPORT_SYMBOL(tcp_init_sock);",
"static void tcp_tx_timestamp(struct sock *sk, u16 tsflags, struct sk_buff *skb)\n{\n\tif (tsflags && skb) {\n\t\tstruct skb_shared_info *shinfo = skb_shinfo(skb);\n\t\tstruct tcp_skb_cb *tcb = TCP_SKB_CB(skb);",
"\t\tsock_tx_timestamp(sk, tsflags, &shinfo->tx_flags);\n\t\tif (tsflags & SOF_TIMESTAMPING_TX_ACK)\n\t\t\ttcb->txstamp_ack = 1;\n\t\tif (tsflags & SOF_TIMESTAMPING_TX_RECORD_MASK)\n\t\t\tshinfo->tskey = TCP_SKB_CB(skb)->seq + skb->len - 1;\n\t}\n}",
"/*\n *\tWait for a TCP event.\n *\n *\tNote that we don't need to lock the socket, as the upper poll layers\n *\ttake care of normal races (between the test and the event) and we don't\n *\tgo look at any of the socket buffers directly.\n */\nunsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)\n{\n\tunsigned int mask;\n\tstruct sock *sk = sock->sk;\n\tconst struct tcp_sock *tp = tcp_sk(sk);\n\tint state;",
"\tsock_rps_record_flow(sk);",
"\tsock_poll_wait(file, sk_sleep(sk), wait);",
"\tstate = sk_state_load(sk);\n\tif (state == TCP_LISTEN)\n\t\treturn inet_csk_listen_poll(sk);",
"\t/* Socket is not locked. We are protected from async events\n\t * by poll logic and correct handling of state changes\n\t * made by other threads is impossible in any case.\n\t */",
"\tmask = 0;",
"\t/*\n\t * POLLHUP is certainly not done right. But poll() doesn't\n\t * have a notion of HUP in just one direction, and for a\n\t * socket the read side is more interesting.\n\t *\n\t * Some poll() documentation says that POLLHUP is incompatible\n\t * with the POLLOUT/POLLWR flags, so somebody should check this\n\t * all. But careful, it tends to be safer to return too many\n\t * bits than too few, and you can easily break real applications\n\t * if you don't tell them that something has hung up!\n\t *\n\t * Check-me.\n\t *\n\t * Check number 1. POLLHUP is _UNMASKABLE_ event (see UNIX98 and\n\t * our fs/select.c). It means that after we received EOF,\n\t * poll always returns immediately, making impossible poll() on write()\n\t * in state CLOSE_WAIT. One solution is evident --- to set POLLHUP\n\t * if and only if shutdown has been made in both directions.\n\t * Actually, it is interesting to look how Solaris and DUX\n\t * solve this dilemma. I would prefer, if POLLHUP were maskable,\n\t * then we could set it on SND_SHUTDOWN. BTW examples given\n\t * in Stevens' books assume exactly this behaviour, it explains\n\t * why POLLHUP is incompatible with POLLOUT.\t--ANK\n\t *\n\t * NOTE. Check for TCP_CLOSE is added. The goal is to prevent\n\t * blocking on fresh not-connected or disconnected socket. --ANK\n\t */\n\tif (sk->sk_shutdown == SHUTDOWN_MASK || state == TCP_CLOSE)\n\t\tmask |= POLLHUP;\n\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\tmask |= POLLIN | POLLRDNORM | POLLRDHUP;",
"\t/* Connected or passive Fast Open socket? */\n\tif (state != TCP_SYN_SENT &&\n\t (state != TCP_SYN_RECV || tp->fastopen_rsk)) {\n\t\tint target = sock_rcvlowat(sk, 0, INT_MAX);",
"\t\tif (tp->urg_seq == tp->copied_seq &&\n\t\t !sock_flag(sk, SOCK_URGINLINE) &&\n\t\t tp->urg_data)\n\t\t\ttarget++;",
"\t\tif (tp->rcv_nxt - tp->copied_seq >= target)\n\t\t\tmask |= POLLIN | POLLRDNORM;",
"\t\tif (!(sk->sk_shutdown & SEND_SHUTDOWN)) {\n\t\t\tif (sk_stream_is_writeable(sk)) {\n\t\t\t\tmask |= POLLOUT | POLLWRNORM;\n\t\t\t} else { /* send SIGIO later */\n\t\t\t\tsk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);\n\t\t\t\tset_bit(SOCK_NOSPACE, &sk->sk_socket->flags);",
"\t\t\t\t/* Race breaker. If space is freed after\n\t\t\t\t * wspace test but before the flags are set,\n\t\t\t\t * IO signal will be lost. Memory barrier\n\t\t\t\t * pairs with the input side.\n\t\t\t\t */\n\t\t\t\tsmp_mb__after_atomic();\n\t\t\t\tif (sk_stream_is_writeable(sk))\n\t\t\t\t\tmask |= POLLOUT | POLLWRNORM;\n\t\t\t}\n\t\t} else\n\t\t\tmask |= POLLOUT | POLLWRNORM;",
"\t\tif (tp->urg_data & TCP_URG_VALID)\n\t\t\tmask |= POLLPRI;\n\t} else if (state == TCP_SYN_SENT && inet_sk(sk)->defer_connect) {\n\t\t/* Active TCP fastopen socket with defer_connect\n\t\t * Return POLLOUT so application can call write()\n\t\t * in order for kernel to generate SYN+data\n\t\t */\n\t\tmask |= POLLOUT | POLLWRNORM;\n\t}\n\t/* This barrier is coupled with smp_wmb() in tcp_reset() */\n\tsmp_rmb();\n\tif (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))\n\t\tmask |= POLLERR;",
"\treturn mask;\n}\nEXPORT_SYMBOL(tcp_poll);",
"int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint answ;\n\tbool slow;",
"\tswitch (cmd) {\n\tcase SIOCINQ:\n\t\tif (sk->sk_state == TCP_LISTEN)\n\t\t\treturn -EINVAL;",
"\t\tslow = lock_sock_fast(sk);\n\t\tansw = tcp_inq(sk);\n\t\tunlock_sock_fast(sk, slow);\n\t\tbreak;\n\tcase SIOCATMARK:\n\t\tansw = tp->urg_data && tp->urg_seq == tp->copied_seq;\n\t\tbreak;\n\tcase SIOCOUTQ:\n\t\tif (sk->sk_state == TCP_LISTEN)\n\t\t\treturn -EINVAL;",
"\t\tif ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))\n\t\t\tansw = 0;\n\t\telse\n\t\t\tansw = tp->write_seq - tp->snd_una;\n\t\tbreak;\n\tcase SIOCOUTQNSD:\n\t\tif (sk->sk_state == TCP_LISTEN)\n\t\t\treturn -EINVAL;",
"\t\tif ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))\n\t\t\tansw = 0;\n\t\telse\n\t\t\tansw = tp->write_seq - tp->snd_nxt;\n\t\tbreak;\n\tdefault:\n\t\treturn -ENOIOCTLCMD;\n\t}",
"\treturn put_user(answ, (int __user *)arg);\n}\nEXPORT_SYMBOL(tcp_ioctl);",
"static inline void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb)\n{\n\tTCP_SKB_CB(skb)->tcp_flags |= TCPHDR_PSH;\n\ttp->pushed_seq = tp->write_seq;\n}",
"static inline bool forced_push(const struct tcp_sock *tp)\n{\n\treturn after(tp->write_seq, tp->pushed_seq + (tp->max_window >> 1));\n}",
"static void skb_entail(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct tcp_skb_cb *tcb = TCP_SKB_CB(skb);",
"\tskb->csum = 0;\n\ttcb->seq = tcb->end_seq = tp->write_seq;\n\ttcb->tcp_flags = TCPHDR_ACK;\n\ttcb->sacked = 0;\n\t__skb_header_release(skb);\n\ttcp_add_write_queue_tail(sk, skb);\n\tsk->sk_wmem_queued += skb->truesize;\n\tsk_mem_charge(sk, skb->truesize);\n\tif (tp->nonagle & TCP_NAGLE_PUSH)\n\t\ttp->nonagle &= ~TCP_NAGLE_PUSH;",
"\ttcp_slow_start_after_idle_check(sk);\n}",
"static inline void tcp_mark_urg(struct tcp_sock *tp, int flags)\n{\n\tif (flags & MSG_OOB)\n\t\ttp->snd_up = tp->write_seq;\n}",
"/* If a not yet filled skb is pushed, do not send it if\n * we have data packets in Qdisc or NIC queues :\n * Because TX completion will happen shortly, it gives a chance\n * to coalesce future sendmsg() payload into this skb, without\n * need for a timer, and with no latency trade off.\n * As packets containing data payload have a bigger truesize\n * than pure acks (dataless) packets, the last checks prevent\n * autocorking if we only have an ACK in Qdisc/NIC queues,\n * or if TX completion was delayed after we processed ACK packet.\n */\nstatic bool tcp_should_autocork(struct sock *sk, struct sk_buff *skb,\n\t\t\t\tint size_goal)\n{\n\treturn skb->len < size_goal &&\n\t sysctl_tcp_autocorking &&\n\t skb != tcp_write_queue_head(sk) &&\n\t atomic_read(&sk->sk_wmem_alloc) > skb->truesize;\n}",
"static void tcp_push(struct sock *sk, int flags, int mss_now,\n\t\t int nonagle, int size_goal)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct sk_buff *skb;",
"\tif (!tcp_send_head(sk))\n\t\treturn;",
"\tskb = tcp_write_queue_tail(sk);\n\tif (!(flags & MSG_MORE) || forced_push(tp))\n\t\ttcp_mark_push(tp, skb);",
"\ttcp_mark_urg(tp, flags);",
"\tif (tcp_should_autocork(sk, skb, size_goal)) {",
"\t\t/* avoid atomic op if TSQ_THROTTLED bit is already set */\n\t\tif (!test_bit(TSQ_THROTTLED, &sk->sk_tsq_flags)) {\n\t\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAUTOCORKING);\n\t\t\tset_bit(TSQ_THROTTLED, &sk->sk_tsq_flags);\n\t\t}\n\t\t/* It is possible TX completion already happened\n\t\t * before we set TSQ_THROTTLED.\n\t\t */\n\t\tif (atomic_read(&sk->sk_wmem_alloc) > skb->truesize)\n\t\t\treturn;\n\t}",
"\tif (flags & MSG_MORE)\n\t\tnonagle = TCP_NAGLE_CORK;",
"\t__tcp_push_pending_frames(sk, mss_now, nonagle);\n}",
"static int tcp_splice_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,\n\t\t\t\tunsigned int offset, size_t len)\n{\n\tstruct tcp_splice_state *tss = rd_desc->arg.data;\n\tint ret;",
"\tret = skb_splice_bits(skb, skb->sk, offset, tss->pipe,\n\t\t\t min(rd_desc->count, len), tss->flags);\n\tif (ret > 0)\n\t\trd_desc->count -= ret;\n\treturn ret;\n}",
"static int __tcp_splice_read(struct sock *sk, struct tcp_splice_state *tss)\n{\n\t/* Store TCP splice context information in read_descriptor_t. */\n\tread_descriptor_t rd_desc = {\n\t\t.arg.data = tss,\n\t\t.count\t = tss->len,\n\t};",
"\treturn tcp_read_sock(sk, &rd_desc, tcp_splice_data_recv);\n}",
"/**\n * tcp_splice_read - splice data from TCP socket to a pipe\n * @sock:\tsocket to splice from\n * @ppos:\tposition (not valid)\n * @pipe:\tpipe to splice to\n * @len:\tnumber of bytes to splice\n * @flags:\tsplice modifier flags\n *\n * Description:\n * Will read pages from given socket and fill them into a pipe.\n *\n **/\nssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,\n\t\t\tstruct pipe_inode_info *pipe, size_t len,\n\t\t\tunsigned int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tcp_splice_state tss = {\n\t\t.pipe = pipe,\n\t\t.len = len,\n\t\t.flags = flags,\n\t};\n\tlong timeo;\n\tssize_t spliced;\n\tint ret;",
"\tsock_rps_record_flow(sk);\n\t/*\n\t * We can't seek on a socket input\n\t */\n\tif (unlikely(*ppos))\n\t\treturn -ESPIPE;",
"\tret = spliced = 0;",
"\tlock_sock(sk);",
"\ttimeo = sock_rcvtimeo(sk, sock->file->f_flags & O_NONBLOCK);\n\twhile (tss.len) {\n\t\tret = __tcp_splice_read(sk, &tss);\n\t\tif (ret < 0)\n\t\t\tbreak;\n\t\telse if (!ret) {\n\t\t\tif (spliced)\n\t\t\t\tbreak;\n\t\t\tif (sock_flag(sk, SOCK_DONE))\n\t\t\t\tbreak;\n\t\t\tif (sk->sk_err) {\n\t\t\t\tret = sock_error(sk);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\t\t\tbreak;\n\t\t\tif (sk->sk_state == TCP_CLOSE) {\n\t\t\t\t/*\n\t\t\t\t * This occurs when user tries to read\n\t\t\t\t * from never connected socket.\n\t\t\t\t */\n\t\t\t\tif (!sock_flag(sk, SOCK_DONE))\n\t\t\t\t\tret = -ENOTCONN;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!timeo) {\n\t\t\t\tret = -EAGAIN;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t/* if __tcp_splice_read() got nothing while we have\n\t\t\t * an skb in receive queue, we do not want to loop.\n\t\t\t * This might happen with URG data.\n\t\t\t */\n\t\t\tif (!skb_queue_empty(&sk->sk_receive_queue))\n\t\t\t\tbreak;\n\t\t\tsk_wait_data(sk, &timeo, NULL);\n\t\t\tif (signal_pending(current)) {\n\t\t\t\tret = sock_intr_errno(timeo);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\ttss.len -= ret;\n\t\tspliced += ret;",
"\t\tif (!timeo)\n\t\t\tbreak;\n\t\trelease_sock(sk);\n\t\tlock_sock(sk);",
"\t\tif (sk->sk_err || sk->sk_state == TCP_CLOSE ||\n\t\t (sk->sk_shutdown & RCV_SHUTDOWN) ||\n\t\t signal_pending(current))\n\t\t\tbreak;\n\t}",
"\trelease_sock(sk);",
"\tif (spliced)\n\t\treturn spliced;",
"\treturn ret;\n}\nEXPORT_SYMBOL(tcp_splice_read);",
"struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,\n\t\t\t\t bool force_schedule)\n{\n\tstruct sk_buff *skb;",
"\t/* The TCP header must be at least 32-bit aligned. */\n\tsize = ALIGN(size, 4);",
"\tif (unlikely(tcp_under_memory_pressure(sk)))\n\t\tsk_mem_reclaim_partial(sk);",
"\tskb = alloc_skb_fclone(size + sk->sk_prot->max_header, gfp);\n\tif (likely(skb)) {\n\t\tbool mem_scheduled;",
"\t\tif (force_schedule) {\n\t\t\tmem_scheduled = true;\n\t\t\tsk_forced_mem_schedule(sk, skb->truesize);\n\t\t} else {\n\t\t\tmem_scheduled = sk_wmem_schedule(sk, skb->truesize);\n\t\t}\n\t\tif (likely(mem_scheduled)) {\n\t\t\tskb_reserve(skb, sk->sk_prot->max_header);\n\t\t\t/*\n\t\t\t * Make sure that we have exactly size bytes\n\t\t\t * available to the caller, no more, no less.\n\t\t\t */\n\t\t\tskb->reserved_tailroom = skb->end - skb->tail - size;\n\t\t\treturn skb;\n\t\t}\n\t\t__kfree_skb(skb);\n\t} else {\n\t\tsk->sk_prot->enter_memory_pressure(sk);\n\t\tsk_stream_moderate_sndbuf(sk);\n\t}\n\treturn NULL;\n}",
"static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now,\n\t\t\t\t int large_allowed)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tu32 new_size_goal, size_goal;",
"\tif (!large_allowed || !sk_can_gso(sk))\n\t\treturn mss_now;",
"\t/* Note : tcp_tso_autosize() will eventually split this later */\n\tnew_size_goal = sk->sk_gso_max_size - 1 - MAX_TCP_HEADER;\n\tnew_size_goal = tcp_bound_to_half_wnd(tp, new_size_goal);",
"\t/* We try hard to avoid divides here */\n\tsize_goal = tp->gso_segs * mss_now;\n\tif (unlikely(new_size_goal < size_goal ||\n\t\t new_size_goal >= size_goal + mss_now)) {\n\t\ttp->gso_segs = min_t(u16, new_size_goal / mss_now,\n\t\t\t\t sk->sk_gso_max_segs);\n\t\tsize_goal = tp->gso_segs * mss_now;\n\t}",
"\treturn max(size_goal, mss_now);\n}",
"static int tcp_send_mss(struct sock *sk, int *size_goal, int flags)\n{\n\tint mss_now;",
"\tmss_now = tcp_current_mss(sk);\n\t*size_goal = tcp_xmit_size_goal(sk, mss_now, !(flags & MSG_OOB));",
"\treturn mss_now;\n}",
"static ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset,\n\t\t\t\tsize_t size, int flags)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint mss_now, size_goal;\n\tint err;\n\tssize_t copied;\n\tlong timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);",
"\t/* Wait for a connection to finish. One exception is TCP Fast Open\n\t * (passive side) where data is allowed to be sent before a connection\n\t * is fully established.\n\t */\n\tif (((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) &&\n\t !tcp_passive_fastopen(sk)) {\n\t\terr = sk_stream_wait_connect(sk, &timeo);\n\t\tif (err != 0)\n\t\t\tgoto out_err;\n\t}",
"\tsk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);",
"\tmss_now = tcp_send_mss(sk, &size_goal, flags);\n\tcopied = 0;",
"\terr = -EPIPE;\n\tif (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))\n\t\tgoto out_err;",
"\twhile (size > 0) {\n\t\tstruct sk_buff *skb = tcp_write_queue_tail(sk);\n\t\tint copy, i;\n\t\tbool can_coalesce;",
"\t\tif (!tcp_send_head(sk) || (copy = size_goal - skb->len) <= 0 ||\n\t\t !tcp_skb_can_collapse_to(skb)) {\nnew_segment:\n\t\t\tif (!sk_stream_memory_free(sk))\n\t\t\t\tgoto wait_for_sndbuf;",
"\t\t\tskb = sk_stream_alloc_skb(sk, 0, sk->sk_allocation,\n\t\t\t\t\t\t skb_queue_empty(&sk->sk_write_queue));\n\t\t\tif (!skb)\n\t\t\t\tgoto wait_for_memory;",
"\t\t\tskb_entail(sk, skb);\n\t\t\tcopy = size_goal;\n\t\t}",
"\t\tif (copy > size)\n\t\t\tcopy = size;",
"\t\ti = skb_shinfo(skb)->nr_frags;\n\t\tcan_coalesce = skb_can_coalesce(skb, i, page, offset);\n\t\tif (!can_coalesce && i >= sysctl_max_skb_frags) {\n\t\t\ttcp_mark_push(tp, skb);\n\t\t\tgoto new_segment;\n\t\t}\n\t\tif (!sk_wmem_schedule(sk, copy))\n\t\t\tgoto wait_for_memory;",
"\t\tif (can_coalesce) {\n\t\t\tskb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy);\n\t\t} else {\n\t\t\tget_page(page);\n\t\t\tskb_fill_page_desc(skb, i, page, offset, copy);\n\t\t}\n\t\tskb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;",
"\t\tskb->len += copy;\n\t\tskb->data_len += copy;\n\t\tskb->truesize += copy;\n\t\tsk->sk_wmem_queued += copy;\n\t\tsk_mem_charge(sk, copy);\n\t\tskb->ip_summed = CHECKSUM_PARTIAL;\n\t\ttp->write_seq += copy;\n\t\tTCP_SKB_CB(skb)->end_seq += copy;\n\t\ttcp_skb_pcount_set(skb, 0);",
"\t\tif (!copied)\n\t\t\tTCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH;",
"\t\tcopied += copy;\n\t\toffset += copy;\n\t\tsize -= copy;\n\t\tif (!size)\n\t\t\tgoto out;",
"\t\tif (skb->len < size_goal || (flags & MSG_OOB))\n\t\t\tcontinue;",
"\t\tif (forced_push(tp)) {\n\t\t\ttcp_mark_push(tp, skb);\n\t\t\t__tcp_push_pending_frames(sk, mss_now, TCP_NAGLE_PUSH);\n\t\t} else if (skb == tcp_send_head(sk))\n\t\t\ttcp_push_one(sk, mss_now);\n\t\tcontinue;",
"wait_for_sndbuf:\n\t\tset_bit(SOCK_NOSPACE, &sk->sk_socket->flags);\nwait_for_memory:\n\t\ttcp_push(sk, flags & ~MSG_MORE, mss_now,\n\t\t\t TCP_NAGLE_PUSH, size_goal);",
"\t\terr = sk_stream_wait_memory(sk, &timeo);\n\t\tif (err != 0)\n\t\t\tgoto do_error;",
"\t\tmss_now = tcp_send_mss(sk, &size_goal, flags);\n\t}",
"out:\n\tif (copied) {\n\t\ttcp_tx_timestamp(sk, sk->sk_tsflags, tcp_write_queue_tail(sk));\n\t\tif (!(flags & MSG_SENDPAGE_NOTLAST))\n\t\t\ttcp_push(sk, flags, mss_now, tp->nonagle, size_goal);\n\t}\n\treturn copied;",
"do_error:\n\tif (copied)\n\t\tgoto out;\nout_err:\n\t/* make sure we wake any epoll edge trigger waiter */\n\tif (unlikely(skb_queue_len(&sk->sk_write_queue) == 0 &&\n\t\t err == -EAGAIN)) {\n\t\tsk->sk_write_space(sk);\n\t\ttcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);\n\t}\n\treturn sk_stream_error(sk, flags, err);\n}",
"int tcp_sendpage(struct sock *sk, struct page *page, int offset,\n\t\t size_t size, int flags)\n{\n\tssize_t res;",
"\tif (!(sk->sk_route_caps & NETIF_F_SG) ||\n\t !sk_check_csum_caps(sk))\n\t\treturn sock_no_sendpage(sk->sk_socket, page, offset, size,\n\t\t\t\t\tflags);",
"\tlock_sock(sk);",
"\ttcp_rate_check_app_limited(sk); /* is sending application-limited? */",
"\tres = do_tcp_sendpages(sk, page, offset, size, flags);\n\trelease_sock(sk);\n\treturn res;\n}\nEXPORT_SYMBOL(tcp_sendpage);",
"/* Do not bother using a page frag for very small frames.\n * But use this heuristic only for the first skb in write queue.\n *\n * Having no payload in skb->head allows better SACK shifting\n * in tcp_shift_skb_data(), reducing sack/rack overhead, because\n * write queue has less skbs.\n * Each skb can hold up to MAX_SKB_FRAGS * 32Kbytes, or ~0.5 MB.\n * This also speeds up tso_fragment(), since it wont fallback\n * to tcp_fragment().\n */\nstatic int linear_payload_sz(bool first_skb)\n{\n\tif (first_skb)\n\t\treturn SKB_WITH_OVERHEAD(2048 - MAX_TCP_HEADER);\n\treturn 0;\n}",
"static int select_size(const struct sock *sk, bool sg, bool first_skb)\n{\n\tconst struct tcp_sock *tp = tcp_sk(sk);\n\tint tmp = tp->mss_cache;",
"\tif (sg) {\n\t\tif (sk_can_gso(sk)) {\n\t\t\ttmp = linear_payload_sz(first_skb);\n\t\t} else {\n\t\t\tint pgbreak = SKB_MAX_HEAD(MAX_TCP_HEADER);",
"\t\t\tif (tmp >= pgbreak &&\n\t\t\t tmp <= pgbreak + (MAX_SKB_FRAGS - 1) * PAGE_SIZE)\n\t\t\t\ttmp = pgbreak;\n\t\t}\n\t}",
"\treturn tmp;\n}",
"void tcp_free_fastopen_req(struct tcp_sock *tp)\n{\n\tif (tp->fastopen_req) {\n\t\tkfree(tp->fastopen_req);\n\t\ttp->fastopen_req = NULL;\n\t}\n}",
"static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,\n\t\t\t\tint *copied, size_t size)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct inet_sock *inet = inet_sk(sk);\n\tint err, flags;",
"\tif (!(sysctl_tcp_fastopen & TFO_CLIENT_ENABLE))\n\t\treturn -EOPNOTSUPP;\n\tif (tp->fastopen_req)\n\t\treturn -EALREADY; /* Another Fast Open is in progress */",
"\ttp->fastopen_req = kzalloc(sizeof(struct tcp_fastopen_request),\n\t\t\t\t sk->sk_allocation);\n\tif (unlikely(!tp->fastopen_req))\n\t\treturn -ENOBUFS;\n\ttp->fastopen_req->data = msg;\n\ttp->fastopen_req->size = size;",
"\tif (inet->defer_connect) {\n\t\terr = tcp_connect(sk);\n\t\t/* Same failure procedure as in tcp_v4/6_connect */\n\t\tif (err) {\n\t\t\ttcp_set_state(sk, TCP_CLOSE);\n\t\t\tinet->inet_dport = 0;\n\t\t\tsk->sk_route_caps = 0;\n\t\t}\n\t}\n\tflags = (msg->msg_flags & MSG_DONTWAIT) ? O_NONBLOCK : 0;\n\terr = __inet_stream_connect(sk->sk_socket, msg->msg_name,\n\t\t\t\t msg->msg_namelen, flags, 1);\n\t/* fastopen_req could already be freed in __inet_stream_connect\n\t * if the connection times out or gets rst\n\t */\n\tif (tp->fastopen_req) {\n\t\t*copied = tp->fastopen_req->copied;\n\t\ttcp_free_fastopen_req(tp);\n\t\tinet->defer_connect = 0;\n\t}\n\treturn err;\n}",
"int tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct sk_buff *skb;\n\tstruct sockcm_cookie sockc;\n\tint flags, err, copied = 0;\n\tint mss_now = 0, size_goal, copied_syn = 0;\n\tbool process_backlog = false;\n\tbool sg;\n\tlong timeo;",
"\tlock_sock(sk);",
"\tflags = msg->msg_flags;\n\tif (unlikely(flags & MSG_FASTOPEN || inet_sk(sk)->defer_connect)) {\n\t\terr = tcp_sendmsg_fastopen(sk, msg, &copied_syn, size);\n\t\tif (err == -EINPROGRESS && copied_syn > 0)\n\t\t\tgoto out;\n\t\telse if (err)\n\t\t\tgoto out_err;\n\t}",
"\ttimeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);",
"\ttcp_rate_check_app_limited(sk); /* is sending application-limited? */",
"\t/* Wait for a connection to finish. One exception is TCP Fast Open\n\t * (passive side) where data is allowed to be sent before a connection\n\t * is fully established.\n\t */\n\tif (((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) &&\n\t !tcp_passive_fastopen(sk)) {\n\t\terr = sk_stream_wait_connect(sk, &timeo);\n\t\tif (err != 0)\n\t\t\tgoto do_error;\n\t}",
"\tif (unlikely(tp->repair)) {\n\t\tif (tp->repair_queue == TCP_RECV_QUEUE) {\n\t\t\tcopied = tcp_send_rcvq(sk, msg, size);\n\t\t\tgoto out_nopush;\n\t\t}",
"\t\terr = -EINVAL;\n\t\tif (tp->repair_queue == TCP_NO_QUEUE)\n\t\t\tgoto out_err;",
"\t\t/* 'common' sending to sendq */\n\t}",
"\tsockc.tsflags = sk->sk_tsflags;\n\tif (msg->msg_controllen) {\n\t\terr = sock_cmsg_send(sk, msg, &sockc);\n\t\tif (unlikely(err)) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto out_err;\n\t\t}\n\t}",
"\t/* This should be in poll */\n\tsk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);",
"\t/* Ok commence sending. */\n\tcopied = 0;",
"restart:\n\tmss_now = tcp_send_mss(sk, &size_goal, flags);",
"\terr = -EPIPE;\n\tif (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))\n\t\tgoto do_error;",
"\tsg = !!(sk->sk_route_caps & NETIF_F_SG);",
"\twhile (msg_data_left(msg)) {\n\t\tint copy = 0;\n\t\tint max = size_goal;",
"\t\tskb = tcp_write_queue_tail(sk);\n\t\tif (tcp_send_head(sk)) {\n\t\t\tif (skb->ip_summed == CHECKSUM_NONE)\n\t\t\t\tmax = mss_now;\n\t\t\tcopy = max - skb->len;\n\t\t}",
"\t\tif (copy <= 0 || !tcp_skb_can_collapse_to(skb)) {\n\t\t\tbool first_skb;",
"new_segment:\n\t\t\t/* Allocate new segment. If the interface is SG,\n\t\t\t * allocate skb fitting to single page.\n\t\t\t */\n\t\t\tif (!sk_stream_memory_free(sk))\n\t\t\t\tgoto wait_for_sndbuf;",
"\t\t\tif (process_backlog && sk_flush_backlog(sk)) {\n\t\t\t\tprocess_backlog = false;\n\t\t\t\tgoto restart;\n\t\t\t}\n\t\t\tfirst_skb = skb_queue_empty(&sk->sk_write_queue);\n\t\t\tskb = sk_stream_alloc_skb(sk,\n\t\t\t\t\t\t select_size(sk, sg, first_skb),\n\t\t\t\t\t\t sk->sk_allocation,\n\t\t\t\t\t\t first_skb);\n\t\t\tif (!skb)\n\t\t\t\tgoto wait_for_memory;",
"\t\t\tprocess_backlog = true;\n\t\t\t/*\n\t\t\t * Check whether we can use HW checksum.\n\t\t\t */\n\t\t\tif (sk_check_csum_caps(sk))\n\t\t\t\tskb->ip_summed = CHECKSUM_PARTIAL;",
"\t\t\tskb_entail(sk, skb);\n\t\t\tcopy = size_goal;\n\t\t\tmax = size_goal;",
"\t\t\t/* All packets are restored as if they have\n\t\t\t * already been sent. skb_mstamp isn't set to\n\t\t\t * avoid wrong rtt estimation.\n\t\t\t */\n\t\t\tif (tp->repair)\n\t\t\t\tTCP_SKB_CB(skb)->sacked |= TCPCB_REPAIRED;\n\t\t}",
"\t\t/* Try to append data to the end of skb. */\n\t\tif (copy > msg_data_left(msg))\n\t\t\tcopy = msg_data_left(msg);",
"\t\t/* Where to copy to? */\n\t\tif (skb_availroom(skb) > 0) {\n\t\t\t/* We have some space in skb head. Superb! */\n\t\t\tcopy = min_t(int, copy, skb_availroom(skb));\n\t\t\terr = skb_add_data_nocache(sk, skb, &msg->msg_iter, copy);\n\t\t\tif (err)\n\t\t\t\tgoto do_fault;\n\t\t} else {\n\t\t\tbool merge = true;\n\t\t\tint i = skb_shinfo(skb)->nr_frags;\n\t\t\tstruct page_frag *pfrag = sk_page_frag(sk);",
"\t\t\tif (!sk_page_frag_refill(sk, pfrag))\n\t\t\t\tgoto wait_for_memory;",
"\t\t\tif (!skb_can_coalesce(skb, i, pfrag->page,\n\t\t\t\t\t pfrag->offset)) {\n\t\t\t\tif (i >= sysctl_max_skb_frags || !sg) {\n\t\t\t\t\ttcp_mark_push(tp, skb);\n\t\t\t\t\tgoto new_segment;\n\t\t\t\t}\n\t\t\t\tmerge = false;\n\t\t\t}",
"\t\t\tcopy = min_t(int, copy, pfrag->size - pfrag->offset);",
"\t\t\tif (!sk_wmem_schedule(sk, copy))\n\t\t\t\tgoto wait_for_memory;",
"\t\t\terr = skb_copy_to_page_nocache(sk, &msg->msg_iter, skb,\n\t\t\t\t\t\t pfrag->page,\n\t\t\t\t\t\t pfrag->offset,\n\t\t\t\t\t\t copy);\n\t\t\tif (err)\n\t\t\t\tgoto do_error;",
"\t\t\t/* Update the skb. */\n\t\t\tif (merge) {\n\t\t\t\tskb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy);\n\t\t\t} else {\n\t\t\t\tskb_fill_page_desc(skb, i, pfrag->page,\n\t\t\t\t\t\t pfrag->offset, copy);\n\t\t\t\tpage_ref_inc(pfrag->page);\n\t\t\t}\n\t\t\tpfrag->offset += copy;\n\t\t}",
"\t\tif (!copied)\n\t\t\tTCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH;",
"\t\ttp->write_seq += copy;\n\t\tTCP_SKB_CB(skb)->end_seq += copy;\n\t\ttcp_skb_pcount_set(skb, 0);",
"\t\tcopied += copy;\n\t\tif (!msg_data_left(msg)) {\n\t\t\tif (unlikely(flags & MSG_EOR))\n\t\t\t\tTCP_SKB_CB(skb)->eor = 1;\n\t\t\tgoto out;\n\t\t}",
"\t\tif (skb->len < max || (flags & MSG_OOB) || unlikely(tp->repair))\n\t\t\tcontinue;",
"\t\tif (forced_push(tp)) {\n\t\t\ttcp_mark_push(tp, skb);\n\t\t\t__tcp_push_pending_frames(sk, mss_now, TCP_NAGLE_PUSH);\n\t\t} else if (skb == tcp_send_head(sk))\n\t\t\ttcp_push_one(sk, mss_now);\n\t\tcontinue;",
"wait_for_sndbuf:\n\t\tset_bit(SOCK_NOSPACE, &sk->sk_socket->flags);\nwait_for_memory:\n\t\tif (copied)\n\t\t\ttcp_push(sk, flags & ~MSG_MORE, mss_now,\n\t\t\t\t TCP_NAGLE_PUSH, size_goal);",
"\t\terr = sk_stream_wait_memory(sk, &timeo);\n\t\tif (err != 0)\n\t\t\tgoto do_error;",
"\t\tmss_now = tcp_send_mss(sk, &size_goal, flags);\n\t}",
"out:\n\tif (copied) {\n\t\ttcp_tx_timestamp(sk, sockc.tsflags, tcp_write_queue_tail(sk));\n\t\ttcp_push(sk, flags, mss_now, tp->nonagle, size_goal);\n\t}\nout_nopush:\n\trelease_sock(sk);\n\treturn copied + copied_syn;",
"do_fault:\n\tif (!skb->len) {\n\t\ttcp_unlink_write_queue(skb, sk);\n\t\t/* It is the one place in all of TCP, except connection\n\t\t * reset, where we can be unlinking the send_head.\n\t\t */\n\t\ttcp_check_send_head(sk, skb);\n\t\tsk_wmem_free_skb(sk, skb);\n\t}",
"do_error:\n\tif (copied + copied_syn)\n\t\tgoto out;\nout_err:\n\terr = sk_stream_error(sk, flags, err);\n\t/* make sure we wake any epoll edge trigger waiter */\n\tif (unlikely(skb_queue_len(&sk->sk_write_queue) == 0 &&\n\t\t err == -EAGAIN)) {\n\t\tsk->sk_write_space(sk);\n\t\ttcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);\n\t}\n\trelease_sock(sk);\n\treturn err;\n}\nEXPORT_SYMBOL(tcp_sendmsg);",
"/*\n *\tHandle reading urgent data. BSD has very simple semantics for\n *\tthis, no blocking and very strange errors 8)\n */",
"static int tcp_recv_urg(struct sock *sk, struct msghdr *msg, int len, int flags)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);",
"\t/* No URG data to read. */\n\tif (sock_flag(sk, SOCK_URGINLINE) || !tp->urg_data ||\n\t tp->urg_data == TCP_URG_READ)\n\t\treturn -EINVAL;\t/* Yes this is right ! */",
"\tif (sk->sk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DONE))\n\t\treturn -ENOTCONN;",
"\tif (tp->urg_data & TCP_URG_VALID) {\n\t\tint err = 0;\n\t\tchar c = tp->urg_data;",
"\t\tif (!(flags & MSG_PEEK))\n\t\t\ttp->urg_data = TCP_URG_READ;",
"\t\t/* Read urgent data. */\n\t\tmsg->msg_flags |= MSG_OOB;",
"\t\tif (len > 0) {\n\t\t\tif (!(flags & MSG_TRUNC))\n\t\t\t\terr = memcpy_to_msg(msg, &c, 1);\n\t\t\tlen = 1;\n\t\t} else\n\t\t\tmsg->msg_flags |= MSG_TRUNC;",
"\t\treturn err ? -EFAULT : len;\n\t}",
"\tif (sk->sk_state == TCP_CLOSE || (sk->sk_shutdown & RCV_SHUTDOWN))\n\t\treturn 0;",
"\t/* Fixed the recv(..., MSG_OOB) behaviour. BSD docs and\n\t * the available implementations agree in this case:\n\t * this call should never block, independent of the\n\t * blocking state of the socket.\n\t * Mike <pall@rz.uni-karlsruhe.de>\n\t */\n\treturn -EAGAIN;\n}",
"static int tcp_peek_sndq(struct sock *sk, struct msghdr *msg, int len)\n{\n\tstruct sk_buff *skb;\n\tint copied = 0, err = 0;",
"\t/* XXX -- need to support SO_PEEK_OFF */",
"\tskb_queue_walk(&sk->sk_write_queue, skb) {\n\t\terr = skb_copy_datagram_msg(skb, 0, msg, skb->len);\n\t\tif (err)\n\t\t\tbreak;",
"\t\tcopied += skb->len;\n\t}",
"\treturn err ?: copied;\n}",
"/* Clean up the receive buffer for full frames taken by the user,\n * then send an ACK if necessary. COPIED is the number of bytes\n * tcp_recvmsg has given to the user so far, it speeds up the\n * calculation of whether or not we must ACK for the sake of\n * a window update.\n */\nstatic void tcp_cleanup_rbuf(struct sock *sk, int copied)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tbool time_to_ack = false;",
"\tstruct sk_buff *skb = skb_peek(&sk->sk_receive_queue);",
"\tWARN(skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq),\n\t \"cleanup rbuf bug: copied %X seq %X rcvnxt %X\\n\",\n\t tp->copied_seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt);",
"\tif (inet_csk_ack_scheduled(sk)) {\n\t\tconst struct inet_connection_sock *icsk = inet_csk(sk);\n\t\t /* Delayed ACKs frequently hit locked sockets during bulk\n\t\t * receive. */\n\t\tif (icsk->icsk_ack.blocked ||\n\t\t /* Once-per-two-segments ACK was not sent by tcp_input.c */\n\t\t tp->rcv_nxt - tp->rcv_wup > icsk->icsk_ack.rcv_mss ||\n\t\t /*\n\t\t * If this read emptied read buffer, we send ACK, if\n\t\t * connection is not bidirectional, user drained\n\t\t * receive buffer and there was a small segment\n\t\t * in queue.\n\t\t */\n\t\t (copied > 0 &&\n\t\t ((icsk->icsk_ack.pending & ICSK_ACK_PUSHED2) ||\n\t\t ((icsk->icsk_ack.pending & ICSK_ACK_PUSHED) &&\n\t\t !icsk->icsk_ack.pingpong)) &&\n\t\t !atomic_read(&sk->sk_rmem_alloc)))\n\t\t\ttime_to_ack = true;\n\t}",
"\t/* We send an ACK if we can now advertise a non-zero window\n\t * which has been raised \"significantly\".\n\t *\n\t * Even if window raised up to infinity, do not send window open ACK\n\t * in states, where we will not receive more. It is useless.\n\t */\n\tif (copied > 0 && !time_to_ack && !(sk->sk_shutdown & RCV_SHUTDOWN)) {\n\t\t__u32 rcv_window_now = tcp_receive_window(tp);",
"\t\t/* Optimize, __tcp_select_window() is not cheap. */\n\t\tif (2*rcv_window_now <= tp->window_clamp) {\n\t\t\t__u32 new_window = __tcp_select_window(sk);",
"\t\t\t/* Send ACK now, if this read freed lots of space\n\t\t\t * in our buffer. Certainly, new_window is new window.\n\t\t\t * We can advertise it now, if it is not less than current one.\n\t\t\t * \"Lots\" means \"at least twice\" here.\n\t\t\t */\n\t\t\tif (new_window && new_window >= 2 * rcv_window_now)\n\t\t\t\ttime_to_ack = true;\n\t\t}\n\t}\n\tif (time_to_ack)\n\t\ttcp_send_ack(sk);\n}",
"static void tcp_prequeue_process(struct sock *sk)\n{\n\tstruct sk_buff *skb;\n\tstruct tcp_sock *tp = tcp_sk(sk);",
"\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPPREQUEUED);",
"\twhile ((skb = __skb_dequeue(&tp->ucopy.prequeue)) != NULL)\n\t\tsk_backlog_rcv(sk, skb);",
"\t/* Clear memory counter. */\n\ttp->ucopy.memory = 0;\n}",
"static struct sk_buff *tcp_recv_skb(struct sock *sk, u32 seq, u32 *off)\n{\n\tstruct sk_buff *skb;\n\tu32 offset;",
"\twhile ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) {\n\t\toffset = seq - TCP_SKB_CB(skb)->seq;\n\t\tif (unlikely(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) {\n\t\t\tpr_err_once(\"%s: found a SYN, please report !\\n\", __func__);\n\t\t\toffset--;\n\t\t}\n\t\tif (offset < skb->len || (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)) {\n\t\t\t*off = offset;\n\t\t\treturn skb;\n\t\t}\n\t\t/* This looks weird, but this can happen if TCP collapsing\n\t\t * splitted a fat GRO packet, while we released socket lock\n\t\t * in skb_splice_bits()\n\t\t */\n\t\tsk_eat_skb(sk, skb);\n\t}\n\treturn NULL;\n}",
"/*\n * This routine provides an alternative to tcp_recvmsg() for routines\n * that would like to handle copying from skbuffs directly in 'sendfile'\n * fashion.\n * Note:\n *\t- It is assumed that the socket was locked by the caller.\n *\t- The routine does not block.\n *\t- At present, there is no support for reading OOB data\n *\t or for 'peeking' the socket using this routine\n *\t (although both would be easy to implement).\n */\nint tcp_read_sock(struct sock *sk, read_descriptor_t *desc,\n\t\t sk_read_actor_t recv_actor)\n{\n\tstruct sk_buff *skb;\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tu32 seq = tp->copied_seq;\n\tu32 offset;\n\tint copied = 0;",
"\tif (sk->sk_state == TCP_LISTEN)\n\t\treturn -ENOTCONN;\n\twhile ((skb = tcp_recv_skb(sk, seq, &offset)) != NULL) {\n\t\tif (offset < skb->len) {\n\t\t\tint used;\n\t\t\tsize_t len;",
"\t\t\tlen = skb->len - offset;\n\t\t\t/* Stop reading if we hit a patch of urgent data */\n\t\t\tif (tp->urg_data) {\n\t\t\t\tu32 urg_offset = tp->urg_seq - seq;\n\t\t\t\tif (urg_offset < len)\n\t\t\t\t\tlen = urg_offset;\n\t\t\t\tif (!len)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tused = recv_actor(desc, skb, offset, len);\n\t\t\tif (used <= 0) {\n\t\t\t\tif (!copied)\n\t\t\t\t\tcopied = used;\n\t\t\t\tbreak;\n\t\t\t} else if (used <= len) {\n\t\t\t\tseq += used;\n\t\t\t\tcopied += used;\n\t\t\t\toffset += used;\n\t\t\t}\n\t\t\t/* If recv_actor drops the lock (e.g. TCP splice\n\t\t\t * receive) the skb pointer might be invalid when\n\t\t\t * getting here: tcp_collapse might have deleted it\n\t\t\t * while aggregating skbs from the socket queue.\n\t\t\t */\n\t\t\tskb = tcp_recv_skb(sk, seq - 1, &offset);\n\t\t\tif (!skb)\n\t\t\t\tbreak;\n\t\t\t/* TCP coalescing might have appended data to the skb.\n\t\t\t * Try to splice more frags\n\t\t\t */\n\t\t\tif (offset + 1 != skb->len)\n\t\t\t\tcontinue;\n\t\t}\n\t\tif (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) {\n\t\t\tsk_eat_skb(sk, skb);\n\t\t\t++seq;\n\t\t\tbreak;\n\t\t}\n\t\tsk_eat_skb(sk, skb);\n\t\tif (!desc->count)\n\t\t\tbreak;\n\t\ttp->copied_seq = seq;\n\t}\n\ttp->copied_seq = seq;",
"\ttcp_rcv_space_adjust(sk);",
"\t/* Clean up data we have read: This will do ACK frames. */\n\tif (copied > 0) {\n\t\ttcp_recv_skb(sk, seq, &offset);\n\t\ttcp_cleanup_rbuf(sk, copied);\n\t}\n\treturn copied;\n}\nEXPORT_SYMBOL(tcp_read_sock);",
"int tcp_peek_len(struct socket *sock)\n{\n\treturn tcp_inq(sock->sk);\n}\nEXPORT_SYMBOL(tcp_peek_len);",
"/*\n *\tThis routine copies from a sock struct into the user buffer.\n *\n *\tTechnical note: in 2.3 we work on _locked_ socket, so that\n *\ttricks with *seq access order and skb->users are not required.\n *\tProbably, code can be easily improved even more.\n */",
"int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,\n\t\tint flags, int *addr_len)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint copied = 0;\n\tu32 peek_seq;\n\tu32 *seq;\n\tunsigned long used;\n\tint err;\n\tint target;\t\t/* Read at least this many bytes */\n\tlong timeo;\n\tstruct task_struct *user_recv = NULL;\n\tstruct sk_buff *skb, *last;\n\tu32 urg_hole = 0;",
"\tif (unlikely(flags & MSG_ERRQUEUE))\n\t\treturn inet_recv_error(sk, msg, len, addr_len);",
"\tif (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue) &&\n\t (sk->sk_state == TCP_ESTABLISHED))\n\t\tsk_busy_loop(sk, nonblock);",
"\tlock_sock(sk);",
"\terr = -ENOTCONN;\n\tif (sk->sk_state == TCP_LISTEN)\n\t\tgoto out;",
"\ttimeo = sock_rcvtimeo(sk, nonblock);",
"\t/* Urgent data needs to be handled specially. */\n\tif (flags & MSG_OOB)\n\t\tgoto recv_urg;",
"\tif (unlikely(tp->repair)) {\n\t\terr = -EPERM;\n\t\tif (!(flags & MSG_PEEK))\n\t\t\tgoto out;",
"\t\tif (tp->repair_queue == TCP_SEND_QUEUE)\n\t\t\tgoto recv_sndq;",
"\t\terr = -EINVAL;\n\t\tif (tp->repair_queue == TCP_NO_QUEUE)\n\t\t\tgoto out;",
"\t\t/* 'common' recv queue MSG_PEEK-ing */\n\t}",
"\tseq = &tp->copied_seq;\n\tif (flags & MSG_PEEK) {\n\t\tpeek_seq = tp->copied_seq;\n\t\tseq = &peek_seq;\n\t}",
"\ttarget = sock_rcvlowat(sk, flags & MSG_WAITALL, len);",
"\tdo {\n\t\tu32 offset;",
"\t\t/* Are we at urgent data? Stop if we have read anything or have SIGURG pending. */\n\t\tif (tp->urg_data && tp->urg_seq == *seq) {\n\t\t\tif (copied)\n\t\t\t\tbreak;\n\t\t\tif (signal_pending(current)) {\n\t\t\t\tcopied = timeo ? sock_intr_errno(timeo) : -EAGAIN;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\t/* Next get a buffer. */",
"\t\tlast = skb_peek_tail(&sk->sk_receive_queue);\n\t\tskb_queue_walk(&sk->sk_receive_queue, skb) {\n\t\t\tlast = skb;\n\t\t\t/* Now that we have two receive queues this\n\t\t\t * shouldn't happen.\n\t\t\t */\n\t\t\tif (WARN(before(*seq, TCP_SKB_CB(skb)->seq),\n\t\t\t\t \"recvmsg bug: copied %X seq %X rcvnxt %X fl %X\\n\",\n\t\t\t\t *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt,\n\t\t\t\t flags))\n\t\t\t\tbreak;",
"\t\t\toffset = *seq - TCP_SKB_CB(skb)->seq;\n\t\t\tif (unlikely(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) {\n\t\t\t\tpr_err_once(\"%s: found a SYN, please report !\\n\", __func__);\n\t\t\t\toffset--;\n\t\t\t}\n\t\t\tif (offset < skb->len)\n\t\t\t\tgoto found_ok_skb;\n\t\t\tif (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)\n\t\t\t\tgoto found_fin_ok;\n\t\t\tWARN(!(flags & MSG_PEEK),\n\t\t\t \"recvmsg bug 2: copied %X seq %X rcvnxt %X fl %X\\n\",\n\t\t\t *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt, flags);\n\t\t}",
"\t\t/* Well, if we have backlog, try to process it now yet. */",
"\t\tif (copied >= target && !sk->sk_backlog.tail)\n\t\t\tbreak;",
"\t\tif (copied) {\n\t\t\tif (sk->sk_err ||\n\t\t\t sk->sk_state == TCP_CLOSE ||\n\t\t\t (sk->sk_shutdown & RCV_SHUTDOWN) ||\n\t\t\t !timeo ||\n\t\t\t signal_pending(current))\n\t\t\t\tbreak;\n\t\t} else {\n\t\t\tif (sock_flag(sk, SOCK_DONE))\n\t\t\t\tbreak;",
"\t\t\tif (sk->sk_err) {\n\t\t\t\tcopied = sock_error(sk);\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\t\t\tbreak;",
"\t\t\tif (sk->sk_state == TCP_CLOSE) {\n\t\t\t\tif (!sock_flag(sk, SOCK_DONE)) {\n\t\t\t\t\t/* This occurs when user tries to read\n\t\t\t\t\t * from never connected socket.\n\t\t\t\t\t */\n\t\t\t\t\tcopied = -ENOTCONN;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tif (!timeo) {\n\t\t\t\tcopied = -EAGAIN;\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tif (signal_pending(current)) {\n\t\t\t\tcopied = sock_intr_errno(timeo);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\ttcp_cleanup_rbuf(sk, copied);",
"\t\tif (!sysctl_tcp_low_latency && tp->ucopy.task == user_recv) {\n\t\t\t/* Install new reader */\n\t\t\tif (!user_recv && !(flags & (MSG_TRUNC | MSG_PEEK))) {\n\t\t\t\tuser_recv = current;\n\t\t\t\ttp->ucopy.task = user_recv;\n\t\t\t\ttp->ucopy.msg = msg;\n\t\t\t}",
"\t\t\ttp->ucopy.len = len;",
"\t\t\tWARN_ON(tp->copied_seq != tp->rcv_nxt &&\n\t\t\t\t!(flags & (MSG_PEEK | MSG_TRUNC)));",
"\t\t\t/* Ugly... If prequeue is not empty, we have to\n\t\t\t * process it before releasing socket, otherwise\n\t\t\t * order will be broken at second iteration.\n\t\t\t * More elegant solution is required!!!\n\t\t\t *\n\t\t\t * Look: we have the following (pseudo)queues:\n\t\t\t *\n\t\t\t * 1. packets in flight\n\t\t\t * 2. backlog\n\t\t\t * 3. prequeue\n\t\t\t * 4. receive_queue\n\t\t\t *\n\t\t\t * Each queue can be processed only if the next ones\n\t\t\t * are empty. At this point we have empty receive_queue.\n\t\t\t * But prequeue _can_ be not empty after 2nd iteration,\n\t\t\t * when we jumped to start of loop because backlog\n\t\t\t * processing added something to receive_queue.\n\t\t\t * We cannot release_sock(), because backlog contains\n\t\t\t * packets arrived _after_ prequeued ones.\n\t\t\t *\n\t\t\t * Shortly, algorithm is clear --- to process all\n\t\t\t * the queues in order. We could make it more directly,\n\t\t\t * requeueing packets from backlog to prequeue, if\n\t\t\t * is not empty. It is more elegant, but eats cycles,\n\t\t\t * unfortunately.\n\t\t\t */\n\t\t\tif (!skb_queue_empty(&tp->ucopy.prequeue))\n\t\t\t\tgoto do_prequeue;",
"\t\t\t/* __ Set realtime policy in scheduler __ */\n\t\t}",
"\t\tif (copied >= target) {\n\t\t\t/* Do not sleep, just process backlog. */\n\t\t\trelease_sock(sk);\n\t\t\tlock_sock(sk);\n\t\t} else {\n\t\t\tsk_wait_data(sk, &timeo, last);\n\t\t}",
"\t\tif (user_recv) {\n\t\t\tint chunk;",
"\t\t\t/* __ Restore normal policy in scheduler __ */",
"\t\t\tchunk = len - tp->ucopy.len;\n\t\t\tif (chunk != 0) {\n\t\t\t\tNET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPDIRECTCOPYFROMBACKLOG, chunk);\n\t\t\t\tlen -= chunk;\n\t\t\t\tcopied += chunk;\n\t\t\t}",
"\t\t\tif (tp->rcv_nxt == tp->copied_seq &&\n\t\t\t !skb_queue_empty(&tp->ucopy.prequeue)) {\ndo_prequeue:\n\t\t\t\ttcp_prequeue_process(sk);",
"\t\t\t\tchunk = len - tp->ucopy.len;\n\t\t\t\tif (chunk != 0) {\n\t\t\t\t\tNET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPDIRECTCOPYFROMPREQUEUE, chunk);\n\t\t\t\t\tlen -= chunk;\n\t\t\t\t\tcopied += chunk;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ((flags & MSG_PEEK) &&\n\t\t (peek_seq - copied - urg_hole != tp->copied_seq)) {\n\t\t\tnet_dbg_ratelimited(\"TCP(%s:%d): Application bug, race in MSG_PEEK\\n\",\n\t\t\t\t\t current->comm,\n\t\t\t\t\t task_pid_nr(current));\n\t\t\tpeek_seq = tp->copied_seq;\n\t\t}\n\t\tcontinue;",
"\tfound_ok_skb:\n\t\t/* Ok so how much can we use? */\n\t\tused = skb->len - offset;\n\t\tif (len < used)\n\t\t\tused = len;",
"\t\t/* Do we have urgent data here? */\n\t\tif (tp->urg_data) {\n\t\t\tu32 urg_offset = tp->urg_seq - *seq;\n\t\t\tif (urg_offset < used) {\n\t\t\t\tif (!urg_offset) {\n\t\t\t\t\tif (!sock_flag(sk, SOCK_URGINLINE)) {\n\t\t\t\t\t\t++*seq;\n\t\t\t\t\t\turg_hole++;\n\t\t\t\t\t\toffset++;\n\t\t\t\t\t\tused--;\n\t\t\t\t\t\tif (!used)\n\t\t\t\t\t\t\tgoto skip_copy;\n\t\t\t\t\t}\n\t\t\t\t} else\n\t\t\t\t\tused = urg_offset;\n\t\t\t}\n\t\t}",
"\t\tif (!(flags & MSG_TRUNC)) {\n\t\t\terr = skb_copy_datagram_msg(skb, offset, msg, used);\n\t\t\tif (err) {\n\t\t\t\t/* Exception. Bailout! */\n\t\t\t\tif (!copied)\n\t\t\t\t\tcopied = -EFAULT;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\t*seq += used;\n\t\tcopied += used;\n\t\tlen -= used;",
"\t\ttcp_rcv_space_adjust(sk);",
"skip_copy:\n\t\tif (tp->urg_data && after(tp->copied_seq, tp->urg_seq)) {\n\t\t\ttp->urg_data = 0;\n\t\t\ttcp_fast_path_check(sk);\n\t\t}\n\t\tif (used + offset < skb->len)\n\t\t\tcontinue;",
"\t\tif (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)\n\t\t\tgoto found_fin_ok;\n\t\tif (!(flags & MSG_PEEK))\n\t\t\tsk_eat_skb(sk, skb);\n\t\tcontinue;",
"\tfound_fin_ok:\n\t\t/* Process the FIN. */\n\t\t++*seq;\n\t\tif (!(flags & MSG_PEEK))\n\t\t\tsk_eat_skb(sk, skb);\n\t\tbreak;\n\t} while (len > 0);",
"\tif (user_recv) {\n\t\tif (!skb_queue_empty(&tp->ucopy.prequeue)) {\n\t\t\tint chunk;",
"\t\t\ttp->ucopy.len = copied > 0 ? len : 0;",
"\t\t\ttcp_prequeue_process(sk);",
"\t\t\tif (copied > 0 && (chunk = len - tp->ucopy.len) != 0) {\n\t\t\t\tNET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPDIRECTCOPYFROMPREQUEUE, chunk);\n\t\t\t\tlen -= chunk;\n\t\t\t\tcopied += chunk;\n\t\t\t}\n\t\t}",
"\t\ttp->ucopy.task = NULL;\n\t\ttp->ucopy.len = 0;\n\t}",
"\t/* According to UNIX98, msg_name/msg_namelen are ignored\n\t * on connected socket. I was just happy when found this 8) --ANK\n\t */",
"\t/* Clean up data we have read: This will do ACK frames. */\n\ttcp_cleanup_rbuf(sk, copied);",
"\trelease_sock(sk);\n\treturn copied;",
"out:\n\trelease_sock(sk);\n\treturn err;",
"recv_urg:\n\terr = tcp_recv_urg(sk, msg, len, flags);\n\tgoto out;",
"recv_sndq:\n\terr = tcp_peek_sndq(sk, msg, len);\n\tgoto out;\n}\nEXPORT_SYMBOL(tcp_recvmsg);",
"void tcp_set_state(struct sock *sk, int state)\n{\n\tint oldstate = sk->sk_state;",
"\tswitch (state) {\n\tcase TCP_ESTABLISHED:\n\t\tif (oldstate != TCP_ESTABLISHED)\n\t\t\tTCP_INC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);\n\t\tbreak;",
"\tcase TCP_CLOSE:\n\t\tif (oldstate == TCP_CLOSE_WAIT || oldstate == TCP_ESTABLISHED)\n\t\t\tTCP_INC_STATS(sock_net(sk), TCP_MIB_ESTABRESETS);",
"\t\tsk->sk_prot->unhash(sk);\n\t\tif (inet_csk(sk)->icsk_bind_hash &&\n\t\t !(sk->sk_userlocks & SOCK_BINDPORT_LOCK))\n\t\t\tinet_put_port(sk);\n\t\t/* fall through */\n\tdefault:\n\t\tif (oldstate == TCP_ESTABLISHED)\n\t\t\tTCP_DEC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);\n\t}",
"\t/* Change state AFTER socket is unhashed to avoid closed\n\t * socket sitting in hash tables.\n\t */\n\tsk_state_store(sk, state);",
"#ifdef STATE_TRACE\n\tSOCK_DEBUG(sk, \"TCP sk=%p, State %s -> %s\\n\", sk, statename[oldstate], statename[state]);\n#endif\n}\nEXPORT_SYMBOL_GPL(tcp_set_state);",
"/*\n *\tState processing on a close. This implements the state shift for\n *\tsending our FIN frame. Note that we only send a FIN for some\n *\tstates. A shutdown() may have already sent the FIN, or we may be\n *\tclosed.\n */",
"static const unsigned char new_state[16] = {\n /* current state: new state: action:\t*/\n [0 /* (Invalid) */]\t= TCP_CLOSE,\n [TCP_ESTABLISHED]\t= TCP_FIN_WAIT1 | TCP_ACTION_FIN,\n [TCP_SYN_SENT]\t= TCP_CLOSE,\n [TCP_SYN_RECV]\t= TCP_FIN_WAIT1 | TCP_ACTION_FIN,\n [TCP_FIN_WAIT1]\t= TCP_FIN_WAIT1,\n [TCP_FIN_WAIT2]\t= TCP_FIN_WAIT2,\n [TCP_TIME_WAIT]\t= TCP_CLOSE,\n [TCP_CLOSE]\t\t= TCP_CLOSE,\n [TCP_CLOSE_WAIT]\t= TCP_LAST_ACK | TCP_ACTION_FIN,\n [TCP_LAST_ACK]\t= TCP_LAST_ACK,\n [TCP_LISTEN]\t\t= TCP_CLOSE,\n [TCP_CLOSING]\t\t= TCP_CLOSING,\n [TCP_NEW_SYN_RECV]\t= TCP_CLOSE,\t/* should not happen ! */\n};",
"static int tcp_close_state(struct sock *sk)\n{\n\tint next = (int)new_state[sk->sk_state];\n\tint ns = next & TCP_STATE_MASK;",
"\ttcp_set_state(sk, ns);",
"\treturn next & TCP_ACTION_FIN;\n}",
"/*\n *\tShutdown the sending side of a connection. Much like close except\n *\tthat we don't receive shut down or sock_set_flag(sk, SOCK_DEAD).\n */",
"void tcp_shutdown(struct sock *sk, int how)\n{\n\t/*\tWe need to grab some memory, and put together a FIN,\n\t *\tand then put it into the queue to be sent.\n\t *\t\tTim MacKenzie(tym@dibbler.cs.monash.edu.au) 4 Dec '92.\n\t */\n\tif (!(how & SEND_SHUTDOWN))\n\t\treturn;",
"\t/* If we've already sent a FIN, or it's a closed state, skip this. */\n\tif ((1 << sk->sk_state) &\n\t (TCPF_ESTABLISHED | TCPF_SYN_SENT |\n\t TCPF_SYN_RECV | TCPF_CLOSE_WAIT)) {\n\t\t/* Clear out any half completed packets. FIN if needed. */\n\t\tif (tcp_close_state(sk))\n\t\t\ttcp_send_fin(sk);\n\t}\n}\nEXPORT_SYMBOL(tcp_shutdown);",
"bool tcp_check_oom(struct sock *sk, int shift)\n{\n\tbool too_many_orphans, out_of_socket_memory;",
"\ttoo_many_orphans = tcp_too_many_orphans(sk, shift);\n\tout_of_socket_memory = tcp_out_of_memory(sk);",
"\tif (too_many_orphans)\n\t\tnet_info_ratelimited(\"too many orphaned sockets\\n\");\n\tif (out_of_socket_memory)\n\t\tnet_info_ratelimited(\"out of memory -- consider tuning tcp_mem\\n\");\n\treturn too_many_orphans || out_of_socket_memory;\n}",
"void tcp_close(struct sock *sk, long timeout)\n{\n\tstruct sk_buff *skb;\n\tint data_was_unread = 0;\n\tint state;",
"\tlock_sock(sk);\n\tsk->sk_shutdown = SHUTDOWN_MASK;",
"\tif (sk->sk_state == TCP_LISTEN) {\n\t\ttcp_set_state(sk, TCP_CLOSE);",
"\t\t/* Special case. */\n\t\tinet_csk_listen_stop(sk);",
"\t\tgoto adjudge_to_death;\n\t}",
"\t/* We need to flush the recv. buffs. We do this only on the\n\t * descriptor close, not protocol-sourced closes, because the\n\t * reader process may not have drained the data yet!\n\t */\n\twhile ((skb = __skb_dequeue(&sk->sk_receive_queue)) != NULL) {\n\t\tu32 len = TCP_SKB_CB(skb)->end_seq - TCP_SKB_CB(skb)->seq;",
"\t\tif (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)\n\t\t\tlen--;\n\t\tdata_was_unread += len;\n\t\t__kfree_skb(skb);\n\t}",
"\tsk_mem_reclaim(sk);",
"\t/* If socket has been already reset (e.g. in tcp_reset()) - kill it. */\n\tif (sk->sk_state == TCP_CLOSE)\n\t\tgoto adjudge_to_death;",
"\t/* As outlined in RFC 2525, section 2.17, we send a RST here because\n\t * data was lost. To witness the awful effects of the old behavior of\n\t * always doing a FIN, run an older 2.1.x kernel or 2.0.x, start a bulk\n\t * GET in an FTP client, suspend the process, wait for the client to\n\t * advertise a zero window, then kill -9 the FTP client, wheee...\n\t * Note: timeout is always zero in such a case.\n\t */\n\tif (unlikely(tcp_sk(sk)->repair)) {\n\t\tsk->sk_prot->disconnect(sk, 0);\n\t} else if (data_was_unread) {\n\t\t/* Unread data was tossed, zap the connection. */\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONCLOSE);\n\t\ttcp_set_state(sk, TCP_CLOSE);\n\t\ttcp_send_active_reset(sk, sk->sk_allocation);\n\t} else if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) {\n\t\t/* Check zero linger _after_ checking for unread data. */\n\t\tsk->sk_prot->disconnect(sk, 0);\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA);\n\t} else if (tcp_close_state(sk)) {\n\t\t/* We FIN if the application ate all the data before\n\t\t * zapping the connection.\n\t\t */",
"\t\t/* RED-PEN. Formally speaking, we have broken TCP state\n\t\t * machine. State transitions:\n\t\t *\n\t\t * TCP_ESTABLISHED -> TCP_FIN_WAIT1\n\t\t * TCP_SYN_RECV\t-> TCP_FIN_WAIT1 (forget it, it's impossible)\n\t\t * TCP_CLOSE_WAIT -> TCP_LAST_ACK\n\t\t *\n\t\t * are legal only when FIN has been sent (i.e. in window),\n\t\t * rather than queued out of window. Purists blame.\n\t\t *\n\t\t * F.e. \"RFC state\" is ESTABLISHED,\n\t\t * if Linux state is FIN-WAIT-1, but FIN is still not sent.\n\t\t *\n\t\t * The visible declinations are that sometimes\n\t\t * we enter time-wait state, when it is not required really\n\t\t * (harmless), do not send active resets, when they are\n\t\t * required by specs (TCP_ESTABLISHED, TCP_CLOSE_WAIT, when\n\t\t * they look as CLOSING or LAST_ACK for Linux)\n\t\t * Probably, I missed some more holelets.\n\t\t * \t\t\t\t\t\t--ANK\n\t\t * XXX (TFO) - To start off we don't support SYN+ACK+FIN\n\t\t * in a single packet! (May consider it later but will\n\t\t * probably need API support or TCP_CORK SYN-ACK until\n\t\t * data is written and socket is closed.)\n\t\t */\n\t\ttcp_send_fin(sk);\n\t}",
"\tsk_stream_wait_close(sk, timeout);",
"adjudge_to_death:\n\tstate = sk->sk_state;\n\tsock_hold(sk);\n\tsock_orphan(sk);",
"\t/* It is the last release_sock in its life. It will remove backlog. */\n\trelease_sock(sk);",
"\n\t/* Now socket is owned by kernel and we acquire BH lock\n\t to finish close. No need to check for user refs.\n\t */\n\tlocal_bh_disable();\n\tbh_lock_sock(sk);\n\tWARN_ON(sock_owned_by_user(sk));",
"\tpercpu_counter_inc(sk->sk_prot->orphan_count);",
"\t/* Have we already been destroyed by a softirq or backlog? */\n\tif (state != TCP_CLOSE && sk->sk_state == TCP_CLOSE)\n\t\tgoto out;",
"\t/*\tThis is a (useful) BSD violating of the RFC. There is a\n\t *\tproblem with TCP as specified in that the other end could\n\t *\tkeep a socket open forever with no application left this end.\n\t *\tWe use a 1 minute timeout (about the same as BSD) then kill\n\t *\tour end. If they send after that then tough - BUT: long enough\n\t *\tthat we won't make the old 4*rto = almost no time - whoops\n\t *\treset mistake.\n\t *\n\t *\tNope, it was not mistake. It is really desired behaviour\n\t *\tf.e. on http servers, when such sockets are useless, but\n\t *\tconsume significant resources. Let's do it with special\n\t *\tlinger2\toption.\t\t\t\t\t--ANK\n\t */",
"\tif (sk->sk_state == TCP_FIN_WAIT2) {\n\t\tstruct tcp_sock *tp = tcp_sk(sk);\n\t\tif (tp->linger2 < 0) {\n\t\t\ttcp_set_state(sk, TCP_CLOSE);\n\t\t\ttcp_send_active_reset(sk, GFP_ATOMIC);\n\t\t\t__NET_INC_STATS(sock_net(sk),\n\t\t\t\t\tLINUX_MIB_TCPABORTONLINGER);\n\t\t} else {\n\t\t\tconst int tmo = tcp_fin_time(sk);",
"\t\t\tif (tmo > TCP_TIMEWAIT_LEN) {\n\t\t\t\tinet_csk_reset_keepalive_timer(sk,\n\t\t\t\t\t\ttmo - TCP_TIMEWAIT_LEN);\n\t\t\t} else {\n\t\t\t\ttcp_time_wait(sk, TCP_FIN_WAIT2, tmo);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t}\n\tif (sk->sk_state != TCP_CLOSE) {\n\t\tsk_mem_reclaim(sk);\n\t\tif (tcp_check_oom(sk, 0)) {\n\t\t\ttcp_set_state(sk, TCP_CLOSE);\n\t\t\ttcp_send_active_reset(sk, GFP_ATOMIC);\n\t\t\t__NET_INC_STATS(sock_net(sk),\n\t\t\t\t\tLINUX_MIB_TCPABORTONMEMORY);\n\t\t}\n\t}",
"\tif (sk->sk_state == TCP_CLOSE) {\n\t\tstruct request_sock *req = tcp_sk(sk)->fastopen_rsk;\n\t\t/* We could get here with a non-NULL req if the socket is\n\t\t * aborted (e.g., closed with unread data) before 3WHS\n\t\t * finishes.\n\t\t */\n\t\tif (req)\n\t\t\treqsk_fastopen_remove(sk, req, false);\n\t\tinet_csk_destroy_sock(sk);\n\t}\n\t/* Otherwise, socket is reprieved until protocol close. */",
"out:\n\tbh_unlock_sock(sk);\n\tlocal_bh_enable();\n\tsock_put(sk);\n}\nEXPORT_SYMBOL(tcp_close);",
"/* These states need RST on ABORT according to RFC793 */",
"static inline bool tcp_need_reset(int state)\n{\n\treturn (1 << state) &\n\t (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_FIN_WAIT1 |\n\t\tTCPF_FIN_WAIT2 | TCPF_SYN_RECV);\n}",
"int tcp_disconnect(struct sock *sk, int flags)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint err = 0;\n\tint old_state = sk->sk_state;",
"\tif (old_state != TCP_CLOSE)\n\t\ttcp_set_state(sk, TCP_CLOSE);",
"\t/* ABORT function of RFC793 */\n\tif (old_state == TCP_LISTEN) {\n\t\tinet_csk_listen_stop(sk);\n\t} else if (unlikely(tp->repair)) {\n\t\tsk->sk_err = ECONNABORTED;\n\t} else if (tcp_need_reset(old_state) ||\n\t\t (tp->snd_nxt != tp->write_seq &&\n\t\t (1 << old_state) & (TCPF_CLOSING | TCPF_LAST_ACK))) {\n\t\t/* The last check adjusts for discrepancy of Linux wrt. RFC\n\t\t * states\n\t\t */\n\t\ttcp_send_active_reset(sk, gfp_any());\n\t\tsk->sk_err = ECONNRESET;\n\t} else if (old_state == TCP_SYN_SENT)\n\t\tsk->sk_err = ECONNRESET;",
"\ttcp_clear_xmit_timers(sk);\n\t__skb_queue_purge(&sk->sk_receive_queue);\n\ttcp_write_queue_purge(sk);\n\ttcp_fastopen_active_disable_ofo_check(sk);\n\tskb_rbtree_purge(&tp->out_of_order_queue);",
"\tinet->inet_dport = 0;",
"\tif (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))\n\t\tinet_reset_saddr(sk);",
"\tsk->sk_shutdown = 0;\n\tsock_reset_flag(sk, SOCK_DONE);\n\ttp->srtt_us = 0;\n\ttp->write_seq += tp->max_window + 2;\n\tif (tp->write_seq == 0)\n\t\ttp->write_seq = 1;\n\ticsk->icsk_backoff = 0;\n\ttp->snd_cwnd = 2;\n\ticsk->icsk_probes_out = 0;\n\ttp->packets_out = 0;\n\ttp->snd_ssthresh = TCP_INFINITE_SSTHRESH;\n\ttp->snd_cwnd_cnt = 0;\n\ttp->window_clamp = 0;\n\ttcp_set_ca_state(sk, TCP_CA_Open);\n\ttcp_clear_retrans(tp);\n\tinet_csk_delack_init(sk);",
"",
"\ttcp_init_send_head(sk);\n\tmemset(&tp->rx_opt, 0, sizeof(tp->rx_opt));\n\t__sk_dst_reset(sk);\n\ttcp_saved_syn_free(tp);",
"\t/* Clean up fastopen related fields */\n\ttcp_free_fastopen_req(tp);\n\tinet->defer_connect = 0;",
"\tWARN_ON(inet->inet_num && !icsk->icsk_bind_hash);",
"\tsk->sk_error_report(sk);\n\treturn err;\n}\nEXPORT_SYMBOL(tcp_disconnect);",
"static inline bool tcp_can_repair_sock(const struct sock *sk)\n{\n\treturn ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN) &&\n\t\t(sk->sk_state != TCP_LISTEN);\n}",
"static int tcp_repair_set_window(struct tcp_sock *tp, char __user *optbuf, int len)\n{\n\tstruct tcp_repair_window opt;",
"\tif (!tp->repair)\n\t\treturn -EPERM;",
"\tif (len != sizeof(opt))\n\t\treturn -EINVAL;",
"\tif (copy_from_user(&opt, optbuf, sizeof(opt)))\n\t\treturn -EFAULT;",
"\tif (opt.max_window < opt.snd_wnd)\n\t\treturn -EINVAL;",
"\tif (after(opt.snd_wl1, tp->rcv_nxt + opt.rcv_wnd))\n\t\treturn -EINVAL;",
"\tif (after(opt.rcv_wup, tp->rcv_nxt))\n\t\treturn -EINVAL;",
"\ttp->snd_wl1\t= opt.snd_wl1;\n\ttp->snd_wnd\t= opt.snd_wnd;\n\ttp->max_window\t= opt.max_window;",
"\ttp->rcv_wnd\t= opt.rcv_wnd;\n\ttp->rcv_wup\t= opt.rcv_wup;",
"\treturn 0;\n}",
"static int tcp_repair_options_est(struct tcp_sock *tp,\n\t\tstruct tcp_repair_opt __user *optbuf, unsigned int len)\n{\n\tstruct tcp_repair_opt opt;",
"\twhile (len >= sizeof(opt)) {\n\t\tif (copy_from_user(&opt, optbuf, sizeof(opt)))\n\t\t\treturn -EFAULT;",
"\t\toptbuf++;\n\t\tlen -= sizeof(opt);",
"\t\tswitch (opt.opt_code) {\n\t\tcase TCPOPT_MSS:\n\t\t\ttp->rx_opt.mss_clamp = opt.opt_val;\n\t\t\tbreak;\n\t\tcase TCPOPT_WINDOW:\n\t\t\t{\n\t\t\t\tu16 snd_wscale = opt.opt_val & 0xFFFF;\n\t\t\t\tu16 rcv_wscale = opt.opt_val >> 16;",
"\t\t\t\tif (snd_wscale > TCP_MAX_WSCALE || rcv_wscale > TCP_MAX_WSCALE)\n\t\t\t\t\treturn -EFBIG;",
"\t\t\t\ttp->rx_opt.snd_wscale = snd_wscale;\n\t\t\t\ttp->rx_opt.rcv_wscale = rcv_wscale;\n\t\t\t\ttp->rx_opt.wscale_ok = 1;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TCPOPT_SACK_PERM:\n\t\t\tif (opt.opt_val != 0)\n\t\t\t\treturn -EINVAL;",
"\t\t\ttp->rx_opt.sack_ok |= TCP_SACK_SEEN;\n\t\t\tif (sysctl_tcp_fack)\n\t\t\t\ttcp_enable_fack(tp);\n\t\t\tbreak;\n\t\tcase TCPOPT_TIMESTAMP:\n\t\t\tif (opt.opt_val != 0)\n\t\t\t\treturn -EINVAL;",
"\t\t\ttp->rx_opt.tstamp_ok = 1;\n\t\t\tbreak;\n\t\t}\n\t}",
"\treturn 0;\n}",
"/*\n *\tSocket option code for TCP.\n */\nstatic int do_tcp_setsockopt(struct sock *sk, int level,\n\t\tint optname, char __user *optval, unsigned int optlen)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct net *net = sock_net(sk);\n\tint val;\n\tint err = 0;",
"\t/* These are data/string values, all the others are ints */\n\tswitch (optname) {\n\tcase TCP_CONGESTION: {\n\t\tchar name[TCP_CA_NAME_MAX];",
"\t\tif (optlen < 1)\n\t\t\treturn -EINVAL;",
"\t\tval = strncpy_from_user(name, optval,\n\t\t\t\t\tmin_t(long, TCP_CA_NAME_MAX-1, optlen));\n\t\tif (val < 0)\n\t\t\treturn -EFAULT;\n\t\tname[val] = 0;",
"\t\tlock_sock(sk);\n\t\terr = tcp_set_congestion_control(sk, name);\n\t\trelease_sock(sk);\n\t\treturn err;\n\t}\n\tdefault:\n\t\t/* fallthru */\n\t\tbreak;\n\t}",
"\tif (optlen < sizeof(int))\n\t\treturn -EINVAL;",
"\tif (get_user(val, (int __user *)optval))\n\t\treturn -EFAULT;",
"\tlock_sock(sk);",
"\tswitch (optname) {\n\tcase TCP_MAXSEG:\n\t\t/* Values greater than interface MTU won't take effect. However\n\t\t * at the point when this call is done we typically don't yet\n\t\t * know which interface is going to be used */\n\t\tif (val && (val < TCP_MIN_MSS || val > MAX_TCP_WINDOW)) {\n\t\t\terr = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\t\ttp->rx_opt.user_mss = val;\n\t\tbreak;",
"\tcase TCP_NODELAY:\n\t\tif (val) {\n\t\t\t/* TCP_NODELAY is weaker than TCP_CORK, so that\n\t\t\t * this option on corked socket is remembered, but\n\t\t\t * it is not activated until cork is cleared.\n\t\t\t *\n\t\t\t * However, when TCP_NODELAY is set we make\n\t\t\t * an explicit push, which overrides even TCP_CORK\n\t\t\t * for currently queued segments.\n\t\t\t */\n\t\t\ttp->nonagle |= TCP_NAGLE_OFF|TCP_NAGLE_PUSH;\n\t\t\ttcp_push_pending_frames(sk);\n\t\t} else {\n\t\t\ttp->nonagle &= ~TCP_NAGLE_OFF;\n\t\t}\n\t\tbreak;",
"\tcase TCP_THIN_LINEAR_TIMEOUTS:\n\t\tif (val < 0 || val > 1)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ttp->thin_lto = val;\n\t\tbreak;",
"\tcase TCP_THIN_DUPACK:\n\t\tif (val < 0 || val > 1)\n\t\t\terr = -EINVAL;\n\t\tbreak;",
"\tcase TCP_REPAIR:\n\t\tif (!tcp_can_repair_sock(sk))\n\t\t\terr = -EPERM;\n\t\telse if (val == 1) {\n\t\t\ttp->repair = 1;\n\t\t\tsk->sk_reuse = SK_FORCE_REUSE;\n\t\t\ttp->repair_queue = TCP_NO_QUEUE;\n\t\t} else if (val == 0) {\n\t\t\ttp->repair = 0;\n\t\t\tsk->sk_reuse = SK_NO_REUSE;\n\t\t\ttcp_send_window_probe(sk);\n\t\t} else\n\t\t\terr = -EINVAL;",
"\t\tbreak;",
"\tcase TCP_REPAIR_QUEUE:\n\t\tif (!tp->repair)\n\t\t\terr = -EPERM;\n\t\telse if (val < TCP_QUEUES_NR)\n\t\t\ttp->repair_queue = val;\n\t\telse\n\t\t\terr = -EINVAL;\n\t\tbreak;",
"\tcase TCP_QUEUE_SEQ:\n\t\tif (sk->sk_state != TCP_CLOSE)\n\t\t\terr = -EPERM;\n\t\telse if (tp->repair_queue == TCP_SEND_QUEUE)\n\t\t\ttp->write_seq = val;\n\t\telse if (tp->repair_queue == TCP_RECV_QUEUE)\n\t\t\ttp->rcv_nxt = val;\n\t\telse\n\t\t\terr = -EINVAL;\n\t\tbreak;",
"\tcase TCP_REPAIR_OPTIONS:\n\t\tif (!tp->repair)\n\t\t\terr = -EINVAL;\n\t\telse if (sk->sk_state == TCP_ESTABLISHED)\n\t\t\terr = tcp_repair_options_est(tp,\n\t\t\t\t\t(struct tcp_repair_opt __user *)optval,\n\t\t\t\t\toptlen);\n\t\telse\n\t\t\terr = -EPERM;\n\t\tbreak;",
"\tcase TCP_CORK:\n\t\t/* When set indicates to always queue non-full frames.\n\t\t * Later the user clears this option and we transmit\n\t\t * any pending partial frames in the queue. This is\n\t\t * meant to be used alongside sendfile() to get properly\n\t\t * filled frames when the user (for example) must write\n\t\t * out headers with a write() call first and then use\n\t\t * sendfile to send out the data parts.\n\t\t *\n\t\t * TCP_CORK can be set together with TCP_NODELAY and it is\n\t\t * stronger than TCP_NODELAY.\n\t\t */\n\t\tif (val) {\n\t\t\ttp->nonagle |= TCP_NAGLE_CORK;\n\t\t} else {\n\t\t\ttp->nonagle &= ~TCP_NAGLE_CORK;\n\t\t\tif (tp->nonagle&TCP_NAGLE_OFF)\n\t\t\t\ttp->nonagle |= TCP_NAGLE_PUSH;\n\t\t\ttcp_push_pending_frames(sk);\n\t\t}\n\t\tbreak;",
"\tcase TCP_KEEPIDLE:\n\t\tif (val < 1 || val > MAX_TCP_KEEPIDLE)\n\t\t\terr = -EINVAL;\n\t\telse {\n\t\t\ttp->keepalive_time = val * HZ;\n\t\t\tif (sock_flag(sk, SOCK_KEEPOPEN) &&\n\t\t\t !((1 << sk->sk_state) &\n\t\t\t (TCPF_CLOSE | TCPF_LISTEN))) {\n\t\t\t\tu32 elapsed = keepalive_time_elapsed(tp);\n\t\t\t\tif (tp->keepalive_time > elapsed)\n\t\t\t\t\telapsed = tp->keepalive_time - elapsed;\n\t\t\t\telse\n\t\t\t\t\telapsed = 0;\n\t\t\t\tinet_csk_reset_keepalive_timer(sk, elapsed);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase TCP_KEEPINTVL:\n\t\tif (val < 1 || val > MAX_TCP_KEEPINTVL)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ttp->keepalive_intvl = val * HZ;\n\t\tbreak;\n\tcase TCP_KEEPCNT:\n\t\tif (val < 1 || val > MAX_TCP_KEEPCNT)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ttp->keepalive_probes = val;\n\t\tbreak;\n\tcase TCP_SYNCNT:\n\t\tif (val < 1 || val > MAX_TCP_SYNCNT)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ticsk->icsk_syn_retries = val;\n\t\tbreak;",
"\tcase TCP_SAVE_SYN:\n\t\tif (val < 0 || val > 1)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ttp->save_syn = val;\n\t\tbreak;",
"\tcase TCP_LINGER2:\n\t\tif (val < 0)\n\t\t\ttp->linger2 = -1;\n\t\telse if (val > net->ipv4.sysctl_tcp_fin_timeout / HZ)\n\t\t\ttp->linger2 = 0;\n\t\telse\n\t\t\ttp->linger2 = val * HZ;\n\t\tbreak;",
"\tcase TCP_DEFER_ACCEPT:\n\t\t/* Translate value in seconds to number of retransmits */\n\t\ticsk->icsk_accept_queue.rskq_defer_accept =\n\t\t\tsecs_to_retrans(val, TCP_TIMEOUT_INIT / HZ,\n\t\t\t\t\tTCP_RTO_MAX / HZ);\n\t\tbreak;",
"\tcase TCP_WINDOW_CLAMP:\n\t\tif (!val) {\n\t\t\tif (sk->sk_state != TCP_CLOSE) {\n\t\t\t\terr = -EINVAL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttp->window_clamp = 0;\n\t\t} else\n\t\t\ttp->window_clamp = val < SOCK_MIN_RCVBUF / 2 ?\n\t\t\t\t\t\tSOCK_MIN_RCVBUF / 2 : val;\n\t\tbreak;",
"\tcase TCP_QUICKACK:\n\t\tif (!val) {\n\t\t\ticsk->icsk_ack.pingpong = 1;\n\t\t} else {\n\t\t\ticsk->icsk_ack.pingpong = 0;\n\t\t\tif ((1 << sk->sk_state) &\n\t\t\t (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) &&\n\t\t\t inet_csk_ack_scheduled(sk)) {\n\t\t\t\ticsk->icsk_ack.pending |= ICSK_ACK_PUSHED;\n\t\t\t\ttcp_cleanup_rbuf(sk, 1);\n\t\t\t\tif (!(val & 1))\n\t\t\t\t\ticsk->icsk_ack.pingpong = 1;\n\t\t\t}\n\t\t}\n\t\tbreak;",
"#ifdef CONFIG_TCP_MD5SIG\n\tcase TCP_MD5SIG:\n\t\t/* Read the IP->Key mappings from userspace */\n\t\terr = tp->af_specific->md5_parse(sk, optval, optlen);\n\t\tbreak;\n#endif\n\tcase TCP_USER_TIMEOUT:\n\t\t/* Cap the max time in ms TCP will retry or probe the window\n\t\t * before giving up and aborting (ETIMEDOUT) a connection.\n\t\t */\n\t\tif (val < 0)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ticsk->icsk_user_timeout = msecs_to_jiffies(val);\n\t\tbreak;",
"\tcase TCP_FASTOPEN:\n\t\tif (val >= 0 && ((1 << sk->sk_state) & (TCPF_CLOSE |\n\t\t TCPF_LISTEN))) {\n\t\t\ttcp_fastopen_init_key_once(true);",
"\t\t\tfastopen_queue_tune(sk, val);\n\t\t} else {\n\t\t\terr = -EINVAL;\n\t\t}\n\t\tbreak;\n\tcase TCP_FASTOPEN_CONNECT:\n\t\tif (val > 1 || val < 0) {\n\t\t\terr = -EINVAL;\n\t\t} else if (sysctl_tcp_fastopen & TFO_CLIENT_ENABLE) {\n\t\t\tif (sk->sk_state == TCP_CLOSE)\n\t\t\t\ttp->fastopen_connect = val;\n\t\t\telse\n\t\t\t\terr = -EINVAL;\n\t\t} else {\n\t\t\terr = -EOPNOTSUPP;\n\t\t}\n\t\tbreak;\n\tcase TCP_TIMESTAMP:\n\t\tif (!tp->repair)\n\t\t\terr = -EPERM;\n\t\telse\n\t\t\ttp->tsoffset = val - tcp_time_stamp;\n\t\tbreak;\n\tcase TCP_REPAIR_WINDOW:\n\t\terr = tcp_repair_set_window(tp, optval, optlen);\n\t\tbreak;\n\tcase TCP_NOTSENT_LOWAT:\n\t\ttp->notsent_lowat = val;\n\t\tsk->sk_write_space(sk);\n\t\tbreak;\n\tdefault:\n\t\terr = -ENOPROTOOPT;\n\t\tbreak;\n\t}",
"\trelease_sock(sk);\n\treturn err;\n}",
"int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,\n\t\t unsigned int optlen)\n{\n\tconst struct inet_connection_sock *icsk = inet_csk(sk);",
"\tif (level != SOL_TCP)\n\t\treturn icsk->icsk_af_ops->setsockopt(sk, level, optname,\n\t\t\t\t\t\t optval, optlen);\n\treturn do_tcp_setsockopt(sk, level, optname, optval, optlen);\n}\nEXPORT_SYMBOL(tcp_setsockopt);",
"#ifdef CONFIG_COMPAT\nint compat_tcp_setsockopt(struct sock *sk, int level, int optname,\n\t\t\t char __user *optval, unsigned int optlen)\n{\n\tif (level != SOL_TCP)\n\t\treturn inet_csk_compat_setsockopt(sk, level, optname,\n\t\t\t\t\t\t optval, optlen);\n\treturn do_tcp_setsockopt(sk, level, optname, optval, optlen);\n}\nEXPORT_SYMBOL(compat_tcp_setsockopt);\n#endif",
"static void tcp_get_info_chrono_stats(const struct tcp_sock *tp,\n\t\t\t\t struct tcp_info *info)\n{\n\tu64 stats[__TCP_CHRONO_MAX], total = 0;\n\tenum tcp_chrono i;",
"\tfor (i = TCP_CHRONO_BUSY; i < __TCP_CHRONO_MAX; ++i) {\n\t\tstats[i] = tp->chrono_stat[i - 1];\n\t\tif (i == tp->chrono_type)\n\t\t\tstats[i] += tcp_time_stamp - tp->chrono_start;\n\t\tstats[i] *= USEC_PER_SEC / HZ;\n\t\ttotal += stats[i];\n\t}",
"\tinfo->tcpi_busy_time = total;\n\tinfo->tcpi_rwnd_limited = stats[TCP_CHRONO_RWND_LIMITED];\n\tinfo->tcpi_sndbuf_limited = stats[TCP_CHRONO_SNDBUF_LIMITED];\n}",
"/* Return information about state of tcp endpoint in API format. */\nvoid tcp_get_info(struct sock *sk, struct tcp_info *info)\n{\n\tconst struct tcp_sock *tp = tcp_sk(sk); /* iff sk_type == SOCK_STREAM */\n\tconst struct inet_connection_sock *icsk = inet_csk(sk);\n\tu32 now, intv;\n\tu64 rate64;\n\tbool slow;\n\tu32 rate;",
"\tmemset(info, 0, sizeof(*info));\n\tif (sk->sk_type != SOCK_STREAM)\n\t\treturn;",
"\tinfo->tcpi_state = sk_state_load(sk);",
"\t/* Report meaningful fields for all TCP states, including listeners */\n\trate = READ_ONCE(sk->sk_pacing_rate);\n\trate64 = rate != ~0U ? rate : ~0ULL;\n\tinfo->tcpi_pacing_rate = rate64;",
"\trate = READ_ONCE(sk->sk_max_pacing_rate);\n\trate64 = rate != ~0U ? rate : ~0ULL;\n\tinfo->tcpi_max_pacing_rate = rate64;",
"\tinfo->tcpi_reordering = tp->reordering;\n\tinfo->tcpi_snd_cwnd = tp->snd_cwnd;",
"\tif (info->tcpi_state == TCP_LISTEN) {\n\t\t/* listeners aliased fields :\n\t\t * tcpi_unacked -> Number of children ready for accept()\n\t\t * tcpi_sacked -> max backlog\n\t\t */\n\t\tinfo->tcpi_unacked = sk->sk_ack_backlog;\n\t\tinfo->tcpi_sacked = sk->sk_max_ack_backlog;\n\t\treturn;\n\t}",
"\tslow = lock_sock_fast(sk);",
"\tinfo->tcpi_ca_state = icsk->icsk_ca_state;\n\tinfo->tcpi_retransmits = icsk->icsk_retransmits;\n\tinfo->tcpi_probes = icsk->icsk_probes_out;\n\tinfo->tcpi_backoff = icsk->icsk_backoff;",
"\tif (tp->rx_opt.tstamp_ok)\n\t\tinfo->tcpi_options |= TCPI_OPT_TIMESTAMPS;\n\tif (tcp_is_sack(tp))\n\t\tinfo->tcpi_options |= TCPI_OPT_SACK;\n\tif (tp->rx_opt.wscale_ok) {\n\t\tinfo->tcpi_options |= TCPI_OPT_WSCALE;\n\t\tinfo->tcpi_snd_wscale = tp->rx_opt.snd_wscale;\n\t\tinfo->tcpi_rcv_wscale = tp->rx_opt.rcv_wscale;\n\t}",
"\tif (tp->ecn_flags & TCP_ECN_OK)\n\t\tinfo->tcpi_options |= TCPI_OPT_ECN;\n\tif (tp->ecn_flags & TCP_ECN_SEEN)\n\t\tinfo->tcpi_options |= TCPI_OPT_ECN_SEEN;\n\tif (tp->syn_data_acked)\n\t\tinfo->tcpi_options |= TCPI_OPT_SYN_DATA;",
"\tinfo->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto);\n\tinfo->tcpi_ato = jiffies_to_usecs(icsk->icsk_ack.ato);\n\tinfo->tcpi_snd_mss = tp->mss_cache;\n\tinfo->tcpi_rcv_mss = icsk->icsk_ack.rcv_mss;",
"\tinfo->tcpi_unacked = tp->packets_out;\n\tinfo->tcpi_sacked = tp->sacked_out;",
"\tinfo->tcpi_lost = tp->lost_out;\n\tinfo->tcpi_retrans = tp->retrans_out;\n\tinfo->tcpi_fackets = tp->fackets_out;",
"\tnow = tcp_time_stamp;\n\tinfo->tcpi_last_data_sent = jiffies_to_msecs(now - tp->lsndtime);\n\tinfo->tcpi_last_data_recv = jiffies_to_msecs(now - icsk->icsk_ack.lrcvtime);\n\tinfo->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp);",
"\tinfo->tcpi_pmtu = icsk->icsk_pmtu_cookie;\n\tinfo->tcpi_rcv_ssthresh = tp->rcv_ssthresh;\n\tinfo->tcpi_rtt = tp->srtt_us >> 3;\n\tinfo->tcpi_rttvar = tp->mdev_us >> 2;\n\tinfo->tcpi_snd_ssthresh = tp->snd_ssthresh;\n\tinfo->tcpi_advmss = tp->advmss;",
"\tinfo->tcpi_rcv_rtt = tp->rcv_rtt_est.rtt_us >> 3;\n\tinfo->tcpi_rcv_space = tp->rcvq_space.space;",
"\tinfo->tcpi_total_retrans = tp->total_retrans;",
"\tinfo->tcpi_bytes_acked = tp->bytes_acked;\n\tinfo->tcpi_bytes_received = tp->bytes_received;\n\tinfo->tcpi_notsent_bytes = max_t(int, 0, tp->write_seq - tp->snd_nxt);\n\ttcp_get_info_chrono_stats(tp, info);",
"\tinfo->tcpi_segs_out = tp->segs_out;\n\tinfo->tcpi_segs_in = tp->segs_in;",
"\tinfo->tcpi_min_rtt = tcp_min_rtt(tp);\n\tinfo->tcpi_data_segs_in = tp->data_segs_in;\n\tinfo->tcpi_data_segs_out = tp->data_segs_out;",
"\tinfo->tcpi_delivery_rate_app_limited = tp->rate_app_limited ? 1 : 0;\n\trate = READ_ONCE(tp->rate_delivered);\n\tintv = READ_ONCE(tp->rate_interval_us);\n\tif (rate && intv) {\n\t\trate64 = (u64)rate * tp->mss_cache * USEC_PER_SEC;\n\t\tdo_div(rate64, intv);\n\t\tinfo->tcpi_delivery_rate = rate64;\n\t}\n\tunlock_sock_fast(sk, slow);\n}\nEXPORT_SYMBOL_GPL(tcp_get_info);",
"struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk)\n{\n\tconst struct tcp_sock *tp = tcp_sk(sk);\n\tstruct sk_buff *stats;\n\tstruct tcp_info info;",
"\tstats = alloc_skb(5 * nla_total_size_64bit(sizeof(u64)), GFP_ATOMIC);\n\tif (!stats)\n\t\treturn NULL;",
"\ttcp_get_info_chrono_stats(tp, &info);\n\tnla_put_u64_64bit(stats, TCP_NLA_BUSY,\n\t\t\t info.tcpi_busy_time, TCP_NLA_PAD);\n\tnla_put_u64_64bit(stats, TCP_NLA_RWND_LIMITED,\n\t\t\t info.tcpi_rwnd_limited, TCP_NLA_PAD);\n\tnla_put_u64_64bit(stats, TCP_NLA_SNDBUF_LIMITED,\n\t\t\t info.tcpi_sndbuf_limited, TCP_NLA_PAD);\n\tnla_put_u64_64bit(stats, TCP_NLA_DATA_SEGS_OUT,\n\t\t\t tp->data_segs_out, TCP_NLA_PAD);\n\tnla_put_u64_64bit(stats, TCP_NLA_TOTAL_RETRANS,\n\t\t\t tp->total_retrans, TCP_NLA_PAD);\n\treturn stats;\n}",
"static int do_tcp_getsockopt(struct sock *sk, int level,\n\t\tint optname, char __user *optval, int __user *optlen)\n{\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct net *net = sock_net(sk);\n\tint val, len;",
"\tif (get_user(len, optlen))\n\t\treturn -EFAULT;",
"\tlen = min_t(unsigned int, len, sizeof(int));",
"\tif (len < 0)\n\t\treturn -EINVAL;",
"\tswitch (optname) {\n\tcase TCP_MAXSEG:\n\t\tval = tp->mss_cache;\n\t\tif (!val && ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))\n\t\t\tval = tp->rx_opt.user_mss;\n\t\tif (tp->repair)\n\t\t\tval = tp->rx_opt.mss_clamp;\n\t\tbreak;\n\tcase TCP_NODELAY:\n\t\tval = !!(tp->nonagle&TCP_NAGLE_OFF);\n\t\tbreak;\n\tcase TCP_CORK:\n\t\tval = !!(tp->nonagle&TCP_NAGLE_CORK);\n\t\tbreak;\n\tcase TCP_KEEPIDLE:\n\t\tval = keepalive_time_when(tp) / HZ;\n\t\tbreak;\n\tcase TCP_KEEPINTVL:\n\t\tval = keepalive_intvl_when(tp) / HZ;\n\t\tbreak;\n\tcase TCP_KEEPCNT:\n\t\tval = keepalive_probes(tp);\n\t\tbreak;\n\tcase TCP_SYNCNT:\n\t\tval = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retries;\n\t\tbreak;\n\tcase TCP_LINGER2:\n\t\tval = tp->linger2;\n\t\tif (val >= 0)\n\t\t\tval = (val ? : net->ipv4.sysctl_tcp_fin_timeout) / HZ;\n\t\tbreak;\n\tcase TCP_DEFER_ACCEPT:\n\t\tval = retrans_to_secs(icsk->icsk_accept_queue.rskq_defer_accept,\n\t\t\t\t TCP_TIMEOUT_INIT / HZ, TCP_RTO_MAX / HZ);\n\t\tbreak;\n\tcase TCP_WINDOW_CLAMP:\n\t\tval = tp->window_clamp;\n\t\tbreak;\n\tcase TCP_INFO: {\n\t\tstruct tcp_info info;",
"\t\tif (get_user(len, optlen))\n\t\t\treturn -EFAULT;",
"\t\ttcp_get_info(sk, &info);",
"\t\tlen = min_t(unsigned int, len, sizeof(info));\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, &info, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tcase TCP_CC_INFO: {\n\t\tconst struct tcp_congestion_ops *ca_ops;\n\t\tunion tcp_cc_info info;\n\t\tsize_t sz = 0;\n\t\tint attr;",
"\t\tif (get_user(len, optlen))\n\t\t\treturn -EFAULT;",
"\t\tca_ops = icsk->icsk_ca_ops;\n\t\tif (ca_ops && ca_ops->get_info)\n\t\t\tsz = ca_ops->get_info(sk, ~0U, &attr, &info);",
"\t\tlen = min_t(unsigned int, len, sz);\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, &info, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tcase TCP_QUICKACK:\n\t\tval = !icsk->icsk_ack.pingpong;\n\t\tbreak;",
"\tcase TCP_CONGESTION:\n\t\tif (get_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tlen = min_t(unsigned int, len, TCP_CA_NAME_MAX);\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, icsk->icsk_ca_ops->name, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;",
"\tcase TCP_THIN_LINEAR_TIMEOUTS:\n\t\tval = tp->thin_lto;\n\t\tbreak;",
"\tcase TCP_THIN_DUPACK:\n\t\tval = 0;\n\t\tbreak;",
"\tcase TCP_REPAIR:\n\t\tval = tp->repair;\n\t\tbreak;",
"\tcase TCP_REPAIR_QUEUE:\n\t\tif (tp->repair)\n\t\t\tval = tp->repair_queue;\n\t\telse\n\t\t\treturn -EINVAL;\n\t\tbreak;",
"\tcase TCP_REPAIR_WINDOW: {\n\t\tstruct tcp_repair_window opt;",
"\t\tif (get_user(len, optlen))\n\t\t\treturn -EFAULT;",
"\t\tif (len != sizeof(opt))\n\t\t\treturn -EINVAL;",
"\t\tif (!tp->repair)\n\t\t\treturn -EPERM;",
"\t\topt.snd_wl1\t= tp->snd_wl1;\n\t\topt.snd_wnd\t= tp->snd_wnd;\n\t\topt.max_window\t= tp->max_window;\n\t\topt.rcv_wnd\t= tp->rcv_wnd;\n\t\topt.rcv_wup\t= tp->rcv_wup;",
"\t\tif (copy_to_user(optval, &opt, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tcase TCP_QUEUE_SEQ:\n\t\tif (tp->repair_queue == TCP_SEND_QUEUE)\n\t\t\tval = tp->write_seq;\n\t\telse if (tp->repair_queue == TCP_RECV_QUEUE)\n\t\t\tval = tp->rcv_nxt;\n\t\telse\n\t\t\treturn -EINVAL;\n\t\tbreak;",
"\tcase TCP_USER_TIMEOUT:\n\t\tval = jiffies_to_msecs(icsk->icsk_user_timeout);\n\t\tbreak;",
"\tcase TCP_FASTOPEN:\n\t\tval = icsk->icsk_accept_queue.fastopenq.max_qlen;\n\t\tbreak;",
"\tcase TCP_FASTOPEN_CONNECT:\n\t\tval = tp->fastopen_connect;\n\t\tbreak;",
"\tcase TCP_TIMESTAMP:\n\t\tval = tcp_time_stamp + tp->tsoffset;\n\t\tbreak;\n\tcase TCP_NOTSENT_LOWAT:\n\t\tval = tp->notsent_lowat;\n\t\tbreak;\n\tcase TCP_SAVE_SYN:\n\t\tval = tp->save_syn;\n\t\tbreak;\n\tcase TCP_SAVED_SYN: {\n\t\tif (get_user(len, optlen))\n\t\t\treturn -EFAULT;",
"\t\tlock_sock(sk);\n\t\tif (tp->saved_syn) {\n\t\t\tif (len < tp->saved_syn[0]) {\n\t\t\t\tif (put_user(tp->saved_syn[0], optlen)) {\n\t\t\t\t\trelease_sock(sk);\n\t\t\t\t\treturn -EFAULT;\n\t\t\t\t}\n\t\t\t\trelease_sock(sk);\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\tlen = tp->saved_syn[0];\n\t\t\tif (put_user(len, optlen)) {\n\t\t\t\trelease_sock(sk);\n\t\t\t\treturn -EFAULT;\n\t\t\t}\n\t\t\tif (copy_to_user(optval, tp->saved_syn + 1, len)) {\n\t\t\t\trelease_sock(sk);\n\t\t\t\treturn -EFAULT;\n\t\t\t}\n\t\t\ttcp_saved_syn_free(tp);\n\t\t\trelease_sock(sk);\n\t\t} else {\n\t\t\trelease_sock(sk);\n\t\t\tlen = 0;\n\t\t\tif (put_user(len, optlen))\n\t\t\t\treturn -EFAULT;\n\t\t}\n\t\treturn 0;\n\t}\n\tdefault:\n\t\treturn -ENOPROTOOPT;\n\t}",
"\tif (put_user(len, optlen))\n\t\treturn -EFAULT;\n\tif (copy_to_user(optval, &val, len))\n\t\treturn -EFAULT;\n\treturn 0;\n}",
"int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval,\n\t\t int __user *optlen)\n{\n\tstruct inet_connection_sock *icsk = inet_csk(sk);",
"\tif (level != SOL_TCP)\n\t\treturn icsk->icsk_af_ops->getsockopt(sk, level, optname,\n\t\t\t\t\t\t optval, optlen);\n\treturn do_tcp_getsockopt(sk, level, optname, optval, optlen);\n}\nEXPORT_SYMBOL(tcp_getsockopt);",
"#ifdef CONFIG_COMPAT\nint compat_tcp_getsockopt(struct sock *sk, int level, int optname,\n\t\t\t char __user *optval, int __user *optlen)\n{\n\tif (level != SOL_TCP)\n\t\treturn inet_csk_compat_getsockopt(sk, level, optname,\n\t\t\t\t\t\t optval, optlen);\n\treturn do_tcp_getsockopt(sk, level, optname, optval, optlen);\n}\nEXPORT_SYMBOL(compat_tcp_getsockopt);\n#endif",
"#ifdef CONFIG_TCP_MD5SIG\nstatic DEFINE_PER_CPU(struct tcp_md5sig_pool, tcp_md5sig_pool);\nstatic DEFINE_MUTEX(tcp_md5sig_mutex);\nstatic bool tcp_md5sig_pool_populated = false;",
"static void __tcp_alloc_md5sig_pool(void)\n{\n\tstruct crypto_ahash *hash;\n\tint cpu;",
"\thash = crypto_alloc_ahash(\"md5\", 0, CRYPTO_ALG_ASYNC);\n\tif (IS_ERR(hash))\n\t\treturn;",
"\tfor_each_possible_cpu(cpu) {\n\t\tvoid *scratch = per_cpu(tcp_md5sig_pool, cpu).scratch;\n\t\tstruct ahash_request *req;",
"\t\tif (!scratch) {\n\t\t\tscratch = kmalloc_node(sizeof(union tcp_md5sum_block) +\n\t\t\t\t\t sizeof(struct tcphdr),\n\t\t\t\t\t GFP_KERNEL,\n\t\t\t\t\t cpu_to_node(cpu));\n\t\t\tif (!scratch)\n\t\t\t\treturn;\n\t\t\tper_cpu(tcp_md5sig_pool, cpu).scratch = scratch;\n\t\t}\n\t\tif (per_cpu(tcp_md5sig_pool, cpu).md5_req)\n\t\t\tcontinue;",
"\t\treq = ahash_request_alloc(hash, GFP_KERNEL);\n\t\tif (!req)\n\t\t\treturn;",
"\t\tahash_request_set_callback(req, 0, NULL, NULL);",
"\t\tper_cpu(tcp_md5sig_pool, cpu).md5_req = req;\n\t}\n\t/* before setting tcp_md5sig_pool_populated, we must commit all writes\n\t * to memory. See smp_rmb() in tcp_get_md5sig_pool()\n\t */\n\tsmp_wmb();\n\ttcp_md5sig_pool_populated = true;\n}",
"bool tcp_alloc_md5sig_pool(void)\n{\n\tif (unlikely(!tcp_md5sig_pool_populated)) {\n\t\tmutex_lock(&tcp_md5sig_mutex);",
"\t\tif (!tcp_md5sig_pool_populated)\n\t\t\t__tcp_alloc_md5sig_pool();",
"\t\tmutex_unlock(&tcp_md5sig_mutex);\n\t}\n\treturn tcp_md5sig_pool_populated;\n}\nEXPORT_SYMBOL(tcp_alloc_md5sig_pool);",
"\n/**\n *\ttcp_get_md5sig_pool - get md5sig_pool for this user\n *\n *\tWe use percpu structure, so if we succeed, we exit with preemption\n *\tand BH disabled, to make sure another thread or softirq handling\n *\twont try to get same context.\n */\nstruct tcp_md5sig_pool *tcp_get_md5sig_pool(void)\n{\n\tlocal_bh_disable();",
"\tif (tcp_md5sig_pool_populated) {\n\t\t/* coupled with smp_wmb() in __tcp_alloc_md5sig_pool() */\n\t\tsmp_rmb();\n\t\treturn this_cpu_ptr(&tcp_md5sig_pool);\n\t}\n\tlocal_bh_enable();\n\treturn NULL;\n}\nEXPORT_SYMBOL(tcp_get_md5sig_pool);",
"int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,\n\t\t\t const struct sk_buff *skb, unsigned int header_len)\n{\n\tstruct scatterlist sg;\n\tconst struct tcphdr *tp = tcp_hdr(skb);\n\tstruct ahash_request *req = hp->md5_req;\n\tunsigned int i;\n\tconst unsigned int head_data_len = skb_headlen(skb) > header_len ?\n\t\t\t\t\t skb_headlen(skb) - header_len : 0;\n\tconst struct skb_shared_info *shi = skb_shinfo(skb);\n\tstruct sk_buff *frag_iter;",
"\tsg_init_table(&sg, 1);",
"\tsg_set_buf(&sg, ((u8 *) tp) + header_len, head_data_len);\n\tahash_request_set_crypt(req, &sg, NULL, head_data_len);\n\tif (crypto_ahash_update(req))\n\t\treturn 1;",
"\tfor (i = 0; i < shi->nr_frags; ++i) {\n\t\tconst struct skb_frag_struct *f = &shi->frags[i];\n\t\tunsigned int offset = f->page_offset;\n\t\tstruct page *page = skb_frag_page(f) + (offset >> PAGE_SHIFT);",
"\t\tsg_set_page(&sg, page, skb_frag_size(f),\n\t\t\t offset_in_page(offset));\n\t\tahash_request_set_crypt(req, &sg, NULL, skb_frag_size(f));\n\t\tif (crypto_ahash_update(req))\n\t\t\treturn 1;\n\t}",
"\tskb_walk_frags(skb, frag_iter)\n\t\tif (tcp_md5_hash_skb_data(hp, frag_iter, 0))\n\t\t\treturn 1;",
"\treturn 0;\n}\nEXPORT_SYMBOL(tcp_md5_hash_skb_data);",
"int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, const struct tcp_md5sig_key *key)\n{\n\tstruct scatterlist sg;",
"\tsg_init_one(&sg, key->key, key->keylen);\n\tahash_request_set_crypt(hp->md5_req, &sg, NULL, key->keylen);\n\treturn crypto_ahash_update(hp->md5_req);\n}\nEXPORT_SYMBOL(tcp_md5_hash_key);",
"#endif",
"void tcp_done(struct sock *sk)\n{\n\tstruct request_sock *req = tcp_sk(sk)->fastopen_rsk;",
"\tif (sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV)\n\t\tTCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);",
"\ttcp_set_state(sk, TCP_CLOSE);\n\ttcp_clear_xmit_timers(sk);\n\tif (req)\n\t\treqsk_fastopen_remove(sk, req, false);",
"\tsk->sk_shutdown = SHUTDOWN_MASK;",
"\tif (!sock_flag(sk, SOCK_DEAD))\n\t\tsk->sk_state_change(sk);\n\telse\n\t\tinet_csk_destroy_sock(sk);\n}\nEXPORT_SYMBOL_GPL(tcp_done);",
"int tcp_abort(struct sock *sk, int err)\n{\n\tif (!sk_fullsock(sk)) {\n\t\tif (sk->sk_state == TCP_NEW_SYN_RECV) {\n\t\t\tstruct request_sock *req = inet_reqsk(sk);",
"\t\t\tlocal_bh_disable();\n\t\t\tinet_csk_reqsk_queue_drop_and_put(req->rsk_listener,\n\t\t\t\t\t\t\t req);\n\t\t\tlocal_bh_enable();\n\t\t\treturn 0;\n\t\t}\n\t\treturn -EOPNOTSUPP;\n\t}",
"\t/* Don't race with userspace socket closes such as tcp_close. */\n\tlock_sock(sk);",
"\tif (sk->sk_state == TCP_LISTEN) {\n\t\ttcp_set_state(sk, TCP_CLOSE);\n\t\tinet_csk_listen_stop(sk);\n\t}",
"\t/* Don't race with BH socket closes such as inet_csk_listen_stop. */\n\tlocal_bh_disable();\n\tbh_lock_sock(sk);",
"\tif (!sock_flag(sk, SOCK_DEAD)) {\n\t\tsk->sk_err = err;\n\t\t/* This barrier is coupled with smp_rmb() in tcp_poll() */\n\t\tsmp_wmb();\n\t\tsk->sk_error_report(sk);\n\t\tif (tcp_need_reset(sk->sk_state))\n\t\t\ttcp_send_active_reset(sk, GFP_ATOMIC);\n\t\ttcp_done(sk);\n\t}",
"\tbh_unlock_sock(sk);\n\tlocal_bh_enable();\n\trelease_sock(sk);\n\treturn 0;\n}\nEXPORT_SYMBOL_GPL(tcp_abort);",
"extern struct tcp_congestion_ops tcp_reno;",
"static __initdata unsigned long thash_entries;\nstatic int __init set_thash_entries(char *str)\n{\n\tssize_t ret;",
"\tif (!str)\n\t\treturn 0;",
"\tret = kstrtoul(str, 0, &thash_entries);\n\tif (ret)\n\t\treturn 0;",
"\treturn 1;\n}\n__setup(\"thash_entries=\", set_thash_entries);",
"static void __init tcp_init_mem(void)\n{\n\tunsigned long limit = nr_free_buffer_pages() / 16;",
"\tlimit = max(limit, 128UL);\n\tsysctl_tcp_mem[0] = limit / 4 * 3;\t\t/* 4.68 % */\n\tsysctl_tcp_mem[1] = limit;\t\t\t/* 6.25 % */\n\tsysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2;\t/* 9.37 % */\n}",
"void __init tcp_init(void)\n{\n\tint max_rshare, max_wshare, cnt;\n\tunsigned long limit;\n\tunsigned int i;",
"\tBUILD_BUG_ON(sizeof(struct tcp_skb_cb) >\n\t\t FIELD_SIZEOF(struct sk_buff, cb));",
"\tpercpu_counter_init(&tcp_sockets_allocated, 0, GFP_KERNEL);\n\tpercpu_counter_init(&tcp_orphan_count, 0, GFP_KERNEL);\n\tinet_hashinfo_init(&tcp_hashinfo);\n\ttcp_hashinfo.bind_bucket_cachep =\n\t\tkmem_cache_create(\"tcp_bind_bucket\",\n\t\t\t\t sizeof(struct inet_bind_bucket), 0,\n\t\t\t\t SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);",
"\t/* Size and allocate the main established and bind bucket\n\t * hash tables.\n\t *\n\t * The methodology is similar to that of the buffer cache.\n\t */\n\ttcp_hashinfo.ehash =\n\t\talloc_large_system_hash(\"TCP established\",\n\t\t\t\t\tsizeof(struct inet_ehash_bucket),\n\t\t\t\t\tthash_entries,\n\t\t\t\t\t17, /* one slot per 128 KB of memory */\n\t\t\t\t\t0,\n\t\t\t\t\tNULL,\n\t\t\t\t\t&tcp_hashinfo.ehash_mask,\n\t\t\t\t\t0,\n\t\t\t\t\tthash_entries ? 0 : 512 * 1024);\n\tfor (i = 0; i <= tcp_hashinfo.ehash_mask; i++)\n\t\tINIT_HLIST_NULLS_HEAD(&tcp_hashinfo.ehash[i].chain, i);",
"\tif (inet_ehash_locks_alloc(&tcp_hashinfo))\n\t\tpanic(\"TCP: failed to alloc ehash_locks\");\n\ttcp_hashinfo.bhash =\n\t\talloc_large_system_hash(\"TCP bind\",\n\t\t\t\t\tsizeof(struct inet_bind_hashbucket),\n\t\t\t\t\ttcp_hashinfo.ehash_mask + 1,\n\t\t\t\t\t17, /* one slot per 128 KB of memory */\n\t\t\t\t\t0,\n\t\t\t\t\t&tcp_hashinfo.bhash_size,\n\t\t\t\t\tNULL,\n\t\t\t\t\t0,\n\t\t\t\t\t64 * 1024);\n\ttcp_hashinfo.bhash_size = 1U << tcp_hashinfo.bhash_size;\n\tfor (i = 0; i < tcp_hashinfo.bhash_size; i++) {\n\t\tspin_lock_init(&tcp_hashinfo.bhash[i].lock);\n\t\tINIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain);\n\t}",
"\n\tcnt = tcp_hashinfo.ehash_mask + 1;\n\tsysctl_tcp_max_orphans = cnt / 2;",
"\ttcp_init_mem();\n\t/* Set per-socket limits to no more than 1/128 the pressure threshold */\n\tlimit = nr_free_buffer_pages() << (PAGE_SHIFT - 7);\n\tmax_wshare = min(4UL*1024*1024, limit);\n\tmax_rshare = min(6UL*1024*1024, limit);",
"\tsysctl_tcp_wmem[0] = SK_MEM_QUANTUM;\n\tsysctl_tcp_wmem[1] = 16*1024;\n\tsysctl_tcp_wmem[2] = max(64*1024, max_wshare);",
"\tsysctl_tcp_rmem[0] = SK_MEM_QUANTUM;\n\tsysctl_tcp_rmem[1] = 87380;\n\tsysctl_tcp_rmem[2] = max(87380, max_rshare);",
"\tpr_info(\"Hash tables configured (established %u bind %u)\\n\",\n\t\ttcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size);",
"\ttcp_v4_init();\n\ttcp_metrics_init();\n\tBUG_ON(tcp_register_congestion_control(&tcp_reno) != 0);\n\ttcp_tasklet_init();\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [2322], "buggy_code_start_loc": [2322], "filenames": ["net/ipv4/tcp.c"], "fixing_code_end_loc": [2327], "fixing_code_start_loc": [2323], "message": "The tcp_disconnect function in net/ipv4/tcp.c in the Linux kernel before 4.12 allows local users to cause a denial of service (__tcp_select_window divide-by-zero error and system crash) by triggering a disconnect within a certain tcp_recvmsg code path.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "13332751-6BF4-4D8A-A5D2-62A8AF6C1F92", "versionEndExcluding": null, "versionEndIncluding": "4.11.12", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "The tcp_disconnect function in net/ipv4/tcp.c in the Linux kernel before 4.12 allows local users to cause a denial of service (__tcp_select_window divide-by-zero error and system crash) by triggering a disconnect within a certain tcp_recvmsg code path."}, {"lang": "es", "value": "La funci\u00f3n tcp_disconnect en net/ipv4/tcp.c en el kernel de Linux en versiones anteriores a la 4.12 permite que usuarios locales provoquen una denegaci\u00f3n de servicio allows local users to cause a denial of service (error __tcp_select_window de divisi\u00f3n por cero y bloqueo del sistema) desencadenando una desconexi\u00f3n en una ruta de c\u00f3digo tcp_recvmsg determinada."}], "evaluatorComment": null, "id": "CVE-2017-14106", "lastModified": "2018-07-13T01:29:00.667", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 4.9, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:L/AC:L/Au:N/C:N/I:N/A:C", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 6.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H", "version": "3.0"}, "exploitabilityScore": 1.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-09-01T16:29:00.377", "references": [{"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=499350a5a6e7512d9ed369ed63a4244b6536f4f8"}, {"source": "cve@mitre.org", "tags": null, "url": "http://lists.opensuse.org/opensuse-security-announce/2018-01/msg00007.html"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.debian.org/security/2017/dsa-3981"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/100878"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securitytracker.com/id/1039549"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2017:2918"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2017:2930"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2017:2931"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2017:3200"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2018:2172"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/499350a5a6e7512d9ed369ed63a4244b6536f4f8"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "https://www.mail-archive.com/netdev@vger.kernel.org/msg186255.html"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-369"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/499350a5a6e7512d9ed369ed63a4244b6536f4f8"}, "type": "CWE-369"}
| 370
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * INET\t\tAn implementation of the TCP/IP protocol suite for the LINUX\n *\t\toperating system. INET is implemented using the BSD Socket\n *\t\tinterface as the means of communication with the user level.\n *\n *\t\tImplementation of the Transmission Control Protocol(TCP).\n *\n * Authors:\tRoss Biro\n *\t\tFred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>\n *\t\tMark Evans, <evansmp@uhura.aston.ac.uk>\n *\t\tCorey Minyard <wf-rch!minyard@relay.EU.net>\n *\t\tFlorian La Roche, <flla@stud.uni-sb.de>\n *\t\tCharles Hedrick, <hedrick@klinzhai.rutgers.edu>\n *\t\tLinus Torvalds, <torvalds@cs.helsinki.fi>\n *\t\tAlan Cox, <gw4pts@gw4pts.ampr.org>\n *\t\tMatthew Dillon, <dillon@apollo.west.oic.com>\n *\t\tArnt Gulbrandsen, <agulbra@nvg.unit.no>\n *\t\tJorge Cwik, <jorge@laser.satlink.net>\n *\n * Fixes:\n *\t\tAlan Cox\t:\tNumerous verify_area() calls\n *\t\tAlan Cox\t:\tSet the ACK bit on a reset\n *\t\tAlan Cox\t:\tStopped it crashing if it closed while\n *\t\t\t\t\tsk->inuse=1 and was trying to connect\n *\t\t\t\t\t(tcp_err()).\n *\t\tAlan Cox\t:\tAll icmp error handling was broken\n *\t\t\t\t\tpointers passed where wrong and the\n *\t\t\t\t\tsocket was looked up backwards. Nobody\n *\t\t\t\t\ttested any icmp error code obviously.\n *\t\tAlan Cox\t:\ttcp_err() now handled properly. It\n *\t\t\t\t\twakes people on errors. poll\n *\t\t\t\t\tbehaves and the icmp error race\n *\t\t\t\t\thas gone by moving it into sock.c\n *\t\tAlan Cox\t:\ttcp_send_reset() fixed to work for\n *\t\t\t\t\teverything not just packets for\n *\t\t\t\t\tunknown sockets.\n *\t\tAlan Cox\t:\ttcp option processing.\n *\t\tAlan Cox\t:\tReset tweaked (still not 100%) [Had\n *\t\t\t\t\tsyn rule wrong]\n *\t\tHerp Rosmanith :\tMore reset fixes\n *\t\tAlan Cox\t:\tNo longer acks invalid rst frames.\n *\t\t\t\t\tAcking any kind of RST is right out.\n *\t\tAlan Cox\t:\tSets an ignore me flag on an rst\n *\t\t\t\t\treceive otherwise odd bits of prattle\n *\t\t\t\t\tescape still\n *\t\tAlan Cox\t:\tFixed another acking RST frame bug.\n *\t\t\t\t\tShould stop LAN workplace lockups.\n *\t\tAlan Cox\t: \tSome tidyups using the new skb list\n *\t\t\t\t\tfacilities\n *\t\tAlan Cox\t:\tsk->keepopen now seems to work\n *\t\tAlan Cox\t:\tPulls options out correctly on accepts\n *\t\tAlan Cox\t:\tFixed assorted sk->rqueue->next errors\n *\t\tAlan Cox\t:\tPSH doesn't end a TCP read. Switched a\n *\t\t\t\t\tbit to skb ops.\n *\t\tAlan Cox\t:\tTidied tcp_data to avoid a potential\n *\t\t\t\t\tnasty.\n *\t\tAlan Cox\t:\tAdded some better commenting, as the\n *\t\t\t\t\ttcp is hard to follow\n *\t\tAlan Cox\t:\tRemoved incorrect check for 20 * psh\n *\tMichael O'Reilly\t:\tack < copied bug fix.\n *\tJohannes Stille\t\t:\tMisc tcp fixes (not all in yet).\n *\t\tAlan Cox\t:\tFIN with no memory -> CRASH\n *\t\tAlan Cox\t:\tAdded socket option proto entries.\n *\t\t\t\t\tAlso added awareness of them to accept.\n *\t\tAlan Cox\t:\tAdded TCP options (SOL_TCP)\n *\t\tAlan Cox\t:\tSwitched wakeup calls to callbacks,\n *\t\t\t\t\tso the kernel can layer network\n *\t\t\t\t\tsockets.\n *\t\tAlan Cox\t:\tUse ip_tos/ip_ttl settings.\n *\t\tAlan Cox\t:\tHandle FIN (more) properly (we hope).\n *\t\tAlan Cox\t:\tRST frames sent on unsynchronised\n *\t\t\t\t\tstate ack error.\n *\t\tAlan Cox\t:\tPut in missing check for SYN bit.\n *\t\tAlan Cox\t:\tAdded tcp_select_window() aka NET2E\n *\t\t\t\t\twindow non shrink trick.\n *\t\tAlan Cox\t:\tAdded a couple of small NET2E timer\n *\t\t\t\t\tfixes\n *\t\tCharles Hedrick :\tTCP fixes\n *\t\tToomas Tamm\t:\tTCP window fixes\n *\t\tAlan Cox\t:\tSmall URG fix to rlogin ^C ack fight\n *\t\tCharles Hedrick\t:\tRewrote most of it to actually work\n *\t\tLinus\t\t:\tRewrote tcp_read() and URG handling\n *\t\t\t\t\tcompletely\n *\t\tGerhard Koerting:\tFixed some missing timer handling\n *\t\tMatthew Dillon :\tReworked TCP machine states as per RFC\n *\t\tGerhard Koerting:\tPC/TCP workarounds\n *\t\tAdam Caldwell\t:\tAssorted timer/timing errors\n *\t\tMatthew Dillon\t:\tFixed another RST bug\n *\t\tAlan Cox\t:\tMove to kernel side addressing changes.\n *\t\tAlan Cox\t:\tBeginning work on TCP fastpathing\n *\t\t\t\t\t(not yet usable)\n *\t\tArnt Gulbrandsen:\tTurbocharged tcp_check() routine.\n *\t\tAlan Cox\t:\tTCP fast path debugging\n *\t\tAlan Cox\t:\tWindow clamping\n *\t\tMichael Riepe\t:\tBug in tcp_check()\n *\t\tMatt Dillon\t:\tMore TCP improvements and RST bug fixes\n *\t\tMatt Dillon\t:\tYet more small nasties remove from the\n *\t\t\t\t\tTCP code (Be very nice to this man if\n *\t\t\t\t\ttcp finally works 100%) 8)\n *\t\tAlan Cox\t:\tBSD accept semantics.\n *\t\tAlan Cox\t:\tReset on closedown bug.\n *\tPeter De Schrijver\t:\tENOTCONN check missing in tcp_sendto().\n *\t\tMichael Pall\t:\tHandle poll() after URG properly in\n *\t\t\t\t\tall cases.\n *\t\tMichael Pall\t:\tUndo the last fix in tcp_read_urg()\n *\t\t\t\t\t(multi URG PUSH broke rlogin).\n *\t\tMichael Pall\t:\tFix the multi URG PUSH problem in\n *\t\t\t\t\ttcp_readable(), poll() after URG\n *\t\t\t\t\tworks now.\n *\t\tMichael Pall\t:\trecv(...,MSG_OOB) never blocks in the\n *\t\t\t\t\tBSD api.\n *\t\tAlan Cox\t:\tChanged the semantics of sk->socket to\n *\t\t\t\t\tfix a race and a signal problem with\n *\t\t\t\t\taccept() and async I/O.\n *\t\tAlan Cox\t:\tRelaxed the rules on tcp_sendto().\n *\t\tYury Shevchuk\t:\tReally fixed accept() blocking problem.\n *\t\tCraig I. Hagan :\tAllow for BSD compatible TIME_WAIT for\n *\t\t\t\t\tclients/servers which listen in on\n *\t\t\t\t\tfixed ports.\n *\t\tAlan Cox\t:\tCleaned the above up and shrank it to\n *\t\t\t\t\ta sensible code size.\n *\t\tAlan Cox\t:\tSelf connect lockup fix.\n *\t\tAlan Cox\t:\tNo connect to multicast.\n *\t\tRoss Biro\t:\tClose unaccepted children on master\n *\t\t\t\t\tsocket close.\n *\t\tAlan Cox\t:\tReset tracing code.\n *\t\tAlan Cox\t:\tSpurious resets on shutdown.\n *\t\tAlan Cox\t:\tGiant 15 minute/60 second timer error\n *\t\tAlan Cox\t:\tSmall whoops in polling before an\n *\t\t\t\t\taccept.\n *\t\tAlan Cox\t:\tKept the state trace facility since\n *\t\t\t\t\tit's handy for debugging.\n *\t\tAlan Cox\t:\tMore reset handler fixes.\n *\t\tAlan Cox\t:\tStarted rewriting the code based on\n *\t\t\t\t\tthe RFC's for other useful protocol\n *\t\t\t\t\treferences see: Comer, KA9Q NOS, and\n *\t\t\t\t\tfor a reference on the difference\n *\t\t\t\t\tbetween specifications and how BSD\n *\t\t\t\t\tworks see the 4.4lite source.\n *\t\tA.N.Kuznetsov\t:\tDon't time wait on completion of tidy\n *\t\t\t\t\tclose.\n *\t\tLinus Torvalds\t:\tFin/Shutdown & copied_seq changes.\n *\t\tLinus Torvalds\t:\tFixed BSD port reuse to work first syn\n *\t\tAlan Cox\t:\tReimplemented timers as per the RFC\n *\t\t\t\t\tand using multiple timers for sanity.\n *\t\tAlan Cox\t:\tSmall bug fixes, and a lot of new\n *\t\t\t\t\tcomments.\n *\t\tAlan Cox\t:\tFixed dual reader crash by locking\n *\t\t\t\t\tthe buffers (much like datagram.c)\n *\t\tAlan Cox\t:\tFixed stuck sockets in probe. A probe\n *\t\t\t\t\tnow gets fed up of retrying without\n *\t\t\t\t\t(even a no space) answer.\n *\t\tAlan Cox\t:\tExtracted closing code better\n *\t\tAlan Cox\t:\tFixed the closing state machine to\n *\t\t\t\t\tresemble the RFC.\n *\t\tAlan Cox\t:\tMore 'per spec' fixes.\n *\t\tJorge Cwik\t:\tEven faster checksumming.\n *\t\tAlan Cox\t:\ttcp_data() doesn't ack illegal PSH\n *\t\t\t\t\tonly frames. At least one pc tcp stack\n *\t\t\t\t\tgenerates them.\n *\t\tAlan Cox\t:\tCache last socket.\n *\t\tAlan Cox\t:\tPer route irtt.\n *\t\tMatt Day\t:\tpoll()->select() match BSD precisely on error\n *\t\tAlan Cox\t:\tNew buffers\n *\t\tMarc Tamsky\t:\tVarious sk->prot->retransmits and\n *\t\t\t\t\tsk->retransmits misupdating fixed.\n *\t\t\t\t\tFixed tcp_write_timeout: stuck close,\n *\t\t\t\t\tand TCP syn retries gets used now.\n *\t\tMark Yarvis\t:\tIn tcp_read_wakeup(), don't send an\n *\t\t\t\t\tack if state is TCP_CLOSED.\n *\t\tAlan Cox\t:\tLook up device on a retransmit - routes may\n *\t\t\t\t\tchange. Doesn't yet cope with MSS shrink right\n *\t\t\t\t\tbut it's a start!\n *\t\tMarc Tamsky\t:\tClosing in closing fixes.\n *\t\tMike Shaver\t:\tRFC1122 verifications.\n *\t\tAlan Cox\t:\trcv_saddr errors.\n *\t\tAlan Cox\t:\tBlock double connect().\n *\t\tAlan Cox\t:\tSmall hooks for enSKIP.\n *\t\tAlexey Kuznetsov:\tPath MTU discovery.\n *\t\tAlan Cox\t:\tSupport soft errors.\n *\t\tAlan Cox\t:\tFix MTU discovery pathological case\n *\t\t\t\t\twhen the remote claims no mtu!\n *\t\tMarc Tamsky\t:\tTCP_CLOSE fix.\n *\t\tColin (G3TNE)\t:\tSend a reset on syn ack replies in\n *\t\t\t\t\twindow but wrong (fixes NT lpd problems)\n *\t\tPedro Roque\t:\tBetter TCP window handling, delayed ack.\n *\t\tJoerg Reuter\t:\tNo modification of locked buffers in\n *\t\t\t\t\ttcp_do_retransmit()\n *\t\tEric Schenk\t:\tChanged receiver side silly window\n *\t\t\t\t\tavoidance algorithm to BSD style\n *\t\t\t\t\talgorithm. This doubles throughput\n *\t\t\t\t\tagainst machines running Solaris,\n *\t\t\t\t\tand seems to result in general\n *\t\t\t\t\timprovement.\n *\tStefan Magdalinski\t:\tadjusted tcp_readable() to fix FIONREAD\n *\tWilly Konynenberg\t:\tTransparent proxying support.\n *\tMike McLagan\t\t:\tRouting by source\n *\t\tKeith Owens\t:\tDo proper merging with partial SKB's in\n *\t\t\t\t\ttcp_do_sendmsg to avoid burstiness.\n *\t\tEric Schenk\t:\tFix fast close down bug with\n *\t\t\t\t\tshutdown() followed by close().\n *\t\tAndi Kleen \t:\tMake poll agree with SIGIO\n *\tSalvatore Sanfilippo\t:\tSupport SO_LINGER with linger == 1 and\n *\t\t\t\t\tlingertime == 0 (RFC 793 ABORT Call)\n *\tHirokazu Takahashi\t:\tUse copy_from_user() instead of\n *\t\t\t\t\tcsum_and_copy_from_user() if possible.\n *\n *\t\tThis program is free software; you can redistribute it and/or\n *\t\tmodify it under the terms of the GNU General Public License\n *\t\tas published by the Free Software Foundation; either version\n *\t\t2 of the License, or(at your option) any later version.\n *\n * Description of States:\n *\n *\tTCP_SYN_SENT\t\tsent a connection request, waiting for ack\n *\n *\tTCP_SYN_RECV\t\treceived a connection request, sent ack,\n *\t\t\t\twaiting for final ack in three-way handshake.\n *\n *\tTCP_ESTABLISHED\t\tconnection established\n *\n *\tTCP_FIN_WAIT1\t\tour side has shutdown, waiting to complete\n *\t\t\t\ttransmission of remaining buffered data\n *\n *\tTCP_FIN_WAIT2\t\tall buffered data sent, waiting for remote\n *\t\t\t\tto shutdown\n *\n *\tTCP_CLOSING\t\tboth sides have shutdown but we still have\n *\t\t\t\tdata we have to finish sending\n *\n *\tTCP_TIME_WAIT\t\ttimeout to catch resent junk before entering\n *\t\t\t\tclosed, can only be entered from FIN_WAIT2\n *\t\t\t\tor CLOSING. Required because the other end\n *\t\t\t\tmay not have gotten our last ACK causing it\n *\t\t\t\tto retransmit the data packet (which we ignore)\n *\n *\tTCP_CLOSE_WAIT\t\tremote side has shutdown and is waiting for\n *\t\t\t\tus to finish writing our data and to shutdown\n *\t\t\t\t(we have to close() to move on to LAST_ACK)\n *\n *\tTCP_LAST_ACK\t\tout side has shutdown after remote has\n *\t\t\t\tshutdown. There may still be data in our\n *\t\t\t\tbuffer that we have to finish sending\n *\n *\tTCP_CLOSE\t\tsocket is finished\n */",
"#define pr_fmt(fmt) \"TCP: \" fmt",
"#include <crypto/hash.h>\n#include <linux/kernel.h>\n#include <linux/module.h>\n#include <linux/types.h>\n#include <linux/fcntl.h>\n#include <linux/poll.h>\n#include <linux/inet_diag.h>\n#include <linux/init.h>\n#include <linux/fs.h>\n#include <linux/skbuff.h>\n#include <linux/scatterlist.h>\n#include <linux/splice.h>\n#include <linux/net.h>\n#include <linux/socket.h>\n#include <linux/random.h>\n#include <linux/bootmem.h>\n#include <linux/highmem.h>\n#include <linux/swap.h>\n#include <linux/cache.h>\n#include <linux/err.h>\n#include <linux/time.h>\n#include <linux/slab.h>",
"#include <net/icmp.h>\n#include <net/inet_common.h>\n#include <net/tcp.h>\n#include <net/xfrm.h>\n#include <net/ip.h>\n#include <net/sock.h>",
"#include <linux/uaccess.h>\n#include <asm/ioctls.h>\n#include <net/busy_poll.h>",
"int sysctl_tcp_min_tso_segs __read_mostly = 2;",
"int sysctl_tcp_autocorking __read_mostly = 1;",
"struct percpu_counter tcp_orphan_count;\nEXPORT_SYMBOL_GPL(tcp_orphan_count);",
"long sysctl_tcp_mem[3] __read_mostly;\nint sysctl_tcp_wmem[3] __read_mostly;\nint sysctl_tcp_rmem[3] __read_mostly;",
"EXPORT_SYMBOL(sysctl_tcp_mem);\nEXPORT_SYMBOL(sysctl_tcp_rmem);\nEXPORT_SYMBOL(sysctl_tcp_wmem);",
"atomic_long_t tcp_memory_allocated;\t/* Current allocated memory. */\nEXPORT_SYMBOL(tcp_memory_allocated);",
"/*\n * Current number of TCP sockets.\n */\nstruct percpu_counter tcp_sockets_allocated;\nEXPORT_SYMBOL(tcp_sockets_allocated);",
"/*\n * TCP splice context\n */\nstruct tcp_splice_state {\n\tstruct pipe_inode_info *pipe;\n\tsize_t len;\n\tunsigned int flags;\n};",
"/*\n * Pressure flag: try to collapse.\n * Technical note: it is used by multiple contexts non atomically.\n * All the __sk_mem_schedule() is of this nature: accounting\n * is strict, actions are advisory and have some latency.\n */\nint tcp_memory_pressure __read_mostly;\nEXPORT_SYMBOL(tcp_memory_pressure);",
"void tcp_enter_memory_pressure(struct sock *sk)\n{\n\tif (!tcp_memory_pressure) {\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMEMORYPRESSURES);\n\t\ttcp_memory_pressure = 1;\n\t}\n}\nEXPORT_SYMBOL(tcp_enter_memory_pressure);",
"/* Convert seconds to retransmits based on initial and max timeout */\nstatic u8 secs_to_retrans(int seconds, int timeout, int rto_max)\n{\n\tu8 res = 0;",
"\tif (seconds > 0) {\n\t\tint period = timeout;",
"\t\tres = 1;\n\t\twhile (seconds > period && res < 255) {\n\t\t\tres++;\n\t\t\ttimeout <<= 1;\n\t\t\tif (timeout > rto_max)\n\t\t\t\ttimeout = rto_max;\n\t\t\tperiod += timeout;\n\t\t}\n\t}\n\treturn res;\n}",
"/* Convert retransmits to seconds based on initial and max timeout */\nstatic int retrans_to_secs(u8 retrans, int timeout, int rto_max)\n{\n\tint period = 0;",
"\tif (retrans > 0) {\n\t\tperiod = timeout;\n\t\twhile (--retrans) {\n\t\t\ttimeout <<= 1;\n\t\t\tif (timeout > rto_max)\n\t\t\t\ttimeout = rto_max;\n\t\t\tperiod += timeout;\n\t\t}\n\t}\n\treturn period;\n}",
"/* Address-family independent initialization for a tcp_sock.\n *\n * NOTE: A lot of things set to zero explicitly by call to\n * sk_alloc() so need not be done here.\n */\nvoid tcp_init_sock(struct sock *sk)\n{\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct tcp_sock *tp = tcp_sk(sk);",
"\ttp->out_of_order_queue = RB_ROOT;\n\ttcp_init_xmit_timers(sk);\n\ttcp_prequeue_init(tp);\n\tINIT_LIST_HEAD(&tp->tsq_node);",
"\ticsk->icsk_rto = TCP_TIMEOUT_INIT;\n\ttp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);\n\tminmax_reset(&tp->rtt_min, tcp_time_stamp, ~0U);",
"\t/* So many TCP implementations out there (incorrectly) count the\n\t * initial SYN frame in their delayed-ACK and congestion control\n\t * algorithms that we must have the following bandaid to talk\n\t * efficiently to them. -DaveM\n\t */\n\ttp->snd_cwnd = TCP_INIT_CWND;",
"\t/* There's a bubble in the pipe until at least the first ACK. */\n\ttp->app_limited = ~0U;",
"\t/* See draft-stevens-tcpca-spec-01 for discussion of the\n\t * initialization of these values.\n\t */\n\ttp->snd_ssthresh = TCP_INFINITE_SSTHRESH;\n\ttp->snd_cwnd_clamp = ~0;\n\ttp->mss_cache = TCP_MSS_DEFAULT;",
"\ttp->reordering = sock_net(sk)->ipv4.sysctl_tcp_reordering;\n\ttcp_assign_congestion_control(sk);",
"\ttp->tsoffset = 0;",
"\tsk->sk_state = TCP_CLOSE;",
"\tsk->sk_write_space = sk_stream_write_space;\n\tsock_set_flag(sk, SOCK_USE_WRITE_QUEUE);",
"\ticsk->icsk_sync_mss = tcp_sync_mss;",
"\tsk->sk_sndbuf = sysctl_tcp_wmem[1];\n\tsk->sk_rcvbuf = sysctl_tcp_rmem[1];",
"\tsk_sockets_allocated_inc(sk);\n}\nEXPORT_SYMBOL(tcp_init_sock);",
"static void tcp_tx_timestamp(struct sock *sk, u16 tsflags, struct sk_buff *skb)\n{\n\tif (tsflags && skb) {\n\t\tstruct skb_shared_info *shinfo = skb_shinfo(skb);\n\t\tstruct tcp_skb_cb *tcb = TCP_SKB_CB(skb);",
"\t\tsock_tx_timestamp(sk, tsflags, &shinfo->tx_flags);\n\t\tif (tsflags & SOF_TIMESTAMPING_TX_ACK)\n\t\t\ttcb->txstamp_ack = 1;\n\t\tif (tsflags & SOF_TIMESTAMPING_TX_RECORD_MASK)\n\t\t\tshinfo->tskey = TCP_SKB_CB(skb)->seq + skb->len - 1;\n\t}\n}",
"/*\n *\tWait for a TCP event.\n *\n *\tNote that we don't need to lock the socket, as the upper poll layers\n *\ttake care of normal races (between the test and the event) and we don't\n *\tgo look at any of the socket buffers directly.\n */\nunsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)\n{\n\tunsigned int mask;\n\tstruct sock *sk = sock->sk;\n\tconst struct tcp_sock *tp = tcp_sk(sk);\n\tint state;",
"\tsock_rps_record_flow(sk);",
"\tsock_poll_wait(file, sk_sleep(sk), wait);",
"\tstate = sk_state_load(sk);\n\tif (state == TCP_LISTEN)\n\t\treturn inet_csk_listen_poll(sk);",
"\t/* Socket is not locked. We are protected from async events\n\t * by poll logic and correct handling of state changes\n\t * made by other threads is impossible in any case.\n\t */",
"\tmask = 0;",
"\t/*\n\t * POLLHUP is certainly not done right. But poll() doesn't\n\t * have a notion of HUP in just one direction, and for a\n\t * socket the read side is more interesting.\n\t *\n\t * Some poll() documentation says that POLLHUP is incompatible\n\t * with the POLLOUT/POLLWR flags, so somebody should check this\n\t * all. But careful, it tends to be safer to return too many\n\t * bits than too few, and you can easily break real applications\n\t * if you don't tell them that something has hung up!\n\t *\n\t * Check-me.\n\t *\n\t * Check number 1. POLLHUP is _UNMASKABLE_ event (see UNIX98 and\n\t * our fs/select.c). It means that after we received EOF,\n\t * poll always returns immediately, making impossible poll() on write()\n\t * in state CLOSE_WAIT. One solution is evident --- to set POLLHUP\n\t * if and only if shutdown has been made in both directions.\n\t * Actually, it is interesting to look how Solaris and DUX\n\t * solve this dilemma. I would prefer, if POLLHUP were maskable,\n\t * then we could set it on SND_SHUTDOWN. BTW examples given\n\t * in Stevens' books assume exactly this behaviour, it explains\n\t * why POLLHUP is incompatible with POLLOUT.\t--ANK\n\t *\n\t * NOTE. Check for TCP_CLOSE is added. The goal is to prevent\n\t * blocking on fresh not-connected or disconnected socket. --ANK\n\t */\n\tif (sk->sk_shutdown == SHUTDOWN_MASK || state == TCP_CLOSE)\n\t\tmask |= POLLHUP;\n\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\tmask |= POLLIN | POLLRDNORM | POLLRDHUP;",
"\t/* Connected or passive Fast Open socket? */\n\tif (state != TCP_SYN_SENT &&\n\t (state != TCP_SYN_RECV || tp->fastopen_rsk)) {\n\t\tint target = sock_rcvlowat(sk, 0, INT_MAX);",
"\t\tif (tp->urg_seq == tp->copied_seq &&\n\t\t !sock_flag(sk, SOCK_URGINLINE) &&\n\t\t tp->urg_data)\n\t\t\ttarget++;",
"\t\tif (tp->rcv_nxt - tp->copied_seq >= target)\n\t\t\tmask |= POLLIN | POLLRDNORM;",
"\t\tif (!(sk->sk_shutdown & SEND_SHUTDOWN)) {\n\t\t\tif (sk_stream_is_writeable(sk)) {\n\t\t\t\tmask |= POLLOUT | POLLWRNORM;\n\t\t\t} else { /* send SIGIO later */\n\t\t\t\tsk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);\n\t\t\t\tset_bit(SOCK_NOSPACE, &sk->sk_socket->flags);",
"\t\t\t\t/* Race breaker. If space is freed after\n\t\t\t\t * wspace test but before the flags are set,\n\t\t\t\t * IO signal will be lost. Memory barrier\n\t\t\t\t * pairs with the input side.\n\t\t\t\t */\n\t\t\t\tsmp_mb__after_atomic();\n\t\t\t\tif (sk_stream_is_writeable(sk))\n\t\t\t\t\tmask |= POLLOUT | POLLWRNORM;\n\t\t\t}\n\t\t} else\n\t\t\tmask |= POLLOUT | POLLWRNORM;",
"\t\tif (tp->urg_data & TCP_URG_VALID)\n\t\t\tmask |= POLLPRI;\n\t} else if (state == TCP_SYN_SENT && inet_sk(sk)->defer_connect) {\n\t\t/* Active TCP fastopen socket with defer_connect\n\t\t * Return POLLOUT so application can call write()\n\t\t * in order for kernel to generate SYN+data\n\t\t */\n\t\tmask |= POLLOUT | POLLWRNORM;\n\t}\n\t/* This barrier is coupled with smp_wmb() in tcp_reset() */\n\tsmp_rmb();\n\tif (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))\n\t\tmask |= POLLERR;",
"\treturn mask;\n}\nEXPORT_SYMBOL(tcp_poll);",
"int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint answ;\n\tbool slow;",
"\tswitch (cmd) {\n\tcase SIOCINQ:\n\t\tif (sk->sk_state == TCP_LISTEN)\n\t\t\treturn -EINVAL;",
"\t\tslow = lock_sock_fast(sk);\n\t\tansw = tcp_inq(sk);\n\t\tunlock_sock_fast(sk, slow);\n\t\tbreak;\n\tcase SIOCATMARK:\n\t\tansw = tp->urg_data && tp->urg_seq == tp->copied_seq;\n\t\tbreak;\n\tcase SIOCOUTQ:\n\t\tif (sk->sk_state == TCP_LISTEN)\n\t\t\treturn -EINVAL;",
"\t\tif ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))\n\t\t\tansw = 0;\n\t\telse\n\t\t\tansw = tp->write_seq - tp->snd_una;\n\t\tbreak;\n\tcase SIOCOUTQNSD:\n\t\tif (sk->sk_state == TCP_LISTEN)\n\t\t\treturn -EINVAL;",
"\t\tif ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))\n\t\t\tansw = 0;\n\t\telse\n\t\t\tansw = tp->write_seq - tp->snd_nxt;\n\t\tbreak;\n\tdefault:\n\t\treturn -ENOIOCTLCMD;\n\t}",
"\treturn put_user(answ, (int __user *)arg);\n}\nEXPORT_SYMBOL(tcp_ioctl);",
"static inline void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb)\n{\n\tTCP_SKB_CB(skb)->tcp_flags |= TCPHDR_PSH;\n\ttp->pushed_seq = tp->write_seq;\n}",
"static inline bool forced_push(const struct tcp_sock *tp)\n{\n\treturn after(tp->write_seq, tp->pushed_seq + (tp->max_window >> 1));\n}",
"static void skb_entail(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct tcp_skb_cb *tcb = TCP_SKB_CB(skb);",
"\tskb->csum = 0;\n\ttcb->seq = tcb->end_seq = tp->write_seq;\n\ttcb->tcp_flags = TCPHDR_ACK;\n\ttcb->sacked = 0;\n\t__skb_header_release(skb);\n\ttcp_add_write_queue_tail(sk, skb);\n\tsk->sk_wmem_queued += skb->truesize;\n\tsk_mem_charge(sk, skb->truesize);\n\tif (tp->nonagle & TCP_NAGLE_PUSH)\n\t\ttp->nonagle &= ~TCP_NAGLE_PUSH;",
"\ttcp_slow_start_after_idle_check(sk);\n}",
"static inline void tcp_mark_urg(struct tcp_sock *tp, int flags)\n{\n\tif (flags & MSG_OOB)\n\t\ttp->snd_up = tp->write_seq;\n}",
"/* If a not yet filled skb is pushed, do not send it if\n * we have data packets in Qdisc or NIC queues :\n * Because TX completion will happen shortly, it gives a chance\n * to coalesce future sendmsg() payload into this skb, without\n * need for a timer, and with no latency trade off.\n * As packets containing data payload have a bigger truesize\n * than pure acks (dataless) packets, the last checks prevent\n * autocorking if we only have an ACK in Qdisc/NIC queues,\n * or if TX completion was delayed after we processed ACK packet.\n */\nstatic bool tcp_should_autocork(struct sock *sk, struct sk_buff *skb,\n\t\t\t\tint size_goal)\n{\n\treturn skb->len < size_goal &&\n\t sysctl_tcp_autocorking &&\n\t skb != tcp_write_queue_head(sk) &&\n\t atomic_read(&sk->sk_wmem_alloc) > skb->truesize;\n}",
"static void tcp_push(struct sock *sk, int flags, int mss_now,\n\t\t int nonagle, int size_goal)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct sk_buff *skb;",
"\tif (!tcp_send_head(sk))\n\t\treturn;",
"\tskb = tcp_write_queue_tail(sk);\n\tif (!(flags & MSG_MORE) || forced_push(tp))\n\t\ttcp_mark_push(tp, skb);",
"\ttcp_mark_urg(tp, flags);",
"\tif (tcp_should_autocork(sk, skb, size_goal)) {",
"\t\t/* avoid atomic op if TSQ_THROTTLED bit is already set */\n\t\tif (!test_bit(TSQ_THROTTLED, &sk->sk_tsq_flags)) {\n\t\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAUTOCORKING);\n\t\t\tset_bit(TSQ_THROTTLED, &sk->sk_tsq_flags);\n\t\t}\n\t\t/* It is possible TX completion already happened\n\t\t * before we set TSQ_THROTTLED.\n\t\t */\n\t\tif (atomic_read(&sk->sk_wmem_alloc) > skb->truesize)\n\t\t\treturn;\n\t}",
"\tif (flags & MSG_MORE)\n\t\tnonagle = TCP_NAGLE_CORK;",
"\t__tcp_push_pending_frames(sk, mss_now, nonagle);\n}",
"static int tcp_splice_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,\n\t\t\t\tunsigned int offset, size_t len)\n{\n\tstruct tcp_splice_state *tss = rd_desc->arg.data;\n\tint ret;",
"\tret = skb_splice_bits(skb, skb->sk, offset, tss->pipe,\n\t\t\t min(rd_desc->count, len), tss->flags);\n\tif (ret > 0)\n\t\trd_desc->count -= ret;\n\treturn ret;\n}",
"static int __tcp_splice_read(struct sock *sk, struct tcp_splice_state *tss)\n{\n\t/* Store TCP splice context information in read_descriptor_t. */\n\tread_descriptor_t rd_desc = {\n\t\t.arg.data = tss,\n\t\t.count\t = tss->len,\n\t};",
"\treturn tcp_read_sock(sk, &rd_desc, tcp_splice_data_recv);\n}",
"/**\n * tcp_splice_read - splice data from TCP socket to a pipe\n * @sock:\tsocket to splice from\n * @ppos:\tposition (not valid)\n * @pipe:\tpipe to splice to\n * @len:\tnumber of bytes to splice\n * @flags:\tsplice modifier flags\n *\n * Description:\n * Will read pages from given socket and fill them into a pipe.\n *\n **/\nssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,\n\t\t\tstruct pipe_inode_info *pipe, size_t len,\n\t\t\tunsigned int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tcp_splice_state tss = {\n\t\t.pipe = pipe,\n\t\t.len = len,\n\t\t.flags = flags,\n\t};\n\tlong timeo;\n\tssize_t spliced;\n\tint ret;",
"\tsock_rps_record_flow(sk);\n\t/*\n\t * We can't seek on a socket input\n\t */\n\tif (unlikely(*ppos))\n\t\treturn -ESPIPE;",
"\tret = spliced = 0;",
"\tlock_sock(sk);",
"\ttimeo = sock_rcvtimeo(sk, sock->file->f_flags & O_NONBLOCK);\n\twhile (tss.len) {\n\t\tret = __tcp_splice_read(sk, &tss);\n\t\tif (ret < 0)\n\t\t\tbreak;\n\t\telse if (!ret) {\n\t\t\tif (spliced)\n\t\t\t\tbreak;\n\t\t\tif (sock_flag(sk, SOCK_DONE))\n\t\t\t\tbreak;\n\t\t\tif (sk->sk_err) {\n\t\t\t\tret = sock_error(sk);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\t\t\tbreak;\n\t\t\tif (sk->sk_state == TCP_CLOSE) {\n\t\t\t\t/*\n\t\t\t\t * This occurs when user tries to read\n\t\t\t\t * from never connected socket.\n\t\t\t\t */\n\t\t\t\tif (!sock_flag(sk, SOCK_DONE))\n\t\t\t\t\tret = -ENOTCONN;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!timeo) {\n\t\t\t\tret = -EAGAIN;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t/* if __tcp_splice_read() got nothing while we have\n\t\t\t * an skb in receive queue, we do not want to loop.\n\t\t\t * This might happen with URG data.\n\t\t\t */\n\t\t\tif (!skb_queue_empty(&sk->sk_receive_queue))\n\t\t\t\tbreak;\n\t\t\tsk_wait_data(sk, &timeo, NULL);\n\t\t\tif (signal_pending(current)) {\n\t\t\t\tret = sock_intr_errno(timeo);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\ttss.len -= ret;\n\t\tspliced += ret;",
"\t\tif (!timeo)\n\t\t\tbreak;\n\t\trelease_sock(sk);\n\t\tlock_sock(sk);",
"\t\tif (sk->sk_err || sk->sk_state == TCP_CLOSE ||\n\t\t (sk->sk_shutdown & RCV_SHUTDOWN) ||\n\t\t signal_pending(current))\n\t\t\tbreak;\n\t}",
"\trelease_sock(sk);",
"\tif (spliced)\n\t\treturn spliced;",
"\treturn ret;\n}\nEXPORT_SYMBOL(tcp_splice_read);",
"struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,\n\t\t\t\t bool force_schedule)\n{\n\tstruct sk_buff *skb;",
"\t/* The TCP header must be at least 32-bit aligned. */\n\tsize = ALIGN(size, 4);",
"\tif (unlikely(tcp_under_memory_pressure(sk)))\n\t\tsk_mem_reclaim_partial(sk);",
"\tskb = alloc_skb_fclone(size + sk->sk_prot->max_header, gfp);\n\tif (likely(skb)) {\n\t\tbool mem_scheduled;",
"\t\tif (force_schedule) {\n\t\t\tmem_scheduled = true;\n\t\t\tsk_forced_mem_schedule(sk, skb->truesize);\n\t\t} else {\n\t\t\tmem_scheduled = sk_wmem_schedule(sk, skb->truesize);\n\t\t}\n\t\tif (likely(mem_scheduled)) {\n\t\t\tskb_reserve(skb, sk->sk_prot->max_header);\n\t\t\t/*\n\t\t\t * Make sure that we have exactly size bytes\n\t\t\t * available to the caller, no more, no less.\n\t\t\t */\n\t\t\tskb->reserved_tailroom = skb->end - skb->tail - size;\n\t\t\treturn skb;\n\t\t}\n\t\t__kfree_skb(skb);\n\t} else {\n\t\tsk->sk_prot->enter_memory_pressure(sk);\n\t\tsk_stream_moderate_sndbuf(sk);\n\t}\n\treturn NULL;\n}",
"static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now,\n\t\t\t\t int large_allowed)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tu32 new_size_goal, size_goal;",
"\tif (!large_allowed || !sk_can_gso(sk))\n\t\treturn mss_now;",
"\t/* Note : tcp_tso_autosize() will eventually split this later */\n\tnew_size_goal = sk->sk_gso_max_size - 1 - MAX_TCP_HEADER;\n\tnew_size_goal = tcp_bound_to_half_wnd(tp, new_size_goal);",
"\t/* We try hard to avoid divides here */\n\tsize_goal = tp->gso_segs * mss_now;\n\tif (unlikely(new_size_goal < size_goal ||\n\t\t new_size_goal >= size_goal + mss_now)) {\n\t\ttp->gso_segs = min_t(u16, new_size_goal / mss_now,\n\t\t\t\t sk->sk_gso_max_segs);\n\t\tsize_goal = tp->gso_segs * mss_now;\n\t}",
"\treturn max(size_goal, mss_now);\n}",
"static int tcp_send_mss(struct sock *sk, int *size_goal, int flags)\n{\n\tint mss_now;",
"\tmss_now = tcp_current_mss(sk);\n\t*size_goal = tcp_xmit_size_goal(sk, mss_now, !(flags & MSG_OOB));",
"\treturn mss_now;\n}",
"static ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset,\n\t\t\t\tsize_t size, int flags)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint mss_now, size_goal;\n\tint err;\n\tssize_t copied;\n\tlong timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);",
"\t/* Wait for a connection to finish. One exception is TCP Fast Open\n\t * (passive side) where data is allowed to be sent before a connection\n\t * is fully established.\n\t */\n\tif (((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) &&\n\t !tcp_passive_fastopen(sk)) {\n\t\terr = sk_stream_wait_connect(sk, &timeo);\n\t\tif (err != 0)\n\t\t\tgoto out_err;\n\t}",
"\tsk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);",
"\tmss_now = tcp_send_mss(sk, &size_goal, flags);\n\tcopied = 0;",
"\terr = -EPIPE;\n\tif (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))\n\t\tgoto out_err;",
"\twhile (size > 0) {\n\t\tstruct sk_buff *skb = tcp_write_queue_tail(sk);\n\t\tint copy, i;\n\t\tbool can_coalesce;",
"\t\tif (!tcp_send_head(sk) || (copy = size_goal - skb->len) <= 0 ||\n\t\t !tcp_skb_can_collapse_to(skb)) {\nnew_segment:\n\t\t\tif (!sk_stream_memory_free(sk))\n\t\t\t\tgoto wait_for_sndbuf;",
"\t\t\tskb = sk_stream_alloc_skb(sk, 0, sk->sk_allocation,\n\t\t\t\t\t\t skb_queue_empty(&sk->sk_write_queue));\n\t\t\tif (!skb)\n\t\t\t\tgoto wait_for_memory;",
"\t\t\tskb_entail(sk, skb);\n\t\t\tcopy = size_goal;\n\t\t}",
"\t\tif (copy > size)\n\t\t\tcopy = size;",
"\t\ti = skb_shinfo(skb)->nr_frags;\n\t\tcan_coalesce = skb_can_coalesce(skb, i, page, offset);\n\t\tif (!can_coalesce && i >= sysctl_max_skb_frags) {\n\t\t\ttcp_mark_push(tp, skb);\n\t\t\tgoto new_segment;\n\t\t}\n\t\tif (!sk_wmem_schedule(sk, copy))\n\t\t\tgoto wait_for_memory;",
"\t\tif (can_coalesce) {\n\t\t\tskb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy);\n\t\t} else {\n\t\t\tget_page(page);\n\t\t\tskb_fill_page_desc(skb, i, page, offset, copy);\n\t\t}\n\t\tskb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;",
"\t\tskb->len += copy;\n\t\tskb->data_len += copy;\n\t\tskb->truesize += copy;\n\t\tsk->sk_wmem_queued += copy;\n\t\tsk_mem_charge(sk, copy);\n\t\tskb->ip_summed = CHECKSUM_PARTIAL;\n\t\ttp->write_seq += copy;\n\t\tTCP_SKB_CB(skb)->end_seq += copy;\n\t\ttcp_skb_pcount_set(skb, 0);",
"\t\tif (!copied)\n\t\t\tTCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH;",
"\t\tcopied += copy;\n\t\toffset += copy;\n\t\tsize -= copy;\n\t\tif (!size)\n\t\t\tgoto out;",
"\t\tif (skb->len < size_goal || (flags & MSG_OOB))\n\t\t\tcontinue;",
"\t\tif (forced_push(tp)) {\n\t\t\ttcp_mark_push(tp, skb);\n\t\t\t__tcp_push_pending_frames(sk, mss_now, TCP_NAGLE_PUSH);\n\t\t} else if (skb == tcp_send_head(sk))\n\t\t\ttcp_push_one(sk, mss_now);\n\t\tcontinue;",
"wait_for_sndbuf:\n\t\tset_bit(SOCK_NOSPACE, &sk->sk_socket->flags);\nwait_for_memory:\n\t\ttcp_push(sk, flags & ~MSG_MORE, mss_now,\n\t\t\t TCP_NAGLE_PUSH, size_goal);",
"\t\terr = sk_stream_wait_memory(sk, &timeo);\n\t\tif (err != 0)\n\t\t\tgoto do_error;",
"\t\tmss_now = tcp_send_mss(sk, &size_goal, flags);\n\t}",
"out:\n\tif (copied) {\n\t\ttcp_tx_timestamp(sk, sk->sk_tsflags, tcp_write_queue_tail(sk));\n\t\tif (!(flags & MSG_SENDPAGE_NOTLAST))\n\t\t\ttcp_push(sk, flags, mss_now, tp->nonagle, size_goal);\n\t}\n\treturn copied;",
"do_error:\n\tif (copied)\n\t\tgoto out;\nout_err:\n\t/* make sure we wake any epoll edge trigger waiter */\n\tif (unlikely(skb_queue_len(&sk->sk_write_queue) == 0 &&\n\t\t err == -EAGAIN)) {\n\t\tsk->sk_write_space(sk);\n\t\ttcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);\n\t}\n\treturn sk_stream_error(sk, flags, err);\n}",
"int tcp_sendpage(struct sock *sk, struct page *page, int offset,\n\t\t size_t size, int flags)\n{\n\tssize_t res;",
"\tif (!(sk->sk_route_caps & NETIF_F_SG) ||\n\t !sk_check_csum_caps(sk))\n\t\treturn sock_no_sendpage(sk->sk_socket, page, offset, size,\n\t\t\t\t\tflags);",
"\tlock_sock(sk);",
"\ttcp_rate_check_app_limited(sk); /* is sending application-limited? */",
"\tres = do_tcp_sendpages(sk, page, offset, size, flags);\n\trelease_sock(sk);\n\treturn res;\n}\nEXPORT_SYMBOL(tcp_sendpage);",
"/* Do not bother using a page frag for very small frames.\n * But use this heuristic only for the first skb in write queue.\n *\n * Having no payload in skb->head allows better SACK shifting\n * in tcp_shift_skb_data(), reducing sack/rack overhead, because\n * write queue has less skbs.\n * Each skb can hold up to MAX_SKB_FRAGS * 32Kbytes, or ~0.5 MB.\n * This also speeds up tso_fragment(), since it wont fallback\n * to tcp_fragment().\n */\nstatic int linear_payload_sz(bool first_skb)\n{\n\tif (first_skb)\n\t\treturn SKB_WITH_OVERHEAD(2048 - MAX_TCP_HEADER);\n\treturn 0;\n}",
"static int select_size(const struct sock *sk, bool sg, bool first_skb)\n{\n\tconst struct tcp_sock *tp = tcp_sk(sk);\n\tint tmp = tp->mss_cache;",
"\tif (sg) {\n\t\tif (sk_can_gso(sk)) {\n\t\t\ttmp = linear_payload_sz(first_skb);\n\t\t} else {\n\t\t\tint pgbreak = SKB_MAX_HEAD(MAX_TCP_HEADER);",
"\t\t\tif (tmp >= pgbreak &&\n\t\t\t tmp <= pgbreak + (MAX_SKB_FRAGS - 1) * PAGE_SIZE)\n\t\t\t\ttmp = pgbreak;\n\t\t}\n\t}",
"\treturn tmp;\n}",
"void tcp_free_fastopen_req(struct tcp_sock *tp)\n{\n\tif (tp->fastopen_req) {\n\t\tkfree(tp->fastopen_req);\n\t\ttp->fastopen_req = NULL;\n\t}\n}",
"static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,\n\t\t\t\tint *copied, size_t size)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct inet_sock *inet = inet_sk(sk);\n\tint err, flags;",
"\tif (!(sysctl_tcp_fastopen & TFO_CLIENT_ENABLE))\n\t\treturn -EOPNOTSUPP;\n\tif (tp->fastopen_req)\n\t\treturn -EALREADY; /* Another Fast Open is in progress */",
"\ttp->fastopen_req = kzalloc(sizeof(struct tcp_fastopen_request),\n\t\t\t\t sk->sk_allocation);\n\tif (unlikely(!tp->fastopen_req))\n\t\treturn -ENOBUFS;\n\ttp->fastopen_req->data = msg;\n\ttp->fastopen_req->size = size;",
"\tif (inet->defer_connect) {\n\t\terr = tcp_connect(sk);\n\t\t/* Same failure procedure as in tcp_v4/6_connect */\n\t\tif (err) {\n\t\t\ttcp_set_state(sk, TCP_CLOSE);\n\t\t\tinet->inet_dport = 0;\n\t\t\tsk->sk_route_caps = 0;\n\t\t}\n\t}\n\tflags = (msg->msg_flags & MSG_DONTWAIT) ? O_NONBLOCK : 0;\n\terr = __inet_stream_connect(sk->sk_socket, msg->msg_name,\n\t\t\t\t msg->msg_namelen, flags, 1);\n\t/* fastopen_req could already be freed in __inet_stream_connect\n\t * if the connection times out or gets rst\n\t */\n\tif (tp->fastopen_req) {\n\t\t*copied = tp->fastopen_req->copied;\n\t\ttcp_free_fastopen_req(tp);\n\t\tinet->defer_connect = 0;\n\t}\n\treturn err;\n}",
"int tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct sk_buff *skb;\n\tstruct sockcm_cookie sockc;\n\tint flags, err, copied = 0;\n\tint mss_now = 0, size_goal, copied_syn = 0;\n\tbool process_backlog = false;\n\tbool sg;\n\tlong timeo;",
"\tlock_sock(sk);",
"\tflags = msg->msg_flags;\n\tif (unlikely(flags & MSG_FASTOPEN || inet_sk(sk)->defer_connect)) {\n\t\terr = tcp_sendmsg_fastopen(sk, msg, &copied_syn, size);\n\t\tif (err == -EINPROGRESS && copied_syn > 0)\n\t\t\tgoto out;\n\t\telse if (err)\n\t\t\tgoto out_err;\n\t}",
"\ttimeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);",
"\ttcp_rate_check_app_limited(sk); /* is sending application-limited? */",
"\t/* Wait for a connection to finish. One exception is TCP Fast Open\n\t * (passive side) where data is allowed to be sent before a connection\n\t * is fully established.\n\t */\n\tif (((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) &&\n\t !tcp_passive_fastopen(sk)) {\n\t\terr = sk_stream_wait_connect(sk, &timeo);\n\t\tif (err != 0)\n\t\t\tgoto do_error;\n\t}",
"\tif (unlikely(tp->repair)) {\n\t\tif (tp->repair_queue == TCP_RECV_QUEUE) {\n\t\t\tcopied = tcp_send_rcvq(sk, msg, size);\n\t\t\tgoto out_nopush;\n\t\t}",
"\t\terr = -EINVAL;\n\t\tif (tp->repair_queue == TCP_NO_QUEUE)\n\t\t\tgoto out_err;",
"\t\t/* 'common' sending to sendq */\n\t}",
"\tsockc.tsflags = sk->sk_tsflags;\n\tif (msg->msg_controllen) {\n\t\terr = sock_cmsg_send(sk, msg, &sockc);\n\t\tif (unlikely(err)) {\n\t\t\terr = -EINVAL;\n\t\t\tgoto out_err;\n\t\t}\n\t}",
"\t/* This should be in poll */\n\tsk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);",
"\t/* Ok commence sending. */\n\tcopied = 0;",
"restart:\n\tmss_now = tcp_send_mss(sk, &size_goal, flags);",
"\terr = -EPIPE;\n\tif (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))\n\t\tgoto do_error;",
"\tsg = !!(sk->sk_route_caps & NETIF_F_SG);",
"\twhile (msg_data_left(msg)) {\n\t\tint copy = 0;\n\t\tint max = size_goal;",
"\t\tskb = tcp_write_queue_tail(sk);\n\t\tif (tcp_send_head(sk)) {\n\t\t\tif (skb->ip_summed == CHECKSUM_NONE)\n\t\t\t\tmax = mss_now;\n\t\t\tcopy = max - skb->len;\n\t\t}",
"\t\tif (copy <= 0 || !tcp_skb_can_collapse_to(skb)) {\n\t\t\tbool first_skb;",
"new_segment:\n\t\t\t/* Allocate new segment. If the interface is SG,\n\t\t\t * allocate skb fitting to single page.\n\t\t\t */\n\t\t\tif (!sk_stream_memory_free(sk))\n\t\t\t\tgoto wait_for_sndbuf;",
"\t\t\tif (process_backlog && sk_flush_backlog(sk)) {\n\t\t\t\tprocess_backlog = false;\n\t\t\t\tgoto restart;\n\t\t\t}\n\t\t\tfirst_skb = skb_queue_empty(&sk->sk_write_queue);\n\t\t\tskb = sk_stream_alloc_skb(sk,\n\t\t\t\t\t\t select_size(sk, sg, first_skb),\n\t\t\t\t\t\t sk->sk_allocation,\n\t\t\t\t\t\t first_skb);\n\t\t\tif (!skb)\n\t\t\t\tgoto wait_for_memory;",
"\t\t\tprocess_backlog = true;\n\t\t\t/*\n\t\t\t * Check whether we can use HW checksum.\n\t\t\t */\n\t\t\tif (sk_check_csum_caps(sk))\n\t\t\t\tskb->ip_summed = CHECKSUM_PARTIAL;",
"\t\t\tskb_entail(sk, skb);\n\t\t\tcopy = size_goal;\n\t\t\tmax = size_goal;",
"\t\t\t/* All packets are restored as if they have\n\t\t\t * already been sent. skb_mstamp isn't set to\n\t\t\t * avoid wrong rtt estimation.\n\t\t\t */\n\t\t\tif (tp->repair)\n\t\t\t\tTCP_SKB_CB(skb)->sacked |= TCPCB_REPAIRED;\n\t\t}",
"\t\t/* Try to append data to the end of skb. */\n\t\tif (copy > msg_data_left(msg))\n\t\t\tcopy = msg_data_left(msg);",
"\t\t/* Where to copy to? */\n\t\tif (skb_availroom(skb) > 0) {\n\t\t\t/* We have some space in skb head. Superb! */\n\t\t\tcopy = min_t(int, copy, skb_availroom(skb));\n\t\t\terr = skb_add_data_nocache(sk, skb, &msg->msg_iter, copy);\n\t\t\tif (err)\n\t\t\t\tgoto do_fault;\n\t\t} else {\n\t\t\tbool merge = true;\n\t\t\tint i = skb_shinfo(skb)->nr_frags;\n\t\t\tstruct page_frag *pfrag = sk_page_frag(sk);",
"\t\t\tif (!sk_page_frag_refill(sk, pfrag))\n\t\t\t\tgoto wait_for_memory;",
"\t\t\tif (!skb_can_coalesce(skb, i, pfrag->page,\n\t\t\t\t\t pfrag->offset)) {\n\t\t\t\tif (i >= sysctl_max_skb_frags || !sg) {\n\t\t\t\t\ttcp_mark_push(tp, skb);\n\t\t\t\t\tgoto new_segment;\n\t\t\t\t}\n\t\t\t\tmerge = false;\n\t\t\t}",
"\t\t\tcopy = min_t(int, copy, pfrag->size - pfrag->offset);",
"\t\t\tif (!sk_wmem_schedule(sk, copy))\n\t\t\t\tgoto wait_for_memory;",
"\t\t\terr = skb_copy_to_page_nocache(sk, &msg->msg_iter, skb,\n\t\t\t\t\t\t pfrag->page,\n\t\t\t\t\t\t pfrag->offset,\n\t\t\t\t\t\t copy);\n\t\t\tif (err)\n\t\t\t\tgoto do_error;",
"\t\t\t/* Update the skb. */\n\t\t\tif (merge) {\n\t\t\t\tskb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy);\n\t\t\t} else {\n\t\t\t\tskb_fill_page_desc(skb, i, pfrag->page,\n\t\t\t\t\t\t pfrag->offset, copy);\n\t\t\t\tpage_ref_inc(pfrag->page);\n\t\t\t}\n\t\t\tpfrag->offset += copy;\n\t\t}",
"\t\tif (!copied)\n\t\t\tTCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH;",
"\t\ttp->write_seq += copy;\n\t\tTCP_SKB_CB(skb)->end_seq += copy;\n\t\ttcp_skb_pcount_set(skb, 0);",
"\t\tcopied += copy;\n\t\tif (!msg_data_left(msg)) {\n\t\t\tif (unlikely(flags & MSG_EOR))\n\t\t\t\tTCP_SKB_CB(skb)->eor = 1;\n\t\t\tgoto out;\n\t\t}",
"\t\tif (skb->len < max || (flags & MSG_OOB) || unlikely(tp->repair))\n\t\t\tcontinue;",
"\t\tif (forced_push(tp)) {\n\t\t\ttcp_mark_push(tp, skb);\n\t\t\t__tcp_push_pending_frames(sk, mss_now, TCP_NAGLE_PUSH);\n\t\t} else if (skb == tcp_send_head(sk))\n\t\t\ttcp_push_one(sk, mss_now);\n\t\tcontinue;",
"wait_for_sndbuf:\n\t\tset_bit(SOCK_NOSPACE, &sk->sk_socket->flags);\nwait_for_memory:\n\t\tif (copied)\n\t\t\ttcp_push(sk, flags & ~MSG_MORE, mss_now,\n\t\t\t\t TCP_NAGLE_PUSH, size_goal);",
"\t\terr = sk_stream_wait_memory(sk, &timeo);\n\t\tif (err != 0)\n\t\t\tgoto do_error;",
"\t\tmss_now = tcp_send_mss(sk, &size_goal, flags);\n\t}",
"out:\n\tif (copied) {\n\t\ttcp_tx_timestamp(sk, sockc.tsflags, tcp_write_queue_tail(sk));\n\t\ttcp_push(sk, flags, mss_now, tp->nonagle, size_goal);\n\t}\nout_nopush:\n\trelease_sock(sk);\n\treturn copied + copied_syn;",
"do_fault:\n\tif (!skb->len) {\n\t\ttcp_unlink_write_queue(skb, sk);\n\t\t/* It is the one place in all of TCP, except connection\n\t\t * reset, where we can be unlinking the send_head.\n\t\t */\n\t\ttcp_check_send_head(sk, skb);\n\t\tsk_wmem_free_skb(sk, skb);\n\t}",
"do_error:\n\tif (copied + copied_syn)\n\t\tgoto out;\nout_err:\n\terr = sk_stream_error(sk, flags, err);\n\t/* make sure we wake any epoll edge trigger waiter */\n\tif (unlikely(skb_queue_len(&sk->sk_write_queue) == 0 &&\n\t\t err == -EAGAIN)) {\n\t\tsk->sk_write_space(sk);\n\t\ttcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);\n\t}\n\trelease_sock(sk);\n\treturn err;\n}\nEXPORT_SYMBOL(tcp_sendmsg);",
"/*\n *\tHandle reading urgent data. BSD has very simple semantics for\n *\tthis, no blocking and very strange errors 8)\n */",
"static int tcp_recv_urg(struct sock *sk, struct msghdr *msg, int len, int flags)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);",
"\t/* No URG data to read. */\n\tif (sock_flag(sk, SOCK_URGINLINE) || !tp->urg_data ||\n\t tp->urg_data == TCP_URG_READ)\n\t\treturn -EINVAL;\t/* Yes this is right ! */",
"\tif (sk->sk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DONE))\n\t\treturn -ENOTCONN;",
"\tif (tp->urg_data & TCP_URG_VALID) {\n\t\tint err = 0;\n\t\tchar c = tp->urg_data;",
"\t\tif (!(flags & MSG_PEEK))\n\t\t\ttp->urg_data = TCP_URG_READ;",
"\t\t/* Read urgent data. */\n\t\tmsg->msg_flags |= MSG_OOB;",
"\t\tif (len > 0) {\n\t\t\tif (!(flags & MSG_TRUNC))\n\t\t\t\terr = memcpy_to_msg(msg, &c, 1);\n\t\t\tlen = 1;\n\t\t} else\n\t\t\tmsg->msg_flags |= MSG_TRUNC;",
"\t\treturn err ? -EFAULT : len;\n\t}",
"\tif (sk->sk_state == TCP_CLOSE || (sk->sk_shutdown & RCV_SHUTDOWN))\n\t\treturn 0;",
"\t/* Fixed the recv(..., MSG_OOB) behaviour. BSD docs and\n\t * the available implementations agree in this case:\n\t * this call should never block, independent of the\n\t * blocking state of the socket.\n\t * Mike <pall@rz.uni-karlsruhe.de>\n\t */\n\treturn -EAGAIN;\n}",
"static int tcp_peek_sndq(struct sock *sk, struct msghdr *msg, int len)\n{\n\tstruct sk_buff *skb;\n\tint copied = 0, err = 0;",
"\t/* XXX -- need to support SO_PEEK_OFF */",
"\tskb_queue_walk(&sk->sk_write_queue, skb) {\n\t\terr = skb_copy_datagram_msg(skb, 0, msg, skb->len);\n\t\tif (err)\n\t\t\tbreak;",
"\t\tcopied += skb->len;\n\t}",
"\treturn err ?: copied;\n}",
"/* Clean up the receive buffer for full frames taken by the user,\n * then send an ACK if necessary. COPIED is the number of bytes\n * tcp_recvmsg has given to the user so far, it speeds up the\n * calculation of whether or not we must ACK for the sake of\n * a window update.\n */\nstatic void tcp_cleanup_rbuf(struct sock *sk, int copied)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tbool time_to_ack = false;",
"\tstruct sk_buff *skb = skb_peek(&sk->sk_receive_queue);",
"\tWARN(skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq),\n\t \"cleanup rbuf bug: copied %X seq %X rcvnxt %X\\n\",\n\t tp->copied_seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt);",
"\tif (inet_csk_ack_scheduled(sk)) {\n\t\tconst struct inet_connection_sock *icsk = inet_csk(sk);\n\t\t /* Delayed ACKs frequently hit locked sockets during bulk\n\t\t * receive. */\n\t\tif (icsk->icsk_ack.blocked ||\n\t\t /* Once-per-two-segments ACK was not sent by tcp_input.c */\n\t\t tp->rcv_nxt - tp->rcv_wup > icsk->icsk_ack.rcv_mss ||\n\t\t /*\n\t\t * If this read emptied read buffer, we send ACK, if\n\t\t * connection is not bidirectional, user drained\n\t\t * receive buffer and there was a small segment\n\t\t * in queue.\n\t\t */\n\t\t (copied > 0 &&\n\t\t ((icsk->icsk_ack.pending & ICSK_ACK_PUSHED2) ||\n\t\t ((icsk->icsk_ack.pending & ICSK_ACK_PUSHED) &&\n\t\t !icsk->icsk_ack.pingpong)) &&\n\t\t !atomic_read(&sk->sk_rmem_alloc)))\n\t\t\ttime_to_ack = true;\n\t}",
"\t/* We send an ACK if we can now advertise a non-zero window\n\t * which has been raised \"significantly\".\n\t *\n\t * Even if window raised up to infinity, do not send window open ACK\n\t * in states, where we will not receive more. It is useless.\n\t */\n\tif (copied > 0 && !time_to_ack && !(sk->sk_shutdown & RCV_SHUTDOWN)) {\n\t\t__u32 rcv_window_now = tcp_receive_window(tp);",
"\t\t/* Optimize, __tcp_select_window() is not cheap. */\n\t\tif (2*rcv_window_now <= tp->window_clamp) {\n\t\t\t__u32 new_window = __tcp_select_window(sk);",
"\t\t\t/* Send ACK now, if this read freed lots of space\n\t\t\t * in our buffer. Certainly, new_window is new window.\n\t\t\t * We can advertise it now, if it is not less than current one.\n\t\t\t * \"Lots\" means \"at least twice\" here.\n\t\t\t */\n\t\t\tif (new_window && new_window >= 2 * rcv_window_now)\n\t\t\t\ttime_to_ack = true;\n\t\t}\n\t}\n\tif (time_to_ack)\n\t\ttcp_send_ack(sk);\n}",
"static void tcp_prequeue_process(struct sock *sk)\n{\n\tstruct sk_buff *skb;\n\tstruct tcp_sock *tp = tcp_sk(sk);",
"\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPPREQUEUED);",
"\twhile ((skb = __skb_dequeue(&tp->ucopy.prequeue)) != NULL)\n\t\tsk_backlog_rcv(sk, skb);",
"\t/* Clear memory counter. */\n\ttp->ucopy.memory = 0;\n}",
"static struct sk_buff *tcp_recv_skb(struct sock *sk, u32 seq, u32 *off)\n{\n\tstruct sk_buff *skb;\n\tu32 offset;",
"\twhile ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) {\n\t\toffset = seq - TCP_SKB_CB(skb)->seq;\n\t\tif (unlikely(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) {\n\t\t\tpr_err_once(\"%s: found a SYN, please report !\\n\", __func__);\n\t\t\toffset--;\n\t\t}\n\t\tif (offset < skb->len || (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)) {\n\t\t\t*off = offset;\n\t\t\treturn skb;\n\t\t}\n\t\t/* This looks weird, but this can happen if TCP collapsing\n\t\t * splitted a fat GRO packet, while we released socket lock\n\t\t * in skb_splice_bits()\n\t\t */\n\t\tsk_eat_skb(sk, skb);\n\t}\n\treturn NULL;\n}",
"/*\n * This routine provides an alternative to tcp_recvmsg() for routines\n * that would like to handle copying from skbuffs directly in 'sendfile'\n * fashion.\n * Note:\n *\t- It is assumed that the socket was locked by the caller.\n *\t- The routine does not block.\n *\t- At present, there is no support for reading OOB data\n *\t or for 'peeking' the socket using this routine\n *\t (although both would be easy to implement).\n */\nint tcp_read_sock(struct sock *sk, read_descriptor_t *desc,\n\t\t sk_read_actor_t recv_actor)\n{\n\tstruct sk_buff *skb;\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tu32 seq = tp->copied_seq;\n\tu32 offset;\n\tint copied = 0;",
"\tif (sk->sk_state == TCP_LISTEN)\n\t\treturn -ENOTCONN;\n\twhile ((skb = tcp_recv_skb(sk, seq, &offset)) != NULL) {\n\t\tif (offset < skb->len) {\n\t\t\tint used;\n\t\t\tsize_t len;",
"\t\t\tlen = skb->len - offset;\n\t\t\t/* Stop reading if we hit a patch of urgent data */\n\t\t\tif (tp->urg_data) {\n\t\t\t\tu32 urg_offset = tp->urg_seq - seq;\n\t\t\t\tif (urg_offset < len)\n\t\t\t\t\tlen = urg_offset;\n\t\t\t\tif (!len)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tused = recv_actor(desc, skb, offset, len);\n\t\t\tif (used <= 0) {\n\t\t\t\tif (!copied)\n\t\t\t\t\tcopied = used;\n\t\t\t\tbreak;\n\t\t\t} else if (used <= len) {\n\t\t\t\tseq += used;\n\t\t\t\tcopied += used;\n\t\t\t\toffset += used;\n\t\t\t}\n\t\t\t/* If recv_actor drops the lock (e.g. TCP splice\n\t\t\t * receive) the skb pointer might be invalid when\n\t\t\t * getting here: tcp_collapse might have deleted it\n\t\t\t * while aggregating skbs from the socket queue.\n\t\t\t */\n\t\t\tskb = tcp_recv_skb(sk, seq - 1, &offset);\n\t\t\tif (!skb)\n\t\t\t\tbreak;\n\t\t\t/* TCP coalescing might have appended data to the skb.\n\t\t\t * Try to splice more frags\n\t\t\t */\n\t\t\tif (offset + 1 != skb->len)\n\t\t\t\tcontinue;\n\t\t}\n\t\tif (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) {\n\t\t\tsk_eat_skb(sk, skb);\n\t\t\t++seq;\n\t\t\tbreak;\n\t\t}\n\t\tsk_eat_skb(sk, skb);\n\t\tif (!desc->count)\n\t\t\tbreak;\n\t\ttp->copied_seq = seq;\n\t}\n\ttp->copied_seq = seq;",
"\ttcp_rcv_space_adjust(sk);",
"\t/* Clean up data we have read: This will do ACK frames. */\n\tif (copied > 0) {\n\t\ttcp_recv_skb(sk, seq, &offset);\n\t\ttcp_cleanup_rbuf(sk, copied);\n\t}\n\treturn copied;\n}\nEXPORT_SYMBOL(tcp_read_sock);",
"int tcp_peek_len(struct socket *sock)\n{\n\treturn tcp_inq(sock->sk);\n}\nEXPORT_SYMBOL(tcp_peek_len);",
"/*\n *\tThis routine copies from a sock struct into the user buffer.\n *\n *\tTechnical note: in 2.3 we work on _locked_ socket, so that\n *\ttricks with *seq access order and skb->users are not required.\n *\tProbably, code can be easily improved even more.\n */",
"int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,\n\t\tint flags, int *addr_len)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint copied = 0;\n\tu32 peek_seq;\n\tu32 *seq;\n\tunsigned long used;\n\tint err;\n\tint target;\t\t/* Read at least this many bytes */\n\tlong timeo;\n\tstruct task_struct *user_recv = NULL;\n\tstruct sk_buff *skb, *last;\n\tu32 urg_hole = 0;",
"\tif (unlikely(flags & MSG_ERRQUEUE))\n\t\treturn inet_recv_error(sk, msg, len, addr_len);",
"\tif (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue) &&\n\t (sk->sk_state == TCP_ESTABLISHED))\n\t\tsk_busy_loop(sk, nonblock);",
"\tlock_sock(sk);",
"\terr = -ENOTCONN;\n\tif (sk->sk_state == TCP_LISTEN)\n\t\tgoto out;",
"\ttimeo = sock_rcvtimeo(sk, nonblock);",
"\t/* Urgent data needs to be handled specially. */\n\tif (flags & MSG_OOB)\n\t\tgoto recv_urg;",
"\tif (unlikely(tp->repair)) {\n\t\terr = -EPERM;\n\t\tif (!(flags & MSG_PEEK))\n\t\t\tgoto out;",
"\t\tif (tp->repair_queue == TCP_SEND_QUEUE)\n\t\t\tgoto recv_sndq;",
"\t\terr = -EINVAL;\n\t\tif (tp->repair_queue == TCP_NO_QUEUE)\n\t\t\tgoto out;",
"\t\t/* 'common' recv queue MSG_PEEK-ing */\n\t}",
"\tseq = &tp->copied_seq;\n\tif (flags & MSG_PEEK) {\n\t\tpeek_seq = tp->copied_seq;\n\t\tseq = &peek_seq;\n\t}",
"\ttarget = sock_rcvlowat(sk, flags & MSG_WAITALL, len);",
"\tdo {\n\t\tu32 offset;",
"\t\t/* Are we at urgent data? Stop if we have read anything or have SIGURG pending. */\n\t\tif (tp->urg_data && tp->urg_seq == *seq) {\n\t\t\tif (copied)\n\t\t\t\tbreak;\n\t\t\tif (signal_pending(current)) {\n\t\t\t\tcopied = timeo ? sock_intr_errno(timeo) : -EAGAIN;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\t/* Next get a buffer. */",
"\t\tlast = skb_peek_tail(&sk->sk_receive_queue);\n\t\tskb_queue_walk(&sk->sk_receive_queue, skb) {\n\t\t\tlast = skb;\n\t\t\t/* Now that we have two receive queues this\n\t\t\t * shouldn't happen.\n\t\t\t */\n\t\t\tif (WARN(before(*seq, TCP_SKB_CB(skb)->seq),\n\t\t\t\t \"recvmsg bug: copied %X seq %X rcvnxt %X fl %X\\n\",\n\t\t\t\t *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt,\n\t\t\t\t flags))\n\t\t\t\tbreak;",
"\t\t\toffset = *seq - TCP_SKB_CB(skb)->seq;\n\t\t\tif (unlikely(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) {\n\t\t\t\tpr_err_once(\"%s: found a SYN, please report !\\n\", __func__);\n\t\t\t\toffset--;\n\t\t\t}\n\t\t\tif (offset < skb->len)\n\t\t\t\tgoto found_ok_skb;\n\t\t\tif (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)\n\t\t\t\tgoto found_fin_ok;\n\t\t\tWARN(!(flags & MSG_PEEK),\n\t\t\t \"recvmsg bug 2: copied %X seq %X rcvnxt %X fl %X\\n\",\n\t\t\t *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt, flags);\n\t\t}",
"\t\t/* Well, if we have backlog, try to process it now yet. */",
"\t\tif (copied >= target && !sk->sk_backlog.tail)\n\t\t\tbreak;",
"\t\tif (copied) {\n\t\t\tif (sk->sk_err ||\n\t\t\t sk->sk_state == TCP_CLOSE ||\n\t\t\t (sk->sk_shutdown & RCV_SHUTDOWN) ||\n\t\t\t !timeo ||\n\t\t\t signal_pending(current))\n\t\t\t\tbreak;\n\t\t} else {\n\t\t\tif (sock_flag(sk, SOCK_DONE))\n\t\t\t\tbreak;",
"\t\t\tif (sk->sk_err) {\n\t\t\t\tcopied = sock_error(sk);\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\t\t\tbreak;",
"\t\t\tif (sk->sk_state == TCP_CLOSE) {\n\t\t\t\tif (!sock_flag(sk, SOCK_DONE)) {\n\t\t\t\t\t/* This occurs when user tries to read\n\t\t\t\t\t * from never connected socket.\n\t\t\t\t\t */\n\t\t\t\t\tcopied = -ENOTCONN;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tif (!timeo) {\n\t\t\t\tcopied = -EAGAIN;\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tif (signal_pending(current)) {\n\t\t\t\tcopied = sock_intr_errno(timeo);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\ttcp_cleanup_rbuf(sk, copied);",
"\t\tif (!sysctl_tcp_low_latency && tp->ucopy.task == user_recv) {\n\t\t\t/* Install new reader */\n\t\t\tif (!user_recv && !(flags & (MSG_TRUNC | MSG_PEEK))) {\n\t\t\t\tuser_recv = current;\n\t\t\t\ttp->ucopy.task = user_recv;\n\t\t\t\ttp->ucopy.msg = msg;\n\t\t\t}",
"\t\t\ttp->ucopy.len = len;",
"\t\t\tWARN_ON(tp->copied_seq != tp->rcv_nxt &&\n\t\t\t\t!(flags & (MSG_PEEK | MSG_TRUNC)));",
"\t\t\t/* Ugly... If prequeue is not empty, we have to\n\t\t\t * process it before releasing socket, otherwise\n\t\t\t * order will be broken at second iteration.\n\t\t\t * More elegant solution is required!!!\n\t\t\t *\n\t\t\t * Look: we have the following (pseudo)queues:\n\t\t\t *\n\t\t\t * 1. packets in flight\n\t\t\t * 2. backlog\n\t\t\t * 3. prequeue\n\t\t\t * 4. receive_queue\n\t\t\t *\n\t\t\t * Each queue can be processed only if the next ones\n\t\t\t * are empty. At this point we have empty receive_queue.\n\t\t\t * But prequeue _can_ be not empty after 2nd iteration,\n\t\t\t * when we jumped to start of loop because backlog\n\t\t\t * processing added something to receive_queue.\n\t\t\t * We cannot release_sock(), because backlog contains\n\t\t\t * packets arrived _after_ prequeued ones.\n\t\t\t *\n\t\t\t * Shortly, algorithm is clear --- to process all\n\t\t\t * the queues in order. We could make it more directly,\n\t\t\t * requeueing packets from backlog to prequeue, if\n\t\t\t * is not empty. It is more elegant, but eats cycles,\n\t\t\t * unfortunately.\n\t\t\t */\n\t\t\tif (!skb_queue_empty(&tp->ucopy.prequeue))\n\t\t\t\tgoto do_prequeue;",
"\t\t\t/* __ Set realtime policy in scheduler __ */\n\t\t}",
"\t\tif (copied >= target) {\n\t\t\t/* Do not sleep, just process backlog. */\n\t\t\trelease_sock(sk);\n\t\t\tlock_sock(sk);\n\t\t} else {\n\t\t\tsk_wait_data(sk, &timeo, last);\n\t\t}",
"\t\tif (user_recv) {\n\t\t\tint chunk;",
"\t\t\t/* __ Restore normal policy in scheduler __ */",
"\t\t\tchunk = len - tp->ucopy.len;\n\t\t\tif (chunk != 0) {\n\t\t\t\tNET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPDIRECTCOPYFROMBACKLOG, chunk);\n\t\t\t\tlen -= chunk;\n\t\t\t\tcopied += chunk;\n\t\t\t}",
"\t\t\tif (tp->rcv_nxt == tp->copied_seq &&\n\t\t\t !skb_queue_empty(&tp->ucopy.prequeue)) {\ndo_prequeue:\n\t\t\t\ttcp_prequeue_process(sk);",
"\t\t\t\tchunk = len - tp->ucopy.len;\n\t\t\t\tif (chunk != 0) {\n\t\t\t\t\tNET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPDIRECTCOPYFROMPREQUEUE, chunk);\n\t\t\t\t\tlen -= chunk;\n\t\t\t\t\tcopied += chunk;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ((flags & MSG_PEEK) &&\n\t\t (peek_seq - copied - urg_hole != tp->copied_seq)) {\n\t\t\tnet_dbg_ratelimited(\"TCP(%s:%d): Application bug, race in MSG_PEEK\\n\",\n\t\t\t\t\t current->comm,\n\t\t\t\t\t task_pid_nr(current));\n\t\t\tpeek_seq = tp->copied_seq;\n\t\t}\n\t\tcontinue;",
"\tfound_ok_skb:\n\t\t/* Ok so how much can we use? */\n\t\tused = skb->len - offset;\n\t\tif (len < used)\n\t\t\tused = len;",
"\t\t/* Do we have urgent data here? */\n\t\tif (tp->urg_data) {\n\t\t\tu32 urg_offset = tp->urg_seq - *seq;\n\t\t\tif (urg_offset < used) {\n\t\t\t\tif (!urg_offset) {\n\t\t\t\t\tif (!sock_flag(sk, SOCK_URGINLINE)) {\n\t\t\t\t\t\t++*seq;\n\t\t\t\t\t\turg_hole++;\n\t\t\t\t\t\toffset++;\n\t\t\t\t\t\tused--;\n\t\t\t\t\t\tif (!used)\n\t\t\t\t\t\t\tgoto skip_copy;\n\t\t\t\t\t}\n\t\t\t\t} else\n\t\t\t\t\tused = urg_offset;\n\t\t\t}\n\t\t}",
"\t\tif (!(flags & MSG_TRUNC)) {\n\t\t\terr = skb_copy_datagram_msg(skb, offset, msg, used);\n\t\t\tif (err) {\n\t\t\t\t/* Exception. Bailout! */\n\t\t\t\tif (!copied)\n\t\t\t\t\tcopied = -EFAULT;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\t*seq += used;\n\t\tcopied += used;\n\t\tlen -= used;",
"\t\ttcp_rcv_space_adjust(sk);",
"skip_copy:\n\t\tif (tp->urg_data && after(tp->copied_seq, tp->urg_seq)) {\n\t\t\ttp->urg_data = 0;\n\t\t\ttcp_fast_path_check(sk);\n\t\t}\n\t\tif (used + offset < skb->len)\n\t\t\tcontinue;",
"\t\tif (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)\n\t\t\tgoto found_fin_ok;\n\t\tif (!(flags & MSG_PEEK))\n\t\t\tsk_eat_skb(sk, skb);\n\t\tcontinue;",
"\tfound_fin_ok:\n\t\t/* Process the FIN. */\n\t\t++*seq;\n\t\tif (!(flags & MSG_PEEK))\n\t\t\tsk_eat_skb(sk, skb);\n\t\tbreak;\n\t} while (len > 0);",
"\tif (user_recv) {\n\t\tif (!skb_queue_empty(&tp->ucopy.prequeue)) {\n\t\t\tint chunk;",
"\t\t\ttp->ucopy.len = copied > 0 ? len : 0;",
"\t\t\ttcp_prequeue_process(sk);",
"\t\t\tif (copied > 0 && (chunk = len - tp->ucopy.len) != 0) {\n\t\t\t\tNET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPDIRECTCOPYFROMPREQUEUE, chunk);\n\t\t\t\tlen -= chunk;\n\t\t\t\tcopied += chunk;\n\t\t\t}\n\t\t}",
"\t\ttp->ucopy.task = NULL;\n\t\ttp->ucopy.len = 0;\n\t}",
"\t/* According to UNIX98, msg_name/msg_namelen are ignored\n\t * on connected socket. I was just happy when found this 8) --ANK\n\t */",
"\t/* Clean up data we have read: This will do ACK frames. */\n\ttcp_cleanup_rbuf(sk, copied);",
"\trelease_sock(sk);\n\treturn copied;",
"out:\n\trelease_sock(sk);\n\treturn err;",
"recv_urg:\n\terr = tcp_recv_urg(sk, msg, len, flags);\n\tgoto out;",
"recv_sndq:\n\terr = tcp_peek_sndq(sk, msg, len);\n\tgoto out;\n}\nEXPORT_SYMBOL(tcp_recvmsg);",
"void tcp_set_state(struct sock *sk, int state)\n{\n\tint oldstate = sk->sk_state;",
"\tswitch (state) {\n\tcase TCP_ESTABLISHED:\n\t\tif (oldstate != TCP_ESTABLISHED)\n\t\t\tTCP_INC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);\n\t\tbreak;",
"\tcase TCP_CLOSE:\n\t\tif (oldstate == TCP_CLOSE_WAIT || oldstate == TCP_ESTABLISHED)\n\t\t\tTCP_INC_STATS(sock_net(sk), TCP_MIB_ESTABRESETS);",
"\t\tsk->sk_prot->unhash(sk);\n\t\tif (inet_csk(sk)->icsk_bind_hash &&\n\t\t !(sk->sk_userlocks & SOCK_BINDPORT_LOCK))\n\t\t\tinet_put_port(sk);\n\t\t/* fall through */\n\tdefault:\n\t\tif (oldstate == TCP_ESTABLISHED)\n\t\t\tTCP_DEC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);\n\t}",
"\t/* Change state AFTER socket is unhashed to avoid closed\n\t * socket sitting in hash tables.\n\t */\n\tsk_state_store(sk, state);",
"#ifdef STATE_TRACE\n\tSOCK_DEBUG(sk, \"TCP sk=%p, State %s -> %s\\n\", sk, statename[oldstate], statename[state]);\n#endif\n}\nEXPORT_SYMBOL_GPL(tcp_set_state);",
"/*\n *\tState processing on a close. This implements the state shift for\n *\tsending our FIN frame. Note that we only send a FIN for some\n *\tstates. A shutdown() may have already sent the FIN, or we may be\n *\tclosed.\n */",
"static const unsigned char new_state[16] = {\n /* current state: new state: action:\t*/\n [0 /* (Invalid) */]\t= TCP_CLOSE,\n [TCP_ESTABLISHED]\t= TCP_FIN_WAIT1 | TCP_ACTION_FIN,\n [TCP_SYN_SENT]\t= TCP_CLOSE,\n [TCP_SYN_RECV]\t= TCP_FIN_WAIT1 | TCP_ACTION_FIN,\n [TCP_FIN_WAIT1]\t= TCP_FIN_WAIT1,\n [TCP_FIN_WAIT2]\t= TCP_FIN_WAIT2,\n [TCP_TIME_WAIT]\t= TCP_CLOSE,\n [TCP_CLOSE]\t\t= TCP_CLOSE,\n [TCP_CLOSE_WAIT]\t= TCP_LAST_ACK | TCP_ACTION_FIN,\n [TCP_LAST_ACK]\t= TCP_LAST_ACK,\n [TCP_LISTEN]\t\t= TCP_CLOSE,\n [TCP_CLOSING]\t\t= TCP_CLOSING,\n [TCP_NEW_SYN_RECV]\t= TCP_CLOSE,\t/* should not happen ! */\n};",
"static int tcp_close_state(struct sock *sk)\n{\n\tint next = (int)new_state[sk->sk_state];\n\tint ns = next & TCP_STATE_MASK;",
"\ttcp_set_state(sk, ns);",
"\treturn next & TCP_ACTION_FIN;\n}",
"/*\n *\tShutdown the sending side of a connection. Much like close except\n *\tthat we don't receive shut down or sock_set_flag(sk, SOCK_DEAD).\n */",
"void tcp_shutdown(struct sock *sk, int how)\n{\n\t/*\tWe need to grab some memory, and put together a FIN,\n\t *\tand then put it into the queue to be sent.\n\t *\t\tTim MacKenzie(tym@dibbler.cs.monash.edu.au) 4 Dec '92.\n\t */\n\tif (!(how & SEND_SHUTDOWN))\n\t\treturn;",
"\t/* If we've already sent a FIN, or it's a closed state, skip this. */\n\tif ((1 << sk->sk_state) &\n\t (TCPF_ESTABLISHED | TCPF_SYN_SENT |\n\t TCPF_SYN_RECV | TCPF_CLOSE_WAIT)) {\n\t\t/* Clear out any half completed packets. FIN if needed. */\n\t\tif (tcp_close_state(sk))\n\t\t\ttcp_send_fin(sk);\n\t}\n}\nEXPORT_SYMBOL(tcp_shutdown);",
"bool tcp_check_oom(struct sock *sk, int shift)\n{\n\tbool too_many_orphans, out_of_socket_memory;",
"\ttoo_many_orphans = tcp_too_many_orphans(sk, shift);\n\tout_of_socket_memory = tcp_out_of_memory(sk);",
"\tif (too_many_orphans)\n\t\tnet_info_ratelimited(\"too many orphaned sockets\\n\");\n\tif (out_of_socket_memory)\n\t\tnet_info_ratelimited(\"out of memory -- consider tuning tcp_mem\\n\");\n\treturn too_many_orphans || out_of_socket_memory;\n}",
"void tcp_close(struct sock *sk, long timeout)\n{\n\tstruct sk_buff *skb;\n\tint data_was_unread = 0;\n\tint state;",
"\tlock_sock(sk);\n\tsk->sk_shutdown = SHUTDOWN_MASK;",
"\tif (sk->sk_state == TCP_LISTEN) {\n\t\ttcp_set_state(sk, TCP_CLOSE);",
"\t\t/* Special case. */\n\t\tinet_csk_listen_stop(sk);",
"\t\tgoto adjudge_to_death;\n\t}",
"\t/* We need to flush the recv. buffs. We do this only on the\n\t * descriptor close, not protocol-sourced closes, because the\n\t * reader process may not have drained the data yet!\n\t */\n\twhile ((skb = __skb_dequeue(&sk->sk_receive_queue)) != NULL) {\n\t\tu32 len = TCP_SKB_CB(skb)->end_seq - TCP_SKB_CB(skb)->seq;",
"\t\tif (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)\n\t\t\tlen--;\n\t\tdata_was_unread += len;\n\t\t__kfree_skb(skb);\n\t}",
"\tsk_mem_reclaim(sk);",
"\t/* If socket has been already reset (e.g. in tcp_reset()) - kill it. */\n\tif (sk->sk_state == TCP_CLOSE)\n\t\tgoto adjudge_to_death;",
"\t/* As outlined in RFC 2525, section 2.17, we send a RST here because\n\t * data was lost. To witness the awful effects of the old behavior of\n\t * always doing a FIN, run an older 2.1.x kernel or 2.0.x, start a bulk\n\t * GET in an FTP client, suspend the process, wait for the client to\n\t * advertise a zero window, then kill -9 the FTP client, wheee...\n\t * Note: timeout is always zero in such a case.\n\t */\n\tif (unlikely(tcp_sk(sk)->repair)) {\n\t\tsk->sk_prot->disconnect(sk, 0);\n\t} else if (data_was_unread) {\n\t\t/* Unread data was tossed, zap the connection. */\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONCLOSE);\n\t\ttcp_set_state(sk, TCP_CLOSE);\n\t\ttcp_send_active_reset(sk, sk->sk_allocation);\n\t} else if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) {\n\t\t/* Check zero linger _after_ checking for unread data. */\n\t\tsk->sk_prot->disconnect(sk, 0);\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA);\n\t} else if (tcp_close_state(sk)) {\n\t\t/* We FIN if the application ate all the data before\n\t\t * zapping the connection.\n\t\t */",
"\t\t/* RED-PEN. Formally speaking, we have broken TCP state\n\t\t * machine. State transitions:\n\t\t *\n\t\t * TCP_ESTABLISHED -> TCP_FIN_WAIT1\n\t\t * TCP_SYN_RECV\t-> TCP_FIN_WAIT1 (forget it, it's impossible)\n\t\t * TCP_CLOSE_WAIT -> TCP_LAST_ACK\n\t\t *\n\t\t * are legal only when FIN has been sent (i.e. in window),\n\t\t * rather than queued out of window. Purists blame.\n\t\t *\n\t\t * F.e. \"RFC state\" is ESTABLISHED,\n\t\t * if Linux state is FIN-WAIT-1, but FIN is still not sent.\n\t\t *\n\t\t * The visible declinations are that sometimes\n\t\t * we enter time-wait state, when it is not required really\n\t\t * (harmless), do not send active resets, when they are\n\t\t * required by specs (TCP_ESTABLISHED, TCP_CLOSE_WAIT, when\n\t\t * they look as CLOSING or LAST_ACK for Linux)\n\t\t * Probably, I missed some more holelets.\n\t\t * \t\t\t\t\t\t--ANK\n\t\t * XXX (TFO) - To start off we don't support SYN+ACK+FIN\n\t\t * in a single packet! (May consider it later but will\n\t\t * probably need API support or TCP_CORK SYN-ACK until\n\t\t * data is written and socket is closed.)\n\t\t */\n\t\ttcp_send_fin(sk);\n\t}",
"\tsk_stream_wait_close(sk, timeout);",
"adjudge_to_death:\n\tstate = sk->sk_state;\n\tsock_hold(sk);\n\tsock_orphan(sk);",
"\t/* It is the last release_sock in its life. It will remove backlog. */\n\trelease_sock(sk);",
"\n\t/* Now socket is owned by kernel and we acquire BH lock\n\t to finish close. No need to check for user refs.\n\t */\n\tlocal_bh_disable();\n\tbh_lock_sock(sk);\n\tWARN_ON(sock_owned_by_user(sk));",
"\tpercpu_counter_inc(sk->sk_prot->orphan_count);",
"\t/* Have we already been destroyed by a softirq or backlog? */\n\tif (state != TCP_CLOSE && sk->sk_state == TCP_CLOSE)\n\t\tgoto out;",
"\t/*\tThis is a (useful) BSD violating of the RFC. There is a\n\t *\tproblem with TCP as specified in that the other end could\n\t *\tkeep a socket open forever with no application left this end.\n\t *\tWe use a 1 minute timeout (about the same as BSD) then kill\n\t *\tour end. If they send after that then tough - BUT: long enough\n\t *\tthat we won't make the old 4*rto = almost no time - whoops\n\t *\treset mistake.\n\t *\n\t *\tNope, it was not mistake. It is really desired behaviour\n\t *\tf.e. on http servers, when such sockets are useless, but\n\t *\tconsume significant resources. Let's do it with special\n\t *\tlinger2\toption.\t\t\t\t\t--ANK\n\t */",
"\tif (sk->sk_state == TCP_FIN_WAIT2) {\n\t\tstruct tcp_sock *tp = tcp_sk(sk);\n\t\tif (tp->linger2 < 0) {\n\t\t\ttcp_set_state(sk, TCP_CLOSE);\n\t\t\ttcp_send_active_reset(sk, GFP_ATOMIC);\n\t\t\t__NET_INC_STATS(sock_net(sk),\n\t\t\t\t\tLINUX_MIB_TCPABORTONLINGER);\n\t\t} else {\n\t\t\tconst int tmo = tcp_fin_time(sk);",
"\t\t\tif (tmo > TCP_TIMEWAIT_LEN) {\n\t\t\t\tinet_csk_reset_keepalive_timer(sk,\n\t\t\t\t\t\ttmo - TCP_TIMEWAIT_LEN);\n\t\t\t} else {\n\t\t\t\ttcp_time_wait(sk, TCP_FIN_WAIT2, tmo);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t}\n\tif (sk->sk_state != TCP_CLOSE) {\n\t\tsk_mem_reclaim(sk);\n\t\tif (tcp_check_oom(sk, 0)) {\n\t\t\ttcp_set_state(sk, TCP_CLOSE);\n\t\t\ttcp_send_active_reset(sk, GFP_ATOMIC);\n\t\t\t__NET_INC_STATS(sock_net(sk),\n\t\t\t\t\tLINUX_MIB_TCPABORTONMEMORY);\n\t\t}\n\t}",
"\tif (sk->sk_state == TCP_CLOSE) {\n\t\tstruct request_sock *req = tcp_sk(sk)->fastopen_rsk;\n\t\t/* We could get here with a non-NULL req if the socket is\n\t\t * aborted (e.g., closed with unread data) before 3WHS\n\t\t * finishes.\n\t\t */\n\t\tif (req)\n\t\t\treqsk_fastopen_remove(sk, req, false);\n\t\tinet_csk_destroy_sock(sk);\n\t}\n\t/* Otherwise, socket is reprieved until protocol close. */",
"out:\n\tbh_unlock_sock(sk);\n\tlocal_bh_enable();\n\tsock_put(sk);\n}\nEXPORT_SYMBOL(tcp_close);",
"/* These states need RST on ABORT according to RFC793 */",
"static inline bool tcp_need_reset(int state)\n{\n\treturn (1 << state) &\n\t (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_FIN_WAIT1 |\n\t\tTCPF_FIN_WAIT2 | TCPF_SYN_RECV);\n}",
"int tcp_disconnect(struct sock *sk, int flags)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tint err = 0;\n\tint old_state = sk->sk_state;",
"\tif (old_state != TCP_CLOSE)\n\t\ttcp_set_state(sk, TCP_CLOSE);",
"\t/* ABORT function of RFC793 */\n\tif (old_state == TCP_LISTEN) {\n\t\tinet_csk_listen_stop(sk);\n\t} else if (unlikely(tp->repair)) {\n\t\tsk->sk_err = ECONNABORTED;\n\t} else if (tcp_need_reset(old_state) ||\n\t\t (tp->snd_nxt != tp->write_seq &&\n\t\t (1 << old_state) & (TCPF_CLOSING | TCPF_LAST_ACK))) {\n\t\t/* The last check adjusts for discrepancy of Linux wrt. RFC\n\t\t * states\n\t\t */\n\t\ttcp_send_active_reset(sk, gfp_any());\n\t\tsk->sk_err = ECONNRESET;\n\t} else if (old_state == TCP_SYN_SENT)\n\t\tsk->sk_err = ECONNRESET;",
"\ttcp_clear_xmit_timers(sk);\n\t__skb_queue_purge(&sk->sk_receive_queue);\n\ttcp_write_queue_purge(sk);\n\ttcp_fastopen_active_disable_ofo_check(sk);\n\tskb_rbtree_purge(&tp->out_of_order_queue);",
"\tinet->inet_dport = 0;",
"\tif (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))\n\t\tinet_reset_saddr(sk);",
"\tsk->sk_shutdown = 0;\n\tsock_reset_flag(sk, SOCK_DONE);\n\ttp->srtt_us = 0;\n\ttp->write_seq += tp->max_window + 2;\n\tif (tp->write_seq == 0)\n\t\ttp->write_seq = 1;\n\ticsk->icsk_backoff = 0;\n\ttp->snd_cwnd = 2;\n\ticsk->icsk_probes_out = 0;\n\ttp->packets_out = 0;\n\ttp->snd_ssthresh = TCP_INFINITE_SSTHRESH;\n\ttp->snd_cwnd_cnt = 0;\n\ttp->window_clamp = 0;\n\ttcp_set_ca_state(sk, TCP_CA_Open);\n\ttcp_clear_retrans(tp);\n\tinet_csk_delack_init(sk);",
"\t/* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0\n\t * issue in __tcp_select_window()\n\t */\n\ticsk->icsk_ack.rcv_mss = TCP_MIN_MSS;",
"\ttcp_init_send_head(sk);\n\tmemset(&tp->rx_opt, 0, sizeof(tp->rx_opt));\n\t__sk_dst_reset(sk);\n\ttcp_saved_syn_free(tp);",
"\t/* Clean up fastopen related fields */\n\ttcp_free_fastopen_req(tp);\n\tinet->defer_connect = 0;",
"\tWARN_ON(inet->inet_num && !icsk->icsk_bind_hash);",
"\tsk->sk_error_report(sk);\n\treturn err;\n}\nEXPORT_SYMBOL(tcp_disconnect);",
"static inline bool tcp_can_repair_sock(const struct sock *sk)\n{\n\treturn ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN) &&\n\t\t(sk->sk_state != TCP_LISTEN);\n}",
"static int tcp_repair_set_window(struct tcp_sock *tp, char __user *optbuf, int len)\n{\n\tstruct tcp_repair_window opt;",
"\tif (!tp->repair)\n\t\treturn -EPERM;",
"\tif (len != sizeof(opt))\n\t\treturn -EINVAL;",
"\tif (copy_from_user(&opt, optbuf, sizeof(opt)))\n\t\treturn -EFAULT;",
"\tif (opt.max_window < opt.snd_wnd)\n\t\treturn -EINVAL;",
"\tif (after(opt.snd_wl1, tp->rcv_nxt + opt.rcv_wnd))\n\t\treturn -EINVAL;",
"\tif (after(opt.rcv_wup, tp->rcv_nxt))\n\t\treturn -EINVAL;",
"\ttp->snd_wl1\t= opt.snd_wl1;\n\ttp->snd_wnd\t= opt.snd_wnd;\n\ttp->max_window\t= opt.max_window;",
"\ttp->rcv_wnd\t= opt.rcv_wnd;\n\ttp->rcv_wup\t= opt.rcv_wup;",
"\treturn 0;\n}",
"static int tcp_repair_options_est(struct tcp_sock *tp,\n\t\tstruct tcp_repair_opt __user *optbuf, unsigned int len)\n{\n\tstruct tcp_repair_opt opt;",
"\twhile (len >= sizeof(opt)) {\n\t\tif (copy_from_user(&opt, optbuf, sizeof(opt)))\n\t\t\treturn -EFAULT;",
"\t\toptbuf++;\n\t\tlen -= sizeof(opt);",
"\t\tswitch (opt.opt_code) {\n\t\tcase TCPOPT_MSS:\n\t\t\ttp->rx_opt.mss_clamp = opt.opt_val;\n\t\t\tbreak;\n\t\tcase TCPOPT_WINDOW:\n\t\t\t{\n\t\t\t\tu16 snd_wscale = opt.opt_val & 0xFFFF;\n\t\t\t\tu16 rcv_wscale = opt.opt_val >> 16;",
"\t\t\t\tif (snd_wscale > TCP_MAX_WSCALE || rcv_wscale > TCP_MAX_WSCALE)\n\t\t\t\t\treturn -EFBIG;",
"\t\t\t\ttp->rx_opt.snd_wscale = snd_wscale;\n\t\t\t\ttp->rx_opt.rcv_wscale = rcv_wscale;\n\t\t\t\ttp->rx_opt.wscale_ok = 1;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TCPOPT_SACK_PERM:\n\t\t\tif (opt.opt_val != 0)\n\t\t\t\treturn -EINVAL;",
"\t\t\ttp->rx_opt.sack_ok |= TCP_SACK_SEEN;\n\t\t\tif (sysctl_tcp_fack)\n\t\t\t\ttcp_enable_fack(tp);\n\t\t\tbreak;\n\t\tcase TCPOPT_TIMESTAMP:\n\t\t\tif (opt.opt_val != 0)\n\t\t\t\treturn -EINVAL;",
"\t\t\ttp->rx_opt.tstamp_ok = 1;\n\t\t\tbreak;\n\t\t}\n\t}",
"\treturn 0;\n}",
"/*\n *\tSocket option code for TCP.\n */\nstatic int do_tcp_setsockopt(struct sock *sk, int level,\n\t\tint optname, char __user *optval, unsigned int optlen)\n{\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct net *net = sock_net(sk);\n\tint val;\n\tint err = 0;",
"\t/* These are data/string values, all the others are ints */\n\tswitch (optname) {\n\tcase TCP_CONGESTION: {\n\t\tchar name[TCP_CA_NAME_MAX];",
"\t\tif (optlen < 1)\n\t\t\treturn -EINVAL;",
"\t\tval = strncpy_from_user(name, optval,\n\t\t\t\t\tmin_t(long, TCP_CA_NAME_MAX-1, optlen));\n\t\tif (val < 0)\n\t\t\treturn -EFAULT;\n\t\tname[val] = 0;",
"\t\tlock_sock(sk);\n\t\terr = tcp_set_congestion_control(sk, name);\n\t\trelease_sock(sk);\n\t\treturn err;\n\t}\n\tdefault:\n\t\t/* fallthru */\n\t\tbreak;\n\t}",
"\tif (optlen < sizeof(int))\n\t\treturn -EINVAL;",
"\tif (get_user(val, (int __user *)optval))\n\t\treturn -EFAULT;",
"\tlock_sock(sk);",
"\tswitch (optname) {\n\tcase TCP_MAXSEG:\n\t\t/* Values greater than interface MTU won't take effect. However\n\t\t * at the point when this call is done we typically don't yet\n\t\t * know which interface is going to be used */\n\t\tif (val && (val < TCP_MIN_MSS || val > MAX_TCP_WINDOW)) {\n\t\t\terr = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\t\ttp->rx_opt.user_mss = val;\n\t\tbreak;",
"\tcase TCP_NODELAY:\n\t\tif (val) {\n\t\t\t/* TCP_NODELAY is weaker than TCP_CORK, so that\n\t\t\t * this option on corked socket is remembered, but\n\t\t\t * it is not activated until cork is cleared.\n\t\t\t *\n\t\t\t * However, when TCP_NODELAY is set we make\n\t\t\t * an explicit push, which overrides even TCP_CORK\n\t\t\t * for currently queued segments.\n\t\t\t */\n\t\t\ttp->nonagle |= TCP_NAGLE_OFF|TCP_NAGLE_PUSH;\n\t\t\ttcp_push_pending_frames(sk);\n\t\t} else {\n\t\t\ttp->nonagle &= ~TCP_NAGLE_OFF;\n\t\t}\n\t\tbreak;",
"\tcase TCP_THIN_LINEAR_TIMEOUTS:\n\t\tif (val < 0 || val > 1)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ttp->thin_lto = val;\n\t\tbreak;",
"\tcase TCP_THIN_DUPACK:\n\t\tif (val < 0 || val > 1)\n\t\t\terr = -EINVAL;\n\t\tbreak;",
"\tcase TCP_REPAIR:\n\t\tif (!tcp_can_repair_sock(sk))\n\t\t\terr = -EPERM;\n\t\telse if (val == 1) {\n\t\t\ttp->repair = 1;\n\t\t\tsk->sk_reuse = SK_FORCE_REUSE;\n\t\t\ttp->repair_queue = TCP_NO_QUEUE;\n\t\t} else if (val == 0) {\n\t\t\ttp->repair = 0;\n\t\t\tsk->sk_reuse = SK_NO_REUSE;\n\t\t\ttcp_send_window_probe(sk);\n\t\t} else\n\t\t\terr = -EINVAL;",
"\t\tbreak;",
"\tcase TCP_REPAIR_QUEUE:\n\t\tif (!tp->repair)\n\t\t\terr = -EPERM;\n\t\telse if (val < TCP_QUEUES_NR)\n\t\t\ttp->repair_queue = val;\n\t\telse\n\t\t\terr = -EINVAL;\n\t\tbreak;",
"\tcase TCP_QUEUE_SEQ:\n\t\tif (sk->sk_state != TCP_CLOSE)\n\t\t\terr = -EPERM;\n\t\telse if (tp->repair_queue == TCP_SEND_QUEUE)\n\t\t\ttp->write_seq = val;\n\t\telse if (tp->repair_queue == TCP_RECV_QUEUE)\n\t\t\ttp->rcv_nxt = val;\n\t\telse\n\t\t\terr = -EINVAL;\n\t\tbreak;",
"\tcase TCP_REPAIR_OPTIONS:\n\t\tif (!tp->repair)\n\t\t\terr = -EINVAL;\n\t\telse if (sk->sk_state == TCP_ESTABLISHED)\n\t\t\terr = tcp_repair_options_est(tp,\n\t\t\t\t\t(struct tcp_repair_opt __user *)optval,\n\t\t\t\t\toptlen);\n\t\telse\n\t\t\terr = -EPERM;\n\t\tbreak;",
"\tcase TCP_CORK:\n\t\t/* When set indicates to always queue non-full frames.\n\t\t * Later the user clears this option and we transmit\n\t\t * any pending partial frames in the queue. This is\n\t\t * meant to be used alongside sendfile() to get properly\n\t\t * filled frames when the user (for example) must write\n\t\t * out headers with a write() call first and then use\n\t\t * sendfile to send out the data parts.\n\t\t *\n\t\t * TCP_CORK can be set together with TCP_NODELAY and it is\n\t\t * stronger than TCP_NODELAY.\n\t\t */\n\t\tif (val) {\n\t\t\ttp->nonagle |= TCP_NAGLE_CORK;\n\t\t} else {\n\t\t\ttp->nonagle &= ~TCP_NAGLE_CORK;\n\t\t\tif (tp->nonagle&TCP_NAGLE_OFF)\n\t\t\t\ttp->nonagle |= TCP_NAGLE_PUSH;\n\t\t\ttcp_push_pending_frames(sk);\n\t\t}\n\t\tbreak;",
"\tcase TCP_KEEPIDLE:\n\t\tif (val < 1 || val > MAX_TCP_KEEPIDLE)\n\t\t\terr = -EINVAL;\n\t\telse {\n\t\t\ttp->keepalive_time = val * HZ;\n\t\t\tif (sock_flag(sk, SOCK_KEEPOPEN) &&\n\t\t\t !((1 << sk->sk_state) &\n\t\t\t (TCPF_CLOSE | TCPF_LISTEN))) {\n\t\t\t\tu32 elapsed = keepalive_time_elapsed(tp);\n\t\t\t\tif (tp->keepalive_time > elapsed)\n\t\t\t\t\telapsed = tp->keepalive_time - elapsed;\n\t\t\t\telse\n\t\t\t\t\telapsed = 0;\n\t\t\t\tinet_csk_reset_keepalive_timer(sk, elapsed);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase TCP_KEEPINTVL:\n\t\tif (val < 1 || val > MAX_TCP_KEEPINTVL)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ttp->keepalive_intvl = val * HZ;\n\t\tbreak;\n\tcase TCP_KEEPCNT:\n\t\tif (val < 1 || val > MAX_TCP_KEEPCNT)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ttp->keepalive_probes = val;\n\t\tbreak;\n\tcase TCP_SYNCNT:\n\t\tif (val < 1 || val > MAX_TCP_SYNCNT)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ticsk->icsk_syn_retries = val;\n\t\tbreak;",
"\tcase TCP_SAVE_SYN:\n\t\tif (val < 0 || val > 1)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ttp->save_syn = val;\n\t\tbreak;",
"\tcase TCP_LINGER2:\n\t\tif (val < 0)\n\t\t\ttp->linger2 = -1;\n\t\telse if (val > net->ipv4.sysctl_tcp_fin_timeout / HZ)\n\t\t\ttp->linger2 = 0;\n\t\telse\n\t\t\ttp->linger2 = val * HZ;\n\t\tbreak;",
"\tcase TCP_DEFER_ACCEPT:\n\t\t/* Translate value in seconds to number of retransmits */\n\t\ticsk->icsk_accept_queue.rskq_defer_accept =\n\t\t\tsecs_to_retrans(val, TCP_TIMEOUT_INIT / HZ,\n\t\t\t\t\tTCP_RTO_MAX / HZ);\n\t\tbreak;",
"\tcase TCP_WINDOW_CLAMP:\n\t\tif (!val) {\n\t\t\tif (sk->sk_state != TCP_CLOSE) {\n\t\t\t\terr = -EINVAL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttp->window_clamp = 0;\n\t\t} else\n\t\t\ttp->window_clamp = val < SOCK_MIN_RCVBUF / 2 ?\n\t\t\t\t\t\tSOCK_MIN_RCVBUF / 2 : val;\n\t\tbreak;",
"\tcase TCP_QUICKACK:\n\t\tif (!val) {\n\t\t\ticsk->icsk_ack.pingpong = 1;\n\t\t} else {\n\t\t\ticsk->icsk_ack.pingpong = 0;\n\t\t\tif ((1 << sk->sk_state) &\n\t\t\t (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) &&\n\t\t\t inet_csk_ack_scheduled(sk)) {\n\t\t\t\ticsk->icsk_ack.pending |= ICSK_ACK_PUSHED;\n\t\t\t\ttcp_cleanup_rbuf(sk, 1);\n\t\t\t\tif (!(val & 1))\n\t\t\t\t\ticsk->icsk_ack.pingpong = 1;\n\t\t\t}\n\t\t}\n\t\tbreak;",
"#ifdef CONFIG_TCP_MD5SIG\n\tcase TCP_MD5SIG:\n\t\t/* Read the IP->Key mappings from userspace */\n\t\terr = tp->af_specific->md5_parse(sk, optval, optlen);\n\t\tbreak;\n#endif\n\tcase TCP_USER_TIMEOUT:\n\t\t/* Cap the max time in ms TCP will retry or probe the window\n\t\t * before giving up and aborting (ETIMEDOUT) a connection.\n\t\t */\n\t\tif (val < 0)\n\t\t\terr = -EINVAL;\n\t\telse\n\t\t\ticsk->icsk_user_timeout = msecs_to_jiffies(val);\n\t\tbreak;",
"\tcase TCP_FASTOPEN:\n\t\tif (val >= 0 && ((1 << sk->sk_state) & (TCPF_CLOSE |\n\t\t TCPF_LISTEN))) {\n\t\t\ttcp_fastopen_init_key_once(true);",
"\t\t\tfastopen_queue_tune(sk, val);\n\t\t} else {\n\t\t\terr = -EINVAL;\n\t\t}\n\t\tbreak;\n\tcase TCP_FASTOPEN_CONNECT:\n\t\tif (val > 1 || val < 0) {\n\t\t\terr = -EINVAL;\n\t\t} else if (sysctl_tcp_fastopen & TFO_CLIENT_ENABLE) {\n\t\t\tif (sk->sk_state == TCP_CLOSE)\n\t\t\t\ttp->fastopen_connect = val;\n\t\t\telse\n\t\t\t\terr = -EINVAL;\n\t\t} else {\n\t\t\terr = -EOPNOTSUPP;\n\t\t}\n\t\tbreak;\n\tcase TCP_TIMESTAMP:\n\t\tif (!tp->repair)\n\t\t\terr = -EPERM;\n\t\telse\n\t\t\ttp->tsoffset = val - tcp_time_stamp;\n\t\tbreak;\n\tcase TCP_REPAIR_WINDOW:\n\t\terr = tcp_repair_set_window(tp, optval, optlen);\n\t\tbreak;\n\tcase TCP_NOTSENT_LOWAT:\n\t\ttp->notsent_lowat = val;\n\t\tsk->sk_write_space(sk);\n\t\tbreak;\n\tdefault:\n\t\terr = -ENOPROTOOPT;\n\t\tbreak;\n\t}",
"\trelease_sock(sk);\n\treturn err;\n}",
"int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,\n\t\t unsigned int optlen)\n{\n\tconst struct inet_connection_sock *icsk = inet_csk(sk);",
"\tif (level != SOL_TCP)\n\t\treturn icsk->icsk_af_ops->setsockopt(sk, level, optname,\n\t\t\t\t\t\t optval, optlen);\n\treturn do_tcp_setsockopt(sk, level, optname, optval, optlen);\n}\nEXPORT_SYMBOL(tcp_setsockopt);",
"#ifdef CONFIG_COMPAT\nint compat_tcp_setsockopt(struct sock *sk, int level, int optname,\n\t\t\t char __user *optval, unsigned int optlen)\n{\n\tif (level != SOL_TCP)\n\t\treturn inet_csk_compat_setsockopt(sk, level, optname,\n\t\t\t\t\t\t optval, optlen);\n\treturn do_tcp_setsockopt(sk, level, optname, optval, optlen);\n}\nEXPORT_SYMBOL(compat_tcp_setsockopt);\n#endif",
"static void tcp_get_info_chrono_stats(const struct tcp_sock *tp,\n\t\t\t\t struct tcp_info *info)\n{\n\tu64 stats[__TCP_CHRONO_MAX], total = 0;\n\tenum tcp_chrono i;",
"\tfor (i = TCP_CHRONO_BUSY; i < __TCP_CHRONO_MAX; ++i) {\n\t\tstats[i] = tp->chrono_stat[i - 1];\n\t\tif (i == tp->chrono_type)\n\t\t\tstats[i] += tcp_time_stamp - tp->chrono_start;\n\t\tstats[i] *= USEC_PER_SEC / HZ;\n\t\ttotal += stats[i];\n\t}",
"\tinfo->tcpi_busy_time = total;\n\tinfo->tcpi_rwnd_limited = stats[TCP_CHRONO_RWND_LIMITED];\n\tinfo->tcpi_sndbuf_limited = stats[TCP_CHRONO_SNDBUF_LIMITED];\n}",
"/* Return information about state of tcp endpoint in API format. */\nvoid tcp_get_info(struct sock *sk, struct tcp_info *info)\n{\n\tconst struct tcp_sock *tp = tcp_sk(sk); /* iff sk_type == SOCK_STREAM */\n\tconst struct inet_connection_sock *icsk = inet_csk(sk);\n\tu32 now, intv;\n\tu64 rate64;\n\tbool slow;\n\tu32 rate;",
"\tmemset(info, 0, sizeof(*info));\n\tif (sk->sk_type != SOCK_STREAM)\n\t\treturn;",
"\tinfo->tcpi_state = sk_state_load(sk);",
"\t/* Report meaningful fields for all TCP states, including listeners */\n\trate = READ_ONCE(sk->sk_pacing_rate);\n\trate64 = rate != ~0U ? rate : ~0ULL;\n\tinfo->tcpi_pacing_rate = rate64;",
"\trate = READ_ONCE(sk->sk_max_pacing_rate);\n\trate64 = rate != ~0U ? rate : ~0ULL;\n\tinfo->tcpi_max_pacing_rate = rate64;",
"\tinfo->tcpi_reordering = tp->reordering;\n\tinfo->tcpi_snd_cwnd = tp->snd_cwnd;",
"\tif (info->tcpi_state == TCP_LISTEN) {\n\t\t/* listeners aliased fields :\n\t\t * tcpi_unacked -> Number of children ready for accept()\n\t\t * tcpi_sacked -> max backlog\n\t\t */\n\t\tinfo->tcpi_unacked = sk->sk_ack_backlog;\n\t\tinfo->tcpi_sacked = sk->sk_max_ack_backlog;\n\t\treturn;\n\t}",
"\tslow = lock_sock_fast(sk);",
"\tinfo->tcpi_ca_state = icsk->icsk_ca_state;\n\tinfo->tcpi_retransmits = icsk->icsk_retransmits;\n\tinfo->tcpi_probes = icsk->icsk_probes_out;\n\tinfo->tcpi_backoff = icsk->icsk_backoff;",
"\tif (tp->rx_opt.tstamp_ok)\n\t\tinfo->tcpi_options |= TCPI_OPT_TIMESTAMPS;\n\tif (tcp_is_sack(tp))\n\t\tinfo->tcpi_options |= TCPI_OPT_SACK;\n\tif (tp->rx_opt.wscale_ok) {\n\t\tinfo->tcpi_options |= TCPI_OPT_WSCALE;\n\t\tinfo->tcpi_snd_wscale = tp->rx_opt.snd_wscale;\n\t\tinfo->tcpi_rcv_wscale = tp->rx_opt.rcv_wscale;\n\t}",
"\tif (tp->ecn_flags & TCP_ECN_OK)\n\t\tinfo->tcpi_options |= TCPI_OPT_ECN;\n\tif (tp->ecn_flags & TCP_ECN_SEEN)\n\t\tinfo->tcpi_options |= TCPI_OPT_ECN_SEEN;\n\tif (tp->syn_data_acked)\n\t\tinfo->tcpi_options |= TCPI_OPT_SYN_DATA;",
"\tinfo->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto);\n\tinfo->tcpi_ato = jiffies_to_usecs(icsk->icsk_ack.ato);\n\tinfo->tcpi_snd_mss = tp->mss_cache;\n\tinfo->tcpi_rcv_mss = icsk->icsk_ack.rcv_mss;",
"\tinfo->tcpi_unacked = tp->packets_out;\n\tinfo->tcpi_sacked = tp->sacked_out;",
"\tinfo->tcpi_lost = tp->lost_out;\n\tinfo->tcpi_retrans = tp->retrans_out;\n\tinfo->tcpi_fackets = tp->fackets_out;",
"\tnow = tcp_time_stamp;\n\tinfo->tcpi_last_data_sent = jiffies_to_msecs(now - tp->lsndtime);\n\tinfo->tcpi_last_data_recv = jiffies_to_msecs(now - icsk->icsk_ack.lrcvtime);\n\tinfo->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp);",
"\tinfo->tcpi_pmtu = icsk->icsk_pmtu_cookie;\n\tinfo->tcpi_rcv_ssthresh = tp->rcv_ssthresh;\n\tinfo->tcpi_rtt = tp->srtt_us >> 3;\n\tinfo->tcpi_rttvar = tp->mdev_us >> 2;\n\tinfo->tcpi_snd_ssthresh = tp->snd_ssthresh;\n\tinfo->tcpi_advmss = tp->advmss;",
"\tinfo->tcpi_rcv_rtt = tp->rcv_rtt_est.rtt_us >> 3;\n\tinfo->tcpi_rcv_space = tp->rcvq_space.space;",
"\tinfo->tcpi_total_retrans = tp->total_retrans;",
"\tinfo->tcpi_bytes_acked = tp->bytes_acked;\n\tinfo->tcpi_bytes_received = tp->bytes_received;\n\tinfo->tcpi_notsent_bytes = max_t(int, 0, tp->write_seq - tp->snd_nxt);\n\ttcp_get_info_chrono_stats(tp, info);",
"\tinfo->tcpi_segs_out = tp->segs_out;\n\tinfo->tcpi_segs_in = tp->segs_in;",
"\tinfo->tcpi_min_rtt = tcp_min_rtt(tp);\n\tinfo->tcpi_data_segs_in = tp->data_segs_in;\n\tinfo->tcpi_data_segs_out = tp->data_segs_out;",
"\tinfo->tcpi_delivery_rate_app_limited = tp->rate_app_limited ? 1 : 0;\n\trate = READ_ONCE(tp->rate_delivered);\n\tintv = READ_ONCE(tp->rate_interval_us);\n\tif (rate && intv) {\n\t\trate64 = (u64)rate * tp->mss_cache * USEC_PER_SEC;\n\t\tdo_div(rate64, intv);\n\t\tinfo->tcpi_delivery_rate = rate64;\n\t}\n\tunlock_sock_fast(sk, slow);\n}\nEXPORT_SYMBOL_GPL(tcp_get_info);",
"struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk)\n{\n\tconst struct tcp_sock *tp = tcp_sk(sk);\n\tstruct sk_buff *stats;\n\tstruct tcp_info info;",
"\tstats = alloc_skb(5 * nla_total_size_64bit(sizeof(u64)), GFP_ATOMIC);\n\tif (!stats)\n\t\treturn NULL;",
"\ttcp_get_info_chrono_stats(tp, &info);\n\tnla_put_u64_64bit(stats, TCP_NLA_BUSY,\n\t\t\t info.tcpi_busy_time, TCP_NLA_PAD);\n\tnla_put_u64_64bit(stats, TCP_NLA_RWND_LIMITED,\n\t\t\t info.tcpi_rwnd_limited, TCP_NLA_PAD);\n\tnla_put_u64_64bit(stats, TCP_NLA_SNDBUF_LIMITED,\n\t\t\t info.tcpi_sndbuf_limited, TCP_NLA_PAD);\n\tnla_put_u64_64bit(stats, TCP_NLA_DATA_SEGS_OUT,\n\t\t\t tp->data_segs_out, TCP_NLA_PAD);\n\tnla_put_u64_64bit(stats, TCP_NLA_TOTAL_RETRANS,\n\t\t\t tp->total_retrans, TCP_NLA_PAD);\n\treturn stats;\n}",
"static int do_tcp_getsockopt(struct sock *sk, int level,\n\t\tint optname, char __user *optval, int __user *optlen)\n{\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct net *net = sock_net(sk);\n\tint val, len;",
"\tif (get_user(len, optlen))\n\t\treturn -EFAULT;",
"\tlen = min_t(unsigned int, len, sizeof(int));",
"\tif (len < 0)\n\t\treturn -EINVAL;",
"\tswitch (optname) {\n\tcase TCP_MAXSEG:\n\t\tval = tp->mss_cache;\n\t\tif (!val && ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))\n\t\t\tval = tp->rx_opt.user_mss;\n\t\tif (tp->repair)\n\t\t\tval = tp->rx_opt.mss_clamp;\n\t\tbreak;\n\tcase TCP_NODELAY:\n\t\tval = !!(tp->nonagle&TCP_NAGLE_OFF);\n\t\tbreak;\n\tcase TCP_CORK:\n\t\tval = !!(tp->nonagle&TCP_NAGLE_CORK);\n\t\tbreak;\n\tcase TCP_KEEPIDLE:\n\t\tval = keepalive_time_when(tp) / HZ;\n\t\tbreak;\n\tcase TCP_KEEPINTVL:\n\t\tval = keepalive_intvl_when(tp) / HZ;\n\t\tbreak;\n\tcase TCP_KEEPCNT:\n\t\tval = keepalive_probes(tp);\n\t\tbreak;\n\tcase TCP_SYNCNT:\n\t\tval = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retries;\n\t\tbreak;\n\tcase TCP_LINGER2:\n\t\tval = tp->linger2;\n\t\tif (val >= 0)\n\t\t\tval = (val ? : net->ipv4.sysctl_tcp_fin_timeout) / HZ;\n\t\tbreak;\n\tcase TCP_DEFER_ACCEPT:\n\t\tval = retrans_to_secs(icsk->icsk_accept_queue.rskq_defer_accept,\n\t\t\t\t TCP_TIMEOUT_INIT / HZ, TCP_RTO_MAX / HZ);\n\t\tbreak;\n\tcase TCP_WINDOW_CLAMP:\n\t\tval = tp->window_clamp;\n\t\tbreak;\n\tcase TCP_INFO: {\n\t\tstruct tcp_info info;",
"\t\tif (get_user(len, optlen))\n\t\t\treturn -EFAULT;",
"\t\ttcp_get_info(sk, &info);",
"\t\tlen = min_t(unsigned int, len, sizeof(info));\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, &info, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tcase TCP_CC_INFO: {\n\t\tconst struct tcp_congestion_ops *ca_ops;\n\t\tunion tcp_cc_info info;\n\t\tsize_t sz = 0;\n\t\tint attr;",
"\t\tif (get_user(len, optlen))\n\t\t\treturn -EFAULT;",
"\t\tca_ops = icsk->icsk_ca_ops;\n\t\tif (ca_ops && ca_ops->get_info)\n\t\t\tsz = ca_ops->get_info(sk, ~0U, &attr, &info);",
"\t\tlen = min_t(unsigned int, len, sz);\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, &info, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tcase TCP_QUICKACK:\n\t\tval = !icsk->icsk_ack.pingpong;\n\t\tbreak;",
"\tcase TCP_CONGESTION:\n\t\tif (get_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tlen = min_t(unsigned int, len, TCP_CA_NAME_MAX);\n\t\tif (put_user(len, optlen))\n\t\t\treturn -EFAULT;\n\t\tif (copy_to_user(optval, icsk->icsk_ca_ops->name, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;",
"\tcase TCP_THIN_LINEAR_TIMEOUTS:\n\t\tval = tp->thin_lto;\n\t\tbreak;",
"\tcase TCP_THIN_DUPACK:\n\t\tval = 0;\n\t\tbreak;",
"\tcase TCP_REPAIR:\n\t\tval = tp->repair;\n\t\tbreak;",
"\tcase TCP_REPAIR_QUEUE:\n\t\tif (tp->repair)\n\t\t\tval = tp->repair_queue;\n\t\telse\n\t\t\treturn -EINVAL;\n\t\tbreak;",
"\tcase TCP_REPAIR_WINDOW: {\n\t\tstruct tcp_repair_window opt;",
"\t\tif (get_user(len, optlen))\n\t\t\treturn -EFAULT;",
"\t\tif (len != sizeof(opt))\n\t\t\treturn -EINVAL;",
"\t\tif (!tp->repair)\n\t\t\treturn -EPERM;",
"\t\topt.snd_wl1\t= tp->snd_wl1;\n\t\topt.snd_wnd\t= tp->snd_wnd;\n\t\topt.max_window\t= tp->max_window;\n\t\topt.rcv_wnd\t= tp->rcv_wnd;\n\t\topt.rcv_wup\t= tp->rcv_wup;",
"\t\tif (copy_to_user(optval, &opt, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\tcase TCP_QUEUE_SEQ:\n\t\tif (tp->repair_queue == TCP_SEND_QUEUE)\n\t\t\tval = tp->write_seq;\n\t\telse if (tp->repair_queue == TCP_RECV_QUEUE)\n\t\t\tval = tp->rcv_nxt;\n\t\telse\n\t\t\treturn -EINVAL;\n\t\tbreak;",
"\tcase TCP_USER_TIMEOUT:\n\t\tval = jiffies_to_msecs(icsk->icsk_user_timeout);\n\t\tbreak;",
"\tcase TCP_FASTOPEN:\n\t\tval = icsk->icsk_accept_queue.fastopenq.max_qlen;\n\t\tbreak;",
"\tcase TCP_FASTOPEN_CONNECT:\n\t\tval = tp->fastopen_connect;\n\t\tbreak;",
"\tcase TCP_TIMESTAMP:\n\t\tval = tcp_time_stamp + tp->tsoffset;\n\t\tbreak;\n\tcase TCP_NOTSENT_LOWAT:\n\t\tval = tp->notsent_lowat;\n\t\tbreak;\n\tcase TCP_SAVE_SYN:\n\t\tval = tp->save_syn;\n\t\tbreak;\n\tcase TCP_SAVED_SYN: {\n\t\tif (get_user(len, optlen))\n\t\t\treturn -EFAULT;",
"\t\tlock_sock(sk);\n\t\tif (tp->saved_syn) {\n\t\t\tif (len < tp->saved_syn[0]) {\n\t\t\t\tif (put_user(tp->saved_syn[0], optlen)) {\n\t\t\t\t\trelease_sock(sk);\n\t\t\t\t\treturn -EFAULT;\n\t\t\t\t}\n\t\t\t\trelease_sock(sk);\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\tlen = tp->saved_syn[0];\n\t\t\tif (put_user(len, optlen)) {\n\t\t\t\trelease_sock(sk);\n\t\t\t\treturn -EFAULT;\n\t\t\t}\n\t\t\tif (copy_to_user(optval, tp->saved_syn + 1, len)) {\n\t\t\t\trelease_sock(sk);\n\t\t\t\treturn -EFAULT;\n\t\t\t}\n\t\t\ttcp_saved_syn_free(tp);\n\t\t\trelease_sock(sk);\n\t\t} else {\n\t\t\trelease_sock(sk);\n\t\t\tlen = 0;\n\t\t\tif (put_user(len, optlen))\n\t\t\t\treturn -EFAULT;\n\t\t}\n\t\treturn 0;\n\t}\n\tdefault:\n\t\treturn -ENOPROTOOPT;\n\t}",
"\tif (put_user(len, optlen))\n\t\treturn -EFAULT;\n\tif (copy_to_user(optval, &val, len))\n\t\treturn -EFAULT;\n\treturn 0;\n}",
"int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval,\n\t\t int __user *optlen)\n{\n\tstruct inet_connection_sock *icsk = inet_csk(sk);",
"\tif (level != SOL_TCP)\n\t\treturn icsk->icsk_af_ops->getsockopt(sk, level, optname,\n\t\t\t\t\t\t optval, optlen);\n\treturn do_tcp_getsockopt(sk, level, optname, optval, optlen);\n}\nEXPORT_SYMBOL(tcp_getsockopt);",
"#ifdef CONFIG_COMPAT\nint compat_tcp_getsockopt(struct sock *sk, int level, int optname,\n\t\t\t char __user *optval, int __user *optlen)\n{\n\tif (level != SOL_TCP)\n\t\treturn inet_csk_compat_getsockopt(sk, level, optname,\n\t\t\t\t\t\t optval, optlen);\n\treturn do_tcp_getsockopt(sk, level, optname, optval, optlen);\n}\nEXPORT_SYMBOL(compat_tcp_getsockopt);\n#endif",
"#ifdef CONFIG_TCP_MD5SIG\nstatic DEFINE_PER_CPU(struct tcp_md5sig_pool, tcp_md5sig_pool);\nstatic DEFINE_MUTEX(tcp_md5sig_mutex);\nstatic bool tcp_md5sig_pool_populated = false;",
"static void __tcp_alloc_md5sig_pool(void)\n{\n\tstruct crypto_ahash *hash;\n\tint cpu;",
"\thash = crypto_alloc_ahash(\"md5\", 0, CRYPTO_ALG_ASYNC);\n\tif (IS_ERR(hash))\n\t\treturn;",
"\tfor_each_possible_cpu(cpu) {\n\t\tvoid *scratch = per_cpu(tcp_md5sig_pool, cpu).scratch;\n\t\tstruct ahash_request *req;",
"\t\tif (!scratch) {\n\t\t\tscratch = kmalloc_node(sizeof(union tcp_md5sum_block) +\n\t\t\t\t\t sizeof(struct tcphdr),\n\t\t\t\t\t GFP_KERNEL,\n\t\t\t\t\t cpu_to_node(cpu));\n\t\t\tif (!scratch)\n\t\t\t\treturn;\n\t\t\tper_cpu(tcp_md5sig_pool, cpu).scratch = scratch;\n\t\t}\n\t\tif (per_cpu(tcp_md5sig_pool, cpu).md5_req)\n\t\t\tcontinue;",
"\t\treq = ahash_request_alloc(hash, GFP_KERNEL);\n\t\tif (!req)\n\t\t\treturn;",
"\t\tahash_request_set_callback(req, 0, NULL, NULL);",
"\t\tper_cpu(tcp_md5sig_pool, cpu).md5_req = req;\n\t}\n\t/* before setting tcp_md5sig_pool_populated, we must commit all writes\n\t * to memory. See smp_rmb() in tcp_get_md5sig_pool()\n\t */\n\tsmp_wmb();\n\ttcp_md5sig_pool_populated = true;\n}",
"bool tcp_alloc_md5sig_pool(void)\n{\n\tif (unlikely(!tcp_md5sig_pool_populated)) {\n\t\tmutex_lock(&tcp_md5sig_mutex);",
"\t\tif (!tcp_md5sig_pool_populated)\n\t\t\t__tcp_alloc_md5sig_pool();",
"\t\tmutex_unlock(&tcp_md5sig_mutex);\n\t}\n\treturn tcp_md5sig_pool_populated;\n}\nEXPORT_SYMBOL(tcp_alloc_md5sig_pool);",
"\n/**\n *\ttcp_get_md5sig_pool - get md5sig_pool for this user\n *\n *\tWe use percpu structure, so if we succeed, we exit with preemption\n *\tand BH disabled, to make sure another thread or softirq handling\n *\twont try to get same context.\n */\nstruct tcp_md5sig_pool *tcp_get_md5sig_pool(void)\n{\n\tlocal_bh_disable();",
"\tif (tcp_md5sig_pool_populated) {\n\t\t/* coupled with smp_wmb() in __tcp_alloc_md5sig_pool() */\n\t\tsmp_rmb();\n\t\treturn this_cpu_ptr(&tcp_md5sig_pool);\n\t}\n\tlocal_bh_enable();\n\treturn NULL;\n}\nEXPORT_SYMBOL(tcp_get_md5sig_pool);",
"int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,\n\t\t\t const struct sk_buff *skb, unsigned int header_len)\n{\n\tstruct scatterlist sg;\n\tconst struct tcphdr *tp = tcp_hdr(skb);\n\tstruct ahash_request *req = hp->md5_req;\n\tunsigned int i;\n\tconst unsigned int head_data_len = skb_headlen(skb) > header_len ?\n\t\t\t\t\t skb_headlen(skb) - header_len : 0;\n\tconst struct skb_shared_info *shi = skb_shinfo(skb);\n\tstruct sk_buff *frag_iter;",
"\tsg_init_table(&sg, 1);",
"\tsg_set_buf(&sg, ((u8 *) tp) + header_len, head_data_len);\n\tahash_request_set_crypt(req, &sg, NULL, head_data_len);\n\tif (crypto_ahash_update(req))\n\t\treturn 1;",
"\tfor (i = 0; i < shi->nr_frags; ++i) {\n\t\tconst struct skb_frag_struct *f = &shi->frags[i];\n\t\tunsigned int offset = f->page_offset;\n\t\tstruct page *page = skb_frag_page(f) + (offset >> PAGE_SHIFT);",
"\t\tsg_set_page(&sg, page, skb_frag_size(f),\n\t\t\t offset_in_page(offset));\n\t\tahash_request_set_crypt(req, &sg, NULL, skb_frag_size(f));\n\t\tif (crypto_ahash_update(req))\n\t\t\treturn 1;\n\t}",
"\tskb_walk_frags(skb, frag_iter)\n\t\tif (tcp_md5_hash_skb_data(hp, frag_iter, 0))\n\t\t\treturn 1;",
"\treturn 0;\n}\nEXPORT_SYMBOL(tcp_md5_hash_skb_data);",
"int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, const struct tcp_md5sig_key *key)\n{\n\tstruct scatterlist sg;",
"\tsg_init_one(&sg, key->key, key->keylen);\n\tahash_request_set_crypt(hp->md5_req, &sg, NULL, key->keylen);\n\treturn crypto_ahash_update(hp->md5_req);\n}\nEXPORT_SYMBOL(tcp_md5_hash_key);",
"#endif",
"void tcp_done(struct sock *sk)\n{\n\tstruct request_sock *req = tcp_sk(sk)->fastopen_rsk;",
"\tif (sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV)\n\t\tTCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);",
"\ttcp_set_state(sk, TCP_CLOSE);\n\ttcp_clear_xmit_timers(sk);\n\tif (req)\n\t\treqsk_fastopen_remove(sk, req, false);",
"\tsk->sk_shutdown = SHUTDOWN_MASK;",
"\tif (!sock_flag(sk, SOCK_DEAD))\n\t\tsk->sk_state_change(sk);\n\telse\n\t\tinet_csk_destroy_sock(sk);\n}\nEXPORT_SYMBOL_GPL(tcp_done);",
"int tcp_abort(struct sock *sk, int err)\n{\n\tif (!sk_fullsock(sk)) {\n\t\tif (sk->sk_state == TCP_NEW_SYN_RECV) {\n\t\t\tstruct request_sock *req = inet_reqsk(sk);",
"\t\t\tlocal_bh_disable();\n\t\t\tinet_csk_reqsk_queue_drop_and_put(req->rsk_listener,\n\t\t\t\t\t\t\t req);\n\t\t\tlocal_bh_enable();\n\t\t\treturn 0;\n\t\t}\n\t\treturn -EOPNOTSUPP;\n\t}",
"\t/* Don't race with userspace socket closes such as tcp_close. */\n\tlock_sock(sk);",
"\tif (sk->sk_state == TCP_LISTEN) {\n\t\ttcp_set_state(sk, TCP_CLOSE);\n\t\tinet_csk_listen_stop(sk);\n\t}",
"\t/* Don't race with BH socket closes such as inet_csk_listen_stop. */\n\tlocal_bh_disable();\n\tbh_lock_sock(sk);",
"\tif (!sock_flag(sk, SOCK_DEAD)) {\n\t\tsk->sk_err = err;\n\t\t/* This barrier is coupled with smp_rmb() in tcp_poll() */\n\t\tsmp_wmb();\n\t\tsk->sk_error_report(sk);\n\t\tif (tcp_need_reset(sk->sk_state))\n\t\t\ttcp_send_active_reset(sk, GFP_ATOMIC);\n\t\ttcp_done(sk);\n\t}",
"\tbh_unlock_sock(sk);\n\tlocal_bh_enable();\n\trelease_sock(sk);\n\treturn 0;\n}\nEXPORT_SYMBOL_GPL(tcp_abort);",
"extern struct tcp_congestion_ops tcp_reno;",
"static __initdata unsigned long thash_entries;\nstatic int __init set_thash_entries(char *str)\n{\n\tssize_t ret;",
"\tif (!str)\n\t\treturn 0;",
"\tret = kstrtoul(str, 0, &thash_entries);\n\tif (ret)\n\t\treturn 0;",
"\treturn 1;\n}\n__setup(\"thash_entries=\", set_thash_entries);",
"static void __init tcp_init_mem(void)\n{\n\tunsigned long limit = nr_free_buffer_pages() / 16;",
"\tlimit = max(limit, 128UL);\n\tsysctl_tcp_mem[0] = limit / 4 * 3;\t\t/* 4.68 % */\n\tsysctl_tcp_mem[1] = limit;\t\t\t/* 6.25 % */\n\tsysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2;\t/* 9.37 % */\n}",
"void __init tcp_init(void)\n{\n\tint max_rshare, max_wshare, cnt;\n\tunsigned long limit;\n\tunsigned int i;",
"\tBUILD_BUG_ON(sizeof(struct tcp_skb_cb) >\n\t\t FIELD_SIZEOF(struct sk_buff, cb));",
"\tpercpu_counter_init(&tcp_sockets_allocated, 0, GFP_KERNEL);\n\tpercpu_counter_init(&tcp_orphan_count, 0, GFP_KERNEL);\n\tinet_hashinfo_init(&tcp_hashinfo);\n\ttcp_hashinfo.bind_bucket_cachep =\n\t\tkmem_cache_create(\"tcp_bind_bucket\",\n\t\t\t\t sizeof(struct inet_bind_bucket), 0,\n\t\t\t\t SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);",
"\t/* Size and allocate the main established and bind bucket\n\t * hash tables.\n\t *\n\t * The methodology is similar to that of the buffer cache.\n\t */\n\ttcp_hashinfo.ehash =\n\t\talloc_large_system_hash(\"TCP established\",\n\t\t\t\t\tsizeof(struct inet_ehash_bucket),\n\t\t\t\t\tthash_entries,\n\t\t\t\t\t17, /* one slot per 128 KB of memory */\n\t\t\t\t\t0,\n\t\t\t\t\tNULL,\n\t\t\t\t\t&tcp_hashinfo.ehash_mask,\n\t\t\t\t\t0,\n\t\t\t\t\tthash_entries ? 0 : 512 * 1024);\n\tfor (i = 0; i <= tcp_hashinfo.ehash_mask; i++)\n\t\tINIT_HLIST_NULLS_HEAD(&tcp_hashinfo.ehash[i].chain, i);",
"\tif (inet_ehash_locks_alloc(&tcp_hashinfo))\n\t\tpanic(\"TCP: failed to alloc ehash_locks\");\n\ttcp_hashinfo.bhash =\n\t\talloc_large_system_hash(\"TCP bind\",\n\t\t\t\t\tsizeof(struct inet_bind_hashbucket),\n\t\t\t\t\ttcp_hashinfo.ehash_mask + 1,\n\t\t\t\t\t17, /* one slot per 128 KB of memory */\n\t\t\t\t\t0,\n\t\t\t\t\t&tcp_hashinfo.bhash_size,\n\t\t\t\t\tNULL,\n\t\t\t\t\t0,\n\t\t\t\t\t64 * 1024);\n\ttcp_hashinfo.bhash_size = 1U << tcp_hashinfo.bhash_size;\n\tfor (i = 0; i < tcp_hashinfo.bhash_size; i++) {\n\t\tspin_lock_init(&tcp_hashinfo.bhash[i].lock);\n\t\tINIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain);\n\t}",
"\n\tcnt = tcp_hashinfo.ehash_mask + 1;\n\tsysctl_tcp_max_orphans = cnt / 2;",
"\ttcp_init_mem();\n\t/* Set per-socket limits to no more than 1/128 the pressure threshold */\n\tlimit = nr_free_buffer_pages() << (PAGE_SHIFT - 7);\n\tmax_wshare = min(4UL*1024*1024, limit);\n\tmax_rshare = min(6UL*1024*1024, limit);",
"\tsysctl_tcp_wmem[0] = SK_MEM_QUANTUM;\n\tsysctl_tcp_wmem[1] = 16*1024;\n\tsysctl_tcp_wmem[2] = max(64*1024, max_wshare);",
"\tsysctl_tcp_rmem[0] = SK_MEM_QUANTUM;\n\tsysctl_tcp_rmem[1] = 87380;\n\tsysctl_tcp_rmem[2] = max(87380, max_rshare);",
"\tpr_info(\"Hash tables configured (established %u bind %u)\\n\",\n\t\ttcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size);",
"\ttcp_v4_init();\n\ttcp_metrics_init();\n\tBUG_ON(tcp_register_congestion_control(&tcp_reno) != 0);\n\ttcp_tasklet_init();\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [2322], "buggy_code_start_loc": [2322], "filenames": ["net/ipv4/tcp.c"], "fixing_code_end_loc": [2327], "fixing_code_start_loc": [2323], "message": "The tcp_disconnect function in net/ipv4/tcp.c in the Linux kernel before 4.12 allows local users to cause a denial of service (__tcp_select_window divide-by-zero error and system crash) by triggering a disconnect within a certain tcp_recvmsg code path.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "13332751-6BF4-4D8A-A5D2-62A8AF6C1F92", "versionEndExcluding": null, "versionEndIncluding": "4.11.12", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "The tcp_disconnect function in net/ipv4/tcp.c in the Linux kernel before 4.12 allows local users to cause a denial of service (__tcp_select_window divide-by-zero error and system crash) by triggering a disconnect within a certain tcp_recvmsg code path."}, {"lang": "es", "value": "La funci\u00f3n tcp_disconnect en net/ipv4/tcp.c en el kernel de Linux en versiones anteriores a la 4.12 permite que usuarios locales provoquen una denegaci\u00f3n de servicio allows local users to cause a denial of service (error __tcp_select_window de divisi\u00f3n por cero y bloqueo del sistema) desencadenando una desconexi\u00f3n en una ruta de c\u00f3digo tcp_recvmsg determinada."}], "evaluatorComment": null, "id": "CVE-2017-14106", "lastModified": "2018-07-13T01:29:00.667", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 4.9, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:L/AC:L/Au:N/C:N/I:N/A:C", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 6.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H", "version": "3.0"}, "exploitabilityScore": 1.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}], "cvssMetricV31": null}, "published": "2017-09-01T16:29:00.377", "references": [{"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=499350a5a6e7512d9ed369ed63a4244b6536f4f8"}, {"source": "cve@mitre.org", "tags": null, "url": "http://lists.opensuse.org/opensuse-security-announce/2018-01/msg00007.html"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.debian.org/security/2017/dsa-3981"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securityfocus.com/bid/100878"}, {"source": "cve@mitre.org", "tags": null, "url": "http://www.securitytracker.com/id/1039549"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2017:2918"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2017:2930"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2017:2931"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2017:3200"}, {"source": "cve@mitre.org", "tags": null, "url": "https://access.redhat.com/errata/RHSA-2018:2172"}, {"source": "cve@mitre.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/499350a5a6e7512d9ed369ed63a4244b6536f4f8"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "https://www.mail-archive.com/netdev@vger.kernel.org/msg186255.html"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-369"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/499350a5a6e7512d9ed369ed63a4244b6536f4f8"}, "type": "CWE-369"}
| 370
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n *\tHandle firewalling\n *\tLinux ethernet bridge\n *\n *\tAuthors:\n *\tLennert Buytenhek\t\t<buytenh@gnu.org>\n *\tBart De Schuymer\t\t<bdschuym@pandora.be>\n *\n *\tThis program is free software; you can redistribute it and/or\n *\tmodify it under the terms of the GNU General Public License\n *\tas published by the Free Software Foundation; either version\n *\t2 of the License, or (at your option) any later version.\n *\n *\tLennert dedicates this file to Kerstin Wurdinger.\n */",
"#include <linux/module.h>\n#include <linux/kernel.h>\n#include <linux/slab.h>\n#include <linux/ip.h>\n#include <linux/netdevice.h>\n#include <linux/skbuff.h>\n#include <linux/if_arp.h>\n#include <linux/if_ether.h>\n#include <linux/if_vlan.h>\n#include <linux/if_pppox.h>\n#include <linux/ppp_defs.h>\n#include <linux/netfilter_bridge.h>\n#include <linux/netfilter_ipv4.h>\n#include <linux/netfilter_ipv6.h>\n#include <linux/netfilter_arp.h>\n#include <linux/in_route.h>\n#include <linux/inetdevice.h>",
"#include <net/ip.h>\n#include <net/ipv6.h>\n#include <net/route.h>",
"#include <asm/uaccess.h>\n#include \"br_private.h\"\n#ifdef CONFIG_SYSCTL\n#include <linux/sysctl.h>\n#endif",
"#define skb_origaddr(skb)\t (((struct bridge_skb_cb *) \\\n\t\t\t\t (skb->nf_bridge->data))->daddr.ipv4)\n#define store_orig_dstaddr(skb)\t (skb_origaddr(skb) = ip_hdr(skb)->daddr)\n#define dnat_took_place(skb)\t (skb_origaddr(skb) != ip_hdr(skb)->daddr)",
"#ifdef CONFIG_SYSCTL\nstatic struct ctl_table_header *brnf_sysctl_header;\nstatic int brnf_call_iptables __read_mostly = 1;\nstatic int brnf_call_ip6tables __read_mostly = 1;\nstatic int brnf_call_arptables __read_mostly = 1;\nstatic int brnf_filter_vlan_tagged __read_mostly = 0;\nstatic int brnf_filter_pppoe_tagged __read_mostly = 0;\n#else\n#define brnf_call_iptables 1\n#define brnf_call_ip6tables 1\n#define brnf_call_arptables 1\n#define brnf_filter_vlan_tagged 0\n#define brnf_filter_pppoe_tagged 0\n#endif",
"static inline __be16 vlan_proto(const struct sk_buff *skb)\n{\n\tif (vlan_tx_tag_present(skb))\n\t\treturn skb->protocol;\n\telse if (skb->protocol == htons(ETH_P_8021Q))\n\t\treturn vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;\n\telse\n\t\treturn 0;\n}",
"#define IS_VLAN_IP(skb) \\\n\t(vlan_proto(skb) == htons(ETH_P_IP) && \\\n\t brnf_filter_vlan_tagged)",
"#define IS_VLAN_IPV6(skb) \\\n\t(vlan_proto(skb) == htons(ETH_P_IPV6) && \\\n\t brnf_filter_vlan_tagged)",
"#define IS_VLAN_ARP(skb) \\\n\t(vlan_proto(skb) == htons(ETH_P_ARP) &&\t\\\n\t brnf_filter_vlan_tagged)",
"static inline __be16 pppoe_proto(const struct sk_buff *skb)\n{\n\treturn *((__be16 *)(skb_mac_header(skb) + ETH_HLEN +\n\t\t\t sizeof(struct pppoe_hdr)));\n}",
"#define IS_PPPOE_IP(skb) \\\n\t(skb->protocol == htons(ETH_P_PPP_SES) && \\\n\t pppoe_proto(skb) == htons(PPP_IP) && \\\n\t brnf_filter_pppoe_tagged)",
"#define IS_PPPOE_IPV6(skb) \\\n\t(skb->protocol == htons(ETH_P_PPP_SES) && \\\n\t pppoe_proto(skb) == htons(PPP_IPV6) && \\\n\t brnf_filter_pppoe_tagged)",
"static void fake_update_pmtu(struct dst_entry *dst, u32 mtu)\n{\n}",
"static struct dst_ops fake_dst_ops = {\n\t.family =\t\tAF_INET,\n\t.protocol =\t\tcpu_to_be16(ETH_P_IP),\n\t.update_pmtu =\t\tfake_update_pmtu,\n};",
"/*\n * Initialize bogus route table used to keep netfilter happy.\n * Currently, we fill in the PMTU entry because netfilter\n * refragmentation needs it, and the rt_flags entry because\n * ipt_REJECT needs it. Future netfilter modules might\n * require us to fill additional fields.\n */\nvoid br_netfilter_rtable_init(struct net_bridge *br)\n{\n\tstruct rtable *rt = &br->fake_rtable;",
"\tatomic_set(&rt->dst.__refcnt, 1);\n\trt->dst.dev = br->dev;\n\trt->dst.path = &rt->dst;\n\tdst_metric_set(&rt->dst, RTAX_MTU, 1500);\n\trt->dst.flags\t= DST_NOXFRM;\n\trt->dst.ops = &fake_dst_ops;\n}",
"static inline struct rtable *bridge_parent_rtable(const struct net_device *dev)\n{\n\tstruct net_bridge_port *port;",
"\tport = br_port_get_rcu(dev);\n\treturn port ? &port->br->fake_rtable : NULL;\n}",
"static inline struct net_device *bridge_parent(const struct net_device *dev)\n{\n\tstruct net_bridge_port *port;",
"\tport = br_port_get_rcu(dev);\n\treturn port ? port->br->dev : NULL;\n}",
"static inline struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)\n{\n\tskb->nf_bridge = kzalloc(sizeof(struct nf_bridge_info), GFP_ATOMIC);\n\tif (likely(skb->nf_bridge))\n\t\tatomic_set(&(skb->nf_bridge->use), 1);",
"\treturn skb->nf_bridge;\n}",
"static inline struct nf_bridge_info *nf_bridge_unshare(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;",
"\tif (atomic_read(&nf_bridge->use) > 1) {\n\t\tstruct nf_bridge_info *tmp = nf_bridge_alloc(skb);",
"\t\tif (tmp) {\n\t\t\tmemcpy(tmp, nf_bridge, sizeof(struct nf_bridge_info));\n\t\t\tatomic_set(&tmp->use, 1);\n\t\t}\n\t\tnf_bridge_put(nf_bridge);\n\t\tnf_bridge = tmp;\n\t}\n\treturn nf_bridge;\n}",
"static inline void nf_bridge_push_encap_header(struct sk_buff *skb)\n{\n\tunsigned int len = nf_bridge_encap_header_len(skb);",
"\tskb_push(skb, len);\n\tskb->network_header -= len;\n}",
"static inline void nf_bridge_pull_encap_header(struct sk_buff *skb)\n{\n\tunsigned int len = nf_bridge_encap_header_len(skb);",
"\tskb_pull(skb, len);\n\tskb->network_header += len;\n}",
"static inline void nf_bridge_pull_encap_header_rcsum(struct sk_buff *skb)\n{\n\tunsigned int len = nf_bridge_encap_header_len(skb);",
"\tskb_pull_rcsum(skb, len);\n\tskb->network_header += len;\n}",
"static inline void nf_bridge_save_header(struct sk_buff *skb)\n{\n\tint header_size = ETH_HLEN + nf_bridge_encap_header_len(skb);",
"\tskb_copy_from_linear_data_offset(skb, -header_size,\n\t\t\t\t\t skb->nf_bridge->data, header_size);\n}",
"static inline void nf_bridge_update_protocol(struct sk_buff *skb)\n{\n\tif (skb->nf_bridge->mask & BRNF_8021Q)\n\t\tskb->protocol = htons(ETH_P_8021Q);\n\telse if (skb->nf_bridge->mask & BRNF_PPPoE)\n\t\tskb->protocol = htons(ETH_P_PPP_SES);\n}",
"/* When handing a packet over to the IP layer\n * check whether we have a skb that is in the\n * expected format\n */",
"static int br_parse_ip_options(struct sk_buff *skb)\n{\n\tstruct ip_options *opt;\n\tstruct iphdr *iph;\n\tstruct net_device *dev = skb->dev;\n\tu32 len;",
"\tiph = ip_hdr(skb);\n\topt = &(IPCB(skb)->opt);",
"\t/* Basic sanity checks */\n\tif (iph->ihl < 5 || iph->version != 4)\n\t\tgoto inhdr_error;",
"\tif (!pskb_may_pull(skb, iph->ihl*4))\n\t\tgoto inhdr_error;",
"\tiph = ip_hdr(skb);\n\tif (unlikely(ip_fast_csum((u8 *)iph, iph->ihl)))\n\t\tgoto inhdr_error;",
"\tlen = ntohs(iph->tot_len);\n\tif (skb->len < len) {\n\t\tIP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INTRUNCATEDPKTS);\n\t\tgoto drop;\n\t} else if (len < (iph->ihl*4))\n\t\tgoto inhdr_error;",
"\tif (pskb_trim_rcsum(skb, len)) {\n\t\tIP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INDISCARDS);\n\t\tgoto drop;\n\t}\n",
"\t/* Zero out the CB buffer if no options present */\n\tif (iph->ihl == 5) {\n\t\tmemset(IPCB(skb), 0, sizeof(struct inet_skb_parm));",
"\t\treturn 0;",
"\t}",
"\n\topt->optlen = iph->ihl*4 - sizeof(struct iphdr);\n\tif (ip_options_compile(dev_net(dev), opt, skb))\n\t\tgoto inhdr_error;",
"\t/* Check correct handling of SRR option */\n\tif (unlikely(opt->srr)) {\n\t\tstruct in_device *in_dev = __in_dev_get_rcu(dev);\n\t\tif (in_dev && !IN_DEV_SOURCE_ROUTE(in_dev))\n\t\t\tgoto drop;",
"\t\tif (ip_options_rcv_srr(skb))\n\t\t\tgoto drop;\n\t}",
"\treturn 0;",
"inhdr_error:\n\tIP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INHDRERRORS);\ndrop:\n\treturn -1;\n}",
"/* Fill in the header for fragmented IP packets handled by\n * the IPv4 connection tracking code.\n */\nint nf_bridge_copy_header(struct sk_buff *skb)\n{\n\tint err;\n\tunsigned int header_size;",
"\tnf_bridge_update_protocol(skb);\n\theader_size = ETH_HLEN + nf_bridge_encap_header_len(skb);\n\terr = skb_cow_head(skb, header_size);\n\tif (err)\n\t\treturn err;",
"\tskb_copy_to_linear_data_offset(skb, -header_size,\n\t\t\t\t skb->nf_bridge->data, header_size);\n\t__skb_push(skb, nf_bridge_encap_header_len(skb));\n\treturn 0;\n}",
"/* PF_BRIDGE/PRE_ROUTING *********************************************/\n/* Undo the changes made for ip6tables PREROUTING and continue the\n * bridge PRE_ROUTING hook. */\nstatic int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct rtable *rt;",
"\tif (nf_bridge->mask & BRNF_PKT_TYPE) {\n\t\tskb->pkt_type = PACKET_OTHERHOST;\n\t\tnf_bridge->mask ^= BRNF_PKT_TYPE;\n\t}\n\tnf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;",
"\trt = bridge_parent_rtable(nf_bridge->physindev);\n\tif (!rt) {\n\t\tkfree_skb(skb);\n\t\treturn 0;\n\t}\n\tskb_dst_set_noref(skb, &rt->dst);",
"\tskb->dev = nf_bridge->physindev;\n\tnf_bridge_update_protocol(skb);\n\tnf_bridge_push_encap_header(skb);\n\tNF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,\n\t\t br_handle_frame_finish, 1);",
"\treturn 0;\n}",
"/* Obtain the correct destination MAC address, while preserving the original\n * source MAC address. If we already know this address, we just copy it. If we\n * don't, we use the neighbour framework to find out. In both cases, we make\n * sure that br_handle_frame_finish() is called afterwards.\n */\nstatic int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct dst_entry *dst;",
"\tskb->dev = bridge_parent(skb->dev);\n\tif (!skb->dev)\n\t\tgoto free_skb;\n\tdst = skb_dst(skb);\n\tif (dst->hh) {\n\t\tneigh_hh_bridge(dst->hh, skb);\n\t\tskb->dev = nf_bridge->physindev;\n\t\treturn br_handle_frame_finish(skb);\n\t} else if (dst->neighbour) {\n\t\t/* the neighbour function below overwrites the complete\n\t\t * MAC header, so we save the Ethernet source address and\n\t\t * protocol number. */\n\t\tskb_copy_from_linear_data_offset(skb, -(ETH_HLEN-ETH_ALEN), skb->nf_bridge->data, ETH_HLEN-ETH_ALEN);\n\t\t/* tell br_dev_xmit to continue with forwarding */\n\t\tnf_bridge->mask |= BRNF_BRIDGED_DNAT;\n\t\treturn dst->neighbour->output(skb);\n\t}\nfree_skb:\n\tkfree_skb(skb);\n\treturn 0;\n}",
"/* This requires some explaining. If DNAT has taken place,\n * we will need to fix up the destination Ethernet address.\n *\n * There are two cases to consider:\n * 1. The packet was DNAT'ed to a device in the same bridge\n * port group as it was received on. We can still bridge\n * the packet.\n * 2. The packet was DNAT'ed to a different device, either\n * a non-bridged device or another bridge port group.\n * The packet will need to be routed.\n *\n * The correct way of distinguishing between these two cases is to\n * call ip_route_input() and to look at skb->dst->dev, which is\n * changed to the destination device if ip_route_input() succeeds.\n *\n * Let's first consider the case that ip_route_input() succeeds:\n *\n * If the output device equals the logical bridge device the packet\n * came in on, we can consider this bridging. The corresponding MAC\n * address will be obtained in br_nf_pre_routing_finish_bridge.\n * Otherwise, the packet is considered to be routed and we just\n * change the destination MAC address so that the packet will\n * later be passed up to the IP stack to be routed. For a redirected\n * packet, ip_route_input() will give back the localhost as output device,\n * which differs from the bridge device.\n *\n * Let's now consider the case that ip_route_input() fails:\n *\n * This can be because the destination address is martian, in which case\n * the packet will be dropped.\n * If IP forwarding is disabled, ip_route_input() will fail, while\n * ip_route_output_key() can return success. The source\n * address for ip_route_output_key() is set to zero, so ip_route_output_key()\n * thinks we're handling a locally generated packet and won't care\n * if IP forwarding is enabled. If the output device equals the logical bridge\n * device, we proceed as if ip_route_input() succeeded. If it differs from the\n * logical bridge port or if ip_route_output_key() fails we drop the packet.\n */\nstatic int br_nf_pre_routing_finish(struct sk_buff *skb)\n{\n\tstruct net_device *dev = skb->dev;\n\tstruct iphdr *iph = ip_hdr(skb);\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct rtable *rt;\n\tint err;",
"\tif (nf_bridge->mask & BRNF_PKT_TYPE) {\n\t\tskb->pkt_type = PACKET_OTHERHOST;\n\t\tnf_bridge->mask ^= BRNF_PKT_TYPE;\n\t}\n\tnf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;\n\tif (dnat_took_place(skb)) {\n\t\tif ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) {\n\t\t\tstruct in_device *in_dev = __in_dev_get_rcu(dev);",
"\t\t\t/* If err equals -EHOSTUNREACH the error is due to a\n\t\t\t * martian destination or due to the fact that\n\t\t\t * forwarding is disabled. For most martian packets,\n\t\t\t * ip_route_output_key() will fail. It won't fail for 2 types of\n\t\t\t * martian destinations: loopback destinations and destination\n\t\t\t * 0.0.0.0. In both cases the packet will be dropped because the\n\t\t\t * destination is the loopback device and not the bridge. */\n\t\t\tif (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev))\n\t\t\t\tgoto free_skb;",
"\t\t\trt = ip_route_output(dev_net(dev), iph->daddr, 0,\n\t\t\t\t\t RT_TOS(iph->tos), 0);\n\t\t\tif (!IS_ERR(rt)) {\n\t\t\t\t/* - Bridged-and-DNAT'ed traffic doesn't\n\t\t\t\t * require ip_forwarding. */\n\t\t\t\tif (rt->dst.dev == dev) {\n\t\t\t\t\tskb_dst_set(skb, &rt->dst);\n\t\t\t\t\tgoto bridged_dnat;\n\t\t\t\t}\n\t\t\t\tip_rt_put(rt);\n\t\t\t}\nfree_skb:\n\t\t\tkfree_skb(skb);\n\t\t\treturn 0;\n\t\t} else {\n\t\t\tif (skb_dst(skb)->dev == dev) {\nbridged_dnat:\n\t\t\t\tskb->dev = nf_bridge->physindev;\n\t\t\t\tnf_bridge_update_protocol(skb);\n\t\t\t\tnf_bridge_push_encap_header(skb);\n\t\t\t\tNF_HOOK_THRESH(NFPROTO_BRIDGE,\n\t\t\t\t\t NF_BR_PRE_ROUTING,\n\t\t\t\t\t skb, skb->dev, NULL,\n\t\t\t\t\t br_nf_pre_routing_finish_bridge,\n\t\t\t\t\t 1);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tmemcpy(eth_hdr(skb)->h_dest, dev->dev_addr, ETH_ALEN);\n\t\t\tskb->pkt_type = PACKET_HOST;\n\t\t}\n\t} else {\n\t\trt = bridge_parent_rtable(nf_bridge->physindev);\n\t\tif (!rt) {\n\t\t\tkfree_skb(skb);\n\t\t\treturn 0;\n\t\t}\n\t\tskb_dst_set_noref(skb, &rt->dst);\n\t}",
"\tskb->dev = nf_bridge->physindev;\n\tnf_bridge_update_protocol(skb);\n\tnf_bridge_push_encap_header(skb);\n\tNF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,\n\t\t br_handle_frame_finish, 1);",
"\treturn 0;\n}",
"/* Some common code for IPv4/IPv6 */\nstatic struct net_device *setup_pre_routing(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;",
"\tif (skb->pkt_type == PACKET_OTHERHOST) {\n\t\tskb->pkt_type = PACKET_HOST;\n\t\tnf_bridge->mask |= BRNF_PKT_TYPE;\n\t}",
"\tnf_bridge->mask |= BRNF_NF_BRIDGE_PREROUTING;\n\tnf_bridge->physindev = skb->dev;\n\tskb->dev = bridge_parent(skb->dev);\n\tif (skb->protocol == htons(ETH_P_8021Q))\n\t\tnf_bridge->mask |= BRNF_8021Q;\n\telse if (skb->protocol == htons(ETH_P_PPP_SES))\n\t\tnf_bridge->mask |= BRNF_PPPoE;",
"\treturn skb->dev;\n}",
"/* We only check the length. A bridge shouldn't do any hop-by-hop stuff anyway */\nstatic int check_hbh_len(struct sk_buff *skb)\n{\n\tunsigned char *raw = (u8 *)(ipv6_hdr(skb) + 1);\n\tu32 pkt_len;\n\tconst unsigned char *nh = skb_network_header(skb);\n\tint off = raw - nh;\n\tint len = (raw[1] + 1) << 3;",
"\tif ((raw + len) - skb->data > skb_headlen(skb))\n\t\tgoto bad;",
"\toff += 2;\n\tlen -= 2;",
"\twhile (len > 0) {\n\t\tint optlen = nh[off + 1] + 2;",
"\t\tswitch (nh[off]) {\n\t\tcase IPV6_TLV_PAD0:\n\t\t\toptlen = 1;\n\t\t\tbreak;",
"\t\tcase IPV6_TLV_PADN:\n\t\t\tbreak;",
"\t\tcase IPV6_TLV_JUMBO:\n\t\t\tif (nh[off + 1] != 4 || (off & 3) != 2)\n\t\t\t\tgoto bad;\n\t\t\tpkt_len = ntohl(*(__be32 *) (nh + off + 2));\n\t\t\tif (pkt_len <= IPV6_MAXPLEN ||\n\t\t\t ipv6_hdr(skb)->payload_len)\n\t\t\t\tgoto bad;\n\t\t\tif (pkt_len > skb->len - sizeof(struct ipv6hdr))\n\t\t\t\tgoto bad;\n\t\t\tif (pskb_trim_rcsum(skb,\n\t\t\t\t\t pkt_len + sizeof(struct ipv6hdr)))\n\t\t\t\tgoto bad;\n\t\t\tnh = skb_network_header(skb);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (optlen > len)\n\t\t\t\tgoto bad;\n\t\t\tbreak;\n\t\t}\n\t\toff += optlen;\n\t\tlen -= optlen;\n\t}\n\tif (len == 0)\n\t\treturn 0;\nbad:\n\treturn -1;",
"}",
"/* Replicate the checks that IPv6 does on packet reception and pass the packet\n * to ip6tables, which doesn't support NAT, so things are fairly simple. */\nstatic unsigned int br_nf_pre_routing_ipv6(unsigned int hook,\n\t\t\t\t\t struct sk_buff *skb,\n\t\t\t\t\t const struct net_device *in,\n\t\t\t\t\t const struct net_device *out,\n\t\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct ipv6hdr *hdr;\n\tu32 pkt_len;",
"\tif (skb->len < sizeof(struct ipv6hdr))\n\t\treturn NF_DROP;",
"\tif (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))\n\t\treturn NF_DROP;",
"\thdr = ipv6_hdr(skb);",
"\tif (hdr->version != 6)\n\t\treturn NF_DROP;",
"\tpkt_len = ntohs(hdr->payload_len);",
"\tif (pkt_len || hdr->nexthdr != NEXTHDR_HOP) {\n\t\tif (pkt_len + sizeof(struct ipv6hdr) > skb->len)\n\t\t\treturn NF_DROP;\n\t\tif (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))\n\t\t\treturn NF_DROP;\n\t}\n\tif (hdr->nexthdr == NEXTHDR_HOP && check_hbh_len(skb))\n\t\treturn NF_DROP;",
"\tnf_bridge_put(skb->nf_bridge);\n\tif (!nf_bridge_alloc(skb))\n\t\treturn NF_DROP;\n\tif (!setup_pre_routing(skb))\n\t\treturn NF_DROP;",
"\tskb->protocol = htons(ETH_P_IPV6);\n\tNF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, skb, skb->dev, NULL,\n\t\tbr_nf_pre_routing_finish_ipv6);",
"\treturn NF_STOLEN;\n}",
"/* Direct IPv6 traffic to br_nf_pre_routing_ipv6.\n * Replicate the checks that IPv4 does on packet reception.\n * Set skb->dev to the bridge device (i.e. parent of the\n * receiving device) to make netfilter happy, the REDIRECT\n * target in particular. Save the original destination IP\n * address to be able to detect DNAT afterwards. */\nstatic unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct net_bridge_port *p;\n\tstruct net_bridge *br;\n\t__u32 len = nf_bridge_encap_header_len(skb);",
"\tif (unlikely(!pskb_may_pull(skb, len)))\n\t\treturn NF_DROP;",
"\tp = br_port_get_rcu(in);\n\tif (p == NULL)\n\t\treturn NF_DROP;\n\tbr = p->br;",
"\tif (skb->protocol == htons(ETH_P_IPV6) || IS_VLAN_IPV6(skb) ||\n\t IS_PPPOE_IPV6(skb)) {\n\t\tif (!brnf_call_ip6tables && !br->nf_call_ip6tables)\n\t\t\treturn NF_ACCEPT;",
"\t\tnf_bridge_pull_encap_header_rcsum(skb);\n\t\treturn br_nf_pre_routing_ipv6(hook, skb, in, out, okfn);\n\t}",
"\tif (!brnf_call_iptables && !br->nf_call_iptables)\n\t\treturn NF_ACCEPT;",
"\tif (skb->protocol != htons(ETH_P_IP) && !IS_VLAN_IP(skb) &&\n\t !IS_PPPOE_IP(skb))\n\t\treturn NF_ACCEPT;",
"\tnf_bridge_pull_encap_header_rcsum(skb);",
"\tif (br_parse_ip_options(skb))\n\t\treturn NF_DROP;",
"\tnf_bridge_put(skb->nf_bridge);\n\tif (!nf_bridge_alloc(skb))\n\t\treturn NF_DROP;\n\tif (!setup_pre_routing(skb))\n\t\treturn NF_DROP;\n\tstore_orig_dstaddr(skb);\n\tskb->protocol = htons(ETH_P_IP);",
"\tNF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, skb, skb->dev, NULL,\n\t\tbr_nf_pre_routing_finish);",
"\treturn NF_STOLEN;\n}",
"\n/* PF_BRIDGE/LOCAL_IN ************************************************/\n/* The packet is locally destined, which requires a real\n * dst_entry, so detach the fake one. On the way up, the\n * packet would pass through PRE_ROUTING again (which already\n * took place when the packet entered the bridge), but we\n * register an IPv4 PRE_ROUTING 'sabotage' hook that will\n * prevent this from happening. */\nstatic unsigned int br_nf_local_in(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct rtable *rt = skb_rtable(skb);",
"\tif (rt && rt == bridge_parent_rtable(in))\n\t\tskb_dst_drop(skb);",
"\treturn NF_ACCEPT;\n}",
"/* PF_BRIDGE/FORWARD *************************************************/\nstatic int br_nf_forward_finish(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct net_device *in;",
"\tif (skb->protocol != htons(ETH_P_ARP) && !IS_VLAN_ARP(skb)) {\n\t\tin = nf_bridge->physindev;\n\t\tif (nf_bridge->mask & BRNF_PKT_TYPE) {\n\t\t\tskb->pkt_type = PACKET_OTHERHOST;\n\t\t\tnf_bridge->mask ^= BRNF_PKT_TYPE;\n\t\t}\n\t\tnf_bridge_update_protocol(skb);\n\t} else {\n\t\tin = *((struct net_device **)(skb->cb));\n\t}\n\tnf_bridge_push_encap_header(skb);",
"\tNF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, in,\n\t\t skb->dev, br_forward_finish, 1);\n\treturn 0;\n}",
"/* This is the 'purely bridged' case. For IP, we pass the packet to\n * netfilter with indev and outdev set to the bridge device,\n * but we are still able to filter on the 'real' indev/outdev\n * because of the physdev module. For ARP, indev and outdev are the\n * bridge ports. */\nstatic unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct nf_bridge_info *nf_bridge;\n\tstruct net_device *parent;\n\tu_int8_t pf;",
"\tif (!skb->nf_bridge)\n\t\treturn NF_ACCEPT;",
"\t/* Need exclusive nf_bridge_info since we might have multiple\n\t * different physoutdevs. */\n\tif (!nf_bridge_unshare(skb))\n\t\treturn NF_DROP;",
"\tparent = bridge_parent(out);\n\tif (!parent)\n\t\treturn NF_DROP;",
"\tif (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP(skb) ||\n\t IS_PPPOE_IP(skb))\n\t\tpf = PF_INET;\n\telse if (skb->protocol == htons(ETH_P_IPV6) || IS_VLAN_IPV6(skb) ||\n\t\t IS_PPPOE_IPV6(skb))\n\t\tpf = PF_INET6;\n\telse\n\t\treturn NF_ACCEPT;",
"\tnf_bridge_pull_encap_header(skb);",
"\tnf_bridge = skb->nf_bridge;\n\tif (skb->pkt_type == PACKET_OTHERHOST) {\n\t\tskb->pkt_type = PACKET_HOST;\n\t\tnf_bridge->mask |= BRNF_PKT_TYPE;\n\t}",
"\tif (br_parse_ip_options(skb))\n\t\treturn NF_DROP;",
"\t/* The physdev module checks on this */\n\tnf_bridge->mask |= BRNF_BRIDGED;\n\tnf_bridge->physoutdev = skb->dev;\n\tif (pf == PF_INET)\n\t\tskb->protocol = htons(ETH_P_IP);\n\telse\n\t\tskb->protocol = htons(ETH_P_IPV6);",
"\tNF_HOOK(pf, NF_INET_FORWARD, skb, bridge_parent(in), parent,\n\t\tbr_nf_forward_finish);",
"\treturn NF_STOLEN;\n}",
"static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct net_bridge_port *p;\n\tstruct net_bridge *br;\n\tstruct net_device **d = (struct net_device **)(skb->cb);",
"\tp = br_port_get_rcu(out);\n\tif (p == NULL)\n\t\treturn NF_ACCEPT;\n\tbr = p->br;",
"\tif (!brnf_call_arptables && !br->nf_call_arptables)\n\t\treturn NF_ACCEPT;",
"\tif (skb->protocol != htons(ETH_P_ARP)) {\n\t\tif (!IS_VLAN_ARP(skb))\n\t\t\treturn NF_ACCEPT;\n\t\tnf_bridge_pull_encap_header(skb);\n\t}",
"\tif (arp_hdr(skb)->ar_pln != 4) {\n\t\tif (IS_VLAN_ARP(skb))\n\t\t\tnf_bridge_push_encap_header(skb);\n\t\treturn NF_ACCEPT;\n\t}\n\t*d = (struct net_device *)in;\n\tNF_HOOK(NFPROTO_ARP, NF_ARP_FORWARD, skb, (struct net_device *)in,\n\t\t(struct net_device *)out, br_nf_forward_finish);",
"\treturn NF_STOLEN;\n}",
"#if defined(CONFIG_NF_CONNTRACK_IPV4) || defined(CONFIG_NF_CONNTRACK_IPV4_MODULE)\nstatic int br_nf_dev_queue_xmit(struct sk_buff *skb)\n{\n\tint ret;",
"\tif (skb->nfct != NULL && skb->protocol == htons(ETH_P_IP) &&\n\t skb->len + nf_bridge_mtu_reduction(skb) > skb->dev->mtu &&\n\t !skb_is_gso(skb)) {\n\t\tif (br_parse_ip_options(skb))\n\t\t\t/* Drop invalid packet */\n\t\t\treturn NF_DROP;\n\t\tret = ip_fragment(skb, br_dev_queue_push_xmit);\n\t} else\n\t\tret = br_dev_queue_push_xmit(skb);",
"\treturn ret;\n}\n#else\nstatic int br_nf_dev_queue_xmit(struct sk_buff *skb)\n{\n return br_dev_queue_push_xmit(skb);\n}\n#endif",
"/* PF_BRIDGE/POST_ROUTING ********************************************/\nstatic unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct net_device *realoutdev = bridge_parent(skb->dev);\n\tu_int8_t pf;",
"\tif (!nf_bridge || !(nf_bridge->mask & BRNF_BRIDGED))\n\t\treturn NF_ACCEPT;",
"\tif (!realoutdev)\n\t\treturn NF_DROP;",
"\tif (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP(skb) ||\n\t IS_PPPOE_IP(skb))\n\t\tpf = PF_INET;\n\telse if (skb->protocol == htons(ETH_P_IPV6) || IS_VLAN_IPV6(skb) ||\n\t\t IS_PPPOE_IPV6(skb))\n\t\tpf = PF_INET6;\n\telse\n\t\treturn NF_ACCEPT;",
"\t/* We assume any code from br_dev_queue_push_xmit onwards doesn't care\n\t * about the value of skb->pkt_type. */\n\tif (skb->pkt_type == PACKET_OTHERHOST) {\n\t\tskb->pkt_type = PACKET_HOST;\n\t\tnf_bridge->mask |= BRNF_PKT_TYPE;\n\t}",
"\tnf_bridge_pull_encap_header(skb);\n\tnf_bridge_save_header(skb);\n\tif (pf == PF_INET)\n\t\tskb->protocol = htons(ETH_P_IP);\n\telse\n\t\tskb->protocol = htons(ETH_P_IPV6);",
"\tNF_HOOK(pf, NF_INET_POST_ROUTING, skb, NULL, realoutdev,\n\t\tbr_nf_dev_queue_xmit);",
"\treturn NF_STOLEN;\n}",
"/* IP/SABOTAGE *****************************************************/\n/* Don't hand locally destined packets to PF_INET(6)/PRE_ROUTING\n * for the second time. */\nstatic unsigned int ip_sabotage_in(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tif (skb->nf_bridge &&\n\t !(skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING)) {\n\t\treturn NF_STOP;\n\t}",
"\treturn NF_ACCEPT;\n}",
"/* For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because\n * br_dev_queue_push_xmit is called afterwards */\nstatic struct nf_hook_ops br_nf_ops[] __read_mostly = {\n\t{\n\t\t.hook = br_nf_pre_routing,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_BRIDGE,\n\t\t.hooknum = NF_BR_PRE_ROUTING,\n\t\t.priority = NF_BR_PRI_BRNF,\n\t},\n\t{\n\t\t.hook = br_nf_local_in,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_BRIDGE,\n\t\t.hooknum = NF_BR_LOCAL_IN,\n\t\t.priority = NF_BR_PRI_BRNF,\n\t},\n\t{\n\t\t.hook = br_nf_forward_ip,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_BRIDGE,\n\t\t.hooknum = NF_BR_FORWARD,\n\t\t.priority = NF_BR_PRI_BRNF - 1,\n\t},\n\t{\n\t\t.hook = br_nf_forward_arp,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_BRIDGE,\n\t\t.hooknum = NF_BR_FORWARD,\n\t\t.priority = NF_BR_PRI_BRNF,\n\t},\n\t{\n\t\t.hook = br_nf_post_routing,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_BRIDGE,\n\t\t.hooknum = NF_BR_POST_ROUTING,\n\t\t.priority = NF_BR_PRI_LAST,\n\t},\n\t{\n\t\t.hook = ip_sabotage_in,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_INET,\n\t\t.hooknum = NF_INET_PRE_ROUTING,\n\t\t.priority = NF_IP_PRI_FIRST,\n\t},\n\t{\n\t\t.hook = ip_sabotage_in,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_INET6,\n\t\t.hooknum = NF_INET_PRE_ROUTING,\n\t\t.priority = NF_IP6_PRI_FIRST,\n\t},\n};",
"#ifdef CONFIG_SYSCTL\nstatic\nint brnf_sysctl_call_tables(ctl_table * ctl, int write,\n\t\t\t void __user * buffer, size_t * lenp, loff_t * ppos)\n{\n\tint ret;",
"\tret = proc_dointvec(ctl, write, buffer, lenp, ppos);",
"\tif (write && *(int *)(ctl->data))\n\t\t*(int *)(ctl->data) = 1;\n\treturn ret;\n}",
"static ctl_table brnf_table[] = {\n\t{\n\t\t.procname\t= \"bridge-nf-call-arptables\",\n\t\t.data\t\t= &brnf_call_arptables,\n\t\t.maxlen\t\t= sizeof(int),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= brnf_sysctl_call_tables,\n\t},\n\t{\n\t\t.procname\t= \"bridge-nf-call-iptables\",\n\t\t.data\t\t= &brnf_call_iptables,\n\t\t.maxlen\t\t= sizeof(int),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= brnf_sysctl_call_tables,\n\t},\n\t{\n\t\t.procname\t= \"bridge-nf-call-ip6tables\",\n\t\t.data\t\t= &brnf_call_ip6tables,\n\t\t.maxlen\t\t= sizeof(int),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= brnf_sysctl_call_tables,\n\t},\n\t{\n\t\t.procname\t= \"bridge-nf-filter-vlan-tagged\",\n\t\t.data\t\t= &brnf_filter_vlan_tagged,\n\t\t.maxlen\t\t= sizeof(int),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= brnf_sysctl_call_tables,\n\t},\n\t{\n\t\t.procname\t= \"bridge-nf-filter-pppoe-tagged\",\n\t\t.data\t\t= &brnf_filter_pppoe_tagged,\n\t\t.maxlen\t\t= sizeof(int),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= brnf_sysctl_call_tables,\n\t},\n\t{ }\n};",
"static struct ctl_path brnf_path[] = {\n\t{ .procname = \"net\", },\n\t{ .procname = \"bridge\", },\n\t{ }\n};\n#endif",
"int __init br_netfilter_init(void)\n{\n\tint ret;",
"\tret = dst_entries_init(&fake_dst_ops);\n\tif (ret < 0)\n\t\treturn ret;",
"\tret = nf_register_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));\n\tif (ret < 0) {\n\t\tdst_entries_destroy(&fake_dst_ops);\n\t\treturn ret;\n\t}\n#ifdef CONFIG_SYSCTL\n\tbrnf_sysctl_header = register_sysctl_paths(brnf_path, brnf_table);\n\tif (brnf_sysctl_header == NULL) {\n\t\tprintk(KERN_WARNING\n\t\t \"br_netfilter: can't register to sysctl.\\n\");\n\t\tnf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));\n\t\tdst_entries_destroy(&fake_dst_ops);\n\t\treturn -ENOMEM;\n\t}\n#endif\n\tprintk(KERN_NOTICE \"Bridge firewalling registered\\n\");\n\treturn 0;\n}",
"void br_netfilter_fini(void)\n{\n\tnf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));\n#ifdef CONFIG_SYSCTL\n\tunregister_sysctl_table(brnf_sysctl_header);\n#endif\n\tdst_entries_destroy(&fake_dst_ops);\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [257], "buggy_code_start_loc": [252], "filenames": ["net/bridge/br_netfilter.c"], "fixing_code_end_loc": [254], "fixing_code_start_loc": [252], "message": "The br_parse_ip_options function in net/bridge/br_netfilter.c in the Linux kernel before 2.6.39 does not properly initialize a certain data structure, which allows remote attackers to cause a denial of service by leveraging connectivity to a network interface that uses an Ethernet bridge device.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "176353CE-F17E-4776-AD9F-19014DA75B76", "versionEndExcluding": "2.6.39", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "The br_parse_ip_options function in net/bridge/br_netfilter.c in the Linux kernel before 2.6.39 does not properly initialize a certain data structure, which allows remote attackers to cause a denial of service by leveraging connectivity to a network interface that uses an Ethernet bridge device."}, {"lang": "es", "value": "La funci\u00f3n br_parse_ip_options en net/bridge/br_netfilter.c de los kernel Linux anteriores a v2.6.39 no inicia adecuadamente cierta estructura de datos, permitiendo que atacantes remotos provoquen denegaciones de servicio mediante la indicaci\u00f3n de conexi\u00f3n a un interfaz de red que usa un dispositivo bridge Ethernet."}], "evaluatorComment": null, "id": "CVE-2011-4087", "lastModified": "2020-07-27T19:57:08.700", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:N/AC:M/Au:N/C:N/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2013-06-08T13:05:55.210", "references": [{"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://ftp.osuosl.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39"}, {"source": "secalert@redhat.com", "tags": ["Exploit", "Patch", "Vendor Advisory"], "url": "http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f8e9881c2aef1e982e5abc25c046820cd0b7cf64"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2011/10/28/14"}, {"source": "secalert@redhat.com", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/f8e9881c2aef1e982e5abc25c046820cd0b7cf64"}], "sourceIdentifier": "secalert@redhat.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-665"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/f8e9881c2aef1e982e5abc25c046820cd0b7cf64"}, "type": "CWE-665"}
| 371
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n *\tHandle firewalling\n *\tLinux ethernet bridge\n *\n *\tAuthors:\n *\tLennert Buytenhek\t\t<buytenh@gnu.org>\n *\tBart De Schuymer\t\t<bdschuym@pandora.be>\n *\n *\tThis program is free software; you can redistribute it and/or\n *\tmodify it under the terms of the GNU General Public License\n *\tas published by the Free Software Foundation; either version\n *\t2 of the License, or (at your option) any later version.\n *\n *\tLennert dedicates this file to Kerstin Wurdinger.\n */",
"#include <linux/module.h>\n#include <linux/kernel.h>\n#include <linux/slab.h>\n#include <linux/ip.h>\n#include <linux/netdevice.h>\n#include <linux/skbuff.h>\n#include <linux/if_arp.h>\n#include <linux/if_ether.h>\n#include <linux/if_vlan.h>\n#include <linux/if_pppox.h>\n#include <linux/ppp_defs.h>\n#include <linux/netfilter_bridge.h>\n#include <linux/netfilter_ipv4.h>\n#include <linux/netfilter_ipv6.h>\n#include <linux/netfilter_arp.h>\n#include <linux/in_route.h>\n#include <linux/inetdevice.h>",
"#include <net/ip.h>\n#include <net/ipv6.h>\n#include <net/route.h>",
"#include <asm/uaccess.h>\n#include \"br_private.h\"\n#ifdef CONFIG_SYSCTL\n#include <linux/sysctl.h>\n#endif",
"#define skb_origaddr(skb)\t (((struct bridge_skb_cb *) \\\n\t\t\t\t (skb->nf_bridge->data))->daddr.ipv4)\n#define store_orig_dstaddr(skb)\t (skb_origaddr(skb) = ip_hdr(skb)->daddr)\n#define dnat_took_place(skb)\t (skb_origaddr(skb) != ip_hdr(skb)->daddr)",
"#ifdef CONFIG_SYSCTL\nstatic struct ctl_table_header *brnf_sysctl_header;\nstatic int brnf_call_iptables __read_mostly = 1;\nstatic int brnf_call_ip6tables __read_mostly = 1;\nstatic int brnf_call_arptables __read_mostly = 1;\nstatic int brnf_filter_vlan_tagged __read_mostly = 0;\nstatic int brnf_filter_pppoe_tagged __read_mostly = 0;\n#else\n#define brnf_call_iptables 1\n#define brnf_call_ip6tables 1\n#define brnf_call_arptables 1\n#define brnf_filter_vlan_tagged 0\n#define brnf_filter_pppoe_tagged 0\n#endif",
"static inline __be16 vlan_proto(const struct sk_buff *skb)\n{\n\tif (vlan_tx_tag_present(skb))\n\t\treturn skb->protocol;\n\telse if (skb->protocol == htons(ETH_P_8021Q))\n\t\treturn vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;\n\telse\n\t\treturn 0;\n}",
"#define IS_VLAN_IP(skb) \\\n\t(vlan_proto(skb) == htons(ETH_P_IP) && \\\n\t brnf_filter_vlan_tagged)",
"#define IS_VLAN_IPV6(skb) \\\n\t(vlan_proto(skb) == htons(ETH_P_IPV6) && \\\n\t brnf_filter_vlan_tagged)",
"#define IS_VLAN_ARP(skb) \\\n\t(vlan_proto(skb) == htons(ETH_P_ARP) &&\t\\\n\t brnf_filter_vlan_tagged)",
"static inline __be16 pppoe_proto(const struct sk_buff *skb)\n{\n\treturn *((__be16 *)(skb_mac_header(skb) + ETH_HLEN +\n\t\t\t sizeof(struct pppoe_hdr)));\n}",
"#define IS_PPPOE_IP(skb) \\\n\t(skb->protocol == htons(ETH_P_PPP_SES) && \\\n\t pppoe_proto(skb) == htons(PPP_IP) && \\\n\t brnf_filter_pppoe_tagged)",
"#define IS_PPPOE_IPV6(skb) \\\n\t(skb->protocol == htons(ETH_P_PPP_SES) && \\\n\t pppoe_proto(skb) == htons(PPP_IPV6) && \\\n\t brnf_filter_pppoe_tagged)",
"static void fake_update_pmtu(struct dst_entry *dst, u32 mtu)\n{\n}",
"static struct dst_ops fake_dst_ops = {\n\t.family =\t\tAF_INET,\n\t.protocol =\t\tcpu_to_be16(ETH_P_IP),\n\t.update_pmtu =\t\tfake_update_pmtu,\n};",
"/*\n * Initialize bogus route table used to keep netfilter happy.\n * Currently, we fill in the PMTU entry because netfilter\n * refragmentation needs it, and the rt_flags entry because\n * ipt_REJECT needs it. Future netfilter modules might\n * require us to fill additional fields.\n */\nvoid br_netfilter_rtable_init(struct net_bridge *br)\n{\n\tstruct rtable *rt = &br->fake_rtable;",
"\tatomic_set(&rt->dst.__refcnt, 1);\n\trt->dst.dev = br->dev;\n\trt->dst.path = &rt->dst;\n\tdst_metric_set(&rt->dst, RTAX_MTU, 1500);\n\trt->dst.flags\t= DST_NOXFRM;\n\trt->dst.ops = &fake_dst_ops;\n}",
"static inline struct rtable *bridge_parent_rtable(const struct net_device *dev)\n{\n\tstruct net_bridge_port *port;",
"\tport = br_port_get_rcu(dev);\n\treturn port ? &port->br->fake_rtable : NULL;\n}",
"static inline struct net_device *bridge_parent(const struct net_device *dev)\n{\n\tstruct net_bridge_port *port;",
"\tport = br_port_get_rcu(dev);\n\treturn port ? port->br->dev : NULL;\n}",
"static inline struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)\n{\n\tskb->nf_bridge = kzalloc(sizeof(struct nf_bridge_info), GFP_ATOMIC);\n\tif (likely(skb->nf_bridge))\n\t\tatomic_set(&(skb->nf_bridge->use), 1);",
"\treturn skb->nf_bridge;\n}",
"static inline struct nf_bridge_info *nf_bridge_unshare(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;",
"\tif (atomic_read(&nf_bridge->use) > 1) {\n\t\tstruct nf_bridge_info *tmp = nf_bridge_alloc(skb);",
"\t\tif (tmp) {\n\t\t\tmemcpy(tmp, nf_bridge, sizeof(struct nf_bridge_info));\n\t\t\tatomic_set(&tmp->use, 1);\n\t\t}\n\t\tnf_bridge_put(nf_bridge);\n\t\tnf_bridge = tmp;\n\t}\n\treturn nf_bridge;\n}",
"static inline void nf_bridge_push_encap_header(struct sk_buff *skb)\n{\n\tunsigned int len = nf_bridge_encap_header_len(skb);",
"\tskb_push(skb, len);\n\tskb->network_header -= len;\n}",
"static inline void nf_bridge_pull_encap_header(struct sk_buff *skb)\n{\n\tunsigned int len = nf_bridge_encap_header_len(skb);",
"\tskb_pull(skb, len);\n\tskb->network_header += len;\n}",
"static inline void nf_bridge_pull_encap_header_rcsum(struct sk_buff *skb)\n{\n\tunsigned int len = nf_bridge_encap_header_len(skb);",
"\tskb_pull_rcsum(skb, len);\n\tskb->network_header += len;\n}",
"static inline void nf_bridge_save_header(struct sk_buff *skb)\n{\n\tint header_size = ETH_HLEN + nf_bridge_encap_header_len(skb);",
"\tskb_copy_from_linear_data_offset(skb, -header_size,\n\t\t\t\t\t skb->nf_bridge->data, header_size);\n}",
"static inline void nf_bridge_update_protocol(struct sk_buff *skb)\n{\n\tif (skb->nf_bridge->mask & BRNF_8021Q)\n\t\tskb->protocol = htons(ETH_P_8021Q);\n\telse if (skb->nf_bridge->mask & BRNF_PPPoE)\n\t\tskb->protocol = htons(ETH_P_PPP_SES);\n}",
"/* When handing a packet over to the IP layer\n * check whether we have a skb that is in the\n * expected format\n */",
"static int br_parse_ip_options(struct sk_buff *skb)\n{\n\tstruct ip_options *opt;\n\tstruct iphdr *iph;\n\tstruct net_device *dev = skb->dev;\n\tu32 len;",
"\tiph = ip_hdr(skb);\n\topt = &(IPCB(skb)->opt);",
"\t/* Basic sanity checks */\n\tif (iph->ihl < 5 || iph->version != 4)\n\t\tgoto inhdr_error;",
"\tif (!pskb_may_pull(skb, iph->ihl*4))\n\t\tgoto inhdr_error;",
"\tiph = ip_hdr(skb);\n\tif (unlikely(ip_fast_csum((u8 *)iph, iph->ihl)))\n\t\tgoto inhdr_error;",
"\tlen = ntohs(iph->tot_len);\n\tif (skb->len < len) {\n\t\tIP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INTRUNCATEDPKTS);\n\t\tgoto drop;\n\t} else if (len < (iph->ihl*4))\n\t\tgoto inhdr_error;",
"\tif (pskb_trim_rcsum(skb, len)) {\n\t\tIP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INDISCARDS);\n\t\tgoto drop;\n\t}\n",
"\tmemset(IPCB(skb), 0, sizeof(struct inet_skb_parm));\n\tif (iph->ihl == 5)",
"\t\treturn 0;",
"",
"\n\topt->optlen = iph->ihl*4 - sizeof(struct iphdr);\n\tif (ip_options_compile(dev_net(dev), opt, skb))\n\t\tgoto inhdr_error;",
"\t/* Check correct handling of SRR option */\n\tif (unlikely(opt->srr)) {\n\t\tstruct in_device *in_dev = __in_dev_get_rcu(dev);\n\t\tif (in_dev && !IN_DEV_SOURCE_ROUTE(in_dev))\n\t\t\tgoto drop;",
"\t\tif (ip_options_rcv_srr(skb))\n\t\t\tgoto drop;\n\t}",
"\treturn 0;",
"inhdr_error:\n\tIP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INHDRERRORS);\ndrop:\n\treturn -1;\n}",
"/* Fill in the header for fragmented IP packets handled by\n * the IPv4 connection tracking code.\n */\nint nf_bridge_copy_header(struct sk_buff *skb)\n{\n\tint err;\n\tunsigned int header_size;",
"\tnf_bridge_update_protocol(skb);\n\theader_size = ETH_HLEN + nf_bridge_encap_header_len(skb);\n\terr = skb_cow_head(skb, header_size);\n\tif (err)\n\t\treturn err;",
"\tskb_copy_to_linear_data_offset(skb, -header_size,\n\t\t\t\t skb->nf_bridge->data, header_size);\n\t__skb_push(skb, nf_bridge_encap_header_len(skb));\n\treturn 0;\n}",
"/* PF_BRIDGE/PRE_ROUTING *********************************************/\n/* Undo the changes made for ip6tables PREROUTING and continue the\n * bridge PRE_ROUTING hook. */\nstatic int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct rtable *rt;",
"\tif (nf_bridge->mask & BRNF_PKT_TYPE) {\n\t\tskb->pkt_type = PACKET_OTHERHOST;\n\t\tnf_bridge->mask ^= BRNF_PKT_TYPE;\n\t}\n\tnf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;",
"\trt = bridge_parent_rtable(nf_bridge->physindev);\n\tif (!rt) {\n\t\tkfree_skb(skb);\n\t\treturn 0;\n\t}\n\tskb_dst_set_noref(skb, &rt->dst);",
"\tskb->dev = nf_bridge->physindev;\n\tnf_bridge_update_protocol(skb);\n\tnf_bridge_push_encap_header(skb);\n\tNF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,\n\t\t br_handle_frame_finish, 1);",
"\treturn 0;\n}",
"/* Obtain the correct destination MAC address, while preserving the original\n * source MAC address. If we already know this address, we just copy it. If we\n * don't, we use the neighbour framework to find out. In both cases, we make\n * sure that br_handle_frame_finish() is called afterwards.\n */\nstatic int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct dst_entry *dst;",
"\tskb->dev = bridge_parent(skb->dev);\n\tif (!skb->dev)\n\t\tgoto free_skb;\n\tdst = skb_dst(skb);\n\tif (dst->hh) {\n\t\tneigh_hh_bridge(dst->hh, skb);\n\t\tskb->dev = nf_bridge->physindev;\n\t\treturn br_handle_frame_finish(skb);\n\t} else if (dst->neighbour) {\n\t\t/* the neighbour function below overwrites the complete\n\t\t * MAC header, so we save the Ethernet source address and\n\t\t * protocol number. */\n\t\tskb_copy_from_linear_data_offset(skb, -(ETH_HLEN-ETH_ALEN), skb->nf_bridge->data, ETH_HLEN-ETH_ALEN);\n\t\t/* tell br_dev_xmit to continue with forwarding */\n\t\tnf_bridge->mask |= BRNF_BRIDGED_DNAT;\n\t\treturn dst->neighbour->output(skb);\n\t}\nfree_skb:\n\tkfree_skb(skb);\n\treturn 0;\n}",
"/* This requires some explaining. If DNAT has taken place,\n * we will need to fix up the destination Ethernet address.\n *\n * There are two cases to consider:\n * 1. The packet was DNAT'ed to a device in the same bridge\n * port group as it was received on. We can still bridge\n * the packet.\n * 2. The packet was DNAT'ed to a different device, either\n * a non-bridged device or another bridge port group.\n * The packet will need to be routed.\n *\n * The correct way of distinguishing between these two cases is to\n * call ip_route_input() and to look at skb->dst->dev, which is\n * changed to the destination device if ip_route_input() succeeds.\n *\n * Let's first consider the case that ip_route_input() succeeds:\n *\n * If the output device equals the logical bridge device the packet\n * came in on, we can consider this bridging. The corresponding MAC\n * address will be obtained in br_nf_pre_routing_finish_bridge.\n * Otherwise, the packet is considered to be routed and we just\n * change the destination MAC address so that the packet will\n * later be passed up to the IP stack to be routed. For a redirected\n * packet, ip_route_input() will give back the localhost as output device,\n * which differs from the bridge device.\n *\n * Let's now consider the case that ip_route_input() fails:\n *\n * This can be because the destination address is martian, in which case\n * the packet will be dropped.\n * If IP forwarding is disabled, ip_route_input() will fail, while\n * ip_route_output_key() can return success. The source\n * address for ip_route_output_key() is set to zero, so ip_route_output_key()\n * thinks we're handling a locally generated packet and won't care\n * if IP forwarding is enabled. If the output device equals the logical bridge\n * device, we proceed as if ip_route_input() succeeded. If it differs from the\n * logical bridge port or if ip_route_output_key() fails we drop the packet.\n */\nstatic int br_nf_pre_routing_finish(struct sk_buff *skb)\n{\n\tstruct net_device *dev = skb->dev;\n\tstruct iphdr *iph = ip_hdr(skb);\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct rtable *rt;\n\tint err;",
"\tif (nf_bridge->mask & BRNF_PKT_TYPE) {\n\t\tskb->pkt_type = PACKET_OTHERHOST;\n\t\tnf_bridge->mask ^= BRNF_PKT_TYPE;\n\t}\n\tnf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;\n\tif (dnat_took_place(skb)) {\n\t\tif ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) {\n\t\t\tstruct in_device *in_dev = __in_dev_get_rcu(dev);",
"\t\t\t/* If err equals -EHOSTUNREACH the error is due to a\n\t\t\t * martian destination or due to the fact that\n\t\t\t * forwarding is disabled. For most martian packets,\n\t\t\t * ip_route_output_key() will fail. It won't fail for 2 types of\n\t\t\t * martian destinations: loopback destinations and destination\n\t\t\t * 0.0.0.0. In both cases the packet will be dropped because the\n\t\t\t * destination is the loopback device and not the bridge. */\n\t\t\tif (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev))\n\t\t\t\tgoto free_skb;",
"\t\t\trt = ip_route_output(dev_net(dev), iph->daddr, 0,\n\t\t\t\t\t RT_TOS(iph->tos), 0);\n\t\t\tif (!IS_ERR(rt)) {\n\t\t\t\t/* - Bridged-and-DNAT'ed traffic doesn't\n\t\t\t\t * require ip_forwarding. */\n\t\t\t\tif (rt->dst.dev == dev) {\n\t\t\t\t\tskb_dst_set(skb, &rt->dst);\n\t\t\t\t\tgoto bridged_dnat;\n\t\t\t\t}\n\t\t\t\tip_rt_put(rt);\n\t\t\t}\nfree_skb:\n\t\t\tkfree_skb(skb);\n\t\t\treturn 0;\n\t\t} else {\n\t\t\tif (skb_dst(skb)->dev == dev) {\nbridged_dnat:\n\t\t\t\tskb->dev = nf_bridge->physindev;\n\t\t\t\tnf_bridge_update_protocol(skb);\n\t\t\t\tnf_bridge_push_encap_header(skb);\n\t\t\t\tNF_HOOK_THRESH(NFPROTO_BRIDGE,\n\t\t\t\t\t NF_BR_PRE_ROUTING,\n\t\t\t\t\t skb, skb->dev, NULL,\n\t\t\t\t\t br_nf_pre_routing_finish_bridge,\n\t\t\t\t\t 1);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tmemcpy(eth_hdr(skb)->h_dest, dev->dev_addr, ETH_ALEN);\n\t\t\tskb->pkt_type = PACKET_HOST;\n\t\t}\n\t} else {\n\t\trt = bridge_parent_rtable(nf_bridge->physindev);\n\t\tif (!rt) {\n\t\t\tkfree_skb(skb);\n\t\t\treturn 0;\n\t\t}\n\t\tskb_dst_set_noref(skb, &rt->dst);\n\t}",
"\tskb->dev = nf_bridge->physindev;\n\tnf_bridge_update_protocol(skb);\n\tnf_bridge_push_encap_header(skb);\n\tNF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,\n\t\t br_handle_frame_finish, 1);",
"\treturn 0;\n}",
"/* Some common code for IPv4/IPv6 */\nstatic struct net_device *setup_pre_routing(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;",
"\tif (skb->pkt_type == PACKET_OTHERHOST) {\n\t\tskb->pkt_type = PACKET_HOST;\n\t\tnf_bridge->mask |= BRNF_PKT_TYPE;\n\t}",
"\tnf_bridge->mask |= BRNF_NF_BRIDGE_PREROUTING;\n\tnf_bridge->physindev = skb->dev;\n\tskb->dev = bridge_parent(skb->dev);\n\tif (skb->protocol == htons(ETH_P_8021Q))\n\t\tnf_bridge->mask |= BRNF_8021Q;\n\telse if (skb->protocol == htons(ETH_P_PPP_SES))\n\t\tnf_bridge->mask |= BRNF_PPPoE;",
"\treturn skb->dev;\n}",
"/* We only check the length. A bridge shouldn't do any hop-by-hop stuff anyway */\nstatic int check_hbh_len(struct sk_buff *skb)\n{\n\tunsigned char *raw = (u8 *)(ipv6_hdr(skb) + 1);\n\tu32 pkt_len;\n\tconst unsigned char *nh = skb_network_header(skb);\n\tint off = raw - nh;\n\tint len = (raw[1] + 1) << 3;",
"\tif ((raw + len) - skb->data > skb_headlen(skb))\n\t\tgoto bad;",
"\toff += 2;\n\tlen -= 2;",
"\twhile (len > 0) {\n\t\tint optlen = nh[off + 1] + 2;",
"\t\tswitch (nh[off]) {\n\t\tcase IPV6_TLV_PAD0:\n\t\t\toptlen = 1;\n\t\t\tbreak;",
"\t\tcase IPV6_TLV_PADN:\n\t\t\tbreak;",
"\t\tcase IPV6_TLV_JUMBO:\n\t\t\tif (nh[off + 1] != 4 || (off & 3) != 2)\n\t\t\t\tgoto bad;\n\t\t\tpkt_len = ntohl(*(__be32 *) (nh + off + 2));\n\t\t\tif (pkt_len <= IPV6_MAXPLEN ||\n\t\t\t ipv6_hdr(skb)->payload_len)\n\t\t\t\tgoto bad;\n\t\t\tif (pkt_len > skb->len - sizeof(struct ipv6hdr))\n\t\t\t\tgoto bad;\n\t\t\tif (pskb_trim_rcsum(skb,\n\t\t\t\t\t pkt_len + sizeof(struct ipv6hdr)))\n\t\t\t\tgoto bad;\n\t\t\tnh = skb_network_header(skb);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (optlen > len)\n\t\t\t\tgoto bad;\n\t\t\tbreak;\n\t\t}\n\t\toff += optlen;\n\t\tlen -= optlen;\n\t}\n\tif (len == 0)\n\t\treturn 0;\nbad:\n\treturn -1;",
"}",
"/* Replicate the checks that IPv6 does on packet reception and pass the packet\n * to ip6tables, which doesn't support NAT, so things are fairly simple. */\nstatic unsigned int br_nf_pre_routing_ipv6(unsigned int hook,\n\t\t\t\t\t struct sk_buff *skb,\n\t\t\t\t\t const struct net_device *in,\n\t\t\t\t\t const struct net_device *out,\n\t\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct ipv6hdr *hdr;\n\tu32 pkt_len;",
"\tif (skb->len < sizeof(struct ipv6hdr))\n\t\treturn NF_DROP;",
"\tif (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))\n\t\treturn NF_DROP;",
"\thdr = ipv6_hdr(skb);",
"\tif (hdr->version != 6)\n\t\treturn NF_DROP;",
"\tpkt_len = ntohs(hdr->payload_len);",
"\tif (pkt_len || hdr->nexthdr != NEXTHDR_HOP) {\n\t\tif (pkt_len + sizeof(struct ipv6hdr) > skb->len)\n\t\t\treturn NF_DROP;\n\t\tif (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))\n\t\t\treturn NF_DROP;\n\t}\n\tif (hdr->nexthdr == NEXTHDR_HOP && check_hbh_len(skb))\n\t\treturn NF_DROP;",
"\tnf_bridge_put(skb->nf_bridge);\n\tif (!nf_bridge_alloc(skb))\n\t\treturn NF_DROP;\n\tif (!setup_pre_routing(skb))\n\t\treturn NF_DROP;",
"\tskb->protocol = htons(ETH_P_IPV6);\n\tNF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, skb, skb->dev, NULL,\n\t\tbr_nf_pre_routing_finish_ipv6);",
"\treturn NF_STOLEN;\n}",
"/* Direct IPv6 traffic to br_nf_pre_routing_ipv6.\n * Replicate the checks that IPv4 does on packet reception.\n * Set skb->dev to the bridge device (i.e. parent of the\n * receiving device) to make netfilter happy, the REDIRECT\n * target in particular. Save the original destination IP\n * address to be able to detect DNAT afterwards. */\nstatic unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct net_bridge_port *p;\n\tstruct net_bridge *br;\n\t__u32 len = nf_bridge_encap_header_len(skb);",
"\tif (unlikely(!pskb_may_pull(skb, len)))\n\t\treturn NF_DROP;",
"\tp = br_port_get_rcu(in);\n\tif (p == NULL)\n\t\treturn NF_DROP;\n\tbr = p->br;",
"\tif (skb->protocol == htons(ETH_P_IPV6) || IS_VLAN_IPV6(skb) ||\n\t IS_PPPOE_IPV6(skb)) {\n\t\tif (!brnf_call_ip6tables && !br->nf_call_ip6tables)\n\t\t\treturn NF_ACCEPT;",
"\t\tnf_bridge_pull_encap_header_rcsum(skb);\n\t\treturn br_nf_pre_routing_ipv6(hook, skb, in, out, okfn);\n\t}",
"\tif (!brnf_call_iptables && !br->nf_call_iptables)\n\t\treturn NF_ACCEPT;",
"\tif (skb->protocol != htons(ETH_P_IP) && !IS_VLAN_IP(skb) &&\n\t !IS_PPPOE_IP(skb))\n\t\treturn NF_ACCEPT;",
"\tnf_bridge_pull_encap_header_rcsum(skb);",
"\tif (br_parse_ip_options(skb))\n\t\treturn NF_DROP;",
"\tnf_bridge_put(skb->nf_bridge);\n\tif (!nf_bridge_alloc(skb))\n\t\treturn NF_DROP;\n\tif (!setup_pre_routing(skb))\n\t\treturn NF_DROP;\n\tstore_orig_dstaddr(skb);\n\tskb->protocol = htons(ETH_P_IP);",
"\tNF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, skb, skb->dev, NULL,\n\t\tbr_nf_pre_routing_finish);",
"\treturn NF_STOLEN;\n}",
"\n/* PF_BRIDGE/LOCAL_IN ************************************************/\n/* The packet is locally destined, which requires a real\n * dst_entry, so detach the fake one. On the way up, the\n * packet would pass through PRE_ROUTING again (which already\n * took place when the packet entered the bridge), but we\n * register an IPv4 PRE_ROUTING 'sabotage' hook that will\n * prevent this from happening. */\nstatic unsigned int br_nf_local_in(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct rtable *rt = skb_rtable(skb);",
"\tif (rt && rt == bridge_parent_rtable(in))\n\t\tskb_dst_drop(skb);",
"\treturn NF_ACCEPT;\n}",
"/* PF_BRIDGE/FORWARD *************************************************/\nstatic int br_nf_forward_finish(struct sk_buff *skb)\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct net_device *in;",
"\tif (skb->protocol != htons(ETH_P_ARP) && !IS_VLAN_ARP(skb)) {\n\t\tin = nf_bridge->physindev;\n\t\tif (nf_bridge->mask & BRNF_PKT_TYPE) {\n\t\t\tskb->pkt_type = PACKET_OTHERHOST;\n\t\t\tnf_bridge->mask ^= BRNF_PKT_TYPE;\n\t\t}\n\t\tnf_bridge_update_protocol(skb);\n\t} else {\n\t\tin = *((struct net_device **)(skb->cb));\n\t}\n\tnf_bridge_push_encap_header(skb);",
"\tNF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, in,\n\t\t skb->dev, br_forward_finish, 1);\n\treturn 0;\n}",
"/* This is the 'purely bridged' case. For IP, we pass the packet to\n * netfilter with indev and outdev set to the bridge device,\n * but we are still able to filter on the 'real' indev/outdev\n * because of the physdev module. For ARP, indev and outdev are the\n * bridge ports. */\nstatic unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct nf_bridge_info *nf_bridge;\n\tstruct net_device *parent;\n\tu_int8_t pf;",
"\tif (!skb->nf_bridge)\n\t\treturn NF_ACCEPT;",
"\t/* Need exclusive nf_bridge_info since we might have multiple\n\t * different physoutdevs. */\n\tif (!nf_bridge_unshare(skb))\n\t\treturn NF_DROP;",
"\tparent = bridge_parent(out);\n\tif (!parent)\n\t\treturn NF_DROP;",
"\tif (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP(skb) ||\n\t IS_PPPOE_IP(skb))\n\t\tpf = PF_INET;\n\telse if (skb->protocol == htons(ETH_P_IPV6) || IS_VLAN_IPV6(skb) ||\n\t\t IS_PPPOE_IPV6(skb))\n\t\tpf = PF_INET6;\n\telse\n\t\treturn NF_ACCEPT;",
"\tnf_bridge_pull_encap_header(skb);",
"\tnf_bridge = skb->nf_bridge;\n\tif (skb->pkt_type == PACKET_OTHERHOST) {\n\t\tskb->pkt_type = PACKET_HOST;\n\t\tnf_bridge->mask |= BRNF_PKT_TYPE;\n\t}",
"\tif (br_parse_ip_options(skb))\n\t\treturn NF_DROP;",
"\t/* The physdev module checks on this */\n\tnf_bridge->mask |= BRNF_BRIDGED;\n\tnf_bridge->physoutdev = skb->dev;\n\tif (pf == PF_INET)\n\t\tskb->protocol = htons(ETH_P_IP);\n\telse\n\t\tskb->protocol = htons(ETH_P_IPV6);",
"\tNF_HOOK(pf, NF_INET_FORWARD, skb, bridge_parent(in), parent,\n\t\tbr_nf_forward_finish);",
"\treturn NF_STOLEN;\n}",
"static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct net_bridge_port *p;\n\tstruct net_bridge *br;\n\tstruct net_device **d = (struct net_device **)(skb->cb);",
"\tp = br_port_get_rcu(out);\n\tif (p == NULL)\n\t\treturn NF_ACCEPT;\n\tbr = p->br;",
"\tif (!brnf_call_arptables && !br->nf_call_arptables)\n\t\treturn NF_ACCEPT;",
"\tif (skb->protocol != htons(ETH_P_ARP)) {\n\t\tif (!IS_VLAN_ARP(skb))\n\t\t\treturn NF_ACCEPT;\n\t\tnf_bridge_pull_encap_header(skb);\n\t}",
"\tif (arp_hdr(skb)->ar_pln != 4) {\n\t\tif (IS_VLAN_ARP(skb))\n\t\t\tnf_bridge_push_encap_header(skb);\n\t\treturn NF_ACCEPT;\n\t}\n\t*d = (struct net_device *)in;\n\tNF_HOOK(NFPROTO_ARP, NF_ARP_FORWARD, skb, (struct net_device *)in,\n\t\t(struct net_device *)out, br_nf_forward_finish);",
"\treturn NF_STOLEN;\n}",
"#if defined(CONFIG_NF_CONNTRACK_IPV4) || defined(CONFIG_NF_CONNTRACK_IPV4_MODULE)\nstatic int br_nf_dev_queue_xmit(struct sk_buff *skb)\n{\n\tint ret;",
"\tif (skb->nfct != NULL && skb->protocol == htons(ETH_P_IP) &&\n\t skb->len + nf_bridge_mtu_reduction(skb) > skb->dev->mtu &&\n\t !skb_is_gso(skb)) {\n\t\tif (br_parse_ip_options(skb))\n\t\t\t/* Drop invalid packet */\n\t\t\treturn NF_DROP;\n\t\tret = ip_fragment(skb, br_dev_queue_push_xmit);\n\t} else\n\t\tret = br_dev_queue_push_xmit(skb);",
"\treturn ret;\n}\n#else\nstatic int br_nf_dev_queue_xmit(struct sk_buff *skb)\n{\n return br_dev_queue_push_xmit(skb);\n}\n#endif",
"/* PF_BRIDGE/POST_ROUTING ********************************************/\nstatic unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tstruct nf_bridge_info *nf_bridge = skb->nf_bridge;\n\tstruct net_device *realoutdev = bridge_parent(skb->dev);\n\tu_int8_t pf;",
"\tif (!nf_bridge || !(nf_bridge->mask & BRNF_BRIDGED))\n\t\treturn NF_ACCEPT;",
"\tif (!realoutdev)\n\t\treturn NF_DROP;",
"\tif (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP(skb) ||\n\t IS_PPPOE_IP(skb))\n\t\tpf = PF_INET;\n\telse if (skb->protocol == htons(ETH_P_IPV6) || IS_VLAN_IPV6(skb) ||\n\t\t IS_PPPOE_IPV6(skb))\n\t\tpf = PF_INET6;\n\telse\n\t\treturn NF_ACCEPT;",
"\t/* We assume any code from br_dev_queue_push_xmit onwards doesn't care\n\t * about the value of skb->pkt_type. */\n\tif (skb->pkt_type == PACKET_OTHERHOST) {\n\t\tskb->pkt_type = PACKET_HOST;\n\t\tnf_bridge->mask |= BRNF_PKT_TYPE;\n\t}",
"\tnf_bridge_pull_encap_header(skb);\n\tnf_bridge_save_header(skb);\n\tif (pf == PF_INET)\n\t\tskb->protocol = htons(ETH_P_IP);\n\telse\n\t\tskb->protocol = htons(ETH_P_IPV6);",
"\tNF_HOOK(pf, NF_INET_POST_ROUTING, skb, NULL, realoutdev,\n\t\tbr_nf_dev_queue_xmit);",
"\treturn NF_STOLEN;\n}",
"/* IP/SABOTAGE *****************************************************/\n/* Don't hand locally destined packets to PF_INET(6)/PRE_ROUTING\n * for the second time. */\nstatic unsigned int ip_sabotage_in(unsigned int hook, struct sk_buff *skb,\n\t\t\t\t const struct net_device *in,\n\t\t\t\t const struct net_device *out,\n\t\t\t\t int (*okfn)(struct sk_buff *))\n{\n\tif (skb->nf_bridge &&\n\t !(skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING)) {\n\t\treturn NF_STOP;\n\t}",
"\treturn NF_ACCEPT;\n}",
"/* For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because\n * br_dev_queue_push_xmit is called afterwards */\nstatic struct nf_hook_ops br_nf_ops[] __read_mostly = {\n\t{\n\t\t.hook = br_nf_pre_routing,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_BRIDGE,\n\t\t.hooknum = NF_BR_PRE_ROUTING,\n\t\t.priority = NF_BR_PRI_BRNF,\n\t},\n\t{\n\t\t.hook = br_nf_local_in,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_BRIDGE,\n\t\t.hooknum = NF_BR_LOCAL_IN,\n\t\t.priority = NF_BR_PRI_BRNF,\n\t},\n\t{\n\t\t.hook = br_nf_forward_ip,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_BRIDGE,\n\t\t.hooknum = NF_BR_FORWARD,\n\t\t.priority = NF_BR_PRI_BRNF - 1,\n\t},\n\t{\n\t\t.hook = br_nf_forward_arp,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_BRIDGE,\n\t\t.hooknum = NF_BR_FORWARD,\n\t\t.priority = NF_BR_PRI_BRNF,\n\t},\n\t{\n\t\t.hook = br_nf_post_routing,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_BRIDGE,\n\t\t.hooknum = NF_BR_POST_ROUTING,\n\t\t.priority = NF_BR_PRI_LAST,\n\t},\n\t{\n\t\t.hook = ip_sabotage_in,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_INET,\n\t\t.hooknum = NF_INET_PRE_ROUTING,\n\t\t.priority = NF_IP_PRI_FIRST,\n\t},\n\t{\n\t\t.hook = ip_sabotage_in,\n\t\t.owner = THIS_MODULE,\n\t\t.pf = PF_INET6,\n\t\t.hooknum = NF_INET_PRE_ROUTING,\n\t\t.priority = NF_IP6_PRI_FIRST,\n\t},\n};",
"#ifdef CONFIG_SYSCTL\nstatic\nint brnf_sysctl_call_tables(ctl_table * ctl, int write,\n\t\t\t void __user * buffer, size_t * lenp, loff_t * ppos)\n{\n\tint ret;",
"\tret = proc_dointvec(ctl, write, buffer, lenp, ppos);",
"\tif (write && *(int *)(ctl->data))\n\t\t*(int *)(ctl->data) = 1;\n\treturn ret;\n}",
"static ctl_table brnf_table[] = {\n\t{\n\t\t.procname\t= \"bridge-nf-call-arptables\",\n\t\t.data\t\t= &brnf_call_arptables,\n\t\t.maxlen\t\t= sizeof(int),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= brnf_sysctl_call_tables,\n\t},\n\t{\n\t\t.procname\t= \"bridge-nf-call-iptables\",\n\t\t.data\t\t= &brnf_call_iptables,\n\t\t.maxlen\t\t= sizeof(int),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= brnf_sysctl_call_tables,\n\t},\n\t{\n\t\t.procname\t= \"bridge-nf-call-ip6tables\",\n\t\t.data\t\t= &brnf_call_ip6tables,\n\t\t.maxlen\t\t= sizeof(int),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= brnf_sysctl_call_tables,\n\t},\n\t{\n\t\t.procname\t= \"bridge-nf-filter-vlan-tagged\",\n\t\t.data\t\t= &brnf_filter_vlan_tagged,\n\t\t.maxlen\t\t= sizeof(int),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= brnf_sysctl_call_tables,\n\t},\n\t{\n\t\t.procname\t= \"bridge-nf-filter-pppoe-tagged\",\n\t\t.data\t\t= &brnf_filter_pppoe_tagged,\n\t\t.maxlen\t\t= sizeof(int),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= brnf_sysctl_call_tables,\n\t},\n\t{ }\n};",
"static struct ctl_path brnf_path[] = {\n\t{ .procname = \"net\", },\n\t{ .procname = \"bridge\", },\n\t{ }\n};\n#endif",
"int __init br_netfilter_init(void)\n{\n\tint ret;",
"\tret = dst_entries_init(&fake_dst_ops);\n\tif (ret < 0)\n\t\treturn ret;",
"\tret = nf_register_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));\n\tif (ret < 0) {\n\t\tdst_entries_destroy(&fake_dst_ops);\n\t\treturn ret;\n\t}\n#ifdef CONFIG_SYSCTL\n\tbrnf_sysctl_header = register_sysctl_paths(brnf_path, brnf_table);\n\tif (brnf_sysctl_header == NULL) {\n\t\tprintk(KERN_WARNING\n\t\t \"br_netfilter: can't register to sysctl.\\n\");\n\t\tnf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));\n\t\tdst_entries_destroy(&fake_dst_ops);\n\t\treturn -ENOMEM;\n\t}\n#endif\n\tprintk(KERN_NOTICE \"Bridge firewalling registered\\n\");\n\treturn 0;\n}",
"void br_netfilter_fini(void)\n{\n\tnf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));\n#ifdef CONFIG_SYSCTL\n\tunregister_sysctl_table(brnf_sysctl_header);\n#endif\n\tdst_entries_destroy(&fake_dst_ops);\n}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [257], "buggy_code_start_loc": [252], "filenames": ["net/bridge/br_netfilter.c"], "fixing_code_end_loc": [254], "fixing_code_start_loc": [252], "message": "The br_parse_ip_options function in net/bridge/br_netfilter.c in the Linux kernel before 2.6.39 does not properly initialize a certain data structure, which allows remote attackers to cause a denial of service by leveraging connectivity to a network interface that uses an Ethernet bridge device.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "176353CE-F17E-4776-AD9F-19014DA75B76", "versionEndExcluding": "2.6.39", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "The br_parse_ip_options function in net/bridge/br_netfilter.c in the Linux kernel before 2.6.39 does not properly initialize a certain data structure, which allows remote attackers to cause a denial of service by leveraging connectivity to a network interface that uses an Ethernet bridge device."}, {"lang": "es", "value": "La funci\u00f3n br_parse_ip_options en net/bridge/br_netfilter.c de los kernel Linux anteriores a v2.6.39 no inicia adecuadamente cierta estructura de datos, permitiendo que atacantes remotos provoquen denegaciones de servicio mediante la indicaci\u00f3n de conexi\u00f3n a un interfaz de red que usa un dispositivo bridge Ethernet."}], "evaluatorComment": null, "id": "CVE-2011-4087", "lastModified": "2020-07-27T19:57:08.700", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:N/AC:M/Au:N/C:N/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": false}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2013-06-08T13:05:55.210", "references": [{"source": "secalert@redhat.com", "tags": ["Third Party Advisory"], "url": "http://ftp.osuosl.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39"}, {"source": "secalert@redhat.com", "tags": ["Exploit", "Patch", "Vendor Advisory"], "url": "http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f8e9881c2aef1e982e5abc25c046820cd0b7cf64"}, {"source": "secalert@redhat.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2011/10/28/14"}, {"source": "secalert@redhat.com", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://github.com/torvalds/linux/commit/f8e9881c2aef1e982e5abc25c046820cd0b7cf64"}], "sourceIdentifier": "secalert@redhat.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-665"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/f8e9881c2aef1e982e5abc25c046820cd0b7cf64"}, "type": "CWE-665"}
| 371
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\nnamespace PFBC;",
"abstract class Base {\n\tpublic function configure(array $properties = null) {\n if(!empty($properties)) {\n\t\t\t$class = get_class($this);",
"\t\t\t/*The property_reference lookup array is created so that properties can be set\n\t\t\tcase-insensitively.*/\n $available = array_keys(get_class_vars($class));\n $property_reference = array();\n foreach($available as $property)\n $property_reference[strtolower($property)] = $property;",
"\t\t\t/*The method reference lookup array is created so that \"set\" methods can be called\n\t\t\tcase-insensitively.*/\n $available = get_class_methods($class);\n $method_reference = array();\n foreach($available as $method)\n $method_reference[strtolower($method)] = $method;\n\t\t\t\n foreach($properties as $property => $value) {\n\t\t\t\t$property = strtolower($property);\n\t\t\t\t/*The attributes property cannot be set directly.*/\n\t\t\t\tif($property != \"attributes\") {\n\t\t\t\t\t/*If the appropriate class has a \"set\" method for the property provided, then\n\t\t\t\t\tit is called instead or setting the property directly.*/\n\t\t\t\t\tif(isset($method_reference[\"set\" . $property]))\n\t\t\t\t\t\t$this->$method_reference[\"set\" . $property]($value);\n\t\t\t\t\telseif(isset($property_reference[$property]))\n\t\t\t\t\t\t$this->$property_reference[$property] = $value;\n\t\t\t\t\t/*Entries that don't match an available class property are stored in the attributes\n\t\t\t\t\tproperty if applicable. Typically, these entries will be element attributes such as\n\t\t\t\t\tclass, value, onkeyup, etc.*/\n\t\t\t\t\telseif(isset($property_reference[\"attributes\"]))\n\t\t\t\t\t\t$this->attributes[$property] = $value;\n\t\t\t\t}\n }\n }\n return $this;\n }",
"\t/*This method can be used to view a class' state.*/\n\tpublic function debug() {\n\t\techo \"<pre>\", print_r($this, true), \"</pre>\";\n\t}",
"\t/*This method prevents double/single quotes in html attributes from breaking the markup.*/\n\tprotected function filter($str) {",
"\t\treturn str_replace('\"', '"', $str);",
"\t}",
"\t/*This method is used by the Form class and all Element classes to return a string of html\n\tattributes. There is an ignore parameter that allows special attributes from being included.*/\n\tpublic function getAttributes($ignore = \"\") {\n $str = \"\";\n\t\tif(!empty($this->attributes)) {\n\t\t\tif(!is_array($ignore))\n\t\t\t\t$ignore = array($ignore);\n\t\t\t$attributes = array_diff(array_keys($this->attributes), $ignore);\n\t\t\tforeach($attributes as $attribute) {\n\t\t\t\t$str .= ' ' . $attribute;\n\t\t\t\tif($this->attributes[$attribute] !== \"\")\n\t\t\t\t\t$str .= '=\"' . $this->filter($this->attributes[$attribute]) . '\"';\n\t\t\t}\t\n\t\t}\t\n return $str;\n }\n}\n?>"
] |
[
1,
1,
1,
1,
1,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [52, 11], "buggy_code_start_loc": [51, 10], "filenames": ["PFBC/Base.php", "PFBC/Element/Textarea.php"], "fixing_code_end_loc": [52, 11], "fixing_code_start_loc": [51, 10], "message": "A vulnerability has been found in manikandan170890 php-form-builder-class and classified as problematic. Affected by this vulnerability is an unknown functionality of the file PFBC/Element/Textarea.php of the component Textarea Handler. The manipulation of the argument value leads to cross site scripting. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The name of the patch is 74897993818d826595fd5857038e6703456a594a. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218155.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:php-form-builder-class_project:php-form-builder-class:*:*:*:*:*:*:*:*", "matchCriteriaId": "B6319B4F-2112-4469-A599-72FEB25A7E26", "versionEndExcluding": "2012-11-22", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability has been found in manikandan170890 php-form-builder-class and classified as problematic. Affected by this vulnerability is an unknown functionality of the file PFBC/Element/Textarea.php of the component Textarea Handler. The manipulation of the argument value leads to cross site scripting. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The name of the patch is 74897993818d826595fd5857038e6703456a594a. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218155."}], "evaluatorComment": null, "id": "CVE-2012-10005", "lastModified": "2023-01-20T20:10:42.567", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 4.0, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:S/C:N/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.1, "impactScore": 1.4, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-12T16:15:09.257", "references": [{"source": "cna@vuldb.com", "tags": ["Exploit", "Third Party Advisory"], "url": "https://code.google.com/archive/p/php-form-builder-class/issues/184"}, {"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/manikandan170890/php-form-builder-class/commit/74897993818d826595fd5857038e6703456a594a"}, {"source": "cna@vuldb.com", "tags": ["Permissions Required", "Third Party Advisory"], "url": "https://vuldb.com/?ctiid.218155"}, {"source": "cna@vuldb.com", "tags": ["Permissions Required", "Third Party Advisory"], "url": "https://vuldb.com/?id.218155"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "cna@vuldb.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/manikandan170890/php-form-builder-class/commit/74897993818d826595fd5857038e6703456a594a"}, "type": "CWE-79"}
| 372
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\nnamespace PFBC;",
"abstract class Base {\n\tpublic function configure(array $properties = null) {\n if(!empty($properties)) {\n\t\t\t$class = get_class($this);",
"\t\t\t/*The property_reference lookup array is created so that properties can be set\n\t\t\tcase-insensitively.*/\n $available = array_keys(get_class_vars($class));\n $property_reference = array();\n foreach($available as $property)\n $property_reference[strtolower($property)] = $property;",
"\t\t\t/*The method reference lookup array is created so that \"set\" methods can be called\n\t\t\tcase-insensitively.*/\n $available = get_class_methods($class);\n $method_reference = array();\n foreach($available as $method)\n $method_reference[strtolower($method)] = $method;\n\t\t\t\n foreach($properties as $property => $value) {\n\t\t\t\t$property = strtolower($property);\n\t\t\t\t/*The attributes property cannot be set directly.*/\n\t\t\t\tif($property != \"attributes\") {\n\t\t\t\t\t/*If the appropriate class has a \"set\" method for the property provided, then\n\t\t\t\t\tit is called instead or setting the property directly.*/\n\t\t\t\t\tif(isset($method_reference[\"set\" . $property]))\n\t\t\t\t\t\t$this->$method_reference[\"set\" . $property]($value);\n\t\t\t\t\telseif(isset($property_reference[$property]))\n\t\t\t\t\t\t$this->$property_reference[$property] = $value;\n\t\t\t\t\t/*Entries that don't match an available class property are stored in the attributes\n\t\t\t\t\tproperty if applicable. Typically, these entries will be element attributes such as\n\t\t\t\t\tclass, value, onkeyup, etc.*/\n\t\t\t\t\telseif(isset($property_reference[\"attributes\"]))\n\t\t\t\t\t\t$this->attributes[$property] = $value;\n\t\t\t\t}\n }\n }\n return $this;\n }",
"\t/*This method can be used to view a class' state.*/\n\tpublic function debug() {\n\t\techo \"<pre>\", print_r($this, true), \"</pre>\";\n\t}",
"\t/*This method prevents double/single quotes in html attributes from breaking the markup.*/\n\tprotected function filter($str) {",
"\t\treturn htmlspecialchars($str);",
"\t}",
"\t/*This method is used by the Form class and all Element classes to return a string of html\n\tattributes. There is an ignore parameter that allows special attributes from being included.*/\n\tpublic function getAttributes($ignore = \"\") {\n $str = \"\";\n\t\tif(!empty($this->attributes)) {\n\t\t\tif(!is_array($ignore))\n\t\t\t\t$ignore = array($ignore);\n\t\t\t$attributes = array_diff(array_keys($this->attributes), $ignore);\n\t\t\tforeach($attributes as $attribute) {\n\t\t\t\t$str .= ' ' . $attribute;\n\t\t\t\tif($this->attributes[$attribute] !== \"\")\n\t\t\t\t\t$str .= '=\"' . $this->filter($this->attributes[$attribute]) . '\"';\n\t\t\t}\t\n\t\t}\t\n return $str;\n }\n}\n?>"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [52, 11], "buggy_code_start_loc": [51, 10], "filenames": ["PFBC/Base.php", "PFBC/Element/Textarea.php"], "fixing_code_end_loc": [52, 11], "fixing_code_start_loc": [51, 10], "message": "A vulnerability has been found in manikandan170890 php-form-builder-class and classified as problematic. Affected by this vulnerability is an unknown functionality of the file PFBC/Element/Textarea.php of the component Textarea Handler. The manipulation of the argument value leads to cross site scripting. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The name of the patch is 74897993818d826595fd5857038e6703456a594a. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218155.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:php-form-builder-class_project:php-form-builder-class:*:*:*:*:*:*:*:*", "matchCriteriaId": "B6319B4F-2112-4469-A599-72FEB25A7E26", "versionEndExcluding": "2012-11-22", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability has been found in manikandan170890 php-form-builder-class and classified as problematic. Affected by this vulnerability is an unknown functionality of the file PFBC/Element/Textarea.php of the component Textarea Handler. The manipulation of the argument value leads to cross site scripting. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The name of the patch is 74897993818d826595fd5857038e6703456a594a. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218155."}], "evaluatorComment": null, "id": "CVE-2012-10005", "lastModified": "2023-01-20T20:10:42.567", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 4.0, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:S/C:N/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.1, "impactScore": 1.4, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-12T16:15:09.257", "references": [{"source": "cna@vuldb.com", "tags": ["Exploit", "Third Party Advisory"], "url": "https://code.google.com/archive/p/php-form-builder-class/issues/184"}, {"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/manikandan170890/php-form-builder-class/commit/74897993818d826595fd5857038e6703456a594a"}, {"source": "cna@vuldb.com", "tags": ["Permissions Required", "Third Party Advisory"], "url": "https://vuldb.com/?ctiid.218155"}, {"source": "cna@vuldb.com", "tags": ["Permissions Required", "Third Party Advisory"], "url": "https://vuldb.com/?id.218155"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "cna@vuldb.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/manikandan170890/php-form-builder-class/commit/74897993818d826595fd5857038e6703456a594a"}, "type": "CWE-79"}
| 372
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\nnamespace PFBC\\Element;",
"class Textarea extends \\PFBC\\Element {\n\tprotected $attributes = array(\"rows\" => \"5\");",
"\tpublic function render() {\n echo \"<textarea\", $this->getAttributes(\"value\"), \">\";\n if(!empty($this->attributes[\"value\"]))",
" echo $this->attributes[\"value\"];",
" echo \"</textarea>\";\n }\n}"
] |
[
1,
1,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [52, 11], "buggy_code_start_loc": [51, 10], "filenames": ["PFBC/Base.php", "PFBC/Element/Textarea.php"], "fixing_code_end_loc": [52, 11], "fixing_code_start_loc": [51, 10], "message": "A vulnerability has been found in manikandan170890 php-form-builder-class and classified as problematic. Affected by this vulnerability is an unknown functionality of the file PFBC/Element/Textarea.php of the component Textarea Handler. The manipulation of the argument value leads to cross site scripting. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The name of the patch is 74897993818d826595fd5857038e6703456a594a. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218155.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:php-form-builder-class_project:php-form-builder-class:*:*:*:*:*:*:*:*", "matchCriteriaId": "B6319B4F-2112-4469-A599-72FEB25A7E26", "versionEndExcluding": "2012-11-22", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability has been found in manikandan170890 php-form-builder-class and classified as problematic. Affected by this vulnerability is an unknown functionality of the file PFBC/Element/Textarea.php of the component Textarea Handler. The manipulation of the argument value leads to cross site scripting. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The name of the patch is 74897993818d826595fd5857038e6703456a594a. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218155."}], "evaluatorComment": null, "id": "CVE-2012-10005", "lastModified": "2023-01-20T20:10:42.567", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 4.0, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:S/C:N/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.1, "impactScore": 1.4, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-12T16:15:09.257", "references": [{"source": "cna@vuldb.com", "tags": ["Exploit", "Third Party Advisory"], "url": "https://code.google.com/archive/p/php-form-builder-class/issues/184"}, {"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/manikandan170890/php-form-builder-class/commit/74897993818d826595fd5857038e6703456a594a"}, {"source": "cna@vuldb.com", "tags": ["Permissions Required", "Third Party Advisory"], "url": "https://vuldb.com/?ctiid.218155"}, {"source": "cna@vuldb.com", "tags": ["Permissions Required", "Third Party Advisory"], "url": "https://vuldb.com/?id.218155"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "cna@vuldb.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/manikandan170890/php-form-builder-class/commit/74897993818d826595fd5857038e6703456a594a"}, "type": "CWE-79"}
| 372
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\nnamespace PFBC\\Element;",
"class Textarea extends \\PFBC\\Element {\n\tprotected $attributes = array(\"rows\" => \"5\");",
"\tpublic function render() {\n echo \"<textarea\", $this->getAttributes(\"value\"), \">\";\n if(!empty($this->attributes[\"value\"]))",
" echo $this->filter($this->attributes[\"value\"]);",
" echo \"</textarea>\";\n }\n}"
] |
[
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [52, 11], "buggy_code_start_loc": [51, 10], "filenames": ["PFBC/Base.php", "PFBC/Element/Textarea.php"], "fixing_code_end_loc": [52, 11], "fixing_code_start_loc": [51, 10], "message": "A vulnerability has been found in manikandan170890 php-form-builder-class and classified as problematic. Affected by this vulnerability is an unknown functionality of the file PFBC/Element/Textarea.php of the component Textarea Handler. The manipulation of the argument value leads to cross site scripting. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The name of the patch is 74897993818d826595fd5857038e6703456a594a. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218155.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:php-form-builder-class_project:php-form-builder-class:*:*:*:*:*:*:*:*", "matchCriteriaId": "B6319B4F-2112-4469-A599-72FEB25A7E26", "versionEndExcluding": "2012-11-22", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability has been found in manikandan170890 php-form-builder-class and classified as problematic. Affected by this vulnerability is an unknown functionality of the file PFBC/Element/Textarea.php of the component Textarea Handler. The manipulation of the argument value leads to cross site scripting. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The name of the patch is 74897993818d826595fd5857038e6703456a594a. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-218155."}], "evaluatorComment": null, "id": "CVE-2012-10005", "lastModified": "2023-01-20T20:10:42.567", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 4.0, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:S/C:N/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 2.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.1, "impactScore": 1.4, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.1, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 2.7, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-12T16:15:09.257", "references": [{"source": "cna@vuldb.com", "tags": ["Exploit", "Third Party Advisory"], "url": "https://code.google.com/archive/p/php-form-builder-class/issues/184"}, {"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/manikandan170890/php-form-builder-class/commit/74897993818d826595fd5857038e6703456a594a"}, {"source": "cna@vuldb.com", "tags": ["Permissions Required", "Third Party Advisory"], "url": "https://vuldb.com/?ctiid.218155"}, {"source": "cna@vuldb.com", "tags": ["Permissions Required", "Third Party Advisory"], "url": "https://vuldb.com/?id.218155"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-79"}], "source": "cna@vuldb.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/manikandan170890/php-form-builder-class/commit/74897993818d826595fd5857038e6703456a594a"}, "type": "CWE-79"}
| 372
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.