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 * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\DataFixtures\\UserFixtures;\nuse App\\Entity\\Configuration;\nuse App\\Entity\\User;\nuse App\\Repository\\ConfigurationRepository;\nuse App\\Repository\\UserRepository;\nuse App\\Tests\\KernelTestTrait;\nuse Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase;\nuse Symfony\\Component\\HttpFoundation\\BinaryFileResponse;\nuse Symfony\\Component\\HttpFoundation\\RedirectResponse;\nuse Symfony\\Component\\HttpFoundation\\Test\\Constraint as ResponseConstraint;\nuse Symfony\\Component\\HttpKernel\\HttpKernelBrowser;",
"/**\n * ControllerBaseTest adds some useful functions for writing integration tests.\n */\nabstract class ControllerBaseTest extends WebTestCase\n{\n use KernelTestTrait;",
" public const DEFAULT_LANGUAGE = 'en';",
" protected function tearDown(): void\n {\n $this->clearConfigCache();\n parent::tearDown();\n }",
" /**\n * Using a special container, to access private services as well.\n *\n * @param string $service\n * @return object|null\n * @see https://symfony.com/blog/new-in-symfony-4-1-simpler-service-testing\n */\n protected function getPrivateService(string $service)\n {\n return self::$container->get($service);\n }",
" protected function loadUserFromDatabase(string $username)\n {\n $container = self::$kernel->getContainer();\n /** @var UserRepository $userRepository */\n $userRepository = $container->get('doctrine')->getRepository(User::class);\n $user = $userRepository->loadUserByUsername($username);\n self::assertInstanceOf(User::class, $user);",
" return $user;\n }",
" protected function setSystemConfiguration(string $name, $value): void\n {\n $repository = static::$kernel->getContainer()->get(ConfigurationRepository::class);",
" $entity = $repository->findOneBy(['name' => $name]);\n if ($entity === null) {\n $entity = new Configuration();\n $entity->setName($name);\n }\n $entity->setValue($value);\n $repository->saveConfiguration($entity);\n $this->clearConfigCache();\n }",
" protected function clearConfigCache()\n {\n /** @var ConfigurationRepository $repository */\n $repository = static::$kernel->getContainer()->get(ConfigurationRepository::class);\n $repository->clearCache();\n }",
" protected function getClientForAuthenticatedUser(string $role = User::ROLE_USER): HttpKernelBrowser\n {\n switch ($role) {\n case User::ROLE_SUPER_ADMIN:\n $client = self::createClient([], [\n 'PHP_AUTH_USER' => UserFixtures::USERNAME_SUPER_ADMIN,\n 'PHP_AUTH_PW' => UserFixtures::DEFAULT_PASSWORD,\n ]);\n break;",
" case User::ROLE_ADMIN:\n $client = self::createClient([], [\n 'PHP_AUTH_USER' => UserFixtures::USERNAME_ADMIN,\n 'PHP_AUTH_PW' => UserFixtures::DEFAULT_PASSWORD,\n ]);\n break;",
" case User::ROLE_TEAMLEAD:\n $client = self::createClient([], [\n 'PHP_AUTH_USER' => UserFixtures::USERNAME_TEAMLEAD,\n 'PHP_AUTH_PW' => UserFixtures::DEFAULT_PASSWORD,\n ]);\n break;",
" case User::ROLE_USER:\n $client = self::createClient([], [\n 'PHP_AUTH_USER' => UserFixtures::USERNAME_USER,\n 'PHP_AUTH_PW' => UserFixtures::DEFAULT_PASSWORD,\n ]);\n break;",
" default:\n $client = null;\n break;\n }",
" return $client;\n }",
" protected function createUrl(string $url): string\n {\n return '/' . self::DEFAULT_LANGUAGE . '/' . ltrim($url, '/');\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string $url\n * @param string $method\n * @param array $parameters\n * @param string $content\n * @return \\Symfony\\Component\\DomCrawler\\Crawler\n */\n protected function request(HttpKernelBrowser $client, string $url, $method = 'GET', array $parameters = [], string $content = null)\n {\n return $client->request($method, $this->createUrl($url), $parameters, [], [], $content);\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string $url\n * @param string $method\n */\n protected function assertRequestIsSecured(HttpKernelBrowser $client, string $url, ?string $method = 'GET')\n {\n $this->request($client, $url, $method);",
" /** @var RedirectResponse $response */\n $response = $client->getResponse();\n self::assertInstanceOf(RedirectResponse::class, $response);",
" self::assertTrue(\n $response->isRedirect(),\n sprintf('The secure URL %s is not protected.', $url)\n );",
" self::assertStringEndsWith(\n '/login',\n $response->getTargetUrl(),\n sprintf('The secure URL %s does not redirect to the login form.', $url)\n );\n }",
" protected function assertSuccessResponse(HttpKernelBrowser $client, string $message = '')\n {\n $response = $client->getResponse();\n self::assertThat($response, new ResponseConstraint\\ResponseIsSuccessful(), 'Response is not successful, got code: ' . $response->getStatusCode());\n }",
" /**\n * @param string $url\n * @param string $method\n */\n protected function assertUrlIsSecured(string $url, $method = 'GET')\n {\n $client = self::createClient();\n $this->assertRequestIsSecured($client, $url, $method);\n }",
" /**\n * @param string $role\n * @param string $url\n * @param string $method\n */\n protected function assertUrlIsSecuredForRole(string $role, string $url, string $method = 'GET')\n {\n $client = $this->getClientForAuthenticatedUser($role);\n $client->request($method, $this->createUrl($url));\n self::assertFalse(\n $client->getResponse()->isSuccessful(),\n sprintf('The secure URL %s is not protected for role %s', $url, $role)\n );\n $this->assertAccessDenied($client);\n }",
" protected function assertAccessDenied(HttpKernelBrowser $client)\n {\n self::assertFalse(\n $client->getResponse()->isSuccessful(),\n 'Access is not denied for URL: ' . $client->getRequest()->getUri()\n );\n self::assertStringContainsString(\n 'Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException',\n $client->getResponse()->getContent(),\n 'Could not find AccessDeniedException in response'\n );\n }",
" protected function assertAccessIsGranted(HttpKernelBrowser $client, string $url, string $method = 'GET', array $parameters = [])\n {\n $this->request($client, $url, $method, $parameters);\n self::assertTrue($client->getResponse()->isSuccessful());\n }",
" protected function assertRouteNotFound(HttpKernelBrowser $client)\n {\n self::assertFalse($client->getResponse()->isSuccessful());\n self::assertEquals(404, $client->getResponse()->getStatusCode());\n }",
" protected function assertMainContentClass(HttpKernelBrowser $client, string $classname)\n {\n self::assertStringContainsString('<section class=\"content ' . $classname . '\">', $client->getResponse()->getContent());\n }",
" /**\n * @param HttpKernelBrowser $client\n */\n protected function assertHasDataTable(HttpKernelBrowser $client)\n {\n self::assertStringContainsString('<table class=\"table table-hover dataTable\" role=\"grid\" data-reload-event=\"', $client->getResponse()->getContent());\n }",
" /**\n * @param HttpKernelBrowser $client\n */\n protected static function assertHasProgressbar(HttpKernelBrowser $client)\n {\n $content = $client->getResponse()->getContent();\n self::assertStringContainsString('<div class=\"progress-bar progress-bar-', $content);\n self::assertStringContainsString('\" role=\"progressbar\" aria-valuenow=\"', $content);\n self::assertStringContainsString('\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: ', $content);\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string $class\n * @param int $count\n */\n protected function assertDataTableRowCount(HttpKernelBrowser $client, string $class, int $count)\n {\n $node = $client->getCrawler()->filter('section.content div.' . $class . ' table.dataTable tbody tr:not(.summary)');\n self::assertEquals($count, $node->count());\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param array $buttons\n */\n protected function assertPageActions(HttpKernelBrowser $client, array $buttons)\n {\n $node = $client->getCrawler()->filter('section.content-header div.breadcrumb div.box-tools div.btn-group a');",
" /** @var \\DOMElement $element */\n foreach ($node->getIterator() as $element) {\n $expectedClass = str_replace('btn btn-default btn-', '', $element->getAttribute('class'));\n self::assertArrayHasKey($expectedClass, $buttons);\n $expectedUrl = $buttons[$expectedClass];\n self::assertEquals($expectedUrl, $element->getAttribute('href'));\n }",
" self::assertEquals(\\count($buttons), $node->count(), 'Invalid amount of page actions');\n }",
" /**\n * @param HttpKernelBrowser $client the client to use\n * @param string $url the URL of the page displaying the initial form to submit\n * @param string $formSelector a selector to find the form to test\n * @param array $formData values to fill in the form\n * @param array $fieldNames array of form-fields that should fail\n * @param bool $disableValidation whether the form should validate before submitting or not\n */\n protected function assertHasValidationError(HttpKernelBrowser $client, $url, $formSelector, array $formData, array $fieldNames, $disableValidation = true)\n {\n $crawler = $client->request('GET', $this->createUrl($url));\n $form = $crawler->filter($formSelector)->form();\n if ($disableValidation) {\n $form->disableValidation();\n }\n $result = $client->submit($form, $formData);",
" $submittedForm = $result->filter($formSelector);\n $validationErrors = $submittedForm->filter('li.text-danger');",
" self::assertEquals(\n \\count($fieldNames),\n \\count($validationErrors),\n sprintf('Expected %s validation errors, found %s', \\count($fieldNames), \\count($validationErrors))\n );",
" foreach ($fieldNames as $name) {\n $field = $submittedForm->filter($name);\n self::assertNotNull($field, 'Could not find form field: ' . $name);\n $list = $field->nextAll();\n self::assertNotNull($list, 'Form field has no validation message: ' . $name);",
" $validation = $list->filter('li.text-danger');\n if (\\count($validation) < 1) {\n // decorated form fields with icon have a different html structure, see kimai-theme.html.twig\n /** @var \\DOMElement $listMsg */\n $listMsg = $field->parents()->getNode(1);\n $classes = $listMsg->getAttribute('class');\n self::assertStringContainsString('has-error', $classes, 'Form field has no validation message: ' . $name);\n }\n }\n }",
" /**\n * @param string $role the USER role to use for the request\n * @param string $url the URL of the page displaying the initial form to submit\n * @param string $formSelector a selector to find the form to test\n * @param array $formData values to fill in the form\n * @param array $fieldNames array of form-fields that should fail\n * @param bool $disableValidation whether the form should validate before submitting or not\n */\n protected function assertFormHasValidationError($role, $url, $formSelector, array $formData, array $fieldNames, $disableValidation = true)\n {\n $client = $this->getClientForAuthenticatedUser($role);\n $this->assertHasValidationError($client, $url, $formSelector, $formData, $fieldNames, $disableValidation);\n }",
" /**\n * @param HttpKernelBrowser $client\n */\n protected function assertHasNoEntriesWithFilter(HttpKernelBrowser $client)\n {\n $this->assertCalloutWidgetWithMessage($client, 'No entries were found based on your selected filters.');\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string $message\n */\n protected function assertCalloutWidgetWithMessage(HttpKernelBrowser $client, string $message)\n {\n $node = $client->getCrawler()->filter('div.callout.callout-warning.lead');\n self::assertStringContainsString($message, $node->text(null, true));\n }",
" protected function assertHasFlashDeleteSuccess(HttpKernelBrowser $client)\n {\n $this->assertHasFlashSuccess($client, 'Entry was deleted');\n }",
" protected function assertHasFlashSaveSuccess(HttpKernelBrowser $client)\n {\n $this->assertHasFlashSuccess($client, 'Saved changes');\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string|null $message\n */\n protected function assertHasFlashSuccess(HttpKernelBrowser $client, string $message = null)\n {\n $this->assertHasFlashMessage($client, 'success', $message);\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string|null $message\n */\n protected function assertHasFlashError(HttpKernelBrowser $client, string $message = null)\n {\n $this->assertHasFlashMessage($client, 'error', $message);\n }",
" private function assertHasFlashMessage(HttpKernelBrowser $client, string $type, string $message = null)\n {\n $content = $client->getResponse()->getContent();\n self::assertStringContainsString('ALERT.' . $type . '(\\'', $content, 'Could not find flash ' . $type . ' message');\n if (null !== $message) {\n // this is a lazy workaround, the templates use the javascript escape filter: |e('js')\n // if you ever want to test more complex strings, this logic has to be enhanced\n $message = str_replace([' ', ':'], ['\\u0020', '\\u003A'], $message);\n self::assertStringContainsString($message, $content);\n }\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string $url\n */\n protected function assertIsRedirect(HttpKernelBrowser $client, $url = null)\n {\n self::assertResponseRedirects();",
" if (null === $url) {\n return;\n }",
" $this->assertRedirectUrl($client, $url);\n }",
" protected function assertRedirectUrl(HttpKernelBrowser $client, $url = null, $endsWith = true)\n {\n self::assertTrue($client->getResponse()->headers->has('Location'), 'Could not find \"Location\" header');\n $location = $client->getResponse()->headers->get('Location');",
" if ($endsWith) {\n self::assertStringEndsWith($url, $location, 'Redirect URL does not match');\n } else {\n self::assertStringContainsString($url, $location, 'Redirect URL does not match');\n }\n }",
" protected function assertExcelExportResponse(HttpKernelBrowser $client, string $prefix)\n {\n /** @var BinaryFileResponse $response */\n $response = $client->getResponse();\n self::assertInstanceOf(BinaryFileResponse::class, $response);",
" self::assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type'));\n self::assertStringContainsString('attachment; filename=' . $prefix, $response->headers->get('Content-Disposition'));\n self::assertStringContainsString('.xlsx', $response->headers->get('Content-Disposition'));\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,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\DataFixtures\\UserFixtures;\nuse App\\Entity\\Configuration;\nuse App\\Entity\\User;\nuse App\\Repository\\ConfigurationRepository;\nuse App\\Repository\\UserRepository;\nuse App\\Tests\\KernelTestTrait;\nuse Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase;\nuse Symfony\\Component\\HttpFoundation\\BinaryFileResponse;\nuse Symfony\\Component\\HttpFoundation\\RedirectResponse;\nuse Symfony\\Component\\HttpFoundation\\Test\\Constraint as ResponseConstraint;\nuse Symfony\\Component\\HttpKernel\\HttpKernelBrowser;",
"/**\n * ControllerBaseTest adds some useful functions for writing integration tests.\n */\nabstract class ControllerBaseTest extends WebTestCase\n{\n use KernelTestTrait;",
" public const DEFAULT_LANGUAGE = 'en';",
" protected function tearDown(): void\n {\n $this->clearConfigCache();\n parent::tearDown();\n }",
" /**\n * Using a special container, to access private services as well.\n *\n * @param string $service\n * @return object|null\n * @see https://symfony.com/blog/new-in-symfony-4-1-simpler-service-testing\n */\n protected function getPrivateService(string $service)\n {\n return self::$container->get($service);\n }",
" protected function loadUserFromDatabase(string $username)\n {\n $container = self::$kernel->getContainer();\n /** @var UserRepository $userRepository */\n $userRepository = $container->get('doctrine')->getRepository(User::class);\n $user = $userRepository->loadUserByUsername($username);\n self::assertInstanceOf(User::class, $user);",
" return $user;\n }",
" protected function setSystemConfiguration(string $name, $value): void\n {\n $repository = static::$kernel->getContainer()->get(ConfigurationRepository::class);",
" $entity = $repository->findOneBy(['name' => $name]);\n if ($entity === null) {\n $entity = new Configuration();\n $entity->setName($name);\n }\n $entity->setValue($value);\n $repository->saveConfiguration($entity);\n $this->clearConfigCache();\n }",
" protected function clearConfigCache()\n {\n /** @var ConfigurationRepository $repository */\n $repository = static::$kernel->getContainer()->get(ConfigurationRepository::class);\n $repository->clearCache();\n }",
" protected function getClientForAuthenticatedUser(string $role = User::ROLE_USER): HttpKernelBrowser\n {\n switch ($role) {\n case User::ROLE_SUPER_ADMIN:\n $client = self::createClient([], [\n 'PHP_AUTH_USER' => UserFixtures::USERNAME_SUPER_ADMIN,\n 'PHP_AUTH_PW' => UserFixtures::DEFAULT_PASSWORD,\n ]);\n break;",
" case User::ROLE_ADMIN:\n $client = self::createClient([], [\n 'PHP_AUTH_USER' => UserFixtures::USERNAME_ADMIN,\n 'PHP_AUTH_PW' => UserFixtures::DEFAULT_PASSWORD,\n ]);\n break;",
" case User::ROLE_TEAMLEAD:\n $client = self::createClient([], [\n 'PHP_AUTH_USER' => UserFixtures::USERNAME_TEAMLEAD,\n 'PHP_AUTH_PW' => UserFixtures::DEFAULT_PASSWORD,\n ]);\n break;",
" case User::ROLE_USER:\n $client = self::createClient([], [\n 'PHP_AUTH_USER' => UserFixtures::USERNAME_USER,\n 'PHP_AUTH_PW' => UserFixtures::DEFAULT_PASSWORD,\n ]);\n break;",
" default:\n $client = null;\n break;\n }",
" return $client;\n }",
" protected function createUrl(string $url): string\n {\n return '/' . self::DEFAULT_LANGUAGE . '/' . ltrim($url, '/');\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string $url\n * @param string $method\n * @param array $parameters\n * @param string $content\n * @return \\Symfony\\Component\\DomCrawler\\Crawler\n */\n protected function request(HttpKernelBrowser $client, string $url, $method = 'GET', array $parameters = [], string $content = null)\n {\n return $client->request($method, $this->createUrl($url), $parameters, [], [], $content);\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string $url\n * @param string $method\n */\n protected function assertRequestIsSecured(HttpKernelBrowser $client, string $url, ?string $method = 'GET')\n {\n $this->request($client, $url, $method);",
" /** @var RedirectResponse $response */\n $response = $client->getResponse();\n self::assertInstanceOf(RedirectResponse::class, $response);",
" self::assertTrue(\n $response->isRedirect(),\n sprintf('The secure URL %s is not protected.', $url)\n );",
" self::assertStringEndsWith(\n '/login',\n $response->getTargetUrl(),\n sprintf('The secure URL %s does not redirect to the login form.', $url)\n );\n }",
" protected function assertSuccessResponse(HttpKernelBrowser $client, string $message = '')\n {\n $response = $client->getResponse();\n self::assertThat($response, new ResponseConstraint\\ResponseIsSuccessful(), 'Response is not successful, got code: ' . $response->getStatusCode());\n }",
" /**\n * @param string $url\n * @param string $method\n */\n protected function assertUrlIsSecured(string $url, $method = 'GET')\n {\n $client = self::createClient();\n $this->assertRequestIsSecured($client, $url, $method);\n }",
" /**\n * @param string $role\n * @param string $url\n * @param string $method\n */\n protected function assertUrlIsSecuredForRole(string $role, string $url, string $method = 'GET')\n {\n $client = $this->getClientForAuthenticatedUser($role);\n $client->request($method, $this->createUrl($url));\n self::assertFalse(\n $client->getResponse()->isSuccessful(),\n sprintf('The secure URL %s is not protected for role %s', $url, $role)\n );\n $this->assertAccessDenied($client);\n }",
" protected function assertAccessDenied(HttpKernelBrowser $client)\n {\n self::assertFalse(\n $client->getResponse()->isSuccessful(),\n 'Access is not denied for URL: ' . $client->getRequest()->getUri()\n );\n self::assertStringContainsString(\n 'Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException',\n $client->getResponse()->getContent(),\n 'Could not find AccessDeniedException in response'\n );\n }",
" protected function assertAccessIsGranted(HttpKernelBrowser $client, string $url, string $method = 'GET', array $parameters = [])\n {\n $this->request($client, $url, $method, $parameters);\n self::assertTrue($client->getResponse()->isSuccessful());\n }",
" protected function assertRouteNotFound(HttpKernelBrowser $client)\n {\n self::assertFalse($client->getResponse()->isSuccessful());\n self::assertEquals(404, $client->getResponse()->getStatusCode());\n }",
" protected function assertMainContentClass(HttpKernelBrowser $client, string $classname)\n {\n self::assertStringContainsString('<section class=\"content ' . $classname . '\">', $client->getResponse()->getContent());\n }",
" /**\n * @param HttpKernelBrowser $client\n */\n protected function assertHasDataTable(HttpKernelBrowser $client)\n {\n self::assertStringContainsString('<table class=\"table table-hover dataTable\" role=\"grid\" data-reload-event=\"', $client->getResponse()->getContent());\n }",
" /**\n * @param HttpKernelBrowser $client\n */\n protected static function assertHasProgressbar(HttpKernelBrowser $client)\n {\n $content = $client->getResponse()->getContent();\n self::assertStringContainsString('<div class=\"progress-bar progress-bar-', $content);\n self::assertStringContainsString('\" role=\"progressbar\" aria-valuenow=\"', $content);\n self::assertStringContainsString('\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: ', $content);\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string $class\n * @param int $count\n */\n protected function assertDataTableRowCount(HttpKernelBrowser $client, string $class, int $count)\n {\n $node = $client->getCrawler()->filter('section.content div.' . $class . ' table.dataTable tbody tr:not(.summary)');\n self::assertEquals($count, $node->count());\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param array $buttons\n */\n protected function assertPageActions(HttpKernelBrowser $client, array $buttons)\n {\n $node = $client->getCrawler()->filter('section.content-header div.breadcrumb div.box-tools div.btn-group a');",
" /** @var \\DOMElement $element */\n foreach ($node->getIterator() as $element) {\n $expectedClass = str_replace('btn btn-default btn-', '', $element->getAttribute('class'));\n self::assertArrayHasKey($expectedClass, $buttons);\n $expectedUrl = $buttons[$expectedClass];\n self::assertEquals($expectedUrl, $element->getAttribute('href'));\n }",
" self::assertEquals(\\count($buttons), $node->count(), 'Invalid amount of page actions');\n }",
" /**\n * @param HttpKernelBrowser $client the client to use\n * @param string $url the URL of the page displaying the initial form to submit\n * @param string $formSelector a selector to find the form to test\n * @param array $formData values to fill in the form\n * @param array $fieldNames array of form-fields that should fail\n * @param bool $disableValidation whether the form should validate before submitting or not\n */\n protected function assertHasValidationError(HttpKernelBrowser $client, $url, $formSelector, array $formData, array $fieldNames, $disableValidation = true)\n {\n $crawler = $client->request('GET', $this->createUrl($url));\n $form = $crawler->filter($formSelector)->form();\n if ($disableValidation) {\n $form->disableValidation();\n }\n $result = $client->submit($form, $formData);",
" $submittedForm = $result->filter($formSelector);\n $validationErrors = $submittedForm->filter('li.text-danger');",
" self::assertEquals(\n \\count($fieldNames),\n \\count($validationErrors),\n sprintf('Expected %s validation errors, found %s', \\count($fieldNames), \\count($validationErrors))\n );",
" foreach ($fieldNames as $name) {\n $field = $submittedForm->filter($name);\n self::assertNotNull($field, 'Could not find form field: ' . $name);\n $list = $field->nextAll();\n self::assertNotNull($list, 'Form field has no validation message: ' . $name);",
" $validation = $list->filter('li.text-danger');\n if (\\count($validation) < 1) {\n // decorated form fields with icon have a different html structure, see kimai-theme.html.twig\n /** @var \\DOMElement $listMsg */\n $listMsg = $field->parents()->getNode(1);\n $classes = $listMsg->getAttribute('class');\n self::assertStringContainsString('has-error', $classes, 'Form field has no validation message: ' . $name);\n }\n }\n }",
" /**\n * @param string $role the USER role to use for the request\n * @param string $url the URL of the page displaying the initial form to submit\n * @param string $formSelector a selector to find the form to test\n * @param array $formData values to fill in the form\n * @param array $fieldNames array of form-fields that should fail\n * @param bool $disableValidation whether the form should validate before submitting or not\n */\n protected function assertFormHasValidationError($role, $url, $formSelector, array $formData, array $fieldNames, $disableValidation = true)\n {\n $client = $this->getClientForAuthenticatedUser($role);\n $this->assertHasValidationError($client, $url, $formSelector, $formData, $fieldNames, $disableValidation);\n }",
" /**\n * @param HttpKernelBrowser $client\n */\n protected function assertHasNoEntriesWithFilter(HttpKernelBrowser $client)\n {\n $this->assertCalloutWidgetWithMessage($client, 'No entries were found based on your selected filters.');\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string $message\n */\n protected function assertCalloutWidgetWithMessage(HttpKernelBrowser $client, string $message)\n {\n $node = $client->getCrawler()->filter('div.callout.callout-warning.lead');\n self::assertStringContainsString($message, $node->text(null, true));\n }",
" protected function assertHasFlashDeleteSuccess(HttpKernelBrowser $client)\n {\n $this->assertHasFlashSuccess($client, 'Entry was deleted');\n }",
" protected function assertHasFlashSaveSuccess(HttpKernelBrowser $client)\n {\n $this->assertHasFlashSuccess($client, 'Saved changes');\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string|null $message\n */\n protected function assertHasFlashSuccess(HttpKernelBrowser $client, string $message = null)\n {\n $this->assertHasFlashMessage($client, 'success', $message);\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string|null $message\n */\n protected function assertHasFlashError(HttpKernelBrowser $client, string $message = null)\n {\n $this->assertHasFlashMessage($client, 'error', $message);\n }",
" private function assertHasFlashMessage(HttpKernelBrowser $client, string $type, string $message = null)\n {\n $content = $client->getResponse()->getContent();\n self::assertStringContainsString('ALERT.' . $type . '(\\'', $content, 'Could not find flash ' . $type . ' message');\n if (null !== $message) {\n // this is a lazy workaround, the templates use the javascript escape filter: |e('js')\n // if you ever want to test more complex strings, this logic has to be enhanced\n $message = str_replace([' ', ':'], ['\\u0020', '\\u003A'], $message);\n self::assertStringContainsString($message, $content);\n }\n }",
" /**\n * @param HttpKernelBrowser $client\n * @param string $url\n */\n protected function assertIsRedirect(HttpKernelBrowser $client, $url = null)\n {\n self::assertResponseRedirects();",
" if (null === $url) {\n return;\n }",
" $this->assertRedirectUrl($client, $url);\n }",
" protected function assertRedirectUrl(HttpKernelBrowser $client, $url = null, $endsWith = true)\n {\n self::assertTrue($client->getResponse()->headers->has('Location'), 'Could not find \"Location\" header');\n $location = $client->getResponse()->headers->get('Location');",
" if ($endsWith) {\n self::assertStringEndsWith($url, $location, 'Redirect URL does not match');\n } else {\n self::assertStringContainsString($url, $location, 'Redirect URL does not match');\n }\n }",
" protected function assertExcelExportResponse(HttpKernelBrowser $client, string $prefix)\n {\n /** @var BinaryFileResponse $response */\n $response = $client->getResponse();\n self::assertInstanceOf(BinaryFileResponse::class, $response);",
" self::assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type'));\n self::assertStringContainsString('attachment; filename=' . $prefix, $response->headers->get('Content-Disposition'));\n self::assertStringContainsString('.xlsx', $response->headers->get('Content-Disposition'));\n }",
"\n protected function assertInvalidCsrfToken(HttpKernelBrowser $client, string $url, string $expectedRedirect)\n {\n $this->request($client, $url);",
" $this->assertIsRedirect($client);\n $this->assertRedirectUrl($client, $expectedRedirect);\n $client->followRedirect();\n $this->assertHasFlashError($client, 'The action could not be performed: invalid security token.');\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\Entity\\User;",
"/**\n * @group integration\n */\nclass DoctorControllerTest extends ControllerBaseTest\n{\n public function testDoctorIsSecure()\n {\n $this->assertUrlIsSecured('/doctor');\n }",
" public function testDoctorIsSecureForRole()\n {\n $this->assertUrlIsSecuredForRole(User::ROLE_ADMIN, '/doctor');\n }",
" public function testIndexAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);\n $this->assertAccessIsGranted($client, '/doctor');",
" $result = $client->getCrawler()->filter('.content .box-header');\n self::assertCount(6, $result);\n }",
"",
"}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\Entity\\User;",
"/**\n * @group integration\n */\nclass DoctorControllerTest extends ControllerBaseTest\n{\n public function testDoctorIsSecure()\n {\n $this->assertUrlIsSecured('/doctor');\n }",
" public function testDoctorIsSecureForRole()\n {\n $this->assertUrlIsSecuredForRole(User::ROLE_ADMIN, '/doctor');\n }",
" public function testIndexAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);\n $this->assertAccessIsGranted($client, '/doctor');",
" $result = $client->getCrawler()->filter('.content .box-header');\n self::assertCount(6, $result);\n }",
"\n public function testFlushLogWithInvalidCsrf()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);",
" $this->assertInvalidCsrfToken($client, '/doctor/flush-log/rsetdzfukgli78t6r5uedtjfzkugl', $this->createUrl('/doctor'));\n }",
"}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\Entity\\Activity;\nuse App\\Entity\\ActivityMeta;\nuse App\\Entity\\ActivityRate;\nuse App\\Entity\\Project;\nuse App\\Entity\\ProjectComment;\nuse App\\Entity\\ProjectMeta;\nuse App\\Entity\\ProjectRate;\nuse App\\Entity\\Team;\nuse App\\Entity\\Timesheet;\nuse App\\Entity\\User;\nuse App\\Tests\\DataFixtures\\ActivityFixtures;\nuse App\\Tests\\DataFixtures\\ProjectFixtures;\nuse App\\Tests\\DataFixtures\\TeamFixtures;\nuse App\\Tests\\DataFixtures\\TimesheetFixtures;\nuse App\\Tests\\Mocks\\ProjectTestMetaFieldSubscriberMock;\nuse Doctrine\\ORM\\EntityManager;\nuse Symfony\\Component\\DomCrawler\\Field\\ChoiceFormField;\nuse Symfony\\Component\\HttpKernel\\HttpKernelBrowser;",
"/**\n * @group integration\n */\nclass ProjectControllerTest extends ControllerBaseTest\n{\n public function testIsSecure()\n {\n $this->assertUrlIsSecured('/admin/project/');\n }",
" public function testIsSecureForRole()\n {\n $this->assertUrlIsSecuredForRole(User::ROLE_USER, '/admin/project/');\n }",
" public function testIndexAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);\n $this->assertAccessIsGranted($client, '/admin/project/');\n $this->assertHasDataTable($client);\n }",
" public function testIndexActionWithSearchTermQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $fixture = new ProjectFixtures();\n $fixture->setAmount(5);\n $fixture->setCallback(function (Project $project) {\n $project->setVisible(true);\n $project->setComment('I am a foobar with tralalalala some more content');\n $project->setMetaField((new ProjectMeta())->setName('location')->setValue('homeoffice'));\n $project->setMetaField((new ProjectMeta())->setName('feature')->setValue('timetracking'));\n });\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/project/');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'searchTerm' => 'feature:timetracking foo',\n 'visibility' => 1,\n 'customers' => [1],\n 'pageSize' => 50,\n 'page' => 1,\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_project_admin', 5);\n }",
" public function testExportIsSecureForRole()\n {\n $this->assertUrlIsSecuredForRole(User::ROLE_USER, '/admin/project/export');\n }",
" public function testExportAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);\n $this->assertAccessIsGranted($client, '/admin/project/export');\n $this->assertExcelExportResponse($client, 'kimai-projects_');\n }",
" public function testExportActionWithSearchTermQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $fixture = new ProjectFixtures();\n $fixture->setAmount(5);\n $fixture->setCallback(function (Project $project) {\n $project->setVisible(true);\n $project->setComment('I am a foobar with tralalalala some more content');\n $project->setMetaField((new ProjectMeta())->setName('location')->setValue('homeoffice'));\n $project->setMetaField((new ProjectMeta())->setName('feature')->setValue('timetracking'));\n });\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/project/');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $form->getFormNode()->setAttribute('action', $this->createUrl('/admin/project/export'));\n $client->submit($form, [\n 'searchTerm' => 'feature:timetracking foo',\n 'visibility' => 1,\n 'customers' => [1],\n 'pageSize' => 50,\n 'page' => 1,\n ]);",
" $this->assertExcelExportResponse($client, 'kimai-projects_');\n }",
" public function testDetailsAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n /** @var EntityManager $em */\n $em = $this->getEntityManager();",
" $project = $em->getRepository(Project::class)->find(1);",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setProjects([$project]);\n $fixture->setUser($this->getUserByRole(User::ROLE_ADMIN));\n $this->importFixture($fixture);",
" $project = $em->getRepository(Project::class)->find(1);\n $fixture = new ActivityFixtures();\n $fixture->setAmount(6); // to trigger a second page\n $fixture->setProjects([$project]);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/project/1/details');\n self::assertHasProgressbar($client);",
" $node = $client->getCrawler()->filter('div.box#project_details_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#activity_list_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#time_budget_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#budget_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#team_listing_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#comments_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#team_listing_box a.btn.btn-default');\n self::assertEquals(2, $node->count());\n $node = $client->getCrawler()->filter('div.box#project_rates_box');\n self::assertEquals(1, $node->count());\n }",
" public function testAddRateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAddRate($client, 123.45, 1);\n }",
" protected function assertAddRate(HttpKernelBrowser $client, $rate, $projectId)\n {\n $this->assertAccessIsGranted($client, '/admin/project/' . $projectId . '/rate');\n $form = $client->getCrawler()->filter('form[name=project_rate_form]')->form();\n $client->submit($form, [\n 'project_rate_form' => [\n 'user' => null,\n 'rate' => $rate,\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/' . $projectId . '/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#project_rates_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#project_rates_box table.dataTable tbody tr:not(.summary)');\n self::assertEquals(1, $node->count());\n self::assertStringContainsString($rate, $node->text(null, true));\n }",
" public function testDuplicateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n /** @var EntityManager $em */\n $em = $this->getEntityManager();\n $project = $em->find(Project::class, 1);\n $project->setMetaField((new ProjectMeta())->setName('foo')->setValue('bar'));\n $project->setEnd(new \\DateTime());\n $em->persist($project);\n $team = new Team();\n $team->addTeamlead($this->getUserByRole(User::ROLE_ADMIN));\n $team->addProject($project);\n $team->setName('project 1');\n $em->persist($team);\n $rate = new ProjectRate();\n $rate->setProject($project);\n $rate->setRate(123.45);\n $em->persist($rate);\n $activity = new Activity();\n $activity->setName('blub');\n $activity->setProject($project);\n $activity->setMetaField((new ActivityMeta())->setName('blub')->setValue('blab'));\n $em->persist($activity);\n $rate = new ActivityRate();\n $rate->setActivity($activity);\n $rate->setRate(123.45);\n $em->persist($rate);\n $em->flush();\n",
" $this->request($client, '/admin/project/1/duplicate');",
" $this->assertIsRedirect($client, '/details');\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#project_rates_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#project_rates_box table.dataTable tbody tr:not(.summary)');\n self::assertEquals(1, $node->count());\n self::assertStringContainsString('123.45', $node->text(null, true));",
"",
" }",
" public function testAddCommentAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/details');\n $form = $client->getCrawler()->filter('form[name=project_comment_form]')->form();\n $client->submit($form, [\n 'project_comment_form' => [\n 'message' => 'A beautiful and long comment **with some** markdown formatting',\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text');\n self::assertStringContainsString('<p>A beautiful and long comment <strong>with some</strong> markdown formatting</p>', $node->html());\n }",
" public function testDeleteCommentAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/details');\n $form = $client->getCrawler()->filter('form[name=project_comment_form]')->form();\n $client->submit($form, [\n 'project_comment_form' => [\n 'message' => 'Foo bar blub',\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text');\n self::assertStringContainsString('Foo bar blub', $node->html());\n $node = $client->getCrawler()->filter('div.box#comments_box .box-body a.confirmation-link');",
" $comments = $this->getEntityManager()->getRepository(ProjectComment::class)->findAll();\n $id = $comments[0]->getId();",
" $token = self::$container->get('security.csrf.token_manager')->getToken('project.delete_comment');",
" self::assertEquals($this->createUrl('/admin/project/' . $id . '/comment_delete/' . $token), $node->attr('href'));\n $this->request($client, '/admin/project/' . $id . '/comment_delete/' . $token);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .box-body');\n self::assertStringContainsString('There were no comments posted yet', $node->html());\n }",
" public function testPinCommentAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/details');\n $form = $client->getCrawler()->filter('form[name=project_comment_form]')->form();\n $client->submit($form, [\n 'project_comment_form' => [\n 'message' => 'Foo bar blub',\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text');\n self::assertStringContainsString('Foo bar blub', $node->html());\n $node = $client->getCrawler()->filter('div.box#comments_box .box-body a.btn.active');\n self::assertEquals(0, $node->count());",
" $comments = $this->getEntityManager()->getRepository(ProjectComment::class)->findAll();\n $id = $comments[0]->getId();",
" $token = self::$container->get('security.csrf.token_manager')->getToken('project.pin_comment');",
" $this->request($client, '/admin/project/' . $id . '/comment_pin/' . $token);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .box-body a.btn.active');\n self::assertEquals(1, $node->count());\n self::assertEquals($this->createUrl('/admin/project/' . $id . '/comment_pin/' . $token), $node->attr('href'));\n }",
" public function testCreateDefaultTeamAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/details');\n $node = $client->getCrawler()->filter('div.box#team_listing_box .box-body');\n self::assertStringContainsString('Visible to everyone, as no team was assigned yet.', $node->text(null, true));",
" $this->request($client, '/admin/project/1/create_team');\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#team_listing_box .box-title');\n self::assertStringContainsString('Only visible to the following teams and all admins.', $node->text(null, true));\n $node = $client->getCrawler()->filter('div.box#team_listing_box .box-body table tbody tr');\n self::assertEquals(1, $node->count());",
" // creating the default team a second time fails, as the name already exists\n $this->request($client, '/admin/project/1/create_team');\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $this->assertHasFlashError($client, 'Changes could not be saved: Team already existing');\n }",
" public function testActivitiesAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/activities/1');\n $node = $client->getCrawler()->filter('div.box#activity_list_box .box-tools ul.pagination li');\n self::assertEquals(0, $node->count());\n $node = $client->getCrawler()->filter('div.box#activity_list_box .box-tools a.modal-ajax-form.open-edit');\n self::assertEquals(1, $node->count());",
" /** @var EntityManager $em */\n $em = $this->getEntityManager();\n $project = $em->getRepository(Project::class)->find(1);\n $fixture = new ActivityFixtures();\n $fixture->setAmount(9); // to trigger a second page (every third activity is hidden)\n $fixture->setProjects([$project]);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/project/1/activities/1');",
" $node = $client->getCrawler()->filter('div.box#activity_list_box .box-tools ul.pagination li');\n self::assertEquals(4, $node->count());",
" $node = $client->getCrawler()->filter('div.box#activity_list_box .box-body table tbody tr');\n self::assertEquals(5, $node->count());\n }",
" public function testCreateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/create');\n $form = $client->getCrawler()->filter('form[name=project_edit_form]')->form();\n $client->submit($form, [\n 'project_edit_form' => [\n 'name' => 'Test 2',\n 'customer' => 1,\n ]\n ]);\n $this->assertIsRedirect($client, '/details');\n $client->followRedirect();\n $this->assertHasFlashSuccess($client);\n }",
" public function testCreateActionShowsMetaFields()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n static::$kernel->getContainer()->get('event_dispatcher')->addSubscriber(new ProjectTestMetaFieldSubscriberMock());\n $this->assertAccessIsGranted($client, '/admin/project/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=project_edit_form]')->form();\n $this->assertTrue($form->has('project_edit_form[metaFields][0][value]'));\n $this->assertFalse($form->has('project_edit_form[metaFields][1][value]'));\n }",
" public function testEditAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/edit');\n $form = $client->getCrawler()->filter('form[name=project_edit_form]')->form();\n $this->assertEquals('Test', $form->get('project_edit_form[name]')->getValue());\n $client->submit($form, [\n 'project_edit_form' => ['name' => 'Test 2']\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $this->request($client, '/admin/project/1/edit');\n $editForm = $client->getCrawler()->filter('form[name=project_edit_form]')->form();\n $this->assertEquals('Test 2', $editForm->get('project_edit_form[name]')->getValue());\n }",
" public function testTeamPermissionAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $em = $this->getEntityManager();",
" /** @var Project $project */\n $project = $em->getRepository(Project::class)->find(1);\n self::assertEquals(0, $project->getTeams()->count());",
" $fixture = new TeamFixtures();\n $fixture->setAmount(2);\n $fixture->setAddCustomer(false);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/project/1/permissions');\n $form = $client->getCrawler()->filter('form[name=project_team_permission_form]')->form();\n /** @var ChoiceFormField $team1 */\n $team1 = $form->get('project_team_permission_form[teams][0]');\n $team1->tick();\n /** @var ChoiceFormField $team2 */\n $team2 = $form->get('project_team_permission_form[teams][1]');\n $team2->tick();",
" $client->submit($form);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));",
" /** @var Project $project */\n $project = $em->getRepository(Project::class)->find(1);\n self::assertEquals(2, $project->getTeams()->count());\n }",
" public function testDeleteAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $fixture = new ProjectFixtures();\n $fixture->setAmount(1);\n /** @var Project[] $projects */\n $projects = $this->importFixture($fixture);\n $id = $projects[0]->getId();",
" $this->request($client, '/admin/project/' . $id . '/edit');\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->request($client, '/admin/project/' . $id . '/delete');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=form]')->form();\n $this->assertStringEndsWith($this->createUrl('/admin/project/' . $id . '/delete'), $form->getUri());\n $client->submit($form);",
" $client->followRedirect();\n $this->assertHasDataTable($client);\n $this->assertHasFlashSuccess($client);",
" $this->request($client, '/admin/project/' . $id . '/edit');\n $this->assertFalse($client->getResponse()->isSuccessful());\n }",
" public function testDeleteActionWithTimesheetEntries()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $em = $this->getEntityManager();\n $fixture = new TimesheetFixtures();\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setAmount(10);\n $this->importFixture($fixture);",
" $timesheets = $em->getRepository(Timesheet::class)->findAll();\n $this->assertEquals(10, \\count($timesheets));",
" /** @var Timesheet $entry */\n foreach ($timesheets as $entry) {\n $this->assertEquals(1, $entry->getActivity()->getId());\n }",
" $this->request($client, '/admin/project/1/delete');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=form]')->form();\n $this->assertStringEndsWith($this->createUrl('/admin/project/1/delete'), $form->getUri());\n $client->submit($form);",
" $this->assertIsRedirect($client, $this->createUrl('/admin/project/'));\n $client->followRedirect();\n $this->assertHasFlashDeleteSuccess($client);\n $this->assertHasNoEntriesWithFilter($client);",
" $em->clear();\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n $this->assertEquals(0, \\count($timesheets));",
" $this->request($client, '/admin/project/1/edit');\n $this->assertFalse($client->getResponse()->isSuccessful());\n }",
" public function testDeleteActionWithTimesheetEntriesAndReplacement()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $em = $this->getEntityManager();\n $fixture = new TimesheetFixtures();\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setAmount(10);\n $this->importFixture($fixture);\n $fixture = new ProjectFixtures();\n $fixture->setAmount(1)->setIsVisible(true);\n $projects = $this->importFixture($fixture);\n $id = $projects[0]->getId();",
" $timesheets = $em->getRepository(Timesheet::class)->findAll();\n $this->assertEquals(10, \\count($timesheets));",
" /** @var Timesheet $entry */\n foreach ($timesheets as $entry) {\n $this->assertEquals(1, $entry->getProject()->getId());\n }",
" $this->request($client, '/admin/project/1/delete');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=form]')->form();\n $this->assertStringEndsWith($this->createUrl('/admin/project/1/delete'), $form->getUri());\n $client->submit($form, [\n 'form' => [\n 'project' => $id\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/admin/project/'));\n $client->followRedirect();\n $this->assertHasDataTable($client);\n $this->assertHasFlashSuccess($client);",
" $timesheets = $em->getRepository(Timesheet::class)->findAll();\n $this->assertEquals(10, \\count($timesheets));",
" /** @var Timesheet $entry */\n foreach ($timesheets as $entry) {\n $this->assertEquals($id, $entry->getProject()->getId());\n }",
" $this->request($client, '/admin/project/1/edit');\n $this->assertFalse($client->getResponse()->isSuccessful());\n }",
" /**\n * @dataProvider getValidationTestData\n */\n public function testValidationForCreateAction(array $formData, array $validationFields)\n {\n $this->assertFormHasValidationError(\n User::ROLE_ADMIN,\n '/admin/project/create',\n 'form[name=project_edit_form]',\n $formData,\n $validationFields\n );\n }",
" public function getValidationTestData()\n {\n return [\n [\n [\n 'project_edit_form' => [\n 'name' => '',\n 'customer' => 0,\n ]\n ],\n [\n '#project_edit_form_name',\n '#project_edit_form_customer',\n ]\n ],\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,
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
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\Entity\\Activity;\nuse App\\Entity\\ActivityMeta;\nuse App\\Entity\\ActivityRate;\nuse App\\Entity\\Project;\nuse App\\Entity\\ProjectComment;\nuse App\\Entity\\ProjectMeta;\nuse App\\Entity\\ProjectRate;\nuse App\\Entity\\Team;\nuse App\\Entity\\Timesheet;\nuse App\\Entity\\User;\nuse App\\Tests\\DataFixtures\\ActivityFixtures;\nuse App\\Tests\\DataFixtures\\ProjectFixtures;\nuse App\\Tests\\DataFixtures\\TeamFixtures;\nuse App\\Tests\\DataFixtures\\TimesheetFixtures;\nuse App\\Tests\\Mocks\\ProjectTestMetaFieldSubscriberMock;\nuse Doctrine\\ORM\\EntityManager;\nuse Symfony\\Component\\DomCrawler\\Field\\ChoiceFormField;\nuse Symfony\\Component\\HttpKernel\\HttpKernelBrowser;",
"/**\n * @group integration\n */\nclass ProjectControllerTest extends ControllerBaseTest\n{\n public function testIsSecure()\n {\n $this->assertUrlIsSecured('/admin/project/');\n }",
" public function testIsSecureForRole()\n {\n $this->assertUrlIsSecuredForRole(User::ROLE_USER, '/admin/project/');\n }",
" public function testIndexAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);\n $this->assertAccessIsGranted($client, '/admin/project/');\n $this->assertHasDataTable($client);\n }",
" public function testIndexActionWithSearchTermQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $fixture = new ProjectFixtures();\n $fixture->setAmount(5);\n $fixture->setCallback(function (Project $project) {\n $project->setVisible(true);\n $project->setComment('I am a foobar with tralalalala some more content');\n $project->setMetaField((new ProjectMeta())->setName('location')->setValue('homeoffice'));\n $project->setMetaField((new ProjectMeta())->setName('feature')->setValue('timetracking'));\n });\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/project/');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'searchTerm' => 'feature:timetracking foo',\n 'visibility' => 1,\n 'customers' => [1],\n 'pageSize' => 50,\n 'page' => 1,\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_project_admin', 5);\n }",
" public function testExportIsSecureForRole()\n {\n $this->assertUrlIsSecuredForRole(User::ROLE_USER, '/admin/project/export');\n }",
" public function testExportAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);\n $this->assertAccessIsGranted($client, '/admin/project/export');\n $this->assertExcelExportResponse($client, 'kimai-projects_');\n }",
" public function testExportActionWithSearchTermQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $fixture = new ProjectFixtures();\n $fixture->setAmount(5);\n $fixture->setCallback(function (Project $project) {\n $project->setVisible(true);\n $project->setComment('I am a foobar with tralalalala some more content');\n $project->setMetaField((new ProjectMeta())->setName('location')->setValue('homeoffice'));\n $project->setMetaField((new ProjectMeta())->setName('feature')->setValue('timetracking'));\n });\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/project/');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $form->getFormNode()->setAttribute('action', $this->createUrl('/admin/project/export'));\n $client->submit($form, [\n 'searchTerm' => 'feature:timetracking foo',\n 'visibility' => 1,\n 'customers' => [1],\n 'pageSize' => 50,\n 'page' => 1,\n ]);",
" $this->assertExcelExportResponse($client, 'kimai-projects_');\n }",
" public function testDetailsAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n /** @var EntityManager $em */\n $em = $this->getEntityManager();",
" $project = $em->getRepository(Project::class)->find(1);",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setProjects([$project]);\n $fixture->setUser($this->getUserByRole(User::ROLE_ADMIN));\n $this->importFixture($fixture);",
" $project = $em->getRepository(Project::class)->find(1);\n $fixture = new ActivityFixtures();\n $fixture->setAmount(6); // to trigger a second page\n $fixture->setProjects([$project]);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/project/1/details');\n self::assertHasProgressbar($client);",
" $node = $client->getCrawler()->filter('div.box#project_details_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#activity_list_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#time_budget_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#budget_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#team_listing_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#comments_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#team_listing_box a.btn.btn-default');\n self::assertEquals(2, $node->count());\n $node = $client->getCrawler()->filter('div.box#project_rates_box');\n self::assertEquals(1, $node->count());\n }",
" public function testAddRateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAddRate($client, 123.45, 1);\n }",
" protected function assertAddRate(HttpKernelBrowser $client, $rate, $projectId)\n {\n $this->assertAccessIsGranted($client, '/admin/project/' . $projectId . '/rate');\n $form = $client->getCrawler()->filter('form[name=project_rate_form]')->form();\n $client->submit($form, [\n 'project_rate_form' => [\n 'user' => null,\n 'rate' => $rate,\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/' . $projectId . '/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#project_rates_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#project_rates_box table.dataTable tbody tr:not(.summary)');\n self::assertEquals(1, $node->count());\n self::assertStringContainsString($rate, $node->text(null, true));\n }",
" public function testDuplicateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n /** @var EntityManager $em */\n $em = $this->getEntityManager();\n $project = $em->find(Project::class, 1);\n $project->setMetaField((new ProjectMeta())->setName('foo')->setValue('bar'));\n $project->setEnd(new \\DateTime());\n $em->persist($project);\n $team = new Team();\n $team->addTeamlead($this->getUserByRole(User::ROLE_ADMIN));\n $team->addProject($project);\n $team->setName('project 1');\n $em->persist($team);\n $rate = new ProjectRate();\n $rate->setProject($project);\n $rate->setRate(123.45);\n $em->persist($rate);\n $activity = new Activity();\n $activity->setName('blub');\n $activity->setProject($project);\n $activity->setMetaField((new ActivityMeta())->setName('blub')->setValue('blab'));\n $em->persist($activity);\n $rate = new ActivityRate();\n $rate->setActivity($activity);\n $rate->setRate(123.45);\n $em->persist($rate);\n $em->flush();\n",
" $token = self::$container->get('security.csrf.token_manager')->getToken('project.duplicate');",
" $this->request($client, '/admin/project/1/duplicate/' . $token);",
" $this->assertIsRedirect($client, '/details');\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#project_rates_box');\n self::assertEquals(1, $node->count());\n $node = $client->getCrawler()->filter('div.box#project_rates_box table.dataTable tbody tr:not(.summary)');\n self::assertEquals(1, $node->count());\n self::assertStringContainsString('123.45', $node->text(null, true));",
" }",
" public function testDuplicateActionWithInvalidCsrf()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n /** @var EntityManager $em */\n $em = $this->getEntityManager();\n $project = $em->find(Project::class, 1);\n $project->setMetaField((new ProjectMeta())->setName('foo')->setValue('bar'));\n $project->setEnd(new \\DateTime());\n $em->persist($project);\n $activity = new Activity();\n $activity->setName('blub');\n $activity->setProject($project);\n $activity->setMetaField((new ActivityMeta())->setName('blub')->setValue('blab'));\n $em->persist($activity);\n $em->flush();",
" $this->assertInvalidCsrfToken($client, '/admin/project/1/duplicate/rsetdzfukgli78t6r5uedtjfzkugl', $this->createUrl('/admin/project/1/details'));",
" }",
" public function testAddCommentAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/details');\n $form = $client->getCrawler()->filter('form[name=project_comment_form]')->form();\n $client->submit($form, [\n 'project_comment_form' => [\n 'message' => 'A beautiful and long comment **with some** markdown formatting',\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text');\n self::assertStringContainsString('<p>A beautiful and long comment <strong>with some</strong> markdown formatting</p>', $node->html());\n }",
" public function testDeleteCommentAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/details');\n $form = $client->getCrawler()->filter('form[name=project_comment_form]')->form();\n $client->submit($form, [\n 'project_comment_form' => [\n 'message' => 'Foo bar blub',\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text');\n self::assertStringContainsString('Foo bar blub', $node->html());\n $node = $client->getCrawler()->filter('div.box#comments_box .box-body a.confirmation-link');",
" $comments = $this->getEntityManager()->getRepository(ProjectComment::class)->findAll();\n $id = $comments[0]->getId();",
" $token = self::$container->get('security.csrf.token_manager')->getToken('project.delete_comment');",
" self::assertEquals($this->createUrl('/admin/project/' . $id . '/comment_delete/' . $token), $node->attr('href'));\n $this->request($client, '/admin/project/' . $id . '/comment_delete/' . $token);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .box-body');\n self::assertStringContainsString('There were no comments posted yet', $node->html());\n }",
" public function testPinCommentAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/details');\n $form = $client->getCrawler()->filter('form[name=project_comment_form]')->form();\n $client->submit($form, [\n 'project_comment_form' => [\n 'message' => 'Foo bar blub',\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text');\n self::assertStringContainsString('Foo bar blub', $node->html());\n $node = $client->getCrawler()->filter('div.box#comments_box .box-body a.btn.active');\n self::assertEquals(0, $node->count());",
" $comments = $this->getEntityManager()->getRepository(ProjectComment::class)->findAll();\n $id = $comments[0]->getId();",
" $token = self::$container->get('security.csrf.token_manager')->getToken('project.pin_comment');",
" $this->request($client, '/admin/project/' . $id . '/comment_pin/' . $token);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#comments_box .box-body a.btn.active');\n self::assertEquals(1, $node->count());\n self::assertEquals($this->createUrl('/admin/project/' . $id . '/comment_pin/' . $token), $node->attr('href'));\n }",
" public function testCreateDefaultTeamAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/details');\n $node = $client->getCrawler()->filter('div.box#team_listing_box .box-body');\n self::assertStringContainsString('Visible to everyone, as no team was assigned yet.', $node->text(null, true));",
" $this->request($client, '/admin/project/1/create_team');\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $node = $client->getCrawler()->filter('div.box#team_listing_box .box-title');\n self::assertStringContainsString('Only visible to the following teams and all admins.', $node->text(null, true));\n $node = $client->getCrawler()->filter('div.box#team_listing_box .box-body table tbody tr');\n self::assertEquals(1, $node->count());",
" // creating the default team a second time fails, as the name already exists\n $this->request($client, '/admin/project/1/create_team');\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $this->assertHasFlashError($client, 'Changes could not be saved: Team already existing');\n }",
" public function testActivitiesAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/activities/1');\n $node = $client->getCrawler()->filter('div.box#activity_list_box .box-tools ul.pagination li');\n self::assertEquals(0, $node->count());\n $node = $client->getCrawler()->filter('div.box#activity_list_box .box-tools a.modal-ajax-form.open-edit');\n self::assertEquals(1, $node->count());",
" /** @var EntityManager $em */\n $em = $this->getEntityManager();\n $project = $em->getRepository(Project::class)->find(1);\n $fixture = new ActivityFixtures();\n $fixture->setAmount(9); // to trigger a second page (every third activity is hidden)\n $fixture->setProjects([$project]);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/project/1/activities/1');",
" $node = $client->getCrawler()->filter('div.box#activity_list_box .box-tools ul.pagination li');\n self::assertEquals(4, $node->count());",
" $node = $client->getCrawler()->filter('div.box#activity_list_box .box-body table tbody tr');\n self::assertEquals(5, $node->count());\n }",
" public function testCreateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/create');\n $form = $client->getCrawler()->filter('form[name=project_edit_form]')->form();\n $client->submit($form, [\n 'project_edit_form' => [\n 'name' => 'Test 2',\n 'customer' => 1,\n ]\n ]);\n $this->assertIsRedirect($client, '/details');\n $client->followRedirect();\n $this->assertHasFlashSuccess($client);\n }",
" public function testCreateActionShowsMetaFields()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n static::$kernel->getContainer()->get('event_dispatcher')->addSubscriber(new ProjectTestMetaFieldSubscriberMock());\n $this->assertAccessIsGranted($client, '/admin/project/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=project_edit_form]')->form();\n $this->assertTrue($form->has('project_edit_form[metaFields][0][value]'));\n $this->assertFalse($form->has('project_edit_form[metaFields][1][value]'));\n }",
" public function testEditAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/project/1/edit');\n $form = $client->getCrawler()->filter('form[name=project_edit_form]')->form();\n $this->assertEquals('Test', $form->get('project_edit_form[name]')->getValue());\n $client->submit($form, [\n 'project_edit_form' => ['name' => 'Test 2']\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));\n $client->followRedirect();\n $this->request($client, '/admin/project/1/edit');\n $editForm = $client->getCrawler()->filter('form[name=project_edit_form]')->form();\n $this->assertEquals('Test 2', $editForm->get('project_edit_form[name]')->getValue());\n }",
" public function testTeamPermissionAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $em = $this->getEntityManager();",
" /** @var Project $project */\n $project = $em->getRepository(Project::class)->find(1);\n self::assertEquals(0, $project->getTeams()->count());",
" $fixture = new TeamFixtures();\n $fixture->setAmount(2);\n $fixture->setAddCustomer(false);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/project/1/permissions');\n $form = $client->getCrawler()->filter('form[name=project_team_permission_form]')->form();\n /** @var ChoiceFormField $team1 */\n $team1 = $form->get('project_team_permission_form[teams][0]');\n $team1->tick();\n /** @var ChoiceFormField $team2 */\n $team2 = $form->get('project_team_permission_form[teams][1]');\n $team2->tick();",
" $client->submit($form);\n $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));",
" /** @var Project $project */\n $project = $em->getRepository(Project::class)->find(1);\n self::assertEquals(2, $project->getTeams()->count());\n }",
" public function testDeleteAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $fixture = new ProjectFixtures();\n $fixture->setAmount(1);\n /** @var Project[] $projects */\n $projects = $this->importFixture($fixture);\n $id = $projects[0]->getId();",
" $this->request($client, '/admin/project/' . $id . '/edit');\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->request($client, '/admin/project/' . $id . '/delete');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=form]')->form();\n $this->assertStringEndsWith($this->createUrl('/admin/project/' . $id . '/delete'), $form->getUri());\n $client->submit($form);",
" $client->followRedirect();\n $this->assertHasDataTable($client);\n $this->assertHasFlashSuccess($client);",
" $this->request($client, '/admin/project/' . $id . '/edit');\n $this->assertFalse($client->getResponse()->isSuccessful());\n }",
" public function testDeleteActionWithTimesheetEntries()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $em = $this->getEntityManager();\n $fixture = new TimesheetFixtures();\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setAmount(10);\n $this->importFixture($fixture);",
" $timesheets = $em->getRepository(Timesheet::class)->findAll();\n $this->assertEquals(10, \\count($timesheets));",
" /** @var Timesheet $entry */\n foreach ($timesheets as $entry) {\n $this->assertEquals(1, $entry->getActivity()->getId());\n }",
" $this->request($client, '/admin/project/1/delete');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=form]')->form();\n $this->assertStringEndsWith($this->createUrl('/admin/project/1/delete'), $form->getUri());\n $client->submit($form);",
" $this->assertIsRedirect($client, $this->createUrl('/admin/project/'));\n $client->followRedirect();\n $this->assertHasFlashDeleteSuccess($client);\n $this->assertHasNoEntriesWithFilter($client);",
" $em->clear();\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n $this->assertEquals(0, \\count($timesheets));",
" $this->request($client, '/admin/project/1/edit');\n $this->assertFalse($client->getResponse()->isSuccessful());\n }",
" public function testDeleteActionWithTimesheetEntriesAndReplacement()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $em = $this->getEntityManager();\n $fixture = new TimesheetFixtures();\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setAmount(10);\n $this->importFixture($fixture);\n $fixture = new ProjectFixtures();\n $fixture->setAmount(1)->setIsVisible(true);\n $projects = $this->importFixture($fixture);\n $id = $projects[0]->getId();",
" $timesheets = $em->getRepository(Timesheet::class)->findAll();\n $this->assertEquals(10, \\count($timesheets));",
" /** @var Timesheet $entry */\n foreach ($timesheets as $entry) {\n $this->assertEquals(1, $entry->getProject()->getId());\n }",
" $this->request($client, '/admin/project/1/delete');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=form]')->form();\n $this->assertStringEndsWith($this->createUrl('/admin/project/1/delete'), $form->getUri());\n $client->submit($form, [\n 'form' => [\n 'project' => $id\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/admin/project/'));\n $client->followRedirect();\n $this->assertHasDataTable($client);\n $this->assertHasFlashSuccess($client);",
" $timesheets = $em->getRepository(Timesheet::class)->findAll();\n $this->assertEquals(10, \\count($timesheets));",
" /** @var Timesheet $entry */\n foreach ($timesheets as $entry) {\n $this->assertEquals($id, $entry->getProject()->getId());\n }",
" $this->request($client, '/admin/project/1/edit');\n $this->assertFalse($client->getResponse()->isSuccessful());\n }",
" /**\n * @dataProvider getValidationTestData\n */\n public function testValidationForCreateAction(array $formData, array $validationFields)\n {\n $this->assertFormHasValidationError(\n User::ROLE_ADMIN,\n '/admin/project/create',\n 'form[name=project_edit_form]',\n $formData,\n $validationFields\n );\n }",
" public function getValidationTestData()\n {\n return [\n [\n [\n 'project_edit_form' => [\n 'name' => '',\n 'customer' => 0,\n ]\n ],\n [\n '#project_edit_form_name',\n '#project_edit_form_customer',\n ]\n ],\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,
1,
1,
1,
1,
1,
1,
1,
1,
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": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\Entity\\Team;\nuse App\\Entity\\User;\nuse App\\Tests\\DataFixtures\\TeamFixtures;\nuse Doctrine\\ORM\\EntityManager;\nuse Symfony\\Component\\DomCrawler\\Field\\ChoiceFormField;\nuse Symfony\\Component\\HttpKernel\\HttpKernelBrowser;",
"/**\n * @group integration\n */\nclass TeamControllerTest extends ControllerBaseTest\n{\n public function testIsSecure()\n {\n $this->assertUrlIsSecured('/admin/teams/');\n }",
" public function testIsSecureForRole()\n {\n $this->assertUrlIsSecuredForRole(User::ROLE_TEAMLEAD, '/admin/teams/');\n }",
" public function testIndexAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $em = $this->getEntityManager();\n $fixture = new TeamFixtures();\n $fixture->setAmount(5);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/teams/');\n $this->assertPageActions($client, [\n 'search' => '#',\n 'create' => $this->createUrl('/admin/teams/create'),\n 'help' => 'https://www.kimai.org/documentation/teams.html'\n ]);\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_admin_teams', 6);\n }",
" public function testIndexActionWithSearchTermQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $em = $this->getEntityManager();\n $fixture = new TeamFixtures();\n $fixture->setAmount(5);\n $fixture->setCallback(function (Team $team) {\n $team->setName($team->getName() . '- fantastic team with foooo bar magic');\n });\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/teams/');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'searchTerm' => 'foo',\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_admin_teams', 5);\n }",
" public function testCreateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/teams/create');\n $form = $client->getCrawler()->filter('form[name=team_edit_form]')->form();",
" $this->assertEquals('', $form->get('team_edit_form[name]')->getValue());",
" $values = $form->getPhpValues();\n $values['team_edit_form']['name'] = 'Test Team' . uniqid();\n $values['team_edit_form']['members'][0]['user'] = 5;\n $values['team_edit_form']['members'][0]['teamlead'] = 1;\n $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());",
" $this->assertIsRedirect($client, '/edit');\n $client->followRedirect();\n $this->assertHasFlashSuccess($client);\n $this->assertHasCustomerAndProjectPermissionBoxes($client);\n }",
" protected function assertHasCustomerAndProjectPermissionBoxes(HttpKernelBrowser $client)\n {\n $content = $client->getResponse()->getContent();\n $this->assertStringContainsString('Grant access to customers', $content);\n $this->assertStringContainsString('Grant access to projects', $content);\n $this->assertEquals(1, $client->getCrawler()->filter('form[name=team_customer_form]')->count());\n $this->assertEquals(1, $client->getCrawler()->filter('form[name=team_project_form]')->count());\n }",
" public function testEditAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $fixture = new TeamFixtures();\n $fixture->setAmount(2);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/teams/1/edit');\n $form = $client->getCrawler()->filter('form[name=team_edit_form]')->form();",
" $client->submit($form, [\n 'team_edit_form' => [\n 'name' => 'Test Team 2'\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit'));\n $client->followRedirect();\n $editForm = $client->getCrawler()->filter('form[name=team_edit_form]')->form();\n $this->assertEquals('Test Team 2', $editForm->get('team_edit_form[name]')->getValue());\n }",
" public function testEditMemberAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $em = $this->getEntityManager();\n $fixture = new TeamFixtures();\n $fixture->setAmount(2);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/teams/1/edit_member');\n $form = $client->getCrawler()->filter('form[name=team_edit_form]')->form();\n $client->submit($form, [\n 'team_edit_form' => [\n 'name' => 'Test Team 2'\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit'));\n $client->followRedirect();\n $editForm = $client->getCrawler()->filter('form[name=team_edit_form]')->form();\n $this->assertEquals('Test Team 2', $editForm->get('team_edit_form[name]')->getValue());\n }",
" public function testEditCustomerAccessAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" /** @var EntityManager $em */\n $em = $this->getEntityManager();",
" $fixture = new TeamFixtures();\n $fixture->setAmount(2);\n $fixture->setAddCustomer(false);\n $this->importFixture($fixture);",
" $team = $em->getRepository(Team::class)->find(1);\n self::assertEquals(0, \\count($team->getCustomers()));",
" $this->assertAccessIsGranted($client, '/admin/teams/1/edit');\n $form = $client->getCrawler()->filter('form[name=team_customer_form]')->form();",
" /** @var ChoiceFormField $customer */\n $customer = $form->get('team_customer_form[customers][0]');\n $customer->tick();",
" $client->submit($form);\n $this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit'));",
" $team = $em->getRepository(Team::class)->find(1);\n self::assertEquals(1, \\count($team->getCustomers()));\n }",
" public function testEditProjectAccessAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" /** @var EntityManager $em */\n $em = $this->getEntityManager();",
" $fixture = new TeamFixtures();\n $fixture->setAmount(2);\n $fixture->setAddCustomer(false);\n $this->importFixture($fixture);",
" $team = $em->getRepository(Team::class)->find(1);\n self::assertEquals(0, \\count($team->getProjects()));",
" $this->assertAccessIsGranted($client, '/admin/teams/1/edit');\n $form = $client->getCrawler()->filter('form[name=team_project_form]')->form();",
" /** @var ChoiceFormField $customer */\n $customer = $form->get('team_project_form[projects]');\n $customer->select([1]);",
" $client->submit($form);\n $this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit'));",
" $team = $em->getRepository(Team::class)->find(1);\n self::assertEquals(1, \\count($team->getProjects()));\n }",
" public function testDuplicateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $this->request($client, '/admin/teams/1/duplicate');",
" $this->assertIsRedirect($client, '/edit');\n $client->followRedirect();\n $node = $client->getCrawler()->filter('#team_edit_form_name');\n self::assertEquals(1, $node->count());\n self::assertEquals('Test team [COPY]', $node->attr('value'));\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,
0,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\Entity\\Team;\nuse App\\Entity\\User;\nuse App\\Tests\\DataFixtures\\TeamFixtures;\nuse Doctrine\\ORM\\EntityManager;\nuse Symfony\\Component\\DomCrawler\\Field\\ChoiceFormField;\nuse Symfony\\Component\\HttpKernel\\HttpKernelBrowser;",
"/**\n * @group integration\n */\nclass TeamControllerTest extends ControllerBaseTest\n{\n public function testIsSecure()\n {\n $this->assertUrlIsSecured('/admin/teams/');\n }",
" public function testIsSecureForRole()\n {\n $this->assertUrlIsSecuredForRole(User::ROLE_TEAMLEAD, '/admin/teams/');\n }",
" public function testIndexAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $em = $this->getEntityManager();\n $fixture = new TeamFixtures();\n $fixture->setAmount(5);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/teams/');\n $this->assertPageActions($client, [\n 'search' => '#',\n 'create' => $this->createUrl('/admin/teams/create'),\n 'help' => 'https://www.kimai.org/documentation/teams.html'\n ]);\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_admin_teams', 6);\n }",
" public function testIndexActionWithSearchTermQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $em = $this->getEntityManager();\n $fixture = new TeamFixtures();\n $fixture->setAmount(5);\n $fixture->setCallback(function (Team $team) {\n $team->setName($team->getName() . '- fantastic team with foooo bar magic');\n });\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/teams/');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'searchTerm' => 'foo',\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_admin_teams', 5);\n }",
" public function testCreateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/teams/create');\n $form = $client->getCrawler()->filter('form[name=team_edit_form]')->form();",
" $this->assertEquals('', $form->get('team_edit_form[name]')->getValue());",
" $values = $form->getPhpValues();\n $values['team_edit_form']['name'] = 'Test Team' . uniqid();\n $values['team_edit_form']['members'][0]['user'] = 5;\n $values['team_edit_form']['members'][0]['teamlead'] = 1;\n $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());",
" $this->assertIsRedirect($client, '/edit');\n $client->followRedirect();\n $this->assertHasFlashSuccess($client);\n $this->assertHasCustomerAndProjectPermissionBoxes($client);\n }",
" protected function assertHasCustomerAndProjectPermissionBoxes(HttpKernelBrowser $client)\n {\n $content = $client->getResponse()->getContent();\n $this->assertStringContainsString('Grant access to customers', $content);\n $this->assertStringContainsString('Grant access to projects', $content);\n $this->assertEquals(1, $client->getCrawler()->filter('form[name=team_customer_form]')->count());\n $this->assertEquals(1, $client->getCrawler()->filter('form[name=team_project_form]')->count());\n }",
" public function testEditAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $fixture = new TeamFixtures();\n $fixture->setAmount(2);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/teams/1/edit');\n $form = $client->getCrawler()->filter('form[name=team_edit_form]')->form();",
" $client->submit($form, [\n 'team_edit_form' => [\n 'name' => 'Test Team 2'\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit'));\n $client->followRedirect();\n $editForm = $client->getCrawler()->filter('form[name=team_edit_form]')->form();\n $this->assertEquals('Test Team 2', $editForm->get('team_edit_form[name]')->getValue());\n }",
" public function testEditMemberAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $em = $this->getEntityManager();\n $fixture = new TeamFixtures();\n $fixture->setAmount(2);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/admin/teams/1/edit_member');\n $form = $client->getCrawler()->filter('form[name=team_edit_form]')->form();\n $client->submit($form, [\n 'team_edit_form' => [\n 'name' => 'Test Team 2'\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit'));\n $client->followRedirect();\n $editForm = $client->getCrawler()->filter('form[name=team_edit_form]')->form();\n $this->assertEquals('Test Team 2', $editForm->get('team_edit_form[name]')->getValue());\n }",
" public function testEditCustomerAccessAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" /** @var EntityManager $em */\n $em = $this->getEntityManager();",
" $fixture = new TeamFixtures();\n $fixture->setAmount(2);\n $fixture->setAddCustomer(false);\n $this->importFixture($fixture);",
" $team = $em->getRepository(Team::class)->find(1);\n self::assertEquals(0, \\count($team->getCustomers()));",
" $this->assertAccessIsGranted($client, '/admin/teams/1/edit');\n $form = $client->getCrawler()->filter('form[name=team_customer_form]')->form();",
" /** @var ChoiceFormField $customer */\n $customer = $form->get('team_customer_form[customers][0]');\n $customer->tick();",
" $client->submit($form);\n $this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit'));",
" $team = $em->getRepository(Team::class)->find(1);\n self::assertEquals(1, \\count($team->getCustomers()));\n }",
" public function testEditProjectAccessAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" /** @var EntityManager $em */\n $em = $this->getEntityManager();",
" $fixture = new TeamFixtures();\n $fixture->setAmount(2);\n $fixture->setAddCustomer(false);\n $this->importFixture($fixture);",
" $team = $em->getRepository(Team::class)->find(1);\n self::assertEquals(0, \\count($team->getProjects()));",
" $this->assertAccessIsGranted($client, '/admin/teams/1/edit');\n $form = $client->getCrawler()->filter('form[name=team_project_form]')->form();",
" /** @var ChoiceFormField $customer */\n $customer = $form->get('team_project_form[projects]');\n $customer->select([1]);",
" $client->submit($form);\n $this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit'));",
" $team = $em->getRepository(Team::class)->find(1);\n self::assertEquals(1, \\count($team->getProjects()));\n }",
" public function testDuplicateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
"\n $token = self::$container->get('security.csrf.token_manager')->getToken('team.duplicate');",
" $this->request($client, '/admin/teams/1/duplicate/' . $token);",
" $this->assertIsRedirect($client, '/edit');\n $client->followRedirect();\n $node = $client->getCrawler()->filter('#team_edit_form_name');\n self::assertEquals(1, $node->count());\n self::assertEquals('Test team [COPY]', $node->attr('value'));\n }",
"\n public function testDuplicateActionWithInvalidCsrf()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->assertInvalidCsrfToken($client, '/admin/teams/1/duplicate/rsetdzfukgli78t6r5uedtjfzkugl', $this->createUrl('/admin/teams/1/edit'));\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\Entity\\Activity;\nuse App\\Entity\\Configuration;\nuse App\\Entity\\Timesheet;\nuse App\\Entity\\TimesheetMeta;\nuse App\\Entity\\User;\nuse App\\Form\\Type\\DateRangeType;\nuse App\\Repository\\ConfigurationRepository;\nuse App\\Tests\\DataFixtures\\ActivityFixtures;\nuse App\\Tests\\DataFixtures\\TimesheetFixtures;\nuse App\\Tests\\Mocks\\TimesheetTestMetaFieldSubscriberMock;\nuse App\\Timesheet\\DateTimeFactory;",
"/**\n * @group integration\n */\nclass TimesheetControllerTest extends ControllerBaseTest\n{\n public function testIsSecure()\n {\n $this->assertUrlIsSecured('/timesheet/');\n }",
" public function testIndexAction()\n {\n $client = $this->getClientForAuthenticatedUser();\n $this->request($client, '/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" // there are no records by default in the test database\n $this->assertHasNoEntriesWithFilter($client);\n $this->assertPageActions($client, [\n 'search' => '#',\n 'visibility' => '#',\n 'download toolbar-action modal-ajax-form' => $this->createUrl('/timesheet/export/'),\n 'create modal-ajax-form' => $this->createUrl('/timesheet/create'),\n 'help' => 'https://www.kimai.org/documentation/timesheet.html'\n ]);\n }",
" public function testIndexActionWithQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_USER);\n $start = new \\DateTime('first day of this month');",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setAmountRunning(2);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($start);\n $this->importFixture($fixture);",
" $this->request($client, '/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime('last day of this month'))->format('Y-m-d');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'state' => 1,\n 'pageSize' => 25,\n 'daterange' => $dateRange,\n 'customers' => [1],\n 'projects' => [1],\n 'activities' => [1],\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_timesheet', 7);",
" // make sure the recording css class exist on tr for targeting running record rows\n $node = $client->getCrawler()->filter('section.content div.datatable_timesheet table.dataTable tbody tr.recording');\n self::assertEquals(2, $node->count());\n }",
" public function testIndexActionWithSearchTermQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_USER);\n $start = new \\DateTime('first day of this month');",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($start);\n $fixture->setCallback(function (Timesheet $timesheet) {\n $timesheet->setDescription('I am a foobar with tralalalala some more content');\n $timesheet->setMetaField((new TimesheetMeta())->setName('location')->setValue('homeoffice'));\n $timesheet->setMetaField((new TimesheetMeta())->setName('feature')->setValue('timetracking'));\n });\n $this->importFixture($fixture);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setAmountRunning(5);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($start);\n $this->importFixture($fixture);",
" $this->request($client, '/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime('last day of this month'))->format('Y-m-d');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'searchTerm' => 'location:homeoffice foobar',\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_timesheet', 5);\n }",
" public function testExportAction()\n {\n $client = $this->getClientForAuthenticatedUser();",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate(new \\DateTime('-10 days'));\n $this->importFixture($fixture);",
" $this->request($client, '/timesheet/export/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = (new \\DateTime('-10 days'))->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime())->format('Y-m-d');",
" $client->submitForm('export-btn-print', [\n 'export' => [\n 'state' => 1,\n 'daterange' => $dateRange,\n 'customers' => [],\n ]\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());",
" $node = $client->getCrawler()->filter('body');\n /** @var \\DOMElement $body */\n $body = $node->getNode(0);\n $this->assertEquals('invoice_print', $body->getAttribute('class'));",
" $result = $node->filter('section.invoice table.table tbody tr');\n $this->assertEquals(5, \\count($result));\n }",
" public function testCreateAction()\n {\n $client = $this->getClientForAuthenticatedUser();\n $this->request($client, '/timesheet/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'description' => 'Testing is fun!',\n // begin is always pre-filled with the current datetime\n // 'begin' => null,\n // end must be allowed to be null, to start a record\n // there was a bug with end begin required, so we manually set this field to be empty\n 'end' => null,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertNull($timesheet->getEnd());\n $this->assertEquals('Testing is fun!', $timesheet->getDescription());\n $this->assertEquals(0, $timesheet->getRate());\n $this->assertNull($timesheet->getHourlyRate());\n $this->assertNull($timesheet->getFixedRate());\n }",
" /**\n * @dataProvider getTestDataForDurationValues\n */\n public function testCreateActionWithDurationValues($begin, $end, $duration, $expectedDuration, $expectedEnd)\n {\n $client = $this->getClientForAuthenticatedUser();\n $this->request($client, '/timesheet/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'description' => 'Testing is fun!',\n 'begin' => $begin,\n 'end' => $end,\n 'duration' => $duration,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getEnd());\n $this->assertEquals($expectedDuration, $timesheet->getDuration());\n $this->assertEquals($expectedEnd, $timesheet->getEnd()->format('Y-m-d H:i:s'));\n $this->assertEquals('Testing is fun!', $timesheet->getDescription());\n }",
" public function getTestDataForDurationValues()\n {\n // duration is ignored, because end is set and the duration might come from a rounding rule (by default seconds are rounded down with 1)\n yield ['2018-12-31 00:00:00', '2018-12-31 02:10:10', '01:00', 7800, '2018-12-31 02:10:00'];\n yield ['2018-12-31 00:00:00', '2018-12-31 02:09:59', '01:00', 7740, '2018-12-31 02:09:00'];\n // if seconds are given, they are first rounded up (default for duration rounding is 1)\n yield ['2018-12-31 00:00:00', null, '01:00', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '01:00:10', 3660, '2018-12-31 01:01:00'];\n yield ['2018-12-31 00:00:00', null, '1h', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '1h10m', 4200, '2018-12-31 01:10:00'];\n yield ['2018-12-31 00:00:00', null, '1h10s', 3660, '2018-12-31 01:01:00'];\n yield ['2018-12-31 00:00:00', null, '60m', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '60M1s', 3660, '2018-12-31 01:01:00'];\n yield ['2018-12-31 00:00:00', null, '3600s', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '59m60s', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '1', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '1,0', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '1.0', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '1.5', 5400, '2018-12-31 01:30:00'];\n yield ['2018-12-31 00:00:00', null, '1,25', 4500, '2018-12-31 01:15:00'];\n }",
" public function testCreateActionShowsMetaFields()\n {\n $client = $this->getClientForAuthenticatedUser();\n static::$kernel->getContainer()->get('event_dispatcher')->addSubscriber(new TimesheetTestMetaFieldSubscriberMock());\n $this->request($client, '/timesheet/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $this->assertTrue($form->has('timesheet_edit_form[metaFields][0][value]'));\n $this->assertFalse($form->has('timesheet_edit_form[metaFields][1][value]'));\n }",
" public function testCreateActionDoesNotShowRateFieldsForUser()\n {\n $client = $this->getClientForAuthenticatedUser();\n $this->request($client, '/timesheet/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $this->assertFalse($form->has('hourlyRate'));\n $this->assertFalse($form->has('fixedRate'));\n }",
" public function testCreateActionWithFromAndToValues()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/timesheet/create?from=2018-08-02T20%3A00%3A00&to=2018-08-02T20%3A30%3A00');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getEnd());\n $this->assertEquals(50, $timesheet->getRate());",
" $expected = new \\DateTime('2018-08-02T20:00:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getBegin()->format(\\DateTimeInterface::ATOM));",
" $expected = new \\DateTime('2018-08-02T20:30:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getEnd()->format(\\DateTimeInterface::ATOM));\n }",
" public function testCreateActionWithFromAndToValuesTwice()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/timesheet/create?from=2018-08-02T20%3A00%3A00&to=2018-08-02T20%3A30%3A00');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getEnd());\n $this->assertEquals(50, $timesheet->getRate());",
" $expected = new \\DateTime('2018-08-02T20:00:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getBegin()->format(\\DateTimeInterface::ATOM));",
" $expected = new \\DateTime('2018-08-02T20:30:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getEnd()->format(\\DateTimeInterface::ATOM));",
" // create a second entry that is overlapping\n $this->request($client, '/timesheet/create?from=2018-08-02T20%3A02%3A00&to=2018-08-02T20%3A20%3A00');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);\n }",
" public function testCreateActionWithFromAndToValuesTwiceFailsOnOverlappingRecord()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/system-config/');",
" $form = $client->getCrawler()->filter('form[name=system_configuration_form_timesheet]')->form();\n $client->submit($form, [\n 'system_configuration_form_timesheet' => [\n 'configuration' => [\n ['name' => 'timesheet.mode', 'value' => 'default'],\n ['name' => 'timesheet.active_entries.default_begin', 'value' => '08:00'],\n ['name' => 'timesheet.rules.allow_future_times', 'value' => true],\n ['name' => 'timesheet.rules.allow_overlapping_records', 'value' => false],\n ['name' => 'timesheet.rules.allow_overbooking_budget', 'value' => true],\n ['name' => 'timesheet.active_entries.hard_limit', 'value' => 1],\n ]\n ]\n ]);",
" $begin = new \\DateTime('2018-08-02T20:00:00');\n $end = new \\DateTime('2018-08-02T20:30:00');",
" $fixture = new TimesheetFixtures();\n $fixture->setCallback(function (Timesheet $timesheet) use ($begin, $end) {\n $timesheet->setBegin($begin);\n $timesheet->setEnd($end);\n });\n $fixture->setAmount(1);\n $fixture->setUser($this->getUserByRole(User::ROLE_SUPER_ADMIN));\n $this->importFixture($fixture);",
" // create a second entry that is overlapping - should fail due to the changed config above\n $this->assertHasValidationError(\n $client,\n '/timesheet/create?from=2018-08-02T20%3A02%3A00&to=2018-08-02T20%3A20%3A00',\n 'form[name=timesheet_edit_form]',\n [\n 'timesheet_edit_form' => [\n //'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ],\n ['#timesheet_edit_form_begin']\n );\n }",
" public function testCreateActionWithOverbookedActivity()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);",
" $fixture = new ActivityFixtures();\n $fixture->setAmount(1);\n $fixture->setIsGlobal(true);\n $fixture->setIsVisible(true);\n $fixture->setCallback(function (Activity $activity) {\n $activity->setBudget(1000);\n $activity->setTimeBudget(3600);\n });\n $activities = $this->importFixture($fixture);\n /** @var Activity $activity */\n $activity = $activities[0];",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(1);\n $fixture->setActivities([$activity]);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $timesheets = $this->importFixture($fixture);\n $id = $timesheets[0]->getId();",
" $this->request($client, '/timesheet/' . $id . '/edit');",
" $response = $client->getResponse();\n $this->assertTrue($response->isSuccessful());",
" /** @var ConfigurationRepository $repository */\n $repository = $this->getEntityManager()->getRepository(Configuration::class);\n $config = new Configuration();\n $config->setName('timesheet.rules.allow_overbooking_budget');\n $config->setValue(false);\n $repository->saveConfiguration($config);",
" $this->assertHasValidationError(\n $client,\n '/timesheet/' . $id . '/edit',\n 'form[name=timesheet_edit_form]',\n [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'begin' => '2020-02-18 01:00',\n 'end' => '2020-02-18 02:10',\n 'duration' => '01:10',\n 'project' => 1,\n 'activity' => $activity->getId(),\n ]\n ],\n ['#timesheet_edit_form_activity']\n );\n }",
" public function testCreateActionWithBeginAndEndAndTagValues()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/timesheet/create?begin=2018-08-02&end=2018-08-02&tags=one,two,three');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getEnd());\n $this->assertEquals(800, $timesheet->getRate());",
" $expected = new \\DateTime('2018-08-02T10:00:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getBegin()->format(\\DateTimeInterface::ATOM));",
" $expected = new \\DateTime('2018-08-02T18:00:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getEnd()->format(\\DateTimeInterface::ATOM));",
" $this->assertEquals(['one', 'two', 'three'], $timesheet->getTagsAsArray());\n }",
" public function testCreateActionWithDescription()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $this->request($client, '/timesheet/create?description=Lorem%20Ipsum');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertEquals('Lorem Ipsum', $timesheet->getDescription());\n }",
" public function testCreateActionWithDescriptionHtmlInjection()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $this->request($client, '/timesheet/create?description=Some text\"><bold>HelloWorld<%2Fbold>');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertEquals('Some text\"><bold>HelloWorld</bold>', $timesheet->getDescription());\n }",
" public function testEditAction()\n {\n $client = $this->getClientForAuthenticatedUser();",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(1);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setFixedStartDate(new \\DateTime('-2 hours'));\n $timesheets = $this->importFixture($fixture);\n $id = $timesheets[0]->getId();",
" $this->request($client, '/timesheet/' . $id . '/edit');",
" $response = $client->getResponse();\n $this->assertTrue($response->isSuccessful());",
" $this->assertStringContainsString(\n 'href=\"https://www.kimai.org/documentation/timesheet.html\"',\n $response->getContent(),\n 'Could not find link to documentation'\n );",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'description' => 'foo-bar',\n 'tags' => 'foo,bar, testing, hello world,,',\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSaveSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->find($id);\n $this->assertEquals('foo-bar', $timesheet->getDescription());\n }",
" public function testMultiDeleteAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_USER);",
" $user = $this->getUserByRole(User::ROLE_USER);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setUser($user);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/timesheet/');",
" $form = $client->getCrawler()->filter('form[name=multi_update_table]')->form();\n $node = $form->getFormNode();\n $node->setAttribute('action', $this->createUrl('/timesheet/multi-delete'));",
" $em = $this->getEntityManager();\n /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n $ids = [];\n foreach ($timesheets as $timesheet) {\n $ids[] = $timesheet->getId();\n }",
" $client->submit($form, [\n 'multi_update_table' => [\n 'action' => $this->createUrl('/timesheet/multi-delete'),\n 'entities' => implode(',', $ids)\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();",
" $em->clear();\n self::assertEquals(0, $em->getRepository(Timesheet::class)->count([]));\n }",
" public function testMultiUpdate()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);",
" $user = $this->getUserByRole(User::ROLE_SUPER_ADMIN);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setUser($user);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/timesheet/');",
" $form = $client->getCrawler()->filter('form[name=multi_update_table]')->form();\n $node = $form->getFormNode();\n $node->setAttribute('action', $this->createUrl('/timesheet/multi-update'));",
" $em = $this->getEntityManager();\n /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n $ids = [];\n foreach ($timesheets as $timesheet) {\n self::assertEmpty($timesheet->getTags());\n self::assertFalse($timesheet->isExported());\n $ids[] = $timesheet->getId();\n }",
" $client->submit($form, [\n 'multi_update_table' => [\n 'action' => $this->createUrl('/timesheet/multi-update'),\n 'entities' => implode(',', $ids)\n ]\n ]);\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_multi_update]')->form();\n $client->submit($form, [\n 'timesheet_multi_update' => [\n 'exported' => true,\n 'tags' => 'test, foo-bar',\n 'fixedRate' => 13,\n ]\n ]);",
" $em->clear();",
" /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n foreach ($timesheets as $timesheet) {\n self::assertCount(2, $timesheet->getTags());\n self::assertTrue($timesheet->isExported());\n self::assertEquals(13, $timesheet->getFixedRate());\n }\n }",
" public function testDuplicateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $dateTime = new DateTimeFactory(new \\DateTimeZone('Europe/London'));",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(1);\n $fixture->setAmountRunning(0);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($dateTime->createDateTime());\n $fixture->setCallback(function (Timesheet $timesheet) {\n $timesheet->setDescription('Testing is fun!');\n $begin = clone $timesheet->getBegin();\n $begin->setTime(0, 0, 0);\n $timesheet->setBegin($begin);\n $end = clone $timesheet->getBegin();\n $end->modify('+ 8 hours');\n $timesheet->setEnd($end);\n $timesheet->setFixedRate(2016);\n $timesheet->setHourlyRate(127);\n });",
" /** @var Timesheet[] $ids */\n $ids = $this->importFixture($fixture);\n $newId = $ids[0]->getId();\n",
" $this->request($client, '/timesheet/' . $newId . '/duplicate');",
" $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, $form->getPhpValues());",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->find($newId++);\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertEquals('Europe/London', $timesheet->getBegin()->getTimezone()->getName());\n $this->assertEquals('Testing is fun!', $timesheet->getDescription());\n $this->assertEquals(2016, $timesheet->getRate());\n $this->assertEquals(127, $timesheet->getHourlyRate());\n $this->assertEquals(2016, $timesheet->getFixedRate());\n $this->assertEquals(2016, $timesheet->getRate());\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,
0,
1,
1,
1,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\Entity\\Activity;\nuse App\\Entity\\Configuration;\nuse App\\Entity\\Timesheet;\nuse App\\Entity\\TimesheetMeta;\nuse App\\Entity\\User;\nuse App\\Form\\Type\\DateRangeType;\nuse App\\Repository\\ConfigurationRepository;\nuse App\\Tests\\DataFixtures\\ActivityFixtures;\nuse App\\Tests\\DataFixtures\\TimesheetFixtures;\nuse App\\Tests\\Mocks\\TimesheetTestMetaFieldSubscriberMock;\nuse App\\Timesheet\\DateTimeFactory;",
"/**\n * @group integration\n */\nclass TimesheetControllerTest extends ControllerBaseTest\n{\n public function testIsSecure()\n {\n $this->assertUrlIsSecured('/timesheet/');\n }",
" public function testIndexAction()\n {\n $client = $this->getClientForAuthenticatedUser();\n $this->request($client, '/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" // there are no records by default in the test database\n $this->assertHasNoEntriesWithFilter($client);\n $this->assertPageActions($client, [\n 'search' => '#',\n 'visibility' => '#',\n 'download toolbar-action modal-ajax-form' => $this->createUrl('/timesheet/export/'),\n 'create modal-ajax-form' => $this->createUrl('/timesheet/create'),\n 'help' => 'https://www.kimai.org/documentation/timesheet.html'\n ]);\n }",
" public function testIndexActionWithQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_USER);\n $start = new \\DateTime('first day of this month');",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setAmountRunning(2);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($start);\n $this->importFixture($fixture);",
" $this->request($client, '/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime('last day of this month'))->format('Y-m-d');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'state' => 1,\n 'pageSize' => 25,\n 'daterange' => $dateRange,\n 'customers' => [1],\n 'projects' => [1],\n 'activities' => [1],\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_timesheet', 7);",
" // make sure the recording css class exist on tr for targeting running record rows\n $node = $client->getCrawler()->filter('section.content div.datatable_timesheet table.dataTable tbody tr.recording');\n self::assertEquals(2, $node->count());\n }",
" public function testIndexActionWithSearchTermQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_USER);\n $start = new \\DateTime('first day of this month');",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($start);\n $fixture->setCallback(function (Timesheet $timesheet) {\n $timesheet->setDescription('I am a foobar with tralalalala some more content');\n $timesheet->setMetaField((new TimesheetMeta())->setName('location')->setValue('homeoffice'));\n $timesheet->setMetaField((new TimesheetMeta())->setName('feature')->setValue('timetracking'));\n });\n $this->importFixture($fixture);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setAmountRunning(5);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($start);\n $this->importFixture($fixture);",
" $this->request($client, '/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime('last day of this month'))->format('Y-m-d');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'searchTerm' => 'location:homeoffice foobar',\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_timesheet', 5);\n }",
" public function testExportAction()\n {\n $client = $this->getClientForAuthenticatedUser();",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate(new \\DateTime('-10 days'));\n $this->importFixture($fixture);",
" $this->request($client, '/timesheet/export/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = (new \\DateTime('-10 days'))->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime())->format('Y-m-d');",
" $client->submitForm('export-btn-print', [\n 'export' => [\n 'state' => 1,\n 'daterange' => $dateRange,\n 'customers' => [],\n ]\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());",
" $node = $client->getCrawler()->filter('body');\n /** @var \\DOMElement $body */\n $body = $node->getNode(0);\n $this->assertEquals('invoice_print', $body->getAttribute('class'));",
" $result = $node->filter('section.invoice table.table tbody tr');\n $this->assertEquals(5, \\count($result));\n }",
" public function testCreateAction()\n {\n $client = $this->getClientForAuthenticatedUser();\n $this->request($client, '/timesheet/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'description' => 'Testing is fun!',\n // begin is always pre-filled with the current datetime\n // 'begin' => null,\n // end must be allowed to be null, to start a record\n // there was a bug with end begin required, so we manually set this field to be empty\n 'end' => null,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertNull($timesheet->getEnd());\n $this->assertEquals('Testing is fun!', $timesheet->getDescription());\n $this->assertEquals(0, $timesheet->getRate());\n $this->assertNull($timesheet->getHourlyRate());\n $this->assertNull($timesheet->getFixedRate());\n }",
" /**\n * @dataProvider getTestDataForDurationValues\n */\n public function testCreateActionWithDurationValues($begin, $end, $duration, $expectedDuration, $expectedEnd)\n {\n $client = $this->getClientForAuthenticatedUser();\n $this->request($client, '/timesheet/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'description' => 'Testing is fun!',\n 'begin' => $begin,\n 'end' => $end,\n 'duration' => $duration,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getEnd());\n $this->assertEquals($expectedDuration, $timesheet->getDuration());\n $this->assertEquals($expectedEnd, $timesheet->getEnd()->format('Y-m-d H:i:s'));\n $this->assertEquals('Testing is fun!', $timesheet->getDescription());\n }",
" public function getTestDataForDurationValues()\n {\n // duration is ignored, because end is set and the duration might come from a rounding rule (by default seconds are rounded down with 1)\n yield ['2018-12-31 00:00:00', '2018-12-31 02:10:10', '01:00', 7800, '2018-12-31 02:10:00'];\n yield ['2018-12-31 00:00:00', '2018-12-31 02:09:59', '01:00', 7740, '2018-12-31 02:09:00'];\n // if seconds are given, they are first rounded up (default for duration rounding is 1)\n yield ['2018-12-31 00:00:00', null, '01:00', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '01:00:10', 3660, '2018-12-31 01:01:00'];\n yield ['2018-12-31 00:00:00', null, '1h', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '1h10m', 4200, '2018-12-31 01:10:00'];\n yield ['2018-12-31 00:00:00', null, '1h10s', 3660, '2018-12-31 01:01:00'];\n yield ['2018-12-31 00:00:00', null, '60m', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '60M1s', 3660, '2018-12-31 01:01:00'];\n yield ['2018-12-31 00:00:00', null, '3600s', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '59m60s', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '1', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '1,0', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '1.0', 3600, '2018-12-31 01:00:00'];\n yield ['2018-12-31 00:00:00', null, '1.5', 5400, '2018-12-31 01:30:00'];\n yield ['2018-12-31 00:00:00', null, '1,25', 4500, '2018-12-31 01:15:00'];\n }",
" public function testCreateActionShowsMetaFields()\n {\n $client = $this->getClientForAuthenticatedUser();\n static::$kernel->getContainer()->get('event_dispatcher')->addSubscriber(new TimesheetTestMetaFieldSubscriberMock());\n $this->request($client, '/timesheet/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $this->assertTrue($form->has('timesheet_edit_form[metaFields][0][value]'));\n $this->assertFalse($form->has('timesheet_edit_form[metaFields][1][value]'));\n }",
" public function testCreateActionDoesNotShowRateFieldsForUser()\n {\n $client = $this->getClientForAuthenticatedUser();\n $this->request($client, '/timesheet/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $this->assertFalse($form->has('hourlyRate'));\n $this->assertFalse($form->has('fixedRate'));\n }",
" public function testCreateActionWithFromAndToValues()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/timesheet/create?from=2018-08-02T20%3A00%3A00&to=2018-08-02T20%3A30%3A00');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getEnd());\n $this->assertEquals(50, $timesheet->getRate());",
" $expected = new \\DateTime('2018-08-02T20:00:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getBegin()->format(\\DateTimeInterface::ATOM));",
" $expected = new \\DateTime('2018-08-02T20:30:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getEnd()->format(\\DateTimeInterface::ATOM));\n }",
" public function testCreateActionWithFromAndToValuesTwice()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/timesheet/create?from=2018-08-02T20%3A00%3A00&to=2018-08-02T20%3A30%3A00');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getEnd());\n $this->assertEquals(50, $timesheet->getRate());",
" $expected = new \\DateTime('2018-08-02T20:00:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getBegin()->format(\\DateTimeInterface::ATOM));",
" $expected = new \\DateTime('2018-08-02T20:30:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getEnd()->format(\\DateTimeInterface::ATOM));",
" // create a second entry that is overlapping\n $this->request($client, '/timesheet/create?from=2018-08-02T20%3A02%3A00&to=2018-08-02T20%3A20%3A00');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);\n }",
" public function testCreateActionWithFromAndToValuesTwiceFailsOnOverlappingRecord()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);\n $this->assertAccessIsGranted($client, '/admin/system-config/');",
" $form = $client->getCrawler()->filter('form[name=system_configuration_form_timesheet]')->form();\n $client->submit($form, [\n 'system_configuration_form_timesheet' => [\n 'configuration' => [\n ['name' => 'timesheet.mode', 'value' => 'default'],\n ['name' => 'timesheet.active_entries.default_begin', 'value' => '08:00'],\n ['name' => 'timesheet.rules.allow_future_times', 'value' => true],\n ['name' => 'timesheet.rules.allow_overlapping_records', 'value' => false],\n ['name' => 'timesheet.rules.allow_overbooking_budget', 'value' => true],\n ['name' => 'timesheet.active_entries.hard_limit', 'value' => 1],\n ]\n ]\n ]);",
" $begin = new \\DateTime('2018-08-02T20:00:00');\n $end = new \\DateTime('2018-08-02T20:30:00');",
" $fixture = new TimesheetFixtures();\n $fixture->setCallback(function (Timesheet $timesheet) use ($begin, $end) {\n $timesheet->setBegin($begin);\n $timesheet->setEnd($end);\n });\n $fixture->setAmount(1);\n $fixture->setUser($this->getUserByRole(User::ROLE_SUPER_ADMIN));\n $this->importFixture($fixture);",
" // create a second entry that is overlapping - should fail due to the changed config above\n $this->assertHasValidationError(\n $client,\n '/timesheet/create?from=2018-08-02T20%3A02%3A00&to=2018-08-02T20%3A20%3A00',\n 'form[name=timesheet_edit_form]',\n [\n 'timesheet_edit_form' => [\n //'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ],\n ['#timesheet_edit_form_begin']\n );\n }",
" public function testCreateActionWithOverbookedActivity()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);",
" $fixture = new ActivityFixtures();\n $fixture->setAmount(1);\n $fixture->setIsGlobal(true);\n $fixture->setIsVisible(true);\n $fixture->setCallback(function (Activity $activity) {\n $activity->setBudget(1000);\n $activity->setTimeBudget(3600);\n });\n $activities = $this->importFixture($fixture);\n /** @var Activity $activity */\n $activity = $activities[0];",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(1);\n $fixture->setActivities([$activity]);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $timesheets = $this->importFixture($fixture);\n $id = $timesheets[0]->getId();",
" $this->request($client, '/timesheet/' . $id . '/edit');",
" $response = $client->getResponse();\n $this->assertTrue($response->isSuccessful());",
" /** @var ConfigurationRepository $repository */\n $repository = $this->getEntityManager()->getRepository(Configuration::class);\n $config = new Configuration();\n $config->setName('timesheet.rules.allow_overbooking_budget');\n $config->setValue(false);\n $repository->saveConfiguration($config);",
" $this->assertHasValidationError(\n $client,\n '/timesheet/' . $id . '/edit',\n 'form[name=timesheet_edit_form]',\n [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'begin' => '2020-02-18 01:00',\n 'end' => '2020-02-18 02:10',\n 'duration' => '01:10',\n 'project' => 1,\n 'activity' => $activity->getId(),\n ]\n ],\n ['#timesheet_edit_form_activity']\n );\n }",
" public function testCreateActionWithBeginAndEndAndTagValues()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/timesheet/create?begin=2018-08-02&end=2018-08-02&tags=one,two,three');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getEnd());\n $this->assertEquals(800, $timesheet->getRate());",
" $expected = new \\DateTime('2018-08-02T10:00:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getBegin()->format(\\DateTimeInterface::ATOM));",
" $expected = new \\DateTime('2018-08-02T18:00:00');\n $this->assertEquals($expected->format(\\DateTimeInterface::ATOM), $timesheet->getEnd()->format(\\DateTimeInterface::ATOM));",
" $this->assertEquals(['one', 'two', 'three'], $timesheet->getTagsAsArray());\n }",
" public function testCreateActionWithDescription()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $this->request($client, '/timesheet/create?description=Lorem%20Ipsum');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertEquals('Lorem Ipsum', $timesheet->getDescription());\n }",
" public function testCreateActionWithDescriptionHtmlInjection()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $this->request($client, '/timesheet/create?description=Some text\"><bold>HelloWorld<%2Fbold>');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'hourlyRate' => 100,\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertEquals('Some text\"><bold>HelloWorld</bold>', $timesheet->getDescription());\n }",
" public function testEditAction()\n {\n $client = $this->getClientForAuthenticatedUser();",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(1);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setFixedStartDate(new \\DateTime('-2 hours'));\n $timesheets = $this->importFixture($fixture);\n $id = $timesheets[0]->getId();",
" $this->request($client, '/timesheet/' . $id . '/edit');",
" $response = $client->getResponse();\n $this->assertTrue($response->isSuccessful());",
" $this->assertStringContainsString(\n 'href=\"https://www.kimai.org/documentation/timesheet.html\"',\n $response->getContent(),\n 'Could not find link to documentation'\n );",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_edit_form' => [\n 'description' => 'foo-bar',\n 'tags' => 'foo,bar, testing, hello world,,',\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSaveSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->find($id);\n $this->assertEquals('foo-bar', $timesheet->getDescription());\n }",
" public function testMultiDeleteAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_USER);",
" $user = $this->getUserByRole(User::ROLE_USER);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setUser($user);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/timesheet/');",
" $form = $client->getCrawler()->filter('form[name=multi_update_table]')->form();\n $node = $form->getFormNode();\n $node->setAttribute('action', $this->createUrl('/timesheet/multi-delete'));",
" $em = $this->getEntityManager();\n /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n $ids = [];\n foreach ($timesheets as $timesheet) {\n $ids[] = $timesheet->getId();\n }",
" $client->submit($form, [\n 'multi_update_table' => [\n 'action' => $this->createUrl('/timesheet/multi-delete'),\n 'entities' => implode(',', $ids)\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();",
" $em->clear();\n self::assertEquals(0, $em->getRepository(Timesheet::class)->count([]));\n }",
" public function testMultiUpdate()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);",
" $user = $this->getUserByRole(User::ROLE_SUPER_ADMIN);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setUser($user);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/timesheet/');",
" $form = $client->getCrawler()->filter('form[name=multi_update_table]')->form();\n $node = $form->getFormNode();\n $node->setAttribute('action', $this->createUrl('/timesheet/multi-update'));",
" $em = $this->getEntityManager();\n /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n $ids = [];\n foreach ($timesheets as $timesheet) {\n self::assertEmpty($timesheet->getTags());\n self::assertFalse($timesheet->isExported());\n $ids[] = $timesheet->getId();\n }",
" $client->submit($form, [\n 'multi_update_table' => [\n 'action' => $this->createUrl('/timesheet/multi-update'),\n 'entities' => implode(',', $ids)\n ]\n ]);\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_multi_update]')->form();\n $client->submit($form, [\n 'timesheet_multi_update' => [\n 'exported' => true,\n 'tags' => 'test, foo-bar',\n 'fixedRate' => 13,\n ]\n ]);",
" $em->clear();",
" /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n foreach ($timesheets as $timesheet) {\n self::assertCount(2, $timesheet->getTags());\n self::assertTrue($timesheet->isExported());\n self::assertEquals(13, $timesheet->getFixedRate());\n }\n }",
" public function testDuplicateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $dateTime = new DateTimeFactory(new \\DateTimeZone('Europe/London'));",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(1);\n $fixture->setAmountRunning(0);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($dateTime->createDateTime());\n $fixture->setCallback(function (Timesheet $timesheet) {\n $timesheet->setDescription('Testing is fun!');\n $begin = clone $timesheet->getBegin();\n $begin->setTime(0, 0, 0);\n $timesheet->setBegin($begin);\n $end = clone $timesheet->getBegin();\n $end->modify('+ 8 hours');\n $timesheet->setEnd($end);\n $timesheet->setFixedRate(2016);\n $timesheet->setHourlyRate(127);\n });",
" /** @var Timesheet[] $ids */\n $ids = $this->importFixture($fixture);\n $newId = $ids[0]->getId();\n",
" $token = self::$container->get('security.csrf.token_manager')->getToken('timesheet.duplicate');",
" $this->request($client, '/timesheet/' . $newId . '/duplicate/' . $token);",
" $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();\n $client->submit($form, $form->getPhpValues());",
" $this->assertIsRedirect($client, $this->createUrl('/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->find($newId++);\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertEquals('Europe/London', $timesheet->getBegin()->getTimezone()->getName());\n $this->assertEquals('Testing is fun!', $timesheet->getDescription());\n $this->assertEquals(2016, $timesheet->getRate());\n $this->assertEquals(127, $timesheet->getHourlyRate());\n $this->assertEquals(2016, $timesheet->getFixedRate());\n $this->assertEquals(2016, $timesheet->getRate());\n }",
"\n public function testDuplicateActionWithInvalidCsrf()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $dateTime = new DateTimeFactory(new \\DateTimeZone('Europe/London'));",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(1);\n $fixture->setAmountRunning(0);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($dateTime->createDateTime());\n $fixture->setCallback(function (Timesheet $timesheet) {\n $timesheet->setDescription('Testing is fun!');\n $begin = clone $timesheet->getBegin();\n $begin->setTime(0, 0, 0);\n $timesheet->setBegin($begin);\n $end = clone $timesheet->getBegin();\n $end->modify('+ 8 hours');\n $timesheet->setEnd($end);\n $timesheet->setFixedRate(2016);\n $timesheet->setHourlyRate(127);\n });",
" /** @var Timesheet[] $ids */\n $ids = $this->importFixture($fixture);\n $newId = $ids[0]->getId();",
" $this->assertInvalidCsrfToken($client, '/timesheet/' . $newId . '/duplicate/dfghdfghdfghdfghdfgh', $this->createUrl('/timesheet/'));\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\Entity\\Timesheet;\nuse App\\Entity\\TimesheetMeta;\nuse App\\Entity\\User;\nuse App\\Form\\Type\\DateRangeType;\nuse App\\Tests\\DataFixtures\\TimesheetFixtures;\nuse App\\Timesheet\\DateTimeFactory;\nuse App\\Timesheet\\Util;",
"/**\n * @group integration\n */\nclass TimesheetTeamControllerTest extends ControllerBaseTest\n{\n public function testIsSecure()\n {\n $this->assertUrlIsSecured('/team/timesheet/');\n }",
" public function testIsSecureForRole()\n {\n $this->assertUrlIsSecuredForRole(User::ROLE_USER, '/team/timesheet/');\n }",
" public function testIndexAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);\n $this->assertAccessIsGranted($client, '/team/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" // there are no records by default in the test database\n $this->assertHasNoEntriesWithFilter($client);",
" $this->assertPageActions($client, [\n 'search' => '#',\n 'visibility' => '#',\n 'download toolbar-action modal-ajax-form' => $this->createUrl('/team/timesheet/export/'),\n 'create-ts modal-ajax-form' => $this->createUrl('/team/timesheet/create'),\n 'create-ts-mu modal-ajax-form' => $this->createUrl('/team/timesheet/create_mu'),\n 'help' => 'https://www.kimai.org/documentation/timesheet.html'\n ]);\n }",
" public function testIndexActionWithQuery()\n {\n // Switching the user is not allowed for TEAMLEADs but ONLLY for admin and super-admins\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $start = new \\DateTime('first day of this month');",
" $em = $this->getEntityManager();\n $user = $this->getUserByRole(User::ROLE_USER);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setAmountRunning(3);\n $fixture->setUser($user);\n $fixture->setStartDate($start);\n $this->importFixture($fixture);",
" $this->request($client, '/team/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime('last day of this month'))->format('Y-m-d');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'state' => 1,\n 'users' => [$user->getId()],\n 'pageSize' => 25,\n 'daterange' => $dateRange,\n 'customers' => [],\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_timesheet_admin', 13);",
" // make sure the recording css class exist on tr for targeting running record rows\n $node = $client->getCrawler()->filter('section.content div.datatable_timesheet_admin table.dataTable tbody tr.recording');\n self::assertEquals(3, $node->count());\n }",
" public function testIndexActionWithSearchTermQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $start = new \\DateTime('first day of this month');",
" $em = $this->getEntityManager();\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($start);\n $fixture->setCallback(function (Timesheet $timesheet) {\n $timesheet->setDescription('I am a foobar with tralalalala some more content');\n $timesheet->setMetaField((new TimesheetMeta())->setName('location')->setValue('homeoffice'));\n $timesheet->setMetaField((new TimesheetMeta())->setName('feature')->setValue('timetracking'));\n });\n $this->importFixture($fixture);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setAmountRunning(5);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($start);\n $this->importFixture($fixture);",
" $this->request($client, '/team/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime('last day of this month'))->format('Y-m-d');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'searchTerm' => 'location:homeoffice foobar',\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_timesheet_admin', 5);\n }",
" public function testExportAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $em = $this->getEntityManager();\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(7);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate(new \\DateTime('-10 days'));\n $this->importFixture($fixture);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(3);\n $fixture->setUser($this->getUserByRole(User::ROLE_TEAMLEAD));\n $fixture->setStartDate(new \\DateTime('-10 days'));\n $this->importFixture($fixture);",
" $this->request($client, '/team/timesheet/export/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = (new \\DateTime('-10 days'))->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime())->format('Y-m-d');",
" $client->submitForm('export-btn-print', [\n 'export' => [\n 'state' => 1,\n 'daterange' => $dateRange,\n 'customers' => [],\n ]\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());",
" $node = $client->getCrawler()->filter('body');\n /** @var \\DOMElement $body */\n $body = $node->getNode(0);\n $this->assertEquals('invoice_print', $body->getAttribute('class'));",
" $result = $node->filter('section.invoice table.table tbody tr');\n $this->assertEquals(10, \\count($result));\n }",
" public function testCreateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/team/timesheet/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_admin_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_admin_edit_form' => [\n 'description' => 'Testing is fun!',\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/team/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertNull($timesheet->getEnd());\n $this->assertEquals('Testing is fun!', $timesheet->getDescription());\n $this->assertEquals(0, $timesheet->getRate());\n $this->assertNull($timesheet->getHourlyRate());\n $this->assertNull($timesheet->getFixedRate());\n }",
" public function testCreateForMultipleUsersAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/team/timesheet/create_mu');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_multi_user_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_multi_user_edit_form' => [\n 'description' => 'Testing is more fun!',\n 'project' => 1,\n 'activity' => 1,\n 'teams' => '1',\n 'tags' => 'test,1234,foo-bar',\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/team/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n $this->assertCount(2, $timesheets);\n foreach ($timesheets as $timesheet) {\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertNull($timesheet->getEnd());\n $this->assertEquals('Testing is more fun!', $timesheet->getDescription());\n $this->assertEquals(0, $timesheet->getRate());\n $this->assertNull($timesheet->getHourlyRate());\n $this->assertNull($timesheet->getFixedRate());\n $this->assertEquals(['test', '1234', 'foo-bar'], $timesheet->getTagsAsArray());\n }\n }",
" public function testCreateForMultipleUsersActionWithoutUserOrTeam()\n {\n $data = [\n 'timesheet_multi_user_edit_form' => [\n 'description' => 'Testing is more fun!',\n 'project' => 1,\n 'activity' => 1,\n // make sure the default validation for timesheets is applied as well\n 'begin' => (new \\DateTime())->format('Y-m-d H:i'),\n 'end' => (new \\DateTime('-1 hour'))->format('Y-m-d H:i'),\n ]\n ];",
" $this->assertFormHasValidationError(\n User::ROLE_ADMIN,\n '/team/timesheet/create_mu',\n 'form[name=timesheet_multi_user_edit_form]',\n $data,\n ['#timesheet_multi_user_edit_form_users', '#timesheet_multi_user_edit_form_teams', '#timesheet_multi_user_edit_form_end']\n );\n }",
" public function testEditAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $user = $this->getUserByRole(User::ROLE_USER);\n $teamlead = $this->getUserByRole(User::ROLE_TEAMLEAD);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setUser($user);\n $fixture->setFixedStartDate(new \\DateTime('-2 hours'));\n $timesheets = $this->importFixture($fixture);\n $id = $timesheets[0]->getId();",
" $this->request($client, '/team/timesheet/' . $id . '/edit');",
" $response = $client->getResponse();\n $this->assertTrue($response->isSuccessful());",
" $this->assertStringContainsString(\n 'href=\"https://www.kimai.org/documentation/timesheet.html\"',\n $response->getContent(),\n 'Could not find link to documentation'\n );",
" $form = $client->getCrawler()->filter('form[name=timesheet_admin_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_admin_edit_form' => [\n 'description' => 'foo-bar',\n 'tags' => 'foo,bar, testing, hello world,,',\n 'user' => $teamlead->getId()\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/team/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSaveSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->find($id);\n $this->assertEquals('foo-bar', $timesheet->getDescription());\n $this->assertEquals($teamlead->getId(), $timesheet->getUser()->getId());\n }",
" public function testMultiDeleteAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);",
" $em = $this->getEntityManager();\n $user = $this->getUserByRole(User::ROLE_TEAMLEAD);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setUser($user);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/team/timesheet/');",
" $form = $client->getCrawler()->filter('form[name=multi_update_table]')->form();\n $node = $form->getFormNode();\n $node->setAttribute('action', $this->createUrl('/team/timesheet/multi-delete'));",
" $em = $this->getEntityManager();\n /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n $ids = [];\n foreach ($timesheets as $timesheet) {\n $ids[] = $timesheet->getId();\n }",
" $client->submit($form, [\n 'multi_update_table' => [\n 'action' => $this->createUrl('/team/timesheet/multi-delete'),\n 'entities' => implode(',', $ids)\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/team/timesheet/'));\n $client->followRedirect();",
" $em->clear();\n self::assertEquals(0, $em->getRepository(Timesheet::class)->count([]));\n }",
" public function testMultiUpdate()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);",
" $em = $this->getEntityManager();\n $user = $this->getUserByRole(User::ROLE_TEAMLEAD);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setUser($user);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/team/timesheet/');",
" $form = $client->getCrawler()->filter('form[name=multi_update_table]')->form();\n $node = $form->getFormNode();\n $node->setAttribute('action', $this->createUrl('/team/timesheet/multi-update'));",
" $em = $this->getEntityManager();\n /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n $ids = [];\n foreach ($timesheets as $timesheet) {\n self::assertFalse($timesheet->isExported());\n self::assertEquals($user->getId(), $timesheet->getUser()->getId());\n $ids[] = $timesheet->getId();\n }",
" $client->submit($form, [\n 'multi_update_table' => [\n 'action' => $this->createUrl('/team/timesheet/multi-update'),\n 'entities' => implode(',', $ids)\n ]\n ]);\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $newUser = $this->getUserByRole(User::ROLE_USER);\n $form = $client->getCrawler()->filter('form[name=timesheet_multi_update]')->form();\n $client->submit($form, [\n 'timesheet_multi_update' => [\n 'user' => $newUser->getId(),\n 'exported' => true,\n 'replaceTags' => true,\n 'tags' => 'test, foo-bar, tralalala',\n 'hourlyRate' => 13.78,\n ]\n ]);",
" $em->clear();",
" /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n foreach ($timesheets as $timesheet) {\n self::assertCount(3, $timesheet->getTags());\n self::assertEquals($newUser->getId(), $timesheet->getUser()->getId());\n self::assertTrue($timesheet->isExported());\n self::assertEquals(Util::calculateRate(13.78, $timesheet->getDuration()), $timesheet->getRate());\n }\n }",
" public function testDuplicateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $dateTime = new DateTimeFactory(new \\DateTimeZone('Europe/London'));",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(1);\n $fixture->setAmountRunning(0);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($dateTime->createDateTime());\n $fixture->setCallback(function (Timesheet $timesheet) {\n $timesheet->setDescription('Testing is fun!');\n $begin = clone $timesheet->getBegin();\n $begin->setTime(0, 0, 0);\n $timesheet->setBegin($begin);\n $end = clone $timesheet->getBegin();\n $end->modify('+ 8 hours');\n $timesheet->setEnd($end);\n $timesheet->setFixedRate(2016);\n $timesheet->setHourlyRate(127);\n });",
" /** @var Timesheet[] $ids */\n $ids = $this->importFixture($fixture);\n $newId = $ids[0]->getId();\n",
" $this->request($client, '/team/timesheet/' . $newId . '/duplicate');",
" $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_admin_edit_form]')->form();\n $client->submit($form, $form->getPhpValues());",
" $this->assertIsRedirect($client, $this->createUrl('/team/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->find($newId++);\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertEquals('Europe/London', $timesheet->getBegin()->getTimezone()->getName());\n $this->assertEquals('Testing is fun!', $timesheet->getDescription());\n $this->assertEquals(2016, $timesheet->getRate());\n $this->assertEquals(127, $timesheet->getHourlyRate());\n $this->assertEquals(2016, $timesheet->getFixedRate());\n $this->assertEquals(2016, $timesheet->getRate());\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,
0,
1,
1,
1,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php",
"/*\n * This file is part of the Kimai time-tracking app.\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */",
"namespace App\\Tests\\Controller;",
"use App\\Entity\\Timesheet;\nuse App\\Entity\\TimesheetMeta;\nuse App\\Entity\\User;\nuse App\\Form\\Type\\DateRangeType;\nuse App\\Tests\\DataFixtures\\TimesheetFixtures;\nuse App\\Timesheet\\DateTimeFactory;\nuse App\\Timesheet\\Util;",
"/**\n * @group integration\n */\nclass TimesheetTeamControllerTest extends ControllerBaseTest\n{\n public function testIsSecure()\n {\n $this->assertUrlIsSecured('/team/timesheet/');\n }",
" public function testIsSecureForRole()\n {\n $this->assertUrlIsSecuredForRole(User::ROLE_USER, '/team/timesheet/');\n }",
" public function testIndexAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);\n $this->assertAccessIsGranted($client, '/team/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" // there are no records by default in the test database\n $this->assertHasNoEntriesWithFilter($client);",
" $this->assertPageActions($client, [\n 'search' => '#',\n 'visibility' => '#',\n 'download toolbar-action modal-ajax-form' => $this->createUrl('/team/timesheet/export/'),\n 'create-ts modal-ajax-form' => $this->createUrl('/team/timesheet/create'),\n 'create-ts-mu modal-ajax-form' => $this->createUrl('/team/timesheet/create_mu'),\n 'help' => 'https://www.kimai.org/documentation/timesheet.html'\n ]);\n }",
" public function testIndexActionWithQuery()\n {\n // Switching the user is not allowed for TEAMLEADs but ONLLY for admin and super-admins\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $start = new \\DateTime('first day of this month');",
" $em = $this->getEntityManager();\n $user = $this->getUserByRole(User::ROLE_USER);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setAmountRunning(3);\n $fixture->setUser($user);\n $fixture->setStartDate($start);\n $this->importFixture($fixture);",
" $this->request($client, '/team/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime('last day of this month'))->format('Y-m-d');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'state' => 1,\n 'users' => [$user->getId()],\n 'pageSize' => 25,\n 'daterange' => $dateRange,\n 'customers' => [],\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_timesheet_admin', 13);",
" // make sure the recording css class exist on tr for targeting running record rows\n $node = $client->getCrawler()->filter('section.content div.datatable_timesheet_admin table.dataTable tbody tr.recording');\n self::assertEquals(3, $node->count());\n }",
" public function testIndexActionWithSearchTermQuery()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $start = new \\DateTime('first day of this month');",
" $em = $this->getEntityManager();\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($start);\n $fixture->setCallback(function (Timesheet $timesheet) {\n $timesheet->setDescription('I am a foobar with tralalalala some more content');\n $timesheet->setMetaField((new TimesheetMeta())->setName('location')->setValue('homeoffice'));\n $timesheet->setMetaField((new TimesheetMeta())->setName('feature')->setValue('timetracking'));\n });\n $this->importFixture($fixture);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(5);\n $fixture->setAmountRunning(5);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($start);\n $this->importFixture($fixture);",
" $this->request($client, '/team/timesheet/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = ($start)->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime('last day of this month'))->format('Y-m-d');",
" $form = $client->getCrawler()->filter('form.searchform')->form();\n $client->submit($form, [\n 'searchTerm' => 'location:homeoffice foobar',\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasDataTable($client);\n $this->assertDataTableRowCount($client, 'datatable_timesheet_admin', 5);\n }",
" public function testExportAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $em = $this->getEntityManager();\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(7);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate(new \\DateTime('-10 days'));\n $this->importFixture($fixture);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(3);\n $fixture->setUser($this->getUserByRole(User::ROLE_TEAMLEAD));\n $fixture->setStartDate(new \\DateTime('-10 days'));\n $this->importFixture($fixture);",
" $this->request($client, '/team/timesheet/export/');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $dateRange = (new \\DateTime('-10 days'))->format('Y-m-d') . DateRangeType::DATE_SPACER . (new \\DateTime())->format('Y-m-d');",
" $client->submitForm('export-btn-print', [\n 'export' => [\n 'state' => 1,\n 'daterange' => $dateRange,\n 'customers' => [],\n ]\n ]);",
" $this->assertTrue($client->getResponse()->isSuccessful());",
" $node = $client->getCrawler()->filter('body');\n /** @var \\DOMElement $body */\n $body = $node->getNode(0);\n $this->assertEquals('invoice_print', $body->getAttribute('class'));",
" $result = $node->filter('section.invoice table.table tbody tr');\n $this->assertEquals(10, \\count($result));\n }",
" public function testCreateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/team/timesheet/create');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_admin_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_admin_edit_form' => [\n 'description' => 'Testing is fun!',\n 'project' => 1,\n 'activity' => 1,\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/team/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->findAll()[0];\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertNull($timesheet->getEnd());\n $this->assertEquals('Testing is fun!', $timesheet->getDescription());\n $this->assertEquals(0, $timesheet->getRate());\n $this->assertNull($timesheet->getHourlyRate());\n $this->assertNull($timesheet->getFixedRate());\n }",
" public function testCreateForMultipleUsersAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $this->request($client, '/team/timesheet/create_mu');\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_multi_user_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_multi_user_edit_form' => [\n 'description' => 'Testing is more fun!',\n 'project' => 1,\n 'activity' => 1,\n 'teams' => '1',\n 'tags' => 'test,1234,foo-bar',\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/team/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n $this->assertCount(2, $timesheets);\n foreach ($timesheets as $timesheet) {\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertNull($timesheet->getEnd());\n $this->assertEquals('Testing is more fun!', $timesheet->getDescription());\n $this->assertEquals(0, $timesheet->getRate());\n $this->assertNull($timesheet->getHourlyRate());\n $this->assertNull($timesheet->getFixedRate());\n $this->assertEquals(['test', '1234', 'foo-bar'], $timesheet->getTagsAsArray());\n }\n }",
" public function testCreateForMultipleUsersActionWithoutUserOrTeam()\n {\n $data = [\n 'timesheet_multi_user_edit_form' => [\n 'description' => 'Testing is more fun!',\n 'project' => 1,\n 'activity' => 1,\n // make sure the default validation for timesheets is applied as well\n 'begin' => (new \\DateTime())->format('Y-m-d H:i'),\n 'end' => (new \\DateTime('-1 hour'))->format('Y-m-d H:i'),\n ]\n ];",
" $this->assertFormHasValidationError(\n User::ROLE_ADMIN,\n '/team/timesheet/create_mu',\n 'form[name=timesheet_multi_user_edit_form]',\n $data,\n ['#timesheet_multi_user_edit_form_users', '#timesheet_multi_user_edit_form_teams', '#timesheet_multi_user_edit_form_end']\n );\n }",
" public function testEditAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);",
" $user = $this->getUserByRole(User::ROLE_USER);\n $teamlead = $this->getUserByRole(User::ROLE_TEAMLEAD);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setUser($user);\n $fixture->setFixedStartDate(new \\DateTime('-2 hours'));\n $timesheets = $this->importFixture($fixture);\n $id = $timesheets[0]->getId();",
" $this->request($client, '/team/timesheet/' . $id . '/edit');",
" $response = $client->getResponse();\n $this->assertTrue($response->isSuccessful());",
" $this->assertStringContainsString(\n 'href=\"https://www.kimai.org/documentation/timesheet.html\"',\n $response->getContent(),\n 'Could not find link to documentation'\n );",
" $form = $client->getCrawler()->filter('form[name=timesheet_admin_edit_form]')->form();\n $client->submit($form, [\n 'timesheet_admin_edit_form' => [\n 'description' => 'foo-bar',\n 'tags' => 'foo,bar, testing, hello world,,',\n 'user' => $teamlead->getId()\n ]\n ]);",
" $this->assertIsRedirect($client, $this->createUrl('/team/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSaveSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->find($id);\n $this->assertEquals('foo-bar', $timesheet->getDescription());\n $this->assertEquals($teamlead->getId(), $timesheet->getUser()->getId());\n }",
" public function testMultiDeleteAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);",
" $em = $this->getEntityManager();\n $user = $this->getUserByRole(User::ROLE_TEAMLEAD);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setUser($user);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/team/timesheet/');",
" $form = $client->getCrawler()->filter('form[name=multi_update_table]')->form();\n $node = $form->getFormNode();\n $node->setAttribute('action', $this->createUrl('/team/timesheet/multi-delete'));",
" $em = $this->getEntityManager();\n /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n $ids = [];\n foreach ($timesheets as $timesheet) {\n $ids[] = $timesheet->getId();\n }",
" $client->submit($form, [\n 'multi_update_table' => [\n 'action' => $this->createUrl('/team/timesheet/multi-delete'),\n 'entities' => implode(',', $ids)\n ]\n ]);\n $this->assertIsRedirect($client, $this->createUrl('/team/timesheet/'));\n $client->followRedirect();",
" $em->clear();\n self::assertEquals(0, $em->getRepository(Timesheet::class)->count([]));\n }",
" public function testMultiUpdate()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);",
" $em = $this->getEntityManager();\n $user = $this->getUserByRole(User::ROLE_TEAMLEAD);\n $fixture = new TimesheetFixtures();\n $fixture->setAmount(10);\n $fixture->setUser($user);\n $this->importFixture($fixture);",
" $this->assertAccessIsGranted($client, '/team/timesheet/');",
" $form = $client->getCrawler()->filter('form[name=multi_update_table]')->form();\n $node = $form->getFormNode();\n $node->setAttribute('action', $this->createUrl('/team/timesheet/multi-update'));",
" $em = $this->getEntityManager();\n /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n $ids = [];\n foreach ($timesheets as $timesheet) {\n self::assertFalse($timesheet->isExported());\n self::assertEquals($user->getId(), $timesheet->getUser()->getId());\n $ids[] = $timesheet->getId();\n }",
" $client->submit($form, [\n 'multi_update_table' => [\n 'action' => $this->createUrl('/team/timesheet/multi-update'),\n 'entities' => implode(',', $ids)\n ]\n ]);\n $this->assertTrue($client->getResponse()->isSuccessful());",
" $newUser = $this->getUserByRole(User::ROLE_USER);\n $form = $client->getCrawler()->filter('form[name=timesheet_multi_update]')->form();\n $client->submit($form, [\n 'timesheet_multi_update' => [\n 'user' => $newUser->getId(),\n 'exported' => true,\n 'replaceTags' => true,\n 'tags' => 'test, foo-bar, tralalala',\n 'hourlyRate' => 13.78,\n ]\n ]);",
" $em->clear();",
" /** @var Timesheet[] $timesheets */\n $timesheets = $em->getRepository(Timesheet::class)->findAll();\n self::assertCount(10, $timesheets);\n foreach ($timesheets as $timesheet) {\n self::assertCount(3, $timesheet->getTags());\n self::assertEquals($newUser->getId(), $timesheet->getUser()->getId());\n self::assertTrue($timesheet->isExported());\n self::assertEquals(Util::calculateRate(13.78, $timesheet->getDuration()), $timesheet->getRate());\n }\n }",
" public function testDuplicateAction()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $dateTime = new DateTimeFactory(new \\DateTimeZone('Europe/London'));",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(1);\n $fixture->setAmountRunning(0);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($dateTime->createDateTime());\n $fixture->setCallback(function (Timesheet $timesheet) {\n $timesheet->setDescription('Testing is fun!');\n $begin = clone $timesheet->getBegin();\n $begin->setTime(0, 0, 0);\n $timesheet->setBegin($begin);\n $end = clone $timesheet->getBegin();\n $end->modify('+ 8 hours');\n $timesheet->setEnd($end);\n $timesheet->setFixedRate(2016);\n $timesheet->setHourlyRate(127);\n });",
" /** @var Timesheet[] $ids */\n $ids = $this->importFixture($fixture);\n $newId = $ids[0]->getId();\n",
" $token = self::$container->get('security.csrf.token_manager')->getToken('admin_timesheet.duplicate');",
" $this->request($client, '/team/timesheet/' . $newId . '/duplicate/' . $token);",
" $this->assertTrue($client->getResponse()->isSuccessful());",
" $form = $client->getCrawler()->filter('form[name=timesheet_admin_edit_form]')->form();\n $client->submit($form, $form->getPhpValues());",
" $this->assertIsRedirect($client, $this->createUrl('/team/timesheet/'));\n $client->followRedirect();\n $this->assertTrue($client->getResponse()->isSuccessful());\n $this->assertHasFlashSuccess($client);",
" $em = $this->getEntityManager();\n /** @var Timesheet $timesheet */\n $timesheet = $em->getRepository(Timesheet::class)->find($newId++);\n $this->assertInstanceOf(\\DateTime::class, $timesheet->getBegin());\n $this->assertEquals('Europe/London', $timesheet->getBegin()->getTimezone()->getName());\n $this->assertEquals('Testing is fun!', $timesheet->getDescription());\n $this->assertEquals(2016, $timesheet->getRate());\n $this->assertEquals(127, $timesheet->getHourlyRate());\n $this->assertEquals(2016, $timesheet->getFixedRate());\n $this->assertEquals(2016, $timesheet->getRate());\n }",
"\n public function testDuplicateActionWithInvalidCsrf()\n {\n $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);\n $dateTime = new DateTimeFactory(new \\DateTimeZone('Europe/London'));",
" $fixture = new TimesheetFixtures();\n $fixture->setAmount(1);\n $fixture->setAmountRunning(0);\n $fixture->setUser($this->getUserByRole(User::ROLE_USER));\n $fixture->setStartDate($dateTime->createDateTime());\n $fixture->setCallback(function (Timesheet $timesheet) {\n $timesheet->setDescription('Testing is fun!');\n $begin = clone $timesheet->getBegin();\n $begin->setTime(0, 0, 0);\n $timesheet->setBegin($begin);\n $end = clone $timesheet->getBegin();\n $end->modify('+ 8 hours');\n $timesheet->setEnd($end);\n $timesheet->setFixedRate(2016);\n $timesheet->setHourlyRate(127);\n });",
" /** @var Timesheet[] $ids */\n $ids = $this->importFixture($fixture);\n $newId = $ids[0]->getId();",
" $this->assertInvalidCsrfToken($client, '/team/timesheet/' . $newId . '/duplicate/dfghdfghdfghdfghdfgh', $this->createUrl('/team/timesheet/'));\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"utf-8\"?>",
"<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"ja\" datatype=\"plaintext\" original=\"about.en.xlf\">\n <body>\n <trans-unit id=\"3Clo55j\" resname=\"about.title\">\n <source>about.title</source>\n <target>Kimai について</target>\n </trans-unit>\n <trans-unit id=\"oYYDCG5\" resname=\"support\">\n <source>support</source>\n <target>サポート</target>\n </trans-unit>\n <trans-unit id=\"dHqPOYO\" resname=\"website\">\n <source>website</source>\n <target>ホームページ</target>\n </trans-unit>\n <trans-unit id=\"EGpYQvx\" resname=\"help\">\n <source>help</source>\n <target>ドキュメント</target>\n </trans-unit>\n <trans-unit id=\"mz4ieCN\" resname=\"donate\">\n <source>donate</source>\n <target>Kimai の発展のために寄付を行う</target>\n </trans-unit>\n <trans-unit id=\"DwbowBh\" resname=\"published_under\">\n <source>published_under</source>\n <target>%kimai% は次のもとに公開されています</target>\n </trans-unit>\n <trans-unit id=\"A0nWoXZ\" resname=\"special_thanks\">\n <source>special_thanks</source>",
" <target>Special thanks go to …</target>",
" </trans-unit>\n <trans-unit id=\"L7cff3Q\" resname=\"library_authors\">\n <source>library_authors</source>\n <target>… これらのソフトウェア・ライブラリなくして Kimai は実現できませんでした。作成者の方々に感謝します 👍</target>\n </trans-unit>\n </body>\n </file>\n</xliff>"
] |
[
0,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"ja\" datatype=\"plaintext\" original=\"about.en.xlf\">\n <body>\n <trans-unit id=\"3Clo55j\" resname=\"about.title\">\n <source>about.title</source>\n <target>Kimai について</target>\n </trans-unit>\n <trans-unit id=\"oYYDCG5\" resname=\"support\">\n <source>support</source>\n <target>サポート</target>\n </trans-unit>\n <trans-unit id=\"dHqPOYO\" resname=\"website\">\n <source>website</source>\n <target>ホームページ</target>\n </trans-unit>\n <trans-unit id=\"EGpYQvx\" resname=\"help\">\n <source>help</source>\n <target>ドキュメント</target>\n </trans-unit>\n <trans-unit id=\"mz4ieCN\" resname=\"donate\">\n <source>donate</source>\n <target>Kimai の発展のために寄付を行う</target>\n </trans-unit>\n <trans-unit id=\"DwbowBh\" resname=\"published_under\">\n <source>published_under</source>\n <target>%kimai% は次のもとに公開されています</target>\n </trans-unit>\n <trans-unit id=\"A0nWoXZ\" resname=\"special_thanks\">\n <source>special_thanks</source>",
" <target>これらの方々に特に感謝いたします。</target>",
" </trans-unit>\n <trans-unit id=\"L7cff3Q\" resname=\"library_authors\">\n <source>library_authors</source>\n <target>… これらのソフトウェア・ライブラリなくして Kimai は実現できませんでした。作成者の方々に感謝します 👍</target>\n </trans-unit>\n </body>\n </file>\n</xliff>"
] |
[
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"utf-8\"?>",
"<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"el\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target>Προειδοποίηση</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target>Η καταγραφή ωραρίου σταμάτησε</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target>Η καταγραφή ωραρίου δεν μπόρεσε να σταματήσει</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target>Η καταγραφή ωραρίου ξεκίνησε</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target>Η καταγραφή ωραρίου δεν μπόρεσε να ξεκινήσει</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target>Έχει συμπληρωθεί το όριο των ενεργών καταγραφών ωραρίου, παρακαλούμε σταματήστε τουλάχιστον μία εκτελούμενη μέτρηση ωραρίου.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target>Η εγγραφή που επεξεργάζεστε έχει ήδη εξαχθεί</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target>Αποθηκευμένες αλλαγές</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target>Δεν ήταν δυνατή η αποθήκευση των αλλαγών: %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target>Η καταχώριση διαγράφηκε</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target>Η καταχώριση δεν ήταν δυνατό να διαγραφεί: %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target>Παρακαλούμε δημιουργήστε πρώτα ένα πρότυπο τιμολογίου</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>Δεν ήταν δυνατή η μεταφόρτωση ή η αποθήκευση του αρχείου: %reason%</target>\n </trans-unit>",
"",
" </body>\n </file>\n</xliff>"
] |
[
0,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"el\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target>Προειδοποίηση</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target>Η καταγραφή ωραρίου σταμάτησε</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target>Η καταγραφή ωραρίου δεν μπόρεσε να σταματήσει</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target>Η καταγραφή ωραρίου ξεκίνησε</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target>Η καταγραφή ωραρίου δεν μπόρεσε να ξεκινήσει</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target>Έχει συμπληρωθεί το όριο των ενεργών καταγραφών ωραρίου, παρακαλούμε σταματήστε τουλάχιστον μία εκτελούμενη μέτρηση ωραρίου.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target>Η εγγραφή που επεξεργάζεστε έχει ήδη εξαχθεί</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target>Αποθηκευμένες αλλαγές</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target>Δεν ήταν δυνατή η αποθήκευση των αλλαγών: %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target>Η καταχώριση διαγράφηκε</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target>Η καταχώριση δεν ήταν δυνατό να διαγραφεί: %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target>Παρακαλούμε δημιουργήστε πρώτα ένα πρότυπο τιμολογίου</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>Δεν ήταν δυνατή η μεταφόρτωση ή η αποθήκευση του αρχείου: %reason%</target>\n </trans-unit>",
" <trans-unit resname=\"action.csrf.error\" id=\"bOE_q5R\">\n <source>action.csrf.error</source>\n <target>Αυτή η ενέργεια δεν μπορεί να πραγματοποιηθεί: Μη έγκυρο τεκμήριο ασφάλειας.</target>\n </trans-unit>",
" </body>\n </file>\n</xliff>"
] |
[
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"fr\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target>Avertissement</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target>Le chronomètre a été arrêté</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target>Le chronomètre ne peut pas être arrêté</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target>Le chronométrage a commencé</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target>Le chronométrage ne peut pas être lancé</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target>La limite d'enregistrement du temps d'activité a été atteinte, veuillez arrêter au moins un enregistrement.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target>Vous modifiez un enregistrement que vous avez exporté</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target>Modifications enregistrées</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target>Les modifications n'ont pas pu êtres enregistrées : %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target>L'entrée a été supprimée</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target>L'entrée n'a pas pu être supprimée : %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target>Vous devez créer votre premier modèle de facture avant de continuer</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>Le fichier n'a pas pu être mis en ligne ou enregistré : %reason%</target>\n </trans-unit>",
"",
" </body>\n </file>\n</xliff>"
] |
[
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"fr\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target>Avertissement</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target>Le chronomètre a été arrêté</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target>Le chronomètre ne peut pas être arrêté</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target>Le chronométrage a commencé</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target>Le chronométrage ne peut pas être lancé</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target>La limite d'enregistrement du temps d'activité a été atteinte, veuillez arrêter au moins un enregistrement.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target>Vous modifiez un enregistrement que vous avez exporté</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target>Modifications enregistrées</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target>Les modifications n'ont pas pu êtres enregistrées : %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target>L'entrée a été supprimée</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target>L'entrée n'a pas pu être supprimée : %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target>Vous devez créer votre premier modèle de facture avant de continuer</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>Le fichier n'a pas pu être mis en ligne ou enregistré : %reason%</target>\n </trans-unit>",
" <trans-unit resname=\"action.csrf.error\" id=\"bOE_q5R\">\n <source>action.csrf.error</source>\n <target>L'action n'a pas pu être effectuée : jeton de sécurité invalide.</target>\n </trans-unit>",
" </body>\n </file>\n</xliff>"
] |
[
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"he\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target>אזהרה</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target>הקלטת זמן נעצרה</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target>לא ניתן לעצור הקלטת זמן</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target>הקלטת זמן החלה</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target>לא ניתן להתחיל הקלטת זמן</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target>הגעת למגבלת כמות רשומות זמן פעילות. אנא עצור לפחות רשומת זמן אחת.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target>אתה עורך רשומה שכבר יוצאה</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target>השינויים נשמרו</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target>לא ניתן לשמור את השינויים: %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target>הרשומה נמחקה</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target>לא ניתן למחוק את הרשומה: %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target>אנא צור קודם תבנית חשבונית</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>לא ניתן להעלות או לשמור את הקובץ: %reason%</target>\n </trans-unit>",
"",
" </body>\n </file>\n</xliff>"
] |
[
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"he\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target>אזהרה</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target>הקלטת זמן נעצרה</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target>לא ניתן לעצור הקלטת זמן</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target>הקלטת זמן החלה</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target>לא ניתן להתחיל הקלטת זמן</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target>הגעת למגבלת כמות רשומות זמן פעילות. אנא עצור לפחות רשומת זמן אחת.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target>אתה עורך רשומה שכבר יוצאה</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target>השינויים נשמרו</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target>לא ניתן לשמור את השינויים: %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target>הרשומה נמחקה</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target>לא ניתן למחוק את הרשומה: %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target>אנא צור קודם תבנית חשבונית</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>לא ניתן להעלות או לשמור את הקובץ: %reason%</target>\n </trans-unit>",
" <trans-unit resname=\"action.csrf.error\" id=\"bOE_q5R\">\n <source>action.csrf.error</source>\n <target>אי אפשר לבצע את הפעולה: אסימון אבטחה שגוי.</target>\n </trans-unit>",
" </body>\n </file>\n</xliff>"
] |
[
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"pt\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target>Aviso</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target>A gravação de tempo foi interrompida</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target>Não foi possível interromper a gravação de tempo</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target>A gravação de tempo foi iniciada</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target>Não foi possível iniciar a gravação de tempo</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target>Foi atingido o limite de registos de tempo ativos. Pare primeiro pelo menos uma medição de tempo de execução.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target>Está a editar um registo exportado</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target>Alterações guardadas com sucesso</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target>As alterações não puderam ser guardadas: %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target>A entrada foi eliminada</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target>A entrada não pode ser eliminada: %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target>Crie primeiro um modelo de fatura</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>Não foi possível enviar ou guardar o ficheiro: %reason%</target>\n </trans-unit>",
"",
" </body>\n </file>\n</xliff>"
] |
[
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"pt\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target>Aviso</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target>A gravação de tempo foi interrompida</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target>Não foi possível interromper a gravação de tempo</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target>A gravação de tempo foi iniciada</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target>Não foi possível iniciar a gravação de tempo</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target>Foi atingido o limite de registos de tempo ativos. Pare primeiro pelo menos uma medição de tempo de execução.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target>Está a editar um registo exportado</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target>Alterações guardadas com sucesso</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target>As alterações não puderam ser guardadas: %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target>A entrada foi eliminada</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target>A entrada não pode ser eliminada: %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target>Crie primeiro um modelo de fatura</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>Não foi possível enviar ou guardar o ficheiro: %reason%</target>\n </trans-unit>",
" <trans-unit resname=\"action.csrf.error\" id=\"bOE_q5R\">\n <source>action.csrf.error</source>\n <target>Não foi possível realizar a ação: token de segurança inválido.</target>\n </trans-unit>",
" </body>\n </file>\n</xliff>"
] |
[
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"pt-BR\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target>Aviso</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target>A gravação de tempo foi interrompida</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target>A gravação de tempo não pôde ser interrompida</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target>A gravação de tempo foi iniciada</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target>A gravação de tempo não pôde ser iniciada</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target>O limite de registros de tempo ativos foi atingido, por favor, pare pelo menos uma medição de tempo de execução primeiro.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target>Você está editando um registro exportado</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target>Alterações salvas com sucesso</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target>As alterações não puderam ser salvas: %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target>A entrada foi excluída com sucesso</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target>A entrada não pode ser excluída: %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target>Você precisa criar sua primeira fatura modelo antes de prosseguir</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>O arquivo não pôde ser carregado ou salvo: %reason%</target>\n </trans-unit>",
"",
" </body>\n </file>\n</xliff>"
] |
[
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"pt-BR\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target>Aviso</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target>A gravação de tempo foi interrompida</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target>A gravação de tempo não pôde ser interrompida</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target>A gravação de tempo foi iniciada</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target>A gravação de tempo não pôde ser iniciada</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target>O limite de registros de tempo ativos foi atingido, por favor, pare pelo menos uma medição de tempo de execução primeiro.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target>Você está editando um registro exportado</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target>Alterações salvas com sucesso</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target>As alterações não puderam ser salvas: %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target>A entrada foi excluída com sucesso</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target>A entrada não pode ser excluída: %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target>Você precisa criar sua primeira fatura modelo antes de prosseguir</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>O arquivo não pôde ser carregado ou salvo: %reason%</target>\n </trans-unit>",
" <trans-unit resname=\"action.csrf.error\" id=\"bOE_q5R\">\n <source>action.csrf.error</source>\n <target>A ação não pôde ser realizada: token de segurança inválido.</target>\n </trans-unit>",
" </body>\n </file>\n</xliff>"
] |
[
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"tr\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target state=\"translated\">Uyarı</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target state=\"translated\">Zaman kaydı durduruldu</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target state=\"translated\">Zaman kaydı durdurulamadı</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target state=\"translated\">Zaman kaydı başlatıldı</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target state=\"translated\">Zaman kaydı başlatılamadı</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target state=\"translated\">Etkin zaman kayıtlarının sınırına ulaşıldı, lütfen önce en az bir çalışan zaman ölçümünü durdurun.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target state=\"translated\">Dışa aktarılan bir kaydı düzenliyorsunuz</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target state=\"translated\">Değişiklikler kaydedildi</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target state=\"translated\">Değişiklikler kaydedilemedİ: %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target state=\"translated\">Kayıt silindi</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target state=\"translated\">Kayıt silinemedi: %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target state=\"translated\">Devam edebilmek için fatura şablonu oluşturmanız gereklidir</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>Dosya karşıya yüklenemedi veya kaydedilemedi: %reason%</target>\n </trans-unit>",
"",
" </body>\n </file>\n</xliff>"
] |
[
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"tr\" datatype=\"plaintext\" original=\"flashmessages.en.xlf\">\n <body>\n <trans-unit id=\"S9k1S7Z\" resname=\"warning\">\n <source>warning</source>\n <target state=\"translated\">Uyarı</target>\n </trans-unit>\n <trans-unit id=\"WmrEP_5\" resname=\"timesheet.stop.success\">\n <source>timesheet.stop.success</source>\n <target state=\"translated\">Zaman kaydı durduruldu</target>\n </trans-unit>\n <trans-unit id=\"NPBnpK_\" resname=\"timesheet.stop.error\">\n <source>timesheet.stop.error</source>\n <target state=\"translated\">Zaman kaydı durdurulamadı</target>\n </trans-unit>\n <trans-unit id=\"CCUoZga\" resname=\"timesheet.start.success\">\n <source>timesheet.start.success</source>\n <target state=\"translated\">Zaman kaydı başlatıldı</target>\n </trans-unit>\n <trans-unit id=\"3w9tuox\" resname=\"timesheet.start.error\">\n <source>timesheet.start.error</source>\n <target state=\"translated\">Zaman kaydı başlatılamadı</target>\n </trans-unit>\n <trans-unit id=\"srhs0gp\" resname=\"timesheet.start.exceeded_limit\">\n <source>timesheet.start.exceeded_limit</source>\n <target state=\"translated\">Etkin zaman kayıtlarının sınırına ulaşıldı, lütfen önce en az bir çalışan zaman ölçümünü durdurun.</target>\n </trans-unit>\n <trans-unit id=\"kPINWEK\" resname=\"timesheet.locked.warning\">\n <source>timesheet.locked.warning</source>\n <target state=\"translated\">Dışa aktarılan bir kaydı düzenliyorsunuz</target>\n </trans-unit>\n <trans-unit id=\"72Ih8zO\" resname=\"action.update.success\">\n <source>action.update.success</source>\n <target state=\"translated\">Değişiklikler kaydedildi</target>\n </trans-unit>\n <trans-unit id=\"xeu1LSy\" resname=\"action.update.error\">\n <source>action.update.error</source>\n <target state=\"translated\">Değişiklikler kaydedilemedİ: %reason%</target>\n </trans-unit>\n <trans-unit id=\"YV50HDB\" resname=\"action.delete.success\">\n <source>action.delete.success</source>\n <target state=\"translated\">Kayıt silindi</target>\n </trans-unit>\n <trans-unit id=\"mW91Tmb\" resname=\"action.delete.error\">\n <source>action.delete.error</source>\n <target state=\"translated\">Kayıt silinemedi: %reason%</target>\n </trans-unit>\n <trans-unit id=\"B_cz49z\" resname=\"invoice.first_template\">\n <source>invoice.first_template</source>\n <target state=\"translated\">Devam edebilmek için fatura şablonu oluşturmanız gereklidir</target>\n </trans-unit>\n <trans-unit id=\"wejAEcR\" resname=\"action.upload.error\">\n <source>action.upload.error</source>\n <target>Dosya karşıya yüklenemedi veya kaydedilemedi: %reason%</target>\n </trans-unit>",
" <trans-unit resname=\"action.csrf.error\" id=\"bOE_q5R\">\n <source>action.csrf.error</source>\n <target>Eylem gerçekleştirilemedi: geçersiz güvenlik belirteci.</target>\n </trans-unit>",
" </body>\n </file>\n</xliff>"
] |
[
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"de\" datatype=\"plaintext\" original=\"messages.en.xlf\">\n <body>\n <!--\n Global template keys\n -->\n <trans-unit id=\"N7mikjJ\" resname=\"time_tracking\">\n <source>time_tracking</source>\n <target>Zeiterfassung</target>\n </trans-unit>\n <trans-unit id=\"inmIkP6\" resname=\"yes\">\n <source>yes</source>\n <target>Ja</target>\n </trans-unit>\n <trans-unit id=\"k5Apjz_\" resname=\"no\">\n <source>no</source>\n <target>Nein</target>\n </trans-unit>\n <trans-unit id=\".3dyBTq\" resname=\"both\">\n <source>both</source>\n <target>Beides</target>\n </trans-unit>\n <trans-unit id=\"KLIuHvt\" resname=\"This is a mandatory field\">\n <source>This is a mandatory field</source>\n <target>Pflichtfeld</target>\n </trans-unit>\n <trans-unit id=\"_ohHsMM\" resname=\"create\">\n <source>create</source>\n <target>Erstellen</target>\n </trans-unit>\n <trans-unit id=\"DYHuW58\" resname=\"confirm.delete\">\n <source>confirm.delete</source>\n <target>Wollen Sie das wirklich löschen?</target>\n </trans-unit>\n <trans-unit id=\"vDd3alC\" resname=\"admin_entity.delete_confirm\">\n <source>admin_entity.delete_confirm</source>\n <target>\n Diese Daten werden ebenfalls mit gelöscht!\n Alternativ können Sie einen Eintrag auswählen, auf den alle existierenden Daten umgebucht werden:\n </target>\n </trans-unit>\n <trans-unit id=\"COyxNde\" resname=\"delete.not_in_use\">\n <source>delete.not_in_use</source>\n <target>Dieses Element kann sicher gelöscht werden.</target>\n </trans-unit>\n <trans-unit id=\"I3TZF5S\" resname=\"cancel\">\n <source>cancel</source>\n <target>Abbrechen</target>\n </trans-unit>\n <trans-unit id=\"PyZ8KrQ\" resname=\"confirm\">\n <source>confirm</source>\n <target>Bestätigen</target>\n </trans-unit>\n <trans-unit id=\".0CFrRV\" resname=\"upload\">\n <source>upload</source>\n <target>Hochladen</target>\n </trans-unit>\n <trans-unit id=\"JBkykGe\" resname=\"search\">\n <source>search</source>\n <target>Suchen</target>\n </trans-unit>\n <trans-unit id=\"IolBPQD\" resname=\"label.searchTerm\">\n <source>label.searchTerm</source>\n <target>Suchbegriff</target>\n </trans-unit>\n <trans-unit id=\"BytPihM\" resname=\"label.set_as_default\">\n <source>label.set_as_default</source>\n <target>Einstellung als Suchfavorit speichern</target>\n </trans-unit>\n <trans-unit id=\"NNKq04n\" resname=\"label.remove_default\">\n <source>label.remove_default</source>\n <target>Suchfavorit löschen</target>\n </trans-unit>\n <trans-unit id=\"31x84Dt\" resname=\"label.asc\">\n <source>label.asc</source>\n <target>Aufsteigend</target>\n </trans-unit>\n <trans-unit id=\"0D_zaYd\" resname=\"label.desc\">\n <source>label.desc</source>\n <target>Absteigend</target>\n </trans-unit>\n <trans-unit id=\"Z8Fxbvf\" resname=\"label.orderBy\">\n <source>label.orderBy</source>\n <target>Sortieren nach</target>\n </trans-unit>\n <trans-unit id=\"hBNESu6\" resname=\"my.profile\">\n <source>my.profile</source>\n <target>Mein Profil</target>\n </trans-unit>\n <trans-unit id=\"J258iS6\" resname=\"update_multiple\">\n <source>update_multiple</source>\n <target>%action% von %count% Einträgen?</target>\n </trans-unit>\n <trans-unit id=\"OTDmccn\" resname=\"attachments\">\n <source>attachments</source>\n <target>Dateien</target>\n </trans-unit>\n <trans-unit id=\"O5w1jzb\" resname=\"file\">\n <source>file</source>\n <target>Datei</target>\n </trans-unit>\n <trans-unit id=\"0M_Gylq\" resname=\"rates.empty\">\n <source>rates.empty</source>\n <target>Es wurden noch keine Stundensätze hinterlegt.</target>\n </trans-unit>\n <trans-unit id=\"mflwMcX\" resname=\"rates.title\">\n <source>rates.title</source>\n <target>Gebühren</target>\n </trans-unit>\n <trans-unit id=\"zFfl7jw\" resname=\"sum.total\">\n <source>sum.total</source>\n <target>Gesamt</target>\n </trans-unit>\n <trans-unit id=\"XP5zkiN\" resname=\"modal.dirty\">\n <source>modal.dirty</source>\n <target>Das Formular wurde geändert. Bitte klicken Sie „Speichern“, um die Änderungen zu sichern oder „Schließen“, um abzubrechen.</target>\n </trans-unit>\n <!--\n Login / Security\n -->\n <trans-unit id=\"9pvowqn\" resname=\"label.password\">\n <source>label.password</source>\n <target>Passwort</target>\n </trans-unit>\n <trans-unit id=\"WxAnbP0\" resname=\"label.password_repeat\">\n <source>label.password_repeat</source>\n <target>Passwort wiederholen</target>\n </trans-unit>\n <trans-unit id=\"II4DGnv\" resname=\"label.logout\">\n <source>label.logout</source>\n <target>Abmelden</target>\n </trans-unit>\n <trans-unit id=\"hFFZGp_\" resname=\"label.user_profile\">\n <source>label.user_profile</source>\n <target>Mein Profil</target>\n </trans-unit>\n <trans-unit id=\"gXZR.hV\" resname=\"label.api_token\">\n <source>label.api_token</source>\n <target>API-Passwort</target>\n </trans-unit>\n <trans-unit id=\"s_X2xpI\" resname=\"label.api_token_repeat\">\n <source>label.api_token_repeat</source>\n <target>API-Passwort wiederholen</target>\n </trans-unit>\n <trans-unit id=\".372.o7\" resname=\"login_required\">\n <source>login_required</source>\n <target>Fehlende Berechtigung. Zur Anmeldung wechseln?</target>\n </trans-unit>\n <trans-unit id=\".ndupSK\" resname=\"registration.check_email\">\n <source>registration.check_email</source>\n <target>Eine E-Mail wurde an %email% gesendet. Sie enthält einen Link, den Sie anklicken müssen, um Ihr Benutzerkonto zu bestätigen.</target>\n </trans-unit>\n <trans-unit id=\"_cY.wHP\" resname=\"resetting.check_email\">\n <source>resetting.check_email</source>\n <target>\n Eine E-Mail wurde verschickt. Sie beinhaltet einen Link zum Zurücksetzen des Passwortes.\n Hinweis: Ein neues Passwort kann nur alle %tokenLifetime% Stunden beantragt werden.",
" Eventuell wurde diese E-Mail als Spam markiert, wenn sie nicht angekommen ist.\n </target>\n </trans-unit>\n <!--\n Menu / Navbar items\n -->\n <trans-unit id=\"UoOv6mx\" approved=\"yes\" resname=\"menu.homepage\">\n <source>menu.homepage</source>\n <target>Dashboard</target>\n </trans-unit>\n <trans-unit id=\"wvvYSw_\" resname=\"menu.admin\">\n <source>menu.admin</source>\n <target>Administration</target>\n </trans-unit>\n <trans-unit id=\"6OKwCUB\" resname=\"menu.system\">\n <source>menu.system</source>\n <target>System</target>\n </trans-unit>\n <trans-unit id=\"wBTFKFR\" resname=\"menu.logout\">\n <source>menu.logout</source>\n <target>Abmelden</target>\n </trans-unit>\n <trans-unit id=\"C0W7_BT\" resname=\"menu.timesheet\">\n <source>menu.timesheet</source>\n <target>Meine Zeiten</target>\n </trans-unit>\n <trans-unit id=\"Ci9W8.K\" resname=\"menu.invoice\">\n <source>menu.invoice</source>\n <target>Rechnungen</target>\n </trans-unit>\n <trans-unit id=\"I.eil4u\" resname=\"menu.export\">\n <source>menu.export</source>\n <target>Export</target>\n </trans-unit>\n <trans-unit id=\"ypVQO7o\" resname=\"menu.reporting\">\n <source>menu.reporting</source>\n <target>Berichte</target>\n </trans-unit>\n <trans-unit id=\"WGIhZv1\" resname=\"menu.admin_timesheet\">\n <source>menu.admin_timesheet</source>\n <target>Zeiterfassung</target>\n </trans-unit>\n <trans-unit id=\"Y_jAD36\" resname=\"menu.admin_customer\">\n <source>menu.admin_customer</source>\n <target>Kunden</target>\n </trans-unit>\n <trans-unit id=\"oDLp9t3\" resname=\"menu.admin_project\">\n <source>menu.admin_project</source>\n <target>Projekte</target>\n </trans-unit>\n <trans-unit id=\"wriHFwl\" resname=\"menu.admin_activity\">\n <source>menu.admin_activity</source>\n <target>Tätigkeiten</target>\n </trans-unit>\n <trans-unit id=\"oZo1BnZ\" resname=\"menu.admin_user\">\n <source>menu.admin_user</source>\n <target>Benutzer</target>\n </trans-unit>\n <trans-unit id=\"pA.bYIk\" resname=\"menu.admin_team\">\n <source>menu.admin_team</source>\n <target>Teams</target>\n </trans-unit>\n <trans-unit id=\"hOZxcaK\" resname=\"menu.plugin\">\n <source>menu.plugin</source>\n <target>Erweiterungen</target>\n </trans-unit>\n <trans-unit id=\"IXtkHRw\" resname=\"menu.system_configuration\">\n <source>menu.system_configuration</source>\n <target>Einstellungen</target>\n </trans-unit>\n <trans-unit id=\"yo4f8Kh\" resname=\"menu.tags\">\n <source>menu.tags</source>\n <target>Schlagworte</target>\n </trans-unit>\n <trans-unit id=\"1kHI0gb\" resname=\"menu.doctor\">\n <source>menu.doctor</source>\n <target>Doktor</target>\n </trans-unit>\n <!--\n Error templates\n -->\n <trans-unit id=\"Vz3Igj3\" resname=\"error.no_entries_found\">\n <source>error.no_entries_found</source>\n <target>Anhand ihrer ausgewählten Filter wurden keine Einträge gefunden.</target>\n </trans-unit>\n <trans-unit id=\"hlu4iX5\" resname=\"error.no_comments_found\">\n <source>error.no_comments_found</source>\n <target>Es wurden noch keine Kommentare abgegeben.</target>\n </trans-unit>\n <trans-unit id=\"XQ2.pq2\" resname=\"error.too_many_entries\">\n <source>error.too_many_entries</source>\n <target>Die Anfrage konnte nicht verarbeitet werden. Es wurden zu viele Ergebnisse gefunden.</target>\n </trans-unit>\n <!--\n General labels\n -->\n <trans-unit id=\"H1qEi4d\" resname=\"label.date\">\n <source>label.date</source>\n <target>Datum</target>\n </trans-unit>\n <trans-unit id=\"eJPDE76\" resname=\"label.starttime\">\n <source>label.starttime</source>\n <target>Beginn</target>\n </trans-unit>\n <trans-unit id=\"uZlpDFh\" resname=\"label.endtime\">\n <source>label.endtime</source>\n <target>Ende</target>\n </trans-unit>\n <trans-unit id=\"cgpmY0I\" resname=\"label.duration\">\n <source>label.duration</source>\n <target>Dauer</target>\n </trans-unit>\n <trans-unit id=\"O2X4xZH\" resname=\"label.user\">\n <source>label.user</source>\n <target>Benutzer</target>\n </trans-unit>\n <trans-unit id=\"LDhDPrF\" resname=\"label.username\">\n <source>label.username</source>\n <target>Benutzer</target>\n </trans-unit>\n <trans-unit id=\"4cEApe1\" resname=\"label.description\">\n <source>label.description</source>\n <target>Beschreibung</target>\n </trans-unit>\n <trans-unit id=\"ysOvPSq\" resname=\"label.name\">\n <source>label.name</source>\n <target>Name</target>\n </trans-unit>\n <trans-unit id=\"WqTho4C\" resname=\"label.comment\">\n <source>label.comment</source>\n <target>Kommentar</target>\n </trans-unit>\n <trans-unit id=\"txRonia\" resname=\"label.id\">\n <source>label.id</source>\n <target>ID</target>\n </trans-unit>\n <trans-unit id=\"CYpZwBz\" resname=\"label.visible\">\n <source>label.visible</source>\n <target>Sichtbar</target>\n </trans-unit>\n <trans-unit id=\"2ktNwkr\" approved=\"yes\" resname=\"label.budget\">\n <source>label.budget</source>\n <target>Budget</target>\n </trans-unit>\n <trans-unit id=\"x8TrOec\" resname=\"label.timeBudget\">\n <source>label.timeBudget</source>\n <target>Zeit-Budget</target>\n </trans-unit>\n <trans-unit id=\"l1wiL0h\" resname=\"label.activity\">\n <source>label.activity</source>\n <target>Tätigkeit</target>\n </trans-unit>\n <trans-unit id=\"KtnqJcg\" resname=\"label.project\">\n <source>label.project</source>\n <target>Projekt</target>\n </trans-unit>\n <trans-unit id=\"VAbtieW\" resname=\"label.hourlyRate\">\n <source>label.hourlyRate</source>\n <target>Stundenlohn</target>\n </trans-unit>\n <trans-unit id=\"VNCQ7YU\" resname=\"label.tag\">\n <source>label.tag</source>\n <target>Schlagworte</target>\n </trans-unit>\n <trans-unit id=\"ijQyGRo\" resname=\"label.tags\">\n <source>label.tags</source>\n <target>Schlagworte</target>\n </trans-unit>\n <trans-unit id=\"IQ.tlua\" resname=\"label.hourly_rate\">\n <source>label.hourly_rate</source>\n <target>Stundenlohn</target>\n </trans-unit>\n <trans-unit id=\"dezCZWf\" resname=\"label.skin\">\n <source>label.skin</source>\n <target>Darstellung: Farben</target>\n </trans-unit>\n <trans-unit id=\"42BRM3Q\" resname=\"label.theme.layout\">\n <source>label.theme.layout</source>\n <target>Darstellung: Layout</target>\n </trans-unit>\n <trans-unit id=\"w8T34A6\" resname=\"label.hours\">\n <source>label.hours</source>\n <target>Stunden</target>\n </trans-unit>\n <trans-unit id=\"Ih3IFXj\" resname=\"label.rate\">\n <source>label.rate</source>\n <target>Lohn</target>\n </trans-unit>\n <trans-unit id=\"djL6LMC\" resname=\"help.rate\">\n <source>help.rate</source>\n <target>Zu berechnender Stundensatz</target>\n </trans-unit>\n <trans-unit id=\"QzvjNwg\" resname=\"label.rate_internal\">\n <source>label.rate_internal</source>\n <target>Interner Lohn</target>\n </trans-unit>\n <trans-unit id=\"uz4SmfP\" resname=\"help.rate_internal\">\n <source>help.rate_internal</source>\n <target>Interner Verrechnungswert (wenn dieser nicht angegeben ist, wird der normale Satz verwendet)</target>\n </trans-unit>\n <trans-unit id=\"v72sA1c\" resname=\"label.recalculate_rates\">\n <source>label.recalculate_rates</source>\n <target>Preise neu berechnen</target>\n </trans-unit>\n <trans-unit id=\"foM2o5T\" resname=\"label.language\">\n <source>label.language</source>\n <target>Sprache</target>\n </trans-unit>\n <trans-unit id=\"Z8a2kUf\" resname=\"label.customer\">\n <source>label.customer</source>\n <target>Kunde</target>\n </trans-unit>\n <trans-unit id=\"D2N6_cP\" resname=\"label.email\">\n <source>label.email</source>\n <target>E-Mail</target>\n </trans-unit>\n <trans-unit id=\"Ss2xe99\" resname=\"label.team\">\n <source>label.team</source>\n <target>Team</target>\n </trans-unit>\n <trans-unit id=\"Zpj9UB4\" resname=\"label.teamlead\">\n <source>label.teamlead</source>\n <target>Teamleiter</target>\n </trans-unit>\n <trans-unit id=\"hX.EQKy\" resname=\"label.create_more\">\n <source>label.create_more</source>\n <target>Weitere Einträge erstellen</target>\n </trans-unit>\n <trans-unit id=\"LIOnolg\" resname=\"placeholder.type_message\">\n <source>placeholder.type_message</source>\n <target>Schreibe deine Nachricht …</target>\n </trans-unit>\n <trans-unit id=\"vkHr9AP\" resname=\"label.billable\">\n <source>label.billable</source>\n <target>Abrechenbar</target>\n </trans-unit>\n <!--\n Buttons & Actions\n -->\n <trans-unit id=\"zldXQq6\" resname=\"label.actions\">\n <source>label.actions</source>\n <target>Aktionen</target>\n </trans-unit>\n <trans-unit id=\"ovKkXwU\" resname=\"action.edit\">\n <source>action.edit</source>\n <target>Bearbeiten</target>\n </trans-unit>\n <trans-unit id=\"jdbtx6z\" resname=\"action.add\">\n <source>action.add</source>\n <target>Hinzufügen</target>\n </trans-unit>\n <trans-unit id=\"hTKWQ6g\" resname=\"action.delete\">\n <source>action.delete</source>\n <target>Löschen</target>\n </trans-unit>\n <trans-unit id=\"HLtdhYw\" resname=\"action.save\">\n <source>action.save</source>\n <target>Speichern</target>\n </trans-unit>\n <trans-unit id=\"9hpJPiG\" resname=\"action.save_all\">\n <source>action.save_all</source>\n <target>Alle speichern</target>\n </trans-unit>\n <trans-unit id=\"tKZKI2Z\" resname=\"action.reset\">\n <source>action.reset</source>\n <target>Zurücksetzen</target>\n </trans-unit>\n <trans-unit id=\"Eb7Ygpo\" resname=\"action.back\">\n <source>action.back</source>\n <target>Zurück</target>\n </trans-unit>\n <trans-unit id=\"wCazS.X\" resname=\"action.close\">\n <source>action.close</source>\n <target>Schließen</target>\n </trans-unit>\n <!--\n Dashboard\n -->\n <trans-unit id=\"3bqLM8Q\" resname=\"dashboard.title\">\n <source>dashboard.title</source>\n <target>Dashboard</target>\n </trans-unit>\n <trans-unit id=\"3PYadzb\" resname=\"dashboard.subtitle\">\n <source>dashboard.subtitle</source>\n <target>Willkommen!</target>\n </trans-unit>\n <trans-unit id=\"yEa1Yz3\" resname=\"dashboard.all\">\n <source>dashboard.all</source>\n <target>Alle Benutzer</target>\n </trans-unit>\n <!--\n Widgets\n -->\n <trans-unit id=\"giznf_R\" resname=\"more.info.link\">\n <source>more.info.link</source>\n <target>Mehr Infos</target>\n </trans-unit>\n <trans-unit id=\"4iliLZT\" resname=\"label.toggle_dropdown\">\n <source>label.toggle_dropdown</source>\n <target>Menü anzeigen</target>\n </trans-unit>\n <trans-unit id=\"f3KMQJh\" resname=\"label.my_teams\">\n <source>label.my_teams</source>\n <target>Meine Teams</target>\n </trans-unit>\n <trans-unit id=\"jTiYRIu\" resname=\"label.my_team_projects\">\n <source>label.my_team_projects</source>\n <target>Meine Projekte</target>\n </trans-unit>\n <trans-unit id=\"1PQHtXu\" resname=\"label.progress\">\n <source>label.progress</source>\n <target>Fortschritt</target>\n </trans-unit>\n <trans-unit id=\"vTY9SUk\" resname=\"label.plus_more\">\n <source>label.plus_more</source>\n <target>+%count% weitere</target>\n </trans-unit>\n <!--\n Timesheet\n -->\n <trans-unit id=\"VXj0Y3h\" resname=\"timesheet.title\">\n <source>timesheet.title</source>\n <target>Meine Zeiten</target>\n </trans-unit>\n <trans-unit id=\"dwEVXUR\" resname=\"timesheet.edit\">\n <source>timesheet.edit</source>\n <target>Eintrag bearbeiten</target>\n </trans-unit>\n <trans-unit id=\"trDJK9W\" resname=\"label.begin\">\n <source>label.begin</source>\n <target>Von</target>\n </trans-unit>\n <trans-unit id=\"R9typUt\" resname=\"label.end\">\n <source>label.end</source>\n <target>Bis</target>\n </trans-unit>\n <trans-unit id=\"egaNXjp\" resname=\"label.daterange\">\n <source>label.daterange</source>\n <target>Zeitraum</target>\n </trans-unit>\n <trans-unit id=\"UbnqJLn\" resname=\"modal.columns.title\">\n <source>modal.columns.title</source>\n <target>Ändere Spalten-Sichtbarkeit</target>\n </trans-unit>\n <trans-unit id=\"EbfIoLp\" resname=\"modal.columns.description\">\n <source>modal.columns.description</source>\n <target>Beim Speichern werden die nicht ausgewählten Spalten ausgeblendet und diese Einstellungen in einem Browser Cookie hinterlegt. Sollten Sie Ihre Cookies löschen, werden die Einstellungen rückgängig gemacht.</target>\n </trans-unit>\n <trans-unit id=\"5gjqxgK\" resname=\"label.fixedRate\">\n <source>label.fixedRate</source>\n <target>Festbetrag</target>\n </trans-unit>\n <trans-unit id=\"b43sCwO\" resname=\"help.fixedRate\">\n <source>help.fixedRate</source>\n <target>Jeder Zeiteintrag bekommt den gleichen Wert, unabhängig von seiner Dauer</target>\n </trans-unit>\n <trans-unit id=\"YTSS_Q1\" resname=\"label.color\">\n <source>label.color</source>\n <target>Farbe</target>\n </trans-unit>\n <trans-unit id=\"EoouxGX\" resname=\"label.replaceTags\">\n <source>label.replaceTags</source>\n <target>Schlagworte ersetzen</target>\n </trans-unit>\n <trans-unit id=\"BxkmaKz\" resname=\"label.appendTags\">\n <source>label.appendTags</source>\n <target>Schlagworte hinzufügen</target>\n </trans-unit>\n <!--\n User profile\n -->\n <trans-unit id=\"1_wnK76\" resname=\"profile.title\">\n <source>profile.title</source>\n <target>Benutzerprofil</target>\n </trans-unit>\n <trans-unit id=\"HWKJZ0T\" resname=\"profile.about_me\">\n <source>profile.about_me</source>\n <target>Über mich</target>\n </trans-unit>\n <trans-unit id=\"Fm.kwVn\" resname=\"profile.first_entry\">\n <source>profile.first_entry</source>\n <target>Arbeitet seit</target>\n </trans-unit>\n <trans-unit id=\"1c0EQaz\" resname=\"profile.registration_date\">\n <source>profile.registration_date</source>\n <target>Registriert am</target>\n </trans-unit>\n <trans-unit id=\"xEYQXPy\" resname=\"profile.settings\">\n <source>profile.settings</source>\n <target>Profil</target>\n </trans-unit>\n <trans-unit id=\"A6TLLQa\" resname=\"profile.password\">\n <source>profile.password</source>\n <target>Passwort</target>\n </trans-unit>\n <trans-unit id=\"Z34ZpjK\" resname=\"profile.api-token\">\n <source>profile.api-token</source>\n <target>API</target>\n </trans-unit>\n <trans-unit id=\"ygtTz8.\" resname=\"profile.roles\">\n <source>profile.roles</source>\n <target>Rollen</target>\n </trans-unit>\n <trans-unit id=\"DZ7XGML\" resname=\"profile.teams\">\n <source>profile.teams</source>\n <target>Teams</target>\n </trans-unit>\n <trans-unit id=\"MQKiG33\" resname=\"profile.preferences\">\n <source>profile.preferences</source>\n <target>Einstellungen</target>\n </trans-unit>\n <trans-unit id=\"Eq78QrH\" resname=\"label.theme.collapsed_sidebar\">\n <source>label.theme.collapsed_sidebar</source>\n <target>Minimiert die linke Navigationsleiste</target>\n </trans-unit>\n <trans-unit id=\"0sgroZi\" resname=\"label.calendar.initial_view\">\n <source>label.calendar.initial_view</source>\n <target>Initiale Darstellung des Kalenders</target>\n </trans-unit>\n <trans-unit id=\"iqQsgIW\" resname=\"label.login.initial_view\">\n <source>label.login.initial_view</source>\n <target>Initiale Ansicht nach Anmeldung</target>\n </trans-unit>\n <trans-unit id=\"hO7mkmf\" resname=\"label.lastLogin\">\n <source>label.lastLogin</source>\n <target>Letzte Anmeldung</target>\n </trans-unit>\n <!-- Options for user-preference label.calendar.initial_view -->\n <trans-unit id=\"pcfRcZ4\" resname=\"month\">\n <source>month</source>\n <target>Monat</target>\n </trans-unit>\n <trans-unit id=\"Irm6dfx\" resname=\"agendaWeek\">\n <source>agendaWeek</source>\n <target>Woche</target>\n </trans-unit>\n <trans-unit id=\"Q0Zip02\" resname=\"agendaDay\">\n <source>agendaDay</source>\n <target>Tag</target>\n </trans-unit>\n <trans-unit id=\"rYzHCFd\" resname=\"label.timesheet.daily_stats\">\n <source>label.timesheet.daily_stats</source>\n <target>Tägliche Statistiken im Timesheet anzeigen</target>\n </trans-unit>\n <trans-unit id=\"tSlqVK2\" resname=\"label.timesheet.export_decimal\">\n <source>label.timesheet.export_decimal</source>\n <target>Dezimal Format für Export nutzen</target>\n </trans-unit>\n <trans-unit id=\"5R.QsZ3\" resname=\"theme.update_browser_title\">\n <source>theme.update_browser_title</source>\n <target>Browser Titel aktualisieren</target>\n </trans-unit>\n <!--\n User timesheet calendar\n -->\n <trans-unit id=\"HWiuMV6\" resname=\"calendar.title\">\n <source>calendar.title</source>\n <target>Kalender</target>\n </trans-unit>\n <trans-unit id=\"75kjTF9\" resname=\"calendar.drag_and_drop.delete\">\n <source>calendar.drag_and_drop.delete</source>\n <target>Wenn Sie einen Eintrag löschen wollen, müssen Sie ihn auf die Schaltfläche ziehen.</target>\n </trans-unit>\n <!--\n Admin: Timesheet\n -->\n <trans-unit id=\"bSDjzZL\" resname=\"admin_timesheet.title\">\n <source>admin_timesheet.title</source>\n <target>Zeiterfassung</target>\n </trans-unit>\n <!--\n Admin: Projects\n -->\n <trans-unit id=\"DFjFRGe\" resname=\"admin_project.title\">\n <source>admin_project.title</source>\n <target>Projekte</target>\n </trans-unit>\n <trans-unit id=\"yLOqEX_\" resname=\"label.project_start\">\n <source>label.project_start</source>\n <target>Projekt Start</target>\n </trans-unit>\n <trans-unit id=\"4kQGReV\" resname=\"label.project_end\">\n <source>label.project_end</source>\n <target>Projekt Ende</target>\n </trans-unit>\n <!--\n Admin: Activity\n -->\n <trans-unit id=\"auu8q0u\" resname=\"admin_activity.title\">\n <source>admin_activity.title</source>\n <target>Tätigkeiten</target>\n </trans-unit>\n <!--\n Admin: Customer\n -->\n <trans-unit id=\"2TvKX9Z\" resname=\"admin_customer.title\">\n <source>admin_customer.title</source>\n <target>Kunden</target>\n </trans-unit>\n <trans-unit id=\"39AtPxQ\" resname=\"label.number\">\n <source>label.number</source>\n <target>Kundennummer</target>\n </trans-unit>\n <trans-unit id=\"7jfRn_1\" resname=\"label.company\">\n <source>label.company</source>\n <target>Unternehmensbezeichnung</target>\n </trans-unit>\n <trans-unit id=\"GOStgLi\" resname=\"label.vat\">\n <source>label.vat</source>\n <target>Umsatzsteuer</target>\n </trans-unit>\n <trans-unit id=\"Dgmh_mv\" resname=\"label.vat_id\">\n <source>label.vat_id</source>\n <target>Umsatzsteuer-ID</target>\n </trans-unit>\n <trans-unit id=\"YNGNfGn\" resname=\"label.tax_rate\">\n <source>label.tax_rate</source>\n <target>Steuersatz</target>\n </trans-unit>\n <trans-unit id=\"0tkOMo1\" resname=\"label.contact\">\n <source>label.contact</source>\n <target>Kontakt</target>\n </trans-unit>\n <trans-unit id=\"c9W5AO4\" resname=\"label.address\">\n <source>label.address</source>\n <target>Adresse</target>\n </trans-unit>\n <trans-unit id=\"k7MJQ82\" resname=\"label.country\">\n <source>label.country</source>\n <target>Land</target>\n </trans-unit>\n <trans-unit id=\"g03c_vw\" resname=\"label.phone\">\n <source>label.phone</source>\n <target>Telefon</target>\n </trans-unit>\n <trans-unit id=\"eRyhERS\" resname=\"label.fax\">\n <source>label.fax</source>\n <target>Fax</target>\n </trans-unit>\n <trans-unit id=\"AawT9pW\" resname=\"label.mobile\">\n <source>label.mobile</source>\n <target>Mobiltelefon</target>\n </trans-unit>\n <trans-unit id=\"PS9IH_t\" approved=\"yes\" resname=\"label.homepage\">\n <source>label.homepage</source>\n <target>Homepage</target>\n </trans-unit>\n <trans-unit id=\"dmtPdwq\" resname=\"label.timezone\">\n <source>label.timezone</source>\n <target>Zeitzone</target>\n </trans-unit>\n <trans-unit id=\"otd2FZd\" resname=\"label.currency\">\n <source>label.currency</source>\n <target>Währung</target>\n </trans-unit>\n <!--\n Admin: User\n -->\n <trans-unit id=\"t34EvnF\" resname=\"admin_user.title\">\n <source>admin_user.title</source>\n <target>Benutzer</target>\n </trans-unit>\n <trans-unit id=\"TRDzmCV\" resname=\"label.alias\">\n <source>label.alias</source>\n <target>Name</target>\n </trans-unit>\n <trans-unit id=\"UrRn8xj\" resname=\"label.title\">\n <source>label.title</source>\n <target>Titel</target>\n </trans-unit>\n <trans-unit id=\"nWMH_Nr\" resname=\"label.avatar\">\n <source>label.avatar</source>\n <target>Profilbild (URL)</target>\n </trans-unit>\n <trans-unit id=\"KtTP.Sh\" resname=\"label.active\">\n <source>label.active</source>\n <target>Aktiv</target>\n </trans-unit>\n <trans-unit id=\"iD6CNOO\" resname=\"label.roles\">\n <source>label.roles</source>\n <target>Rolle</target>\n </trans-unit>\n <trans-unit id=\"ZlZ20pG\" resname=\"user_permissions.title\">\n <source>user_permissions.title</source>\n <target>Benutzer Berechtigungen</target>\n </trans-unit>\n <trans-unit id=\"G.GEdlk\" resname=\"user_role.title\">\n <source>user_role.title</source>\n <target>Benutzer Rolle</target>\n </trans-unit>\n <trans-unit id=\"E7G60OF\" resname=\"Allowed character: A-Z and _\">\n <source>Allowed character: A-Z and _</source>\n <target>Erlaubte Zeichen: A-Z und _</target>\n </trans-unit>\n <!--\n Admin: Plugins\n -->\n <trans-unit id=\"d75KAlJ\" resname=\"label.version\">\n <source>label.version</source>\n <target>Version</target>\n </trans-unit>\n <trans-unit id=\"8Rfa01v\" resname=\"label.required_version\">\n <source>label.required_version</source>\n <target>Kompatibel mit</target>\n </trans-unit>\n <!--\n ROLES\n -->\n <trans-unit id=\"WRuKTcz\" resname=\"ROLE_SUPER_ADMIN\">\n <source>ROLE_SUPER_ADMIN</source>\n <target>System-Admin</target>\n </trans-unit>\n <trans-unit id=\"718iPw6\" resname=\"ROLE_ADMIN\">\n <source>ROLE_ADMIN</source>\n <target>Administrator</target>\n </trans-unit>\n <trans-unit id=\"yttGLAB\" resname=\"ROLE_TEAMLEAD\">\n <source>ROLE_TEAMLEAD</source>\n <target>Teamleiter</target>\n </trans-unit>\n <trans-unit id=\"rvO5ZXf\" resname=\"ROLE_USER\">\n <source>ROLE_USER</source>\n <target>Benutzer</target>\n </trans-unit>\n <!--\n Statistics data for Dashboard & Users profile\n -->\n <trans-unit id=\"lfSTZGe\" resname=\"stats.workingTimeToday\">\n <source>stats.workingTimeToday</source>\n <target>Heute, %day%</target>\n </trans-unit>\n <trans-unit id=\"XdYs3I8\" resname=\"stats.workingTimeWeek\">\n <source>stats.workingTimeWeek</source>\n <target>Kalenderwoche %week%</target>\n </trans-unit>",
"",
" <trans-unit id=\"JIKNAYP\" approved=\"yes\" resname=\"stats.workingTimeMonth\">\n <source>stats.workingTimeMonth</source>\n <target>%month% %year%</target>\n </trans-unit>\n <trans-unit id=\"JnUFsNi\" resname=\"stats.workingTimeYear\">\n <source>stats.workingTimeYear</source>\n <target>Gesamtes Jahr %year%</target>\n </trans-unit>\n <trans-unit id=\"HWB4OGJ\" resname=\"stats.workingTimeFinancialYear\">\n <source>stats.workingTimeFinancialYear</source>\n <target>Geschäftsjahr</target>\n </trans-unit>\n <trans-unit id=\"BXBFJP8\" resname=\"stats.workingTime\">\n <source>stats.workingTime</source>\n <target>Arbeitszeit</target>\n </trans-unit>\n <trans-unit id=\"pX_3dNm\" resname=\"stats.revenue\">\n <source>stats.revenue</source>\n <target>Einnahmen</target>\n </trans-unit>\n <trans-unit id=\"TdBJBAl\" resname=\"stats.durationToday\">\n <source>stats.durationToday</source>\n <target>Arbeitszeit heute</target>\n </trans-unit>\n <trans-unit id=\"XhKalZH\" resname=\"stats.durationWeek\">\n <source>stats.durationWeek</source>\n <target>Arbeitszeit diese Woche</target>\n </trans-unit>\n <trans-unit id=\"uaOwf_P\" resname=\"stats.durationMonth\">\n <source>stats.durationMonth</source>\n <target>Arbeitszeit diesen Monat</target>\n </trans-unit>\n <trans-unit id=\"WqF84KR\" resname=\"stats.durationYear\">\n <source>stats.durationYear</source>\n <target>Arbeitszeit dieses Jahr</target>\n </trans-unit>\n <trans-unit id=\"xkugSAA\" resname=\"stats.durationFinancialYear\">\n <source>stats.durationFinancialYear</source>\n <target>Arbeitszeit dieses Geschäftsjahr</target>\n </trans-unit>\n <trans-unit id=\"YtvPnl1\" resname=\"stats.durationTotal\">\n <source>stats.durationTotal</source>\n <target>Arbeitszeit total</target>\n </trans-unit>\n <trans-unit id=\"IFOLMgp\" resname=\"stats.yourWorkingHours\">\n <source>stats.yourWorkingHours</source>\n <target>Meine Arbeitszeiten</target>\n </trans-unit>\n <trans-unit id=\"023M9Ta\" resname=\"stats.amountToday\">\n <source>stats.amountToday</source>\n <target>Umsatz heute</target>\n </trans-unit>\n <trans-unit id=\"xnJvYAE\" resname=\"stats.amountWeek\">\n <source>stats.amountWeek</source>\n <target>Umsatz diese Woche</target>\n </trans-unit>\n <trans-unit id=\"ulr3reE\" resname=\"stats.amountMonth\">\n <source>stats.amountMonth</source>\n <target>Umsatz diesen Monat</target>\n </trans-unit>\n <trans-unit id=\"bQZyZaO\" resname=\"stats.amountYear\">\n <source>stats.amountYear</source>\n <target>Umsatz dieses Jahr</target>\n </trans-unit>\n <trans-unit id=\"wuUWovn\" resname=\"stats.amountFinancialYear\">\n <source>stats.amountFinancialYear</source>\n <target>Umsatz dieses Geschäftsjahr</target>\n </trans-unit>\n <trans-unit id=\"Z0fz23v\" resname=\"stats.amountTotal\">\n <source>stats.amountTotal</source>\n <target>Umsatz total</target>\n </trans-unit>\n <trans-unit id=\"xyiadv3\" resname=\"stats.userActiveToday\">\n <source>stats.userActiveToday</source>\n <target>Aktive Benutzer heute</target>\n </trans-unit>\n <trans-unit id=\"knMHaeO\" resname=\"stats.userActiveWeek\">\n <source>stats.userActiveWeek</source>\n <target>Aktive Benutzer diese Woche</target>\n </trans-unit>\n <trans-unit id=\"adzVDgb\" resname=\"stats.userActiveMonth\">\n <source>stats.userActiveMonth</source>\n <target>Aktive Benutzer diesen Monat</target>\n </trans-unit>\n <trans-unit id=\"AswjFvh\" resname=\"stats.userActiveYear\">\n <source>stats.userActiveYear</source>\n <target>Aktive Benutzer dieses Jahr</target>\n </trans-unit>\n <trans-unit id=\"zMY6gkY\" resname=\"stats.userActiveFinancialYear\">\n <source>stats.userActiveFinancialYear</source>\n <target>Aktive Benutzer dieses Geschäftsjahr</target>\n </trans-unit>\n <trans-unit id=\"dLTb1Po\" resname=\"stats.userActiveTotal\">\n <source>stats.userActiveTotal</source>\n <target>Aktive Benutzer jemals</target>\n </trans-unit>\n <trans-unit id=\"lEW82ex\" resname=\"stats.activeRecordings\">\n <source>stats.activeRecordings</source>\n <target>Aktive Zeitmessungen</target>\n </trans-unit>\n <trans-unit id=\"t5eIWp8\" resname=\"stats.userTotal\">\n <source>stats.userTotal</source>\n <target>Anzahl Benutzer</target>\n </trans-unit>\n <trans-unit id=\"Bor.76M\" resname=\"stats.activityTotal\">\n <source>stats.activityTotal</source>\n <target>Anzahl Tätigkeiten</target>\n </trans-unit>\n <trans-unit id=\"67uSaR3\" resname=\"stats.projectTotal\">\n <source>stats.projectTotal</source>\n <target>Anzahl Projekte</target>\n </trans-unit>\n <trans-unit id=\"tnD6aPj\" resname=\"stats.customerTotal\">\n <source>stats.customerTotal</source>\n <target>Anzahl Kunden</target>\n </trans-unit>\n <trans-unit id=\"unC5MXv\" resname=\"stats.percentUsed\">\n <source>stats.percentUsed</source>\n <target>%percent%% verwendet</target>\n </trans-unit>\n <trans-unit id=\"HkjvwLc\" resname=\"stats.percentUsedLeft\">\n <source>stats.percentUsedLeft</source>\n <target>%percent%% verwendet (noch %left% offen)</target>\n </trans-unit>\n <trans-unit id=\"xN7MfSA\" resname=\"stats.percentUsed_month\">\n <source>stats.percentUsed_month</source>\n <target>%percent%% verwendet diesen Monat</target>\n </trans-unit>\n <trans-unit id=\"vWJPpYU\" resname=\"stats.percentUsedLeft_month\">\n <source>stats.percentUsedLeft_month</source>\n <target>%percent%% verwendet (noch %left% diesen Monat offen)</target>\n </trans-unit>\n <!--\n Invoice\n -->\n <trans-unit id=\"Oq.KtC6\" resname=\"admin_invoice_template.title\">\n <source>admin_invoice_template.title</source>\n <target>Rechnungsvorlagen</target>\n </trans-unit>\n <trans-unit id=\"iERywrp\" resname=\"invoice.title\">\n <source>invoice.title</source>\n <target>Rechnungen</target>\n </trans-unit>\n <trans-unit id=\"ov4OQOh\" resname=\"invoice.filter\">\n <source>invoice.filter</source>\n <target>Rechnungsdaten filtern</target>\n </trans-unit>\n <trans-unit id=\"7H7P1mE\" resname=\"button.preview\">\n <source>button.preview</source>\n <target>Vorschau</target>\n </trans-unit>\n <trans-unit id=\"IQ9DUOW\" resname=\"button.preview_print\">\n <source>button.preview_print</source>\n <target>Druck Vorschau</target>\n </trans-unit>\n <trans-unit id=\"X70dwP8\" resname=\"button.print\">\n <source>button.print</source>\n <target>Drucken</target>\n </trans-unit>\n <trans-unit id=\"W_TXvSi\" resname=\"button.csv\">\n <source>button.csv</source>\n <target>CSV</target>\n </trans-unit>\n <trans-unit id=\"vC2IsaP\" resname=\"button.xlsx\">\n <source>button.xlsx</source>\n <target>Excel</target>\n </trans-unit>\n <trans-unit id=\"aAa5uRR\" resname=\"button.pdf\">\n <source>button.pdf</source>\n <target>PDF</target>\n </trans-unit>\n <trans-unit id=\"ulYFDIo\" resname=\"button.ods\">\n <source>button.ods</source>\n <target>ODS</target>\n </trans-unit>\n <trans-unit id=\"zPcx3O_\" resname=\"invoice_print\">\n <source>invoice_print</source>\n <target>Rechnung</target>\n </trans-unit>\n <trans-unit id=\"7J7G3Vr\" resname=\"label.mark_as_exported\">\n <source>label.mark_as_exported</source>\n <target>Als exportiert markieren</target>\n </trans-unit>\n <trans-unit id=\"p0IprAw\" resname=\"label.template\">\n <source>label.template</source>\n <target>Vorlage</target>\n </trans-unit>\n <trans-unit id=\"zfIRxJh\" resname=\"label.due_days\">\n <source>label.due_days</source>\n <target>Zahlungsziel in Tagen</target>\n </trans-unit>\n <trans-unit id=\"rAJrxSK\" resname=\"invoice.due_days\">\n <source>invoice.due_days</source>\n <target>Zahlungsziel</target>\n </trans-unit>\n <trans-unit id=\"Xij3oQl\" resname=\"invoice.payment_date\">\n <source>invoice.payment_date</source>\n <target>Zahlungsdatum</target>\n </trans-unit>\n <trans-unit id=\"4XKFnWh\" resname=\"invoice.from\">\n <source>invoice.from</source>\n <target>Von</target>\n </trans-unit>\n <trans-unit id=\"hx7vsMA\" resname=\"invoice.to\">\n <source>invoice.to</source>\n <target>An</target>\n </trans-unit>\n <trans-unit id=\"x_W5sV4\" resname=\"invoice.number\">\n <source>invoice.number</source>\n <target>Rechnungsnummer</target>\n </trans-unit>\n <trans-unit id=\"86KyrKO\" resname=\"invoice.subtotal\">\n <source>invoice.subtotal</source>\n <target>Rechnungsbetrag (netto)</target>\n </trans-unit>\n <trans-unit id=\"EO57yXg\" resname=\"invoice.tax\">\n <source>invoice.tax</source>\n <target>Umsatzsteuer</target>\n </trans-unit>\n <trans-unit id=\"N68vyvo\" resname=\"invoice.total\">\n <source>invoice.total</source>\n <target>Rechnungsendbetrag</target>\n </trans-unit>\n <trans-unit id=\"TPzFWUs\" resname=\"invoice.service_date\">\n <source>invoice.service_date</source>\n <target>Leistungsdatum</target>\n </trans-unit>\n <trans-unit id=\"6x24VVR\" resname=\"label.amount\">\n <source>label.amount</source>\n <target>Anzahl</target>\n </trans-unit>\n <trans-unit id=\"g7EpaPY\" resname=\"label.total_rate\">\n <source>label.total_rate</source>\n <target>Gesamtpreis</target>\n </trans-unit>\n <trans-unit id=\"MF3MdTu\" resname=\"label.unit_price\">\n <source>label.unit_price</source>\n <target>Einzelbetrag</target>\n </trans-unit>\n <trans-unit id=\"77aZC3r\" resname=\"label.payment_terms\">\n <source>label.payment_terms</source>\n <target>Zahlungsinformationen</target>\n </trans-unit>\n <trans-unit id=\"9p2KQag\" resname=\"invoice.signature_user\">\n <source>invoice.signature_user</source>\n <target>Leistungsbestätigung: Datum / Name Berater / Unterschrift</target>\n </trans-unit>\n <trans-unit id=\"Q9ykNhO\" resname=\"invoice.signature_customer\">\n <source>invoice.signature_customer</source>\n <target>Leistungsbestätigung: Datum / Name Kunde / Unterschrift</target>\n </trans-unit>\n <trans-unit id=\"c3d6p33\" resname=\"invoice.total_working_time\">\n <source>invoice.total_working_time</source>\n <target>Gesamtdauer</target>\n </trans-unit>\n <trans-unit id=\"BS00SS7\" resname=\"label.orderNumber\">\n <source>label.orderNumber</source>\n <target>Bestellnummer</target>\n </trans-unit>\n <trans-unit id=\"as948k9\" resname=\"label.orderDate\">\n <source>label.orderDate</source>\n <target>Bestelldatum</target>\n </trans-unit>\n <trans-unit id=\"RRj6PYN\" resname=\"label.invoice_tax_number\">\n <source>label.invoice_tax_number</source>\n <target>USt-IdNr.:</target>\n </trans-unit>\n <trans-unit id=\"uFZA7Uf\" resname=\"label.invoice_bank_account\">\n <source>label.invoice_bank_account</source>\n <target>Bankverbindung</target>\n </trans-unit>\n <trans-unit id=\"9VxfLLy\" resname=\"label.decimalDuration\">\n <source>label.decimalDuration</source>\n <target>Dauer als Dezimalzahl anzeigen</target>\n </trans-unit>\n <trans-unit id=\"hzhzbqw\" resname=\"label.status\">\n <source>label.status</source>\n <target>Status</target>\n </trans-unit>\n <trans-unit id=\"X_NRsed\" resname=\"status.new\">\n <source>status.new</source>\n <target>Neu</target>\n </trans-unit>\n <trans-unit id=\"Uvo1CbP\" resname=\"status.pending\">\n <source>status.pending</source>\n <target>Ausstehend</target>\n </trans-unit>\n <trans-unit id=\"PHJwR4w\" resname=\"status.paid\">\n <source>status.paid</source>\n <target>Bezahlt</target>\n </trans-unit>\n <trans-unit id=\"gT9W2pZ\" resname=\"status.canceled\">\n <source>status.canceled</source>\n <target>Storniert</target>\n </trans-unit>\n <trans-unit id=\"crrlEUA\" resname=\"preview.skipped_rows\">\n <source>preview.skipped_rows</source>\n <target>Überspringe Vorschau von %rows% weiteren Zeilen …</target>\n </trans-unit>\n <!--\n Export\n -->\n <trans-unit id=\"F6Jmro7\" resname=\"export.title\">\n <source>export.title</source>\n <target>Export</target>\n </trans-unit>\n <trans-unit id=\"iwWaUoa\" resname=\"export.filter\">\n <source>export.filter</source>\n <target>Daten für Export filtern</target>\n </trans-unit>\n <trans-unit id=\"vjmoQGo\" resname=\"export.period\">\n <source>export.period</source>\n <target>Zeitraum</target>\n </trans-unit>\n <trans-unit id=\"3CQ7A2m\" resname=\"export.document_title\">\n <source>export.document_title</source>\n <target>Export von Zeiten</target>\n </trans-unit>\n <trans-unit id=\"d5wyWRD\" resname=\"export.full_list\">\n <source>export.full_list</source>\n <target>Vollständige Auflistung</target>\n </trans-unit>\n <trans-unit id=\"N778uJ6\" resname=\"export.summary\">\n <source>export.summary</source>\n <target>Zusammenfassung</target>\n </trans-unit>\n <trans-unit id=\"ElDyzrx\" resname=\"export.page_of\">\n <source>export.page_of</source>\n <target>Seite %page% von %pages%</target>\n </trans-unit>\n <trans-unit id=\"vKY0tof\" resname=\"export.date_copyright\">\n <source>export.date_copyright</source>\n <target>Erstellt %date% mit %kimai%</target>\n </trans-unit>\n <trans-unit id=\"W92QGbY\" resname=\"export.warn_result_amount\">\n <source>export.warn_result_amount</source>\n <target>Ihre Suche führt zu %count% Ergebnissen. Sollte der Export fehlschlagen, müssen Sie die Suche weiter eingrenzen.</target>\n </trans-unit>\n <trans-unit id=\"pnGDFmf\" resname=\"label.type\">\n <source>label.type</source>\n <target>Typ</target>\n </trans-unit>\n <!--\n Navbar - recent entries and activities\n -->\n <trans-unit id=\"OxdYMR3\" resname=\"active.entries\">\n <source>active.entries</source>\n <target>Ihre aktiven Zeitmessungen</target>\n </trans-unit>\n <trans-unit id=\"e7XS97t\" resname=\"timesheet.all\">\n <source>timesheet.all</source>\n <target>Alle Einträge anzeigen</target>\n </trans-unit>\n <trans-unit id=\"WVU_S.A\" resname=\"recent.activities\">\n <source>recent.activities</source>\n <target>Eine ihrer letzten Tätigkeiten neustarten</target>\n </trans-unit>\n <trans-unit id=\"SLV47Uu\" resname=\"recent.activities.format\">\n <source>recent.activities.format</source>\n <target>%activity% in %project% für %customer%</target>\n </trans-unit>\n <trans-unit id=\"dTHY7Mw\" resname=\"timesheet.start\">\n <source>timesheet.start</source>\n <target>Neue Zeitmessung starten</target>\n </trans-unit>\n <!--\n TOOLBARS\n -->\n <trans-unit id=\"MPimOps\" resname=\"label.pageSize\">\n <source>label.pageSize</source>\n <target>Ergebnisse</target>\n </trans-unit>\n <trans-unit id=\"KhyA_PW\" resname=\"label.entryState\">\n <source>label.entryState</source>\n <target>Zeiten</target>\n </trans-unit>\n <trans-unit id=\"X3JM9wj\" resname=\"label.exported\">\n <source>label.exported</source>\n <target>Exportiert</target>\n </trans-unit>\n <trans-unit id=\"_DDecAV\" resname=\"entryState.exported\">\n <source>entryState.exported</source>\n <target>Abgerechnet</target>\n </trans-unit>\n <trans-unit id=\"ccCiXyR\" resname=\"entryState.not_exported\">\n <source>entryState.not_exported</source>\n <target>Offen</target>\n </trans-unit>\n <trans-unit id=\"do7fP0q\" resname=\"entryState.all\">\n <source>entryState.all</source>\n <target>Alle</target>\n </trans-unit>\n <trans-unit id=\"xm7mqoK\" resname=\"entryState.running\">\n <source>entryState.running</source>\n <target>Laufende</target>\n </trans-unit>\n <trans-unit id=\"spHpd_I\" resname=\"entryState.stopped\">\n <source>entryState.stopped</source>\n <target>Beendete</target>\n </trans-unit>\n <trans-unit id=\"BhsaLxX\" resname=\"export.clear_all\">\n <source>export.clear_all</source>\n <target>Alle angezeigten Einträge als offen markieren?</target>\n </trans-unit>\n <trans-unit id=\"qtjPKUT\" resname=\"export.mark_all\">\n <source>export.mark_all</source>\n <target>Alle angezeigten Einträge als abgerechnet markieren?</target>\n </trans-unit>\n <trans-unit id=\"S0vT92U\" resname=\"label.globalsOnly\">\n <source>label.globalsOnly</source>\n <target>Nur globale</target>\n </trans-unit>\n <trans-unit id=\"2Ek7sXu\" resname=\"label.batch_meta_fields\">\n <source>label.batch_meta_fields</source>\n <target>Zusätzliche Felder</target>\n </trans-unit>\n <trans-unit id=\"9Wt8Pp_\" resname=\"help.batch_meta_fields\">\n <source>help.batch_meta_fields</source>\n <target>Felder die aktualisiert werden sollen, müssen zunächst durch einen Klick auf die zugehörige Checkbox freigeschaltet werden.</target>\n </trans-unit>\n <trans-unit id=\"z_YHoZn\" resname=\"label.includeNoWork\">\n <source>label.includeNoWork</source>\n <target>Einträge ohne Buchungen anzeigen</target>\n </trans-unit>\n <trans-unit id=\"B.Dbbob\" resname=\"label.includeNoBudget\">\n <source>label.includeNoBudget</source>\n <target>Einträge ohne Budget anzeigen</target>\n </trans-unit>\n <trans-unit id=\"Wq.h4nD\" resname=\"label.includeBudgetType_month\">\n <source>label.includeBudgetType_month</source>\n <target>Einträge mit „Monats-Budget“ anzeigen</target>\n </trans-unit>\n <trans-unit id=\"nVulc7.\" resname=\"label.includeBudgetType_full\">\n <source>label.includeBudgetType_full</source>\n <target>Einträge mit „Lebenszyklus“-Budget anzeigen</target>\n </trans-unit>\n <trans-unit id=\"3zn5T5e\" resname=\"label.not_exported\">\n <source>label.not_exported</source>\n <target>Nicht exportiert</target>\n </trans-unit>\n <trans-unit id=\"csF1D35\" resname=\"label.not_invoiced\">\n <source>label.not_invoiced</source>\n <target>Nicht abgerechnet</target>\n </trans-unit>\n <trans-unit id=\"AJ6dwR.\" resname=\"label.last_record_before\">\n <source>label.last_record_before</source>\n <target>Keine Zeitbuchung mehr seit</target>\n </trans-unit>\n <trans-unit id=\"qDnURk7\" resname=\"label.last_record\">\n <source>label.last_record</source>\n <target>Letzter Eintrag</target>\n </trans-unit>\n <trans-unit id=\"LXdqaTH\" resname=\"label.account_number\">\n <source>label.account_number</source>\n <target>Personalnummer</target>\n </trans-unit>\n <trans-unit id=\"PoF7hD8\" resname=\"label.budgetType\">\n <source>label.budgetType</source>\n <target>Budget-Typ</target>\n </trans-unit>\n <trans-unit id=\"cHfLJtL\" resname=\"label.budgetType_month\">\n <source>label.budgetType_month</source>\n <target>Monatlich</target>\n </trans-unit>\n <trans-unit id=\"9Rhadz6\" resname=\"label.budgetType_full\">\n <source>label.budgetType_full</source>\n <target>Lebenszyklus</target>\n </trans-unit>\n <trans-unit id=\"tvV0NhL\" resname=\"delete_warning.short_stats\">\n <source>delete_warning.short_stats</source>\n <target>Momentan existieren insgesamt %records% Zeiteinträge, welche sich auf eine Gesamtdauer von %duration% belaufen.</target>\n </trans-unit>\n <trans-unit id=\"Zif614Q\" resname=\"add_user.label\">\n <source>add_user.label</source>\n <target>Benutzer hinzufügen</target>\n </trans-unit>\n <trans-unit id=\"tp.gIrE\" resname=\"team.add_user.help\">\n <source>team.add_user.help</source>\n <target>Durch Auswahl wird dem Team ein neuer Benutzer hinzugefügt. Sie können im Anschluss festlegen, ob der Benutzer ein Teamleiter sein soll.</target>\n </trans-unit>\n <trans-unit id=\"yNWIi5U\" resname=\"default_value_new\">\n <source>default_value_new</source>\n <target>Standardwert für neue Einträge</target>\n </trans-unit>\n <!--\n QUICK ENTRIES\n -->\n <trans-unit id=\"f8oNzSP\" resname=\"quick_entry.title\">\n <source>quick_entry.title</source>\n <target>Wochen-Arbeitsstunden</target>\n </trans-unit>\n <trans-unit id=\"61p_ckr\" resname=\"label.hours_24\">\n <source>label.hours_24</source>\n <target>24 Stunden</target>\n </trans-unit>\n </body>\n </file>\n</xliff>"
] |
[
1,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"de\" datatype=\"plaintext\" original=\"messages.en.xlf\">\n <body>\n <!--\n Global template keys\n -->\n <trans-unit id=\"N7mikjJ\" resname=\"time_tracking\">\n <source>time_tracking</source>\n <target>Zeiterfassung</target>\n </trans-unit>\n <trans-unit id=\"inmIkP6\" resname=\"yes\">\n <source>yes</source>\n <target>Ja</target>\n </trans-unit>\n <trans-unit id=\"k5Apjz_\" resname=\"no\">\n <source>no</source>\n <target>Nein</target>\n </trans-unit>\n <trans-unit id=\".3dyBTq\" resname=\"both\">\n <source>both</source>\n <target>Beides</target>\n </trans-unit>\n <trans-unit id=\"KLIuHvt\" resname=\"This is a mandatory field\">\n <source>This is a mandatory field</source>\n <target>Pflichtfeld</target>\n </trans-unit>\n <trans-unit id=\"_ohHsMM\" resname=\"create\">\n <source>create</source>\n <target>Erstellen</target>\n </trans-unit>\n <trans-unit id=\"DYHuW58\" resname=\"confirm.delete\">\n <source>confirm.delete</source>\n <target>Wollen Sie das wirklich löschen?</target>\n </trans-unit>\n <trans-unit id=\"vDd3alC\" resname=\"admin_entity.delete_confirm\">\n <source>admin_entity.delete_confirm</source>\n <target>\n Diese Daten werden ebenfalls mit gelöscht!\n Alternativ können Sie einen Eintrag auswählen, auf den alle existierenden Daten umgebucht werden:\n </target>\n </trans-unit>\n <trans-unit id=\"COyxNde\" resname=\"delete.not_in_use\">\n <source>delete.not_in_use</source>\n <target>Dieses Element kann sicher gelöscht werden.</target>\n </trans-unit>\n <trans-unit id=\"I3TZF5S\" resname=\"cancel\">\n <source>cancel</source>\n <target>Abbrechen</target>\n </trans-unit>\n <trans-unit id=\"PyZ8KrQ\" resname=\"confirm\">\n <source>confirm</source>\n <target>Bestätigen</target>\n </trans-unit>\n <trans-unit id=\".0CFrRV\" resname=\"upload\">\n <source>upload</source>\n <target>Hochladen</target>\n </trans-unit>\n <trans-unit id=\"JBkykGe\" resname=\"search\">\n <source>search</source>\n <target>Suchen</target>\n </trans-unit>\n <trans-unit id=\"IolBPQD\" resname=\"label.searchTerm\">\n <source>label.searchTerm</source>\n <target>Suchbegriff</target>\n </trans-unit>\n <trans-unit id=\"BytPihM\" resname=\"label.set_as_default\">\n <source>label.set_as_default</source>\n <target>Einstellung als Suchfavorit speichern</target>\n </trans-unit>\n <trans-unit id=\"NNKq04n\" resname=\"label.remove_default\">\n <source>label.remove_default</source>\n <target>Suchfavorit löschen</target>\n </trans-unit>\n <trans-unit id=\"31x84Dt\" resname=\"label.asc\">\n <source>label.asc</source>\n <target>Aufsteigend</target>\n </trans-unit>\n <trans-unit id=\"0D_zaYd\" resname=\"label.desc\">\n <source>label.desc</source>\n <target>Absteigend</target>\n </trans-unit>\n <trans-unit id=\"Z8Fxbvf\" resname=\"label.orderBy\">\n <source>label.orderBy</source>\n <target>Sortieren nach</target>\n </trans-unit>\n <trans-unit id=\"hBNESu6\" resname=\"my.profile\">\n <source>my.profile</source>\n <target>Mein Profil</target>\n </trans-unit>\n <trans-unit id=\"J258iS6\" resname=\"update_multiple\">\n <source>update_multiple</source>\n <target>%action% von %count% Einträgen?</target>\n </trans-unit>\n <trans-unit id=\"OTDmccn\" resname=\"attachments\">\n <source>attachments</source>\n <target>Dateien</target>\n </trans-unit>\n <trans-unit id=\"O5w1jzb\" resname=\"file\">\n <source>file</source>\n <target>Datei</target>\n </trans-unit>\n <trans-unit id=\"0M_Gylq\" resname=\"rates.empty\">\n <source>rates.empty</source>\n <target>Es wurden noch keine Stundensätze hinterlegt.</target>\n </trans-unit>\n <trans-unit id=\"mflwMcX\" resname=\"rates.title\">\n <source>rates.title</source>\n <target>Gebühren</target>\n </trans-unit>\n <trans-unit id=\"zFfl7jw\" resname=\"sum.total\">\n <source>sum.total</source>\n <target>Gesamt</target>\n </trans-unit>\n <trans-unit id=\"XP5zkiN\" resname=\"modal.dirty\">\n <source>modal.dirty</source>\n <target>Das Formular wurde geändert. Bitte klicken Sie „Speichern“, um die Änderungen zu sichern oder „Schließen“, um abzubrechen.</target>\n </trans-unit>\n <!--\n Login / Security\n -->\n <trans-unit id=\"9pvowqn\" resname=\"label.password\">\n <source>label.password</source>\n <target>Passwort</target>\n </trans-unit>\n <trans-unit id=\"WxAnbP0\" resname=\"label.password_repeat\">\n <source>label.password_repeat</source>\n <target>Passwort wiederholen</target>\n </trans-unit>\n <trans-unit id=\"II4DGnv\" resname=\"label.logout\">\n <source>label.logout</source>\n <target>Abmelden</target>\n </trans-unit>\n <trans-unit id=\"hFFZGp_\" resname=\"label.user_profile\">\n <source>label.user_profile</source>\n <target>Mein Profil</target>\n </trans-unit>\n <trans-unit id=\"gXZR.hV\" resname=\"label.api_token\">\n <source>label.api_token</source>\n <target>API-Passwort</target>\n </trans-unit>\n <trans-unit id=\"s_X2xpI\" resname=\"label.api_token_repeat\">\n <source>label.api_token_repeat</source>\n <target>API-Passwort wiederholen</target>\n </trans-unit>\n <trans-unit id=\".372.o7\" resname=\"login_required\">\n <source>login_required</source>\n <target>Fehlende Berechtigung. Zur Anmeldung wechseln?</target>\n </trans-unit>\n <trans-unit id=\".ndupSK\" resname=\"registration.check_email\">\n <source>registration.check_email</source>\n <target>Eine E-Mail wurde an %email% gesendet. Sie enthält einen Link, den Sie anklicken müssen, um Ihr Benutzerkonto zu bestätigen.</target>\n </trans-unit>\n <trans-unit id=\"_cY.wHP\" resname=\"resetting.check_email\">\n <source>resetting.check_email</source>\n <target>\n Eine E-Mail wurde verschickt. Sie beinhaltet einen Link zum Zurücksetzen des Passwortes.\n Hinweis: Ein neues Passwort kann nur alle %tokenLifetime% Stunden beantragt werden.",
" Eventuell wurde diese E-Mail als Spam markiert, wenn sie nicht angekommen ist.\n </target>\n </trans-unit>\n <!--\n Menu / Navbar items\n -->\n <trans-unit id=\"UoOv6mx\" approved=\"yes\" resname=\"menu.homepage\">\n <source>menu.homepage</source>\n <target>Dashboard</target>\n </trans-unit>\n <trans-unit id=\"wvvYSw_\" resname=\"menu.admin\">\n <source>menu.admin</source>\n <target>Administration</target>\n </trans-unit>\n <trans-unit id=\"6OKwCUB\" resname=\"menu.system\">\n <source>menu.system</source>\n <target>System</target>\n </trans-unit>\n <trans-unit id=\"wBTFKFR\" resname=\"menu.logout\">\n <source>menu.logout</source>\n <target>Abmelden</target>\n </trans-unit>\n <trans-unit id=\"C0W7_BT\" resname=\"menu.timesheet\">\n <source>menu.timesheet</source>\n <target>Meine Zeiten</target>\n </trans-unit>\n <trans-unit id=\"Ci9W8.K\" resname=\"menu.invoice\">\n <source>menu.invoice</source>\n <target>Rechnungen</target>\n </trans-unit>\n <trans-unit id=\"I.eil4u\" resname=\"menu.export\">\n <source>menu.export</source>\n <target>Export</target>\n </trans-unit>\n <trans-unit id=\"ypVQO7o\" resname=\"menu.reporting\">\n <source>menu.reporting</source>\n <target>Berichte</target>\n </trans-unit>\n <trans-unit id=\"WGIhZv1\" resname=\"menu.admin_timesheet\">\n <source>menu.admin_timesheet</source>\n <target>Zeiterfassung</target>\n </trans-unit>\n <trans-unit id=\"Y_jAD36\" resname=\"menu.admin_customer\">\n <source>menu.admin_customer</source>\n <target>Kunden</target>\n </trans-unit>\n <trans-unit id=\"oDLp9t3\" resname=\"menu.admin_project\">\n <source>menu.admin_project</source>\n <target>Projekte</target>\n </trans-unit>\n <trans-unit id=\"wriHFwl\" resname=\"menu.admin_activity\">\n <source>menu.admin_activity</source>\n <target>Tätigkeiten</target>\n </trans-unit>\n <trans-unit id=\"oZo1BnZ\" resname=\"menu.admin_user\">\n <source>menu.admin_user</source>\n <target>Benutzer</target>\n </trans-unit>\n <trans-unit id=\"pA.bYIk\" resname=\"menu.admin_team\">\n <source>menu.admin_team</source>\n <target>Teams</target>\n </trans-unit>\n <trans-unit id=\"hOZxcaK\" resname=\"menu.plugin\">\n <source>menu.plugin</source>\n <target>Erweiterungen</target>\n </trans-unit>\n <trans-unit id=\"IXtkHRw\" resname=\"menu.system_configuration\">\n <source>menu.system_configuration</source>\n <target>Einstellungen</target>\n </trans-unit>\n <trans-unit id=\"yo4f8Kh\" resname=\"menu.tags\">\n <source>menu.tags</source>\n <target>Schlagworte</target>\n </trans-unit>\n <trans-unit id=\"1kHI0gb\" resname=\"menu.doctor\">\n <source>menu.doctor</source>\n <target>Doktor</target>\n </trans-unit>\n <!--\n Error templates\n -->\n <trans-unit id=\"Vz3Igj3\" resname=\"error.no_entries_found\">\n <source>error.no_entries_found</source>\n <target>Anhand ihrer ausgewählten Filter wurden keine Einträge gefunden.</target>\n </trans-unit>\n <trans-unit id=\"hlu4iX5\" resname=\"error.no_comments_found\">\n <source>error.no_comments_found</source>\n <target>Es wurden noch keine Kommentare abgegeben.</target>\n </trans-unit>\n <trans-unit id=\"XQ2.pq2\" resname=\"error.too_many_entries\">\n <source>error.too_many_entries</source>\n <target>Die Anfrage konnte nicht verarbeitet werden. Es wurden zu viele Ergebnisse gefunden.</target>\n </trans-unit>\n <!--\n General labels\n -->\n <trans-unit id=\"H1qEi4d\" resname=\"label.date\">\n <source>label.date</source>\n <target>Datum</target>\n </trans-unit>\n <trans-unit id=\"eJPDE76\" resname=\"label.starttime\">\n <source>label.starttime</source>\n <target>Beginn</target>\n </trans-unit>\n <trans-unit id=\"uZlpDFh\" resname=\"label.endtime\">\n <source>label.endtime</source>\n <target>Ende</target>\n </trans-unit>\n <trans-unit id=\"cgpmY0I\" resname=\"label.duration\">\n <source>label.duration</source>\n <target>Dauer</target>\n </trans-unit>\n <trans-unit id=\"O2X4xZH\" resname=\"label.user\">\n <source>label.user</source>\n <target>Benutzer</target>\n </trans-unit>\n <trans-unit id=\"LDhDPrF\" resname=\"label.username\">\n <source>label.username</source>\n <target>Benutzer</target>\n </trans-unit>\n <trans-unit id=\"4cEApe1\" resname=\"label.description\">\n <source>label.description</source>\n <target>Beschreibung</target>\n </trans-unit>\n <trans-unit id=\"ysOvPSq\" resname=\"label.name\">\n <source>label.name</source>\n <target>Name</target>\n </trans-unit>\n <trans-unit id=\"WqTho4C\" resname=\"label.comment\">\n <source>label.comment</source>\n <target>Kommentar</target>\n </trans-unit>\n <trans-unit id=\"txRonia\" resname=\"label.id\">\n <source>label.id</source>\n <target>ID</target>\n </trans-unit>\n <trans-unit id=\"CYpZwBz\" resname=\"label.visible\">\n <source>label.visible</source>\n <target>Sichtbar</target>\n </trans-unit>\n <trans-unit id=\"2ktNwkr\" approved=\"yes\" resname=\"label.budget\">\n <source>label.budget</source>\n <target>Budget</target>\n </trans-unit>\n <trans-unit id=\"x8TrOec\" resname=\"label.timeBudget\">\n <source>label.timeBudget</source>\n <target>Zeit-Budget</target>\n </trans-unit>\n <trans-unit id=\"l1wiL0h\" resname=\"label.activity\">\n <source>label.activity</source>\n <target>Tätigkeit</target>\n </trans-unit>\n <trans-unit id=\"KtnqJcg\" resname=\"label.project\">\n <source>label.project</source>\n <target>Projekt</target>\n </trans-unit>\n <trans-unit id=\"VAbtieW\" resname=\"label.hourlyRate\">\n <source>label.hourlyRate</source>\n <target>Stundenlohn</target>\n </trans-unit>\n <trans-unit id=\"VNCQ7YU\" resname=\"label.tag\">\n <source>label.tag</source>\n <target>Schlagworte</target>\n </trans-unit>\n <trans-unit id=\"ijQyGRo\" resname=\"label.tags\">\n <source>label.tags</source>\n <target>Schlagworte</target>\n </trans-unit>\n <trans-unit id=\"IQ.tlua\" resname=\"label.hourly_rate\">\n <source>label.hourly_rate</source>\n <target>Stundenlohn</target>\n </trans-unit>\n <trans-unit id=\"dezCZWf\" resname=\"label.skin\">\n <source>label.skin</source>\n <target>Darstellung: Farben</target>\n </trans-unit>\n <trans-unit id=\"42BRM3Q\" resname=\"label.theme.layout\">\n <source>label.theme.layout</source>\n <target>Darstellung: Layout</target>\n </trans-unit>\n <trans-unit id=\"w8T34A6\" resname=\"label.hours\">\n <source>label.hours</source>\n <target>Stunden</target>\n </trans-unit>\n <trans-unit id=\"Ih3IFXj\" resname=\"label.rate\">\n <source>label.rate</source>\n <target>Lohn</target>\n </trans-unit>\n <trans-unit id=\"djL6LMC\" resname=\"help.rate\">\n <source>help.rate</source>\n <target>Zu berechnender Stundensatz</target>\n </trans-unit>\n <trans-unit id=\"QzvjNwg\" resname=\"label.rate_internal\">\n <source>label.rate_internal</source>\n <target>Interner Lohn</target>\n </trans-unit>\n <trans-unit id=\"uz4SmfP\" resname=\"help.rate_internal\">\n <source>help.rate_internal</source>\n <target>Interner Verrechnungswert (wenn dieser nicht angegeben ist, wird der normale Satz verwendet)</target>\n </trans-unit>\n <trans-unit id=\"v72sA1c\" resname=\"label.recalculate_rates\">\n <source>label.recalculate_rates</source>\n <target>Preise neu berechnen</target>\n </trans-unit>\n <trans-unit id=\"foM2o5T\" resname=\"label.language\">\n <source>label.language</source>\n <target>Sprache</target>\n </trans-unit>\n <trans-unit id=\"Z8a2kUf\" resname=\"label.customer\">\n <source>label.customer</source>\n <target>Kunde</target>\n </trans-unit>\n <trans-unit id=\"D2N6_cP\" resname=\"label.email\">\n <source>label.email</source>\n <target>E-Mail</target>\n </trans-unit>\n <trans-unit id=\"Ss2xe99\" resname=\"label.team\">\n <source>label.team</source>\n <target>Team</target>\n </trans-unit>\n <trans-unit id=\"Zpj9UB4\" resname=\"label.teamlead\">\n <source>label.teamlead</source>\n <target>Teamleiter</target>\n </trans-unit>\n <trans-unit id=\"hX.EQKy\" resname=\"label.create_more\">\n <source>label.create_more</source>\n <target>Weitere Einträge erstellen</target>\n </trans-unit>\n <trans-unit id=\"LIOnolg\" resname=\"placeholder.type_message\">\n <source>placeholder.type_message</source>\n <target>Schreibe deine Nachricht …</target>\n </trans-unit>\n <trans-unit id=\"vkHr9AP\" resname=\"label.billable\">\n <source>label.billable</source>\n <target>Abrechenbar</target>\n </trans-unit>\n <!--\n Buttons & Actions\n -->\n <trans-unit id=\"zldXQq6\" resname=\"label.actions\">\n <source>label.actions</source>\n <target>Aktionen</target>\n </trans-unit>\n <trans-unit id=\"ovKkXwU\" resname=\"action.edit\">\n <source>action.edit</source>\n <target>Bearbeiten</target>\n </trans-unit>\n <trans-unit id=\"jdbtx6z\" resname=\"action.add\">\n <source>action.add</source>\n <target>Hinzufügen</target>\n </trans-unit>\n <trans-unit id=\"hTKWQ6g\" resname=\"action.delete\">\n <source>action.delete</source>\n <target>Löschen</target>\n </trans-unit>\n <trans-unit id=\"HLtdhYw\" resname=\"action.save\">\n <source>action.save</source>\n <target>Speichern</target>\n </trans-unit>\n <trans-unit id=\"9hpJPiG\" resname=\"action.save_all\">\n <source>action.save_all</source>\n <target>Alle speichern</target>\n </trans-unit>\n <trans-unit id=\"tKZKI2Z\" resname=\"action.reset\">\n <source>action.reset</source>\n <target>Zurücksetzen</target>\n </trans-unit>\n <trans-unit id=\"Eb7Ygpo\" resname=\"action.back\">\n <source>action.back</source>\n <target>Zurück</target>\n </trans-unit>\n <trans-unit id=\"wCazS.X\" resname=\"action.close\">\n <source>action.close</source>\n <target>Schließen</target>\n </trans-unit>\n <!--\n Dashboard\n -->\n <trans-unit id=\"3bqLM8Q\" resname=\"dashboard.title\">\n <source>dashboard.title</source>\n <target>Dashboard</target>\n </trans-unit>\n <trans-unit id=\"3PYadzb\" resname=\"dashboard.subtitle\">\n <source>dashboard.subtitle</source>\n <target>Willkommen!</target>\n </trans-unit>\n <trans-unit id=\"yEa1Yz3\" resname=\"dashboard.all\">\n <source>dashboard.all</source>\n <target>Alle Benutzer</target>\n </trans-unit>\n <!--\n Widgets\n -->\n <trans-unit id=\"giznf_R\" resname=\"more.info.link\">\n <source>more.info.link</source>\n <target>Mehr Infos</target>\n </trans-unit>\n <trans-unit id=\"4iliLZT\" resname=\"label.toggle_dropdown\">\n <source>label.toggle_dropdown</source>\n <target>Menü anzeigen</target>\n </trans-unit>\n <trans-unit id=\"f3KMQJh\" resname=\"label.my_teams\">\n <source>label.my_teams</source>\n <target>Meine Teams</target>\n </trans-unit>\n <trans-unit id=\"jTiYRIu\" resname=\"label.my_team_projects\">\n <source>label.my_team_projects</source>\n <target>Meine Projekte</target>\n </trans-unit>\n <trans-unit id=\"1PQHtXu\" resname=\"label.progress\">\n <source>label.progress</source>\n <target>Fortschritt</target>\n </trans-unit>\n <trans-unit id=\"vTY9SUk\" resname=\"label.plus_more\">\n <source>label.plus_more</source>\n <target>+%count% weitere</target>\n </trans-unit>\n <!--\n Timesheet\n -->\n <trans-unit id=\"VXj0Y3h\" resname=\"timesheet.title\">\n <source>timesheet.title</source>\n <target>Meine Zeiten</target>\n </trans-unit>\n <trans-unit id=\"dwEVXUR\" resname=\"timesheet.edit\">\n <source>timesheet.edit</source>\n <target>Eintrag bearbeiten</target>\n </trans-unit>\n <trans-unit id=\"trDJK9W\" resname=\"label.begin\">\n <source>label.begin</source>\n <target>Von</target>\n </trans-unit>\n <trans-unit id=\"R9typUt\" resname=\"label.end\">\n <source>label.end</source>\n <target>Bis</target>\n </trans-unit>\n <trans-unit id=\"egaNXjp\" resname=\"label.daterange\">\n <source>label.daterange</source>\n <target>Zeitraum</target>\n </trans-unit>\n <trans-unit id=\"UbnqJLn\" resname=\"modal.columns.title\">\n <source>modal.columns.title</source>\n <target>Ändere Spalten-Sichtbarkeit</target>\n </trans-unit>\n <trans-unit id=\"EbfIoLp\" resname=\"modal.columns.description\">\n <source>modal.columns.description</source>\n <target>Beim Speichern werden die nicht ausgewählten Spalten ausgeblendet und diese Einstellungen in einem Browser Cookie hinterlegt. Sollten Sie Ihre Cookies löschen, werden die Einstellungen rückgängig gemacht.</target>\n </trans-unit>\n <trans-unit id=\"5gjqxgK\" resname=\"label.fixedRate\">\n <source>label.fixedRate</source>\n <target>Festbetrag</target>\n </trans-unit>\n <trans-unit id=\"b43sCwO\" resname=\"help.fixedRate\">\n <source>help.fixedRate</source>\n <target>Jeder Zeiteintrag bekommt den gleichen Wert, unabhängig von seiner Dauer</target>\n </trans-unit>\n <trans-unit id=\"YTSS_Q1\" resname=\"label.color\">\n <source>label.color</source>\n <target>Farbe</target>\n </trans-unit>\n <trans-unit id=\"EoouxGX\" resname=\"label.replaceTags\">\n <source>label.replaceTags</source>\n <target>Schlagworte ersetzen</target>\n </trans-unit>\n <trans-unit id=\"BxkmaKz\" resname=\"label.appendTags\">\n <source>label.appendTags</source>\n <target>Schlagworte hinzufügen</target>\n </trans-unit>\n <!--\n User profile\n -->\n <trans-unit id=\"1_wnK76\" resname=\"profile.title\">\n <source>profile.title</source>\n <target>Benutzerprofil</target>\n </trans-unit>\n <trans-unit id=\"HWKJZ0T\" resname=\"profile.about_me\">\n <source>profile.about_me</source>\n <target>Über mich</target>\n </trans-unit>\n <trans-unit id=\"Fm.kwVn\" resname=\"profile.first_entry\">\n <source>profile.first_entry</source>\n <target>Arbeitet seit</target>\n </trans-unit>\n <trans-unit id=\"1c0EQaz\" resname=\"profile.registration_date\">\n <source>profile.registration_date</source>\n <target>Registriert am</target>\n </trans-unit>\n <trans-unit id=\"xEYQXPy\" resname=\"profile.settings\">\n <source>profile.settings</source>\n <target>Profil</target>\n </trans-unit>\n <trans-unit id=\"A6TLLQa\" resname=\"profile.password\">\n <source>profile.password</source>\n <target>Passwort</target>\n </trans-unit>\n <trans-unit id=\"Z34ZpjK\" resname=\"profile.api-token\">\n <source>profile.api-token</source>\n <target>API</target>\n </trans-unit>\n <trans-unit id=\"ygtTz8.\" resname=\"profile.roles\">\n <source>profile.roles</source>\n <target>Rollen</target>\n </trans-unit>\n <trans-unit id=\"DZ7XGML\" resname=\"profile.teams\">\n <source>profile.teams</source>\n <target>Teams</target>\n </trans-unit>\n <trans-unit id=\"MQKiG33\" resname=\"profile.preferences\">\n <source>profile.preferences</source>\n <target>Einstellungen</target>\n </trans-unit>\n <trans-unit id=\"Eq78QrH\" resname=\"label.theme.collapsed_sidebar\">\n <source>label.theme.collapsed_sidebar</source>\n <target>Minimiert die linke Navigationsleiste</target>\n </trans-unit>\n <trans-unit id=\"0sgroZi\" resname=\"label.calendar.initial_view\">\n <source>label.calendar.initial_view</source>\n <target>Initiale Darstellung des Kalenders</target>\n </trans-unit>\n <trans-unit id=\"iqQsgIW\" resname=\"label.login.initial_view\">\n <source>label.login.initial_view</source>\n <target>Initiale Ansicht nach Anmeldung</target>\n </trans-unit>\n <trans-unit id=\"hO7mkmf\" resname=\"label.lastLogin\">\n <source>label.lastLogin</source>\n <target>Letzte Anmeldung</target>\n </trans-unit>\n <!-- Options for user-preference label.calendar.initial_view -->\n <trans-unit id=\"pcfRcZ4\" resname=\"month\">\n <source>month</source>\n <target>Monat</target>\n </trans-unit>\n <trans-unit id=\"Irm6dfx\" resname=\"agendaWeek\">\n <source>agendaWeek</source>\n <target>Woche</target>\n </trans-unit>\n <trans-unit id=\"Q0Zip02\" resname=\"agendaDay\">\n <source>agendaDay</source>\n <target>Tag</target>\n </trans-unit>\n <trans-unit id=\"rYzHCFd\" resname=\"label.timesheet.daily_stats\">\n <source>label.timesheet.daily_stats</source>\n <target>Tägliche Statistiken im Timesheet anzeigen</target>\n </trans-unit>\n <trans-unit id=\"tSlqVK2\" resname=\"label.timesheet.export_decimal\">\n <source>label.timesheet.export_decimal</source>\n <target>Dezimal Format für Export nutzen</target>\n </trans-unit>\n <trans-unit id=\"5R.QsZ3\" resname=\"theme.update_browser_title\">\n <source>theme.update_browser_title</source>\n <target>Browser Titel aktualisieren</target>\n </trans-unit>\n <!--\n User timesheet calendar\n -->\n <trans-unit id=\"HWiuMV6\" resname=\"calendar.title\">\n <source>calendar.title</source>\n <target>Kalender</target>\n </trans-unit>\n <trans-unit id=\"75kjTF9\" resname=\"calendar.drag_and_drop.delete\">\n <source>calendar.drag_and_drop.delete</source>\n <target>Wenn Sie einen Eintrag löschen wollen, müssen Sie ihn auf die Schaltfläche ziehen.</target>\n </trans-unit>\n <!--\n Admin: Timesheet\n -->\n <trans-unit id=\"bSDjzZL\" resname=\"admin_timesheet.title\">\n <source>admin_timesheet.title</source>\n <target>Zeiterfassung</target>\n </trans-unit>\n <!--\n Admin: Projects\n -->\n <trans-unit id=\"DFjFRGe\" resname=\"admin_project.title\">\n <source>admin_project.title</source>\n <target>Projekte</target>\n </trans-unit>\n <trans-unit id=\"yLOqEX_\" resname=\"label.project_start\">\n <source>label.project_start</source>\n <target>Projekt Start</target>\n </trans-unit>\n <trans-unit id=\"4kQGReV\" resname=\"label.project_end\">\n <source>label.project_end</source>\n <target>Projekt Ende</target>\n </trans-unit>\n <!--\n Admin: Activity\n -->\n <trans-unit id=\"auu8q0u\" resname=\"admin_activity.title\">\n <source>admin_activity.title</source>\n <target>Tätigkeiten</target>\n </trans-unit>\n <!--\n Admin: Customer\n -->\n <trans-unit id=\"2TvKX9Z\" resname=\"admin_customer.title\">\n <source>admin_customer.title</source>\n <target>Kunden</target>\n </trans-unit>\n <trans-unit id=\"39AtPxQ\" resname=\"label.number\">\n <source>label.number</source>\n <target>Kundennummer</target>\n </trans-unit>\n <trans-unit id=\"7jfRn_1\" resname=\"label.company\">\n <source>label.company</source>\n <target>Unternehmensbezeichnung</target>\n </trans-unit>\n <trans-unit id=\"GOStgLi\" resname=\"label.vat\">\n <source>label.vat</source>\n <target>Umsatzsteuer</target>\n </trans-unit>\n <trans-unit id=\"Dgmh_mv\" resname=\"label.vat_id\">\n <source>label.vat_id</source>\n <target>Umsatzsteuer-ID</target>\n </trans-unit>\n <trans-unit id=\"YNGNfGn\" resname=\"label.tax_rate\">\n <source>label.tax_rate</source>\n <target>Steuersatz</target>\n </trans-unit>\n <trans-unit id=\"0tkOMo1\" resname=\"label.contact\">\n <source>label.contact</source>\n <target>Kontakt</target>\n </trans-unit>\n <trans-unit id=\"c9W5AO4\" resname=\"label.address\">\n <source>label.address</source>\n <target>Adresse</target>\n </trans-unit>\n <trans-unit id=\"k7MJQ82\" resname=\"label.country\">\n <source>label.country</source>\n <target>Land</target>\n </trans-unit>\n <trans-unit id=\"g03c_vw\" resname=\"label.phone\">\n <source>label.phone</source>\n <target>Telefon</target>\n </trans-unit>\n <trans-unit id=\"eRyhERS\" resname=\"label.fax\">\n <source>label.fax</source>\n <target>Fax</target>\n </trans-unit>\n <trans-unit id=\"AawT9pW\" resname=\"label.mobile\">\n <source>label.mobile</source>\n <target>Mobiltelefon</target>\n </trans-unit>\n <trans-unit id=\"PS9IH_t\" approved=\"yes\" resname=\"label.homepage\">\n <source>label.homepage</source>\n <target>Homepage</target>\n </trans-unit>\n <trans-unit id=\"dmtPdwq\" resname=\"label.timezone\">\n <source>label.timezone</source>\n <target>Zeitzone</target>\n </trans-unit>\n <trans-unit id=\"otd2FZd\" resname=\"label.currency\">\n <source>label.currency</source>\n <target>Währung</target>\n </trans-unit>\n <!--\n Admin: User\n -->\n <trans-unit id=\"t34EvnF\" resname=\"admin_user.title\">\n <source>admin_user.title</source>\n <target>Benutzer</target>\n </trans-unit>\n <trans-unit id=\"TRDzmCV\" resname=\"label.alias\">\n <source>label.alias</source>\n <target>Name</target>\n </trans-unit>\n <trans-unit id=\"UrRn8xj\" resname=\"label.title\">\n <source>label.title</source>\n <target>Titel</target>\n </trans-unit>\n <trans-unit id=\"nWMH_Nr\" resname=\"label.avatar\">\n <source>label.avatar</source>\n <target>Profilbild (URL)</target>\n </trans-unit>\n <trans-unit id=\"KtTP.Sh\" resname=\"label.active\">\n <source>label.active</source>\n <target>Aktiv</target>\n </trans-unit>\n <trans-unit id=\"iD6CNOO\" resname=\"label.roles\">\n <source>label.roles</source>\n <target>Rolle</target>\n </trans-unit>\n <trans-unit id=\"ZlZ20pG\" resname=\"user_permissions.title\">\n <source>user_permissions.title</source>\n <target>Benutzer Berechtigungen</target>\n </trans-unit>\n <trans-unit id=\"G.GEdlk\" resname=\"user_role.title\">\n <source>user_role.title</source>\n <target>Benutzer Rolle</target>\n </trans-unit>\n <trans-unit id=\"E7G60OF\" resname=\"Allowed character: A-Z and _\">\n <source>Allowed character: A-Z and _</source>\n <target>Erlaubte Zeichen: A-Z und _</target>\n </trans-unit>\n <!--\n Admin: Plugins\n -->\n <trans-unit id=\"d75KAlJ\" resname=\"label.version\">\n <source>label.version</source>\n <target>Version</target>\n </trans-unit>\n <trans-unit id=\"8Rfa01v\" resname=\"label.required_version\">\n <source>label.required_version</source>\n <target>Kompatibel mit</target>\n </trans-unit>\n <!--\n ROLES\n -->\n <trans-unit id=\"WRuKTcz\" resname=\"ROLE_SUPER_ADMIN\">\n <source>ROLE_SUPER_ADMIN</source>\n <target>System-Admin</target>\n </trans-unit>\n <trans-unit id=\"718iPw6\" resname=\"ROLE_ADMIN\">\n <source>ROLE_ADMIN</source>\n <target>Administrator</target>\n </trans-unit>\n <trans-unit id=\"yttGLAB\" resname=\"ROLE_TEAMLEAD\">\n <source>ROLE_TEAMLEAD</source>\n <target>Teamleiter</target>\n </trans-unit>\n <trans-unit id=\"rvO5ZXf\" resname=\"ROLE_USER\">\n <source>ROLE_USER</source>\n <target>Benutzer</target>\n </trans-unit>\n <!--\n Statistics data for Dashboard & Users profile\n -->\n <trans-unit id=\"lfSTZGe\" resname=\"stats.workingTimeToday\">\n <source>stats.workingTimeToday</source>\n <target>Heute, %day%</target>\n </trans-unit>\n <trans-unit id=\"XdYs3I8\" resname=\"stats.workingTimeWeek\">\n <source>stats.workingTimeWeek</source>\n <target>Kalenderwoche %week%</target>\n </trans-unit>",
" <trans-unit id=\"HPhRbtc\" resname=\"stats.workingTimeWeekShort\">\n <source>stats.workingTimeWeekShort</source>\n <target>KW %week%</target>\n </trans-unit>",
" <trans-unit id=\"JIKNAYP\" approved=\"yes\" resname=\"stats.workingTimeMonth\">\n <source>stats.workingTimeMonth</source>\n <target>%month% %year%</target>\n </trans-unit>\n <trans-unit id=\"JnUFsNi\" resname=\"stats.workingTimeYear\">\n <source>stats.workingTimeYear</source>\n <target>Gesamtes Jahr %year%</target>\n </trans-unit>\n <trans-unit id=\"HWB4OGJ\" resname=\"stats.workingTimeFinancialYear\">\n <source>stats.workingTimeFinancialYear</source>\n <target>Geschäftsjahr</target>\n </trans-unit>\n <trans-unit id=\"BXBFJP8\" resname=\"stats.workingTime\">\n <source>stats.workingTime</source>\n <target>Arbeitszeit</target>\n </trans-unit>\n <trans-unit id=\"pX_3dNm\" resname=\"stats.revenue\">\n <source>stats.revenue</source>\n <target>Einnahmen</target>\n </trans-unit>\n <trans-unit id=\"TdBJBAl\" resname=\"stats.durationToday\">\n <source>stats.durationToday</source>\n <target>Arbeitszeit heute</target>\n </trans-unit>\n <trans-unit id=\"XhKalZH\" resname=\"stats.durationWeek\">\n <source>stats.durationWeek</source>\n <target>Arbeitszeit diese Woche</target>\n </trans-unit>\n <trans-unit id=\"uaOwf_P\" resname=\"stats.durationMonth\">\n <source>stats.durationMonth</source>\n <target>Arbeitszeit diesen Monat</target>\n </trans-unit>\n <trans-unit id=\"WqF84KR\" resname=\"stats.durationYear\">\n <source>stats.durationYear</source>\n <target>Arbeitszeit dieses Jahr</target>\n </trans-unit>\n <trans-unit id=\"xkugSAA\" resname=\"stats.durationFinancialYear\">\n <source>stats.durationFinancialYear</source>\n <target>Arbeitszeit dieses Geschäftsjahr</target>\n </trans-unit>\n <trans-unit id=\"YtvPnl1\" resname=\"stats.durationTotal\">\n <source>stats.durationTotal</source>\n <target>Arbeitszeit total</target>\n </trans-unit>\n <trans-unit id=\"IFOLMgp\" resname=\"stats.yourWorkingHours\">\n <source>stats.yourWorkingHours</source>\n <target>Meine Arbeitszeiten</target>\n </trans-unit>\n <trans-unit id=\"023M9Ta\" resname=\"stats.amountToday\">\n <source>stats.amountToday</source>\n <target>Umsatz heute</target>\n </trans-unit>\n <trans-unit id=\"xnJvYAE\" resname=\"stats.amountWeek\">\n <source>stats.amountWeek</source>\n <target>Umsatz diese Woche</target>\n </trans-unit>\n <trans-unit id=\"ulr3reE\" resname=\"stats.amountMonth\">\n <source>stats.amountMonth</source>\n <target>Umsatz diesen Monat</target>\n </trans-unit>\n <trans-unit id=\"bQZyZaO\" resname=\"stats.amountYear\">\n <source>stats.amountYear</source>\n <target>Umsatz dieses Jahr</target>\n </trans-unit>\n <trans-unit id=\"wuUWovn\" resname=\"stats.amountFinancialYear\">\n <source>stats.amountFinancialYear</source>\n <target>Umsatz dieses Geschäftsjahr</target>\n </trans-unit>\n <trans-unit id=\"Z0fz23v\" resname=\"stats.amountTotal\">\n <source>stats.amountTotal</source>\n <target>Umsatz total</target>\n </trans-unit>\n <trans-unit id=\"xyiadv3\" resname=\"stats.userActiveToday\">\n <source>stats.userActiveToday</source>\n <target>Aktive Benutzer heute</target>\n </trans-unit>\n <trans-unit id=\"knMHaeO\" resname=\"stats.userActiveWeek\">\n <source>stats.userActiveWeek</source>\n <target>Aktive Benutzer diese Woche</target>\n </trans-unit>\n <trans-unit id=\"adzVDgb\" resname=\"stats.userActiveMonth\">\n <source>stats.userActiveMonth</source>\n <target>Aktive Benutzer diesen Monat</target>\n </trans-unit>\n <trans-unit id=\"AswjFvh\" resname=\"stats.userActiveYear\">\n <source>stats.userActiveYear</source>\n <target>Aktive Benutzer dieses Jahr</target>\n </trans-unit>\n <trans-unit id=\"zMY6gkY\" resname=\"stats.userActiveFinancialYear\">\n <source>stats.userActiveFinancialYear</source>\n <target>Aktive Benutzer dieses Geschäftsjahr</target>\n </trans-unit>\n <trans-unit id=\"dLTb1Po\" resname=\"stats.userActiveTotal\">\n <source>stats.userActiveTotal</source>\n <target>Aktive Benutzer jemals</target>\n </trans-unit>\n <trans-unit id=\"lEW82ex\" resname=\"stats.activeRecordings\">\n <source>stats.activeRecordings</source>\n <target>Aktive Zeitmessungen</target>\n </trans-unit>\n <trans-unit id=\"t5eIWp8\" resname=\"stats.userTotal\">\n <source>stats.userTotal</source>\n <target>Anzahl Benutzer</target>\n </trans-unit>\n <trans-unit id=\"Bor.76M\" resname=\"stats.activityTotal\">\n <source>stats.activityTotal</source>\n <target>Anzahl Tätigkeiten</target>\n </trans-unit>\n <trans-unit id=\"67uSaR3\" resname=\"stats.projectTotal\">\n <source>stats.projectTotal</source>\n <target>Anzahl Projekte</target>\n </trans-unit>\n <trans-unit id=\"tnD6aPj\" resname=\"stats.customerTotal\">\n <source>stats.customerTotal</source>\n <target>Anzahl Kunden</target>\n </trans-unit>\n <trans-unit id=\"unC5MXv\" resname=\"stats.percentUsed\">\n <source>stats.percentUsed</source>\n <target>%percent%% verwendet</target>\n </trans-unit>\n <trans-unit id=\"HkjvwLc\" resname=\"stats.percentUsedLeft\">\n <source>stats.percentUsedLeft</source>\n <target>%percent%% verwendet (noch %left% offen)</target>\n </trans-unit>\n <trans-unit id=\"xN7MfSA\" resname=\"stats.percentUsed_month\">\n <source>stats.percentUsed_month</source>\n <target>%percent%% verwendet diesen Monat</target>\n </trans-unit>\n <trans-unit id=\"vWJPpYU\" resname=\"stats.percentUsedLeft_month\">\n <source>stats.percentUsedLeft_month</source>\n <target>%percent%% verwendet (noch %left% diesen Monat offen)</target>\n </trans-unit>\n <!--\n Invoice\n -->\n <trans-unit id=\"Oq.KtC6\" resname=\"admin_invoice_template.title\">\n <source>admin_invoice_template.title</source>\n <target>Rechnungsvorlagen</target>\n </trans-unit>\n <trans-unit id=\"iERywrp\" resname=\"invoice.title\">\n <source>invoice.title</source>\n <target>Rechnungen</target>\n </trans-unit>\n <trans-unit id=\"ov4OQOh\" resname=\"invoice.filter\">\n <source>invoice.filter</source>\n <target>Rechnungsdaten filtern</target>\n </trans-unit>\n <trans-unit id=\"7H7P1mE\" resname=\"button.preview\">\n <source>button.preview</source>\n <target>Vorschau</target>\n </trans-unit>\n <trans-unit id=\"IQ9DUOW\" resname=\"button.preview_print\">\n <source>button.preview_print</source>\n <target>Druck Vorschau</target>\n </trans-unit>\n <trans-unit id=\"X70dwP8\" resname=\"button.print\">\n <source>button.print</source>\n <target>Drucken</target>\n </trans-unit>\n <trans-unit id=\"W_TXvSi\" resname=\"button.csv\">\n <source>button.csv</source>\n <target>CSV</target>\n </trans-unit>\n <trans-unit id=\"vC2IsaP\" resname=\"button.xlsx\">\n <source>button.xlsx</source>\n <target>Excel</target>\n </trans-unit>\n <trans-unit id=\"aAa5uRR\" resname=\"button.pdf\">\n <source>button.pdf</source>\n <target>PDF</target>\n </trans-unit>\n <trans-unit id=\"ulYFDIo\" resname=\"button.ods\">\n <source>button.ods</source>\n <target>ODS</target>\n </trans-unit>\n <trans-unit id=\"zPcx3O_\" resname=\"invoice_print\">\n <source>invoice_print</source>\n <target>Rechnung</target>\n </trans-unit>\n <trans-unit id=\"7J7G3Vr\" resname=\"label.mark_as_exported\">\n <source>label.mark_as_exported</source>\n <target>Als exportiert markieren</target>\n </trans-unit>\n <trans-unit id=\"p0IprAw\" resname=\"label.template\">\n <source>label.template</source>\n <target>Vorlage</target>\n </trans-unit>\n <trans-unit id=\"zfIRxJh\" resname=\"label.due_days\">\n <source>label.due_days</source>\n <target>Zahlungsziel in Tagen</target>\n </trans-unit>\n <trans-unit id=\"rAJrxSK\" resname=\"invoice.due_days\">\n <source>invoice.due_days</source>\n <target>Zahlungsziel</target>\n </trans-unit>\n <trans-unit id=\"Xij3oQl\" resname=\"invoice.payment_date\">\n <source>invoice.payment_date</source>\n <target>Zahlungsdatum</target>\n </trans-unit>\n <trans-unit id=\"4XKFnWh\" resname=\"invoice.from\">\n <source>invoice.from</source>\n <target>Von</target>\n </trans-unit>\n <trans-unit id=\"hx7vsMA\" resname=\"invoice.to\">\n <source>invoice.to</source>\n <target>An</target>\n </trans-unit>\n <trans-unit id=\"x_W5sV4\" resname=\"invoice.number\">\n <source>invoice.number</source>\n <target>Rechnungsnummer</target>\n </trans-unit>\n <trans-unit id=\"86KyrKO\" resname=\"invoice.subtotal\">\n <source>invoice.subtotal</source>\n <target>Rechnungsbetrag (netto)</target>\n </trans-unit>\n <trans-unit id=\"EO57yXg\" resname=\"invoice.tax\">\n <source>invoice.tax</source>\n <target>Umsatzsteuer</target>\n </trans-unit>\n <trans-unit id=\"N68vyvo\" resname=\"invoice.total\">\n <source>invoice.total</source>\n <target>Rechnungsendbetrag</target>\n </trans-unit>\n <trans-unit id=\"TPzFWUs\" resname=\"invoice.service_date\">\n <source>invoice.service_date</source>\n <target>Leistungsdatum</target>\n </trans-unit>\n <trans-unit id=\"6x24VVR\" resname=\"label.amount\">\n <source>label.amount</source>\n <target>Anzahl</target>\n </trans-unit>\n <trans-unit id=\"g7EpaPY\" resname=\"label.total_rate\">\n <source>label.total_rate</source>\n <target>Gesamtpreis</target>\n </trans-unit>\n <trans-unit id=\"MF3MdTu\" resname=\"label.unit_price\">\n <source>label.unit_price</source>\n <target>Einzelbetrag</target>\n </trans-unit>\n <trans-unit id=\"77aZC3r\" resname=\"label.payment_terms\">\n <source>label.payment_terms</source>\n <target>Zahlungsinformationen</target>\n </trans-unit>\n <trans-unit id=\"9p2KQag\" resname=\"invoice.signature_user\">\n <source>invoice.signature_user</source>\n <target>Leistungsbestätigung: Datum / Name Berater / Unterschrift</target>\n </trans-unit>\n <trans-unit id=\"Q9ykNhO\" resname=\"invoice.signature_customer\">\n <source>invoice.signature_customer</source>\n <target>Leistungsbestätigung: Datum / Name Kunde / Unterschrift</target>\n </trans-unit>\n <trans-unit id=\"c3d6p33\" resname=\"invoice.total_working_time\">\n <source>invoice.total_working_time</source>\n <target>Gesamtdauer</target>\n </trans-unit>\n <trans-unit id=\"BS00SS7\" resname=\"label.orderNumber\">\n <source>label.orderNumber</source>\n <target>Bestellnummer</target>\n </trans-unit>\n <trans-unit id=\"as948k9\" resname=\"label.orderDate\">\n <source>label.orderDate</source>\n <target>Bestelldatum</target>\n </trans-unit>\n <trans-unit id=\"RRj6PYN\" resname=\"label.invoice_tax_number\">\n <source>label.invoice_tax_number</source>\n <target>USt-IdNr.:</target>\n </trans-unit>\n <trans-unit id=\"uFZA7Uf\" resname=\"label.invoice_bank_account\">\n <source>label.invoice_bank_account</source>\n <target>Bankverbindung</target>\n </trans-unit>\n <trans-unit id=\"9VxfLLy\" resname=\"label.decimalDuration\">\n <source>label.decimalDuration</source>\n <target>Dauer als Dezimalzahl anzeigen</target>\n </trans-unit>\n <trans-unit id=\"hzhzbqw\" resname=\"label.status\">\n <source>label.status</source>\n <target>Status</target>\n </trans-unit>\n <trans-unit id=\"X_NRsed\" resname=\"status.new\">\n <source>status.new</source>\n <target>Neu</target>\n </trans-unit>\n <trans-unit id=\"Uvo1CbP\" resname=\"status.pending\">\n <source>status.pending</source>\n <target>Ausstehend</target>\n </trans-unit>\n <trans-unit id=\"PHJwR4w\" resname=\"status.paid\">\n <source>status.paid</source>\n <target>Bezahlt</target>\n </trans-unit>\n <trans-unit id=\"gT9W2pZ\" resname=\"status.canceled\">\n <source>status.canceled</source>\n <target>Storniert</target>\n </trans-unit>\n <trans-unit id=\"crrlEUA\" resname=\"preview.skipped_rows\">\n <source>preview.skipped_rows</source>\n <target>Überspringe Vorschau von %rows% weiteren Zeilen …</target>\n </trans-unit>\n <!--\n Export\n -->\n <trans-unit id=\"F6Jmro7\" resname=\"export.title\">\n <source>export.title</source>\n <target>Export</target>\n </trans-unit>\n <trans-unit id=\"iwWaUoa\" resname=\"export.filter\">\n <source>export.filter</source>\n <target>Daten für Export filtern</target>\n </trans-unit>\n <trans-unit id=\"vjmoQGo\" resname=\"export.period\">\n <source>export.period</source>\n <target>Zeitraum</target>\n </trans-unit>\n <trans-unit id=\"3CQ7A2m\" resname=\"export.document_title\">\n <source>export.document_title</source>\n <target>Export von Zeiten</target>\n </trans-unit>\n <trans-unit id=\"d5wyWRD\" resname=\"export.full_list\">\n <source>export.full_list</source>\n <target>Vollständige Auflistung</target>\n </trans-unit>\n <trans-unit id=\"N778uJ6\" resname=\"export.summary\">\n <source>export.summary</source>\n <target>Zusammenfassung</target>\n </trans-unit>\n <trans-unit id=\"ElDyzrx\" resname=\"export.page_of\">\n <source>export.page_of</source>\n <target>Seite %page% von %pages%</target>\n </trans-unit>\n <trans-unit id=\"vKY0tof\" resname=\"export.date_copyright\">\n <source>export.date_copyright</source>\n <target>Erstellt %date% mit %kimai%</target>\n </trans-unit>\n <trans-unit id=\"W92QGbY\" resname=\"export.warn_result_amount\">\n <source>export.warn_result_amount</source>\n <target>Ihre Suche führt zu %count% Ergebnissen. Sollte der Export fehlschlagen, müssen Sie die Suche weiter eingrenzen.</target>\n </trans-unit>\n <trans-unit id=\"pnGDFmf\" resname=\"label.type\">\n <source>label.type</source>\n <target>Typ</target>\n </trans-unit>\n <!--\n Navbar - recent entries and activities\n -->\n <trans-unit id=\"OxdYMR3\" resname=\"active.entries\">\n <source>active.entries</source>\n <target>Ihre aktiven Zeitmessungen</target>\n </trans-unit>\n <trans-unit id=\"e7XS97t\" resname=\"timesheet.all\">\n <source>timesheet.all</source>\n <target>Alle Einträge anzeigen</target>\n </trans-unit>\n <trans-unit id=\"WVU_S.A\" resname=\"recent.activities\">\n <source>recent.activities</source>\n <target>Eine ihrer letzten Tätigkeiten neustarten</target>\n </trans-unit>\n <trans-unit id=\"SLV47Uu\" resname=\"recent.activities.format\">\n <source>recent.activities.format</source>\n <target>%activity% in %project% für %customer%</target>\n </trans-unit>\n <trans-unit id=\"dTHY7Mw\" resname=\"timesheet.start\">\n <source>timesheet.start</source>\n <target>Neue Zeitmessung starten</target>\n </trans-unit>\n <!--\n TOOLBARS\n -->\n <trans-unit id=\"MPimOps\" resname=\"label.pageSize\">\n <source>label.pageSize</source>\n <target>Ergebnisse</target>\n </trans-unit>\n <trans-unit id=\"KhyA_PW\" resname=\"label.entryState\">\n <source>label.entryState</source>\n <target>Zeiten</target>\n </trans-unit>\n <trans-unit id=\"X3JM9wj\" resname=\"label.exported\">\n <source>label.exported</source>\n <target>Exportiert</target>\n </trans-unit>\n <trans-unit id=\"_DDecAV\" resname=\"entryState.exported\">\n <source>entryState.exported</source>\n <target>Abgerechnet</target>\n </trans-unit>\n <trans-unit id=\"ccCiXyR\" resname=\"entryState.not_exported\">\n <source>entryState.not_exported</source>\n <target>Offen</target>\n </trans-unit>\n <trans-unit id=\"do7fP0q\" resname=\"entryState.all\">\n <source>entryState.all</source>\n <target>Alle</target>\n </trans-unit>\n <trans-unit id=\"xm7mqoK\" resname=\"entryState.running\">\n <source>entryState.running</source>\n <target>Laufende</target>\n </trans-unit>\n <trans-unit id=\"spHpd_I\" resname=\"entryState.stopped\">\n <source>entryState.stopped</source>\n <target>Beendete</target>\n </trans-unit>\n <trans-unit id=\"BhsaLxX\" resname=\"export.clear_all\">\n <source>export.clear_all</source>\n <target>Alle angezeigten Einträge als offen markieren?</target>\n </trans-unit>\n <trans-unit id=\"qtjPKUT\" resname=\"export.mark_all\">\n <source>export.mark_all</source>\n <target>Alle angezeigten Einträge als abgerechnet markieren?</target>\n </trans-unit>\n <trans-unit id=\"S0vT92U\" resname=\"label.globalsOnly\">\n <source>label.globalsOnly</source>\n <target>Nur globale</target>\n </trans-unit>\n <trans-unit id=\"2Ek7sXu\" resname=\"label.batch_meta_fields\">\n <source>label.batch_meta_fields</source>\n <target>Zusätzliche Felder</target>\n </trans-unit>\n <trans-unit id=\"9Wt8Pp_\" resname=\"help.batch_meta_fields\">\n <source>help.batch_meta_fields</source>\n <target>Felder die aktualisiert werden sollen, müssen zunächst durch einen Klick auf die zugehörige Checkbox freigeschaltet werden.</target>\n </trans-unit>\n <trans-unit id=\"z_YHoZn\" resname=\"label.includeNoWork\">\n <source>label.includeNoWork</source>\n <target>Einträge ohne Buchungen anzeigen</target>\n </trans-unit>\n <trans-unit id=\"B.Dbbob\" resname=\"label.includeNoBudget\">\n <source>label.includeNoBudget</source>\n <target>Einträge ohne Budget anzeigen</target>\n </trans-unit>\n <trans-unit id=\"Wq.h4nD\" resname=\"label.includeBudgetType_month\">\n <source>label.includeBudgetType_month</source>\n <target>Einträge mit „Monats-Budget“ anzeigen</target>\n </trans-unit>\n <trans-unit id=\"nVulc7.\" resname=\"label.includeBudgetType_full\">\n <source>label.includeBudgetType_full</source>\n <target>Einträge mit „Lebenszyklus“-Budget anzeigen</target>\n </trans-unit>\n <trans-unit id=\"3zn5T5e\" resname=\"label.not_exported\">\n <source>label.not_exported</source>\n <target>Nicht exportiert</target>\n </trans-unit>\n <trans-unit id=\"csF1D35\" resname=\"label.not_invoiced\">\n <source>label.not_invoiced</source>\n <target>Nicht abgerechnet</target>\n </trans-unit>\n <trans-unit id=\"AJ6dwR.\" resname=\"label.last_record_before\">\n <source>label.last_record_before</source>\n <target>Keine Zeitbuchung mehr seit</target>\n </trans-unit>\n <trans-unit id=\"qDnURk7\" resname=\"label.last_record\">\n <source>label.last_record</source>\n <target>Letzter Eintrag</target>\n </trans-unit>\n <trans-unit id=\"LXdqaTH\" resname=\"label.account_number\">\n <source>label.account_number</source>\n <target>Personalnummer</target>\n </trans-unit>\n <trans-unit id=\"PoF7hD8\" resname=\"label.budgetType\">\n <source>label.budgetType</source>\n <target>Budget-Typ</target>\n </trans-unit>\n <trans-unit id=\"cHfLJtL\" resname=\"label.budgetType_month\">\n <source>label.budgetType_month</source>\n <target>Monatlich</target>\n </trans-unit>\n <trans-unit id=\"9Rhadz6\" resname=\"label.budgetType_full\">\n <source>label.budgetType_full</source>\n <target>Lebenszyklus</target>\n </trans-unit>\n <trans-unit id=\"tvV0NhL\" resname=\"delete_warning.short_stats\">\n <source>delete_warning.short_stats</source>\n <target>Momentan existieren insgesamt %records% Zeiteinträge, welche sich auf eine Gesamtdauer von %duration% belaufen.</target>\n </trans-unit>\n <trans-unit id=\"Zif614Q\" resname=\"add_user.label\">\n <source>add_user.label</source>\n <target>Benutzer hinzufügen</target>\n </trans-unit>\n <trans-unit id=\"tp.gIrE\" resname=\"team.add_user.help\">\n <source>team.add_user.help</source>\n <target>Durch Auswahl wird dem Team ein neuer Benutzer hinzugefügt. Sie können im Anschluss festlegen, ob der Benutzer ein Teamleiter sein soll.</target>\n </trans-unit>\n <trans-unit id=\"yNWIi5U\" resname=\"default_value_new\">\n <source>default_value_new</source>\n <target>Standardwert für neue Einträge</target>\n </trans-unit>\n <!--\n QUICK ENTRIES\n -->\n <trans-unit id=\"f8oNzSP\" resname=\"quick_entry.title\">\n <source>quick_entry.title</source>\n <target>Wochen-Arbeitsstunden</target>\n </trans-unit>\n <trans-unit id=\"61p_ckr\" resname=\"label.hours_24\">\n <source>label.hours_24</source>\n <target>24 Stunden</target>\n </trans-unit>\n </body>\n </file>\n</xliff>"
] |
[
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"en\" datatype=\"plaintext\" original=\"messages.en.xlf\">\n <body>\n <!--\n Global template keys\n -->\n <trans-unit id=\"N7mikjJ\" resname=\"time_tracking\">\n <source>time_tracking</source>\n <target>Time Tracking</target>\n </trans-unit>\n <trans-unit id=\"inmIkP6\" resname=\"yes\">\n <source>yes</source>\n <target>Yes</target>\n </trans-unit>\n <trans-unit id=\"k5Apjz_\" resname=\"no\">\n <source>no</source>\n <target>No</target>\n </trans-unit>\n <trans-unit id=\".3dyBTq\" resname=\"both\">\n <source>both</source>\n <target>Both</target>\n </trans-unit>\n <trans-unit id=\"KLIuHvt\" resname=\"This is a mandatory field\">\n <source>This is a mandatory field</source>\n <target>Mandatory</target>\n </trans-unit>\n <trans-unit id=\"_ohHsMM\" resname=\"create\">\n <source>create</source>\n <target>Create</target>\n </trans-unit>\n <trans-unit id=\"DYHuW58\" resname=\"confirm.delete\">\n <source>confirm.delete</source>\n <target>Do you really want to delete it?</target>\n </trans-unit>\n <trans-unit id=\"vDd3alC\" resname=\"admin_entity.delete_confirm\">\n <source>admin_entity.delete_confirm</source>\n <target>\n This data will be deleted as well!\n Alternatively, you can select an entry to which all data will be transferred:\n </target>\n </trans-unit>\n <trans-unit id=\"COyxNde\" resname=\"delete.not_in_use\">\n <source>delete.not_in_use</source>\n <target>This item can be safely deleted.</target>\n </trans-unit>\n <trans-unit id=\"I3TZF5S\" resname=\"cancel\">\n <source>cancel</source>\n <target>Cancel</target>\n </trans-unit>\n <trans-unit id=\"PyZ8KrQ\" resname=\"confirm\">\n <source>confirm</source>\n <target>Confirm</target>\n </trans-unit>\n <trans-unit id=\".0CFrRV\" resname=\"upload\">\n <source>upload</source>\n <target>Upload</target>\n </trans-unit>\n <trans-unit id=\"JBkykGe\" resname=\"search\">\n <source>search</source>\n <target>Search</target>\n </trans-unit>\n <trans-unit id=\"IolBPQD\" resname=\"label.searchTerm\">\n <source>label.searchTerm</source>\n <target>Search term</target>\n </trans-unit>\n <trans-unit id=\"BytPihM\" resname=\"label.set_as_default\">\n <source>label.set_as_default</source>\n <target>Save setting as search favourite</target>\n </trans-unit>\n <trans-unit id=\"NNKq04n\" resname=\"label.remove_default\">\n <source>label.remove_default</source>\n <target>Delete search favourite</target>\n </trans-unit>\n <trans-unit id=\"31x84Dt\" resname=\"label.asc\">\n <source>label.asc</source>\n <target>Ascending</target>\n </trans-unit>\n <trans-unit id=\"0D_zaYd\" resname=\"label.desc\">\n <source>label.desc</source>\n <target>Descending</target>\n </trans-unit>\n <trans-unit id=\"Z8Fxbvf\" resname=\"label.orderBy\">\n <source>label.orderBy</source>\n <target>Order by</target>\n </trans-unit>\n <trans-unit id=\"hBNESu6\" resname=\"my.profile\">\n <source>my.profile</source>\n <target>My profile</target>\n </trans-unit>\n <trans-unit id=\"J258iS6\" resname=\"update_multiple\">\n <source>update_multiple</source>\n <target>%action% %count% entries?</target>\n </trans-unit>\n <trans-unit id=\"OTDmccn\" resname=\"attachments\">\n <source>attachments</source>\n <target>Files</target>\n </trans-unit>\n <trans-unit id=\"O5w1jzb\" resname=\"file\">\n <source>file</source>\n <target>File</target>\n </trans-unit>\n <trans-unit id=\"0M_Gylq\" resname=\"rates.empty\">\n <source>rates.empty</source>\n <target>No hourly rates have yet been configured.</target>\n </trans-unit>\n <trans-unit id=\"mflwMcX\" resname=\"rates.title\">\n <source>rates.title</source>\n <target>Fees</target>\n </trans-unit>\n <trans-unit id=\"zFfl7jw\" resname=\"sum.total\">\n <source>sum.total</source>\n <target>Total</target>\n </trans-unit>\n <trans-unit id=\"XP5zkiN\" resname=\"modal.dirty\">\n <source>modal.dirty</source>\n <target>The form has changed. Please click \"Save\" to save the changes or \"Close\" to cancel.</target>\n </trans-unit>\n <!--\n Login / Security\n -->\n <trans-unit id=\"9pvowqn\" resname=\"label.password\">\n <source>label.password</source>\n <target>Password</target>\n </trans-unit>\n <trans-unit id=\"WxAnbP0\" resname=\"label.password_repeat\">\n <source>label.password_repeat</source>\n <target>Repeat password</target>\n </trans-unit>\n <trans-unit id=\"II4DGnv\" resname=\"label.logout\">\n <source>label.logout</source>\n <target>Logout</target>\n </trans-unit>\n <trans-unit id=\"hFFZGp_\" resname=\"label.user_profile\">\n <source>label.user_profile</source>\n <target>My profile</target>\n </trans-unit>\n <trans-unit id=\"gXZR.hV\" resname=\"label.api_token\">\n <source>label.api_token</source>\n <target>API password</target>\n </trans-unit>\n <trans-unit id=\"s_X2xpI\" resname=\"label.api_token_repeat\">\n <source>label.api_token_repeat</source>\n <target>Repeat API password</target>\n </trans-unit>\n <trans-unit id=\".372.o7\" resname=\"login_required\">\n <source>login_required</source>\n <target>Missing permission. Redirect to login?</target>\n </trans-unit>\n <trans-unit id=\".ndupSK\" resname=\"registration.check_email\">\n <source>registration.check_email</source>\n <target>An email has been sent to %email%. It contains an activation link you must click to activate your account.</target>\n </trans-unit>\n <trans-unit id=\"_cY.wHP\" resname=\"resetting.check_email\">\n <source>resetting.check_email</source>\n <target>\n An email has been sent. It contains a link you must click to reset your password.\n Note: You can only request a new password once within %tokenLifetime% hours.",
" If you don't get an email check your spam folder or try again.\n </target>\n </trans-unit>\n <!--\n Menu / Navbar items\n -->\n <trans-unit id=\"UoOv6mx\" resname=\"menu.homepage\">\n <source>menu.homepage</source>\n <target>Dashboard</target>\n </trans-unit>\n <trans-unit id=\"wvvYSw_\" resname=\"menu.admin\">\n <source>menu.admin</source>\n <target>Administration</target>\n </trans-unit>\n <trans-unit id=\"6OKwCUB\" resname=\"menu.system\">\n <source>menu.system</source>\n <target>System</target>\n </trans-unit>\n <trans-unit id=\"wBTFKFR\" resname=\"menu.logout\">\n <source>menu.logout</source>\n <target>Logout</target>\n </trans-unit>\n <trans-unit id=\"C0W7_BT\" resname=\"menu.timesheet\">\n <source>menu.timesheet</source>\n <target>My times</target>\n </trans-unit>\n <trans-unit id=\"Ci9W8.K\" resname=\"menu.invoice\">\n <source>menu.invoice</source>\n <target>Invoices</target>\n </trans-unit>\n <trans-unit id=\"I.eil4u\" resname=\"menu.export\">\n <source>menu.export</source>\n <target>Export</target>\n </trans-unit>\n <trans-unit id=\"ypVQO7o\" resname=\"menu.reporting\">\n <source>menu.reporting</source>\n <target>Reporting</target>\n </trans-unit>\n <trans-unit id=\"WGIhZv1\" resname=\"menu.admin_timesheet\">\n <source>menu.admin_timesheet</source>\n <target>Timesheets</target>\n </trans-unit>\n <trans-unit id=\"Y_jAD36\" resname=\"menu.admin_customer\">\n <source>menu.admin_customer</source>\n <target>Customers</target>\n </trans-unit>\n <trans-unit id=\"oDLp9t3\" resname=\"menu.admin_project\">\n <source>menu.admin_project</source>\n <target>Projects</target>\n </trans-unit>\n <trans-unit id=\"wriHFwl\" resname=\"menu.admin_activity\">\n <source>menu.admin_activity</source>\n <target>Activities</target>\n </trans-unit>\n <trans-unit id=\"oZo1BnZ\" resname=\"menu.admin_user\">\n <source>menu.admin_user</source>\n <target>Users</target>\n </trans-unit>\n <trans-unit id=\"pA.bYIk\" resname=\"menu.admin_team\">\n <source>menu.admin_team</source>\n <target>Teams</target>\n </trans-unit>\n <trans-unit id=\"hOZxcaK\" resname=\"menu.plugin\">\n <source>menu.plugin</source>\n <target>Plugins</target>\n </trans-unit>\n <trans-unit id=\"IXtkHRw\" resname=\"menu.system_configuration\">\n <source>menu.system_configuration</source>\n <target>Settings</target>\n </trans-unit>\n <trans-unit id=\"yo4f8Kh\" resname=\"menu.tags\">\n <source>menu.tags</source>\n <target>Tags</target>\n </trans-unit>\n <trans-unit id=\"1kHI0gb\" resname=\"menu.doctor\">\n <source>menu.doctor</source>\n <target>Doctor</target>\n </trans-unit>\n <!--\n Error templates\n -->\n <trans-unit id=\"Vz3Igj3\" resname=\"error.no_entries_found\">\n <source>error.no_entries_found</source>\n <target>No entries were found based on your selected filters.</target>\n </trans-unit>\n <trans-unit id=\"hlu4iX5\" resname=\"error.no_comments_found\">\n <source>error.no_comments_found</source>\n <target>There were no comments posted yet.</target>\n </trans-unit>\n <trans-unit id=\"XQ2.pq2\" resname=\"error.too_many_entries\">\n <source>error.too_many_entries</source>\n <target>The request could not be processed. Too many results were found.</target>\n </trans-unit>\n <!--\n General labels\n -->\n <trans-unit id=\"H1qEi4d\" resname=\"label.date\">\n <source>label.date</source>\n <target>Date</target>\n </trans-unit>\n <trans-unit id=\"eJPDE76\" resname=\"label.starttime\">\n <source>label.starttime</source>\n <target>Begin</target>\n </trans-unit>\n <trans-unit id=\"uZlpDFh\" resname=\"label.endtime\">\n <source>label.endtime</source>\n <target>End</target>\n </trans-unit>\n <trans-unit id=\"cgpmY0I\" resname=\"label.duration\">\n <source>label.duration</source>\n <target>Duration</target>\n </trans-unit>\n <trans-unit id=\"O2X4xZH\" resname=\"label.user\">\n <source>label.user</source>\n <target>User</target>\n </trans-unit>\n <trans-unit id=\"LDhDPrF\" resname=\"label.username\">\n <source>label.username</source>\n <target>User</target>\n </trans-unit>\n <trans-unit id=\"4cEApe1\" resname=\"label.description\">\n <source>label.description</source>\n <target>Description</target>\n </trans-unit>\n <trans-unit id=\"ysOvPSq\" resname=\"label.name\">\n <source>label.name</source>\n <target>Name</target>\n </trans-unit>\n <trans-unit id=\"WqTho4C\" resname=\"label.comment\">\n <source>label.comment</source>\n <target>Comment</target>\n </trans-unit>\n <trans-unit id=\"txRonia\" resname=\"label.id\">\n <source>label.id</source>\n <target>ID</target>\n </trans-unit>\n <trans-unit id=\"CYpZwBz\" resname=\"label.visible\">\n <source>label.visible</source>\n <target>Visible</target>\n </trans-unit>\n <trans-unit id=\"2ktNwkr\" resname=\"label.budget\">\n <source>label.budget</source>\n <target>Budget</target>\n </trans-unit>\n <trans-unit id=\"x8TrOec\" resname=\"label.timeBudget\">\n <source>label.timeBudget</source>\n <target>Time budget</target>\n </trans-unit>\n <trans-unit id=\"l1wiL0h\" resname=\"label.activity\">\n <source>label.activity</source>\n <target>Activity</target>\n </trans-unit>\n <trans-unit id=\"KtnqJcg\" resname=\"label.project\">\n <source>label.project</source>\n <target>Project</target>\n </trans-unit>\n <trans-unit id=\"VNCQ7YU\" resname=\"label.tag\">\n <source>label.tag</source>\n <target>Tags</target>\n </trans-unit>\n <trans-unit id=\"ijQyGRo\" resname=\"label.tags\">\n <source>label.tags</source>\n <target>Tags</target>\n </trans-unit>\n <trans-unit id=\"VAbtieW\" resname=\"label.hourlyRate\">\n <source>label.hourlyRate</source>\n <target>Hourly rate</target>\n </trans-unit>\n <trans-unit id=\"IQ.tlua\" resname=\"label.hourly_rate\">\n <source>label.hourly_rate</source>\n <target>Hourly rate</target>\n </trans-unit>\n <trans-unit id=\"dezCZWf\" resname=\"label.skin\">\n <source>label.skin</source>\n <target>Display: colors</target>\n </trans-unit>\n <trans-unit id=\"O40d_3K\" resname=\"theme.layout\">\n <source>Display: layout</source>\n <target state=\"needs-translation\">Display: layout</target>\n </trans-unit>\n <trans-unit id=\"w8T34A6\" resname=\"label.hours\">\n <source>label.hours</source>\n <target>Hours</target>\n </trans-unit>\n <trans-unit id=\"Ih3IFXj\" resname=\"label.rate\">\n <source>label.rate</source>\n <target>Rate</target>\n </trans-unit>\n <trans-unit id=\"djL6LMC\" resname=\"help.rate\">\n <source>help.rate</source>\n <target>Hourly rate to be charged</target>\n </trans-unit>\n <trans-unit id=\"QzvjNwg\" resname=\"label.rate_internal\">\n <source>label.rate_internal</source>\n <target>Internal rate</target>\n </trans-unit>\n <trans-unit id=\"uz4SmfP\" resname=\"help.rate_internal\">\n <source>help.rate_internal</source>\n <target>Internal costs (if this is not specified, the normal rate is used)</target>\n </trans-unit>\n <trans-unit id=\"v72sA1c\" resname=\"label.recalculate_rates\">\n <source>label.recalculate_rates</source>\n <target>Recalculate rates</target>\n </trans-unit>\n <trans-unit id=\"foM2o5T\" resname=\"label.language\">\n <source>label.language</source>\n <target>Language</target>\n </trans-unit>\n <trans-unit id=\"Z8a2kUf\" resname=\"label.customer\">\n <source>label.customer</source>\n <target>Customer</target>\n </trans-unit>\n <trans-unit id=\"D2N6_cP\" resname=\"label.email\">\n <source>label.email</source>\n <target>Email</target>\n </trans-unit>\n <trans-unit id=\"Ss2xe99\" resname=\"label.team\">\n <source>label.team</source>\n <target>Team</target>\n </trans-unit>\n <trans-unit id=\"Zpj9UB4\" resname=\"label.teamlead\">\n <source>label.teamlead</source>\n <target>Teamlead</target>\n </trans-unit>\n <trans-unit id=\"hX.EQKy\" resname=\"label.create_more\">\n <source>label.create_more</source>\n <target>Create further entries</target>\n </trans-unit>\n <trans-unit id=\"LIOnolg\" resname=\"placeholder.type_message\">\n <source>placeholder.type_message</source>\n <target>Type your message…</target>\n </trans-unit>\n <trans-unit id=\"vkHr9AP\" resname=\"label.billable\">\n <source>label.billable</source>\n <target>Billable</target>\n </trans-unit>\n <!--\n Buttons & Actions\n -->\n <trans-unit id=\"zldXQq6\" resname=\"label.actions\">\n <source>label.actions</source>\n <target>Actions</target>\n </trans-unit>\n <trans-unit id=\"ovKkXwU\" resname=\"action.edit\">\n <source>action.edit</source>\n <target>Edit</target>\n </trans-unit>\n <trans-unit id=\"jdbtx6z\" resname=\"action.add\">\n <source>action.add</source>\n <target>Add</target>\n </trans-unit>\n <trans-unit id=\"hTKWQ6g\" resname=\"action.delete\">\n <source>action.delete</source>\n <target>Delete</target>\n </trans-unit>\n <trans-unit id=\"HLtdhYw\" resname=\"action.save\">\n <source>action.save</source>\n <target>Save</target>\n </trans-unit>\n <trans-unit id=\"9hpJPiG\" resname=\"action.save_all\">\n <source>action.save_all</source>\n <target>Save all</target>\n </trans-unit>\n <trans-unit id=\"tKZKI2Z\" resname=\"action.reset\">\n <source>action.reset</source>\n <target>Reset</target>\n </trans-unit>\n <trans-unit id=\"Eb7Ygpo\" resname=\"action.back\">\n <source>action.back</source>\n <target>Back</target>\n </trans-unit>\n <trans-unit id=\"wCazS.X\" resname=\"action.close\">\n <source>action.close</source>\n <target>Close</target>\n </trans-unit>\n <!--\n Dashboard\n -->\n <trans-unit id=\"3bqLM8Q\" resname=\"dashboard.title\">\n <source>dashboard.title</source>\n <target>Dashboard</target>\n </trans-unit>\n <trans-unit id=\"3PYadzb\" resname=\"dashboard.subtitle\">\n <source>dashboard.subtitle</source>\n <target>Welcome!</target>\n </trans-unit>\n <trans-unit id=\"yEa1Yz3\" resname=\"dashboard.all\">\n <source>dashboard.all</source>\n <target>All users</target>\n </trans-unit>\n <!--\n Widgets\n -->\n <trans-unit id=\"giznf_R\" resname=\"more.info.link\">\n <source>more.info.link</source>\n <target>More info</target>\n </trans-unit>\n <trans-unit id=\"4iliLZT\" resname=\"label.toggle_dropdown\">\n <source>label.toggle_dropdown</source>\n <target>Show menu</target>\n </trans-unit>\n <trans-unit id=\"f3KMQJh\" resname=\"label.my_teams\">\n <source>label.my_teams</source>\n <target>My teams</target>\n </trans-unit>\n <trans-unit id=\"jTiYRIu\" resname=\"label.my_team_projects\">\n <source>label.my_team_projects</source>\n <target>My projects</target>\n </trans-unit>\n <trans-unit id=\"1PQHtXu\" resname=\"label.progress\">\n <source>label.progress</source>\n <target>Progress</target>\n </trans-unit>\n <trans-unit id=\"vTY9SUk\" resname=\"label.plus_more\">\n <source>label.plus_more</source>\n <target>+%count% more</target>\n </trans-unit>\n <!--\n Timesheet\n -->\n <trans-unit id=\"VXj0Y3h\" resname=\"timesheet.title\">\n <source>timesheet.title</source>\n <target>My times</target>\n </trans-unit>\n <trans-unit id=\"dwEVXUR\" resname=\"timesheet.edit\">\n <source>timesheet.edit</source>\n <target>Edit record</target>\n </trans-unit>\n <trans-unit id=\"trDJK9W\" resname=\"label.begin\">\n <source>label.begin</source>\n <target>From</target>\n </trans-unit>\n <trans-unit id=\"R9typUt\" resname=\"label.end\">\n <source>label.end</source>\n <target>To</target>\n </trans-unit>\n <trans-unit id=\"egaNXjp\" resname=\"label.daterange\">\n <source>label.daterange</source>\n <target>Time range</target>\n </trans-unit>\n <trans-unit id=\"UbnqJLn\" resname=\"modal.columns.title\">\n <source>modal.columns.title</source>\n <target>Change column visibility</target>\n </trans-unit>\n <trans-unit id=\"EbfIoLp\" resname=\"modal.columns.description\">\n <source>modal.columns.description</source>\n <target>Upon saving the un-checked columns will be hidden and this setting will be stored in a browser cookie. If you delete your cookies, the settings will be reversed.</target>\n </trans-unit>\n <trans-unit id=\"5gjqxgK\" resname=\"label.fixedRate\">\n <source>label.fixedRate</source>\n <target>Fixed rate</target>\n </trans-unit>\n <trans-unit id=\"b43sCwO\" resname=\"help.fixedRate\">\n <source>help.fixedRate</source>\n <target>Each time record gets the same value, regardless of its duration</target>\n </trans-unit>\n <trans-unit id=\"YTSS_Q1\" resname=\"label.color\">\n <source>label.color</source>\n <target>Color</target>\n </trans-unit>\n <trans-unit id=\"EoouxGX\" resname=\"label.replaceTags\">\n <source>label.replaceTags</source>\n <target>Replace tags</target>\n </trans-unit>\n <trans-unit id=\"BxkmaKz\" resname=\"label.appendTags\">\n <source>label.appendTags</source>\n <target>Append tags</target>\n </trans-unit>\n <!--\n User profile\n -->\n <trans-unit id=\"1_wnK76\" resname=\"profile.title\">\n <source>profile.title</source>\n <target>User profile</target>\n </trans-unit>\n <trans-unit id=\"HWKJZ0T\" resname=\"profile.about_me\">\n <source>profile.about_me</source>\n <target>About me</target>\n </trans-unit>\n <trans-unit id=\"Fm.kwVn\" resname=\"profile.first_entry\">\n <source>profile.first_entry</source>\n <target>Working since</target>\n </trans-unit>\n <trans-unit id=\"1c0EQaz\" resname=\"profile.registration_date\">\n <source>profile.registration_date</source>\n <target>Registered at</target>\n </trans-unit>\n <trans-unit id=\"xEYQXPy\" resname=\"profile.settings\">\n <source>profile.settings</source>\n <target>Profile</target>\n </trans-unit>\n <trans-unit id=\"A6TLLQa\" resname=\"profile.password\">\n <source>profile.password</source>\n <target>Password</target>\n </trans-unit>\n <trans-unit id=\"Z34ZpjK\" resname=\"profile.api-token\">\n <source>profile.api-token</source>\n <target>API</target>\n </trans-unit>\n <trans-unit id=\"ygtTz8.\" resname=\"profile.roles\">\n <source>profile.roles</source>\n <target>Roles</target>\n </trans-unit>\n <trans-unit id=\"DZ7XGML\" resname=\"profile.teams\">\n <source>profile.teams</source>\n <target>Teams</target>\n </trans-unit>\n <trans-unit id=\"MQKiG33\" resname=\"profile.preferences\">\n <source>profile.preferences</source>\n <target>Preferences</target>\n </trans-unit>\n <trans-unit id=\"Eq78QrH\" resname=\"label.theme.collapsed_sidebar\">\n <source>label.theme.collapsed_sidebar</source>\n <target>Minimize the left sidebar</target>\n </trans-unit>\n <trans-unit id=\"0sgroZi\" resname=\"label.calendar.initial_view\">\n <source>label.calendar.initial_view</source>\n <target>Initial calendar view</target>\n </trans-unit>\n <trans-unit id=\"iqQsgIW\" resname=\"label.login.initial_view\">\n <source>label.login.initial_view</source>\n <target>Initial view after login</target>\n </trans-unit>\n <trans-unit id=\"hO7mkmf\" resname=\"label.lastLogin\">\n <source>label.lastLogin</source>\n <target>Last login</target>\n </trans-unit>\n <!-- Options for user-preference label.calendar.initial_view -->\n <trans-unit id=\"pcfRcZ4\" resname=\"month\">\n <source>month</source>\n <target>Month</target>\n </trans-unit>\n <trans-unit id=\"Irm6dfx\" resname=\"agendaWeek\">\n <source>agendaWeek</source>\n <target>Week</target>\n </trans-unit>\n <trans-unit id=\"Q0Zip02\" resname=\"agendaDay\">\n <source>agendaDay</source>\n <target>Day</target>\n </trans-unit>\n <trans-unit id=\"rYzHCFd\" resname=\"label.timesheet.daily_stats\">\n <source>label.timesheet.daily_stats</source>\n <target>Show daily stats in timesheet</target>\n </trans-unit>\n <trans-unit id=\"tSlqVK2\" resname=\"label.timesheet.export_decimal\">\n <source>label.timesheet.export_decimal</source>\n <target>Use decimal duration in export</target>\n </trans-unit>\n <trans-unit id=\"5R.QsZ3\" resname=\"theme.update_browser_title\">\n <source>theme.update_browser_title</source>\n <target>Update browser title</target>\n </trans-unit>\n <!--\n User timesheet calendar\n -->\n <trans-unit id=\"HWiuMV6\" resname=\"calendar.title\">\n <source>calendar.title</source>\n <target>Calendar</target>\n </trans-unit>\n <trans-unit id=\"75kjTF9\" resname=\"calendar.drag_and_drop.delete\">\n <source>calendar.drag_and_drop.delete</source>\n <target>If you want to delete an entry, you must drag it onto the button.</target>\n </trans-unit>\n <!--\n Admin: Timesheet\n -->\n <trans-unit id=\"bSDjzZL\" resname=\"admin_timesheet.title\">\n <source>admin_timesheet.title</source>\n <target>Timesheets</target>\n </trans-unit>\n <!--\n Admin: Projects\n -->\n <trans-unit id=\"DFjFRGe\" resname=\"admin_project.title\">\n <source>admin_project.title</source>\n <target>Projects</target>\n </trans-unit>\n <trans-unit id=\"yLOqEX_\" resname=\"label.project_start\">\n <source>label.project_start</source>\n <target>Project start</target>\n </trans-unit>\n <trans-unit id=\"4kQGReV\" resname=\"label.project_end\">\n <source>label.project_end</source>\n <target>Project end</target>\n </trans-unit>\n <!--\n Admin: Activity\n -->\n <trans-unit id=\"auu8q0u\" resname=\"admin_activity.title\">\n <source>admin_activity.title</source>\n <target>Activities</target>\n </trans-unit>\n <!--\n Admin: Customer\n -->\n <trans-unit id=\"2TvKX9Z\" resname=\"admin_customer.title\">\n <source>admin_customer.title</source>\n <target>Customer</target>\n </trans-unit>\n <trans-unit id=\"39AtPxQ\" resname=\"label.number\">\n <source>label.number</source>\n <target>Account</target>\n </trans-unit>\n <trans-unit id=\"7jfRn_1\" resname=\"label.company\">\n <source>label.company</source>\n <target>Company name</target>\n </trans-unit>\n <trans-unit id=\"GOStgLi\" resname=\"label.vat\">\n <source>label.vat</source>\n <target>Tax</target>\n </trans-unit>\n <trans-unit id=\"Dgmh_mv\" resname=\"label.vat_id\">\n <source>label.vat_id</source>\n <target>VAT-ID</target>\n </trans-unit>\n <trans-unit id=\"YNGNfGn\" resname=\"label.tax_rate\">\n <source>label.tax_rate</source>\n <target>Tax rate</target>\n </trans-unit>\n <trans-unit id=\"0tkOMo1\" resname=\"label.contact\">\n <source>label.contact</source>\n <target>Contact</target>\n </trans-unit>\n <trans-unit id=\"c9W5AO4\" resname=\"label.address\">\n <source>label.address</source>\n <target>Address</target>\n </trans-unit>\n <trans-unit id=\"k7MJQ82\" resname=\"label.country\">\n <source>label.country</source>\n <target>Country</target>\n </trans-unit>\n <trans-unit id=\"g03c_vw\" resname=\"label.phone\">\n <source>label.phone</source>\n <target>Phone</target>\n </trans-unit>\n <trans-unit id=\"eRyhERS\" resname=\"label.fax\">\n <source>label.fax</source>\n <target>Fax</target>\n </trans-unit>\n <trans-unit id=\"AawT9pW\" resname=\"label.mobile\">\n <source>label.mobile</source>\n <target>Mobile</target>\n </trans-unit>\n <trans-unit id=\"PS9IH_t\" resname=\"label.homepage\">\n <source>label.homepage</source>\n <target>Homepage</target>\n </trans-unit>\n <trans-unit id=\"dmtPdwq\" resname=\"label.timezone\">\n <source>label.timezone</source>\n <target>Timezone</target>\n </trans-unit>\n <trans-unit id=\"otd2FZd\" resname=\"label.currency\">\n <source>label.currency</source>\n <target>Currency</target>\n </trans-unit>\n <!--\n Admin: Users\n -->\n <trans-unit id=\"t34EvnF\" resname=\"admin_user.title\">\n <source>admin_user.title</source>\n <target>User</target>\n </trans-unit>\n <trans-unit id=\"TRDzmCV\" resname=\"label.alias\">\n <source>label.alias</source>\n <target>Name</target>\n </trans-unit>\n <trans-unit id=\"UrRn8xj\" resname=\"label.title\">\n <source>label.title</source>\n <target>Title</target>\n </trans-unit>\n <trans-unit id=\"nWMH_Nr\" resname=\"label.avatar\">\n <source>label.avatar</source>\n <target>Profile image (URL)</target>\n </trans-unit>\n <trans-unit id=\"KtTP.Sh\" resname=\"label.active\">\n <source>label.active</source>\n <target>Active</target>\n </trans-unit>\n <trans-unit id=\"iD6CNOO\" resname=\"label.roles\">\n <source>label.roles</source>\n <target>Role</target>\n </trans-unit>\n <trans-unit id=\"ZlZ20pG\" resname=\"user_permissions.title\">\n <source>user_permissions.title</source>\n <target>User permissions</target>\n </trans-unit>\n <trans-unit id=\"G.GEdlk\" resname=\"user_role.title\">\n <source>user_role.title</source>\n <target>User role</target>\n </trans-unit>\n <trans-unit id=\"E7G60OF\" resname=\"Allowed character: A-Z and _\">\n <source>Allowed character: A-Z and _</source>\n <target>Allowed character: A-Z and _</target>\n </trans-unit>\n <!--\n Admin: Plugins\n -->\n <trans-unit id=\"d75KAlJ\" resname=\"label.version\">\n <source>label.version</source>\n <target>Version</target>\n </trans-unit>\n <trans-unit id=\"8Rfa01v\" resname=\"label.required_version\">\n <source>label.required_version</source>\n <target>Compatible with</target>\n </trans-unit>\n <!--\n ROLES\n -->\n <trans-unit id=\"WRuKTcz\" resname=\"ROLE_SUPER_ADMIN\">\n <source>ROLE_SUPER_ADMIN</source>\n <target>System-Admin</target>\n </trans-unit>\n <trans-unit id=\"718iPw6\" resname=\"ROLE_ADMIN\">\n <source>ROLE_ADMIN</source>\n <target>Administrator</target>\n </trans-unit>\n <trans-unit id=\"yttGLAB\" resname=\"ROLE_TEAMLEAD\">\n <source>ROLE_TEAMLEAD</source>\n <target>Teamlead</target>\n </trans-unit>\n <trans-unit id=\"rvO5ZXf\" resname=\"ROLE_USER\">\n <source>ROLE_USER</source>\n <target>User</target>\n </trans-unit>\n <!--\n Statistics data for Dashboard & Users profile\n -->\n <trans-unit id=\"lfSTZGe\" resname=\"stats.workingTimeToday\">\n <source>stats.workingTimeToday</source>\n <target>Today, %day%</target>\n </trans-unit>\n <trans-unit id=\"XdYs3I8\" resname=\"stats.workingTimeWeek\">\n <source>stats.workingTimeWeek</source>\n <target>Calendar week %week%</target>\n </trans-unit>",
"",
" <trans-unit id=\"JIKNAYP\" resname=\"stats.workingTimeMonth\">\n <source>stats.workingTimeMonth</source>\n <target>%month% %year%</target>\n </trans-unit>\n <trans-unit id=\"JnUFsNi\" resname=\"stats.workingTimeYear\">\n <source>stats.workingTimeYear</source>\n <target>Full year %year%</target>\n </trans-unit>\n <trans-unit id=\"HWB4OGJ\" resname=\"stats.workingTimeFinancialYear\">\n <source>stats.workingTimeFinancialYear</source>\n <target>Financial year</target>\n </trans-unit>\n <trans-unit id=\"BXBFJP8\" resname=\"stats.workingTime\">\n <source>stats.workingTime</source>\n <target>Working time</target>\n </trans-unit>\n <trans-unit id=\"pX_3dNm\" resname=\"stats.revenue\">\n <source>stats.revenue</source>\n <target>Revenues</target>\n </trans-unit>\n <trans-unit id=\"TdBJBAl\" resname=\"stats.durationToday\">\n <source>stats.durationToday</source>\n <target>Working hours today</target>\n </trans-unit>\n <trans-unit id=\"XhKalZH\" resname=\"stats.durationWeek\">\n <source>stats.durationWeek</source>\n <target>Working hours this week</target>\n </trans-unit>\n <trans-unit id=\"uaOwf_P\" resname=\"stats.durationMonth\">\n <source>stats.durationMonth</source>\n <target>Working hours this month</target>\n </trans-unit>\n <trans-unit id=\"WqF84KR\" resname=\"stats.durationYear\">\n <source>stats.durationYear</source>\n <target>Working hours this year</target>\n </trans-unit>\n <trans-unit id=\"xkugSAA\" resname=\"stats.durationFinancialYear\">\n <source>stats.durationFinancialYear</source>\n <target>Working hours this financial year</target>\n </trans-unit>\n <trans-unit id=\"YtvPnl1\" resname=\"stats.durationTotal\">\n <source>stats.durationTotal</source>\n <target>Working hours total</target>\n </trans-unit>\n <trans-unit id=\"IFOLMgp\" resname=\"stats.yourWorkingHours\">\n <source>stats.yourWorkingHours</source>\n <target>My working hours</target>\n </trans-unit>\n <trans-unit id=\"023M9Ta\" resname=\"stats.amountToday\">\n <source>stats.amountToday</source>\n <target>Revenue today</target>\n </trans-unit>\n <trans-unit id=\"xnJvYAE\" resname=\"stats.amountWeek\">\n <source>stats.amountWeek</source>\n <target>Revenue this week</target>\n </trans-unit>\n <trans-unit id=\"ulr3reE\" resname=\"stats.amountMonth\">\n <source>stats.amountMonth</source>\n <target>Revenue this month</target>\n </trans-unit>\n <trans-unit id=\"bQZyZaO\" resname=\"stats.amountYear\">\n <source>stats.amountYear</source>\n <target>Revenue this year</target>\n </trans-unit>\n <trans-unit id=\"wuUWovn\" resname=\"stats.amountFinancialYear\">\n <source>stats.amountFinancialYear</source>\n <target>Revenue this financial year</target>\n </trans-unit>\n <trans-unit id=\"Z0fz23v\" resname=\"stats.amountTotal\">\n <source>stats.amountTotal</source>\n <target>Total revenue</target>\n </trans-unit>\n <trans-unit id=\"xyiadv3\" resname=\"stats.userActiveToday\">\n <source>stats.userActiveToday</source>\n <target>Active users today</target>\n </trans-unit>\n <trans-unit id=\"knMHaeO\" resname=\"stats.userActiveWeek\">\n <source>stats.userActiveWeek</source>\n <target>Active users this week</target>\n </trans-unit>\n <trans-unit id=\"adzVDgb\" resname=\"stats.userActiveMonth\">\n <source>stats.userActiveMonth</source>\n <target>Active users this month</target>\n </trans-unit>\n <trans-unit id=\"AswjFvh\" resname=\"stats.userActiveYear\">\n <source>stats.userActiveYear</source>\n <target>Active users this year</target>\n </trans-unit>\n <trans-unit id=\"zMY6gkY\" resname=\"stats.userActiveFinancialYear\">\n <source>stats.userActiveFinancialYear</source>\n <target>Active users this financial year</target>\n </trans-unit>\n <trans-unit id=\"dLTb1Po\" resname=\"stats.userActiveTotal\">\n <source>stats.userActiveTotal</source>\n <target>Active users ever</target>\n </trans-unit>\n <trans-unit id=\"lEW82ex\" resname=\"stats.activeRecordings\">\n <source>stats.activeRecordings</source>\n <target>Active records</target>\n </trans-unit>\n <trans-unit id=\"t5eIWp8\" resname=\"stats.userTotal\">\n <source>stats.userTotal</source>\n <target>Users</target>\n </trans-unit>\n <trans-unit id=\"Bor.76M\" resname=\"stats.activityTotal\">\n <source>stats.activityTotal</source>\n <target>Activities</target>\n </trans-unit>\n <trans-unit id=\"67uSaR3\" resname=\"stats.projectTotal\">\n <source>stats.projectTotal</source>\n <target>Projects</target>\n </trans-unit>\n <trans-unit id=\"tnD6aPj\" resname=\"stats.customerTotal\">\n <source>stats.customerTotal</source>\n <target>Customers</target>\n </trans-unit>\n <trans-unit id=\"unC5MXv\" resname=\"stats.percentUsed\">\n <source>stats.percentUsed</source>\n <target>%percent%% used</target>\n </trans-unit>\n <trans-unit id=\"HkjvwLc\" resname=\"stats.percentUsedLeft\">\n <source>stats.percentUsedLeft</source>\n <target>%percent%% used (%left% are still open)</target>\n </trans-unit>\n <trans-unit id=\"xN7MfSA\" resname=\"stats.percentUsed_month\">\n <source>stats.percentUsed_month</source>\n <target>%percent%% used this month</target>\n </trans-unit>\n <trans-unit id=\"vWJPpYU\" resname=\"stats.percentUsedLeft_month\">\n <source>stats.percentUsedLeft_month</source>\n <target>%percent%% used (%left% are still open this month)</target>\n </trans-unit>\n <!--\n Invoice\n -->\n <trans-unit id=\"Oq.KtC6\" resname=\"admin_invoice_template.title\">\n <source>admin_invoice_template.title</source>\n <target>Invoice template</target>\n </trans-unit>\n <trans-unit id=\"iERywrp\" resname=\"invoice.title\">\n <source>invoice.title</source>\n <target>Invoices</target>\n </trans-unit>\n <trans-unit id=\"ov4OQOh\" resname=\"invoice.filter\">\n <source>invoice.filter</source>\n <target>Filter invoice data</target>\n </trans-unit>\n <trans-unit id=\"7H7P1mE\" resname=\"button.preview\">\n <source>button.preview</source>\n <target>Preview</target>\n </trans-unit>\n <trans-unit id=\"IQ9DUOW\" resname=\"button.preview_print\">\n <source>button.preview_print</source>\n <target>Print preview</target>\n </trans-unit>\n <trans-unit id=\"X70dwP8\" resname=\"button.print\">\n <source>button.print</source>\n <target>Print</target>\n </trans-unit>\n <trans-unit id=\"W_TXvSi\" resname=\"button.csv\">\n <source>button.csv</source>\n <target>CSV</target>\n </trans-unit>\n <trans-unit id=\"vC2IsaP\" resname=\"button.xlsx\">\n <source>button.xlsx</source>\n <target>Excel</target>\n </trans-unit>\n <trans-unit id=\"aAa5uRR\" resname=\"button.pdf\">\n <source>button.pdf</source>\n <target>PDF</target>\n </trans-unit>\n <trans-unit id=\"ulYFDIo\" resname=\"button.ods\">\n <source>button.ods</source>\n <target>ODS</target>\n </trans-unit>\n <trans-unit id=\"zPcx3O_\" resname=\"invoice_print\">\n <source>invoice_print</source>\n <target>Invoice</target>\n </trans-unit>\n <trans-unit id=\"7J7G3Vr\" resname=\"label.mark_as_exported\">\n <source>label.mark_as_exported</source>\n <target>Mark as exported</target>\n </trans-unit>\n <trans-unit id=\"p0IprAw\" resname=\"label.template\">\n <source>label.template</source>\n <target>Template</target>\n </trans-unit>\n <trans-unit id=\"zfIRxJh\" resname=\"label.due_days\">\n <source>label.due_days</source>\n <target>Payment term in days</target>\n </trans-unit>\n <trans-unit id=\"rAJrxSK\" resname=\"invoice.due_days\">\n <source>invoice.due_days</source>\n <target>Payment target</target>\n </trans-unit>\n <trans-unit id=\"Xij3oQl\" resname=\"invoice.payment_date\">\n <source>invoice.payment_date</source>\n <target>Payment date</target>\n </trans-unit>\n <trans-unit id=\"4XKFnWh\" resname=\"invoice.from\">\n <source>invoice.from</source>\n <target>From</target>\n </trans-unit>\n <trans-unit id=\"hx7vsMA\" resname=\"invoice.to\">\n <source>invoice.to</source>\n <target>To</target>\n </trans-unit>\n <trans-unit id=\"x_W5sV4\" resname=\"invoice.number\">\n <source>invoice.number</source>\n <target>Invoice number</target>\n </trans-unit>\n <trans-unit id=\"86KyrKO\" resname=\"invoice.subtotal\">\n <source>invoice.subtotal</source>\n <target>Subtotal</target>\n </trans-unit>\n <trans-unit id=\"EO57yXg\" resname=\"invoice.tax\">\n <source>invoice.tax</source>\n <target>Tax</target>\n </trans-unit>\n <trans-unit id=\"N68vyvo\" resname=\"invoice.total\">\n <source>invoice.total</source>\n <target>Total</target>\n </trans-unit>\n <trans-unit id=\"TPzFWUs\" resname=\"invoice.service_date\">\n <source>invoice.service_date</source>\n <target>Service date</target>\n </trans-unit>\n <trans-unit id=\"6x24VVR\" resname=\"label.amount\">\n <source>label.amount</source>\n <target>Quantity</target>\n </trans-unit>\n <trans-unit id=\"g7EpaPY\" resname=\"label.total_rate\">\n <source>label.total_rate</source>\n <target>Total price</target>\n </trans-unit>\n <trans-unit id=\"MF3MdTu\" resname=\"label.unit_price\">\n <source>label.unit_price</source>\n <target>Unit price</target>\n </trans-unit>\n <trans-unit id=\"77aZC3r\" resname=\"label.payment_terms\">\n <source>label.payment_terms</source>\n <target>Terms of payment</target>\n </trans-unit>\n <trans-unit id=\"9p2KQag\" resname=\"invoice.signature_user\">\n <source>invoice.signature_user</source>\n <target>Confirmation: Date / Consultant's name / Signature</target>\n </trans-unit>\n <trans-unit id=\"Q9ykNhO\" resname=\"invoice.signature_customer\">\n <source>invoice.signature_customer</source>\n <target>Confirmation: Date / Customer's name / Signature</target>\n </trans-unit>\n <trans-unit id=\"c3d6p33\" resname=\"invoice.total_working_time\">\n <source>invoice.total_working_time</source>\n <target>Total duration</target>\n </trans-unit>\n <trans-unit id=\"BS00SS7\" resname=\"label.orderNumber\">\n <source>label.orderNumber</source>\n <target>Order number</target>\n </trans-unit>\n <trans-unit id=\"as948k9\" resname=\"label.orderDate\">\n <source>label.orderDate</source>\n <target>Order date</target>\n </trans-unit>\n <trans-unit id=\"RRj6PYN\" resname=\"label.invoice_tax_number\">\n <source>label.invoice_tax_number</source>\n <target>VAT no.:</target>\n </trans-unit>\n <trans-unit id=\"uFZA7Uf\" resname=\"label.invoice_bank_account\">\n <source>label.invoice_bank_account</source>\n <target>Bank account</target>\n </trans-unit>\n <trans-unit id=\"9VxfLLy\" resname=\"label.decimalDuration\">\n <source>label.decimalDuration</source>\n <target>Display duration as decimal number</target>\n </trans-unit>\n <trans-unit id=\"hzhzbqw\" resname=\"label.status\">\n <source>label.status</source>\n <target>Status</target>\n </trans-unit>\n <trans-unit id=\"X_NRsed\" resname=\"status.new\">\n <source>status.new</source>\n <target>New</target>\n </trans-unit>\n <trans-unit id=\"Uvo1CbP\" resname=\"status.pending\">\n <source>status.pending</source>\n <target>Pending</target>\n </trans-unit>\n <trans-unit id=\"PHJwR4w\" resname=\"status.paid\">\n <source>status.paid</source>\n <target>Paid</target>\n </trans-unit>\n <trans-unit id=\"gT9W2pZ\" resname=\"status.canceled\">\n <source>status.canceled</source>\n <target>Canceled</target>\n </trans-unit>\n <trans-unit id=\"crrlEUA\" resname=\"preview.skipped_rows\">\n <source>preview.skipped_rows</source>\n <target>Skipped preview of %rows% more rows …</target>\n </trans-unit>\n <!--\n Export\n -->\n <trans-unit id=\"F6Jmro7\" resname=\"export.title\">\n <source>export.title</source>\n <target>Export</target>\n </trans-unit>\n <trans-unit id=\"iwWaUoa\" resname=\"export.filter\">\n <source>export.filter</source>\n <target>Filter data for export</target>\n </trans-unit>\n <trans-unit id=\"vjmoQGo\" resname=\"export.period\">\n <source>export.period</source>\n <target>Period</target>\n </trans-unit>\n <trans-unit id=\"3CQ7A2m\" resname=\"export.document_title\">\n <source>export.document_title</source>\n <target>Export of timesheets</target>\n </trans-unit>\n <trans-unit id=\"d5wyWRD\" resname=\"export.full_list\">\n <source>export.full_list</source>\n <target>Full list</target>\n </trans-unit>\n <trans-unit id=\"N778uJ6\" resname=\"export.summary\">\n <source>export.summary</source>\n <target>Summary</target>\n </trans-unit>\n <trans-unit id=\"ElDyzrx\" resname=\"export.page_of\">\n <source>export.page_of</source>\n <target>Page %page% of %pages%</target>\n </trans-unit>\n <trans-unit id=\"vKY0tof\" resname=\"export.date_copyright\">\n <source>export.date_copyright</source>\n <target>Created %date% with %kimai%</target>\n </trans-unit>\n <trans-unit id=\"W92QGbY\" resname=\"export.warn_result_amount\">\n <source>export.warn_result_amount</source>\n <target>Your search leads to %count% results. If the export fails, you have to narrow down your search further.</target>\n </trans-unit>\n <trans-unit id=\"pnGDFmf\" resname=\"label.type\">\n <source>label.type</source>\n <target>Type</target>\n </trans-unit>\n <!--\n Navbar - recent entries and activities\n -->\n <trans-unit id=\"OxdYMR3\" resname=\"active.entries\">\n <source>active.entries</source>\n <target>Your active time measurements</target>\n </trans-unit>\n <trans-unit id=\"e7XS97t\" resname=\"timesheet.all\">\n <source>timesheet.all</source>\n <target>Show all records</target>\n </trans-unit>\n <trans-unit id=\"WVU_S.A\" resname=\"recent.activities\">\n <source>recent.activities</source>\n <target>Restart one of your last activities</target>\n </trans-unit>\n <trans-unit id=\"SLV47Uu\" resname=\"recent.activities.format\">\n <source>recent.activities.format</source>\n <target>%activity% in %project% for %customer%</target>\n </trans-unit>\n <trans-unit id=\"dTHY7Mw\" resname=\"timesheet.start\">\n <source>timesheet.start</source>\n <target>Create new time-record</target>\n </trans-unit>\n <!--\n TOOLBARS\n -->\n <trans-unit id=\"MPimOps\" resname=\"label.pageSize\">\n <source>label.pageSize</source>\n <target>Page size</target>\n </trans-unit>\n <trans-unit id=\"KhyA_PW\" resname=\"label.entryState\">\n <source>label.entryState</source>\n <target>Records</target>\n </trans-unit>\n <trans-unit id=\"X3JM9wj\" resname=\"label.exported\">\n <source>label.exported</source>\n <target>Exported</target>\n </trans-unit>\n <trans-unit id=\"_DDecAV\" resname=\"entryState.exported\">\n <source>entryState.exported</source>\n <target>Cleared</target>\n </trans-unit>\n <trans-unit id=\"ccCiXyR\" resname=\"entryState.not_exported\">\n <source>entryState.not_exported</source>\n <target>Open</target>\n </trans-unit>\n <trans-unit id=\"do7fP0q\" resname=\"entryState.all\">\n <source>entryState.all</source>\n <target>All</target>\n </trans-unit>\n <trans-unit id=\"xm7mqoK\" resname=\"entryState.running\">\n <source>entryState.running</source>\n <target>Active</target>\n </trans-unit>\n <trans-unit id=\"spHpd_I\" resname=\"entryState.stopped\">\n <source>entryState.stopped</source>\n <target>Stopped</target>\n </trans-unit>\n <trans-unit id=\"BhsaLxX\" resname=\"export.clear_all\">\n <source>export.clear_all</source>\n <target>Mark all shown records as open?</target>\n </trans-unit>\n <trans-unit id=\"qtjPKUT\" resname=\"export.mark_all\">\n <source>export.mark_all</source>\n <target>Mark all shown records as cleared?</target>\n </trans-unit>\n <trans-unit id=\"keE.KO.\" resname=\"Only global\">\n <source>Only global</source>\n <target state=\"needs-translation\">Only global</target>\n </trans-unit>\n <trans-unit id=\"2Ek7sXu\" resname=\"label.batch_meta_fields\">\n <source>label.batch_meta_fields</source>\n <target>Additional fields</target>\n </trans-unit>\n <trans-unit id=\"9Wt8Pp_\" resname=\"help.batch_meta_fields\">\n <source>help.batch_meta_fields</source>\n <target>Fields that are to be updated must first be activated by clicking on the associated checkbox.</target>\n </trans-unit>\n <trans-unit id=\"z_YHoZn\" resname=\"label.includeNoWork\">\n <source>label.includeNoWork</source>\n <target>Show entries without bookings</target>\n </trans-unit>\n <trans-unit id=\"B.Dbbob\" resname=\"label.includeNoBudget\">\n <source>label.includeNoBudget</source>\n <target>Show entries without budget</target>\n </trans-unit>\n <trans-unit id=\"Wq.h4nD\" resname=\"label.includeBudgetType_month\">\n <source>label.includeBudgetType_month</source>\n <target>Show entries with \"monthly\" budget</target>\n </trans-unit>\n <trans-unit id=\"nVulc7.\" resname=\"label.includeBudgetType_full\">\n <source>label.includeBudgetType_full</source>\n <target>Show entries with \"life cycle\" budget</target>\n </trans-unit>\n <trans-unit id=\"3zn5T5e\" resname=\"label.not_exported\">\n <source>label.not_exported</source>\n <target>Not exported</target>\n </trans-unit>\n <trans-unit id=\"csF1D35\" resname=\"label.not_invoiced\">\n <source>label.not_invoiced</source>\n <target>Not billed</target>\n </trans-unit>\n <trans-unit id=\"AJ6dwR.\" resname=\"label.last_record_before\">\n <source>label.last_record_before</source>\n <target>No time booking since</target>\n </trans-unit>\n <trans-unit id=\"qDnURk7\" resname=\"label.last_record\">\n <source>label.last_record</source>\n <target>Last entry</target>\n </trans-unit>\n <trans-unit id=\"LXdqaTH\" resname=\"label.account_number\">\n <source>label.account_number</source>\n <target>Staff number</target>\n </trans-unit>\n <trans-unit id=\"PoF7hD8\" resname=\"label.budgetType\">\n <source>label.budgetType</source>\n <target>Budget-Type</target>\n </trans-unit>\n <trans-unit id=\"cHfLJtL\" resname=\"label.budgetType_month\">\n <source>label.budgetType_month</source>\n <target>Monthly</target>\n </trans-unit>\n <trans-unit id=\"9Rhadz6\" resname=\"label.budgetType_full\">\n <source>label.budgetType_full</source>\n <target>Life cycle</target>\n </trans-unit>\n <trans-unit id=\"tvV0NhL\" resname=\"delete_warning.short_stats\">\n <source>delete_warning.short_stats</source>\n <target>Currently %records% time-records exists, which sum up to a total duration of %duration%.</target>\n </trans-unit>\n <trans-unit id=\"Zif614Q\" resname=\"add_user.label\">\n <source>add_user.label</source>\n <target>Add user</target>\n </trans-unit>\n <trans-unit id=\"tp.gIrE\" resname=\"team.add_user.help\">\n <source>team.add_user.help</source>\n <target>Add a new user to the team by selecting it from the list. Afterwards you can decide if the user should become a teamlead.</target>\n </trans-unit>\n <trans-unit id=\"yNWIi5U\" resname=\"default_value_new\">\n <source>default_value_new</source>\n <target>Default values for new entries</target>\n </trans-unit>\n <!--\n QUICK ENTRIES\n -->\n <trans-unit id=\"f8oNzSP\" resname=\"quick_entry.title\">\n <source>quick_entry.title</source>\n <target>Weekly working hours</target>\n </trans-unit>\n <trans-unit id=\"61p_ckr\" resname=\"label.hours_24\">\n <source>label.hours_24</source>\n <target>24 hours</target>\n </trans-unit>\n </body>\n </file>\n</xliff>"
] |
[
1,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">\n <file source-language=\"en\" target-language=\"en\" datatype=\"plaintext\" original=\"messages.en.xlf\">\n <body>\n <!--\n Global template keys\n -->\n <trans-unit id=\"N7mikjJ\" resname=\"time_tracking\">\n <source>time_tracking</source>\n <target>Time Tracking</target>\n </trans-unit>\n <trans-unit id=\"inmIkP6\" resname=\"yes\">\n <source>yes</source>\n <target>Yes</target>\n </trans-unit>\n <trans-unit id=\"k5Apjz_\" resname=\"no\">\n <source>no</source>\n <target>No</target>\n </trans-unit>\n <trans-unit id=\".3dyBTq\" resname=\"both\">\n <source>both</source>\n <target>Both</target>\n </trans-unit>\n <trans-unit id=\"KLIuHvt\" resname=\"This is a mandatory field\">\n <source>This is a mandatory field</source>\n <target>Mandatory</target>\n </trans-unit>\n <trans-unit id=\"_ohHsMM\" resname=\"create\">\n <source>create</source>\n <target>Create</target>\n </trans-unit>\n <trans-unit id=\"DYHuW58\" resname=\"confirm.delete\">\n <source>confirm.delete</source>\n <target>Do you really want to delete it?</target>\n </trans-unit>\n <trans-unit id=\"vDd3alC\" resname=\"admin_entity.delete_confirm\">\n <source>admin_entity.delete_confirm</source>\n <target>\n This data will be deleted as well!\n Alternatively, you can select an entry to which all data will be transferred:\n </target>\n </trans-unit>\n <trans-unit id=\"COyxNde\" resname=\"delete.not_in_use\">\n <source>delete.not_in_use</source>\n <target>This item can be safely deleted.</target>\n </trans-unit>\n <trans-unit id=\"I3TZF5S\" resname=\"cancel\">\n <source>cancel</source>\n <target>Cancel</target>\n </trans-unit>\n <trans-unit id=\"PyZ8KrQ\" resname=\"confirm\">\n <source>confirm</source>\n <target>Confirm</target>\n </trans-unit>\n <trans-unit id=\".0CFrRV\" resname=\"upload\">\n <source>upload</source>\n <target>Upload</target>\n </trans-unit>\n <trans-unit id=\"JBkykGe\" resname=\"search\">\n <source>search</source>\n <target>Search</target>\n </trans-unit>\n <trans-unit id=\"IolBPQD\" resname=\"label.searchTerm\">\n <source>label.searchTerm</source>\n <target>Search term</target>\n </trans-unit>\n <trans-unit id=\"BytPihM\" resname=\"label.set_as_default\">\n <source>label.set_as_default</source>\n <target>Save setting as search favourite</target>\n </trans-unit>\n <trans-unit id=\"NNKq04n\" resname=\"label.remove_default\">\n <source>label.remove_default</source>\n <target>Delete search favourite</target>\n </trans-unit>\n <trans-unit id=\"31x84Dt\" resname=\"label.asc\">\n <source>label.asc</source>\n <target>Ascending</target>\n </trans-unit>\n <trans-unit id=\"0D_zaYd\" resname=\"label.desc\">\n <source>label.desc</source>\n <target>Descending</target>\n </trans-unit>\n <trans-unit id=\"Z8Fxbvf\" resname=\"label.orderBy\">\n <source>label.orderBy</source>\n <target>Order by</target>\n </trans-unit>\n <trans-unit id=\"hBNESu6\" resname=\"my.profile\">\n <source>my.profile</source>\n <target>My profile</target>\n </trans-unit>\n <trans-unit id=\"J258iS6\" resname=\"update_multiple\">\n <source>update_multiple</source>\n <target>%action% %count% entries?</target>\n </trans-unit>\n <trans-unit id=\"OTDmccn\" resname=\"attachments\">\n <source>attachments</source>\n <target>Files</target>\n </trans-unit>\n <trans-unit id=\"O5w1jzb\" resname=\"file\">\n <source>file</source>\n <target>File</target>\n </trans-unit>\n <trans-unit id=\"0M_Gylq\" resname=\"rates.empty\">\n <source>rates.empty</source>\n <target>No hourly rates have yet been configured.</target>\n </trans-unit>\n <trans-unit id=\"mflwMcX\" resname=\"rates.title\">\n <source>rates.title</source>\n <target>Fees</target>\n </trans-unit>\n <trans-unit id=\"zFfl7jw\" resname=\"sum.total\">\n <source>sum.total</source>\n <target>Total</target>\n </trans-unit>\n <trans-unit id=\"XP5zkiN\" resname=\"modal.dirty\">\n <source>modal.dirty</source>\n <target>The form has changed. Please click \"Save\" to save the changes or \"Close\" to cancel.</target>\n </trans-unit>\n <!--\n Login / Security\n -->\n <trans-unit id=\"9pvowqn\" resname=\"label.password\">\n <source>label.password</source>\n <target>Password</target>\n </trans-unit>\n <trans-unit id=\"WxAnbP0\" resname=\"label.password_repeat\">\n <source>label.password_repeat</source>\n <target>Repeat password</target>\n </trans-unit>\n <trans-unit id=\"II4DGnv\" resname=\"label.logout\">\n <source>label.logout</source>\n <target>Logout</target>\n </trans-unit>\n <trans-unit id=\"hFFZGp_\" resname=\"label.user_profile\">\n <source>label.user_profile</source>\n <target>My profile</target>\n </trans-unit>\n <trans-unit id=\"gXZR.hV\" resname=\"label.api_token\">\n <source>label.api_token</source>\n <target>API password</target>\n </trans-unit>\n <trans-unit id=\"s_X2xpI\" resname=\"label.api_token_repeat\">\n <source>label.api_token_repeat</source>\n <target>Repeat API password</target>\n </trans-unit>\n <trans-unit id=\".372.o7\" resname=\"login_required\">\n <source>login_required</source>\n <target>Missing permission. Redirect to login?</target>\n </trans-unit>\n <trans-unit id=\".ndupSK\" resname=\"registration.check_email\">\n <source>registration.check_email</source>\n <target>An email has been sent to %email%. It contains an activation link you must click to activate your account.</target>\n </trans-unit>\n <trans-unit id=\"_cY.wHP\" resname=\"resetting.check_email\">\n <source>resetting.check_email</source>\n <target>\n An email has been sent. It contains a link you must click to reset your password.\n Note: You can only request a new password once within %tokenLifetime% hours.",
" If you don't get an email check your spam folder or try again.\n </target>\n </trans-unit>\n <!--\n Menu / Navbar items\n -->\n <trans-unit id=\"UoOv6mx\" resname=\"menu.homepage\">\n <source>menu.homepage</source>\n <target>Dashboard</target>\n </trans-unit>\n <trans-unit id=\"wvvYSw_\" resname=\"menu.admin\">\n <source>menu.admin</source>\n <target>Administration</target>\n </trans-unit>\n <trans-unit id=\"6OKwCUB\" resname=\"menu.system\">\n <source>menu.system</source>\n <target>System</target>\n </trans-unit>\n <trans-unit id=\"wBTFKFR\" resname=\"menu.logout\">\n <source>menu.logout</source>\n <target>Logout</target>\n </trans-unit>\n <trans-unit id=\"C0W7_BT\" resname=\"menu.timesheet\">\n <source>menu.timesheet</source>\n <target>My times</target>\n </trans-unit>\n <trans-unit id=\"Ci9W8.K\" resname=\"menu.invoice\">\n <source>menu.invoice</source>\n <target>Invoices</target>\n </trans-unit>\n <trans-unit id=\"I.eil4u\" resname=\"menu.export\">\n <source>menu.export</source>\n <target>Export</target>\n </trans-unit>\n <trans-unit id=\"ypVQO7o\" resname=\"menu.reporting\">\n <source>menu.reporting</source>\n <target>Reporting</target>\n </trans-unit>\n <trans-unit id=\"WGIhZv1\" resname=\"menu.admin_timesheet\">\n <source>menu.admin_timesheet</source>\n <target>Timesheets</target>\n </trans-unit>\n <trans-unit id=\"Y_jAD36\" resname=\"menu.admin_customer\">\n <source>menu.admin_customer</source>\n <target>Customers</target>\n </trans-unit>\n <trans-unit id=\"oDLp9t3\" resname=\"menu.admin_project\">\n <source>menu.admin_project</source>\n <target>Projects</target>\n </trans-unit>\n <trans-unit id=\"wriHFwl\" resname=\"menu.admin_activity\">\n <source>menu.admin_activity</source>\n <target>Activities</target>\n </trans-unit>\n <trans-unit id=\"oZo1BnZ\" resname=\"menu.admin_user\">\n <source>menu.admin_user</source>\n <target>Users</target>\n </trans-unit>\n <trans-unit id=\"pA.bYIk\" resname=\"menu.admin_team\">\n <source>menu.admin_team</source>\n <target>Teams</target>\n </trans-unit>\n <trans-unit id=\"hOZxcaK\" resname=\"menu.plugin\">\n <source>menu.plugin</source>\n <target>Plugins</target>\n </trans-unit>\n <trans-unit id=\"IXtkHRw\" resname=\"menu.system_configuration\">\n <source>menu.system_configuration</source>\n <target>Settings</target>\n </trans-unit>\n <trans-unit id=\"yo4f8Kh\" resname=\"menu.tags\">\n <source>menu.tags</source>\n <target>Tags</target>\n </trans-unit>\n <trans-unit id=\"1kHI0gb\" resname=\"menu.doctor\">\n <source>menu.doctor</source>\n <target>Doctor</target>\n </trans-unit>\n <!--\n Error templates\n -->\n <trans-unit id=\"Vz3Igj3\" resname=\"error.no_entries_found\">\n <source>error.no_entries_found</source>\n <target>No entries were found based on your selected filters.</target>\n </trans-unit>\n <trans-unit id=\"hlu4iX5\" resname=\"error.no_comments_found\">\n <source>error.no_comments_found</source>\n <target>There were no comments posted yet.</target>\n </trans-unit>\n <trans-unit id=\"XQ2.pq2\" resname=\"error.too_many_entries\">\n <source>error.too_many_entries</source>\n <target>The request could not be processed. Too many results were found.</target>\n </trans-unit>\n <!--\n General labels\n -->\n <trans-unit id=\"H1qEi4d\" resname=\"label.date\">\n <source>label.date</source>\n <target>Date</target>\n </trans-unit>\n <trans-unit id=\"eJPDE76\" resname=\"label.starttime\">\n <source>label.starttime</source>\n <target>Begin</target>\n </trans-unit>\n <trans-unit id=\"uZlpDFh\" resname=\"label.endtime\">\n <source>label.endtime</source>\n <target>End</target>\n </trans-unit>\n <trans-unit id=\"cgpmY0I\" resname=\"label.duration\">\n <source>label.duration</source>\n <target>Duration</target>\n </trans-unit>\n <trans-unit id=\"O2X4xZH\" resname=\"label.user\">\n <source>label.user</source>\n <target>User</target>\n </trans-unit>\n <trans-unit id=\"LDhDPrF\" resname=\"label.username\">\n <source>label.username</source>\n <target>User</target>\n </trans-unit>\n <trans-unit id=\"4cEApe1\" resname=\"label.description\">\n <source>label.description</source>\n <target>Description</target>\n </trans-unit>\n <trans-unit id=\"ysOvPSq\" resname=\"label.name\">\n <source>label.name</source>\n <target>Name</target>\n </trans-unit>\n <trans-unit id=\"WqTho4C\" resname=\"label.comment\">\n <source>label.comment</source>\n <target>Comment</target>\n </trans-unit>\n <trans-unit id=\"txRonia\" resname=\"label.id\">\n <source>label.id</source>\n <target>ID</target>\n </trans-unit>\n <trans-unit id=\"CYpZwBz\" resname=\"label.visible\">\n <source>label.visible</source>\n <target>Visible</target>\n </trans-unit>\n <trans-unit id=\"2ktNwkr\" resname=\"label.budget\">\n <source>label.budget</source>\n <target>Budget</target>\n </trans-unit>\n <trans-unit id=\"x8TrOec\" resname=\"label.timeBudget\">\n <source>label.timeBudget</source>\n <target>Time budget</target>\n </trans-unit>\n <trans-unit id=\"l1wiL0h\" resname=\"label.activity\">\n <source>label.activity</source>\n <target>Activity</target>\n </trans-unit>\n <trans-unit id=\"KtnqJcg\" resname=\"label.project\">\n <source>label.project</source>\n <target>Project</target>\n </trans-unit>\n <trans-unit id=\"VNCQ7YU\" resname=\"label.tag\">\n <source>label.tag</source>\n <target>Tags</target>\n </trans-unit>\n <trans-unit id=\"ijQyGRo\" resname=\"label.tags\">\n <source>label.tags</source>\n <target>Tags</target>\n </trans-unit>\n <trans-unit id=\"VAbtieW\" resname=\"label.hourlyRate\">\n <source>label.hourlyRate</source>\n <target>Hourly rate</target>\n </trans-unit>\n <trans-unit id=\"IQ.tlua\" resname=\"label.hourly_rate\">\n <source>label.hourly_rate</source>\n <target>Hourly rate</target>\n </trans-unit>\n <trans-unit id=\"dezCZWf\" resname=\"label.skin\">\n <source>label.skin</source>\n <target>Display: colors</target>\n </trans-unit>\n <trans-unit id=\"O40d_3K\" resname=\"theme.layout\">\n <source>Display: layout</source>\n <target state=\"needs-translation\">Display: layout</target>\n </trans-unit>\n <trans-unit id=\"w8T34A6\" resname=\"label.hours\">\n <source>label.hours</source>\n <target>Hours</target>\n </trans-unit>\n <trans-unit id=\"Ih3IFXj\" resname=\"label.rate\">\n <source>label.rate</source>\n <target>Rate</target>\n </trans-unit>\n <trans-unit id=\"djL6LMC\" resname=\"help.rate\">\n <source>help.rate</source>\n <target>Hourly rate to be charged</target>\n </trans-unit>\n <trans-unit id=\"QzvjNwg\" resname=\"label.rate_internal\">\n <source>label.rate_internal</source>\n <target>Internal rate</target>\n </trans-unit>\n <trans-unit id=\"uz4SmfP\" resname=\"help.rate_internal\">\n <source>help.rate_internal</source>\n <target>Internal costs (if this is not specified, the normal rate is used)</target>\n </trans-unit>\n <trans-unit id=\"v72sA1c\" resname=\"label.recalculate_rates\">\n <source>label.recalculate_rates</source>\n <target>Recalculate rates</target>\n </trans-unit>\n <trans-unit id=\"foM2o5T\" resname=\"label.language\">\n <source>label.language</source>\n <target>Language</target>\n </trans-unit>\n <trans-unit id=\"Z8a2kUf\" resname=\"label.customer\">\n <source>label.customer</source>\n <target>Customer</target>\n </trans-unit>\n <trans-unit id=\"D2N6_cP\" resname=\"label.email\">\n <source>label.email</source>\n <target>Email</target>\n </trans-unit>\n <trans-unit id=\"Ss2xe99\" resname=\"label.team\">\n <source>label.team</source>\n <target>Team</target>\n </trans-unit>\n <trans-unit id=\"Zpj9UB4\" resname=\"label.teamlead\">\n <source>label.teamlead</source>\n <target>Teamlead</target>\n </trans-unit>\n <trans-unit id=\"hX.EQKy\" resname=\"label.create_more\">\n <source>label.create_more</source>\n <target>Create further entries</target>\n </trans-unit>\n <trans-unit id=\"LIOnolg\" resname=\"placeholder.type_message\">\n <source>placeholder.type_message</source>\n <target>Type your message…</target>\n </trans-unit>\n <trans-unit id=\"vkHr9AP\" resname=\"label.billable\">\n <source>label.billable</source>\n <target>Billable</target>\n </trans-unit>\n <!--\n Buttons & Actions\n -->\n <trans-unit id=\"zldXQq6\" resname=\"label.actions\">\n <source>label.actions</source>\n <target>Actions</target>\n </trans-unit>\n <trans-unit id=\"ovKkXwU\" resname=\"action.edit\">\n <source>action.edit</source>\n <target>Edit</target>\n </trans-unit>\n <trans-unit id=\"jdbtx6z\" resname=\"action.add\">\n <source>action.add</source>\n <target>Add</target>\n </trans-unit>\n <trans-unit id=\"hTKWQ6g\" resname=\"action.delete\">\n <source>action.delete</source>\n <target>Delete</target>\n </trans-unit>\n <trans-unit id=\"HLtdhYw\" resname=\"action.save\">\n <source>action.save</source>\n <target>Save</target>\n </trans-unit>\n <trans-unit id=\"9hpJPiG\" resname=\"action.save_all\">\n <source>action.save_all</source>\n <target>Save all</target>\n </trans-unit>\n <trans-unit id=\"tKZKI2Z\" resname=\"action.reset\">\n <source>action.reset</source>\n <target>Reset</target>\n </trans-unit>\n <trans-unit id=\"Eb7Ygpo\" resname=\"action.back\">\n <source>action.back</source>\n <target>Back</target>\n </trans-unit>\n <trans-unit id=\"wCazS.X\" resname=\"action.close\">\n <source>action.close</source>\n <target>Close</target>\n </trans-unit>\n <!--\n Dashboard\n -->\n <trans-unit id=\"3bqLM8Q\" resname=\"dashboard.title\">\n <source>dashboard.title</source>\n <target>Dashboard</target>\n </trans-unit>\n <trans-unit id=\"3PYadzb\" resname=\"dashboard.subtitle\">\n <source>dashboard.subtitle</source>\n <target>Welcome!</target>\n </trans-unit>\n <trans-unit id=\"yEa1Yz3\" resname=\"dashboard.all\">\n <source>dashboard.all</source>\n <target>All users</target>\n </trans-unit>\n <!--\n Widgets\n -->\n <trans-unit id=\"giznf_R\" resname=\"more.info.link\">\n <source>more.info.link</source>\n <target>More info</target>\n </trans-unit>\n <trans-unit id=\"4iliLZT\" resname=\"label.toggle_dropdown\">\n <source>label.toggle_dropdown</source>\n <target>Show menu</target>\n </trans-unit>\n <trans-unit id=\"f3KMQJh\" resname=\"label.my_teams\">\n <source>label.my_teams</source>\n <target>My teams</target>\n </trans-unit>\n <trans-unit id=\"jTiYRIu\" resname=\"label.my_team_projects\">\n <source>label.my_team_projects</source>\n <target>My projects</target>\n </trans-unit>\n <trans-unit id=\"1PQHtXu\" resname=\"label.progress\">\n <source>label.progress</source>\n <target>Progress</target>\n </trans-unit>\n <trans-unit id=\"vTY9SUk\" resname=\"label.plus_more\">\n <source>label.plus_more</source>\n <target>+%count% more</target>\n </trans-unit>\n <!--\n Timesheet\n -->\n <trans-unit id=\"VXj0Y3h\" resname=\"timesheet.title\">\n <source>timesheet.title</source>\n <target>My times</target>\n </trans-unit>\n <trans-unit id=\"dwEVXUR\" resname=\"timesheet.edit\">\n <source>timesheet.edit</source>\n <target>Edit record</target>\n </trans-unit>\n <trans-unit id=\"trDJK9W\" resname=\"label.begin\">\n <source>label.begin</source>\n <target>From</target>\n </trans-unit>\n <trans-unit id=\"R9typUt\" resname=\"label.end\">\n <source>label.end</source>\n <target>To</target>\n </trans-unit>\n <trans-unit id=\"egaNXjp\" resname=\"label.daterange\">\n <source>label.daterange</source>\n <target>Time range</target>\n </trans-unit>\n <trans-unit id=\"UbnqJLn\" resname=\"modal.columns.title\">\n <source>modal.columns.title</source>\n <target>Change column visibility</target>\n </trans-unit>\n <trans-unit id=\"EbfIoLp\" resname=\"modal.columns.description\">\n <source>modal.columns.description</source>\n <target>Upon saving the un-checked columns will be hidden and this setting will be stored in a browser cookie. If you delete your cookies, the settings will be reversed.</target>\n </trans-unit>\n <trans-unit id=\"5gjqxgK\" resname=\"label.fixedRate\">\n <source>label.fixedRate</source>\n <target>Fixed rate</target>\n </trans-unit>\n <trans-unit id=\"b43sCwO\" resname=\"help.fixedRate\">\n <source>help.fixedRate</source>\n <target>Each time record gets the same value, regardless of its duration</target>\n </trans-unit>\n <trans-unit id=\"YTSS_Q1\" resname=\"label.color\">\n <source>label.color</source>\n <target>Color</target>\n </trans-unit>\n <trans-unit id=\"EoouxGX\" resname=\"label.replaceTags\">\n <source>label.replaceTags</source>\n <target>Replace tags</target>\n </trans-unit>\n <trans-unit id=\"BxkmaKz\" resname=\"label.appendTags\">\n <source>label.appendTags</source>\n <target>Append tags</target>\n </trans-unit>\n <!--\n User profile\n -->\n <trans-unit id=\"1_wnK76\" resname=\"profile.title\">\n <source>profile.title</source>\n <target>User profile</target>\n </trans-unit>\n <trans-unit id=\"HWKJZ0T\" resname=\"profile.about_me\">\n <source>profile.about_me</source>\n <target>About me</target>\n </trans-unit>\n <trans-unit id=\"Fm.kwVn\" resname=\"profile.first_entry\">\n <source>profile.first_entry</source>\n <target>Working since</target>\n </trans-unit>\n <trans-unit id=\"1c0EQaz\" resname=\"profile.registration_date\">\n <source>profile.registration_date</source>\n <target>Registered at</target>\n </trans-unit>\n <trans-unit id=\"xEYQXPy\" resname=\"profile.settings\">\n <source>profile.settings</source>\n <target>Profile</target>\n </trans-unit>\n <trans-unit id=\"A6TLLQa\" resname=\"profile.password\">\n <source>profile.password</source>\n <target>Password</target>\n </trans-unit>\n <trans-unit id=\"Z34ZpjK\" resname=\"profile.api-token\">\n <source>profile.api-token</source>\n <target>API</target>\n </trans-unit>\n <trans-unit id=\"ygtTz8.\" resname=\"profile.roles\">\n <source>profile.roles</source>\n <target>Roles</target>\n </trans-unit>\n <trans-unit id=\"DZ7XGML\" resname=\"profile.teams\">\n <source>profile.teams</source>\n <target>Teams</target>\n </trans-unit>\n <trans-unit id=\"MQKiG33\" resname=\"profile.preferences\">\n <source>profile.preferences</source>\n <target>Preferences</target>\n </trans-unit>\n <trans-unit id=\"Eq78QrH\" resname=\"label.theme.collapsed_sidebar\">\n <source>label.theme.collapsed_sidebar</source>\n <target>Minimize the left sidebar</target>\n </trans-unit>\n <trans-unit id=\"0sgroZi\" resname=\"label.calendar.initial_view\">\n <source>label.calendar.initial_view</source>\n <target>Initial calendar view</target>\n </trans-unit>\n <trans-unit id=\"iqQsgIW\" resname=\"label.login.initial_view\">\n <source>label.login.initial_view</source>\n <target>Initial view after login</target>\n </trans-unit>\n <trans-unit id=\"hO7mkmf\" resname=\"label.lastLogin\">\n <source>label.lastLogin</source>\n <target>Last login</target>\n </trans-unit>\n <!-- Options for user-preference label.calendar.initial_view -->\n <trans-unit id=\"pcfRcZ4\" resname=\"month\">\n <source>month</source>\n <target>Month</target>\n </trans-unit>\n <trans-unit id=\"Irm6dfx\" resname=\"agendaWeek\">\n <source>agendaWeek</source>\n <target>Week</target>\n </trans-unit>\n <trans-unit id=\"Q0Zip02\" resname=\"agendaDay\">\n <source>agendaDay</source>\n <target>Day</target>\n </trans-unit>\n <trans-unit id=\"rYzHCFd\" resname=\"label.timesheet.daily_stats\">\n <source>label.timesheet.daily_stats</source>\n <target>Show daily stats in timesheet</target>\n </trans-unit>\n <trans-unit id=\"tSlqVK2\" resname=\"label.timesheet.export_decimal\">\n <source>label.timesheet.export_decimal</source>\n <target>Use decimal duration in export</target>\n </trans-unit>\n <trans-unit id=\"5R.QsZ3\" resname=\"theme.update_browser_title\">\n <source>theme.update_browser_title</source>\n <target>Update browser title</target>\n </trans-unit>\n <!--\n User timesheet calendar\n -->\n <trans-unit id=\"HWiuMV6\" resname=\"calendar.title\">\n <source>calendar.title</source>\n <target>Calendar</target>\n </trans-unit>\n <trans-unit id=\"75kjTF9\" resname=\"calendar.drag_and_drop.delete\">\n <source>calendar.drag_and_drop.delete</source>\n <target>If you want to delete an entry, you must drag it onto the button.</target>\n </trans-unit>\n <!--\n Admin: Timesheet\n -->\n <trans-unit id=\"bSDjzZL\" resname=\"admin_timesheet.title\">\n <source>admin_timesheet.title</source>\n <target>Timesheets</target>\n </trans-unit>\n <!--\n Admin: Projects\n -->\n <trans-unit id=\"DFjFRGe\" resname=\"admin_project.title\">\n <source>admin_project.title</source>\n <target>Projects</target>\n </trans-unit>\n <trans-unit id=\"yLOqEX_\" resname=\"label.project_start\">\n <source>label.project_start</source>\n <target>Project start</target>\n </trans-unit>\n <trans-unit id=\"4kQGReV\" resname=\"label.project_end\">\n <source>label.project_end</source>\n <target>Project end</target>\n </trans-unit>\n <!--\n Admin: Activity\n -->\n <trans-unit id=\"auu8q0u\" resname=\"admin_activity.title\">\n <source>admin_activity.title</source>\n <target>Activities</target>\n </trans-unit>\n <!--\n Admin: Customer\n -->\n <trans-unit id=\"2TvKX9Z\" resname=\"admin_customer.title\">\n <source>admin_customer.title</source>\n <target>Customer</target>\n </trans-unit>\n <trans-unit id=\"39AtPxQ\" resname=\"label.number\">\n <source>label.number</source>\n <target>Account</target>\n </trans-unit>\n <trans-unit id=\"7jfRn_1\" resname=\"label.company\">\n <source>label.company</source>\n <target>Company name</target>\n </trans-unit>\n <trans-unit id=\"GOStgLi\" resname=\"label.vat\">\n <source>label.vat</source>\n <target>Tax</target>\n </trans-unit>\n <trans-unit id=\"Dgmh_mv\" resname=\"label.vat_id\">\n <source>label.vat_id</source>\n <target>VAT-ID</target>\n </trans-unit>\n <trans-unit id=\"YNGNfGn\" resname=\"label.tax_rate\">\n <source>label.tax_rate</source>\n <target>Tax rate</target>\n </trans-unit>\n <trans-unit id=\"0tkOMo1\" resname=\"label.contact\">\n <source>label.contact</source>\n <target>Contact</target>\n </trans-unit>\n <trans-unit id=\"c9W5AO4\" resname=\"label.address\">\n <source>label.address</source>\n <target>Address</target>\n </trans-unit>\n <trans-unit id=\"k7MJQ82\" resname=\"label.country\">\n <source>label.country</source>\n <target>Country</target>\n </trans-unit>\n <trans-unit id=\"g03c_vw\" resname=\"label.phone\">\n <source>label.phone</source>\n <target>Phone</target>\n </trans-unit>\n <trans-unit id=\"eRyhERS\" resname=\"label.fax\">\n <source>label.fax</source>\n <target>Fax</target>\n </trans-unit>\n <trans-unit id=\"AawT9pW\" resname=\"label.mobile\">\n <source>label.mobile</source>\n <target>Mobile</target>\n </trans-unit>\n <trans-unit id=\"PS9IH_t\" resname=\"label.homepage\">\n <source>label.homepage</source>\n <target>Homepage</target>\n </trans-unit>\n <trans-unit id=\"dmtPdwq\" resname=\"label.timezone\">\n <source>label.timezone</source>\n <target>Timezone</target>\n </trans-unit>\n <trans-unit id=\"otd2FZd\" resname=\"label.currency\">\n <source>label.currency</source>\n <target>Currency</target>\n </trans-unit>\n <!--\n Admin: Users\n -->\n <trans-unit id=\"t34EvnF\" resname=\"admin_user.title\">\n <source>admin_user.title</source>\n <target>User</target>\n </trans-unit>\n <trans-unit id=\"TRDzmCV\" resname=\"label.alias\">\n <source>label.alias</source>\n <target>Name</target>\n </trans-unit>\n <trans-unit id=\"UrRn8xj\" resname=\"label.title\">\n <source>label.title</source>\n <target>Title</target>\n </trans-unit>\n <trans-unit id=\"nWMH_Nr\" resname=\"label.avatar\">\n <source>label.avatar</source>\n <target>Profile image (URL)</target>\n </trans-unit>\n <trans-unit id=\"KtTP.Sh\" resname=\"label.active\">\n <source>label.active</source>\n <target>Active</target>\n </trans-unit>\n <trans-unit id=\"iD6CNOO\" resname=\"label.roles\">\n <source>label.roles</source>\n <target>Role</target>\n </trans-unit>\n <trans-unit id=\"ZlZ20pG\" resname=\"user_permissions.title\">\n <source>user_permissions.title</source>\n <target>User permissions</target>\n </trans-unit>\n <trans-unit id=\"G.GEdlk\" resname=\"user_role.title\">\n <source>user_role.title</source>\n <target>User role</target>\n </trans-unit>\n <trans-unit id=\"E7G60OF\" resname=\"Allowed character: A-Z and _\">\n <source>Allowed character: A-Z and _</source>\n <target>Allowed character: A-Z and _</target>\n </trans-unit>\n <!--\n Admin: Plugins\n -->\n <trans-unit id=\"d75KAlJ\" resname=\"label.version\">\n <source>label.version</source>\n <target>Version</target>\n </trans-unit>\n <trans-unit id=\"8Rfa01v\" resname=\"label.required_version\">\n <source>label.required_version</source>\n <target>Compatible with</target>\n </trans-unit>\n <!--\n ROLES\n -->\n <trans-unit id=\"WRuKTcz\" resname=\"ROLE_SUPER_ADMIN\">\n <source>ROLE_SUPER_ADMIN</source>\n <target>System-Admin</target>\n </trans-unit>\n <trans-unit id=\"718iPw6\" resname=\"ROLE_ADMIN\">\n <source>ROLE_ADMIN</source>\n <target>Administrator</target>\n </trans-unit>\n <trans-unit id=\"yttGLAB\" resname=\"ROLE_TEAMLEAD\">\n <source>ROLE_TEAMLEAD</source>\n <target>Teamlead</target>\n </trans-unit>\n <trans-unit id=\"rvO5ZXf\" resname=\"ROLE_USER\">\n <source>ROLE_USER</source>\n <target>User</target>\n </trans-unit>\n <!--\n Statistics data for Dashboard & Users profile\n -->\n <trans-unit id=\"lfSTZGe\" resname=\"stats.workingTimeToday\">\n <source>stats.workingTimeToday</source>\n <target>Today, %day%</target>\n </trans-unit>\n <trans-unit id=\"XdYs3I8\" resname=\"stats.workingTimeWeek\">\n <source>stats.workingTimeWeek</source>\n <target>Calendar week %week%</target>\n </trans-unit>",
" <trans-unit id=\"HPhRbtc\" resname=\"stats.workingTimeWeekShort\">\n <source>stats.workingTimeWeekShort</source>\n <target>Week %week%</target>\n </trans-unit>",
" <trans-unit id=\"JIKNAYP\" resname=\"stats.workingTimeMonth\">\n <source>stats.workingTimeMonth</source>\n <target>%month% %year%</target>\n </trans-unit>\n <trans-unit id=\"JnUFsNi\" resname=\"stats.workingTimeYear\">\n <source>stats.workingTimeYear</source>\n <target>Full year %year%</target>\n </trans-unit>\n <trans-unit id=\"HWB4OGJ\" resname=\"stats.workingTimeFinancialYear\">\n <source>stats.workingTimeFinancialYear</source>\n <target>Financial year</target>\n </trans-unit>\n <trans-unit id=\"BXBFJP8\" resname=\"stats.workingTime\">\n <source>stats.workingTime</source>\n <target>Working time</target>\n </trans-unit>\n <trans-unit id=\"pX_3dNm\" resname=\"stats.revenue\">\n <source>stats.revenue</source>\n <target>Revenues</target>\n </trans-unit>\n <trans-unit id=\"TdBJBAl\" resname=\"stats.durationToday\">\n <source>stats.durationToday</source>\n <target>Working hours today</target>\n </trans-unit>\n <trans-unit id=\"XhKalZH\" resname=\"stats.durationWeek\">\n <source>stats.durationWeek</source>\n <target>Working hours this week</target>\n </trans-unit>\n <trans-unit id=\"uaOwf_P\" resname=\"stats.durationMonth\">\n <source>stats.durationMonth</source>\n <target>Working hours this month</target>\n </trans-unit>\n <trans-unit id=\"WqF84KR\" resname=\"stats.durationYear\">\n <source>stats.durationYear</source>\n <target>Working hours this year</target>\n </trans-unit>\n <trans-unit id=\"xkugSAA\" resname=\"stats.durationFinancialYear\">\n <source>stats.durationFinancialYear</source>\n <target>Working hours this financial year</target>\n </trans-unit>\n <trans-unit id=\"YtvPnl1\" resname=\"stats.durationTotal\">\n <source>stats.durationTotal</source>\n <target>Working hours total</target>\n </trans-unit>\n <trans-unit id=\"IFOLMgp\" resname=\"stats.yourWorkingHours\">\n <source>stats.yourWorkingHours</source>\n <target>My working hours</target>\n </trans-unit>\n <trans-unit id=\"023M9Ta\" resname=\"stats.amountToday\">\n <source>stats.amountToday</source>\n <target>Revenue today</target>\n </trans-unit>\n <trans-unit id=\"xnJvYAE\" resname=\"stats.amountWeek\">\n <source>stats.amountWeek</source>\n <target>Revenue this week</target>\n </trans-unit>\n <trans-unit id=\"ulr3reE\" resname=\"stats.amountMonth\">\n <source>stats.amountMonth</source>\n <target>Revenue this month</target>\n </trans-unit>\n <trans-unit id=\"bQZyZaO\" resname=\"stats.amountYear\">\n <source>stats.amountYear</source>\n <target>Revenue this year</target>\n </trans-unit>\n <trans-unit id=\"wuUWovn\" resname=\"stats.amountFinancialYear\">\n <source>stats.amountFinancialYear</source>\n <target>Revenue this financial year</target>\n </trans-unit>\n <trans-unit id=\"Z0fz23v\" resname=\"stats.amountTotal\">\n <source>stats.amountTotal</source>\n <target>Total revenue</target>\n </trans-unit>\n <trans-unit id=\"xyiadv3\" resname=\"stats.userActiveToday\">\n <source>stats.userActiveToday</source>\n <target>Active users today</target>\n </trans-unit>\n <trans-unit id=\"knMHaeO\" resname=\"stats.userActiveWeek\">\n <source>stats.userActiveWeek</source>\n <target>Active users this week</target>\n </trans-unit>\n <trans-unit id=\"adzVDgb\" resname=\"stats.userActiveMonth\">\n <source>stats.userActiveMonth</source>\n <target>Active users this month</target>\n </trans-unit>\n <trans-unit id=\"AswjFvh\" resname=\"stats.userActiveYear\">\n <source>stats.userActiveYear</source>\n <target>Active users this year</target>\n </trans-unit>\n <trans-unit id=\"zMY6gkY\" resname=\"stats.userActiveFinancialYear\">\n <source>stats.userActiveFinancialYear</source>\n <target>Active users this financial year</target>\n </trans-unit>\n <trans-unit id=\"dLTb1Po\" resname=\"stats.userActiveTotal\">\n <source>stats.userActiveTotal</source>\n <target>Active users ever</target>\n </trans-unit>\n <trans-unit id=\"lEW82ex\" resname=\"stats.activeRecordings\">\n <source>stats.activeRecordings</source>\n <target>Active records</target>\n </trans-unit>\n <trans-unit id=\"t5eIWp8\" resname=\"stats.userTotal\">\n <source>stats.userTotal</source>\n <target>Users</target>\n </trans-unit>\n <trans-unit id=\"Bor.76M\" resname=\"stats.activityTotal\">\n <source>stats.activityTotal</source>\n <target>Activities</target>\n </trans-unit>\n <trans-unit id=\"67uSaR3\" resname=\"stats.projectTotal\">\n <source>stats.projectTotal</source>\n <target>Projects</target>\n </trans-unit>\n <trans-unit id=\"tnD6aPj\" resname=\"stats.customerTotal\">\n <source>stats.customerTotal</source>\n <target>Customers</target>\n </trans-unit>\n <trans-unit id=\"unC5MXv\" resname=\"stats.percentUsed\">\n <source>stats.percentUsed</source>\n <target>%percent%% used</target>\n </trans-unit>\n <trans-unit id=\"HkjvwLc\" resname=\"stats.percentUsedLeft\">\n <source>stats.percentUsedLeft</source>\n <target>%percent%% used (%left% are still open)</target>\n </trans-unit>\n <trans-unit id=\"xN7MfSA\" resname=\"stats.percentUsed_month\">\n <source>stats.percentUsed_month</source>\n <target>%percent%% used this month</target>\n </trans-unit>\n <trans-unit id=\"vWJPpYU\" resname=\"stats.percentUsedLeft_month\">\n <source>stats.percentUsedLeft_month</source>\n <target>%percent%% used (%left% are still open this month)</target>\n </trans-unit>\n <!--\n Invoice\n -->\n <trans-unit id=\"Oq.KtC6\" resname=\"admin_invoice_template.title\">\n <source>admin_invoice_template.title</source>\n <target>Invoice template</target>\n </trans-unit>\n <trans-unit id=\"iERywrp\" resname=\"invoice.title\">\n <source>invoice.title</source>\n <target>Invoices</target>\n </trans-unit>\n <trans-unit id=\"ov4OQOh\" resname=\"invoice.filter\">\n <source>invoice.filter</source>\n <target>Filter invoice data</target>\n </trans-unit>\n <trans-unit id=\"7H7P1mE\" resname=\"button.preview\">\n <source>button.preview</source>\n <target>Preview</target>\n </trans-unit>\n <trans-unit id=\"IQ9DUOW\" resname=\"button.preview_print\">\n <source>button.preview_print</source>\n <target>Print preview</target>\n </trans-unit>\n <trans-unit id=\"X70dwP8\" resname=\"button.print\">\n <source>button.print</source>\n <target>Print</target>\n </trans-unit>\n <trans-unit id=\"W_TXvSi\" resname=\"button.csv\">\n <source>button.csv</source>\n <target>CSV</target>\n </trans-unit>\n <trans-unit id=\"vC2IsaP\" resname=\"button.xlsx\">\n <source>button.xlsx</source>\n <target>Excel</target>\n </trans-unit>\n <trans-unit id=\"aAa5uRR\" resname=\"button.pdf\">\n <source>button.pdf</source>\n <target>PDF</target>\n </trans-unit>\n <trans-unit id=\"ulYFDIo\" resname=\"button.ods\">\n <source>button.ods</source>\n <target>ODS</target>\n </trans-unit>\n <trans-unit id=\"zPcx3O_\" resname=\"invoice_print\">\n <source>invoice_print</source>\n <target>Invoice</target>\n </trans-unit>\n <trans-unit id=\"7J7G3Vr\" resname=\"label.mark_as_exported\">\n <source>label.mark_as_exported</source>\n <target>Mark as exported</target>\n </trans-unit>\n <trans-unit id=\"p0IprAw\" resname=\"label.template\">\n <source>label.template</source>\n <target>Template</target>\n </trans-unit>\n <trans-unit id=\"zfIRxJh\" resname=\"label.due_days\">\n <source>label.due_days</source>\n <target>Payment term in days</target>\n </trans-unit>\n <trans-unit id=\"rAJrxSK\" resname=\"invoice.due_days\">\n <source>invoice.due_days</source>\n <target>Payment target</target>\n </trans-unit>\n <trans-unit id=\"Xij3oQl\" resname=\"invoice.payment_date\">\n <source>invoice.payment_date</source>\n <target>Payment date</target>\n </trans-unit>\n <trans-unit id=\"4XKFnWh\" resname=\"invoice.from\">\n <source>invoice.from</source>\n <target>From</target>\n </trans-unit>\n <trans-unit id=\"hx7vsMA\" resname=\"invoice.to\">\n <source>invoice.to</source>\n <target>To</target>\n </trans-unit>\n <trans-unit id=\"x_W5sV4\" resname=\"invoice.number\">\n <source>invoice.number</source>\n <target>Invoice number</target>\n </trans-unit>\n <trans-unit id=\"86KyrKO\" resname=\"invoice.subtotal\">\n <source>invoice.subtotal</source>\n <target>Subtotal</target>\n </trans-unit>\n <trans-unit id=\"EO57yXg\" resname=\"invoice.tax\">\n <source>invoice.tax</source>\n <target>Tax</target>\n </trans-unit>\n <trans-unit id=\"N68vyvo\" resname=\"invoice.total\">\n <source>invoice.total</source>\n <target>Total</target>\n </trans-unit>\n <trans-unit id=\"TPzFWUs\" resname=\"invoice.service_date\">\n <source>invoice.service_date</source>\n <target>Service date</target>\n </trans-unit>\n <trans-unit id=\"6x24VVR\" resname=\"label.amount\">\n <source>label.amount</source>\n <target>Quantity</target>\n </trans-unit>\n <trans-unit id=\"g7EpaPY\" resname=\"label.total_rate\">\n <source>label.total_rate</source>\n <target>Total price</target>\n </trans-unit>\n <trans-unit id=\"MF3MdTu\" resname=\"label.unit_price\">\n <source>label.unit_price</source>\n <target>Unit price</target>\n </trans-unit>\n <trans-unit id=\"77aZC3r\" resname=\"label.payment_terms\">\n <source>label.payment_terms</source>\n <target>Terms of payment</target>\n </trans-unit>\n <trans-unit id=\"9p2KQag\" resname=\"invoice.signature_user\">\n <source>invoice.signature_user</source>\n <target>Confirmation: Date / Consultant's name / Signature</target>\n </trans-unit>\n <trans-unit id=\"Q9ykNhO\" resname=\"invoice.signature_customer\">\n <source>invoice.signature_customer</source>\n <target>Confirmation: Date / Customer's name / Signature</target>\n </trans-unit>\n <trans-unit id=\"c3d6p33\" resname=\"invoice.total_working_time\">\n <source>invoice.total_working_time</source>\n <target>Total duration</target>\n </trans-unit>\n <trans-unit id=\"BS00SS7\" resname=\"label.orderNumber\">\n <source>label.orderNumber</source>\n <target>Order number</target>\n </trans-unit>\n <trans-unit id=\"as948k9\" resname=\"label.orderDate\">\n <source>label.orderDate</source>\n <target>Order date</target>\n </trans-unit>\n <trans-unit id=\"RRj6PYN\" resname=\"label.invoice_tax_number\">\n <source>label.invoice_tax_number</source>\n <target>VAT no.:</target>\n </trans-unit>\n <trans-unit id=\"uFZA7Uf\" resname=\"label.invoice_bank_account\">\n <source>label.invoice_bank_account</source>\n <target>Bank account</target>\n </trans-unit>\n <trans-unit id=\"9VxfLLy\" resname=\"label.decimalDuration\">\n <source>label.decimalDuration</source>\n <target>Display duration as decimal number</target>\n </trans-unit>\n <trans-unit id=\"hzhzbqw\" resname=\"label.status\">\n <source>label.status</source>\n <target>Status</target>\n </trans-unit>\n <trans-unit id=\"X_NRsed\" resname=\"status.new\">\n <source>status.new</source>\n <target>New</target>\n </trans-unit>\n <trans-unit id=\"Uvo1CbP\" resname=\"status.pending\">\n <source>status.pending</source>\n <target>Pending</target>\n </trans-unit>\n <trans-unit id=\"PHJwR4w\" resname=\"status.paid\">\n <source>status.paid</source>\n <target>Paid</target>\n </trans-unit>\n <trans-unit id=\"gT9W2pZ\" resname=\"status.canceled\">\n <source>status.canceled</source>\n <target>Canceled</target>\n </trans-unit>\n <trans-unit id=\"crrlEUA\" resname=\"preview.skipped_rows\">\n <source>preview.skipped_rows</source>\n <target>Skipped preview of %rows% more rows …</target>\n </trans-unit>\n <!--\n Export\n -->\n <trans-unit id=\"F6Jmro7\" resname=\"export.title\">\n <source>export.title</source>\n <target>Export</target>\n </trans-unit>\n <trans-unit id=\"iwWaUoa\" resname=\"export.filter\">\n <source>export.filter</source>\n <target>Filter data for export</target>\n </trans-unit>\n <trans-unit id=\"vjmoQGo\" resname=\"export.period\">\n <source>export.period</source>\n <target>Period</target>\n </trans-unit>\n <trans-unit id=\"3CQ7A2m\" resname=\"export.document_title\">\n <source>export.document_title</source>\n <target>Export of timesheets</target>\n </trans-unit>\n <trans-unit id=\"d5wyWRD\" resname=\"export.full_list\">\n <source>export.full_list</source>\n <target>Full list</target>\n </trans-unit>\n <trans-unit id=\"N778uJ6\" resname=\"export.summary\">\n <source>export.summary</source>\n <target>Summary</target>\n </trans-unit>\n <trans-unit id=\"ElDyzrx\" resname=\"export.page_of\">\n <source>export.page_of</source>\n <target>Page %page% of %pages%</target>\n </trans-unit>\n <trans-unit id=\"vKY0tof\" resname=\"export.date_copyright\">\n <source>export.date_copyright</source>\n <target>Created %date% with %kimai%</target>\n </trans-unit>\n <trans-unit id=\"W92QGbY\" resname=\"export.warn_result_amount\">\n <source>export.warn_result_amount</source>\n <target>Your search leads to %count% results. If the export fails, you have to narrow down your search further.</target>\n </trans-unit>\n <trans-unit id=\"pnGDFmf\" resname=\"label.type\">\n <source>label.type</source>\n <target>Type</target>\n </trans-unit>\n <!--\n Navbar - recent entries and activities\n -->\n <trans-unit id=\"OxdYMR3\" resname=\"active.entries\">\n <source>active.entries</source>\n <target>Your active time measurements</target>\n </trans-unit>\n <trans-unit id=\"e7XS97t\" resname=\"timesheet.all\">\n <source>timesheet.all</source>\n <target>Show all records</target>\n </trans-unit>\n <trans-unit id=\"WVU_S.A\" resname=\"recent.activities\">\n <source>recent.activities</source>\n <target>Restart one of your last activities</target>\n </trans-unit>\n <trans-unit id=\"SLV47Uu\" resname=\"recent.activities.format\">\n <source>recent.activities.format</source>\n <target>%activity% in %project% for %customer%</target>\n </trans-unit>\n <trans-unit id=\"dTHY7Mw\" resname=\"timesheet.start\">\n <source>timesheet.start</source>\n <target>Create new time-record</target>\n </trans-unit>\n <!--\n TOOLBARS\n -->\n <trans-unit id=\"MPimOps\" resname=\"label.pageSize\">\n <source>label.pageSize</source>\n <target>Page size</target>\n </trans-unit>\n <trans-unit id=\"KhyA_PW\" resname=\"label.entryState\">\n <source>label.entryState</source>\n <target>Records</target>\n </trans-unit>\n <trans-unit id=\"X3JM9wj\" resname=\"label.exported\">\n <source>label.exported</source>\n <target>Exported</target>\n </trans-unit>\n <trans-unit id=\"_DDecAV\" resname=\"entryState.exported\">\n <source>entryState.exported</source>\n <target>Cleared</target>\n </trans-unit>\n <trans-unit id=\"ccCiXyR\" resname=\"entryState.not_exported\">\n <source>entryState.not_exported</source>\n <target>Open</target>\n </trans-unit>\n <trans-unit id=\"do7fP0q\" resname=\"entryState.all\">\n <source>entryState.all</source>\n <target>All</target>\n </trans-unit>\n <trans-unit id=\"xm7mqoK\" resname=\"entryState.running\">\n <source>entryState.running</source>\n <target>Active</target>\n </trans-unit>\n <trans-unit id=\"spHpd_I\" resname=\"entryState.stopped\">\n <source>entryState.stopped</source>\n <target>Stopped</target>\n </trans-unit>\n <trans-unit id=\"BhsaLxX\" resname=\"export.clear_all\">\n <source>export.clear_all</source>\n <target>Mark all shown records as open?</target>\n </trans-unit>\n <trans-unit id=\"qtjPKUT\" resname=\"export.mark_all\">\n <source>export.mark_all</source>\n <target>Mark all shown records as cleared?</target>\n </trans-unit>\n <trans-unit id=\"keE.KO.\" resname=\"Only global\">\n <source>Only global</source>\n <target state=\"needs-translation\">Only global</target>\n </trans-unit>\n <trans-unit id=\"2Ek7sXu\" resname=\"label.batch_meta_fields\">\n <source>label.batch_meta_fields</source>\n <target>Additional fields</target>\n </trans-unit>\n <trans-unit id=\"9Wt8Pp_\" resname=\"help.batch_meta_fields\">\n <source>help.batch_meta_fields</source>\n <target>Fields that are to be updated must first be activated by clicking on the associated checkbox.</target>\n </trans-unit>\n <trans-unit id=\"z_YHoZn\" resname=\"label.includeNoWork\">\n <source>label.includeNoWork</source>\n <target>Show entries without bookings</target>\n </trans-unit>\n <trans-unit id=\"B.Dbbob\" resname=\"label.includeNoBudget\">\n <source>label.includeNoBudget</source>\n <target>Show entries without budget</target>\n </trans-unit>\n <trans-unit id=\"Wq.h4nD\" resname=\"label.includeBudgetType_month\">\n <source>label.includeBudgetType_month</source>\n <target>Show entries with \"monthly\" budget</target>\n </trans-unit>\n <trans-unit id=\"nVulc7.\" resname=\"label.includeBudgetType_full\">\n <source>label.includeBudgetType_full</source>\n <target>Show entries with \"life cycle\" budget</target>\n </trans-unit>\n <trans-unit id=\"3zn5T5e\" resname=\"label.not_exported\">\n <source>label.not_exported</source>\n <target>Not exported</target>\n </trans-unit>\n <trans-unit id=\"csF1D35\" resname=\"label.not_invoiced\">\n <source>label.not_invoiced</source>\n <target>Not billed</target>\n </trans-unit>\n <trans-unit id=\"AJ6dwR.\" resname=\"label.last_record_before\">\n <source>label.last_record_before</source>\n <target>No time booking since</target>\n </trans-unit>\n <trans-unit id=\"qDnURk7\" resname=\"label.last_record\">\n <source>label.last_record</source>\n <target>Last entry</target>\n </trans-unit>\n <trans-unit id=\"LXdqaTH\" resname=\"label.account_number\">\n <source>label.account_number</source>\n <target>Staff number</target>\n </trans-unit>\n <trans-unit id=\"PoF7hD8\" resname=\"label.budgetType\">\n <source>label.budgetType</source>\n <target>Budget-Type</target>\n </trans-unit>\n <trans-unit id=\"cHfLJtL\" resname=\"label.budgetType_month\">\n <source>label.budgetType_month</source>\n <target>Monthly</target>\n </trans-unit>\n <trans-unit id=\"9Rhadz6\" resname=\"label.budgetType_full\">\n <source>label.budgetType_full</source>\n <target>Life cycle</target>\n </trans-unit>\n <trans-unit id=\"tvV0NhL\" resname=\"delete_warning.short_stats\">\n <source>delete_warning.short_stats</source>\n <target>Currently %records% time-records exists, which sum up to a total duration of %duration%.</target>\n </trans-unit>\n <trans-unit id=\"Zif614Q\" resname=\"add_user.label\">\n <source>add_user.label</source>\n <target>Add user</target>\n </trans-unit>\n <trans-unit id=\"tp.gIrE\" resname=\"team.add_user.help\">\n <source>team.add_user.help</source>\n <target>Add a new user to the team by selecting it from the list. Afterwards you can decide if the user should become a teamlead.</target>\n </trans-unit>\n <trans-unit id=\"yNWIi5U\" resname=\"default_value_new\">\n <source>default_value_new</source>\n <target>Default values for new entries</target>\n </trans-unit>\n <!--\n QUICK ENTRIES\n -->\n <trans-unit id=\"f8oNzSP\" resname=\"quick_entry.title\">\n <source>quick_entry.title</source>\n <target>Weekly working hours</target>\n </trans-unit>\n <trans-unit id=\"61p_ckr\" resname=\"label.hours_24\">\n <source>label.hours_24</source>\n <target>24 hours</target>\n </trans-unit>\n </body>\n </file>\n</xliff>"
] |
[
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [25, 429, 89, 616, 106, 201, 43, 77, 38, 45, 94, 55, 37, 65, 51, 48, 31, 165, 10, 10, 10, 10, 427, 36, 226, 215, 732, 452, 32, 56, 56, 56, 56, 56, 56, 794, 794], "buggy_code_start_loc": [20, 424, 24, 214, 23, 30, 42, 76, 37, 25, 40, 36, 26, 25, 28, 47, 31, 161, 9, 9, 9, 9, 427, 36, 219, 209, 711, 431, 1, 1, 56, 56, 56, 56, 56, 794, 794], "filenames": ["src/Constants.php", "src/Controller/ProjectController.php", "src/Controller/TeamController.php", "src/Controller/TimesheetAbstractController.php", "src/Controller/TimesheetController.php", "src/Controller/TimesheetTeamController.php", "src/EventSubscriber/Actions/AbstractTimesheetSubscriber.php", "src/EventSubscriber/Actions/ProjectSubscriber.php", "src/EventSubscriber/Actions/TeamSubscriber.php", "src/Migrations/Version20180701120000.php", "src/Migrations/Version20180715160326.php", "src/Migrations/Version20180730044139.php", "src/Migrations/Version20180924111853.php", "src/Migrations/Version20181031220003.php", "src/Migrations/Version20190305152308.php", "src/Migrations/Version20210802152814.php", "src/Migrations/Version20211008092010.php", "templates/form/kimai-theme.html.twig", "templates/project/actions.html.twig", "templates/team/actions.html.twig", "templates/timesheet-team/actions.html.twig", "templates/timesheet/actions.html.twig", "tests/Controller/ControllerBaseTest.php", "tests/Controller/DoctorControllerTest.php", "tests/Controller/ProjectControllerTest.php", "tests/Controller/TeamControllerTest.php", "tests/Controller/TimesheetControllerTest.php", "tests/Controller/TimesheetTeamControllerTest.php", "translations/about.ja.xlf", "translations/flashmessages.el.xlf", "translations/flashmessages.fr.xlf", "translations/flashmessages.he.xlf", "translations/flashmessages.pt.xlf", "translations/flashmessages.pt_BR.xlf", "translations/flashmessages.tr.xlf", "translations/messages.de.xlf", "translations/messages.en.xlf"], "fixing_code_end_loc": [25, 440, 99, 616, 116, 211, 43, 77, 38, 37, 90, 48, 33, 55, 40, 48, 34, 163, 10, 10, 10, 10, 438, 44, 248, 225, 764, 484, 32, 61, 61, 61, 61, 61, 61, 799, 799], "fixing_code_start_loc": [20, 424, 25, 214, 24, 31, 42, 76, 37, 25, 39, 36, 26, 24, 28, 47, 32, 161, 9, 9, 9, 9, 428, 37, 219, 209, 711, 431, 1, 1, 57, 57, 57, 57, 57, 795, 795], "message": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:kimai:kimai_2:*:*:*:*:*:*:*:*", "matchCriteriaId": "18DE946F-C2DA-4605-B44E-49B5DC42961C", "versionEndExcluding": "1.16.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "kimai2 is vulnerable to Cross-Site Request Forgery (CSRF)"}, {"lang": "es", "value": "kimai2 es vulnerable a un ataque de tipo Cross-Site Request Forgery (CSRF)"}], "evaluatorComment": null, "id": "CVE-2021-3976", "lastModified": "2021-11-23T17:25:49.577", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.0"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2021-11-19T11:15:07.880", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/0567048a-118c-42ec-9f94-b55533017406"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-352"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/kevinpapst/kimai2/commit/b28e9c120c87222e21a238f1b03a609d6a5d506e"}, "type": "CWE-352"}
| 211
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/* radare - LGPL - Copyright 2019-2022 - GustavoLCR */",
"#include \"ne.h\"\n#define NE_BUG 0",
"static char *__get_target_os(r_bin_ne_obj_t *bin) {\n\tswitch (bin->ne_header->targOS) {\n\tcase 1:\n\t\treturn \"OS/2\";\n\tcase 2:\n\t\treturn \"Windows\";\n\tcase 3:\n\t\treturn \"European MS-DOS 4.x\";\n\tcase 4:\n\t\treturn \"Windows 386\";\n\tcase 5:\n\t\treturn \"BOSS (Borland Operating System Services)\";\n\tdefault:\n\t\treturn \"Unknown\";\n\t}\n}",
"static int __translate_perms(int flags) {\n\tint perms = 0;\n\tif (flags & IS_RX) {\n\t\tif (flags & IS_DATA) {\n\t\t\tperms = R_PERM_R;\n\t\t} else {\n\t\t\tperms = R_PERM_X;\n\t\t}\n\t}\n\tif (!perms) {\n\t\tperms = R_PERM_RWX;\n\t}\n\treturn perms;\n}",
"static char *__read_nonnull_str_at(RBuffer *buf, ut64 offset) {\n\tut8 sz = r_buf_read8_at (buf, offset);\n\tif (!sz) {\n\t\treturn NULL;\n\t}\n\tchar *str = malloc ((ut64)sz + 1);\n\tif (!str) {\n\t\treturn NULL;\n\t}\n\tr_buf_read_at (buf, offset + 1, (ut8 *)str, sz);\n\tstr[sz] = '\\0';\n\treturn str;\n}",
"static char *__func_name_from_ord(const char *module, ut16 ordinal) {\n\tif (!module) {\n\t\treturn NULL;\n\t}\n\tchar *lower_module = strdup (module);\n\tr_str_case (lower_module, false);\n\tchar *path = r_str_newf (R_JOIN_4_PATHS (\"%s\", R2_SDB_FORMAT, \"dll\", \"%s.sdb\"), r_sys_prefix (NULL), lower_module);\n\tfree (lower_module);\n\tchar *ord = r_str_newf (\"%d\", ordinal);\n\tchar *name;\n\tif (r_file_exists (path)) {\n\t\tSdb *sdb = sdb_new (NULL, path, 0);\n\t\tname = sdb_get (sdb, ord, NULL);\n\t\tif (!name) {\n\t\t\tname = ord;\n\t\t} else {\n\t\t\tfree (ord);\n\t\t}\n\t\tsdb_close (sdb);\n\t\tfree (sdb);\n\t} else {\n\t\tname = ord;\n\t}\n\tfree (path);\n\treturn name;\n}",
"RList *r_bin_ne_get_segments(r_bin_ne_obj_t *bin) {\n\tint i;\n\tif (!bin) {\n\t\treturn NULL;\n\t}\n\tRList *segments = r_list_newf (free);\n\tfor (i = 0; i < bin->ne_header->SegCount; i++) {\n\t\tRBinSection *bs = R_NEW0 (RBinSection);\n\t\tif (!bs) {\n\t\t\treturn segments;\n\t\t}\n\t\tNE_image_segment_entry *se = &bin->segment_entries[i];\n\t\tbs->size = se->length;\n\t\tbs->vsize = se->minAllocSz ? se->minAllocSz : 64000;\n\t\tbs->bits = R_SYS_BITS_16;\n\t\tbs->is_data = se->flags & IS_DATA;\n\t\tbs->perm = __translate_perms (se->flags);\n\t\tbs->paddr = (ut64)se->offset * bin->alignment;\n\t\tbs->name = r_str_newf (\"%s.%\" PFMT64d, se->flags & IS_MOVEABLE ? \"MOVEABLE\" : \"FIXED\", bs->paddr);\n\t\tbs->is_segment = true;\n\t\tr_list_append (segments, bs);\n\t}\n\tbin->segments = segments;\n\treturn segments;\n}",
"static int __find_symbol_by_paddr(const void *paddr, const void *sym) {\n\treturn (int)!(*(ut64 *)paddr == ((RBinSymbol *)sym)->paddr);\n}",
"RList *r_bin_ne_get_symbols(r_bin_ne_obj_t *bin) {\n\tRBinSymbol *sym;\n\tut16 off = bin->ne_header->ResidNamTable + bin->header_offset;\n\tRList *symbols = r_list_newf (free);\n\tif (!symbols) {\n\t\treturn NULL;\n\t}\n\tRList *entries = r_bin_ne_get_entrypoints (bin);\n\tbool resident = true, first = true;",
"\twhile (true) {",
"\t\tut8 sz = r_buf_read8_at (bin->buf, off);\n\t\tif (!sz) {\n\t\t\tfirst = true;\n\t\t\tif (resident) {\n\t\t\t\tresident = false;\n\t\t\t\toff = bin->ne_header->OffStartNonResTab;\n\t\t\t\tsz = r_buf_read8_at (bin->buf, off);\n\t\t\t\tif (!sz) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tchar *name = malloc ((ut64)sz + 1);\n\t\tif (!name) {\n\t\t\tbreak;\n\t\t}\n\t\toff++;\n\t\tr_buf_read_at (bin->buf, off, (ut8 *)name, sz);\n\t\tname[sz] = '\\0';\n\t\toff += sz;\n\t\tsym = R_NEW0 (RBinSymbol);\n\t\tif (!sym) {\n\t\t\tbreak;\n\t\t}\n\t\tsym->name = name;\n\t\tif (!first) {\n\t\t\tsym->bind = R_BIN_BIND_GLOBAL_STR;\n\t\t}\n\t\tut16 entry_off = r_buf_read_le16_at (bin->buf, off);\n\t\toff += 2;\n\t\tRBinAddr *entry = r_list_get_n (entries, entry_off);\n\t\tif (entry) {\n\t\t\tsym->paddr = entry->paddr;\n\t\t} else {\n\t\t\tsym->paddr = -1;\n\t\t}\n\t\tsym->ordinal = entry_off;\n\t\tr_list_append (symbols, sym);\n\t\tfirst = false;\n\t}\n\tRListIter *it;\n\tRBinAddr *en;\n\tint i = 1;\n\tr_list_foreach (entries, it, en) {\n\t\tif (!r_list_find (symbols, &en->paddr, __find_symbol_by_paddr)) {\n\t\t\tsym = R_NEW0 (RBinSymbol);\n\t\t\tif (!sym) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsym->name = r_str_newf (\"entry%d\", i - 1);\n\t\t\tsym->paddr = en->paddr;\n\t\t\tsym->bind = R_BIN_BIND_GLOBAL_STR;\n\t\t\tsym->ordinal = i;\n\t\t\tr_list_append (symbols, sym);\n\t\t}\n\t\ti++;\n\t}\n\tbin->symbols = symbols;\n\treturn symbols;\n}",
"static char *__resource_type_str(int type) {\n\tchar *typeName;\n\tswitch (type) {\n\tcase 1:\n\t\ttypeName = \"CURSOR\";\n\t\tbreak;\n\tcase 2:\n\t\ttypeName = \"BITMAP\";\n\t\tbreak;\n\tcase 3:\n\t\ttypeName = \"ICON\";\n\t\tbreak;\n\tcase 4:\n\t\ttypeName = \"MENU\";\n\t\tbreak;\n\tcase 5:\n\t\ttypeName = \"DIALOG\";\n\t\tbreak;\n\tcase 6:\n\t\ttypeName = \"STRING\";\n\t\tbreak;\n\tcase 7:\n\t\ttypeName = \"FONTDIR\";\n\t\tbreak;\n\tcase 8:\n\t\ttypeName = \"FONT\";\n\t\tbreak;\n\tcase 9:\n\t\ttypeName = \"ACCELERATOR\";\n\t\tbreak;\n\tcase 10:\n\t\ttypeName = \"RCDATA\";\n\t\tbreak;\n\tcase 11:\n\t\ttypeName = \"MESSAGETABLE\";\n\t\tbreak;\n\tcase 12:\n\t\ttypeName = \"GROUP_CURSOR\";\n\t\tbreak;\n\tcase 14:\n\t\ttypeName = \"GROUP_ICON\";\n\t\tbreak;\n\tcase 15:\n\t\ttypeName = \"NAMETABLE\";\n\t\tbreak;\n\tcase 16:\n\t\ttypeName = \"VERSION\";\n\t\tbreak;\n\tcase 17:\n\t\ttypeName = \"DLGINCLUDE\";\n\t\tbreak;\n\tcase 19:\n\t\ttypeName = \"PLUGPLAY\";\n\t\tbreak;\n\tcase 20:\n\t\ttypeName = \"VXD\";\n\t\tbreak;\n\tcase 21:\n\t\ttypeName = \"ANICURSOR\";\n\t\tbreak;\n\tcase 22:\n\t\ttypeName = \"ANIICON\";\n\t\tbreak;\n\tcase 23:\n\t\ttypeName = \"HTML\";\n\t\tbreak;\n\tcase 24:\n\t\ttypeName = \"MANIFEST\";\n\t\tbreak;\n\tdefault:\n\t\treturn r_str_newf (\"UNKNOWN (%d)\", type);\n\t}\n\treturn strdup (typeName);\n}",
"static void __free_resource_entry(void *entry) {\n\tr_ne_resource_entry *en = (r_ne_resource_entry *)entry;\n\tfree (en->name);\n\tfree (en);\n}",
"static void __free_resource(void *resource) {\n\tr_ne_resource *res = (r_ne_resource *)resource;\n\tfree (res->name);\n\tr_list_free (res->entry);\n\tfree (res);\n}",
"static bool __ne_get_resources(r_bin_ne_obj_t *bin) {\n\tif (!bin->resources) {\n\t\tbin->resources = r_list_newf (__free_resource);\n\t}\n\tut16 resoff = bin->ne_header->ResTableOffset + bin->header_offset;\n\tut16 alignment = r_buf_read_le16_at (bin->buf, resoff);\n\tut32 off = resoff + 2;\n\twhile (true) {\n\t\tNE_image_typeinfo_entry ti = {0};\n\t\tr_ne_resource *res = R_NEW0 (r_ne_resource);\n\t\tif (!res) {\n\t\t\tbreak;\n\t\t}\n\t\tres->entry = r_list_newf (__free_resource_entry);\n\t\tif (!res->entry) {\n\t\t\tbreak;\n\t\t}\n\t\tr_buf_read_at (bin->buf, off, (ut8 *)&ti, sizeof (ti));\n\t\tif (!ti.rtTypeID) {\n\t\t\tbreak;\n\t\t} else if (ti.rtTypeID & 0x8000) {\n\t\t\tres->name = __resource_type_str (ti.rtTypeID & ~0x8000);\n\t\t} else {\n\t\t\t// Offset to resident name table\n\t\t\tres->name = __read_nonnull_str_at (bin->buf, (ut64)resoff + ti.rtTypeID);\n\t\t}\n\t\toff += sizeof (NE_image_typeinfo_entry);\n\t\tint i;\n\t\tfor (i = 0; i < ti.rtResourceCount; i++) {\n\t\t\tNE_image_nameinfo_entry ni;\n\t\t\tr_ne_resource_entry *ren = R_NEW0 (r_ne_resource_entry);\n\t\t\tif (!ren) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tr_buf_read_at (bin->buf, off, (ut8 *)&ni, sizeof (NE_image_nameinfo_entry));\n\t\t\tren->offset = ni.rnOffset << alignment;\n\t\t\tren->size = ni.rnLength;\n\t\t\tif (ni.rnID & 0x8000) {\n\t\t\t\tren->name = r_str_newf (\"%d\", ni.rnID & ~0x8000);\n\t\t\t} else {\n\t\t\t\t// Offset to resident name table\n\t\t\t\tren->name = __read_nonnull_str_at (bin->buf, (ut64)resoff + ni.rnID);\n\t\t\t}\n\t\t\tr_list_append (res->entry, ren);\n\t\t\toff += sizeof (NE_image_nameinfo_entry);\n\t\t}\n\t\tr_list_append (bin->resources, res);\n\t}\n\treturn true;\n}",
"RList *r_bin_ne_get_imports(r_bin_ne_obj_t *bin) {\n\tRList *imports = r_list_newf ((RListFree)r_bin_import_free);\n\tif (!imports) {\n\t\treturn NULL;\n\t}\n\tut16 off = bin->ne_header->ImportNameTable + bin->header_offset + 1;\n\tint i;\n\tfor (i = 0; i < bin->ne_header->ModRefs; i++) {\n\t\tRBinImport *imp = R_NEW0 (RBinImport);\n\t\tif (!imp) {\n\t\t\tbreak;\n\t\t}\n\t\tut8 sz = r_buf_read8_at (bin->buf, off);\n\t\tif (!sz) {\n\t\t\tr_bin_import_free (imp);\n\t\t\tbreak;\n\t\t}\n\t\toff++;\n\t\tchar *name = malloc ((ut64)sz + 1);\n\t\tif (!name) {\n\t\t\tbreak;\n\t\t}\n\t\tr_buf_read_at (bin->buf, off, (ut8 *)name, sz);\n\t\tname[sz] = '\\0';\n\t\timp->name = name;\n\t\timp->ordinal = i + 1;\n\t\tr_list_append (imports, imp);\n\t\toff += sz;\n\t}\n\tbin->imports = imports;\n\treturn imports;\n}",
"RList *r_bin_ne_get_entrypoints(r_bin_ne_obj_t *bin) {",
"",
"\tRList *entries = r_list_newf (free);\n\tif (!entries) {\n\t\treturn NULL;\n\t}\n\tRList *segments = r_bin_ne_get_segments (bin);\n\tif (!segments) {\n\t\tr_list_free (entries);\n\t\treturn NULL;\n\t}\n\tif (bin->ne_header->csEntryPoint) {\n\t\tRBinAddr *entry = R_NEW0 (RBinAddr);\n\t\tif (!entry) {\n\t\t\tr_list_free (entries);\n\t\t\treturn NULL;\n\t\t}\n\t\tentry->bits = 16;\n\t\tut32 entry_cs = bin->ne_header->csEntryPoint;\n\t\tRBinSection *s = r_list_get_n (segments, entry_cs - 1);\n\t\tentry->paddr = bin->ne_header->ipEntryPoint + (s? s->paddr: 0);",
"\t\tr_list_append (entries, entry);\n\t}\n\tint off = 0;\n\tsize_t tableat = bin->header_offset + bin->ne_header->EntryTableOffset;\n\twhile (off < bin->ne_header->EntryTableLength) {\n\t\tif (tableat + off >= r_buf_size (bin->buf)) {\n\t\t\tbreak;\n\t\t}\n\t\tut8 bundle_length = *(ut8 *)(bin->entry_table + off);\n\t\tif (!bundle_length) {\n\t\t\tbreak;\n\t\t}\n\t\toff++;\n\t\tut8 bundle_type = *(ut8 *)(bin->entry_table + off);\n\t\toff++;\n\t\tint i;\n\t\tfor (i = 0; i < bundle_length; i++) {\n\t\t\tif (tableat + off + 4 >= r_buf_size (bin->buf)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tRBinAddr *entry = R_NEW0 (RBinAddr);\n\t\t\tif (!entry) {\n\t\t\t\tr_list_free (entries);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\toff++;\n\t\t\tif (!bundle_type) { // Skip\n\t\t\t\toff--;\n\t\t\t\tfree (entry);\n\t\t\t\tbreak;\n\t\t\t} else if (bundle_type == 0xff) { // moveable\n\t\t\t\toff += 2;\n\t\t\t\tut8 segnum = *(bin->entry_table + off);\n\t\t\t\toff++;\n\t\t\t\tut16 segoff = *(ut16 *)(bin->entry_table + off);\n\t\t\t\tif (segnum > 0) {\n\t\t\t\t\tentry->paddr = (ut64)bin->segment_entries[segnum - 1].offset * bin->alignment + segoff;\n\t\t\t\t}\n\t\t\t} else { // Fixed\n\t\t\t\tif (bundle_type < bin->ne_header->SegCount) {\n\t\t\t\t\tentry->paddr = (ut64)bin->segment_entries[bundle_type - 1].offset\n\t\t\t\t\t\t* bin->alignment + *(ut16 *)(bin->entry_table + off);\n\t\t\t\t}\n\t\t\t}\n\t\t\toff += 2;\n\t\t\tr_list_append (entries, entry);\n\t\t}\n\t}\n\tr_list_free (segments);\n\tbin->entries = entries;\n\treturn entries;\n}",
"RList *r_bin_ne_get_relocs(r_bin_ne_obj_t *bin) {\n\tRList *segments = bin->segments;\n\tif (!segments) {\n\t\treturn NULL;\n\t}\n\tRList *entries = bin->entries;\n\tif (!entries) {\n\t\treturn NULL;\n\t}\n\tRList *symbols = bin->symbols;\n\tif (!symbols) {\n\t\treturn NULL;\n\t}",
"\tut16 *modref = calloc (bin->ne_header->ModRefs, sizeof (ut16));\n\tif (!modref) {\n\t\treturn NULL;\n\t}\n\tr_buf_read_at (bin->buf, (ut64)bin->ne_header->ModRefTable + bin->header_offset, (ut8 *)modref, bin->ne_header->ModRefs * sizeof (ut16));",
"\tRList *relocs = r_list_newf (free);\n\tif (!relocs) {\n\t\tfree (modref);\n\t\treturn NULL;\n\t}",
"\tRListIter *it;\n\tRBinSection *seg;\n\tint index = -1;\n\tr_list_foreach (segments, it, seg) {\n\t\tindex++;\n\t\tif (!(bin->segment_entries[index].flags & RELOCINFO)) {\n\t\t\tcontinue;\n\t\t}\n\t\tut32 off = seg->paddr + seg->size;\n\t\tut32 start = off;\n\t\tut16 length = r_buf_read_le16_at (bin->buf, off);\n\t\tif (!length) {\n\t\t\tcontinue;\n\t\t}\n\t\toff += 2;\n\t\t// size_t buf_size = r_buf_size (bin->buf);\n\t\twhile (off < start + length * sizeof (NE_image_reloc_item)) {\n\t\t\t// && off + sizeof (NE_image_reloc_item) < buf_size)\n\t\t\tNE_image_reloc_item rel = {0};\n\t\t\tif (r_buf_read_at (bin->buf, off, (ut8 *)&rel, sizeof (rel)) < 1) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tRBinReloc *reloc = R_NEW0 (RBinReloc);\n\t\t\tif (!reloc) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\treloc->paddr = seg->paddr + rel.offset;\n\t\t\tswitch (rel.type) {\n\t\t\tcase LOBYTE:\n\t\t\t\treloc->type = R_BIN_RELOC_8;\n\t\t\t\tbreak;\n\t\t\tcase SEL_16:\n\t\t\tcase OFF_16:\n\t\t\t\treloc->type = R_BIN_RELOC_16;\n\t\t\t\tbreak;\n\t\t\tcase POI_32:\n\t\t\tcase OFF_32:\n\t\t\t\treloc->type = R_BIN_RELOC_32;\n\t\t\t\tbreak;\n\t\t\tcase POI_48:\n\t\t\t\treloc->type = R_BIN_RELOC_64;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tut32 offset;\n\t\t\tif (rel.flags & (IMPORTED_ORD | IMPORTED_NAME)) {\n\t\t\t\tRBinImport *imp = R_NEW0 (RBinImport);\n\t\t\t\tif (!imp) {\n\t\t\t\t\tfree (reloc);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tchar *name;\n#if NE_BUG\n\t\t\t\tif (rel.index > 0 && rel.index < bin->ne_header->ModRefs) {\n\t\t\t\t\toffset = modref[rel.index - 1] + bin->header_offset + bin->ne_header->ImportNameTable;\n\t\t\t\t\tname = __read_nonnull_str_at (bin->buf, offset);\n\t\t\t\t} else {\n\t\t\t\t\tname = r_str_newf (\"UnknownModule%d_%x\", rel.index, off); // ????\n\t\t\t\t}\n#else\n\t\t\t\tif (rel.index > bin->ne_header->ModRefs) {\n\t\t\t\t\tname = r_str_newf (\"UnknownModule%d_%x\", rel.index, off); // ????\n\t\t\t\t} else {\n\t\t\t\t\toffset = modref[rel.index - 1] + bin->header_offset + bin->ne_header->ImportNameTable;\n\t\t\t\t\tname = __read_nonnull_str_at (bin->buf, offset);\n\t\t\t\t}\n#endif\n\t\t\t\tif (rel.flags & IMPORTED_ORD) {\n\t\t\t\t\timp->ordinal = rel.func_ord;\n\t\t\t\t\timp->name = r_str_newf (\"%s.%s\", name, __func_name_from_ord(name, rel.func_ord));\n\t\t\t\t} else {\n\t\t\t\t\toffset = bin->header_offset + bin->ne_header->ImportNameTable + rel.name_off;\n\t\t\t\t\tchar *func = __read_nonnull_str_at (bin->buf, offset);\n\t\t\t\t\timp->name = r_str_newf (\"%s.%s\", name, func);\n\t\t\t\t\tfree (func);\n\t\t\t\t}\n\t\t\t\tfree (name);\n\t\t\t\treloc->import = imp;\n\t\t\t} else if (rel.flags & OSFIXUP) {\n\t\t\t\t// TODO\n\t\t\t} else {\n\t\t\t\tif (strstr (seg->name, \"FIXED\")) {\n\t\t\t\t\tRBinSection *s = r_list_get_n (segments, rel.segnum - 1);\n\t\t\t\t\tif (s) {\n\t\t\t\t\t\toffset = s->paddr + rel.segoff;\n\t\t\t\t\t} else {\n\t\t\t\t\t\toffset = -1;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tRBinAddr *entry = r_list_get_n (entries, rel.entry_ordinal - 1);\n\t\t\t\t\tif (entry) {\n\t\t\t\t\t\toffset = entry->paddr;\n\t\t\t\t\t} else {\n\t\t\t\t\t\toffset = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treloc->addend = offset;\n\t\t\t\tRBinSymbol *sym = NULL;\n\t\t\t\tRListIter *sit;\n\t\t\t\tr_list_foreach (symbols, sit, sym) {\n\t\t\t\t\tif (sym->paddr == reloc->addend) {\n\t\t\t\t\t\treloc->symbol = sym;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"\t\t\tif (rel.flags & ADDITIVE) {\n\t\t\t\treloc->additive = 1;\n\t\t\t\tr_list_append (relocs, reloc);\n\t\t\t} else {\n\t\t\t\tdo {\n#if NE_BUG\n\t\t\t\t\tif (reloc->paddr + 4 < r_buf_size (bin->buf)) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n#endif\n\t\t\t\t\tr_list_append (relocs, reloc);\n\t\t\t\t\toffset = r_buf_read_le16_at (bin->buf, reloc->paddr);\n\t\t\t\t\tRBinReloc *tmp = reloc;\n\t\t\t\t\treloc = R_NEW0 (RBinReloc);\n\t\t\t\t\tif (!reloc) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t*reloc = *tmp;\n\t\t\t\t\treloc->paddr = seg->paddr + offset;\n\t\t\t\t} while (offset != 0xFFFF);\n\t\t\t\tfree (reloc);\n\t\t\t}",
"\t\t\toff += sizeof (NE_image_reloc_item);\n\t\t}\n\t}\n\tfree (modref);\n\treturn relocs;\n}",
"void __init(RBuffer *buf, r_bin_ne_obj_t *bin) {\n\tbin->header_offset = r_buf_read_le16_at (buf, 0x3c);\n\tbin->ne_header = R_NEW0 (NE_image_header);\n\tif (!bin->ne_header) {\n\t\treturn;\n\t}\n\tbin->buf = buf;\n\t// XXX this is endian unsafe\n\tif (r_buf_read_at (buf, bin->header_offset, (ut8 *)bin->ne_header, sizeof (NE_image_header)) < 1) {\n\t\tR_FREE (bin->ne_header);\n\t\treturn;\n\t}\n\tif (bin->ne_header->FileAlnSzShftCnt > 15) {\n\t\tbin->ne_header->FileAlnSzShftCnt = 15;\n\t}\n\tut64 from = bin->ne_header->ModRefTable + bin->header_offset;\n\tut64 left = r_buf_size (bin->buf) - from;\n\tif (from + bin->ne_header->ModRefs * sizeof (ut16) >= left) {\n\t\tbin->ne_header->ModRefs = left / sizeof (ut16);\n\t}\n\tbin->alignment = 1 << bin->ne_header->FileAlnSzShftCnt;\n\tif (!bin->alignment) {\n\t\tbin->alignment = 1 << 9;\n\t}\n\tbin->os = __get_target_os (bin);",
"\tut16 offset = bin->ne_header->SegTableOffset + bin->header_offset;\n\tsize_t size = bin->ne_header->SegCount * sizeof (NE_image_segment_entry);\n\tif (offset >= r_buf_size (bin->buf)) {\n\t\treturn;\n\t}\n\tsize_t remaining = r_buf_size (bin->buf) - offset;\n\tsize = R_MIN (remaining, size);\n\tbin->ne_header->SegCount = size / sizeof (NE_image_segment_entry); // * sizeof (NE_image_segment_entry);\n\tbin->segment_entries = calloc (1, size);\n\tif (size >= remaining) {\n\t\tbin->ne_header->SegCount = size / sizeof (NE_image_segment_entry);\n\t}\n\tif (!bin->segment_entries) {\n\t\treturn;\n\t}\n\tr_buf_read_at (buf, offset, (ut8 *)bin->segment_entries, size);\n\tbin->entry_table = calloc (4, bin->ne_header->EntryTableLength);\n\tif (!bin->entry_table) {\n\t\tR_FREE (bin->segment_entries);\n\t\treturn;\n\t}\n\tr_buf_read_at (buf, (ut64)bin->header_offset + bin->ne_header->EntryTableOffset, bin->entry_table, bin->ne_header->EntryTableLength);\n\tbin->imports = r_bin_ne_get_imports (bin);\n\t__ne_get_resources (bin);\n}",
"void r_bin_ne_free(r_bin_ne_obj_t *bin) {\n\t// r_list_free (bin->imports); // double free\n\tr_list_free (bin->resources);\n\tfree (bin->entry_table);\n\tfree (bin->ne_header);\n\tfree (bin->resident_name_table);\n\tfree (bin->segment_entries);\n\tfree (bin);\n}",
"r_bin_ne_obj_t *r_bin_ne_new_buf(RBuffer *buf, bool verbose) {\n\tr_bin_ne_obj_t *bin = R_NEW0 (r_bin_ne_obj_t);\n\tif (!bin) {\n\t\treturn NULL;\n\t}\n\t__init(buf, bin);\n\treturn bin;\n}"
] |
[
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
] |
PreciseBugs
|
{"buggy_code_end_loc": [354], "buggy_code_start_loc": [118], "filenames": ["libr/bin/format/ne/ne.c"], "fixing_code_end_loc": [358], "fixing_code_start_loc": [118], "message": "NULL Pointer Dereference in r_bin_ne_get_entrypoints function in GitHub repository radareorg/radare2 prior to 5.6.8. This vulnerability allows attackers to cause a denial of service (application crash).", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:radare:radare2:*:*:*:*:*:*:*:*", "matchCriteriaId": "8956009B-4EDA-4AA6-997D-B2C8C5D05CEC", "versionEndExcluding": "5.6.8", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "NULL Pointer Dereference in r_bin_ne_get_entrypoints function in GitHub repository radareorg/radare2 prior to 5.6.8. This vulnerability allows attackers to cause a denial of service (application crash)."}, {"lang": "es", "value": "Un Desreferencia de Puntero NULL en la funci\u00f3n r_bin_ne_get_entrypoints en el repositorio de GitHub radareorg/radare2 versiones anteriores a 5.6.8. Esta vulnerabilidad permite a atacantes causar una denegaci\u00f3n de servicio (bloqueo de la aplicaci\u00f3n)"}], "evaluatorComment": null, "id": "CVE-2022-1283", "lastModified": "2022-04-15T15:28:01.770", "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": true}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 6.6, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:H", "version": "3.0"}, "exploitabilityScore": 1.8, "impactScore": 4.7, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-04-08T18:15:09.703", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/radareorg/radare2/commit/18d1d064bf599a255d55f09fca3104776fc34a67"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/bfeb8fb8-644d-4587-80d4-cb704c404013"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-476"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/radareorg/radare2/commit/18d1d064bf599a255d55f09fca3104776fc34a67"}, "type": "CWE-476"}
| 212
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/* radare - LGPL - Copyright 2019-2022 - GustavoLCR */",
"#include \"ne.h\"\n#define NE_BUG 0",
"static char *__get_target_os(r_bin_ne_obj_t *bin) {\n\tswitch (bin->ne_header->targOS) {\n\tcase 1:\n\t\treturn \"OS/2\";\n\tcase 2:\n\t\treturn \"Windows\";\n\tcase 3:\n\t\treturn \"European MS-DOS 4.x\";\n\tcase 4:\n\t\treturn \"Windows 386\";\n\tcase 5:\n\t\treturn \"BOSS (Borland Operating System Services)\";\n\tdefault:\n\t\treturn \"Unknown\";\n\t}\n}",
"static int __translate_perms(int flags) {\n\tint perms = 0;\n\tif (flags & IS_RX) {\n\t\tif (flags & IS_DATA) {\n\t\t\tperms = R_PERM_R;\n\t\t} else {\n\t\t\tperms = R_PERM_X;\n\t\t}\n\t}\n\tif (!perms) {\n\t\tperms = R_PERM_RWX;\n\t}\n\treturn perms;\n}",
"static char *__read_nonnull_str_at(RBuffer *buf, ut64 offset) {\n\tut8 sz = r_buf_read8_at (buf, offset);\n\tif (!sz) {\n\t\treturn NULL;\n\t}\n\tchar *str = malloc ((ut64)sz + 1);\n\tif (!str) {\n\t\treturn NULL;\n\t}\n\tr_buf_read_at (buf, offset + 1, (ut8 *)str, sz);\n\tstr[sz] = '\\0';\n\treturn str;\n}",
"static char *__func_name_from_ord(const char *module, ut16 ordinal) {\n\tif (!module) {\n\t\treturn NULL;\n\t}\n\tchar *lower_module = strdup (module);\n\tr_str_case (lower_module, false);\n\tchar *path = r_str_newf (R_JOIN_4_PATHS (\"%s\", R2_SDB_FORMAT, \"dll\", \"%s.sdb\"), r_sys_prefix (NULL), lower_module);\n\tfree (lower_module);\n\tchar *ord = r_str_newf (\"%d\", ordinal);\n\tchar *name;\n\tif (r_file_exists (path)) {\n\t\tSdb *sdb = sdb_new (NULL, path, 0);\n\t\tname = sdb_get (sdb, ord, NULL);\n\t\tif (!name) {\n\t\t\tname = ord;\n\t\t} else {\n\t\t\tfree (ord);\n\t\t}\n\t\tsdb_close (sdb);\n\t\tfree (sdb);\n\t} else {\n\t\tname = ord;\n\t}\n\tfree (path);\n\treturn name;\n}",
"RList *r_bin_ne_get_segments(r_bin_ne_obj_t *bin) {\n\tint i;\n\tif (!bin) {\n\t\treturn NULL;\n\t}\n\tRList *segments = r_list_newf (free);\n\tfor (i = 0; i < bin->ne_header->SegCount; i++) {\n\t\tRBinSection *bs = R_NEW0 (RBinSection);\n\t\tif (!bs) {\n\t\t\treturn segments;\n\t\t}\n\t\tNE_image_segment_entry *se = &bin->segment_entries[i];\n\t\tbs->size = se->length;\n\t\tbs->vsize = se->minAllocSz ? se->minAllocSz : 64000;\n\t\tbs->bits = R_SYS_BITS_16;\n\t\tbs->is_data = se->flags & IS_DATA;\n\t\tbs->perm = __translate_perms (se->flags);\n\t\tbs->paddr = (ut64)se->offset * bin->alignment;\n\t\tbs->name = r_str_newf (\"%s.%\" PFMT64d, se->flags & IS_MOVEABLE ? \"MOVEABLE\" : \"FIXED\", bs->paddr);\n\t\tbs->is_segment = true;\n\t\tr_list_append (segments, bs);\n\t}\n\tbin->segments = segments;\n\treturn segments;\n}",
"static int __find_symbol_by_paddr(const void *paddr, const void *sym) {\n\treturn (int)!(*(ut64 *)paddr == ((RBinSymbol *)sym)->paddr);\n}",
"RList *r_bin_ne_get_symbols(r_bin_ne_obj_t *bin) {\n\tRBinSymbol *sym;\n\tut16 off = bin->ne_header->ResidNamTable + bin->header_offset;\n\tRList *symbols = r_list_newf (free);\n\tif (!symbols) {\n\t\treturn NULL;\n\t}\n\tRList *entries = r_bin_ne_get_entrypoints (bin);\n\tbool resident = true, first = true;",
"\twhile (entries) {",
"\t\tut8 sz = r_buf_read8_at (bin->buf, off);\n\t\tif (!sz) {\n\t\t\tfirst = true;\n\t\t\tif (resident) {\n\t\t\t\tresident = false;\n\t\t\t\toff = bin->ne_header->OffStartNonResTab;\n\t\t\t\tsz = r_buf_read8_at (bin->buf, off);\n\t\t\t\tif (!sz) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tchar *name = malloc ((ut64)sz + 1);\n\t\tif (!name) {\n\t\t\tbreak;\n\t\t}\n\t\toff++;\n\t\tr_buf_read_at (bin->buf, off, (ut8 *)name, sz);\n\t\tname[sz] = '\\0';\n\t\toff += sz;\n\t\tsym = R_NEW0 (RBinSymbol);\n\t\tif (!sym) {\n\t\t\tbreak;\n\t\t}\n\t\tsym->name = name;\n\t\tif (!first) {\n\t\t\tsym->bind = R_BIN_BIND_GLOBAL_STR;\n\t\t}\n\t\tut16 entry_off = r_buf_read_le16_at (bin->buf, off);\n\t\toff += 2;\n\t\tRBinAddr *entry = r_list_get_n (entries, entry_off);\n\t\tif (entry) {\n\t\t\tsym->paddr = entry->paddr;\n\t\t} else {\n\t\t\tsym->paddr = -1;\n\t\t}\n\t\tsym->ordinal = entry_off;\n\t\tr_list_append (symbols, sym);\n\t\tfirst = false;\n\t}\n\tRListIter *it;\n\tRBinAddr *en;\n\tint i = 1;\n\tr_list_foreach (entries, it, en) {\n\t\tif (!r_list_find (symbols, &en->paddr, __find_symbol_by_paddr)) {\n\t\t\tsym = R_NEW0 (RBinSymbol);\n\t\t\tif (!sym) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsym->name = r_str_newf (\"entry%d\", i - 1);\n\t\t\tsym->paddr = en->paddr;\n\t\t\tsym->bind = R_BIN_BIND_GLOBAL_STR;\n\t\t\tsym->ordinal = i;\n\t\t\tr_list_append (symbols, sym);\n\t\t}\n\t\ti++;\n\t}\n\tbin->symbols = symbols;\n\treturn symbols;\n}",
"static char *__resource_type_str(int type) {\n\tchar *typeName;\n\tswitch (type) {\n\tcase 1:\n\t\ttypeName = \"CURSOR\";\n\t\tbreak;\n\tcase 2:\n\t\ttypeName = \"BITMAP\";\n\t\tbreak;\n\tcase 3:\n\t\ttypeName = \"ICON\";\n\t\tbreak;\n\tcase 4:\n\t\ttypeName = \"MENU\";\n\t\tbreak;\n\tcase 5:\n\t\ttypeName = \"DIALOG\";\n\t\tbreak;\n\tcase 6:\n\t\ttypeName = \"STRING\";\n\t\tbreak;\n\tcase 7:\n\t\ttypeName = \"FONTDIR\";\n\t\tbreak;\n\tcase 8:\n\t\ttypeName = \"FONT\";\n\t\tbreak;\n\tcase 9:\n\t\ttypeName = \"ACCELERATOR\";\n\t\tbreak;\n\tcase 10:\n\t\ttypeName = \"RCDATA\";\n\t\tbreak;\n\tcase 11:\n\t\ttypeName = \"MESSAGETABLE\";\n\t\tbreak;\n\tcase 12:\n\t\ttypeName = \"GROUP_CURSOR\";\n\t\tbreak;\n\tcase 14:\n\t\ttypeName = \"GROUP_ICON\";\n\t\tbreak;\n\tcase 15:\n\t\ttypeName = \"NAMETABLE\";\n\t\tbreak;\n\tcase 16:\n\t\ttypeName = \"VERSION\";\n\t\tbreak;\n\tcase 17:\n\t\ttypeName = \"DLGINCLUDE\";\n\t\tbreak;\n\tcase 19:\n\t\ttypeName = \"PLUGPLAY\";\n\t\tbreak;\n\tcase 20:\n\t\ttypeName = \"VXD\";\n\t\tbreak;\n\tcase 21:\n\t\ttypeName = \"ANICURSOR\";\n\t\tbreak;\n\tcase 22:\n\t\ttypeName = \"ANIICON\";\n\t\tbreak;\n\tcase 23:\n\t\ttypeName = \"HTML\";\n\t\tbreak;\n\tcase 24:\n\t\ttypeName = \"MANIFEST\";\n\t\tbreak;\n\tdefault:\n\t\treturn r_str_newf (\"UNKNOWN (%d)\", type);\n\t}\n\treturn strdup (typeName);\n}",
"static void __free_resource_entry(void *entry) {\n\tr_ne_resource_entry *en = (r_ne_resource_entry *)entry;\n\tfree (en->name);\n\tfree (en);\n}",
"static void __free_resource(void *resource) {\n\tr_ne_resource *res = (r_ne_resource *)resource;\n\tfree (res->name);\n\tr_list_free (res->entry);\n\tfree (res);\n}",
"static bool __ne_get_resources(r_bin_ne_obj_t *bin) {\n\tif (!bin->resources) {\n\t\tbin->resources = r_list_newf (__free_resource);\n\t}\n\tut16 resoff = bin->ne_header->ResTableOffset + bin->header_offset;\n\tut16 alignment = r_buf_read_le16_at (bin->buf, resoff);\n\tut32 off = resoff + 2;\n\twhile (true) {\n\t\tNE_image_typeinfo_entry ti = {0};\n\t\tr_ne_resource *res = R_NEW0 (r_ne_resource);\n\t\tif (!res) {\n\t\t\tbreak;\n\t\t}\n\t\tres->entry = r_list_newf (__free_resource_entry);\n\t\tif (!res->entry) {\n\t\t\tbreak;\n\t\t}\n\t\tr_buf_read_at (bin->buf, off, (ut8 *)&ti, sizeof (ti));\n\t\tif (!ti.rtTypeID) {\n\t\t\tbreak;\n\t\t} else if (ti.rtTypeID & 0x8000) {\n\t\t\tres->name = __resource_type_str (ti.rtTypeID & ~0x8000);\n\t\t} else {\n\t\t\t// Offset to resident name table\n\t\t\tres->name = __read_nonnull_str_at (bin->buf, (ut64)resoff + ti.rtTypeID);\n\t\t}\n\t\toff += sizeof (NE_image_typeinfo_entry);\n\t\tint i;\n\t\tfor (i = 0; i < ti.rtResourceCount; i++) {\n\t\t\tNE_image_nameinfo_entry ni;\n\t\t\tr_ne_resource_entry *ren = R_NEW0 (r_ne_resource_entry);\n\t\t\tif (!ren) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tr_buf_read_at (bin->buf, off, (ut8 *)&ni, sizeof (NE_image_nameinfo_entry));\n\t\t\tren->offset = ni.rnOffset << alignment;\n\t\t\tren->size = ni.rnLength;\n\t\t\tif (ni.rnID & 0x8000) {\n\t\t\t\tren->name = r_str_newf (\"%d\", ni.rnID & ~0x8000);\n\t\t\t} else {\n\t\t\t\t// Offset to resident name table\n\t\t\t\tren->name = __read_nonnull_str_at (bin->buf, (ut64)resoff + ni.rnID);\n\t\t\t}\n\t\t\tr_list_append (res->entry, ren);\n\t\t\toff += sizeof (NE_image_nameinfo_entry);\n\t\t}\n\t\tr_list_append (bin->resources, res);\n\t}\n\treturn true;\n}",
"RList *r_bin_ne_get_imports(r_bin_ne_obj_t *bin) {\n\tRList *imports = r_list_newf ((RListFree)r_bin_import_free);\n\tif (!imports) {\n\t\treturn NULL;\n\t}\n\tut16 off = bin->ne_header->ImportNameTable + bin->header_offset + 1;\n\tint i;\n\tfor (i = 0; i < bin->ne_header->ModRefs; i++) {\n\t\tRBinImport *imp = R_NEW0 (RBinImport);\n\t\tif (!imp) {\n\t\t\tbreak;\n\t\t}\n\t\tut8 sz = r_buf_read8_at (bin->buf, off);\n\t\tif (!sz) {\n\t\t\tr_bin_import_free (imp);\n\t\t\tbreak;\n\t\t}\n\t\toff++;\n\t\tchar *name = malloc ((ut64)sz + 1);\n\t\tif (!name) {\n\t\t\tbreak;\n\t\t}\n\t\tr_buf_read_at (bin->buf, off, (ut8 *)name, sz);\n\t\tname[sz] = '\\0';\n\t\timp->name = name;\n\t\timp->ordinal = i + 1;\n\t\tr_list_append (imports, imp);\n\t\toff += sz;\n\t}\n\tbin->imports = imports;\n\treturn imports;\n}",
"RList *r_bin_ne_get_entrypoints(r_bin_ne_obj_t *bin) {",
"\tif (!bin->entry_table) {\n\t\treturn NULL;\n\t}",
"\tRList *entries = r_list_newf (free);\n\tif (!entries) {\n\t\treturn NULL;\n\t}\n\tRList *segments = r_bin_ne_get_segments (bin);\n\tif (!segments) {\n\t\tr_list_free (entries);\n\t\treturn NULL;\n\t}\n\tif (bin->ne_header->csEntryPoint) {\n\t\tRBinAddr *entry = R_NEW0 (RBinAddr);\n\t\tif (!entry) {\n\t\t\tr_list_free (entries);\n\t\t\treturn NULL;\n\t\t}\n\t\tentry->bits = 16;\n\t\tut32 entry_cs = bin->ne_header->csEntryPoint;\n\t\tRBinSection *s = r_list_get_n (segments, entry_cs - 1);\n\t\tentry->paddr = bin->ne_header->ipEntryPoint + (s? s->paddr: 0);",
"\t\tr_list_append (entries, entry);\n\t}\n\tint off = 0;\n\tsize_t tableat = bin->header_offset + bin->ne_header->EntryTableOffset;\n\twhile (off < bin->ne_header->EntryTableLength) {\n\t\tif (tableat + off >= r_buf_size (bin->buf)) {\n\t\t\tbreak;\n\t\t}\n\t\tut8 bundle_length = *(ut8 *)(bin->entry_table + off);\n\t\tif (!bundle_length) {\n\t\t\tbreak;\n\t\t}\n\t\toff++;\n\t\tut8 bundle_type = *(ut8 *)(bin->entry_table + off);\n\t\toff++;\n\t\tint i;\n\t\tfor (i = 0; i < bundle_length; i++) {\n\t\t\tif (tableat + off + 4 >= r_buf_size (bin->buf)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tRBinAddr *entry = R_NEW0 (RBinAddr);\n\t\t\tif (!entry) {\n\t\t\t\tr_list_free (entries);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\toff++;\n\t\t\tif (!bundle_type) { // Skip\n\t\t\t\toff--;\n\t\t\t\tfree (entry);\n\t\t\t\tbreak;\n\t\t\t} else if (bundle_type == 0xff) { // moveable\n\t\t\t\toff += 2;\n\t\t\t\tut8 segnum = *(bin->entry_table + off);\n\t\t\t\toff++;\n\t\t\t\tut16 segoff = *(ut16 *)(bin->entry_table + off);\n\t\t\t\tif (segnum > 0) {\n\t\t\t\t\tentry->paddr = (ut64)bin->segment_entries[segnum - 1].offset * bin->alignment + segoff;\n\t\t\t\t}\n\t\t\t} else { // Fixed\n\t\t\t\tif (bundle_type < bin->ne_header->SegCount) {\n\t\t\t\t\tentry->paddr = (ut64)bin->segment_entries[bundle_type - 1].offset\n\t\t\t\t\t\t* bin->alignment + *(ut16 *)(bin->entry_table + off);\n\t\t\t\t}\n\t\t\t}\n\t\t\toff += 2;\n\t\t\tr_list_append (entries, entry);\n\t\t}\n\t}\n\tr_list_free (segments);\n\tbin->entries = entries;\n\treturn entries;\n}",
"RList *r_bin_ne_get_relocs(r_bin_ne_obj_t *bin) {\n\tRList *segments = bin->segments;\n\tif (!segments) {\n\t\treturn NULL;\n\t}\n\tRList *entries = bin->entries;\n\tif (!entries) {\n\t\treturn NULL;\n\t}\n\tRList *symbols = bin->symbols;\n\tif (!symbols) {\n\t\treturn NULL;\n\t}",
"\tut16 *modref = calloc (bin->ne_header->ModRefs, sizeof (ut16));\n\tif (!modref) {\n\t\treturn NULL;\n\t}\n\tr_buf_read_at (bin->buf, (ut64)bin->ne_header->ModRefTable + bin->header_offset, (ut8 *)modref, bin->ne_header->ModRefs * sizeof (ut16));",
"\tRList *relocs = r_list_newf (free);\n\tif (!relocs) {\n\t\tfree (modref);\n\t\treturn NULL;\n\t}",
"\tRListIter *it;\n\tRBinSection *seg;\n\tint index = -1;\n\tr_list_foreach (segments, it, seg) {\n\t\tindex++;\n\t\tif (!(bin->segment_entries[index].flags & RELOCINFO)) {\n\t\t\tcontinue;\n\t\t}\n\t\tut32 off = seg->paddr + seg->size;\n\t\tut32 start = off;\n\t\tut16 length = r_buf_read_le16_at (bin->buf, off);\n\t\tif (!length) {\n\t\t\tcontinue;\n\t\t}\n\t\toff += 2;\n\t\t// size_t buf_size = r_buf_size (bin->buf);\n\t\twhile (off < start + length * sizeof (NE_image_reloc_item)) {\n\t\t\t// && off + sizeof (NE_image_reloc_item) < buf_size)\n\t\t\tNE_image_reloc_item rel = {0};\n\t\t\tif (r_buf_read_at (bin->buf, off, (ut8 *)&rel, sizeof (rel)) < 1) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tRBinReloc *reloc = R_NEW0 (RBinReloc);\n\t\t\tif (!reloc) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\treloc->paddr = seg->paddr + rel.offset;\n\t\t\tswitch (rel.type) {\n\t\t\tcase LOBYTE:\n\t\t\t\treloc->type = R_BIN_RELOC_8;\n\t\t\t\tbreak;\n\t\t\tcase SEL_16:\n\t\t\tcase OFF_16:\n\t\t\t\treloc->type = R_BIN_RELOC_16;\n\t\t\t\tbreak;\n\t\t\tcase POI_32:\n\t\t\tcase OFF_32:\n\t\t\t\treloc->type = R_BIN_RELOC_32;\n\t\t\t\tbreak;\n\t\t\tcase POI_48:\n\t\t\t\treloc->type = R_BIN_RELOC_64;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tut32 offset;\n\t\t\tif (rel.flags & (IMPORTED_ORD | IMPORTED_NAME)) {\n\t\t\t\tRBinImport *imp = R_NEW0 (RBinImport);\n\t\t\t\tif (!imp) {\n\t\t\t\t\tfree (reloc);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tchar *name;\n#if NE_BUG\n\t\t\t\tif (rel.index > 0 && rel.index < bin->ne_header->ModRefs) {\n\t\t\t\t\toffset = modref[rel.index - 1] + bin->header_offset + bin->ne_header->ImportNameTable;\n\t\t\t\t\tname = __read_nonnull_str_at (bin->buf, offset);\n\t\t\t\t} else {\n\t\t\t\t\tname = r_str_newf (\"UnknownModule%d_%x\", rel.index, off); // ????\n\t\t\t\t}\n#else\n\t\t\t\tif (rel.index > bin->ne_header->ModRefs) {\n\t\t\t\t\tname = r_str_newf (\"UnknownModule%d_%x\", rel.index, off); // ????\n\t\t\t\t} else {\n\t\t\t\t\toffset = modref[rel.index - 1] + bin->header_offset + bin->ne_header->ImportNameTable;\n\t\t\t\t\tname = __read_nonnull_str_at (bin->buf, offset);\n\t\t\t\t}\n#endif\n\t\t\t\tif (rel.flags & IMPORTED_ORD) {\n\t\t\t\t\timp->ordinal = rel.func_ord;\n\t\t\t\t\timp->name = r_str_newf (\"%s.%s\", name, __func_name_from_ord(name, rel.func_ord));\n\t\t\t\t} else {\n\t\t\t\t\toffset = bin->header_offset + bin->ne_header->ImportNameTable + rel.name_off;\n\t\t\t\t\tchar *func = __read_nonnull_str_at (bin->buf, offset);\n\t\t\t\t\timp->name = r_str_newf (\"%s.%s\", name, func);\n\t\t\t\t\tfree (func);\n\t\t\t\t}\n\t\t\t\tfree (name);\n\t\t\t\treloc->import = imp;\n\t\t\t} else if (rel.flags & OSFIXUP) {\n\t\t\t\t// TODO\n\t\t\t} else {\n\t\t\t\tif (strstr (seg->name, \"FIXED\")) {\n\t\t\t\t\tRBinSection *s = r_list_get_n (segments, rel.segnum - 1);\n\t\t\t\t\tif (s) {\n\t\t\t\t\t\toffset = s->paddr + rel.segoff;\n\t\t\t\t\t} else {\n\t\t\t\t\t\toffset = -1;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tRBinAddr *entry = r_list_get_n (entries, rel.entry_ordinal - 1);\n\t\t\t\t\tif (entry) {\n\t\t\t\t\t\toffset = entry->paddr;\n\t\t\t\t\t} else {\n\t\t\t\t\t\toffset = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treloc->addend = offset;\n\t\t\t\tRBinSymbol *sym = NULL;\n\t\t\t\tRListIter *sit;\n\t\t\t\tr_list_foreach (symbols, sit, sym) {\n\t\t\t\t\tif (sym->paddr == reloc->addend) {\n\t\t\t\t\t\treloc->symbol = sym;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"\t\t\tif (rel.flags & ADDITIVE) {\n\t\t\t\treloc->additive = 1;\n\t\t\t\tr_list_append (relocs, reloc);\n\t\t\t} else {\n\t\t\t\tdo {\n#if NE_BUG\n\t\t\t\t\tif (reloc->paddr + 4 < r_buf_size (bin->buf)) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n#endif\n\t\t\t\t\tr_list_append (relocs, reloc);\n\t\t\t\t\toffset = r_buf_read_le16_at (bin->buf, reloc->paddr);\n\t\t\t\t\tRBinReloc *tmp = reloc;\n\t\t\t\t\treloc = R_NEW0 (RBinReloc);\n\t\t\t\t\tif (!reloc) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t*reloc = *tmp;\n\t\t\t\t\treloc->paddr = seg->paddr + offset;\n\t\t\t\t} while (offset != 0xFFFF);\n\t\t\t\tfree (reloc);\n\t\t\t}",
"\t\t\toff += sizeof (NE_image_reloc_item);\n\t\t}\n\t}\n\tfree (modref);\n\treturn relocs;\n}",
"void __init(RBuffer *buf, r_bin_ne_obj_t *bin) {\n\tbin->header_offset = r_buf_read_le16_at (buf, 0x3c);\n\tbin->ne_header = R_NEW0 (NE_image_header);\n\tif (!bin->ne_header) {\n\t\treturn;\n\t}\n\tbin->buf = buf;\n\t// XXX this is endian unsafe\n\tif (r_buf_read_at (buf, bin->header_offset, (ut8 *)bin->ne_header, sizeof (NE_image_header)) < 1) {\n\t\tR_FREE (bin->ne_header);\n\t\treturn;\n\t}\n\tif (bin->ne_header->FileAlnSzShftCnt > 15) {\n\t\tbin->ne_header->FileAlnSzShftCnt = 15;\n\t}\n\tut64 from = bin->ne_header->ModRefTable + bin->header_offset;\n\tut64 left = r_buf_size (bin->buf) - from;\n\tif (from + bin->ne_header->ModRefs * sizeof (ut16) >= left) {\n\t\tbin->ne_header->ModRefs = left / sizeof (ut16);\n\t}\n\tbin->alignment = 1 << bin->ne_header->FileAlnSzShftCnt;\n\tif (!bin->alignment) {\n\t\tbin->alignment = 1 << 9;\n\t}\n\tbin->os = __get_target_os (bin);",
"\tut16 offset = bin->ne_header->SegTableOffset + bin->header_offset;\n\tsize_t size = bin->ne_header->SegCount * sizeof (NE_image_segment_entry);\n\tif (offset >= r_buf_size (bin->buf)) {\n\t\treturn;\n\t}\n\tsize_t remaining = r_buf_size (bin->buf) - offset;\n\tsize = R_MIN (remaining, size);\n\tbin->ne_header->SegCount = size / sizeof (NE_image_segment_entry); // * sizeof (NE_image_segment_entry);\n\tbin->segment_entries = calloc (1, size);\n\tif (size >= remaining) {\n\t\tbin->ne_header->SegCount = size / sizeof (NE_image_segment_entry);\n\t}\n\tif (!bin->segment_entries) {\n\t\treturn;\n\t}\n\tr_buf_read_at (buf, offset, (ut8 *)bin->segment_entries, size);\n\tbin->entry_table = calloc (4, bin->ne_header->EntryTableLength);\n\tif (!bin->entry_table) {\n\t\tR_FREE (bin->segment_entries);\n\t\treturn;\n\t}\n\tr_buf_read_at (buf, (ut64)bin->header_offset + bin->ne_header->EntryTableOffset, bin->entry_table, bin->ne_header->EntryTableLength);\n\tbin->imports = r_bin_ne_get_imports (bin);\n\t__ne_get_resources (bin);\n}",
"void r_bin_ne_free(r_bin_ne_obj_t *bin) {\n\t// r_list_free (bin->imports); // double free\n\tr_list_free (bin->resources);\n\tfree (bin->entry_table);\n\tfree (bin->ne_header);\n\tfree (bin->resident_name_table);\n\tfree (bin->segment_entries);\n\tfree (bin);\n}",
"r_bin_ne_obj_t *r_bin_ne_new_buf(RBuffer *buf, bool verbose) {\n\tr_bin_ne_obj_t *bin = R_NEW0 (r_bin_ne_obj_t);\n\tif (!bin) {\n\t\treturn NULL;\n\t}\n\t__init(buf, bin);\n\treturn bin;\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": [354], "buggy_code_start_loc": [118], "filenames": ["libr/bin/format/ne/ne.c"], "fixing_code_end_loc": [358], "fixing_code_start_loc": [118], "message": "NULL Pointer Dereference in r_bin_ne_get_entrypoints function in GitHub repository radareorg/radare2 prior to 5.6.8. This vulnerability allows attackers to cause a denial of service (application crash).", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:radare:radare2:*:*:*:*:*:*:*:*", "matchCriteriaId": "8956009B-4EDA-4AA6-997D-B2C8C5D05CEC", "versionEndExcluding": "5.6.8", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "NULL Pointer Dereference in r_bin_ne_get_entrypoints function in GitHub repository radareorg/radare2 prior to 5.6.8. This vulnerability allows attackers to cause a denial of service (application crash)."}, {"lang": "es", "value": "Un Desreferencia de Puntero NULL en la funci\u00f3n r_bin_ne_get_entrypoints en el repositorio de GitHub radareorg/radare2 versiones anteriores a 5.6.8. Esta vulnerabilidad permite a atacantes causar una denegaci\u00f3n de servicio (bloqueo de la aplicaci\u00f3n)"}], "evaluatorComment": null, "id": "CVE-2022-1283", "lastModified": "2022-04-15T15:28:01.770", "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": true}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 6.6, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:H", "version": "3.0"}, "exploitabilityScore": 1.8, "impactScore": 4.7, "source": "security@huntr.dev", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2022-04-08T18:15:09.703", "references": [{"source": "security@huntr.dev", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/radareorg/radare2/commit/18d1d064bf599a255d55f09fca3104776fc34a67"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://huntr.dev/bounties/bfeb8fb8-644d-4587-80d4-cb704c404013"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-476"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/radareorg/radare2/commit/18d1d064bf599a255d55f09fca3104776fc34a67"}, "type": "CWE-476"}
| 212
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# [DEPRECATED] \n# Please use [Appium Inspector](https://github.com/appium/appium-inspector) and the command line version of [Appium](https://github.com/appium/appium) to inspect elements.",
"❗❗ This project is no longer maintained since it is not compatible with Appium 2.0+. For Appium 1.x and 2.0+, use the command line Appium server (see the [Appium docs](https://appium.github.io/appium/docs/en/latest/) for installation and setup information), in combination with [Appium Inspector](https://github.com/appium/appium-inspector).\n",
"The old documentation for this project remains below.",
"\n# Appium Desktop",
"[](https://dev.azure.com/AppiumCI/Appium%20Desktop/_build/latest?definitionId=1)\n[](https://crowdin.com/project/appium-desktop)",
"",
"Appium Desktop is an app for Mac, Windows, and Linux which gives you the power of the [Appium](http://appium.io) automation server in a beautiful and flexible UI. It is basically a graphical interface for the Appium Server. You can set options, start/stop the server, see logs, etc... You also don't need to use Node/NPM to install Appium, as the Node runtime comes bundled with Appium Desktop.",
"**Note:** an inspector UI used to be included with Appium Desktop. It is now its own separate app: [Appium Inspector](https://github.com/appium/appium-inspector).",
"## Download Appium Desktop",
"You can always pick up the latest release of the Server GUI at our\n[Release](https://github.com/appium/appium-desktop/releases/latest) page on\nGitHub.",
"If you're on Windows or macOS, Appium Desktop will automatically provide you\nwith updated versions of the app when they are released. If you encounter\na problem updating, simply delete or uninstall the app and re-download the\nlatest from the link above.",
"Note that Appium Desktop _is not_ the same thing as Appium. Appium Desktop is\na graphical frontend to Appium with additional tools. Appium Desktop is\nreleased on its own cadence and has its own versioning system. If you are\nreporting an issue with Appium Desktop, always be sure to include _both_ the\nversion of Appium Desktop and the version of the Appium Server which is in use\n(see below).",
"If you're on macOS, you will need to install Appium Desktop apps by copying the app\nfrom the downloaded DMG file to your own file system (the best place is the\n\"Applications\" folder). Running Appium from in side the attached DMG itself is\nnot supported, and will not work.",
"### Installing on macOS",
"If you're using the desktop app on macOS, when you run it you may be greeted with some error about\nthe app not being able to be opened, or not verified by Apple, or something similar. The easiest\nway to get around this is to run `xattr -cr` on the file you downloaded. So let's say you\ndownloaded `Appium-Server-GUI-mac-<version>.dmg` and copy `Appium Server GUI.app` in\n`/Applications` inside the disk image. Then you would run `xattr -cr \"/Applications/Appium Server\nGUI.app\"` before opening it. The same goes for the zip version (or the .app itself).",
"## Known Issues",
"* Some Windows 10 Users experience a `PathTooLongException` when installing the EXE. The workaround for this is to update the setting on Windows to [enable long paths](https://superuser.com/questions/1119883/windows-10-enable-ntfs-long-paths-policy-option-missing)",
"## Usage Instructions",
"These instructions assume you are already familiar with Appium and Appium-related concepts. If you\nare new to Appium, please visit [appium.io](http://appium.io) and read our introductory material.\nThey also assume that you have downloaded both the Server GUI and the Inspector apps.",
"This app provides a convenient way to download and run the Appium automation\nserver, as well as a tool for inspecting elements in Chrome/Safari browser and your Android or iOS application. Its\nvarious capabilities are described in the following sections.",
"#### Starting a simple server",
"",
"When you open Appium Desktop, you are greeted with the server start window. The\nbasic option is to start an Appium server with all its defaults and the ability\nto modify the host and port. The start button will also let you know which\nversion of the Appium server you are running, which can be useful when\nreporting issues to the Appium team.",
"#### Starting a server with advanced options",
"",
"By clicking on the 'Advanced' tab, you have the ability to set all the server\nflags that are available in Appium. This is for advanced users and should only\nbe modified after consulting the Appium documentation.",
"#### Server presets",
"",
"If you use the advanced server options, you have the ability to save\na configuration for later use. Simply save the preset on the 'Advanced' tab,\nand you will subsequently be able to recall and start the server with that\nconfiguration from the 'Preset' tab.",
"### The server console output window",
"Once you start the server, it will launch on the host and port you specified,\nand open a new window displaying the server log output.",
"",
"This is fairly straightforward and no real interaction is possible, beyond\nusing the button to stop the server. You can also copy-and-paste the logs from\nthis window which is useful in reporting Appium issues.",
"## Reporting Issues and Requesting Features",
"Appium Desktop is open source, and we use GitHub for issue tracking. Please\nsimply report issues at our [issue\ntracker](https://github.com/appium/appium-desktop/issues). We will endeavor to\ndetermine whether the issue you are reporting is related to Appium Desktop or\nAppium Server. If it's not related to Appium Desktop specifically, we will\nclose the issue and ask you to open a general Appium issue at [Appium's main\nissue tracker](https://github.com/appium/appium/issues). Please, save\nyourselves and us valuable time by getting clear on whether the issue you're\nexperiencing is related to Appium Desktop specifically or instead is a general\nAppium issue. You can do this by seeing whether the issue reproduces with the\nAppium command line server as well. If it does, direct your report to Appium's\nissue tracker.",
"Have a feature request? Follow the same process and submit an issue to the\nappropriate tracker! (Either here in this repo if the request is specifically\nfor Appium Desktop, or Appium's main tracker if the request is for Appium more\ngenerally.)",
"## Advanced Topics and Troubleshooting",
"#### Appium can't detect environment variables on Mac",
"Appium uses environment variables like `ANDROID_HOME` as well as relying on\nvarious binaries in your `PATH` and so on. When running from the command line\nin an environment where you have set these variables appropriately, Appium has\nno problem in picking them up. However, Appium Desktop does not run in a shell\nor a command-line environment, and so by default it does not have access to\nenvironment variables you have set in your shell startup script or profile. To\nwork around this, we use the\n[shell-env](https://github.com/sindresorhus/shell-env) package to pick up\nenvironment variables defined in your shell. This package only looks in certain\ncommon init scripts, however, like `~/.bashrc`, `~/.bash_profile`, and\n`~/.zshrc`. If you set your Appium environment variables in some other way, you\nwill need to create one of these default init scripts and set your environment\nvariables there as well, so that Appium Desktop will successfully pick them up.",
"#### Warnings about being on a read-only file system",
"This probably means you tried to launch Appium Desktop from the downloaded disk\nimage (`.dmg` file). This is not a supported mode of running Appium Desktop. To\ncorrectly install Appium Desktop, copy the application from the disk image to\nyour local filesystem, to somewhere like `/Applications`. Then, run the app\nfrom that new location.",
"## Developer Instructions",
"Want to hack on Appium Desktop? Awesome! Head on over to our [Contributing\nDoc](CONTRIBUTING.md) for information on how to get a dev environment set up\nand submit changes back to the project."
] |
[
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
] |
PreciseBugs
|
{"buggy_code_end_loc": [7], "buggy_code_start_loc": [6], "filenames": ["README.md"], "fixing_code_end_loc": [9], "fixing_code_start_loc": [6], "message": "OS Command Injection in GitHub repository appium/appium-desktop prior to v1.22.3-4.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:appium:appium-desktop:*:*:*:*:*:*:*:*", "matchCriteriaId": "28162FC6-3759-475D-AD57-A8F38BE6CB08", "versionEndExcluding": "1.22.3-4", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "OS Command Injection in GitHub repository appium/appium-desktop prior to v1.22.3-4."}], "evaluatorComment": null, "id": "CVE-2023-2479", "lastModified": "2023-05-17T17:05:52.643", "metrics": {"cvssMetricV2": null, "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": "security@huntr.dev", "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-05-02T15:15:23.760", "references": [{"source": "security@huntr.dev", "tags": ["Patch"], "url": "https://github.com/appium/appium-desktop/commit/12a988aa08b9822e97056a09486c9bebb3aad8fe"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Third Party Advisory"], "url": "https://huntr.dev/bounties/fbdeec3c-d197-4a68-a547-7f93fb9594b4"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-78"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/appium/appium-desktop/commit/12a988aa08b9822e97056a09486c9bebb3aad8fe"}, "type": "CWE-78"}
| 213
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# [DEPRECATED] \n# Please use [Appium Inspector](https://github.com/appium/appium-inspector) and the command line version of [Appium](https://github.com/appium/appium) to inspect elements.",
"❗❗ This project is no longer maintained since it is not compatible with Appium 2.0+. For Appium 1.x and 2.0+, use the command line Appium server (see the [Appium docs](https://appium.github.io/appium/docs/en/latest/) for installation and setup information), in combination with [Appium Inspector](https://github.com/appium/appium-inspector).\n",
"❗❗ Since this project was deprecated at least one security vulnerability was discovered that could allow remote code execution by a malicious party if Appium Desktop's open ports are exposed to the wider internet. This project is unsupported and no fixes are planned. Again, please do not use Appium Desktop anymore. Use Appium and the Appium Inspector instead.",
"_The old documentation for this project remains below._",
"\n# Appium Desktop",
"[](https://dev.azure.com/AppiumCI/Appium%20Desktop/_build/latest?definitionId=1)\n[](https://crowdin.com/project/appium-desktop)",
"",
"Appium Desktop is an app for Mac, Windows, and Linux which gives you the power of the [Appium](http://appium.io) automation server in a beautiful and flexible UI. It is basically a graphical interface for the Appium Server. You can set options, start/stop the server, see logs, etc... You also don't need to use Node/NPM to install Appium, as the Node runtime comes bundled with Appium Desktop.",
"**Note:** an inspector UI used to be included with Appium Desktop. It is now its own separate app: [Appium Inspector](https://github.com/appium/appium-inspector).",
"## Download Appium Desktop",
"You can always pick up the latest release of the Server GUI at our\n[Release](https://github.com/appium/appium-desktop/releases/latest) page on\nGitHub.",
"If you're on Windows or macOS, Appium Desktop will automatically provide you\nwith updated versions of the app when they are released. If you encounter\na problem updating, simply delete or uninstall the app and re-download the\nlatest from the link above.",
"Note that Appium Desktop _is not_ the same thing as Appium. Appium Desktop is\na graphical frontend to Appium with additional tools. Appium Desktop is\nreleased on its own cadence and has its own versioning system. If you are\nreporting an issue with Appium Desktop, always be sure to include _both_ the\nversion of Appium Desktop and the version of the Appium Server which is in use\n(see below).",
"If you're on macOS, you will need to install Appium Desktop apps by copying the app\nfrom the downloaded DMG file to your own file system (the best place is the\n\"Applications\" folder). Running Appium from in side the attached DMG itself is\nnot supported, and will not work.",
"### Installing on macOS",
"If you're using the desktop app on macOS, when you run it you may be greeted with some error about\nthe app not being able to be opened, or not verified by Apple, or something similar. The easiest\nway to get around this is to run `xattr -cr` on the file you downloaded. So let's say you\ndownloaded `Appium-Server-GUI-mac-<version>.dmg` and copy `Appium Server GUI.app` in\n`/Applications` inside the disk image. Then you would run `xattr -cr \"/Applications/Appium Server\nGUI.app\"` before opening it. The same goes for the zip version (or the .app itself).",
"## Known Issues",
"* Some Windows 10 Users experience a `PathTooLongException` when installing the EXE. The workaround for this is to update the setting on Windows to [enable long paths](https://superuser.com/questions/1119883/windows-10-enable-ntfs-long-paths-policy-option-missing)",
"## Usage Instructions",
"These instructions assume you are already familiar with Appium and Appium-related concepts. If you\nare new to Appium, please visit [appium.io](http://appium.io) and read our introductory material.\nThey also assume that you have downloaded both the Server GUI and the Inspector apps.",
"This app provides a convenient way to download and run the Appium automation\nserver, as well as a tool for inspecting elements in Chrome/Safari browser and your Android or iOS application. Its\nvarious capabilities are described in the following sections.",
"#### Starting a simple server",
"",
"When you open Appium Desktop, you are greeted with the server start window. The\nbasic option is to start an Appium server with all its defaults and the ability\nto modify the host and port. The start button will also let you know which\nversion of the Appium server you are running, which can be useful when\nreporting issues to the Appium team.",
"#### Starting a server with advanced options",
"",
"By clicking on the 'Advanced' tab, you have the ability to set all the server\nflags that are available in Appium. This is for advanced users and should only\nbe modified after consulting the Appium documentation.",
"#### Server presets",
"",
"If you use the advanced server options, you have the ability to save\na configuration for later use. Simply save the preset on the 'Advanced' tab,\nand you will subsequently be able to recall and start the server with that\nconfiguration from the 'Preset' tab.",
"### The server console output window",
"Once you start the server, it will launch on the host and port you specified,\nand open a new window displaying the server log output.",
"",
"This is fairly straightforward and no real interaction is possible, beyond\nusing the button to stop the server. You can also copy-and-paste the logs from\nthis window which is useful in reporting Appium issues.",
"## Reporting Issues and Requesting Features",
"Appium Desktop is open source, and we use GitHub for issue tracking. Please\nsimply report issues at our [issue\ntracker](https://github.com/appium/appium-desktop/issues). We will endeavor to\ndetermine whether the issue you are reporting is related to Appium Desktop or\nAppium Server. If it's not related to Appium Desktop specifically, we will\nclose the issue and ask you to open a general Appium issue at [Appium's main\nissue tracker](https://github.com/appium/appium/issues). Please, save\nyourselves and us valuable time by getting clear on whether the issue you're\nexperiencing is related to Appium Desktop specifically or instead is a general\nAppium issue. You can do this by seeing whether the issue reproduces with the\nAppium command line server as well. If it does, direct your report to Appium's\nissue tracker.",
"Have a feature request? Follow the same process and submit an issue to the\nappropriate tracker! (Either here in this repo if the request is specifically\nfor Appium Desktop, or Appium's main tracker if the request is for Appium more\ngenerally.)",
"## Advanced Topics and Troubleshooting",
"#### Appium can't detect environment variables on Mac",
"Appium uses environment variables like `ANDROID_HOME` as well as relying on\nvarious binaries in your `PATH` and so on. When running from the command line\nin an environment where you have set these variables appropriately, Appium has\nno problem in picking them up. However, Appium Desktop does not run in a shell\nor a command-line environment, and so by default it does not have access to\nenvironment variables you have set in your shell startup script or profile. To\nwork around this, we use the\n[shell-env](https://github.com/sindresorhus/shell-env) package to pick up\nenvironment variables defined in your shell. This package only looks in certain\ncommon init scripts, however, like `~/.bashrc`, `~/.bash_profile`, and\n`~/.zshrc`. If you set your Appium environment variables in some other way, you\nwill need to create one of these default init scripts and set your environment\nvariables there as well, so that Appium Desktop will successfully pick them up.",
"#### Warnings about being on a read-only file system",
"This probably means you tried to launch Appium Desktop from the downloaded disk\nimage (`.dmg` file). This is not a supported mode of running Appium Desktop. To\ncorrectly install Appium Desktop, copy the application from the disk image to\nyour local filesystem, to somewhere like `/Applications`. Then, run the app\nfrom that new location.",
"## Developer Instructions",
"Want to hack on Appium Desktop? Awesome! Head on over to our [Contributing\nDoc](CONTRIBUTING.md) for information on how to get a dev environment set up\nand submit changes back to the project."
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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": [7], "buggy_code_start_loc": [6], "filenames": ["README.md"], "fixing_code_end_loc": [9], "fixing_code_start_loc": [6], "message": "OS Command Injection in GitHub repository appium/appium-desktop prior to v1.22.3-4.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:appium:appium-desktop:*:*:*:*:*:*:*:*", "matchCriteriaId": "28162FC6-3759-475D-AD57-A8F38BE6CB08", "versionEndExcluding": "1.22.3-4", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "OS Command Injection in GitHub repository appium/appium-desktop prior to v1.22.3-4."}], "evaluatorComment": null, "id": "CVE-2023-2479", "lastModified": "2023-05-17T17:05:52.643", "metrics": {"cvssMetricV2": null, "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": "security@huntr.dev", "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-05-02T15:15:23.760", "references": [{"source": "security@huntr.dev", "tags": ["Patch"], "url": "https://github.com/appium/appium-desktop/commit/12a988aa08b9822e97056a09486c9bebb3aad8fe"}, {"source": "security@huntr.dev", "tags": ["Exploit", "Third Party Advisory"], "url": "https://huntr.dev/bounties/fbdeec3c-d197-4a68-a547-7f93fb9594b4"}], "sourceIdentifier": "security@huntr.dev", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-78"}], "source": "security@huntr.dev", "type": "Primary"}]}, "github_commit_url": "https://github.com/appium/appium-desktop/commit/12a988aa08b9822e97056a09486c9bebb3aad8fe"}, "type": "CWE-78"}
| 213
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Monkey's Audio APE demuxer\n * Copyright (c) 2007 Benjamin Zores <ben@geexbox.org>\n * based upon libdemac from Dave Chapman.\n *\n * This file is part of FFmpeg.\n *\n * FFmpeg is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public\n * License as published by the Free Software Foundation; either\n * version 2.1 of the License, or (at your option) any later version.\n *\n * FFmpeg 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 GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with FFmpeg; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n */",
"#include <stdio.h>",
"#include \"libavutil/intreadwrite.h\"\n#include \"avformat.h\"\n#include \"apetag.h\"",
"#define ENABLE_DEBUG 0",
"/* The earliest and latest file formats supported by this library */\n#define APE_MIN_VERSION 3950\n#define APE_MAX_VERSION 3990",
"#define MAC_FORMAT_FLAG_8_BIT 1 // is 8-bit [OBSOLETE]\n#define MAC_FORMAT_FLAG_CRC 2 // uses the new CRC32 error detection [OBSOLETE]\n#define MAC_FORMAT_FLAG_HAS_PEAK_LEVEL 4 // uint32 nPeakLevel after the header [OBSOLETE]\n#define MAC_FORMAT_FLAG_24_BIT 8 // is 24-bit [OBSOLETE]\n#define MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS 16 // has the number of seek elements after the peak level\n#define MAC_FORMAT_FLAG_CREATE_WAV_HEADER 32 // create the wave header on decompression (not stored)",
"#define MAC_SUBFRAME_SIZE 4608",
"#define APE_EXTRADATA_SIZE 6",
"typedef struct {\n int64_t pos;\n int nblocks;\n int size;\n int skip;\n int64_t pts;\n} APEFrame;",
"typedef struct {\n /* Derived fields */\n uint32_t junklength;\n uint32_t firstframe;\n uint32_t totalsamples;\n int currentframe;\n APEFrame *frames;",
" /* Info from Descriptor Block */\n char magic[4];\n int16_t fileversion;\n int16_t padding1;\n uint32_t descriptorlength;\n uint32_t headerlength;\n uint32_t seektablelength;\n uint32_t wavheaderlength;\n uint32_t audiodatalength;\n uint32_t audiodatalength_high;\n uint32_t wavtaillength;\n uint8_t md5[16];",
" /* Info from Header Block */\n uint16_t compressiontype;\n uint16_t formatflags;\n uint32_t blocksperframe;\n uint32_t finalframeblocks;\n uint32_t totalframes;\n uint16_t bps;\n uint16_t channels;\n uint32_t samplerate;",
" /* Seektable */\n uint32_t *seektable;\n} APEContext;",
"static int ape_probe(AVProbeData * p)\n{\n if (p->buf[0] == 'M' && p->buf[1] == 'A' && p->buf[2] == 'C' && p->buf[3] == ' ')\n return AVPROBE_SCORE_MAX;",
" return 0;\n}",
"static void ape_dumpinfo(AVFormatContext * s, APEContext * ape_ctx)\n{\n#if ENABLE_DEBUG\n int i;",
" av_log(s, AV_LOG_DEBUG, \"Descriptor Block:\\n\\n\");\n av_log(s, AV_LOG_DEBUG, \"magic = \\\"%c%c%c%c\\\"\\n\", ape_ctx->magic[0], ape_ctx->magic[1], ape_ctx->magic[2], ape_ctx->magic[3]);\n av_log(s, AV_LOG_DEBUG, \"fileversion = %d\\n\", ape_ctx->fileversion);\n av_log(s, AV_LOG_DEBUG, \"descriptorlength = %d\\n\", ape_ctx->descriptorlength);\n av_log(s, AV_LOG_DEBUG, \"headerlength = %d\\n\", ape_ctx->headerlength);\n av_log(s, AV_LOG_DEBUG, \"seektablelength = %d\\n\", ape_ctx->seektablelength);\n av_log(s, AV_LOG_DEBUG, \"wavheaderlength = %d\\n\", ape_ctx->wavheaderlength);\n av_log(s, AV_LOG_DEBUG, \"audiodatalength = %d\\n\", ape_ctx->audiodatalength);\n av_log(s, AV_LOG_DEBUG, \"audiodatalength_high = %d\\n\", ape_ctx->audiodatalength_high);\n av_log(s, AV_LOG_DEBUG, \"wavtaillength = %d\\n\", ape_ctx->wavtaillength);\n av_log(s, AV_LOG_DEBUG, \"md5 = \");\n for (i = 0; i < 16; i++)\n av_log(s, AV_LOG_DEBUG, \"%02x\", ape_ctx->md5[i]);\n av_log(s, AV_LOG_DEBUG, \"\\n\");",
" av_log(s, AV_LOG_DEBUG, \"\\nHeader Block:\\n\\n\");",
" av_log(s, AV_LOG_DEBUG, \"compressiontype = %d\\n\", ape_ctx->compressiontype);\n av_log(s, AV_LOG_DEBUG, \"formatflags = %d\\n\", ape_ctx->formatflags);\n av_log(s, AV_LOG_DEBUG, \"blocksperframe = %d\\n\", ape_ctx->blocksperframe);\n av_log(s, AV_LOG_DEBUG, \"finalframeblocks = %d\\n\", ape_ctx->finalframeblocks);\n av_log(s, AV_LOG_DEBUG, \"totalframes = %d\\n\", ape_ctx->totalframes);\n av_log(s, AV_LOG_DEBUG, \"bps = %d\\n\", ape_ctx->bps);\n av_log(s, AV_LOG_DEBUG, \"channels = %d\\n\", ape_ctx->channels);\n av_log(s, AV_LOG_DEBUG, \"samplerate = %d\\n\", ape_ctx->samplerate);",
" av_log(s, AV_LOG_DEBUG, \"\\nSeektable\\n\\n\");\n if ((ape_ctx->seektablelength / sizeof(uint32_t)) != ape_ctx->totalframes) {\n av_log(s, AV_LOG_DEBUG, \"No seektable\\n\");\n } else {\n for (i = 0; i < ape_ctx->seektablelength / sizeof(uint32_t); i++) {\n if (i < ape_ctx->totalframes - 1) {\n av_log(s, AV_LOG_DEBUG, \"%8d %d (%d bytes)\\n\", i, ape_ctx->seektable[i], ape_ctx->seektable[i + 1] - ape_ctx->seektable[i]);\n } else {\n av_log(s, AV_LOG_DEBUG, \"%8d %d\\n\", i, ape_ctx->seektable[i]);\n }\n }\n }",
" av_log(s, AV_LOG_DEBUG, \"\\nFrames\\n\\n\");\n for (i = 0; i < ape_ctx->totalframes; i++)\n av_log(s, AV_LOG_DEBUG, \"%8d %8lld %8d (%d samples)\\n\", i, ape_ctx->frames[i].pos, ape_ctx->frames[i].size, ape_ctx->frames[i].nblocks);",
" av_log(s, AV_LOG_DEBUG, \"\\nCalculated information:\\n\\n\");\n av_log(s, AV_LOG_DEBUG, \"junklength = %d\\n\", ape_ctx->junklength);\n av_log(s, AV_LOG_DEBUG, \"firstframe = %d\\n\", ape_ctx->firstframe);\n av_log(s, AV_LOG_DEBUG, \"totalsamples = %d\\n\", ape_ctx->totalsamples);\n#endif\n}",
"static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)\n{\n AVIOContext *pb = s->pb;\n APEContext *ape = s->priv_data;\n AVStream *st;\n uint32_t tag;\n int i;\n int total_blocks;\n int64_t pts;",
" /* TODO: Skip any leading junk such as id3v2 tags */\n ape->junklength = 0;",
" tag = avio_rl32(pb);\n if (tag != MKTAG('M', 'A', 'C', ' '))\n return -1;",
" ape->fileversion = avio_rl16(pb);",
" if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {\n av_log(s, AV_LOG_ERROR, \"Unsupported file version - %d.%02d\\n\", ape->fileversion / 1000, (ape->fileversion % 1000) / 10);\n return -1;\n }",
" if (ape->fileversion >= 3980) {\n ape->padding1 = avio_rl16(pb);\n ape->descriptorlength = avio_rl32(pb);\n ape->headerlength = avio_rl32(pb);\n ape->seektablelength = avio_rl32(pb);\n ape->wavheaderlength = avio_rl32(pb);\n ape->audiodatalength = avio_rl32(pb);\n ape->audiodatalength_high = avio_rl32(pb);\n ape->wavtaillength = avio_rl32(pb);\n avio_read(pb, ape->md5, 16);",
" /* Skip any unknown bytes at the end of the descriptor.\n This is for future compatibility */\n if (ape->descriptorlength > 52)\n avio_seek(pb, ape->descriptorlength - 52, SEEK_CUR);",
" /* Read header data */\n ape->compressiontype = avio_rl16(pb);\n ape->formatflags = avio_rl16(pb);\n ape->blocksperframe = avio_rl32(pb);\n ape->finalframeblocks = avio_rl32(pb);\n ape->totalframes = avio_rl32(pb);\n ape->bps = avio_rl16(pb);\n ape->channels = avio_rl16(pb);\n ape->samplerate = avio_rl32(pb);\n } else {\n ape->descriptorlength = 0;\n ape->headerlength = 32;",
" ape->compressiontype = avio_rl16(pb);\n ape->formatflags = avio_rl16(pb);\n ape->channels = avio_rl16(pb);\n ape->samplerate = avio_rl32(pb);\n ape->wavheaderlength = avio_rl32(pb);\n ape->wavtaillength = avio_rl32(pb);\n ape->totalframes = avio_rl32(pb);\n ape->finalframeblocks = avio_rl32(pb);",
" if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {\n avio_seek(pb, 4, SEEK_CUR); /* Skip the peak level */\n ape->headerlength += 4;\n }",
" if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {\n ape->seektablelength = avio_rl32(pb);\n ape->headerlength += 4;\n ape->seektablelength *= sizeof(int32_t);\n } else\n ape->seektablelength = ape->totalframes * sizeof(int32_t);",
" if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT)\n ape->bps = 8;\n else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT)\n ape->bps = 24;\n else\n ape->bps = 16;",
" if (ape->fileversion >= 3950)\n ape->blocksperframe = 73728 * 4;\n else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000))\n ape->blocksperframe = 73728;\n else\n ape->blocksperframe = 9216;",
" /* Skip any stored wav header */\n if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER))\n avio_seek(pb, ape->wavheaderlength, SEEK_CUR);\n }\n",
"",
" if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){\n av_log(s, AV_LOG_ERROR, \"Too many frames: %d\\n\", ape->totalframes);\n return -1;\n }\n ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame));\n if(!ape->frames)\n return AVERROR(ENOMEM);\n ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength;\n ape->currentframe = 0;",
"\n ape->totalsamples = ape->finalframeblocks;\n if (ape->totalframes > 1)\n ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1);",
" if (ape->seektablelength > 0) {\n ape->seektable = av_malloc(ape->seektablelength);\n for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++)\n ape->seektable[i] = avio_rl32(pb);\n }",
" ape->frames[0].pos = ape->firstframe;\n ape->frames[0].nblocks = ape->blocksperframe;\n ape->frames[0].skip = 0;\n for (i = 1; i < ape->totalframes; i++) {\n ape->frames[i].pos = ape->seektable[i]; //ape->frames[i-1].pos + ape->blocksperframe;\n ape->frames[i].nblocks = ape->blocksperframe;\n ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos;\n ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 3;\n }\n ape->frames[ape->totalframes - 1].size = ape->finalframeblocks * 4;\n ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks;",
" for (i = 0; i < ape->totalframes; i++) {\n if(ape->frames[i].skip){\n ape->frames[i].pos -= ape->frames[i].skip;\n ape->frames[i].size += ape->frames[i].skip;\n }\n ape->frames[i].size = (ape->frames[i].size + 3) & ~3;\n }",
"\n ape_dumpinfo(s, ape);",
" /* try to read APE tags */\n if (!url_is_streamed(pb)) {\n ff_ape_parse_tag(s);\n avio_seek(pb, 0, SEEK_SET);\n }",
" av_log(s, AV_LOG_DEBUG, \"Decoding file - v%d.%02d, compression level %d\\n\", ape->fileversion / 1000, (ape->fileversion % 1000) / 10, ape->compressiontype);",
" /* now we are ready: build format streams */\n st = av_new_stream(s, 0);\n if (!st)\n return -1;",
" total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;",
" st->codec->codec_type = AVMEDIA_TYPE_AUDIO;\n st->codec->codec_id = CODEC_ID_APE;\n st->codec->codec_tag = MKTAG('A', 'P', 'E', ' ');\n st->codec->channels = ape->channels;\n st->codec->sample_rate = ape->samplerate;\n st->codec->bits_per_coded_sample = ape->bps;\n st->codec->frame_size = MAC_SUBFRAME_SIZE;",
" st->nb_frames = ape->totalframes;\n st->start_time = 0;\n st->duration = total_blocks / MAC_SUBFRAME_SIZE;\n av_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate);",
" st->codec->extradata = av_malloc(APE_EXTRADATA_SIZE);\n st->codec->extradata_size = APE_EXTRADATA_SIZE;\n AV_WL16(st->codec->extradata + 0, ape->fileversion);\n AV_WL16(st->codec->extradata + 2, ape->compressiontype);\n AV_WL16(st->codec->extradata + 4, ape->formatflags);",
" pts = 0;\n for (i = 0; i < ape->totalframes; i++) {\n ape->frames[i].pts = pts;\n av_add_index_entry(st, ape->frames[i].pos, ape->frames[i].pts, 0, 0, AVINDEX_KEYFRAME);\n pts += ape->blocksperframe / MAC_SUBFRAME_SIZE;\n }",
" return 0;\n}",
"static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)\n{\n int ret;\n int nblocks;\n APEContext *ape = s->priv_data;\n uint32_t extra_size = 8;",
" if (s->pb->eof_reached)\n return AVERROR(EIO);\n if (ape->currentframe > ape->totalframes)\n return AVERROR(EIO);",
" avio_seek (s->pb, ape->frames[ape->currentframe].pos, SEEK_SET);",
" /* Calculate how many blocks there are in this frame */\n if (ape->currentframe == (ape->totalframes - 1))\n nblocks = ape->finalframeblocks;\n else\n nblocks = ape->blocksperframe;",
" if (av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size) < 0)\n return AVERROR(ENOMEM);",
" AV_WL32(pkt->data , nblocks);\n AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);\n ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);",
" pkt->pts = ape->frames[ape->currentframe].pts;\n pkt->stream_index = 0;",
" /* note: we need to modify the packet size here to handle the last\n packet */\n pkt->size = ret + extra_size;",
" ape->currentframe++;",
" return 0;\n}",
"static int ape_read_close(AVFormatContext * s)\n{\n APEContext *ape = s->priv_data;",
" av_freep(&ape->frames);\n av_freep(&ape->seektable);\n return 0;\n}",
"static int ape_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)\n{\n AVStream *st = s->streams[stream_index];\n APEContext *ape = s->priv_data;\n int index = av_index_search_timestamp(st, timestamp, flags);",
" if (index < 0)\n return -1;",
" ape->currentframe = index;\n return 0;\n}",
"AVInputFormat ff_ape_demuxer = {\n \"ape\",\n NULL_IF_CONFIG_SMALL(\"Monkey's Audio\"),\n sizeof(APEContext),\n ape_probe,\n ape_read_header,\n ape_read_packet,\n ape_read_close,\n ape_read_seek,\n .extensions = \"ape,apl,mac\"\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,
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": [244], "buggy_code_start_loc": [244], "filenames": ["libavformat/ape.c"], "fixing_code_end_loc": [249], "fixing_code_start_loc": [245], "message": "The ape_read_header function in ape.c in libavformat in FFmpeg before 0.5.4, as used in MPlayer, VideoLAN VLC media player, and other products, allows remote attackers to cause a denial of service (application crash) via an APE (aka Monkey's Audio) file that contains a header but no frames.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:ffmpeg:ffmpeg:*:*:*:*:*:*:*:*", "matchCriteriaId": "4FED443E-75BC-4534-89EE-D0B9CD93209A", "versionEndExcluding": "0.5.4", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "The ape_read_header function in ape.c in libavformat in FFmpeg before 0.5.4, as used in MPlayer, VideoLAN VLC media player, and other products, allows remote attackers to cause a denial of service (application crash) via an APE (aka Monkey's Audio) file that contains a header but no frames."}, {"lang": "es", "value": "La funci\u00f3n ape_read_header en ape.c en libavformat en FFmpeg antes de v0.5.4, tal como se utiliza en MPlayer, VideoLAN VLC media player, y otros productos, permite a atacantes remotos provocar una denegaci\u00f3n de servicio (solicitud de bloqueo) a trav\u00e9s de un archivo APE (tambi\u00e9n conocido como Monkey's Audio) que contiene un encabezado pero sin marcos."}], "evaluatorComment": null, "id": "CVE-2011-2161", "lastModified": "2018-10-17T14:40:15.887", "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": true}], "cvssMetricV30": null, "cvssMetricV31": null}, "published": "2011-05-20T22:55:06.000", "references": [{"source": "cve@mitre.org", "tags": ["Vendor Advisory"], "url": "http://ffmpeg.mplayerhq.hu/"}, {"source": "cve@mitre.org", "tags": ["Broken Link"], "url": "http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/FFmpeg/FFmpeg/commit/8312e3fc9041027a33c8bc667bb99740fdf41dd5"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-399"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/FFmpeg/FFmpeg/commit/8312e3fc9041027a33c8bc667bb99740fdf41dd5"}, "type": "CWE-399"}
| 214
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Monkey's Audio APE demuxer\n * Copyright (c) 2007 Benjamin Zores <ben@geexbox.org>\n * based upon libdemac from Dave Chapman.\n *\n * This file is part of FFmpeg.\n *\n * FFmpeg is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public\n * License as published by the Free Software Foundation; either\n * version 2.1 of the License, or (at your option) any later version.\n *\n * FFmpeg 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 GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with FFmpeg; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n */",
"#include <stdio.h>",
"#include \"libavutil/intreadwrite.h\"\n#include \"avformat.h\"\n#include \"apetag.h\"",
"#define ENABLE_DEBUG 0",
"/* The earliest and latest file formats supported by this library */\n#define APE_MIN_VERSION 3950\n#define APE_MAX_VERSION 3990",
"#define MAC_FORMAT_FLAG_8_BIT 1 // is 8-bit [OBSOLETE]\n#define MAC_FORMAT_FLAG_CRC 2 // uses the new CRC32 error detection [OBSOLETE]\n#define MAC_FORMAT_FLAG_HAS_PEAK_LEVEL 4 // uint32 nPeakLevel after the header [OBSOLETE]\n#define MAC_FORMAT_FLAG_24_BIT 8 // is 24-bit [OBSOLETE]\n#define MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS 16 // has the number of seek elements after the peak level\n#define MAC_FORMAT_FLAG_CREATE_WAV_HEADER 32 // create the wave header on decompression (not stored)",
"#define MAC_SUBFRAME_SIZE 4608",
"#define APE_EXTRADATA_SIZE 6",
"typedef struct {\n int64_t pos;\n int nblocks;\n int size;\n int skip;\n int64_t pts;\n} APEFrame;",
"typedef struct {\n /* Derived fields */\n uint32_t junklength;\n uint32_t firstframe;\n uint32_t totalsamples;\n int currentframe;\n APEFrame *frames;",
" /* Info from Descriptor Block */\n char magic[4];\n int16_t fileversion;\n int16_t padding1;\n uint32_t descriptorlength;\n uint32_t headerlength;\n uint32_t seektablelength;\n uint32_t wavheaderlength;\n uint32_t audiodatalength;\n uint32_t audiodatalength_high;\n uint32_t wavtaillength;\n uint8_t md5[16];",
" /* Info from Header Block */\n uint16_t compressiontype;\n uint16_t formatflags;\n uint32_t blocksperframe;\n uint32_t finalframeblocks;\n uint32_t totalframes;\n uint16_t bps;\n uint16_t channels;\n uint32_t samplerate;",
" /* Seektable */\n uint32_t *seektable;\n} APEContext;",
"static int ape_probe(AVProbeData * p)\n{\n if (p->buf[0] == 'M' && p->buf[1] == 'A' && p->buf[2] == 'C' && p->buf[3] == ' ')\n return AVPROBE_SCORE_MAX;",
" return 0;\n}",
"static void ape_dumpinfo(AVFormatContext * s, APEContext * ape_ctx)\n{\n#if ENABLE_DEBUG\n int i;",
" av_log(s, AV_LOG_DEBUG, \"Descriptor Block:\\n\\n\");\n av_log(s, AV_LOG_DEBUG, \"magic = \\\"%c%c%c%c\\\"\\n\", ape_ctx->magic[0], ape_ctx->magic[1], ape_ctx->magic[2], ape_ctx->magic[3]);\n av_log(s, AV_LOG_DEBUG, \"fileversion = %d\\n\", ape_ctx->fileversion);\n av_log(s, AV_LOG_DEBUG, \"descriptorlength = %d\\n\", ape_ctx->descriptorlength);\n av_log(s, AV_LOG_DEBUG, \"headerlength = %d\\n\", ape_ctx->headerlength);\n av_log(s, AV_LOG_DEBUG, \"seektablelength = %d\\n\", ape_ctx->seektablelength);\n av_log(s, AV_LOG_DEBUG, \"wavheaderlength = %d\\n\", ape_ctx->wavheaderlength);\n av_log(s, AV_LOG_DEBUG, \"audiodatalength = %d\\n\", ape_ctx->audiodatalength);\n av_log(s, AV_LOG_DEBUG, \"audiodatalength_high = %d\\n\", ape_ctx->audiodatalength_high);\n av_log(s, AV_LOG_DEBUG, \"wavtaillength = %d\\n\", ape_ctx->wavtaillength);\n av_log(s, AV_LOG_DEBUG, \"md5 = \");\n for (i = 0; i < 16; i++)\n av_log(s, AV_LOG_DEBUG, \"%02x\", ape_ctx->md5[i]);\n av_log(s, AV_LOG_DEBUG, \"\\n\");",
" av_log(s, AV_LOG_DEBUG, \"\\nHeader Block:\\n\\n\");",
" av_log(s, AV_LOG_DEBUG, \"compressiontype = %d\\n\", ape_ctx->compressiontype);\n av_log(s, AV_LOG_DEBUG, \"formatflags = %d\\n\", ape_ctx->formatflags);\n av_log(s, AV_LOG_DEBUG, \"blocksperframe = %d\\n\", ape_ctx->blocksperframe);\n av_log(s, AV_LOG_DEBUG, \"finalframeblocks = %d\\n\", ape_ctx->finalframeblocks);\n av_log(s, AV_LOG_DEBUG, \"totalframes = %d\\n\", ape_ctx->totalframes);\n av_log(s, AV_LOG_DEBUG, \"bps = %d\\n\", ape_ctx->bps);\n av_log(s, AV_LOG_DEBUG, \"channels = %d\\n\", ape_ctx->channels);\n av_log(s, AV_LOG_DEBUG, \"samplerate = %d\\n\", ape_ctx->samplerate);",
" av_log(s, AV_LOG_DEBUG, \"\\nSeektable\\n\\n\");\n if ((ape_ctx->seektablelength / sizeof(uint32_t)) != ape_ctx->totalframes) {\n av_log(s, AV_LOG_DEBUG, \"No seektable\\n\");\n } else {\n for (i = 0; i < ape_ctx->seektablelength / sizeof(uint32_t); i++) {\n if (i < ape_ctx->totalframes - 1) {\n av_log(s, AV_LOG_DEBUG, \"%8d %d (%d bytes)\\n\", i, ape_ctx->seektable[i], ape_ctx->seektable[i + 1] - ape_ctx->seektable[i]);\n } else {\n av_log(s, AV_LOG_DEBUG, \"%8d %d\\n\", i, ape_ctx->seektable[i]);\n }\n }\n }",
" av_log(s, AV_LOG_DEBUG, \"\\nFrames\\n\\n\");\n for (i = 0; i < ape_ctx->totalframes; i++)\n av_log(s, AV_LOG_DEBUG, \"%8d %8lld %8d (%d samples)\\n\", i, ape_ctx->frames[i].pos, ape_ctx->frames[i].size, ape_ctx->frames[i].nblocks);",
" av_log(s, AV_LOG_DEBUG, \"\\nCalculated information:\\n\\n\");\n av_log(s, AV_LOG_DEBUG, \"junklength = %d\\n\", ape_ctx->junklength);\n av_log(s, AV_LOG_DEBUG, \"firstframe = %d\\n\", ape_ctx->firstframe);\n av_log(s, AV_LOG_DEBUG, \"totalsamples = %d\\n\", ape_ctx->totalsamples);\n#endif\n}",
"static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)\n{\n AVIOContext *pb = s->pb;\n APEContext *ape = s->priv_data;\n AVStream *st;\n uint32_t tag;\n int i;\n int total_blocks;\n int64_t pts;",
" /* TODO: Skip any leading junk such as id3v2 tags */\n ape->junklength = 0;",
" tag = avio_rl32(pb);\n if (tag != MKTAG('M', 'A', 'C', ' '))\n return -1;",
" ape->fileversion = avio_rl16(pb);",
" if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {\n av_log(s, AV_LOG_ERROR, \"Unsupported file version - %d.%02d\\n\", ape->fileversion / 1000, (ape->fileversion % 1000) / 10);\n return -1;\n }",
" if (ape->fileversion >= 3980) {\n ape->padding1 = avio_rl16(pb);\n ape->descriptorlength = avio_rl32(pb);\n ape->headerlength = avio_rl32(pb);\n ape->seektablelength = avio_rl32(pb);\n ape->wavheaderlength = avio_rl32(pb);\n ape->audiodatalength = avio_rl32(pb);\n ape->audiodatalength_high = avio_rl32(pb);\n ape->wavtaillength = avio_rl32(pb);\n avio_read(pb, ape->md5, 16);",
" /* Skip any unknown bytes at the end of the descriptor.\n This is for future compatibility */\n if (ape->descriptorlength > 52)\n avio_seek(pb, ape->descriptorlength - 52, SEEK_CUR);",
" /* Read header data */\n ape->compressiontype = avio_rl16(pb);\n ape->formatflags = avio_rl16(pb);\n ape->blocksperframe = avio_rl32(pb);\n ape->finalframeblocks = avio_rl32(pb);\n ape->totalframes = avio_rl32(pb);\n ape->bps = avio_rl16(pb);\n ape->channels = avio_rl16(pb);\n ape->samplerate = avio_rl32(pb);\n } else {\n ape->descriptorlength = 0;\n ape->headerlength = 32;",
" ape->compressiontype = avio_rl16(pb);\n ape->formatflags = avio_rl16(pb);\n ape->channels = avio_rl16(pb);\n ape->samplerate = avio_rl32(pb);\n ape->wavheaderlength = avio_rl32(pb);\n ape->wavtaillength = avio_rl32(pb);\n ape->totalframes = avio_rl32(pb);\n ape->finalframeblocks = avio_rl32(pb);",
" if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {\n avio_seek(pb, 4, SEEK_CUR); /* Skip the peak level */\n ape->headerlength += 4;\n }",
" if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {\n ape->seektablelength = avio_rl32(pb);\n ape->headerlength += 4;\n ape->seektablelength *= sizeof(int32_t);\n } else\n ape->seektablelength = ape->totalframes * sizeof(int32_t);",
" if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT)\n ape->bps = 8;\n else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT)\n ape->bps = 24;\n else\n ape->bps = 16;",
" if (ape->fileversion >= 3950)\n ape->blocksperframe = 73728 * 4;\n else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000))\n ape->blocksperframe = 73728;\n else\n ape->blocksperframe = 9216;",
" /* Skip any stored wav header */\n if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER))\n avio_seek(pb, ape->wavheaderlength, SEEK_CUR);\n }\n",
" if(!ape->totalframes){\n av_log(s, AV_LOG_ERROR, \"No frames in the file!\\n\");\n return AVERROR(EINVAL);\n }",
" if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){\n av_log(s, AV_LOG_ERROR, \"Too many frames: %d\\n\", ape->totalframes);\n return -1;\n }\n ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame));\n if(!ape->frames)\n return AVERROR(ENOMEM);\n ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength;\n ape->currentframe = 0;",
"\n ape->totalsamples = ape->finalframeblocks;\n if (ape->totalframes > 1)\n ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1);",
" if (ape->seektablelength > 0) {\n ape->seektable = av_malloc(ape->seektablelength);\n for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++)\n ape->seektable[i] = avio_rl32(pb);\n }",
" ape->frames[0].pos = ape->firstframe;\n ape->frames[0].nblocks = ape->blocksperframe;\n ape->frames[0].skip = 0;\n for (i = 1; i < ape->totalframes; i++) {\n ape->frames[i].pos = ape->seektable[i]; //ape->frames[i-1].pos + ape->blocksperframe;\n ape->frames[i].nblocks = ape->blocksperframe;\n ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos;\n ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 3;\n }\n ape->frames[ape->totalframes - 1].size = ape->finalframeblocks * 4;\n ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks;",
" for (i = 0; i < ape->totalframes; i++) {\n if(ape->frames[i].skip){\n ape->frames[i].pos -= ape->frames[i].skip;\n ape->frames[i].size += ape->frames[i].skip;\n }\n ape->frames[i].size = (ape->frames[i].size + 3) & ~3;\n }",
"\n ape_dumpinfo(s, ape);",
" /* try to read APE tags */\n if (!url_is_streamed(pb)) {\n ff_ape_parse_tag(s);\n avio_seek(pb, 0, SEEK_SET);\n }",
" av_log(s, AV_LOG_DEBUG, \"Decoding file - v%d.%02d, compression level %d\\n\", ape->fileversion / 1000, (ape->fileversion % 1000) / 10, ape->compressiontype);",
" /* now we are ready: build format streams */\n st = av_new_stream(s, 0);\n if (!st)\n return -1;",
" total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;",
" st->codec->codec_type = AVMEDIA_TYPE_AUDIO;\n st->codec->codec_id = CODEC_ID_APE;\n st->codec->codec_tag = MKTAG('A', 'P', 'E', ' ');\n st->codec->channels = ape->channels;\n st->codec->sample_rate = ape->samplerate;\n st->codec->bits_per_coded_sample = ape->bps;\n st->codec->frame_size = MAC_SUBFRAME_SIZE;",
" st->nb_frames = ape->totalframes;\n st->start_time = 0;\n st->duration = total_blocks / MAC_SUBFRAME_SIZE;\n av_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate);",
" st->codec->extradata = av_malloc(APE_EXTRADATA_SIZE);\n st->codec->extradata_size = APE_EXTRADATA_SIZE;\n AV_WL16(st->codec->extradata + 0, ape->fileversion);\n AV_WL16(st->codec->extradata + 2, ape->compressiontype);\n AV_WL16(st->codec->extradata + 4, ape->formatflags);",
" pts = 0;\n for (i = 0; i < ape->totalframes; i++) {\n ape->frames[i].pts = pts;\n av_add_index_entry(st, ape->frames[i].pos, ape->frames[i].pts, 0, 0, AVINDEX_KEYFRAME);\n pts += ape->blocksperframe / MAC_SUBFRAME_SIZE;\n }",
" return 0;\n}",
"static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)\n{\n int ret;\n int nblocks;\n APEContext *ape = s->priv_data;\n uint32_t extra_size = 8;",
" if (s->pb->eof_reached)\n return AVERROR(EIO);\n if (ape->currentframe > ape->totalframes)\n return AVERROR(EIO);",
" avio_seek (s->pb, ape->frames[ape->currentframe].pos, SEEK_SET);",
" /* Calculate how many blocks there are in this frame */\n if (ape->currentframe == (ape->totalframes - 1))\n nblocks = ape->finalframeblocks;\n else\n nblocks = ape->blocksperframe;",
" if (av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size) < 0)\n return AVERROR(ENOMEM);",
" AV_WL32(pkt->data , nblocks);\n AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);\n ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);",
" pkt->pts = ape->frames[ape->currentframe].pts;\n pkt->stream_index = 0;",
" /* note: we need to modify the packet size here to handle the last\n packet */\n pkt->size = ret + extra_size;",
" ape->currentframe++;",
" return 0;\n}",
"static int ape_read_close(AVFormatContext * s)\n{\n APEContext *ape = s->priv_data;",
" av_freep(&ape->frames);\n av_freep(&ape->seektable);\n return 0;\n}",
"static int ape_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)\n{\n AVStream *st = s->streams[stream_index];\n APEContext *ape = s->priv_data;\n int index = av_index_search_timestamp(st, timestamp, flags);",
" if (index < 0)\n return -1;",
" ape->currentframe = index;\n return 0;\n}",
"AVInputFormat ff_ape_demuxer = {\n \"ape\",\n NULL_IF_CONFIG_SMALL(\"Monkey's Audio\"),\n sizeof(APEContext),\n ape_probe,\n ape_read_header,\n ape_read_packet,\n ape_read_close,\n ape_read_seek,\n .extensions = \"ape,apl,mac\"\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": [244], "buggy_code_start_loc": [244], "filenames": ["libavformat/ape.c"], "fixing_code_end_loc": [249], "fixing_code_start_loc": [245], "message": "The ape_read_header function in ape.c in libavformat in FFmpeg before 0.5.4, as used in MPlayer, VideoLAN VLC media player, and other products, allows remote attackers to cause a denial of service (application crash) via an APE (aka Monkey's Audio) file that contains a header but no frames.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:ffmpeg:ffmpeg:*:*:*:*:*:*:*:*", "matchCriteriaId": "4FED443E-75BC-4534-89EE-D0B9CD93209A", "versionEndExcluding": "0.5.4", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "The ape_read_header function in ape.c in libavformat in FFmpeg before 0.5.4, as used in MPlayer, VideoLAN VLC media player, and other products, allows remote attackers to cause a denial of service (application crash) via an APE (aka Monkey's Audio) file that contains a header but no frames."}, {"lang": "es", "value": "La funci\u00f3n ape_read_header en ape.c en libavformat en FFmpeg antes de v0.5.4, tal como se utiliza en MPlayer, VideoLAN VLC media player, y otros productos, permite a atacantes remotos provocar una denegaci\u00f3n de servicio (solicitud de bloqueo) a trav\u00e9s de un archivo APE (tambi\u00e9n conocido como Monkey's Audio) que contiene un encabezado pero sin marcos."}], "evaluatorComment": null, "id": "CVE-2011-2161", "lastModified": "2018-10-17T14:40:15.887", "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": true}], "cvssMetricV30": null, "cvssMetricV31": null}, "published": "2011-05-20T22:55:06.000", "references": [{"source": "cve@mitre.org", "tags": ["Vendor Advisory"], "url": "http://ffmpeg.mplayerhq.hu/"}, {"source": "cve@mitre.org", "tags": ["Broken Link"], "url": "http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/FFmpeg/FFmpeg/commit/8312e3fc9041027a33c8bc667bb99740fdf41dd5"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-399"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/FFmpeg/FFmpeg/commit/8312e3fc9041027a33c8bc667bb99740fdf41dd5"}, "type": "CWE-399"}
| 214
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n *\tDCCP over IPv6\n *\tLinux INET6 implementation\n *\n *\tBased on net/dccp6/ipv6.c\n *\n *\tArnaldo Carvalho de Melo <acme@ghostprotocols.net>\n *\n *\tThis 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 */",
"#include <linux/module.h>\n#include <linux/random.h>\n#include <linux/slab.h>\n#include <linux/xfrm.h>",
"#include <net/addrconf.h>\n#include <net/inet_common.h>\n#include <net/inet_hashtables.h>\n#include <net/inet_sock.h>\n#include <net/inet6_connection_sock.h>\n#include <net/inet6_hashtables.h>\n#include <net/ip6_route.h>\n#include <net/ipv6.h>\n#include <net/protocol.h>\n#include <net/transp_v6.h>\n#include <net/ip6_checksum.h>\n#include <net/xfrm.h>\n#include <net/secure_seq.h>",
"#include \"dccp.h\"\n#include \"ipv6.h\"\n#include \"feat.h\"",
"/* The per-net dccp.v6_ctl_sk is used for sending RSTs and ACKs */",
"static const struct inet_connection_sock_af_ops dccp_ipv6_mapped;\nstatic const struct inet_connection_sock_af_ops dccp_ipv6_af_ops;",
"/* add pseudo-header to DCCP checksum stored in skb->csum */\nstatic inline __sum16 dccp_v6_csum_finish(struct sk_buff *skb,\n\t\t\t\t const struct in6_addr *saddr,\n\t\t\t\t const struct in6_addr *daddr)\n{\n\treturn csum_ipv6_magic(saddr, daddr, skb->len, IPPROTO_DCCP, skb->csum);\n}",
"static inline void dccp_v6_send_check(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct dccp_hdr *dh = dccp_hdr(skb);",
"\tdccp_csum_outgoing(skb);\n\tdh->dccph_checksum = dccp_v6_csum_finish(skb, &np->saddr, &sk->sk_v6_daddr);\n}",
"static inline __u64 dccp_v6_init_sequence(struct sk_buff *skb)\n{\n\treturn secure_dccpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,\n\t\t\t\t\t ipv6_hdr(skb)->saddr.s6_addr32,\n\t\t\t\t\t dccp_hdr(skb)->dccph_dport,\n\t\t\t\t\t dccp_hdr(skb)->dccph_sport );",
"}",
"static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n\t\t\tu8 type, u8 code, int offset, __be32 info)\n{\n\tconst struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;\n\tconst struct dccp_hdr *dh;\n\tstruct dccp_sock *dp;\n\tstruct ipv6_pinfo *np;\n\tstruct sock *sk;\n\tint err;\n\t__u64 seq;\n\tstruct net *net = dev_net(skb->dev);",
"\t/* Only need dccph_dport & dccph_sport which are the first\n\t * 4 bytes in dccp header.\n\t * Our caller (icmpv6_notify()) already pulled 8 bytes for us.\n\t */\n\tBUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_sport) > 8);\n\tBUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_dport) > 8);\n\tdh = (struct dccp_hdr *)(skb->data + offset);",
"\tsk = __inet6_lookup_established(net, &dccp_hashinfo,\n\t\t\t\t\t&hdr->daddr, dh->dccph_dport,\n\t\t\t\t\t&hdr->saddr, ntohs(dh->dccph_sport),\n\t\t\t\t\tinet6_iif(skb));",
"\tif (!sk) {\n\t\t__ICMP6_INC_STATS(net, __in6_dev_get(skb->dev),\n\t\t\t\t ICMP6_MIB_INERRORS);\n\t\treturn;\n\t}",
"\tif (sk->sk_state == DCCP_TIME_WAIT) {\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\treturn;\n\t}\n\tseq = dccp_hdr_seq(dh);\n\tif (sk->sk_state == DCCP_NEW_SYN_RECV)\n\t\treturn dccp_req_err(sk, seq);",
"\tbh_lock_sock(sk);\n\tif (sock_owned_by_user(sk))\n\t\t__NET_INC_STATS(net, LINUX_MIB_LOCKDROPPEDICMPS);",
"\tif (sk->sk_state == DCCP_CLOSED)\n\t\tgoto out;",
"\tdp = dccp_sk(sk);\n\tif ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_LISTEN) &&\n\t !between48(seq, dp->dccps_awl, dp->dccps_awh)) {\n\t\t__NET_INC_STATS(net, LINUX_MIB_OUTOFWINDOWICMPS);\n\t\tgoto out;\n\t}",
"\tnp = inet6_sk(sk);",
"\tif (type == NDISC_REDIRECT) {\n\t\tif (!sock_owned_by_user(sk)) {\n\t\t\tstruct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);",
"\t\t\tif (dst)\n\t\t\t\tdst->ops->redirect(dst, sk, skb);\n\t\t}\n\t\tgoto out;\n\t}",
"\tif (type == ICMPV6_PKT_TOOBIG) {\n\t\tstruct dst_entry *dst = NULL;",
"\t\tif (!ip6_sk_accept_pmtu(sk))\n\t\t\tgoto out;",
"\t\tif (sock_owned_by_user(sk))\n\t\t\tgoto out;\n\t\tif ((1 << sk->sk_state) & (DCCPF_LISTEN | DCCPF_CLOSED))\n\t\t\tgoto out;",
"\t\tdst = inet6_csk_update_pmtu(sk, ntohl(info));\n\t\tif (!dst)\n\t\t\tgoto out;",
"\t\tif (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst))\n\t\t\tdccp_sync_mss(sk, dst_mtu(dst));\n\t\tgoto out;\n\t}",
"\ticmpv6_err_convert(type, code, &err);",
"\t/* Might be for an request_sock */\n\tswitch (sk->sk_state) {\n\tcase DCCP_REQUESTING:\n\tcase DCCP_RESPOND: /* Cannot happen.\n\t\t\t It can, it SYNs are crossed. --ANK */\n\t\tif (!sock_owned_by_user(sk)) {\n\t\t\t__DCCP_INC_STATS(DCCP_MIB_ATTEMPTFAILS);\n\t\t\tsk->sk_err = err;\n\t\t\t/*\n\t\t\t * Wake people up to see the error\n\t\t\t * (see connect in sock.c)\n\t\t\t */\n\t\t\tsk->sk_error_report(sk);\n\t\t\tdccp_done(sk);\n\t\t} else\n\t\t\tsk->sk_err_soft = err;\n\t\tgoto out;\n\t}",
"\tif (!sock_owned_by_user(sk) && np->recverr) {\n\t\tsk->sk_err = err;\n\t\tsk->sk_error_report(sk);\n\t} else\n\t\tsk->sk_err_soft = err;",
"out:\n\tbh_unlock_sock(sk);\n\tsock_put(sk);\n}",
"\nstatic int dccp_v6_send_response(const struct sock *sk, struct request_sock *req)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct sk_buff *skb;\n\tstruct in6_addr *final_p, final;\n\tstruct flowi6 fl6;\n\tint err = -1;\n\tstruct dst_entry *dst;",
"\tmemset(&fl6, 0, sizeof(fl6));\n\tfl6.flowi6_proto = IPPROTO_DCCP;\n\tfl6.daddr = ireq->ir_v6_rmt_addr;\n\tfl6.saddr = ireq->ir_v6_loc_addr;\n\tfl6.flowlabel = 0;\n\tfl6.flowi6_oif = ireq->ir_iif;\n\tfl6.fl6_dport = ireq->ir_rmt_port;\n\tfl6.fl6_sport = htons(ireq->ir_num);\n\tsecurity_req_classify_flow(req, flowi6_to_flowi(&fl6));",
"\n\trcu_read_lock();\n\tfinal_p = fl6_update_dst(&fl6, rcu_dereference(np->opt), &final);\n\trcu_read_unlock();",
"\tdst = ip6_dst_lookup_flow(sk, &fl6, final_p);\n\tif (IS_ERR(dst)) {\n\t\terr = PTR_ERR(dst);\n\t\tdst = NULL;\n\t\tgoto done;\n\t}",
"\tskb = dccp_make_response(sk, dst, req);\n\tif (skb != NULL) {\n\t\tstruct dccp_hdr *dh = dccp_hdr(skb);\n\t\tstruct ipv6_txoptions *opt;",
"\t\tdh->dccph_checksum = dccp_v6_csum_finish(skb,\n\t\t\t\t\t\t\t &ireq->ir_v6_loc_addr,\n\t\t\t\t\t\t\t &ireq->ir_v6_rmt_addr);\n\t\tfl6.daddr = ireq->ir_v6_rmt_addr;\n\t\trcu_read_lock();\n\t\topt = ireq->ipv6_opt;\n\t\tif (!opt)\n\t\t\topt = rcu_dereference(np->opt);\n\t\terr = ip6_xmit(sk, skb, &fl6, sk->sk_mark, opt, np->tclass);\n\t\trcu_read_unlock();\n\t\terr = net_xmit_eval(err);\n\t}",
"done:\n\tdst_release(dst);\n\treturn err;\n}",
"static void dccp_v6_reqsk_destructor(struct request_sock *req)\n{\n\tdccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg);\n\tkfree(inet_rsk(req)->ipv6_opt);\n\tkfree_skb(inet_rsk(req)->pktopts);\n}",
"static void dccp_v6_ctl_send_reset(const struct sock *sk, struct sk_buff *rxskb)\n{\n\tconst struct ipv6hdr *rxip6h;\n\tstruct sk_buff *skb;\n\tstruct flowi6 fl6;\n\tstruct net *net = dev_net(skb_dst(rxskb)->dev);\n\tstruct sock *ctl_sk = net->dccp.v6_ctl_sk;\n\tstruct dst_entry *dst;",
"\tif (dccp_hdr(rxskb)->dccph_type == DCCP_PKT_RESET)\n\t\treturn;",
"\tif (!ipv6_unicast_destination(rxskb))\n\t\treturn;",
"\tskb = dccp_ctl_make_reset(ctl_sk, rxskb);\n\tif (skb == NULL)\n\t\treturn;",
"\trxip6h = ipv6_hdr(rxskb);\n\tdccp_hdr(skb)->dccph_checksum = dccp_v6_csum_finish(skb, &rxip6h->saddr,\n\t\t\t\t\t\t\t &rxip6h->daddr);",
"\tmemset(&fl6, 0, sizeof(fl6));\n\tfl6.daddr = rxip6h->saddr;\n\tfl6.saddr = rxip6h->daddr;",
"\tfl6.flowi6_proto = IPPROTO_DCCP;\n\tfl6.flowi6_oif = inet6_iif(rxskb);\n\tfl6.fl6_dport = dccp_hdr(skb)->dccph_dport;\n\tfl6.fl6_sport = dccp_hdr(skb)->dccph_sport;\n\tsecurity_skb_classify_flow(rxskb, flowi6_to_flowi(&fl6));",
"\t/* sk = NULL, but it is safe for now. RST socket required. */\n\tdst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);\n\tif (!IS_ERR(dst)) {\n\t\tskb_dst_set(skb, dst);\n\t\tip6_xmit(ctl_sk, skb, &fl6, 0, NULL, 0);\n\t\tDCCP_INC_STATS(DCCP_MIB_OUTSEGS);\n\t\tDCCP_INC_STATS(DCCP_MIB_OUTRSTS);\n\t\treturn;\n\t}",
"\tkfree_skb(skb);\n}",
"static struct request_sock_ops dccp6_request_sock_ops = {\n\t.family\t\t= AF_INET6,\n\t.obj_size\t= sizeof(struct dccp6_request_sock),\n\t.rtx_syn_ack\t= dccp_v6_send_response,\n\t.send_ack\t= dccp_reqsk_send_ack,\n\t.destructor\t= dccp_v6_reqsk_destructor,\n\t.send_reset\t= dccp_v6_ctl_send_reset,\n\t.syn_ack_timeout = dccp_syn_ack_timeout,\n};",
"static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct request_sock *req;\n\tstruct dccp_request_sock *dreq;\n\tstruct inet_request_sock *ireq;\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tconst __be32 service = dccp_hdr_request(skb)->dccph_req_service;\n\tstruct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);",
"\tif (skb->protocol == htons(ETH_P_IP))\n\t\treturn dccp_v4_conn_request(sk, skb);",
"\tif (!ipv6_unicast_destination(skb))\n\t\treturn 0;\t/* discard, don't send a reset here */",
"\tif (dccp_bad_service_code(sk, service)) {\n\t\tdcb->dccpd_reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;\n\t\tgoto drop;\n\t}\n\t/*\n\t * There are no SYN attacks on IPv6, yet...\n\t */\n\tdcb->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY;\n\tif (inet_csk_reqsk_queue_is_full(sk))\n\t\tgoto drop;",
"\tif (sk_acceptq_is_full(sk))\n\t\tgoto drop;",
"\treq = inet_reqsk_alloc(&dccp6_request_sock_ops, sk, true);\n\tif (req == NULL)\n\t\tgoto drop;",
"\tif (dccp_reqsk_init(req, dccp_sk(sk), skb))\n\t\tgoto drop_and_free;",
"\tdreq = dccp_rsk(req);\n\tif (dccp_parse_options(sk, dreq, skb))\n\t\tgoto drop_and_free;",
"\tif (security_inet_conn_request(sk, skb, req))\n\t\tgoto drop_and_free;",
"\tireq = inet_rsk(req);\n\tireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;\n\tireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;\n\tireq->ireq_family = AF_INET6;",
"\tif (ipv6_opt_accepted(sk, skb, IP6CB(skb)) ||\n\t np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||\n\t np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) {\n\t\tatomic_inc(&skb->users);\n\t\tireq->pktopts = skb;\n\t}\n\tireq->ir_iif = sk->sk_bound_dev_if;",
"\t/* So that link locals have meaning */\n\tif (!sk->sk_bound_dev_if &&\n\t ipv6_addr_type(&ireq->ir_v6_rmt_addr) & IPV6_ADDR_LINKLOCAL)\n\t\tireq->ir_iif = inet6_iif(skb);",
"\t/*\n\t * Step 3: Process LISTEN state\n\t *\n\t * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie\n\t *\n\t * Setting S.SWL/S.SWH to is deferred to dccp_create_openreq_child().\n\t */\n\tdreq->dreq_isr\t = dcb->dccpd_seq;\n\tdreq->dreq_gsr = dreq->dreq_isr;\n\tdreq->dreq_iss\t = dccp_v6_init_sequence(skb);\n\tdreq->dreq_gss = dreq->dreq_iss;\n\tdreq->dreq_service = service;",
"\tif (dccp_v6_send_response(sk, req))\n\t\tgoto drop_and_free;",
"\tinet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);\n\treturn 0;",
"drop_and_free:\n\treqsk_free(req);\ndrop:\n\t__DCCP_INC_STATS(DCCP_MIB_ATTEMPTFAILS);\n\treturn -1;\n}",
"static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,\n\t\t\t\t\t struct sk_buff *skb,\n\t\t\t\t\t struct request_sock *req,\n\t\t\t\t\t struct dst_entry *dst,\n\t\t\t\t\t struct request_sock *req_unhash,\n\t\t\t\t\t bool *own_req)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ipv6_pinfo *newnp;\n\tconst struct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct ipv6_txoptions *opt;\n\tstruct inet_sock *newinet;\n\tstruct dccp6_sock *newdp6;\n\tstruct sock *newsk;",
"\tif (skb->protocol == htons(ETH_P_IP)) {\n\t\t/*\n\t\t *\tv6 mapped\n\t\t */\n\t\tnewsk = dccp_v4_request_recv_sock(sk, skb, req, dst,\n\t\t\t\t\t\t req_unhash, own_req);\n\t\tif (newsk == NULL)\n\t\t\treturn NULL;",
"\t\tnewdp6 = (struct dccp6_sock *)newsk;\n\t\tnewinet = inet_sk(newsk);\n\t\tnewinet->pinet6 = &newdp6->inet6;\n\t\tnewnp = inet6_sk(newsk);",
"\t\tmemcpy(newnp, np, sizeof(struct ipv6_pinfo));",
"\t\tnewnp->saddr = newsk->sk_v6_rcv_saddr;",
"\t\tinet_csk(newsk)->icsk_af_ops = &dccp_ipv6_mapped;\n\t\tnewsk->sk_backlog_rcv = dccp_v4_do_rcv;\n\t\tnewnp->pktoptions = NULL;\n\t\tnewnp->opt\t = NULL;",
"",
"\t\tnewnp->mcast_oif = inet6_iif(skb);\n\t\tnewnp->mcast_hops = ipv6_hdr(skb)->hop_limit;",
"\t\t/*\n\t\t * No need to charge this sock to the relevant IPv6 refcnt debug socks count\n\t\t * here, dccp_create_openreq_child now does this for us, see the comment in\n\t\t * that function for the gory details. -acme\n\t\t */",
"\t\t/* It is tricky place. Until this moment IPv4 tcp\n\t\t worked with IPv6 icsk.icsk_af_ops.\n\t\t Sync it now.\n\t\t */\n\t\tdccp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie);",
"\t\treturn newsk;\n\t}",
"\n\tif (sk_acceptq_is_full(sk))\n\t\tgoto out_overflow;",
"\tif (!dst) {\n\t\tstruct flowi6 fl6;",
"\t\tdst = inet6_csk_route_req(sk, &fl6, req, IPPROTO_DCCP);\n\t\tif (!dst)\n\t\t\tgoto out;\n\t}",
"\tnewsk = dccp_create_openreq_child(sk, req, skb);\n\tif (newsk == NULL)\n\t\tgoto out_nonewsk;",
"\t/*\n\t * No need to charge this sock to the relevant IPv6 refcnt debug socks\n\t * count here, dccp_create_openreq_child now does this for us, see the\n\t * comment in that function for the gory details. -acme\n\t */",
"\tip6_dst_store(newsk, dst, NULL, NULL);\n\tnewsk->sk_route_caps = dst->dev->features & ~(NETIF_F_IP_CSUM |\n\t\t\t\t\t\t NETIF_F_TSO);\n\tnewdp6 = (struct dccp6_sock *)newsk;\n\tnewinet = inet_sk(newsk);\n\tnewinet->pinet6 = &newdp6->inet6;\n\tnewnp = inet6_sk(newsk);",
"\tmemcpy(newnp, np, sizeof(struct ipv6_pinfo));",
"\tnewsk->sk_v6_daddr\t= ireq->ir_v6_rmt_addr;\n\tnewnp->saddr\t\t= ireq->ir_v6_loc_addr;\n\tnewsk->sk_v6_rcv_saddr\t= ireq->ir_v6_loc_addr;\n\tnewsk->sk_bound_dev_if\t= ireq->ir_iif;",
"\t/* Now IPv6 options...",
"\t First: no IPv4 options.\n\t */\n\tnewinet->inet_opt = NULL;",
"\t/* Clone RX bits */\n\tnewnp->rxopt.all = np->rxopt.all;\n",
"",
"\tnewnp->pktoptions = NULL;\n\tnewnp->opt\t = NULL;\n\tnewnp->mcast_oif = inet6_iif(skb);\n\tnewnp->mcast_hops = ipv6_hdr(skb)->hop_limit;",
"\t/*\n\t * Clone native IPv6 options from listening socket (if any)\n\t *\n\t * Yes, keeping reference count would be much more clever, but we make\n\t * one more one thing there: reattach optmem to newsk.\n\t */\n\topt = ireq->ipv6_opt;\n\tif (!opt)\n\t\topt = rcu_dereference(np->opt);\n\tif (opt) {\n\t\topt = ipv6_dup_options(newsk, opt);\n\t\tRCU_INIT_POINTER(newnp->opt, opt);\n\t}\n\tinet_csk(newsk)->icsk_ext_hdr_len = 0;\n\tif (opt)\n\t\tinet_csk(newsk)->icsk_ext_hdr_len = opt->opt_nflen +\n\t\t\t\t\t\t opt->opt_flen;",
"\tdccp_sync_mss(newsk, dst_mtu(dst));",
"\tnewinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6;\n\tnewinet->inet_rcv_saddr = LOOPBACK4_IPV6;",
"\tif (__inet_inherit_port(sk, newsk) < 0) {\n\t\tinet_csk_prepare_forced_close(newsk);\n\t\tdccp_done(newsk);\n\t\tgoto out;\n\t}\n\t*own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));\n\t/* Clone pktoptions received with SYN, if we own the req */\n\tif (*own_req && ireq->pktopts) {\n\t\tnewnp->pktoptions = skb_clone(ireq->pktopts, GFP_ATOMIC);\n\t\tconsume_skb(ireq->pktopts);\n\t\tireq->pktopts = NULL;\n\t\tif (newnp->pktoptions)\n\t\t\tskb_set_owner_r(newnp->pktoptions, newsk);\n\t}",
"\treturn newsk;",
"out_overflow:\n\t__NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);\nout_nonewsk:\n\tdst_release(dst);\nout:\n\t__NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENDROPS);\n\treturn NULL;\n}",
"/* The socket must have it's spinlock held when we get\n * here.\n *\n * We have a potential double-lock case here, so even when\n * doing backlog processing we use the BH locking scheme.\n * This is because we cannot sleep with the original spinlock\n * held.\n */\nstatic int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct sk_buff *opt_skb = NULL;",
"\t/* Imagine: socket is IPv6. IPv4 packet arrives,\n\t goes to IPv4 receive handler and backlogged.\n\t From backlog it always goes here. Kerboom...\n\t Fortunately, dccp_rcv_established and rcv_established\n\t handle them correctly, but it is not case with\n\t dccp_v6_hnd_req and dccp_v6_ctl_send_reset(). --ANK\n\t */",
"\tif (skb->protocol == htons(ETH_P_IP))\n\t\treturn dccp_v4_do_rcv(sk, skb);",
"\tif (sk_filter(sk, skb))\n\t\tgoto discard;",
"\t/*\n\t * socket locking is here for SMP purposes as backlog rcv is currently\n\t * called with bh processing disabled.\n\t */",
"\t/* Do Stevens' IPV6_PKTOPTIONS.",
"\t Yes, guys, it is the only place in our code, where we\n\t may make it not affecting IPv4.\n\t The rest of code is protocol independent,\n\t and I do not like idea to uglify IPv4.",
"\t Actually, all the idea behind IPV6_PKTOPTIONS\n\t looks not very well thought. For now we latch\n\t options, received in the last packet, enqueued\n\t by tcp. Feel free to propose better solution.\n\t\t\t\t\t --ANK (980728)\n\t */\n\tif (np->rxopt.all)\n\t/*\n\t * FIXME: Add handling of IPV6_PKTOPTIONS skb. See the comments below\n\t * (wrt ipv6_pktopions) and net/ipv6/tcp_ipv6.c for an example.\n\t */\n\t\topt_skb = skb_clone(skb, GFP_ATOMIC);",
"\tif (sk->sk_state == DCCP_OPEN) { /* Fast path */\n\t\tif (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len))\n\t\t\tgoto reset;\n\t\tif (opt_skb) {\n\t\t\t/* XXX This is where we would goto ipv6_pktoptions. */\n\t\t\t__kfree_skb(opt_skb);\n\t\t}\n\t\treturn 0;\n\t}",
"\t/*\n\t * Step 3: Process LISTEN state\n\t * If S.state == LISTEN,\n\t *\t If P.type == Request or P contains a valid Init Cookie option,\n\t *\t (* Must scan the packet's options to check for Init\n\t *\t\t Cookies. Only Init Cookies are processed here,\n\t *\t\t however; other options are processed in Step 8. This\n\t *\t\t scan need only be performed if the endpoint uses Init\n\t *\t\t Cookies *)\n\t *\t (* Generate a new socket and switch to that socket *)\n\t *\t Set S := new socket for this port pair\n\t *\t S.state = RESPOND\n\t *\t Choose S.ISS (initial seqno) or set from Init Cookies\n\t *\t Initialize S.GAR := S.ISS\n\t *\t Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies\n\t *\t Continue with S.state == RESPOND\n\t *\t (* A Response packet will be generated in Step 11 *)\n\t *\t Otherwise,\n\t *\t Generate Reset(No Connection) unless P.type == Reset\n\t *\t Drop packet and return\n\t *\n\t * NOTE: the check for the packet types is done in\n\t *\t dccp_rcv_state_process\n\t */",
"\tif (dccp_rcv_state_process(sk, skb, dccp_hdr(skb), skb->len))\n\t\tgoto reset;\n\tif (opt_skb) {\n\t\t/* XXX This is where we would goto ipv6_pktoptions. */\n\t\t__kfree_skb(opt_skb);\n\t}\n\treturn 0;",
"reset:\n\tdccp_v6_ctl_send_reset(sk, skb);\ndiscard:\n\tif (opt_skb != NULL)\n\t\t__kfree_skb(opt_skb);\n\tkfree_skb(skb);\n\treturn 0;\n}",
"static int dccp_v6_rcv(struct sk_buff *skb)\n{\n\tconst struct dccp_hdr *dh;\n\tbool refcounted;\n\tstruct sock *sk;\n\tint min_cov;",
"\t/* Step 1: Check header basics */",
"\tif (dccp_invalid_packet(skb))\n\t\tgoto discard_it;",
"\t/* Step 1: If header checksum is incorrect, drop packet and return. */\n\tif (dccp_v6_csum_finish(skb, &ipv6_hdr(skb)->saddr,\n\t\t\t\t &ipv6_hdr(skb)->daddr)) {\n\t\tDCCP_WARN(\"dropped packet with invalid checksum\\n\");\n\t\tgoto discard_it;\n\t}",
"\tdh = dccp_hdr(skb);",
"\tDCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh);\n\tDCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;",
"\tif (dccp_packet_without_ack(skb))\n\t\tDCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ;\n\telse\n\t\tDCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);",
"lookup:\n\tsk = __inet6_lookup_skb(&dccp_hashinfo, skb, __dccp_hdr_len(dh),\n\t\t\t dh->dccph_sport, dh->dccph_dport,\n\t\t\t\tinet6_iif(skb), &refcounted);\n\tif (!sk) {\n\t\tdccp_pr_debug(\"failed to look up flow ID in table and \"\n\t\t\t \"get corresponding socket\\n\");\n\t\tgoto no_dccp_socket;\n\t}",
"\t/*\n\t * Step 2:\n\t *\t... or S.state == TIMEWAIT,\n\t *\t\tGenerate Reset(No Connection) unless P.type == Reset\n\t *\t\tDrop packet and return\n\t */\n\tif (sk->sk_state == DCCP_TIME_WAIT) {\n\t\tdccp_pr_debug(\"sk->sk_state == DCCP_TIME_WAIT: do_time_wait\\n\");\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\tgoto no_dccp_socket;\n\t}",
"\tif (sk->sk_state == DCCP_NEW_SYN_RECV) {\n\t\tstruct request_sock *req = inet_reqsk(sk);\n\t\tstruct sock *nsk;",
"\t\tsk = req->rsk_listener;\n\t\tif (unlikely(sk->sk_state != DCCP_LISTEN)) {\n\t\t\tinet_csk_reqsk_queue_drop_and_put(sk, req);\n\t\t\tgoto lookup;\n\t\t}\n\t\tsock_hold(sk);\n\t\trefcounted = true;\n\t\tnsk = dccp_check_req(sk, skb, req);\n\t\tif (!nsk) {\n\t\t\treqsk_put(req);\n\t\t\tgoto discard_and_relse;\n\t\t}\n\t\tif (nsk == sk) {\n\t\t\treqsk_put(req);\n\t\t} else if (dccp_child_process(sk, nsk, skb)) {\n\t\t\tdccp_v6_ctl_send_reset(sk, skb);\n\t\t\tgoto discard_and_relse;\n\t\t} else {\n\t\t\tsock_put(sk);\n\t\t\treturn 0;\n\t\t}\n\t}\n\t/*\n\t * RFC 4340, sec. 9.2.1: Minimum Checksum Coverage\n\t *\to if MinCsCov = 0, only packets with CsCov = 0 are accepted\n\t *\to if MinCsCov > 0, also accept packets with CsCov >= MinCsCov\n\t */\n\tmin_cov = dccp_sk(sk)->dccps_pcrlen;\n\tif (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {\n\t\tdccp_pr_debug(\"Packet CsCov %d does not satisfy MinCsCov %d\\n\",\n\t\t\t dh->dccph_cscov, min_cov);\n\t\t/* FIXME: send Data Dropped option (see also dccp_v4_rcv) */\n\t\tgoto discard_and_relse;\n\t}",
"\tif (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))\n\t\tgoto discard_and_relse;",
"\treturn __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4,\n\t\t\t\trefcounted) ? -1 : 0;",
"no_dccp_socket:\n\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))\n\t\tgoto discard_it;\n\t/*\n\t * Step 2:\n\t *\tIf no socket ...\n\t *\t\tGenerate Reset(No Connection) unless P.type == Reset\n\t *\t\tDrop packet and return\n\t */\n\tif (dh->dccph_type != DCCP_PKT_RESET) {\n\t\tDCCP_SKB_CB(skb)->dccpd_reset_code =\n\t\t\t\t\tDCCP_RESET_CODE_NO_CONNECTION;\n\t\tdccp_v6_ctl_send_reset(sk, skb);\n\t}",
"discard_it:\n\tkfree_skb(skb);\n\treturn 0;",
"discard_and_relse:\n\tif (refcounted)\n\t\tsock_put(sk);\n\tgoto discard_it;\n}",
"static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,\n\t\t\t int addr_len)\n{\n\tstruct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr;\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct dccp_sock *dp = dccp_sk(sk);\n\tstruct in6_addr *saddr = NULL, *final_p, final;\n\tstruct ipv6_txoptions *opt;\n\tstruct flowi6 fl6;\n\tstruct dst_entry *dst;\n\tint addr_type;\n\tint err;",
"\tdp->dccps_role = DCCP_ROLE_CLIENT;",
"\tif (addr_len < SIN6_LEN_RFC2133)\n\t\treturn -EINVAL;",
"\tif (usin->sin6_family != AF_INET6)\n\t\treturn -EAFNOSUPPORT;",
"\tmemset(&fl6, 0, sizeof(fl6));",
"\tif (np->sndflow) {\n\t\tfl6.flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK;\n\t\tIP6_ECN_flow_init(fl6.flowlabel);\n\t\tif (fl6.flowlabel & IPV6_FLOWLABEL_MASK) {\n\t\t\tstruct ip6_flowlabel *flowlabel;\n\t\t\tflowlabel = fl6_sock_lookup(sk, fl6.flowlabel);\n\t\t\tif (flowlabel == NULL)\n\t\t\t\treturn -EINVAL;\n\t\t\tfl6_sock_release(flowlabel);\n\t\t}\n\t}\n\t/*\n\t * connect() to INADDR_ANY means loopback (BSD'ism).\n\t */\n\tif (ipv6_addr_any(&usin->sin6_addr))\n\t\tusin->sin6_addr.s6_addr[15] = 1;",
"\taddr_type = ipv6_addr_type(&usin->sin6_addr);",
"\tif (addr_type & IPV6_ADDR_MULTICAST)\n\t\treturn -ENETUNREACH;",
"\tif (addr_type & IPV6_ADDR_LINKLOCAL) {\n\t\tif (addr_len >= sizeof(struct sockaddr_in6) &&\n\t\t usin->sin6_scope_id) {\n\t\t\t/* If interface is set while binding, indices\n\t\t\t * must coincide.\n\t\t\t */\n\t\t\tif (sk->sk_bound_dev_if &&\n\t\t\t sk->sk_bound_dev_if != usin->sin6_scope_id)\n\t\t\t\treturn -EINVAL;",
"\t\t\tsk->sk_bound_dev_if = usin->sin6_scope_id;\n\t\t}",
"\t\t/* Connect to link-local address requires an interface */\n\t\tif (!sk->sk_bound_dev_if)\n\t\t\treturn -EINVAL;\n\t}",
"\tsk->sk_v6_daddr = usin->sin6_addr;\n\tnp->flow_label = fl6.flowlabel;",
"\t/*\n\t * DCCP over IPv4\n\t */\n\tif (addr_type == IPV6_ADDR_MAPPED) {\n\t\tu32 exthdrlen = icsk->icsk_ext_hdr_len;\n\t\tstruct sockaddr_in sin;",
"\t\tSOCK_DEBUG(sk, \"connect: ipv4 mapped\\n\");",
"\t\tif (__ipv6_only_sock(sk))\n\t\t\treturn -ENETUNREACH;",
"\t\tsin.sin_family = AF_INET;\n\t\tsin.sin_port = usin->sin6_port;\n\t\tsin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];",
"\t\ticsk->icsk_af_ops = &dccp_ipv6_mapped;\n\t\tsk->sk_backlog_rcv = dccp_v4_do_rcv;",
"\t\terr = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));\n\t\tif (err) {\n\t\t\ticsk->icsk_ext_hdr_len = exthdrlen;\n\t\t\ticsk->icsk_af_ops = &dccp_ipv6_af_ops;\n\t\t\tsk->sk_backlog_rcv = dccp_v6_do_rcv;\n\t\t\tgoto failure;\n\t\t}\n\t\tnp->saddr = sk->sk_v6_rcv_saddr;\n\t\treturn err;\n\t}",
"\tif (!ipv6_addr_any(&sk->sk_v6_rcv_saddr))\n\t\tsaddr = &sk->sk_v6_rcv_saddr;",
"\tfl6.flowi6_proto = IPPROTO_DCCP;\n\tfl6.daddr = sk->sk_v6_daddr;\n\tfl6.saddr = saddr ? *saddr : np->saddr;\n\tfl6.flowi6_oif = sk->sk_bound_dev_if;\n\tfl6.fl6_dport = usin->sin6_port;\n\tfl6.fl6_sport = inet->inet_sport;\n\tsecurity_sk_classify_flow(sk, flowi6_to_flowi(&fl6));",
"\topt = rcu_dereference_protected(np->opt, lockdep_sock_is_held(sk));\n\tfinal_p = fl6_update_dst(&fl6, opt, &final);",
"\tdst = ip6_dst_lookup_flow(sk, &fl6, final_p);\n\tif (IS_ERR(dst)) {\n\t\terr = PTR_ERR(dst);\n\t\tgoto failure;\n\t}",
"\tif (saddr == NULL) {\n\t\tsaddr = &fl6.saddr;\n\t\tsk->sk_v6_rcv_saddr = *saddr;\n\t}",
"\t/* set the source address */\n\tnp->saddr = *saddr;\n\tinet->inet_rcv_saddr = LOOPBACK4_IPV6;",
"\tip6_dst_store(sk, dst, NULL, NULL);",
"\ticsk->icsk_ext_hdr_len = 0;\n\tif (opt)\n\t\ticsk->icsk_ext_hdr_len = opt->opt_flen + opt->opt_nflen;",
"\tinet->inet_dport = usin->sin6_port;",
"\tdccp_set_state(sk, DCCP_REQUESTING);\n\terr = inet6_hash_connect(&dccp_death_row, sk);\n\tif (err)\n\t\tgoto late_failure;",
"\tdp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32,\n\t\t\t\t\t\t sk->sk_v6_daddr.s6_addr32,\n\t\t\t\t\t\t inet->inet_sport,\n\t\t\t\t\t\t inet->inet_dport);\n\terr = dccp_connect(sk);\n\tif (err)\n\t\tgoto late_failure;",
"\treturn 0;",
"late_failure:\n\tdccp_set_state(sk, DCCP_CLOSED);\n\t__sk_dst_reset(sk);\nfailure:\n\tinet->inet_dport = 0;\n\tsk->sk_route_caps = 0;\n\treturn err;\n}",
"static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops = {\n\t.queue_xmit\t = inet6_csk_xmit,\n\t.send_check\t = dccp_v6_send_check,\n\t.rebuild_header\t = inet6_sk_rebuild_header,\n\t.conn_request\t = dccp_v6_conn_request,\n\t.syn_recv_sock\t = dccp_v6_request_recv_sock,\n\t.net_header_len\t = sizeof(struct ipv6hdr),\n\t.setsockopt\t = ipv6_setsockopt,\n\t.getsockopt\t = ipv6_getsockopt,\n\t.addr2sockaddr\t = inet6_csk_addr2sockaddr,\n\t.sockaddr_len\t = sizeof(struct sockaddr_in6),\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_ipv6_setsockopt,\n\t.compat_getsockopt = compat_ipv6_getsockopt,\n#endif\n};",
"/*\n *\tDCCP over IPv4 via INET6 API\n */\nstatic const struct inet_connection_sock_af_ops dccp_ipv6_mapped = {\n\t.queue_xmit\t = ip_queue_xmit,\n\t.send_check\t = dccp_v4_send_check,\n\t.rebuild_header\t = inet_sk_rebuild_header,\n\t.conn_request\t = dccp_v6_conn_request,\n\t.syn_recv_sock\t = dccp_v6_request_recv_sock,\n\t.net_header_len\t = sizeof(struct iphdr),\n\t.setsockopt\t = ipv6_setsockopt,\n\t.getsockopt\t = ipv6_getsockopt,\n\t.addr2sockaddr\t = inet6_csk_addr2sockaddr,\n\t.sockaddr_len\t = sizeof(struct sockaddr_in6),\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_ipv6_setsockopt,\n\t.compat_getsockopt = compat_ipv6_getsockopt,\n#endif\n};",
"/* NOTE: A lot of things set to zero explicitly by call to\n * sk_alloc() so need not be done here.\n */\nstatic int dccp_v6_init_sock(struct sock *sk)\n{\n\tstatic __u8 dccp_v6_ctl_sock_initialized;\n\tint err = dccp_init_sock(sk, dccp_v6_ctl_sock_initialized);",
"\tif (err == 0) {\n\t\tif (unlikely(!dccp_v6_ctl_sock_initialized))\n\t\t\tdccp_v6_ctl_sock_initialized = 1;\n\t\tinet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops;\n\t}",
"\treturn err;\n}",
"static void dccp_v6_destroy_sock(struct sock *sk)\n{\n\tdccp_destroy_sock(sk);\n\tinet6_destroy_sock(sk);\n}",
"static struct timewait_sock_ops dccp6_timewait_sock_ops = {\n\t.twsk_obj_size\t= sizeof(struct dccp6_timewait_sock),\n};",
"static struct proto dccp_v6_prot = {\n\t.name\t\t = \"DCCPv6\",\n\t.owner\t\t = THIS_MODULE,\n\t.close\t\t = dccp_close,\n\t.connect\t = dccp_v6_connect,\n\t.disconnect\t = dccp_disconnect,\n\t.ioctl\t\t = dccp_ioctl,\n\t.init\t\t = dccp_v6_init_sock,\n\t.setsockopt\t = dccp_setsockopt,\n\t.getsockopt\t = dccp_getsockopt,\n\t.sendmsg\t = dccp_sendmsg,\n\t.recvmsg\t = dccp_recvmsg,\n\t.backlog_rcv\t = dccp_v6_do_rcv,\n\t.hash\t\t = inet6_hash,\n\t.unhash\t\t = inet_unhash,\n\t.accept\t\t = inet_csk_accept,\n\t.get_port\t = inet_csk_get_port,\n\t.shutdown\t = dccp_shutdown,\n\t.destroy\t = dccp_v6_destroy_sock,\n\t.orphan_count\t = &dccp_orphan_count,\n\t.max_header\t = MAX_DCCP_HEADER,\n\t.obj_size\t = sizeof(struct dccp6_sock),\n\t.slab_flags\t = SLAB_DESTROY_BY_RCU,\n\t.rsk_prot\t = &dccp6_request_sock_ops,\n\t.twsk_prot\t = &dccp6_timewait_sock_ops,\n\t.h.hashinfo\t = &dccp_hashinfo,\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_dccp_setsockopt,\n\t.compat_getsockopt = compat_dccp_getsockopt,\n#endif\n};",
"static const struct inet6_protocol dccp_v6_protocol = {\n\t.handler\t= dccp_v6_rcv,\n\t.err_handler\t= dccp_v6_err,\n\t.flags\t\t= INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,\n};",
"static const struct proto_ops inet6_dccp_ops = {\n\t.family\t\t = PF_INET6,\n\t.owner\t\t = THIS_MODULE,\n\t.release\t = inet6_release,\n\t.bind\t\t = inet6_bind,\n\t.connect\t = inet_stream_connect,\n\t.socketpair\t = sock_no_socketpair,\n\t.accept\t\t = inet_accept,\n\t.getname\t = inet6_getname,\n\t.poll\t\t = dccp_poll,\n\t.ioctl\t\t = inet6_ioctl,\n\t.listen\t\t = inet_dccp_listen,\n\t.shutdown\t = inet_shutdown,\n\t.setsockopt\t = sock_common_setsockopt,\n\t.getsockopt\t = sock_common_getsockopt,\n\t.sendmsg\t = inet_sendmsg,\n\t.recvmsg\t = sock_common_recvmsg,\n\t.mmap\t\t = sock_no_mmap,\n\t.sendpage\t = sock_no_sendpage,\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_sock_common_setsockopt,\n\t.compat_getsockopt = compat_sock_common_getsockopt,\n#endif\n};",
"static struct inet_protosw dccp_v6_protosw = {\n\t.type\t\t= SOCK_DCCP,\n\t.protocol\t= IPPROTO_DCCP,\n\t.prot\t\t= &dccp_v6_prot,\n\t.ops\t\t= &inet6_dccp_ops,\n\t.flags\t\t= INET_PROTOSW_ICSK,\n};",
"static int __net_init dccp_v6_init_net(struct net *net)\n{\n\tif (dccp_hashinfo.bhash == NULL)\n\t\treturn -ESOCKTNOSUPPORT;",
"\treturn inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6,\n\t\t\t\t SOCK_DCCP, IPPROTO_DCCP, net);\n}",
"static void __net_exit dccp_v6_exit_net(struct net *net)\n{\n\tinet_ctl_sock_destroy(net->dccp.v6_ctl_sk);\n}",
"static void __net_exit dccp_v6_exit_batch(struct list_head *net_exit_list)\n{\n\tinet_twsk_purge(&dccp_hashinfo, AF_INET6);\n}",
"static struct pernet_operations dccp_v6_ops = {\n\t.init = dccp_v6_init_net,\n\t.exit = dccp_v6_exit_net,\n\t.exit_batch = dccp_v6_exit_batch,\n};",
"static int __init dccp_v6_init(void)\n{\n\tint err = proto_register(&dccp_v6_prot, 1);",
"\tif (err != 0)\n\t\tgoto out;",
"\terr = inet6_add_protocol(&dccp_v6_protocol, IPPROTO_DCCP);\n\tif (err != 0)\n\t\tgoto out_unregister_proto;",
"\tinet6_register_protosw(&dccp_v6_protosw);",
"\terr = register_pernet_subsys(&dccp_v6_ops);\n\tif (err != 0)\n\t\tgoto out_destroy_ctl_sock;\nout:\n\treturn err;",
"out_destroy_ctl_sock:\n\tinet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);\n\tinet6_unregister_protosw(&dccp_v6_protosw);\nout_unregister_proto:\n\tproto_unregister(&dccp_v6_prot);\n\tgoto out;\n}",
"static void __exit dccp_v6_exit(void)\n{\n\tunregister_pernet_subsys(&dccp_v6_ops);\n\tinet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);\n\tinet6_unregister_protosw(&dccp_v6_protosw);\n\tproto_unregister(&dccp_v6_prot);\n}",
"module_init(dccp_v6_init);\nmodule_exit(dccp_v6_exit);",
"/*\n * __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)\n * values directly, Also cover the case where the protocol is not specified,\n * i.e. net-pf-PF_INET6-proto-0-type-SOCK_DCCP\n */\nMODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET6, 33, 6);\nMODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET6, 0, 6);\nMODULE_LICENSE(\"GPL\");\nMODULE_AUTHOR(\"Arnaldo Carvalho de Melo <acme@mandriva.com>\");\nMODULE_DESCRIPTION(\"DCCPv6 - Datagram Congestion Controlled Protocol\");"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
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
] |
PreciseBugs
|
{"buggy_code_end_loc": [492, 1133], "buggy_code_start_loc": [428, 1064], "filenames": ["net/dccp/ipv6.c", "net/ipv6/tcp_ipv6.c"], "fixing_code_end_loc": [499, 1136], "fixing_code_start_loc": [429, 1065], "message": "The dccp_v6_request_recv_sock function in net/dccp/ipv6.c in the Linux kernel through 4.11.1 mishandles inheritance, which allows local users to cause a denial of service or possibly have unspecified other impact via crafted system calls, a related issue to CVE-2017-8890.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "9A5C1F01-214B-4477-A3A1-F6DF10181D3C", "versionEndExcluding": "3.2.89", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "8C1901E2-6C4D-488B-A7CE-F7E14A38418F", "versionEndExcluding": "3.16.44", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.3", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "DB67DFF9-D1AD-49F9-AC6A-2BBFE1619CE2", "versionEndExcluding": "3.18.84", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.17", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "A4AF9D2F-2101-41EE-9E8C-95EE62CB1186", "versionEndExcluding": "4.4.71", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.19", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "001F55C3-810A-444F-AE18-F067A84F6B31", "versionEndExcluding": "4.9.31", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "4.5", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "1A25FD29-5617-4236-AC9A-6D68DC220925", "versionEndExcluding": "4.11.4", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "4.10", "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}], "descriptions": [{"lang": "en", "value": "The dccp_v6_request_recv_sock function in net/dccp/ipv6.c in the Linux kernel through 4.11.1 mishandles inheritance, which allows local users to cause a denial of service or possibly have unspecified other impact via crafted system calls, a related issue to CVE-2017-8890."}, {"lang": "es", "value": "La funci\u00f3n dccp_v6_request_recv_sock en el archivo net/dccp/ipv6.c en el kernel de Linux hasta versi\u00f3n 4.11.1, el manejo inapropiado de la herencia, permite a los usuarios locales causar una denegaci\u00f3n de servicio o posiblemente tener otro impacto no especificado por medio de llamadas de sistema dise\u00f1adas, un problema relacionado con CVE-2017 -8890."}], "evaluatorComment": null, "id": "CVE-2017-9076", "lastModified": "2023-02-24T18:39:05.640", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 7.2, "confidentialityImpact": "COMPLETE", "integrityImpact": "COMPLETE", "vectorString": "AV:L/AC:L/Au:N/C:C/I:C/A:C", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 10.0, "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": 7.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2017-05-19T07:29:00.307", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Vendor Advisory"], "url": "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=83eaddab4378db256d00d295bda6ca997cd13a52"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "http://www.debian.org/security/2017/dsa-3886"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/98586"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:1842"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:2077"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:2669"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:1854"}, {"source": "cve@mitre.org", "tags": ["Patch", "Vendor Advisory"], "url": "https://github.com/torvalds/linux/commit/83eaddab4378db256d00d295bda6ca997cd13a52"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://patchwork.ozlabs.org/patch/760370/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://source.android.com/security/bulletin/2017-09-01"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "NVD-CWE-noinfo"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/83eaddab4378db256d00d295bda6ca997cd13a52"}, "type": "NVD-CWE-noinfo"}
| 215
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n *\tDCCP over IPv6\n *\tLinux INET6 implementation\n *\n *\tBased on net/dccp6/ipv6.c\n *\n *\tArnaldo Carvalho de Melo <acme@ghostprotocols.net>\n *\n *\tThis 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 */",
"#include <linux/module.h>\n#include <linux/random.h>\n#include <linux/slab.h>\n#include <linux/xfrm.h>",
"#include <net/addrconf.h>\n#include <net/inet_common.h>\n#include <net/inet_hashtables.h>\n#include <net/inet_sock.h>\n#include <net/inet6_connection_sock.h>\n#include <net/inet6_hashtables.h>\n#include <net/ip6_route.h>\n#include <net/ipv6.h>\n#include <net/protocol.h>\n#include <net/transp_v6.h>\n#include <net/ip6_checksum.h>\n#include <net/xfrm.h>\n#include <net/secure_seq.h>",
"#include \"dccp.h\"\n#include \"ipv6.h\"\n#include \"feat.h\"",
"/* The per-net dccp.v6_ctl_sk is used for sending RSTs and ACKs */",
"static const struct inet_connection_sock_af_ops dccp_ipv6_mapped;\nstatic const struct inet_connection_sock_af_ops dccp_ipv6_af_ops;",
"/* add pseudo-header to DCCP checksum stored in skb->csum */\nstatic inline __sum16 dccp_v6_csum_finish(struct sk_buff *skb,\n\t\t\t\t const struct in6_addr *saddr,\n\t\t\t\t const struct in6_addr *daddr)\n{\n\treturn csum_ipv6_magic(saddr, daddr, skb->len, IPPROTO_DCCP, skb->csum);\n}",
"static inline void dccp_v6_send_check(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct dccp_hdr *dh = dccp_hdr(skb);",
"\tdccp_csum_outgoing(skb);\n\tdh->dccph_checksum = dccp_v6_csum_finish(skb, &np->saddr, &sk->sk_v6_daddr);\n}",
"static inline __u64 dccp_v6_init_sequence(struct sk_buff *skb)\n{\n\treturn secure_dccpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,\n\t\t\t\t\t ipv6_hdr(skb)->saddr.s6_addr32,\n\t\t\t\t\t dccp_hdr(skb)->dccph_dport,\n\t\t\t\t\t dccp_hdr(skb)->dccph_sport );",
"}",
"static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n\t\t\tu8 type, u8 code, int offset, __be32 info)\n{\n\tconst struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;\n\tconst struct dccp_hdr *dh;\n\tstruct dccp_sock *dp;\n\tstruct ipv6_pinfo *np;\n\tstruct sock *sk;\n\tint err;\n\t__u64 seq;\n\tstruct net *net = dev_net(skb->dev);",
"\t/* Only need dccph_dport & dccph_sport which are the first\n\t * 4 bytes in dccp header.\n\t * Our caller (icmpv6_notify()) already pulled 8 bytes for us.\n\t */\n\tBUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_sport) > 8);\n\tBUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_dport) > 8);\n\tdh = (struct dccp_hdr *)(skb->data + offset);",
"\tsk = __inet6_lookup_established(net, &dccp_hashinfo,\n\t\t\t\t\t&hdr->daddr, dh->dccph_dport,\n\t\t\t\t\t&hdr->saddr, ntohs(dh->dccph_sport),\n\t\t\t\t\tinet6_iif(skb));",
"\tif (!sk) {\n\t\t__ICMP6_INC_STATS(net, __in6_dev_get(skb->dev),\n\t\t\t\t ICMP6_MIB_INERRORS);\n\t\treturn;\n\t}",
"\tif (sk->sk_state == DCCP_TIME_WAIT) {\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\treturn;\n\t}\n\tseq = dccp_hdr_seq(dh);\n\tif (sk->sk_state == DCCP_NEW_SYN_RECV)\n\t\treturn dccp_req_err(sk, seq);",
"\tbh_lock_sock(sk);\n\tif (sock_owned_by_user(sk))\n\t\t__NET_INC_STATS(net, LINUX_MIB_LOCKDROPPEDICMPS);",
"\tif (sk->sk_state == DCCP_CLOSED)\n\t\tgoto out;",
"\tdp = dccp_sk(sk);\n\tif ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_LISTEN) &&\n\t !between48(seq, dp->dccps_awl, dp->dccps_awh)) {\n\t\t__NET_INC_STATS(net, LINUX_MIB_OUTOFWINDOWICMPS);\n\t\tgoto out;\n\t}",
"\tnp = inet6_sk(sk);",
"\tif (type == NDISC_REDIRECT) {\n\t\tif (!sock_owned_by_user(sk)) {\n\t\t\tstruct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);",
"\t\t\tif (dst)\n\t\t\t\tdst->ops->redirect(dst, sk, skb);\n\t\t}\n\t\tgoto out;\n\t}",
"\tif (type == ICMPV6_PKT_TOOBIG) {\n\t\tstruct dst_entry *dst = NULL;",
"\t\tif (!ip6_sk_accept_pmtu(sk))\n\t\t\tgoto out;",
"\t\tif (sock_owned_by_user(sk))\n\t\t\tgoto out;\n\t\tif ((1 << sk->sk_state) & (DCCPF_LISTEN | DCCPF_CLOSED))\n\t\t\tgoto out;",
"\t\tdst = inet6_csk_update_pmtu(sk, ntohl(info));\n\t\tif (!dst)\n\t\t\tgoto out;",
"\t\tif (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst))\n\t\t\tdccp_sync_mss(sk, dst_mtu(dst));\n\t\tgoto out;\n\t}",
"\ticmpv6_err_convert(type, code, &err);",
"\t/* Might be for an request_sock */\n\tswitch (sk->sk_state) {\n\tcase DCCP_REQUESTING:\n\tcase DCCP_RESPOND: /* Cannot happen.\n\t\t\t It can, it SYNs are crossed. --ANK */\n\t\tif (!sock_owned_by_user(sk)) {\n\t\t\t__DCCP_INC_STATS(DCCP_MIB_ATTEMPTFAILS);\n\t\t\tsk->sk_err = err;\n\t\t\t/*\n\t\t\t * Wake people up to see the error\n\t\t\t * (see connect in sock.c)\n\t\t\t */\n\t\t\tsk->sk_error_report(sk);\n\t\t\tdccp_done(sk);\n\t\t} else\n\t\t\tsk->sk_err_soft = err;\n\t\tgoto out;\n\t}",
"\tif (!sock_owned_by_user(sk) && np->recverr) {\n\t\tsk->sk_err = err;\n\t\tsk->sk_error_report(sk);\n\t} else\n\t\tsk->sk_err_soft = err;",
"out:\n\tbh_unlock_sock(sk);\n\tsock_put(sk);\n}",
"\nstatic int dccp_v6_send_response(const struct sock *sk, struct request_sock *req)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct sk_buff *skb;\n\tstruct in6_addr *final_p, final;\n\tstruct flowi6 fl6;\n\tint err = -1;\n\tstruct dst_entry *dst;",
"\tmemset(&fl6, 0, sizeof(fl6));\n\tfl6.flowi6_proto = IPPROTO_DCCP;\n\tfl6.daddr = ireq->ir_v6_rmt_addr;\n\tfl6.saddr = ireq->ir_v6_loc_addr;\n\tfl6.flowlabel = 0;\n\tfl6.flowi6_oif = ireq->ir_iif;\n\tfl6.fl6_dport = ireq->ir_rmt_port;\n\tfl6.fl6_sport = htons(ireq->ir_num);\n\tsecurity_req_classify_flow(req, flowi6_to_flowi(&fl6));",
"\n\trcu_read_lock();\n\tfinal_p = fl6_update_dst(&fl6, rcu_dereference(np->opt), &final);\n\trcu_read_unlock();",
"\tdst = ip6_dst_lookup_flow(sk, &fl6, final_p);\n\tif (IS_ERR(dst)) {\n\t\terr = PTR_ERR(dst);\n\t\tdst = NULL;\n\t\tgoto done;\n\t}",
"\tskb = dccp_make_response(sk, dst, req);\n\tif (skb != NULL) {\n\t\tstruct dccp_hdr *dh = dccp_hdr(skb);\n\t\tstruct ipv6_txoptions *opt;",
"\t\tdh->dccph_checksum = dccp_v6_csum_finish(skb,\n\t\t\t\t\t\t\t &ireq->ir_v6_loc_addr,\n\t\t\t\t\t\t\t &ireq->ir_v6_rmt_addr);\n\t\tfl6.daddr = ireq->ir_v6_rmt_addr;\n\t\trcu_read_lock();\n\t\topt = ireq->ipv6_opt;\n\t\tif (!opt)\n\t\t\topt = rcu_dereference(np->opt);\n\t\terr = ip6_xmit(sk, skb, &fl6, sk->sk_mark, opt, np->tclass);\n\t\trcu_read_unlock();\n\t\terr = net_xmit_eval(err);\n\t}",
"done:\n\tdst_release(dst);\n\treturn err;\n}",
"static void dccp_v6_reqsk_destructor(struct request_sock *req)\n{\n\tdccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg);\n\tkfree(inet_rsk(req)->ipv6_opt);\n\tkfree_skb(inet_rsk(req)->pktopts);\n}",
"static void dccp_v6_ctl_send_reset(const struct sock *sk, struct sk_buff *rxskb)\n{\n\tconst struct ipv6hdr *rxip6h;\n\tstruct sk_buff *skb;\n\tstruct flowi6 fl6;\n\tstruct net *net = dev_net(skb_dst(rxskb)->dev);\n\tstruct sock *ctl_sk = net->dccp.v6_ctl_sk;\n\tstruct dst_entry *dst;",
"\tif (dccp_hdr(rxskb)->dccph_type == DCCP_PKT_RESET)\n\t\treturn;",
"\tif (!ipv6_unicast_destination(rxskb))\n\t\treturn;",
"\tskb = dccp_ctl_make_reset(ctl_sk, rxskb);\n\tif (skb == NULL)\n\t\treturn;",
"\trxip6h = ipv6_hdr(rxskb);\n\tdccp_hdr(skb)->dccph_checksum = dccp_v6_csum_finish(skb, &rxip6h->saddr,\n\t\t\t\t\t\t\t &rxip6h->daddr);",
"\tmemset(&fl6, 0, sizeof(fl6));\n\tfl6.daddr = rxip6h->saddr;\n\tfl6.saddr = rxip6h->daddr;",
"\tfl6.flowi6_proto = IPPROTO_DCCP;\n\tfl6.flowi6_oif = inet6_iif(rxskb);\n\tfl6.fl6_dport = dccp_hdr(skb)->dccph_dport;\n\tfl6.fl6_sport = dccp_hdr(skb)->dccph_sport;\n\tsecurity_skb_classify_flow(rxskb, flowi6_to_flowi(&fl6));",
"\t/* sk = NULL, but it is safe for now. RST socket required. */\n\tdst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);\n\tif (!IS_ERR(dst)) {\n\t\tskb_dst_set(skb, dst);\n\t\tip6_xmit(ctl_sk, skb, &fl6, 0, NULL, 0);\n\t\tDCCP_INC_STATS(DCCP_MIB_OUTSEGS);\n\t\tDCCP_INC_STATS(DCCP_MIB_OUTRSTS);\n\t\treturn;\n\t}",
"\tkfree_skb(skb);\n}",
"static struct request_sock_ops dccp6_request_sock_ops = {\n\t.family\t\t= AF_INET6,\n\t.obj_size\t= sizeof(struct dccp6_request_sock),\n\t.rtx_syn_ack\t= dccp_v6_send_response,\n\t.send_ack\t= dccp_reqsk_send_ack,\n\t.destructor\t= dccp_v6_reqsk_destructor,\n\t.send_reset\t= dccp_v6_ctl_send_reset,\n\t.syn_ack_timeout = dccp_syn_ack_timeout,\n};",
"static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct request_sock *req;\n\tstruct dccp_request_sock *dreq;\n\tstruct inet_request_sock *ireq;\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tconst __be32 service = dccp_hdr_request(skb)->dccph_req_service;\n\tstruct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);",
"\tif (skb->protocol == htons(ETH_P_IP))\n\t\treturn dccp_v4_conn_request(sk, skb);",
"\tif (!ipv6_unicast_destination(skb))\n\t\treturn 0;\t/* discard, don't send a reset here */",
"\tif (dccp_bad_service_code(sk, service)) {\n\t\tdcb->dccpd_reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;\n\t\tgoto drop;\n\t}\n\t/*\n\t * There are no SYN attacks on IPv6, yet...\n\t */\n\tdcb->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY;\n\tif (inet_csk_reqsk_queue_is_full(sk))\n\t\tgoto drop;",
"\tif (sk_acceptq_is_full(sk))\n\t\tgoto drop;",
"\treq = inet_reqsk_alloc(&dccp6_request_sock_ops, sk, true);\n\tif (req == NULL)\n\t\tgoto drop;",
"\tif (dccp_reqsk_init(req, dccp_sk(sk), skb))\n\t\tgoto drop_and_free;",
"\tdreq = dccp_rsk(req);\n\tif (dccp_parse_options(sk, dreq, skb))\n\t\tgoto drop_and_free;",
"\tif (security_inet_conn_request(sk, skb, req))\n\t\tgoto drop_and_free;",
"\tireq = inet_rsk(req);\n\tireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;\n\tireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;\n\tireq->ireq_family = AF_INET6;",
"\tif (ipv6_opt_accepted(sk, skb, IP6CB(skb)) ||\n\t np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||\n\t np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) {\n\t\tatomic_inc(&skb->users);\n\t\tireq->pktopts = skb;\n\t}\n\tireq->ir_iif = sk->sk_bound_dev_if;",
"\t/* So that link locals have meaning */\n\tif (!sk->sk_bound_dev_if &&\n\t ipv6_addr_type(&ireq->ir_v6_rmt_addr) & IPV6_ADDR_LINKLOCAL)\n\t\tireq->ir_iif = inet6_iif(skb);",
"\t/*\n\t * Step 3: Process LISTEN state\n\t *\n\t * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie\n\t *\n\t * Setting S.SWL/S.SWH to is deferred to dccp_create_openreq_child().\n\t */\n\tdreq->dreq_isr\t = dcb->dccpd_seq;\n\tdreq->dreq_gsr = dreq->dreq_isr;\n\tdreq->dreq_iss\t = dccp_v6_init_sequence(skb);\n\tdreq->dreq_gss = dreq->dreq_iss;\n\tdreq->dreq_service = service;",
"\tif (dccp_v6_send_response(sk, req))\n\t\tgoto drop_and_free;",
"\tinet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);\n\treturn 0;",
"drop_and_free:\n\treqsk_free(req);\ndrop:\n\t__DCCP_INC_STATS(DCCP_MIB_ATTEMPTFAILS);\n\treturn -1;\n}",
"static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,\n\t\t\t\t\t struct sk_buff *skb,\n\t\t\t\t\t struct request_sock *req,\n\t\t\t\t\t struct dst_entry *dst,\n\t\t\t\t\t struct request_sock *req_unhash,\n\t\t\t\t\t bool *own_req)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ipv6_pinfo *newnp;\n\tconst struct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct ipv6_txoptions *opt;\n\tstruct inet_sock *newinet;\n\tstruct dccp6_sock *newdp6;\n\tstruct sock *newsk;",
"\tif (skb->protocol == htons(ETH_P_IP)) {\n\t\t/*\n\t\t *\tv6 mapped\n\t\t */\n\t\tnewsk = dccp_v4_request_recv_sock(sk, skb, req, dst,\n\t\t\t\t\t\t req_unhash, own_req);\n\t\tif (newsk == NULL)\n\t\t\treturn NULL;",
"\t\tnewdp6 = (struct dccp6_sock *)newsk;\n\t\tnewinet = inet_sk(newsk);\n\t\tnewinet->pinet6 = &newdp6->inet6;\n\t\tnewnp = inet6_sk(newsk);",
"\t\tmemcpy(newnp, np, sizeof(struct ipv6_pinfo));",
"\t\tnewnp->saddr = newsk->sk_v6_rcv_saddr;",
"\t\tinet_csk(newsk)->icsk_af_ops = &dccp_ipv6_mapped;\n\t\tnewsk->sk_backlog_rcv = dccp_v4_do_rcv;\n\t\tnewnp->pktoptions = NULL;\n\t\tnewnp->opt\t = NULL;",
"\t\tnewnp->ipv6_mc_list = NULL;\n\t\tnewnp->ipv6_ac_list = NULL;\n\t\tnewnp->ipv6_fl_list = NULL;",
"\t\tnewnp->mcast_oif = inet6_iif(skb);\n\t\tnewnp->mcast_hops = ipv6_hdr(skb)->hop_limit;",
"\t\t/*\n\t\t * No need to charge this sock to the relevant IPv6 refcnt debug socks count\n\t\t * here, dccp_create_openreq_child now does this for us, see the comment in\n\t\t * that function for the gory details. -acme\n\t\t */",
"\t\t/* It is tricky place. Until this moment IPv4 tcp\n\t\t worked with IPv6 icsk.icsk_af_ops.\n\t\t Sync it now.\n\t\t */\n\t\tdccp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie);",
"\t\treturn newsk;\n\t}",
"\n\tif (sk_acceptq_is_full(sk))\n\t\tgoto out_overflow;",
"\tif (!dst) {\n\t\tstruct flowi6 fl6;",
"\t\tdst = inet6_csk_route_req(sk, &fl6, req, IPPROTO_DCCP);\n\t\tif (!dst)\n\t\t\tgoto out;\n\t}",
"\tnewsk = dccp_create_openreq_child(sk, req, skb);\n\tif (newsk == NULL)\n\t\tgoto out_nonewsk;",
"\t/*\n\t * No need to charge this sock to the relevant IPv6 refcnt debug socks\n\t * count here, dccp_create_openreq_child now does this for us, see the\n\t * comment in that function for the gory details. -acme\n\t */",
"\tip6_dst_store(newsk, dst, NULL, NULL);\n\tnewsk->sk_route_caps = dst->dev->features & ~(NETIF_F_IP_CSUM |\n\t\t\t\t\t\t NETIF_F_TSO);\n\tnewdp6 = (struct dccp6_sock *)newsk;\n\tnewinet = inet_sk(newsk);\n\tnewinet->pinet6 = &newdp6->inet6;\n\tnewnp = inet6_sk(newsk);",
"\tmemcpy(newnp, np, sizeof(struct ipv6_pinfo));",
"\tnewsk->sk_v6_daddr\t= ireq->ir_v6_rmt_addr;\n\tnewnp->saddr\t\t= ireq->ir_v6_loc_addr;\n\tnewsk->sk_v6_rcv_saddr\t= ireq->ir_v6_loc_addr;\n\tnewsk->sk_bound_dev_if\t= ireq->ir_iif;",
"\t/* Now IPv6 options...",
"\t First: no IPv4 options.\n\t */\n\tnewinet->inet_opt = NULL;",
"\t/* Clone RX bits */\n\tnewnp->rxopt.all = np->rxopt.all;\n",
"\tnewnp->ipv6_mc_list = NULL;\n\tnewnp->ipv6_ac_list = NULL;\n\tnewnp->ipv6_fl_list = NULL;",
"\tnewnp->pktoptions = NULL;\n\tnewnp->opt\t = NULL;\n\tnewnp->mcast_oif = inet6_iif(skb);\n\tnewnp->mcast_hops = ipv6_hdr(skb)->hop_limit;",
"\t/*\n\t * Clone native IPv6 options from listening socket (if any)\n\t *\n\t * Yes, keeping reference count would be much more clever, but we make\n\t * one more one thing there: reattach optmem to newsk.\n\t */\n\topt = ireq->ipv6_opt;\n\tif (!opt)\n\t\topt = rcu_dereference(np->opt);\n\tif (opt) {\n\t\topt = ipv6_dup_options(newsk, opt);\n\t\tRCU_INIT_POINTER(newnp->opt, opt);\n\t}\n\tinet_csk(newsk)->icsk_ext_hdr_len = 0;\n\tif (opt)\n\t\tinet_csk(newsk)->icsk_ext_hdr_len = opt->opt_nflen +\n\t\t\t\t\t\t opt->opt_flen;",
"\tdccp_sync_mss(newsk, dst_mtu(dst));",
"\tnewinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6;\n\tnewinet->inet_rcv_saddr = LOOPBACK4_IPV6;",
"\tif (__inet_inherit_port(sk, newsk) < 0) {\n\t\tinet_csk_prepare_forced_close(newsk);\n\t\tdccp_done(newsk);\n\t\tgoto out;\n\t}\n\t*own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));\n\t/* Clone pktoptions received with SYN, if we own the req */\n\tif (*own_req && ireq->pktopts) {\n\t\tnewnp->pktoptions = skb_clone(ireq->pktopts, GFP_ATOMIC);\n\t\tconsume_skb(ireq->pktopts);\n\t\tireq->pktopts = NULL;\n\t\tif (newnp->pktoptions)\n\t\t\tskb_set_owner_r(newnp->pktoptions, newsk);\n\t}",
"\treturn newsk;",
"out_overflow:\n\t__NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);\nout_nonewsk:\n\tdst_release(dst);\nout:\n\t__NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENDROPS);\n\treturn NULL;\n}",
"/* The socket must have it's spinlock held when we get\n * here.\n *\n * We have a potential double-lock case here, so even when\n * doing backlog processing we use the BH locking scheme.\n * This is because we cannot sleep with the original spinlock\n * held.\n */\nstatic int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct sk_buff *opt_skb = NULL;",
"\t/* Imagine: socket is IPv6. IPv4 packet arrives,\n\t goes to IPv4 receive handler and backlogged.\n\t From backlog it always goes here. Kerboom...\n\t Fortunately, dccp_rcv_established and rcv_established\n\t handle them correctly, but it is not case with\n\t dccp_v6_hnd_req and dccp_v6_ctl_send_reset(). --ANK\n\t */",
"\tif (skb->protocol == htons(ETH_P_IP))\n\t\treturn dccp_v4_do_rcv(sk, skb);",
"\tif (sk_filter(sk, skb))\n\t\tgoto discard;",
"\t/*\n\t * socket locking is here for SMP purposes as backlog rcv is currently\n\t * called with bh processing disabled.\n\t */",
"\t/* Do Stevens' IPV6_PKTOPTIONS.",
"\t Yes, guys, it is the only place in our code, where we\n\t may make it not affecting IPv4.\n\t The rest of code is protocol independent,\n\t and I do not like idea to uglify IPv4.",
"\t Actually, all the idea behind IPV6_PKTOPTIONS\n\t looks not very well thought. For now we latch\n\t options, received in the last packet, enqueued\n\t by tcp. Feel free to propose better solution.\n\t\t\t\t\t --ANK (980728)\n\t */\n\tif (np->rxopt.all)\n\t/*\n\t * FIXME: Add handling of IPV6_PKTOPTIONS skb. See the comments below\n\t * (wrt ipv6_pktopions) and net/ipv6/tcp_ipv6.c for an example.\n\t */\n\t\topt_skb = skb_clone(skb, GFP_ATOMIC);",
"\tif (sk->sk_state == DCCP_OPEN) { /* Fast path */\n\t\tif (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len))\n\t\t\tgoto reset;\n\t\tif (opt_skb) {\n\t\t\t/* XXX This is where we would goto ipv6_pktoptions. */\n\t\t\t__kfree_skb(opt_skb);\n\t\t}\n\t\treturn 0;\n\t}",
"\t/*\n\t * Step 3: Process LISTEN state\n\t * If S.state == LISTEN,\n\t *\t If P.type == Request or P contains a valid Init Cookie option,\n\t *\t (* Must scan the packet's options to check for Init\n\t *\t\t Cookies. Only Init Cookies are processed here,\n\t *\t\t however; other options are processed in Step 8. This\n\t *\t\t scan need only be performed if the endpoint uses Init\n\t *\t\t Cookies *)\n\t *\t (* Generate a new socket and switch to that socket *)\n\t *\t Set S := new socket for this port pair\n\t *\t S.state = RESPOND\n\t *\t Choose S.ISS (initial seqno) or set from Init Cookies\n\t *\t Initialize S.GAR := S.ISS\n\t *\t Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies\n\t *\t Continue with S.state == RESPOND\n\t *\t (* A Response packet will be generated in Step 11 *)\n\t *\t Otherwise,\n\t *\t Generate Reset(No Connection) unless P.type == Reset\n\t *\t Drop packet and return\n\t *\n\t * NOTE: the check for the packet types is done in\n\t *\t dccp_rcv_state_process\n\t */",
"\tif (dccp_rcv_state_process(sk, skb, dccp_hdr(skb), skb->len))\n\t\tgoto reset;\n\tif (opt_skb) {\n\t\t/* XXX This is where we would goto ipv6_pktoptions. */\n\t\t__kfree_skb(opt_skb);\n\t}\n\treturn 0;",
"reset:\n\tdccp_v6_ctl_send_reset(sk, skb);\ndiscard:\n\tif (opt_skb != NULL)\n\t\t__kfree_skb(opt_skb);\n\tkfree_skb(skb);\n\treturn 0;\n}",
"static int dccp_v6_rcv(struct sk_buff *skb)\n{\n\tconst struct dccp_hdr *dh;\n\tbool refcounted;\n\tstruct sock *sk;\n\tint min_cov;",
"\t/* Step 1: Check header basics */",
"\tif (dccp_invalid_packet(skb))\n\t\tgoto discard_it;",
"\t/* Step 1: If header checksum is incorrect, drop packet and return. */\n\tif (dccp_v6_csum_finish(skb, &ipv6_hdr(skb)->saddr,\n\t\t\t\t &ipv6_hdr(skb)->daddr)) {\n\t\tDCCP_WARN(\"dropped packet with invalid checksum\\n\");\n\t\tgoto discard_it;\n\t}",
"\tdh = dccp_hdr(skb);",
"\tDCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh);\n\tDCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;",
"\tif (dccp_packet_without_ack(skb))\n\t\tDCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ;\n\telse\n\t\tDCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);",
"lookup:\n\tsk = __inet6_lookup_skb(&dccp_hashinfo, skb, __dccp_hdr_len(dh),\n\t\t\t dh->dccph_sport, dh->dccph_dport,\n\t\t\t\tinet6_iif(skb), &refcounted);\n\tif (!sk) {\n\t\tdccp_pr_debug(\"failed to look up flow ID in table and \"\n\t\t\t \"get corresponding socket\\n\");\n\t\tgoto no_dccp_socket;\n\t}",
"\t/*\n\t * Step 2:\n\t *\t... or S.state == TIMEWAIT,\n\t *\t\tGenerate Reset(No Connection) unless P.type == Reset\n\t *\t\tDrop packet and return\n\t */\n\tif (sk->sk_state == DCCP_TIME_WAIT) {\n\t\tdccp_pr_debug(\"sk->sk_state == DCCP_TIME_WAIT: do_time_wait\\n\");\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\tgoto no_dccp_socket;\n\t}",
"\tif (sk->sk_state == DCCP_NEW_SYN_RECV) {\n\t\tstruct request_sock *req = inet_reqsk(sk);\n\t\tstruct sock *nsk;",
"\t\tsk = req->rsk_listener;\n\t\tif (unlikely(sk->sk_state != DCCP_LISTEN)) {\n\t\t\tinet_csk_reqsk_queue_drop_and_put(sk, req);\n\t\t\tgoto lookup;\n\t\t}\n\t\tsock_hold(sk);\n\t\trefcounted = true;\n\t\tnsk = dccp_check_req(sk, skb, req);\n\t\tif (!nsk) {\n\t\t\treqsk_put(req);\n\t\t\tgoto discard_and_relse;\n\t\t}\n\t\tif (nsk == sk) {\n\t\t\treqsk_put(req);\n\t\t} else if (dccp_child_process(sk, nsk, skb)) {\n\t\t\tdccp_v6_ctl_send_reset(sk, skb);\n\t\t\tgoto discard_and_relse;\n\t\t} else {\n\t\t\tsock_put(sk);\n\t\t\treturn 0;\n\t\t}\n\t}\n\t/*\n\t * RFC 4340, sec. 9.2.1: Minimum Checksum Coverage\n\t *\to if MinCsCov = 0, only packets with CsCov = 0 are accepted\n\t *\to if MinCsCov > 0, also accept packets with CsCov >= MinCsCov\n\t */\n\tmin_cov = dccp_sk(sk)->dccps_pcrlen;\n\tif (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {\n\t\tdccp_pr_debug(\"Packet CsCov %d does not satisfy MinCsCov %d\\n\",\n\t\t\t dh->dccph_cscov, min_cov);\n\t\t/* FIXME: send Data Dropped option (see also dccp_v4_rcv) */\n\t\tgoto discard_and_relse;\n\t}",
"\tif (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))\n\t\tgoto discard_and_relse;",
"\treturn __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4,\n\t\t\t\trefcounted) ? -1 : 0;",
"no_dccp_socket:\n\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))\n\t\tgoto discard_it;\n\t/*\n\t * Step 2:\n\t *\tIf no socket ...\n\t *\t\tGenerate Reset(No Connection) unless P.type == Reset\n\t *\t\tDrop packet and return\n\t */\n\tif (dh->dccph_type != DCCP_PKT_RESET) {\n\t\tDCCP_SKB_CB(skb)->dccpd_reset_code =\n\t\t\t\t\tDCCP_RESET_CODE_NO_CONNECTION;\n\t\tdccp_v6_ctl_send_reset(sk, skb);\n\t}",
"discard_it:\n\tkfree_skb(skb);\n\treturn 0;",
"discard_and_relse:\n\tif (refcounted)\n\t\tsock_put(sk);\n\tgoto discard_it;\n}",
"static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,\n\t\t\t int addr_len)\n{\n\tstruct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr;\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct dccp_sock *dp = dccp_sk(sk);\n\tstruct in6_addr *saddr = NULL, *final_p, final;\n\tstruct ipv6_txoptions *opt;\n\tstruct flowi6 fl6;\n\tstruct dst_entry *dst;\n\tint addr_type;\n\tint err;",
"\tdp->dccps_role = DCCP_ROLE_CLIENT;",
"\tif (addr_len < SIN6_LEN_RFC2133)\n\t\treturn -EINVAL;",
"\tif (usin->sin6_family != AF_INET6)\n\t\treturn -EAFNOSUPPORT;",
"\tmemset(&fl6, 0, sizeof(fl6));",
"\tif (np->sndflow) {\n\t\tfl6.flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK;\n\t\tIP6_ECN_flow_init(fl6.flowlabel);\n\t\tif (fl6.flowlabel & IPV6_FLOWLABEL_MASK) {\n\t\t\tstruct ip6_flowlabel *flowlabel;\n\t\t\tflowlabel = fl6_sock_lookup(sk, fl6.flowlabel);\n\t\t\tif (flowlabel == NULL)\n\t\t\t\treturn -EINVAL;\n\t\t\tfl6_sock_release(flowlabel);\n\t\t}\n\t}\n\t/*\n\t * connect() to INADDR_ANY means loopback (BSD'ism).\n\t */\n\tif (ipv6_addr_any(&usin->sin6_addr))\n\t\tusin->sin6_addr.s6_addr[15] = 1;",
"\taddr_type = ipv6_addr_type(&usin->sin6_addr);",
"\tif (addr_type & IPV6_ADDR_MULTICAST)\n\t\treturn -ENETUNREACH;",
"\tif (addr_type & IPV6_ADDR_LINKLOCAL) {\n\t\tif (addr_len >= sizeof(struct sockaddr_in6) &&\n\t\t usin->sin6_scope_id) {\n\t\t\t/* If interface is set while binding, indices\n\t\t\t * must coincide.\n\t\t\t */\n\t\t\tif (sk->sk_bound_dev_if &&\n\t\t\t sk->sk_bound_dev_if != usin->sin6_scope_id)\n\t\t\t\treturn -EINVAL;",
"\t\t\tsk->sk_bound_dev_if = usin->sin6_scope_id;\n\t\t}",
"\t\t/* Connect to link-local address requires an interface */\n\t\tif (!sk->sk_bound_dev_if)\n\t\t\treturn -EINVAL;\n\t}",
"\tsk->sk_v6_daddr = usin->sin6_addr;\n\tnp->flow_label = fl6.flowlabel;",
"\t/*\n\t * DCCP over IPv4\n\t */\n\tif (addr_type == IPV6_ADDR_MAPPED) {\n\t\tu32 exthdrlen = icsk->icsk_ext_hdr_len;\n\t\tstruct sockaddr_in sin;",
"\t\tSOCK_DEBUG(sk, \"connect: ipv4 mapped\\n\");",
"\t\tif (__ipv6_only_sock(sk))\n\t\t\treturn -ENETUNREACH;",
"\t\tsin.sin_family = AF_INET;\n\t\tsin.sin_port = usin->sin6_port;\n\t\tsin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];",
"\t\ticsk->icsk_af_ops = &dccp_ipv6_mapped;\n\t\tsk->sk_backlog_rcv = dccp_v4_do_rcv;",
"\t\terr = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));\n\t\tif (err) {\n\t\t\ticsk->icsk_ext_hdr_len = exthdrlen;\n\t\t\ticsk->icsk_af_ops = &dccp_ipv6_af_ops;\n\t\t\tsk->sk_backlog_rcv = dccp_v6_do_rcv;\n\t\t\tgoto failure;\n\t\t}\n\t\tnp->saddr = sk->sk_v6_rcv_saddr;\n\t\treturn err;\n\t}",
"\tif (!ipv6_addr_any(&sk->sk_v6_rcv_saddr))\n\t\tsaddr = &sk->sk_v6_rcv_saddr;",
"\tfl6.flowi6_proto = IPPROTO_DCCP;\n\tfl6.daddr = sk->sk_v6_daddr;\n\tfl6.saddr = saddr ? *saddr : np->saddr;\n\tfl6.flowi6_oif = sk->sk_bound_dev_if;\n\tfl6.fl6_dport = usin->sin6_port;\n\tfl6.fl6_sport = inet->inet_sport;\n\tsecurity_sk_classify_flow(sk, flowi6_to_flowi(&fl6));",
"\topt = rcu_dereference_protected(np->opt, lockdep_sock_is_held(sk));\n\tfinal_p = fl6_update_dst(&fl6, opt, &final);",
"\tdst = ip6_dst_lookup_flow(sk, &fl6, final_p);\n\tif (IS_ERR(dst)) {\n\t\terr = PTR_ERR(dst);\n\t\tgoto failure;\n\t}",
"\tif (saddr == NULL) {\n\t\tsaddr = &fl6.saddr;\n\t\tsk->sk_v6_rcv_saddr = *saddr;\n\t}",
"\t/* set the source address */\n\tnp->saddr = *saddr;\n\tinet->inet_rcv_saddr = LOOPBACK4_IPV6;",
"\tip6_dst_store(sk, dst, NULL, NULL);",
"\ticsk->icsk_ext_hdr_len = 0;\n\tif (opt)\n\t\ticsk->icsk_ext_hdr_len = opt->opt_flen + opt->opt_nflen;",
"\tinet->inet_dport = usin->sin6_port;",
"\tdccp_set_state(sk, DCCP_REQUESTING);\n\terr = inet6_hash_connect(&dccp_death_row, sk);\n\tif (err)\n\t\tgoto late_failure;",
"\tdp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32,\n\t\t\t\t\t\t sk->sk_v6_daddr.s6_addr32,\n\t\t\t\t\t\t inet->inet_sport,\n\t\t\t\t\t\t inet->inet_dport);\n\terr = dccp_connect(sk);\n\tif (err)\n\t\tgoto late_failure;",
"\treturn 0;",
"late_failure:\n\tdccp_set_state(sk, DCCP_CLOSED);\n\t__sk_dst_reset(sk);\nfailure:\n\tinet->inet_dport = 0;\n\tsk->sk_route_caps = 0;\n\treturn err;\n}",
"static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops = {\n\t.queue_xmit\t = inet6_csk_xmit,\n\t.send_check\t = dccp_v6_send_check,\n\t.rebuild_header\t = inet6_sk_rebuild_header,\n\t.conn_request\t = dccp_v6_conn_request,\n\t.syn_recv_sock\t = dccp_v6_request_recv_sock,\n\t.net_header_len\t = sizeof(struct ipv6hdr),\n\t.setsockopt\t = ipv6_setsockopt,\n\t.getsockopt\t = ipv6_getsockopt,\n\t.addr2sockaddr\t = inet6_csk_addr2sockaddr,\n\t.sockaddr_len\t = sizeof(struct sockaddr_in6),\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_ipv6_setsockopt,\n\t.compat_getsockopt = compat_ipv6_getsockopt,\n#endif\n};",
"/*\n *\tDCCP over IPv4 via INET6 API\n */\nstatic const struct inet_connection_sock_af_ops dccp_ipv6_mapped = {\n\t.queue_xmit\t = ip_queue_xmit,\n\t.send_check\t = dccp_v4_send_check,\n\t.rebuild_header\t = inet_sk_rebuild_header,\n\t.conn_request\t = dccp_v6_conn_request,\n\t.syn_recv_sock\t = dccp_v6_request_recv_sock,\n\t.net_header_len\t = sizeof(struct iphdr),\n\t.setsockopt\t = ipv6_setsockopt,\n\t.getsockopt\t = ipv6_getsockopt,\n\t.addr2sockaddr\t = inet6_csk_addr2sockaddr,\n\t.sockaddr_len\t = sizeof(struct sockaddr_in6),\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_ipv6_setsockopt,\n\t.compat_getsockopt = compat_ipv6_getsockopt,\n#endif\n};",
"/* NOTE: A lot of things set to zero explicitly by call to\n * sk_alloc() so need not be done here.\n */\nstatic int dccp_v6_init_sock(struct sock *sk)\n{\n\tstatic __u8 dccp_v6_ctl_sock_initialized;\n\tint err = dccp_init_sock(sk, dccp_v6_ctl_sock_initialized);",
"\tif (err == 0) {\n\t\tif (unlikely(!dccp_v6_ctl_sock_initialized))\n\t\t\tdccp_v6_ctl_sock_initialized = 1;\n\t\tinet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops;\n\t}",
"\treturn err;\n}",
"static void dccp_v6_destroy_sock(struct sock *sk)\n{\n\tdccp_destroy_sock(sk);\n\tinet6_destroy_sock(sk);\n}",
"static struct timewait_sock_ops dccp6_timewait_sock_ops = {\n\t.twsk_obj_size\t= sizeof(struct dccp6_timewait_sock),\n};",
"static struct proto dccp_v6_prot = {\n\t.name\t\t = \"DCCPv6\",\n\t.owner\t\t = THIS_MODULE,\n\t.close\t\t = dccp_close,\n\t.connect\t = dccp_v6_connect,\n\t.disconnect\t = dccp_disconnect,\n\t.ioctl\t\t = dccp_ioctl,\n\t.init\t\t = dccp_v6_init_sock,\n\t.setsockopt\t = dccp_setsockopt,\n\t.getsockopt\t = dccp_getsockopt,\n\t.sendmsg\t = dccp_sendmsg,\n\t.recvmsg\t = dccp_recvmsg,\n\t.backlog_rcv\t = dccp_v6_do_rcv,\n\t.hash\t\t = inet6_hash,\n\t.unhash\t\t = inet_unhash,\n\t.accept\t\t = inet_csk_accept,\n\t.get_port\t = inet_csk_get_port,\n\t.shutdown\t = dccp_shutdown,\n\t.destroy\t = dccp_v6_destroy_sock,\n\t.orphan_count\t = &dccp_orphan_count,\n\t.max_header\t = MAX_DCCP_HEADER,\n\t.obj_size\t = sizeof(struct dccp6_sock),\n\t.slab_flags\t = SLAB_DESTROY_BY_RCU,\n\t.rsk_prot\t = &dccp6_request_sock_ops,\n\t.twsk_prot\t = &dccp6_timewait_sock_ops,\n\t.h.hashinfo\t = &dccp_hashinfo,\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_dccp_setsockopt,\n\t.compat_getsockopt = compat_dccp_getsockopt,\n#endif\n};",
"static const struct inet6_protocol dccp_v6_protocol = {\n\t.handler\t= dccp_v6_rcv,\n\t.err_handler\t= dccp_v6_err,\n\t.flags\t\t= INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,\n};",
"static const struct proto_ops inet6_dccp_ops = {\n\t.family\t\t = PF_INET6,\n\t.owner\t\t = THIS_MODULE,\n\t.release\t = inet6_release,\n\t.bind\t\t = inet6_bind,\n\t.connect\t = inet_stream_connect,\n\t.socketpair\t = sock_no_socketpair,\n\t.accept\t\t = inet_accept,\n\t.getname\t = inet6_getname,\n\t.poll\t\t = dccp_poll,\n\t.ioctl\t\t = inet6_ioctl,\n\t.listen\t\t = inet_dccp_listen,\n\t.shutdown\t = inet_shutdown,\n\t.setsockopt\t = sock_common_setsockopt,\n\t.getsockopt\t = sock_common_getsockopt,\n\t.sendmsg\t = inet_sendmsg,\n\t.recvmsg\t = sock_common_recvmsg,\n\t.mmap\t\t = sock_no_mmap,\n\t.sendpage\t = sock_no_sendpage,\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_sock_common_setsockopt,\n\t.compat_getsockopt = compat_sock_common_getsockopt,\n#endif\n};",
"static struct inet_protosw dccp_v6_protosw = {\n\t.type\t\t= SOCK_DCCP,\n\t.protocol\t= IPPROTO_DCCP,\n\t.prot\t\t= &dccp_v6_prot,\n\t.ops\t\t= &inet6_dccp_ops,\n\t.flags\t\t= INET_PROTOSW_ICSK,\n};",
"static int __net_init dccp_v6_init_net(struct net *net)\n{\n\tif (dccp_hashinfo.bhash == NULL)\n\t\treturn -ESOCKTNOSUPPORT;",
"\treturn inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6,\n\t\t\t\t SOCK_DCCP, IPPROTO_DCCP, net);\n}",
"static void __net_exit dccp_v6_exit_net(struct net *net)\n{\n\tinet_ctl_sock_destroy(net->dccp.v6_ctl_sk);\n}",
"static void __net_exit dccp_v6_exit_batch(struct list_head *net_exit_list)\n{\n\tinet_twsk_purge(&dccp_hashinfo, AF_INET6);\n}",
"static struct pernet_operations dccp_v6_ops = {\n\t.init = dccp_v6_init_net,\n\t.exit = dccp_v6_exit_net,\n\t.exit_batch = dccp_v6_exit_batch,\n};",
"static int __init dccp_v6_init(void)\n{\n\tint err = proto_register(&dccp_v6_prot, 1);",
"\tif (err != 0)\n\t\tgoto out;",
"\terr = inet6_add_protocol(&dccp_v6_protocol, IPPROTO_DCCP);\n\tif (err != 0)\n\t\tgoto out_unregister_proto;",
"\tinet6_register_protosw(&dccp_v6_protosw);",
"\terr = register_pernet_subsys(&dccp_v6_ops);\n\tif (err != 0)\n\t\tgoto out_destroy_ctl_sock;\nout:\n\treturn err;",
"out_destroy_ctl_sock:\n\tinet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);\n\tinet6_unregister_protosw(&dccp_v6_protosw);\nout_unregister_proto:\n\tproto_unregister(&dccp_v6_prot);\n\tgoto out;\n}",
"static void __exit dccp_v6_exit(void)\n{\n\tunregister_pernet_subsys(&dccp_v6_ops);\n\tinet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);\n\tinet6_unregister_protosw(&dccp_v6_protosw);\n\tproto_unregister(&dccp_v6_prot);\n}",
"module_init(dccp_v6_init);\nmodule_exit(dccp_v6_exit);",
"/*\n * __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)\n * values directly, Also cover the case where the protocol is not specified,\n * i.e. net-pf-PF_INET6-proto-0-type-SOCK_DCCP\n */\nMODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET6, 33, 6);\nMODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET6, 0, 6);\nMODULE_LICENSE(\"GPL\");\nMODULE_AUTHOR(\"Arnaldo Carvalho de Melo <acme@mandriva.com>\");\nMODULE_DESCRIPTION(\"DCCPv6 - Datagram Congestion Controlled Protocol\");"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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": [492, 1133], "buggy_code_start_loc": [428, 1064], "filenames": ["net/dccp/ipv6.c", "net/ipv6/tcp_ipv6.c"], "fixing_code_end_loc": [499, 1136], "fixing_code_start_loc": [429, 1065], "message": "The dccp_v6_request_recv_sock function in net/dccp/ipv6.c in the Linux kernel through 4.11.1 mishandles inheritance, which allows local users to cause a denial of service or possibly have unspecified other impact via crafted system calls, a related issue to CVE-2017-8890.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "9A5C1F01-214B-4477-A3A1-F6DF10181D3C", "versionEndExcluding": "3.2.89", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "8C1901E2-6C4D-488B-A7CE-F7E14A38418F", "versionEndExcluding": "3.16.44", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.3", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "DB67DFF9-D1AD-49F9-AC6A-2BBFE1619CE2", "versionEndExcluding": "3.18.84", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.17", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "A4AF9D2F-2101-41EE-9E8C-95EE62CB1186", "versionEndExcluding": "4.4.71", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.19", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "001F55C3-810A-444F-AE18-F067A84F6B31", "versionEndExcluding": "4.9.31", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "4.5", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "1A25FD29-5617-4236-AC9A-6D68DC220925", "versionEndExcluding": "4.11.4", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "4.10", "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}], "descriptions": [{"lang": "en", "value": "The dccp_v6_request_recv_sock function in net/dccp/ipv6.c in the Linux kernel through 4.11.1 mishandles inheritance, which allows local users to cause a denial of service or possibly have unspecified other impact via crafted system calls, a related issue to CVE-2017-8890."}, {"lang": "es", "value": "La funci\u00f3n dccp_v6_request_recv_sock en el archivo net/dccp/ipv6.c en el kernel de Linux hasta versi\u00f3n 4.11.1, el manejo inapropiado de la herencia, permite a los usuarios locales causar una denegaci\u00f3n de servicio o posiblemente tener otro impacto no especificado por medio de llamadas de sistema dise\u00f1adas, un problema relacionado con CVE-2017 -8890."}], "evaluatorComment": null, "id": "CVE-2017-9076", "lastModified": "2023-02-24T18:39:05.640", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 7.2, "confidentialityImpact": "COMPLETE", "integrityImpact": "COMPLETE", "vectorString": "AV:L/AC:L/Au:N/C:C/I:C/A:C", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 10.0, "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": 7.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2017-05-19T07:29:00.307", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Vendor Advisory"], "url": "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=83eaddab4378db256d00d295bda6ca997cd13a52"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "http://www.debian.org/security/2017/dsa-3886"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/98586"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:1842"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:2077"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:2669"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:1854"}, {"source": "cve@mitre.org", "tags": ["Patch", "Vendor Advisory"], "url": "https://github.com/torvalds/linux/commit/83eaddab4378db256d00d295bda6ca997cd13a52"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://patchwork.ozlabs.org/patch/760370/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://source.android.com/security/bulletin/2017-09-01"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "NVD-CWE-noinfo"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/83eaddab4378db256d00d295bda6ca997cd13a52"}, "type": "NVD-CWE-noinfo"}
| 215
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n *\tTCP over IPv6\n *\tLinux INET6 implementation\n *\n *\tAuthors:\n *\tPedro Roque\t\t<roque@di.fc.ul.pt>\n *\n *\tBased on:\n *\tlinux/net/ipv4/tcp.c\n *\tlinux/net/ipv4/tcp_input.c\n *\tlinux/net/ipv4/tcp_output.c\n *\n *\tFixes:\n *\tHideaki YOSHIFUJI\t:\tsin6_scope_id support\n *\tYOSHIFUJI Hideaki @USAGI and:\tSupport IPV6_V6ONLY socket option, which\n *\tAlexey Kuznetsov\t\tallow both IPv4 and IPv6 sockets to bind\n *\t\t\t\t\ta single port at the same time.\n *\tYOSHIFUJI Hideaki @USAGI:\tconvert /proc/net/tcp6 to seq_file.\n *\n *\tThis 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 */",
"#include <linux/bottom_half.h>\n#include <linux/module.h>\n#include <linux/errno.h>\n#include <linux/types.h>\n#include <linux/socket.h>\n#include <linux/sockios.h>\n#include <linux/net.h>\n#include <linux/jiffies.h>\n#include <linux/in.h>\n#include <linux/in6.h>\n#include <linux/netdevice.h>\n#include <linux/init.h>\n#include <linux/jhash.h>\n#include <linux/ipsec.h>\n#include <linux/times.h>\n#include <linux/slab.h>\n#include <linux/uaccess.h>\n#include <linux/ipv6.h>\n#include <linux/icmpv6.h>\n#include <linux/random.h>",
"#include <net/tcp.h>\n#include <net/ndisc.h>\n#include <net/inet6_hashtables.h>\n#include <net/inet6_connection_sock.h>\n#include <net/ipv6.h>\n#include <net/transp_v6.h>\n#include <net/addrconf.h>\n#include <net/ip6_route.h>\n#include <net/ip6_checksum.h>\n#include <net/inet_ecn.h>\n#include <net/protocol.h>\n#include <net/xfrm.h>\n#include <net/snmp.h>\n#include <net/dsfield.h>\n#include <net/timewait_sock.h>\n#include <net/inet_common.h>\n#include <net/secure_seq.h>\n#include <net/busy_poll.h>",
"#include <linux/proc_fs.h>\n#include <linux/seq_file.h>",
"#include <crypto/hash.h>\n#include <linux/scatterlist.h>",
"static void\ttcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb);\nstatic void\ttcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,\n\t\t\t\t struct request_sock *req);",
"static int\ttcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb);",
"static const struct inet_connection_sock_af_ops ipv6_mapped;\nstatic const struct inet_connection_sock_af_ops ipv6_specific;\n#ifdef CONFIG_TCP_MD5SIG\nstatic const struct tcp_sock_af_ops tcp_sock_ipv6_specific;\nstatic const struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific;\n#else\nstatic struct tcp_md5sig_key *tcp_v6_md5_do_lookup(const struct sock *sk,\n\t\t\t\t\t\t const struct in6_addr *addr)\n{\n\treturn NULL;\n}\n#endif",
"static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)\n{\n\tstruct dst_entry *dst = skb_dst(skb);",
"\tif (dst && dst_hold_safe(dst)) {\n\t\tconst struct rt6_info *rt = (const struct rt6_info *)dst;",
"\t\tsk->sk_rx_dst = dst;\n\t\tinet_sk(sk)->rx_dst_ifindex = skb->skb_iif;\n\t\tinet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt);\n\t}\n}",
"static u32 tcp_v6_init_seq(const struct sk_buff *skb)\n{\n\treturn secure_tcpv6_seq(ipv6_hdr(skb)->daddr.s6_addr32,\n\t\t\t\tipv6_hdr(skb)->saddr.s6_addr32,\n\t\t\t\ttcp_hdr(skb)->dest,\n\t\t\t\ttcp_hdr(skb)->source);\n}",
"static u32 tcp_v6_init_ts_off(const struct sk_buff *skb)\n{\n\treturn secure_tcpv6_ts_off(ipv6_hdr(skb)->daddr.s6_addr32,\n\t\t\t\t ipv6_hdr(skb)->saddr.s6_addr32);\n}",
"static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,\n\t\t\t int addr_len)\n{\n\tstruct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct in6_addr *saddr = NULL, *final_p, final;\n\tstruct ipv6_txoptions *opt;\n\tstruct flowi6 fl6;\n\tstruct dst_entry *dst;\n\tint addr_type;\n\tint err;\n\tstruct inet_timewait_death_row *tcp_death_row = &sock_net(sk)->ipv4.tcp_death_row;",
"\tif (addr_len < SIN6_LEN_RFC2133)\n\t\treturn -EINVAL;",
"\tif (usin->sin6_family != AF_INET6)\n\t\treturn -EAFNOSUPPORT;",
"\tmemset(&fl6, 0, sizeof(fl6));",
"\tif (np->sndflow) {\n\t\tfl6.flowlabel = usin->sin6_flowinfo&IPV6_FLOWINFO_MASK;\n\t\tIP6_ECN_flow_init(fl6.flowlabel);\n\t\tif (fl6.flowlabel&IPV6_FLOWLABEL_MASK) {\n\t\t\tstruct ip6_flowlabel *flowlabel;\n\t\t\tflowlabel = fl6_sock_lookup(sk, fl6.flowlabel);\n\t\t\tif (!flowlabel)\n\t\t\t\treturn -EINVAL;\n\t\t\tfl6_sock_release(flowlabel);\n\t\t}\n\t}",
"\t/*\n\t *\tconnect() to INADDR_ANY means loopback (BSD'ism).\n\t */",
"\tif (ipv6_addr_any(&usin->sin6_addr)) {\n\t\tif (ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))\n\t\t\tipv6_addr_set_v4mapped(htonl(INADDR_LOOPBACK),\n\t\t\t\t\t &usin->sin6_addr);\n\t\telse\n\t\t\tusin->sin6_addr = in6addr_loopback;\n\t}",
"\taddr_type = ipv6_addr_type(&usin->sin6_addr);",
"\tif (addr_type & IPV6_ADDR_MULTICAST)\n\t\treturn -ENETUNREACH;",
"\tif (addr_type&IPV6_ADDR_LINKLOCAL) {\n\t\tif (addr_len >= sizeof(struct sockaddr_in6) &&\n\t\t usin->sin6_scope_id) {\n\t\t\t/* If interface is set while binding, indices\n\t\t\t * must coincide.\n\t\t\t */\n\t\t\tif (sk->sk_bound_dev_if &&\n\t\t\t sk->sk_bound_dev_if != usin->sin6_scope_id)\n\t\t\t\treturn -EINVAL;",
"\t\t\tsk->sk_bound_dev_if = usin->sin6_scope_id;\n\t\t}",
"\t\t/* Connect to link-local address requires an interface */\n\t\tif (!sk->sk_bound_dev_if)\n\t\t\treturn -EINVAL;\n\t}",
"\tif (tp->rx_opt.ts_recent_stamp &&\n\t !ipv6_addr_equal(&sk->sk_v6_daddr, &usin->sin6_addr)) {\n\t\ttp->rx_opt.ts_recent = 0;\n\t\ttp->rx_opt.ts_recent_stamp = 0;\n\t\ttp->write_seq = 0;\n\t}",
"\tsk->sk_v6_daddr = usin->sin6_addr;\n\tnp->flow_label = fl6.flowlabel;",
"\t/*\n\t *\tTCP over IPv4\n\t */",
"\tif (addr_type & IPV6_ADDR_MAPPED) {\n\t\tu32 exthdrlen = icsk->icsk_ext_hdr_len;\n\t\tstruct sockaddr_in sin;",
"\t\tSOCK_DEBUG(sk, \"connect: ipv4 mapped\\n\");",
"\t\tif (__ipv6_only_sock(sk))\n\t\t\treturn -ENETUNREACH;",
"\t\tsin.sin_family = AF_INET;\n\t\tsin.sin_port = usin->sin6_port;\n\t\tsin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];",
"\t\ticsk->icsk_af_ops = &ipv6_mapped;\n\t\tsk->sk_backlog_rcv = tcp_v4_do_rcv;\n#ifdef CONFIG_TCP_MD5SIG\n\t\ttp->af_specific = &tcp_sock_ipv6_mapped_specific;\n#endif",
"\t\terr = tcp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));",
"\t\tif (err) {\n\t\t\ticsk->icsk_ext_hdr_len = exthdrlen;\n\t\t\ticsk->icsk_af_ops = &ipv6_specific;\n\t\t\tsk->sk_backlog_rcv = tcp_v6_do_rcv;\n#ifdef CONFIG_TCP_MD5SIG\n\t\t\ttp->af_specific = &tcp_sock_ipv6_specific;\n#endif\n\t\t\tgoto failure;\n\t\t}\n\t\tnp->saddr = sk->sk_v6_rcv_saddr;",
"\t\treturn err;\n\t}",
"\tif (!ipv6_addr_any(&sk->sk_v6_rcv_saddr))\n\t\tsaddr = &sk->sk_v6_rcv_saddr;",
"\tfl6.flowi6_proto = IPPROTO_TCP;\n\tfl6.daddr = sk->sk_v6_daddr;\n\tfl6.saddr = saddr ? *saddr : np->saddr;\n\tfl6.flowi6_oif = sk->sk_bound_dev_if;\n\tfl6.flowi6_mark = sk->sk_mark;\n\tfl6.fl6_dport = usin->sin6_port;\n\tfl6.fl6_sport = inet->inet_sport;\n\tfl6.flowi6_uid = sk->sk_uid;",
"\topt = rcu_dereference_protected(np->opt, lockdep_sock_is_held(sk));\n\tfinal_p = fl6_update_dst(&fl6, opt, &final);",
"\tsecurity_sk_classify_flow(sk, flowi6_to_flowi(&fl6));",
"\tdst = ip6_dst_lookup_flow(sk, &fl6, final_p);\n\tif (IS_ERR(dst)) {\n\t\terr = PTR_ERR(dst);\n\t\tgoto failure;\n\t}",
"\tif (!saddr) {\n\t\tsaddr = &fl6.saddr;\n\t\tsk->sk_v6_rcv_saddr = *saddr;\n\t}",
"\t/* set the source address */\n\tnp->saddr = *saddr;\n\tinet->inet_rcv_saddr = LOOPBACK4_IPV6;",
"\tsk->sk_gso_type = SKB_GSO_TCPV6;\n\tip6_dst_store(sk, dst, NULL, NULL);",
"\ticsk->icsk_ext_hdr_len = 0;\n\tif (opt)\n\t\ticsk->icsk_ext_hdr_len = opt->opt_flen +\n\t\t\t\t\t opt->opt_nflen;",
"\ttp->rx_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr);",
"\tinet->inet_dport = usin->sin6_port;",
"\ttcp_set_state(sk, TCP_SYN_SENT);\n\terr = inet6_hash_connect(tcp_death_row, sk);\n\tif (err)\n\t\tgoto late_failure;",
"\tsk_set_txhash(sk);",
"\tif (likely(!tp->repair)) {\n\t\tif (!tp->write_seq)\n\t\t\ttp->write_seq = secure_tcpv6_seq(np->saddr.s6_addr32,\n\t\t\t\t\t\t\t sk->sk_v6_daddr.s6_addr32,\n\t\t\t\t\t\t\t inet->inet_sport,\n\t\t\t\t\t\t\t inet->inet_dport);\n\t\ttp->tsoffset = secure_tcpv6_ts_off(np->saddr.s6_addr32,\n\t\t\t\t\t\t sk->sk_v6_daddr.s6_addr32);\n\t}",
"\tif (tcp_fastopen_defer_connect(sk, &err))\n\t\treturn err;\n\tif (err)\n\t\tgoto late_failure;",
"\terr = tcp_connect(sk);\n\tif (err)\n\t\tgoto late_failure;",
"\treturn 0;",
"late_failure:\n\ttcp_set_state(sk, TCP_CLOSE);\nfailure:\n\tinet->inet_dport = 0;\n\tsk->sk_route_caps = 0;\n\treturn err;\n}",
"static void tcp_v6_mtu_reduced(struct sock *sk)\n{\n\tstruct dst_entry *dst;",
"\tif ((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))\n\t\treturn;",
"\tdst = inet6_csk_update_pmtu(sk, tcp_sk(sk)->mtu_info);\n\tif (!dst)\n\t\treturn;",
"\tif (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst)) {\n\t\ttcp_sync_mss(sk, dst_mtu(dst));\n\t\ttcp_simple_retransmit(sk);\n\t}\n}",
"static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n\t\tu8 type, u8 code, int offset, __be32 info)\n{\n\tconst struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;\n\tconst struct tcphdr *th = (struct tcphdr *)(skb->data+offset);\n\tstruct net *net = dev_net(skb->dev);\n\tstruct request_sock *fastopen;\n\tstruct ipv6_pinfo *np;\n\tstruct tcp_sock *tp;\n\t__u32 seq, snd_una;\n\tstruct sock *sk;\n\tbool fatal;\n\tint err;",
"\tsk = __inet6_lookup_established(net, &tcp_hashinfo,\n\t\t\t\t\t&hdr->daddr, th->dest,\n\t\t\t\t\t&hdr->saddr, ntohs(th->source),\n\t\t\t\t\tskb->dev->ifindex);",
"\tif (!sk) {\n\t\t__ICMP6_INC_STATS(net, __in6_dev_get(skb->dev),\n\t\t\t\t ICMP6_MIB_INERRORS);\n\t\treturn;\n\t}",
"\tif (sk->sk_state == TCP_TIME_WAIT) {\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\treturn;\n\t}\n\tseq = ntohl(th->seq);\n\tfatal = icmpv6_err_convert(type, code, &err);\n\tif (sk->sk_state == TCP_NEW_SYN_RECV)\n\t\treturn tcp_req_err(sk, seq, fatal);",
"\tbh_lock_sock(sk);\n\tif (sock_owned_by_user(sk) && type != ICMPV6_PKT_TOOBIG)\n\t\t__NET_INC_STATS(net, LINUX_MIB_LOCKDROPPEDICMPS);",
"\tif (sk->sk_state == TCP_CLOSE)\n\t\tgoto out;",
"\tif (ipv6_hdr(skb)->hop_limit < inet6_sk(sk)->min_hopcount) {\n\t\t__NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP);\n\t\tgoto out;\n\t}",
"\ttp = tcp_sk(sk);\n\t/* XXX (TFO) - tp->snd_una should be ISN (tcp_create_openreq_child() */\n\tfastopen = tp->fastopen_rsk;\n\tsnd_una = fastopen ? tcp_rsk(fastopen)->snt_isn : tp->snd_una;\n\tif (sk->sk_state != TCP_LISTEN &&\n\t !between(seq, snd_una, tp->snd_nxt)) {\n\t\t__NET_INC_STATS(net, LINUX_MIB_OUTOFWINDOWICMPS);\n\t\tgoto out;\n\t}",
"\tnp = inet6_sk(sk);",
"\tif (type == NDISC_REDIRECT) {\n\t\tif (!sock_owned_by_user(sk)) {\n\t\t\tstruct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);",
"\t\t\tif (dst)\n\t\t\t\tdst->ops->redirect(dst, sk, skb);\n\t\t}\n\t\tgoto out;\n\t}",
"\tif (type == ICMPV6_PKT_TOOBIG) {\n\t\t/* We are not interested in TCP_LISTEN and open_requests\n\t\t * (SYN-ACKs send out by Linux are always <576bytes so\n\t\t * they should go through unfragmented).\n\t\t */\n\t\tif (sk->sk_state == TCP_LISTEN)\n\t\t\tgoto out;",
"\t\tif (!ip6_sk_accept_pmtu(sk))\n\t\t\tgoto out;",
"\t\ttp->mtu_info = ntohl(info);\n\t\tif (!sock_owned_by_user(sk))\n\t\t\ttcp_v6_mtu_reduced(sk);\n\t\telse if (!test_and_set_bit(TCP_MTU_REDUCED_DEFERRED,\n\t\t\t\t\t &sk->sk_tsq_flags))\n\t\t\tsock_hold(sk);\n\t\tgoto out;\n\t}",
"\n\t/* Might be for an request_sock */\n\tswitch (sk->sk_state) {\n\tcase TCP_SYN_SENT:\n\tcase TCP_SYN_RECV:\n\t\t/* Only in fast or simultaneous open. If a fast open socket is\n\t\t * is already accepted it is treated as a connected one below.\n\t\t */\n\t\tif (fastopen && !fastopen->sk)\n\t\t\tbreak;",
"\t\tif (!sock_owned_by_user(sk)) {\n\t\t\tsk->sk_err = err;\n\t\t\tsk->sk_error_report(sk);\t\t/* Wake people up to see the error (see connect in sock.c) */",
"\t\t\ttcp_done(sk);\n\t\t} else\n\t\t\tsk->sk_err_soft = err;\n\t\tgoto out;\n\t}",
"\tif (!sock_owned_by_user(sk) && np->recverr) {\n\t\tsk->sk_err = err;\n\t\tsk->sk_error_report(sk);\n\t} else\n\t\tsk->sk_err_soft = err;",
"out:\n\tbh_unlock_sock(sk);\n\tsock_put(sk);\n}",
"\nstatic int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst,\n\t\t\t struct flowi *fl,\n\t\t\t struct request_sock *req,\n\t\t\t struct tcp_fastopen_cookie *foc,\n\t\t\t enum tcp_synack_type synack_type)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct ipv6_txoptions *opt;\n\tstruct flowi6 *fl6 = &fl->u.ip6;\n\tstruct sk_buff *skb;\n\tint err = -ENOMEM;",
"\t/* First, grab a route. */\n\tif (!dst && (dst = inet6_csk_route_req(sk, fl6, req,\n\t\t\t\t\t IPPROTO_TCP)) == NULL)\n\t\tgoto done;",
"\tskb = tcp_make_synack(sk, dst, req, foc, synack_type);",
"\tif (skb) {\n\t\t__tcp_v6_send_check(skb, &ireq->ir_v6_loc_addr,\n\t\t\t\t &ireq->ir_v6_rmt_addr);",
"\t\tfl6->daddr = ireq->ir_v6_rmt_addr;\n\t\tif (np->repflow && ireq->pktopts)\n\t\t\tfl6->flowlabel = ip6_flowlabel(ipv6_hdr(ireq->pktopts));",
"\t\trcu_read_lock();\n\t\topt = ireq->ipv6_opt;\n\t\tif (!opt)\n\t\t\topt = rcu_dereference(np->opt);\n\t\terr = ip6_xmit(sk, skb, fl6, sk->sk_mark, opt, np->tclass);\n\t\trcu_read_unlock();\n\t\terr = net_xmit_eval(err);\n\t}",
"done:\n\treturn err;\n}",
"\nstatic void tcp_v6_reqsk_destructor(struct request_sock *req)\n{\n\tkfree(inet_rsk(req)->ipv6_opt);\n\tkfree_skb(inet_rsk(req)->pktopts);\n}",
"#ifdef CONFIG_TCP_MD5SIG\nstatic struct tcp_md5sig_key *tcp_v6_md5_do_lookup(const struct sock *sk,\n\t\t\t\t\t\t const struct in6_addr *addr)\n{\n\treturn tcp_md5_do_lookup(sk, (union tcp_md5_addr *)addr, AF_INET6);\n}",
"static struct tcp_md5sig_key *tcp_v6_md5_lookup(const struct sock *sk,\n\t\t\t\t\t\tconst struct sock *addr_sk)\n{\n\treturn tcp_v6_md5_do_lookup(sk, &addr_sk->sk_v6_daddr);\n}",
"static int tcp_v6_parse_md5_keys(struct sock *sk, char __user *optval,\n\t\t\t\t int optlen)\n{\n\tstruct tcp_md5sig cmd;\n\tstruct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&cmd.tcpm_addr;",
"\tif (optlen < sizeof(cmd))\n\t\treturn -EINVAL;",
"\tif (copy_from_user(&cmd, optval, sizeof(cmd)))\n\t\treturn -EFAULT;",
"\tif (sin6->sin6_family != AF_INET6)\n\t\treturn -EINVAL;",
"\tif (!cmd.tcpm_keylen) {\n\t\tif (ipv6_addr_v4mapped(&sin6->sin6_addr))\n\t\t\treturn tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3],\n\t\t\t\t\t AF_INET);\n\t\treturn tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr,\n\t\t\t\t AF_INET6);\n\t}",
"\tif (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)\n\t\treturn -EINVAL;",
"\tif (ipv6_addr_v4mapped(&sin6->sin6_addr))\n\t\treturn tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3],\n\t\t\t\t AF_INET, cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);",
"\treturn tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin6->sin6_addr,\n\t\t\t AF_INET6, cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);\n}",
"static int tcp_v6_md5_hash_headers(struct tcp_md5sig_pool *hp,\n\t\t\t\t const struct in6_addr *daddr,\n\t\t\t\t const struct in6_addr *saddr,\n\t\t\t\t const struct tcphdr *th, int nbytes)\n{\n\tstruct tcp6_pseudohdr *bp;\n\tstruct scatterlist sg;\n\tstruct tcphdr *_th;",
"\tbp = hp->scratch;\n\t/* 1. TCP pseudo-header (RFC2460) */\n\tbp->saddr = *saddr;\n\tbp->daddr = *daddr;\n\tbp->protocol = cpu_to_be32(IPPROTO_TCP);\n\tbp->len = cpu_to_be32(nbytes);",
"\t_th = (struct tcphdr *)(bp + 1);\n\tmemcpy(_th, th, sizeof(*th));\n\t_th->check = 0;",
"\tsg_init_one(&sg, bp, sizeof(*bp) + sizeof(*th));\n\tahash_request_set_crypt(hp->md5_req, &sg, NULL,\n\t\t\t\tsizeof(*bp) + sizeof(*th));\n\treturn crypto_ahash_update(hp->md5_req);\n}",
"static int tcp_v6_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,\n\t\t\t const struct in6_addr *daddr, struct in6_addr *saddr,\n\t\t\t const struct tcphdr *th)\n{\n\tstruct tcp_md5sig_pool *hp;\n\tstruct ahash_request *req;",
"\thp = tcp_get_md5sig_pool();\n\tif (!hp)\n\t\tgoto clear_hash_noput;\n\treq = hp->md5_req;",
"\tif (crypto_ahash_init(req))\n\t\tgoto clear_hash;\n\tif (tcp_v6_md5_hash_headers(hp, daddr, saddr, th, th->doff << 2))\n\t\tgoto clear_hash;\n\tif (tcp_md5_hash_key(hp, key))\n\t\tgoto clear_hash;\n\tahash_request_set_crypt(req, NULL, md5_hash, 0);\n\tif (crypto_ahash_final(req))\n\t\tgoto clear_hash;",
"\ttcp_put_md5sig_pool();\n\treturn 0;",
"clear_hash:\n\ttcp_put_md5sig_pool();\nclear_hash_noput:\n\tmemset(md5_hash, 0, 16);\n\treturn 1;\n}",
"static int tcp_v6_md5_hash_skb(char *md5_hash,\n\t\t\t const struct tcp_md5sig_key *key,\n\t\t\t const struct sock *sk,\n\t\t\t const struct sk_buff *skb)\n{\n\tconst struct in6_addr *saddr, *daddr;\n\tstruct tcp_md5sig_pool *hp;\n\tstruct ahash_request *req;\n\tconst struct tcphdr *th = tcp_hdr(skb);",
"\tif (sk) { /* valid for establish/request sockets */\n\t\tsaddr = &sk->sk_v6_rcv_saddr;\n\t\tdaddr = &sk->sk_v6_daddr;\n\t} else {\n\t\tconst struct ipv6hdr *ip6h = ipv6_hdr(skb);\n\t\tsaddr = &ip6h->saddr;\n\t\tdaddr = &ip6h->daddr;\n\t}",
"\thp = tcp_get_md5sig_pool();\n\tif (!hp)\n\t\tgoto clear_hash_noput;\n\treq = hp->md5_req;",
"\tif (crypto_ahash_init(req))\n\t\tgoto clear_hash;",
"\tif (tcp_v6_md5_hash_headers(hp, daddr, saddr, th, skb->len))\n\t\tgoto clear_hash;\n\tif (tcp_md5_hash_skb_data(hp, skb, th->doff << 2))\n\t\tgoto clear_hash;\n\tif (tcp_md5_hash_key(hp, key))\n\t\tgoto clear_hash;\n\tahash_request_set_crypt(req, NULL, md5_hash, 0);\n\tif (crypto_ahash_final(req))\n\t\tgoto clear_hash;",
"\ttcp_put_md5sig_pool();\n\treturn 0;",
"clear_hash:\n\ttcp_put_md5sig_pool();\nclear_hash_noput:\n\tmemset(md5_hash, 0, 16);\n\treturn 1;\n}",
"#endif",
"static bool tcp_v6_inbound_md5_hash(const struct sock *sk,\n\t\t\t\t const struct sk_buff *skb)\n{\n#ifdef CONFIG_TCP_MD5SIG\n\tconst __u8 *hash_location = NULL;\n\tstruct tcp_md5sig_key *hash_expected;\n\tconst struct ipv6hdr *ip6h = ipv6_hdr(skb);\n\tconst struct tcphdr *th = tcp_hdr(skb);\n\tint genhash;\n\tu8 newhash[16];",
"\thash_expected = tcp_v6_md5_do_lookup(sk, &ip6h->saddr);\n\thash_location = tcp_parse_md5sig_option(th);",
"\t/* We've parsed the options - do we have a hash? */\n\tif (!hash_expected && !hash_location)\n\t\treturn false;",
"\tif (hash_expected && !hash_location) {\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5NOTFOUND);\n\t\treturn true;\n\t}",
"\tif (!hash_expected && hash_location) {\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5UNEXPECTED);\n\t\treturn true;\n\t}",
"\t/* check the signature */\n\tgenhash = tcp_v6_md5_hash_skb(newhash,\n\t\t\t\t hash_expected,\n\t\t\t\t NULL, skb);",
"\tif (genhash || memcmp(hash_location, newhash, 16) != 0) {\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5FAILURE);\n\t\tnet_info_ratelimited(\"MD5 Hash %s for [%pI6c]:%u->[%pI6c]:%u\\n\",\n\t\t\t\t genhash ? \"failed\" : \"mismatch\",\n\t\t\t\t &ip6h->saddr, ntohs(th->source),\n\t\t\t\t &ip6h->daddr, ntohs(th->dest));\n\t\treturn true;\n\t}\n#endif\n\treturn false;\n}",
"static void tcp_v6_init_req(struct request_sock *req,\n\t\t\t const struct sock *sk_listener,\n\t\t\t struct sk_buff *skb)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tconst struct ipv6_pinfo *np = inet6_sk(sk_listener);",
"\tireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;\n\tireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;",
"\t/* So that link locals have meaning */\n\tif (!sk_listener->sk_bound_dev_if &&\n\t ipv6_addr_type(&ireq->ir_v6_rmt_addr) & IPV6_ADDR_LINKLOCAL)\n\t\tireq->ir_iif = tcp_v6_iif(skb);",
"\tif (!TCP_SKB_CB(skb)->tcp_tw_isn &&\n\t (ipv6_opt_accepted(sk_listener, skb, &TCP_SKB_CB(skb)->header.h6) ||\n\t np->rxopt.bits.rxinfo ||\n\t np->rxopt.bits.rxoinfo || np->rxopt.bits.rxhlim ||\n\t np->rxopt.bits.rxohlim || np->repflow)) {\n\t\tatomic_inc(&skb->users);\n\t\tireq->pktopts = skb;\n\t}\n}",
"static struct dst_entry *tcp_v6_route_req(const struct sock *sk,\n\t\t\t\t\t struct flowi *fl,\n\t\t\t\t\t const struct request_sock *req)\n{\n\treturn inet6_csk_route_req(sk, &fl->u.ip6, req, IPPROTO_TCP);\n}",
"struct request_sock_ops tcp6_request_sock_ops __read_mostly = {\n\t.family\t\t=\tAF_INET6,\n\t.obj_size\t=\tsizeof(struct tcp6_request_sock),\n\t.rtx_syn_ack\t=\ttcp_rtx_synack,\n\t.send_ack\t=\ttcp_v6_reqsk_send_ack,\n\t.destructor\t=\ttcp_v6_reqsk_destructor,\n\t.send_reset\t=\ttcp_v6_send_reset,\n\t.syn_ack_timeout =\ttcp_syn_ack_timeout,\n};",
"static const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = {\n\t.mss_clamp\t=\tIPV6_MIN_MTU - sizeof(struct tcphdr) -\n\t\t\t\tsizeof(struct ipv6hdr),\n#ifdef CONFIG_TCP_MD5SIG\n\t.req_md5_lookup\t=\ttcp_v6_md5_lookup,\n\t.calc_md5_hash\t=\ttcp_v6_md5_hash_skb,\n#endif\n\t.init_req\t=\ttcp_v6_init_req,\n#ifdef CONFIG_SYN_COOKIES\n\t.cookie_init_seq =\tcookie_v6_init_sequence,\n#endif\n\t.route_req\t=\ttcp_v6_route_req,\n\t.init_seq\t=\ttcp_v6_init_seq,\n\t.init_ts_off\t=\ttcp_v6_init_ts_off,\n\t.send_synack\t=\ttcp_v6_send_synack,\n};",
"static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 seq,\n\t\t\t\t u32 ack, u32 win, u32 tsval, u32 tsecr,\n\t\t\t\t int oif, struct tcp_md5sig_key *key, int rst,\n\t\t\t\t u8 tclass, __be32 label)\n{\n\tconst struct tcphdr *th = tcp_hdr(skb);\n\tstruct tcphdr *t1;\n\tstruct sk_buff *buff;\n\tstruct flowi6 fl6;\n\tstruct net *net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);\n\tstruct sock *ctl_sk = net->ipv6.tcp_sk;\n\tunsigned int tot_len = sizeof(struct tcphdr);\n\tstruct dst_entry *dst;\n\t__be32 *topt;",
"\tif (tsecr)\n\t\ttot_len += TCPOLEN_TSTAMP_ALIGNED;\n#ifdef CONFIG_TCP_MD5SIG\n\tif (key)\n\t\ttot_len += TCPOLEN_MD5SIG_ALIGNED;\n#endif",
"\tbuff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len,\n\t\t\t GFP_ATOMIC);\n\tif (!buff)\n\t\treturn;",
"\tskb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + tot_len);",
"\tt1 = (struct tcphdr *) skb_push(buff, tot_len);\n\tskb_reset_transport_header(buff);",
"\t/* Swap the send and the receive. */\n\tmemset(t1, 0, sizeof(*t1));\n\tt1->dest = th->source;\n\tt1->source = th->dest;\n\tt1->doff = tot_len / 4;\n\tt1->seq = htonl(seq);\n\tt1->ack_seq = htonl(ack);\n\tt1->ack = !rst || !th->ack;\n\tt1->rst = rst;\n\tt1->window = htons(win);",
"\ttopt = (__be32 *)(t1 + 1);",
"\tif (tsecr) {\n\t\t*topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |\n\t\t\t\t(TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);\n\t\t*topt++ = htonl(tsval);\n\t\t*topt++ = htonl(tsecr);\n\t}",
"#ifdef CONFIG_TCP_MD5SIG\n\tif (key) {\n\t\t*topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |\n\t\t\t\t(TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG);\n\t\ttcp_v6_md5_hash_hdr((__u8 *)topt, key,\n\t\t\t\t &ipv6_hdr(skb)->saddr,\n\t\t\t\t &ipv6_hdr(skb)->daddr, t1);\n\t}\n#endif",
"\tmemset(&fl6, 0, sizeof(fl6));\n\tfl6.daddr = ipv6_hdr(skb)->saddr;\n\tfl6.saddr = ipv6_hdr(skb)->daddr;\n\tfl6.flowlabel = label;",
"\tbuff->ip_summed = CHECKSUM_PARTIAL;\n\tbuff->csum = 0;",
"\t__tcp_v6_send_check(buff, &fl6.saddr, &fl6.daddr);",
"\tfl6.flowi6_proto = IPPROTO_TCP;\n\tif (rt6_need_strict(&fl6.daddr) && !oif)\n\t\tfl6.flowi6_oif = tcp_v6_iif(skb);\n\telse {\n\t\tif (!oif && netif_index_is_l3_master(net, skb->skb_iif))\n\t\t\toif = skb->skb_iif;",
"\t\tfl6.flowi6_oif = oif;\n\t}",
"\tfl6.flowi6_mark = IP6_REPLY_MARK(net, skb->mark);\n\tfl6.fl6_dport = t1->dest;\n\tfl6.fl6_sport = t1->source;\n\tfl6.flowi6_uid = sock_net_uid(net, sk && sk_fullsock(sk) ? sk : NULL);\n\tsecurity_skb_classify_flow(skb, flowi6_to_flowi(&fl6));",
"\t/* Pass a socket to ip6_dst_lookup either it is for RST\n\t * Underlying function will use this to retrieve the network\n\t * namespace\n\t */\n\tdst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);\n\tif (!IS_ERR(dst)) {\n\t\tskb_dst_set(buff, dst);\n\t\tip6_xmit(ctl_sk, buff, &fl6, fl6.flowi6_mark, NULL, tclass);\n\t\tTCP_INC_STATS(net, TCP_MIB_OUTSEGS);\n\t\tif (rst)\n\t\t\tTCP_INC_STATS(net, TCP_MIB_OUTRSTS);\n\t\treturn;\n\t}",
"\tkfree_skb(buff);\n}",
"static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb)\n{\n\tconst struct tcphdr *th = tcp_hdr(skb);\n\tu32 seq = 0, ack_seq = 0;\n\tstruct tcp_md5sig_key *key = NULL;\n#ifdef CONFIG_TCP_MD5SIG\n\tconst __u8 *hash_location = NULL;\n\tstruct ipv6hdr *ipv6h = ipv6_hdr(skb);\n\tunsigned char newhash[16];\n\tint genhash;\n\tstruct sock *sk1 = NULL;\n#endif\n\tint oif;",
"\tif (th->rst)\n\t\treturn;",
"\t/* If sk not NULL, it means we did a successful lookup and incoming\n\t * route had to be correct. prequeue might have dropped our dst.\n\t */\n\tif (!sk && !ipv6_unicast_destination(skb))\n\t\treturn;",
"#ifdef CONFIG_TCP_MD5SIG\n\trcu_read_lock();\n\thash_location = tcp_parse_md5sig_option(th);\n\tif (sk && sk_fullsock(sk)) {\n\t\tkey = tcp_v6_md5_do_lookup(sk, &ipv6h->saddr);\n\t} else if (hash_location) {\n\t\t/*\n\t\t * active side is lost. Try to find listening socket through\n\t\t * source port, and then find md5 key through listening socket.\n\t\t * we are not loose security here:\n\t\t * Incoming packet is checked with md5 hash with finding key,\n\t\t * no RST generated if md5 hash doesn't match.\n\t\t */\n\t\tsk1 = inet6_lookup_listener(dev_net(skb_dst(skb)->dev),\n\t\t\t\t\t &tcp_hashinfo, NULL, 0,\n\t\t\t\t\t &ipv6h->saddr,\n\t\t\t\t\t th->source, &ipv6h->daddr,\n\t\t\t\t\t ntohs(th->source), tcp_v6_iif(skb));\n\t\tif (!sk1)\n\t\t\tgoto out;",
"\t\tkey = tcp_v6_md5_do_lookup(sk1, &ipv6h->saddr);\n\t\tif (!key)\n\t\t\tgoto out;",
"\t\tgenhash = tcp_v6_md5_hash_skb(newhash, key, NULL, skb);\n\t\tif (genhash || memcmp(hash_location, newhash, 16) != 0)\n\t\t\tgoto out;\n\t}\n#endif",
"\tif (th->ack)\n\t\tseq = ntohl(th->ack_seq);\n\telse\n\t\tack_seq = ntohl(th->seq) + th->syn + th->fin + skb->len -\n\t\t\t (th->doff << 2);",
"\toif = sk ? sk->sk_bound_dev_if : 0;\n\ttcp_v6_send_response(sk, skb, seq, ack_seq, 0, 0, 0, oif, key, 1, 0, 0);",
"#ifdef CONFIG_TCP_MD5SIG\nout:\n\trcu_read_unlock();\n#endif\n}",
"static void tcp_v6_send_ack(const struct sock *sk, struct sk_buff *skb, u32 seq,\n\t\t\t u32 ack, u32 win, u32 tsval, u32 tsecr, int oif,\n\t\t\t struct tcp_md5sig_key *key, u8 tclass,\n\t\t\t __be32 label)\n{\n\ttcp_v6_send_response(sk, skb, seq, ack, win, tsval, tsecr, oif, key, 0,\n\t\t\t tclass, label);\n}",
"static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct inet_timewait_sock *tw = inet_twsk(sk);\n\tstruct tcp_timewait_sock *tcptw = tcp_twsk(sk);",
"\ttcp_v6_send_ack(sk, skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt,\n\t\t\ttcptw->tw_rcv_wnd >> tw->tw_rcv_wscale,\n\t\t\ttcp_time_stamp + tcptw->tw_ts_offset,\n\t\t\ttcptw->tw_ts_recent, tw->tw_bound_dev_if, tcp_twsk_md5_key(tcptw),\n\t\t\ttw->tw_tclass, cpu_to_be32(tw->tw_flowlabel));",
"\tinet_twsk_put(tw);\n}",
"static void tcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,\n\t\t\t\t struct request_sock *req)\n{\n\t/* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV\n\t * sk->sk_state == TCP_SYN_RECV -> for Fast Open.\n\t */\n\t/* RFC 7323 2.3\n\t * The window field (SEG.WND) of every outgoing segment, with the\n\t * exception of <SYN> segments, MUST be right-shifted by\n\t * Rcv.Wind.Shift bits:\n\t */\n\ttcp_v6_send_ack(sk, skb, (sk->sk_state == TCP_LISTEN) ?\n\t\t\ttcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt,\n\t\t\ttcp_rsk(req)->rcv_nxt,\n\t\t\treq->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale,\n\t\t\ttcp_time_stamp + tcp_rsk(req)->ts_off,\n\t\t\treq->ts_recent, sk->sk_bound_dev_if,\n\t\t\ttcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr),\n\t\t\t0, 0);\n}",
"\nstatic struct sock *tcp_v6_cookie_check(struct sock *sk, struct sk_buff *skb)\n{\n#ifdef CONFIG_SYN_COOKIES\n\tconst struct tcphdr *th = tcp_hdr(skb);",
"\tif (!th->syn)\n\t\tsk = cookie_v6_check(sk, skb);\n#endif\n\treturn sk;\n}",
"static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)\n{\n\tif (skb->protocol == htons(ETH_P_IP))\n\t\treturn tcp_v4_conn_request(sk, skb);",
"\tif (!ipv6_unicast_destination(skb))\n\t\tgoto drop;",
"\treturn tcp_conn_request(&tcp6_request_sock_ops,\n\t\t\t\t&tcp_request_sock_ipv6_ops, sk, skb);",
"drop:\n\ttcp_listendrop(sk);\n\treturn 0; /* don't send reset */\n}",
"static void tcp_v6_restore_cb(struct sk_buff *skb)\n{\n\t/* We need to move header back to the beginning if xfrm6_policy_check()\n\t * and tcp_v6_fill_cb() are going to be called again.\n\t * ip6_datagram_recv_specific_ctl() also expects IP6CB to be there.\n\t */\n\tmemmove(IP6CB(skb), &TCP_SKB_CB(skb)->header.h6,\n\t\tsizeof(struct inet6_skb_parm));\n}",
"static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,\n\t\t\t\t\t struct request_sock *req,\n\t\t\t\t\t struct dst_entry *dst,\n\t\t\t\t\t struct request_sock *req_unhash,\n\t\t\t\t\t bool *own_req)\n{\n\tstruct inet_request_sock *ireq;\n\tstruct ipv6_pinfo *newnp;\n\tconst struct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct ipv6_txoptions *opt;\n\tstruct tcp6_sock *newtcp6sk;\n\tstruct inet_sock *newinet;\n\tstruct tcp_sock *newtp;\n\tstruct sock *newsk;\n#ifdef CONFIG_TCP_MD5SIG\n\tstruct tcp_md5sig_key *key;\n#endif\n\tstruct flowi6 fl6;",
"\tif (skb->protocol == htons(ETH_P_IP)) {\n\t\t/*\n\t\t *\tv6 mapped\n\t\t */",
"\t\tnewsk = tcp_v4_syn_recv_sock(sk, skb, req, dst,\n\t\t\t\t\t req_unhash, own_req);",
"\t\tif (!newsk)\n\t\t\treturn NULL;",
"\t\tnewtcp6sk = (struct tcp6_sock *)newsk;\n\t\tinet_sk(newsk)->pinet6 = &newtcp6sk->inet6;",
"\t\tnewinet = inet_sk(newsk);\n\t\tnewnp = inet6_sk(newsk);\n\t\tnewtp = tcp_sk(newsk);",
"\t\tmemcpy(newnp, np, sizeof(struct ipv6_pinfo));",
"\t\tnewnp->saddr = newsk->sk_v6_rcv_saddr;",
"\t\tinet_csk(newsk)->icsk_af_ops = &ipv6_mapped;\n\t\tnewsk->sk_backlog_rcv = tcp_v4_do_rcv;\n#ifdef CONFIG_TCP_MD5SIG\n\t\tnewtp->af_specific = &tcp_sock_ipv6_mapped_specific;\n#endif\n",
"",
"\t\tnewnp->ipv6_ac_list = NULL;\n\t\tnewnp->ipv6_fl_list = NULL;\n\t\tnewnp->pktoptions = NULL;\n\t\tnewnp->opt\t = NULL;\n\t\tnewnp->mcast_oif = tcp_v6_iif(skb);\n\t\tnewnp->mcast_hops = ipv6_hdr(skb)->hop_limit;\n\t\tnewnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));\n\t\tif (np->repflow)\n\t\t\tnewnp->flow_label = ip6_flowlabel(ipv6_hdr(skb));",
"\t\t/*\n\t\t * No need to charge this sock to the relevant IPv6 refcnt debug socks count\n\t\t * here, tcp_create_openreq_child now does this for us, see the comment in\n\t\t * that function for the gory details. -acme\n\t\t */",
"\t\t/* It is tricky place. Until this moment IPv4 tcp\n\t\t worked with IPv6 icsk.icsk_af_ops.\n\t\t Sync it now.\n\t\t */\n\t\ttcp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie);",
"\t\treturn newsk;\n\t}",
"\tireq = inet_rsk(req);",
"\tif (sk_acceptq_is_full(sk))\n\t\tgoto out_overflow;",
"\tif (!dst) {\n\t\tdst = inet6_csk_route_req(sk, &fl6, req, IPPROTO_TCP);\n\t\tif (!dst)\n\t\t\tgoto out;\n\t}",
"\tnewsk = tcp_create_openreq_child(sk, req, skb);\n\tif (!newsk)\n\t\tgoto out_nonewsk;",
"\t/*\n\t * No need to charge this sock to the relevant IPv6 refcnt debug socks\n\t * count here, tcp_create_openreq_child now does this for us, see the\n\t * comment in that function for the gory details. -acme\n\t */",
"\tnewsk->sk_gso_type = SKB_GSO_TCPV6;\n\tip6_dst_store(newsk, dst, NULL, NULL);\n\tinet6_sk_rx_dst_set(newsk, skb);",
"\tnewtcp6sk = (struct tcp6_sock *)newsk;\n\tinet_sk(newsk)->pinet6 = &newtcp6sk->inet6;",
"\tnewtp = tcp_sk(newsk);\n\tnewinet = inet_sk(newsk);\n\tnewnp = inet6_sk(newsk);",
"\tmemcpy(newnp, np, sizeof(struct ipv6_pinfo));",
"\tnewsk->sk_v6_daddr = ireq->ir_v6_rmt_addr;\n\tnewnp->saddr = ireq->ir_v6_loc_addr;\n\tnewsk->sk_v6_rcv_saddr = ireq->ir_v6_loc_addr;\n\tnewsk->sk_bound_dev_if = ireq->ir_iif;",
"\t/* Now IPv6 options...",
"\t First: no IPv4 options.\n\t */\n\tnewinet->inet_opt = NULL;",
"",
"\tnewnp->ipv6_ac_list = NULL;\n\tnewnp->ipv6_fl_list = NULL;",
"\t/* Clone RX bits */\n\tnewnp->rxopt.all = np->rxopt.all;",
"\tnewnp->pktoptions = NULL;\n\tnewnp->opt\t = NULL;\n\tnewnp->mcast_oif = tcp_v6_iif(skb);\n\tnewnp->mcast_hops = ipv6_hdr(skb)->hop_limit;\n\tnewnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));\n\tif (np->repflow)\n\t\tnewnp->flow_label = ip6_flowlabel(ipv6_hdr(skb));",
"\t/* Clone native IPv6 options from listening socket (if any)",
"\t Yes, keeping reference count would be much more clever,\n\t but we make one more one thing there: reattach optmem\n\t to newsk.\n\t */\n\topt = ireq->ipv6_opt;\n\tif (!opt)\n\t\topt = rcu_dereference(np->opt);\n\tif (opt) {\n\t\topt = ipv6_dup_options(newsk, opt);\n\t\tRCU_INIT_POINTER(newnp->opt, opt);\n\t}\n\tinet_csk(newsk)->icsk_ext_hdr_len = 0;\n\tif (opt)\n\t\tinet_csk(newsk)->icsk_ext_hdr_len = opt->opt_nflen +\n\t\t\t\t\t\t opt->opt_flen;",
"\ttcp_ca_openreq_child(newsk, dst);",
"\ttcp_sync_mss(newsk, dst_mtu(dst));\n\tnewtp->advmss = tcp_mss_clamp(tcp_sk(sk), dst_metric_advmss(dst));",
"\ttcp_initialize_rcv_mss(newsk);",
"\tnewinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6;\n\tnewinet->inet_rcv_saddr = LOOPBACK4_IPV6;",
"#ifdef CONFIG_TCP_MD5SIG\n\t/* Copy over the MD5 key from the original socket */\n\tkey = tcp_v6_md5_do_lookup(sk, &newsk->sk_v6_daddr);\n\tif (key) {\n\t\t/* We're using one, so create a matching key\n\t\t * on the newsk structure. If we fail to get\n\t\t * memory, then we end up not copying the key\n\t\t * across. Shucks.\n\t\t */\n\t\ttcp_md5_do_add(newsk, (union tcp_md5_addr *)&newsk->sk_v6_daddr,\n\t\t\t AF_INET6, key->key, key->keylen,\n\t\t\t sk_gfp_mask(sk, GFP_ATOMIC));\n\t}\n#endif",
"\tif (__inet_inherit_port(sk, newsk) < 0) {\n\t\tinet_csk_prepare_forced_close(newsk);\n\t\ttcp_done(newsk);\n\t\tgoto out;\n\t}\n\t*own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));\n\tif (*own_req) {\n\t\ttcp_move_syn(newtp, req);",
"\t\t/* Clone pktoptions received with SYN, if we own the req */\n\t\tif (ireq->pktopts) {\n\t\t\tnewnp->pktoptions = skb_clone(ireq->pktopts,\n\t\t\t\t\t\t sk_gfp_mask(sk, GFP_ATOMIC));\n\t\t\tconsume_skb(ireq->pktopts);\n\t\t\tireq->pktopts = NULL;\n\t\t\tif (newnp->pktoptions) {\n\t\t\t\ttcp_v6_restore_cb(newnp->pktoptions);\n\t\t\t\tskb_set_owner_r(newnp->pktoptions, newsk);\n\t\t\t}\n\t\t}\n\t}",
"\treturn newsk;",
"out_overflow:\n\t__NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);\nout_nonewsk:\n\tdst_release(dst);\nout:\n\ttcp_listendrop(sk);\n\treturn NULL;\n}",
"/* The socket must have it's spinlock held when we get\n * here, unless it is a TCP_LISTEN socket.\n *\n * We have a potential double-lock case here, so even when\n * doing backlog processing we use the BH locking scheme.\n * This is because we cannot sleep with the original spinlock\n * held.\n */\nstatic int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct tcp_sock *tp;\n\tstruct sk_buff *opt_skb = NULL;",
"\t/* Imagine: socket is IPv6. IPv4 packet arrives,\n\t goes to IPv4 receive handler and backlogged.\n\t From backlog it always goes here. Kerboom...\n\t Fortunately, tcp_rcv_established and rcv_established\n\t handle them correctly, but it is not case with\n\t tcp_v6_hnd_req and tcp_v6_send_reset(). --ANK\n\t */",
"\tif (skb->protocol == htons(ETH_P_IP))\n\t\treturn tcp_v4_do_rcv(sk, skb);",
"\tif (tcp_filter(sk, skb))\n\t\tgoto discard;",
"\t/*\n\t *\tsocket locking is here for SMP purposes as backlog rcv\n\t *\tis currently called with bh processing disabled.\n\t */",
"\t/* Do Stevens' IPV6_PKTOPTIONS.",
"\t Yes, guys, it is the only place in our code, where we\n\t may make it not affecting IPv4.\n\t The rest of code is protocol independent,\n\t and I do not like idea to uglify IPv4.",
"\t Actually, all the idea behind IPV6_PKTOPTIONS\n\t looks not very well thought. For now we latch\n\t options, received in the last packet, enqueued\n\t by tcp. Feel free to propose better solution.\n\t\t\t\t\t --ANK (980728)\n\t */\n\tif (np->rxopt.all)\n\t\topt_skb = skb_clone(skb, sk_gfp_mask(sk, GFP_ATOMIC));",
"\tif (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */\n\t\tstruct dst_entry *dst = sk->sk_rx_dst;",
"\t\tsock_rps_save_rxhash(sk, skb);\n\t\tsk_mark_napi_id(sk, skb);\n\t\tif (dst) {\n\t\t\tif (inet_sk(sk)->rx_dst_ifindex != skb->skb_iif ||\n\t\t\t dst->ops->check(dst, np->rx_dst_cookie) == NULL) {\n\t\t\t\tdst_release(dst);\n\t\t\t\tsk->sk_rx_dst = NULL;\n\t\t\t}\n\t\t}",
"\t\ttcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len);\n\t\tif (opt_skb)\n\t\t\tgoto ipv6_pktoptions;\n\t\treturn 0;\n\t}",
"\tif (tcp_checksum_complete(skb))\n\t\tgoto csum_err;",
"\tif (sk->sk_state == TCP_LISTEN) {\n\t\tstruct sock *nsk = tcp_v6_cookie_check(sk, skb);",
"\t\tif (!nsk)\n\t\t\tgoto discard;",
"\t\tif (nsk != sk) {\n\t\t\tif (tcp_child_process(sk, nsk, skb))\n\t\t\t\tgoto reset;\n\t\t\tif (opt_skb)\n\t\t\t\t__kfree_skb(opt_skb);\n\t\t\treturn 0;\n\t\t}\n\t} else\n\t\tsock_rps_save_rxhash(sk, skb);",
"\tif (tcp_rcv_state_process(sk, skb))\n\t\tgoto reset;\n\tif (opt_skb)\n\t\tgoto ipv6_pktoptions;\n\treturn 0;",
"reset:\n\ttcp_v6_send_reset(sk, skb);\ndiscard:\n\tif (opt_skb)\n\t\t__kfree_skb(opt_skb);\n\tkfree_skb(skb);\n\treturn 0;\ncsum_err:\n\tTCP_INC_STATS(sock_net(sk), TCP_MIB_CSUMERRORS);\n\tTCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS);\n\tgoto discard;",
"\nipv6_pktoptions:\n\t/* Do you ask, what is it?",
"\t 1. skb was enqueued by tcp.\n\t 2. skb is added to tail of read queue, rather than out of order.\n\t 3. socket is not in passive state.\n\t 4. Finally, it really contains options, which user wants to receive.\n\t */\n\ttp = tcp_sk(sk);\n\tif (TCP_SKB_CB(opt_skb)->end_seq == tp->rcv_nxt &&\n\t !((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) {\n\t\tif (np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo)\n\t\t\tnp->mcast_oif = tcp_v6_iif(opt_skb);\n\t\tif (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)\n\t\t\tnp->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;\n\t\tif (np->rxopt.bits.rxflow || np->rxopt.bits.rxtclass)\n\t\t\tnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(opt_skb));\n\t\tif (np->repflow)\n\t\t\tnp->flow_label = ip6_flowlabel(ipv6_hdr(opt_skb));\n\t\tif (ipv6_opt_accepted(sk, opt_skb, &TCP_SKB_CB(opt_skb)->header.h6)) {\n\t\t\tskb_set_owner_r(opt_skb, sk);\n\t\t\ttcp_v6_restore_cb(opt_skb);\n\t\t\topt_skb = xchg(&np->pktoptions, opt_skb);\n\t\t} else {\n\t\t\t__kfree_skb(opt_skb);\n\t\t\topt_skb = xchg(&np->pktoptions, NULL);\n\t\t}\n\t}",
"\tkfree_skb(opt_skb);\n\treturn 0;\n}",
"static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr,\n\t\t\t const struct tcphdr *th)\n{\n\t/* This is tricky: we move IP6CB at its correct location into\n\t * TCP_SKB_CB(). It must be done after xfrm6_policy_check(), because\n\t * _decode_session6() uses IP6CB().\n\t * barrier() makes sure compiler won't play aliasing games.\n\t */\n\tmemmove(&TCP_SKB_CB(skb)->header.h6, IP6CB(skb),\n\t\tsizeof(struct inet6_skb_parm));\n\tbarrier();",
"\tTCP_SKB_CB(skb)->seq = ntohl(th->seq);\n\tTCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +\n\t\t\t\t skb->len - th->doff*4);\n\tTCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);\n\tTCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th);\n\tTCP_SKB_CB(skb)->tcp_tw_isn = 0;\n\tTCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr);\n\tTCP_SKB_CB(skb)->sacked = 0;\n}",
"static int tcp_v6_rcv(struct sk_buff *skb)\n{\n\tconst struct tcphdr *th;\n\tconst struct ipv6hdr *hdr;\n\tbool refcounted;\n\tstruct sock *sk;\n\tint ret;\n\tstruct net *net = dev_net(skb->dev);",
"\tif (skb->pkt_type != PACKET_HOST)\n\t\tgoto discard_it;",
"\t/*\n\t *\tCount it even if it's bad.\n\t */\n\t__TCP_INC_STATS(net, TCP_MIB_INSEGS);",
"\tif (!pskb_may_pull(skb, sizeof(struct tcphdr)))\n\t\tgoto discard_it;",
"\tth = (const struct tcphdr *)skb->data;",
"\tif (unlikely(th->doff < sizeof(struct tcphdr)/4))\n\t\tgoto bad_packet;\n\tif (!pskb_may_pull(skb, th->doff*4))\n\t\tgoto discard_it;",
"\tif (skb_checksum_init(skb, IPPROTO_TCP, ip6_compute_pseudo))\n\t\tgoto csum_error;",
"\tth = (const struct tcphdr *)skb->data;\n\thdr = ipv6_hdr(skb);",
"lookup:\n\tsk = __inet6_lookup_skb(&tcp_hashinfo, skb, __tcp_hdrlen(th),\n\t\t\t\tth->source, th->dest, inet6_iif(skb),\n\t\t\t\t&refcounted);\n\tif (!sk)\n\t\tgoto no_tcp_socket;",
"process:\n\tif (sk->sk_state == TCP_TIME_WAIT)\n\t\tgoto do_time_wait;",
"\tif (sk->sk_state == TCP_NEW_SYN_RECV) {\n\t\tstruct request_sock *req = inet_reqsk(sk);\n\t\tstruct sock *nsk;",
"\t\tsk = req->rsk_listener;\n\t\ttcp_v6_fill_cb(skb, hdr, th);\n\t\tif (tcp_v6_inbound_md5_hash(sk, skb)) {\n\t\t\tsk_drops_add(sk, skb);\n\t\t\treqsk_put(req);\n\t\t\tgoto discard_it;\n\t\t}\n\t\tif (unlikely(sk->sk_state != TCP_LISTEN)) {\n\t\t\tinet_csk_reqsk_queue_drop_and_put(sk, req);\n\t\t\tgoto lookup;\n\t\t}\n\t\tsock_hold(sk);\n\t\trefcounted = true;\n\t\tnsk = tcp_check_req(sk, skb, req, false);\n\t\tif (!nsk) {\n\t\t\treqsk_put(req);\n\t\t\tgoto discard_and_relse;\n\t\t}\n\t\tif (nsk == sk) {\n\t\t\treqsk_put(req);\n\t\t\ttcp_v6_restore_cb(skb);\n\t\t} else if (tcp_child_process(sk, nsk, skb)) {\n\t\t\ttcp_v6_send_reset(nsk, skb);\n\t\t\tgoto discard_and_relse;\n\t\t} else {\n\t\t\tsock_put(sk);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {\n\t\t__NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP);\n\t\tgoto discard_and_relse;\n\t}",
"\tif (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))\n\t\tgoto discard_and_relse;",
"\ttcp_v6_fill_cb(skb, hdr, th);",
"\tif (tcp_v6_inbound_md5_hash(sk, skb))\n\t\tgoto discard_and_relse;",
"\tif (tcp_filter(sk, skb))\n\t\tgoto discard_and_relse;\n\tth = (const struct tcphdr *)skb->data;\n\thdr = ipv6_hdr(skb);",
"\tskb->dev = NULL;",
"\tif (sk->sk_state == TCP_LISTEN) {\n\t\tret = tcp_v6_do_rcv(sk, skb);\n\t\tgoto put_and_return;\n\t}",
"\tsk_incoming_cpu_update(sk);",
"\tbh_lock_sock_nested(sk);\n\ttcp_segs_in(tcp_sk(sk), skb);\n\tret = 0;\n\tif (!sock_owned_by_user(sk)) {\n\t\tif (!tcp_prequeue(sk, skb))\n\t\t\tret = tcp_v6_do_rcv(sk, skb);\n\t} else if (tcp_add_backlog(sk, skb)) {\n\t\tgoto discard_and_relse;\n\t}\n\tbh_unlock_sock(sk);",
"put_and_return:\n\tif (refcounted)\n\t\tsock_put(sk);\n\treturn ret ? -1 : 0;",
"no_tcp_socket:\n\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))\n\t\tgoto discard_it;",
"\ttcp_v6_fill_cb(skb, hdr, th);",
"\tif (tcp_checksum_complete(skb)) {\ncsum_error:\n\t\t__TCP_INC_STATS(net, TCP_MIB_CSUMERRORS);\nbad_packet:\n\t\t__TCP_INC_STATS(net, TCP_MIB_INERRS);\n\t} else {\n\t\ttcp_v6_send_reset(NULL, skb);\n\t}",
"discard_it:\n\tkfree_skb(skb);\n\treturn 0;",
"discard_and_relse:\n\tsk_drops_add(sk, skb);\n\tif (refcounted)\n\t\tsock_put(sk);\n\tgoto discard_it;",
"do_time_wait:\n\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\tgoto discard_it;\n\t}",
"\ttcp_v6_fill_cb(skb, hdr, th);",
"\tif (tcp_checksum_complete(skb)) {\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\tgoto csum_error;\n\t}",
"\tswitch (tcp_timewait_state_process(inet_twsk(sk), skb, th)) {\n\tcase TCP_TW_SYN:\n\t{\n\t\tstruct sock *sk2;",
"\t\tsk2 = inet6_lookup_listener(dev_net(skb->dev), &tcp_hashinfo,\n\t\t\t\t\t skb, __tcp_hdrlen(th),\n\t\t\t\t\t &ipv6_hdr(skb)->saddr, th->source,\n\t\t\t\t\t &ipv6_hdr(skb)->daddr,\n\t\t\t\t\t ntohs(th->dest), tcp_v6_iif(skb));\n\t\tif (sk2) {\n\t\t\tstruct inet_timewait_sock *tw = inet_twsk(sk);\n\t\t\tinet_twsk_deschedule_put(tw);\n\t\t\tsk = sk2;\n\t\t\ttcp_v6_restore_cb(skb);\n\t\t\trefcounted = false;\n\t\t\tgoto process;\n\t\t}\n\t\t/* Fall through to ACK */\n\t}\n\tcase TCP_TW_ACK:\n\t\ttcp_v6_timewait_ack(sk, skb);\n\t\tbreak;\n\tcase TCP_TW_RST:\n\t\ttcp_v6_restore_cb(skb);\n\t\ttcp_v6_send_reset(sk, skb);\n\t\tinet_twsk_deschedule_put(inet_twsk(sk));\n\t\tgoto discard_it;\n\tcase TCP_TW_SUCCESS:\n\t\t;\n\t}\n\tgoto discard_it;\n}",
"static void tcp_v6_early_demux(struct sk_buff *skb)\n{\n\tconst struct ipv6hdr *hdr;\n\tconst struct tcphdr *th;\n\tstruct sock *sk;",
"\tif (skb->pkt_type != PACKET_HOST)\n\t\treturn;",
"\tif (!pskb_may_pull(skb, skb_transport_offset(skb) + sizeof(struct tcphdr)))\n\t\treturn;",
"\thdr = ipv6_hdr(skb);\n\tth = tcp_hdr(skb);",
"\tif (th->doff < sizeof(struct tcphdr) / 4)\n\t\treturn;",
"\t/* Note : We use inet6_iif() here, not tcp_v6_iif() */\n\tsk = __inet6_lookup_established(dev_net(skb->dev), &tcp_hashinfo,\n\t\t\t\t\t&hdr->saddr, th->source,\n\t\t\t\t\t&hdr->daddr, ntohs(th->dest),\n\t\t\t\t\tinet6_iif(skb));\n\tif (sk) {\n\t\tskb->sk = sk;\n\t\tskb->destructor = sock_edemux;\n\t\tif (sk_fullsock(sk)) {\n\t\t\tstruct dst_entry *dst = READ_ONCE(sk->sk_rx_dst);",
"\t\t\tif (dst)\n\t\t\t\tdst = dst_check(dst, inet6_sk(sk)->rx_dst_cookie);\n\t\t\tif (dst &&\n\t\t\t inet_sk(sk)->rx_dst_ifindex == skb->skb_iif)\n\t\t\t\tskb_dst_set_noref(skb, dst);\n\t\t}\n\t}\n}",
"static struct timewait_sock_ops tcp6_timewait_sock_ops = {\n\t.twsk_obj_size\t= sizeof(struct tcp6_timewait_sock),\n\t.twsk_unique\t= tcp_twsk_unique,\n\t.twsk_destructor = tcp_twsk_destructor,\n};",
"static const struct inet_connection_sock_af_ops ipv6_specific = {\n\t.queue_xmit\t = inet6_csk_xmit,\n\t.send_check\t = tcp_v6_send_check,\n\t.rebuild_header\t = inet6_sk_rebuild_header,\n\t.sk_rx_dst_set\t = inet6_sk_rx_dst_set,\n\t.conn_request\t = tcp_v6_conn_request,\n\t.syn_recv_sock\t = tcp_v6_syn_recv_sock,\n\t.net_header_len\t = sizeof(struct ipv6hdr),\n\t.net_frag_header_len = sizeof(struct frag_hdr),\n\t.setsockopt\t = ipv6_setsockopt,\n\t.getsockopt\t = ipv6_getsockopt,\n\t.addr2sockaddr\t = inet6_csk_addr2sockaddr,\n\t.sockaddr_len\t = sizeof(struct sockaddr_in6),\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_ipv6_setsockopt,\n\t.compat_getsockopt = compat_ipv6_getsockopt,\n#endif\n\t.mtu_reduced\t = tcp_v6_mtu_reduced,\n};",
"#ifdef CONFIG_TCP_MD5SIG\nstatic const struct tcp_sock_af_ops tcp_sock_ipv6_specific = {\n\t.md5_lookup\t=\ttcp_v6_md5_lookup,\n\t.calc_md5_hash\t=\ttcp_v6_md5_hash_skb,\n\t.md5_parse\t=\ttcp_v6_parse_md5_keys,\n};\n#endif",
"/*\n *\tTCP over IPv4 via INET6 API\n */\nstatic const struct inet_connection_sock_af_ops ipv6_mapped = {\n\t.queue_xmit\t = ip_queue_xmit,\n\t.send_check\t = tcp_v4_send_check,\n\t.rebuild_header\t = inet_sk_rebuild_header,\n\t.sk_rx_dst_set\t = inet_sk_rx_dst_set,\n\t.conn_request\t = tcp_v6_conn_request,\n\t.syn_recv_sock\t = tcp_v6_syn_recv_sock,\n\t.net_header_len\t = sizeof(struct iphdr),\n\t.setsockopt\t = ipv6_setsockopt,\n\t.getsockopt\t = ipv6_getsockopt,\n\t.addr2sockaddr\t = inet6_csk_addr2sockaddr,\n\t.sockaddr_len\t = sizeof(struct sockaddr_in6),\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_ipv6_setsockopt,\n\t.compat_getsockopt = compat_ipv6_getsockopt,\n#endif\n\t.mtu_reduced\t = tcp_v4_mtu_reduced,\n};",
"#ifdef CONFIG_TCP_MD5SIG\nstatic const struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific = {\n\t.md5_lookup\t=\ttcp_v4_md5_lookup,\n\t.calc_md5_hash\t=\ttcp_v4_md5_hash_skb,\n\t.md5_parse\t=\ttcp_v6_parse_md5_keys,\n};\n#endif",
"/* NOTE: A lot of things set to zero explicitly by call to\n * sk_alloc() so need not be done here.\n */\nstatic int tcp_v6_init_sock(struct sock *sk)\n{\n\tstruct inet_connection_sock *icsk = inet_csk(sk);",
"\ttcp_init_sock(sk);",
"\ticsk->icsk_af_ops = &ipv6_specific;",
"#ifdef CONFIG_TCP_MD5SIG\n\ttcp_sk(sk)->af_specific = &tcp_sock_ipv6_specific;\n#endif",
"\treturn 0;\n}",
"static void tcp_v6_destroy_sock(struct sock *sk)\n{\n\ttcp_v4_destroy_sock(sk);\n\tinet6_destroy_sock(sk);\n}",
"#ifdef CONFIG_PROC_FS\n/* Proc filesystem TCPv6 sock list dumping. */\nstatic void get_openreq6(struct seq_file *seq,\n\t\t\t const struct request_sock *req, int i)\n{\n\tlong ttd = req->rsk_timer.expires - jiffies;\n\tconst struct in6_addr *src = &inet_rsk(req)->ir_v6_loc_addr;\n\tconst struct in6_addr *dest = &inet_rsk(req)->ir_v6_rmt_addr;",
"\tif (ttd < 0)\n\t\tttd = 0;",
"\tseq_printf(seq,\n\t\t \"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X \"\n\t\t \"%02X %08X:%08X %02X:%08lX %08X %5u %8d %d %d %pK\\n\",\n\t\t i,\n\t\t src->s6_addr32[0], src->s6_addr32[1],\n\t\t src->s6_addr32[2], src->s6_addr32[3],\n\t\t inet_rsk(req)->ir_num,\n\t\t dest->s6_addr32[0], dest->s6_addr32[1],\n\t\t dest->s6_addr32[2], dest->s6_addr32[3],\n\t\t ntohs(inet_rsk(req)->ir_rmt_port),\n\t\t TCP_SYN_RECV,\n\t\t 0, 0, /* could print option size, but that is af dependent. */\n\t\t 1, /* timers active (only the expire timer) */\n\t\t jiffies_to_clock_t(ttd),\n\t\t req->num_timeout,\n\t\t from_kuid_munged(seq_user_ns(seq),\n\t\t\t\t sock_i_uid(req->rsk_listener)),\n\t\t 0, /* non standard timer */\n\t\t 0, /* open_requests have no inode */\n\t\t 0, req);\n}",
"static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)\n{\n\tconst struct in6_addr *dest, *src;\n\t__u16 destp, srcp;\n\tint timer_active;\n\tunsigned long timer_expires;\n\tconst struct inet_sock *inet = inet_sk(sp);\n\tconst struct tcp_sock *tp = tcp_sk(sp);\n\tconst struct inet_connection_sock *icsk = inet_csk(sp);\n\tconst struct fastopen_queue *fastopenq = &icsk->icsk_accept_queue.fastopenq;\n\tint rx_queue;\n\tint state;",
"\tdest = &sp->sk_v6_daddr;\n\tsrc = &sp->sk_v6_rcv_saddr;\n\tdestp = ntohs(inet->inet_dport);\n\tsrcp = ntohs(inet->inet_sport);",
"\tif (icsk->icsk_pending == ICSK_TIME_RETRANS ||\n\t icsk->icsk_pending == ICSK_TIME_REO_TIMEOUT ||\n\t icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) {\n\t\ttimer_active\t= 1;\n\t\ttimer_expires\t= icsk->icsk_timeout;\n\t} else if (icsk->icsk_pending == ICSK_TIME_PROBE0) {\n\t\ttimer_active\t= 4;\n\t\ttimer_expires\t= icsk->icsk_timeout;\n\t} else if (timer_pending(&sp->sk_timer)) {\n\t\ttimer_active\t= 2;\n\t\ttimer_expires\t= sp->sk_timer.expires;\n\t} else {\n\t\ttimer_active\t= 0;\n\t\ttimer_expires = jiffies;\n\t}",
"\tstate = sk_state_load(sp);\n\tif (state == TCP_LISTEN)\n\t\trx_queue = sp->sk_ack_backlog;\n\telse\n\t\t/* Because we don't lock the socket,\n\t\t * we might find a transient negative value.\n\t\t */\n\t\trx_queue = max_t(int, tp->rcv_nxt - tp->copied_seq, 0);",
"\tseq_printf(seq,\n\t\t \"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X \"\n\t\t \"%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %lu %lu %u %u %d\\n\",\n\t\t i,\n\t\t src->s6_addr32[0], src->s6_addr32[1],\n\t\t src->s6_addr32[2], src->s6_addr32[3], srcp,\n\t\t dest->s6_addr32[0], dest->s6_addr32[1],\n\t\t dest->s6_addr32[2], dest->s6_addr32[3], destp,\n\t\t state,\n\t\t tp->write_seq - tp->snd_una,\n\t\t rx_queue,\n\t\t timer_active,\n\t\t jiffies_delta_to_clock_t(timer_expires - jiffies),\n\t\t icsk->icsk_retransmits,\n\t\t from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),\n\t\t icsk->icsk_probes_out,\n\t\t sock_i_ino(sp),\n\t\t atomic_read(&sp->sk_refcnt), sp,\n\t\t jiffies_to_clock_t(icsk->icsk_rto),\n\t\t jiffies_to_clock_t(icsk->icsk_ack.ato),\n\t\t (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong,\n\t\t tp->snd_cwnd,\n\t\t state == TCP_LISTEN ?\n\t\t\tfastopenq->max_qlen :\n\t\t\t(tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh)\n\t\t );\n}",
"static void get_timewait6_sock(struct seq_file *seq,\n\t\t\t struct inet_timewait_sock *tw, int i)\n{\n\tlong delta = tw->tw_timer.expires - jiffies;\n\tconst struct in6_addr *dest, *src;\n\t__u16 destp, srcp;",
"\tdest = &tw->tw_v6_daddr;\n\tsrc = &tw->tw_v6_rcv_saddr;\n\tdestp = ntohs(tw->tw_dport);\n\tsrcp = ntohs(tw->tw_sport);",
"\tseq_printf(seq,\n\t\t \"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X \"\n\t\t \"%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK\\n\",\n\t\t i,\n\t\t src->s6_addr32[0], src->s6_addr32[1],\n\t\t src->s6_addr32[2], src->s6_addr32[3], srcp,\n\t\t dest->s6_addr32[0], dest->s6_addr32[1],\n\t\t dest->s6_addr32[2], dest->s6_addr32[3], destp,\n\t\t tw->tw_substate, 0, 0,\n\t\t 3, jiffies_delta_to_clock_t(delta), 0, 0, 0, 0,\n\t\t atomic_read(&tw->tw_refcnt), tw);\n}",
"static int tcp6_seq_show(struct seq_file *seq, void *v)\n{\n\tstruct tcp_iter_state *st;\n\tstruct sock *sk = v;",
"\tif (v == SEQ_START_TOKEN) {\n\t\tseq_puts(seq,\n\t\t\t \" sl \"\n\t\t\t \"local_address \"\n\t\t\t \"remote_address \"\n\t\t\t \"st tx_queue rx_queue tr tm->when retrnsmt\"\n\t\t\t \" uid timeout inode\\n\");\n\t\tgoto out;\n\t}\n\tst = seq->private;",
"\tif (sk->sk_state == TCP_TIME_WAIT)\n\t\tget_timewait6_sock(seq, v, st->num);\n\telse if (sk->sk_state == TCP_NEW_SYN_RECV)\n\t\tget_openreq6(seq, v, st->num);\n\telse\n\t\tget_tcp6_sock(seq, v, st->num);\nout:\n\treturn 0;\n}",
"static const struct file_operations tcp6_afinfo_seq_fops = {\n\t.owner = THIS_MODULE,\n\t.open = tcp_seq_open,\n\t.read = seq_read,\n\t.llseek = seq_lseek,\n\t.release = seq_release_net\n};",
"static struct tcp_seq_afinfo tcp6_seq_afinfo = {\n\t.name\t\t= \"tcp6\",\n\t.family\t\t= AF_INET6,\n\t.seq_fops\t= &tcp6_afinfo_seq_fops,\n\t.seq_ops\t= {\n\t\t.show\t\t= tcp6_seq_show,\n\t},\n};",
"int __net_init tcp6_proc_init(struct net *net)\n{\n\treturn tcp_proc_register(net, &tcp6_seq_afinfo);\n}",
"void tcp6_proc_exit(struct net *net)\n{\n\ttcp_proc_unregister(net, &tcp6_seq_afinfo);\n}\n#endif",
"struct proto tcpv6_prot = {\n\t.name\t\t\t= \"TCPv6\",\n\t.owner\t\t\t= THIS_MODULE,\n\t.close\t\t\t= tcp_close,\n\t.connect\t\t= tcp_v6_connect,\n\t.disconnect\t\t= tcp_disconnect,\n\t.accept\t\t\t= inet_csk_accept,\n\t.ioctl\t\t\t= tcp_ioctl,\n\t.init\t\t\t= tcp_v6_init_sock,\n\t.destroy\t\t= tcp_v6_destroy_sock,\n\t.shutdown\t\t= tcp_shutdown,\n\t.setsockopt\t\t= tcp_setsockopt,\n\t.getsockopt\t\t= tcp_getsockopt,\n\t.keepalive\t\t= tcp_set_keepalive,\n\t.recvmsg\t\t= tcp_recvmsg,\n\t.sendmsg\t\t= tcp_sendmsg,\n\t.sendpage\t\t= tcp_sendpage,\n\t.backlog_rcv\t\t= tcp_v6_do_rcv,\n\t.release_cb\t\t= tcp_release_cb,\n\t.hash\t\t\t= inet6_hash,\n\t.unhash\t\t\t= inet_unhash,\n\t.get_port\t\t= inet_csk_get_port,\n\t.enter_memory_pressure\t= tcp_enter_memory_pressure,\n\t.stream_memory_free\t= tcp_stream_memory_free,\n\t.sockets_allocated\t= &tcp_sockets_allocated,\n\t.memory_allocated\t= &tcp_memory_allocated,\n\t.memory_pressure\t= &tcp_memory_pressure,\n\t.orphan_count\t\t= &tcp_orphan_count,\n\t.sysctl_mem\t\t= sysctl_tcp_mem,\n\t.sysctl_wmem\t\t= sysctl_tcp_wmem,\n\t.sysctl_rmem\t\t= sysctl_tcp_rmem,\n\t.max_header\t\t= MAX_TCP_HEADER,\n\t.obj_size\t\t= sizeof(struct tcp6_sock),\n\t.slab_flags\t\t= SLAB_DESTROY_BY_RCU,\n\t.twsk_prot\t\t= &tcp6_timewait_sock_ops,\n\t.rsk_prot\t\t= &tcp6_request_sock_ops,\n\t.h.hashinfo\t\t= &tcp_hashinfo,\n\t.no_autobind\t\t= true,\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt\t= compat_tcp_setsockopt,\n\t.compat_getsockopt\t= compat_tcp_getsockopt,\n#endif\n\t.diag_destroy\t\t= tcp_abort,\n};",
"static struct inet6_protocol tcpv6_protocol = {\n\t.early_demux\t=\ttcp_v6_early_demux,\n\t.early_demux_handler = tcp_v6_early_demux,\n\t.handler\t=\ttcp_v6_rcv,\n\t.err_handler\t=\ttcp_v6_err,\n\t.flags\t\t=\tINET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,\n};",
"static struct inet_protosw tcpv6_protosw = {\n\t.type\t\t=\tSOCK_STREAM,\n\t.protocol\t=\tIPPROTO_TCP,\n\t.prot\t\t=\t&tcpv6_prot,\n\t.ops\t\t=\t&inet6_stream_ops,\n\t.flags\t\t=\tINET_PROTOSW_PERMANENT |\n\t\t\t\tINET_PROTOSW_ICSK,\n};",
"static int __net_init tcpv6_net_init(struct net *net)\n{\n\treturn inet_ctl_sock_create(&net->ipv6.tcp_sk, PF_INET6,\n\t\t\t\t SOCK_RAW, IPPROTO_TCP, net);\n}",
"static void __net_exit tcpv6_net_exit(struct net *net)\n{\n\tinet_ctl_sock_destroy(net->ipv6.tcp_sk);\n}",
"static void __net_exit tcpv6_net_exit_batch(struct list_head *net_exit_list)\n{\n\tinet_twsk_purge(&tcp_hashinfo, AF_INET6);\n}",
"static struct pernet_operations tcpv6_net_ops = {\n\t.init\t = tcpv6_net_init,\n\t.exit\t = tcpv6_net_exit,\n\t.exit_batch = tcpv6_net_exit_batch,\n};",
"int __init tcpv6_init(void)\n{\n\tint ret;",
"\tret = inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP);\n\tif (ret)\n\t\tgoto out;",
"\t/* register inet6 protocol */\n\tret = inet6_register_protosw(&tcpv6_protosw);\n\tif (ret)\n\t\tgoto out_tcpv6_protocol;",
"\tret = register_pernet_subsys(&tcpv6_net_ops);\n\tif (ret)\n\t\tgoto out_tcpv6_protosw;\nout:\n\treturn ret;",
"out_tcpv6_protosw:\n\tinet6_unregister_protosw(&tcpv6_protosw);\nout_tcpv6_protocol:\n\tinet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);\n\tgoto out;\n}",
"void tcpv6_exit(void)\n{\n\tunregister_pernet_subsys(&tcpv6_net_ops);\n\tinet6_unregister_protosw(&tcpv6_protosw);\n\tinet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);\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,
0,
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
] |
PreciseBugs
|
{"buggy_code_end_loc": [492, 1133], "buggy_code_start_loc": [428, 1064], "filenames": ["net/dccp/ipv6.c", "net/ipv6/tcp_ipv6.c"], "fixing_code_end_loc": [499, 1136], "fixing_code_start_loc": [429, 1065], "message": "The dccp_v6_request_recv_sock function in net/dccp/ipv6.c in the Linux kernel through 4.11.1 mishandles inheritance, which allows local users to cause a denial of service or possibly have unspecified other impact via crafted system calls, a related issue to CVE-2017-8890.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "9A5C1F01-214B-4477-A3A1-F6DF10181D3C", "versionEndExcluding": "3.2.89", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "8C1901E2-6C4D-488B-A7CE-F7E14A38418F", "versionEndExcluding": "3.16.44", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.3", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "DB67DFF9-D1AD-49F9-AC6A-2BBFE1619CE2", "versionEndExcluding": "3.18.84", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.17", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "A4AF9D2F-2101-41EE-9E8C-95EE62CB1186", "versionEndExcluding": "4.4.71", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.19", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "001F55C3-810A-444F-AE18-F067A84F6B31", "versionEndExcluding": "4.9.31", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "4.5", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "1A25FD29-5617-4236-AC9A-6D68DC220925", "versionEndExcluding": "4.11.4", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "4.10", "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}], "descriptions": [{"lang": "en", "value": "The dccp_v6_request_recv_sock function in net/dccp/ipv6.c in the Linux kernel through 4.11.1 mishandles inheritance, which allows local users to cause a denial of service or possibly have unspecified other impact via crafted system calls, a related issue to CVE-2017-8890."}, {"lang": "es", "value": "La funci\u00f3n dccp_v6_request_recv_sock en el archivo net/dccp/ipv6.c en el kernel de Linux hasta versi\u00f3n 4.11.1, el manejo inapropiado de la herencia, permite a los usuarios locales causar una denegaci\u00f3n de servicio o posiblemente tener otro impacto no especificado por medio de llamadas de sistema dise\u00f1adas, un problema relacionado con CVE-2017 -8890."}], "evaluatorComment": null, "id": "CVE-2017-9076", "lastModified": "2023-02-24T18:39:05.640", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 7.2, "confidentialityImpact": "COMPLETE", "integrityImpact": "COMPLETE", "vectorString": "AV:L/AC:L/Au:N/C:C/I:C/A:C", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 10.0, "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": 7.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2017-05-19T07:29:00.307", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Vendor Advisory"], "url": "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=83eaddab4378db256d00d295bda6ca997cd13a52"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "http://www.debian.org/security/2017/dsa-3886"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/98586"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:1842"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:2077"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:2669"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:1854"}, {"source": "cve@mitre.org", "tags": ["Patch", "Vendor Advisory"], "url": "https://github.com/torvalds/linux/commit/83eaddab4378db256d00d295bda6ca997cd13a52"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://patchwork.ozlabs.org/patch/760370/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://source.android.com/security/bulletin/2017-09-01"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "NVD-CWE-noinfo"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/83eaddab4378db256d00d295bda6ca997cd13a52"}, "type": "NVD-CWE-noinfo"}
| 215
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n *\tTCP over IPv6\n *\tLinux INET6 implementation\n *\n *\tAuthors:\n *\tPedro Roque\t\t<roque@di.fc.ul.pt>\n *\n *\tBased on:\n *\tlinux/net/ipv4/tcp.c\n *\tlinux/net/ipv4/tcp_input.c\n *\tlinux/net/ipv4/tcp_output.c\n *\n *\tFixes:\n *\tHideaki YOSHIFUJI\t:\tsin6_scope_id support\n *\tYOSHIFUJI Hideaki @USAGI and:\tSupport IPV6_V6ONLY socket option, which\n *\tAlexey Kuznetsov\t\tallow both IPv4 and IPv6 sockets to bind\n *\t\t\t\t\ta single port at the same time.\n *\tYOSHIFUJI Hideaki @USAGI:\tconvert /proc/net/tcp6 to seq_file.\n *\n *\tThis 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 */",
"#include <linux/bottom_half.h>\n#include <linux/module.h>\n#include <linux/errno.h>\n#include <linux/types.h>\n#include <linux/socket.h>\n#include <linux/sockios.h>\n#include <linux/net.h>\n#include <linux/jiffies.h>\n#include <linux/in.h>\n#include <linux/in6.h>\n#include <linux/netdevice.h>\n#include <linux/init.h>\n#include <linux/jhash.h>\n#include <linux/ipsec.h>\n#include <linux/times.h>\n#include <linux/slab.h>\n#include <linux/uaccess.h>\n#include <linux/ipv6.h>\n#include <linux/icmpv6.h>\n#include <linux/random.h>",
"#include <net/tcp.h>\n#include <net/ndisc.h>\n#include <net/inet6_hashtables.h>\n#include <net/inet6_connection_sock.h>\n#include <net/ipv6.h>\n#include <net/transp_v6.h>\n#include <net/addrconf.h>\n#include <net/ip6_route.h>\n#include <net/ip6_checksum.h>\n#include <net/inet_ecn.h>\n#include <net/protocol.h>\n#include <net/xfrm.h>\n#include <net/snmp.h>\n#include <net/dsfield.h>\n#include <net/timewait_sock.h>\n#include <net/inet_common.h>\n#include <net/secure_seq.h>\n#include <net/busy_poll.h>",
"#include <linux/proc_fs.h>\n#include <linux/seq_file.h>",
"#include <crypto/hash.h>\n#include <linux/scatterlist.h>",
"static void\ttcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb);\nstatic void\ttcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,\n\t\t\t\t struct request_sock *req);",
"static int\ttcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb);",
"static const struct inet_connection_sock_af_ops ipv6_mapped;\nstatic const struct inet_connection_sock_af_ops ipv6_specific;\n#ifdef CONFIG_TCP_MD5SIG\nstatic const struct tcp_sock_af_ops tcp_sock_ipv6_specific;\nstatic const struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific;\n#else\nstatic struct tcp_md5sig_key *tcp_v6_md5_do_lookup(const struct sock *sk,\n\t\t\t\t\t\t const struct in6_addr *addr)\n{\n\treturn NULL;\n}\n#endif",
"static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)\n{\n\tstruct dst_entry *dst = skb_dst(skb);",
"\tif (dst && dst_hold_safe(dst)) {\n\t\tconst struct rt6_info *rt = (const struct rt6_info *)dst;",
"\t\tsk->sk_rx_dst = dst;\n\t\tinet_sk(sk)->rx_dst_ifindex = skb->skb_iif;\n\t\tinet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt);\n\t}\n}",
"static u32 tcp_v6_init_seq(const struct sk_buff *skb)\n{\n\treturn secure_tcpv6_seq(ipv6_hdr(skb)->daddr.s6_addr32,\n\t\t\t\tipv6_hdr(skb)->saddr.s6_addr32,\n\t\t\t\ttcp_hdr(skb)->dest,\n\t\t\t\ttcp_hdr(skb)->source);\n}",
"static u32 tcp_v6_init_ts_off(const struct sk_buff *skb)\n{\n\treturn secure_tcpv6_ts_off(ipv6_hdr(skb)->daddr.s6_addr32,\n\t\t\t\t ipv6_hdr(skb)->saddr.s6_addr32);\n}",
"static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,\n\t\t\t int addr_len)\n{\n\tstruct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct inet_connection_sock *icsk = inet_csk(sk);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct tcp_sock *tp = tcp_sk(sk);\n\tstruct in6_addr *saddr = NULL, *final_p, final;\n\tstruct ipv6_txoptions *opt;\n\tstruct flowi6 fl6;\n\tstruct dst_entry *dst;\n\tint addr_type;\n\tint err;\n\tstruct inet_timewait_death_row *tcp_death_row = &sock_net(sk)->ipv4.tcp_death_row;",
"\tif (addr_len < SIN6_LEN_RFC2133)\n\t\treturn -EINVAL;",
"\tif (usin->sin6_family != AF_INET6)\n\t\treturn -EAFNOSUPPORT;",
"\tmemset(&fl6, 0, sizeof(fl6));",
"\tif (np->sndflow) {\n\t\tfl6.flowlabel = usin->sin6_flowinfo&IPV6_FLOWINFO_MASK;\n\t\tIP6_ECN_flow_init(fl6.flowlabel);\n\t\tif (fl6.flowlabel&IPV6_FLOWLABEL_MASK) {\n\t\t\tstruct ip6_flowlabel *flowlabel;\n\t\t\tflowlabel = fl6_sock_lookup(sk, fl6.flowlabel);\n\t\t\tif (!flowlabel)\n\t\t\t\treturn -EINVAL;\n\t\t\tfl6_sock_release(flowlabel);\n\t\t}\n\t}",
"\t/*\n\t *\tconnect() to INADDR_ANY means loopback (BSD'ism).\n\t */",
"\tif (ipv6_addr_any(&usin->sin6_addr)) {\n\t\tif (ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))\n\t\t\tipv6_addr_set_v4mapped(htonl(INADDR_LOOPBACK),\n\t\t\t\t\t &usin->sin6_addr);\n\t\telse\n\t\t\tusin->sin6_addr = in6addr_loopback;\n\t}",
"\taddr_type = ipv6_addr_type(&usin->sin6_addr);",
"\tif (addr_type & IPV6_ADDR_MULTICAST)\n\t\treturn -ENETUNREACH;",
"\tif (addr_type&IPV6_ADDR_LINKLOCAL) {\n\t\tif (addr_len >= sizeof(struct sockaddr_in6) &&\n\t\t usin->sin6_scope_id) {\n\t\t\t/* If interface is set while binding, indices\n\t\t\t * must coincide.\n\t\t\t */\n\t\t\tif (sk->sk_bound_dev_if &&\n\t\t\t sk->sk_bound_dev_if != usin->sin6_scope_id)\n\t\t\t\treturn -EINVAL;",
"\t\t\tsk->sk_bound_dev_if = usin->sin6_scope_id;\n\t\t}",
"\t\t/* Connect to link-local address requires an interface */\n\t\tif (!sk->sk_bound_dev_if)\n\t\t\treturn -EINVAL;\n\t}",
"\tif (tp->rx_opt.ts_recent_stamp &&\n\t !ipv6_addr_equal(&sk->sk_v6_daddr, &usin->sin6_addr)) {\n\t\ttp->rx_opt.ts_recent = 0;\n\t\ttp->rx_opt.ts_recent_stamp = 0;\n\t\ttp->write_seq = 0;\n\t}",
"\tsk->sk_v6_daddr = usin->sin6_addr;\n\tnp->flow_label = fl6.flowlabel;",
"\t/*\n\t *\tTCP over IPv4\n\t */",
"\tif (addr_type & IPV6_ADDR_MAPPED) {\n\t\tu32 exthdrlen = icsk->icsk_ext_hdr_len;\n\t\tstruct sockaddr_in sin;",
"\t\tSOCK_DEBUG(sk, \"connect: ipv4 mapped\\n\");",
"\t\tif (__ipv6_only_sock(sk))\n\t\t\treturn -ENETUNREACH;",
"\t\tsin.sin_family = AF_INET;\n\t\tsin.sin_port = usin->sin6_port;\n\t\tsin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];",
"\t\ticsk->icsk_af_ops = &ipv6_mapped;\n\t\tsk->sk_backlog_rcv = tcp_v4_do_rcv;\n#ifdef CONFIG_TCP_MD5SIG\n\t\ttp->af_specific = &tcp_sock_ipv6_mapped_specific;\n#endif",
"\t\terr = tcp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));",
"\t\tif (err) {\n\t\t\ticsk->icsk_ext_hdr_len = exthdrlen;\n\t\t\ticsk->icsk_af_ops = &ipv6_specific;\n\t\t\tsk->sk_backlog_rcv = tcp_v6_do_rcv;\n#ifdef CONFIG_TCP_MD5SIG\n\t\t\ttp->af_specific = &tcp_sock_ipv6_specific;\n#endif\n\t\t\tgoto failure;\n\t\t}\n\t\tnp->saddr = sk->sk_v6_rcv_saddr;",
"\t\treturn err;\n\t}",
"\tif (!ipv6_addr_any(&sk->sk_v6_rcv_saddr))\n\t\tsaddr = &sk->sk_v6_rcv_saddr;",
"\tfl6.flowi6_proto = IPPROTO_TCP;\n\tfl6.daddr = sk->sk_v6_daddr;\n\tfl6.saddr = saddr ? *saddr : np->saddr;\n\tfl6.flowi6_oif = sk->sk_bound_dev_if;\n\tfl6.flowi6_mark = sk->sk_mark;\n\tfl6.fl6_dport = usin->sin6_port;\n\tfl6.fl6_sport = inet->inet_sport;\n\tfl6.flowi6_uid = sk->sk_uid;",
"\topt = rcu_dereference_protected(np->opt, lockdep_sock_is_held(sk));\n\tfinal_p = fl6_update_dst(&fl6, opt, &final);",
"\tsecurity_sk_classify_flow(sk, flowi6_to_flowi(&fl6));",
"\tdst = ip6_dst_lookup_flow(sk, &fl6, final_p);\n\tif (IS_ERR(dst)) {\n\t\terr = PTR_ERR(dst);\n\t\tgoto failure;\n\t}",
"\tif (!saddr) {\n\t\tsaddr = &fl6.saddr;\n\t\tsk->sk_v6_rcv_saddr = *saddr;\n\t}",
"\t/* set the source address */\n\tnp->saddr = *saddr;\n\tinet->inet_rcv_saddr = LOOPBACK4_IPV6;",
"\tsk->sk_gso_type = SKB_GSO_TCPV6;\n\tip6_dst_store(sk, dst, NULL, NULL);",
"\ticsk->icsk_ext_hdr_len = 0;\n\tif (opt)\n\t\ticsk->icsk_ext_hdr_len = opt->opt_flen +\n\t\t\t\t\t opt->opt_nflen;",
"\ttp->rx_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr);",
"\tinet->inet_dport = usin->sin6_port;",
"\ttcp_set_state(sk, TCP_SYN_SENT);\n\terr = inet6_hash_connect(tcp_death_row, sk);\n\tif (err)\n\t\tgoto late_failure;",
"\tsk_set_txhash(sk);",
"\tif (likely(!tp->repair)) {\n\t\tif (!tp->write_seq)\n\t\t\ttp->write_seq = secure_tcpv6_seq(np->saddr.s6_addr32,\n\t\t\t\t\t\t\t sk->sk_v6_daddr.s6_addr32,\n\t\t\t\t\t\t\t inet->inet_sport,\n\t\t\t\t\t\t\t inet->inet_dport);\n\t\ttp->tsoffset = secure_tcpv6_ts_off(np->saddr.s6_addr32,\n\t\t\t\t\t\t sk->sk_v6_daddr.s6_addr32);\n\t}",
"\tif (tcp_fastopen_defer_connect(sk, &err))\n\t\treturn err;\n\tif (err)\n\t\tgoto late_failure;",
"\terr = tcp_connect(sk);\n\tif (err)\n\t\tgoto late_failure;",
"\treturn 0;",
"late_failure:\n\ttcp_set_state(sk, TCP_CLOSE);\nfailure:\n\tinet->inet_dport = 0;\n\tsk->sk_route_caps = 0;\n\treturn err;\n}",
"static void tcp_v6_mtu_reduced(struct sock *sk)\n{\n\tstruct dst_entry *dst;",
"\tif ((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))\n\t\treturn;",
"\tdst = inet6_csk_update_pmtu(sk, tcp_sk(sk)->mtu_info);\n\tif (!dst)\n\t\treturn;",
"\tif (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst)) {\n\t\ttcp_sync_mss(sk, dst_mtu(dst));\n\t\ttcp_simple_retransmit(sk);\n\t}\n}",
"static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n\t\tu8 type, u8 code, int offset, __be32 info)\n{\n\tconst struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;\n\tconst struct tcphdr *th = (struct tcphdr *)(skb->data+offset);\n\tstruct net *net = dev_net(skb->dev);\n\tstruct request_sock *fastopen;\n\tstruct ipv6_pinfo *np;\n\tstruct tcp_sock *tp;\n\t__u32 seq, snd_una;\n\tstruct sock *sk;\n\tbool fatal;\n\tint err;",
"\tsk = __inet6_lookup_established(net, &tcp_hashinfo,\n\t\t\t\t\t&hdr->daddr, th->dest,\n\t\t\t\t\t&hdr->saddr, ntohs(th->source),\n\t\t\t\t\tskb->dev->ifindex);",
"\tif (!sk) {\n\t\t__ICMP6_INC_STATS(net, __in6_dev_get(skb->dev),\n\t\t\t\t ICMP6_MIB_INERRORS);\n\t\treturn;\n\t}",
"\tif (sk->sk_state == TCP_TIME_WAIT) {\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\treturn;\n\t}\n\tseq = ntohl(th->seq);\n\tfatal = icmpv6_err_convert(type, code, &err);\n\tif (sk->sk_state == TCP_NEW_SYN_RECV)\n\t\treturn tcp_req_err(sk, seq, fatal);",
"\tbh_lock_sock(sk);\n\tif (sock_owned_by_user(sk) && type != ICMPV6_PKT_TOOBIG)\n\t\t__NET_INC_STATS(net, LINUX_MIB_LOCKDROPPEDICMPS);",
"\tif (sk->sk_state == TCP_CLOSE)\n\t\tgoto out;",
"\tif (ipv6_hdr(skb)->hop_limit < inet6_sk(sk)->min_hopcount) {\n\t\t__NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP);\n\t\tgoto out;\n\t}",
"\ttp = tcp_sk(sk);\n\t/* XXX (TFO) - tp->snd_una should be ISN (tcp_create_openreq_child() */\n\tfastopen = tp->fastopen_rsk;\n\tsnd_una = fastopen ? tcp_rsk(fastopen)->snt_isn : tp->snd_una;\n\tif (sk->sk_state != TCP_LISTEN &&\n\t !between(seq, snd_una, tp->snd_nxt)) {\n\t\t__NET_INC_STATS(net, LINUX_MIB_OUTOFWINDOWICMPS);\n\t\tgoto out;\n\t}",
"\tnp = inet6_sk(sk);",
"\tif (type == NDISC_REDIRECT) {\n\t\tif (!sock_owned_by_user(sk)) {\n\t\t\tstruct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);",
"\t\t\tif (dst)\n\t\t\t\tdst->ops->redirect(dst, sk, skb);\n\t\t}\n\t\tgoto out;\n\t}",
"\tif (type == ICMPV6_PKT_TOOBIG) {\n\t\t/* We are not interested in TCP_LISTEN and open_requests\n\t\t * (SYN-ACKs send out by Linux are always <576bytes so\n\t\t * they should go through unfragmented).\n\t\t */\n\t\tif (sk->sk_state == TCP_LISTEN)\n\t\t\tgoto out;",
"\t\tif (!ip6_sk_accept_pmtu(sk))\n\t\t\tgoto out;",
"\t\ttp->mtu_info = ntohl(info);\n\t\tif (!sock_owned_by_user(sk))\n\t\t\ttcp_v6_mtu_reduced(sk);\n\t\telse if (!test_and_set_bit(TCP_MTU_REDUCED_DEFERRED,\n\t\t\t\t\t &sk->sk_tsq_flags))\n\t\t\tsock_hold(sk);\n\t\tgoto out;\n\t}",
"\n\t/* Might be for an request_sock */\n\tswitch (sk->sk_state) {\n\tcase TCP_SYN_SENT:\n\tcase TCP_SYN_RECV:\n\t\t/* Only in fast or simultaneous open. If a fast open socket is\n\t\t * is already accepted it is treated as a connected one below.\n\t\t */\n\t\tif (fastopen && !fastopen->sk)\n\t\t\tbreak;",
"\t\tif (!sock_owned_by_user(sk)) {\n\t\t\tsk->sk_err = err;\n\t\t\tsk->sk_error_report(sk);\t\t/* Wake people up to see the error (see connect in sock.c) */",
"\t\t\ttcp_done(sk);\n\t\t} else\n\t\t\tsk->sk_err_soft = err;\n\t\tgoto out;\n\t}",
"\tif (!sock_owned_by_user(sk) && np->recverr) {\n\t\tsk->sk_err = err;\n\t\tsk->sk_error_report(sk);\n\t} else\n\t\tsk->sk_err_soft = err;",
"out:\n\tbh_unlock_sock(sk);\n\tsock_put(sk);\n}",
"\nstatic int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst,\n\t\t\t struct flowi *fl,\n\t\t\t struct request_sock *req,\n\t\t\t struct tcp_fastopen_cookie *foc,\n\t\t\t enum tcp_synack_type synack_type)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct ipv6_txoptions *opt;\n\tstruct flowi6 *fl6 = &fl->u.ip6;\n\tstruct sk_buff *skb;\n\tint err = -ENOMEM;",
"\t/* First, grab a route. */\n\tif (!dst && (dst = inet6_csk_route_req(sk, fl6, req,\n\t\t\t\t\t IPPROTO_TCP)) == NULL)\n\t\tgoto done;",
"\tskb = tcp_make_synack(sk, dst, req, foc, synack_type);",
"\tif (skb) {\n\t\t__tcp_v6_send_check(skb, &ireq->ir_v6_loc_addr,\n\t\t\t\t &ireq->ir_v6_rmt_addr);",
"\t\tfl6->daddr = ireq->ir_v6_rmt_addr;\n\t\tif (np->repflow && ireq->pktopts)\n\t\t\tfl6->flowlabel = ip6_flowlabel(ipv6_hdr(ireq->pktopts));",
"\t\trcu_read_lock();\n\t\topt = ireq->ipv6_opt;\n\t\tif (!opt)\n\t\t\topt = rcu_dereference(np->opt);\n\t\terr = ip6_xmit(sk, skb, fl6, sk->sk_mark, opt, np->tclass);\n\t\trcu_read_unlock();\n\t\terr = net_xmit_eval(err);\n\t}",
"done:\n\treturn err;\n}",
"\nstatic void tcp_v6_reqsk_destructor(struct request_sock *req)\n{\n\tkfree(inet_rsk(req)->ipv6_opt);\n\tkfree_skb(inet_rsk(req)->pktopts);\n}",
"#ifdef CONFIG_TCP_MD5SIG\nstatic struct tcp_md5sig_key *tcp_v6_md5_do_lookup(const struct sock *sk,\n\t\t\t\t\t\t const struct in6_addr *addr)\n{\n\treturn tcp_md5_do_lookup(sk, (union tcp_md5_addr *)addr, AF_INET6);\n}",
"static struct tcp_md5sig_key *tcp_v6_md5_lookup(const struct sock *sk,\n\t\t\t\t\t\tconst struct sock *addr_sk)\n{\n\treturn tcp_v6_md5_do_lookup(sk, &addr_sk->sk_v6_daddr);\n}",
"static int tcp_v6_parse_md5_keys(struct sock *sk, char __user *optval,\n\t\t\t\t int optlen)\n{\n\tstruct tcp_md5sig cmd;\n\tstruct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&cmd.tcpm_addr;",
"\tif (optlen < sizeof(cmd))\n\t\treturn -EINVAL;",
"\tif (copy_from_user(&cmd, optval, sizeof(cmd)))\n\t\treturn -EFAULT;",
"\tif (sin6->sin6_family != AF_INET6)\n\t\treturn -EINVAL;",
"\tif (!cmd.tcpm_keylen) {\n\t\tif (ipv6_addr_v4mapped(&sin6->sin6_addr))\n\t\t\treturn tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3],\n\t\t\t\t\t AF_INET);\n\t\treturn tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr,\n\t\t\t\t AF_INET6);\n\t}",
"\tif (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)\n\t\treturn -EINVAL;",
"\tif (ipv6_addr_v4mapped(&sin6->sin6_addr))\n\t\treturn tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3],\n\t\t\t\t AF_INET, cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);",
"\treturn tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin6->sin6_addr,\n\t\t\t AF_INET6, cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);\n}",
"static int tcp_v6_md5_hash_headers(struct tcp_md5sig_pool *hp,\n\t\t\t\t const struct in6_addr *daddr,\n\t\t\t\t const struct in6_addr *saddr,\n\t\t\t\t const struct tcphdr *th, int nbytes)\n{\n\tstruct tcp6_pseudohdr *bp;\n\tstruct scatterlist sg;\n\tstruct tcphdr *_th;",
"\tbp = hp->scratch;\n\t/* 1. TCP pseudo-header (RFC2460) */\n\tbp->saddr = *saddr;\n\tbp->daddr = *daddr;\n\tbp->protocol = cpu_to_be32(IPPROTO_TCP);\n\tbp->len = cpu_to_be32(nbytes);",
"\t_th = (struct tcphdr *)(bp + 1);\n\tmemcpy(_th, th, sizeof(*th));\n\t_th->check = 0;",
"\tsg_init_one(&sg, bp, sizeof(*bp) + sizeof(*th));\n\tahash_request_set_crypt(hp->md5_req, &sg, NULL,\n\t\t\t\tsizeof(*bp) + sizeof(*th));\n\treturn crypto_ahash_update(hp->md5_req);\n}",
"static int tcp_v6_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,\n\t\t\t const struct in6_addr *daddr, struct in6_addr *saddr,\n\t\t\t const struct tcphdr *th)\n{\n\tstruct tcp_md5sig_pool *hp;\n\tstruct ahash_request *req;",
"\thp = tcp_get_md5sig_pool();\n\tif (!hp)\n\t\tgoto clear_hash_noput;\n\treq = hp->md5_req;",
"\tif (crypto_ahash_init(req))\n\t\tgoto clear_hash;\n\tif (tcp_v6_md5_hash_headers(hp, daddr, saddr, th, th->doff << 2))\n\t\tgoto clear_hash;\n\tif (tcp_md5_hash_key(hp, key))\n\t\tgoto clear_hash;\n\tahash_request_set_crypt(req, NULL, md5_hash, 0);\n\tif (crypto_ahash_final(req))\n\t\tgoto clear_hash;",
"\ttcp_put_md5sig_pool();\n\treturn 0;",
"clear_hash:\n\ttcp_put_md5sig_pool();\nclear_hash_noput:\n\tmemset(md5_hash, 0, 16);\n\treturn 1;\n}",
"static int tcp_v6_md5_hash_skb(char *md5_hash,\n\t\t\t const struct tcp_md5sig_key *key,\n\t\t\t const struct sock *sk,\n\t\t\t const struct sk_buff *skb)\n{\n\tconst struct in6_addr *saddr, *daddr;\n\tstruct tcp_md5sig_pool *hp;\n\tstruct ahash_request *req;\n\tconst struct tcphdr *th = tcp_hdr(skb);",
"\tif (sk) { /* valid for establish/request sockets */\n\t\tsaddr = &sk->sk_v6_rcv_saddr;\n\t\tdaddr = &sk->sk_v6_daddr;\n\t} else {\n\t\tconst struct ipv6hdr *ip6h = ipv6_hdr(skb);\n\t\tsaddr = &ip6h->saddr;\n\t\tdaddr = &ip6h->daddr;\n\t}",
"\thp = tcp_get_md5sig_pool();\n\tif (!hp)\n\t\tgoto clear_hash_noput;\n\treq = hp->md5_req;",
"\tif (crypto_ahash_init(req))\n\t\tgoto clear_hash;",
"\tif (tcp_v6_md5_hash_headers(hp, daddr, saddr, th, skb->len))\n\t\tgoto clear_hash;\n\tif (tcp_md5_hash_skb_data(hp, skb, th->doff << 2))\n\t\tgoto clear_hash;\n\tif (tcp_md5_hash_key(hp, key))\n\t\tgoto clear_hash;\n\tahash_request_set_crypt(req, NULL, md5_hash, 0);\n\tif (crypto_ahash_final(req))\n\t\tgoto clear_hash;",
"\ttcp_put_md5sig_pool();\n\treturn 0;",
"clear_hash:\n\ttcp_put_md5sig_pool();\nclear_hash_noput:\n\tmemset(md5_hash, 0, 16);\n\treturn 1;\n}",
"#endif",
"static bool tcp_v6_inbound_md5_hash(const struct sock *sk,\n\t\t\t\t const struct sk_buff *skb)\n{\n#ifdef CONFIG_TCP_MD5SIG\n\tconst __u8 *hash_location = NULL;\n\tstruct tcp_md5sig_key *hash_expected;\n\tconst struct ipv6hdr *ip6h = ipv6_hdr(skb);\n\tconst struct tcphdr *th = tcp_hdr(skb);\n\tint genhash;\n\tu8 newhash[16];",
"\thash_expected = tcp_v6_md5_do_lookup(sk, &ip6h->saddr);\n\thash_location = tcp_parse_md5sig_option(th);",
"\t/* We've parsed the options - do we have a hash? */\n\tif (!hash_expected && !hash_location)\n\t\treturn false;",
"\tif (hash_expected && !hash_location) {\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5NOTFOUND);\n\t\treturn true;\n\t}",
"\tif (!hash_expected && hash_location) {\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5UNEXPECTED);\n\t\treturn true;\n\t}",
"\t/* check the signature */\n\tgenhash = tcp_v6_md5_hash_skb(newhash,\n\t\t\t\t hash_expected,\n\t\t\t\t NULL, skb);",
"\tif (genhash || memcmp(hash_location, newhash, 16) != 0) {\n\t\tNET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5FAILURE);\n\t\tnet_info_ratelimited(\"MD5 Hash %s for [%pI6c]:%u->[%pI6c]:%u\\n\",\n\t\t\t\t genhash ? \"failed\" : \"mismatch\",\n\t\t\t\t &ip6h->saddr, ntohs(th->source),\n\t\t\t\t &ip6h->daddr, ntohs(th->dest));\n\t\treturn true;\n\t}\n#endif\n\treturn false;\n}",
"static void tcp_v6_init_req(struct request_sock *req,\n\t\t\t const struct sock *sk_listener,\n\t\t\t struct sk_buff *skb)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tconst struct ipv6_pinfo *np = inet6_sk(sk_listener);",
"\tireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;\n\tireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;",
"\t/* So that link locals have meaning */\n\tif (!sk_listener->sk_bound_dev_if &&\n\t ipv6_addr_type(&ireq->ir_v6_rmt_addr) & IPV6_ADDR_LINKLOCAL)\n\t\tireq->ir_iif = tcp_v6_iif(skb);",
"\tif (!TCP_SKB_CB(skb)->tcp_tw_isn &&\n\t (ipv6_opt_accepted(sk_listener, skb, &TCP_SKB_CB(skb)->header.h6) ||\n\t np->rxopt.bits.rxinfo ||\n\t np->rxopt.bits.rxoinfo || np->rxopt.bits.rxhlim ||\n\t np->rxopt.bits.rxohlim || np->repflow)) {\n\t\tatomic_inc(&skb->users);\n\t\tireq->pktopts = skb;\n\t}\n}",
"static struct dst_entry *tcp_v6_route_req(const struct sock *sk,\n\t\t\t\t\t struct flowi *fl,\n\t\t\t\t\t const struct request_sock *req)\n{\n\treturn inet6_csk_route_req(sk, &fl->u.ip6, req, IPPROTO_TCP);\n}",
"struct request_sock_ops tcp6_request_sock_ops __read_mostly = {\n\t.family\t\t=\tAF_INET6,\n\t.obj_size\t=\tsizeof(struct tcp6_request_sock),\n\t.rtx_syn_ack\t=\ttcp_rtx_synack,\n\t.send_ack\t=\ttcp_v6_reqsk_send_ack,\n\t.destructor\t=\ttcp_v6_reqsk_destructor,\n\t.send_reset\t=\ttcp_v6_send_reset,\n\t.syn_ack_timeout =\ttcp_syn_ack_timeout,\n};",
"static const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = {\n\t.mss_clamp\t=\tIPV6_MIN_MTU - sizeof(struct tcphdr) -\n\t\t\t\tsizeof(struct ipv6hdr),\n#ifdef CONFIG_TCP_MD5SIG\n\t.req_md5_lookup\t=\ttcp_v6_md5_lookup,\n\t.calc_md5_hash\t=\ttcp_v6_md5_hash_skb,\n#endif\n\t.init_req\t=\ttcp_v6_init_req,\n#ifdef CONFIG_SYN_COOKIES\n\t.cookie_init_seq =\tcookie_v6_init_sequence,\n#endif\n\t.route_req\t=\ttcp_v6_route_req,\n\t.init_seq\t=\ttcp_v6_init_seq,\n\t.init_ts_off\t=\ttcp_v6_init_ts_off,\n\t.send_synack\t=\ttcp_v6_send_synack,\n};",
"static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 seq,\n\t\t\t\t u32 ack, u32 win, u32 tsval, u32 tsecr,\n\t\t\t\t int oif, struct tcp_md5sig_key *key, int rst,\n\t\t\t\t u8 tclass, __be32 label)\n{\n\tconst struct tcphdr *th = tcp_hdr(skb);\n\tstruct tcphdr *t1;\n\tstruct sk_buff *buff;\n\tstruct flowi6 fl6;\n\tstruct net *net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);\n\tstruct sock *ctl_sk = net->ipv6.tcp_sk;\n\tunsigned int tot_len = sizeof(struct tcphdr);\n\tstruct dst_entry *dst;\n\t__be32 *topt;",
"\tif (tsecr)\n\t\ttot_len += TCPOLEN_TSTAMP_ALIGNED;\n#ifdef CONFIG_TCP_MD5SIG\n\tif (key)\n\t\ttot_len += TCPOLEN_MD5SIG_ALIGNED;\n#endif",
"\tbuff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len,\n\t\t\t GFP_ATOMIC);\n\tif (!buff)\n\t\treturn;",
"\tskb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + tot_len);",
"\tt1 = (struct tcphdr *) skb_push(buff, tot_len);\n\tskb_reset_transport_header(buff);",
"\t/* Swap the send and the receive. */\n\tmemset(t1, 0, sizeof(*t1));\n\tt1->dest = th->source;\n\tt1->source = th->dest;\n\tt1->doff = tot_len / 4;\n\tt1->seq = htonl(seq);\n\tt1->ack_seq = htonl(ack);\n\tt1->ack = !rst || !th->ack;\n\tt1->rst = rst;\n\tt1->window = htons(win);",
"\ttopt = (__be32 *)(t1 + 1);",
"\tif (tsecr) {\n\t\t*topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |\n\t\t\t\t(TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);\n\t\t*topt++ = htonl(tsval);\n\t\t*topt++ = htonl(tsecr);\n\t}",
"#ifdef CONFIG_TCP_MD5SIG\n\tif (key) {\n\t\t*topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |\n\t\t\t\t(TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG);\n\t\ttcp_v6_md5_hash_hdr((__u8 *)topt, key,\n\t\t\t\t &ipv6_hdr(skb)->saddr,\n\t\t\t\t &ipv6_hdr(skb)->daddr, t1);\n\t}\n#endif",
"\tmemset(&fl6, 0, sizeof(fl6));\n\tfl6.daddr = ipv6_hdr(skb)->saddr;\n\tfl6.saddr = ipv6_hdr(skb)->daddr;\n\tfl6.flowlabel = label;",
"\tbuff->ip_summed = CHECKSUM_PARTIAL;\n\tbuff->csum = 0;",
"\t__tcp_v6_send_check(buff, &fl6.saddr, &fl6.daddr);",
"\tfl6.flowi6_proto = IPPROTO_TCP;\n\tif (rt6_need_strict(&fl6.daddr) && !oif)\n\t\tfl6.flowi6_oif = tcp_v6_iif(skb);\n\telse {\n\t\tif (!oif && netif_index_is_l3_master(net, skb->skb_iif))\n\t\t\toif = skb->skb_iif;",
"\t\tfl6.flowi6_oif = oif;\n\t}",
"\tfl6.flowi6_mark = IP6_REPLY_MARK(net, skb->mark);\n\tfl6.fl6_dport = t1->dest;\n\tfl6.fl6_sport = t1->source;\n\tfl6.flowi6_uid = sock_net_uid(net, sk && sk_fullsock(sk) ? sk : NULL);\n\tsecurity_skb_classify_flow(skb, flowi6_to_flowi(&fl6));",
"\t/* Pass a socket to ip6_dst_lookup either it is for RST\n\t * Underlying function will use this to retrieve the network\n\t * namespace\n\t */\n\tdst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);\n\tif (!IS_ERR(dst)) {\n\t\tskb_dst_set(buff, dst);\n\t\tip6_xmit(ctl_sk, buff, &fl6, fl6.flowi6_mark, NULL, tclass);\n\t\tTCP_INC_STATS(net, TCP_MIB_OUTSEGS);\n\t\tif (rst)\n\t\t\tTCP_INC_STATS(net, TCP_MIB_OUTRSTS);\n\t\treturn;\n\t}",
"\tkfree_skb(buff);\n}",
"static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb)\n{\n\tconst struct tcphdr *th = tcp_hdr(skb);\n\tu32 seq = 0, ack_seq = 0;\n\tstruct tcp_md5sig_key *key = NULL;\n#ifdef CONFIG_TCP_MD5SIG\n\tconst __u8 *hash_location = NULL;\n\tstruct ipv6hdr *ipv6h = ipv6_hdr(skb);\n\tunsigned char newhash[16];\n\tint genhash;\n\tstruct sock *sk1 = NULL;\n#endif\n\tint oif;",
"\tif (th->rst)\n\t\treturn;",
"\t/* If sk not NULL, it means we did a successful lookup and incoming\n\t * route had to be correct. prequeue might have dropped our dst.\n\t */\n\tif (!sk && !ipv6_unicast_destination(skb))\n\t\treturn;",
"#ifdef CONFIG_TCP_MD5SIG\n\trcu_read_lock();\n\thash_location = tcp_parse_md5sig_option(th);\n\tif (sk && sk_fullsock(sk)) {\n\t\tkey = tcp_v6_md5_do_lookup(sk, &ipv6h->saddr);\n\t} else if (hash_location) {\n\t\t/*\n\t\t * active side is lost. Try to find listening socket through\n\t\t * source port, and then find md5 key through listening socket.\n\t\t * we are not loose security here:\n\t\t * Incoming packet is checked with md5 hash with finding key,\n\t\t * no RST generated if md5 hash doesn't match.\n\t\t */\n\t\tsk1 = inet6_lookup_listener(dev_net(skb_dst(skb)->dev),\n\t\t\t\t\t &tcp_hashinfo, NULL, 0,\n\t\t\t\t\t &ipv6h->saddr,\n\t\t\t\t\t th->source, &ipv6h->daddr,\n\t\t\t\t\t ntohs(th->source), tcp_v6_iif(skb));\n\t\tif (!sk1)\n\t\t\tgoto out;",
"\t\tkey = tcp_v6_md5_do_lookup(sk1, &ipv6h->saddr);\n\t\tif (!key)\n\t\t\tgoto out;",
"\t\tgenhash = tcp_v6_md5_hash_skb(newhash, key, NULL, skb);\n\t\tif (genhash || memcmp(hash_location, newhash, 16) != 0)\n\t\t\tgoto out;\n\t}\n#endif",
"\tif (th->ack)\n\t\tseq = ntohl(th->ack_seq);\n\telse\n\t\tack_seq = ntohl(th->seq) + th->syn + th->fin + skb->len -\n\t\t\t (th->doff << 2);",
"\toif = sk ? sk->sk_bound_dev_if : 0;\n\ttcp_v6_send_response(sk, skb, seq, ack_seq, 0, 0, 0, oif, key, 1, 0, 0);",
"#ifdef CONFIG_TCP_MD5SIG\nout:\n\trcu_read_unlock();\n#endif\n}",
"static void tcp_v6_send_ack(const struct sock *sk, struct sk_buff *skb, u32 seq,\n\t\t\t u32 ack, u32 win, u32 tsval, u32 tsecr, int oif,\n\t\t\t struct tcp_md5sig_key *key, u8 tclass,\n\t\t\t __be32 label)\n{\n\ttcp_v6_send_response(sk, skb, seq, ack, win, tsval, tsecr, oif, key, 0,\n\t\t\t tclass, label);\n}",
"static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct inet_timewait_sock *tw = inet_twsk(sk);\n\tstruct tcp_timewait_sock *tcptw = tcp_twsk(sk);",
"\ttcp_v6_send_ack(sk, skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt,\n\t\t\ttcptw->tw_rcv_wnd >> tw->tw_rcv_wscale,\n\t\t\ttcp_time_stamp + tcptw->tw_ts_offset,\n\t\t\ttcptw->tw_ts_recent, tw->tw_bound_dev_if, tcp_twsk_md5_key(tcptw),\n\t\t\ttw->tw_tclass, cpu_to_be32(tw->tw_flowlabel));",
"\tinet_twsk_put(tw);\n}",
"static void tcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,\n\t\t\t\t struct request_sock *req)\n{\n\t/* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV\n\t * sk->sk_state == TCP_SYN_RECV -> for Fast Open.\n\t */\n\t/* RFC 7323 2.3\n\t * The window field (SEG.WND) of every outgoing segment, with the\n\t * exception of <SYN> segments, MUST be right-shifted by\n\t * Rcv.Wind.Shift bits:\n\t */\n\ttcp_v6_send_ack(sk, skb, (sk->sk_state == TCP_LISTEN) ?\n\t\t\ttcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt,\n\t\t\ttcp_rsk(req)->rcv_nxt,\n\t\t\treq->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale,\n\t\t\ttcp_time_stamp + tcp_rsk(req)->ts_off,\n\t\t\treq->ts_recent, sk->sk_bound_dev_if,\n\t\t\ttcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr),\n\t\t\t0, 0);\n}",
"\nstatic struct sock *tcp_v6_cookie_check(struct sock *sk, struct sk_buff *skb)\n{\n#ifdef CONFIG_SYN_COOKIES\n\tconst struct tcphdr *th = tcp_hdr(skb);",
"\tif (!th->syn)\n\t\tsk = cookie_v6_check(sk, skb);\n#endif\n\treturn sk;\n}",
"static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)\n{\n\tif (skb->protocol == htons(ETH_P_IP))\n\t\treturn tcp_v4_conn_request(sk, skb);",
"\tif (!ipv6_unicast_destination(skb))\n\t\tgoto drop;",
"\treturn tcp_conn_request(&tcp6_request_sock_ops,\n\t\t\t\t&tcp_request_sock_ipv6_ops, sk, skb);",
"drop:\n\ttcp_listendrop(sk);\n\treturn 0; /* don't send reset */\n}",
"static void tcp_v6_restore_cb(struct sk_buff *skb)\n{\n\t/* We need to move header back to the beginning if xfrm6_policy_check()\n\t * and tcp_v6_fill_cb() are going to be called again.\n\t * ip6_datagram_recv_specific_ctl() also expects IP6CB to be there.\n\t */\n\tmemmove(IP6CB(skb), &TCP_SKB_CB(skb)->header.h6,\n\t\tsizeof(struct inet6_skb_parm));\n}",
"static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,\n\t\t\t\t\t struct request_sock *req,\n\t\t\t\t\t struct dst_entry *dst,\n\t\t\t\t\t struct request_sock *req_unhash,\n\t\t\t\t\t bool *own_req)\n{\n\tstruct inet_request_sock *ireq;\n\tstruct ipv6_pinfo *newnp;\n\tconst struct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct ipv6_txoptions *opt;\n\tstruct tcp6_sock *newtcp6sk;\n\tstruct inet_sock *newinet;\n\tstruct tcp_sock *newtp;\n\tstruct sock *newsk;\n#ifdef CONFIG_TCP_MD5SIG\n\tstruct tcp_md5sig_key *key;\n#endif\n\tstruct flowi6 fl6;",
"\tif (skb->protocol == htons(ETH_P_IP)) {\n\t\t/*\n\t\t *\tv6 mapped\n\t\t */",
"\t\tnewsk = tcp_v4_syn_recv_sock(sk, skb, req, dst,\n\t\t\t\t\t req_unhash, own_req);",
"\t\tif (!newsk)\n\t\t\treturn NULL;",
"\t\tnewtcp6sk = (struct tcp6_sock *)newsk;\n\t\tinet_sk(newsk)->pinet6 = &newtcp6sk->inet6;",
"\t\tnewinet = inet_sk(newsk);\n\t\tnewnp = inet6_sk(newsk);\n\t\tnewtp = tcp_sk(newsk);",
"\t\tmemcpy(newnp, np, sizeof(struct ipv6_pinfo));",
"\t\tnewnp->saddr = newsk->sk_v6_rcv_saddr;",
"\t\tinet_csk(newsk)->icsk_af_ops = &ipv6_mapped;\n\t\tnewsk->sk_backlog_rcv = tcp_v4_do_rcv;\n#ifdef CONFIG_TCP_MD5SIG\n\t\tnewtp->af_specific = &tcp_sock_ipv6_mapped_specific;\n#endif\n",
"\t\tnewnp->ipv6_mc_list = NULL;",
"\t\tnewnp->ipv6_ac_list = NULL;\n\t\tnewnp->ipv6_fl_list = NULL;\n\t\tnewnp->pktoptions = NULL;\n\t\tnewnp->opt\t = NULL;\n\t\tnewnp->mcast_oif = tcp_v6_iif(skb);\n\t\tnewnp->mcast_hops = ipv6_hdr(skb)->hop_limit;\n\t\tnewnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));\n\t\tif (np->repflow)\n\t\t\tnewnp->flow_label = ip6_flowlabel(ipv6_hdr(skb));",
"\t\t/*\n\t\t * No need to charge this sock to the relevant IPv6 refcnt debug socks count\n\t\t * here, tcp_create_openreq_child now does this for us, see the comment in\n\t\t * that function for the gory details. -acme\n\t\t */",
"\t\t/* It is tricky place. Until this moment IPv4 tcp\n\t\t worked with IPv6 icsk.icsk_af_ops.\n\t\t Sync it now.\n\t\t */\n\t\ttcp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie);",
"\t\treturn newsk;\n\t}",
"\tireq = inet_rsk(req);",
"\tif (sk_acceptq_is_full(sk))\n\t\tgoto out_overflow;",
"\tif (!dst) {\n\t\tdst = inet6_csk_route_req(sk, &fl6, req, IPPROTO_TCP);\n\t\tif (!dst)\n\t\t\tgoto out;\n\t}",
"\tnewsk = tcp_create_openreq_child(sk, req, skb);\n\tif (!newsk)\n\t\tgoto out_nonewsk;",
"\t/*\n\t * No need to charge this sock to the relevant IPv6 refcnt debug socks\n\t * count here, tcp_create_openreq_child now does this for us, see the\n\t * comment in that function for the gory details. -acme\n\t */",
"\tnewsk->sk_gso_type = SKB_GSO_TCPV6;\n\tip6_dst_store(newsk, dst, NULL, NULL);\n\tinet6_sk_rx_dst_set(newsk, skb);",
"\tnewtcp6sk = (struct tcp6_sock *)newsk;\n\tinet_sk(newsk)->pinet6 = &newtcp6sk->inet6;",
"\tnewtp = tcp_sk(newsk);\n\tnewinet = inet_sk(newsk);\n\tnewnp = inet6_sk(newsk);",
"\tmemcpy(newnp, np, sizeof(struct ipv6_pinfo));",
"\tnewsk->sk_v6_daddr = ireq->ir_v6_rmt_addr;\n\tnewnp->saddr = ireq->ir_v6_loc_addr;\n\tnewsk->sk_v6_rcv_saddr = ireq->ir_v6_loc_addr;\n\tnewsk->sk_bound_dev_if = ireq->ir_iif;",
"\t/* Now IPv6 options...",
"\t First: no IPv4 options.\n\t */\n\tnewinet->inet_opt = NULL;",
"\tnewnp->ipv6_mc_list = NULL;",
"\tnewnp->ipv6_ac_list = NULL;\n\tnewnp->ipv6_fl_list = NULL;",
"\t/* Clone RX bits */\n\tnewnp->rxopt.all = np->rxopt.all;",
"\tnewnp->pktoptions = NULL;\n\tnewnp->opt\t = NULL;\n\tnewnp->mcast_oif = tcp_v6_iif(skb);\n\tnewnp->mcast_hops = ipv6_hdr(skb)->hop_limit;\n\tnewnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));\n\tif (np->repflow)\n\t\tnewnp->flow_label = ip6_flowlabel(ipv6_hdr(skb));",
"\t/* Clone native IPv6 options from listening socket (if any)",
"\t Yes, keeping reference count would be much more clever,\n\t but we make one more one thing there: reattach optmem\n\t to newsk.\n\t */\n\topt = ireq->ipv6_opt;\n\tif (!opt)\n\t\topt = rcu_dereference(np->opt);\n\tif (opt) {\n\t\topt = ipv6_dup_options(newsk, opt);\n\t\tRCU_INIT_POINTER(newnp->opt, opt);\n\t}\n\tinet_csk(newsk)->icsk_ext_hdr_len = 0;\n\tif (opt)\n\t\tinet_csk(newsk)->icsk_ext_hdr_len = opt->opt_nflen +\n\t\t\t\t\t\t opt->opt_flen;",
"\ttcp_ca_openreq_child(newsk, dst);",
"\ttcp_sync_mss(newsk, dst_mtu(dst));\n\tnewtp->advmss = tcp_mss_clamp(tcp_sk(sk), dst_metric_advmss(dst));",
"\ttcp_initialize_rcv_mss(newsk);",
"\tnewinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6;\n\tnewinet->inet_rcv_saddr = LOOPBACK4_IPV6;",
"#ifdef CONFIG_TCP_MD5SIG\n\t/* Copy over the MD5 key from the original socket */\n\tkey = tcp_v6_md5_do_lookup(sk, &newsk->sk_v6_daddr);\n\tif (key) {\n\t\t/* We're using one, so create a matching key\n\t\t * on the newsk structure. If we fail to get\n\t\t * memory, then we end up not copying the key\n\t\t * across. Shucks.\n\t\t */\n\t\ttcp_md5_do_add(newsk, (union tcp_md5_addr *)&newsk->sk_v6_daddr,\n\t\t\t AF_INET6, key->key, key->keylen,\n\t\t\t sk_gfp_mask(sk, GFP_ATOMIC));\n\t}\n#endif",
"\tif (__inet_inherit_port(sk, newsk) < 0) {\n\t\tinet_csk_prepare_forced_close(newsk);\n\t\ttcp_done(newsk);\n\t\tgoto out;\n\t}\n\t*own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));\n\tif (*own_req) {\n\t\ttcp_move_syn(newtp, req);",
"\t\t/* Clone pktoptions received with SYN, if we own the req */\n\t\tif (ireq->pktopts) {\n\t\t\tnewnp->pktoptions = skb_clone(ireq->pktopts,\n\t\t\t\t\t\t sk_gfp_mask(sk, GFP_ATOMIC));\n\t\t\tconsume_skb(ireq->pktopts);\n\t\t\tireq->pktopts = NULL;\n\t\t\tif (newnp->pktoptions) {\n\t\t\t\ttcp_v6_restore_cb(newnp->pktoptions);\n\t\t\t\tskb_set_owner_r(newnp->pktoptions, newsk);\n\t\t\t}\n\t\t}\n\t}",
"\treturn newsk;",
"out_overflow:\n\t__NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);\nout_nonewsk:\n\tdst_release(dst);\nout:\n\ttcp_listendrop(sk);\n\treturn NULL;\n}",
"/* The socket must have it's spinlock held when we get\n * here, unless it is a TCP_LISTEN socket.\n *\n * We have a potential double-lock case here, so even when\n * doing backlog processing we use the BH locking scheme.\n * This is because we cannot sleep with the original spinlock\n * held.\n */\nstatic int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct tcp_sock *tp;\n\tstruct sk_buff *opt_skb = NULL;",
"\t/* Imagine: socket is IPv6. IPv4 packet arrives,\n\t goes to IPv4 receive handler and backlogged.\n\t From backlog it always goes here. Kerboom...\n\t Fortunately, tcp_rcv_established and rcv_established\n\t handle them correctly, but it is not case with\n\t tcp_v6_hnd_req and tcp_v6_send_reset(). --ANK\n\t */",
"\tif (skb->protocol == htons(ETH_P_IP))\n\t\treturn tcp_v4_do_rcv(sk, skb);",
"\tif (tcp_filter(sk, skb))\n\t\tgoto discard;",
"\t/*\n\t *\tsocket locking is here for SMP purposes as backlog rcv\n\t *\tis currently called with bh processing disabled.\n\t */",
"\t/* Do Stevens' IPV6_PKTOPTIONS.",
"\t Yes, guys, it is the only place in our code, where we\n\t may make it not affecting IPv4.\n\t The rest of code is protocol independent,\n\t and I do not like idea to uglify IPv4.",
"\t Actually, all the idea behind IPV6_PKTOPTIONS\n\t looks not very well thought. For now we latch\n\t options, received in the last packet, enqueued\n\t by tcp. Feel free to propose better solution.\n\t\t\t\t\t --ANK (980728)\n\t */\n\tif (np->rxopt.all)\n\t\topt_skb = skb_clone(skb, sk_gfp_mask(sk, GFP_ATOMIC));",
"\tif (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */\n\t\tstruct dst_entry *dst = sk->sk_rx_dst;",
"\t\tsock_rps_save_rxhash(sk, skb);\n\t\tsk_mark_napi_id(sk, skb);\n\t\tif (dst) {\n\t\t\tif (inet_sk(sk)->rx_dst_ifindex != skb->skb_iif ||\n\t\t\t dst->ops->check(dst, np->rx_dst_cookie) == NULL) {\n\t\t\t\tdst_release(dst);\n\t\t\t\tsk->sk_rx_dst = NULL;\n\t\t\t}\n\t\t}",
"\t\ttcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len);\n\t\tif (opt_skb)\n\t\t\tgoto ipv6_pktoptions;\n\t\treturn 0;\n\t}",
"\tif (tcp_checksum_complete(skb))\n\t\tgoto csum_err;",
"\tif (sk->sk_state == TCP_LISTEN) {\n\t\tstruct sock *nsk = tcp_v6_cookie_check(sk, skb);",
"\t\tif (!nsk)\n\t\t\tgoto discard;",
"\t\tif (nsk != sk) {\n\t\t\tif (tcp_child_process(sk, nsk, skb))\n\t\t\t\tgoto reset;\n\t\t\tif (opt_skb)\n\t\t\t\t__kfree_skb(opt_skb);\n\t\t\treturn 0;\n\t\t}\n\t} else\n\t\tsock_rps_save_rxhash(sk, skb);",
"\tif (tcp_rcv_state_process(sk, skb))\n\t\tgoto reset;\n\tif (opt_skb)\n\t\tgoto ipv6_pktoptions;\n\treturn 0;",
"reset:\n\ttcp_v6_send_reset(sk, skb);\ndiscard:\n\tif (opt_skb)\n\t\t__kfree_skb(opt_skb);\n\tkfree_skb(skb);\n\treturn 0;\ncsum_err:\n\tTCP_INC_STATS(sock_net(sk), TCP_MIB_CSUMERRORS);\n\tTCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS);\n\tgoto discard;",
"\nipv6_pktoptions:\n\t/* Do you ask, what is it?",
"\t 1. skb was enqueued by tcp.\n\t 2. skb is added to tail of read queue, rather than out of order.\n\t 3. socket is not in passive state.\n\t 4. Finally, it really contains options, which user wants to receive.\n\t */\n\ttp = tcp_sk(sk);\n\tif (TCP_SKB_CB(opt_skb)->end_seq == tp->rcv_nxt &&\n\t !((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) {\n\t\tif (np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo)\n\t\t\tnp->mcast_oif = tcp_v6_iif(opt_skb);\n\t\tif (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)\n\t\t\tnp->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;\n\t\tif (np->rxopt.bits.rxflow || np->rxopt.bits.rxtclass)\n\t\t\tnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(opt_skb));\n\t\tif (np->repflow)\n\t\t\tnp->flow_label = ip6_flowlabel(ipv6_hdr(opt_skb));\n\t\tif (ipv6_opt_accepted(sk, opt_skb, &TCP_SKB_CB(opt_skb)->header.h6)) {\n\t\t\tskb_set_owner_r(opt_skb, sk);\n\t\t\ttcp_v6_restore_cb(opt_skb);\n\t\t\topt_skb = xchg(&np->pktoptions, opt_skb);\n\t\t} else {\n\t\t\t__kfree_skb(opt_skb);\n\t\t\topt_skb = xchg(&np->pktoptions, NULL);\n\t\t}\n\t}",
"\tkfree_skb(opt_skb);\n\treturn 0;\n}",
"static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr,\n\t\t\t const struct tcphdr *th)\n{\n\t/* This is tricky: we move IP6CB at its correct location into\n\t * TCP_SKB_CB(). It must be done after xfrm6_policy_check(), because\n\t * _decode_session6() uses IP6CB().\n\t * barrier() makes sure compiler won't play aliasing games.\n\t */\n\tmemmove(&TCP_SKB_CB(skb)->header.h6, IP6CB(skb),\n\t\tsizeof(struct inet6_skb_parm));\n\tbarrier();",
"\tTCP_SKB_CB(skb)->seq = ntohl(th->seq);\n\tTCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +\n\t\t\t\t skb->len - th->doff*4);\n\tTCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);\n\tTCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th);\n\tTCP_SKB_CB(skb)->tcp_tw_isn = 0;\n\tTCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr);\n\tTCP_SKB_CB(skb)->sacked = 0;\n}",
"static int tcp_v6_rcv(struct sk_buff *skb)\n{\n\tconst struct tcphdr *th;\n\tconst struct ipv6hdr *hdr;\n\tbool refcounted;\n\tstruct sock *sk;\n\tint ret;\n\tstruct net *net = dev_net(skb->dev);",
"\tif (skb->pkt_type != PACKET_HOST)\n\t\tgoto discard_it;",
"\t/*\n\t *\tCount it even if it's bad.\n\t */\n\t__TCP_INC_STATS(net, TCP_MIB_INSEGS);",
"\tif (!pskb_may_pull(skb, sizeof(struct tcphdr)))\n\t\tgoto discard_it;",
"\tth = (const struct tcphdr *)skb->data;",
"\tif (unlikely(th->doff < sizeof(struct tcphdr)/4))\n\t\tgoto bad_packet;\n\tif (!pskb_may_pull(skb, th->doff*4))\n\t\tgoto discard_it;",
"\tif (skb_checksum_init(skb, IPPROTO_TCP, ip6_compute_pseudo))\n\t\tgoto csum_error;",
"\tth = (const struct tcphdr *)skb->data;\n\thdr = ipv6_hdr(skb);",
"lookup:\n\tsk = __inet6_lookup_skb(&tcp_hashinfo, skb, __tcp_hdrlen(th),\n\t\t\t\tth->source, th->dest, inet6_iif(skb),\n\t\t\t\t&refcounted);\n\tif (!sk)\n\t\tgoto no_tcp_socket;",
"process:\n\tif (sk->sk_state == TCP_TIME_WAIT)\n\t\tgoto do_time_wait;",
"\tif (sk->sk_state == TCP_NEW_SYN_RECV) {\n\t\tstruct request_sock *req = inet_reqsk(sk);\n\t\tstruct sock *nsk;",
"\t\tsk = req->rsk_listener;\n\t\ttcp_v6_fill_cb(skb, hdr, th);\n\t\tif (tcp_v6_inbound_md5_hash(sk, skb)) {\n\t\t\tsk_drops_add(sk, skb);\n\t\t\treqsk_put(req);\n\t\t\tgoto discard_it;\n\t\t}\n\t\tif (unlikely(sk->sk_state != TCP_LISTEN)) {\n\t\t\tinet_csk_reqsk_queue_drop_and_put(sk, req);\n\t\t\tgoto lookup;\n\t\t}\n\t\tsock_hold(sk);\n\t\trefcounted = true;\n\t\tnsk = tcp_check_req(sk, skb, req, false);\n\t\tif (!nsk) {\n\t\t\treqsk_put(req);\n\t\t\tgoto discard_and_relse;\n\t\t}\n\t\tif (nsk == sk) {\n\t\t\treqsk_put(req);\n\t\t\ttcp_v6_restore_cb(skb);\n\t\t} else if (tcp_child_process(sk, nsk, skb)) {\n\t\t\ttcp_v6_send_reset(nsk, skb);\n\t\t\tgoto discard_and_relse;\n\t\t} else {\n\t\t\tsock_put(sk);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {\n\t\t__NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP);\n\t\tgoto discard_and_relse;\n\t}",
"\tif (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))\n\t\tgoto discard_and_relse;",
"\ttcp_v6_fill_cb(skb, hdr, th);",
"\tif (tcp_v6_inbound_md5_hash(sk, skb))\n\t\tgoto discard_and_relse;",
"\tif (tcp_filter(sk, skb))\n\t\tgoto discard_and_relse;\n\tth = (const struct tcphdr *)skb->data;\n\thdr = ipv6_hdr(skb);",
"\tskb->dev = NULL;",
"\tif (sk->sk_state == TCP_LISTEN) {\n\t\tret = tcp_v6_do_rcv(sk, skb);\n\t\tgoto put_and_return;\n\t}",
"\tsk_incoming_cpu_update(sk);",
"\tbh_lock_sock_nested(sk);\n\ttcp_segs_in(tcp_sk(sk), skb);\n\tret = 0;\n\tif (!sock_owned_by_user(sk)) {\n\t\tif (!tcp_prequeue(sk, skb))\n\t\t\tret = tcp_v6_do_rcv(sk, skb);\n\t} else if (tcp_add_backlog(sk, skb)) {\n\t\tgoto discard_and_relse;\n\t}\n\tbh_unlock_sock(sk);",
"put_and_return:\n\tif (refcounted)\n\t\tsock_put(sk);\n\treturn ret ? -1 : 0;",
"no_tcp_socket:\n\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))\n\t\tgoto discard_it;",
"\ttcp_v6_fill_cb(skb, hdr, th);",
"\tif (tcp_checksum_complete(skb)) {\ncsum_error:\n\t\t__TCP_INC_STATS(net, TCP_MIB_CSUMERRORS);\nbad_packet:\n\t\t__TCP_INC_STATS(net, TCP_MIB_INERRS);\n\t} else {\n\t\ttcp_v6_send_reset(NULL, skb);\n\t}",
"discard_it:\n\tkfree_skb(skb);\n\treturn 0;",
"discard_and_relse:\n\tsk_drops_add(sk, skb);\n\tif (refcounted)\n\t\tsock_put(sk);\n\tgoto discard_it;",
"do_time_wait:\n\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\tgoto discard_it;\n\t}",
"\ttcp_v6_fill_cb(skb, hdr, th);",
"\tif (tcp_checksum_complete(skb)) {\n\t\tinet_twsk_put(inet_twsk(sk));\n\t\tgoto csum_error;\n\t}",
"\tswitch (tcp_timewait_state_process(inet_twsk(sk), skb, th)) {\n\tcase TCP_TW_SYN:\n\t{\n\t\tstruct sock *sk2;",
"\t\tsk2 = inet6_lookup_listener(dev_net(skb->dev), &tcp_hashinfo,\n\t\t\t\t\t skb, __tcp_hdrlen(th),\n\t\t\t\t\t &ipv6_hdr(skb)->saddr, th->source,\n\t\t\t\t\t &ipv6_hdr(skb)->daddr,\n\t\t\t\t\t ntohs(th->dest), tcp_v6_iif(skb));\n\t\tif (sk2) {\n\t\t\tstruct inet_timewait_sock *tw = inet_twsk(sk);\n\t\t\tinet_twsk_deschedule_put(tw);\n\t\t\tsk = sk2;\n\t\t\ttcp_v6_restore_cb(skb);\n\t\t\trefcounted = false;\n\t\t\tgoto process;\n\t\t}\n\t\t/* Fall through to ACK */\n\t}\n\tcase TCP_TW_ACK:\n\t\ttcp_v6_timewait_ack(sk, skb);\n\t\tbreak;\n\tcase TCP_TW_RST:\n\t\ttcp_v6_restore_cb(skb);\n\t\ttcp_v6_send_reset(sk, skb);\n\t\tinet_twsk_deschedule_put(inet_twsk(sk));\n\t\tgoto discard_it;\n\tcase TCP_TW_SUCCESS:\n\t\t;\n\t}\n\tgoto discard_it;\n}",
"static void tcp_v6_early_demux(struct sk_buff *skb)\n{\n\tconst struct ipv6hdr *hdr;\n\tconst struct tcphdr *th;\n\tstruct sock *sk;",
"\tif (skb->pkt_type != PACKET_HOST)\n\t\treturn;",
"\tif (!pskb_may_pull(skb, skb_transport_offset(skb) + sizeof(struct tcphdr)))\n\t\treturn;",
"\thdr = ipv6_hdr(skb);\n\tth = tcp_hdr(skb);",
"\tif (th->doff < sizeof(struct tcphdr) / 4)\n\t\treturn;",
"\t/* Note : We use inet6_iif() here, not tcp_v6_iif() */\n\tsk = __inet6_lookup_established(dev_net(skb->dev), &tcp_hashinfo,\n\t\t\t\t\t&hdr->saddr, th->source,\n\t\t\t\t\t&hdr->daddr, ntohs(th->dest),\n\t\t\t\t\tinet6_iif(skb));\n\tif (sk) {\n\t\tskb->sk = sk;\n\t\tskb->destructor = sock_edemux;\n\t\tif (sk_fullsock(sk)) {\n\t\t\tstruct dst_entry *dst = READ_ONCE(sk->sk_rx_dst);",
"\t\t\tif (dst)\n\t\t\t\tdst = dst_check(dst, inet6_sk(sk)->rx_dst_cookie);\n\t\t\tif (dst &&\n\t\t\t inet_sk(sk)->rx_dst_ifindex == skb->skb_iif)\n\t\t\t\tskb_dst_set_noref(skb, dst);\n\t\t}\n\t}\n}",
"static struct timewait_sock_ops tcp6_timewait_sock_ops = {\n\t.twsk_obj_size\t= sizeof(struct tcp6_timewait_sock),\n\t.twsk_unique\t= tcp_twsk_unique,\n\t.twsk_destructor = tcp_twsk_destructor,\n};",
"static const struct inet_connection_sock_af_ops ipv6_specific = {\n\t.queue_xmit\t = inet6_csk_xmit,\n\t.send_check\t = tcp_v6_send_check,\n\t.rebuild_header\t = inet6_sk_rebuild_header,\n\t.sk_rx_dst_set\t = inet6_sk_rx_dst_set,\n\t.conn_request\t = tcp_v6_conn_request,\n\t.syn_recv_sock\t = tcp_v6_syn_recv_sock,\n\t.net_header_len\t = sizeof(struct ipv6hdr),\n\t.net_frag_header_len = sizeof(struct frag_hdr),\n\t.setsockopt\t = ipv6_setsockopt,\n\t.getsockopt\t = ipv6_getsockopt,\n\t.addr2sockaddr\t = inet6_csk_addr2sockaddr,\n\t.sockaddr_len\t = sizeof(struct sockaddr_in6),\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_ipv6_setsockopt,\n\t.compat_getsockopt = compat_ipv6_getsockopt,\n#endif\n\t.mtu_reduced\t = tcp_v6_mtu_reduced,\n};",
"#ifdef CONFIG_TCP_MD5SIG\nstatic const struct tcp_sock_af_ops tcp_sock_ipv6_specific = {\n\t.md5_lookup\t=\ttcp_v6_md5_lookup,\n\t.calc_md5_hash\t=\ttcp_v6_md5_hash_skb,\n\t.md5_parse\t=\ttcp_v6_parse_md5_keys,\n};\n#endif",
"/*\n *\tTCP over IPv4 via INET6 API\n */\nstatic const struct inet_connection_sock_af_ops ipv6_mapped = {\n\t.queue_xmit\t = ip_queue_xmit,\n\t.send_check\t = tcp_v4_send_check,\n\t.rebuild_header\t = inet_sk_rebuild_header,\n\t.sk_rx_dst_set\t = inet_sk_rx_dst_set,\n\t.conn_request\t = tcp_v6_conn_request,\n\t.syn_recv_sock\t = tcp_v6_syn_recv_sock,\n\t.net_header_len\t = sizeof(struct iphdr),\n\t.setsockopt\t = ipv6_setsockopt,\n\t.getsockopt\t = ipv6_getsockopt,\n\t.addr2sockaddr\t = inet6_csk_addr2sockaddr,\n\t.sockaddr_len\t = sizeof(struct sockaddr_in6),\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt = compat_ipv6_setsockopt,\n\t.compat_getsockopt = compat_ipv6_getsockopt,\n#endif\n\t.mtu_reduced\t = tcp_v4_mtu_reduced,\n};",
"#ifdef CONFIG_TCP_MD5SIG\nstatic const struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific = {\n\t.md5_lookup\t=\ttcp_v4_md5_lookup,\n\t.calc_md5_hash\t=\ttcp_v4_md5_hash_skb,\n\t.md5_parse\t=\ttcp_v6_parse_md5_keys,\n};\n#endif",
"/* NOTE: A lot of things set to zero explicitly by call to\n * sk_alloc() so need not be done here.\n */\nstatic int tcp_v6_init_sock(struct sock *sk)\n{\n\tstruct inet_connection_sock *icsk = inet_csk(sk);",
"\ttcp_init_sock(sk);",
"\ticsk->icsk_af_ops = &ipv6_specific;",
"#ifdef CONFIG_TCP_MD5SIG\n\ttcp_sk(sk)->af_specific = &tcp_sock_ipv6_specific;\n#endif",
"\treturn 0;\n}",
"static void tcp_v6_destroy_sock(struct sock *sk)\n{\n\ttcp_v4_destroy_sock(sk);\n\tinet6_destroy_sock(sk);\n}",
"#ifdef CONFIG_PROC_FS\n/* Proc filesystem TCPv6 sock list dumping. */\nstatic void get_openreq6(struct seq_file *seq,\n\t\t\t const struct request_sock *req, int i)\n{\n\tlong ttd = req->rsk_timer.expires - jiffies;\n\tconst struct in6_addr *src = &inet_rsk(req)->ir_v6_loc_addr;\n\tconst struct in6_addr *dest = &inet_rsk(req)->ir_v6_rmt_addr;",
"\tif (ttd < 0)\n\t\tttd = 0;",
"\tseq_printf(seq,\n\t\t \"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X \"\n\t\t \"%02X %08X:%08X %02X:%08lX %08X %5u %8d %d %d %pK\\n\",\n\t\t i,\n\t\t src->s6_addr32[0], src->s6_addr32[1],\n\t\t src->s6_addr32[2], src->s6_addr32[3],\n\t\t inet_rsk(req)->ir_num,\n\t\t dest->s6_addr32[0], dest->s6_addr32[1],\n\t\t dest->s6_addr32[2], dest->s6_addr32[3],\n\t\t ntohs(inet_rsk(req)->ir_rmt_port),\n\t\t TCP_SYN_RECV,\n\t\t 0, 0, /* could print option size, but that is af dependent. */\n\t\t 1, /* timers active (only the expire timer) */\n\t\t jiffies_to_clock_t(ttd),\n\t\t req->num_timeout,\n\t\t from_kuid_munged(seq_user_ns(seq),\n\t\t\t\t sock_i_uid(req->rsk_listener)),\n\t\t 0, /* non standard timer */\n\t\t 0, /* open_requests have no inode */\n\t\t 0, req);\n}",
"static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)\n{\n\tconst struct in6_addr *dest, *src;\n\t__u16 destp, srcp;\n\tint timer_active;\n\tunsigned long timer_expires;\n\tconst struct inet_sock *inet = inet_sk(sp);\n\tconst struct tcp_sock *tp = tcp_sk(sp);\n\tconst struct inet_connection_sock *icsk = inet_csk(sp);\n\tconst struct fastopen_queue *fastopenq = &icsk->icsk_accept_queue.fastopenq;\n\tint rx_queue;\n\tint state;",
"\tdest = &sp->sk_v6_daddr;\n\tsrc = &sp->sk_v6_rcv_saddr;\n\tdestp = ntohs(inet->inet_dport);\n\tsrcp = ntohs(inet->inet_sport);",
"\tif (icsk->icsk_pending == ICSK_TIME_RETRANS ||\n\t icsk->icsk_pending == ICSK_TIME_REO_TIMEOUT ||\n\t icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) {\n\t\ttimer_active\t= 1;\n\t\ttimer_expires\t= icsk->icsk_timeout;\n\t} else if (icsk->icsk_pending == ICSK_TIME_PROBE0) {\n\t\ttimer_active\t= 4;\n\t\ttimer_expires\t= icsk->icsk_timeout;\n\t} else if (timer_pending(&sp->sk_timer)) {\n\t\ttimer_active\t= 2;\n\t\ttimer_expires\t= sp->sk_timer.expires;\n\t} else {\n\t\ttimer_active\t= 0;\n\t\ttimer_expires = jiffies;\n\t}",
"\tstate = sk_state_load(sp);\n\tif (state == TCP_LISTEN)\n\t\trx_queue = sp->sk_ack_backlog;\n\telse\n\t\t/* Because we don't lock the socket,\n\t\t * we might find a transient negative value.\n\t\t */\n\t\trx_queue = max_t(int, tp->rcv_nxt - tp->copied_seq, 0);",
"\tseq_printf(seq,\n\t\t \"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X \"\n\t\t \"%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %lu %lu %u %u %d\\n\",\n\t\t i,\n\t\t src->s6_addr32[0], src->s6_addr32[1],\n\t\t src->s6_addr32[2], src->s6_addr32[3], srcp,\n\t\t dest->s6_addr32[0], dest->s6_addr32[1],\n\t\t dest->s6_addr32[2], dest->s6_addr32[3], destp,\n\t\t state,\n\t\t tp->write_seq - tp->snd_una,\n\t\t rx_queue,\n\t\t timer_active,\n\t\t jiffies_delta_to_clock_t(timer_expires - jiffies),\n\t\t icsk->icsk_retransmits,\n\t\t from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),\n\t\t icsk->icsk_probes_out,\n\t\t sock_i_ino(sp),\n\t\t atomic_read(&sp->sk_refcnt), sp,\n\t\t jiffies_to_clock_t(icsk->icsk_rto),\n\t\t jiffies_to_clock_t(icsk->icsk_ack.ato),\n\t\t (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong,\n\t\t tp->snd_cwnd,\n\t\t state == TCP_LISTEN ?\n\t\t\tfastopenq->max_qlen :\n\t\t\t(tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh)\n\t\t );\n}",
"static void get_timewait6_sock(struct seq_file *seq,\n\t\t\t struct inet_timewait_sock *tw, int i)\n{\n\tlong delta = tw->tw_timer.expires - jiffies;\n\tconst struct in6_addr *dest, *src;\n\t__u16 destp, srcp;",
"\tdest = &tw->tw_v6_daddr;\n\tsrc = &tw->tw_v6_rcv_saddr;\n\tdestp = ntohs(tw->tw_dport);\n\tsrcp = ntohs(tw->tw_sport);",
"\tseq_printf(seq,\n\t\t \"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X \"\n\t\t \"%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK\\n\",\n\t\t i,\n\t\t src->s6_addr32[0], src->s6_addr32[1],\n\t\t src->s6_addr32[2], src->s6_addr32[3], srcp,\n\t\t dest->s6_addr32[0], dest->s6_addr32[1],\n\t\t dest->s6_addr32[2], dest->s6_addr32[3], destp,\n\t\t tw->tw_substate, 0, 0,\n\t\t 3, jiffies_delta_to_clock_t(delta), 0, 0, 0, 0,\n\t\t atomic_read(&tw->tw_refcnt), tw);\n}",
"static int tcp6_seq_show(struct seq_file *seq, void *v)\n{\n\tstruct tcp_iter_state *st;\n\tstruct sock *sk = v;",
"\tif (v == SEQ_START_TOKEN) {\n\t\tseq_puts(seq,\n\t\t\t \" sl \"\n\t\t\t \"local_address \"\n\t\t\t \"remote_address \"\n\t\t\t \"st tx_queue rx_queue tr tm->when retrnsmt\"\n\t\t\t \" uid timeout inode\\n\");\n\t\tgoto out;\n\t}\n\tst = seq->private;",
"\tif (sk->sk_state == TCP_TIME_WAIT)\n\t\tget_timewait6_sock(seq, v, st->num);\n\telse if (sk->sk_state == TCP_NEW_SYN_RECV)\n\t\tget_openreq6(seq, v, st->num);\n\telse\n\t\tget_tcp6_sock(seq, v, st->num);\nout:\n\treturn 0;\n}",
"static const struct file_operations tcp6_afinfo_seq_fops = {\n\t.owner = THIS_MODULE,\n\t.open = tcp_seq_open,\n\t.read = seq_read,\n\t.llseek = seq_lseek,\n\t.release = seq_release_net\n};",
"static struct tcp_seq_afinfo tcp6_seq_afinfo = {\n\t.name\t\t= \"tcp6\",\n\t.family\t\t= AF_INET6,\n\t.seq_fops\t= &tcp6_afinfo_seq_fops,\n\t.seq_ops\t= {\n\t\t.show\t\t= tcp6_seq_show,\n\t},\n};",
"int __net_init tcp6_proc_init(struct net *net)\n{\n\treturn tcp_proc_register(net, &tcp6_seq_afinfo);\n}",
"void tcp6_proc_exit(struct net *net)\n{\n\ttcp_proc_unregister(net, &tcp6_seq_afinfo);\n}\n#endif",
"struct proto tcpv6_prot = {\n\t.name\t\t\t= \"TCPv6\",\n\t.owner\t\t\t= THIS_MODULE,\n\t.close\t\t\t= tcp_close,\n\t.connect\t\t= tcp_v6_connect,\n\t.disconnect\t\t= tcp_disconnect,\n\t.accept\t\t\t= inet_csk_accept,\n\t.ioctl\t\t\t= tcp_ioctl,\n\t.init\t\t\t= tcp_v6_init_sock,\n\t.destroy\t\t= tcp_v6_destroy_sock,\n\t.shutdown\t\t= tcp_shutdown,\n\t.setsockopt\t\t= tcp_setsockopt,\n\t.getsockopt\t\t= tcp_getsockopt,\n\t.keepalive\t\t= tcp_set_keepalive,\n\t.recvmsg\t\t= tcp_recvmsg,\n\t.sendmsg\t\t= tcp_sendmsg,\n\t.sendpage\t\t= tcp_sendpage,\n\t.backlog_rcv\t\t= tcp_v6_do_rcv,\n\t.release_cb\t\t= tcp_release_cb,\n\t.hash\t\t\t= inet6_hash,\n\t.unhash\t\t\t= inet_unhash,\n\t.get_port\t\t= inet_csk_get_port,\n\t.enter_memory_pressure\t= tcp_enter_memory_pressure,\n\t.stream_memory_free\t= tcp_stream_memory_free,\n\t.sockets_allocated\t= &tcp_sockets_allocated,\n\t.memory_allocated\t= &tcp_memory_allocated,\n\t.memory_pressure\t= &tcp_memory_pressure,\n\t.orphan_count\t\t= &tcp_orphan_count,\n\t.sysctl_mem\t\t= sysctl_tcp_mem,\n\t.sysctl_wmem\t\t= sysctl_tcp_wmem,\n\t.sysctl_rmem\t\t= sysctl_tcp_rmem,\n\t.max_header\t\t= MAX_TCP_HEADER,\n\t.obj_size\t\t= sizeof(struct tcp6_sock),\n\t.slab_flags\t\t= SLAB_DESTROY_BY_RCU,\n\t.twsk_prot\t\t= &tcp6_timewait_sock_ops,\n\t.rsk_prot\t\t= &tcp6_request_sock_ops,\n\t.h.hashinfo\t\t= &tcp_hashinfo,\n\t.no_autobind\t\t= true,\n#ifdef CONFIG_COMPAT\n\t.compat_setsockopt\t= compat_tcp_setsockopt,\n\t.compat_getsockopt\t= compat_tcp_getsockopt,\n#endif\n\t.diag_destroy\t\t= tcp_abort,\n};",
"static struct inet6_protocol tcpv6_protocol = {\n\t.early_demux\t=\ttcp_v6_early_demux,\n\t.early_demux_handler = tcp_v6_early_demux,\n\t.handler\t=\ttcp_v6_rcv,\n\t.err_handler\t=\ttcp_v6_err,\n\t.flags\t\t=\tINET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,\n};",
"static struct inet_protosw tcpv6_protosw = {\n\t.type\t\t=\tSOCK_STREAM,\n\t.protocol\t=\tIPPROTO_TCP,\n\t.prot\t\t=\t&tcpv6_prot,\n\t.ops\t\t=\t&inet6_stream_ops,\n\t.flags\t\t=\tINET_PROTOSW_PERMANENT |\n\t\t\t\tINET_PROTOSW_ICSK,\n};",
"static int __net_init tcpv6_net_init(struct net *net)\n{\n\treturn inet_ctl_sock_create(&net->ipv6.tcp_sk, PF_INET6,\n\t\t\t\t SOCK_RAW, IPPROTO_TCP, net);\n}",
"static void __net_exit tcpv6_net_exit(struct net *net)\n{\n\tinet_ctl_sock_destroy(net->ipv6.tcp_sk);\n}",
"static void __net_exit tcpv6_net_exit_batch(struct list_head *net_exit_list)\n{\n\tinet_twsk_purge(&tcp_hashinfo, AF_INET6);\n}",
"static struct pernet_operations tcpv6_net_ops = {\n\t.init\t = tcpv6_net_init,\n\t.exit\t = tcpv6_net_exit,\n\t.exit_batch = tcpv6_net_exit_batch,\n};",
"int __init tcpv6_init(void)\n{\n\tint ret;",
"\tret = inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP);\n\tif (ret)\n\t\tgoto out;",
"\t/* register inet6 protocol */\n\tret = inet6_register_protosw(&tcpv6_protosw);\n\tif (ret)\n\t\tgoto out_tcpv6_protocol;",
"\tret = register_pernet_subsys(&tcpv6_net_ops);\n\tif (ret)\n\t\tgoto out_tcpv6_protosw;\nout:\n\treturn ret;",
"out_tcpv6_protosw:\n\tinet6_unregister_protosw(&tcpv6_protosw);\nout_tcpv6_protocol:\n\tinet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);\n\tgoto out;\n}",
"void tcpv6_exit(void)\n{\n\tunregister_pernet_subsys(&tcpv6_net_ops);\n\tinet6_unregister_protosw(&tcpv6_protosw);\n\tinet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [492, 1133], "buggy_code_start_loc": [428, 1064], "filenames": ["net/dccp/ipv6.c", "net/ipv6/tcp_ipv6.c"], "fixing_code_end_loc": [499, 1136], "fixing_code_start_loc": [429, 1065], "message": "The dccp_v6_request_recv_sock function in net/dccp/ipv6.c in the Linux kernel through 4.11.1 mishandles inheritance, which allows local users to cause a denial of service or possibly have unspecified other impact via crafted system calls, a related issue to CVE-2017-8890.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "9A5C1F01-214B-4477-A3A1-F6DF10181D3C", "versionEndExcluding": "3.2.89", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "8C1901E2-6C4D-488B-A7CE-F7E14A38418F", "versionEndExcluding": "3.16.44", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.3", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "DB67DFF9-D1AD-49F9-AC6A-2BBFE1619CE2", "versionEndExcluding": "3.18.84", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.17", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "A4AF9D2F-2101-41EE-9E8C-95EE62CB1186", "versionEndExcluding": "4.4.71", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "3.19", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "001F55C3-810A-444F-AE18-F067A84F6B31", "versionEndExcluding": "4.9.31", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "4.5", "vulnerable": true}, {"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "matchCriteriaId": "1A25FD29-5617-4236-AC9A-6D68DC220925", "versionEndExcluding": "4.11.4", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "4.10", "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}], "descriptions": [{"lang": "en", "value": "The dccp_v6_request_recv_sock function in net/dccp/ipv6.c in the Linux kernel through 4.11.1 mishandles inheritance, which allows local users to cause a denial of service or possibly have unspecified other impact via crafted system calls, a related issue to CVE-2017-8890."}, {"lang": "es", "value": "La funci\u00f3n dccp_v6_request_recv_sock en el archivo net/dccp/ipv6.c en el kernel de Linux hasta versi\u00f3n 4.11.1, el manejo inapropiado de la herencia, permite a los usuarios locales causar una denegaci\u00f3n de servicio o posiblemente tener otro impacto no especificado por medio de llamadas de sistema dise\u00f1adas, un problema relacionado con CVE-2017 -8890."}], "evaluatorComment": null, "id": "CVE-2017-9076", "lastModified": "2023-02-24T18:39:05.640", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "COMPLETE", "baseScore": 7.2, "confidentialityImpact": "COMPLETE", "integrityImpact": "COMPLETE", "vectorString": "AV:L/AC:L/Au:N/C:C/I:C/A:C", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 10.0, "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": 7.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2017-05-19T07:29:00.307", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Vendor Advisory"], "url": "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=83eaddab4378db256d00d295bda6ca997cd13a52"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "http://www.debian.org/security/2017/dsa-3886"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/98586"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:1842"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:2077"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:2669"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:1854"}, {"source": "cve@mitre.org", "tags": ["Patch", "Vendor Advisory"], "url": "https://github.com/torvalds/linux/commit/83eaddab4378db256d00d295bda6ca997cd13a52"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://patchwork.ozlabs.org/patch/760370/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://source.android.com/security/bulletin/2017-09-01"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "NVD-CWE-noinfo"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/torvalds/linux/commit/83eaddab4378db256d00d295bda6ca997cd13a52"}, "type": "NVD-CWE-noinfo"}
| 215
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/* Copyright 2018 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==============================================================================*/",
"#include \"tensorflow/core/common_runtime/eager/execute.h\"",
"#include <cstddef>\n#include <vector>",
"// clang-format off\n// Required for IS_MOBILE_PLATFORM\n#include \"absl/container/btree_map.h\"\n#include \"absl/container/flat_hash_set.h\"\n#include \"absl/strings/str_replace.h\"\n#include \"tensorflow/core/common_runtime/eager/eager_operation.h\"\n#include \"tensorflow/core/framework/cancellation.h\"\n#include \"tensorflow/core/framework/function.pb.h\"\n#include \"tensorflow/core/framework/node_def.pb.h\"\n#include \"tensorflow/core/framework/op.h\"\n#include \"tensorflow/core/framework/op_kernel.h\"\n#include \"tensorflow/core/framework/tensor_shape.h\"\n#include \"tensorflow/core/lib/core/refcount.h\"\n#include \"tensorflow/core/platform/errors.h\"\n#include \"tensorflow/core/platform/platform.h\"\n#include \"tensorflow/core/platform/protobuf.h\"",
"// clang-format on",
"#include \"absl/container/inlined_vector.h\"\n#include \"absl/strings/match.h\"\n#include \"absl/strings/str_cat.h\"\n#include \"absl/types/optional.h\"\n#include \"tensorflow/c/tf_tensor_internal.h\"\n#include \"tensorflow/compiler/jit/defs.h\"\n#include \"tensorflow/core/common_runtime/colocation_graph.h\"\n#include \"tensorflow/core/common_runtime/device.h\"\n#include \"tensorflow/core/common_runtime/device_set.h\"\n#include \"tensorflow/core/common_runtime/eager/context.h\"\n#include \"tensorflow/core/common_runtime/eager/copy_to_device_node.h\"\n#include \"tensorflow/core/common_runtime/eager/execute_node.h\"\n#include \"tensorflow/core/common_runtime/eager/kernel_and_device.h\"\n#include \"tensorflow/core/common_runtime/eager/tensor_handle.h\"\n#include \"tensorflow/core/framework/dataset.h\"\n#include \"tensorflow/core/framework/function.h\"\n#include \"tensorflow/core/framework/logging.h\"\n#include \"tensorflow/core/framework/node_def_util.h\"\n#include \"tensorflow/core/framework/tensor_reference.h\"\n#include \"tensorflow/core/framework/types.pb.h\"\n#include \"tensorflow/core/lib/core/errors.h\"\n#include \"tensorflow/core/platform/statusor.h\"\n#include \"tensorflow/core/profiler/lib/scoped_memory_debug_annotation.h\"\n#include \"tensorflow/core/profiler/lib/traceme.h\"\n#include \"tensorflow/core/protobuf/error_codes.pb.h\"\n#include \"tensorflow/core/util/device_name_utils.h\"\n#if !defined(IS_MOBILE_PLATFORM)\n#include \"tensorflow/core/distributed_runtime/eager/eager_client.h\"\n#include \"tensorflow/core/distributed_runtime/eager/remote_copy_node.h\"\n#include \"tensorflow/core/distributed_runtime/eager/remote_mgr.h\"\n#include \"tensorflow/core/distributed_runtime/eager/remote_execute_node.h\"\n#include \"tensorflow/core/protobuf/remote_tensor_handle.pb.h\"\n#endif // IS_MOBILE_PLATFORM\n#include \"tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h\"\n#include \"tensorflow/core/framework/step_stats.pb.h\"\n#include \"tensorflow/core/framework/tensor.h\"\n#include \"tensorflow/core/framework/types.h\"\n#include \"tensorflow/core/lib/core/status.h\"\n#include \"tensorflow/core/lib/gtl/cleanup.h\"\n#include \"tensorflow/core/lib/gtl/flatset.h\"\n#include \"tensorflow/core/lib/random/random.h\"\n#include \"tensorflow/core/platform/env.h\"\n#include \"tensorflow/core/platform/mutex.h\"\n#include \"tensorflow/core/util/ptr_util.h\"\n#include \"tensorflow/core/util/util.h\"",
"#ifdef INTEL_MKL\n#include \"tensorflow/core/graph/mkl_graph_util.h\"\n#endif",
"namespace tensorflow {",
"namespace {",
"const string& DeviceNameOrUnspecified(Device* device) {\n static string* unspecified_string = new string(\"<unspecified>\");\n return (device == nullptr) ? *unspecified_string : device->name();\n}",
"// Returns whether a kernel should be cached.\nbool KernelCacheEnabled(const OpDef& op_def) {\n if (data::DatasetOpKernel::IsDatasetOp(op_def)) {\n return false;\n }\n // TODO(b/162540360): Revisit a way to mark kernels as uncachable once we have\n // 5+ kernels to exclude.\n return true;\n}",
"// This function expects *handle to point to an existing tensor handle that is\n// currently on \"handle_device\", but where the operation expects that input to\n// reside on \"expected_input_device\". The function will arrange for this\n// transfer to happen and will return OK on success and will storage a new\n// handle to the equivalent tensor on the correct device in \"*result\". Or if an\n// error is encountered, it will return a non-OK status and set \"*result\" to\n// nullptr.\n//\n// `op_device` is passed in explicitly because `op->device()` might be\n// unset and we might have selected some specific device to run this op on.\nStatus CopyInputToExpectedDevice(EagerContext* ctx, EagerOperation* op,\n Device* op_device,\n TensorHandle* handle, // op->Inputs()[i]\n int i, Device* handle_device,\n Device* expected_input_device,\n TensorHandle** result) {\n VLOG(6) << \"Expected input device: \" << expected_input_device->name()\n << \"; handle_device: \" << handle_device->name();\n // Should only be called when these don't match\n DCHECK(expected_input_device != handle_device);\n *result = nullptr;\n const string& op_device_name = DeviceNameOrUnspecified(op_device);",
" switch (ctx->GetDevicePlacementPolicy()) {\n case DEVICE_PLACEMENT_SILENT_FOR_INT32:\n // TODO(xpan): See if we could bubble python related error up\n // to python level.\n if (handle->dtype == DT_INT32) {\n // Note: enabling silent copies of int32 tensors to match behavior\n // of graph mode.\n break;\n }\n VLOG(6) << \"DevicePlacementPolicy: DEVICE_PLACEMENT_SILENT_FOR_INT32 but \"\n \"input type is not INT32.\";\n TF_FALLTHROUGH_INTENDED;\n case DEVICE_PLACEMENT_EXPLICIT:\n // tf.identity is allowed to copy, as indicated in the error message\n // below.\n if (op->Name() == \"Identity\" ||\n op->Name() == \"IdentityN\"\n // Constants start on CPU:0 and are copied via EagerConst to the\n // current device.\n || op->Name() == \"_EagerConst\") {\n break;\n }\n return errors::InvalidArgument(\n \"Tensors on conflicting devices:\"\n \" cannot compute \",\n op->Name(), \" as input #\", i, \" was expected to be on \",\n expected_input_device->name(), \" but is actually on \",\n handle_device->name(), \" (operation running on \", op_device_name, \")\",\n \" Tensors can be copied explicitly using:\"\n \" `with tf.device(device_name): x = tf.identity(x)`\"\n \" or transparently copied by using\"\n \" tf.config.experimental.set_device_policy('silent').\"\n \" Copying tensors between devices may slow down your model\");\n case DEVICE_PLACEMENT_WARN:\n LOG(WARNING) << \"before computing \" << op->Name() << \" input #\" << i\n << \" was expected to be on \" << expected_input_device->name()\n << \" but is actually on \" << handle_device->name()\n << \" (operation running on \" << op_device_name\n << \"). This triggers a copy which can be a performance \"\n \"bottleneck.\";\n break;\n case DEVICE_PLACEMENT_SILENT: // Do nothing.\n break;\n }\n // We are only here if the policy is warn or silent copies, so we should\n // trigger a copy.\n TensorHandle* result_handle = nullptr;\n profiler::TraceMe activity(\n [&] {\n return absl::StrCat(\"_Send input \", i, \" from \", handle_device->name(),\n \" to \", expected_input_device->name());\n },\n profiler::TraceMeLevel::kInfo);\n Status status =\n EagerCopyToDevice(handle, ctx, &op->Executor(), expected_input_device,\n /* mirror= */ true, &result_handle);\n activity.Stop();\n if (!status.ok()) {\n return Status(\n status.code(),\n absl::StrCat(\"Failed copying input tensor from \", handle_device->name(),\n \" to \", expected_input_device->name(), \" in order to run \",\n op->Name(), \": \", status.error_message()));\n }",
" *result = result_handle;",
" return Status::OK();\n}",
"// `op_device_name` the name of the device on which the op will run, if any.\n// For functions running using function library runtime, the device can be\n// unspecified.\nStatus ValidateInputTypeAndPlacement(\n EagerContext* ctx, EagerOperation* op,\n const core::RefCountPtr<KernelAndDevice>& kernel) {\n profiler::TraceMe activity(\"ValidateInputTypeAndPlacement\",\n profiler::TraceMeLevel::kInfo);\n const int n_inputs = op->Inputs().size();\n if (kernel->num_inputs() != n_inputs) {\n return errors::InvalidArgument(\"expected \", kernel->num_inputs(),\n \" inputs, got \", n_inputs);\n }\n const bool is_function = kernel->IsFunction();\n if (n_inputs > 0) {\n const DataType* input_types = &kernel->input_dtypes()[0];\n const absl::InlinedVector<TensorHandle*, 4>* handles;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&handles));\n for (int i = 0; i < n_inputs; ++i) {\n TensorHandle* handle = (*handles)[i];\n Device* expected_device = kernel->InputDevice(i);\n if (!kernel->IsFunction() && handle->Type() == TensorHandle::PACKED) {\n // Extract a handle on the op device from a packed input.\n // This happens when a function is marked for XLA compilation.\n // MaybePackInputTensor guarantees that a primitive op has no packed\n // input at this point.\n for (int j = 0; j < handle->NumPackedHandles(); ++j) {\n TensorHandle* h = nullptr;\n TF_RETURN_IF_ERROR(handle->ExtractPackedHandle(j, &h));\n if ((h->op_device() != nullptr) &&\n (h->op_device()->name() == op->DeviceName())) {\n op->UpdateInput(i, h);\n handle = h;\n break;\n }\n }\n }\n Device* handle_device = handle->DeviceOrHostCPU(*ctx);\n const bool maybe_copy =\n !is_function || handle->Type() != TensorHandle::REMOTE;\n VLOG(6) << \"!is_function: \" << !is_function;\n VLOG(6) << \"handle->Type(): \" << handle->Type();\n // If the input is already on the right device, then nothing to do.\n if (expected_device != handle_device && maybe_copy) {\n TF_RETURN_IF_ERROR(CopyInputToExpectedDevice(ctx, op, kernel->device(),\n handle, i, handle_device,\n expected_device, &handle));\n op->UpdateInput(i, handle);\n // Unref handle since it has a ref as an input now\n handle->Unref();\n }\n if (handle->dtype != input_types[i]) {\n return errors::InvalidArgument(\n \"cannot compute \", op->Name(), \" as input #\", i, \"(zero-based)\",\n \" was expected to be a \", DataTypeString(input_types[i]),\n \" tensor but is a \", DataTypeString(handle->dtype), \" tensor\");\n }\n }\n }\n return Status::OK();\n}",
"Status GetOutputDTypes(EagerOperation* op, DataTypeVector* output_dtypes) {\n const auto& node_def = op->MutableAttrs()->BuildNodeDef();\n const OpDef* op_def = nullptr;",
" const FunctionDef* function_def =\n op->EagerContext().FuncLibDef()->Find(op->Name());\n if (function_def != nullptr) {\n op_def = &(function_def->signature());\n } else {\n TF_RETURN_IF_ERROR(OpDefForOp(op->Name().c_str(), &op_def));\n }",
" TF_RETURN_IF_ERROR(OutputTypesForNode(node_def, *op_def, output_dtypes));",
" return Status::OK();\n}",
"inline tensorflow::Fprint128 FingerprintCat128(const tensorflow::Fprint128& a,\n const tensorflow::Fprint128& b) {\n return {tensorflow::FingerprintCat64(a.low64, b.low64),\n tensorflow::FingerprintCat64(a.high64, b.high64)};\n}",
"inline tensorflow::Fprint128 FingerprintCat128(const tensorflow::Fprint128& a,\n const int64_t b) {\n auto x = tensorflow::FingerprintCat64(a.low64, b);\n return {x, tensorflow::FingerprintCat64(a.high64, x)};\n}",
"Status GetDeviceForInput(const EagerOperation& op, const EagerContext& ctx,\n TensorHandle* tensor_handle, Device** result) {\n Device* cpu_device = ctx.HostCPU();\n string device_name;\n if (tensor_handle->Type() != TensorHandle::LOCAL) {\n Device* device = tensor_handle->device();\n device_name = device != nullptr ? device->name() : cpu_device->name();\n *result = (device == nullptr ? cpu_device : device);\n } else if (tensor_handle->dtype == DT_RESOURCE) {\n // Use the resource's actual device because it is the device that will\n // influence partitioning the multi-device function.\n const Tensor* tensor;\n // TODO(fishx): Avoid blocking here.\n TF_RETURN_IF_ERROR(tensor_handle->Tensor(&tensor));",
"",
" const ResourceHandle& handle = tensor->flat<ResourceHandle>()(0);\n device_name = handle.device();",
" Device* input_device;\n TF_RETURN_IF_ERROR(\n ctx.FindDeviceFromName(device_name.c_str(), &input_device));\n *result = input_device;\n } else {\n Device* device = tensor_handle->device();\n const bool is_tpu = device != nullptr && device->device_type() == \"TPU\";\n // int32 return values can be placed on TPUs.\n const bool use_host_memory =\n is_tpu ? MTypeFromDTypeIntsOnDevice(tensor_handle->dtype)\n : MTypeFromDType(tensor_handle->dtype);\n if (use_host_memory) {\n *result = cpu_device;\n } else {\n // Eager ops executing as functions should have their preferred inputs set\n // to the op's device. This allows us to avoid expensive D2H copies if a\n // mirror of the tensor already exists on the op's device.\n if (!op.is_function() && device != nullptr && device != cpu_device) {\n device = absl::get<Device*>(op.Device());\n }\n *result = (device == nullptr ? cpu_device : device);\n }\n }\n return Status::OK();\n}",
"// Appends a TensorShape object to Fprint128 hash.\n// For best performance, we would like to avoid dynamic memory allocation in\n// this function.\n// If \"shape\" has unknown rank, we attach \"?\" to hashed content; otherwise we\n// attach every dim size to hashed content.\nvoid AppendTensorShapeToFingerprint(const PartialTensorShape& shape,\n Fprint128* fingerprint) {\n if (shape.unknown_rank()) {\n char c = '?';\n *fingerprint = FingerprintCat128(*fingerprint, c);\n } else {\n for (int i = 0; i < shape.dims(); i++) {\n int64_t dim = shape.dim_size(i);\n *fingerprint = FingerprintCat128(*fingerprint, dim);\n }\n }\n}",
"Status GetFuncAttr(const EagerOperation* op, const EagerContext& ctx,\n const char* attr_name, bool* value) {\n Status status = op->Attrs().Get(attr_name, value);\n if (status.ok()) {\n VLOG(2) << \"Caller explicitly specifies \"\n << (attr_name ? \"=true \" : \"=false, \") << op->DebugString();\n return Status::OK();\n }",
" const FunctionDef* function_def =\n ctx.pflr()->GetFunctionLibraryDefinition()->Find(op->Name());\n if (function_def == nullptr) {\n return errors::NotFound(\"Failed to find function '\", op->Name(), \"'\");\n }",
" status = GetNodeAttr(AttrSlice(&function_def->attr()), attr_name, value);\n if (status.ok()) {\n VLOG(2) << \"Function definition explicitly specifies \"\n << (attr_name ? \"=true\" : \"=false\");\n return Status::OK();\n }\n return status;\n}",
"Status MustCompileWithXLA(const EagerOperation* op, const EagerContext& ctx,\n bool* compile_with_xla) {\n if (!op->is_function()) {\n *compile_with_xla = false;\n return Status::OK();\n }",
" if (op->eager_func_params().has_value() &&\n op->eager_func_params().value().step_id.has_value()) {\n // If the op is a component of a multi-device function, don't compile it\n // with XLA.\n *compile_with_xla = false;\n return Status::OK();\n }",
" Status status = GetFuncAttr(op, ctx, kXlaMustCompileAttr, compile_with_xla);\n if (status.ok()) {\n return Status::OK();\n }",
" // No explicit requests. Compile for XLA devices by default.\n if (op->GetDeviceParsedName().type == \"TPU\" ||\n op->GetDeviceParsedName().type == \"XLA_GPU\" ||\n op->GetDeviceParsedName().type == \"XLA_CPU\") {\n VLOG(2) << \"Compiling \" << op->Name()\n << \" with XLA because it is running on an XLA device \"\n << op->GetDeviceParsedName().type;\n *compile_with_xla = true;\n } else {\n *compile_with_xla = false;\n }",
" return Status::OK();\n}",
"Status VerifyWrappableInCallOp(const OpDef& opdef, EagerOperation* op) {\n absl::flat_hash_set<string> opdef_attrs;\n for (const auto& attr : opdef.attr()) {\n opdef_attrs.insert(attr.name());\n }\n const auto& node_def = op->MutableAttrs()->BuildNodeDef();\n for (const auto& attr : node_def.attr()) {\n if (opdef_attrs.find(attr.first) == opdef_attrs.end()) {\n return errors::Unimplemented(\"EagerOperation: \", op->Name(),\n \" has a private attr '\", attr.first, \"'.\");\n }\n }\n return Status::OK();\n}",
"using ProtoArgListType = protobuf::RepeatedPtrField<OpDef_ArgDef>;",
"string EscapeOrigName(const string& orig_name) {\n // Replace _ with __ in the original name to avoid name conflicts.\n return absl::StrReplaceAll(orig_name, {{\"_\", \"__\"}});\n}",
"// Variadic args are flattened during wrapping. This utility returns the name\n// of a flattened arg/attr.\nstring GetFlatName(const string orig_name, int index) {\n return absl::StrCat(EscapeOrigName(orig_name), \"_\", index);\n}",
"// Builds the name of the wrapping FunctionDef for an eager op.\n//\n// For ops without variadic inputs/outputs, the name is simply __wrapped_OpType.\n//\n// For ops with variadic inputs/outputs, the arity of each variadic attr is\n// encoded in the name. For example:\n//\n// IdentityN[T:[DT_FLOAT, DT_INT64]] -> __wrapped__IdentityN_T_2\n// Concat[N:2, T:DT_FLOAT] -> __wrapped__Concat_N_2\nStatus BuildWrappedOpName(EagerOperation* op, const OpDef& opdef,\n const AbstractOpAttrs* op_attrs, string* name) {\n string fname = absl::StrCat(\"__wrapped__\", EscapeOrigName(op->Name()));\n // For every variadic arg in `args`, populates `attr_to_len` with\n // (attr_name, len(arg)).\n auto FillAttrToLen = [op_attrs, op](\n const ProtoArgListType& args,\n absl::btree_map<string, int>* attr_to_len) {\n for (const auto& arg : args) {\n if (!arg.type_list_attr().empty()) {\n gtl::InlinedVector<DataType, 4> type_list;\n TF_RETURN_IF_ERROR(\n op_attrs->GetTypeList(arg.type_list_attr(), &type_list));\n (*attr_to_len)[arg.type_list_attr()] = type_list.size();\n } else if (!arg.number_attr().empty()) {\n int64_t number_attr;\n if (!op_attrs->GetInt(arg.number_attr(), &number_attr)) {\n return errors::Internal(\"Unable to read attr \", arg.number_attr(),\n \" for op \", op->Name());\n }\n (*attr_to_len)[arg.number_attr()] = number_attr;\n }\n }\n return Status::OK();\n };\n absl::btree_map<string, int> attr_to_len;\n TF_RETURN_IF_ERROR(FillAttrToLen(opdef.input_arg(), &attr_to_len));\n TF_RETURN_IF_ERROR(FillAttrToLen(opdef.output_arg(), &attr_to_len));\n for (auto& name_len : attr_to_len) {\n absl::StrAppend(&fname, \"_\", name_len.first, \"_\", name_len.second);\n }\n // The NodeDef in the FunctionDef gets placed on `op-DeviceName()` to ensure\n // placement consistency with eager mode.\n // TODO(b/200153278): Ideally we would just forward the call op's device at\n // runtime but currently there is no way to do it so we incur the cost of\n // creating extra FunctionDefs.\n absl::StrAppend(&fname, \"_device_\", op->DeviceName());\n *name = fname;\n return Status::OK();\n}",
"// Validates the node def. This is required when running in eager op as function\n// mode because this code path does not go through the _apply_op_helper's\n// validation (which is reached when executing in graph mode)\n// or the eager execution's validation (which is reached via the CreateOpKernel\n// call).\nStatus ValidateOp(EagerOperation* op) {\n const NodeDef& node_def = op->MutableAttrs()->BuildNodeDef();\n const OpDef* op_def;\n TF_RETURN_IF_ERROR(OpRegistry::Global()->LookUpOpDef(node_def.op(), &op_def));\n return ValidateNodeDef(node_def, *op_def);\n}",
"// Builds the signature of the wrapping FunctionDef for an eager op.\n//\n// For ops without variadic inputs/outputs, the signature is the same as the\n// OpDef of the original op.\n//\n// Variadic inputs/outputs get flattened since we do not support executing\n// functions with variadic signatures.\n//\n// TODO(srbs): These examples should be tests.\n//\n// Examples:\n//\n// Mixed type list:\n//\n// op {\n// name: \"IdentityN\"\n// input_arg {\n// name: \"input\"\n// type_list_attr: \"T\"\n// }\n// output_arg {\n// name: \"output\"\n// type_list_attr: \"T\"\n// }\n// attr {\n// name: \"T\"\n// type: \"list(type)\"\n// has_minimum: true\n// minimum: 1\n// }\n// }\n//\n// With two inputs T=[DT_FLOAT, DT_INT64] would convert to\n//\n// op {\n// name: \"__wrapped__IdentityN_T_2\"\n// input_arg {\n// name: \"input_0\"\n// type_attr: \"T_0\"\n// }\n// input_arg {\n// name: \"input_1\"\n// type_attr: \"T_1\"\n// }\n// output_arg {\n// name: \"output_0\"\n// type_attr: \"T_0\"\n// }\n// output_arg {\n// name: \"output_1\"\n// type_attr: \"T_1\"\n// }\n// attr {\n// name: \"T_0\"\n// type: \"type\"\n// }\n// attr {\n// name: \"T_1\"\n// type: \"type\"\n// }\n// attr {\n// name: \"T\"\n// type: \"list(type)\"\n// has_minimum: true\n// minimum: 1\n// }\n// }\n//\n// Note that the list(type) attr is preserved so that it can get copied to the\n// inner op via a placeholder. This allows additional verification.\n//\n// Single type list:\n//\n// op {\n// name: \"ConcatV2\"\n// input_arg {\n// name: \"values\"\n// type_attr: \"T\"\n// number_attr: \"N\"\n// }\n// attr {\n// name: \"N\"\n// type: \"int\"\n// has_minimum: true\n// minimum: 2\n// }\n// attr {\n// name: \"T\"\n// type: \"type\"\n// }\n// [axis, output, Tidx are simply copied]\n// }\n//\n// With two inputs N=2 would convert to:\n//\n// op {\n// name: \"__wrapped__ConcatV2_N_2\"\n// input_arg {\n// name: \"values_0\"\n// type_attr: \"T\"\n// }\n// input_arg {\n// name: \"values_1\"\n// type_attr: \"T\"\n// }\n// attr {\n// name: \"N\"\n// type: \"int\"\n// has_minimum: true\n// minimum: 2\n// }\n// attr {\n// name: \"T\"\n// type: \"type\"\n// }\n// [axis, output, Tidx are simply copied]\n// }\n//\n// Note that the N attr is preserved so that it can get copied to the\n// inner op via a placeholder. This allows additional verification.\nStatus BuildWrappedOpSignature(EagerOperation* op, const OpDef& opdef,\n const string& fname, OpDef& signature) {\n signature = opdef;\n signature.clear_input_arg();\n signature.clear_output_arg();\n signature.set_name(fname);\n auto op_attrs = op->GetOpAttrs();\n auto FillSignatureArgs = [op_attrs, op](\n const ProtoArgListType& opdef_args,\n ProtoArgListType* sig_args,\n absl::flat_hash_set<string>& new_attrs) {\n for (const auto& arg : opdef_args) {\n if (!arg.type_list_attr().empty()) {\n gtl::InlinedVector<DataType, 4> type_list;\n TF_RETURN_IF_ERROR(\n op_attrs->GetTypeList(arg.type_list_attr(), &type_list));\n for (size_t i = 0; i < type_list.size(); i++) {\n auto arg_def = sig_args->Add();\n arg_def->set_name(GetFlatName(arg.name(), i));\n auto attr_name = GetFlatName(arg.type_list_attr(), i);\n new_attrs.insert(attr_name);\n arg_def->set_type_attr(std::move(attr_name));\n }\n } else if (!arg.number_attr().empty()) {\n int64_t number_attr;\n if (!op_attrs->GetInt(arg.number_attr(), &number_attr)) {\n return errors::Internal(\"Unable to read attr \", arg.number_attr(),\n \" for op \", op->Name());\n }\n for (int64_t i = 0; i < number_attr; i++) {\n auto arg_def = sig_args->Add();\n arg_def->set_name(GetFlatName(arg.name(), i));\n if (!arg.type_attr().empty()) {\n arg_def->set_type_attr(arg.type_attr());\n } else {\n arg_def->set_type(arg.type());\n }\n }\n } else {\n auto arg_def = sig_args->Add();\n *arg_def = arg;\n arg_def->set_name(EscapeOrigName(arg.name()));\n if (!arg.type_attr().empty()) {\n // Don't escape: type attrs are still referenced by the original name.\n arg_def->set_type_attr(arg.type_attr());\n }\n }\n }\n return Status::OK();\n };\n absl::flat_hash_set<string> new_attrs;\n TF_RETURN_IF_ERROR(FillSignatureArgs(\n opdef.input_arg(), signature.mutable_input_arg(), new_attrs));\n TF_RETURN_IF_ERROR(FillSignatureArgs(\n opdef.output_arg(), signature.mutable_output_arg(), new_attrs));\n for (auto& attr_name : new_attrs) {\n auto attr_def = signature.mutable_attr()->Add();\n attr_def->set_name(attr_name);\n attr_def->set_type(\"type\");\n }\n return Status::OK();\n}",
"// For mixed type inputs \"list(type)\" we create new attributes in the signature\n// for each element tensor (See examples in BuildWrappedOpSignature). Here\n// we construct the values for those attributes and set them on the wrapped op.\nStatus AddMixedTypeListAttrs(EagerOperation* wrapped_op,\n const AbstractOpAttrs* op_attrs,\n const OpDef& opdef) {\n auto FillAttrsToAdd =\n [op_attrs](const ProtoArgListType& opdef_args,\n absl::flat_hash_map<string, DataType>* attrs_to_add) {\n for (const auto& arg : opdef_args) {\n if (!arg.type_list_attr().empty()) {\n gtl::InlinedVector<DataType, 4> type_list;\n TF_RETURN_IF_ERROR(\n op_attrs->GetTypeList(arg.type_list_attr(), &type_list));\n for (size_t i = 0; i < type_list.size(); i++) {\n auto attr_name = GetFlatName(arg.type_list_attr(), i);\n (*attrs_to_add)[attr_name] = type_list[i];\n }\n }\n }\n return Status::OK();\n };\n absl::flat_hash_map<string, DataType> attrs_to_add;\n TF_RETURN_IF_ERROR(FillAttrsToAdd(opdef.input_arg(), &attrs_to_add));\n TF_RETURN_IF_ERROR(FillAttrsToAdd(opdef.output_arg(), &attrs_to_add));\n for (auto& name_type : attrs_to_add) {\n TF_RETURN_IF_ERROR(\n wrapped_op->SetAttrType(name_type.first.data(), name_type.second));\n }\n // TODO(srbs): Rename all original attributes using EscapeOrigName.\n return Status::OK();\n}",
"// Maps the op's outputs to the function outputs. Mainly useful for variadic\n// outputs which need to be flattened.\nStatus PopulateRetMap(FunctionDef* fdef, const AbstractOpAttrs* op_attrs,\n const EagerOperation* op, const OpDef& opdef,\n const OpDef& signature, const string& node_name) {\n int next_sig_output = 0;\n for (size_t i = 0; i < opdef.output_arg_size(); i++) {\n const auto& output_arg = opdef.output_arg(i);\n if (!output_arg.type_list_attr().empty()) {\n gtl::InlinedVector<DataType, 4> type_list;\n TF_RETURN_IF_ERROR(\n op_attrs->GetTypeList(output_arg.type_list_attr(), &type_list));\n for (int j = 0; j < type_list.size(); j++) {\n (*fdef->mutable_ret())[signature.output_arg(next_sig_output++).name()] =\n absl::StrCat(node_name, \":\", output_arg.name(), \":\", j);\n }\n } else if (!output_arg.number_attr().empty()) {\n int64_t number_attr;\n if (!op_attrs->GetInt(output_arg.number_attr(), &number_attr)) {\n return errors::Internal(\"Unable to read attr \",\n output_arg.number_attr(), \" for op \",\n op->Name());\n }\n for (int j = 0; j < number_attr; j++) {\n (*fdef->mutable_ret())[signature.output_arg(next_sig_output++).name()] =\n absl::StrCat(node_name, \":\", output_arg.name(), \":\", j);\n }\n } else {\n (*fdef->mutable_ret())[signature.output_arg(next_sig_output++).name()] =\n absl::StrCat(node_name, \":\", output_arg.name(), \":0\");\n }\n }\n return Status::OK();\n}",
"#ifdef INTEL_MKL\ninline void GetMKLNodeDef(NodeDef* ndef) {\n // All MKL eager ops have `_kernel` private attribute that needs to be set\n // to a fixed label.\n AttrValue attr_kernel;\n attr_kernel.set_s(mkl_op_registry::kMklNameChangeOpLabel);\n (*ndef->mutable_attr()).insert({\"_kernel\", attr_kernel});\n}\n#endif // INTEL_MKL",
"Status WrapInCallOp(EagerOperation* op, EagerOperation** wrapped_op) {\n DCHECK(!op->is_function());\n const OpDef& opdef = OpRegistry::Global()->LookUp(op->Name())->op_def;\n // Raise an error for ops which don't support wrapping yet. This includes\n // ops with list inputs/outputs and ops with private attrs.\n // TODO(srbs): Support list inputs/outputs.\n TF_RETURN_IF_ERROR(VerifyWrappableInCallOp(opdef, op));",
" // Build a FunctionDef containing op as a node and register with context.\n // TODO(srbs): Here we are unable to distinguish between a FunctionDef for\n // a wrapped eager op and an existing user defined function registered with\n // the context e.g. with something like\n // @tf.function\n // def __wrapped__Add(x, y):\n // ...\n // This can be avoided by introducing a dict in EagerContext that stores a\n // mapping from the eager op's name to its unique FunctionDef name.\n auto op_attrs = op->GetOpAttrs();\n string fname;\n TF_RETURN_IF_ERROR(BuildWrappedOpName(op, opdef, op_attrs, &fname));\n if (!op->EagerContext().GetFunctionDef(fname)) {\n FunctionDef fdef;\n // Set signature.\n TF_RETURN_IF_ERROR(\n BuildWrappedOpSignature(op, opdef, fname, *fdef.mutable_signature()));\n // Add node.\n NodeDef* ndef = fdef.add_node_def();\n ndef->set_op(op->Name());\n ndef->set_name(op->Name()); // This could be anything.\n const auto& signature = fdef.signature();\n for (size_t i = 0; i < signature.input_arg_size(); i++) {\n ndef->add_input(absl::StrCat(fdef.signature().input_arg(i).name(), \":0\"));\n }\n // TODO(srbs): Private attrs on the op are dropped here and applied to\n // the call op instead. If this causes problems we might have to copy those\n // attrs to this ndef. That would require updating fname to contain a hash\n // of such attributes.\n for (const auto& attr : opdef.attr()) {\n (*ndef->mutable_attr())[attr.name()].set_placeholder(attr.name());\n }\n // Set the device of this node to be the exact same one that eager mode\n // would have used.\n // TODO(b/200153278): Ideally we would just forward the call op's device at\n // runtime but currently there is no way to do it.\n ndef->set_device(op->DeviceName());",
"#ifdef INTEL_MKL\n if (IsMKLEnabled() &&\n absl::StartsWith(op->Name(), mkl_op_registry::kMklOpPrefix)) {\n GetMKLNodeDef(ndef);\n }\n#endif // INTEL_MKL",
" // Set `ret` map.\n TF_RETURN_IF_ERROR(\n PopulateRetMap(&fdef, op_attrs, op, opdef, signature, ndef->name()));\n VLOG(1) << fdef.DebugString();\n TF_RETURN_IF_ERROR(op->EagerContext().AddFunctionDef(std::move(fdef)));\n }\n // Build the call op.\n auto& ctx = op->EagerContext();\n AbstractOperationPtr call_op(ctx.CreateOperation());\n TF_RETURN_IF_ERROR(call_op->Reset(fname.c_str(), op->DeviceName().c_str()));\n for (auto t : op->Inputs()) {\n TF_RETURN_IF_ERROR(call_op->AddInput(t));\n }\n *wrapped_op = down_cast<EagerOperation*>(call_op.release());\n // Attributes on the elementary eager operation are applied to the call op and\n // to the NodeDef inside the FunctionDef. This allows us to have a single\n // FunctionDef for different attribute values. When the function is\n // instantiated, these attributes get forwarded to the NodeDef. This is done\n // by setting the AttrValue.placeholder field for the NodeDef attrs.\n (*wrapped_op)->AddAttrs(op_attrs);\n return AddMixedTypeListAttrs(*wrapped_op, op_attrs, opdef);\n}",
"bool IntArgsAndRetvalsOnDevice(EagerOperation* op) {\n // Most TF ops expect and generate int32 tensors on the host (or a TPU/XLA\n // device). This is not the case with IteratorGetNext since it is possible to\n // build int32 datasets that produce outputs on device when using\n // prefetch_to_device.\n // When running call ops, by default we assume that the int32 outputs are on a\n // host (except for the XLA/TPU case). So we need to special case\n // IteratorGetNext such that its eager behavior matches the wrapped one.\n // TODO(b/208435025): Remove this if we end up deciding that int32 outputs\n // from IteratorGetNext should indeed live on host.\n return op->Name() == \"IteratorGetNext\";\n}",
"StatusOr<Fprint128> GetKernelCacheKey(\n const EagerOperation& op, const Fprint128& op_cache_key,\n const std::vector<Device*>& input_dev_ptrs,\n const std::unordered_map<int, DtypeAndPartialTensorShape>&\n input_resource_variable_dtypes_and_shapes) {\n EagerContext& ctx = op.EagerContext();",
" Fprint128 cache_key = op_cache_key;\n /// Include soft placement policy in cache key since the placement strategy\n // can change and thus affect which kernel is picked.\n cache_key = FingerprintCat128(cache_key, ctx.AllowSoftPlacement());",
" // Include run_eager_op_as_function policy in cache key since the execution\n // strategy can change and affect which kernel is picked.\n VLOG(3) << \"ctx.RunEagerOpAsFunction(): \" << ctx.RunEagerOpAsFunction();\n cache_key = FingerprintCat128(cache_key, ctx.RunEagerOpAsFunction());",
" // When running in eager_op_as_function mode Send/Recv ops need to be\n // placed on the same rendezvous to match the behaviour of eager mode.\n bool reuse_rendezvous_for_functions =\n (ctx.RunEagerOpAsFunction() && !op.is_function()) ||\n ctx.GetReuseRendezvousForFunctions();\n // The launch-time rendezvous reuse setting is bundled with the kernel, so we\n // need to include it in the cache key.\n cache_key = FingerprintCat128(cache_key, reuse_rendezvous_for_functions);",
" for (int i = 0, end = input_dev_ptrs.size(); i < end; ++i) {\n cache_key =\n FingerprintCat128(cache_key, Fingerprint128(input_dev_ptrs[i]->name()));",
" auto input_resource = input_resource_variable_dtypes_and_shapes.find(i);\n if (input_resource != input_resource_variable_dtypes_and_shapes.end()) {\n // const DtypeAndPartialTensorShape& dtype_and_shape\n const DtypeAndPartialTensorShape& dtype_and_shape =\n input_resource->second;\n // Add _Arg index, dtype and shape to \"cache_key\".\n cache_key = FingerprintCat128(cache_key, i);\n cache_key = FingerprintCat128(cache_key, dtype_and_shape.dtype);\n AppendTensorShapeToFingerprint(dtype_and_shape.shape, &cache_key);\n }\n }",
" return cache_key;\n}",
"Status SetOpDevice(EagerContext& ctx, EagerOperation* op, Device** device) {\n // Here in local execute, set preferred device to be on the local task to\n // avoid placing op on a remote device with higher priority.\n const DeviceNameUtils::ParsedName& preferred_device =\n DeviceNameUtils::HasSomeDetails(op->GetDeviceParsedName())\n ? op->GetDeviceParsedName()\n : DeviceNameUtils::AddressSpace(ctx.HostCPUParsedName());\n // Note: We use the unwrapped op for inferring the device.\n // Without this, when wrapping CPU-only ops like RangeDataset we would\n // place the wrapped op on a GPU (if one is available) which leads to\n // errors because placer pins the function output nodes to GPU thereby\n // forcing a H2D copy of the dataset variant which is not supported.\n auto ndef = op->MutableAttrs()->BuildNodeDef();\n#ifdef INTEL_MKL\n if (IsMKLEnabled() &&\n absl::StartsWith(op->Name(), mkl_op_registry::kMklOpPrefix)) {\n GetMKLNodeDef(&ndef);\n }\n#endif // INTEL_MKL",
" TF_RETURN_IF_ERROR(ctx.SelectDevice(preferred_device, ndef, device));",
" VLOG(1) << \"PreferredDevice \" << op->Name() << \": \" << preferred_device;\n VLOG(1) << \"Placer place op [\" << op->Name()\n << \"] on device: \" << (*device)->name();\n VLOG(4) << \"Available kernels for \" << op->Name() << \" are\"\n << KernelsRegisteredForOp(op->Name());\n op->SetDevice(*device);\n return Status::OK();\n}",
"Fprint128 GetDeviceCacheKey(EagerOperation* op, const EagerContext& ctx) {\n Fprint128 device_cache_key = op->MutableAttrs()->CacheKey(op->DeviceName());\n device_cache_key =\n FingerprintCat128(device_cache_key, ctx.AllowSoftPlacement());\n return device_cache_key;\n}",
"Status GetOrCreateKernelAndDevice(\n EagerOperation* op, TensorHandle** retvals, int* num_retvals,\n core::RefCountPtr<KernelAndDevice>* out_kernel) {\n EagerContext& ctx = op->EagerContext();\n Device* device = absl::get<Device*>(op->Device());",
" // Set the EagerOperation's device prior to extracting the input_dev_ptrs to\n // avoid any redundant H2D/D2H copies.\n if (device == nullptr && !op->is_function()) {\n Fprint128 device_cache_key = GetDeviceCacheKey(op, ctx);\n device = ctx.GetCachedDevice(device_cache_key);\n if (device == nullptr) {\n TF_RETURN_IF_ERROR(SetOpDevice(ctx, op, &device));\n ctx.AddDeviceToCache(device_cache_key, device);\n } else {\n op->SetDevice(device);\n }\n }",
" // Save the original value of reuse_rendezvous_for_functions from the context.\n bool reuse_rendezvous_for_functions_original_value =\n ctx.GetReuseRendezvousForFunctions();\n // When running in eager_op_as_function mode Send/Recv ops need to be\n // placed on the same rendezvous to match the behaviour of eager mode.\n bool reuse_rendezvous_for_functions =\n (ctx.RunEagerOpAsFunction() && !op->is_function()) ||\n reuse_rendezvous_for_functions_original_value;",
" std::vector<Device*> input_dev_ptrs;\n absl::flat_hash_map<string, const std::vector<string>*> composite_devices;\n std::unordered_map<int, DtypeAndPartialTensorShape>\n input_resource_variable_dtypes_and_shapes;\n if (op->is_function() || ctx.RunEagerOpAsFunction()) {\n profiler::TraceMe activity(\"EagerCopyToDevice\",\n profiler::TraceMeLevel::kInfo);\n input_dev_ptrs.reserve(op->Inputs().size());\n const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n for (int i = 0, end = inputs->size(); i < end; ++i) {\n TensorHandle* input = (*inputs)[i];",
" Device* input_device;\n TF_RETURN_IF_ERROR(GetDeviceForInput(*op, ctx, input, &input_device));\n VLOG(1) << op->Name() << \":input:\" << i << \" \" << input_device->name();\n input_dev_ptrs.push_back(input_device);\n CompositeDevice* composite_device = nullptr;\n if (ctx.FindCompositeDeviceFromName(input_device->name(),\n &composite_device)\n .ok()) {\n composite_devices[input_device->name()] =\n composite_device->underlying_devices();\n }\n if (input->dtype == DT_RESOURCE) {\n // We only care about data type and shape for resource variable inputs.\n // But we have no way to tell if input is resource variable (other than\n // looking it up in ResourceMgr, which is slow). So we just get\n // resource_dtypes_and_shapes for all DT_RESOURCE inputs. If\n // resource_dtypes_and_shapes is not empty, take the first element.\n std::vector<DtypeAndPartialTensorShape> resource_dtypes_and_shapes;\n TF_RETURN_IF_ERROR(input->GetResourceHandleDtypesAndShapes(\n &resource_dtypes_and_shapes));\n if (!resource_dtypes_and_shapes.empty()) {\n const DtypeAndPartialTensorShape& dtype_and_shape =\n resource_dtypes_and_shapes.at(0);\n input_resource_variable_dtypes_and_shapes[i] = dtype_and_shape;\n }\n }\n }\n }",
" TF_ASSIGN_OR_RETURN(\n Fprint128 cache_key,\n GetKernelCacheKey(*op, op->MutableAttrs()->CacheKey(op->DeviceName()),\n input_dev_ptrs,\n input_resource_variable_dtypes_and_shapes));\n core::RefCountPtr<KernelAndDevice> kernel = ctx.GetCachedKernel(cache_key);\n AbstractOperationPtr wrapped_op_releaser;\n // We can eliminate some overhead by running simple functions using regular\n // CallOp kernel. However, it is tricky to figure out which functions should\n // be run using CallOp. Also, currently CallOp runs neither optimization\n // passes (needed for TPU/XLA) nor grappler.\n // Here are some cases where a function should be run in multi-device mode:\n // - Function takes at least two resources on different devices.\n // - Function takes a resource on deviceA and a body op explicitly placed\n // on deviceB.\n // - Function has a colocation constraint.\n // - Function has an explicit device annotation (which might not be using\n // full canonical device name) different from op_device. Note that false\n // positives are ok.\n // - Function has a node or a (node) attribute that can potentially make\n // the function multi-device after a rewrite pass (e.g. various XLA/TPU\n // special nodes and attributes)\n if (kernel == nullptr) {\n VLOG(2) << \"Creating new kernel for \" << op->Name() << \" on device \"\n << DeviceNameOrUnspecified(absl::get<Device*>(op->Device()));\n bool run_function_with_flr = false;\n bool function_outputs_on_op_device = false;\n absl::optional<string> xla_compile_device_type;\n if (op->is_function()) {\n bool compile_with_xla;\n TF_RETURN_IF_ERROR(MustCompileWithXLA(op, ctx, &compile_with_xla));\n if (compile_with_xla) {\n if (ctx.JitCompileRewrite()) {\n xla_compile_device_type = op->GetDeviceParsedName().type;\n run_function_with_flr = true;\n } else {\n // Note that it is not ideal, but currently correct, to set this\n // attribute after computing the kernel cache key above.\n // Note: If the attribute is already set to true, this is a noop.\n op->MutableAttrs()->Set(kXlaMustCompileAttr, true);\n }\n } else {\n run_function_with_flr = true;\n }\n GetFuncAttr(op, ctx, kOutputsOnOpDevice, &function_outputs_on_op_device)\n .IgnoreError();\n }",
" VLOG(2) << op->Name() << \" function_outputs_on_op_device: \"\n << function_outputs_on_op_device;\n if (device == nullptr) {\n TF_RETURN_IF_ERROR(SetOpDevice(ctx, op, &device));\n } else {\n VLOG(1) << \"Device for [\" << op->Name()\n << \"] already set to: \" << device->name();\n }",
" // Note: We wrap the eager op AFTER the device has been inferred to ensure\n // that placement of the NodeDef in the function is exactly the same as in\n // eager mode. This is specially important for cases where the\n // preferred device is not the actual device on which the op is run.\n // E.g. the preferred device for a `RangeDataset` op could be set to `GPU`\n // but `ctx->SelectDevice` would still place it on CPU. Placer on the other\n // hand would throw an error.\n //\n // Note: The wrapped function is never jit compiled but rather run via the\n // FLR. This is needed because certain ops e.g. `VarHandleOp` can not be\n // jit compiled. Ideally we would run this via the jit compiled path and\n // expect unsupported ops to be outside compiled but that is not supported\n // on GPUs right now.\n bool allow_small_function_optimizations = false;\n bool int_args_and_retvals_on_device = false;\n bool allow_control_flow_sync_execution = false;\n // TODO(b/176491312): Remove this if shape inference on import flag is\n // removed.\n bool shape_inference_on_tfe_dialect_import = true;\n if (ctx.RunEagerOpAsFunction() && !op->is_function()) {\n EagerOperation* wrapped_op = nullptr;\n TF_RETURN_IF_ERROR(ValidateOp(op));\n TF_RETURN_IF_ERROR(WrapInCallOp(op, &wrapped_op));\n DCHECK(wrapped_op);\n DCHECK(wrapped_op->is_function());\n wrapped_op_releaser.reset(wrapped_op);\n run_function_with_flr = true;\n allow_small_function_optimizations = true;\n allow_control_flow_sync_execution = true;\n shape_inference_on_tfe_dialect_import = false;\n int_args_and_retvals_on_device = IntArgsAndRetvalsOnDevice(op);\n op = wrapped_op;\n }\n const NodeDef& ndef = op->MutableAttrs()->BuildNodeDef();",
" FunctionLibraryRuntime* flr =\n device == nullptr ? nullptr : ctx.func_lib(device);\n if (device != nullptr && flr == nullptr) {\n return errors::NotFound(\n \"Unable to find a FunctionLibraryRuntime corresponding to device \",\n device->name());\n }\n auto runner = (flr != nullptr && flr->runner() != nullptr) ? flr->runner()\n : ctx.runner();\n GraphCollector* graph_collector = nullptr;\n if (ctx.ShouldStoreGraphs()) {\n graph_collector = ctx.GetGraphCollector();\n }\n // Treat the function as multi_device only when we are not compiling\n // it wholly with XLA. When compiling wholly with XLA, flr->CreateKernel\n // will create an XlaLaunchOp kernel to compile and run the function.\n if (run_function_with_flr) {\n // Multi-device functions don't use the rendezvous from eager context.\n // If we use that rendezvous, multiple concurrent calls to the same\n // function will likely result in collisions. However, this also means\n // that we don't support legitimate sending/receiving across function\n // boundary.\n VLOG(2) << \"Running \" << ndef.op() << \" using multi-device function. \"\n << \"Full node_def=\" << ndef.DebugString();\n std::function<int64_t()> get_op_id = nullptr;\n#if !defined(IS_MOBILE_PLATFORM)\n get_op_id = [&ctx]() { return ctx.RemoteMgr()->NextOpId(); };\n#endif // IS_MOBILE_PLATFORM",
" ctx.reuse_rendezvous_for_functions_mu()->lock();\n ctx.SetReuseRendezvousForFunctions(reuse_rendezvous_for_functions);\n auto rendezvous_creator = ctx.RendezvousCreator();\n ctx.SetReuseRendezvousForFunctions(\n reuse_rendezvous_for_functions_original_value);\n ctx.reuse_rendezvous_for_functions_mu()->unlock();\n kernel.reset(new KernelAndDeviceFunc(\n flr, ctx.pflr(), std::move(input_dev_ptrs),\n std::move(composite_devices),\n std::move(input_resource_variable_dtypes_and_shapes), runner,\n ctx.GetCollectiveExecutorHandle(), ctx.HostCPU(), op->Name(),\n function_outputs_on_op_device, allow_small_function_optimizations,\n allow_control_flow_sync_execution,\n shape_inference_on_tfe_dialect_import, int_args_and_retvals_on_device,\n xla_compile_device_type, std::move(rendezvous_creator), get_op_id));\n } else {\n VLOG(2) << \"Running \" << ndef.op() << \" using op kernel. \"\n << \". Full node_def=\" << ndef.DebugString();\n kernel.reset(new KernelAndDeviceOp(\n ctx.GetRendezvous(), ctx.LogMemory(), flr, runner,\n ctx.GetCollectiveExecutorHandle(), ctx.HostCPU()));\n }",
" TF_RETURN_IF_ERROR(\n kernel->Init(ctx.LogDevicePlacement(), ndef, graph_collector));",
" if (op->is_function()) {\n ctx.AddKernelToCache(cache_key, kernel.get());\n } else {\n // Exclude tf.data op kernels from being cached. The reason for this is\n // that tf.data op kernels that accept a user-defined function will have a\n // unique cache key every time they are executed (because the user-defined\n // function is traced every time). Caching such kernels provides no\n // benefit and in some cases results in linear memory growth of use\n // programs that build input pipeline graphs in a loop.\n const OpDef* op_def;\n TF_RETURN_IF_ERROR(OpDefForOp(op->Name().data(), &op_def));\n if (KernelCacheEnabled(*op_def)) {\n ctx.AddKernelToCache(cache_key, kernel.get());\n }\n }\n }",
" int num_outputs = kernel->num_outputs();\n if (num_outputs > *num_retvals) {\n return errors::InvalidArgument(\"Expecting \", num_outputs,\n \" outputs, but *num_retvals is \",\n *num_retvals);\n }\n *num_retvals = num_outputs;",
" kernel->Ref(); // Ownership of reference is passed to out_kernel.\n out_kernel->reset(kernel.get());\n return Status::OK();\n}",
"Status CreateUnshapedOutput(\n const KernelAndDevice& kernel, const int output_num, Device* output_device,\n const DataType& output_dtype,\n const absl::optional<EagerFunctionParams>& eager_func_params,\n EagerContext* ctx, TensorHandle** output) {\n#if defined(IS_MOBILE_PLATFORM)\n return errors::Unimplemented(\n \"Remote outputs are not available on mobile devices.\");\n#else // !IS_MOBILE_PLATFORM\n int64_t op_id;\n if (eager_func_params.has_value()) {\n op_id = eager_func_params.value().op_id;\n } else {\n return errors::InvalidArgument(\n \"Unable to find a remote op id for a remote output of \", kernel.name());\n }\n string remote_task;\n if (!DeviceNameUtils::GetTaskName(output_device->parsed_name(),\n &remote_task)) {\n return errors::InvalidArgument(\n \"Unable to find remote task corresponding to device \",\n output_device->name());\n }\n if (ctx->RemoteMgr()->IsMaster()) {\n *output = TensorHandle::CreateUnshapedRemoteHandle(\n op_id, output_num, remote_task, output_dtype, output_device, ctx);\n } else {\n *output = TensorHandle::CreateLazyRemoteHandle(op_id, output_num,\n output_dtype, output_device,\n /*is_ready=*/false, ctx);\n }\n return Status::OK();\n#endif // !IS_MOBILE_PLATFORM\n}",
"Status AddOrExecuteNode(core::RefCountPtr<KernelAndDevice> kernel,\n EagerOperation* op, TensorHandle** retvals) {\n EagerExecutor& executor = op->Executor();\n EagerContext& ctx = op->EagerContext();\n GraphCollector* graph_collector = nullptr;\n if (ctx.ShouldStoreGraphs()) {\n graph_collector = ctx.GetGraphCollector();\n }\n const int num_outputs = kernel->num_outputs();\n absl::optional<EagerFunctionParams> eager_func_params =\n op->eager_func_params();\n if (kernel->IsCrossProcess() && !eager_func_params.has_value()) {\n // Create an eager op id for a cross-process function if not exist.\n#if defined(IS_MOBILE_PLATFORM)\n return errors::Unimplemented(\n \"Cross-process functions are not supported on mobile devices.\");\n#else // !IS_MOBILE_PLATFORM\n const int64_t op_id = ctx.RemoteMgr()->NextOpId();\n eager_func_params = EagerFunctionParams{op_id, /*step_id=*/absl::nullopt};\n#endif // !IS_MOBILE_PLATFORM\n }\n if (executor.Async()) {\n const DataTypeVector& output_dtypes = kernel->output_dtypes();\n for (int i = 0, end = num_outputs; i < end; ++i) {\n Device* output_device = ctx.CanonicalDevice(kernel->OutputDevice(i));\n if (output_device == nullptr || output_device->IsLocal()) {\n retvals[i] = TensorHandle::CreateEmptyLocalHandle(\n /* d= */ output_device, /* op_device= */ kernel->device(),\n /* resource_device= */ kernel->OutputResourceDevice(i),\n output_dtypes[i], &ctx);\n } else {\n TF_RETURN_IF_ERROR(\n CreateUnshapedOutput(*kernel, i, output_device, output_dtypes[i],\n eager_func_params, &ctx, &retvals[i]));\n }\n }\n const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n auto node = absl::make_unique<AsyncExecuteNode>(\n &ctx, *inputs, eager_func_params, std::move(kernel), graph_collector,\n op->GetCancellationManager(),\n absl::Span<TensorHandle*>(retvals, num_outputs), op->GetStackTrace());\n // Release the inputs from the eager operation since the AsyncExecuteNode\n // would have taken ownership. This allows the inputs to be forwarded if\n // possible.\n op->Clear();\n // For async mode, execution order will make sure that all\n // input handles are ready before executing them.\n // TODO(b/137118203): Consider executing \"cheap\" kernels inline for\n // performance.\n return executor.AddOrExecute(std::move(node));\n } else {\n for (int i = 0, end = num_outputs; i < end; ++i) {\n retvals[i] = nullptr;\n }\n const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n ExecuteNode node(&ctx, *inputs, eager_func_params, kernel, graph_collector,\n op->GetCancellationManager(),\n {retvals, static_cast<size_t>(num_outputs)},\n op->GetStackTrace());\n Status s = executor.SyncExecute(&node);\n // We release the inputs AFTER executing the operation in sync mode since\n // ExecuteNode does not increment the reference count and thus does not have\n // ownership of the inputs while executing.\n op->Clear();\n return s;\n }\n}",
"// There are a lot of references to devices in this function and around.\n// Here is what they mean:\n// EagerOperation::Device(): The device on which the user requested the op\n// be executed, except if we had to change the device due to resource inputs\n// or CPU pinning. If the user did not request a device, the op does not\n// take resources, and we did not pin it to CPU, the device can be nullptr.\n// KernelAndDevice::Device(): The first time we see an op (combined with\n// its attributes), we need to create a KernelAndDevice object for it.\n// If op->Device() is a nullptr, we select a device for the op when\n// creating the KernelAndDevice. A concrete device will always be selected\n// here except when `op` is a function to be executed using function library\n// runtime. In this case, we don't select a device because running\n// a function with explicitly requested device has different behavior than\n// running without an explicitly requested device.\nStatus EagerLocalExecute(EagerOperation* op, TensorHandle** retvals,\n int* num_retvals) {\n profiler::ScopedMemoryDebugAnnotation op_annotation(\n op->op_name(), op->eager_func_params().has_value()\n ? op->eager_func_params().value().step_id.value_or(0)\n : 0);\n profiler::TraceMe activity(\n [&] { return absl::StrCat(\"EagerLocalExecute: \", op->Name()); },\n profiler::TraceMeLevel::kInfo);\n EagerContext& ctx = op->EagerContext();\n auto& executor = op->Executor();\n TF_RETURN_IF_ERROR(executor.status());",
" core::RefCountPtr<KernelAndDevice> kernel;\n auto status = GetOrCreateKernelAndDevice(op, retvals, num_retvals, &kernel);",
"#ifdef INTEL_MKL\n if (IsMKLEnabled() && kernel != nullptr &&\n op->Device() == kVariantDeviceNull) {\n // oneDNN optimization pass relies on the op's assigned device to determine\n // whether it can be rewritten.\n op->SetDevice(kernel->device());\n }\n#endif // INTEL_MKL",
" // Run all the registered rewrite pass after the placement, regardless whether\n // the placement is successful or not. The passes can either create new ops\n // (without placement) or update some fields of the input op.\n std::unique_ptr<tensorflow::EagerOperation> out_op;\n TF_RETURN_IF_ERROR(EagerOpRewriteRegistry::Global()->RunRewrite(\n EagerOpRewriteRegistry::POST_PLACEMENT, op, &out_op));\n if (out_op) {\n op = out_op.get();\n // If the out op doesn't have device, either because it is a new op or\n // the op wasn't placed successfully, then we do the placement again.\n if (op->Device() == kVariantDeviceNull) {\n status = GetOrCreateKernelAndDevice(op, retvals, num_retvals, &kernel);\n }\n }\n if (!status.ok()) return status;",
" int num_outputs = kernel->num_outputs();\n TF_RETURN_IF_ERROR(ValidateInputTypeAndPlacement(&ctx, op, kernel));",
" if (ctx.LogDevicePlacement() || VLOG_IS_ON(1)) {\n string msg = strings::StrCat(\"Executing op \", op->Name(), \" in device \",\n kernel->device()->name());\n if (!logging::LogToListeners(msg)) {\n LOG(INFO) << msg;\n }\n }",
" Status s = AddOrExecuteNode(std::move(kernel), op, retvals);\n // Since the operation failed, we need to Unref any outputs if they were\n // allocated.\n if (!s.ok()) {\n for (int i = 0, end = num_outputs; i < end; ++i) {\n if (retvals[i] != nullptr) {\n retvals[i]->Unref();\n retvals[i] = nullptr;\n }\n }\n }",
" return s;\n}",
"// Run a Pack op to pack the tensors pointed by a packed input TensorHandle if\n// the op is a primitive op.\nStatus MaybePackInputTensor(EagerOperation* op) {\n if (op->is_function() || op->EagerContext().RunEagerOpAsFunction()) {\n // Functions could take packed TensorHandles as inputs.\n return Status::OK();\n }\n EagerContext& ctx = op->EagerContext();\n const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n for (int i = 0; i < inputs->size(); ++i) {\n TensorHandle* handle = (*inputs)[i];\n if (handle->Type() == TensorHandle::PACKED) {\n EagerOperation pack_op(&ctx);\n TF_RETURN_IF_ERROR(pack_op.Reset(\"Pack\", /*device_name=*/nullptr,\n /*remote=*/false, /*executor=*/nullptr));\n pack_op.MutableAttrs()->Set(\"N\", handle->NumPackedHandles());\n pack_op.MutableAttrs()->Set(\"T\", handle->dtype);\n for (int i = 0; i < handle->NumPackedHandles(); ++i) {\n tensorflow::TensorHandle* h = nullptr;\n TF_RETURN_IF_ERROR(handle->ExtractPackedHandle(i, &h));\n TF_RETURN_IF_ERROR(pack_op.AddInput(h));\n }\n int num_retvals = 1;\n absl::FixedArray<tensorflow::TensorHandle*> retvals(num_retvals);\n TF_RETURN_IF_ERROR(\n EagerLocalExecute(&pack_op, retvals.data(), &num_retvals));\n tensorflow::TensorHandle* ret = retvals.at(0);\n op->UpdateInput(i, ret);\n ret->Unref();\n }\n }\n return Status::OK();\n}",
"#if !defined(IS_MOBILE_PLATFORM)\nvoid PrepareRemoteOp(eager::Operation* remote_op, EagerOperation* op) {\n EagerContext& ctx = op->EagerContext();",
" remote_op->set_id(ctx.RemoteMgr()->NextOpId());\n remote_op->set_name(op->Name());",
" op->Attrs().FillAttrValueMapWithoutDefaults(remote_op->mutable_attrs());\n remote_op->set_device(absl::get<Device*>(op->Device())->name());\n remote_op->set_is_function(op->is_function());\n}",
"Status StoreResourceDtypesAndShapes(const eager::Operation& remote_op,\n const DataTypeVector& output_dtypes,\n TensorHandle** retvals) {\n if (remote_op.name() == \"VarHandleOp\") {\n if (output_dtypes.size() != 1) {\n return errors::Internal(\"VarHandleOp should only have one output.\");\n }\n if (output_dtypes[0] != DT_RESOURCE) {\n return errors::Internal(\n \"The output of VarHandleOp should be a DT_RESOURCE.\");\n }\n AttrSlice attr_slice = AttrSlice(&remote_op.attrs());\n const AttrValue* dtype;\n TF_RETURN_IF_ERROR(attr_slice.Find(\"dtype\", &dtype));\n const AttrValue* shape;\n TF_RETURN_IF_ERROR(attr_slice.Find(\"shape\", &shape));\n retvals[0]->SetResourceHandleDtypeAndShape(\n {DtypeAndPartialTensorShape{dtype->type(), shape->shape()}});\n }\n return Status::OK();\n}",
"Status EagerRemoteExecute(EagerOperation* op, TensorHandle** retvals,\n int* num_retvals) {\n EagerContext& ctx = op->EagerContext();",
" // TODO(fishx): Remove following code when lazy tensor copy is ready.\n if (op->Device() == kVariantDeviceNull) {\n tensorflow::Device* device = nullptr;\n string device_name = op->DeviceName();\n TF_RETURN_IF_ERROR(ctx.FindDeviceFromName(device_name.c_str(), &device));\n op->SetDevice(device);\n }",
" core::RefCountPtr<eager::EagerClient> eager_client;\n uint64 context_id = ctx.GetContextId();\n TF_RETURN_IF_ERROR(ctx.GetClient(op->GetDeviceParsedName(), &eager_client));\n string remote_task;\n if (!DeviceNameUtils::GetTaskName(op->GetDeviceParsedName(), &remote_task)) {\n return errors::InvalidArgument(\n \"Unable to find remote task corresponding to device \",\n op->DeviceName());\n }",
" std::unique_ptr<eager::EnqueueRequest> request(new eager::EnqueueRequest);\n request->set_context_id(context_id);",
" eager::Operation* remote_op = request->add_queue()->mutable_operation();",
" tensorflow::Device* op_device = absl::get<Device*>(op->Device());\n {\n profiler::TraceMe activity(\"CopyInputToExpectedDevice\",\n profiler::TraceMeLevel::kInfo);\n const bool is_function = op->is_function();\n const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n for (int i = 0, end = inputs->size(); i < end; i++) {\n tensorflow::TensorHandle* input = (*inputs)[i];\n tensorflow::Device* input_device = input->device();\n tensorflow::Device* input_device_or_cpu = input->DeviceOrHostCPU(ctx);\n const string* input_device_name = &input_device_or_cpu->name();\n bool serialize_resource_dtype_and_shape = false;\n if (op_device != input_device &&\n // If the expected and actual devices are on the same task, don't\n // explicitly copy, and instead depend on the copy to happen locally\n // when the op is executed on the device.\n !ctx.OnSameTask(op_device, input_device)) {\n if (!is_function || input_device_or_cpu->IsLocal()) {\n tensorflow::Device* remote_cpu_device;\n TF_RETURN_IF_ERROR(\n ctx.CPUDeviceOnTask(op_device, &remote_cpu_device));\n // Always copy to the remote CPU so that the actual device can be\n // correctly determined after the kernel is selected/instantiated,\n // since the op might have its inputs on host memory.\n TensorHandle* handle = input;\n Device* handle_device = handle->DeviceOrHostCPU(ctx);\n // If the input is already on the right device, then nothing to do.\n if (remote_cpu_device != handle_device) {\n VLOG(6) << \"remote_cpu_device != handle_device\";\n TF_RETURN_IF_ERROR(CopyInputToExpectedDevice(\n &ctx, op, op_device, handle, i, handle_device,\n remote_cpu_device, &handle));\n op->UpdateInput(i, handle);\n input = handle;\n input_device = remote_cpu_device;\n input_device_name = &remote_cpu_device->name();\n // Unref handle since it has a ref as an input now\n handle->Unref();\n }\n } else {\n serialize_resource_dtype_and_shape =\n (input->dtype == DT_RESOURCE) &&\n (!input->HasResourceShapeMirror(op_device,\n ctx.GetContextViewId()));\n }\n }\n auto* input_handle = remote_op->add_op_inputs()->mutable_remote_handle();\n // For a remote component function, a function execution request and an\n // input generation request may come from different workers. We need to\n // guarantee that the input generation request is processed before the\n // function execution request, so wait until the remote input is ready\n // before sending it to the multi-device function device.\n const bool wait_until_ready = op->is_function();\n TF_RETURN_IF_ERROR(ctx.RemoteMgr()->SerializeRemoteTensorHandle(\n input, wait_until_ready, input_handle, input_device,\n *input_device_name, serialize_resource_dtype_and_shape));\n if (!input_handle->resource_dtypes_and_shapes().empty()) {\n TF_RETURN_IF_ERROR(\n input->AddResourceShapeMirror(op_device, input_handle->op_id(),\n input_handle->output_num(), &ctx));\n }\n }\n }",
" PrepareRemoteOp(remote_op, op);",
" DataTypeVector output_dtypes;\n TF_RETURN_IF_ERROR(GetOutputDTypes(op, &output_dtypes));",
" const size_t num_outputs = output_dtypes.size();\n if (num_outputs != *num_retvals) {\n return errors::InvalidArgument(\n \"num_retvals does not match expected output dtypes\");\n }\n *num_retvals = num_outputs;",
" const tensorflow::uint64 id = remote_op->id();\n for (size_t i = 0; i < num_outputs; ++i) {\n // TODO(nareshmodi): Change the callback to instead add the decref to a\n // list of pending decrefs that we can send as a batch with the next\n // execute.",
" // The device_ and resource_device_ of this TensorHandle might be\n // incorrect. For multi-device functions, we don't know the output device\n // until the function is instantiated on a remote worker. Luckily, we don't\n // need to know the correct remote device here. We just need to know that it\n // is remote. If we need copy this tensor to this process or run any ops\n // which take this tensor as an input, block until the correct device is\n // set.\n const bool unknown_device = op->is_function();\n retvals[i] = TensorHandle::CreateUnshapedRemoteHandle(\n id, i, remote_task, output_dtypes[i], op_device, &ctx, unknown_device);\n }",
" // Store the data type and shape of a remote resource variable on the\n // corresponding remote TensorHandle (output of 'VarHandleOp').\n // If the variable is an input of a remote function, the function may need\n // the type and shape during function instantiation. Store the type and\n // shape on eager master and sent them to the default function device along\n // with the EnqueueRequest.\n TF_RETURN_IF_ERROR(\n StoreResourceDtypesAndShapes(*remote_op, output_dtypes, retvals));",
" auto& executor = op->Executor();\n VLOG(4) << \"Execute remote eager op: \" << op->Name()\n << \" (is async?: \" << executor.Async() << \").\";",
" const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));",
" std::unique_ptr<EagerNode> node(new eager::RemoteExecuteNode(\n &op->EagerContext(), std::move(request), op_device,\n ctx.GetContextViewId(), eager_client.get(), op->GetCancellationManager(),\n op->MutableAttrs()->BuildNodeDef(), op->EagerContext().FuncLibDef(),\n *inputs, {retvals, num_outputs}));",
" if (op->EagerContext().LogDevicePlacement() || VLOG_IS_ON(1)) {\n string msg = strings::StrCat(\n \"Executing op \", op->Name(), \" on task \",\n DeviceNameUtils::ParsedNameToString(op->GetDeviceParsedName()));\n if (!logging::LogToListeners(msg)) {\n LOG(INFO) << msg;\n }\n }",
" Status s = executor.AddOrExecute(std::move(node));\n // Since the operation failed, we need to Unref any outputs that were\n // allocated.\n if (!s.ok()) {\n for (size_t i = 0; i < num_outputs; ++i) {\n retvals[i]->Unref();\n // Ensure that any smart pointers created to wrap results become noops\n // rather than operating on invalid memory.\n retvals[i] = nullptr;\n }\n }",
" return s;\n}\n#endif // IS_MOBILE_PLATFORM",
"Status GetKernelOutputs(\n std::vector<EagerKernelRet>* outputs, int num_outputs,\n TensorHandle** retvals, EagerContext* ctx, KernelAndDevice* kernel,\n const absl::optional<EagerFunctionParams>& eager_func_params) {\n for (int i = 0, end = num_outputs; i < end; ++i) {\n if (retvals[i] == nullptr) {\n EagerKernelRet& ret = (*outputs)[i];\n Device* output_device = ctx->CanonicalDevice(kernel->OutputDevice(i));\n if (ret.index() == 0) {\n retvals[i] = TensorHandle::CreateLocalHandle(\n std::move(absl::get<Tensor>(ret)),\n /* d= */ output_device,\n /* op_device= */ kernel->device(),\n /* resource_device= */ kernel->OutputResourceDevice(i), ctx);\n } else {\n const DataTypeVector& output_dtypes = kernel->output_dtypes();\n TF_RETURN_IF_ERROR(\n CreateUnshapedOutput(*kernel, i, output_device, output_dtypes[i],\n eager_func_params, ctx, &retvals[i]));\n#if !defined(IS_MOBILE_PLATFORM)\n TF_RETURN_IF_ERROR(\n retvals[i]->SetRemoteShape(absl::get<TensorShape>(ret),\n output_device, ctx->GetContextViewId()));\n#endif // IS_MOBILE_PLATFORM\n }\n } else {\n if (!kernel->IsFunction() &&\n TF_PREDICT_FALSE(kernel->device() != retvals[i]->op_device())) {\n return errors::Internal(\n \"Kernel output tensor handle has a different op device than the \"\n \"kernel. This should never happen.\");\n }\n if (TF_PREDICT_FALSE(ctx->CanonicalDevice(kernel->OutputDevice(i)) !=\n retvals[i]->device())) {\n return errors::Internal(\n \"Kernel output tensor handle locates on a different device than \"\n \"the specified kernel output device. This should never happen.\");\n }",
" EagerKernelRet& ret = (*outputs)[i];\n if (ret.index() == 0) {\n TF_RETURN_IF_ERROR(retvals[i]->SetTensor(\n std::move(absl::get<Tensor>(ret)),\n ctx->CanonicalDevice(kernel->OutputDevice(i))));\n } else {\n#if defined(IS_MOBILE_PLATFORM)\n return errors::Unimplemented(\n \"Remote outputs are not available on mobile devices.\");\n#else // !IS_MOBILE_PLATFORM\n TF_RETURN_IF_ERROR(retvals[i]->SetRemoteShape(\n absl::get<TensorShape>(ret), retvals[i]->device(),\n ctx->GetContextViewId()));\n#endif // !IS_MOBILE_PLATFORM\n }\n }\n }\n return Status::OK();\n}",
"void CollectGraphs(EagerContext* ctx) {\n mutex_lock ml(*ctx->MetadataMu());",
" GraphCollector* collector = ctx->GetGraphCollector();\n mutex_lock mll(collector->mu);",
" // Adding to partition graphs for backward compatibility.\n for (const auto& graph : collector->partitioned_graphs) {\n *ctx->RunMetadataProto()->add_partition_graphs() = graph;\n }",
" if (collector->dirty) {\n auto* function_graphs = ctx->RunMetadataProto()->add_function_graphs();\n *function_graphs->mutable_post_optimization_graph() =\n collector->optimized_graph;\n *function_graphs->mutable_pre_optimization_graph() = collector->raw_graph;\n for (const auto& graph : collector->partitioned_graphs) {\n *function_graphs->add_partition_graphs() = graph;\n }\n }",
" collector->ClearGraphs();\n}\n} // namespace",
"Status EagerExecute(EagerOperation* op, TensorHandle** retvals,\n int* num_retvals) {\n profiler::TraceMe activity([&] {\n return ::tensorflow::profiler::TraceMeEncode(\n \"EagerExecute\",\n {{\"eager_op\", op->Name()}, {\"is_func\", op->is_function()}});\n });",
" if (!op->Executor().Async()) {\n VLOG(6) << \"op: \" << op->Name() << \" is not Async.\";\n if (!op->EagerContext()\n .GetGlobalRendezvousForFunctionLocalRendezvousStatus()\n .ok()) {\n VLOG(6) << \"global_rendezvous_for_functions_ is in bad state. Resetting.\";\n op->EagerContext().ResetGlobalRendezvousForFunction();\n }\n // In sync mode, always clear error to maintain the same behavior as before.\n // TODO(b/141004939): Remove this.\n op->Executor().ClearError();\n }",
" std::unique_ptr<tensorflow::EagerOperation> out_op;\n TF_RETURN_IF_ERROR(EagerOpRewriteRegistry::Global()->RunRewrite(\n EagerOpRewriteRegistry::PRE_EXECUTION, op, &out_op));",
" if (op->IsLocal()) {\n if (out_op) {\n op = out_op.get();\n }\n TF_RETURN_IF_ERROR(MaybePackInputTensor(op));\n return EagerLocalExecute(op, retvals, num_retvals);\n }",
"#if defined(IS_MOBILE_PLATFORM)\n return errors::Unimplemented(\n \"Eager's remote execution is not available on mobile devices.\");\n#else // !IS_MOBILE_PLATFORM\n if (out_op) {\n op = out_op.get();\n }\n return EagerRemoteExecute(op, retvals, num_retvals);\n#endif // !IS_MOBILE_PLATFORM\n}",
"// TODO(gjn): Consider moving into ExecuteNode class\nStatus EagerKernelExecute(\n EagerContext* ctx, const absl::InlinedVector<TensorHandle*, 4>& op_inputs,\n const absl::optional<EagerFunctionParams>& eager_func_params,\n const core::RefCountPtr<KernelAndDevice>& kernel,\n GraphCollector* graph_collector, CancellationManager* cancellation_manager,\n absl::Span<TensorHandle*> retvals,\n const absl::optional<ManagedStackTrace>& stack_trace) {\n profiler::TraceMe activity(\"EagerKernelExecute\",\n profiler::TraceMeLevel::kInfo);\n std::vector<EagerKernelRet> outputs(1);",
" ExecuteNodeArgs inputs(op_inputs.size());\n TF_RETURN_IF_ERROR(inputs.Init(ctx, op_inputs, kernel));\n // TODO(apassos) figure out how to record stats for ops which are a part of\n // functions.\n // TODO(b/111859745): When we support recovering from kernel/device errors, we\n // would need to call XlaDevice::EnsureDeviceContextOk() before using an XLA\n // device. We don't call it now because it is an unneeded overhead (it\n // acquires a lock) and we can't recover from errors anyway.\n ScopedStepContainer* container = ctx->StepContainer();\n CoordinationServiceAgent* coord_agent = nullptr;\n#if !defined(IS_MOBILE_PLATFORM)\n if (ctx->GetDistributedManager() != nullptr)\n coord_agent = ctx->GetDistributedManager()->GetCoordinationServiceAgent();\n#endif // !IS_MOBILE_PLATFORM\n TF_RETURN_IF_ERROR(kernel->Run(container, inputs, &outputs,\n cancellation_manager, eager_func_params,\n stack_trace, coord_agent));\n if (graph_collector != nullptr) {\n CollectGraphs(ctx);\n }",
" if (TF_PREDICT_FALSE(retvals.size() != outputs.size())) {\n return errors::Internal(\n \"EagerKernelExecute returns a list of \", outputs.size(),\n \" tensors but \", retvals.size(),\n \" is expected. This should never \"\n \"happen. Please file a bug with the TensorFlow team.\");\n }\n return GetKernelOutputs(&outputs, retvals.size(), retvals.data(), ctx,\n kernel.get(), eager_func_params);\n}",
"namespace {",
"Status LocalEagerCopyToDevice(TensorHandle* h, EagerContext* ctx,\n EagerExecutor* executor, Device* dstd,\n bool mirror, TensorHandle** result) {\n TF_RETURN_IF_ERROR(executor->status());\n Device* d = ctx->CanonicalDevice(dstd);\n if (mirror && h->HasLocalMirror(d)) {\n h->Ref();\n *result = h;\n return Status::OK();\n }",
" bool async = executor->Async();\n if (mirror) {\n h->Ref();\n *result = h;",
" if (h->HasLocalMirror(d)) {\n return Status::OK();\n }",
" // We don't bother adding an empty local mirror in sync mode since we'll be\n // executing the operation directly and be calling AddLocalMirror. A\n // reference count is still needed which will be removed if the operation\n // fails.\n if (async) {\n Status s = h->AddEmptyLocalMirror(d);\n if (!s.ok()) {\n // If a mirror was added since we called HasLocalMirror then just return\n // since another thread has already added the mirror.\n if (s.code() == error::Code::ALREADY_EXISTS) {\n return Status::OK();\n }",
" // Remove the previously added reference count since adding the mirror\n // failed.\n h->Unref();\n *result = nullptr;\n return s;\n }\n }\n } else {\n *result = TensorHandle::CreateEmptyLocalHandle(\n d, dstd, h->resource_device(), h->dtype, ctx);\n }",
" Status s;\n if (async) {\n // Note that `h` may not be currently ready. However execution order will\n // make sure that `h` is ready before the copy is actually done.\n std::unique_ptr<EagerNode> node(\n new CopyToDeviceNode(h, *result, d, *ctx, async, mirror));\n s = executor->AddOrExecute(std::move(node));\n } else {\n CopyToDeviceNode node(h, *result, d, *ctx, async, mirror);\n s = executor->SyncExecute(&node);\n }",
" // Since the operation failed, we need to Unref any outputs that were\n // allocated.\n if (!s.ok()) {\n (*result)->Unref();\n *result = nullptr;\n }",
" return s;\n}",
"} // namespace",
"Status EagerCopyToDevice(TensorHandle* h, EagerContext* ctx,\n EagerExecutor* executor, Device* device, bool mirror,\n TensorHandle** result) {\n TF_RETURN_IF_ERROR(h->WaitUnknownDevice());\n auto send_device = h->DeviceOrHostCPU(*ctx);\n bool sender_is_local = send_device->IsLocal();",
" bool receiver_is_local = device->IsLocal();",
" if (!executor->Async()) {\n // In sync mode, always clear error to maintain the same behavior as before.\n // TODO(b/141004939): Remove this.\n executor->ClearError();\n }",
" if (sender_is_local && receiver_is_local) {\n return LocalEagerCopyToDevice(h, ctx, executor, device, mirror, result);\n } else {\n#if defined(IS_MOBILE_PLATFORM)\n return errors::Unimplemented(\n \"Eager's remote execution is not available on mobile devices.\");\n#else // !IS_MOBILE_PLATFORM\n uint64 recv_op_id = 0;\n if (receiver_is_local) {\n Device* d = ctx->CanonicalDevice(device);\n // TODO(gjn): Need to add support for async execution. Note if receiver\n // is local, we need to first add support in TensorHandle to wait on local\n // mirrors.\n if (mirror) {\n h->Ref();\n *result = h;",
" if (h->HasLocalMirror(d)) {\n return Status::OK();\n }",
" Status s = h->AddEmptyLocalMirror(d);\n if (!s.ok()) {\n // If a mirror was added since we called HasLocalMirror then just\n // return since another thread has already added the mirror.\n if (s.code() == error::Code::ALREADY_EXISTS) {\n return Status::OK();\n }",
" // Remove the previously added reference count since adding the mirror\n // failed.\n h->Unref();\n *result = nullptr;\n return s;\n }\n } else {\n *result = TensorHandle::CreateEmptyLocalHandle(\n /* d= */ d, /* op_device= */ device,\n /*resource_device=*/nullptr, h->dtype, ctx);\n }\n } else {\n if (mirror) {\n if (h->HasRemoteMirror(device, ctx->GetContextViewId())) {\n h->Ref();\n *result = h;\n return Status::OK();\n }\n }\n string remote_task;\n if (!DeviceNameUtils::GetTaskName(device->parsed_name(), &remote_task)) {\n return errors::InvalidArgument(\n \"Unable to find remote task corresponding to device \",\n device->name());\n }\n recv_op_id = ctx->RemoteMgr()->NextOpId();\n if (mirror) {\n TF_RETURN_IF_ERROR(h->AddUnshapedRemoteMirror(device, recv_op_id, 0,\n remote_task, ctx));\n h->Ref();\n *result = h;\n } else {\n *result = TensorHandle::CreateUnshapedRemoteHandle(\n recv_op_id, 0, remote_task, h->dtype, device, ctx);\n }\n }",
" auto node = std::make_unique<eager::RemoteCopyNode>(\n ctx, executor, h, result[0], device, recv_op_id);\n Status s = executor->AddOrExecute(std::move(node));\n if (!s.ok()) {\n result[0]->Unref();\n result[0] = nullptr;\n }\n return s;\n#endif // !IS_MOBILE_PLATFORM\n }\n}",
"namespace {\n// Low-level utility function to execute the kernel specified by `kernel` on\n// `kernel->device()`, with the provided inputs as `op_inputs` in the 'ctx'.\n// Different from `EagerKernelExecute` that ties up the thread until the\n// underlying function finishes execute, this function does not block the thread\n// and could return before the function execution finishes. The provided\n// `StatusCallback` will be triggered after function execution with its status.\nvoid EagerKernelExecuteAsync(\n EagerContext* ctx, const absl::InlinedVector<TensorHandle*, 4>& op_inputs,\n const absl::optional<EagerFunctionParams>& eager_func_params,\n const core::RefCountPtr<KernelAndDevice> kernel,\n GraphCollector* graph_collector, CancellationManager* cancellation_manager,\n TensorHandle** retvals, int num_outputs, StatusCallback done) {\n auto inputs = std::make_shared<ExecuteNodeArgs>(op_inputs.size());\n auto outputs = std::make_shared<std::vector<EagerKernelRet>>(1);",
" Status s = inputs->Init(ctx, op_inputs, kernel);\n if (!s.ok()) {\n done(s);\n return;\n }\n CoordinationServiceAgent* coord_agent = nullptr;\n#if !defined(IS_MOBILE_PLATFORM)\n if (ctx->GetDistributedManager() != nullptr)\n coord_agent = ctx->GetDistributedManager()->GetCoordinationServiceAgent();\n#endif // !IS_MOBILE_PLATFORM",
" kernel->Ref(); // Ownership of reference is transferred to the callback\n kernel->RunAsync(\n ctx->StepContainer(), *inputs, outputs.get(), cancellation_manager,\n eager_func_params, coord_agent,\n [retvals, inputs, outputs, num_outputs, ctx, graph_collector,\n eager_func_params, kernel_raw = kernel.get(),\n done = std::move(done)](const Status& s) {\n auto wrapped_done = [&](const Status& s) {\n kernel_raw->Unref();\n done(s);\n };\n if (!s.ok()) {\n wrapped_done(s);\n return;\n }\n if (graph_collector != nullptr) {\n CollectGraphs(ctx);\n }\n DCHECK_EQ(num_outputs, outputs->size());\n wrapped_done(GetKernelOutputs(outputs.get(), num_outputs, retvals, ctx,\n kernel_raw, eager_func_params));\n });\n}\n} // namespace",
"// Low-level utility to run the eager operation on local devices. Different from\n// `EagerLocalExecute` which blocks and waits for the finishing the op\n// execution, this method does not block the thread and could return before the\n// eager operation execution finishes. The provided `StatusCallback` will be\n// triggered after execution with its status.\nvoid EagerLocalExecuteAsync(EagerOperation* op, TensorHandle** retvals,\n int* num_retvals, StatusCallback done) {\n if (!op->IsLocal()) {\n done(errors::InvalidArgument(\n \"Remote execution is not supported in async EagerLocalExecuteAsync\"));\n return;\n }",
" profiler::ScopedMemoryDebugAnnotation op_annotation(\n op->op_name(), op->eager_func_params().has_value()\n ? op->eager_func_params().value().step_id.value_or(0)\n : 0);\n profiler::TraceMe activity(\n [&] { return absl::StrCat(\"EagerLocalExecuteAsync: \", op->Name()); },\n profiler::TraceMeLevel::kInfo);\n EagerContext& ctx = op->EagerContext();",
" core::RefCountPtr<KernelAndDevice> kernel;\n Status s = GetOrCreateKernelAndDevice(op, retvals, num_retvals, &kernel);\n if (!s.ok()) {\n done(s);\n return;\n }",
" int num_outputs = kernel->num_outputs();\n s = ValidateInputTypeAndPlacement(&ctx, op, kernel);\n if (!s.ok()) {\n done(s);\n return;\n }",
" if (ctx.LogDevicePlacement() || VLOG_IS_ON(1)) {\n string msg = strings::StrCat(\"Executing op \", op->Name(), \" in device \",\n kernel->device()->name());\n if (!logging::LogToListeners(msg)) {\n LOG(INFO) << msg;\n }\n }",
" GraphCollector* graph_collector = nullptr;\n if (ctx.ShouldStoreGraphs()) {\n graph_collector = ctx.GetGraphCollector();\n }",
" for (int i = 0, end = num_outputs; i < end; ++i) {\n const DataTypeVector& output_dtypes = kernel->output_dtypes();\n retvals[i] = TensorHandle::CreateEmptyLocalHandle(\n /* d= */ ctx.CanonicalDevice(kernel->OutputDevice(i)),\n /* op_device= */ kernel->device(),\n /* resource_device= */ kernel->OutputResourceDevice(i),\n output_dtypes[i], &ctx);\n }",
" const absl::InlinedVector<TensorHandle*, 4>* inputs;\n s = op->TensorHandleInputs(&inputs);\n if (!s.ok()) {\n done(s);\n return;\n }\n EagerKernelExecuteAsync(\n &ctx, *inputs, op->eager_func_params(), std::move(kernel),\n graph_collector, op->GetCancellationManager(), retvals, num_outputs,\n [op, num_outputs, retvals, done = std::move(done)](const Status& s) {\n op->Clear();\n // Since the operation failed, we need to Unref any outputs if they were\n // allocated.\n if (!s.ok()) {\n for (int i = 0, end = num_outputs; i < end; ++i) {\n if (retvals[i] != nullptr) {\n retvals[i]->Unref();\n retvals[i] = nullptr;\n }\n }\n }\n done(s);\n });\n}\n} // 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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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": [306], "buggy_code_start_loc": [306], "filenames": ["tensorflow/core/common_runtime/eager/execute.cc"], "fixing_code_end_loc": [310], "fixing_code_start_loc": [307], "message": "TensorFlow is an open source platform for machine learning. Prior to versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4, multiple TensorFlow operations misbehave in eager mode when the resource handle provided to them is invalid. In graph mode, it would have been impossible to perform these API calls, but migration to TF 2.x eager mode opened up this vulnerability. If the resource handle is empty, then a reference is bound to a null pointer inside TensorFlow codebase (various codepaths). This is undefined behavior. Versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4 contain a patch for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "D9359D32-D090-44CF-AC43-2046084A28BB", "versionEndExcluding": "2.6.4", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "C4DFBF2D-5283-42F6-8800-D653BFA5CE82", "versionEndExcluding": "2.7.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.7.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.7.0:rc0:*:*:*:*:*:*", "matchCriteriaId": "A58EDA5C-66D6-46F1-962E-60AFB7C784A7", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.7.0:rc1:*:*:*:*:*:*", "matchCriteriaId": "89522760-C2DF-400D-9624-626D8F160CBA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.8.0:-:*:*:*:*:*:*", "matchCriteriaId": "E9EA1898-ACAA-4699-8BAE-54D62C1819FB", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.8.0:rc0:*:*:*:*:*:*", "matchCriteriaId": "130DE3C9-6842-456F-A259-BF8FF8457217", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.8.0:rc1:*:*:*:*:*:*", "matchCriteriaId": "BBF2FCEF-989C-409D-9F4C-81418C65B972", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.9.0:rc0:*:*:*:*:*:*", "matchCriteriaId": "9CFB1CFC-579D-4647-A472-6DE8BE1951DE", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.9.0:rc1:*:*:*:*:*:*", "matchCriteriaId": "F3F3F37E-D27F-4060-830C-0AFF16150777", "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. Prior to versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4, multiple TensorFlow operations misbehave in eager mode when the resource handle provided to them is invalid. In graph mode, it would have been impossible to perform these API calls, but migration to TF 2.x eager mode opened up this vulnerability. If the resource handle is empty, then a reference is bound to a null pointer inside TensorFlow codebase (various codepaths). This is undefined behavior. Versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4 contain a patch for this issue."}, {"lang": "es", "value": "TensorFlow es una plataforma de c\u00f3digo abierto para el aprendizaje autom\u00e1tico. En versiones anteriores a 2.9.0, 2.8.1, 2.7.2 y 2.6.4, varias operaciones de TensorFlow se comportaban inapropiadamente en modo eager cuando el manejador de recursos que les era proporcionado no era v\u00e1lido. En el modo gr\u00e1fico, habr\u00eda sido imposible llevar a cabo estas llamadas a la API, pero la migraci\u00f3n al modo eager de TF 2.x abri\u00f3 esta vulnerabilidad. Si el manejador de recursos est\u00e1 vac\u00edo, entonces una referencia est\u00e1 ligada a un puntero null dentro de la base de c\u00f3digo de TensorFlow (varios codepaths). Esto es un comportamiento no definido. Las versiones 2.9.0, 2.8.1, 2.7.2 y 2.6.4 contienen un parche para este problema"}], "evaluatorComment": null, "id": "CVE-2022-29207", "lastModified": "2022-06-02T18:12:21.637", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 2.1, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:L/AC:L/Au:N/C:N/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 2.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"}, {"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": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-05-20T22:16:40.997", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/a5b89cd68c02329d793356bda85d079e9e69b4e7"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/dbdd98c37bc25249e8f288bd30d01e118a7b4498"}, {"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/releases/tag/v2.6.4"}, {"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/releases/tag/v2.7.2"}, {"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/releases/tag/v2.8.1"}, {"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/releases/tag/v2.9.0"}, {"source": "security-advisories@github.com", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-5wpj-c6f7-24x8"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-20"}, {"lang": "en", "value": "CWE-475"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/tensorflow/tensorflow/commit/a5b89cd68c02329d793356bda85d079e9e69b4e7"}, "type": "CWE-20"}
| 216
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/* Copyright 2018 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==============================================================================*/",
"#include \"tensorflow/core/common_runtime/eager/execute.h\"",
"#include <cstddef>\n#include <vector>",
"// clang-format off\n// Required for IS_MOBILE_PLATFORM\n#include \"absl/container/btree_map.h\"\n#include \"absl/container/flat_hash_set.h\"\n#include \"absl/strings/str_replace.h\"\n#include \"tensorflow/core/common_runtime/eager/eager_operation.h\"\n#include \"tensorflow/core/framework/cancellation.h\"\n#include \"tensorflow/core/framework/function.pb.h\"\n#include \"tensorflow/core/framework/node_def.pb.h\"\n#include \"tensorflow/core/framework/op.h\"\n#include \"tensorflow/core/framework/op_kernel.h\"\n#include \"tensorflow/core/framework/tensor_shape.h\"\n#include \"tensorflow/core/lib/core/refcount.h\"\n#include \"tensorflow/core/platform/errors.h\"\n#include \"tensorflow/core/platform/platform.h\"\n#include \"tensorflow/core/platform/protobuf.h\"",
"// clang-format on",
"#include \"absl/container/inlined_vector.h\"\n#include \"absl/strings/match.h\"\n#include \"absl/strings/str_cat.h\"\n#include \"absl/types/optional.h\"\n#include \"tensorflow/c/tf_tensor_internal.h\"\n#include \"tensorflow/compiler/jit/defs.h\"\n#include \"tensorflow/core/common_runtime/colocation_graph.h\"\n#include \"tensorflow/core/common_runtime/device.h\"\n#include \"tensorflow/core/common_runtime/device_set.h\"\n#include \"tensorflow/core/common_runtime/eager/context.h\"\n#include \"tensorflow/core/common_runtime/eager/copy_to_device_node.h\"\n#include \"tensorflow/core/common_runtime/eager/execute_node.h\"\n#include \"tensorflow/core/common_runtime/eager/kernel_and_device.h\"\n#include \"tensorflow/core/common_runtime/eager/tensor_handle.h\"\n#include \"tensorflow/core/framework/dataset.h\"\n#include \"tensorflow/core/framework/function.h\"\n#include \"tensorflow/core/framework/logging.h\"\n#include \"tensorflow/core/framework/node_def_util.h\"\n#include \"tensorflow/core/framework/tensor_reference.h\"\n#include \"tensorflow/core/framework/types.pb.h\"\n#include \"tensorflow/core/lib/core/errors.h\"\n#include \"tensorflow/core/platform/statusor.h\"\n#include \"tensorflow/core/profiler/lib/scoped_memory_debug_annotation.h\"\n#include \"tensorflow/core/profiler/lib/traceme.h\"\n#include \"tensorflow/core/protobuf/error_codes.pb.h\"\n#include \"tensorflow/core/util/device_name_utils.h\"\n#if !defined(IS_MOBILE_PLATFORM)\n#include \"tensorflow/core/distributed_runtime/eager/eager_client.h\"\n#include \"tensorflow/core/distributed_runtime/eager/remote_copy_node.h\"\n#include \"tensorflow/core/distributed_runtime/eager/remote_mgr.h\"\n#include \"tensorflow/core/distributed_runtime/eager/remote_execute_node.h\"\n#include \"tensorflow/core/protobuf/remote_tensor_handle.pb.h\"\n#endif // IS_MOBILE_PLATFORM\n#include \"tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h\"\n#include \"tensorflow/core/framework/step_stats.pb.h\"\n#include \"tensorflow/core/framework/tensor.h\"\n#include \"tensorflow/core/framework/types.h\"\n#include \"tensorflow/core/lib/core/status.h\"\n#include \"tensorflow/core/lib/gtl/cleanup.h\"\n#include \"tensorflow/core/lib/gtl/flatset.h\"\n#include \"tensorflow/core/lib/random/random.h\"\n#include \"tensorflow/core/platform/env.h\"\n#include \"tensorflow/core/platform/mutex.h\"\n#include \"tensorflow/core/util/ptr_util.h\"\n#include \"tensorflow/core/util/util.h\"",
"#ifdef INTEL_MKL\n#include \"tensorflow/core/graph/mkl_graph_util.h\"\n#endif",
"namespace tensorflow {",
"namespace {",
"const string& DeviceNameOrUnspecified(Device* device) {\n static string* unspecified_string = new string(\"<unspecified>\");\n return (device == nullptr) ? *unspecified_string : device->name();\n}",
"// Returns whether a kernel should be cached.\nbool KernelCacheEnabled(const OpDef& op_def) {\n if (data::DatasetOpKernel::IsDatasetOp(op_def)) {\n return false;\n }\n // TODO(b/162540360): Revisit a way to mark kernels as uncachable once we have\n // 5+ kernels to exclude.\n return true;\n}",
"// This function expects *handle to point to an existing tensor handle that is\n// currently on \"handle_device\", but where the operation expects that input to\n// reside on \"expected_input_device\". The function will arrange for this\n// transfer to happen and will return OK on success and will storage a new\n// handle to the equivalent tensor on the correct device in \"*result\". Or if an\n// error is encountered, it will return a non-OK status and set \"*result\" to\n// nullptr.\n//\n// `op_device` is passed in explicitly because `op->device()` might be\n// unset and we might have selected some specific device to run this op on.\nStatus CopyInputToExpectedDevice(EagerContext* ctx, EagerOperation* op,\n Device* op_device,\n TensorHandle* handle, // op->Inputs()[i]\n int i, Device* handle_device,\n Device* expected_input_device,\n TensorHandle** result) {\n VLOG(6) << \"Expected input device: \" << expected_input_device->name()\n << \"; handle_device: \" << handle_device->name();\n // Should only be called when these don't match\n DCHECK(expected_input_device != handle_device);\n *result = nullptr;\n const string& op_device_name = DeviceNameOrUnspecified(op_device);",
" switch (ctx->GetDevicePlacementPolicy()) {\n case DEVICE_PLACEMENT_SILENT_FOR_INT32:\n // TODO(xpan): See if we could bubble python related error up\n // to python level.\n if (handle->dtype == DT_INT32) {\n // Note: enabling silent copies of int32 tensors to match behavior\n // of graph mode.\n break;\n }\n VLOG(6) << \"DevicePlacementPolicy: DEVICE_PLACEMENT_SILENT_FOR_INT32 but \"\n \"input type is not INT32.\";\n TF_FALLTHROUGH_INTENDED;\n case DEVICE_PLACEMENT_EXPLICIT:\n // tf.identity is allowed to copy, as indicated in the error message\n // below.\n if (op->Name() == \"Identity\" ||\n op->Name() == \"IdentityN\"\n // Constants start on CPU:0 and are copied via EagerConst to the\n // current device.\n || op->Name() == \"_EagerConst\") {\n break;\n }\n return errors::InvalidArgument(\n \"Tensors on conflicting devices:\"\n \" cannot compute \",\n op->Name(), \" as input #\", i, \" was expected to be on \",\n expected_input_device->name(), \" but is actually on \",\n handle_device->name(), \" (operation running on \", op_device_name, \")\",\n \" Tensors can be copied explicitly using:\"\n \" `with tf.device(device_name): x = tf.identity(x)`\"\n \" or transparently copied by using\"\n \" tf.config.experimental.set_device_policy('silent').\"\n \" Copying tensors between devices may slow down your model\");\n case DEVICE_PLACEMENT_WARN:\n LOG(WARNING) << \"before computing \" << op->Name() << \" input #\" << i\n << \" was expected to be on \" << expected_input_device->name()\n << \" but is actually on \" << handle_device->name()\n << \" (operation running on \" << op_device_name\n << \"). This triggers a copy which can be a performance \"\n \"bottleneck.\";\n break;\n case DEVICE_PLACEMENT_SILENT: // Do nothing.\n break;\n }\n // We are only here if the policy is warn or silent copies, so we should\n // trigger a copy.\n TensorHandle* result_handle = nullptr;\n profiler::TraceMe activity(\n [&] {\n return absl::StrCat(\"_Send input \", i, \" from \", handle_device->name(),\n \" to \", expected_input_device->name());\n },\n profiler::TraceMeLevel::kInfo);\n Status status =\n EagerCopyToDevice(handle, ctx, &op->Executor(), expected_input_device,\n /* mirror= */ true, &result_handle);\n activity.Stop();\n if (!status.ok()) {\n return Status(\n status.code(),\n absl::StrCat(\"Failed copying input tensor from \", handle_device->name(),\n \" to \", expected_input_device->name(), \" in order to run \",\n op->Name(), \": \", status.error_message()));\n }",
" *result = result_handle;",
" return Status::OK();\n}",
"// `op_device_name` the name of the device on which the op will run, if any.\n// For functions running using function library runtime, the device can be\n// unspecified.\nStatus ValidateInputTypeAndPlacement(\n EagerContext* ctx, EagerOperation* op,\n const core::RefCountPtr<KernelAndDevice>& kernel) {\n profiler::TraceMe activity(\"ValidateInputTypeAndPlacement\",\n profiler::TraceMeLevel::kInfo);\n const int n_inputs = op->Inputs().size();\n if (kernel->num_inputs() != n_inputs) {\n return errors::InvalidArgument(\"expected \", kernel->num_inputs(),\n \" inputs, got \", n_inputs);\n }\n const bool is_function = kernel->IsFunction();\n if (n_inputs > 0) {\n const DataType* input_types = &kernel->input_dtypes()[0];\n const absl::InlinedVector<TensorHandle*, 4>* handles;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&handles));\n for (int i = 0; i < n_inputs; ++i) {\n TensorHandle* handle = (*handles)[i];\n Device* expected_device = kernel->InputDevice(i);\n if (!kernel->IsFunction() && handle->Type() == TensorHandle::PACKED) {\n // Extract a handle on the op device from a packed input.\n // This happens when a function is marked for XLA compilation.\n // MaybePackInputTensor guarantees that a primitive op has no packed\n // input at this point.\n for (int j = 0; j < handle->NumPackedHandles(); ++j) {\n TensorHandle* h = nullptr;\n TF_RETURN_IF_ERROR(handle->ExtractPackedHandle(j, &h));\n if ((h->op_device() != nullptr) &&\n (h->op_device()->name() == op->DeviceName())) {\n op->UpdateInput(i, h);\n handle = h;\n break;\n }\n }\n }\n Device* handle_device = handle->DeviceOrHostCPU(*ctx);\n const bool maybe_copy =\n !is_function || handle->Type() != TensorHandle::REMOTE;\n VLOG(6) << \"!is_function: \" << !is_function;\n VLOG(6) << \"handle->Type(): \" << handle->Type();\n // If the input is already on the right device, then nothing to do.\n if (expected_device != handle_device && maybe_copy) {\n TF_RETURN_IF_ERROR(CopyInputToExpectedDevice(ctx, op, kernel->device(),\n handle, i, handle_device,\n expected_device, &handle));\n op->UpdateInput(i, handle);\n // Unref handle since it has a ref as an input now\n handle->Unref();\n }\n if (handle->dtype != input_types[i]) {\n return errors::InvalidArgument(\n \"cannot compute \", op->Name(), \" as input #\", i, \"(zero-based)\",\n \" was expected to be a \", DataTypeString(input_types[i]),\n \" tensor but is a \", DataTypeString(handle->dtype), \" tensor\");\n }\n }\n }\n return Status::OK();\n}",
"Status GetOutputDTypes(EagerOperation* op, DataTypeVector* output_dtypes) {\n const auto& node_def = op->MutableAttrs()->BuildNodeDef();\n const OpDef* op_def = nullptr;",
" const FunctionDef* function_def =\n op->EagerContext().FuncLibDef()->Find(op->Name());\n if (function_def != nullptr) {\n op_def = &(function_def->signature());\n } else {\n TF_RETURN_IF_ERROR(OpDefForOp(op->Name().c_str(), &op_def));\n }",
" TF_RETURN_IF_ERROR(OutputTypesForNode(node_def, *op_def, output_dtypes));",
" return Status::OK();\n}",
"inline tensorflow::Fprint128 FingerprintCat128(const tensorflow::Fprint128& a,\n const tensorflow::Fprint128& b) {\n return {tensorflow::FingerprintCat64(a.low64, b.low64),\n tensorflow::FingerprintCat64(a.high64, b.high64)};\n}",
"inline tensorflow::Fprint128 FingerprintCat128(const tensorflow::Fprint128& a,\n const int64_t b) {\n auto x = tensorflow::FingerprintCat64(a.low64, b);\n return {x, tensorflow::FingerprintCat64(a.high64, x)};\n}",
"Status GetDeviceForInput(const EagerOperation& op, const EagerContext& ctx,\n TensorHandle* tensor_handle, Device** result) {\n Device* cpu_device = ctx.HostCPU();\n string device_name;\n if (tensor_handle->Type() != TensorHandle::LOCAL) {\n Device* device = tensor_handle->device();\n device_name = device != nullptr ? device->name() : cpu_device->name();\n *result = (device == nullptr ? cpu_device : device);\n } else if (tensor_handle->dtype == DT_RESOURCE) {\n // Use the resource's actual device because it is the device that will\n // influence partitioning the multi-device function.\n const Tensor* tensor;\n // TODO(fishx): Avoid blocking here.\n TF_RETURN_IF_ERROR(tensor_handle->Tensor(&tensor));",
" if (tensor->NumElements() == 0) {\n return errors::InvalidArgument(\"Empty resource handle\");\n }",
" const ResourceHandle& handle = tensor->flat<ResourceHandle>()(0);\n device_name = handle.device();",
" Device* input_device;\n TF_RETURN_IF_ERROR(\n ctx.FindDeviceFromName(device_name.c_str(), &input_device));\n *result = input_device;\n } else {\n Device* device = tensor_handle->device();\n const bool is_tpu = device != nullptr && device->device_type() == \"TPU\";\n // int32 return values can be placed on TPUs.\n const bool use_host_memory =\n is_tpu ? MTypeFromDTypeIntsOnDevice(tensor_handle->dtype)\n : MTypeFromDType(tensor_handle->dtype);\n if (use_host_memory) {\n *result = cpu_device;\n } else {\n // Eager ops executing as functions should have their preferred inputs set\n // to the op's device. This allows us to avoid expensive D2H copies if a\n // mirror of the tensor already exists on the op's device.\n if (!op.is_function() && device != nullptr && device != cpu_device) {\n device = absl::get<Device*>(op.Device());\n }\n *result = (device == nullptr ? cpu_device : device);\n }\n }\n return Status::OK();\n}",
"// Appends a TensorShape object to Fprint128 hash.\n// For best performance, we would like to avoid dynamic memory allocation in\n// this function.\n// If \"shape\" has unknown rank, we attach \"?\" to hashed content; otherwise we\n// attach every dim size to hashed content.\nvoid AppendTensorShapeToFingerprint(const PartialTensorShape& shape,\n Fprint128* fingerprint) {\n if (shape.unknown_rank()) {\n char c = '?';\n *fingerprint = FingerprintCat128(*fingerprint, c);\n } else {\n for (int i = 0; i < shape.dims(); i++) {\n int64_t dim = shape.dim_size(i);\n *fingerprint = FingerprintCat128(*fingerprint, dim);\n }\n }\n}",
"Status GetFuncAttr(const EagerOperation* op, const EagerContext& ctx,\n const char* attr_name, bool* value) {\n Status status = op->Attrs().Get(attr_name, value);\n if (status.ok()) {\n VLOG(2) << \"Caller explicitly specifies \"\n << (attr_name ? \"=true \" : \"=false, \") << op->DebugString();\n return Status::OK();\n }",
" const FunctionDef* function_def =\n ctx.pflr()->GetFunctionLibraryDefinition()->Find(op->Name());\n if (function_def == nullptr) {\n return errors::NotFound(\"Failed to find function '\", op->Name(), \"'\");\n }",
" status = GetNodeAttr(AttrSlice(&function_def->attr()), attr_name, value);\n if (status.ok()) {\n VLOG(2) << \"Function definition explicitly specifies \"\n << (attr_name ? \"=true\" : \"=false\");\n return Status::OK();\n }\n return status;\n}",
"Status MustCompileWithXLA(const EagerOperation* op, const EagerContext& ctx,\n bool* compile_with_xla) {\n if (!op->is_function()) {\n *compile_with_xla = false;\n return Status::OK();\n }",
" if (op->eager_func_params().has_value() &&\n op->eager_func_params().value().step_id.has_value()) {\n // If the op is a component of a multi-device function, don't compile it\n // with XLA.\n *compile_with_xla = false;\n return Status::OK();\n }",
" Status status = GetFuncAttr(op, ctx, kXlaMustCompileAttr, compile_with_xla);\n if (status.ok()) {\n return Status::OK();\n }",
" // No explicit requests. Compile for XLA devices by default.\n if (op->GetDeviceParsedName().type == \"TPU\" ||\n op->GetDeviceParsedName().type == \"XLA_GPU\" ||\n op->GetDeviceParsedName().type == \"XLA_CPU\") {\n VLOG(2) << \"Compiling \" << op->Name()\n << \" with XLA because it is running on an XLA device \"\n << op->GetDeviceParsedName().type;\n *compile_with_xla = true;\n } else {\n *compile_with_xla = false;\n }",
" return Status::OK();\n}",
"Status VerifyWrappableInCallOp(const OpDef& opdef, EagerOperation* op) {\n absl::flat_hash_set<string> opdef_attrs;\n for (const auto& attr : opdef.attr()) {\n opdef_attrs.insert(attr.name());\n }\n const auto& node_def = op->MutableAttrs()->BuildNodeDef();\n for (const auto& attr : node_def.attr()) {\n if (opdef_attrs.find(attr.first) == opdef_attrs.end()) {\n return errors::Unimplemented(\"EagerOperation: \", op->Name(),\n \" has a private attr '\", attr.first, \"'.\");\n }\n }\n return Status::OK();\n}",
"using ProtoArgListType = protobuf::RepeatedPtrField<OpDef_ArgDef>;",
"string EscapeOrigName(const string& orig_name) {\n // Replace _ with __ in the original name to avoid name conflicts.\n return absl::StrReplaceAll(orig_name, {{\"_\", \"__\"}});\n}",
"// Variadic args are flattened during wrapping. This utility returns the name\n// of a flattened arg/attr.\nstring GetFlatName(const string orig_name, int index) {\n return absl::StrCat(EscapeOrigName(orig_name), \"_\", index);\n}",
"// Builds the name of the wrapping FunctionDef for an eager op.\n//\n// For ops without variadic inputs/outputs, the name is simply __wrapped_OpType.\n//\n// For ops with variadic inputs/outputs, the arity of each variadic attr is\n// encoded in the name. For example:\n//\n// IdentityN[T:[DT_FLOAT, DT_INT64]] -> __wrapped__IdentityN_T_2\n// Concat[N:2, T:DT_FLOAT] -> __wrapped__Concat_N_2\nStatus BuildWrappedOpName(EagerOperation* op, const OpDef& opdef,\n const AbstractOpAttrs* op_attrs, string* name) {\n string fname = absl::StrCat(\"__wrapped__\", EscapeOrigName(op->Name()));\n // For every variadic arg in `args`, populates `attr_to_len` with\n // (attr_name, len(arg)).\n auto FillAttrToLen = [op_attrs, op](\n const ProtoArgListType& args,\n absl::btree_map<string, int>* attr_to_len) {\n for (const auto& arg : args) {\n if (!arg.type_list_attr().empty()) {\n gtl::InlinedVector<DataType, 4> type_list;\n TF_RETURN_IF_ERROR(\n op_attrs->GetTypeList(arg.type_list_attr(), &type_list));\n (*attr_to_len)[arg.type_list_attr()] = type_list.size();\n } else if (!arg.number_attr().empty()) {\n int64_t number_attr;\n if (!op_attrs->GetInt(arg.number_attr(), &number_attr)) {\n return errors::Internal(\"Unable to read attr \", arg.number_attr(),\n \" for op \", op->Name());\n }\n (*attr_to_len)[arg.number_attr()] = number_attr;\n }\n }\n return Status::OK();\n };\n absl::btree_map<string, int> attr_to_len;\n TF_RETURN_IF_ERROR(FillAttrToLen(opdef.input_arg(), &attr_to_len));\n TF_RETURN_IF_ERROR(FillAttrToLen(opdef.output_arg(), &attr_to_len));\n for (auto& name_len : attr_to_len) {\n absl::StrAppend(&fname, \"_\", name_len.first, \"_\", name_len.second);\n }\n // The NodeDef in the FunctionDef gets placed on `op-DeviceName()` to ensure\n // placement consistency with eager mode.\n // TODO(b/200153278): Ideally we would just forward the call op's device at\n // runtime but currently there is no way to do it so we incur the cost of\n // creating extra FunctionDefs.\n absl::StrAppend(&fname, \"_device_\", op->DeviceName());\n *name = fname;\n return Status::OK();\n}",
"// Validates the node def. This is required when running in eager op as function\n// mode because this code path does not go through the _apply_op_helper's\n// validation (which is reached when executing in graph mode)\n// or the eager execution's validation (which is reached via the CreateOpKernel\n// call).\nStatus ValidateOp(EagerOperation* op) {\n const NodeDef& node_def = op->MutableAttrs()->BuildNodeDef();\n const OpDef* op_def;\n TF_RETURN_IF_ERROR(OpRegistry::Global()->LookUpOpDef(node_def.op(), &op_def));\n return ValidateNodeDef(node_def, *op_def);\n}",
"// Builds the signature of the wrapping FunctionDef for an eager op.\n//\n// For ops without variadic inputs/outputs, the signature is the same as the\n// OpDef of the original op.\n//\n// Variadic inputs/outputs get flattened since we do not support executing\n// functions with variadic signatures.\n//\n// TODO(srbs): These examples should be tests.\n//\n// Examples:\n//\n// Mixed type list:\n//\n// op {\n// name: \"IdentityN\"\n// input_arg {\n// name: \"input\"\n// type_list_attr: \"T\"\n// }\n// output_arg {\n// name: \"output\"\n// type_list_attr: \"T\"\n// }\n// attr {\n// name: \"T\"\n// type: \"list(type)\"\n// has_minimum: true\n// minimum: 1\n// }\n// }\n//\n// With two inputs T=[DT_FLOAT, DT_INT64] would convert to\n//\n// op {\n// name: \"__wrapped__IdentityN_T_2\"\n// input_arg {\n// name: \"input_0\"\n// type_attr: \"T_0\"\n// }\n// input_arg {\n// name: \"input_1\"\n// type_attr: \"T_1\"\n// }\n// output_arg {\n// name: \"output_0\"\n// type_attr: \"T_0\"\n// }\n// output_arg {\n// name: \"output_1\"\n// type_attr: \"T_1\"\n// }\n// attr {\n// name: \"T_0\"\n// type: \"type\"\n// }\n// attr {\n// name: \"T_1\"\n// type: \"type\"\n// }\n// attr {\n// name: \"T\"\n// type: \"list(type)\"\n// has_minimum: true\n// minimum: 1\n// }\n// }\n//\n// Note that the list(type) attr is preserved so that it can get copied to the\n// inner op via a placeholder. This allows additional verification.\n//\n// Single type list:\n//\n// op {\n// name: \"ConcatV2\"\n// input_arg {\n// name: \"values\"\n// type_attr: \"T\"\n// number_attr: \"N\"\n// }\n// attr {\n// name: \"N\"\n// type: \"int\"\n// has_minimum: true\n// minimum: 2\n// }\n// attr {\n// name: \"T\"\n// type: \"type\"\n// }\n// [axis, output, Tidx are simply copied]\n// }\n//\n// With two inputs N=2 would convert to:\n//\n// op {\n// name: \"__wrapped__ConcatV2_N_2\"\n// input_arg {\n// name: \"values_0\"\n// type_attr: \"T\"\n// }\n// input_arg {\n// name: \"values_1\"\n// type_attr: \"T\"\n// }\n// attr {\n// name: \"N\"\n// type: \"int\"\n// has_minimum: true\n// minimum: 2\n// }\n// attr {\n// name: \"T\"\n// type: \"type\"\n// }\n// [axis, output, Tidx are simply copied]\n// }\n//\n// Note that the N attr is preserved so that it can get copied to the\n// inner op via a placeholder. This allows additional verification.\nStatus BuildWrappedOpSignature(EagerOperation* op, const OpDef& opdef,\n const string& fname, OpDef& signature) {\n signature = opdef;\n signature.clear_input_arg();\n signature.clear_output_arg();\n signature.set_name(fname);\n auto op_attrs = op->GetOpAttrs();\n auto FillSignatureArgs = [op_attrs, op](\n const ProtoArgListType& opdef_args,\n ProtoArgListType* sig_args,\n absl::flat_hash_set<string>& new_attrs) {\n for (const auto& arg : opdef_args) {\n if (!arg.type_list_attr().empty()) {\n gtl::InlinedVector<DataType, 4> type_list;\n TF_RETURN_IF_ERROR(\n op_attrs->GetTypeList(arg.type_list_attr(), &type_list));\n for (size_t i = 0; i < type_list.size(); i++) {\n auto arg_def = sig_args->Add();\n arg_def->set_name(GetFlatName(arg.name(), i));\n auto attr_name = GetFlatName(arg.type_list_attr(), i);\n new_attrs.insert(attr_name);\n arg_def->set_type_attr(std::move(attr_name));\n }\n } else if (!arg.number_attr().empty()) {\n int64_t number_attr;\n if (!op_attrs->GetInt(arg.number_attr(), &number_attr)) {\n return errors::Internal(\"Unable to read attr \", arg.number_attr(),\n \" for op \", op->Name());\n }\n for (int64_t i = 0; i < number_attr; i++) {\n auto arg_def = sig_args->Add();\n arg_def->set_name(GetFlatName(arg.name(), i));\n if (!arg.type_attr().empty()) {\n arg_def->set_type_attr(arg.type_attr());\n } else {\n arg_def->set_type(arg.type());\n }\n }\n } else {\n auto arg_def = sig_args->Add();\n *arg_def = arg;\n arg_def->set_name(EscapeOrigName(arg.name()));\n if (!arg.type_attr().empty()) {\n // Don't escape: type attrs are still referenced by the original name.\n arg_def->set_type_attr(arg.type_attr());\n }\n }\n }\n return Status::OK();\n };\n absl::flat_hash_set<string> new_attrs;\n TF_RETURN_IF_ERROR(FillSignatureArgs(\n opdef.input_arg(), signature.mutable_input_arg(), new_attrs));\n TF_RETURN_IF_ERROR(FillSignatureArgs(\n opdef.output_arg(), signature.mutable_output_arg(), new_attrs));\n for (auto& attr_name : new_attrs) {\n auto attr_def = signature.mutable_attr()->Add();\n attr_def->set_name(attr_name);\n attr_def->set_type(\"type\");\n }\n return Status::OK();\n}",
"// For mixed type inputs \"list(type)\" we create new attributes in the signature\n// for each element tensor (See examples in BuildWrappedOpSignature). Here\n// we construct the values for those attributes and set them on the wrapped op.\nStatus AddMixedTypeListAttrs(EagerOperation* wrapped_op,\n const AbstractOpAttrs* op_attrs,\n const OpDef& opdef) {\n auto FillAttrsToAdd =\n [op_attrs](const ProtoArgListType& opdef_args,\n absl::flat_hash_map<string, DataType>* attrs_to_add) {\n for (const auto& arg : opdef_args) {\n if (!arg.type_list_attr().empty()) {\n gtl::InlinedVector<DataType, 4> type_list;\n TF_RETURN_IF_ERROR(\n op_attrs->GetTypeList(arg.type_list_attr(), &type_list));\n for (size_t i = 0; i < type_list.size(); i++) {\n auto attr_name = GetFlatName(arg.type_list_attr(), i);\n (*attrs_to_add)[attr_name] = type_list[i];\n }\n }\n }\n return Status::OK();\n };\n absl::flat_hash_map<string, DataType> attrs_to_add;\n TF_RETURN_IF_ERROR(FillAttrsToAdd(opdef.input_arg(), &attrs_to_add));\n TF_RETURN_IF_ERROR(FillAttrsToAdd(opdef.output_arg(), &attrs_to_add));\n for (auto& name_type : attrs_to_add) {\n TF_RETURN_IF_ERROR(\n wrapped_op->SetAttrType(name_type.first.data(), name_type.second));\n }\n // TODO(srbs): Rename all original attributes using EscapeOrigName.\n return Status::OK();\n}",
"// Maps the op's outputs to the function outputs. Mainly useful for variadic\n// outputs which need to be flattened.\nStatus PopulateRetMap(FunctionDef* fdef, const AbstractOpAttrs* op_attrs,\n const EagerOperation* op, const OpDef& opdef,\n const OpDef& signature, const string& node_name) {\n int next_sig_output = 0;\n for (size_t i = 0; i < opdef.output_arg_size(); i++) {\n const auto& output_arg = opdef.output_arg(i);\n if (!output_arg.type_list_attr().empty()) {\n gtl::InlinedVector<DataType, 4> type_list;\n TF_RETURN_IF_ERROR(\n op_attrs->GetTypeList(output_arg.type_list_attr(), &type_list));\n for (int j = 0; j < type_list.size(); j++) {\n (*fdef->mutable_ret())[signature.output_arg(next_sig_output++).name()] =\n absl::StrCat(node_name, \":\", output_arg.name(), \":\", j);\n }\n } else if (!output_arg.number_attr().empty()) {\n int64_t number_attr;\n if (!op_attrs->GetInt(output_arg.number_attr(), &number_attr)) {\n return errors::Internal(\"Unable to read attr \",\n output_arg.number_attr(), \" for op \",\n op->Name());\n }\n for (int j = 0; j < number_attr; j++) {\n (*fdef->mutable_ret())[signature.output_arg(next_sig_output++).name()] =\n absl::StrCat(node_name, \":\", output_arg.name(), \":\", j);\n }\n } else {\n (*fdef->mutable_ret())[signature.output_arg(next_sig_output++).name()] =\n absl::StrCat(node_name, \":\", output_arg.name(), \":0\");\n }\n }\n return Status::OK();\n}",
"#ifdef INTEL_MKL\ninline void GetMKLNodeDef(NodeDef* ndef) {\n // All MKL eager ops have `_kernel` private attribute that needs to be set\n // to a fixed label.\n AttrValue attr_kernel;\n attr_kernel.set_s(mkl_op_registry::kMklNameChangeOpLabel);\n (*ndef->mutable_attr()).insert({\"_kernel\", attr_kernel});\n}\n#endif // INTEL_MKL",
"Status WrapInCallOp(EagerOperation* op, EagerOperation** wrapped_op) {\n DCHECK(!op->is_function());\n const OpDef& opdef = OpRegistry::Global()->LookUp(op->Name())->op_def;\n // Raise an error for ops which don't support wrapping yet. This includes\n // ops with list inputs/outputs and ops with private attrs.\n // TODO(srbs): Support list inputs/outputs.\n TF_RETURN_IF_ERROR(VerifyWrappableInCallOp(opdef, op));",
" // Build a FunctionDef containing op as a node and register with context.\n // TODO(srbs): Here we are unable to distinguish between a FunctionDef for\n // a wrapped eager op and an existing user defined function registered with\n // the context e.g. with something like\n // @tf.function\n // def __wrapped__Add(x, y):\n // ...\n // This can be avoided by introducing a dict in EagerContext that stores a\n // mapping from the eager op's name to its unique FunctionDef name.\n auto op_attrs = op->GetOpAttrs();\n string fname;\n TF_RETURN_IF_ERROR(BuildWrappedOpName(op, opdef, op_attrs, &fname));\n if (!op->EagerContext().GetFunctionDef(fname)) {\n FunctionDef fdef;\n // Set signature.\n TF_RETURN_IF_ERROR(\n BuildWrappedOpSignature(op, opdef, fname, *fdef.mutable_signature()));\n // Add node.\n NodeDef* ndef = fdef.add_node_def();\n ndef->set_op(op->Name());\n ndef->set_name(op->Name()); // This could be anything.\n const auto& signature = fdef.signature();\n for (size_t i = 0; i < signature.input_arg_size(); i++) {\n ndef->add_input(absl::StrCat(fdef.signature().input_arg(i).name(), \":0\"));\n }\n // TODO(srbs): Private attrs on the op are dropped here and applied to\n // the call op instead. If this causes problems we might have to copy those\n // attrs to this ndef. That would require updating fname to contain a hash\n // of such attributes.\n for (const auto& attr : opdef.attr()) {\n (*ndef->mutable_attr())[attr.name()].set_placeholder(attr.name());\n }\n // Set the device of this node to be the exact same one that eager mode\n // would have used.\n // TODO(b/200153278): Ideally we would just forward the call op's device at\n // runtime but currently there is no way to do it.\n ndef->set_device(op->DeviceName());",
"#ifdef INTEL_MKL\n if (IsMKLEnabled() &&\n absl::StartsWith(op->Name(), mkl_op_registry::kMklOpPrefix)) {\n GetMKLNodeDef(ndef);\n }\n#endif // INTEL_MKL",
" // Set `ret` map.\n TF_RETURN_IF_ERROR(\n PopulateRetMap(&fdef, op_attrs, op, opdef, signature, ndef->name()));\n VLOG(1) << fdef.DebugString();\n TF_RETURN_IF_ERROR(op->EagerContext().AddFunctionDef(std::move(fdef)));\n }\n // Build the call op.\n auto& ctx = op->EagerContext();\n AbstractOperationPtr call_op(ctx.CreateOperation());\n TF_RETURN_IF_ERROR(call_op->Reset(fname.c_str(), op->DeviceName().c_str()));\n for (auto t : op->Inputs()) {\n TF_RETURN_IF_ERROR(call_op->AddInput(t));\n }\n *wrapped_op = down_cast<EagerOperation*>(call_op.release());\n // Attributes on the elementary eager operation are applied to the call op and\n // to the NodeDef inside the FunctionDef. This allows us to have a single\n // FunctionDef for different attribute values. When the function is\n // instantiated, these attributes get forwarded to the NodeDef. This is done\n // by setting the AttrValue.placeholder field for the NodeDef attrs.\n (*wrapped_op)->AddAttrs(op_attrs);\n return AddMixedTypeListAttrs(*wrapped_op, op_attrs, opdef);\n}",
"bool IntArgsAndRetvalsOnDevice(EagerOperation* op) {\n // Most TF ops expect and generate int32 tensors on the host (or a TPU/XLA\n // device). This is not the case with IteratorGetNext since it is possible to\n // build int32 datasets that produce outputs on device when using\n // prefetch_to_device.\n // When running call ops, by default we assume that the int32 outputs are on a\n // host (except for the XLA/TPU case). So we need to special case\n // IteratorGetNext such that its eager behavior matches the wrapped one.\n // TODO(b/208435025): Remove this if we end up deciding that int32 outputs\n // from IteratorGetNext should indeed live on host.\n return op->Name() == \"IteratorGetNext\";\n}",
"StatusOr<Fprint128> GetKernelCacheKey(\n const EagerOperation& op, const Fprint128& op_cache_key,\n const std::vector<Device*>& input_dev_ptrs,\n const std::unordered_map<int, DtypeAndPartialTensorShape>&\n input_resource_variable_dtypes_and_shapes) {\n EagerContext& ctx = op.EagerContext();",
" Fprint128 cache_key = op_cache_key;\n /// Include soft placement policy in cache key since the placement strategy\n // can change and thus affect which kernel is picked.\n cache_key = FingerprintCat128(cache_key, ctx.AllowSoftPlacement());",
" // Include run_eager_op_as_function policy in cache key since the execution\n // strategy can change and affect which kernel is picked.\n VLOG(3) << \"ctx.RunEagerOpAsFunction(): \" << ctx.RunEagerOpAsFunction();\n cache_key = FingerprintCat128(cache_key, ctx.RunEagerOpAsFunction());",
" // When running in eager_op_as_function mode Send/Recv ops need to be\n // placed on the same rendezvous to match the behaviour of eager mode.\n bool reuse_rendezvous_for_functions =\n (ctx.RunEagerOpAsFunction() && !op.is_function()) ||\n ctx.GetReuseRendezvousForFunctions();\n // The launch-time rendezvous reuse setting is bundled with the kernel, so we\n // need to include it in the cache key.\n cache_key = FingerprintCat128(cache_key, reuse_rendezvous_for_functions);",
" for (int i = 0, end = input_dev_ptrs.size(); i < end; ++i) {\n cache_key =\n FingerprintCat128(cache_key, Fingerprint128(input_dev_ptrs[i]->name()));",
" auto input_resource = input_resource_variable_dtypes_and_shapes.find(i);\n if (input_resource != input_resource_variable_dtypes_and_shapes.end()) {\n // const DtypeAndPartialTensorShape& dtype_and_shape\n const DtypeAndPartialTensorShape& dtype_and_shape =\n input_resource->second;\n // Add _Arg index, dtype and shape to \"cache_key\".\n cache_key = FingerprintCat128(cache_key, i);\n cache_key = FingerprintCat128(cache_key, dtype_and_shape.dtype);\n AppendTensorShapeToFingerprint(dtype_and_shape.shape, &cache_key);\n }\n }",
" return cache_key;\n}",
"Status SetOpDevice(EagerContext& ctx, EagerOperation* op, Device** device) {\n // Here in local execute, set preferred device to be on the local task to\n // avoid placing op on a remote device with higher priority.\n const DeviceNameUtils::ParsedName& preferred_device =\n DeviceNameUtils::HasSomeDetails(op->GetDeviceParsedName())\n ? op->GetDeviceParsedName()\n : DeviceNameUtils::AddressSpace(ctx.HostCPUParsedName());\n // Note: We use the unwrapped op for inferring the device.\n // Without this, when wrapping CPU-only ops like RangeDataset we would\n // place the wrapped op on a GPU (if one is available) which leads to\n // errors because placer pins the function output nodes to GPU thereby\n // forcing a H2D copy of the dataset variant which is not supported.\n auto ndef = op->MutableAttrs()->BuildNodeDef();\n#ifdef INTEL_MKL\n if (IsMKLEnabled() &&\n absl::StartsWith(op->Name(), mkl_op_registry::kMklOpPrefix)) {\n GetMKLNodeDef(&ndef);\n }\n#endif // INTEL_MKL",
" TF_RETURN_IF_ERROR(ctx.SelectDevice(preferred_device, ndef, device));",
" VLOG(1) << \"PreferredDevice \" << op->Name() << \": \" << preferred_device;\n VLOG(1) << \"Placer place op [\" << op->Name()\n << \"] on device: \" << (*device)->name();\n VLOG(4) << \"Available kernels for \" << op->Name() << \" are\"\n << KernelsRegisteredForOp(op->Name());\n op->SetDevice(*device);\n return Status::OK();\n}",
"Fprint128 GetDeviceCacheKey(EagerOperation* op, const EagerContext& ctx) {\n Fprint128 device_cache_key = op->MutableAttrs()->CacheKey(op->DeviceName());\n device_cache_key =\n FingerprintCat128(device_cache_key, ctx.AllowSoftPlacement());\n return device_cache_key;\n}",
"Status GetOrCreateKernelAndDevice(\n EagerOperation* op, TensorHandle** retvals, int* num_retvals,\n core::RefCountPtr<KernelAndDevice>* out_kernel) {\n EagerContext& ctx = op->EagerContext();\n Device* device = absl::get<Device*>(op->Device());",
" // Set the EagerOperation's device prior to extracting the input_dev_ptrs to\n // avoid any redundant H2D/D2H copies.\n if (device == nullptr && !op->is_function()) {\n Fprint128 device_cache_key = GetDeviceCacheKey(op, ctx);\n device = ctx.GetCachedDevice(device_cache_key);\n if (device == nullptr) {\n TF_RETURN_IF_ERROR(SetOpDevice(ctx, op, &device));\n ctx.AddDeviceToCache(device_cache_key, device);\n } else {\n op->SetDevice(device);\n }\n }",
" // Save the original value of reuse_rendezvous_for_functions from the context.\n bool reuse_rendezvous_for_functions_original_value =\n ctx.GetReuseRendezvousForFunctions();\n // When running in eager_op_as_function mode Send/Recv ops need to be\n // placed on the same rendezvous to match the behaviour of eager mode.\n bool reuse_rendezvous_for_functions =\n (ctx.RunEagerOpAsFunction() && !op->is_function()) ||\n reuse_rendezvous_for_functions_original_value;",
" std::vector<Device*> input_dev_ptrs;\n absl::flat_hash_map<string, const std::vector<string>*> composite_devices;\n std::unordered_map<int, DtypeAndPartialTensorShape>\n input_resource_variable_dtypes_and_shapes;\n if (op->is_function() || ctx.RunEagerOpAsFunction()) {\n profiler::TraceMe activity(\"EagerCopyToDevice\",\n profiler::TraceMeLevel::kInfo);\n input_dev_ptrs.reserve(op->Inputs().size());\n const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n for (int i = 0, end = inputs->size(); i < end; ++i) {\n TensorHandle* input = (*inputs)[i];",
" Device* input_device;\n TF_RETURN_IF_ERROR(GetDeviceForInput(*op, ctx, input, &input_device));\n VLOG(1) << op->Name() << \":input:\" << i << \" \" << input_device->name();\n input_dev_ptrs.push_back(input_device);\n CompositeDevice* composite_device = nullptr;\n if (ctx.FindCompositeDeviceFromName(input_device->name(),\n &composite_device)\n .ok()) {\n composite_devices[input_device->name()] =\n composite_device->underlying_devices();\n }\n if (input->dtype == DT_RESOURCE) {\n // We only care about data type and shape for resource variable inputs.\n // But we have no way to tell if input is resource variable (other than\n // looking it up in ResourceMgr, which is slow). So we just get\n // resource_dtypes_and_shapes for all DT_RESOURCE inputs. If\n // resource_dtypes_and_shapes is not empty, take the first element.\n std::vector<DtypeAndPartialTensorShape> resource_dtypes_and_shapes;\n TF_RETURN_IF_ERROR(input->GetResourceHandleDtypesAndShapes(\n &resource_dtypes_and_shapes));\n if (!resource_dtypes_and_shapes.empty()) {\n const DtypeAndPartialTensorShape& dtype_and_shape =\n resource_dtypes_and_shapes.at(0);\n input_resource_variable_dtypes_and_shapes[i] = dtype_and_shape;\n }\n }\n }\n }",
" TF_ASSIGN_OR_RETURN(\n Fprint128 cache_key,\n GetKernelCacheKey(*op, op->MutableAttrs()->CacheKey(op->DeviceName()),\n input_dev_ptrs,\n input_resource_variable_dtypes_and_shapes));\n core::RefCountPtr<KernelAndDevice> kernel = ctx.GetCachedKernel(cache_key);\n AbstractOperationPtr wrapped_op_releaser;\n // We can eliminate some overhead by running simple functions using regular\n // CallOp kernel. However, it is tricky to figure out which functions should\n // be run using CallOp. Also, currently CallOp runs neither optimization\n // passes (needed for TPU/XLA) nor grappler.\n // Here are some cases where a function should be run in multi-device mode:\n // - Function takes at least two resources on different devices.\n // - Function takes a resource on deviceA and a body op explicitly placed\n // on deviceB.\n // - Function has a colocation constraint.\n // - Function has an explicit device annotation (which might not be using\n // full canonical device name) different from op_device. Note that false\n // positives are ok.\n // - Function has a node or a (node) attribute that can potentially make\n // the function multi-device after a rewrite pass (e.g. various XLA/TPU\n // special nodes and attributes)\n if (kernel == nullptr) {\n VLOG(2) << \"Creating new kernel for \" << op->Name() << \" on device \"\n << DeviceNameOrUnspecified(absl::get<Device*>(op->Device()));\n bool run_function_with_flr = false;\n bool function_outputs_on_op_device = false;\n absl::optional<string> xla_compile_device_type;\n if (op->is_function()) {\n bool compile_with_xla;\n TF_RETURN_IF_ERROR(MustCompileWithXLA(op, ctx, &compile_with_xla));\n if (compile_with_xla) {\n if (ctx.JitCompileRewrite()) {\n xla_compile_device_type = op->GetDeviceParsedName().type;\n run_function_with_flr = true;\n } else {\n // Note that it is not ideal, but currently correct, to set this\n // attribute after computing the kernel cache key above.\n // Note: If the attribute is already set to true, this is a noop.\n op->MutableAttrs()->Set(kXlaMustCompileAttr, true);\n }\n } else {\n run_function_with_flr = true;\n }\n GetFuncAttr(op, ctx, kOutputsOnOpDevice, &function_outputs_on_op_device)\n .IgnoreError();\n }",
" VLOG(2) << op->Name() << \" function_outputs_on_op_device: \"\n << function_outputs_on_op_device;\n if (device == nullptr) {\n TF_RETURN_IF_ERROR(SetOpDevice(ctx, op, &device));\n } else {\n VLOG(1) << \"Device for [\" << op->Name()\n << \"] already set to: \" << device->name();\n }",
" // Note: We wrap the eager op AFTER the device has been inferred to ensure\n // that placement of the NodeDef in the function is exactly the same as in\n // eager mode. This is specially important for cases where the\n // preferred device is not the actual device on which the op is run.\n // E.g. the preferred device for a `RangeDataset` op could be set to `GPU`\n // but `ctx->SelectDevice` would still place it on CPU. Placer on the other\n // hand would throw an error.\n //\n // Note: The wrapped function is never jit compiled but rather run via the\n // FLR. This is needed because certain ops e.g. `VarHandleOp` can not be\n // jit compiled. Ideally we would run this via the jit compiled path and\n // expect unsupported ops to be outside compiled but that is not supported\n // on GPUs right now.\n bool allow_small_function_optimizations = false;\n bool int_args_and_retvals_on_device = false;\n bool allow_control_flow_sync_execution = false;\n // TODO(b/176491312): Remove this if shape inference on import flag is\n // removed.\n bool shape_inference_on_tfe_dialect_import = true;\n if (ctx.RunEagerOpAsFunction() && !op->is_function()) {\n EagerOperation* wrapped_op = nullptr;\n TF_RETURN_IF_ERROR(ValidateOp(op));\n TF_RETURN_IF_ERROR(WrapInCallOp(op, &wrapped_op));\n DCHECK(wrapped_op);\n DCHECK(wrapped_op->is_function());\n wrapped_op_releaser.reset(wrapped_op);\n run_function_with_flr = true;\n allow_small_function_optimizations = true;\n allow_control_flow_sync_execution = true;\n shape_inference_on_tfe_dialect_import = false;\n int_args_and_retvals_on_device = IntArgsAndRetvalsOnDevice(op);\n op = wrapped_op;\n }\n const NodeDef& ndef = op->MutableAttrs()->BuildNodeDef();",
" FunctionLibraryRuntime* flr =\n device == nullptr ? nullptr : ctx.func_lib(device);\n if (device != nullptr && flr == nullptr) {\n return errors::NotFound(\n \"Unable to find a FunctionLibraryRuntime corresponding to device \",\n device->name());\n }\n auto runner = (flr != nullptr && flr->runner() != nullptr) ? flr->runner()\n : ctx.runner();\n GraphCollector* graph_collector = nullptr;\n if (ctx.ShouldStoreGraphs()) {\n graph_collector = ctx.GetGraphCollector();\n }\n // Treat the function as multi_device only when we are not compiling\n // it wholly with XLA. When compiling wholly with XLA, flr->CreateKernel\n // will create an XlaLaunchOp kernel to compile and run the function.\n if (run_function_with_flr) {\n // Multi-device functions don't use the rendezvous from eager context.\n // If we use that rendezvous, multiple concurrent calls to the same\n // function will likely result in collisions. However, this also means\n // that we don't support legitimate sending/receiving across function\n // boundary.\n VLOG(2) << \"Running \" << ndef.op() << \" using multi-device function. \"\n << \"Full node_def=\" << ndef.DebugString();\n std::function<int64_t()> get_op_id = nullptr;\n#if !defined(IS_MOBILE_PLATFORM)\n get_op_id = [&ctx]() { return ctx.RemoteMgr()->NextOpId(); };\n#endif // IS_MOBILE_PLATFORM",
" ctx.reuse_rendezvous_for_functions_mu()->lock();\n ctx.SetReuseRendezvousForFunctions(reuse_rendezvous_for_functions);\n auto rendezvous_creator = ctx.RendezvousCreator();\n ctx.SetReuseRendezvousForFunctions(\n reuse_rendezvous_for_functions_original_value);\n ctx.reuse_rendezvous_for_functions_mu()->unlock();\n kernel.reset(new KernelAndDeviceFunc(\n flr, ctx.pflr(), std::move(input_dev_ptrs),\n std::move(composite_devices),\n std::move(input_resource_variable_dtypes_and_shapes), runner,\n ctx.GetCollectiveExecutorHandle(), ctx.HostCPU(), op->Name(),\n function_outputs_on_op_device, allow_small_function_optimizations,\n allow_control_flow_sync_execution,\n shape_inference_on_tfe_dialect_import, int_args_and_retvals_on_device,\n xla_compile_device_type, std::move(rendezvous_creator), get_op_id));\n } else {\n VLOG(2) << \"Running \" << ndef.op() << \" using op kernel. \"\n << \". Full node_def=\" << ndef.DebugString();\n kernel.reset(new KernelAndDeviceOp(\n ctx.GetRendezvous(), ctx.LogMemory(), flr, runner,\n ctx.GetCollectiveExecutorHandle(), ctx.HostCPU()));\n }",
" TF_RETURN_IF_ERROR(\n kernel->Init(ctx.LogDevicePlacement(), ndef, graph_collector));",
" if (op->is_function()) {\n ctx.AddKernelToCache(cache_key, kernel.get());\n } else {\n // Exclude tf.data op kernels from being cached. The reason for this is\n // that tf.data op kernels that accept a user-defined function will have a\n // unique cache key every time they are executed (because the user-defined\n // function is traced every time). Caching such kernels provides no\n // benefit and in some cases results in linear memory growth of use\n // programs that build input pipeline graphs in a loop.\n const OpDef* op_def;\n TF_RETURN_IF_ERROR(OpDefForOp(op->Name().data(), &op_def));\n if (KernelCacheEnabled(*op_def)) {\n ctx.AddKernelToCache(cache_key, kernel.get());\n }\n }\n }",
" int num_outputs = kernel->num_outputs();\n if (num_outputs > *num_retvals) {\n return errors::InvalidArgument(\"Expecting \", num_outputs,\n \" outputs, but *num_retvals is \",\n *num_retvals);\n }\n *num_retvals = num_outputs;",
" kernel->Ref(); // Ownership of reference is passed to out_kernel.\n out_kernel->reset(kernel.get());\n return Status::OK();\n}",
"Status CreateUnshapedOutput(\n const KernelAndDevice& kernel, const int output_num, Device* output_device,\n const DataType& output_dtype,\n const absl::optional<EagerFunctionParams>& eager_func_params,\n EagerContext* ctx, TensorHandle** output) {\n#if defined(IS_MOBILE_PLATFORM)\n return errors::Unimplemented(\n \"Remote outputs are not available on mobile devices.\");\n#else // !IS_MOBILE_PLATFORM\n int64_t op_id;\n if (eager_func_params.has_value()) {\n op_id = eager_func_params.value().op_id;\n } else {\n return errors::InvalidArgument(\n \"Unable to find a remote op id for a remote output of \", kernel.name());\n }\n string remote_task;\n if (!DeviceNameUtils::GetTaskName(output_device->parsed_name(),\n &remote_task)) {\n return errors::InvalidArgument(\n \"Unable to find remote task corresponding to device \",\n output_device->name());\n }\n if (ctx->RemoteMgr()->IsMaster()) {\n *output = TensorHandle::CreateUnshapedRemoteHandle(\n op_id, output_num, remote_task, output_dtype, output_device, ctx);\n } else {\n *output = TensorHandle::CreateLazyRemoteHandle(op_id, output_num,\n output_dtype, output_device,\n /*is_ready=*/false, ctx);\n }\n return Status::OK();\n#endif // !IS_MOBILE_PLATFORM\n}",
"Status AddOrExecuteNode(core::RefCountPtr<KernelAndDevice> kernel,\n EagerOperation* op, TensorHandle** retvals) {\n EagerExecutor& executor = op->Executor();\n EagerContext& ctx = op->EagerContext();\n GraphCollector* graph_collector = nullptr;\n if (ctx.ShouldStoreGraphs()) {\n graph_collector = ctx.GetGraphCollector();\n }\n const int num_outputs = kernel->num_outputs();\n absl::optional<EagerFunctionParams> eager_func_params =\n op->eager_func_params();\n if (kernel->IsCrossProcess() && !eager_func_params.has_value()) {\n // Create an eager op id for a cross-process function if not exist.\n#if defined(IS_MOBILE_PLATFORM)\n return errors::Unimplemented(\n \"Cross-process functions are not supported on mobile devices.\");\n#else // !IS_MOBILE_PLATFORM\n const int64_t op_id = ctx.RemoteMgr()->NextOpId();\n eager_func_params = EagerFunctionParams{op_id, /*step_id=*/absl::nullopt};\n#endif // !IS_MOBILE_PLATFORM\n }\n if (executor.Async()) {\n const DataTypeVector& output_dtypes = kernel->output_dtypes();\n for (int i = 0, end = num_outputs; i < end; ++i) {\n Device* output_device = ctx.CanonicalDevice(kernel->OutputDevice(i));\n if (output_device == nullptr || output_device->IsLocal()) {\n retvals[i] = TensorHandle::CreateEmptyLocalHandle(\n /* d= */ output_device, /* op_device= */ kernel->device(),\n /* resource_device= */ kernel->OutputResourceDevice(i),\n output_dtypes[i], &ctx);\n } else {\n TF_RETURN_IF_ERROR(\n CreateUnshapedOutput(*kernel, i, output_device, output_dtypes[i],\n eager_func_params, &ctx, &retvals[i]));\n }\n }\n const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n auto node = absl::make_unique<AsyncExecuteNode>(\n &ctx, *inputs, eager_func_params, std::move(kernel), graph_collector,\n op->GetCancellationManager(),\n absl::Span<TensorHandle*>(retvals, num_outputs), op->GetStackTrace());\n // Release the inputs from the eager operation since the AsyncExecuteNode\n // would have taken ownership. This allows the inputs to be forwarded if\n // possible.\n op->Clear();\n // For async mode, execution order will make sure that all\n // input handles are ready before executing them.\n // TODO(b/137118203): Consider executing \"cheap\" kernels inline for\n // performance.\n return executor.AddOrExecute(std::move(node));\n } else {\n for (int i = 0, end = num_outputs; i < end; ++i) {\n retvals[i] = nullptr;\n }\n const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n ExecuteNode node(&ctx, *inputs, eager_func_params, kernel, graph_collector,\n op->GetCancellationManager(),\n {retvals, static_cast<size_t>(num_outputs)},\n op->GetStackTrace());\n Status s = executor.SyncExecute(&node);\n // We release the inputs AFTER executing the operation in sync mode since\n // ExecuteNode does not increment the reference count and thus does not have\n // ownership of the inputs while executing.\n op->Clear();\n return s;\n }\n}",
"// There are a lot of references to devices in this function and around.\n// Here is what they mean:\n// EagerOperation::Device(): The device on which the user requested the op\n// be executed, except if we had to change the device due to resource inputs\n// or CPU pinning. If the user did not request a device, the op does not\n// take resources, and we did not pin it to CPU, the device can be nullptr.\n// KernelAndDevice::Device(): The first time we see an op (combined with\n// its attributes), we need to create a KernelAndDevice object for it.\n// If op->Device() is a nullptr, we select a device for the op when\n// creating the KernelAndDevice. A concrete device will always be selected\n// here except when `op` is a function to be executed using function library\n// runtime. In this case, we don't select a device because running\n// a function with explicitly requested device has different behavior than\n// running without an explicitly requested device.\nStatus EagerLocalExecute(EagerOperation* op, TensorHandle** retvals,\n int* num_retvals) {\n profiler::ScopedMemoryDebugAnnotation op_annotation(\n op->op_name(), op->eager_func_params().has_value()\n ? op->eager_func_params().value().step_id.value_or(0)\n : 0);\n profiler::TraceMe activity(\n [&] { return absl::StrCat(\"EagerLocalExecute: \", op->Name()); },\n profiler::TraceMeLevel::kInfo);\n EagerContext& ctx = op->EagerContext();\n auto& executor = op->Executor();\n TF_RETURN_IF_ERROR(executor.status());",
" core::RefCountPtr<KernelAndDevice> kernel;\n auto status = GetOrCreateKernelAndDevice(op, retvals, num_retvals, &kernel);",
"#ifdef INTEL_MKL\n if (IsMKLEnabled() && kernel != nullptr &&\n op->Device() == kVariantDeviceNull) {\n // oneDNN optimization pass relies on the op's assigned device to determine\n // whether it can be rewritten.\n op->SetDevice(kernel->device());\n }\n#endif // INTEL_MKL",
" // Run all the registered rewrite pass after the placement, regardless whether\n // the placement is successful or not. The passes can either create new ops\n // (without placement) or update some fields of the input op.\n std::unique_ptr<tensorflow::EagerOperation> out_op;\n TF_RETURN_IF_ERROR(EagerOpRewriteRegistry::Global()->RunRewrite(\n EagerOpRewriteRegistry::POST_PLACEMENT, op, &out_op));\n if (out_op) {\n op = out_op.get();\n // If the out op doesn't have device, either because it is a new op or\n // the op wasn't placed successfully, then we do the placement again.\n if (op->Device() == kVariantDeviceNull) {\n status = GetOrCreateKernelAndDevice(op, retvals, num_retvals, &kernel);\n }\n }\n if (!status.ok()) return status;",
" int num_outputs = kernel->num_outputs();\n TF_RETURN_IF_ERROR(ValidateInputTypeAndPlacement(&ctx, op, kernel));",
" if (ctx.LogDevicePlacement() || VLOG_IS_ON(1)) {\n string msg = strings::StrCat(\"Executing op \", op->Name(), \" in device \",\n kernel->device()->name());\n if (!logging::LogToListeners(msg)) {\n LOG(INFO) << msg;\n }\n }",
" Status s = AddOrExecuteNode(std::move(kernel), op, retvals);\n // Since the operation failed, we need to Unref any outputs if they were\n // allocated.\n if (!s.ok()) {\n for (int i = 0, end = num_outputs; i < end; ++i) {\n if (retvals[i] != nullptr) {\n retvals[i]->Unref();\n retvals[i] = nullptr;\n }\n }\n }",
" return s;\n}",
"// Run a Pack op to pack the tensors pointed by a packed input TensorHandle if\n// the op is a primitive op.\nStatus MaybePackInputTensor(EagerOperation* op) {\n if (op->is_function() || op->EagerContext().RunEagerOpAsFunction()) {\n // Functions could take packed TensorHandles as inputs.\n return Status::OK();\n }\n EagerContext& ctx = op->EagerContext();\n const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n for (int i = 0; i < inputs->size(); ++i) {\n TensorHandle* handle = (*inputs)[i];\n if (handle->Type() == TensorHandle::PACKED) {\n EagerOperation pack_op(&ctx);\n TF_RETURN_IF_ERROR(pack_op.Reset(\"Pack\", /*device_name=*/nullptr,\n /*remote=*/false, /*executor=*/nullptr));\n pack_op.MutableAttrs()->Set(\"N\", handle->NumPackedHandles());\n pack_op.MutableAttrs()->Set(\"T\", handle->dtype);\n for (int i = 0; i < handle->NumPackedHandles(); ++i) {\n tensorflow::TensorHandle* h = nullptr;\n TF_RETURN_IF_ERROR(handle->ExtractPackedHandle(i, &h));\n TF_RETURN_IF_ERROR(pack_op.AddInput(h));\n }\n int num_retvals = 1;\n absl::FixedArray<tensorflow::TensorHandle*> retvals(num_retvals);\n TF_RETURN_IF_ERROR(\n EagerLocalExecute(&pack_op, retvals.data(), &num_retvals));\n tensorflow::TensorHandle* ret = retvals.at(0);\n op->UpdateInput(i, ret);\n ret->Unref();\n }\n }\n return Status::OK();\n}",
"#if !defined(IS_MOBILE_PLATFORM)\nvoid PrepareRemoteOp(eager::Operation* remote_op, EagerOperation* op) {\n EagerContext& ctx = op->EagerContext();",
" remote_op->set_id(ctx.RemoteMgr()->NextOpId());\n remote_op->set_name(op->Name());",
" op->Attrs().FillAttrValueMapWithoutDefaults(remote_op->mutable_attrs());\n remote_op->set_device(absl::get<Device*>(op->Device())->name());\n remote_op->set_is_function(op->is_function());\n}",
"Status StoreResourceDtypesAndShapes(const eager::Operation& remote_op,\n const DataTypeVector& output_dtypes,\n TensorHandle** retvals) {\n if (remote_op.name() == \"VarHandleOp\") {\n if (output_dtypes.size() != 1) {\n return errors::Internal(\"VarHandleOp should only have one output.\");\n }\n if (output_dtypes[0] != DT_RESOURCE) {\n return errors::Internal(\n \"The output of VarHandleOp should be a DT_RESOURCE.\");\n }\n AttrSlice attr_slice = AttrSlice(&remote_op.attrs());\n const AttrValue* dtype;\n TF_RETURN_IF_ERROR(attr_slice.Find(\"dtype\", &dtype));\n const AttrValue* shape;\n TF_RETURN_IF_ERROR(attr_slice.Find(\"shape\", &shape));\n retvals[0]->SetResourceHandleDtypeAndShape(\n {DtypeAndPartialTensorShape{dtype->type(), shape->shape()}});\n }\n return Status::OK();\n}",
"Status EagerRemoteExecute(EagerOperation* op, TensorHandle** retvals,\n int* num_retvals) {\n EagerContext& ctx = op->EagerContext();",
" // TODO(fishx): Remove following code when lazy tensor copy is ready.\n if (op->Device() == kVariantDeviceNull) {\n tensorflow::Device* device = nullptr;\n string device_name = op->DeviceName();\n TF_RETURN_IF_ERROR(ctx.FindDeviceFromName(device_name.c_str(), &device));\n op->SetDevice(device);\n }",
" core::RefCountPtr<eager::EagerClient> eager_client;\n uint64 context_id = ctx.GetContextId();\n TF_RETURN_IF_ERROR(ctx.GetClient(op->GetDeviceParsedName(), &eager_client));\n string remote_task;\n if (!DeviceNameUtils::GetTaskName(op->GetDeviceParsedName(), &remote_task)) {\n return errors::InvalidArgument(\n \"Unable to find remote task corresponding to device \",\n op->DeviceName());\n }",
" std::unique_ptr<eager::EnqueueRequest> request(new eager::EnqueueRequest);\n request->set_context_id(context_id);",
" eager::Operation* remote_op = request->add_queue()->mutable_operation();",
" tensorflow::Device* op_device = absl::get<Device*>(op->Device());\n {\n profiler::TraceMe activity(\"CopyInputToExpectedDevice\",\n profiler::TraceMeLevel::kInfo);\n const bool is_function = op->is_function();\n const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));\n for (int i = 0, end = inputs->size(); i < end; i++) {\n tensorflow::TensorHandle* input = (*inputs)[i];\n tensorflow::Device* input_device = input->device();\n tensorflow::Device* input_device_or_cpu = input->DeviceOrHostCPU(ctx);\n const string* input_device_name = &input_device_or_cpu->name();\n bool serialize_resource_dtype_and_shape = false;\n if (op_device != input_device &&\n // If the expected and actual devices are on the same task, don't\n // explicitly copy, and instead depend on the copy to happen locally\n // when the op is executed on the device.\n !ctx.OnSameTask(op_device, input_device)) {\n if (!is_function || input_device_or_cpu->IsLocal()) {\n tensorflow::Device* remote_cpu_device;\n TF_RETURN_IF_ERROR(\n ctx.CPUDeviceOnTask(op_device, &remote_cpu_device));\n // Always copy to the remote CPU so that the actual device can be\n // correctly determined after the kernel is selected/instantiated,\n // since the op might have its inputs on host memory.\n TensorHandle* handle = input;\n Device* handle_device = handle->DeviceOrHostCPU(ctx);\n // If the input is already on the right device, then nothing to do.\n if (remote_cpu_device != handle_device) {\n VLOG(6) << \"remote_cpu_device != handle_device\";\n TF_RETURN_IF_ERROR(CopyInputToExpectedDevice(\n &ctx, op, op_device, handle, i, handle_device,\n remote_cpu_device, &handle));\n op->UpdateInput(i, handle);\n input = handle;\n input_device = remote_cpu_device;\n input_device_name = &remote_cpu_device->name();\n // Unref handle since it has a ref as an input now\n handle->Unref();\n }\n } else {\n serialize_resource_dtype_and_shape =\n (input->dtype == DT_RESOURCE) &&\n (!input->HasResourceShapeMirror(op_device,\n ctx.GetContextViewId()));\n }\n }\n auto* input_handle = remote_op->add_op_inputs()->mutable_remote_handle();\n // For a remote component function, a function execution request and an\n // input generation request may come from different workers. We need to\n // guarantee that the input generation request is processed before the\n // function execution request, so wait until the remote input is ready\n // before sending it to the multi-device function device.\n const bool wait_until_ready = op->is_function();\n TF_RETURN_IF_ERROR(ctx.RemoteMgr()->SerializeRemoteTensorHandle(\n input, wait_until_ready, input_handle, input_device,\n *input_device_name, serialize_resource_dtype_and_shape));\n if (!input_handle->resource_dtypes_and_shapes().empty()) {\n TF_RETURN_IF_ERROR(\n input->AddResourceShapeMirror(op_device, input_handle->op_id(),\n input_handle->output_num(), &ctx));\n }\n }\n }",
" PrepareRemoteOp(remote_op, op);",
" DataTypeVector output_dtypes;\n TF_RETURN_IF_ERROR(GetOutputDTypes(op, &output_dtypes));",
" const size_t num_outputs = output_dtypes.size();\n if (num_outputs != *num_retvals) {\n return errors::InvalidArgument(\n \"num_retvals does not match expected output dtypes\");\n }\n *num_retvals = num_outputs;",
" const tensorflow::uint64 id = remote_op->id();\n for (size_t i = 0; i < num_outputs; ++i) {\n // TODO(nareshmodi): Change the callback to instead add the decref to a\n // list of pending decrefs that we can send as a batch with the next\n // execute.",
" // The device_ and resource_device_ of this TensorHandle might be\n // incorrect. For multi-device functions, we don't know the output device\n // until the function is instantiated on a remote worker. Luckily, we don't\n // need to know the correct remote device here. We just need to know that it\n // is remote. If we need copy this tensor to this process or run any ops\n // which take this tensor as an input, block until the correct device is\n // set.\n const bool unknown_device = op->is_function();\n retvals[i] = TensorHandle::CreateUnshapedRemoteHandle(\n id, i, remote_task, output_dtypes[i], op_device, &ctx, unknown_device);\n }",
" // Store the data type and shape of a remote resource variable on the\n // corresponding remote TensorHandle (output of 'VarHandleOp').\n // If the variable is an input of a remote function, the function may need\n // the type and shape during function instantiation. Store the type and\n // shape on eager master and sent them to the default function device along\n // with the EnqueueRequest.\n TF_RETURN_IF_ERROR(\n StoreResourceDtypesAndShapes(*remote_op, output_dtypes, retvals));",
" auto& executor = op->Executor();\n VLOG(4) << \"Execute remote eager op: \" << op->Name()\n << \" (is async?: \" << executor.Async() << \").\";",
" const absl::InlinedVector<TensorHandle*, 4>* inputs;\n TF_RETURN_IF_ERROR(op->TensorHandleInputs(&inputs));",
" std::unique_ptr<EagerNode> node(new eager::RemoteExecuteNode(\n &op->EagerContext(), std::move(request), op_device,\n ctx.GetContextViewId(), eager_client.get(), op->GetCancellationManager(),\n op->MutableAttrs()->BuildNodeDef(), op->EagerContext().FuncLibDef(),\n *inputs, {retvals, num_outputs}));",
" if (op->EagerContext().LogDevicePlacement() || VLOG_IS_ON(1)) {\n string msg = strings::StrCat(\n \"Executing op \", op->Name(), \" on task \",\n DeviceNameUtils::ParsedNameToString(op->GetDeviceParsedName()));\n if (!logging::LogToListeners(msg)) {\n LOG(INFO) << msg;\n }\n }",
" Status s = executor.AddOrExecute(std::move(node));\n // Since the operation failed, we need to Unref any outputs that were\n // allocated.\n if (!s.ok()) {\n for (size_t i = 0; i < num_outputs; ++i) {\n retvals[i]->Unref();\n // Ensure that any smart pointers created to wrap results become noops\n // rather than operating on invalid memory.\n retvals[i] = nullptr;\n }\n }",
" return s;\n}\n#endif // IS_MOBILE_PLATFORM",
"Status GetKernelOutputs(\n std::vector<EagerKernelRet>* outputs, int num_outputs,\n TensorHandle** retvals, EagerContext* ctx, KernelAndDevice* kernel,\n const absl::optional<EagerFunctionParams>& eager_func_params) {\n for (int i = 0, end = num_outputs; i < end; ++i) {\n if (retvals[i] == nullptr) {\n EagerKernelRet& ret = (*outputs)[i];\n Device* output_device = ctx->CanonicalDevice(kernel->OutputDevice(i));\n if (ret.index() == 0) {\n retvals[i] = TensorHandle::CreateLocalHandle(\n std::move(absl::get<Tensor>(ret)),\n /* d= */ output_device,\n /* op_device= */ kernel->device(),\n /* resource_device= */ kernel->OutputResourceDevice(i), ctx);\n } else {\n const DataTypeVector& output_dtypes = kernel->output_dtypes();\n TF_RETURN_IF_ERROR(\n CreateUnshapedOutput(*kernel, i, output_device, output_dtypes[i],\n eager_func_params, ctx, &retvals[i]));\n#if !defined(IS_MOBILE_PLATFORM)\n TF_RETURN_IF_ERROR(\n retvals[i]->SetRemoteShape(absl::get<TensorShape>(ret),\n output_device, ctx->GetContextViewId()));\n#endif // IS_MOBILE_PLATFORM\n }\n } else {\n if (!kernel->IsFunction() &&\n TF_PREDICT_FALSE(kernel->device() != retvals[i]->op_device())) {\n return errors::Internal(\n \"Kernel output tensor handle has a different op device than the \"\n \"kernel. This should never happen.\");\n }\n if (TF_PREDICT_FALSE(ctx->CanonicalDevice(kernel->OutputDevice(i)) !=\n retvals[i]->device())) {\n return errors::Internal(\n \"Kernel output tensor handle locates on a different device than \"\n \"the specified kernel output device. This should never happen.\");\n }",
" EagerKernelRet& ret = (*outputs)[i];\n if (ret.index() == 0) {\n TF_RETURN_IF_ERROR(retvals[i]->SetTensor(\n std::move(absl::get<Tensor>(ret)),\n ctx->CanonicalDevice(kernel->OutputDevice(i))));\n } else {\n#if defined(IS_MOBILE_PLATFORM)\n return errors::Unimplemented(\n \"Remote outputs are not available on mobile devices.\");\n#else // !IS_MOBILE_PLATFORM\n TF_RETURN_IF_ERROR(retvals[i]->SetRemoteShape(\n absl::get<TensorShape>(ret), retvals[i]->device(),\n ctx->GetContextViewId()));\n#endif // !IS_MOBILE_PLATFORM\n }\n }\n }\n return Status::OK();\n}",
"void CollectGraphs(EagerContext* ctx) {\n mutex_lock ml(*ctx->MetadataMu());",
" GraphCollector* collector = ctx->GetGraphCollector();\n mutex_lock mll(collector->mu);",
" // Adding to partition graphs for backward compatibility.\n for (const auto& graph : collector->partitioned_graphs) {\n *ctx->RunMetadataProto()->add_partition_graphs() = graph;\n }",
" if (collector->dirty) {\n auto* function_graphs = ctx->RunMetadataProto()->add_function_graphs();\n *function_graphs->mutable_post_optimization_graph() =\n collector->optimized_graph;\n *function_graphs->mutable_pre_optimization_graph() = collector->raw_graph;\n for (const auto& graph : collector->partitioned_graphs) {\n *function_graphs->add_partition_graphs() = graph;\n }\n }",
" collector->ClearGraphs();\n}\n} // namespace",
"Status EagerExecute(EagerOperation* op, TensorHandle** retvals,\n int* num_retvals) {\n profiler::TraceMe activity([&] {\n return ::tensorflow::profiler::TraceMeEncode(\n \"EagerExecute\",\n {{\"eager_op\", op->Name()}, {\"is_func\", op->is_function()}});\n });",
" if (!op->Executor().Async()) {\n VLOG(6) << \"op: \" << op->Name() << \" is not Async.\";\n if (!op->EagerContext()\n .GetGlobalRendezvousForFunctionLocalRendezvousStatus()\n .ok()) {\n VLOG(6) << \"global_rendezvous_for_functions_ is in bad state. Resetting.\";\n op->EagerContext().ResetGlobalRendezvousForFunction();\n }\n // In sync mode, always clear error to maintain the same behavior as before.\n // TODO(b/141004939): Remove this.\n op->Executor().ClearError();\n }",
" std::unique_ptr<tensorflow::EagerOperation> out_op;\n TF_RETURN_IF_ERROR(EagerOpRewriteRegistry::Global()->RunRewrite(\n EagerOpRewriteRegistry::PRE_EXECUTION, op, &out_op));",
" if (op->IsLocal()) {\n if (out_op) {\n op = out_op.get();\n }\n TF_RETURN_IF_ERROR(MaybePackInputTensor(op));\n return EagerLocalExecute(op, retvals, num_retvals);\n }",
"#if defined(IS_MOBILE_PLATFORM)\n return errors::Unimplemented(\n \"Eager's remote execution is not available on mobile devices.\");\n#else // !IS_MOBILE_PLATFORM\n if (out_op) {\n op = out_op.get();\n }\n return EagerRemoteExecute(op, retvals, num_retvals);\n#endif // !IS_MOBILE_PLATFORM\n}",
"// TODO(gjn): Consider moving into ExecuteNode class\nStatus EagerKernelExecute(\n EagerContext* ctx, const absl::InlinedVector<TensorHandle*, 4>& op_inputs,\n const absl::optional<EagerFunctionParams>& eager_func_params,\n const core::RefCountPtr<KernelAndDevice>& kernel,\n GraphCollector* graph_collector, CancellationManager* cancellation_manager,\n absl::Span<TensorHandle*> retvals,\n const absl::optional<ManagedStackTrace>& stack_trace) {\n profiler::TraceMe activity(\"EagerKernelExecute\",\n profiler::TraceMeLevel::kInfo);\n std::vector<EagerKernelRet> outputs(1);",
" ExecuteNodeArgs inputs(op_inputs.size());\n TF_RETURN_IF_ERROR(inputs.Init(ctx, op_inputs, kernel));\n // TODO(apassos) figure out how to record stats for ops which are a part of\n // functions.\n // TODO(b/111859745): When we support recovering from kernel/device errors, we\n // would need to call XlaDevice::EnsureDeviceContextOk() before using an XLA\n // device. We don't call it now because it is an unneeded overhead (it\n // acquires a lock) and we can't recover from errors anyway.\n ScopedStepContainer* container = ctx->StepContainer();\n CoordinationServiceAgent* coord_agent = nullptr;\n#if !defined(IS_MOBILE_PLATFORM)\n if (ctx->GetDistributedManager() != nullptr)\n coord_agent = ctx->GetDistributedManager()->GetCoordinationServiceAgent();\n#endif // !IS_MOBILE_PLATFORM\n TF_RETURN_IF_ERROR(kernel->Run(container, inputs, &outputs,\n cancellation_manager, eager_func_params,\n stack_trace, coord_agent));\n if (graph_collector != nullptr) {\n CollectGraphs(ctx);\n }",
" if (TF_PREDICT_FALSE(retvals.size() != outputs.size())) {\n return errors::Internal(\n \"EagerKernelExecute returns a list of \", outputs.size(),\n \" tensors but \", retvals.size(),\n \" is expected. This should never \"\n \"happen. Please file a bug with the TensorFlow team.\");\n }\n return GetKernelOutputs(&outputs, retvals.size(), retvals.data(), ctx,\n kernel.get(), eager_func_params);\n}",
"namespace {",
"Status LocalEagerCopyToDevice(TensorHandle* h, EagerContext* ctx,\n EagerExecutor* executor, Device* dstd,\n bool mirror, TensorHandle** result) {\n TF_RETURN_IF_ERROR(executor->status());\n Device* d = ctx->CanonicalDevice(dstd);\n if (mirror && h->HasLocalMirror(d)) {\n h->Ref();\n *result = h;\n return Status::OK();\n }",
" bool async = executor->Async();\n if (mirror) {\n h->Ref();\n *result = h;",
" if (h->HasLocalMirror(d)) {\n return Status::OK();\n }",
" // We don't bother adding an empty local mirror in sync mode since we'll be\n // executing the operation directly and be calling AddLocalMirror. A\n // reference count is still needed which will be removed if the operation\n // fails.\n if (async) {\n Status s = h->AddEmptyLocalMirror(d);\n if (!s.ok()) {\n // If a mirror was added since we called HasLocalMirror then just return\n // since another thread has already added the mirror.\n if (s.code() == error::Code::ALREADY_EXISTS) {\n return Status::OK();\n }",
" // Remove the previously added reference count since adding the mirror\n // failed.\n h->Unref();\n *result = nullptr;\n return s;\n }\n }\n } else {\n *result = TensorHandle::CreateEmptyLocalHandle(\n d, dstd, h->resource_device(), h->dtype, ctx);\n }",
" Status s;\n if (async) {\n // Note that `h` may not be currently ready. However execution order will\n // make sure that `h` is ready before the copy is actually done.\n std::unique_ptr<EagerNode> node(\n new CopyToDeviceNode(h, *result, d, *ctx, async, mirror));\n s = executor->AddOrExecute(std::move(node));\n } else {\n CopyToDeviceNode node(h, *result, d, *ctx, async, mirror);\n s = executor->SyncExecute(&node);\n }",
" // Since the operation failed, we need to Unref any outputs that were\n // allocated.\n if (!s.ok()) {\n (*result)->Unref();\n *result = nullptr;\n }",
" return s;\n}",
"} // namespace",
"Status EagerCopyToDevice(TensorHandle* h, EagerContext* ctx,\n EagerExecutor* executor, Device* device, bool mirror,\n TensorHandle** result) {\n TF_RETURN_IF_ERROR(h->WaitUnknownDevice());\n auto send_device = h->DeviceOrHostCPU(*ctx);\n bool sender_is_local = send_device->IsLocal();",
" bool receiver_is_local = device->IsLocal();",
" if (!executor->Async()) {\n // In sync mode, always clear error to maintain the same behavior as before.\n // TODO(b/141004939): Remove this.\n executor->ClearError();\n }",
" if (sender_is_local && receiver_is_local) {\n return LocalEagerCopyToDevice(h, ctx, executor, device, mirror, result);\n } else {\n#if defined(IS_MOBILE_PLATFORM)\n return errors::Unimplemented(\n \"Eager's remote execution is not available on mobile devices.\");\n#else // !IS_MOBILE_PLATFORM\n uint64 recv_op_id = 0;\n if (receiver_is_local) {\n Device* d = ctx->CanonicalDevice(device);\n // TODO(gjn): Need to add support for async execution. Note if receiver\n // is local, we need to first add support in TensorHandle to wait on local\n // mirrors.\n if (mirror) {\n h->Ref();\n *result = h;",
" if (h->HasLocalMirror(d)) {\n return Status::OK();\n }",
" Status s = h->AddEmptyLocalMirror(d);\n if (!s.ok()) {\n // If a mirror was added since we called HasLocalMirror then just\n // return since another thread has already added the mirror.\n if (s.code() == error::Code::ALREADY_EXISTS) {\n return Status::OK();\n }",
" // Remove the previously added reference count since adding the mirror\n // failed.\n h->Unref();\n *result = nullptr;\n return s;\n }\n } else {\n *result = TensorHandle::CreateEmptyLocalHandle(\n /* d= */ d, /* op_device= */ device,\n /*resource_device=*/nullptr, h->dtype, ctx);\n }\n } else {\n if (mirror) {\n if (h->HasRemoteMirror(device, ctx->GetContextViewId())) {\n h->Ref();\n *result = h;\n return Status::OK();\n }\n }\n string remote_task;\n if (!DeviceNameUtils::GetTaskName(device->parsed_name(), &remote_task)) {\n return errors::InvalidArgument(\n \"Unable to find remote task corresponding to device \",\n device->name());\n }\n recv_op_id = ctx->RemoteMgr()->NextOpId();\n if (mirror) {\n TF_RETURN_IF_ERROR(h->AddUnshapedRemoteMirror(device, recv_op_id, 0,\n remote_task, ctx));\n h->Ref();\n *result = h;\n } else {\n *result = TensorHandle::CreateUnshapedRemoteHandle(\n recv_op_id, 0, remote_task, h->dtype, device, ctx);\n }\n }",
" auto node = std::make_unique<eager::RemoteCopyNode>(\n ctx, executor, h, result[0], device, recv_op_id);\n Status s = executor->AddOrExecute(std::move(node));\n if (!s.ok()) {\n result[0]->Unref();\n result[0] = nullptr;\n }\n return s;\n#endif // !IS_MOBILE_PLATFORM\n }\n}",
"namespace {\n// Low-level utility function to execute the kernel specified by `kernel` on\n// `kernel->device()`, with the provided inputs as `op_inputs` in the 'ctx'.\n// Different from `EagerKernelExecute` that ties up the thread until the\n// underlying function finishes execute, this function does not block the thread\n// and could return before the function execution finishes. The provided\n// `StatusCallback` will be triggered after function execution with its status.\nvoid EagerKernelExecuteAsync(\n EagerContext* ctx, const absl::InlinedVector<TensorHandle*, 4>& op_inputs,\n const absl::optional<EagerFunctionParams>& eager_func_params,\n const core::RefCountPtr<KernelAndDevice> kernel,\n GraphCollector* graph_collector, CancellationManager* cancellation_manager,\n TensorHandle** retvals, int num_outputs, StatusCallback done) {\n auto inputs = std::make_shared<ExecuteNodeArgs>(op_inputs.size());\n auto outputs = std::make_shared<std::vector<EagerKernelRet>>(1);",
" Status s = inputs->Init(ctx, op_inputs, kernel);\n if (!s.ok()) {\n done(s);\n return;\n }\n CoordinationServiceAgent* coord_agent = nullptr;\n#if !defined(IS_MOBILE_PLATFORM)\n if (ctx->GetDistributedManager() != nullptr)\n coord_agent = ctx->GetDistributedManager()->GetCoordinationServiceAgent();\n#endif // !IS_MOBILE_PLATFORM",
" kernel->Ref(); // Ownership of reference is transferred to the callback\n kernel->RunAsync(\n ctx->StepContainer(), *inputs, outputs.get(), cancellation_manager,\n eager_func_params, coord_agent,\n [retvals, inputs, outputs, num_outputs, ctx, graph_collector,\n eager_func_params, kernel_raw = kernel.get(),\n done = std::move(done)](const Status& s) {\n auto wrapped_done = [&](const Status& s) {\n kernel_raw->Unref();\n done(s);\n };\n if (!s.ok()) {\n wrapped_done(s);\n return;\n }\n if (graph_collector != nullptr) {\n CollectGraphs(ctx);\n }\n DCHECK_EQ(num_outputs, outputs->size());\n wrapped_done(GetKernelOutputs(outputs.get(), num_outputs, retvals, ctx,\n kernel_raw, eager_func_params));\n });\n}\n} // namespace",
"// Low-level utility to run the eager operation on local devices. Different from\n// `EagerLocalExecute` which blocks and waits for the finishing the op\n// execution, this method does not block the thread and could return before the\n// eager operation execution finishes. The provided `StatusCallback` will be\n// triggered after execution with its status.\nvoid EagerLocalExecuteAsync(EagerOperation* op, TensorHandle** retvals,\n int* num_retvals, StatusCallback done) {\n if (!op->IsLocal()) {\n done(errors::InvalidArgument(\n \"Remote execution is not supported in async EagerLocalExecuteAsync\"));\n return;\n }",
" profiler::ScopedMemoryDebugAnnotation op_annotation(\n op->op_name(), op->eager_func_params().has_value()\n ? op->eager_func_params().value().step_id.value_or(0)\n : 0);\n profiler::TraceMe activity(\n [&] { return absl::StrCat(\"EagerLocalExecuteAsync: \", op->Name()); },\n profiler::TraceMeLevel::kInfo);\n EagerContext& ctx = op->EagerContext();",
" core::RefCountPtr<KernelAndDevice> kernel;\n Status s = GetOrCreateKernelAndDevice(op, retvals, num_retvals, &kernel);\n if (!s.ok()) {\n done(s);\n return;\n }",
" int num_outputs = kernel->num_outputs();\n s = ValidateInputTypeAndPlacement(&ctx, op, kernel);\n if (!s.ok()) {\n done(s);\n return;\n }",
" if (ctx.LogDevicePlacement() || VLOG_IS_ON(1)) {\n string msg = strings::StrCat(\"Executing op \", op->Name(), \" in device \",\n kernel->device()->name());\n if (!logging::LogToListeners(msg)) {\n LOG(INFO) << msg;\n }\n }",
" GraphCollector* graph_collector = nullptr;\n if (ctx.ShouldStoreGraphs()) {\n graph_collector = ctx.GetGraphCollector();\n }",
" for (int i = 0, end = num_outputs; i < end; ++i) {\n const DataTypeVector& output_dtypes = kernel->output_dtypes();\n retvals[i] = TensorHandle::CreateEmptyLocalHandle(\n /* d= */ ctx.CanonicalDevice(kernel->OutputDevice(i)),\n /* op_device= */ kernel->device(),\n /* resource_device= */ kernel->OutputResourceDevice(i),\n output_dtypes[i], &ctx);\n }",
" const absl::InlinedVector<TensorHandle*, 4>* inputs;\n s = op->TensorHandleInputs(&inputs);\n if (!s.ok()) {\n done(s);\n return;\n }\n EagerKernelExecuteAsync(\n &ctx, *inputs, op->eager_func_params(), std::move(kernel),\n graph_collector, op->GetCancellationManager(), retvals, num_outputs,\n [op, num_outputs, retvals, done = std::move(done)](const Status& s) {\n op->Clear();\n // Since the operation failed, we need to Unref any outputs if they were\n // allocated.\n if (!s.ok()) {\n for (int i = 0, end = num_outputs; i < end; ++i) {\n if (retvals[i] != nullptr) {\n retvals[i]->Unref();\n retvals[i] = nullptr;\n }\n }\n }\n done(s);\n });\n}\n} // 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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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": [306], "buggy_code_start_loc": [306], "filenames": ["tensorflow/core/common_runtime/eager/execute.cc"], "fixing_code_end_loc": [310], "fixing_code_start_loc": [307], "message": "TensorFlow is an open source platform for machine learning. Prior to versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4, multiple TensorFlow operations misbehave in eager mode when the resource handle provided to them is invalid. In graph mode, it would have been impossible to perform these API calls, but migration to TF 2.x eager mode opened up this vulnerability. If the resource handle is empty, then a reference is bound to a null pointer inside TensorFlow codebase (various codepaths). This is undefined behavior. Versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4 contain a patch for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "D9359D32-D090-44CF-AC43-2046084A28BB", "versionEndExcluding": "2.6.4", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*", "matchCriteriaId": "C4DFBF2D-5283-42F6-8800-D653BFA5CE82", "versionEndExcluding": "2.7.2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "2.7.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.7.0:rc0:*:*:*:*:*:*", "matchCriteriaId": "A58EDA5C-66D6-46F1-962E-60AFB7C784A7", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.7.0:rc1:*:*:*:*:*:*", "matchCriteriaId": "89522760-C2DF-400D-9624-626D8F160CBA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.8.0:-:*:*:*:*:*:*", "matchCriteriaId": "E9EA1898-ACAA-4699-8BAE-54D62C1819FB", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.8.0:rc0:*:*:*:*:*:*", "matchCriteriaId": "130DE3C9-6842-456F-A259-BF8FF8457217", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.8.0:rc1:*:*:*:*:*:*", "matchCriteriaId": "BBF2FCEF-989C-409D-9F4C-81418C65B972", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.9.0:rc0:*:*:*:*:*:*", "matchCriteriaId": "9CFB1CFC-579D-4647-A472-6DE8BE1951DE", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:google:tensorflow:2.9.0:rc1:*:*:*:*:*:*", "matchCriteriaId": "F3F3F37E-D27F-4060-830C-0AFF16150777", "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. Prior to versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4, multiple TensorFlow operations misbehave in eager mode when the resource handle provided to them is invalid. In graph mode, it would have been impossible to perform these API calls, but migration to TF 2.x eager mode opened up this vulnerability. If the resource handle is empty, then a reference is bound to a null pointer inside TensorFlow codebase (various codepaths). This is undefined behavior. Versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4 contain a patch for this issue."}, {"lang": "es", "value": "TensorFlow es una plataforma de c\u00f3digo abierto para el aprendizaje autom\u00e1tico. En versiones anteriores a 2.9.0, 2.8.1, 2.7.2 y 2.6.4, varias operaciones de TensorFlow se comportaban inapropiadamente en modo eager cuando el manejador de recursos que les era proporcionado no era v\u00e1lido. En el modo gr\u00e1fico, habr\u00eda sido imposible llevar a cabo estas llamadas a la API, pero la migraci\u00f3n al modo eager de TF 2.x abri\u00f3 esta vulnerabilidad. Si el manejador de recursos est\u00e1 vac\u00edo, entonces una referencia est\u00e1 ligada a un puntero null dentro de la base de c\u00f3digo de TensorFlow (varios codepaths). Esto es un comportamiento no definido. Las versiones 2.9.0, 2.8.1, 2.7.2 y 2.6.4 contienen un parche para este problema"}], "evaluatorComment": null, "id": "CVE-2022-29207", "lastModified": "2022-06-02T18:12:21.637", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "LOCAL", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 2.1, "confidentialityImpact": "NONE", "integrityImpact": "NONE", "vectorString": "AV:L/AC:L/Au:N/C:N/I:N/A:P", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 2.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"}, {"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": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-05-20T22:16:40.997", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/a5b89cd68c02329d793356bda85d079e9e69b4e7"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/commit/dbdd98c37bc25249e8f288bd30d01e118a7b4498"}, {"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/releases/tag/v2.6.4"}, {"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/releases/tag/v2.7.2"}, {"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/releases/tag/v2.8.1"}, {"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/releases/tag/v2.9.0"}, {"source": "security-advisories@github.com", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-5wpj-c6f7-24x8"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-20"}, {"lang": "en", "value": "CWE-475"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/tensorflow/tensorflow/commit/a5b89cd68c02329d793356bda85d079e9e69b4e7"}, "type": "CWE-20"}
| 216
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"#!/bin/bash\nif [ \"$INITIALIZED\" != defined ]; then",
"",
" now() {\n date +'%s%N'\n }\n start=$(now)\n temp=\"${temp:-/tmp/spelling}\"\n mkdir -p $temp\n export temp\n if [ -n \"$DEBUG\" ]; then\n set -x\n begin_group() {\n echo \"::group::$1\"\n }\n end_group() {\n echo '::end_group::'\n }\n else\n begin_group() {\n echo \"(...$1...)\"\n }\n end_group() {\n :\n }\n INITIALIZED=defined\n fi\nfi"
] |
[
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [2, 22, 377], "buggy_code_start_loc": [2, 19, 376], "filenames": ["common.sh", "spelling-unknown-word-splitter.pl", "unknown-words.sh"], "fixing_code_end_loc": [8, 22, 398], "fixing_code_start_loc": [3, 19, 376], "message": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:check-spelling:check-spelling:*:*:*:*:*:*:*:*", "matchCriteriaId": "A4A73141-03F7-4AAB-A7E3-6D2331D73257", "versionEndExcluding": "0.0.19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target."}, {"lang": "es", "value": "check-spelling es una acci\u00f3n de github que proporciona una comprobaci\u00f3n ortogr\u00e1fica de CI. En versiones afectadas y para un repositorio con la acci\u00f3n [check-spelling](https://github.com/marketplace/actions/check-spelling) habilitada que desencadena en \"pull_request_target\" (o \"schedule\"), un atacante puede enviar un Pull Request dise\u00f1ado que cause que un \"GITHUB_TOKEN\" sea expuesto. Con el \"GITHUB_TOKEN\", es posible enviar confirmaciones al commit omitiendo los procesos de aprobaci\u00f3n est\u00e1ndar. Los commits al repositorio podr\u00edan entonces robar cualquier/todos los secretos disponibles en el repositorio. Como soluci\u00f3n, los usuarios pueden: [Desactivar el flujo de trabajo](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) hasta que haya corregido todas las ramas o Configurar el repositorio para [Permitir acciones espec\u00edficas](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). la comprobaci\u00f3n de la ortograf\u00eda no es un creador verificado y ciertamente no lo ser\u00e1 pronto. Entonces podr\u00eda a\u00f1adir expl\u00edcitamente otras acciones que su repositorio usa. Ajuste el repositorio [Permisos de flujo de trabajo](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) a \"Read repository contents permission\". Los flujos de trabajo que usen \"check-spelling/check-spelling@main\" obtendr\u00e1n la correcci\u00f3n autom\u00e1ticamente. Los flujos de trabajo que usen una versi\u00f3n con anclaje o etiquetada tendr\u00e1n que cambiar los flujos de trabajo afectados para todas las ramas del repositorio a la \u00faltima versi\u00f3n. Los usuarios pueden verificar qui\u00e9n y qu\u00e9 Pull Requests han ejecutado la acci\u00f3n buscando la acci\u00f3n spelling.yml en la pesta\u00f1a Acciones de sus repositorios, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - puede filtrar los PRs al a\u00f1adir ?query=event%3Apull_request_target, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target"}], "evaluatorComment": null, "id": "CVE-2021-32724", "lastModified": "2021-09-27T14:21:55.153", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 6.8, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 6.4, "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": 9.9, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "CHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.1, "impactScore": 6.0, "source": "security-advisories@github.com", "type": "Primary"}]}, "published": "2021-09-09T21:15:07.250", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, {"source": "security-advisories@github.com", "tags": ["Mitigation", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/security/advisories/GHSA-g86g-chm8-7r2p"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-532"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, "type": "CWE-532"}
| 217
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"#!/bin/bash\nif [ \"$INITIALIZED\" != defined ]; then",
" if [ \"$RUNNER_OS\" = \"Windows\" ]; then\n echo \"::error ::Windows isn't currently supported\"\n exit 5\n fi\n",
" now() {\n date +'%s%N'\n }\n start=$(now)\n temp=\"${temp:-/tmp/spelling}\"\n mkdir -p $temp\n export temp\n if [ -n \"$DEBUG\" ]; then\n set -x\n begin_group() {\n echo \"::group::$1\"\n }\n end_group() {\n echo '::end_group::'\n }\n else\n begin_group() {\n echo \"(...$1...)\"\n }\n end_group() {\n :\n }\n INITIALIZED=defined\n fi\nfi"
] |
[
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [2, 22, 377], "buggy_code_start_loc": [2, 19, 376], "filenames": ["common.sh", "spelling-unknown-word-splitter.pl", "unknown-words.sh"], "fixing_code_end_loc": [8, 22, 398], "fixing_code_start_loc": [3, 19, 376], "message": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:check-spelling:check-spelling:*:*:*:*:*:*:*:*", "matchCriteriaId": "A4A73141-03F7-4AAB-A7E3-6D2331D73257", "versionEndExcluding": "0.0.19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target."}, {"lang": "es", "value": "check-spelling es una acci\u00f3n de github que proporciona una comprobaci\u00f3n ortogr\u00e1fica de CI. En versiones afectadas y para un repositorio con la acci\u00f3n [check-spelling](https://github.com/marketplace/actions/check-spelling) habilitada que desencadena en \"pull_request_target\" (o \"schedule\"), un atacante puede enviar un Pull Request dise\u00f1ado que cause que un \"GITHUB_TOKEN\" sea expuesto. Con el \"GITHUB_TOKEN\", es posible enviar confirmaciones al commit omitiendo los procesos de aprobaci\u00f3n est\u00e1ndar. Los commits al repositorio podr\u00edan entonces robar cualquier/todos los secretos disponibles en el repositorio. Como soluci\u00f3n, los usuarios pueden: [Desactivar el flujo de trabajo](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) hasta que haya corregido todas las ramas o Configurar el repositorio para [Permitir acciones espec\u00edficas](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). la comprobaci\u00f3n de la ortograf\u00eda no es un creador verificado y ciertamente no lo ser\u00e1 pronto. Entonces podr\u00eda a\u00f1adir expl\u00edcitamente otras acciones que su repositorio usa. Ajuste el repositorio [Permisos de flujo de trabajo](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) a \"Read repository contents permission\". Los flujos de trabajo que usen \"check-spelling/check-spelling@main\" obtendr\u00e1n la correcci\u00f3n autom\u00e1ticamente. Los flujos de trabajo que usen una versi\u00f3n con anclaje o etiquetada tendr\u00e1n que cambiar los flujos de trabajo afectados para todas las ramas del repositorio a la \u00faltima versi\u00f3n. Los usuarios pueden verificar qui\u00e9n y qu\u00e9 Pull Requests han ejecutado la acci\u00f3n buscando la acci\u00f3n spelling.yml en la pesta\u00f1a Acciones de sus repositorios, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - puede filtrar los PRs al a\u00f1adir ?query=event%3Apull_request_target, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target"}], "evaluatorComment": null, "id": "CVE-2021-32724", "lastModified": "2021-09-27T14:21:55.153", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 6.8, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 6.4, "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": 9.9, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "CHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.1, "impactScore": 6.0, "source": "security-advisories@github.com", "type": "Primary"}]}, "published": "2021-09-09T21:15:07.250", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, {"source": "security-advisories@github.com", "tags": ["Mitigation", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/security/advisories/GHSA-g86g-chm8-7r2p"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-532"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, "type": "CWE-532"}
| 217
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"#!/bin/sh\n#! -*-perl-*-\neval 'exec perl -x -T -w $0 ${1+\"$@\"}'\n if 0;\n# ~/bin/w\n# Search for potentially misspelled words\n# Output is:\n# misspellled\n# woord (WOORD, Woord, woord, woord's)",
"use File::Basename;\nuse Cwd 'abs_path';\nuse File::Temp qw/ tempfile tempdir /;",
"my $dirname = dirname(abs_path(__FILE__));",
"# skip files that don't exist (including dangling symlinks)\nif (scalar @ARGV) {",
" @ARGV = grep {-r || $_ eq '-'} @ARGV;",
" unless (scalar @ARGV) {",
" print STDERR \"None of the provided files are readable\\n\";",
" exit 0;\n }\n}",
"my $patterns_re = '^$';\nif (open(PATTERNS, '<', \"$dirname/patterns.txt\")) {\n my @patterns;\n local $/=undef;\n local $file=<PATTERNS>;\n close PATTERNS;\n for (split /\\R/, $file) {\n next if /^#/;\n chomp;\n next unless s/^(.+)/(?:$1)/;\n push @patterns, $_;\n }\n $patterns_re = join \"|\", @patterns if scalar @patterns;\n}",
"my $longest_word = get_val_from_env('INPUT_LONGEST_WORD', '');\nmy $shortest_word = get_val_from_env('INPUT_SHORTEST_WORD', '');",
"my ($shortest, $longest) = (undef, undef);\nsub valid_word {\n # shortest_word is an absolute\n $shortest = $shortest_word if $shortest_word;\n if ($longest_word) {\n # longest_word is an absolute\n $longest = $longest_word;\n } elsif (defined $longest) {\n # we allow for some sloppiness (a couple of stuck keys per word)\n # it's possible that this should scale with word length\n $longest += 2;\n }\n return /.../ if (defined $shortest && defined $longest) && ($shortest > $longest);\n $shortest = 3 unless defined $shortest;\n $longest = '' unless defined $longest;\n $word_match = \".{$shortest,$longest}\";\n return qr/\\b$word_match\\b/;\n}",
"my $word_match = valid_word();\n($shortest, $longest) = (255, 0);\n# load dictionary\nmy $dict = \"$dirname/words\";\n$dict = '/usr/share/dict/words' unless -e $dict;\nopen(DICT, '<', $dict);\nmy %dictionary=();\nwhile ($word = <DICT>) {\n chomp $word;\n next unless $word =~ $word_match;\n my $l = length $word;\n $longest = $l if $l > $longest;\n $shortest = $l if $l < $shortest;\n $dictionary{$word}=1;\n}\nclose DICT;",
"sub get_val_from_env {\n my ($var, $fallback) = @_;\n return $fallback unless defined $ENV{$var};\n $ENV{$var} =~ /^(\\d+)$/;\n return $1 || $fallback;\n}",
"$word_match = valid_word();",
"# read all input\nmy ($last_file, $temp_dir, $words, $unrecognized) = ('', '', 0, 0);\nmy %unique;\nmy %unique_unrecognized;\nmy @reports;",
"sub report_stats() {\n if ($unrecognized) {\n open(STATS, '>', \"$temp_dir/stats\");\n print STATS \"{words: $words, unrecognized: $unrecognized, unknown: \".(keys %unique_unrecognized).\", unique: \".(keys %unique).\"}\";\n close STATS;\n open(UNKNOWN, '>', \"$temp_dir/unknown\");\n print UNKNOWN join \"\\n\", sort keys %unique_unrecognized;\n close UNKNOWN;\n close WARNINGS;\n }\n}",
"while (<<>>) {\n if ($last_file ne $ARGV) {\n $. = 1;\n $last_file = $ARGV;\n report_stats();",
" $temp_dir = tempdir();\n push @reports, \"$temp_dir\\n\";\n open(NAME, '>', \"$temp_dir/name\");\n print NAME $last_file;\n close NAME;\n ($words, $unrecognized) = (0, 0);\n %unique = ();\n %unique_unrecognized = ();\n open(WARNINGS, '>', \"$temp_dir/warnings\");\n }\n next unless /./;\n my $raw_line = $_;\n # hook for custom line based text exclusions:\n s/$patterns_re/ /g;\n # This is to make it easier to deal w/ rules:\n s/^/ /;\n while (s/([^\\\\])\\\\[rtn]/$1 /g) {}\n # https://www.fileformat.info/info/unicode/char/2019/\n my $rsqm = \"\\xE2\\x80\\x99\";\n s/$rsqm|'|'/'/g;\n s/[^a-zA-Z']+/ /g;\n while (s/([A-Z]{2,})([A-Z][a-z]{2,})/ $1 $2 /g) {}\n while (s/([a-z']+)([A-Z])/$1 $2/g) {}\n my %unrecognized_line_items = ();\n for my $token (split /\\s+/, $_) {\n $token =~ s/^(?:'|$rsqm)+//g;\n $token =~ s/(?:'|$rsqm)+s?$//g;\n my $raw_token = $token;\n $token =~ s/^[^Ii]?'+(.*)/$1/;\n $token =~ s/(.*?)'+$/$1/;\n next unless $token =~ $word_match;\n if (defined $dictionary{$token}) {\n ++$words;\n $unique{$token}=1;\n next;\n }\n my $key = lc $token;\n $key =~ s/''+/'/g;\n $key =~ s/'[sd]$//;\n if (defined $dictionary{$key}) {\n ++$words;\n $unique{$key}=1;\n next;\n }\n ++$unrecognized;\n $unique_unrecognized{$raw_token}=1;\n $unrecognized_line_items{$raw_token}=1;\n }\n for my $token (keys %unrecognized_line_items) {\n $token =~ s/'/(?:'|$rsqm)+/g;\n while ($raw_line =~ /\\b($token)\\b/g) {\n my ($begin, $end, $match) = ($-[0] + 1, $+[0] + 1, $1);\n next unless $match =~ /./;\n print WARNINGS \"line $. cols $begin-$end: '$match'\\n\";\n }\n }\n}\nreport_stats();\nprint join '', @reports;"
] |
[
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [2, 22, 377], "buggy_code_start_loc": [2, 19, 376], "filenames": ["common.sh", "spelling-unknown-word-splitter.pl", "unknown-words.sh"], "fixing_code_end_loc": [8, 22, 398], "fixing_code_start_loc": [3, 19, 376], "message": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:check-spelling:check-spelling:*:*:*:*:*:*:*:*", "matchCriteriaId": "A4A73141-03F7-4AAB-A7E3-6D2331D73257", "versionEndExcluding": "0.0.19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target."}, {"lang": "es", "value": "check-spelling es una acci\u00f3n de github que proporciona una comprobaci\u00f3n ortogr\u00e1fica de CI. En versiones afectadas y para un repositorio con la acci\u00f3n [check-spelling](https://github.com/marketplace/actions/check-spelling) habilitada que desencadena en \"pull_request_target\" (o \"schedule\"), un atacante puede enviar un Pull Request dise\u00f1ado que cause que un \"GITHUB_TOKEN\" sea expuesto. Con el \"GITHUB_TOKEN\", es posible enviar confirmaciones al commit omitiendo los procesos de aprobaci\u00f3n est\u00e1ndar. Los commits al repositorio podr\u00edan entonces robar cualquier/todos los secretos disponibles en el repositorio. Como soluci\u00f3n, los usuarios pueden: [Desactivar el flujo de trabajo](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) hasta que haya corregido todas las ramas o Configurar el repositorio para [Permitir acciones espec\u00edficas](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). la comprobaci\u00f3n de la ortograf\u00eda no es un creador verificado y ciertamente no lo ser\u00e1 pronto. Entonces podr\u00eda a\u00f1adir expl\u00edcitamente otras acciones que su repositorio usa. Ajuste el repositorio [Permisos de flujo de trabajo](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) a \"Read repository contents permission\". Los flujos de trabajo que usen \"check-spelling/check-spelling@main\" obtendr\u00e1n la correcci\u00f3n autom\u00e1ticamente. Los flujos de trabajo que usen una versi\u00f3n con anclaje o etiquetada tendr\u00e1n que cambiar los flujos de trabajo afectados para todas las ramas del repositorio a la \u00faltima versi\u00f3n. Los usuarios pueden verificar qui\u00e9n y qu\u00e9 Pull Requests han ejecutado la acci\u00f3n buscando la acci\u00f3n spelling.yml en la pesta\u00f1a Acciones de sus repositorios, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - puede filtrar los PRs al a\u00f1adir ?query=event%3Apull_request_target, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target"}], "evaluatorComment": null, "id": "CVE-2021-32724", "lastModified": "2021-09-27T14:21:55.153", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 6.8, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 6.4, "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": 9.9, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "CHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.1, "impactScore": 6.0, "source": "security-advisories@github.com", "type": "Primary"}]}, "published": "2021-09-09T21:15:07.250", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, {"source": "security-advisories@github.com", "tags": ["Mitigation", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/security/advisories/GHSA-g86g-chm8-7r2p"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-532"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, "type": "CWE-532"}
| 217
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"#!/bin/sh\n#! -*-perl-*-\neval 'exec perl -x -T -w $0 ${1+\"$@\"}'\n if 0;\n# ~/bin/w\n# Search for potentially misspelled words\n# Output is:\n# misspellled\n# woord (WOORD, Woord, woord, woord's)",
"use File::Basename;\nuse Cwd 'abs_path';\nuse File::Temp qw/ tempfile tempdir /;",
"my $dirname = dirname(abs_path(__FILE__));",
"# skip files that don't exist (including dangling symlinks)\nif (scalar @ARGV) {",
" @ARGV = grep {! -l && -f && -r} @ARGV;",
" unless (scalar @ARGV) {",
" print STDERR \"::warning ::Was not provided any regular readable files\\n\";",
" exit 0;\n }\n}",
"my $patterns_re = '^$';\nif (open(PATTERNS, '<', \"$dirname/patterns.txt\")) {\n my @patterns;\n local $/=undef;\n local $file=<PATTERNS>;\n close PATTERNS;\n for (split /\\R/, $file) {\n next if /^#/;\n chomp;\n next unless s/^(.+)/(?:$1)/;\n push @patterns, $_;\n }\n $patterns_re = join \"|\", @patterns if scalar @patterns;\n}",
"my $longest_word = get_val_from_env('INPUT_LONGEST_WORD', '');\nmy $shortest_word = get_val_from_env('INPUT_SHORTEST_WORD', '');",
"my ($shortest, $longest) = (undef, undef);\nsub valid_word {\n # shortest_word is an absolute\n $shortest = $shortest_word if $shortest_word;\n if ($longest_word) {\n # longest_word is an absolute\n $longest = $longest_word;\n } elsif (defined $longest) {\n # we allow for some sloppiness (a couple of stuck keys per word)\n # it's possible that this should scale with word length\n $longest += 2;\n }\n return /.../ if (defined $shortest && defined $longest) && ($shortest > $longest);\n $shortest = 3 unless defined $shortest;\n $longest = '' unless defined $longest;\n $word_match = \".{$shortest,$longest}\";\n return qr/\\b$word_match\\b/;\n}",
"my $word_match = valid_word();\n($shortest, $longest) = (255, 0);\n# load dictionary\nmy $dict = \"$dirname/words\";\n$dict = '/usr/share/dict/words' unless -e $dict;\nopen(DICT, '<', $dict);\nmy %dictionary=();\nwhile ($word = <DICT>) {\n chomp $word;\n next unless $word =~ $word_match;\n my $l = length $word;\n $longest = $l if $l > $longest;\n $shortest = $l if $l < $shortest;\n $dictionary{$word}=1;\n}\nclose DICT;",
"sub get_val_from_env {\n my ($var, $fallback) = @_;\n return $fallback unless defined $ENV{$var};\n $ENV{$var} =~ /^(\\d+)$/;\n return $1 || $fallback;\n}",
"$word_match = valid_word();",
"# read all input\nmy ($last_file, $temp_dir, $words, $unrecognized) = ('', '', 0, 0);\nmy %unique;\nmy %unique_unrecognized;\nmy @reports;",
"sub report_stats() {\n if ($unrecognized) {\n open(STATS, '>', \"$temp_dir/stats\");\n print STATS \"{words: $words, unrecognized: $unrecognized, unknown: \".(keys %unique_unrecognized).\", unique: \".(keys %unique).\"}\";\n close STATS;\n open(UNKNOWN, '>', \"$temp_dir/unknown\");\n print UNKNOWN join \"\\n\", sort keys %unique_unrecognized;\n close UNKNOWN;\n close WARNINGS;\n }\n}",
"while (<<>>) {\n if ($last_file ne $ARGV) {\n $. = 1;\n $last_file = $ARGV;\n report_stats();",
" $temp_dir = tempdir();\n push @reports, \"$temp_dir\\n\";\n open(NAME, '>', \"$temp_dir/name\");\n print NAME $last_file;\n close NAME;\n ($words, $unrecognized) = (0, 0);\n %unique = ();\n %unique_unrecognized = ();\n open(WARNINGS, '>', \"$temp_dir/warnings\");\n }\n next unless /./;\n my $raw_line = $_;\n # hook for custom line based text exclusions:\n s/$patterns_re/ /g;\n # This is to make it easier to deal w/ rules:\n s/^/ /;\n while (s/([^\\\\])\\\\[rtn]/$1 /g) {}\n # https://www.fileformat.info/info/unicode/char/2019/\n my $rsqm = \"\\xE2\\x80\\x99\";\n s/$rsqm|'|'/'/g;\n s/[^a-zA-Z']+/ /g;\n while (s/([A-Z]{2,})([A-Z][a-z]{2,})/ $1 $2 /g) {}\n while (s/([a-z']+)([A-Z])/$1 $2/g) {}\n my %unrecognized_line_items = ();\n for my $token (split /\\s+/, $_) {\n $token =~ s/^(?:'|$rsqm)+//g;\n $token =~ s/(?:'|$rsqm)+s?$//g;\n my $raw_token = $token;\n $token =~ s/^[^Ii]?'+(.*)/$1/;\n $token =~ s/(.*?)'+$/$1/;\n next unless $token =~ $word_match;\n if (defined $dictionary{$token}) {\n ++$words;\n $unique{$token}=1;\n next;\n }\n my $key = lc $token;\n $key =~ s/''+/'/g;\n $key =~ s/'[sd]$//;\n if (defined $dictionary{$key}) {\n ++$words;\n $unique{$key}=1;\n next;\n }\n ++$unrecognized;\n $unique_unrecognized{$raw_token}=1;\n $unrecognized_line_items{$raw_token}=1;\n }\n for my $token (keys %unrecognized_line_items) {\n $token =~ s/'/(?:'|$rsqm)+/g;\n while ($raw_line =~ /\\b($token)\\b/g) {\n my ($begin, $end, $match) = ($-[0] + 1, $+[0] + 1, $1);\n next unless $match =~ /./;\n print WARNINGS \"line $. cols $begin-$end: '$match'\\n\";\n }\n }\n}\nreport_stats();\nprint join '', @reports;"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [2, 22, 377], "buggy_code_start_loc": [2, 19, 376], "filenames": ["common.sh", "spelling-unknown-word-splitter.pl", "unknown-words.sh"], "fixing_code_end_loc": [8, 22, 398], "fixing_code_start_loc": [3, 19, 376], "message": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:check-spelling:check-spelling:*:*:*:*:*:*:*:*", "matchCriteriaId": "A4A73141-03F7-4AAB-A7E3-6D2331D73257", "versionEndExcluding": "0.0.19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target."}, {"lang": "es", "value": "check-spelling es una acci\u00f3n de github que proporciona una comprobaci\u00f3n ortogr\u00e1fica de CI. En versiones afectadas y para un repositorio con la acci\u00f3n [check-spelling](https://github.com/marketplace/actions/check-spelling) habilitada que desencadena en \"pull_request_target\" (o \"schedule\"), un atacante puede enviar un Pull Request dise\u00f1ado que cause que un \"GITHUB_TOKEN\" sea expuesto. Con el \"GITHUB_TOKEN\", es posible enviar confirmaciones al commit omitiendo los procesos de aprobaci\u00f3n est\u00e1ndar. Los commits al repositorio podr\u00edan entonces robar cualquier/todos los secretos disponibles en el repositorio. Como soluci\u00f3n, los usuarios pueden: [Desactivar el flujo de trabajo](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) hasta que haya corregido todas las ramas o Configurar el repositorio para [Permitir acciones espec\u00edficas](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). la comprobaci\u00f3n de la ortograf\u00eda no es un creador verificado y ciertamente no lo ser\u00e1 pronto. Entonces podr\u00eda a\u00f1adir expl\u00edcitamente otras acciones que su repositorio usa. Ajuste el repositorio [Permisos de flujo de trabajo](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) a \"Read repository contents permission\". Los flujos de trabajo que usen \"check-spelling/check-spelling@main\" obtendr\u00e1n la correcci\u00f3n autom\u00e1ticamente. Los flujos de trabajo que usen una versi\u00f3n con anclaje o etiquetada tendr\u00e1n que cambiar los flujos de trabajo afectados para todas las ramas del repositorio a la \u00faltima versi\u00f3n. Los usuarios pueden verificar qui\u00e9n y qu\u00e9 Pull Requests han ejecutado la acci\u00f3n buscando la acci\u00f3n spelling.yml en la pesta\u00f1a Acciones de sus repositorios, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - puede filtrar los PRs al a\u00f1adir ?query=event%3Apull_request_target, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target"}], "evaluatorComment": null, "id": "CVE-2021-32724", "lastModified": "2021-09-27T14:21:55.153", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 6.8, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 6.4, "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": 9.9, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "CHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.1, "impactScore": 6.0, "source": "security-advisories@github.com", "type": "Primary"}]}, "published": "2021-09-09T21:15:07.250", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, {"source": "security-advisories@github.com", "tags": ["Mitigation", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/security/advisories/GHSA-g86g-chm8-7r2p"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-532"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, "type": "CWE-532"}
| 217
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"#!/bin/bash\n# This CI acceptance test is based on:\n# https://github.com/jsoref/spelling/tree/04648bdc63723e5cdf5cbeaff2225a462807abc8\n# It is conceptually `f` which runs `w` (spelling-unknown-word-splitter)\n# plus `fchurn` which uses `dn` mostly rolled together.\nset -e\nexport spellchecker=${spellchecker:-/app}\n. \"$spellchecker/common.sh\"",
"main() {\n GITHUB_TOKEN=${GITHUB_TOKEN:-$INPUT_GITHUB_TOKEN}\n if [ -z \"$GITHUB_EVENT_PATH\" ] || [ ! -e \"$GITHUB_EVENT_PATH\" ]; then\n GITHUB_EVENT_PATH=/dev/null\n fi\n case \"$GITHUB_EVENT_NAME\" in\n schedule)\n exec \"$spellchecker/check-pull-requests.sh\"\n ;;\n issue_comment)\n if [ -n \"$DEBUG\" ]; then\n set -x\n fi\n handle_comment\n ;;\n pull_request_review_comment)\n (\n echo 'check-spelling does not currently support comments on code.'\n echo 'If you are trying to ask @check-spelling-bot to update a PR,'\n echo 'please quote the comment link as a top level comment instead'\n echo 'of in a comment on a block of code.'\n echo\n echo 'Future versions may support this feature.'\n echo 'For the time being, early adopters should remove the'\n echo '`pull_request_review_comment` event from their workflow.'\n echo 'workflow.'\n ) >&2\n exit 0\n ;;\n esac\n}",
"offer_quote_reply() {\n case \"$INPUT_EXPERIMENTAL_APPLY_CHANGES_VIA_BOT\" in\n 1|true|TRUE)\n case \"$GITHUB_EVENT_NAME\" in\n issue_comment|pull_request|pull_request_target)\n true;;\n *)\n false;;\n esac\n ;;\n *)\n false\n ;;\n esac\n}",
"repo_is_private() {\n private=$(jq -r .repository.private < \"$GITHUB_EVENT_PATH\")\n [ \"$private\" = \"true\" ]\n}",
"command_v() {\n command -v \"$1\" >/dev/null 2>/dev/null\n}",
"react_comment_and_die() {\n trigger_comment_url=\"$1\"\n message=\"$2\"\n react=\"$3\"\n echo \"::error ::$message\"\n react \"$trigger_comment_url\" \"$react\" > /dev/null\n if [ -n \"$COMMENTS_URL\" ] && [ -z \"${COMMENTS_URL##*:*}\" ]; then\n PAYLOAD=$(mktemp_json)\n echo '{}' | jq --arg body \"@check-spelling-bot: $react_prefix $message\" '.body = $body' > $PAYLOAD",
" res=0\n comment \"$COMMENTS_URL\" \"$PAYLOAD\" > /dev/null || res=$?\n if [ $res -gt 0 ]; then\n if [ -z \"$DEBUG\" ]; then\n echo \"failed posting to $COMMENTS_URL\"\n echo \"$PAYLOAD\"\n fi\n return $res\n fi",
" rm $PAYLOAD\n fi\n exit 1\n}",
"confused_comment() {\n react_comment_and_die \"$1\" \"$2\" \"confused\"\n}",
"github_user_and_email() {\n user_json=$(mktemp_json)\n curl -s \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n \"$GITHUB_API_URL/users/$1\" > $user_json",
" github_name=$(jq -r '.name // empty' < $user_json)\n if [ -z \"$github_name\" ]; then\n github_name=$1\n fi\n github_email=$(jq -r '.email // empty' < $user_json)\n rm $user_json\n if [ -z \"$github_email\" ]; then\n github_email=\"$1@users.noreply.github.com\"\n fi\n COMMIT_AUTHOR=\"--author=$github_name <$github_email>\"\n}",
"git_commit() {\n reason=\"$1\"\n git add -u\n git config user.email \"check-spelling-bot@users.noreply.github.com\"\n git config user.name \"check-spelling-bot\"\n git commit \\\n \"$COMMIT_AUTHOR\" \\\n --date=\"$created_at\" \\\n -m \"$(echo \"[check-spelling] Applying automated metadata updates",
" $reason",
" Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>\n \" | strip_lead)\"\n}",
"mktemp_json() {\n file=$(mktemp)\n mv \"$file\" \"$file.json\"\n echo \"$file.json\"\n}",
"handle_comment() {\n if ! offer_quote_reply; then\n exit 0\n fi",
" action=$(jq -r .action < \"$GITHUB_EVENT_PATH\")\n if [ \"$action\" != \"created\" ]; then\n exit 0\n fi",
" comment=$(mktemp_json)\n jq -r .comment < \"$GITHUB_EVENT_PATH\" > $comment\n body=$(mktemp)\n jq -r .body $comment > $body",
" trigger=$(perl -ne 'print if /\\@check-spelling-bot(?:\\s+|:\\s*)apply/' < $body)\n rm $body\n if [ -z \"$trigger\" ]; then\n exit 0\n fi",
" trigger_comment_url=$(jq -r .url < $comment)\n sender_login=$(jq -r .sender.login < \"$GITHUB_EVENT_PATH\")\n issue_user_login=$(jq -r .issue.user.login < \"$GITHUB_EVENT_PATH\")\n issue=$(mktemp_json)\n jq -r .issue < \"$GITHUB_EVENT_PATH\" > $issue\n pull_request_url=$(jq -r .pull_request.url < $issue)\n pull_request_info=$(mktemp_json)\n pull_request \"$pull_request_url\" | jq .head > $pull_request_info\n pull_request_sha=$(jq -r .sha < $pull_request_info)\n set_comments_url \"$GITHUB_EVENT_NAME\" \"$GITHUB_EVENT_PATH\" \"$pull_request_sha\"\n react_prefix_base=\"Could not perform [request]($trigger_comment_url).\"\n react_prefix=\"$react_prefix_base\"\n if [ \"$sender_login\" != \"$issue_user_login\" ]; then\n collaborators_url=$(jq -r .repository.collaborators_url < \"$GITHUB_EVENT_PATH\")\n collaborators_url=$(echo \"$collaborators_url\" | perl -pne \"s<\\{/collaborator\\}></$sender_login/permission>\")\n collaborator_permission=$(collaborator \"$collaborators_url\" | jq -r .permission)\n case $collaborator_permission in\n admin)\n ;;\n write)\n ;;\n *)\n confused_comment \"$trigger_comment_url\" \"Commenter (@$sender_login) isn't author (@$issue_user_login) / collaborator\"\n ;;\n esac\n fi\n number=$(jq -r .number < $issue)\n created_at=$(jq -r .created_at < $comment)\n issue_url=$(jq -r .url < $issue)\n pull_request_ref=$(jq -r .ref < $pull_request_info)\n pull_request_repo=$(jq -r .repo.clone_url < $pull_request_info)\n git remote add request $pull_request_repo\n git fetch request \"$pull_request_sha\"\n git config advice.detachedHead false\n git reset --hard\n git checkout \"$pull_request_sha\"",
" number_filter() {\n perl -pne 's/\\{.*\\}//'\n }\n comments_base=$(jq -r .repository.comments_url < \"$GITHUB_EVENT_PATH\" | number_filter)\n issue_comments_base=$(jq -r .repository.issue_comment_url < \"$GITHUB_EVENT_PATH\" | number_filter)\n export comments_url=\"$comments_base|$issue_comments_base\"\n comment_url=$(echo \"$trigger\" | perl -ne 'next unless m{((?:$ENV{comments_url})/\\d+)}; print \"$1\\n\";')\n [ -n \"$comment_url\" ] ||\n confused_comment \"$trigger_comment_url\" \"Did not find $comments_url in comment\"",
" res=0\n comment \"$comment_url\" > $comment || res=$?\n if [ $res -gt 0 ]; then\n if [ -z \"$DEBUG\" ]; then\n echo \"failed to retrieve $comment_url\"\n fi\n return $res\n fi",
" comment_body=$(mktemp)\n jq -r .body < $comment > $comment_body\n bot_comment_author=$(jq -r .user.login < $comment)\n bot_comment_node_id=$(jq -r .node_id < $comment)\n bot_comment_url=$(jq -r '.issue_url // .comment.url' < $comment)\n rm $comment\n github_actions_bot=\"github-actions[bot]\"\n [ \"$bot_comment_author\" = \"$github_actions_bot\" ] ||\n confused_comment \"$trigger_comment_url\" \"Expected @$github_actions_bot to be author of $comment_url (found @$bot_comment_author)\"\n [ \"$issue_url\" = \"$bot_comment_url\" ] ||\n confused_comment \"$trigger_comment_url\" \"Referenced comment was for a different object: $bot_comment_url\"\n capture_items() {\n perl -ne 'next unless s{^\\s*my \\@'$1'=qw\\('$q$Q'(.*)'$Q$q'\\);$}{$1}; print'\n }\n capture_item() {\n perl -ne 'next unless s{^\\s*my \\$'$1'=\"(.*)\";$}{$1}; print'\n }\n skip_wrapping=1",
" instructions_head=$(mktemp)\n (\n patch_add=1\n patch_remove=1\n should_exclude_patterns=1\n patch_variables $comment_body > $instructions_head\n )\n git restore $bucket/$project",
" res=0\n . $instructions_head || res=$?\n if [ $res -gt 0 ]; then\n echo \"instructions_head failed ($res)\"\n cat $instructions_head\n return $res\n fi\n rm $comment_body $instructions_head\n instructions=$(generate_instructions)",
" react_prefix=\"$react_prefix [Instructions]($comment_url)\"\n . $instructions || res=$?\n if [ $res -gt 0 ]; then\n echo \"instructions failed ($res)\"\n cat $instructions\n res=0\n confused_comment \"$trigger_comment_url\" \"failed to apply\"\n fi\n rm $instructions\n git status --u=no --porcelain | grep -q . ||\n confused_comment \"$trigger_comment_url\" \"didn't change repository\"\n react_prefix=\"$react_prefix_base\"\n github_user_and_email $sender_login\n git_commit \"$(echo \"Update per $comment_url\n Accepted in $trigger_comment_url\n \"|strip_lead)\" ||\n confused_comment \"$trigger_comment_url\" \"Failed to generate commit\"\n git push request \"HEAD:$pull_request_ref\" ||\n confused_comment \"$trigger_comment_url\" \"Failed to push to $pull_request_repo\"",
" react \"$trigger_comment_url\" 'eyes' > /dev/null\n react \"$comment_url\" 'rocket' > /dev/null\n trigger_node=$(jq -r .comment.node_id < \"$GITHUB_EVENT_PATH\")\n collapse_comment $trigger_node $bot_comment_node_id",
" echo \"# end\"\n exit 0\n}",
"define_variables() {\n bucket=${INPUT_BUCKET:-$bucket}\n project=${INPUT_PROJECT:-$project}\n if [ -z \"$bucket\" ] && [ -z \"$project\" ] && [ -n \"$INPUT_CONFIG\" ]; then\n bucket=${INPUT_CONFIG%/*}\n project=${INPUT_CONFIG##*/}\n fi\n job_count=${INPUT_EXPERIMENTAL_PARALLEL_JOBS:-2}\n if ! [ \"$job_count\" -eq \"$job_count\" ] 2>/dev/null || [ \"$job_count\" -lt 2 ]; then\n job_count=1\n fi",
" dict=\"$spellchecker/words\"\n patterns=\"$spellchecker/patterns.txt\"\n excludes=\"$spellchecker/excludes.txt\"\n excludes_path=\"$temp/excludes.txt\"\n only=\"$spellchecker/only.txt\"\n only_path=\"$temp/only.txt\"\n dictionary_path=\"$temp/dictionary.txt\"\n allow_path=\"$temp/allow.txt\"\n reject_path=\"$temp/reject.txt\"\n expect_path=\"$temp/expect.words.txt\"\n excludelist_path=\"$temp/excludes.txt\"\n patterns_path=\"$temp/patterns.txt\"\n advice_path=\"$temp/advice.md\"\n advice_path_txt=\"$temp/advice.txt\"\n word_splitter=\"$spellchecker/spelling-unknown-word-splitter.pl\"\n word_collator=\"$spellchecker/spelling-collator.pl\"\n run_output=\"$temp/unknown.words.txt\"\n run_files=\"$temp/reporter-input.txt\"\n tokens_file=\"$temp/tokens.txt\"\n}",
"sort_unique() {\n sort -u -f \"$@\" | perl -ne 'next unless /./; print'\n}",
"project_file_path() {\n ext=$(echo \"$2\" | sed -e 's/^.*\\.//')\n echo $bucket/$project/$1.${ext:-txt}\n}",
"check_pattern_file() {\n perl -i -e 'while (<>) {\n next if /^#/;\n next unless /./;\n if (eval {qr/$_/}) {\n print;\n } else {\n $@ =~ s/(.*?)\\n.*/$1/m;\n chomp $@;\n my $err = $@;\n $err =~ s{^.*? in regex; marked by <-- HERE in m/(.*) <-- HERE.*$}{$1};\n print STDERR \"$ARGV: line $., columns $-[0]-$-[0], Warning - bad regex (bad-regex)\\n$@\\n\";\n print \"^\\$\\n\";\n }\n }' $1\n}",
"check_for_newline_at_eof() {\n maybe_missing_eol=\"$1\"\n if [ -s \"$maybe_missing_eol\" ] && [ $(tail -1 \"$maybe_missing_eol\" | wc -l) -eq 0 ]; then\n line=$(( $(cat \"$maybe_missing_eol\" | wc -l) + 1 ))\n start=$(tail -1 \"$maybe_missing_eol\" | wc -c)\n stop=$(( $start + 1 ))\n echo \"$maybe_missing_eol: line $line, columns $start-$stop, Warning - no newline at eof (no-newline-at-eof)\" >&2\n echo >> \"$maybe_missing_eol\"\n fi\n}",
"check_dictionary() {\n file=\"$1\"\n expected_chars=\"[a-zA-Z']\"\n unexpected_chars=\"[^a-zA-Z']\"\n (perl -pi -e '\n chomp;\n my $messy = 0;\n my $orig = $_;\n if (s/\\n|\\r|\\x0b|\\f|\\x85|\\x2028|\\x2029/a/g) {\n $messy = 1;\n }\n if ('\"/^${expected_chars}*(${unexpected_chars}+)/\"') {\n print STDERR \"$ARGV: line $., columns $-[1]-$+[1], Warning - ignoring entry because it contains non alpha characters (non-alpha-in-dictionary)\\n\";\n $_ = \"\";\n } else {\n if ($messy) {\n $_ = $orig;\n s/\\R//;\n print STDERR \"$ARGV: line $., columns $-[0]-$+[0], Warning - entry has unexpected whitespace (whitespace-in-dictionary)\\n\";\n }\n $_ .= \"\\n\";\n }\n' \"$file\") 2>&1\n}",
"cleanup_file() {",
" maybe_bad=\"$1\"",
" type=\"$2\"\n case \"$type\" in\n patterns|excludes|only)\n check_pattern_file \"$maybe_bad\"\n ;;\n dictionary|expect|allow)\n check_dictionary \"$maybe_bad\"\n ;;\n # reject isn't checked, it allows for regular expressions\n esac\n check_for_newline_at_eof \"$maybe_bad\"\n}",
"get_project_files() {\n file=$1\n dest=$2\n type=$1\n if [ ! -e \"$dest\" ] && [ -n \"$bucket\" ] && [ -n \"$project\" ]; then\n from=$(project_file_path $file $dest)\n case \"$from\" in\n .*)\n append_to=\"$from\"\n append_to_generated=\"\"\n if [ -f \"$from\" ]; then\n echo \"Retrieving $file from $from\"\n cleanup_file \"$from\" \"$type\"\n cp \"$from\" $dest\n from_expanded=\"$from\"\n else\n if [ ! -e \"$from\" ]; then\n ext=$(echo \"$from\" | sed -e 's/^.*\\.//')\n from=$(echo $from | sed -e \"s/\\.$ext$//\")\n fi\n if [ -d \"$from\" ]; then\n from_expanded=$(ls $from/*$ext |sort)\n append_to=$from/${GITHUB_SHA:-$(date +%Y%M%d%H%m%S)}.$ext\n append_to_generated=new\n touch $dest\n echo \"Retrieving $file from $from_expanded\"\n for item in $from_expanded; do\n if [ -s $item ]; then\n cleanup_file \"$item\" \"$type\"\n cat \"$item\" >> $dest\n fi\n done\n from=\"$from/$(basename \"$from\")\".$ext\n fi\n fi;;\n ssh://git@*|git@*)\n (\n echo \"Retrieving $file from $from\"\n cd $temp\n repo=$(echo \"$bucket\" | perl -pne 's#(?:ssh://|)git\\@github.com[:/]([^/]*)/(.*.git)#https://github.com/$1/$2#')\n [ -d metadata ] || git clone --depth 1 $repo --single-branch --branch $project metadata\n cleanup_file \"metadata/$file.txt\" \"$type\"\n cp metadata/$file.txt $dest 2> /dev/null || touch $dest\n );;\n gs://*)\n echo \"Retrieving $file from $from\"\n gsutil cp -Z $from $dest >/dev/null 2>/dev/null || touch $dest\n cleanup_file \"$dest\" \"$type\"\n ;;\n *://*)\n echo \"Retrieving $file from $from\"\n download \"$from\" \"$dest\" || touch $dest\n cleanup_file \"$dest\" \"$type\"\n ;;\n esac\n fi\n}\nget_project_files_deprecated() {\n # \"preferred\" \"deprecated\" \"path\"\n if [ ! -s \"$3\" ]; then\n save_append_to=\"$append_to\"\n get_project_files \"$2\" \"$3\"\n if [ -s \"$3\" ]; then\n example=$(for file in $from_expanded; do echo $file; done|head -1)\n if [ $(basename $(dirname $example)) = \"$2\" ]; then\n note=\" directory\"\n else\n note=\"\"\n fi\n echo \"::warning file=$example::deprecation: please rename '$2'$note to '$1'\"\n else\n append_to=\"$save_append_to\"\n fi\n fi\n}",
"download() {\n curl -L -s \"$1\" -o \"$2\" -f\n exit_value=$?\n if [ $exit_value = 0 ]; then\n echo \"Downloaded $1 (to $2)\" >&2\n fi\n return $exit_value\n}",
"download_or_quit_with_error() {\n exit_code=$(mktemp)\n download \"$1\" \"$2\" || (\n echo $? > $exit_code\n echo \"Could not download $1 (to $2)\" >&2\n )\n if [ -s $exit_code ]; then\n exit_value=$(cat $exit_code)\n rm $exit_code\n quit $exit_value\n fi\n}",
"set_up_tools() {\n apps=\"\"\n add_app() {\n if ! command_v $1; then\n apps=\"$apps $@\"\n fi\n }\n add_app curl ca-certificates\n add_app git\n add_app parallel\n if [ -n \"$apps\" ]; then\n if command_v apt-get; then\n export DEBIAN_FRONTEND=noninteractive\n apt-get -qq update &&\n apt-get -qq install --no-install-recommends -y $apps >/dev/null 2>/dev/null\n echo Installed: $apps >&2\n elif command_v brew; then\n brew install $apps\n else\n echo missing $apps -- things will fail >&2\n fi\n fi\n set_up_jq\n}",
"set_up_jq() {\n if ! command_v jq || jq --version | perl -ne 'exit 0 unless s/^jq-//;exit 1 if /^(?:[2-9]|1\\d|1\\.(?:[6-9]|1\\d+))/; exit 0'; then\n jq_url=https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64\n spellchecker_bin=\"$spellchecker/bin\"\n jq_bin=\"$spellchecker_bin/jq\"\n mkdir -p $spellchecker_bin\n download_or_quit_with_error \"$jq_url\" \"$jq_bin\"\n chmod 0755 \"$jq_bin\"\n PATH=$spellchecker_bin:$PATH\n fi\n}",
"set_up_files() {\n mkdir -p .git\n cp $spellchecker/reporter.json .git/\n echo \"::add-matcher::.git/reporter.json\"\n get_project_files expect $expect_path\n get_project_files_deprecated expect whitelist $expect_path\n expect_files=$from_expanded\n expect_file=$from\n touch $expect_path\n new_expect_file=$append_to\n new_expect_file_new=$append_to_generated\n get_project_files excludes $excludelist_path\n excludes_files=$from_expanded\n excludes_file=$from\n if [ -s \"$excludes_path\" ]; then\n cp \"$excludes_path\" \"$excludes\"\n fi\n should_exclude_file=$(mktemp)\n get_project_files dictionary $dictionary_path\n if [ -s \"$dictionary_path\" ]; then\n cp \"$dictionary_path\" \"$dict\"\n fi\n if [ ! -s \"$dict\" ]; then\n DICTIONARY_VERSION=${DICTIONARY_VERSION:-$INPUT_DICTIONARY_VERSION}\n DICTIONARY_URL=${DICTIONARY_URL:-$INPUT_DICTIONARY_URL}\n eval download_or_quit_with_error \"$DICTIONARY_URL\" \"$dict\"\n fi\n get_project_files allow $allow_path\n if [ -s \"$allow_path\" ]; then\n cat \"$allow_path\" >> \"$dict\"\n fi\n get_project_files reject $reject_path\n if [ -s \"$reject_path\" ]; then\n dictionary_temp=$(mktemp)\n if grep_v_string '^('$(echo $(cat \"$reject_path\")|tr \" \" '|')')$' < \"$dict\" > $dictionary_temp; then\n cat $dictionary_temp > \"$dict\"\n fi\n fi\n get_project_files only $only_path\n if [ -s \"$only_path\" ]; then\n cp \"$only_path\" \"$only\"\n fi\n get_project_files patterns $patterns_path\n if [ -s \"$patterns_path\" ]; then\n cp \"$patterns_path\" \"$patterns\"\n fi\n get_project_files advice $advice_path\n if [ ! -s \"$advice_path\" ]; then\n get_project_files advice $advice_path_txt\n if [ -s \"$advice_path\" ]; then\n cp \"$advice_path_txt\" \"$advice_path\"\n fi\n fi",
" if [ -n \"$debug\" ]; then\n echo \"Clean up from previous run\"\n fi\n rm -f \"$run_output\"\n}",
"welcome() {\n echo \"Checking spelling...\"\n if [ -n \"$DEBUG\" ]; then\n begin_group 'Excluded paths'\n if [ -e \"$excludes\" ]; then\n echo 'Excluded paths:'\n cat \"$excludes\"\n else\n echo 'No excluded paths file'\n fi\n end_group\n begin_group 'Only paths restriction'\n if [ -e \"$only\" ]; then\n echo 'Only paths restriction:'\n cat \"$only\"\n else\n echo 'No only paths restriction file'\n fi\n end_group\n fi\n if [ -n \"$INPUT_PATH\" ]; then\n cd \"$INPUT_PATH\"\n fi\n}",
"xargs_zero() {\n if command_v parallel; then\n parallel --no-notice --no-run-if-empty -0 -n1 \"$@\"\n elif [ $(uname) = \"Linux\" ]; then\n xargs --no-run-if-empty -0 -n1 \"$@\"\n else\n arguments=\"$*\" \"$spellchecker/xargs_zero\"\n fi\n}",
"run_spell_check() {\n begin_group 'Spell check files'\n file_list=$(mktemp)\n git 'ls-files' -z 2> /dev/null |\\\n \"$spellchecker/exclude.pl\" > $file_list\n perl -e '$/=\"\\0\"; $count=0; while (<>) {s/\\R//; $count++ if /./;}; print \"Checking $count files\\n\";' $file_list\n end_group",
" begin_group 'Spell check'\n warning_output=$(mktemp)\n more_warnings=$(mktemp)\n (\n # Technically $should_exclude_file is an append race under parallel\n # since the file isn't critical -- it's advisory, I'm going to wait\n # on reports before fixing it.\n # The fix is to have a directory and have each process append to a\n # file named for its pid inside that directory, and then have the\n # caller can collate...\n cat $file_list) |\\\n parallel -0 -n8 \"-j$job_count\" \"$word_splitter\" |\\\n expect=\"$expect_path\" warning_output=\"$warning_output\" more_warnings=\"$more_warnings\" should_exclude_file=\"$should_exclude_file\" \"$word_collator\" |\\\n perl -p -n -e 's/ \\(.*//' > \"$run_output\"\n word_splitter_status=\"${PIPESTATUS[2]} ${PIPESTATUS[3]}\"\n cat \"$warning_output\" \"$more_warnings\"\n rm \"$warning_output\" \"$more_warnings\"\n end_group\n if [ \"$word_splitter_status\" != '0 0' ]; then\n echo \"$word_splitter failed ($word_splitter_status)\"\n exit 2\n fi\n rm $file_list\n}",
"printDetails() {\n echo ''\n echo 'If you are ok with the output of this run, you will need to'\n}",
"relative_note() {\n if [ -n \"$bucket\" ] && [ -n \"$project\" ]; then\n from=$(project_file_path $file)\n case \"$from\" in\n .*)\n ;;\n ssh://git@*|git@*|gs://|*://*)\n echo '(They can be run anywhere with permissions to update the bucket.)';;\n esac\n fi\n}\nto_retrieve_expect() {\n expect_file=expect.txt\n case \"$bucket\" in\n '')\n echo '# no bucket defined -- you can specify one per the README.md using the file defined below:';;\n ssh://git@*|git@*)\n echo \"git clone --depth 1 $bucket --single-branch --branch $project metadata; cp metadata/expect.txt .\";;\n gs://*)\n echo gsutil cp -Z $(project_file_path expect) expect.txt;;\n *://*)\n echo curl -L -s \"$(project_file_path expect)\" -o expect.txt;;\n esac\n}\nto_publish_expect() {\n case \"$bucket\" in\n '')\n echo \"# no bucket defined -- copy $1 to a bucket and configure it per the README.md\";;\n ssh://git@*|git@*)\n echo \"cp $1 metadata/expect.txt; (cd metadata; git commit expect.txt -m 'Updating expect'; git push)\";;\n gs://*)\n echo gsutil cp -Z $1 $(project_file_path expect);;\n *://*)\n echo \"# command to publish $1 is not known. URL: $(project_file_path expect)\";;\n *)\n if [ \"$2\" = new ]; then\n cmd=\"git add $bucket/$project || echo '... you want to ensure $1 is added to your repository...'\"\n case $(realpath --relative-base=\"$bucket\" \"$1\") in\n /*)\n cmd=\"cp $1 $(project_file_path expect); $cmd\";;\n esac\n echo \"$cmd\"\n fi\n ;;\n esac\n}",
"remove_items() {\n patch_remove=$(echo \"$diff_output\" | perl -ne 'next unless s/^-([^-])/$1/; s/\\n/ /; print')\n if [ -n \"$patch_remove\" ]; then\n echo \"\n<details><summary>Previously acknowledged words that are now absent\n</summary>$patch_remove</details>\n\"\n if [ -n \"$INPUT_CAPTURE_STALE_WORDS\" ]; then\n remove_words=$(mktemp)\n echo \"$patch_remove\" > $remove_words\n echo \"::set-output name=stale_words::$remove_words\"\n fi\n else\n rm \"$fewer_misspellings_canary\"\n fi\n}",
"spelling_warning() {\n OUTPUT=\"#### $1:\n\"\n spelling_body \"$2\" \"$3\"\n post_commit_comment\n}\nspelling_info() {\n if [ -z \"$2\" ]; then\n out=\"$1\"\n else\n out=\"$1",
"$2\"\n fi\n spelling_body \"$out\" \"$3\"\n if [ -n \"$VERBOSE\" ]; then\n OUTPUT=\"## @check-spelling-bot Report",
"$OUTPUT\"\n post_commit_comment\n else\n echo \"$OUTPUT\"\n fi\n}\nspelling_body() {\n err=\"$2\"\n if [ -n \"$OUTPUT\" ]; then\n header=\"$OUTPUT",
"\"\n else\n header=\"\"\n fi\n header=\"# @check-spelling-bot Report",
"$header\"\n if [ -z \"$err\" ]; then\n OUTPUT=\"$header$1\"\n else\n if [ -e \"$fewer_misspellings_canary\" ]; then\n cleanup_text=\" (and remove the previously acknowledged and now absent words)\"\n fi\n if [ -n \"$GITHUB_HEAD_REF\" ]; then\n remote_url_ssh=$(jq -r .pull_request.head.repo.ssh_url < $GITHUB_EVENT_PATH)\n remote_url_https=$(jq -r .pull_request.head.repo.clone_url < $GITHUB_EVENT_PATH)\n remote_ref=$GITHUB_HEAD_REF\n else\n remote_url_ssh=$(jq -r .repository.ssh_url < $GITHUB_EVENT_PATH)\n remote_url_https=$(jq -r .repository.clone_url < $GITHUB_EVENT_PATH)\n remote_ref=$GITHUB_REF\n fi\n remote_ref=${remote_ref#refs/heads/}\n OUTPUT=\"$header$1",
"\"\n if [ -s \"$should_exclude_file\" ]; then\n if [ -n \"$INPUT_CAPTURE_SKIPPED_FILES\" ]; then\n echo \"::set-output name=skipped_files::$should_exclude_file\"\n fi\n OUTPUT=\"$OUTPUT\n<details><summary>Some files were were automatically ignored</summary>",
"These sample patterns would exclude them:\n\"'```'\"\n$should_exclude_patterns\n\"'```'\nif [ $(wc -l \"$should_exclude_file\" |perl -pne 's/(\\d+)\\s+.*/$1/') -gt 10 ]; then\n OUTPUT=\"$OUTPUT\n\"'You should consider excluding directory paths (e.g. `(?:^|/)vendor/`), filenames (e.g. `(?:^|/)yarn\\.lock$`), or file extensions (e.g. `\\.gz$`)\n'\nfi\n OUTPUT=\"$OUTPUT\n\"'You should consider adding them to:\n```'\"\n$(echo \"$excludes_files\" | xargs -n1 echo)\n\"'```",
"File matching is via Perl regular expressions.",
"To check these files, more of their words need to be in the dictionary than not. You can use `patterns.txt` to exclude portions, add items to the dictionary (e.g. by adding them to `allow.txt`), or fix typos.\n</details>\n'\n fi\n OUTPUT=\"$OUTPUT\n<details><summary>To accept these unrecognized words as correct$cleanup_text,\nrun the following commands</summary>",
"... in a clone of the [$remote_url_ssh]($remote_url_https) repository\non the \\`$remote_ref\\` branch:\n\"$(relative_note)\"",
"\"'```'\"\n$err\n\"'```\n</details>\n'\n if [ -s \"$advice_path\" ]; then\n OUTPUT=\"$OUTPUT",
"`cat \"$advice_path\"`\n\"\n fi\n fi\n}\nbullet_words_and_warn() {\n echo \"$1\" > \"$tokens_file\"\n if [ -n \"$INPUT_CAPTURE_UNKNOWN_WORDS\" ]; then\n file_with_unknown_words=$(mktemp)\n cp \"$tokens_file\" $file_with_unknown_words\n echo \"::set-output name=unknown_words::$file_with_unknown_words\"\n fi\n perl -pne 's/^(.)/* $1/' \"$tokens_file\"\n remove_items\n rm -f \"$tokens_file\"\n}",
"quit() {\n echo \"::remove-matcher owner=check-spelling::\"\n if [ -n \"$junit\" ]; then\n exit\n fi\n exit $1\n}",
"body_to_payload() {\n BODY=\"$1\"\n PAYLOAD=$(mktemp)\n echo '{}' | jq --rawfile body \"$BODY\" '.body = $body' > $PAYLOAD\n if [ -n \"$DEBUG\" ]; then\n cat $PAYLOAD >&2\n fi\n}",
"collaborator() {\n collaborator_url=\"$1\"\n curl -L -s \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n -H \"Accept: application/vnd.github.v3+json\" \\\n \"$collaborator_url\" 2> /dev/null\n}",
"pull_request() {\n pull_request_url=\"$1\"\n curl -L -s -S \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n \"$pull_request_url\"\n}",
"react() {\n url=\"$1\"\n reaction=\"$2\"\n curl -L -s -S \\\n -X POST \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n -H \"Accept: application/vnd.github.squirrel-girl-preview+json\" \\\n \"$url\"/reactions \\\n -d '{\"content\":\"'\"$reaction\"'\"}'\n}",
"comment() {\n comments_url=\"$1\"\n payload=\"$2\"\n if [ -n \"$payload\" ]; then\n payload=\"--data @$payload\"\n method=\"$3\"\n if [ -n \"$method\" ]; then\n method=\"-X $method\"\n fi\n fi\n curl -L -s -S \\\n $method \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n -H 'Accept: application/vnd.github.comfort-fade-preview+json' \\\n $payload \\\n \"$comments_url\"\n}",
"set_comments_url() {\n event=\"$1\"\n file=\"$2\"\n sha=\"$3\"\n case \"$event\" in\n issue_comment)\n COMMENTS_URL=$(cat $file | jq -r .issue.comments_url);;\n pull_request|pull_request_target|pull_request_review_comment)\n COMMENTS_URL=$(cat $file | jq -r .pull_request.comments_url);;\n push|commit_comment)\n COMMENTS_URL=$(cat $file | jq -r .repository.commits_url | perl -pne 's#\\{/sha}#/'$sha'/comments#');;\n esac\n}",
"post_commit_comment() {\n if [ -n \"$OUTPUT\" ]; then\n if [ -n \"$INPUT_POST_COMMENT\" ]; then\n echo \"Preparing a comment for $GITHUB_EVENT_NAME\"\n set_comments_url \"$GITHUB_EVENT_NAME\" \"$GITHUB_EVENT_PATH\" \"$GITHUB_SHA\"\n if [ -n \"$COMMENTS_URL\" ] && [ -z \"${COMMENTS_URL##*:*}\" ]; then\n BODY=$(mktemp)\n echo \"$OUTPUT\" > $BODY\n body_to_payload $BODY\n echo $COMMENTS_URL\n response=$(mktemp_json)",
" res=0\n comment \"$COMMENTS_URL\" \"$PAYLOAD\" > $response || res=$?\n if [ $res -gt 0 ]; then\n if [ -z \"$DEBUG\" ]; then\n echo \"failed posting to $COMMENTS_URL\"\n echo \"$PAYLOAD\"\n fi\n return $res\n fi",
" if [ -n \"$DEBUG\" ]; then\n cat $response\n fi\n COMMENT_URL=$(jq -r .url < $response)\n perl -p -i.orig -e 's<COMMENT_URL><'\"$COMMENT_URL\"'>' $BODY\n if diff -q \"$BODY.orig\" \"$BODY\" > /dev/null; then\n no_patch=1\n fi\n rm \"$BODY.orig\"\n if offer_quote_reply; then\n (\n echo\n echo \"Alternatively, the bot can do this for you if you reply quoting the following line:\"\n echo \"@check-spelling-bot apply [changes]($COMMENT_URL).\"\n )>> $BODY\n no_patch=\n fi\n if [ -z \"$no_patch\" ]; then\n body_to_payload $BODY\n comment \"$COMMENT_URL\" \"$PAYLOAD\" \"PATCH\" > $response\n if [ -n \"$DEBUG\" ]; then\n cat $response\n fi\n fi\n rm -f $BODY\n else\n echo \"$OUTPUT\"\n fi\n else\n echo \"$OUTPUT\"\n fi\n fi\n}",
"strip_lines() {\n tr \"\\n\" \" \"\n}",
"minimize_comment_call() {\n comment_node=\"$1\"\n echo \"\n minimizeComment(\n input:\n {\n subjectId: ${Q}$comment_node${Q},\n classifier: RESOLVED\n }\n ){\n minimizedComment {\n isMinimized\n }\n }\n\" | strip_lead | strip_lines\n}",
"collapse_comment_mutation() {\n comment_node=\"$1\"\n query_head=\"mutation {\"\n query_tail=\"}\"\n query_body=\"\"\n i=0\n while [ -n \"$1\" ]; do\n query_body=\"$query_body q$i: \"$(minimize_comment_call \"$1\")\n i=\"$((i+1))\"\n shift\n done\n query=\"$query_head$query_body$query_tail\"\n echo '{}' | jq --arg query \"$query\" '.query = $query'\n}",
"collapse_comment() {\n curl -s \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data-binary \"$(collapse_comment_mutation \"$@\")\" \\\n $GITHUB_GRAPHQL_URL\n}",
"exit_if_no_unknown_words() {\n if [ ! -s \"$run_output\" ]; then\n quit 0\n fi\n}",
"grep_v_spellchecker() {\n grep_v_string \"$spellchecker\"\n}",
"grep_v_string() {\n perl -ne \"next if m{$1}; print\"\n}",
"compare_new_output() {\n begin_group 'Compare expect with new output'\n sorted_expect=\"$temp/expect.sorted.txt\"\n (sed -e 's/#.*//' \"$expect_path\" | sort_unique) > \"$sorted_expect\"\n expect_path=\"$sorted_expect\"",
" diff_output=$(\n diff -w -U0 \"$expect_path\" \"$run_output\" |\n grep_v_spellchecker)\n end_group",
" if [ -z \"$diff_output\" ]; then\n begin_group 'No misspellings'\n title=\"No new words with misspellings found\"\n spelling_info \"$title\" \"There are currently $(wc -l $expect_path|sed -e 's/ .*//') expected items.\" \"\"\n end_group\n quit 0\n fi",
" begin_group 'New output'\n new_output=$(\n diff -i -w -U0 \"$expect_path\" \"$run_output\" |\n grep_v_spellchecker |\\\n perl -n -w -e 'next unless /^\\+/; next if /^\\+{3} /; s/^.//; print;')\n end_group",
" should_exclude_patterns=$(sort \"$should_exclude_file\" | path_to_pattern)\n}",
"generate_curl_instructions() {\n instructions=$(mktemp)\n (\n echo 'update_files() {'\n (\n skip_wrapping=1\n if [ -n \"$patch_remove\" ]; then\n patch_remove='$patch_remove'\n fi\n if [ -n \"$patch_add\" ]; then\n patch_add='$patch_add'\n fi\n if [ -n \"$should_exclude_patterns\" ]; then\n should_exclude_patterns='$should_exclude_patterns'\n fi\n generated=$(generate_instructions)\n cat $generated\n rm $generated\n )\n echo '}'\n ) >> $instructions\n echo '\n comment_json=$(mktemp)\n curl -L -s -S \\\n --header \"Content-Type: application/json\" \\\n \"COMMENT_URL\" > \"$comment_json\"\n comment_body=$(mktemp)\n jq -r .body < \"$comment_json\" > $comment_body\n rm $comment_json\n '\"$(patch_variables $Q'$comment_body'$Q)\"'\n update_files\n rm $comment_body\n git add -u\n ' | sed -e 's/^ //' >> $instructions\n echo $instructions\n}",
"skip_curl() {\n [ -n \"$SKIP_CURL\" ] || repo_is_private\n}",
"make_instructions() {\n patch_remove=$(echo \"$diff_output\" | perl -ne 'next unless s/^-([^-])/$1/; s/\\n/ /; print')\n patch_add=$(echo \"$diff_output\" | perl -ne 'next unless s/^\\+([^+])/$1/; s/\\n/ /; print')\n if skip_curl; then\n instructions=$(generate_instructions)\n if [ -n \"$patch_add\" ]; then\n to_publish_expect \"$new_expect_file\" $new_expect_file_new >> $instructions\n fi\n else\n instructions=$(generate_curl_instructions)\n fi\n cat $instructions\n rm $instructions\n}",
"fewer_misspellings() {\n if [ -n \"$new_output\" ]; then\n return\n fi",
" begin_group 'Fewer misspellings'\n title='There are now fewer misspellings than before'\n SKIP_CURL=1\n instructions=$(\n make_instructions\n )\n if [ -n \"$INPUT_EXPERIMENTAL_COMMIT_NOTE\" ]; then\n . \"$spellchecker/update-state.sh\"\n skip_push_and_pop=1",
" instructions_head=$(mktemp)\n (\n patch_add=1\n patch_remove=1\n patch_variables $comment_body > $instructions_head\n )\n . $instructions_head\n rm $instructions_head\n instructions=$(generate_instructions)",
" . $instructions &&\n git_commit \"$INPUT_EXPERIMENTAL_COMMIT_NOTE\" &&\n git push origin ${GITHUB_HEAD_REF:-$GITHUB_REF}\n spelling_info \"$title\" \"\" \"Applied\"\n else\n spelling_info \"$title\" \"\" \"$instructions\"\n fi\n end_group\n quit\n}\nmore_misspellings() {\n begin_group 'Unrecognized'\n title='Unrecognized words, please review'\n instructions=$(\n make_instructions\n )\n spelling_warning \"$title\" \"$(bullet_words_and_warn \"$new_output\")\" \"$instructions\"\n end_group\n quit 1\n}",
"define_variables\nset_up_tools\nset_up_files\n. \"$spellchecker/update-state.sh\"\nmain\nwelcome\nrun_spell_check\nexit_if_no_unknown_words\ncompare_new_output\nfewer_misspellings_canary=$(mktemp)\nfewer_misspellings\nmore_misspellings"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
PreciseBugs
|
{"buggy_code_end_loc": [2, 22, 377], "buggy_code_start_loc": [2, 19, 376], "filenames": ["common.sh", "spelling-unknown-word-splitter.pl", "unknown-words.sh"], "fixing_code_end_loc": [8, 22, 398], "fixing_code_start_loc": [3, 19, 376], "message": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:check-spelling:check-spelling:*:*:*:*:*:*:*:*", "matchCriteriaId": "A4A73141-03F7-4AAB-A7E3-6D2331D73257", "versionEndExcluding": "0.0.19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target."}, {"lang": "es", "value": "check-spelling es una acci\u00f3n de github que proporciona una comprobaci\u00f3n ortogr\u00e1fica de CI. En versiones afectadas y para un repositorio con la acci\u00f3n [check-spelling](https://github.com/marketplace/actions/check-spelling) habilitada que desencadena en \"pull_request_target\" (o \"schedule\"), un atacante puede enviar un Pull Request dise\u00f1ado que cause que un \"GITHUB_TOKEN\" sea expuesto. Con el \"GITHUB_TOKEN\", es posible enviar confirmaciones al commit omitiendo los procesos de aprobaci\u00f3n est\u00e1ndar. Los commits al repositorio podr\u00edan entonces robar cualquier/todos los secretos disponibles en el repositorio. Como soluci\u00f3n, los usuarios pueden: [Desactivar el flujo de trabajo](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) hasta que haya corregido todas las ramas o Configurar el repositorio para [Permitir acciones espec\u00edficas](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). la comprobaci\u00f3n de la ortograf\u00eda no es un creador verificado y ciertamente no lo ser\u00e1 pronto. Entonces podr\u00eda a\u00f1adir expl\u00edcitamente otras acciones que su repositorio usa. Ajuste el repositorio [Permisos de flujo de trabajo](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) a \"Read repository contents permission\". Los flujos de trabajo que usen \"check-spelling/check-spelling@main\" obtendr\u00e1n la correcci\u00f3n autom\u00e1ticamente. Los flujos de trabajo que usen una versi\u00f3n con anclaje o etiquetada tendr\u00e1n que cambiar los flujos de trabajo afectados para todas las ramas del repositorio a la \u00faltima versi\u00f3n. Los usuarios pueden verificar qui\u00e9n y qu\u00e9 Pull Requests han ejecutado la acci\u00f3n buscando la acci\u00f3n spelling.yml en la pesta\u00f1a Acciones de sus repositorios, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - puede filtrar los PRs al a\u00f1adir ?query=event%3Apull_request_target, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target"}], "evaluatorComment": null, "id": "CVE-2021-32724", "lastModified": "2021-09-27T14:21:55.153", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 6.8, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 6.4, "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": 9.9, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "CHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.1, "impactScore": 6.0, "source": "security-advisories@github.com", "type": "Primary"}]}, "published": "2021-09-09T21:15:07.250", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, {"source": "security-advisories@github.com", "tags": ["Mitigation", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/security/advisories/GHSA-g86g-chm8-7r2p"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-532"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, "type": "CWE-532"}
| 217
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"#!/bin/bash\n# This CI acceptance test is based on:\n# https://github.com/jsoref/spelling/tree/04648bdc63723e5cdf5cbeaff2225a462807abc8\n# It is conceptually `f` which runs `w` (spelling-unknown-word-splitter)\n# plus `fchurn` which uses `dn` mostly rolled together.\nset -e\nexport spellchecker=${spellchecker:-/app}\n. \"$spellchecker/common.sh\"",
"main() {\n GITHUB_TOKEN=${GITHUB_TOKEN:-$INPUT_GITHUB_TOKEN}\n if [ -z \"$GITHUB_EVENT_PATH\" ] || [ ! -e \"$GITHUB_EVENT_PATH\" ]; then\n GITHUB_EVENT_PATH=/dev/null\n fi\n case \"$GITHUB_EVENT_NAME\" in\n schedule)\n exec \"$spellchecker/check-pull-requests.sh\"\n ;;\n issue_comment)\n if [ -n \"$DEBUG\" ]; then\n set -x\n fi\n handle_comment\n ;;\n pull_request_review_comment)\n (\n echo 'check-spelling does not currently support comments on code.'\n echo 'If you are trying to ask @check-spelling-bot to update a PR,'\n echo 'please quote the comment link as a top level comment instead'\n echo 'of in a comment on a block of code.'\n echo\n echo 'Future versions may support this feature.'\n echo 'For the time being, early adopters should remove the'\n echo '`pull_request_review_comment` event from their workflow.'\n echo 'workflow.'\n ) >&2\n exit 0\n ;;\n esac\n}",
"offer_quote_reply() {\n case \"$INPUT_EXPERIMENTAL_APPLY_CHANGES_VIA_BOT\" in\n 1|true|TRUE)\n case \"$GITHUB_EVENT_NAME\" in\n issue_comment|pull_request|pull_request_target)\n true;;\n *)\n false;;\n esac\n ;;\n *)\n false\n ;;\n esac\n}",
"repo_is_private() {\n private=$(jq -r .repository.private < \"$GITHUB_EVENT_PATH\")\n [ \"$private\" = \"true\" ]\n}",
"command_v() {\n command -v \"$1\" >/dev/null 2>/dev/null\n}",
"react_comment_and_die() {\n trigger_comment_url=\"$1\"\n message=\"$2\"\n react=\"$3\"\n echo \"::error ::$message\"\n react \"$trigger_comment_url\" \"$react\" > /dev/null\n if [ -n \"$COMMENTS_URL\" ] && [ -z \"${COMMENTS_URL##*:*}\" ]; then\n PAYLOAD=$(mktemp_json)\n echo '{}' | jq --arg body \"@check-spelling-bot: $react_prefix $message\" '.body = $body' > $PAYLOAD",
" res=0\n comment \"$COMMENTS_URL\" \"$PAYLOAD\" > /dev/null || res=$?\n if [ $res -gt 0 ]; then\n if [ -z \"$DEBUG\" ]; then\n echo \"failed posting to $COMMENTS_URL\"\n echo \"$PAYLOAD\"\n fi\n return $res\n fi",
" rm $PAYLOAD\n fi\n exit 1\n}",
"confused_comment() {\n react_comment_and_die \"$1\" \"$2\" \"confused\"\n}",
"github_user_and_email() {\n user_json=$(mktemp_json)\n curl -s \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n \"$GITHUB_API_URL/users/$1\" > $user_json",
" github_name=$(jq -r '.name // empty' < $user_json)\n if [ -z \"$github_name\" ]; then\n github_name=$1\n fi\n github_email=$(jq -r '.email // empty' < $user_json)\n rm $user_json\n if [ -z \"$github_email\" ]; then\n github_email=\"$1@users.noreply.github.com\"\n fi\n COMMIT_AUTHOR=\"--author=$github_name <$github_email>\"\n}",
"git_commit() {\n reason=\"$1\"\n git add -u\n git config user.email \"check-spelling-bot@users.noreply.github.com\"\n git config user.name \"check-spelling-bot\"\n git commit \\\n \"$COMMIT_AUTHOR\" \\\n --date=\"$created_at\" \\\n -m \"$(echo \"[check-spelling] Applying automated metadata updates",
" $reason",
" Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>\n \" | strip_lead)\"\n}",
"mktemp_json() {\n file=$(mktemp)\n mv \"$file\" \"$file.json\"\n echo \"$file.json\"\n}",
"handle_comment() {\n if ! offer_quote_reply; then\n exit 0\n fi",
" action=$(jq -r .action < \"$GITHUB_EVENT_PATH\")\n if [ \"$action\" != \"created\" ]; then\n exit 0\n fi",
" comment=$(mktemp_json)\n jq -r .comment < \"$GITHUB_EVENT_PATH\" > $comment\n body=$(mktemp)\n jq -r .body $comment > $body",
" trigger=$(perl -ne 'print if /\\@check-spelling-bot(?:\\s+|:\\s*)apply/' < $body)\n rm $body\n if [ -z \"$trigger\" ]; then\n exit 0\n fi",
" trigger_comment_url=$(jq -r .url < $comment)\n sender_login=$(jq -r .sender.login < \"$GITHUB_EVENT_PATH\")\n issue_user_login=$(jq -r .issue.user.login < \"$GITHUB_EVENT_PATH\")\n issue=$(mktemp_json)\n jq -r .issue < \"$GITHUB_EVENT_PATH\" > $issue\n pull_request_url=$(jq -r .pull_request.url < $issue)\n pull_request_info=$(mktemp_json)\n pull_request \"$pull_request_url\" | jq .head > $pull_request_info\n pull_request_sha=$(jq -r .sha < $pull_request_info)\n set_comments_url \"$GITHUB_EVENT_NAME\" \"$GITHUB_EVENT_PATH\" \"$pull_request_sha\"\n react_prefix_base=\"Could not perform [request]($trigger_comment_url).\"\n react_prefix=\"$react_prefix_base\"\n if [ \"$sender_login\" != \"$issue_user_login\" ]; then\n collaborators_url=$(jq -r .repository.collaborators_url < \"$GITHUB_EVENT_PATH\")\n collaborators_url=$(echo \"$collaborators_url\" | perl -pne \"s<\\{/collaborator\\}></$sender_login/permission>\")\n collaborator_permission=$(collaborator \"$collaborators_url\" | jq -r .permission)\n case $collaborator_permission in\n admin)\n ;;\n write)\n ;;\n *)\n confused_comment \"$trigger_comment_url\" \"Commenter (@$sender_login) isn't author (@$issue_user_login) / collaborator\"\n ;;\n esac\n fi\n number=$(jq -r .number < $issue)\n created_at=$(jq -r .created_at < $comment)\n issue_url=$(jq -r .url < $issue)\n pull_request_ref=$(jq -r .ref < $pull_request_info)\n pull_request_repo=$(jq -r .repo.clone_url < $pull_request_info)\n git remote add request $pull_request_repo\n git fetch request \"$pull_request_sha\"\n git config advice.detachedHead false\n git reset --hard\n git checkout \"$pull_request_sha\"",
" number_filter() {\n perl -pne 's/\\{.*\\}//'\n }\n comments_base=$(jq -r .repository.comments_url < \"$GITHUB_EVENT_PATH\" | number_filter)\n issue_comments_base=$(jq -r .repository.issue_comment_url < \"$GITHUB_EVENT_PATH\" | number_filter)\n export comments_url=\"$comments_base|$issue_comments_base\"\n comment_url=$(echo \"$trigger\" | perl -ne 'next unless m{((?:$ENV{comments_url})/\\d+)}; print \"$1\\n\";')\n [ -n \"$comment_url\" ] ||\n confused_comment \"$trigger_comment_url\" \"Did not find $comments_url in comment\"",
" res=0\n comment \"$comment_url\" > $comment || res=$?\n if [ $res -gt 0 ]; then\n if [ -z \"$DEBUG\" ]; then\n echo \"failed to retrieve $comment_url\"\n fi\n return $res\n fi",
" comment_body=$(mktemp)\n jq -r .body < $comment > $comment_body\n bot_comment_author=$(jq -r .user.login < $comment)\n bot_comment_node_id=$(jq -r .node_id < $comment)\n bot_comment_url=$(jq -r '.issue_url // .comment.url' < $comment)\n rm $comment\n github_actions_bot=\"github-actions[bot]\"\n [ \"$bot_comment_author\" = \"$github_actions_bot\" ] ||\n confused_comment \"$trigger_comment_url\" \"Expected @$github_actions_bot to be author of $comment_url (found @$bot_comment_author)\"\n [ \"$issue_url\" = \"$bot_comment_url\" ] ||\n confused_comment \"$trigger_comment_url\" \"Referenced comment was for a different object: $bot_comment_url\"\n capture_items() {\n perl -ne 'next unless s{^\\s*my \\@'$1'=qw\\('$q$Q'(.*)'$Q$q'\\);$}{$1}; print'\n }\n capture_item() {\n perl -ne 'next unless s{^\\s*my \\$'$1'=\"(.*)\";$}{$1}; print'\n }\n skip_wrapping=1",
" instructions_head=$(mktemp)\n (\n patch_add=1\n patch_remove=1\n should_exclude_patterns=1\n patch_variables $comment_body > $instructions_head\n )\n git restore $bucket/$project",
" res=0\n . $instructions_head || res=$?\n if [ $res -gt 0 ]; then\n echo \"instructions_head failed ($res)\"\n cat $instructions_head\n return $res\n fi\n rm $comment_body $instructions_head\n instructions=$(generate_instructions)",
" react_prefix=\"$react_prefix [Instructions]($comment_url)\"\n . $instructions || res=$?\n if [ $res -gt 0 ]; then\n echo \"instructions failed ($res)\"\n cat $instructions\n res=0\n confused_comment \"$trigger_comment_url\" \"failed to apply\"\n fi\n rm $instructions\n git status --u=no --porcelain | grep -q . ||\n confused_comment \"$trigger_comment_url\" \"didn't change repository\"\n react_prefix=\"$react_prefix_base\"\n github_user_and_email $sender_login\n git_commit \"$(echo \"Update per $comment_url\n Accepted in $trigger_comment_url\n \"|strip_lead)\" ||\n confused_comment \"$trigger_comment_url\" \"Failed to generate commit\"\n git push request \"HEAD:$pull_request_ref\" ||\n confused_comment \"$trigger_comment_url\" \"Failed to push to $pull_request_repo\"",
" react \"$trigger_comment_url\" 'eyes' > /dev/null\n react \"$comment_url\" 'rocket' > /dev/null\n trigger_node=$(jq -r .comment.node_id < \"$GITHUB_EVENT_PATH\")\n collapse_comment $trigger_node $bot_comment_node_id",
" echo \"# end\"\n exit 0\n}",
"define_variables() {\n bucket=${INPUT_BUCKET:-$bucket}\n project=${INPUT_PROJECT:-$project}\n if [ -z \"$bucket\" ] && [ -z \"$project\" ] && [ -n \"$INPUT_CONFIG\" ]; then\n bucket=${INPUT_CONFIG%/*}\n project=${INPUT_CONFIG##*/}\n fi\n job_count=${INPUT_EXPERIMENTAL_PARALLEL_JOBS:-2}\n if ! [ \"$job_count\" -eq \"$job_count\" ] 2>/dev/null || [ \"$job_count\" -lt 2 ]; then\n job_count=1\n fi",
" dict=\"$spellchecker/words\"\n patterns=\"$spellchecker/patterns.txt\"\n excludes=\"$spellchecker/excludes.txt\"\n excludes_path=\"$temp/excludes.txt\"\n only=\"$spellchecker/only.txt\"\n only_path=\"$temp/only.txt\"\n dictionary_path=\"$temp/dictionary.txt\"\n allow_path=\"$temp/allow.txt\"\n reject_path=\"$temp/reject.txt\"\n expect_path=\"$temp/expect.words.txt\"\n excludelist_path=\"$temp/excludes.txt\"\n patterns_path=\"$temp/patterns.txt\"\n advice_path=\"$temp/advice.md\"\n advice_path_txt=\"$temp/advice.txt\"\n word_splitter=\"$spellchecker/spelling-unknown-word-splitter.pl\"\n word_collator=\"$spellchecker/spelling-collator.pl\"\n run_output=\"$temp/unknown.words.txt\"\n run_files=\"$temp/reporter-input.txt\"\n tokens_file=\"$temp/tokens.txt\"\n}",
"sort_unique() {\n sort -u -f \"$@\" | perl -ne 'next unless /./; print'\n}",
"project_file_path() {\n ext=$(echo \"$2\" | sed -e 's/^.*\\.//')\n echo $bucket/$project/$1.${ext:-txt}\n}",
"check_pattern_file() {\n perl -i -e 'while (<>) {\n next if /^#/;\n next unless /./;\n if (eval {qr/$_/}) {\n print;\n } else {\n $@ =~ s/(.*?)\\n.*/$1/m;\n chomp $@;\n my $err = $@;\n $err =~ s{^.*? in regex; marked by <-- HERE in m/(.*) <-- HERE.*$}{$1};\n print STDERR \"$ARGV: line $., columns $-[0]-$-[0], Warning - bad regex (bad-regex)\\n$@\\n\";\n print \"^\\$\\n\";\n }\n }' $1\n}",
"check_for_newline_at_eof() {\n maybe_missing_eol=\"$1\"\n if [ -s \"$maybe_missing_eol\" ] && [ $(tail -1 \"$maybe_missing_eol\" | wc -l) -eq 0 ]; then\n line=$(( $(cat \"$maybe_missing_eol\" | wc -l) + 1 ))\n start=$(tail -1 \"$maybe_missing_eol\" | wc -c)\n stop=$(( $start + 1 ))\n echo \"$maybe_missing_eol: line $line, columns $start-$stop, Warning - no newline at eof (no-newline-at-eof)\" >&2\n echo >> \"$maybe_missing_eol\"\n fi\n}",
"check_dictionary() {\n file=\"$1\"\n expected_chars=\"[a-zA-Z']\"\n unexpected_chars=\"[^a-zA-Z']\"\n (perl -pi -e '\n chomp;\n my $messy = 0;\n my $orig = $_;\n if (s/\\n|\\r|\\x0b|\\f|\\x85|\\x2028|\\x2029/a/g) {\n $messy = 1;\n }\n if ('\"/^${expected_chars}*(${unexpected_chars}+)/\"') {\n print STDERR \"$ARGV: line $., columns $-[1]-$+[1], Warning - ignoring entry because it contains non alpha characters (non-alpha-in-dictionary)\\n\";\n $_ = \"\";\n } else {\n if ($messy) {\n $_ = $orig;\n s/\\R//;\n print STDERR \"$ARGV: line $., columns $-[0]-$+[0], Warning - entry has unexpected whitespace (whitespace-in-dictionary)\\n\";\n }\n $_ .= \"\\n\";\n }\n' \"$file\") 2>&1\n}",
"cleanup_file() {",
" export maybe_bad=\"$1\"",
" result=0\n perl -e '\n use Cwd qw(abs_path);\n my $maybe_bad=abs_path($ENV{maybe_bad});\n my $workspace_path=abs_path($ENV{GITHUB_WORKSPACE});\n if ($maybe_bad !~ /^\\Q$workspace_path\\E/) {\n print \"::error ::Configuration files must live within $workspace_path...\\n\";\n print \"::error ::Unfortunately, file $maybe_bad appears to reside elsewhere.\\n\";\n exit 3;\n }\n if ($maybe_bad =~ m{/\\.git/}i) {\n print \"::error ::Configuration files must not live within `.git/`...\\n\";\n print \"::error ::Unfortunately, file $maybe_bad appears to.\\n\";\n exit 4;\n }\n ' || result=$?\n if [ $result -gt 0 ]; then\n quit $result\n fi\n",
" type=\"$2\"\n case \"$type\" in\n patterns|excludes|only)\n check_pattern_file \"$maybe_bad\"\n ;;\n dictionary|expect|allow)\n check_dictionary \"$maybe_bad\"\n ;;\n # reject isn't checked, it allows for regular expressions\n esac\n check_for_newline_at_eof \"$maybe_bad\"\n}",
"get_project_files() {\n file=$1\n dest=$2\n type=$1\n if [ ! -e \"$dest\" ] && [ -n \"$bucket\" ] && [ -n \"$project\" ]; then\n from=$(project_file_path $file $dest)\n case \"$from\" in\n .*)\n append_to=\"$from\"\n append_to_generated=\"\"\n if [ -f \"$from\" ]; then\n echo \"Retrieving $file from $from\"\n cleanup_file \"$from\" \"$type\"\n cp \"$from\" $dest\n from_expanded=\"$from\"\n else\n if [ ! -e \"$from\" ]; then\n ext=$(echo \"$from\" | sed -e 's/^.*\\.//')\n from=$(echo $from | sed -e \"s/\\.$ext$//\")\n fi\n if [ -d \"$from\" ]; then\n from_expanded=$(ls $from/*$ext |sort)\n append_to=$from/${GITHUB_SHA:-$(date +%Y%M%d%H%m%S)}.$ext\n append_to_generated=new\n touch $dest\n echo \"Retrieving $file from $from_expanded\"\n for item in $from_expanded; do\n if [ -s $item ]; then\n cleanup_file \"$item\" \"$type\"\n cat \"$item\" >> $dest\n fi\n done\n from=\"$from/$(basename \"$from\")\".$ext\n fi\n fi;;\n ssh://git@*|git@*)\n (\n echo \"Retrieving $file from $from\"\n cd $temp\n repo=$(echo \"$bucket\" | perl -pne 's#(?:ssh://|)git\\@github.com[:/]([^/]*)/(.*.git)#https://github.com/$1/$2#')\n [ -d metadata ] || git clone --depth 1 $repo --single-branch --branch $project metadata\n cleanup_file \"metadata/$file.txt\" \"$type\"\n cp metadata/$file.txt $dest 2> /dev/null || touch $dest\n );;\n gs://*)\n echo \"Retrieving $file from $from\"\n gsutil cp -Z $from $dest >/dev/null 2>/dev/null || touch $dest\n cleanup_file \"$dest\" \"$type\"\n ;;\n *://*)\n echo \"Retrieving $file from $from\"\n download \"$from\" \"$dest\" || touch $dest\n cleanup_file \"$dest\" \"$type\"\n ;;\n esac\n fi\n}\nget_project_files_deprecated() {\n # \"preferred\" \"deprecated\" \"path\"\n if [ ! -s \"$3\" ]; then\n save_append_to=\"$append_to\"\n get_project_files \"$2\" \"$3\"\n if [ -s \"$3\" ]; then\n example=$(for file in $from_expanded; do echo $file; done|head -1)\n if [ $(basename $(dirname $example)) = \"$2\" ]; then\n note=\" directory\"\n else\n note=\"\"\n fi\n echo \"::warning file=$example::deprecation: please rename '$2'$note to '$1'\"\n else\n append_to=\"$save_append_to\"\n fi\n fi\n}",
"download() {\n curl -L -s \"$1\" -o \"$2\" -f\n exit_value=$?\n if [ $exit_value = 0 ]; then\n echo \"Downloaded $1 (to $2)\" >&2\n fi\n return $exit_value\n}",
"download_or_quit_with_error() {\n exit_code=$(mktemp)\n download \"$1\" \"$2\" || (\n echo $? > $exit_code\n echo \"Could not download $1 (to $2)\" >&2\n )\n if [ -s $exit_code ]; then\n exit_value=$(cat $exit_code)\n rm $exit_code\n quit $exit_value\n fi\n}",
"set_up_tools() {\n apps=\"\"\n add_app() {\n if ! command_v $1; then\n apps=\"$apps $@\"\n fi\n }\n add_app curl ca-certificates\n add_app git\n add_app parallel\n if [ -n \"$apps\" ]; then\n if command_v apt-get; then\n export DEBIAN_FRONTEND=noninteractive\n apt-get -qq update &&\n apt-get -qq install --no-install-recommends -y $apps >/dev/null 2>/dev/null\n echo Installed: $apps >&2\n elif command_v brew; then\n brew install $apps\n else\n echo missing $apps -- things will fail >&2\n fi\n fi\n set_up_jq\n}",
"set_up_jq() {\n if ! command_v jq || jq --version | perl -ne 'exit 0 unless s/^jq-//;exit 1 if /^(?:[2-9]|1\\d|1\\.(?:[6-9]|1\\d+))/; exit 0'; then\n jq_url=https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64\n spellchecker_bin=\"$spellchecker/bin\"\n jq_bin=\"$spellchecker_bin/jq\"\n mkdir -p $spellchecker_bin\n download_or_quit_with_error \"$jq_url\" \"$jq_bin\"\n chmod 0755 \"$jq_bin\"\n PATH=$spellchecker_bin:$PATH\n fi\n}",
"set_up_files() {\n mkdir -p .git\n cp $spellchecker/reporter.json .git/\n echo \"::add-matcher::.git/reporter.json\"\n get_project_files expect $expect_path\n get_project_files_deprecated expect whitelist $expect_path\n expect_files=$from_expanded\n expect_file=$from\n touch $expect_path\n new_expect_file=$append_to\n new_expect_file_new=$append_to_generated\n get_project_files excludes $excludelist_path\n excludes_files=$from_expanded\n excludes_file=$from\n if [ -s \"$excludes_path\" ]; then\n cp \"$excludes_path\" \"$excludes\"\n fi\n should_exclude_file=$(mktemp)\n get_project_files dictionary $dictionary_path\n if [ -s \"$dictionary_path\" ]; then\n cp \"$dictionary_path\" \"$dict\"\n fi\n if [ ! -s \"$dict\" ]; then\n DICTIONARY_VERSION=${DICTIONARY_VERSION:-$INPUT_DICTIONARY_VERSION}\n DICTIONARY_URL=${DICTIONARY_URL:-$INPUT_DICTIONARY_URL}\n eval download_or_quit_with_error \"$DICTIONARY_URL\" \"$dict\"\n fi\n get_project_files allow $allow_path\n if [ -s \"$allow_path\" ]; then\n cat \"$allow_path\" >> \"$dict\"\n fi\n get_project_files reject $reject_path\n if [ -s \"$reject_path\" ]; then\n dictionary_temp=$(mktemp)\n if grep_v_string '^('$(echo $(cat \"$reject_path\")|tr \" \" '|')')$' < \"$dict\" > $dictionary_temp; then\n cat $dictionary_temp > \"$dict\"\n fi\n fi\n get_project_files only $only_path\n if [ -s \"$only_path\" ]; then\n cp \"$only_path\" \"$only\"\n fi\n get_project_files patterns $patterns_path\n if [ -s \"$patterns_path\" ]; then\n cp \"$patterns_path\" \"$patterns\"\n fi\n get_project_files advice $advice_path\n if [ ! -s \"$advice_path\" ]; then\n get_project_files advice $advice_path_txt\n if [ -s \"$advice_path\" ]; then\n cp \"$advice_path_txt\" \"$advice_path\"\n fi\n fi",
" if [ -n \"$debug\" ]; then\n echo \"Clean up from previous run\"\n fi\n rm -f \"$run_output\"\n}",
"welcome() {\n echo \"Checking spelling...\"\n if [ -n \"$DEBUG\" ]; then\n begin_group 'Excluded paths'\n if [ -e \"$excludes\" ]; then\n echo 'Excluded paths:'\n cat \"$excludes\"\n else\n echo 'No excluded paths file'\n fi\n end_group\n begin_group 'Only paths restriction'\n if [ -e \"$only\" ]; then\n echo 'Only paths restriction:'\n cat \"$only\"\n else\n echo 'No only paths restriction file'\n fi\n end_group\n fi\n if [ -n \"$INPUT_PATH\" ]; then\n cd \"$INPUT_PATH\"\n fi\n}",
"xargs_zero() {\n if command_v parallel; then\n parallel --no-notice --no-run-if-empty -0 -n1 \"$@\"\n elif [ $(uname) = \"Linux\" ]; then\n xargs --no-run-if-empty -0 -n1 \"$@\"\n else\n arguments=\"$*\" \"$spellchecker/xargs_zero\"\n fi\n}",
"run_spell_check() {\n begin_group 'Spell check files'\n file_list=$(mktemp)\n git 'ls-files' -z 2> /dev/null |\\\n \"$spellchecker/exclude.pl\" > $file_list\n perl -e '$/=\"\\0\"; $count=0; while (<>) {s/\\R//; $count++ if /./;}; print \"Checking $count files\\n\";' $file_list\n end_group",
" begin_group 'Spell check'\n warning_output=$(mktemp)\n more_warnings=$(mktemp)\n (\n # Technically $should_exclude_file is an append race under parallel\n # since the file isn't critical -- it's advisory, I'm going to wait\n # on reports before fixing it.\n # The fix is to have a directory and have each process append to a\n # file named for its pid inside that directory, and then have the\n # caller can collate...\n cat $file_list) |\\\n parallel -0 -n8 \"-j$job_count\" \"$word_splitter\" |\\\n expect=\"$expect_path\" warning_output=\"$warning_output\" more_warnings=\"$more_warnings\" should_exclude_file=\"$should_exclude_file\" \"$word_collator\" |\\\n perl -p -n -e 's/ \\(.*//' > \"$run_output\"\n word_splitter_status=\"${PIPESTATUS[2]} ${PIPESTATUS[3]}\"\n cat \"$warning_output\" \"$more_warnings\"\n rm \"$warning_output\" \"$more_warnings\"\n end_group\n if [ \"$word_splitter_status\" != '0 0' ]; then\n echo \"$word_splitter failed ($word_splitter_status)\"\n exit 2\n fi\n rm $file_list\n}",
"printDetails() {\n echo ''\n echo 'If you are ok with the output of this run, you will need to'\n}",
"relative_note() {\n if [ -n \"$bucket\" ] && [ -n \"$project\" ]; then\n from=$(project_file_path $file)\n case \"$from\" in\n .*)\n ;;\n ssh://git@*|git@*|gs://|*://*)\n echo '(They can be run anywhere with permissions to update the bucket.)';;\n esac\n fi\n}\nto_retrieve_expect() {\n expect_file=expect.txt\n case \"$bucket\" in\n '')\n echo '# no bucket defined -- you can specify one per the README.md using the file defined below:';;\n ssh://git@*|git@*)\n echo \"git clone --depth 1 $bucket --single-branch --branch $project metadata; cp metadata/expect.txt .\";;\n gs://*)\n echo gsutil cp -Z $(project_file_path expect) expect.txt;;\n *://*)\n echo curl -L -s \"$(project_file_path expect)\" -o expect.txt;;\n esac\n}\nto_publish_expect() {\n case \"$bucket\" in\n '')\n echo \"# no bucket defined -- copy $1 to a bucket and configure it per the README.md\";;\n ssh://git@*|git@*)\n echo \"cp $1 metadata/expect.txt; (cd metadata; git commit expect.txt -m 'Updating expect'; git push)\";;\n gs://*)\n echo gsutil cp -Z $1 $(project_file_path expect);;\n *://*)\n echo \"# command to publish $1 is not known. URL: $(project_file_path expect)\";;\n *)\n if [ \"$2\" = new ]; then\n cmd=\"git add $bucket/$project || echo '... you want to ensure $1 is added to your repository...'\"\n case $(realpath --relative-base=\"$bucket\" \"$1\") in\n /*)\n cmd=\"cp $1 $(project_file_path expect); $cmd\";;\n esac\n echo \"$cmd\"\n fi\n ;;\n esac\n}",
"remove_items() {\n patch_remove=$(echo \"$diff_output\" | perl -ne 'next unless s/^-([^-])/$1/; s/\\n/ /; print')\n if [ -n \"$patch_remove\" ]; then\n echo \"\n<details><summary>Previously acknowledged words that are now absent\n</summary>$patch_remove</details>\n\"\n if [ -n \"$INPUT_CAPTURE_STALE_WORDS\" ]; then\n remove_words=$(mktemp)\n echo \"$patch_remove\" > $remove_words\n echo \"::set-output name=stale_words::$remove_words\"\n fi\n else\n rm \"$fewer_misspellings_canary\"\n fi\n}",
"spelling_warning() {\n OUTPUT=\"#### $1:\n\"\n spelling_body \"$2\" \"$3\"\n post_commit_comment\n}\nspelling_info() {\n if [ -z \"$2\" ]; then\n out=\"$1\"\n else\n out=\"$1",
"$2\"\n fi\n spelling_body \"$out\" \"$3\"\n if [ -n \"$VERBOSE\" ]; then\n OUTPUT=\"## @check-spelling-bot Report",
"$OUTPUT\"\n post_commit_comment\n else\n echo \"$OUTPUT\"\n fi\n}\nspelling_body() {\n err=\"$2\"\n if [ -n \"$OUTPUT\" ]; then\n header=\"$OUTPUT",
"\"\n else\n header=\"\"\n fi\n header=\"# @check-spelling-bot Report",
"$header\"\n if [ -z \"$err\" ]; then\n OUTPUT=\"$header$1\"\n else\n if [ -e \"$fewer_misspellings_canary\" ]; then\n cleanup_text=\" (and remove the previously acknowledged and now absent words)\"\n fi\n if [ -n \"$GITHUB_HEAD_REF\" ]; then\n remote_url_ssh=$(jq -r .pull_request.head.repo.ssh_url < $GITHUB_EVENT_PATH)\n remote_url_https=$(jq -r .pull_request.head.repo.clone_url < $GITHUB_EVENT_PATH)\n remote_ref=$GITHUB_HEAD_REF\n else\n remote_url_ssh=$(jq -r .repository.ssh_url < $GITHUB_EVENT_PATH)\n remote_url_https=$(jq -r .repository.clone_url < $GITHUB_EVENT_PATH)\n remote_ref=$GITHUB_REF\n fi\n remote_ref=${remote_ref#refs/heads/}\n OUTPUT=\"$header$1",
"\"\n if [ -s \"$should_exclude_file\" ]; then\n if [ -n \"$INPUT_CAPTURE_SKIPPED_FILES\" ]; then\n echo \"::set-output name=skipped_files::$should_exclude_file\"\n fi\n OUTPUT=\"$OUTPUT\n<details><summary>Some files were were automatically ignored</summary>",
"These sample patterns would exclude them:\n\"'```'\"\n$should_exclude_patterns\n\"'```'\nif [ $(wc -l \"$should_exclude_file\" |perl -pne 's/(\\d+)\\s+.*/$1/') -gt 10 ]; then\n OUTPUT=\"$OUTPUT\n\"'You should consider excluding directory paths (e.g. `(?:^|/)vendor/`), filenames (e.g. `(?:^|/)yarn\\.lock$`), or file extensions (e.g. `\\.gz$`)\n'\nfi\n OUTPUT=\"$OUTPUT\n\"'You should consider adding them to:\n```'\"\n$(echo \"$excludes_files\" | xargs -n1 echo)\n\"'```",
"File matching is via Perl regular expressions.",
"To check these files, more of their words need to be in the dictionary than not. You can use `patterns.txt` to exclude portions, add items to the dictionary (e.g. by adding them to `allow.txt`), or fix typos.\n</details>\n'\n fi\n OUTPUT=\"$OUTPUT\n<details><summary>To accept these unrecognized words as correct$cleanup_text,\nrun the following commands</summary>",
"... in a clone of the [$remote_url_ssh]($remote_url_https) repository\non the \\`$remote_ref\\` branch:\n\"$(relative_note)\"",
"\"'```'\"\n$err\n\"'```\n</details>\n'\n if [ -s \"$advice_path\" ]; then\n OUTPUT=\"$OUTPUT",
"`cat \"$advice_path\"`\n\"\n fi\n fi\n}\nbullet_words_and_warn() {\n echo \"$1\" > \"$tokens_file\"\n if [ -n \"$INPUT_CAPTURE_UNKNOWN_WORDS\" ]; then\n file_with_unknown_words=$(mktemp)\n cp \"$tokens_file\" $file_with_unknown_words\n echo \"::set-output name=unknown_words::$file_with_unknown_words\"\n fi\n perl -pne 's/^(.)/* $1/' \"$tokens_file\"\n remove_items\n rm -f \"$tokens_file\"\n}",
"quit() {\n echo \"::remove-matcher owner=check-spelling::\"\n if [ -n \"$junit\" ]; then\n exit\n fi\n exit $1\n}",
"body_to_payload() {\n BODY=\"$1\"\n PAYLOAD=$(mktemp)\n echo '{}' | jq --rawfile body \"$BODY\" '.body = $body' > $PAYLOAD\n if [ -n \"$DEBUG\" ]; then\n cat $PAYLOAD >&2\n fi\n}",
"collaborator() {\n collaborator_url=\"$1\"\n curl -L -s \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n -H \"Accept: application/vnd.github.v3+json\" \\\n \"$collaborator_url\" 2> /dev/null\n}",
"pull_request() {\n pull_request_url=\"$1\"\n curl -L -s -S \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n \"$pull_request_url\"\n}",
"react() {\n url=\"$1\"\n reaction=\"$2\"\n curl -L -s -S \\\n -X POST \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n -H \"Accept: application/vnd.github.squirrel-girl-preview+json\" \\\n \"$url\"/reactions \\\n -d '{\"content\":\"'\"$reaction\"'\"}'\n}",
"comment() {\n comments_url=\"$1\"\n payload=\"$2\"\n if [ -n \"$payload\" ]; then\n payload=\"--data @$payload\"\n method=\"$3\"\n if [ -n \"$method\" ]; then\n method=\"-X $method\"\n fi\n fi\n curl -L -s -S \\\n $method \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n -H 'Accept: application/vnd.github.comfort-fade-preview+json' \\\n $payload \\\n \"$comments_url\"\n}",
"set_comments_url() {\n event=\"$1\"\n file=\"$2\"\n sha=\"$3\"\n case \"$event\" in\n issue_comment)\n COMMENTS_URL=$(cat $file | jq -r .issue.comments_url);;\n pull_request|pull_request_target|pull_request_review_comment)\n COMMENTS_URL=$(cat $file | jq -r .pull_request.comments_url);;\n push|commit_comment)\n COMMENTS_URL=$(cat $file | jq -r .repository.commits_url | perl -pne 's#\\{/sha}#/'$sha'/comments#');;\n esac\n}",
"post_commit_comment() {\n if [ -n \"$OUTPUT\" ]; then\n if [ -n \"$INPUT_POST_COMMENT\" ]; then\n echo \"Preparing a comment for $GITHUB_EVENT_NAME\"\n set_comments_url \"$GITHUB_EVENT_NAME\" \"$GITHUB_EVENT_PATH\" \"$GITHUB_SHA\"\n if [ -n \"$COMMENTS_URL\" ] && [ -z \"${COMMENTS_URL##*:*}\" ]; then\n BODY=$(mktemp)\n echo \"$OUTPUT\" > $BODY\n body_to_payload $BODY\n echo $COMMENTS_URL\n response=$(mktemp_json)",
" res=0\n comment \"$COMMENTS_URL\" \"$PAYLOAD\" > $response || res=$?\n if [ $res -gt 0 ]; then\n if [ -z \"$DEBUG\" ]; then\n echo \"failed posting to $COMMENTS_URL\"\n echo \"$PAYLOAD\"\n fi\n return $res\n fi",
" if [ -n \"$DEBUG\" ]; then\n cat $response\n fi\n COMMENT_URL=$(jq -r .url < $response)\n perl -p -i.orig -e 's<COMMENT_URL><'\"$COMMENT_URL\"'>' $BODY\n if diff -q \"$BODY.orig\" \"$BODY\" > /dev/null; then\n no_patch=1\n fi\n rm \"$BODY.orig\"\n if offer_quote_reply; then\n (\n echo\n echo \"Alternatively, the bot can do this for you if you reply quoting the following line:\"\n echo \"@check-spelling-bot apply [changes]($COMMENT_URL).\"\n )>> $BODY\n no_patch=\n fi\n if [ -z \"$no_patch\" ]; then\n body_to_payload $BODY\n comment \"$COMMENT_URL\" \"$PAYLOAD\" \"PATCH\" > $response\n if [ -n \"$DEBUG\" ]; then\n cat $response\n fi\n fi\n rm -f $BODY\n else\n echo \"$OUTPUT\"\n fi\n else\n echo \"$OUTPUT\"\n fi\n fi\n}",
"strip_lines() {\n tr \"\\n\" \" \"\n}",
"minimize_comment_call() {\n comment_node=\"$1\"\n echo \"\n minimizeComment(\n input:\n {\n subjectId: ${Q}$comment_node${Q},\n classifier: RESOLVED\n }\n ){\n minimizedComment {\n isMinimized\n }\n }\n\" | strip_lead | strip_lines\n}",
"collapse_comment_mutation() {\n comment_node=\"$1\"\n query_head=\"mutation {\"\n query_tail=\"}\"\n query_body=\"\"\n i=0\n while [ -n \"$1\" ]; do\n query_body=\"$query_body q$i: \"$(minimize_comment_call \"$1\")\n i=\"$((i+1))\"\n shift\n done\n query=\"$query_head$query_body$query_tail\"\n echo '{}' | jq --arg query \"$query\" '.query = $query'\n}",
"collapse_comment() {\n curl -s \\\n -H \"Authorization: token $GITHUB_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data-binary \"$(collapse_comment_mutation \"$@\")\" \\\n $GITHUB_GRAPHQL_URL\n}",
"exit_if_no_unknown_words() {\n if [ ! -s \"$run_output\" ]; then\n quit 0\n fi\n}",
"grep_v_spellchecker() {\n grep_v_string \"$spellchecker\"\n}",
"grep_v_string() {\n perl -ne \"next if m{$1}; print\"\n}",
"compare_new_output() {\n begin_group 'Compare expect with new output'\n sorted_expect=\"$temp/expect.sorted.txt\"\n (sed -e 's/#.*//' \"$expect_path\" | sort_unique) > \"$sorted_expect\"\n expect_path=\"$sorted_expect\"",
" diff_output=$(\n diff -w -U0 \"$expect_path\" \"$run_output\" |\n grep_v_spellchecker)\n end_group",
" if [ -z \"$diff_output\" ]; then\n begin_group 'No misspellings'\n title=\"No new words with misspellings found\"\n spelling_info \"$title\" \"There are currently $(wc -l $expect_path|sed -e 's/ .*//') expected items.\" \"\"\n end_group\n quit 0\n fi",
" begin_group 'New output'\n new_output=$(\n diff -i -w -U0 \"$expect_path\" \"$run_output\" |\n grep_v_spellchecker |\\\n perl -n -w -e 'next unless /^\\+/; next if /^\\+{3} /; s/^.//; print;')\n end_group",
" should_exclude_patterns=$(sort \"$should_exclude_file\" | path_to_pattern)\n}",
"generate_curl_instructions() {\n instructions=$(mktemp)\n (\n echo 'update_files() {'\n (\n skip_wrapping=1\n if [ -n \"$patch_remove\" ]; then\n patch_remove='$patch_remove'\n fi\n if [ -n \"$patch_add\" ]; then\n patch_add='$patch_add'\n fi\n if [ -n \"$should_exclude_patterns\" ]; then\n should_exclude_patterns='$should_exclude_patterns'\n fi\n generated=$(generate_instructions)\n cat $generated\n rm $generated\n )\n echo '}'\n ) >> $instructions\n echo '\n comment_json=$(mktemp)\n curl -L -s -S \\\n --header \"Content-Type: application/json\" \\\n \"COMMENT_URL\" > \"$comment_json\"\n comment_body=$(mktemp)\n jq -r .body < \"$comment_json\" > $comment_body\n rm $comment_json\n '\"$(patch_variables $Q'$comment_body'$Q)\"'\n update_files\n rm $comment_body\n git add -u\n ' | sed -e 's/^ //' >> $instructions\n echo $instructions\n}",
"skip_curl() {\n [ -n \"$SKIP_CURL\" ] || repo_is_private\n}",
"make_instructions() {\n patch_remove=$(echo \"$diff_output\" | perl -ne 'next unless s/^-([^-])/$1/; s/\\n/ /; print')\n patch_add=$(echo \"$diff_output\" | perl -ne 'next unless s/^\\+([^+])/$1/; s/\\n/ /; print')\n if skip_curl; then\n instructions=$(generate_instructions)\n if [ -n \"$patch_add\" ]; then\n to_publish_expect \"$new_expect_file\" $new_expect_file_new >> $instructions\n fi\n else\n instructions=$(generate_curl_instructions)\n fi\n cat $instructions\n rm $instructions\n}",
"fewer_misspellings() {\n if [ -n \"$new_output\" ]; then\n return\n fi",
" begin_group 'Fewer misspellings'\n title='There are now fewer misspellings than before'\n SKIP_CURL=1\n instructions=$(\n make_instructions\n )\n if [ -n \"$INPUT_EXPERIMENTAL_COMMIT_NOTE\" ]; then\n . \"$spellchecker/update-state.sh\"\n skip_push_and_pop=1",
" instructions_head=$(mktemp)\n (\n patch_add=1\n patch_remove=1\n patch_variables $comment_body > $instructions_head\n )\n . $instructions_head\n rm $instructions_head\n instructions=$(generate_instructions)",
" . $instructions &&\n git_commit \"$INPUT_EXPERIMENTAL_COMMIT_NOTE\" &&\n git push origin ${GITHUB_HEAD_REF:-$GITHUB_REF}\n spelling_info \"$title\" \"\" \"Applied\"\n else\n spelling_info \"$title\" \"\" \"$instructions\"\n fi\n end_group\n quit\n}\nmore_misspellings() {\n begin_group 'Unrecognized'\n title='Unrecognized words, please review'\n instructions=$(\n make_instructions\n )\n spelling_warning \"$title\" \"$(bullet_words_and_warn \"$new_output\")\" \"$instructions\"\n end_group\n quit 1\n}",
"define_variables\nset_up_tools\nset_up_files\n. \"$spellchecker/update-state.sh\"\nmain\nwelcome\nrun_spell_check\nexit_if_no_unknown_words\ncompare_new_output\nfewer_misspellings_canary=$(mktemp)\nfewer_misspellings\nmore_misspellings"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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": [2, 22, 377], "buggy_code_start_loc": [2, 19, 376], "filenames": ["common.sh", "spelling-unknown-word-splitter.pl", "unknown-words.sh"], "fixing_code_end_loc": [8, 22, 398], "fixing_code_start_loc": [3, 19, 376], "message": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:check-spelling:check-spelling:*:*:*:*:*:*:*:*", "matchCriteriaId": "A4A73141-03F7-4AAB-A7E3-6D2331D73257", "versionEndExcluding": "0.0.19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "check-spelling is a github action which provides CI spell checking. In affected versions and for a repository with the [check-spelling action](https://github.com/marketplace/actions/check-spelling) enabled that triggers on `pull_request_target` (or `schedule`), an attacker can send a crafted Pull Request that causes a `GITHUB_TOKEN` to be exposed. With the `GITHUB_TOKEN`, it's possible to push commits to the repository bypassing standard approval processes. Commits to the repository could then steal any/all secrets available to the repository. As a workaround users may can either: [Disable the workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) until you've fixed all branches or Set repository to [Allow specific actions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). check-spelling isn't a verified creator and it certainly won't be anytime soon. You could then explicitly add other actions that your repository uses. Set repository [Workflow permissions](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) to `Read repository contents permission`. Workflows using `check-spelling/check-spelling@main` will get the fix automatically. Workflows using a pinned sha or tagged version will need to change the affected workflows for all repository branches to the latest version. Users can verify who and which Pull Requests have been running the action by looking up the spelling.yml action in the Actions tab of their repositories, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - you can filter PRs by adding ?query=event%3Apull_request_target, e.g., https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target."}, {"lang": "es", "value": "check-spelling es una acci\u00f3n de github que proporciona una comprobaci\u00f3n ortogr\u00e1fica de CI. En versiones afectadas y para un repositorio con la acci\u00f3n [check-spelling](https://github.com/marketplace/actions/check-spelling) habilitada que desencadena en \"pull_request_target\" (o \"schedule\"), un atacante puede enviar un Pull Request dise\u00f1ado que cause que un \"GITHUB_TOKEN\" sea expuesto. Con el \"GITHUB_TOKEN\", es posible enviar confirmaciones al commit omitiendo los procesos de aprobaci\u00f3n est\u00e1ndar. Los commits al repositorio podr\u00edan entonces robar cualquier/todos los secretos disponibles en el repositorio. Como soluci\u00f3n, los usuarios pueden: [Desactivar el flujo de trabajo](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) hasta que haya corregido todas las ramas o Configurar el repositorio para [Permitir acciones espec\u00edficas](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#allowing-specific-actions-to-run). la comprobaci\u00f3n de la ortograf\u00eda no es un creador verificado y ciertamente no lo ser\u00e1 pronto. Entonces podr\u00eda a\u00f1adir expl\u00edcitamente otras acciones que su repositorio usa. Ajuste el repositorio [Permisos de flujo de trabajo](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/disabling-or-limiting-github-actions-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository) a \"Read repository contents permission\". Los flujos de trabajo que usen \"check-spelling/check-spelling@main\" obtendr\u00e1n la correcci\u00f3n autom\u00e1ticamente. Los flujos de trabajo que usen una versi\u00f3n con anclaje o etiquetada tendr\u00e1n que cambiar los flujos de trabajo afectados para todas las ramas del repositorio a la \u00faltima versi\u00f3n. Los usuarios pueden verificar qui\u00e9n y qu\u00e9 Pull Requests han ejecutado la acci\u00f3n buscando la acci\u00f3n spelling.yml en la pesta\u00f1a Acciones de sus repositorios, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml - puede filtrar los PRs al a\u00f1adir ?query=event%3Apull_request_target, por ejemplo, https://github.com/check-spelling/check-spelling/actions/workflows/spelling.yml?query=event%3Apull_request_target"}], "evaluatorComment": null, "id": "CVE-2021-32724", "lastModified": "2021-09-27T14:21:55.153", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 6.8, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 6.4, "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": 9.9, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "CHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.1, "impactScore": 6.0, "source": "security-advisories@github.com", "type": "Primary"}]}, "published": "2021-09-09T21:15:07.250", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, {"source": "security-advisories@github.com", "tags": ["Mitigation", "Third Party Advisory"], "url": "https://github.com/check-spelling/check-spelling/security/advisories/GHSA-g86g-chm8-7r2p"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-532"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/check-spelling/check-spelling/commit/436362fc6b588d9d561cbdb575260ca593c8dc56"}, "type": "CWE-532"}
| 217
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com>\n * Copyright (c) 2010-2014, Pieter Noordhuis <pcnoordhuis at gmail dot com>\n * Copyright (c) 2015, Matt Stancliff <matt at genges dot com>,\n * Jan-Erik Rediger <janerik at fnordig dot com>\n *\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 are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n * * 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 * * Neither the name of Redis nor the names of its contributors may be used\n * to endorse or promote products derived from this software without\n * specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */",
"#include \"fmacros.h\"\n#include <string.h>\n#include <stdlib.h>\n#include <assert.h>\n#include <errno.h>\n#include <ctype.h>",
"#include \"hiredis.h\"\n#include \"net.h\"\n#include \"sds.h\"\n#include \"async.h\"\n#include \"win32.h\"",
"extern int redisContextUpdateConnectTimeout(redisContext *c, const struct timeval *timeout);\nextern int redisContextUpdateCommandTimeout(redisContext *c, const struct timeval *timeout);",
"static redisContextFuncs redisContextDefaultFuncs = {\n .free_privctx = NULL,\n .async_read = redisAsyncRead,\n .async_write = redisAsyncWrite,\n .read = redisNetRead,\n .write = redisNetWrite\n};",
"static redisReply *createReplyObject(int type);\nstatic void *createStringObject(const redisReadTask *task, char *str, size_t len);\nstatic void *createArrayObject(const redisReadTask *task, size_t elements);\nstatic void *createIntegerObject(const redisReadTask *task, long long value);\nstatic void *createDoubleObject(const redisReadTask *task, double value, char *str, size_t len);\nstatic void *createNilObject(const redisReadTask *task);\nstatic void *createBoolObject(const redisReadTask *task, int bval);",
"/* Default set of functions to build the reply. Keep in mind that such a\n * function returning NULL is interpreted as OOM. */\nstatic redisReplyObjectFunctions defaultFunctions = {\n createStringObject,\n createArrayObject,\n createIntegerObject,\n createDoubleObject,\n createNilObject,\n createBoolObject,\n freeReplyObject\n};",
"/* Create a reply object */\nstatic redisReply *createReplyObject(int type) {\n redisReply *r = hi_calloc(1,sizeof(*r));",
" if (r == NULL)\n return NULL;",
" r->type = type;\n return r;\n}",
"/* Free a reply object */\nvoid freeReplyObject(void *reply) {\n redisReply *r = reply;\n size_t j;",
" if (r == NULL)\n return;",
" switch(r->type) {\n case REDIS_REPLY_INTEGER:\n break; /* Nothing to free */\n case REDIS_REPLY_ARRAY:\n case REDIS_REPLY_MAP:\n case REDIS_REPLY_SET:\n case REDIS_REPLY_PUSH:\n if (r->element != NULL) {\n for (j = 0; j < r->elements; j++)\n freeReplyObject(r->element[j]);\n hi_free(r->element);\n }\n break;\n case REDIS_REPLY_ERROR:\n case REDIS_REPLY_STATUS:\n case REDIS_REPLY_STRING:\n case REDIS_REPLY_DOUBLE:\n case REDIS_REPLY_VERB:\n hi_free(r->str);\n break;\n }\n hi_free(r);\n}",
"static void *createStringObject(const redisReadTask *task, char *str, size_t len) {\n redisReply *r, *parent;\n char *buf;",
" r = createReplyObject(task->type);\n if (r == NULL)\n return NULL;",
" assert(task->type == REDIS_REPLY_ERROR ||\n task->type == REDIS_REPLY_STATUS ||\n task->type == REDIS_REPLY_STRING ||\n task->type == REDIS_REPLY_VERB);",
" /* Copy string value */\n if (task->type == REDIS_REPLY_VERB) {\n buf = hi_malloc(len-4+1); /* Skip 4 bytes of verbatim type header. */\n if (buf == NULL) goto oom;",
" memcpy(r->vtype,str,3);\n r->vtype[3] = '\\0';\n memcpy(buf,str+4,len-4);\n buf[len-4] = '\\0';\n r->len = len - 4;\n } else {\n buf = hi_malloc(len+1);\n if (buf == NULL) goto oom;",
" memcpy(buf,str,len);\n buf[len] = '\\0';\n r->len = len;\n }\n r->str = buf;",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET ||\n parent->type == REDIS_REPLY_PUSH);\n parent->element[task->idx] = r;\n }\n return r;",
"oom:\n freeReplyObject(r);\n return NULL;\n}",
"static void *createArrayObject(const redisReadTask *task, size_t elements) {\n redisReply *r, *parent;",
" r = createReplyObject(task->type);\n if (r == NULL)\n return NULL;",
" if (elements > 0) {",
"",
" r->element = hi_calloc(elements,sizeof(redisReply*));\n if (r->element == NULL) {\n freeReplyObject(r);\n return NULL;\n }\n }",
" r->elements = elements;",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET ||\n parent->type == REDIS_REPLY_PUSH);\n parent->element[task->idx] = r;\n }\n return r;\n}",
"static void *createIntegerObject(const redisReadTask *task, long long value) {\n redisReply *r, *parent;",
" r = createReplyObject(REDIS_REPLY_INTEGER);\n if (r == NULL)\n return NULL;",
" r->integer = value;",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET ||\n parent->type == REDIS_REPLY_PUSH);\n parent->element[task->idx] = r;\n }\n return r;\n}",
"static void *createDoubleObject(const redisReadTask *task, double value, char *str, size_t len) {\n redisReply *r, *parent;",
" r = createReplyObject(REDIS_REPLY_DOUBLE);\n if (r == NULL)\n return NULL;",
" r->dval = value;\n r->str = hi_malloc(len+1);\n if (r->str == NULL) {\n freeReplyObject(r);\n return NULL;\n }",
" /* The double reply also has the original protocol string representing a\n * double as a null terminated string. This way the caller does not need\n * to format back for string conversion, especially since Redis does efforts\n * to make the string more human readable avoiding the calssical double\n * decimal string conversion artifacts. */\n memcpy(r->str, str, len);\n r->str[len] = '\\0';",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET);\n parent->element[task->idx] = r;\n }\n return r;\n}",
"static void *createNilObject(const redisReadTask *task) {\n redisReply *r, *parent;",
" r = createReplyObject(REDIS_REPLY_NIL);\n if (r == NULL)\n return NULL;",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET ||\n parent->type == REDIS_REPLY_PUSH);\n parent->element[task->idx] = r;\n }\n return r;\n}",
"static void *createBoolObject(const redisReadTask *task, int bval) {\n redisReply *r, *parent;",
" r = createReplyObject(REDIS_REPLY_BOOL);\n if (r == NULL)\n return NULL;",
" r->integer = bval != 0;",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET);\n parent->element[task->idx] = r;\n }\n return r;\n}",
"/* Return the number of digits of 'v' when converted to string in radix 10.\n * Implementation borrowed from link in redis/src/util.c:string2ll(). */\nstatic uint32_t countDigits(uint64_t v) {\n uint32_t result = 1;\n for (;;) {\n if (v < 10) return result;\n if (v < 100) return result + 1;\n if (v < 1000) return result + 2;\n if (v < 10000) return result + 3;\n v /= 10000U;\n result += 4;\n }\n}",
"/* Helper that calculates the bulk length given a certain string length. */\nstatic size_t bulklen(size_t len) {\n return 1+countDigits(len)+2+len+2;\n}",
"int redisvFormatCommand(char **target, const char *format, va_list ap) {\n const char *c = format;\n char *cmd = NULL; /* final command */\n int pos; /* position in final command */\n hisds curarg, newarg; /* current argument */\n int touched = 0; /* was the current argument touched? */\n char **curargv = NULL, **newargv = NULL;\n int argc = 0;\n int totlen = 0;\n int error_type = 0; /* 0 = no error; -1 = memory error; -2 = format error */\n int j;",
" /* Abort if there is not target to set */\n if (target == NULL)\n return -1;",
" /* Build the command string accordingly to protocol */\n curarg = hi_sdsempty();\n if (curarg == NULL)\n return -1;",
" while(*c != '\\0') {\n if (*c != '%' || c[1] == '\\0') {\n if (*c == ' ') {\n if (touched) {\n newargv = hi_realloc(curargv,sizeof(char*)*(argc+1));\n if (newargv == NULL) goto memory_err;\n curargv = newargv;\n curargv[argc++] = curarg;\n totlen += bulklen(hi_sdslen(curarg));",
" /* curarg is put in argv so it can be overwritten. */\n curarg = hi_sdsempty();\n if (curarg == NULL) goto memory_err;\n touched = 0;\n }\n } else {\n newarg = hi_sdscatlen(curarg,c,1);\n if (newarg == NULL) goto memory_err;\n curarg = newarg;\n touched = 1;\n }\n } else {\n char *arg;\n size_t size;",
" /* Set newarg so it can be checked even if it is not touched. */\n newarg = curarg;",
" switch(c[1]) {\n case 's':\n arg = va_arg(ap,char*);\n size = strlen(arg);\n if (size > 0)\n newarg = hi_sdscatlen(curarg,arg,size);\n break;\n case 'b':\n arg = va_arg(ap,char*);\n size = va_arg(ap,size_t);\n if (size > 0)\n newarg = hi_sdscatlen(curarg,arg,size);\n break;\n case '%':\n newarg = hi_sdscat(curarg,\"%\");\n break;\n default:\n /* Try to detect printf format */\n {\n static const char intfmts[] = \"diouxX\";\n static const char flags[] = \"#0-+ \";\n char _format[16];\n const char *_p = c+1;\n size_t _l = 0;\n va_list _cpy;",
" /* Flags */\n while (*_p != '\\0' && strchr(flags,*_p) != NULL) _p++;",
" /* Field width */\n while (*_p != '\\0' && isdigit(*_p)) _p++;",
" /* Precision */\n if (*_p == '.') {\n _p++;\n while (*_p != '\\0' && isdigit(*_p)) _p++;\n }",
" /* Copy va_list before consuming with va_arg */\n va_copy(_cpy,ap);",
" /* Integer conversion (without modifiers) */\n if (strchr(intfmts,*_p) != NULL) {\n va_arg(ap,int);\n goto fmt_valid;\n }",
" /* Double conversion (without modifiers) */\n if (strchr(\"eEfFgGaA\",*_p) != NULL) {\n va_arg(ap,double);\n goto fmt_valid;\n }",
" /* Size: char */\n if (_p[0] == 'h' && _p[1] == 'h') {\n _p += 2;\n if (*_p != '\\0' && strchr(intfmts,*_p) != NULL) {\n va_arg(ap,int); /* char gets promoted to int */\n goto fmt_valid;\n }\n goto fmt_invalid;\n }",
" /* Size: short */\n if (_p[0] == 'h') {\n _p += 1;\n if (*_p != '\\0' && strchr(intfmts,*_p) != NULL) {\n va_arg(ap,int); /* short gets promoted to int */\n goto fmt_valid;\n }\n goto fmt_invalid;\n }",
" /* Size: long long */\n if (_p[0] == 'l' && _p[1] == 'l') {\n _p += 2;\n if (*_p != '\\0' && strchr(intfmts,*_p) != NULL) {\n va_arg(ap,long long);\n goto fmt_valid;\n }\n goto fmt_invalid;\n }",
" /* Size: long */\n if (_p[0] == 'l') {\n _p += 1;\n if (*_p != '\\0' && strchr(intfmts,*_p) != NULL) {\n va_arg(ap,long);\n goto fmt_valid;\n }\n goto fmt_invalid;\n }",
" fmt_invalid:\n va_end(_cpy);\n goto format_err;",
" fmt_valid:\n _l = (_p+1)-c;\n if (_l < sizeof(_format)-2) {\n memcpy(_format,c,_l);\n _format[_l] = '\\0';\n newarg = hi_sdscatvprintf(curarg,_format,_cpy);",
" /* Update current position (note: outer blocks\n * increment c twice so compensate here) */\n c = _p-1;\n }",
" va_end(_cpy);\n break;\n }\n }",
" if (newarg == NULL) goto memory_err;\n curarg = newarg;",
" touched = 1;\n c++;\n }\n c++;\n }",
" /* Add the last argument if needed */\n if (touched) {\n newargv = hi_realloc(curargv,sizeof(char*)*(argc+1));\n if (newargv == NULL) goto memory_err;\n curargv = newargv;\n curargv[argc++] = curarg;\n totlen += bulklen(hi_sdslen(curarg));\n } else {\n hi_sdsfree(curarg);\n }",
" /* Clear curarg because it was put in curargv or was free'd. */\n curarg = NULL;",
" /* Add bytes needed to hold multi bulk count */\n totlen += 1+countDigits(argc)+2;",
" /* Build the command at protocol level */\n cmd = hi_malloc(totlen+1);\n if (cmd == NULL) goto memory_err;",
" pos = sprintf(cmd,\"*%d\\r\\n\",argc);\n for (j = 0; j < argc; j++) {\n pos += sprintf(cmd+pos,\"$%zu\\r\\n\",hi_sdslen(curargv[j]));\n memcpy(cmd+pos,curargv[j],hi_sdslen(curargv[j]));\n pos += hi_sdslen(curargv[j]);\n hi_sdsfree(curargv[j]);\n cmd[pos++] = '\\r';\n cmd[pos++] = '\\n';\n }\n assert(pos == totlen);\n cmd[pos] = '\\0';",
" hi_free(curargv);\n *target = cmd;\n return totlen;",
"format_err:\n error_type = -2;\n goto cleanup;",
"memory_err:\n error_type = -1;\n goto cleanup;",
"cleanup:\n if (curargv) {\n while(argc--)\n hi_sdsfree(curargv[argc]);\n hi_free(curargv);\n }",
" hi_sdsfree(curarg);\n hi_free(cmd);",
" return error_type;\n}",
"/* Format a command according to the Redis protocol. This function\n * takes a format similar to printf:\n *\n * %s represents a C null terminated string you want to interpolate\n * %b represents a binary safe string\n *\n * When using %b you need to provide both the pointer to the string\n * and the length in bytes as a size_t. Examples:\n *\n * len = redisFormatCommand(target, \"GET %s\", mykey);\n * len = redisFormatCommand(target, \"SET %s %b\", mykey, myval, myvallen);\n */\nint redisFormatCommand(char **target, const char *format, ...) {\n va_list ap;\n int len;\n va_start(ap,format);\n len = redisvFormatCommand(target,format,ap);\n va_end(ap);",
" /* The API says \"-1\" means bad result, but we now also return \"-2\" in some\n * cases. Force the return value to always be -1. */\n if (len < 0)\n len = -1;",
" return len;\n}",
"/* Format a command according to the Redis protocol using an hisds string and\n * hi_sdscatfmt for the processing of arguments. This function takes the\n * number of arguments, an array with arguments and an array with their\n * lengths. If the latter is set to NULL, strlen will be used to compute the\n * argument lengths.\n */\nint redisFormatSdsCommandArgv(hisds *target, int argc, const char **argv,\n const size_t *argvlen)\n{\n hisds cmd, aux;\n unsigned long long totlen;\n int j;\n size_t len;",
" /* Abort on a NULL target */\n if (target == NULL)\n return -1;",
" /* Calculate our total size */\n totlen = 1+countDigits(argc)+2;\n for (j = 0; j < argc; j++) {\n len = argvlen ? argvlen[j] : strlen(argv[j]);\n totlen += bulklen(len);\n }",
" /* Use an SDS string for command construction */\n cmd = hi_sdsempty();\n if (cmd == NULL)\n return -1;",
" /* We already know how much storage we need */\n aux = hi_sdsMakeRoomFor(cmd, totlen);\n if (aux == NULL) {\n hi_sdsfree(cmd);\n return -1;\n }",
" cmd = aux;",
" /* Construct command */\n cmd = hi_sdscatfmt(cmd, \"*%i\\r\\n\", argc);\n for (j=0; j < argc; j++) {\n len = argvlen ? argvlen[j] : strlen(argv[j]);\n cmd = hi_sdscatfmt(cmd, \"$%u\\r\\n\", len);\n cmd = hi_sdscatlen(cmd, argv[j], len);\n cmd = hi_sdscatlen(cmd, \"\\r\\n\", sizeof(\"\\r\\n\")-1);\n }",
" assert(hi_sdslen(cmd)==totlen);",
" *target = cmd;\n return totlen;\n}",
"void redisFreeSdsCommand(hisds cmd) {\n hi_sdsfree(cmd);\n}",
"/* Format a command according to the Redis protocol. This function takes the\n * number of arguments, an array with arguments and an array with their\n * lengths. If the latter is set to NULL, strlen will be used to compute the\n * argument lengths.\n */\nint redisFormatCommandArgv(char **target, int argc, const char **argv, const size_t *argvlen) {\n char *cmd = NULL; /* final command */\n int pos; /* position in final command */\n size_t len;\n int totlen, j;",
" /* Abort on a NULL target */\n if (target == NULL)\n return -1;",
" /* Calculate number of bytes needed for the command */\n totlen = 1+countDigits(argc)+2;\n for (j = 0; j < argc; j++) {\n len = argvlen ? argvlen[j] : strlen(argv[j]);\n totlen += bulklen(len);\n }",
" /* Build the command at protocol level */\n cmd = hi_malloc(totlen+1);\n if (cmd == NULL)\n return -1;",
" pos = sprintf(cmd,\"*%d\\r\\n\",argc);\n for (j = 0; j < argc; j++) {\n len = argvlen ? argvlen[j] : strlen(argv[j]);\n pos += sprintf(cmd+pos,\"$%zu\\r\\n\",len);\n memcpy(cmd+pos,argv[j],len);\n pos += len;\n cmd[pos++] = '\\r';\n cmd[pos++] = '\\n';\n }\n assert(pos == totlen);\n cmd[pos] = '\\0';",
" *target = cmd;\n return totlen;\n}",
"void redisFreeCommand(char *cmd) {\n hi_free(cmd);\n}",
"void __redisSetError(redisContext *c, int type, const char *str) {\n size_t len;",
" c->err = type;\n if (str != NULL) {\n len = strlen(str);\n len = len < (sizeof(c->errstr)-1) ? len : (sizeof(c->errstr)-1);\n memcpy(c->errstr,str,len);\n c->errstr[len] = '\\0';\n } else {\n /* Only REDIS_ERR_IO may lack a description! */\n assert(type == REDIS_ERR_IO);\n strerror_r(errno, c->errstr, sizeof(c->errstr));\n }\n}",
"redisReader *redisReaderCreate(void) {\n return redisReaderCreateWithFunctions(&defaultFunctions);\n}",
"static void redisPushAutoFree(void *privdata, void *reply) {\n (void)privdata;\n freeReplyObject(reply);\n}",
"static redisContext *redisContextInit(void) {\n redisContext *c;",
" c = hi_calloc(1, sizeof(*c));\n if (c == NULL)\n return NULL;",
" c->funcs = &redisContextDefaultFuncs;",
" c->obuf = hi_sdsempty();\n c->reader = redisReaderCreate();\n c->fd = REDIS_INVALID_FD;",
" if (c->obuf == NULL || c->reader == NULL) {\n redisFree(c);\n return NULL;\n }",
" return c;\n}",
"void redisFree(redisContext *c) {\n if (c == NULL)\n return;\n redisNetClose(c);",
" hi_sdsfree(c->obuf);\n redisReaderFree(c->reader);\n hi_free(c->tcp.host);\n hi_free(c->tcp.source_addr);\n hi_free(c->unix_sock.path);\n hi_free(c->connect_timeout);\n hi_free(c->command_timeout);\n hi_free(c->saddr);",
" if (c->privdata && c->free_privdata)\n c->free_privdata(c->privdata);",
" if (c->funcs->free_privctx)\n c->funcs->free_privctx(c->privctx);",
" memset(c, 0xff, sizeof(*c));\n hi_free(c);\n}",
"redisFD redisFreeKeepFd(redisContext *c) {\n redisFD fd = c->fd;\n c->fd = REDIS_INVALID_FD;\n redisFree(c);\n return fd;\n}",
"int redisReconnect(redisContext *c) {\n c->err = 0;\n memset(c->errstr, '\\0', strlen(c->errstr));",
" if (c->privctx && c->funcs->free_privctx) {\n c->funcs->free_privctx(c->privctx);\n c->privctx = NULL;\n }",
" redisNetClose(c);",
" hi_sdsfree(c->obuf);\n redisReaderFree(c->reader);",
" c->obuf = hi_sdsempty();\n c->reader = redisReaderCreate();",
" if (c->obuf == NULL || c->reader == NULL) {\n __redisSetError(c, REDIS_ERR_OOM, \"Out of memory\");\n return REDIS_ERR;\n }",
" int ret = REDIS_ERR;\n if (c->connection_type == REDIS_CONN_TCP) {\n ret = redisContextConnectBindTcp(c, c->tcp.host, c->tcp.port,\n c->connect_timeout, c->tcp.source_addr);\n } else if (c->connection_type == REDIS_CONN_UNIX) {\n ret = redisContextConnectUnix(c, c->unix_sock.path, c->connect_timeout);\n } else {\n /* Something bad happened here and shouldn't have. There isn't\n enough information in the context to reconnect. */\n __redisSetError(c,REDIS_ERR_OTHER,\"Not enough information to reconnect\");\n ret = REDIS_ERR;\n }",
" if (c->command_timeout != NULL && (c->flags & REDIS_BLOCK) && c->fd != REDIS_INVALID_FD) {\n redisContextSetTimeout(c, *c->command_timeout);\n }",
" return ret;\n}",
"redisContext *redisConnectWithOptions(const redisOptions *options) {\n redisContext *c = redisContextInit();\n if (c == NULL) {\n return NULL;\n }\n if (!(options->options & REDIS_OPT_NONBLOCK)) {\n c->flags |= REDIS_BLOCK;\n }\n if (options->options & REDIS_OPT_REUSEADDR) {\n c->flags |= REDIS_REUSEADDR;\n }\n if (options->options & REDIS_OPT_NOAUTOFREE) {\n c->flags |= REDIS_NO_AUTO_FREE;\n }",
" /* Set any user supplied RESP3 PUSH handler or use freeReplyObject\n * as a default unless specifically flagged that we don't want one. */\n if (options->push_cb != NULL)\n redisSetPushCallback(c, options->push_cb);\n else if (!(options->options & REDIS_OPT_NO_PUSH_AUTOFREE))\n redisSetPushCallback(c, redisPushAutoFree);",
" c->privdata = options->privdata;\n c->free_privdata = options->free_privdata;",
" if (redisContextUpdateConnectTimeout(c, options->connect_timeout) != REDIS_OK ||\n redisContextUpdateCommandTimeout(c, options->command_timeout) != REDIS_OK) {\n __redisSetError(c, REDIS_ERR_OOM, \"Out of memory\");\n return c;\n }",
" if (options->type == REDIS_CONN_TCP) {\n redisContextConnectBindTcp(c, options->endpoint.tcp.ip,\n options->endpoint.tcp.port, options->connect_timeout,\n options->endpoint.tcp.source_addr);\n } else if (options->type == REDIS_CONN_UNIX) {\n redisContextConnectUnix(c, options->endpoint.unix_socket,\n options->connect_timeout);\n } else if (options->type == REDIS_CONN_USERFD) {\n c->fd = options->endpoint.fd;\n c->flags |= REDIS_CONNECTED;\n } else {\n // Unknown type - FIXME - FREE\n return NULL;\n }",
" if (options->command_timeout != NULL && (c->flags & REDIS_BLOCK) && c->fd != REDIS_INVALID_FD) {\n redisContextSetTimeout(c, *options->command_timeout);\n }",
" return c;\n}",
"/* Connect to a Redis instance. On error the field error in the returned\n * context will be set to the return value of the error function.\n * When no set of reply functions is given, the default set will be used. */\nredisContext *redisConnect(const char *ip, int port) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, ip, port);\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectWithTimeout(const char *ip, int port, const struct timeval tv) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, ip, port);\n options.connect_timeout = &tv;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectNonBlock(const char *ip, int port) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, ip, port);\n options.options |= REDIS_OPT_NONBLOCK;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectBindNonBlock(const char *ip, int port,\n const char *source_addr) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, ip, port);\n options.endpoint.tcp.source_addr = source_addr;\n options.options |= REDIS_OPT_NONBLOCK;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectBindNonBlockWithReuse(const char *ip, int port,\n const char *source_addr) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, ip, port);\n options.endpoint.tcp.source_addr = source_addr;\n options.options |= REDIS_OPT_NONBLOCK|REDIS_OPT_REUSEADDR;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectUnix(const char *path) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_UNIX(&options, path);\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectUnixWithTimeout(const char *path, const struct timeval tv) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_UNIX(&options, path);\n options.connect_timeout = &tv;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectUnixNonBlock(const char *path) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_UNIX(&options, path);\n options.options |= REDIS_OPT_NONBLOCK;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectFd(redisFD fd) {\n redisOptions options = {0};\n options.type = REDIS_CONN_USERFD;\n options.endpoint.fd = fd;\n return redisConnectWithOptions(&options);\n}",
"/* Set read/write timeout on a blocking socket. */\nint redisSetTimeout(redisContext *c, const struct timeval tv) {\n if (c->flags & REDIS_BLOCK)\n return redisContextSetTimeout(c,tv);\n return REDIS_ERR;\n}",
"/* Enable connection KeepAlive. */\nint redisEnableKeepAlive(redisContext *c) {\n if (redisKeepAlive(c, REDIS_KEEPALIVE_INTERVAL) != REDIS_OK)\n return REDIS_ERR;\n return REDIS_OK;\n}",
"/* Set a user provided RESP3 PUSH handler and return any old one set. */\nredisPushFn *redisSetPushCallback(redisContext *c, redisPushFn *fn) {\n redisPushFn *old = c->push_cb;\n c->push_cb = fn;\n return old;\n}",
"/* Use this function to handle a read event on the descriptor. It will try\n * and read some bytes from the socket and feed them to the reply parser.\n *\n * After this function is called, you may use redisGetReplyFromReader to\n * see if there is a reply available. */\nint redisBufferRead(redisContext *c) {\n char buf[1024*16];\n int nread;",
" /* Return early when the context has seen an error. */\n if (c->err)\n return REDIS_ERR;",
" nread = c->funcs->read(c, buf, sizeof(buf));\n if (nread > 0) {\n if (redisReaderFeed(c->reader, buf, nread) != REDIS_OK) {\n __redisSetError(c, c->reader->err, c->reader->errstr);\n return REDIS_ERR;\n } else {\n }\n } else if (nread < 0) {\n return REDIS_ERR;\n }\n return REDIS_OK;\n}",
"/* Write the output buffer to the socket.\n *\n * Returns REDIS_OK when the buffer is empty, or (a part of) the buffer was\n * successfully written to the socket. When the buffer is empty after the\n * write operation, \"done\" is set to 1 (if given).\n *\n * Returns REDIS_ERR if an error occurred trying to write and sets\n * c->errstr to hold the appropriate error string.\n */\nint redisBufferWrite(redisContext *c, int *done) {",
" /* Return early when the context has seen an error. */\n if (c->err)\n return REDIS_ERR;",
" if (hi_sdslen(c->obuf) > 0) {\n ssize_t nwritten = c->funcs->write(c);\n if (nwritten < 0) {\n return REDIS_ERR;\n } else if (nwritten > 0) {\n if (nwritten == (ssize_t)hi_sdslen(c->obuf)) {\n hi_sdsfree(c->obuf);\n c->obuf = hi_sdsempty();\n if (c->obuf == NULL)\n goto oom;\n } else {\n if (hi_sdsrange(c->obuf,nwritten,-1) < 0) goto oom;\n }\n }\n }\n if (done != NULL) *done = (hi_sdslen(c->obuf) == 0);\n return REDIS_OK;",
"oom:\n __redisSetError(c, REDIS_ERR_OOM, \"Out of memory\");\n return REDIS_ERR;\n}",
"/* Internal helper function to try and get a reply from the reader,\n * or set an error in the context otherwise. */\nint redisGetReplyFromReader(redisContext *c, void **reply) {\n if (redisReaderGetReply(c->reader,reply) == REDIS_ERR) {\n __redisSetError(c,c->reader->err,c->reader->errstr);\n return REDIS_ERR;\n }",
" return REDIS_OK;\n}",
"/* Internal helper that returns 1 if the reply was a RESP3 PUSH\n * message and we handled it with a user-provided callback. */\nstatic int redisHandledPushReply(redisContext *c, void *reply) {\n if (reply && c->push_cb && redisIsPushReply(reply)) {\n c->push_cb(c->privdata, reply);\n return 1;\n }",
" return 0;\n}",
"int redisGetReply(redisContext *c, void **reply) {\n int wdone = 0;\n void *aux = NULL;",
" /* Try to read pending replies */\n if (redisGetReplyFromReader(c,&aux) == REDIS_ERR)\n return REDIS_ERR;",
" /* For the blocking context, flush output buffer and read reply */\n if (aux == NULL && c->flags & REDIS_BLOCK) {\n /* Write until done */\n do {\n if (redisBufferWrite(c,&wdone) == REDIS_ERR)\n return REDIS_ERR;\n } while (!wdone);",
" /* Read until there is a reply */\n do {\n if (redisBufferRead(c) == REDIS_ERR)\n return REDIS_ERR;",
" /* We loop here in case the user has specified a RESP3\n * PUSH handler (e.g. for client tracking). */\n do {\n if (redisGetReplyFromReader(c,&aux) == REDIS_ERR)\n return REDIS_ERR;\n } while (redisHandledPushReply(c, aux));\n } while (aux == NULL);\n }",
" /* Set reply or free it if we were passed NULL */\n if (reply != NULL) {\n *reply = aux;\n } else {\n freeReplyObject(aux);\n }",
" return REDIS_OK;\n}",
"\n/* Helper function for the redisAppendCommand* family of functions.\n *\n * Write a formatted command to the output buffer. When this family\n * is used, you need to call redisGetReply yourself to retrieve\n * the reply (or replies in pub/sub).\n */\nint __redisAppendCommand(redisContext *c, const char *cmd, size_t len) {\n hisds newbuf;",
" newbuf = hi_sdscatlen(c->obuf,cmd,len);\n if (newbuf == NULL) {\n __redisSetError(c,REDIS_ERR_OOM,\"Out of memory\");\n return REDIS_ERR;\n }",
" c->obuf = newbuf;\n return REDIS_OK;\n}",
"int redisAppendFormattedCommand(redisContext *c, const char *cmd, size_t len) {",
" if (__redisAppendCommand(c, cmd, len) != REDIS_OK) {\n return REDIS_ERR;\n }",
" return REDIS_OK;\n}",
"int redisvAppendCommand(redisContext *c, const char *format, va_list ap) {\n char *cmd;\n int len;",
" len = redisvFormatCommand(&cmd,format,ap);\n if (len == -1) {\n __redisSetError(c,REDIS_ERR_OOM,\"Out of memory\");\n return REDIS_ERR;\n } else if (len == -2) {\n __redisSetError(c,REDIS_ERR_OTHER,\"Invalid format string\");\n return REDIS_ERR;\n }",
" if (__redisAppendCommand(c,cmd,len) != REDIS_OK) {\n hi_free(cmd);\n return REDIS_ERR;\n }",
" hi_free(cmd);\n return REDIS_OK;\n}",
"int redisAppendCommand(redisContext *c, const char *format, ...) {\n va_list ap;\n int ret;",
" va_start(ap,format);\n ret = redisvAppendCommand(c,format,ap);\n va_end(ap);\n return ret;\n}",
"int redisAppendCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen) {\n hisds cmd;\n int len;",
" len = redisFormatSdsCommandArgv(&cmd,argc,argv,argvlen);\n if (len == -1) {\n __redisSetError(c,REDIS_ERR_OOM,\"Out of memory\");\n return REDIS_ERR;\n }",
" if (__redisAppendCommand(c,cmd,len) != REDIS_OK) {\n hi_sdsfree(cmd);\n return REDIS_ERR;\n }",
" hi_sdsfree(cmd);\n return REDIS_OK;\n}",
"/* Helper function for the redisCommand* family of functions.\n *\n * Write a formatted command to the output buffer. If the given context is\n * blocking, immediately read the reply into the \"reply\" pointer. When the\n * context is non-blocking, the \"reply\" pointer will not be used and the\n * command is simply appended to the write buffer.\n *\n * Returns the reply when a reply was successfully retrieved. Returns NULL\n * otherwise. When NULL is returned in a blocking context, the error field\n * in the context will be set.\n */\nstatic void *__redisBlockForReply(redisContext *c) {\n void *reply;",
" if (c->flags & REDIS_BLOCK) {\n if (redisGetReply(c,&reply) != REDIS_OK)\n return NULL;\n return reply;\n }\n return NULL;\n}",
"void *redisvCommand(redisContext *c, const char *format, va_list ap) {\n if (redisvAppendCommand(c,format,ap) != REDIS_OK)\n return NULL;\n return __redisBlockForReply(c);\n}",
"void *redisCommand(redisContext *c, const char *format, ...) {\n va_list ap;\n va_start(ap,format);\n void *reply = redisvCommand(c,format,ap);\n va_end(ap);\n return reply;\n}",
"void *redisCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen) {\n if (redisAppendCommandArgv(c,argc,argv,argvlen) != REDIS_OK)\n return NULL;\n return __redisBlockForReply(c);\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,
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": [176, 497], "buggy_code_start_loc": [176, 497], "filenames": ["deps/hiredis/hiredis.c", "deps/hiredis/test.c"], "fixing_code_end_loc": [178, 512], "fixing_code_start_loc": [177, 498], "message": "Redis is an open source, in-memory database that persists on disk. The redis-cli command line tool and redis-sentinel service may be vulnerable to integer overflow when parsing specially crafted large multi-bulk network replies. This is a result of a vulnerability in the underlying hiredis library which does not perform an overflow check before calling the calloc() heap allocation function. This issue only impacts systems with heap allocators that do not perform their own overflow checks. Most modern systems do and are therefore not likely to be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator which is also not vulnerable. The problem is fixed in Redis versions 6.2.6, 6.0.16 and 5.0.14.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "D5D64A76-B253-4A64-8AA2-DD8815CB3CF8", "versionEndExcluding": "5.0.14", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "5.0.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "02DF8086-645E-4D42-93D3-A4B11D289C7C", "versionEndExcluding": "6.0.16", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "6.0.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "4686800E-16BA-42CE-B691-011D1D5D0CC2", "versionEndExcluding": "6.2.6", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "6.2.0", "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:*", "matchCriteriaId": "07B237A9-69A3-4A9C-9DA0-4E06BD37AE73", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:*", "matchCriteriaId": "FA6FEEC2-9F11-4643-8827-749718254FED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*", "matchCriteriaId": "E460AA51-FCDA-46B9-AE97-E6676AA5E194", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*", "matchCriteriaId": "A930E247-0B43-43CB-98FF-6CE7B8189835", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*", "matchCriteriaId": "80E516C0-98A4-4ADE-B69F-66A772E2BAAA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:netapp:management_services_for_element_software:-:*:*:*:*:*:*:*", "matchCriteriaId": "86B51137-28D9-41F2-AFA2-3CC22B4954D1", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:management_services_for_netapp_hci:-:*:*:*:*:*:*:*", "matchCriteriaId": "4455CF3A-CC91-4BE4-A7AB-929AC82E34F5", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:4.3:*:*:*:*:*:*:*", "matchCriteriaId": "CBE1A019-7BB6-4226-8AC4-9D6927ADAEFA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:4.4:*:*:*:*:*:*:*", "matchCriteriaId": "B98BAEB2-A540-4E8A-A946-C4331B913AFD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:5.0:*:*:*:*:*:*:*", "matchCriteriaId": "B8FBE260-E306-4215-80C0-D2D27CA43E0F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Redis is an open source, in-memory database that persists on disk. The redis-cli command line tool and redis-sentinel service may be vulnerable to integer overflow when parsing specially crafted large multi-bulk network replies. This is a result of a vulnerability in the underlying hiredis library which does not perform an overflow check before calling the calloc() heap allocation function. This issue only impacts systems with heap allocators that do not perform their own overflow checks. Most modern systems do and are therefore not likely to be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator which is also not vulnerable. The problem is fixed in Redis versions 6.2.6, 6.0.16 and 5.0.14."}, {"lang": "es", "value": "Redis es una base de datos en memoria de c\u00f3digo abierto que persiste en el disco. La herramienta de l\u00ednea de comandos redis-cli y el servicio redis-sentinel pueden ser vulnerables a un desbordamiento de enteros cuando analizan respuestas de red de gran tama\u00f1o especialmente dise\u00f1adas. Esto es resultado de una vulnerabilidad en la biblioteca hiredis subyacente que no lleva a cabo una comprobaci\u00f3n de desbordamiento antes de llamar a la funci\u00f3n de asignaci\u00f3n de pila calloc(). Este problema s\u00f3lo afecta a los sistemas con asignadores de pila que no llevan a cabo sus propias comprobaciones de desbordamiento. La mayor\u00eda de los sistemas modernos lo hacen y, por lo tanto, no es probable que est\u00e9n afectados. Adem\u00e1s, por defecto redis-sentinel usa el asignador jemalloc que tampoco es vulnerable. El problema se ha corregido en las versiones de Redis 6.2.6, 6.0.16 y 5.0.14"}], "evaluatorComment": null, "id": "CVE-2021-32762", "lastModified": "2022-10-06T16:53:25.217", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "COMPLETE", "baseScore": 9.0, "confidentialityImpact": "COMPLETE", "integrityImpact": "COMPLETE", "vectorString": "AV:N/AC:L/Au:S/C:C/I:C/A:C", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 10.0, "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": 8.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.6, "impactScore": 5.9, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2021-10-04T18:15:09.043", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/redis/redis/commit/0215324a66af949be39b34be2d55143232c1cb71"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/redis/redis/security/advisories/GHSA-833w-8v3m-8wwr"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/HTYQ5ZF37HNGTZWVNJD3VXP7I6MEEF42/"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/VL5KXFN3ATM7IIM7Q4O4PWTSRGZ5744Z/"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WR5WKJWXD4D6S3DJCZ56V74ESLTDQRAB/"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/202209-17"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://security.netapp.com/advisory/ntap-20211104-0003/"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2021/dsa-5001"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://www.oracle.com/security-alerts/cpuapr2022.html"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-190"}, {"lang": "en", "value": "CWE-680"}], "source": "security-advisories@github.com", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-190"}], "source": "nvd@nist.gov", "type": "Secondary"}]}, "github_commit_url": "https://github.com/redis/redis/commit/0215324a66af949be39b34be2d55143232c1cb71"}, "type": "CWE-190"}
| 218
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com>\n * Copyright (c) 2010-2014, Pieter Noordhuis <pcnoordhuis at gmail dot com>\n * Copyright (c) 2015, Matt Stancliff <matt at genges dot com>,\n * Jan-Erik Rediger <janerik at fnordig dot com>\n *\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 are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n * * 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 * * Neither the name of Redis nor the names of its contributors may be used\n * to endorse or promote products derived from this software without\n * specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */",
"#include \"fmacros.h\"\n#include <string.h>\n#include <stdlib.h>\n#include <assert.h>\n#include <errno.h>\n#include <ctype.h>",
"#include \"hiredis.h\"\n#include \"net.h\"\n#include \"sds.h\"\n#include \"async.h\"\n#include \"win32.h\"",
"extern int redisContextUpdateConnectTimeout(redisContext *c, const struct timeval *timeout);\nextern int redisContextUpdateCommandTimeout(redisContext *c, const struct timeval *timeout);",
"static redisContextFuncs redisContextDefaultFuncs = {\n .free_privctx = NULL,\n .async_read = redisAsyncRead,\n .async_write = redisAsyncWrite,\n .read = redisNetRead,\n .write = redisNetWrite\n};",
"static redisReply *createReplyObject(int type);\nstatic void *createStringObject(const redisReadTask *task, char *str, size_t len);\nstatic void *createArrayObject(const redisReadTask *task, size_t elements);\nstatic void *createIntegerObject(const redisReadTask *task, long long value);\nstatic void *createDoubleObject(const redisReadTask *task, double value, char *str, size_t len);\nstatic void *createNilObject(const redisReadTask *task);\nstatic void *createBoolObject(const redisReadTask *task, int bval);",
"/* Default set of functions to build the reply. Keep in mind that such a\n * function returning NULL is interpreted as OOM. */\nstatic redisReplyObjectFunctions defaultFunctions = {\n createStringObject,\n createArrayObject,\n createIntegerObject,\n createDoubleObject,\n createNilObject,\n createBoolObject,\n freeReplyObject\n};",
"/* Create a reply object */\nstatic redisReply *createReplyObject(int type) {\n redisReply *r = hi_calloc(1,sizeof(*r));",
" if (r == NULL)\n return NULL;",
" r->type = type;\n return r;\n}",
"/* Free a reply object */\nvoid freeReplyObject(void *reply) {\n redisReply *r = reply;\n size_t j;",
" if (r == NULL)\n return;",
" switch(r->type) {\n case REDIS_REPLY_INTEGER:\n break; /* Nothing to free */\n case REDIS_REPLY_ARRAY:\n case REDIS_REPLY_MAP:\n case REDIS_REPLY_SET:\n case REDIS_REPLY_PUSH:\n if (r->element != NULL) {\n for (j = 0; j < r->elements; j++)\n freeReplyObject(r->element[j]);\n hi_free(r->element);\n }\n break;\n case REDIS_REPLY_ERROR:\n case REDIS_REPLY_STATUS:\n case REDIS_REPLY_STRING:\n case REDIS_REPLY_DOUBLE:\n case REDIS_REPLY_VERB:\n hi_free(r->str);\n break;\n }\n hi_free(r);\n}",
"static void *createStringObject(const redisReadTask *task, char *str, size_t len) {\n redisReply *r, *parent;\n char *buf;",
" r = createReplyObject(task->type);\n if (r == NULL)\n return NULL;",
" assert(task->type == REDIS_REPLY_ERROR ||\n task->type == REDIS_REPLY_STATUS ||\n task->type == REDIS_REPLY_STRING ||\n task->type == REDIS_REPLY_VERB);",
" /* Copy string value */\n if (task->type == REDIS_REPLY_VERB) {\n buf = hi_malloc(len-4+1); /* Skip 4 bytes of verbatim type header. */\n if (buf == NULL) goto oom;",
" memcpy(r->vtype,str,3);\n r->vtype[3] = '\\0';\n memcpy(buf,str+4,len-4);\n buf[len-4] = '\\0';\n r->len = len - 4;\n } else {\n buf = hi_malloc(len+1);\n if (buf == NULL) goto oom;",
" memcpy(buf,str,len);\n buf[len] = '\\0';\n r->len = len;\n }\n r->str = buf;",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET ||\n parent->type == REDIS_REPLY_PUSH);\n parent->element[task->idx] = r;\n }\n return r;",
"oom:\n freeReplyObject(r);\n return NULL;\n}",
"static void *createArrayObject(const redisReadTask *task, size_t elements) {\n redisReply *r, *parent;",
" r = createReplyObject(task->type);\n if (r == NULL)\n return NULL;",
" if (elements > 0) {",
" if (SIZE_MAX / sizeof(redisReply*) < elements) return NULL; /* Don't overflow */",
" r->element = hi_calloc(elements,sizeof(redisReply*));\n if (r->element == NULL) {\n freeReplyObject(r);\n return NULL;\n }\n }",
" r->elements = elements;",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET ||\n parent->type == REDIS_REPLY_PUSH);\n parent->element[task->idx] = r;\n }\n return r;\n}",
"static void *createIntegerObject(const redisReadTask *task, long long value) {\n redisReply *r, *parent;",
" r = createReplyObject(REDIS_REPLY_INTEGER);\n if (r == NULL)\n return NULL;",
" r->integer = value;",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET ||\n parent->type == REDIS_REPLY_PUSH);\n parent->element[task->idx] = r;\n }\n return r;\n}",
"static void *createDoubleObject(const redisReadTask *task, double value, char *str, size_t len) {\n redisReply *r, *parent;",
" r = createReplyObject(REDIS_REPLY_DOUBLE);\n if (r == NULL)\n return NULL;",
" r->dval = value;\n r->str = hi_malloc(len+1);\n if (r->str == NULL) {\n freeReplyObject(r);\n return NULL;\n }",
" /* The double reply also has the original protocol string representing a\n * double as a null terminated string. This way the caller does not need\n * to format back for string conversion, especially since Redis does efforts\n * to make the string more human readable avoiding the calssical double\n * decimal string conversion artifacts. */\n memcpy(r->str, str, len);\n r->str[len] = '\\0';",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET);\n parent->element[task->idx] = r;\n }\n return r;\n}",
"static void *createNilObject(const redisReadTask *task) {\n redisReply *r, *parent;",
" r = createReplyObject(REDIS_REPLY_NIL);\n if (r == NULL)\n return NULL;",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET ||\n parent->type == REDIS_REPLY_PUSH);\n parent->element[task->idx] = r;\n }\n return r;\n}",
"static void *createBoolObject(const redisReadTask *task, int bval) {\n redisReply *r, *parent;",
" r = createReplyObject(REDIS_REPLY_BOOL);\n if (r == NULL)\n return NULL;",
" r->integer = bval != 0;",
" if (task->parent) {\n parent = task->parent->obj;\n assert(parent->type == REDIS_REPLY_ARRAY ||\n parent->type == REDIS_REPLY_MAP ||\n parent->type == REDIS_REPLY_SET);\n parent->element[task->idx] = r;\n }\n return r;\n}",
"/* Return the number of digits of 'v' when converted to string in radix 10.\n * Implementation borrowed from link in redis/src/util.c:string2ll(). */\nstatic uint32_t countDigits(uint64_t v) {\n uint32_t result = 1;\n for (;;) {\n if (v < 10) return result;\n if (v < 100) return result + 1;\n if (v < 1000) return result + 2;\n if (v < 10000) return result + 3;\n v /= 10000U;\n result += 4;\n }\n}",
"/* Helper that calculates the bulk length given a certain string length. */\nstatic size_t bulklen(size_t len) {\n return 1+countDigits(len)+2+len+2;\n}",
"int redisvFormatCommand(char **target, const char *format, va_list ap) {\n const char *c = format;\n char *cmd = NULL; /* final command */\n int pos; /* position in final command */\n hisds curarg, newarg; /* current argument */\n int touched = 0; /* was the current argument touched? */\n char **curargv = NULL, **newargv = NULL;\n int argc = 0;\n int totlen = 0;\n int error_type = 0; /* 0 = no error; -1 = memory error; -2 = format error */\n int j;",
" /* Abort if there is not target to set */\n if (target == NULL)\n return -1;",
" /* Build the command string accordingly to protocol */\n curarg = hi_sdsempty();\n if (curarg == NULL)\n return -1;",
" while(*c != '\\0') {\n if (*c != '%' || c[1] == '\\0') {\n if (*c == ' ') {\n if (touched) {\n newargv = hi_realloc(curargv,sizeof(char*)*(argc+1));\n if (newargv == NULL) goto memory_err;\n curargv = newargv;\n curargv[argc++] = curarg;\n totlen += bulklen(hi_sdslen(curarg));",
" /* curarg is put in argv so it can be overwritten. */\n curarg = hi_sdsempty();\n if (curarg == NULL) goto memory_err;\n touched = 0;\n }\n } else {\n newarg = hi_sdscatlen(curarg,c,1);\n if (newarg == NULL) goto memory_err;\n curarg = newarg;\n touched = 1;\n }\n } else {\n char *arg;\n size_t size;",
" /* Set newarg so it can be checked even if it is not touched. */\n newarg = curarg;",
" switch(c[1]) {\n case 's':\n arg = va_arg(ap,char*);\n size = strlen(arg);\n if (size > 0)\n newarg = hi_sdscatlen(curarg,arg,size);\n break;\n case 'b':\n arg = va_arg(ap,char*);\n size = va_arg(ap,size_t);\n if (size > 0)\n newarg = hi_sdscatlen(curarg,arg,size);\n break;\n case '%':\n newarg = hi_sdscat(curarg,\"%\");\n break;\n default:\n /* Try to detect printf format */\n {\n static const char intfmts[] = \"diouxX\";\n static const char flags[] = \"#0-+ \";\n char _format[16];\n const char *_p = c+1;\n size_t _l = 0;\n va_list _cpy;",
" /* Flags */\n while (*_p != '\\0' && strchr(flags,*_p) != NULL) _p++;",
" /* Field width */\n while (*_p != '\\0' && isdigit(*_p)) _p++;",
" /* Precision */\n if (*_p == '.') {\n _p++;\n while (*_p != '\\0' && isdigit(*_p)) _p++;\n }",
" /* Copy va_list before consuming with va_arg */\n va_copy(_cpy,ap);",
" /* Integer conversion (without modifiers) */\n if (strchr(intfmts,*_p) != NULL) {\n va_arg(ap,int);\n goto fmt_valid;\n }",
" /* Double conversion (without modifiers) */\n if (strchr(\"eEfFgGaA\",*_p) != NULL) {\n va_arg(ap,double);\n goto fmt_valid;\n }",
" /* Size: char */\n if (_p[0] == 'h' && _p[1] == 'h') {\n _p += 2;\n if (*_p != '\\0' && strchr(intfmts,*_p) != NULL) {\n va_arg(ap,int); /* char gets promoted to int */\n goto fmt_valid;\n }\n goto fmt_invalid;\n }",
" /* Size: short */\n if (_p[0] == 'h') {\n _p += 1;\n if (*_p != '\\0' && strchr(intfmts,*_p) != NULL) {\n va_arg(ap,int); /* short gets promoted to int */\n goto fmt_valid;\n }\n goto fmt_invalid;\n }",
" /* Size: long long */\n if (_p[0] == 'l' && _p[1] == 'l') {\n _p += 2;\n if (*_p != '\\0' && strchr(intfmts,*_p) != NULL) {\n va_arg(ap,long long);\n goto fmt_valid;\n }\n goto fmt_invalid;\n }",
" /* Size: long */\n if (_p[0] == 'l') {\n _p += 1;\n if (*_p != '\\0' && strchr(intfmts,*_p) != NULL) {\n va_arg(ap,long);\n goto fmt_valid;\n }\n goto fmt_invalid;\n }",
" fmt_invalid:\n va_end(_cpy);\n goto format_err;",
" fmt_valid:\n _l = (_p+1)-c;\n if (_l < sizeof(_format)-2) {\n memcpy(_format,c,_l);\n _format[_l] = '\\0';\n newarg = hi_sdscatvprintf(curarg,_format,_cpy);",
" /* Update current position (note: outer blocks\n * increment c twice so compensate here) */\n c = _p-1;\n }",
" va_end(_cpy);\n break;\n }\n }",
" if (newarg == NULL) goto memory_err;\n curarg = newarg;",
" touched = 1;\n c++;\n }\n c++;\n }",
" /* Add the last argument if needed */\n if (touched) {\n newargv = hi_realloc(curargv,sizeof(char*)*(argc+1));\n if (newargv == NULL) goto memory_err;\n curargv = newargv;\n curargv[argc++] = curarg;\n totlen += bulklen(hi_sdslen(curarg));\n } else {\n hi_sdsfree(curarg);\n }",
" /* Clear curarg because it was put in curargv or was free'd. */\n curarg = NULL;",
" /* Add bytes needed to hold multi bulk count */\n totlen += 1+countDigits(argc)+2;",
" /* Build the command at protocol level */\n cmd = hi_malloc(totlen+1);\n if (cmd == NULL) goto memory_err;",
" pos = sprintf(cmd,\"*%d\\r\\n\",argc);\n for (j = 0; j < argc; j++) {\n pos += sprintf(cmd+pos,\"$%zu\\r\\n\",hi_sdslen(curargv[j]));\n memcpy(cmd+pos,curargv[j],hi_sdslen(curargv[j]));\n pos += hi_sdslen(curargv[j]);\n hi_sdsfree(curargv[j]);\n cmd[pos++] = '\\r';\n cmd[pos++] = '\\n';\n }\n assert(pos == totlen);\n cmd[pos] = '\\0';",
" hi_free(curargv);\n *target = cmd;\n return totlen;",
"format_err:\n error_type = -2;\n goto cleanup;",
"memory_err:\n error_type = -1;\n goto cleanup;",
"cleanup:\n if (curargv) {\n while(argc--)\n hi_sdsfree(curargv[argc]);\n hi_free(curargv);\n }",
" hi_sdsfree(curarg);\n hi_free(cmd);",
" return error_type;\n}",
"/* Format a command according to the Redis protocol. This function\n * takes a format similar to printf:\n *\n * %s represents a C null terminated string you want to interpolate\n * %b represents a binary safe string\n *\n * When using %b you need to provide both the pointer to the string\n * and the length in bytes as a size_t. Examples:\n *\n * len = redisFormatCommand(target, \"GET %s\", mykey);\n * len = redisFormatCommand(target, \"SET %s %b\", mykey, myval, myvallen);\n */\nint redisFormatCommand(char **target, const char *format, ...) {\n va_list ap;\n int len;\n va_start(ap,format);\n len = redisvFormatCommand(target,format,ap);\n va_end(ap);",
" /* The API says \"-1\" means bad result, but we now also return \"-2\" in some\n * cases. Force the return value to always be -1. */\n if (len < 0)\n len = -1;",
" return len;\n}",
"/* Format a command according to the Redis protocol using an hisds string and\n * hi_sdscatfmt for the processing of arguments. This function takes the\n * number of arguments, an array with arguments and an array with their\n * lengths. If the latter is set to NULL, strlen will be used to compute the\n * argument lengths.\n */\nint redisFormatSdsCommandArgv(hisds *target, int argc, const char **argv,\n const size_t *argvlen)\n{\n hisds cmd, aux;\n unsigned long long totlen;\n int j;\n size_t len;",
" /* Abort on a NULL target */\n if (target == NULL)\n return -1;",
" /* Calculate our total size */\n totlen = 1+countDigits(argc)+2;\n for (j = 0; j < argc; j++) {\n len = argvlen ? argvlen[j] : strlen(argv[j]);\n totlen += bulklen(len);\n }",
" /* Use an SDS string for command construction */\n cmd = hi_sdsempty();\n if (cmd == NULL)\n return -1;",
" /* We already know how much storage we need */\n aux = hi_sdsMakeRoomFor(cmd, totlen);\n if (aux == NULL) {\n hi_sdsfree(cmd);\n return -1;\n }",
" cmd = aux;",
" /* Construct command */\n cmd = hi_sdscatfmt(cmd, \"*%i\\r\\n\", argc);\n for (j=0; j < argc; j++) {\n len = argvlen ? argvlen[j] : strlen(argv[j]);\n cmd = hi_sdscatfmt(cmd, \"$%u\\r\\n\", len);\n cmd = hi_sdscatlen(cmd, argv[j], len);\n cmd = hi_sdscatlen(cmd, \"\\r\\n\", sizeof(\"\\r\\n\")-1);\n }",
" assert(hi_sdslen(cmd)==totlen);",
" *target = cmd;\n return totlen;\n}",
"void redisFreeSdsCommand(hisds cmd) {\n hi_sdsfree(cmd);\n}",
"/* Format a command according to the Redis protocol. This function takes the\n * number of arguments, an array with arguments and an array with their\n * lengths. If the latter is set to NULL, strlen will be used to compute the\n * argument lengths.\n */\nint redisFormatCommandArgv(char **target, int argc, const char **argv, const size_t *argvlen) {\n char *cmd = NULL; /* final command */\n int pos; /* position in final command */\n size_t len;\n int totlen, j;",
" /* Abort on a NULL target */\n if (target == NULL)\n return -1;",
" /* Calculate number of bytes needed for the command */\n totlen = 1+countDigits(argc)+2;\n for (j = 0; j < argc; j++) {\n len = argvlen ? argvlen[j] : strlen(argv[j]);\n totlen += bulklen(len);\n }",
" /* Build the command at protocol level */\n cmd = hi_malloc(totlen+1);\n if (cmd == NULL)\n return -1;",
" pos = sprintf(cmd,\"*%d\\r\\n\",argc);\n for (j = 0; j < argc; j++) {\n len = argvlen ? argvlen[j] : strlen(argv[j]);\n pos += sprintf(cmd+pos,\"$%zu\\r\\n\",len);\n memcpy(cmd+pos,argv[j],len);\n pos += len;\n cmd[pos++] = '\\r';\n cmd[pos++] = '\\n';\n }\n assert(pos == totlen);\n cmd[pos] = '\\0';",
" *target = cmd;\n return totlen;\n}",
"void redisFreeCommand(char *cmd) {\n hi_free(cmd);\n}",
"void __redisSetError(redisContext *c, int type, const char *str) {\n size_t len;",
" c->err = type;\n if (str != NULL) {\n len = strlen(str);\n len = len < (sizeof(c->errstr)-1) ? len : (sizeof(c->errstr)-1);\n memcpy(c->errstr,str,len);\n c->errstr[len] = '\\0';\n } else {\n /* Only REDIS_ERR_IO may lack a description! */\n assert(type == REDIS_ERR_IO);\n strerror_r(errno, c->errstr, sizeof(c->errstr));\n }\n}",
"redisReader *redisReaderCreate(void) {\n return redisReaderCreateWithFunctions(&defaultFunctions);\n}",
"static void redisPushAutoFree(void *privdata, void *reply) {\n (void)privdata;\n freeReplyObject(reply);\n}",
"static redisContext *redisContextInit(void) {\n redisContext *c;",
" c = hi_calloc(1, sizeof(*c));\n if (c == NULL)\n return NULL;",
" c->funcs = &redisContextDefaultFuncs;",
" c->obuf = hi_sdsempty();\n c->reader = redisReaderCreate();\n c->fd = REDIS_INVALID_FD;",
" if (c->obuf == NULL || c->reader == NULL) {\n redisFree(c);\n return NULL;\n }",
" return c;\n}",
"void redisFree(redisContext *c) {\n if (c == NULL)\n return;\n redisNetClose(c);",
" hi_sdsfree(c->obuf);\n redisReaderFree(c->reader);\n hi_free(c->tcp.host);\n hi_free(c->tcp.source_addr);\n hi_free(c->unix_sock.path);\n hi_free(c->connect_timeout);\n hi_free(c->command_timeout);\n hi_free(c->saddr);",
" if (c->privdata && c->free_privdata)\n c->free_privdata(c->privdata);",
" if (c->funcs->free_privctx)\n c->funcs->free_privctx(c->privctx);",
" memset(c, 0xff, sizeof(*c));\n hi_free(c);\n}",
"redisFD redisFreeKeepFd(redisContext *c) {\n redisFD fd = c->fd;\n c->fd = REDIS_INVALID_FD;\n redisFree(c);\n return fd;\n}",
"int redisReconnect(redisContext *c) {\n c->err = 0;\n memset(c->errstr, '\\0', strlen(c->errstr));",
" if (c->privctx && c->funcs->free_privctx) {\n c->funcs->free_privctx(c->privctx);\n c->privctx = NULL;\n }",
" redisNetClose(c);",
" hi_sdsfree(c->obuf);\n redisReaderFree(c->reader);",
" c->obuf = hi_sdsempty();\n c->reader = redisReaderCreate();",
" if (c->obuf == NULL || c->reader == NULL) {\n __redisSetError(c, REDIS_ERR_OOM, \"Out of memory\");\n return REDIS_ERR;\n }",
" int ret = REDIS_ERR;\n if (c->connection_type == REDIS_CONN_TCP) {\n ret = redisContextConnectBindTcp(c, c->tcp.host, c->tcp.port,\n c->connect_timeout, c->tcp.source_addr);\n } else if (c->connection_type == REDIS_CONN_UNIX) {\n ret = redisContextConnectUnix(c, c->unix_sock.path, c->connect_timeout);\n } else {\n /* Something bad happened here and shouldn't have. There isn't\n enough information in the context to reconnect. */\n __redisSetError(c,REDIS_ERR_OTHER,\"Not enough information to reconnect\");\n ret = REDIS_ERR;\n }",
" if (c->command_timeout != NULL && (c->flags & REDIS_BLOCK) && c->fd != REDIS_INVALID_FD) {\n redisContextSetTimeout(c, *c->command_timeout);\n }",
" return ret;\n}",
"redisContext *redisConnectWithOptions(const redisOptions *options) {\n redisContext *c = redisContextInit();\n if (c == NULL) {\n return NULL;\n }\n if (!(options->options & REDIS_OPT_NONBLOCK)) {\n c->flags |= REDIS_BLOCK;\n }\n if (options->options & REDIS_OPT_REUSEADDR) {\n c->flags |= REDIS_REUSEADDR;\n }\n if (options->options & REDIS_OPT_NOAUTOFREE) {\n c->flags |= REDIS_NO_AUTO_FREE;\n }",
" /* Set any user supplied RESP3 PUSH handler or use freeReplyObject\n * as a default unless specifically flagged that we don't want one. */\n if (options->push_cb != NULL)\n redisSetPushCallback(c, options->push_cb);\n else if (!(options->options & REDIS_OPT_NO_PUSH_AUTOFREE))\n redisSetPushCallback(c, redisPushAutoFree);",
" c->privdata = options->privdata;\n c->free_privdata = options->free_privdata;",
" if (redisContextUpdateConnectTimeout(c, options->connect_timeout) != REDIS_OK ||\n redisContextUpdateCommandTimeout(c, options->command_timeout) != REDIS_OK) {\n __redisSetError(c, REDIS_ERR_OOM, \"Out of memory\");\n return c;\n }",
" if (options->type == REDIS_CONN_TCP) {\n redisContextConnectBindTcp(c, options->endpoint.tcp.ip,\n options->endpoint.tcp.port, options->connect_timeout,\n options->endpoint.tcp.source_addr);\n } else if (options->type == REDIS_CONN_UNIX) {\n redisContextConnectUnix(c, options->endpoint.unix_socket,\n options->connect_timeout);\n } else if (options->type == REDIS_CONN_USERFD) {\n c->fd = options->endpoint.fd;\n c->flags |= REDIS_CONNECTED;\n } else {\n // Unknown type - FIXME - FREE\n return NULL;\n }",
" if (options->command_timeout != NULL && (c->flags & REDIS_BLOCK) && c->fd != REDIS_INVALID_FD) {\n redisContextSetTimeout(c, *options->command_timeout);\n }",
" return c;\n}",
"/* Connect to a Redis instance. On error the field error in the returned\n * context will be set to the return value of the error function.\n * When no set of reply functions is given, the default set will be used. */\nredisContext *redisConnect(const char *ip, int port) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, ip, port);\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectWithTimeout(const char *ip, int port, const struct timeval tv) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, ip, port);\n options.connect_timeout = &tv;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectNonBlock(const char *ip, int port) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, ip, port);\n options.options |= REDIS_OPT_NONBLOCK;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectBindNonBlock(const char *ip, int port,\n const char *source_addr) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, ip, port);\n options.endpoint.tcp.source_addr = source_addr;\n options.options |= REDIS_OPT_NONBLOCK;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectBindNonBlockWithReuse(const char *ip, int port,\n const char *source_addr) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, ip, port);\n options.endpoint.tcp.source_addr = source_addr;\n options.options |= REDIS_OPT_NONBLOCK|REDIS_OPT_REUSEADDR;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectUnix(const char *path) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_UNIX(&options, path);\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectUnixWithTimeout(const char *path, const struct timeval tv) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_UNIX(&options, path);\n options.connect_timeout = &tv;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectUnixNonBlock(const char *path) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_UNIX(&options, path);\n options.options |= REDIS_OPT_NONBLOCK;\n return redisConnectWithOptions(&options);\n}",
"redisContext *redisConnectFd(redisFD fd) {\n redisOptions options = {0};\n options.type = REDIS_CONN_USERFD;\n options.endpoint.fd = fd;\n return redisConnectWithOptions(&options);\n}",
"/* Set read/write timeout on a blocking socket. */\nint redisSetTimeout(redisContext *c, const struct timeval tv) {\n if (c->flags & REDIS_BLOCK)\n return redisContextSetTimeout(c,tv);\n return REDIS_ERR;\n}",
"/* Enable connection KeepAlive. */\nint redisEnableKeepAlive(redisContext *c) {\n if (redisKeepAlive(c, REDIS_KEEPALIVE_INTERVAL) != REDIS_OK)\n return REDIS_ERR;\n return REDIS_OK;\n}",
"/* Set a user provided RESP3 PUSH handler and return any old one set. */\nredisPushFn *redisSetPushCallback(redisContext *c, redisPushFn *fn) {\n redisPushFn *old = c->push_cb;\n c->push_cb = fn;\n return old;\n}",
"/* Use this function to handle a read event on the descriptor. It will try\n * and read some bytes from the socket and feed them to the reply parser.\n *\n * After this function is called, you may use redisGetReplyFromReader to\n * see if there is a reply available. */\nint redisBufferRead(redisContext *c) {\n char buf[1024*16];\n int nread;",
" /* Return early when the context has seen an error. */\n if (c->err)\n return REDIS_ERR;",
" nread = c->funcs->read(c, buf, sizeof(buf));\n if (nread > 0) {\n if (redisReaderFeed(c->reader, buf, nread) != REDIS_OK) {\n __redisSetError(c, c->reader->err, c->reader->errstr);\n return REDIS_ERR;\n } else {\n }\n } else if (nread < 0) {\n return REDIS_ERR;\n }\n return REDIS_OK;\n}",
"/* Write the output buffer to the socket.\n *\n * Returns REDIS_OK when the buffer is empty, or (a part of) the buffer was\n * successfully written to the socket. When the buffer is empty after the\n * write operation, \"done\" is set to 1 (if given).\n *\n * Returns REDIS_ERR if an error occurred trying to write and sets\n * c->errstr to hold the appropriate error string.\n */\nint redisBufferWrite(redisContext *c, int *done) {",
" /* Return early when the context has seen an error. */\n if (c->err)\n return REDIS_ERR;",
" if (hi_sdslen(c->obuf) > 0) {\n ssize_t nwritten = c->funcs->write(c);\n if (nwritten < 0) {\n return REDIS_ERR;\n } else if (nwritten > 0) {\n if (nwritten == (ssize_t)hi_sdslen(c->obuf)) {\n hi_sdsfree(c->obuf);\n c->obuf = hi_sdsempty();\n if (c->obuf == NULL)\n goto oom;\n } else {\n if (hi_sdsrange(c->obuf,nwritten,-1) < 0) goto oom;\n }\n }\n }\n if (done != NULL) *done = (hi_sdslen(c->obuf) == 0);\n return REDIS_OK;",
"oom:\n __redisSetError(c, REDIS_ERR_OOM, \"Out of memory\");\n return REDIS_ERR;\n}",
"/* Internal helper function to try and get a reply from the reader,\n * or set an error in the context otherwise. */\nint redisGetReplyFromReader(redisContext *c, void **reply) {\n if (redisReaderGetReply(c->reader,reply) == REDIS_ERR) {\n __redisSetError(c,c->reader->err,c->reader->errstr);\n return REDIS_ERR;\n }",
" return REDIS_OK;\n}",
"/* Internal helper that returns 1 if the reply was a RESP3 PUSH\n * message and we handled it with a user-provided callback. */\nstatic int redisHandledPushReply(redisContext *c, void *reply) {\n if (reply && c->push_cb && redisIsPushReply(reply)) {\n c->push_cb(c->privdata, reply);\n return 1;\n }",
" return 0;\n}",
"int redisGetReply(redisContext *c, void **reply) {\n int wdone = 0;\n void *aux = NULL;",
" /* Try to read pending replies */\n if (redisGetReplyFromReader(c,&aux) == REDIS_ERR)\n return REDIS_ERR;",
" /* For the blocking context, flush output buffer and read reply */\n if (aux == NULL && c->flags & REDIS_BLOCK) {\n /* Write until done */\n do {\n if (redisBufferWrite(c,&wdone) == REDIS_ERR)\n return REDIS_ERR;\n } while (!wdone);",
" /* Read until there is a reply */\n do {\n if (redisBufferRead(c) == REDIS_ERR)\n return REDIS_ERR;",
" /* We loop here in case the user has specified a RESP3\n * PUSH handler (e.g. for client tracking). */\n do {\n if (redisGetReplyFromReader(c,&aux) == REDIS_ERR)\n return REDIS_ERR;\n } while (redisHandledPushReply(c, aux));\n } while (aux == NULL);\n }",
" /* Set reply or free it if we were passed NULL */\n if (reply != NULL) {\n *reply = aux;\n } else {\n freeReplyObject(aux);\n }",
" return REDIS_OK;\n}",
"\n/* Helper function for the redisAppendCommand* family of functions.\n *\n * Write a formatted command to the output buffer. When this family\n * is used, you need to call redisGetReply yourself to retrieve\n * the reply (or replies in pub/sub).\n */\nint __redisAppendCommand(redisContext *c, const char *cmd, size_t len) {\n hisds newbuf;",
" newbuf = hi_sdscatlen(c->obuf,cmd,len);\n if (newbuf == NULL) {\n __redisSetError(c,REDIS_ERR_OOM,\"Out of memory\");\n return REDIS_ERR;\n }",
" c->obuf = newbuf;\n return REDIS_OK;\n}",
"int redisAppendFormattedCommand(redisContext *c, const char *cmd, size_t len) {",
" if (__redisAppendCommand(c, cmd, len) != REDIS_OK) {\n return REDIS_ERR;\n }",
" return REDIS_OK;\n}",
"int redisvAppendCommand(redisContext *c, const char *format, va_list ap) {\n char *cmd;\n int len;",
" len = redisvFormatCommand(&cmd,format,ap);\n if (len == -1) {\n __redisSetError(c,REDIS_ERR_OOM,\"Out of memory\");\n return REDIS_ERR;\n } else if (len == -2) {\n __redisSetError(c,REDIS_ERR_OTHER,\"Invalid format string\");\n return REDIS_ERR;\n }",
" if (__redisAppendCommand(c,cmd,len) != REDIS_OK) {\n hi_free(cmd);\n return REDIS_ERR;\n }",
" hi_free(cmd);\n return REDIS_OK;\n}",
"int redisAppendCommand(redisContext *c, const char *format, ...) {\n va_list ap;\n int ret;",
" va_start(ap,format);\n ret = redisvAppendCommand(c,format,ap);\n va_end(ap);\n return ret;\n}",
"int redisAppendCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen) {\n hisds cmd;\n int len;",
" len = redisFormatSdsCommandArgv(&cmd,argc,argv,argvlen);\n if (len == -1) {\n __redisSetError(c,REDIS_ERR_OOM,\"Out of memory\");\n return REDIS_ERR;\n }",
" if (__redisAppendCommand(c,cmd,len) != REDIS_OK) {\n hi_sdsfree(cmd);\n return REDIS_ERR;\n }",
" hi_sdsfree(cmd);\n return REDIS_OK;\n}",
"/* Helper function for the redisCommand* family of functions.\n *\n * Write a formatted command to the output buffer. If the given context is\n * blocking, immediately read the reply into the \"reply\" pointer. When the\n * context is non-blocking, the \"reply\" pointer will not be used and the\n * command is simply appended to the write buffer.\n *\n * Returns the reply when a reply was successfully retrieved. Returns NULL\n * otherwise. When NULL is returned in a blocking context, the error field\n * in the context will be set.\n */\nstatic void *__redisBlockForReply(redisContext *c) {\n void *reply;",
" if (c->flags & REDIS_BLOCK) {\n if (redisGetReply(c,&reply) != REDIS_OK)\n return NULL;\n return reply;\n }\n return NULL;\n}",
"void *redisvCommand(redisContext *c, const char *format, va_list ap) {\n if (redisvAppendCommand(c,format,ap) != REDIS_OK)\n return NULL;\n return __redisBlockForReply(c);\n}",
"void *redisCommand(redisContext *c, const char *format, ...) {\n va_list ap;\n va_start(ap,format);\n void *reply = redisvCommand(c,format,ap);\n va_end(ap);\n return reply;\n}",
"void *redisCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen) {\n if (redisAppendCommandArgv(c,argc,argv,argvlen) != REDIS_OK)\n return NULL;\n return __redisBlockForReply(c);\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [176, 497], "buggy_code_start_loc": [176, 497], "filenames": ["deps/hiredis/hiredis.c", "deps/hiredis/test.c"], "fixing_code_end_loc": [178, 512], "fixing_code_start_loc": [177, 498], "message": "Redis is an open source, in-memory database that persists on disk. The redis-cli command line tool and redis-sentinel service may be vulnerable to integer overflow when parsing specially crafted large multi-bulk network replies. This is a result of a vulnerability in the underlying hiredis library which does not perform an overflow check before calling the calloc() heap allocation function. This issue only impacts systems with heap allocators that do not perform their own overflow checks. Most modern systems do and are therefore not likely to be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator which is also not vulnerable. The problem is fixed in Redis versions 6.2.6, 6.0.16 and 5.0.14.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "D5D64A76-B253-4A64-8AA2-DD8815CB3CF8", "versionEndExcluding": "5.0.14", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "5.0.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "02DF8086-645E-4D42-93D3-A4B11D289C7C", "versionEndExcluding": "6.0.16", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "6.0.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "4686800E-16BA-42CE-B691-011D1D5D0CC2", "versionEndExcluding": "6.2.6", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "6.2.0", "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:*", "matchCriteriaId": "07B237A9-69A3-4A9C-9DA0-4E06BD37AE73", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:*", "matchCriteriaId": "FA6FEEC2-9F11-4643-8827-749718254FED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*", "matchCriteriaId": "E460AA51-FCDA-46B9-AE97-E6676AA5E194", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*", "matchCriteriaId": "A930E247-0B43-43CB-98FF-6CE7B8189835", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*", "matchCriteriaId": "80E516C0-98A4-4ADE-B69F-66A772E2BAAA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:netapp:management_services_for_element_software:-:*:*:*:*:*:*:*", "matchCriteriaId": "86B51137-28D9-41F2-AFA2-3CC22B4954D1", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:management_services_for_netapp_hci:-:*:*:*:*:*:*:*", "matchCriteriaId": "4455CF3A-CC91-4BE4-A7AB-929AC82E34F5", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:4.3:*:*:*:*:*:*:*", "matchCriteriaId": "CBE1A019-7BB6-4226-8AC4-9D6927ADAEFA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:4.4:*:*:*:*:*:*:*", "matchCriteriaId": "B98BAEB2-A540-4E8A-A946-C4331B913AFD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:5.0:*:*:*:*:*:*:*", "matchCriteriaId": "B8FBE260-E306-4215-80C0-D2D27CA43E0F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Redis is an open source, in-memory database that persists on disk. The redis-cli command line tool and redis-sentinel service may be vulnerable to integer overflow when parsing specially crafted large multi-bulk network replies. This is a result of a vulnerability in the underlying hiredis library which does not perform an overflow check before calling the calloc() heap allocation function. This issue only impacts systems with heap allocators that do not perform their own overflow checks. Most modern systems do and are therefore not likely to be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator which is also not vulnerable. The problem is fixed in Redis versions 6.2.6, 6.0.16 and 5.0.14."}, {"lang": "es", "value": "Redis es una base de datos en memoria de c\u00f3digo abierto que persiste en el disco. La herramienta de l\u00ednea de comandos redis-cli y el servicio redis-sentinel pueden ser vulnerables a un desbordamiento de enteros cuando analizan respuestas de red de gran tama\u00f1o especialmente dise\u00f1adas. Esto es resultado de una vulnerabilidad en la biblioteca hiredis subyacente que no lleva a cabo una comprobaci\u00f3n de desbordamiento antes de llamar a la funci\u00f3n de asignaci\u00f3n de pila calloc(). Este problema s\u00f3lo afecta a los sistemas con asignadores de pila que no llevan a cabo sus propias comprobaciones de desbordamiento. La mayor\u00eda de los sistemas modernos lo hacen y, por lo tanto, no es probable que est\u00e9n afectados. Adem\u00e1s, por defecto redis-sentinel usa el asignador jemalloc que tampoco es vulnerable. El problema se ha corregido en las versiones de Redis 6.2.6, 6.0.16 y 5.0.14"}], "evaluatorComment": null, "id": "CVE-2021-32762", "lastModified": "2022-10-06T16:53:25.217", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "COMPLETE", "baseScore": 9.0, "confidentialityImpact": "COMPLETE", "integrityImpact": "COMPLETE", "vectorString": "AV:N/AC:L/Au:S/C:C/I:C/A:C", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 10.0, "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": 8.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.6, "impactScore": 5.9, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2021-10-04T18:15:09.043", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/redis/redis/commit/0215324a66af949be39b34be2d55143232c1cb71"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/redis/redis/security/advisories/GHSA-833w-8v3m-8wwr"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/HTYQ5ZF37HNGTZWVNJD3VXP7I6MEEF42/"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/VL5KXFN3ATM7IIM7Q4O4PWTSRGZ5744Z/"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WR5WKJWXD4D6S3DJCZ56V74ESLTDQRAB/"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/202209-17"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://security.netapp.com/advisory/ntap-20211104-0003/"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2021/dsa-5001"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://www.oracle.com/security-alerts/cpuapr2022.html"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-190"}, {"lang": "en", "value": "CWE-680"}], "source": "security-advisories@github.com", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-190"}], "source": "nvd@nist.gov", "type": "Secondary"}]}, "github_commit_url": "https://github.com/redis/redis/commit/0215324a66af949be39b34be2d55143232c1cb71"}, "type": "CWE-190"}
| 218
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"#include \"fmacros.h\"\n#include \"sockcompat.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#ifndef _WIN32\n#include <strings.h>\n#include <sys/time.h>\n#endif\n#include <assert.h>\n#include <signal.h>\n#include <errno.h>\n#include <limits.h>",
"#include \"hiredis.h\"\n#include \"async.h\"\n#ifdef HIREDIS_TEST_SSL\n#include \"hiredis_ssl.h\"\n#endif\n#include \"net.h\"\n#include \"win32.h\"",
"enum connection_type {\n CONN_TCP,\n CONN_UNIX,\n CONN_FD,\n CONN_SSL\n};",
"struct config {\n enum connection_type type;",
" struct {\n const char *host;\n int port;\n struct timeval timeout;\n } tcp;",
" struct {\n const char *path;\n } unix_sock;",
" struct {\n const char *host;\n int port;\n const char *ca_cert;\n const char *cert;\n const char *key;\n } ssl;\n};",
"struct privdata {\n int dtor_counter;\n};",
"struct pushCounters {\n int nil;\n int str;\n};",
"#ifdef HIREDIS_TEST_SSL\nredisSSLContext *_ssl_ctx = NULL;\n#endif",
"/* The following lines make up our testing \"framework\" :) */\nstatic int tests = 0, fails = 0, skips = 0;\n#define test(_s) { printf(\"#%02d \", ++tests); printf(_s); }\n#define test_cond(_c) if(_c) printf(\"\\033[0;32mPASSED\\033[0;0m\\n\"); else {printf(\"\\033[0;31mFAILED\\033[0;0m\\n\"); fails++;}\n#define test_skipped() { printf(\"\\033[01;33mSKIPPED\\033[0;0m\\n\"); skips++; }",
"static long long usec(void) {\n#ifndef _MSC_VER\n struct timeval tv;\n gettimeofday(&tv,NULL);\n return (((long long)tv.tv_sec)*1000000)+tv.tv_usec;\n#else\n FILETIME ft;\n GetSystemTimeAsFileTime(&ft);\n return (((long long)ft.dwHighDateTime << 32) | ft.dwLowDateTime) / 10;\n#endif\n}",
"/* The assert() calls below have side effects, so we need assert()\n * even if we are compiling without asserts (-DNDEBUG). */\n#ifdef NDEBUG\n#undef assert\n#define assert(e) (void)(e)\n#endif",
"/* Helper to extract Redis version information. Aborts on any failure. */\n#define REDIS_VERSION_FIELD \"redis_version:\"\nvoid get_redis_version(redisContext *c, int *majorptr, int *minorptr) {\n redisReply *reply;\n char *eptr, *s, *e;\n int major, minor;",
" reply = redisCommand(c, \"INFO\");\n if (reply == NULL || c->err || reply->type != REDIS_REPLY_STRING)\n goto abort;\n if ((s = strstr(reply->str, REDIS_VERSION_FIELD)) == NULL)\n goto abort;",
" s += strlen(REDIS_VERSION_FIELD);",
" /* We need a field terminator and at least 'x.y.z' (5) bytes of data */\n if ((e = strstr(s, \"\\r\\n\")) == NULL || (e - s) < 5)\n goto abort;",
" /* Extract version info */\n major = strtol(s, &eptr, 10);\n if (*eptr != '.') goto abort;\n minor = strtol(eptr+1, NULL, 10);",
" /* Push info the caller wants */\n if (majorptr) *majorptr = major;\n if (minorptr) *minorptr = minor;",
" freeReplyObject(reply);\n return;",
"abort:\n freeReplyObject(reply);\n fprintf(stderr, \"Error: Cannot determine Redis version, aborting\\n\");\n exit(1);\n}",
"static redisContext *select_database(redisContext *c) {\n redisReply *reply;",
" /* Switch to DB 9 for testing, now that we know we can chat. */\n reply = redisCommand(c,\"SELECT 9\");\n assert(reply != NULL);\n freeReplyObject(reply);",
" /* Make sure the DB is emtpy */\n reply = redisCommand(c,\"DBSIZE\");\n assert(reply != NULL);\n if (reply->type == REDIS_REPLY_INTEGER && reply->integer == 0) {\n /* Awesome, DB 9 is empty and we can continue. */\n freeReplyObject(reply);\n } else {\n printf(\"Database #9 is not empty, test can not continue\\n\");\n exit(1);\n }",
" return c;\n}",
"/* Switch protocol */\nstatic void send_hello(redisContext *c, int version) {\n redisReply *reply;\n int expected;",
" reply = redisCommand(c, \"HELLO %d\", version);\n expected = version == 3 ? REDIS_REPLY_MAP : REDIS_REPLY_ARRAY;\n assert(reply != NULL && reply->type == expected);\n freeReplyObject(reply);\n}",
"/* Togggle client tracking */\nstatic void send_client_tracking(redisContext *c, const char *str) {\n redisReply *reply;",
" reply = redisCommand(c, \"CLIENT TRACKING %s\", str);\n assert(reply != NULL && reply->type == REDIS_REPLY_STATUS);\n freeReplyObject(reply);\n}",
"static int disconnect(redisContext *c, int keep_fd) {\n redisReply *reply;",
" /* Make sure we're on DB 9. */\n reply = redisCommand(c,\"SELECT 9\");\n assert(reply != NULL);\n freeReplyObject(reply);\n reply = redisCommand(c,\"FLUSHDB\");\n assert(reply != NULL);\n freeReplyObject(reply);",
" /* Free the context as well, but keep the fd if requested. */\n if (keep_fd)\n return redisFreeKeepFd(c);\n redisFree(c);\n return -1;\n}",
"static void do_ssl_handshake(redisContext *c) {\n#ifdef HIREDIS_TEST_SSL\n redisInitiateSSLWithContext(c, _ssl_ctx);\n if (c->err) {\n printf(\"SSL error: %s\\n\", c->errstr);\n redisFree(c);\n exit(1);\n }\n#else\n (void) c;\n#endif\n}",
"static redisContext *do_connect(struct config config) {\n redisContext *c = NULL;",
" if (config.type == CONN_TCP) {\n c = redisConnect(config.tcp.host, config.tcp.port);\n } else if (config.type == CONN_SSL) {\n c = redisConnect(config.ssl.host, config.ssl.port);\n } else if (config.type == CONN_UNIX) {\n c = redisConnectUnix(config.unix_sock.path);\n } else if (config.type == CONN_FD) {\n /* Create a dummy connection just to get an fd to inherit */\n redisContext *dummy_ctx = redisConnectUnix(config.unix_sock.path);\n if (dummy_ctx) {\n int fd = disconnect(dummy_ctx, 1);\n printf(\"Connecting to inherited fd %d\\n\", fd);\n c = redisConnectFd(fd);\n }\n } else {\n assert(NULL);\n }",
" if (c == NULL) {\n printf(\"Connection error: can't allocate redis context\\n\");\n exit(1);\n } else if (c->err) {\n printf(\"Connection error: %s\\n\", c->errstr);\n redisFree(c);\n exit(1);\n }",
" if (config.type == CONN_SSL) {\n do_ssl_handshake(c);\n }",
" return select_database(c);\n}",
"static void do_reconnect(redisContext *c, struct config config) {\n redisReconnect(c);",
" if (config.type == CONN_SSL) {\n do_ssl_handshake(c);\n }\n}",
"static void test_format_commands(void) {\n char *cmd;\n int len;",
" test(\"Format command without interpolation: \");\n len = redisFormatCommand(&cmd,\"SET foo bar\");\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(3+2));\n hi_free(cmd);",
" test(\"Format command with %%s string interpolation: \");\n len = redisFormatCommand(&cmd,\"SET %s %s\",\"foo\",\"bar\");\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(3+2));\n hi_free(cmd);",
" test(\"Format command with %%s and an empty string: \");\n len = redisFormatCommand(&cmd,\"SET %s %s\",\"foo\",\"\");\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$0\\r\\n\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(0+2));\n hi_free(cmd);",
" test(\"Format command with an empty string in between proper interpolations: \");\n len = redisFormatCommand(&cmd,\"SET %s %s\",\"\",\"foo\");\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$0\\r\\n\\r\\n$3\\r\\nfoo\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(0+2)+4+(3+2));\n hi_free(cmd);",
" test(\"Format command with %%b string interpolation: \");\n len = redisFormatCommand(&cmd,\"SET %b %b\",\"foo\",(size_t)3,\"b\\0r\",(size_t)3);\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$3\\r\\nb\\0r\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(3+2));\n hi_free(cmd);",
" test(\"Format command with %%b and an empty string: \");\n len = redisFormatCommand(&cmd,\"SET %b %b\",\"foo\",(size_t)3,\"\",(size_t)0);\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$0\\r\\n\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(0+2));\n hi_free(cmd);",
" test(\"Format command with literal %%: \");\n len = redisFormatCommand(&cmd,\"SET %% %%\");\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$1\\r\\n%\\r\\n$1\\r\\n%\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(1+2)+4+(1+2));\n hi_free(cmd);",
" /* Vararg width depends on the type. These tests make sure that the\n * width is correctly determined using the format and subsequent varargs\n * can correctly be interpolated. */\n#define INTEGER_WIDTH_TEST(fmt, type) do { \\\n type value = 123; \\\n test(\"Format command with printf-delegation (\" #type \"): \"); \\\n len = redisFormatCommand(&cmd,\"key:%08\" fmt \" str:%s\", value, \"hello\"); \\\n test_cond(strncmp(cmd,\"*2\\r\\n$12\\r\\nkey:00000123\\r\\n$9\\r\\nstr:hello\\r\\n\",len) == 0 && \\\n len == 4+5+(12+2)+4+(9+2)); \\\n hi_free(cmd); \\\n} while(0)",
"#define FLOAT_WIDTH_TEST(type) do { \\\n type value = 123.0; \\\n test(\"Format command with printf-delegation (\" #type \"): \"); \\\n len = redisFormatCommand(&cmd,\"key:%08.3f str:%s\", value, \"hello\"); \\\n test_cond(strncmp(cmd,\"*2\\r\\n$12\\r\\nkey:0123.000\\r\\n$9\\r\\nstr:hello\\r\\n\",len) == 0 && \\\n len == 4+5+(12+2)+4+(9+2)); \\\n hi_free(cmd); \\\n} while(0)",
" INTEGER_WIDTH_TEST(\"d\", int);\n INTEGER_WIDTH_TEST(\"hhd\", char);\n INTEGER_WIDTH_TEST(\"hd\", short);\n INTEGER_WIDTH_TEST(\"ld\", long);\n INTEGER_WIDTH_TEST(\"lld\", long long);\n INTEGER_WIDTH_TEST(\"u\", unsigned int);\n INTEGER_WIDTH_TEST(\"hhu\", unsigned char);\n INTEGER_WIDTH_TEST(\"hu\", unsigned short);\n INTEGER_WIDTH_TEST(\"lu\", unsigned long);\n INTEGER_WIDTH_TEST(\"llu\", unsigned long long);\n FLOAT_WIDTH_TEST(float);\n FLOAT_WIDTH_TEST(double);",
" test(\"Format command with invalid printf format: \");\n len = redisFormatCommand(&cmd,\"key:%08p %b\",(void*)1234,\"foo\",(size_t)3);\n test_cond(len == -1);",
" const char *argv[3];\n argv[0] = \"SET\";\n argv[1] = \"foo\\0xxx\";\n argv[2] = \"bar\";\n size_t lens[3] = { 3, 7, 3 };\n int argc = 3;",
" test(\"Format command by passing argc/argv without lengths: \");\n len = redisFormatCommandArgv(&cmd,argc,argv,NULL);\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(3+2));\n hi_free(cmd);",
" test(\"Format command by passing argc/argv with lengths: \");\n len = redisFormatCommandArgv(&cmd,argc,argv,lens);\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$7\\r\\nfoo\\0xxx\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(7+2)+4+(3+2));\n hi_free(cmd);",
" hisds sds_cmd;",
" sds_cmd = NULL;\n test(\"Format command into hisds by passing argc/argv without lengths: \");\n len = redisFormatSdsCommandArgv(&sds_cmd,argc,argv,NULL);\n test_cond(strncmp(sds_cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(3+2));\n hi_sdsfree(sds_cmd);",
" sds_cmd = NULL;\n test(\"Format command into hisds by passing argc/argv with lengths: \");\n len = redisFormatSdsCommandArgv(&sds_cmd,argc,argv,lens);\n test_cond(strncmp(sds_cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$7\\r\\nfoo\\0xxx\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(7+2)+4+(3+2));\n hi_sdsfree(sds_cmd);\n}",
"static void test_append_formatted_commands(struct config config) {\n redisContext *c;\n redisReply *reply;\n char *cmd;\n int len;",
" c = do_connect(config);",
" test(\"Append format command: \");",
" len = redisFormatCommand(&cmd, \"SET foo bar\");",
" test_cond(redisAppendFormattedCommand(c, cmd, len) == REDIS_OK);",
" assert(redisGetReply(c, (void*)&reply) == REDIS_OK);",
" hi_free(cmd);\n freeReplyObject(reply);",
" disconnect(c, 0);\n}",
"static void test_reply_reader(void) {\n redisReader *reader;\n void *reply, *root;\n int ret;\n int i;",
" test(\"Error handling in reply parser: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader,(char*)\"@foo\\r\\n\",6);\n ret = redisReaderGetReply(reader,NULL);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Protocol error, got \\\"@\\\" as reply type byte\") == 0);\n redisReaderFree(reader);",
" /* when the reply already contains multiple items, they must be free'd\n * on an error. valgrind will bark when this doesn't happen. */\n test(\"Memory cleanup in reply parser: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader,(char*)\"*2\\r\\n\",4);\n redisReaderFeed(reader,(char*)\"$5\\r\\nhello\\r\\n\",11);\n redisReaderFeed(reader,(char*)\"@foo\\r\\n\",6);\n ret = redisReaderGetReply(reader,NULL);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Protocol error, got \\\"@\\\" as reply type byte\") == 0);\n redisReaderFree(reader);",
" reader = redisReaderCreate();\n test(\"Can handle arbitrarily nested multi-bulks: \");\n for (i = 0; i < 128; i++) {\n redisReaderFeed(reader,(char*)\"*1\\r\\n\", 4);\n }\n redisReaderFeed(reader,(char*)\"$6\\r\\nLOLWUT\\r\\n\",12);\n ret = redisReaderGetReply(reader,&reply);\n root = reply; /* Keep track of the root reply */\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_ARRAY &&\n ((redisReply*)reply)->elements == 1);",
" test(\"Can parse arbitrarily nested multi-bulks correctly: \");\n while(i--) {\n assert(reply != NULL && ((redisReply*)reply)->type == REDIS_REPLY_ARRAY);\n reply = ((redisReply*)reply)->element[0];\n }\n test_cond(((redisReply*)reply)->type == REDIS_REPLY_STRING &&\n !memcmp(((redisReply*)reply)->str, \"LOLWUT\", 6));\n freeReplyObject(root);\n redisReaderFree(reader);",
" test(\"Correctly parses LLONG_MAX: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \":9223372036854775807\\r\\n\",22);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_INTEGER &&\n ((redisReply*)reply)->integer == LLONG_MAX);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Set error when > LLONG_MAX: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \":9223372036854775808\\r\\n\",22);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Bad integer value\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Correctly parses LLONG_MIN: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \":-9223372036854775808\\r\\n\",23);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_INTEGER &&\n ((redisReply*)reply)->integer == LLONG_MIN);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Set error when < LLONG_MIN: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \":-9223372036854775809\\r\\n\",23);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Bad integer value\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Set error when array < -1: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \"*-2\\r\\n+asdf\\r\\n\",12);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Multi-bulk length out of range\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Set error when bulk < -1: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \"$-2\\r\\nasdf\\r\\n\",11);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Bulk string length out of range\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Can configure maximum multi-bulk elements: \");\n reader = redisReaderCreate();\n reader->maxelements = 1024;\n redisReaderFeed(reader, \"*1025\\r\\n\", 7);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr, \"Multi-bulk length out of range\") == 0);",
"",
" freeReplyObject(reply);\n redisReaderFree(reader);",
"#if LLONG_MAX > SIZE_MAX\n test(\"Set error when array > SIZE_MAX: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \"*9223372036854775807\\r\\n+asdf\\r\\n\",29);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Multi-bulk length out of range\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Set error when bulk > SIZE_MAX: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \"$9223372036854775807\\r\\nasdf\\r\\n\",28);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Bulk string length out of range\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);\n#endif",
" test(\"Works with NULL functions for reply: \");\n reader = redisReaderCreate();\n reader->fn = NULL;\n redisReaderFeed(reader,(char*)\"+OK\\r\\n\",5);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS);\n redisReaderFree(reader);",
" test(\"Works when a single newline (\\\\r\\\\n) covers two calls to feed: \");\n reader = redisReaderCreate();\n reader->fn = NULL;\n redisReaderFeed(reader,(char*)\"+OK\\r\",4);\n ret = redisReaderGetReply(reader,&reply);\n assert(ret == REDIS_OK && reply == NULL);\n redisReaderFeed(reader,(char*)\"\\n\",1);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS);\n redisReaderFree(reader);",
" test(\"Don't reset state after protocol error: \");\n reader = redisReaderCreate();\n reader->fn = NULL;\n redisReaderFeed(reader,(char*)\"x\",1);\n ret = redisReaderGetReply(reader,&reply);\n assert(ret == REDIS_ERR);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR && reply == NULL);\n redisReaderFree(reader);",
" /* Regression test for issue #45 on GitHub. */\n test(\"Don't do empty allocation for empty multi bulk: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader,(char*)\"*0\\r\\n\",4);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_ARRAY &&\n ((redisReply*)reply)->elements == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" /* RESP3 verbatim strings (GitHub issue #802) */\n test(\"Can parse RESP3 verbatim strings: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader,(char*)\"=10\\r\\ntxt:LOLWUT\\r\\n\",17);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_VERB &&\n !memcmp(((redisReply*)reply)->str,\"LOLWUT\", 6));\n freeReplyObject(reply);\n redisReaderFree(reader);",
" /* RESP3 push messages (Github issue #815) */\n test(\"Can parse RESP3 push messages: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader,(char*)\">2\\r\\n$6\\r\\nLOLWUT\\r\\n:42\\r\\n\",21);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_PUSH &&\n ((redisReply*)reply)->elements == 2 &&\n ((redisReply*)reply)->element[0]->type == REDIS_REPLY_STRING &&\n !memcmp(((redisReply*)reply)->element[0]->str,\"LOLWUT\",6) &&\n ((redisReply*)reply)->element[1]->type == REDIS_REPLY_INTEGER &&\n ((redisReply*)reply)->element[1]->integer == 42);\n freeReplyObject(reply);\n redisReaderFree(reader);\n}",
"static void test_free_null(void) {\n void *redisCtx = NULL;\n void *reply = NULL;",
" test(\"Don't fail when redisFree is passed a NULL value: \");\n redisFree(redisCtx);\n test_cond(redisCtx == NULL);",
" test(\"Don't fail when freeReplyObject is passed a NULL value: \");\n freeReplyObject(reply);\n test_cond(reply == NULL);\n}",
"static void *hi_malloc_fail(size_t size) {\n (void)size;\n return NULL;\n}",
"static void *hi_calloc_fail(size_t nmemb, size_t size) {\n (void)nmemb;\n (void)size;\n return NULL;\n}",
"static void *hi_realloc_fail(void *ptr, size_t size) {\n (void)ptr;\n (void)size;\n return NULL;\n}",
"static void test_allocator_injection(void) {\n hiredisAllocFuncs ha = {\n .mallocFn = hi_malloc_fail,\n .callocFn = hi_calloc_fail,\n .reallocFn = hi_realloc_fail,\n .strdupFn = strdup,\n .freeFn = free,\n };",
" // Override hiredis allocators\n hiredisSetAllocators(&ha);",
" test(\"redisContext uses injected allocators: \");\n redisContext *c = redisConnect(\"localhost\", 6379);\n test_cond(c == NULL);",
" test(\"redisReader uses injected allocators: \");\n redisReader *reader = redisReaderCreate();\n test_cond(reader == NULL);",
" // Return allocators to default\n hiredisResetAllocators();\n}",
"#define HIREDIS_BAD_DOMAIN \"idontexist-noreally.com\"\nstatic void test_blocking_connection_errors(void) {\n redisContext *c;\n struct addrinfo hints = {.ai_family = AF_INET};\n struct addrinfo *ai_tmp = NULL;",
" int rv = getaddrinfo(HIREDIS_BAD_DOMAIN, \"6379\", &hints, &ai_tmp);\n if (rv != 0) {\n // Address does *not* exist\n test(\"Returns error when host cannot be resolved: \");\n // First see if this domain name *actually* resolves to NXDOMAIN\n c = redisConnect(HIREDIS_BAD_DOMAIN, 6379);\n test_cond(\n c->err == REDIS_ERR_OTHER &&\n (strcmp(c->errstr, \"Name or service not known\") == 0 ||\n strcmp(c->errstr, \"Can't resolve: \" HIREDIS_BAD_DOMAIN) == 0 ||\n strcmp(c->errstr, \"Name does not resolve\") == 0 ||\n strcmp(c->errstr, \"nodename nor servname provided, or not known\") == 0 ||\n strcmp(c->errstr, \"No address associated with hostname\") == 0 ||\n strcmp(c->errstr, \"Temporary failure in name resolution\") == 0 ||\n strcmp(c->errstr, \"hostname nor servname provided, or not known\") == 0 ||\n strcmp(c->errstr, \"no address associated with name\") == 0 ||\n strcmp(c->errstr, \"No such host is known. \") == 0));\n redisFree(c);\n } else {\n printf(\"Skipping NXDOMAIN test. Found evil ISP!\\n\");\n freeaddrinfo(ai_tmp);\n }",
"#ifndef _WIN32\n test(\"Returns error when the port is not open: \");\n c = redisConnect((char*)\"localhost\", 1);\n test_cond(c->err == REDIS_ERR_IO &&\n strcmp(c->errstr,\"Connection refused\") == 0);\n redisFree(c);",
" test(\"Returns error when the unix_sock socket path doesn't accept connections: \");\n c = redisConnectUnix((char*)\"/tmp/idontexist.sock\");\n test_cond(c->err == REDIS_ERR_IO); /* Don't care about the message... */\n redisFree(c);\n#endif\n}",
"/* Test push handler */\nvoid push_handler(void *privdata, void *r) {\n struct pushCounters *pcounts = privdata;\n redisReply *reply = r, *payload;",
" assert(reply && reply->type == REDIS_REPLY_PUSH && reply->elements == 2);",
" payload = reply->element[1];\n if (payload->type == REDIS_REPLY_ARRAY) {\n payload = payload->element[0];\n }",
" if (payload->type == REDIS_REPLY_STRING) {\n pcounts->str++;\n } else if (payload->type == REDIS_REPLY_NIL) {\n pcounts->nil++;\n }",
" freeReplyObject(reply);\n}",
"/* Dummy function just to test setting a callback with redisOptions */\nvoid push_handler_async(redisAsyncContext *ac, void *reply) {\n (void)ac;\n (void)reply;\n}",
"static void test_resp3_push_handler(redisContext *c) {\n struct pushCounters pc = {0};\n redisPushFn *old = NULL;\n redisReply *reply;\n void *privdata;",
" /* Switch to RESP3 and turn on client tracking */\n send_hello(c, 3);\n send_client_tracking(c, \"ON\");\n privdata = c->privdata;\n c->privdata = &pc;",
" reply = redisCommand(c, \"GET key:0\");\n assert(reply != NULL);\n freeReplyObject(reply);",
" test(\"RESP3 PUSH messages are handled out of band by default: \");\n reply = redisCommand(c, \"SET key:0 val:0\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS);\n freeReplyObject(reply);",
" assert((reply = redisCommand(c, \"GET key:0\")) != NULL);\n freeReplyObject(reply);",
" old = redisSetPushCallback(c, push_handler);\n test(\"We can set a custom RESP3 PUSH handler: \");\n reply = redisCommand(c, \"SET key:0 val:0\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS && pc.str == 1);\n freeReplyObject(reply);",
" test(\"We properly handle a NIL invalidation payload: \");\n reply = redisCommand(c, \"FLUSHDB\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS && pc.nil == 1);\n freeReplyObject(reply);",
" /* Unset the push callback and generate an invalidate message making\n * sure it is not handled out of band. */\n test(\"With no handler, PUSH replies come in-band: \");\n redisSetPushCallback(c, NULL);\n assert((reply = redisCommand(c, \"GET key:0\")) != NULL);\n freeReplyObject(reply);\n assert((reply = redisCommand(c, \"SET key:0 invalid\")) != NULL);\n test_cond(reply->type == REDIS_REPLY_PUSH);\n freeReplyObject(reply);",
" test(\"With no PUSH handler, no replies are lost: \");\n assert(redisGetReply(c, (void**)&reply) == REDIS_OK);\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS);\n freeReplyObject(reply);",
" /* Return to the originally set PUSH handler */\n assert(old != NULL);\n redisSetPushCallback(c, old);",
" /* Switch back to RESP2 and disable tracking */\n c->privdata = privdata;\n send_client_tracking(c, \"OFF\");\n send_hello(c, 2);\n}",
"redisOptions get_redis_tcp_options(struct config config) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, config.tcp.host, config.tcp.port);\n return options;\n}",
"static void test_resp3_push_options(struct config config) {\n redisAsyncContext *ac;\n redisContext *c;\n redisOptions options;",
" test(\"We set a default RESP3 handler for redisContext: \");\n options = get_redis_tcp_options(config);\n assert((c = redisConnectWithOptions(&options)) != NULL);\n test_cond(c->push_cb != NULL);\n redisFree(c);",
" test(\"We don't set a default RESP3 push handler for redisAsyncContext: \");\n options = get_redis_tcp_options(config);\n assert((ac = redisAsyncConnectWithOptions(&options)) != NULL);\n test_cond(ac->c.push_cb == NULL);\n redisAsyncFree(ac);",
" test(\"Our REDIS_OPT_NO_PUSH_AUTOFREE flag works: \");\n options = get_redis_tcp_options(config);\n options.options |= REDIS_OPT_NO_PUSH_AUTOFREE;\n assert((c = redisConnectWithOptions(&options)) != NULL);\n test_cond(c->push_cb == NULL);\n redisFree(c);",
" test(\"We can use redisOptions to set a custom PUSH handler for redisContext: \");\n options = get_redis_tcp_options(config);\n options.push_cb = push_handler;\n assert((c = redisConnectWithOptions(&options)) != NULL);\n test_cond(c->push_cb == push_handler);\n redisFree(c);",
" test(\"We can use redisOptions to set a custom PUSH handler for redisAsyncContext: \");\n options = get_redis_tcp_options(config);\n options.async_push_cb = push_handler_async;\n assert((ac = redisAsyncConnectWithOptions(&options)) != NULL);\n test_cond(ac->push_cb == push_handler_async);\n redisAsyncFree(ac);\n}",
"void free_privdata(void *privdata) {\n struct privdata *data = privdata;\n data->dtor_counter++;\n}",
"static void test_privdata_hooks(struct config config) {\n struct privdata data = {0};\n redisOptions options;\n redisContext *c;",
" test(\"We can use redisOptions to set privdata: \");\n options = get_redis_tcp_options(config);\n REDIS_OPTIONS_SET_PRIVDATA(&options, &data, free_privdata);\n assert((c = redisConnectWithOptions(&options)) != NULL);\n test_cond(c->privdata == &data);",
" test(\"Our privdata destructor fires when we free the context: \");\n redisFree(c);\n test_cond(data.dtor_counter == 1);\n}",
"static void test_blocking_connection(struct config config) {\n redisContext *c;\n redisReply *reply;\n int major;",
" c = do_connect(config);",
" test(\"Is able to deliver commands: \");\n reply = redisCommand(c,\"PING\");\n test_cond(reply->type == REDIS_REPLY_STATUS &&\n strcasecmp(reply->str,\"pong\") == 0)\n freeReplyObject(reply);",
" test(\"Is a able to send commands verbatim: \");\n reply = redisCommand(c,\"SET foo bar\");\n test_cond (reply->type == REDIS_REPLY_STATUS &&\n strcasecmp(reply->str,\"ok\") == 0)\n freeReplyObject(reply);",
" test(\"%%s String interpolation works: \");\n reply = redisCommand(c,\"SET %s %s\",\"foo\",\"hello world\");\n freeReplyObject(reply);\n reply = redisCommand(c,\"GET foo\");\n test_cond(reply->type == REDIS_REPLY_STRING &&\n strcmp(reply->str,\"hello world\") == 0);\n freeReplyObject(reply);",
" test(\"%%b String interpolation works: \");\n reply = redisCommand(c,\"SET %b %b\",\"foo\",(size_t)3,\"hello\\x00world\",(size_t)11);\n freeReplyObject(reply);\n reply = redisCommand(c,\"GET foo\");\n test_cond(reply->type == REDIS_REPLY_STRING &&\n memcmp(reply->str,\"hello\\x00world\",11) == 0)",
" test(\"Binary reply length is correct: \");\n test_cond(reply->len == 11)\n freeReplyObject(reply);",
" test(\"Can parse nil replies: \");\n reply = redisCommand(c,\"GET nokey\");\n test_cond(reply->type == REDIS_REPLY_NIL)\n freeReplyObject(reply);",
" /* test 7 */\n test(\"Can parse integer replies: \");\n reply = redisCommand(c,\"INCR mycounter\");\n test_cond(reply->type == REDIS_REPLY_INTEGER && reply->integer == 1)\n freeReplyObject(reply);",
" test(\"Can parse multi bulk replies: \");\n freeReplyObject(redisCommand(c,\"LPUSH mylist foo\"));\n freeReplyObject(redisCommand(c,\"LPUSH mylist bar\"));\n reply = redisCommand(c,\"LRANGE mylist 0 -1\");\n test_cond(reply->type == REDIS_REPLY_ARRAY &&\n reply->elements == 2 &&\n !memcmp(reply->element[0]->str,\"bar\",3) &&\n !memcmp(reply->element[1]->str,\"foo\",3))\n freeReplyObject(reply);",
" /* m/e with multi bulk reply *before* other reply.\n * specifically test ordering of reply items to parse. */\n test(\"Can handle nested multi bulk replies: \");\n freeReplyObject(redisCommand(c,\"MULTI\"));\n freeReplyObject(redisCommand(c,\"LRANGE mylist 0 -1\"));\n freeReplyObject(redisCommand(c,\"PING\"));\n reply = (redisCommand(c,\"EXEC\"));\n test_cond(reply->type == REDIS_REPLY_ARRAY &&\n reply->elements == 2 &&\n reply->element[0]->type == REDIS_REPLY_ARRAY &&\n reply->element[0]->elements == 2 &&\n !memcmp(reply->element[0]->element[0]->str,\"bar\",3) &&\n !memcmp(reply->element[0]->element[1]->str,\"foo\",3) &&\n reply->element[1]->type == REDIS_REPLY_STATUS &&\n strcasecmp(reply->element[1]->str,\"pong\") == 0);\n freeReplyObject(reply);",
" /* Make sure passing NULL to redisGetReply is safe */\n test(\"Can pass NULL to redisGetReply: \");\n assert(redisAppendCommand(c, \"PING\") == REDIS_OK);\n test_cond(redisGetReply(c, NULL) == REDIS_OK);",
" get_redis_version(c, &major, NULL);\n if (major >= 6) test_resp3_push_handler(c);\n test_resp3_push_options(config);",
" test_privdata_hooks(config);",
" disconnect(c, 0);\n}",
"/* Send DEBUG SLEEP 0 to detect if we have this command */\nstatic int detect_debug_sleep(redisContext *c) {\n int detected;\n redisReply *reply = redisCommand(c, \"DEBUG SLEEP 0\\r\\n\");",
" if (reply == NULL || c->err) {\n const char *cause = c->err ? c->errstr : \"(none)\";\n fprintf(stderr, \"Error testing for DEBUG SLEEP (Redis error: %s), exiting\\n\", cause);\n exit(-1);\n }",
" detected = reply->type == REDIS_REPLY_STATUS;\n freeReplyObject(reply);",
" return detected;\n}",
"static void test_blocking_connection_timeouts(struct config config) {\n redisContext *c;\n redisReply *reply;\n ssize_t s;\n const char *sleep_cmd = \"DEBUG SLEEP 3\\r\\n\";\n struct timeval tv;",
" c = do_connect(config);\n test(\"Successfully completes a command when the timeout is not exceeded: \");\n reply = redisCommand(c,\"SET foo fast\");\n freeReplyObject(reply);\n tv.tv_sec = 0;\n tv.tv_usec = 10000;\n redisSetTimeout(c, tv);\n reply = redisCommand(c, \"GET foo\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STRING && memcmp(reply->str, \"fast\", 4) == 0);\n freeReplyObject(reply);\n disconnect(c, 0);",
" c = do_connect(config);\n test(\"Does not return a reply when the command times out: \");\n if (detect_debug_sleep(c)) {\n redisAppendFormattedCommand(c, sleep_cmd, strlen(sleep_cmd));\n s = c->funcs->write(c);\n tv.tv_sec = 0;\n tv.tv_usec = 10000;\n redisSetTimeout(c, tv);\n reply = redisCommand(c, \"GET foo\");\n#ifndef _WIN32\n test_cond(s > 0 && reply == NULL && c->err == REDIS_ERR_IO &&\n strcmp(c->errstr, \"Resource temporarily unavailable\") == 0);\n#else\n test_cond(s > 0 && reply == NULL && c->err == REDIS_ERR_TIMEOUT &&\n strcmp(c->errstr, \"recv timeout\") == 0);\n#endif\n freeReplyObject(reply);\n } else {\n test_skipped();\n }",
" test(\"Reconnect properly reconnects after a timeout: \");\n do_reconnect(c, config);\n reply = redisCommand(c, \"PING\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS && strcmp(reply->str, \"PONG\") == 0);\n freeReplyObject(reply);",
" test(\"Reconnect properly uses owned parameters: \");\n config.tcp.host = \"foo\";\n config.unix_sock.path = \"foo\";\n do_reconnect(c, config);\n reply = redisCommand(c, \"PING\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS && strcmp(reply->str, \"PONG\") == 0);\n freeReplyObject(reply);",
" disconnect(c, 0);\n}",
"static void test_blocking_io_errors(struct config config) {\n redisContext *c;\n redisReply *reply;\n void *_reply;\n int major, minor;",
" /* Connect to target given by config. */\n c = do_connect(config);\n get_redis_version(c, &major, &minor);",
" test(\"Returns I/O error when the connection is lost: \");\n reply = redisCommand(c,\"QUIT\");\n if (major > 2 || (major == 2 && minor > 0)) {\n /* > 2.0 returns OK on QUIT and read() should be issued once more\n * to know the descriptor is at EOF. */\n test_cond(strcasecmp(reply->str,\"OK\") == 0 &&\n redisGetReply(c,&_reply) == REDIS_ERR);\n freeReplyObject(reply);\n } else {\n test_cond(reply == NULL);\n }",
"#ifndef _WIN32\n /* On 2.0, QUIT will cause the connection to be closed immediately and\n * the read(2) for the reply on QUIT will set the error to EOF.\n * On >2.0, QUIT will return with OK and another read(2) needed to be\n * issued to find out the socket was closed by the server. In both\n * conditions, the error will be set to EOF. */\n assert(c->err == REDIS_ERR_EOF &&\n strcmp(c->errstr,\"Server closed the connection\") == 0);\n#endif\n redisFree(c);",
" c = do_connect(config);\n test(\"Returns I/O error on socket timeout: \");\n struct timeval tv = { 0, 1000 };\n assert(redisSetTimeout(c,tv) == REDIS_OK);\n int respcode = redisGetReply(c,&_reply);\n#ifndef _WIN32\n test_cond(respcode == REDIS_ERR && c->err == REDIS_ERR_IO && errno == EAGAIN);\n#else\n test_cond(respcode == REDIS_ERR && c->err == REDIS_ERR_TIMEOUT);\n#endif\n redisFree(c);\n}",
"static void test_invalid_timeout_errors(struct config config) {\n redisContext *c;",
" test(\"Set error when an invalid timeout usec value is given to redisConnectWithTimeout: \");",
" config.tcp.timeout.tv_sec = 0;\n config.tcp.timeout.tv_usec = 10000001;",
" c = redisConnectWithTimeout(config.tcp.host, config.tcp.port, config.tcp.timeout);",
" test_cond(c->err == REDIS_ERR_IO && strcmp(c->errstr, \"Invalid timeout specified\") == 0);\n redisFree(c);",
" test(\"Set error when an invalid timeout sec value is given to redisConnectWithTimeout: \");",
" config.tcp.timeout.tv_sec = (((LONG_MAX) - 999) / 1000) + 1;\n config.tcp.timeout.tv_usec = 0;",
" c = redisConnectWithTimeout(config.tcp.host, config.tcp.port, config.tcp.timeout);",
" test_cond(c->err == REDIS_ERR_IO && strcmp(c->errstr, \"Invalid timeout specified\") == 0);\n redisFree(c);\n}",
"/* Wrap malloc to abort on failure so OOM checks don't make the test logic\n * harder to follow. */\nvoid *hi_malloc_safe(size_t size) {\n void *ptr = hi_malloc(size);\n if (ptr == NULL) {\n fprintf(stderr, \"Error: Out of memory\\n\");\n exit(-1);\n }",
" return ptr;\n}",
"static void test_throughput(struct config config) {\n redisContext *c = do_connect(config);\n redisReply **replies;\n int i, num;\n long long t1, t2;",
" test(\"Throughput:\\n\");\n for (i = 0; i < 500; i++)\n freeReplyObject(redisCommand(c,\"LPUSH mylist foo\"));",
" num = 1000;\n replies = hi_malloc_safe(sizeof(redisReply*)*num);\n t1 = usec();\n for (i = 0; i < num; i++) {\n replies[i] = redisCommand(c,\"PING\");\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_STATUS);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx PING: %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" replies = hi_malloc_safe(sizeof(redisReply*)*num);\n t1 = usec();\n for (i = 0; i < num; i++) {\n replies[i] = redisCommand(c,\"LRANGE mylist 0 499\");\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_ARRAY);\n assert(replies[i] != NULL && replies[i]->elements == 500);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx LRANGE with 500 elements: %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" replies = hi_malloc_safe(sizeof(redisReply*)*num);\n t1 = usec();\n for (i = 0; i < num; i++) {\n replies[i] = redisCommand(c, \"INCRBY incrkey %d\", 1000000);\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_INTEGER);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx INCRBY: %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" num = 10000;\n replies = hi_malloc_safe(sizeof(redisReply*)*num);\n for (i = 0; i < num; i++)\n redisAppendCommand(c,\"PING\");\n t1 = usec();\n for (i = 0; i < num; i++) {\n assert(redisGetReply(c, (void*)&replies[i]) == REDIS_OK);\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_STATUS);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx PING (pipelined): %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" replies = hi_malloc_safe(sizeof(redisReply*)*num);\n for (i = 0; i < num; i++)\n redisAppendCommand(c,\"LRANGE mylist 0 499\");\n t1 = usec();\n for (i = 0; i < num; i++) {\n assert(redisGetReply(c, (void*)&replies[i]) == REDIS_OK);\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_ARRAY);\n assert(replies[i] != NULL && replies[i]->elements == 500);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx LRANGE with 500 elements (pipelined): %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" replies = hi_malloc_safe(sizeof(redisReply*)*num);\n for (i = 0; i < num; i++)\n redisAppendCommand(c,\"INCRBY incrkey %d\", 1000000);\n t1 = usec();\n for (i = 0; i < num; i++) {\n assert(redisGetReply(c, (void*)&replies[i]) == REDIS_OK);\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_INTEGER);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx INCRBY (pipelined): %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" disconnect(c, 0);\n}",
"// static long __test_callback_flags = 0;\n// static void __test_callback(redisContext *c, void *privdata) {\n// ((void)c);\n// /* Shift to detect execution order */\n// __test_callback_flags <<= 8;\n// __test_callback_flags |= (long)privdata;\n// }\n//\n// static void __test_reply_callback(redisContext *c, redisReply *reply, void *privdata) {\n// ((void)c);\n// /* Shift to detect execution order */\n// __test_callback_flags <<= 8;\n// __test_callback_flags |= (long)privdata;\n// if (reply) freeReplyObject(reply);\n// }\n//\n// static redisContext *__connect_nonblock() {\n// /* Reset callback flags */\n// __test_callback_flags = 0;\n// return redisConnectNonBlock(\"127.0.0.1\", port, NULL);\n// }\n//\n// static void test_nonblocking_connection() {\n// redisContext *c;\n// int wdone = 0;\n//\n// test(\"Calls command callback when command is issued: \");\n// c = __connect_nonblock();\n// redisSetCommandCallback(c,__test_callback,(void*)1);\n// redisCommand(c,\"PING\");\n// test_cond(__test_callback_flags == 1);\n// redisFree(c);\n//\n// test(\"Calls disconnect callback on redisDisconnect: \");\n// c = __connect_nonblock();\n// redisSetDisconnectCallback(c,__test_callback,(void*)2);\n// redisDisconnect(c);\n// test_cond(__test_callback_flags == 2);\n// redisFree(c);\n//\n// test(\"Calls disconnect callback and free callback on redisFree: \");\n// c = __connect_nonblock();\n// redisSetDisconnectCallback(c,__test_callback,(void*)2);\n// redisSetFreeCallback(c,__test_callback,(void*)4);\n// redisFree(c);\n// test_cond(__test_callback_flags == ((2 << 8) | 4));\n//\n// test(\"redisBufferWrite against empty write buffer: \");\n// c = __connect_nonblock();\n// test_cond(redisBufferWrite(c,&wdone) == REDIS_OK && wdone == 1);\n// redisFree(c);\n//\n// test(\"redisBufferWrite against not yet connected fd: \");\n// c = __connect_nonblock();\n// redisCommand(c,\"PING\");\n// test_cond(redisBufferWrite(c,NULL) == REDIS_ERR &&\n// strncmp(c->error,\"write:\",6) == 0);\n// redisFree(c);\n//\n// test(\"redisBufferWrite against closed fd: \");\n// c = __connect_nonblock();\n// redisCommand(c,\"PING\");\n// redisDisconnect(c);\n// test_cond(redisBufferWrite(c,NULL) == REDIS_ERR &&\n// strncmp(c->error,\"write:\",6) == 0);\n// redisFree(c);\n//\n// test(\"Process callbacks in the right sequence: \");\n// c = __connect_nonblock();\n// redisCommandWithCallback(c,__test_reply_callback,(void*)1,\"PING\");\n// redisCommandWithCallback(c,__test_reply_callback,(void*)2,\"PING\");\n// redisCommandWithCallback(c,__test_reply_callback,(void*)3,\"PING\");\n//\n// /* Write output buffer */\n// wdone = 0;\n// while(!wdone) {\n// usleep(500);\n// redisBufferWrite(c,&wdone);\n// }\n//\n// /* Read until at least one callback is executed (the 3 replies will\n// * arrive in a single packet, causing all callbacks to be executed in\n// * a single pass). */\n// while(__test_callback_flags == 0) {\n// assert(redisBufferRead(c) == REDIS_OK);\n// redisProcessCallbacks(c);\n// }\n// test_cond(__test_callback_flags == 0x010203);\n// redisFree(c);\n//\n// test(\"redisDisconnect executes pending callbacks with NULL reply: \");\n// c = __connect_nonblock();\n// redisSetDisconnectCallback(c,__test_callback,(void*)1);\n// redisCommandWithCallback(c,__test_reply_callback,(void*)2,\"PING\");\n// redisDisconnect(c);\n// test_cond(__test_callback_flags == 0x0201);\n// redisFree(c);\n// }",
"int main(int argc, char **argv) {\n struct config cfg = {\n .tcp = {\n .host = \"127.0.0.1\",\n .port = 6379\n },\n .unix_sock = {\n .path = \"/tmp/redis.sock\"\n }\n };\n int throughput = 1;\n int test_inherit_fd = 1;\n int skips_as_fails = 0;\n int test_unix_socket;",
" /* Parse command line options. */\n argv++; argc--;\n while (argc) {\n if (argc >= 2 && !strcmp(argv[0],\"-h\")) {\n argv++; argc--;\n cfg.tcp.host = argv[0];\n } else if (argc >= 2 && !strcmp(argv[0],\"-p\")) {\n argv++; argc--;\n cfg.tcp.port = atoi(argv[0]);\n } else if (argc >= 2 && !strcmp(argv[0],\"-s\")) {\n argv++; argc--;\n cfg.unix_sock.path = argv[0];\n } else if (argc >= 1 && !strcmp(argv[0],\"--skip-throughput\")) {\n throughput = 0;\n } else if (argc >= 1 && !strcmp(argv[0],\"--skip-inherit-fd\")) {\n test_inherit_fd = 0;\n } else if (argc >= 1 && !strcmp(argv[0],\"--skips-as-fails\")) {\n skips_as_fails = 1;\n#ifdef HIREDIS_TEST_SSL\n } else if (argc >= 2 && !strcmp(argv[0],\"--ssl-port\")) {\n argv++; argc--;\n cfg.ssl.port = atoi(argv[0]);\n } else if (argc >= 2 && !strcmp(argv[0],\"--ssl-host\")) {\n argv++; argc--;\n cfg.ssl.host = argv[0];\n } else if (argc >= 2 && !strcmp(argv[0],\"--ssl-ca-cert\")) {\n argv++; argc--;\n cfg.ssl.ca_cert = argv[0];\n } else if (argc >= 2 && !strcmp(argv[0],\"--ssl-cert\")) {\n argv++; argc--;\n cfg.ssl.cert = argv[0];\n } else if (argc >= 2 && !strcmp(argv[0],\"--ssl-key\")) {\n argv++; argc--;\n cfg.ssl.key = argv[0];\n#endif\n } else {\n fprintf(stderr, \"Invalid argument: %s\\n\", argv[0]);\n exit(1);\n }\n argv++; argc--;\n }",
"#ifndef _WIN32\n /* Ignore broken pipe signal (for I/O error tests). */\n signal(SIGPIPE, SIG_IGN);",
" test_unix_socket = access(cfg.unix_sock.path, F_OK) == 0;",
"#else\n /* Unix sockets don't exist in Windows */\n test_unix_socket = 0;\n#endif",
" test_allocator_injection();",
" test_format_commands();\n test_reply_reader();\n test_blocking_connection_errors();\n test_free_null();",
" printf(\"\\nTesting against TCP connection (%s:%d):\\n\", cfg.tcp.host, cfg.tcp.port);\n cfg.type = CONN_TCP;\n test_blocking_connection(cfg);\n test_blocking_connection_timeouts(cfg);\n test_blocking_io_errors(cfg);\n test_invalid_timeout_errors(cfg);\n test_append_formatted_commands(cfg);\n if (throughput) test_throughput(cfg);",
" printf(\"\\nTesting against Unix socket connection (%s): \", cfg.unix_sock.path);\n if (test_unix_socket) {\n printf(\"\\n\");\n cfg.type = CONN_UNIX;\n test_blocking_connection(cfg);\n test_blocking_connection_timeouts(cfg);\n test_blocking_io_errors(cfg);\n if (throughput) test_throughput(cfg);\n } else {\n test_skipped();\n }",
"#ifdef HIREDIS_TEST_SSL\n if (cfg.ssl.port && cfg.ssl.host) {",
" redisInitOpenSSL();\n _ssl_ctx = redisCreateSSLContext(cfg.ssl.ca_cert, NULL, cfg.ssl.cert, cfg.ssl.key, NULL, NULL);\n assert(_ssl_ctx != NULL);",
" printf(\"\\nTesting against SSL connection (%s:%d):\\n\", cfg.ssl.host, cfg.ssl.port);\n cfg.type = CONN_SSL;",
" test_blocking_connection(cfg);\n test_blocking_connection_timeouts(cfg);\n test_blocking_io_errors(cfg);\n test_invalid_timeout_errors(cfg);\n test_append_formatted_commands(cfg);\n if (throughput) test_throughput(cfg);",
" redisFreeSSLContext(_ssl_ctx);\n _ssl_ctx = NULL;\n }\n#endif",
" if (test_inherit_fd) {\n printf(\"\\nTesting against inherited fd (%s): \", cfg.unix_sock.path);\n if (test_unix_socket) {\n printf(\"\\n\");\n cfg.type = CONN_FD;\n test_blocking_connection(cfg);\n } else {\n test_skipped();\n }\n }",
" if (fails || (skips_as_fails && skips)) {\n printf(\"*** %d TESTS FAILED ***\\n\", fails);\n if (skips) {\n printf(\"*** %d TESTS SKIPPED ***\\n\", skips);\n }\n return 1;\n }",
" printf(\"ALL TESTS PASSED (%d skipped)\\n\", skips);\n return 0;\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,
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
] |
PreciseBugs
|
{"buggy_code_end_loc": [176, 497], "buggy_code_start_loc": [176, 497], "filenames": ["deps/hiredis/hiredis.c", "deps/hiredis/test.c"], "fixing_code_end_loc": [178, 512], "fixing_code_start_loc": [177, 498], "message": "Redis is an open source, in-memory database that persists on disk. The redis-cli command line tool and redis-sentinel service may be vulnerable to integer overflow when parsing specially crafted large multi-bulk network replies. This is a result of a vulnerability in the underlying hiredis library which does not perform an overflow check before calling the calloc() heap allocation function. This issue only impacts systems with heap allocators that do not perform their own overflow checks. Most modern systems do and are therefore not likely to be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator which is also not vulnerable. The problem is fixed in Redis versions 6.2.6, 6.0.16 and 5.0.14.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "D5D64A76-B253-4A64-8AA2-DD8815CB3CF8", "versionEndExcluding": "5.0.14", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "5.0.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "02DF8086-645E-4D42-93D3-A4B11D289C7C", "versionEndExcluding": "6.0.16", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "6.0.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "4686800E-16BA-42CE-B691-011D1D5D0CC2", "versionEndExcluding": "6.2.6", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "6.2.0", "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:*", "matchCriteriaId": "07B237A9-69A3-4A9C-9DA0-4E06BD37AE73", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:*", "matchCriteriaId": "FA6FEEC2-9F11-4643-8827-749718254FED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*", "matchCriteriaId": "E460AA51-FCDA-46B9-AE97-E6676AA5E194", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*", "matchCriteriaId": "A930E247-0B43-43CB-98FF-6CE7B8189835", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*", "matchCriteriaId": "80E516C0-98A4-4ADE-B69F-66A772E2BAAA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:netapp:management_services_for_element_software:-:*:*:*:*:*:*:*", "matchCriteriaId": "86B51137-28D9-41F2-AFA2-3CC22B4954D1", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:management_services_for_netapp_hci:-:*:*:*:*:*:*:*", "matchCriteriaId": "4455CF3A-CC91-4BE4-A7AB-929AC82E34F5", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:4.3:*:*:*:*:*:*:*", "matchCriteriaId": "CBE1A019-7BB6-4226-8AC4-9D6927ADAEFA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:4.4:*:*:*:*:*:*:*", "matchCriteriaId": "B98BAEB2-A540-4E8A-A946-C4331B913AFD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:5.0:*:*:*:*:*:*:*", "matchCriteriaId": "B8FBE260-E306-4215-80C0-D2D27CA43E0F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Redis is an open source, in-memory database that persists on disk. The redis-cli command line tool and redis-sentinel service may be vulnerable to integer overflow when parsing specially crafted large multi-bulk network replies. This is a result of a vulnerability in the underlying hiredis library which does not perform an overflow check before calling the calloc() heap allocation function. This issue only impacts systems with heap allocators that do not perform their own overflow checks. Most modern systems do and are therefore not likely to be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator which is also not vulnerable. The problem is fixed in Redis versions 6.2.6, 6.0.16 and 5.0.14."}, {"lang": "es", "value": "Redis es una base de datos en memoria de c\u00f3digo abierto que persiste en el disco. La herramienta de l\u00ednea de comandos redis-cli y el servicio redis-sentinel pueden ser vulnerables a un desbordamiento de enteros cuando analizan respuestas de red de gran tama\u00f1o especialmente dise\u00f1adas. Esto es resultado de una vulnerabilidad en la biblioteca hiredis subyacente que no lleva a cabo una comprobaci\u00f3n de desbordamiento antes de llamar a la funci\u00f3n de asignaci\u00f3n de pila calloc(). Este problema s\u00f3lo afecta a los sistemas con asignadores de pila que no llevan a cabo sus propias comprobaciones de desbordamiento. La mayor\u00eda de los sistemas modernos lo hacen y, por lo tanto, no es probable que est\u00e9n afectados. Adem\u00e1s, por defecto redis-sentinel usa el asignador jemalloc que tampoco es vulnerable. El problema se ha corregido en las versiones de Redis 6.2.6, 6.0.16 y 5.0.14"}], "evaluatorComment": null, "id": "CVE-2021-32762", "lastModified": "2022-10-06T16:53:25.217", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "COMPLETE", "baseScore": 9.0, "confidentialityImpact": "COMPLETE", "integrityImpact": "COMPLETE", "vectorString": "AV:N/AC:L/Au:S/C:C/I:C/A:C", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 10.0, "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": 8.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.6, "impactScore": 5.9, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2021-10-04T18:15:09.043", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/redis/redis/commit/0215324a66af949be39b34be2d55143232c1cb71"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/redis/redis/security/advisories/GHSA-833w-8v3m-8wwr"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/HTYQ5ZF37HNGTZWVNJD3VXP7I6MEEF42/"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/VL5KXFN3ATM7IIM7Q4O4PWTSRGZ5744Z/"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WR5WKJWXD4D6S3DJCZ56V74ESLTDQRAB/"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/202209-17"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://security.netapp.com/advisory/ntap-20211104-0003/"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2021/dsa-5001"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://www.oracle.com/security-alerts/cpuapr2022.html"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-190"}, {"lang": "en", "value": "CWE-680"}], "source": "security-advisories@github.com", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-190"}], "source": "nvd@nist.gov", "type": "Secondary"}]}, "github_commit_url": "https://github.com/redis/redis/commit/0215324a66af949be39b34be2d55143232c1cb71"}, "type": "CWE-190"}
| 218
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"#include \"fmacros.h\"\n#include \"sockcompat.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#ifndef _WIN32\n#include <strings.h>\n#include <sys/time.h>\n#endif\n#include <assert.h>\n#include <signal.h>\n#include <errno.h>\n#include <limits.h>",
"#include \"hiredis.h\"\n#include \"async.h\"\n#ifdef HIREDIS_TEST_SSL\n#include \"hiredis_ssl.h\"\n#endif\n#include \"net.h\"\n#include \"win32.h\"",
"enum connection_type {\n CONN_TCP,\n CONN_UNIX,\n CONN_FD,\n CONN_SSL\n};",
"struct config {\n enum connection_type type;",
" struct {\n const char *host;\n int port;\n struct timeval timeout;\n } tcp;",
" struct {\n const char *path;\n } unix_sock;",
" struct {\n const char *host;\n int port;\n const char *ca_cert;\n const char *cert;\n const char *key;\n } ssl;\n};",
"struct privdata {\n int dtor_counter;\n};",
"struct pushCounters {\n int nil;\n int str;\n};",
"#ifdef HIREDIS_TEST_SSL\nredisSSLContext *_ssl_ctx = NULL;\n#endif",
"/* The following lines make up our testing \"framework\" :) */\nstatic int tests = 0, fails = 0, skips = 0;\n#define test(_s) { printf(\"#%02d \", ++tests); printf(_s); }\n#define test_cond(_c) if(_c) printf(\"\\033[0;32mPASSED\\033[0;0m\\n\"); else {printf(\"\\033[0;31mFAILED\\033[0;0m\\n\"); fails++;}\n#define test_skipped() { printf(\"\\033[01;33mSKIPPED\\033[0;0m\\n\"); skips++; }",
"static long long usec(void) {\n#ifndef _MSC_VER\n struct timeval tv;\n gettimeofday(&tv,NULL);\n return (((long long)tv.tv_sec)*1000000)+tv.tv_usec;\n#else\n FILETIME ft;\n GetSystemTimeAsFileTime(&ft);\n return (((long long)ft.dwHighDateTime << 32) | ft.dwLowDateTime) / 10;\n#endif\n}",
"/* The assert() calls below have side effects, so we need assert()\n * even if we are compiling without asserts (-DNDEBUG). */\n#ifdef NDEBUG\n#undef assert\n#define assert(e) (void)(e)\n#endif",
"/* Helper to extract Redis version information. Aborts on any failure. */\n#define REDIS_VERSION_FIELD \"redis_version:\"\nvoid get_redis_version(redisContext *c, int *majorptr, int *minorptr) {\n redisReply *reply;\n char *eptr, *s, *e;\n int major, minor;",
" reply = redisCommand(c, \"INFO\");\n if (reply == NULL || c->err || reply->type != REDIS_REPLY_STRING)\n goto abort;\n if ((s = strstr(reply->str, REDIS_VERSION_FIELD)) == NULL)\n goto abort;",
" s += strlen(REDIS_VERSION_FIELD);",
" /* We need a field terminator and at least 'x.y.z' (5) bytes of data */\n if ((e = strstr(s, \"\\r\\n\")) == NULL || (e - s) < 5)\n goto abort;",
" /* Extract version info */\n major = strtol(s, &eptr, 10);\n if (*eptr != '.') goto abort;\n minor = strtol(eptr+1, NULL, 10);",
" /* Push info the caller wants */\n if (majorptr) *majorptr = major;\n if (minorptr) *minorptr = minor;",
" freeReplyObject(reply);\n return;",
"abort:\n freeReplyObject(reply);\n fprintf(stderr, \"Error: Cannot determine Redis version, aborting\\n\");\n exit(1);\n}",
"static redisContext *select_database(redisContext *c) {\n redisReply *reply;",
" /* Switch to DB 9 for testing, now that we know we can chat. */\n reply = redisCommand(c,\"SELECT 9\");\n assert(reply != NULL);\n freeReplyObject(reply);",
" /* Make sure the DB is emtpy */\n reply = redisCommand(c,\"DBSIZE\");\n assert(reply != NULL);\n if (reply->type == REDIS_REPLY_INTEGER && reply->integer == 0) {\n /* Awesome, DB 9 is empty and we can continue. */\n freeReplyObject(reply);\n } else {\n printf(\"Database #9 is not empty, test can not continue\\n\");\n exit(1);\n }",
" return c;\n}",
"/* Switch protocol */\nstatic void send_hello(redisContext *c, int version) {\n redisReply *reply;\n int expected;",
" reply = redisCommand(c, \"HELLO %d\", version);\n expected = version == 3 ? REDIS_REPLY_MAP : REDIS_REPLY_ARRAY;\n assert(reply != NULL && reply->type == expected);\n freeReplyObject(reply);\n}",
"/* Togggle client tracking */\nstatic void send_client_tracking(redisContext *c, const char *str) {\n redisReply *reply;",
" reply = redisCommand(c, \"CLIENT TRACKING %s\", str);\n assert(reply != NULL && reply->type == REDIS_REPLY_STATUS);\n freeReplyObject(reply);\n}",
"static int disconnect(redisContext *c, int keep_fd) {\n redisReply *reply;",
" /* Make sure we're on DB 9. */\n reply = redisCommand(c,\"SELECT 9\");\n assert(reply != NULL);\n freeReplyObject(reply);\n reply = redisCommand(c,\"FLUSHDB\");\n assert(reply != NULL);\n freeReplyObject(reply);",
" /* Free the context as well, but keep the fd if requested. */\n if (keep_fd)\n return redisFreeKeepFd(c);\n redisFree(c);\n return -1;\n}",
"static void do_ssl_handshake(redisContext *c) {\n#ifdef HIREDIS_TEST_SSL\n redisInitiateSSLWithContext(c, _ssl_ctx);\n if (c->err) {\n printf(\"SSL error: %s\\n\", c->errstr);\n redisFree(c);\n exit(1);\n }\n#else\n (void) c;\n#endif\n}",
"static redisContext *do_connect(struct config config) {\n redisContext *c = NULL;",
" if (config.type == CONN_TCP) {\n c = redisConnect(config.tcp.host, config.tcp.port);\n } else if (config.type == CONN_SSL) {\n c = redisConnect(config.ssl.host, config.ssl.port);\n } else if (config.type == CONN_UNIX) {\n c = redisConnectUnix(config.unix_sock.path);\n } else if (config.type == CONN_FD) {\n /* Create a dummy connection just to get an fd to inherit */\n redisContext *dummy_ctx = redisConnectUnix(config.unix_sock.path);\n if (dummy_ctx) {\n int fd = disconnect(dummy_ctx, 1);\n printf(\"Connecting to inherited fd %d\\n\", fd);\n c = redisConnectFd(fd);\n }\n } else {\n assert(NULL);\n }",
" if (c == NULL) {\n printf(\"Connection error: can't allocate redis context\\n\");\n exit(1);\n } else if (c->err) {\n printf(\"Connection error: %s\\n\", c->errstr);\n redisFree(c);\n exit(1);\n }",
" if (config.type == CONN_SSL) {\n do_ssl_handshake(c);\n }",
" return select_database(c);\n}",
"static void do_reconnect(redisContext *c, struct config config) {\n redisReconnect(c);",
" if (config.type == CONN_SSL) {\n do_ssl_handshake(c);\n }\n}",
"static void test_format_commands(void) {\n char *cmd;\n int len;",
" test(\"Format command without interpolation: \");\n len = redisFormatCommand(&cmd,\"SET foo bar\");\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(3+2));\n hi_free(cmd);",
" test(\"Format command with %%s string interpolation: \");\n len = redisFormatCommand(&cmd,\"SET %s %s\",\"foo\",\"bar\");\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(3+2));\n hi_free(cmd);",
" test(\"Format command with %%s and an empty string: \");\n len = redisFormatCommand(&cmd,\"SET %s %s\",\"foo\",\"\");\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$0\\r\\n\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(0+2));\n hi_free(cmd);",
" test(\"Format command with an empty string in between proper interpolations: \");\n len = redisFormatCommand(&cmd,\"SET %s %s\",\"\",\"foo\");\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$0\\r\\n\\r\\n$3\\r\\nfoo\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(0+2)+4+(3+2));\n hi_free(cmd);",
" test(\"Format command with %%b string interpolation: \");\n len = redisFormatCommand(&cmd,\"SET %b %b\",\"foo\",(size_t)3,\"b\\0r\",(size_t)3);\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$3\\r\\nb\\0r\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(3+2));\n hi_free(cmd);",
" test(\"Format command with %%b and an empty string: \");\n len = redisFormatCommand(&cmd,\"SET %b %b\",\"foo\",(size_t)3,\"\",(size_t)0);\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$0\\r\\n\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(0+2));\n hi_free(cmd);",
" test(\"Format command with literal %%: \");\n len = redisFormatCommand(&cmd,\"SET %% %%\");\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$1\\r\\n%\\r\\n$1\\r\\n%\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(1+2)+4+(1+2));\n hi_free(cmd);",
" /* Vararg width depends on the type. These tests make sure that the\n * width is correctly determined using the format and subsequent varargs\n * can correctly be interpolated. */\n#define INTEGER_WIDTH_TEST(fmt, type) do { \\\n type value = 123; \\\n test(\"Format command with printf-delegation (\" #type \"): \"); \\\n len = redisFormatCommand(&cmd,\"key:%08\" fmt \" str:%s\", value, \"hello\"); \\\n test_cond(strncmp(cmd,\"*2\\r\\n$12\\r\\nkey:00000123\\r\\n$9\\r\\nstr:hello\\r\\n\",len) == 0 && \\\n len == 4+5+(12+2)+4+(9+2)); \\\n hi_free(cmd); \\\n} while(0)",
"#define FLOAT_WIDTH_TEST(type) do { \\\n type value = 123.0; \\\n test(\"Format command with printf-delegation (\" #type \"): \"); \\\n len = redisFormatCommand(&cmd,\"key:%08.3f str:%s\", value, \"hello\"); \\\n test_cond(strncmp(cmd,\"*2\\r\\n$12\\r\\nkey:0123.000\\r\\n$9\\r\\nstr:hello\\r\\n\",len) == 0 && \\\n len == 4+5+(12+2)+4+(9+2)); \\\n hi_free(cmd); \\\n} while(0)",
" INTEGER_WIDTH_TEST(\"d\", int);\n INTEGER_WIDTH_TEST(\"hhd\", char);\n INTEGER_WIDTH_TEST(\"hd\", short);\n INTEGER_WIDTH_TEST(\"ld\", long);\n INTEGER_WIDTH_TEST(\"lld\", long long);\n INTEGER_WIDTH_TEST(\"u\", unsigned int);\n INTEGER_WIDTH_TEST(\"hhu\", unsigned char);\n INTEGER_WIDTH_TEST(\"hu\", unsigned short);\n INTEGER_WIDTH_TEST(\"lu\", unsigned long);\n INTEGER_WIDTH_TEST(\"llu\", unsigned long long);\n FLOAT_WIDTH_TEST(float);\n FLOAT_WIDTH_TEST(double);",
" test(\"Format command with invalid printf format: \");\n len = redisFormatCommand(&cmd,\"key:%08p %b\",(void*)1234,\"foo\",(size_t)3);\n test_cond(len == -1);",
" const char *argv[3];\n argv[0] = \"SET\";\n argv[1] = \"foo\\0xxx\";\n argv[2] = \"bar\";\n size_t lens[3] = { 3, 7, 3 };\n int argc = 3;",
" test(\"Format command by passing argc/argv without lengths: \");\n len = redisFormatCommandArgv(&cmd,argc,argv,NULL);\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(3+2));\n hi_free(cmd);",
" test(\"Format command by passing argc/argv with lengths: \");\n len = redisFormatCommandArgv(&cmd,argc,argv,lens);\n test_cond(strncmp(cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$7\\r\\nfoo\\0xxx\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(7+2)+4+(3+2));\n hi_free(cmd);",
" hisds sds_cmd;",
" sds_cmd = NULL;\n test(\"Format command into hisds by passing argc/argv without lengths: \");\n len = redisFormatSdsCommandArgv(&sds_cmd,argc,argv,NULL);\n test_cond(strncmp(sds_cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$3\\r\\nfoo\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(3+2)+4+(3+2));\n hi_sdsfree(sds_cmd);",
" sds_cmd = NULL;\n test(\"Format command into hisds by passing argc/argv with lengths: \");\n len = redisFormatSdsCommandArgv(&sds_cmd,argc,argv,lens);\n test_cond(strncmp(sds_cmd,\"*3\\r\\n$3\\r\\nSET\\r\\n$7\\r\\nfoo\\0xxx\\r\\n$3\\r\\nbar\\r\\n\",len) == 0 &&\n len == 4+4+(3+2)+4+(7+2)+4+(3+2));\n hi_sdsfree(sds_cmd);\n}",
"static void test_append_formatted_commands(struct config config) {\n redisContext *c;\n redisReply *reply;\n char *cmd;\n int len;",
" c = do_connect(config);",
" test(\"Append format command: \");",
" len = redisFormatCommand(&cmd, \"SET foo bar\");",
" test_cond(redisAppendFormattedCommand(c, cmd, len) == REDIS_OK);",
" assert(redisGetReply(c, (void*)&reply) == REDIS_OK);",
" hi_free(cmd);\n freeReplyObject(reply);",
" disconnect(c, 0);\n}",
"static void test_reply_reader(void) {\n redisReader *reader;\n void *reply, *root;\n int ret;\n int i;",
" test(\"Error handling in reply parser: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader,(char*)\"@foo\\r\\n\",6);\n ret = redisReaderGetReply(reader,NULL);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Protocol error, got \\\"@\\\" as reply type byte\") == 0);\n redisReaderFree(reader);",
" /* when the reply already contains multiple items, they must be free'd\n * on an error. valgrind will bark when this doesn't happen. */\n test(\"Memory cleanup in reply parser: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader,(char*)\"*2\\r\\n\",4);\n redisReaderFeed(reader,(char*)\"$5\\r\\nhello\\r\\n\",11);\n redisReaderFeed(reader,(char*)\"@foo\\r\\n\",6);\n ret = redisReaderGetReply(reader,NULL);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Protocol error, got \\\"@\\\" as reply type byte\") == 0);\n redisReaderFree(reader);",
" reader = redisReaderCreate();\n test(\"Can handle arbitrarily nested multi-bulks: \");\n for (i = 0; i < 128; i++) {\n redisReaderFeed(reader,(char*)\"*1\\r\\n\", 4);\n }\n redisReaderFeed(reader,(char*)\"$6\\r\\nLOLWUT\\r\\n\",12);\n ret = redisReaderGetReply(reader,&reply);\n root = reply; /* Keep track of the root reply */\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_ARRAY &&\n ((redisReply*)reply)->elements == 1);",
" test(\"Can parse arbitrarily nested multi-bulks correctly: \");\n while(i--) {\n assert(reply != NULL && ((redisReply*)reply)->type == REDIS_REPLY_ARRAY);\n reply = ((redisReply*)reply)->element[0];\n }\n test_cond(((redisReply*)reply)->type == REDIS_REPLY_STRING &&\n !memcmp(((redisReply*)reply)->str, \"LOLWUT\", 6));\n freeReplyObject(root);\n redisReaderFree(reader);",
" test(\"Correctly parses LLONG_MAX: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \":9223372036854775807\\r\\n\",22);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_INTEGER &&\n ((redisReply*)reply)->integer == LLONG_MAX);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Set error when > LLONG_MAX: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \":9223372036854775808\\r\\n\",22);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Bad integer value\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Correctly parses LLONG_MIN: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \":-9223372036854775808\\r\\n\",23);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_INTEGER &&\n ((redisReply*)reply)->integer == LLONG_MIN);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Set error when < LLONG_MIN: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \":-9223372036854775809\\r\\n\",23);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Bad integer value\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Set error when array < -1: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \"*-2\\r\\n+asdf\\r\\n\",12);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Multi-bulk length out of range\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Set error when bulk < -1: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \"$-2\\r\\nasdf\\r\\n\",11);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Bulk string length out of range\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Can configure maximum multi-bulk elements: \");\n reader = redisReaderCreate();\n reader->maxelements = 1024;\n redisReaderFeed(reader, \"*1025\\r\\n\", 7);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr, \"Multi-bulk length out of range\") == 0);",
" freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Multi-bulk never overflows regardless of maxelements: \");\n size_t bad_mbulk_len = (SIZE_MAX / sizeof(void *)) + 3;\n char bad_mbulk_reply[100];\n snprintf(bad_mbulk_reply, sizeof(bad_mbulk_reply), \"*%llu\\r\\n+asdf\\r\\n\",\n (unsigned long long) bad_mbulk_len);",
" reader = redisReaderCreate();\n reader->maxelements = 0; /* Don't rely on default limit */\n redisReaderFeed(reader, bad_mbulk_reply, strlen(bad_mbulk_reply));\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR && strcasecmp(reader->errstr, \"Out of memory\") == 0);",
" freeReplyObject(reply);\n redisReaderFree(reader);",
"#if LLONG_MAX > SIZE_MAX\n test(\"Set error when array > SIZE_MAX: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \"*9223372036854775807\\r\\n+asdf\\r\\n\",29);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Multi-bulk length out of range\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" test(\"Set error when bulk > SIZE_MAX: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader, \"$9223372036854775807\\r\\nasdf\\r\\n\",28);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR &&\n strcasecmp(reader->errstr,\"Bulk string length out of range\") == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);\n#endif",
" test(\"Works with NULL functions for reply: \");\n reader = redisReaderCreate();\n reader->fn = NULL;\n redisReaderFeed(reader,(char*)\"+OK\\r\\n\",5);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS);\n redisReaderFree(reader);",
" test(\"Works when a single newline (\\\\r\\\\n) covers two calls to feed: \");\n reader = redisReaderCreate();\n reader->fn = NULL;\n redisReaderFeed(reader,(char*)\"+OK\\r\",4);\n ret = redisReaderGetReply(reader,&reply);\n assert(ret == REDIS_OK && reply == NULL);\n redisReaderFeed(reader,(char*)\"\\n\",1);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS);\n redisReaderFree(reader);",
" test(\"Don't reset state after protocol error: \");\n reader = redisReaderCreate();\n reader->fn = NULL;\n redisReaderFeed(reader,(char*)\"x\",1);\n ret = redisReaderGetReply(reader,&reply);\n assert(ret == REDIS_ERR);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_ERR && reply == NULL);\n redisReaderFree(reader);",
" /* Regression test for issue #45 on GitHub. */\n test(\"Don't do empty allocation for empty multi bulk: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader,(char*)\"*0\\r\\n\",4);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_ARRAY &&\n ((redisReply*)reply)->elements == 0);\n freeReplyObject(reply);\n redisReaderFree(reader);",
" /* RESP3 verbatim strings (GitHub issue #802) */\n test(\"Can parse RESP3 verbatim strings: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader,(char*)\"=10\\r\\ntxt:LOLWUT\\r\\n\",17);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_VERB &&\n !memcmp(((redisReply*)reply)->str,\"LOLWUT\", 6));\n freeReplyObject(reply);\n redisReaderFree(reader);",
" /* RESP3 push messages (Github issue #815) */\n test(\"Can parse RESP3 push messages: \");\n reader = redisReaderCreate();\n redisReaderFeed(reader,(char*)\">2\\r\\n$6\\r\\nLOLWUT\\r\\n:42\\r\\n\",21);\n ret = redisReaderGetReply(reader,&reply);\n test_cond(ret == REDIS_OK &&\n ((redisReply*)reply)->type == REDIS_REPLY_PUSH &&\n ((redisReply*)reply)->elements == 2 &&\n ((redisReply*)reply)->element[0]->type == REDIS_REPLY_STRING &&\n !memcmp(((redisReply*)reply)->element[0]->str,\"LOLWUT\",6) &&\n ((redisReply*)reply)->element[1]->type == REDIS_REPLY_INTEGER &&\n ((redisReply*)reply)->element[1]->integer == 42);\n freeReplyObject(reply);\n redisReaderFree(reader);\n}",
"static void test_free_null(void) {\n void *redisCtx = NULL;\n void *reply = NULL;",
" test(\"Don't fail when redisFree is passed a NULL value: \");\n redisFree(redisCtx);\n test_cond(redisCtx == NULL);",
" test(\"Don't fail when freeReplyObject is passed a NULL value: \");\n freeReplyObject(reply);\n test_cond(reply == NULL);\n}",
"static void *hi_malloc_fail(size_t size) {\n (void)size;\n return NULL;\n}",
"static void *hi_calloc_fail(size_t nmemb, size_t size) {\n (void)nmemb;\n (void)size;\n return NULL;\n}",
"static void *hi_realloc_fail(void *ptr, size_t size) {\n (void)ptr;\n (void)size;\n return NULL;\n}",
"static void test_allocator_injection(void) {\n hiredisAllocFuncs ha = {\n .mallocFn = hi_malloc_fail,\n .callocFn = hi_calloc_fail,\n .reallocFn = hi_realloc_fail,\n .strdupFn = strdup,\n .freeFn = free,\n };",
" // Override hiredis allocators\n hiredisSetAllocators(&ha);",
" test(\"redisContext uses injected allocators: \");\n redisContext *c = redisConnect(\"localhost\", 6379);\n test_cond(c == NULL);",
" test(\"redisReader uses injected allocators: \");\n redisReader *reader = redisReaderCreate();\n test_cond(reader == NULL);",
" // Return allocators to default\n hiredisResetAllocators();\n}",
"#define HIREDIS_BAD_DOMAIN \"idontexist-noreally.com\"\nstatic void test_blocking_connection_errors(void) {\n redisContext *c;\n struct addrinfo hints = {.ai_family = AF_INET};\n struct addrinfo *ai_tmp = NULL;",
" int rv = getaddrinfo(HIREDIS_BAD_DOMAIN, \"6379\", &hints, &ai_tmp);\n if (rv != 0) {\n // Address does *not* exist\n test(\"Returns error when host cannot be resolved: \");\n // First see if this domain name *actually* resolves to NXDOMAIN\n c = redisConnect(HIREDIS_BAD_DOMAIN, 6379);\n test_cond(\n c->err == REDIS_ERR_OTHER &&\n (strcmp(c->errstr, \"Name or service not known\") == 0 ||\n strcmp(c->errstr, \"Can't resolve: \" HIREDIS_BAD_DOMAIN) == 0 ||\n strcmp(c->errstr, \"Name does not resolve\") == 0 ||\n strcmp(c->errstr, \"nodename nor servname provided, or not known\") == 0 ||\n strcmp(c->errstr, \"No address associated with hostname\") == 0 ||\n strcmp(c->errstr, \"Temporary failure in name resolution\") == 0 ||\n strcmp(c->errstr, \"hostname nor servname provided, or not known\") == 0 ||\n strcmp(c->errstr, \"no address associated with name\") == 0 ||\n strcmp(c->errstr, \"No such host is known. \") == 0));\n redisFree(c);\n } else {\n printf(\"Skipping NXDOMAIN test. Found evil ISP!\\n\");\n freeaddrinfo(ai_tmp);\n }",
"#ifndef _WIN32\n test(\"Returns error when the port is not open: \");\n c = redisConnect((char*)\"localhost\", 1);\n test_cond(c->err == REDIS_ERR_IO &&\n strcmp(c->errstr,\"Connection refused\") == 0);\n redisFree(c);",
" test(\"Returns error when the unix_sock socket path doesn't accept connections: \");\n c = redisConnectUnix((char*)\"/tmp/idontexist.sock\");\n test_cond(c->err == REDIS_ERR_IO); /* Don't care about the message... */\n redisFree(c);\n#endif\n}",
"/* Test push handler */\nvoid push_handler(void *privdata, void *r) {\n struct pushCounters *pcounts = privdata;\n redisReply *reply = r, *payload;",
" assert(reply && reply->type == REDIS_REPLY_PUSH && reply->elements == 2);",
" payload = reply->element[1];\n if (payload->type == REDIS_REPLY_ARRAY) {\n payload = payload->element[0];\n }",
" if (payload->type == REDIS_REPLY_STRING) {\n pcounts->str++;\n } else if (payload->type == REDIS_REPLY_NIL) {\n pcounts->nil++;\n }",
" freeReplyObject(reply);\n}",
"/* Dummy function just to test setting a callback with redisOptions */\nvoid push_handler_async(redisAsyncContext *ac, void *reply) {\n (void)ac;\n (void)reply;\n}",
"static void test_resp3_push_handler(redisContext *c) {\n struct pushCounters pc = {0};\n redisPushFn *old = NULL;\n redisReply *reply;\n void *privdata;",
" /* Switch to RESP3 and turn on client tracking */\n send_hello(c, 3);\n send_client_tracking(c, \"ON\");\n privdata = c->privdata;\n c->privdata = &pc;",
" reply = redisCommand(c, \"GET key:0\");\n assert(reply != NULL);\n freeReplyObject(reply);",
" test(\"RESP3 PUSH messages are handled out of band by default: \");\n reply = redisCommand(c, \"SET key:0 val:0\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS);\n freeReplyObject(reply);",
" assert((reply = redisCommand(c, \"GET key:0\")) != NULL);\n freeReplyObject(reply);",
" old = redisSetPushCallback(c, push_handler);\n test(\"We can set a custom RESP3 PUSH handler: \");\n reply = redisCommand(c, \"SET key:0 val:0\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS && pc.str == 1);\n freeReplyObject(reply);",
" test(\"We properly handle a NIL invalidation payload: \");\n reply = redisCommand(c, \"FLUSHDB\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS && pc.nil == 1);\n freeReplyObject(reply);",
" /* Unset the push callback and generate an invalidate message making\n * sure it is not handled out of band. */\n test(\"With no handler, PUSH replies come in-band: \");\n redisSetPushCallback(c, NULL);\n assert((reply = redisCommand(c, \"GET key:0\")) != NULL);\n freeReplyObject(reply);\n assert((reply = redisCommand(c, \"SET key:0 invalid\")) != NULL);\n test_cond(reply->type == REDIS_REPLY_PUSH);\n freeReplyObject(reply);",
" test(\"With no PUSH handler, no replies are lost: \");\n assert(redisGetReply(c, (void**)&reply) == REDIS_OK);\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS);\n freeReplyObject(reply);",
" /* Return to the originally set PUSH handler */\n assert(old != NULL);\n redisSetPushCallback(c, old);",
" /* Switch back to RESP2 and disable tracking */\n c->privdata = privdata;\n send_client_tracking(c, \"OFF\");\n send_hello(c, 2);\n}",
"redisOptions get_redis_tcp_options(struct config config) {\n redisOptions options = {0};\n REDIS_OPTIONS_SET_TCP(&options, config.tcp.host, config.tcp.port);\n return options;\n}",
"static void test_resp3_push_options(struct config config) {\n redisAsyncContext *ac;\n redisContext *c;\n redisOptions options;",
" test(\"We set a default RESP3 handler for redisContext: \");\n options = get_redis_tcp_options(config);\n assert((c = redisConnectWithOptions(&options)) != NULL);\n test_cond(c->push_cb != NULL);\n redisFree(c);",
" test(\"We don't set a default RESP3 push handler for redisAsyncContext: \");\n options = get_redis_tcp_options(config);\n assert((ac = redisAsyncConnectWithOptions(&options)) != NULL);\n test_cond(ac->c.push_cb == NULL);\n redisAsyncFree(ac);",
" test(\"Our REDIS_OPT_NO_PUSH_AUTOFREE flag works: \");\n options = get_redis_tcp_options(config);\n options.options |= REDIS_OPT_NO_PUSH_AUTOFREE;\n assert((c = redisConnectWithOptions(&options)) != NULL);\n test_cond(c->push_cb == NULL);\n redisFree(c);",
" test(\"We can use redisOptions to set a custom PUSH handler for redisContext: \");\n options = get_redis_tcp_options(config);\n options.push_cb = push_handler;\n assert((c = redisConnectWithOptions(&options)) != NULL);\n test_cond(c->push_cb == push_handler);\n redisFree(c);",
" test(\"We can use redisOptions to set a custom PUSH handler for redisAsyncContext: \");\n options = get_redis_tcp_options(config);\n options.async_push_cb = push_handler_async;\n assert((ac = redisAsyncConnectWithOptions(&options)) != NULL);\n test_cond(ac->push_cb == push_handler_async);\n redisAsyncFree(ac);\n}",
"void free_privdata(void *privdata) {\n struct privdata *data = privdata;\n data->dtor_counter++;\n}",
"static void test_privdata_hooks(struct config config) {\n struct privdata data = {0};\n redisOptions options;\n redisContext *c;",
" test(\"We can use redisOptions to set privdata: \");\n options = get_redis_tcp_options(config);\n REDIS_OPTIONS_SET_PRIVDATA(&options, &data, free_privdata);\n assert((c = redisConnectWithOptions(&options)) != NULL);\n test_cond(c->privdata == &data);",
" test(\"Our privdata destructor fires when we free the context: \");\n redisFree(c);\n test_cond(data.dtor_counter == 1);\n}",
"static void test_blocking_connection(struct config config) {\n redisContext *c;\n redisReply *reply;\n int major;",
" c = do_connect(config);",
" test(\"Is able to deliver commands: \");\n reply = redisCommand(c,\"PING\");\n test_cond(reply->type == REDIS_REPLY_STATUS &&\n strcasecmp(reply->str,\"pong\") == 0)\n freeReplyObject(reply);",
" test(\"Is a able to send commands verbatim: \");\n reply = redisCommand(c,\"SET foo bar\");\n test_cond (reply->type == REDIS_REPLY_STATUS &&\n strcasecmp(reply->str,\"ok\") == 0)\n freeReplyObject(reply);",
" test(\"%%s String interpolation works: \");\n reply = redisCommand(c,\"SET %s %s\",\"foo\",\"hello world\");\n freeReplyObject(reply);\n reply = redisCommand(c,\"GET foo\");\n test_cond(reply->type == REDIS_REPLY_STRING &&\n strcmp(reply->str,\"hello world\") == 0);\n freeReplyObject(reply);",
" test(\"%%b String interpolation works: \");\n reply = redisCommand(c,\"SET %b %b\",\"foo\",(size_t)3,\"hello\\x00world\",(size_t)11);\n freeReplyObject(reply);\n reply = redisCommand(c,\"GET foo\");\n test_cond(reply->type == REDIS_REPLY_STRING &&\n memcmp(reply->str,\"hello\\x00world\",11) == 0)",
" test(\"Binary reply length is correct: \");\n test_cond(reply->len == 11)\n freeReplyObject(reply);",
" test(\"Can parse nil replies: \");\n reply = redisCommand(c,\"GET nokey\");\n test_cond(reply->type == REDIS_REPLY_NIL)\n freeReplyObject(reply);",
" /* test 7 */\n test(\"Can parse integer replies: \");\n reply = redisCommand(c,\"INCR mycounter\");\n test_cond(reply->type == REDIS_REPLY_INTEGER && reply->integer == 1)\n freeReplyObject(reply);",
" test(\"Can parse multi bulk replies: \");\n freeReplyObject(redisCommand(c,\"LPUSH mylist foo\"));\n freeReplyObject(redisCommand(c,\"LPUSH mylist bar\"));\n reply = redisCommand(c,\"LRANGE mylist 0 -1\");\n test_cond(reply->type == REDIS_REPLY_ARRAY &&\n reply->elements == 2 &&\n !memcmp(reply->element[0]->str,\"bar\",3) &&\n !memcmp(reply->element[1]->str,\"foo\",3))\n freeReplyObject(reply);",
" /* m/e with multi bulk reply *before* other reply.\n * specifically test ordering of reply items to parse. */\n test(\"Can handle nested multi bulk replies: \");\n freeReplyObject(redisCommand(c,\"MULTI\"));\n freeReplyObject(redisCommand(c,\"LRANGE mylist 0 -1\"));\n freeReplyObject(redisCommand(c,\"PING\"));\n reply = (redisCommand(c,\"EXEC\"));\n test_cond(reply->type == REDIS_REPLY_ARRAY &&\n reply->elements == 2 &&\n reply->element[0]->type == REDIS_REPLY_ARRAY &&\n reply->element[0]->elements == 2 &&\n !memcmp(reply->element[0]->element[0]->str,\"bar\",3) &&\n !memcmp(reply->element[0]->element[1]->str,\"foo\",3) &&\n reply->element[1]->type == REDIS_REPLY_STATUS &&\n strcasecmp(reply->element[1]->str,\"pong\") == 0);\n freeReplyObject(reply);",
" /* Make sure passing NULL to redisGetReply is safe */\n test(\"Can pass NULL to redisGetReply: \");\n assert(redisAppendCommand(c, \"PING\") == REDIS_OK);\n test_cond(redisGetReply(c, NULL) == REDIS_OK);",
" get_redis_version(c, &major, NULL);\n if (major >= 6) test_resp3_push_handler(c);\n test_resp3_push_options(config);",
" test_privdata_hooks(config);",
" disconnect(c, 0);\n}",
"/* Send DEBUG SLEEP 0 to detect if we have this command */\nstatic int detect_debug_sleep(redisContext *c) {\n int detected;\n redisReply *reply = redisCommand(c, \"DEBUG SLEEP 0\\r\\n\");",
" if (reply == NULL || c->err) {\n const char *cause = c->err ? c->errstr : \"(none)\";\n fprintf(stderr, \"Error testing for DEBUG SLEEP (Redis error: %s), exiting\\n\", cause);\n exit(-1);\n }",
" detected = reply->type == REDIS_REPLY_STATUS;\n freeReplyObject(reply);",
" return detected;\n}",
"static void test_blocking_connection_timeouts(struct config config) {\n redisContext *c;\n redisReply *reply;\n ssize_t s;\n const char *sleep_cmd = \"DEBUG SLEEP 3\\r\\n\";\n struct timeval tv;",
" c = do_connect(config);\n test(\"Successfully completes a command when the timeout is not exceeded: \");\n reply = redisCommand(c,\"SET foo fast\");\n freeReplyObject(reply);\n tv.tv_sec = 0;\n tv.tv_usec = 10000;\n redisSetTimeout(c, tv);\n reply = redisCommand(c, \"GET foo\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STRING && memcmp(reply->str, \"fast\", 4) == 0);\n freeReplyObject(reply);\n disconnect(c, 0);",
" c = do_connect(config);\n test(\"Does not return a reply when the command times out: \");\n if (detect_debug_sleep(c)) {\n redisAppendFormattedCommand(c, sleep_cmd, strlen(sleep_cmd));\n s = c->funcs->write(c);\n tv.tv_sec = 0;\n tv.tv_usec = 10000;\n redisSetTimeout(c, tv);\n reply = redisCommand(c, \"GET foo\");\n#ifndef _WIN32\n test_cond(s > 0 && reply == NULL && c->err == REDIS_ERR_IO &&\n strcmp(c->errstr, \"Resource temporarily unavailable\") == 0);\n#else\n test_cond(s > 0 && reply == NULL && c->err == REDIS_ERR_TIMEOUT &&\n strcmp(c->errstr, \"recv timeout\") == 0);\n#endif\n freeReplyObject(reply);\n } else {\n test_skipped();\n }",
" test(\"Reconnect properly reconnects after a timeout: \");\n do_reconnect(c, config);\n reply = redisCommand(c, \"PING\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS && strcmp(reply->str, \"PONG\") == 0);\n freeReplyObject(reply);",
" test(\"Reconnect properly uses owned parameters: \");\n config.tcp.host = \"foo\";\n config.unix_sock.path = \"foo\";\n do_reconnect(c, config);\n reply = redisCommand(c, \"PING\");\n test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS && strcmp(reply->str, \"PONG\") == 0);\n freeReplyObject(reply);",
" disconnect(c, 0);\n}",
"static void test_blocking_io_errors(struct config config) {\n redisContext *c;\n redisReply *reply;\n void *_reply;\n int major, minor;",
" /* Connect to target given by config. */\n c = do_connect(config);\n get_redis_version(c, &major, &minor);",
" test(\"Returns I/O error when the connection is lost: \");\n reply = redisCommand(c,\"QUIT\");\n if (major > 2 || (major == 2 && minor > 0)) {\n /* > 2.0 returns OK on QUIT and read() should be issued once more\n * to know the descriptor is at EOF. */\n test_cond(strcasecmp(reply->str,\"OK\") == 0 &&\n redisGetReply(c,&_reply) == REDIS_ERR);\n freeReplyObject(reply);\n } else {\n test_cond(reply == NULL);\n }",
"#ifndef _WIN32\n /* On 2.0, QUIT will cause the connection to be closed immediately and\n * the read(2) for the reply on QUIT will set the error to EOF.\n * On >2.0, QUIT will return with OK and another read(2) needed to be\n * issued to find out the socket was closed by the server. In both\n * conditions, the error will be set to EOF. */\n assert(c->err == REDIS_ERR_EOF &&\n strcmp(c->errstr,\"Server closed the connection\") == 0);\n#endif\n redisFree(c);",
" c = do_connect(config);\n test(\"Returns I/O error on socket timeout: \");\n struct timeval tv = { 0, 1000 };\n assert(redisSetTimeout(c,tv) == REDIS_OK);\n int respcode = redisGetReply(c,&_reply);\n#ifndef _WIN32\n test_cond(respcode == REDIS_ERR && c->err == REDIS_ERR_IO && errno == EAGAIN);\n#else\n test_cond(respcode == REDIS_ERR && c->err == REDIS_ERR_TIMEOUT);\n#endif\n redisFree(c);\n}",
"static void test_invalid_timeout_errors(struct config config) {\n redisContext *c;",
" test(\"Set error when an invalid timeout usec value is given to redisConnectWithTimeout: \");",
" config.tcp.timeout.tv_sec = 0;\n config.tcp.timeout.tv_usec = 10000001;",
" c = redisConnectWithTimeout(config.tcp.host, config.tcp.port, config.tcp.timeout);",
" test_cond(c->err == REDIS_ERR_IO && strcmp(c->errstr, \"Invalid timeout specified\") == 0);\n redisFree(c);",
" test(\"Set error when an invalid timeout sec value is given to redisConnectWithTimeout: \");",
" config.tcp.timeout.tv_sec = (((LONG_MAX) - 999) / 1000) + 1;\n config.tcp.timeout.tv_usec = 0;",
" c = redisConnectWithTimeout(config.tcp.host, config.tcp.port, config.tcp.timeout);",
" test_cond(c->err == REDIS_ERR_IO && strcmp(c->errstr, \"Invalid timeout specified\") == 0);\n redisFree(c);\n}",
"/* Wrap malloc to abort on failure so OOM checks don't make the test logic\n * harder to follow. */\nvoid *hi_malloc_safe(size_t size) {\n void *ptr = hi_malloc(size);\n if (ptr == NULL) {\n fprintf(stderr, \"Error: Out of memory\\n\");\n exit(-1);\n }",
" return ptr;\n}",
"static void test_throughput(struct config config) {\n redisContext *c = do_connect(config);\n redisReply **replies;\n int i, num;\n long long t1, t2;",
" test(\"Throughput:\\n\");\n for (i = 0; i < 500; i++)\n freeReplyObject(redisCommand(c,\"LPUSH mylist foo\"));",
" num = 1000;\n replies = hi_malloc_safe(sizeof(redisReply*)*num);\n t1 = usec();\n for (i = 0; i < num; i++) {\n replies[i] = redisCommand(c,\"PING\");\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_STATUS);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx PING: %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" replies = hi_malloc_safe(sizeof(redisReply*)*num);\n t1 = usec();\n for (i = 0; i < num; i++) {\n replies[i] = redisCommand(c,\"LRANGE mylist 0 499\");\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_ARRAY);\n assert(replies[i] != NULL && replies[i]->elements == 500);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx LRANGE with 500 elements: %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" replies = hi_malloc_safe(sizeof(redisReply*)*num);\n t1 = usec();\n for (i = 0; i < num; i++) {\n replies[i] = redisCommand(c, \"INCRBY incrkey %d\", 1000000);\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_INTEGER);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx INCRBY: %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" num = 10000;\n replies = hi_malloc_safe(sizeof(redisReply*)*num);\n for (i = 0; i < num; i++)\n redisAppendCommand(c,\"PING\");\n t1 = usec();\n for (i = 0; i < num; i++) {\n assert(redisGetReply(c, (void*)&replies[i]) == REDIS_OK);\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_STATUS);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx PING (pipelined): %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" replies = hi_malloc_safe(sizeof(redisReply*)*num);\n for (i = 0; i < num; i++)\n redisAppendCommand(c,\"LRANGE mylist 0 499\");\n t1 = usec();\n for (i = 0; i < num; i++) {\n assert(redisGetReply(c, (void*)&replies[i]) == REDIS_OK);\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_ARRAY);\n assert(replies[i] != NULL && replies[i]->elements == 500);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx LRANGE with 500 elements (pipelined): %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" replies = hi_malloc_safe(sizeof(redisReply*)*num);\n for (i = 0; i < num; i++)\n redisAppendCommand(c,\"INCRBY incrkey %d\", 1000000);\n t1 = usec();\n for (i = 0; i < num; i++) {\n assert(redisGetReply(c, (void*)&replies[i]) == REDIS_OK);\n assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_INTEGER);\n }\n t2 = usec();\n for (i = 0; i < num; i++) freeReplyObject(replies[i]);\n hi_free(replies);\n printf(\"\\t(%dx INCRBY (pipelined): %.3fs)\\n\", num, (t2-t1)/1000000.0);",
" disconnect(c, 0);\n}",
"// static long __test_callback_flags = 0;\n// static void __test_callback(redisContext *c, void *privdata) {\n// ((void)c);\n// /* Shift to detect execution order */\n// __test_callback_flags <<= 8;\n// __test_callback_flags |= (long)privdata;\n// }\n//\n// static void __test_reply_callback(redisContext *c, redisReply *reply, void *privdata) {\n// ((void)c);\n// /* Shift to detect execution order */\n// __test_callback_flags <<= 8;\n// __test_callback_flags |= (long)privdata;\n// if (reply) freeReplyObject(reply);\n// }\n//\n// static redisContext *__connect_nonblock() {\n// /* Reset callback flags */\n// __test_callback_flags = 0;\n// return redisConnectNonBlock(\"127.0.0.1\", port, NULL);\n// }\n//\n// static void test_nonblocking_connection() {\n// redisContext *c;\n// int wdone = 0;\n//\n// test(\"Calls command callback when command is issued: \");\n// c = __connect_nonblock();\n// redisSetCommandCallback(c,__test_callback,(void*)1);\n// redisCommand(c,\"PING\");\n// test_cond(__test_callback_flags == 1);\n// redisFree(c);\n//\n// test(\"Calls disconnect callback on redisDisconnect: \");\n// c = __connect_nonblock();\n// redisSetDisconnectCallback(c,__test_callback,(void*)2);\n// redisDisconnect(c);\n// test_cond(__test_callback_flags == 2);\n// redisFree(c);\n//\n// test(\"Calls disconnect callback and free callback on redisFree: \");\n// c = __connect_nonblock();\n// redisSetDisconnectCallback(c,__test_callback,(void*)2);\n// redisSetFreeCallback(c,__test_callback,(void*)4);\n// redisFree(c);\n// test_cond(__test_callback_flags == ((2 << 8) | 4));\n//\n// test(\"redisBufferWrite against empty write buffer: \");\n// c = __connect_nonblock();\n// test_cond(redisBufferWrite(c,&wdone) == REDIS_OK && wdone == 1);\n// redisFree(c);\n//\n// test(\"redisBufferWrite against not yet connected fd: \");\n// c = __connect_nonblock();\n// redisCommand(c,\"PING\");\n// test_cond(redisBufferWrite(c,NULL) == REDIS_ERR &&\n// strncmp(c->error,\"write:\",6) == 0);\n// redisFree(c);\n//\n// test(\"redisBufferWrite against closed fd: \");\n// c = __connect_nonblock();\n// redisCommand(c,\"PING\");\n// redisDisconnect(c);\n// test_cond(redisBufferWrite(c,NULL) == REDIS_ERR &&\n// strncmp(c->error,\"write:\",6) == 0);\n// redisFree(c);\n//\n// test(\"Process callbacks in the right sequence: \");\n// c = __connect_nonblock();\n// redisCommandWithCallback(c,__test_reply_callback,(void*)1,\"PING\");\n// redisCommandWithCallback(c,__test_reply_callback,(void*)2,\"PING\");\n// redisCommandWithCallback(c,__test_reply_callback,(void*)3,\"PING\");\n//\n// /* Write output buffer */\n// wdone = 0;\n// while(!wdone) {\n// usleep(500);\n// redisBufferWrite(c,&wdone);\n// }\n//\n// /* Read until at least one callback is executed (the 3 replies will\n// * arrive in a single packet, causing all callbacks to be executed in\n// * a single pass). */\n// while(__test_callback_flags == 0) {\n// assert(redisBufferRead(c) == REDIS_OK);\n// redisProcessCallbacks(c);\n// }\n// test_cond(__test_callback_flags == 0x010203);\n// redisFree(c);\n//\n// test(\"redisDisconnect executes pending callbacks with NULL reply: \");\n// c = __connect_nonblock();\n// redisSetDisconnectCallback(c,__test_callback,(void*)1);\n// redisCommandWithCallback(c,__test_reply_callback,(void*)2,\"PING\");\n// redisDisconnect(c);\n// test_cond(__test_callback_flags == 0x0201);\n// redisFree(c);\n// }",
"int main(int argc, char **argv) {\n struct config cfg = {\n .tcp = {\n .host = \"127.0.0.1\",\n .port = 6379\n },\n .unix_sock = {\n .path = \"/tmp/redis.sock\"\n }\n };\n int throughput = 1;\n int test_inherit_fd = 1;\n int skips_as_fails = 0;\n int test_unix_socket;",
" /* Parse command line options. */\n argv++; argc--;\n while (argc) {\n if (argc >= 2 && !strcmp(argv[0],\"-h\")) {\n argv++; argc--;\n cfg.tcp.host = argv[0];\n } else if (argc >= 2 && !strcmp(argv[0],\"-p\")) {\n argv++; argc--;\n cfg.tcp.port = atoi(argv[0]);\n } else if (argc >= 2 && !strcmp(argv[0],\"-s\")) {\n argv++; argc--;\n cfg.unix_sock.path = argv[0];\n } else if (argc >= 1 && !strcmp(argv[0],\"--skip-throughput\")) {\n throughput = 0;\n } else if (argc >= 1 && !strcmp(argv[0],\"--skip-inherit-fd\")) {\n test_inherit_fd = 0;\n } else if (argc >= 1 && !strcmp(argv[0],\"--skips-as-fails\")) {\n skips_as_fails = 1;\n#ifdef HIREDIS_TEST_SSL\n } else if (argc >= 2 && !strcmp(argv[0],\"--ssl-port\")) {\n argv++; argc--;\n cfg.ssl.port = atoi(argv[0]);\n } else if (argc >= 2 && !strcmp(argv[0],\"--ssl-host\")) {\n argv++; argc--;\n cfg.ssl.host = argv[0];\n } else if (argc >= 2 && !strcmp(argv[0],\"--ssl-ca-cert\")) {\n argv++; argc--;\n cfg.ssl.ca_cert = argv[0];\n } else if (argc >= 2 && !strcmp(argv[0],\"--ssl-cert\")) {\n argv++; argc--;\n cfg.ssl.cert = argv[0];\n } else if (argc >= 2 && !strcmp(argv[0],\"--ssl-key\")) {\n argv++; argc--;\n cfg.ssl.key = argv[0];\n#endif\n } else {\n fprintf(stderr, \"Invalid argument: %s\\n\", argv[0]);\n exit(1);\n }\n argv++; argc--;\n }",
"#ifndef _WIN32\n /* Ignore broken pipe signal (for I/O error tests). */\n signal(SIGPIPE, SIG_IGN);",
" test_unix_socket = access(cfg.unix_sock.path, F_OK) == 0;",
"#else\n /* Unix sockets don't exist in Windows */\n test_unix_socket = 0;\n#endif",
" test_allocator_injection();",
" test_format_commands();\n test_reply_reader();\n test_blocking_connection_errors();\n test_free_null();",
" printf(\"\\nTesting against TCP connection (%s:%d):\\n\", cfg.tcp.host, cfg.tcp.port);\n cfg.type = CONN_TCP;\n test_blocking_connection(cfg);\n test_blocking_connection_timeouts(cfg);\n test_blocking_io_errors(cfg);\n test_invalid_timeout_errors(cfg);\n test_append_formatted_commands(cfg);\n if (throughput) test_throughput(cfg);",
" printf(\"\\nTesting against Unix socket connection (%s): \", cfg.unix_sock.path);\n if (test_unix_socket) {\n printf(\"\\n\");\n cfg.type = CONN_UNIX;\n test_blocking_connection(cfg);\n test_blocking_connection_timeouts(cfg);\n test_blocking_io_errors(cfg);\n if (throughput) test_throughput(cfg);\n } else {\n test_skipped();\n }",
"#ifdef HIREDIS_TEST_SSL\n if (cfg.ssl.port && cfg.ssl.host) {",
" redisInitOpenSSL();\n _ssl_ctx = redisCreateSSLContext(cfg.ssl.ca_cert, NULL, cfg.ssl.cert, cfg.ssl.key, NULL, NULL);\n assert(_ssl_ctx != NULL);",
" printf(\"\\nTesting against SSL connection (%s:%d):\\n\", cfg.ssl.host, cfg.ssl.port);\n cfg.type = CONN_SSL;",
" test_blocking_connection(cfg);\n test_blocking_connection_timeouts(cfg);\n test_blocking_io_errors(cfg);\n test_invalid_timeout_errors(cfg);\n test_append_formatted_commands(cfg);\n if (throughput) test_throughput(cfg);",
" redisFreeSSLContext(_ssl_ctx);\n _ssl_ctx = NULL;\n }\n#endif",
" if (test_inherit_fd) {\n printf(\"\\nTesting against inherited fd (%s): \", cfg.unix_sock.path);\n if (test_unix_socket) {\n printf(\"\\n\");\n cfg.type = CONN_FD;\n test_blocking_connection(cfg);\n } else {\n test_skipped();\n }\n }",
" if (fails || (skips_as_fails && skips)) {\n printf(\"*** %d TESTS FAILED ***\\n\", fails);\n if (skips) {\n printf(\"*** %d TESTS SKIPPED ***\\n\", skips);\n }\n return 1;\n }",
" printf(\"ALL TESTS PASSED (%d skipped)\\n\", skips);\n return 0;\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [176, 497], "buggy_code_start_loc": [176, 497], "filenames": ["deps/hiredis/hiredis.c", "deps/hiredis/test.c"], "fixing_code_end_loc": [178, 512], "fixing_code_start_loc": [177, 498], "message": "Redis is an open source, in-memory database that persists on disk. The redis-cli command line tool and redis-sentinel service may be vulnerable to integer overflow when parsing specially crafted large multi-bulk network replies. This is a result of a vulnerability in the underlying hiredis library which does not perform an overflow check before calling the calloc() heap allocation function. This issue only impacts systems with heap allocators that do not perform their own overflow checks. Most modern systems do and are therefore not likely to be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator which is also not vulnerable. The problem is fixed in Redis versions 6.2.6, 6.0.16 and 5.0.14.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "D5D64A76-B253-4A64-8AA2-DD8815CB3CF8", "versionEndExcluding": "5.0.14", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "5.0.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "02DF8086-645E-4D42-93D3-A4B11D289C7C", "versionEndExcluding": "6.0.16", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "6.0.0", "vulnerable": true}, {"criteria": "cpe:2.3:a:redis:redis:*:*:*:*:*:*:*:*", "matchCriteriaId": "4686800E-16BA-42CE-B691-011D1D5D0CC2", "versionEndExcluding": "6.2.6", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": "6.2.0", "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:*", "matchCriteriaId": "07B237A9-69A3-4A9C-9DA0-4E06BD37AE73", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:*", "matchCriteriaId": "FA6FEEC2-9F11-4643-8827-749718254FED", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*", "matchCriteriaId": "E460AA51-FCDA-46B9-AE97-E6676AA5E194", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*", "matchCriteriaId": "A930E247-0B43-43CB-98FF-6CE7B8189835", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*", "matchCriteriaId": "80E516C0-98A4-4ADE-B69F-66A772E2BAAA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:netapp:management_services_for_element_software:-:*:*:*:*:*:*:*", "matchCriteriaId": "86B51137-28D9-41F2-AFA2-3CC22B4954D1", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:netapp:management_services_for_netapp_hci:-:*:*:*:*:*:*:*", "matchCriteriaId": "4455CF3A-CC91-4BE4-A7AB-929AC82E34F5", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:4.3:*:*:*:*:*:*:*", "matchCriteriaId": "CBE1A019-7BB6-4226-8AC4-9D6927ADAEFA", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:4.4:*:*:*:*:*:*:*", "matchCriteriaId": "B98BAEB2-A540-4E8A-A946-C4331B913AFD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:oracle:communications_operations_monitor:5.0:*:*:*:*:*:*:*", "matchCriteriaId": "B8FBE260-E306-4215-80C0-D2D27CA43E0F", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Redis is an open source, in-memory database that persists on disk. The redis-cli command line tool and redis-sentinel service may be vulnerable to integer overflow when parsing specially crafted large multi-bulk network replies. This is a result of a vulnerability in the underlying hiredis library which does not perform an overflow check before calling the calloc() heap allocation function. This issue only impacts systems with heap allocators that do not perform their own overflow checks. Most modern systems do and are therefore not likely to be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator which is also not vulnerable. The problem is fixed in Redis versions 6.2.6, 6.0.16 and 5.0.14."}, {"lang": "es", "value": "Redis es una base de datos en memoria de c\u00f3digo abierto que persiste en el disco. La herramienta de l\u00ednea de comandos redis-cli y el servicio redis-sentinel pueden ser vulnerables a un desbordamiento de enteros cuando analizan respuestas de red de gran tama\u00f1o especialmente dise\u00f1adas. Esto es resultado de una vulnerabilidad en la biblioteca hiredis subyacente que no lleva a cabo una comprobaci\u00f3n de desbordamiento antes de llamar a la funci\u00f3n de asignaci\u00f3n de pila calloc(). Este problema s\u00f3lo afecta a los sistemas con asignadores de pila que no llevan a cabo sus propias comprobaciones de desbordamiento. La mayor\u00eda de los sistemas modernos lo hacen y, por lo tanto, no es probable que est\u00e9n afectados. Adem\u00e1s, por defecto redis-sentinel usa el asignador jemalloc que tampoco es vulnerable. El problema se ha corregido en las versiones de Redis 6.2.6, 6.0.16 y 5.0.14"}], "evaluatorComment": null, "id": "CVE-2021-32762", "lastModified": "2022-10-06T16:53:25.217", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "HIGH", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "COMPLETE", "baseScore": 9.0, "confidentialityImpact": "COMPLETE", "integrityImpact": "COMPLETE", "vectorString": "AV:N/AC:L/Au:S/C:C/I:C/A:C", "version": "2.0"}, "exploitabilityScore": 8.0, "impactScore": 10.0, "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": 8.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 7.5, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.6, "impactScore": 5.9, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2021-10-04T18:15:09.043", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/redis/redis/commit/0215324a66af949be39b34be2d55143232c1cb71"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/redis/redis/security/advisories/GHSA-833w-8v3m-8wwr"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/HTYQ5ZF37HNGTZWVNJD3VXP7I6MEEF42/"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/VL5KXFN3ATM7IIM7Q4O4PWTSRGZ5744Z/"}, {"source": "security-advisories@github.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WR5WKJWXD4D6S3DJCZ56V74ESLTDQRAB/"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/202209-17"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://security.netapp.com/advisory/ntap-20211104-0003/"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2021/dsa-5001"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://www.oracle.com/security-alerts/cpuapr2022.html"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-190"}, {"lang": "en", "value": "CWE-680"}], "source": "security-advisories@github.com", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-190"}], "source": "nvd@nist.gov", "type": "Secondary"}]}, "github_commit_url": "https://github.com/redis/redis/commit/0215324a66af949be39b34be2d55143232c1cb71"}, "type": "CWE-190"}
| 218
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\n require_once \"../configuration.php\";\n require_once \"../includes/class.inc.php\";\n newClass();\n //Preset variables\n /**\n * Is register succeeded?\n * @var bool\n */\n $register = False;\n /**\n * Is register username or mail already in use?\n * @var bool\n */\n $in_use = False;\n //Checks if variables are set\n if(isset($_POST[\"U\"])&&isset($_POST[\"M\"])&&isset($_POST[\"P\"])&&isset($_POST[\"PR\"])){\n //Checks if both passwords are the same\n if($_POST[\"P\"]==$_POST[\"PR\"]){\n //Checks if the mailadress is valid\n if(preg_match('/^[^\\x00-\\x20()<>@,;:\\\\\".[\\]\\x7f-\\xff]+(?:\\.[^\\x00-\\x20()<>@,;:\\\\\".[\\]\\x7f-\\xff]+)*\\@[^\\x00-\\x20()<>@,;:\\\\\".[\\]\\x7f-\\xff]+(?:\\.[^\\x00-\\x20()<>@,;:\\\\\".[\\]\\x7f-\\xff]+)+$/i', $_POST[\"M\"])){\n //Checks if the username is valid\n if(preg_match('/^[a-z0-9A-Z.]{3,15}$/',$_POST[\"U\"])){\n //Checks if the password is valid\n if(preg_match('/^[a-z0-9A-Z.:,;]{8,25}$/',$_POST[\"P\"])){\n $register = True;\n $sql = \"SELECT * FROM User\";",
" $db_erg = mysqli_query($U->db_link, $sql);\n while ($row = mysqli_fetch_array($db_erg, MYSQLI_ASSOC))",
" {\n //Checks if username or mail are in use\n if(strtolower($row[\"Username\"]) == strtolower($_POST[\"U\"])||strtolower($row[\"Mail\"])==strtolower($_POST[\"M\"])){\n $register = False;\n $in_use = True;\n }\n }\n }else{\n echo str_replace(\"%a\",$U->getLang(\"login.password\"),$U->getLang(\"login.invalid\"));\n }\n }else{\n echo str_replace(\"%a\",$U->getLang(\"login.username\"),$U->getLang(\"login.invalid\"));\n }\n }else{\n echo str_replace(\"%a\",$U->getLang(\"login.mail\"),$U->getLang(\"login.invalid\"));\n }\n }else{\n echo $U->getLang(\"login.fail_same_password\");\n }\n }else{\n echo $U->getLang(\"login.fillout\");\n }\n //Checks if register is cloded\n if($U->getSetting(\"login.register_open\")==\"0\" || $U->getSetting(\"login.login_open\") == \"0\"){\n echo $U->getLang(\"register.closed\");\n $register = False;\n }\n if($register){\n //Register succeeded:\n //Register user",
" $sql = 'INSERT INTO User (Username, Mail, Password, Type) VALUES ('.\"'\".$_POST[\"U\"].\"'\".','.\"'\".$_POST[\"M\"].\"'\".','.\"'\".password_hash($_POST[\"P\"],PASSWORD_DEFAULT).\"'\".',0);';\n if($db_erg = mysqli_query($U->db_link, $sql)){",
" //Database register is succeeded\n echo $U->getLang(\"register.succeed\");\n header(\"Location: \".$USOC[\"DOMAIN\"]);\n }else{\n //Database register is failed\n echo mysqli_error($U->db_link);\n }\n }\n if($in_use){\n //Username or mail already in use:\n echo $U->getLang(\"register.in_use\");\n }\n?>"
] |
[
1,
0,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [62], "buggy_code_start_loc": [28], "filenames": ["login/register.php"], "fixing_code_end_loc": [62], "fixing_code_start_loc": [28], "message": "USOC is an open source CMS with a focus on simplicity. In affected versions USOC allows for SQL injection via register.php. In particular usernames, email addresses, and passwords provided by the user were not sanitized and were used directly to construct a sql statement. Users are advised to upgrade as soon as possible. There are not workarounds for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:useful_simple_open-source_cms_project:useful_simple_open-source_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "2DBB6ACF-B401-4A14-A2F3-2E0EB6DE5852", "versionEndExcluding": "pb2.4bfx2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "USOC is an open source CMS with a focus on simplicity. In affected versions USOC allows for SQL injection via register.php. In particular usernames, email addresses, and passwords provided by the user were not sanitized and were used directly to construct a sql statement. Users are advised to upgrade as soon as possible. There are not workarounds for this issue."}, {"lang": "es", "value": "USOC es un CMS de c\u00f3digo abierto centrado en la simplicidad. En las versiones afectadas, USOC permite la inyecci\u00f3n SQL por medio del archivo register.php. En particular, los nombres de usuario, las direcciones de correo electr\u00f3nico y las contrase\u00f1as proporcionadas por el usuario no estaban saneadas y eran usadas directamente para construir una sentencia sql. Se aconseja a usuarios que actualicen lo antes posible. No se presentan medidas de mitigaci\u00f3n para este problema"}], "evaluatorComment": null, "id": "CVE-2022-21643", "lastModified": "2022-01-21T14:24:44.283", "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": null, "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"}, {"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 10.0, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 6.0, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-01-04T20:15:07.797", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Aaron-Junker/USOC/commit/21e8bfd7a9ab0b7f9344a7a3a7c32a7cdd5a0b69"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Aaron-Junker/USOC/security/advisories/GHSA-fjp4-phjh-jgmc"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-89"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Aaron-Junker/USOC/commit/21e8bfd7a9ab0b7f9344a7a3a7c32a7cdd5a0b69"}, "type": "CWE-89"}
| 219
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"<?php\n require_once \"../configuration.php\";\n require_once \"../includes/class.inc.php\";\n newClass();\n //Preset variables\n /**\n * Is register succeeded?\n * @var bool\n */\n $register = False;\n /**\n * Is register username or mail already in use?\n * @var bool\n */\n $in_use = False;\n //Checks if variables are set\n if(isset($_POST[\"U\"])&&isset($_POST[\"M\"])&&isset($_POST[\"P\"])&&isset($_POST[\"PR\"])){\n //Checks if both passwords are the same\n if($_POST[\"P\"]==$_POST[\"PR\"]){\n //Checks if the mailadress is valid\n if(preg_match('/^[^\\x00-\\x20()<>@,;:\\\\\".[\\]\\x7f-\\xff]+(?:\\.[^\\x00-\\x20()<>@,;:\\\\\".[\\]\\x7f-\\xff]+)*\\@[^\\x00-\\x20()<>@,;:\\\\\".[\\]\\x7f-\\xff]+(?:\\.[^\\x00-\\x20()<>@,;:\\\\\".[\\]\\x7f-\\xff]+)+$/i', $_POST[\"M\"])){\n //Checks if the username is valid\n if(preg_match('/^[a-z0-9A-Z.]{3,15}$/',$_POST[\"U\"])){\n //Checks if the password is valid\n if(preg_match('/^[a-z0-9A-Z.:,;]{8,25}$/',$_POST[\"P\"])){\n $register = True;\n $sql = \"SELECT * FROM User\";",
" $dbRes = mysqli_query($U->db_link, $sql);\n while ($row = mysqli_fetch_array($dbRes, MYSQLI_ASSOC))",
" {\n //Checks if username or mail are in use\n if(strtolower($row[\"Username\"]) == strtolower($_POST[\"U\"])||strtolower($row[\"Mail\"])==strtolower($_POST[\"M\"])){\n $register = False;\n $in_use = True;\n }\n }\n }else{\n echo str_replace(\"%a\",$U->getLang(\"login.password\"),$U->getLang(\"login.invalid\"));\n }\n }else{\n echo str_replace(\"%a\",$U->getLang(\"login.username\"),$U->getLang(\"login.invalid\"));\n }\n }else{\n echo str_replace(\"%a\",$U->getLang(\"login.mail\"),$U->getLang(\"login.invalid\"));\n }\n }else{\n echo $U->getLang(\"login.fail_same_password\");\n }\n }else{\n echo $U->getLang(\"login.fillout\");\n }\n //Checks if register is cloded\n if($U->getSetting(\"login.register_open\")==\"0\" || $U->getSetting(\"login.login_open\") == \"0\"){\n echo $U->getLang(\"register.closed\");\n $register = False;\n }\n if($register){\n //Register succeeded:\n //Register user",
" $sql = 'INSERT INTO User (Username, Mail, Password, Type) VALUES ('.\"'\".mysqli::real_escape_string($_POST[\"U\"]).\"'\".','.\"'\".mysqli::real_escape_string($_POST[\"M\"]).\"'\".','.\"'\".password_hash(mysqli::real_escape_string($_POST[\"P\"]),PASSWORD_DEFAULT).\"'\".','.$USOC[\"userRights\"][\"AfterRegistration\"].');';\n if($dbRes = mysqli_query($U->db_link, $sql)){",
" //Database register is succeeded\n echo $U->getLang(\"register.succeed\");\n header(\"Location: \".$USOC[\"DOMAIN\"]);\n }else{\n //Database register is failed\n echo mysqli_error($U->db_link);\n }\n }\n if($in_use){\n //Username or mail already in use:\n echo $U->getLang(\"register.in_use\");\n }\n?>"
] |
[
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [62], "buggy_code_start_loc": [28], "filenames": ["login/register.php"], "fixing_code_end_loc": [62], "fixing_code_start_loc": [28], "message": "USOC is an open source CMS with a focus on simplicity. In affected versions USOC allows for SQL injection via register.php. In particular usernames, email addresses, and passwords provided by the user were not sanitized and were used directly to construct a sql statement. Users are advised to upgrade as soon as possible. There are not workarounds for this issue.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:useful_simple_open-source_cms_project:useful_simple_open-source_cms:*:*:*:*:*:*:*:*", "matchCriteriaId": "2DBB6ACF-B401-4A14-A2F3-2E0EB6DE5852", "versionEndExcluding": "pb2.4bfx2", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "USOC is an open source CMS with a focus on simplicity. In affected versions USOC allows for SQL injection via register.php. In particular usernames, email addresses, and passwords provided by the user were not sanitized and were used directly to construct a sql statement. Users are advised to upgrade as soon as possible. There are not workarounds for this issue."}, {"lang": "es", "value": "USOC es un CMS de c\u00f3digo abierto centrado en la simplicidad. En las versiones afectadas, USOC permite la inyecci\u00f3n SQL por medio del archivo register.php. En particular, los nombres de usuario, las direcciones de correo electr\u00f3nico y las contrase\u00f1as proporcionadas por el usuario no estaban saneadas y eran usadas directamente para construir una sentencia sql. Se aconseja a usuarios que actualicen lo antes posible. No se presentan medidas de mitigaci\u00f3n para este problema"}], "evaluatorComment": null, "id": "CVE-2022-21643", "lastModified": "2022-01-21T14:24:44.283", "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": null, "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"}, {"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 10.0, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 6.0, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2022-01-04T20:15:07.797", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Aaron-Junker/USOC/commit/21e8bfd7a9ab0b7f9344a7a3a7c32a7cdd5a0b69"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Aaron-Junker/USOC/security/advisories/GHSA-fjp4-phjh-jgmc"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-89"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-89"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Aaron-Junker/USOC/commit/21e8bfd7a9ab0b7f9344a7a3a7c32a7cdd5a0b69"}, "type": "CWE-89"}
| 219
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/**\n * @file\n * IMAP helper functions\n *\n * @authors\n * Copyright (C) 1996-1998,2010,2012-2013 Michael R. Elkins <me@mutt.org>\n * Copyright (C) 1996-1999 Brandon Long <blong@fiction.net>\n * Copyright (C) 1999-2009,2012 Brendan Cully <brendan@kublai.com>\n *\n * @copyright\n * This program is free software: you can redistribute it and/or modify it under\n * the terms of the GNU General Public License as published by the Free Software\n * Foundation, either version 2 of the License, or (at your option) any later\n * version.\n *\n * This program is distributed in the hope that it will be useful, but WITHOUT\n * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n * details.\n *\n * You should have received a copy of the GNU General Public License along with\n * this program. If not, see <http://www.gnu.org/licenses/>.\n */",
"/**\n * @page imap_util IMAP helper functions\n *\n * IMAP helper functions\n */",
"#include \"config.h\"\n#include <ctype.h>\n#include <errno.h>\n#include <netdb.h>\n#include <netinet/in.h>\n#include <signal.h>\n#include <stdbool.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/wait.h>\n#include <time.h>\n#include <unistd.h>\n#include \"imap_private.h\"\n#include \"mutt/mutt.h\"\n#include \"conn/conn.h\"\n#include \"bcache.h\"\n#include \"context.h\"\n#include \"globals.h\"\n#include \"header.h\"\n#include \"imap/imap.h\"\n#include \"mailbox.h\"\n#include \"message.h\"\n#include \"mutt_account.h\"\n#include \"mutt_socket.h\"\n#include \"mx.h\"\n#include \"options.h\"\n#include \"protos.h\"\n#include \"url.h\"\n#ifdef USE_HCACHE\n#include \"hcache/hcache.h\"\n#endif",
"/**\n * imap_expand_path - Canonicalise an IMAP path\n * @param path Buffer containing path\n * @param len Buffer length\n * @retval 0 Success\n * @retval -1 Error\n *\n * IMAP implementation of mutt_expand_path. Rewrite an IMAP path in canonical\n * and absolute form. The buffer is rewritten in place with the canonical IMAP\n * path.\n *\n * Function can fail if imap_parse_path() or url_tostring() fail,\n * of if the buffer isn't large enough.\n */\nint imap_expand_path(char *path, size_t len)\n{\n struct ImapMbox mx;\n struct ImapData *idata = NULL;\n struct Url url;\n char fixedpath[LONG_STRING];\n int rc;",
" if (imap_parse_path(path, &mx) < 0)\n return -1;",
" idata = imap_conn_find(&mx.account, MUTT_IMAP_CONN_NONEW);\n mutt_account_tourl(&mx.account, &url);\n imap_fix_path(idata, mx.mbox, fixedpath, sizeof(fixedpath));\n url.path = fixedpath;",
" rc = url_tostring(&url, path, len, U_DECODE_PASSWD);\n FREE(&mx.mbox);",
" return rc;\n}",
"/**\n * imap_get_parent - Get an IMAP folder's parent\n * @param output Buffer for the result\n * @param mbox Mailbox whose parent is to be determined\n * @param olen Length of the buffer\n * @param delim Path delimiter\n */\nvoid imap_get_parent(char *output, const char *mbox, size_t olen, char delim)\n{\n int n;",
" /* Make a copy of the mailbox name, but only if the pointers are different */\n if (mbox != output)\n mutt_str_strfcpy(output, mbox, olen);",
" n = mutt_str_strlen(output);",
" /* Let's go backwards until the next delimiter\n *\n * If output[n] is a '/', the first n-- will allow us\n * to ignore it. If it isn't, then output looks like\n * \"/aaaaa/bbbb\". There is at least one \"b\", so we can't skip\n * the \"/\" after the 'a's.\n *\n * If output == '/', then n-- => n == 0, so the loop ends\n * immediately\n */\n for (n--; n >= 0 && output[n] != delim; n--)\n ;",
" /* We stopped before the beginning. There is a trailing\n * slash.\n */\n if (n > 0)\n {\n /* Strip the trailing delimiter. */\n output[n] = '\\0';\n }\n else\n {\n output[0] = (n == 0) ? delim : '\\0';\n }\n}",
"/**\n * imap_get_parent_path - Get the path of the parent folder\n * @param output Buffer for the result\n * @param path Mailbox whose parent is to be determined\n * @param olen Length of the buffer\n *\n * Provided an imap path, returns in output the parent directory if\n * existent. Else returns the same path.\n */\nvoid imap_get_parent_path(char *output, const char *path, size_t olen)\n{\n struct ImapMbox mx;\n struct ImapData *idata = NULL;\n char mbox[LONG_STRING] = \"\";",
" if (imap_parse_path(path, &mx) < 0)\n {\n mutt_str_strfcpy(output, path, olen);\n return;\n }",
" idata = imap_conn_find(&mx.account, MUTT_IMAP_CONN_NONEW);\n if (!idata)\n {\n mutt_str_strfcpy(output, path, olen);\n return;\n }",
" /* Stores a fixed path in mbox */\n imap_fix_path(idata, mx.mbox, mbox, sizeof(mbox));",
" /* Gets the parent mbox in mbox */\n imap_get_parent(mbox, mbox, sizeof(mbox), idata->delim);",
" /* Returns a fully qualified IMAP url */\n imap_qualify_path(output, olen, &mx, mbox);\n FREE(&mx.mbox);\n}",
"/**\n * imap_clean_path - Cleans an IMAP path using imap_fix_path\n * @param path Path to be cleaned\n * @param plen Length of the buffer\n *\n * Does it in place.\n */\nvoid imap_clean_path(char *path, size_t plen)\n{\n struct ImapMbox mx;\n struct ImapData *idata = NULL;\n char mbox[LONG_STRING] = \"\";",
" if (imap_parse_path(path, &mx) < 0)\n return;",
" idata = imap_conn_find(&mx.account, MUTT_IMAP_CONN_NONEW);\n if (!idata)\n return;",
" /* Stores a fixed path in mbox */\n imap_fix_path(idata, mx.mbox, mbox, sizeof(mbox));",
" /* Returns a fully qualified IMAP url */\n imap_qualify_path(path, plen, &mx, mbox);\n}",
"#ifdef USE_HCACHE\n/**\n * imap_hcache_namer - Generate a filename for the header cache\n * @param path Path for the header cache file\n * @param dest Buffer for result\n * @param dlen Length of buffer\n * @retval num Chars written to dest\n */\nstatic int imap_hcache_namer(const char *path, char *dest, size_t dlen)\n{\n return snprintf(dest, dlen, \"%s.hcache\", path);\n}",
"/**\n * imap_hcache_open - Open a header cache\n * @param idata Server data\n * @param path Path to the header cache\n * @retval ptr HeaderCache\n * @retval NULL Failure\n */\nheader_cache_t *imap_hcache_open(struct ImapData *idata, const char *path)\n{\n struct ImapMbox mx;\n struct Url url;\n char cachepath[PATH_MAX];\n char mbox[PATH_MAX];",
" if (path)\n imap_cachepath(idata, path, mbox, sizeof(mbox));\n else\n {\n if (!idata->ctx || imap_parse_path(idata->ctx->path, &mx) < 0)\n return NULL;",
" imap_cachepath(idata, mx.mbox, mbox, sizeof(mbox));\n FREE(&mx.mbox);\n }\n",
"",
" mutt_account_tourl(&idata->conn->account, &url);\n url.path = mbox;\n url_tostring(&url, cachepath, sizeof(cachepath), U_PATH);",
" return mutt_hcache_open(HeaderCache, cachepath, imap_hcache_namer);\n}",
"/**\n * imap_hcache_close - Close the header cache\n * @param idata Server data\n */\nvoid imap_hcache_close(struct ImapData *idata)\n{\n if (!idata->hcache)\n return;",
" mutt_hcache_close(idata->hcache);\n idata->hcache = NULL;\n}",
"/**\n * imap_hcache_get - Get a header cache entry by its UID\n * @param idata Server data\n * @param uid UID to find\n * @retval ptr Email Header\n * @retval NULL Failure\n */\nstruct Header *imap_hcache_get(struct ImapData *idata, unsigned int uid)\n{\n char key[16];\n void *uv = NULL;\n struct Header *h = NULL;",
" if (!idata->hcache)\n return NULL;",
" sprintf(key, \"/%u\", uid);\n uv = mutt_hcache_fetch(idata->hcache, key, imap_hcache_keylen(key));\n if (uv)\n {\n if (*(unsigned int *) uv == idata->uid_validity)\n h = mutt_hcache_restore(uv);\n else\n mutt_debug(3, \"hcache uidvalidity mismatch: %u\\n\", *(unsigned int *) uv);\n mutt_hcache_free(idata->hcache, &uv);\n }",
" return h;\n}",
"/**\n * imap_hcache_put - Add an entry to the header cache\n * @param idata Server data\n * @param h Email Header\n * @retval 0 Success\n * @retval -1 Failure\n */\nint imap_hcache_put(struct ImapData *idata, struct Header *h)\n{\n char key[16];",
" if (!idata->hcache)\n return -1;",
" sprintf(key, \"/%u\", HEADER_DATA(h)->uid);\n return mutt_hcache_store(idata->hcache, key, imap_hcache_keylen(key), h, idata->uid_validity);\n}",
"/**\n * imap_hcache_del - Delete an item from the header cache\n * @param idata Server data\n * @param uid UID of entry to delete\n * @retval 0 Success\n * @retval -1 Failure\n */\nint imap_hcache_del(struct ImapData *idata, unsigned int uid)\n{\n char key[16];",
" if (!idata->hcache)\n return -1;",
" sprintf(key, \"/%u\", uid);\n return mutt_hcache_delete(idata->hcache, key, imap_hcache_keylen(key));\n}\n#endif",
"/**\n * imap_parse_path - Parse an IMAP mailbox name into name,host,port\n * @param path Mailbox path to parse\n * @param mx An IMAP mailbox\n * @retval 0 Success\n * @retval -1 Failure\n *\n * Given an IMAP mailbox name, return host, port and a path IMAP servers will\n * recognize. mx.mbox is malloc'd, caller must free it\n */\nint imap_parse_path(const char *path, struct ImapMbox *mx)\n{\n static unsigned short ImapPort = 0;\n static unsigned short ImapsPort = 0;\n struct servent *service = NULL;\n struct Url url;\n char *c = NULL;",
" if (!ImapPort)\n {\n service = getservbyname(\"imap\", \"tcp\");\n if (service)\n ImapPort = ntohs(service->s_port);\n else\n ImapPort = IMAP_PORT;\n mutt_debug(3, \"Using default IMAP port %d\\n\", ImapPort);\n }\n if (!ImapsPort)\n {\n service = getservbyname(\"imaps\", \"tcp\");\n if (service)\n ImapsPort = ntohs(service->s_port);\n else\n ImapsPort = IMAP_SSL_PORT;\n mutt_debug(3, \"Using default IMAPS port %d\\n\", ImapsPort);\n }",
" /* Defaults */\n memset(&mx->account, 0, sizeof(mx->account));\n mx->account.port = ImapPort;\n mx->account.type = MUTT_ACCT_TYPE_IMAP;",
" c = mutt_str_strdup(path);\n url_parse(&url, c);\n if (url.scheme == U_IMAP || url.scheme == U_IMAPS)\n {\n if (mutt_account_fromurl(&mx->account, &url) < 0 || !*mx->account.host)\n {\n url_free(&url);\n FREE(&c);\n return -1;\n }",
" mx->mbox = mutt_str_strdup(url.path);",
" if (url.scheme == U_IMAPS)\n mx->account.flags |= MUTT_ACCT_SSL;",
" url_free(&url);\n FREE(&c);\n }\n /* old PINE-compatibility code */\n else\n {\n url_free(&url);\n FREE(&c);\n char tmp[128];\n if (sscanf(path, \"{%127[^}]}\", tmp) != 1)\n return -1;",
" c = strchr(path, '}');\n if (!c)\n return -1;\n else\n {\n /* walk past closing '}' */\n mx->mbox = mutt_str_strdup(c + 1);\n }",
" c = strrchr(tmp, '@');\n if (c)\n {\n *c = '\\0';\n mutt_str_strfcpy(mx->account.user, tmp, sizeof(mx->account.user));\n mutt_str_strfcpy(tmp, c + 1, sizeof(tmp));\n mx->account.flags |= MUTT_ACCT_USER;\n }",
" const int n = sscanf(tmp, \"%127[^:/]%127s\", mx->account.host, tmp);\n if (n < 1)\n {\n mutt_debug(1, \"NULL host in %s\\n\", path);\n FREE(&mx->mbox);\n return -1;\n }",
" if (n > 1)\n {\n if (sscanf(tmp, \":%hu%127s\", &(mx->account.port), tmp) >= 1)\n mx->account.flags |= MUTT_ACCT_PORT;\n if (sscanf(tmp, \"/%s\", tmp) == 1)\n {\n if (mutt_str_strncmp(tmp, \"ssl\", 3) == 0)\n mx->account.flags |= MUTT_ACCT_SSL;\n else\n {\n mutt_debug(1, \"Unknown connection type in %s\\n\", path);\n FREE(&mx->mbox);\n return -1;\n }\n }\n }\n }",
" if ((mx->account.flags & MUTT_ACCT_SSL) && !(mx->account.flags & MUTT_ACCT_PORT))\n mx->account.port = ImapsPort;",
" return 0;\n}",
"/**\n * imap_mxcmp - Compare mailbox names, giving priority to INBOX\n * @param mx1 First mailbox name\n * @param mx2 Second mailbox name\n * @retval <0 First mailbox precedes Second mailbox\n * @retval 0 Mailboxes are the same\n * @retval >0 Second mailbox precedes First mailbox\n *\n * Like a normal sort function except that \"INBOX\" will be sorted to the\n * beginning of the list.\n */\nint imap_mxcmp(const char *mx1, const char *mx2)\n{\n char *b1 = NULL;\n char *b2 = NULL;\n int rc;",
" if (!mx1 || !*mx1)\n mx1 = \"INBOX\";\n if (!mx2 || !*mx2)\n mx2 = \"INBOX\";\n if ((mutt_str_strcasecmp(mx1, \"INBOX\") == 0) &&\n (mutt_str_strcasecmp(mx2, \"INBOX\") == 0))\n {\n return 0;\n }",
" b1 = mutt_mem_malloc(strlen(mx1) + 1);\n b2 = mutt_mem_malloc(strlen(mx2) + 1);",
" imap_fix_path(NULL, mx1, b1, strlen(mx1) + 1);\n imap_fix_path(NULL, mx2, b2, strlen(mx2) + 1);",
" rc = mutt_str_strcmp(b1, b2);\n FREE(&b1);\n FREE(&b2);",
" return rc;\n}",
"/**\n * imap_pretty_mailbox - Prettify an IMAP mailbox name\n * @param path Mailbox name to be tidied\n *\n * Called by mutt_pretty_mailbox() to make IMAP paths look nice.\n */\nvoid imap_pretty_mailbox(char *path)\n{\n struct ImapMbox home, target;\n struct Url url;\n char *delim = NULL;\n int tlen;\n int hlen = 0;\n bool home_match = false;",
" if (imap_parse_path(path, &target) < 0)\n return;",
" tlen = mutt_str_strlen(target.mbox);\n /* check whether we can do '=' substitution */\n if (mx_is_imap(Folder) && !imap_parse_path(Folder, &home))\n {\n hlen = mutt_str_strlen(home.mbox);\n if (tlen && mutt_account_match(&home.account, &target.account) &&\n (mutt_str_strncmp(home.mbox, target.mbox, hlen) == 0))\n {\n if (hlen == 0)\n home_match = true;\n else if (ImapDelimChars)\n {\n for (delim = ImapDelimChars; *delim != '\\0'; delim++)\n if (target.mbox[hlen] == *delim)\n home_match = true;\n }\n }\n FREE(&home.mbox);\n }",
" /* do the '=' substitution */\n if (home_match)\n {\n *path++ = '=';\n /* copy remaining path, skipping delimiter */\n if (hlen == 0)\n hlen = -1;\n memcpy(path, target.mbox + hlen + 1, tlen - hlen - 1);\n path[tlen - hlen - 1] = '\\0';\n }\n else\n {\n mutt_account_tourl(&target.account, &url);\n url.path = target.mbox;\n /* FIXME: That hard-coded constant is bogus. But we need the actual\n * size of the buffer from mutt_pretty_mailbox. And these pretty\n * operations usually shrink the result. Still... */\n url_tostring(&url, path, 1024, 0);\n }",
" FREE(&target.mbox);\n}",
"/**\n * imap_continue - display a message and ask the user if they want to go on\n * @param msg Location of the error\n * @param resp Message for user\n * @retval num Result: #MUTT_YES, #MUTT_NO, #MUTT_ABORT\n */\nint imap_continue(const char *msg, const char *resp)\n{\n imap_error(msg, resp);\n return mutt_yesorno(_(\"Continue?\"), 0);\n}",
"/**\n * imap_error - show an error and abort\n * @param where Location of the error\n * @param msg Message for user\n */\nvoid imap_error(const char *where, const char *msg)\n{\n mutt_error(\"%s [%s]\\n\", where, msg);\n}",
"/**\n * imap_new_idata - Allocate and initialise a new ImapData structure\n * @retval NULL Failure (no mem)\n * @retval ptr New ImapData\n */\nstruct ImapData *imap_new_idata(void)\n{\n struct ImapData *idata = mutt_mem_calloc(1, sizeof(struct ImapData));",
" idata->cmdbuf = mutt_buffer_new();\n idata->cmdslots = ImapPipelineDepth + 2;\n idata->cmds = mutt_mem_calloc(idata->cmdslots, sizeof(*idata->cmds));",
" STAILQ_INIT(&idata->flags);\n STAILQ_INIT(&idata->mboxcache);",
" return idata;\n}",
"/**\n * imap_free_idata - Release and clear storage in an ImapData structure\n * @param idata Server data\n */\nvoid imap_free_idata(struct ImapData **idata)\n{\n if (!idata)\n return;",
" FREE(&(*idata)->capstr);\n mutt_list_free(&(*idata)->flags);\n imap_mboxcache_free(*idata);\n mutt_buffer_free(&(*idata)->cmdbuf);\n FREE(&(*idata)->buf);\n mutt_bcache_close(&(*idata)->bcache);\n FREE(&(*idata)->cmds);\n FREE(idata);\n}",
"/**\n * imap_fix_path - Fix up the imap path\n * @param idata Server data\n * @param mailbox Mailbox path\n * @param path Buffer for the result\n * @param plen Length of buffer\n * @retval ptr Fixed-up path\n *\n * This is necessary because the rest of neomutt assumes a hierarchy delimiter of\n * '/', which is not necessarily true in IMAP. Additionally, the filesystem\n * converts multiple hierarchy delimiters into a single one, ie \"///\" is equal\n * to \"/\". IMAP servers are not required to do this.\n * Moreover, IMAP servers may dislike the path ending with the delimiter.\n */\nchar *imap_fix_path(struct ImapData *idata, const char *mailbox, char *path, size_t plen)\n{\n int i = 0;\n char delim = '\\0';",
" if (idata)\n delim = idata->delim;",
" while (mailbox && *mailbox && i < plen - 1)\n {\n if ((ImapDelimChars && strchr(ImapDelimChars, *mailbox)) || (delim && *mailbox == delim))\n {\n /* use connection delimiter if known. Otherwise use user delimiter */\n if (!idata)\n delim = *mailbox;",
" while (*mailbox && ((ImapDelimChars && strchr(ImapDelimChars, *mailbox)) ||\n (delim && *mailbox == delim)))\n {\n mailbox++;\n }\n path[i] = delim;\n }\n else\n {\n path[i] = *mailbox;\n mailbox++;\n }\n i++;\n }\n if (i && path[--i] != delim)\n i++;\n path[i] = '\\0';",
" return path;\n}",
"/**\n * imap_cachepath - Generate a cache path for a mailbox\n * @param idata Server data\n * @param mailbox Mailbox name\n * @param dest Buffer to store cache path\n * @param dlen Length of buffer\n */\nvoid imap_cachepath(struct ImapData *idata, const char *mailbox, char *dest, size_t dlen)\n{\n char *s = NULL;\n const char *p = mailbox;",
" for (s = dest; p && *p && dlen; dlen--)\n {\n if (*p == idata->delim)\n {\n *s = '/';\n /* simple way to avoid collisions with UIDs */\n if (*(p + 1) >= '0' && *(p + 1) <= '9')\n {\n if (--dlen)\n *++s = '_';\n }\n }\n else\n *s = *p;\n p++;\n s++;\n }\n *s = '\\0';\n}",
"/**\n * imap_get_literal_count - write number of bytes in an IMAP literal into bytes\n * @param[in] buf Number as a string\n * @param[out] bytes Resulting number\n * @retval 0 Success\n * @retval -1 Failure\n */\nint imap_get_literal_count(const char *buf, unsigned int *bytes)\n{\n char *pc = NULL;\n char *pn = NULL;",
" if (!buf || !(pc = strchr(buf, '{')))\n return -1;",
" pc++;\n pn = pc;\n while (isdigit((unsigned char) *pc))\n pc++;\n *pc = '\\0';\n if (mutt_str_atoui(pn, bytes) < 0)\n return -1;",
" return 0;\n}",
"/**\n * imap_get_qualifier - Get the qualifier from a tagged response\n * @param buf Command string to process\n * @retval ptr Start of the qualifier\n *\n * In a tagged response, skip tag and status for the qualifier message.\n * Used by imap_copy_message for TRYCREATE\n */\nchar *imap_get_qualifier(char *buf)\n{\n char *s = buf;",
" /* skip tag */\n s = imap_next_word(s);\n /* skip OK/NO/BAD response */\n s = imap_next_word(s);",
" return s;\n}",
"/**\n * imap_next_word - Find where the next IMAP word begins\n * @param s Command string to process\n * @retval ptr Next IMAP word\n */\nchar *imap_next_word(char *s)\n{\n int quoted = 0;",
" while (*s)\n {\n if (*s == '\\\\')\n {\n s++;\n if (*s)\n s++;\n continue;\n }\n if (*s == '\\\"')\n quoted = quoted ? 0 : 1;\n if (!quoted && ISSPACE(*s))\n break;\n s++;\n }",
" SKIPWS(s);\n return s;\n}",
"/**\n * imap_qualify_path - Make an absolute IMAP folder target\n * @param dest Buffer for the result\n * @param len Length of buffer\n * @param mx Imap mailbox\n * @param path Path relative to the mailbox\n *\n * given ImapMbox and relative path.\n */\nvoid imap_qualify_path(char *dest, size_t len, struct ImapMbox *mx, char *path)\n{\n struct Url url;",
" mutt_account_tourl(&mx->account, &url);\n url.path = path;",
" url_tostring(&url, dest, len, 0);\n}",
"/**\n * imap_quote_string - quote string according to IMAP rules\n * @param dest Buffer for the result\n * @param dlen Length of the buffer\n * @param src String to be quoted\n *\n * Surround string with quotes, escape \" and \\ with backslash\n */\nvoid imap_quote_string(char *dest, size_t dlen, const char *src, bool quote_backtick)\n{\n const char *quote = \"`\\\"\\\\\";\n if (!quote_backtick)\n quote++;",
" char *pt = dest;\n const char *s = src;",
" *pt++ = '\"';\n /* save room for trailing quote-char */\n dlen -= 2;",
" for (; *s && dlen; s++)\n {\n if (strchr(quote, *s))\n {\n dlen -= 2;\n if (dlen == 0)\n break;\n *pt++ = '\\\\';\n *pt++ = *s;\n }\n else\n {\n *pt++ = *s;\n dlen--;\n }\n }\n *pt++ = '\"';\n *pt = '\\0';\n}",
"/**\n * imap_unquote_string - equally stupid unquoting routine\n * @param s String to be unquoted\n */\nvoid imap_unquote_string(char *s)\n{\n char *d = s;",
" if (*s == '\\\"')\n s++;\n else\n return;",
" while (*s)\n {\n if (*s == '\\\"')\n {\n *d = '\\0';\n return;\n }\n if (*s == '\\\\')\n {\n s++;\n }\n if (*s)\n {\n *d = *s;\n d++;\n s++;\n }\n }\n *d = '\\0';\n}",
"/**\n * imap_munge_mbox_name - Quote awkward characters in a mailbox name\n * @param idata Server data\n * @param dest Buffer to store safe mailbox name\n * @param dlen Length of buffer\n * @param src Mailbox name\n */\nvoid imap_munge_mbox_name(struct ImapData *idata, char *dest, size_t dlen, const char *src)\n{\n char *buf = mutt_str_strdup(src);\n imap_utf_encode(idata, &buf);",
" imap_quote_string(dest, dlen, buf, false);",
" FREE(&buf);\n}",
"/**\n * imap_unmunge_mbox_name - Remove quoting from a mailbox name\n * @param idata Server data\n * @param s Mailbox name\n *\n * The string will be altered in-place.\n */\nvoid imap_unmunge_mbox_name(struct ImapData *idata, char *s)\n{\n imap_unquote_string(s);",
" char *buf = mutt_str_strdup(s);\n if (buf)\n {\n imap_utf_decode(idata, &buf);\n strncpy(s, buf, strlen(s));\n }",
" FREE(&buf);\n}",
"/**\n * imap_keepalive - poll the current folder to keep the connection alive\n */\nvoid imap_keepalive(void)\n{\n struct Connection *conn = NULL;\n struct ImapData *idata = NULL;\n time_t now = time(NULL);",
" TAILQ_FOREACH(conn, mutt_socket_head(), entries)\n {\n if (conn->account.type == MUTT_ACCT_TYPE_IMAP)\n {\n idata = conn->data;\n if (idata->state >= IMAP_AUTHENTICATED && now >= idata->lastread + ImapKeepalive)\n {\n imap_check(idata, 1);\n }\n }\n }\n}",
"/**\n * imap_wait_keepalive - Wait for a process to change state\n * @param pid Process ID to listen to\n * @retval num 'wstatus' from waitpid()\n */\nint imap_wait_keepalive(pid_t pid)\n{\n struct sigaction oldalrm;\n struct sigaction act;\n sigset_t oldmask;\n int rc;",
" bool imap_passive = ImapPassive;",
" ImapPassive = true;\n OptKeepQuiet = true;",
" sigprocmask(SIG_SETMASK, NULL, &oldmask);",
" sigemptyset(&act.sa_mask);\n act.sa_handler = mutt_sig_empty_handler;\n#ifdef SA_INTERRUPT\n act.sa_flags = SA_INTERRUPT;\n#else\n act.sa_flags = 0;\n#endif",
" sigaction(SIGALRM, &act, &oldalrm);",
" alarm(ImapKeepalive);\n while (waitpid(pid, &rc, 0) < 0 && errno == EINTR)\n {\n alarm(0); /* cancel a possibly pending alarm */\n imap_keepalive();\n alarm(ImapKeepalive);\n }",
" alarm(0); /* cancel a possibly pending alarm */",
" sigaction(SIGALRM, &oldalrm, NULL);\n sigprocmask(SIG_SETMASK, &oldmask, NULL);",
" OptKeepQuiet = false;\n if (!imap_passive)\n ImapPassive = false;",
" return rc;\n}",
"/**\n * imap_allow_reopen - Allow re-opening a folder upon expunge\n * @param ctx Context\n */\nvoid imap_allow_reopen(struct Context *ctx)\n{\n struct ImapData *idata = NULL;\n if (!ctx || !ctx->data || ctx->magic != MUTT_IMAP)\n return;",
" idata = ctx->data;\n if (idata->ctx == ctx)\n idata->reopen |= IMAP_REOPEN_ALLOW;\n}",
"/**\n * imap_disallow_reopen - Disallow re-opening a folder upon expunge\n * @param ctx Context\n */\nvoid imap_disallow_reopen(struct Context *ctx)\n{\n struct ImapData *idata = NULL;\n if (!ctx || !ctx->data || ctx->magic != MUTT_IMAP)\n return;",
" idata = ctx->data;\n if (idata->ctx == ctx)\n idata->reopen &= ~IMAP_REOPEN_ALLOW;\n}",
"/**\n * imap_account_match - Compare two Accounts\n * @param a1 First Account\n * @param a2 Second Account\n * @retval true Accounts match\n */\nint imap_account_match(const struct Account *a1, const struct Account *a2)\n{\n struct ImapData *a1_idata = imap_conn_find(a1, MUTT_IMAP_CONN_NONEW);\n struct ImapData *a2_idata = imap_conn_find(a2, MUTT_IMAP_CONN_NONEW);\n const struct Account *a1_canon = a1_idata == NULL ? a1 : &a1_idata->conn->account;\n const struct Account *a2_canon = a2_idata == NULL ? a2 : &a2_idata->conn->account;",
" return mutt_account_match(a1_canon, a2_canon);\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,
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
] |
PreciseBugs
|
{"buggy_code_end_loc": [247], "buggy_code_start_loc": [247], "filenames": ["imap/util.c"], "fixing_code_end_loc": [254], "fixing_code_start_loc": [248], "message": "An issue was discovered in Mutt before 1.10.1 and NeoMutt before 2018-07-16. imap/util.c mishandles \"..\" directory traversal in a mailbox name.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"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": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:mutt:mutt:*:*:*:*:*:*:*:*", "matchCriteriaId": "2FA2C3A6-423C-4BE5-8FA7-0241384D58D0", "versionEndExcluding": "1.10.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:neomutt:neomutt:*:*:*:*:*:*:*:*", "matchCriteriaId": "1C15CCD1-1752-4913-9506-32035B52A513", "versionEndExcluding": "20180716", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"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}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "An issue was discovered in Mutt before 1.10.1 and NeoMutt before 2018-07-16. imap/util.c mishandles \"..\" directory traversal in a mailbox name."}, {"lang": "es", "value": "Se ha descubierto un problema en Mutt en versiones anteriores a la 1.10.1 y NeoMutt en versiones anteriores al 2018-07-16. imap/util.c gestiona de manera incorrecta un salto de directorio \"..\" en un nombre de mailbox."}], "evaluatorComment": null, "id": "CVE-2018-14355", "lastModified": "2020-05-20T01:19:28.847", "metrics": {"cvssMetricV2": [{"acInsufInfo": true, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 5.0, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:N/AC:L/Au:N/C:P/I:N/A:N", "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": "NONE", "baseScore": 5.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 1.4, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2018-07-17T17:29:00.590", "references": [{"source": "cve@mitre.org", "tags": ["Release Notes", "Vendor Advisory"], "url": "http://www.mutt.org/news.html"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/neomutt/neomutt/commit/57971dba06346b2d7179294f4528b8d4427a7c5d"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://gitlab.com/muttmua/mutt/commit/31eef6c766f47df8281942d19f76e35f475c781d"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2018/08/msg00001.html"}, {"source": "cve@mitre.org", "tags": ["Release Notes", "Vendor Advisory"], "url": "https://neomutt.org/2018/07/16/release"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/201810-07"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://usn.ubuntu.com/3719-3/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2018/dsa-4277"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-22"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/neomutt/neomutt/commit/57971dba06346b2d7179294f4528b8d4427a7c5d"}, "type": "CWE-22"}
| 220
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/**\n * @file\n * IMAP helper functions\n *\n * @authors\n * Copyright (C) 1996-1998,2010,2012-2013 Michael R. Elkins <me@mutt.org>\n * Copyright (C) 1996-1999 Brandon Long <blong@fiction.net>\n * Copyright (C) 1999-2009,2012 Brendan Cully <brendan@kublai.com>\n *\n * @copyright\n * This program is free software: you can redistribute it and/or modify it under\n * the terms of the GNU General Public License as published by the Free Software\n * Foundation, either version 2 of the License, or (at your option) any later\n * version.\n *\n * This program is distributed in the hope that it will be useful, but WITHOUT\n * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n * details.\n *\n * You should have received a copy of the GNU General Public License along with\n * this program. If not, see <http://www.gnu.org/licenses/>.\n */",
"/**\n * @page imap_util IMAP helper functions\n *\n * IMAP helper functions\n */",
"#include \"config.h\"\n#include <ctype.h>\n#include <errno.h>\n#include <netdb.h>\n#include <netinet/in.h>\n#include <signal.h>\n#include <stdbool.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/wait.h>\n#include <time.h>\n#include <unistd.h>\n#include \"imap_private.h\"\n#include \"mutt/mutt.h\"\n#include \"conn/conn.h\"\n#include \"bcache.h\"\n#include \"context.h\"\n#include \"globals.h\"\n#include \"header.h\"\n#include \"imap/imap.h\"\n#include \"mailbox.h\"\n#include \"message.h\"\n#include \"mutt_account.h\"\n#include \"mutt_socket.h\"\n#include \"mx.h\"\n#include \"options.h\"\n#include \"protos.h\"\n#include \"url.h\"\n#ifdef USE_HCACHE\n#include \"hcache/hcache.h\"\n#endif",
"/**\n * imap_expand_path - Canonicalise an IMAP path\n * @param path Buffer containing path\n * @param len Buffer length\n * @retval 0 Success\n * @retval -1 Error\n *\n * IMAP implementation of mutt_expand_path. Rewrite an IMAP path in canonical\n * and absolute form. The buffer is rewritten in place with the canonical IMAP\n * path.\n *\n * Function can fail if imap_parse_path() or url_tostring() fail,\n * of if the buffer isn't large enough.\n */\nint imap_expand_path(char *path, size_t len)\n{\n struct ImapMbox mx;\n struct ImapData *idata = NULL;\n struct Url url;\n char fixedpath[LONG_STRING];\n int rc;",
" if (imap_parse_path(path, &mx) < 0)\n return -1;",
" idata = imap_conn_find(&mx.account, MUTT_IMAP_CONN_NONEW);\n mutt_account_tourl(&mx.account, &url);\n imap_fix_path(idata, mx.mbox, fixedpath, sizeof(fixedpath));\n url.path = fixedpath;",
" rc = url_tostring(&url, path, len, U_DECODE_PASSWD);\n FREE(&mx.mbox);",
" return rc;\n}",
"/**\n * imap_get_parent - Get an IMAP folder's parent\n * @param output Buffer for the result\n * @param mbox Mailbox whose parent is to be determined\n * @param olen Length of the buffer\n * @param delim Path delimiter\n */\nvoid imap_get_parent(char *output, const char *mbox, size_t olen, char delim)\n{\n int n;",
" /* Make a copy of the mailbox name, but only if the pointers are different */\n if (mbox != output)\n mutt_str_strfcpy(output, mbox, olen);",
" n = mutt_str_strlen(output);",
" /* Let's go backwards until the next delimiter\n *\n * If output[n] is a '/', the first n-- will allow us\n * to ignore it. If it isn't, then output looks like\n * \"/aaaaa/bbbb\". There is at least one \"b\", so we can't skip\n * the \"/\" after the 'a's.\n *\n * If output == '/', then n-- => n == 0, so the loop ends\n * immediately\n */\n for (n--; n >= 0 && output[n] != delim; n--)\n ;",
" /* We stopped before the beginning. There is a trailing\n * slash.\n */\n if (n > 0)\n {\n /* Strip the trailing delimiter. */\n output[n] = '\\0';\n }\n else\n {\n output[0] = (n == 0) ? delim : '\\0';\n }\n}",
"/**\n * imap_get_parent_path - Get the path of the parent folder\n * @param output Buffer for the result\n * @param path Mailbox whose parent is to be determined\n * @param olen Length of the buffer\n *\n * Provided an imap path, returns in output the parent directory if\n * existent. Else returns the same path.\n */\nvoid imap_get_parent_path(char *output, const char *path, size_t olen)\n{\n struct ImapMbox mx;\n struct ImapData *idata = NULL;\n char mbox[LONG_STRING] = \"\";",
" if (imap_parse_path(path, &mx) < 0)\n {\n mutt_str_strfcpy(output, path, olen);\n return;\n }",
" idata = imap_conn_find(&mx.account, MUTT_IMAP_CONN_NONEW);\n if (!idata)\n {\n mutt_str_strfcpy(output, path, olen);\n return;\n }",
" /* Stores a fixed path in mbox */\n imap_fix_path(idata, mx.mbox, mbox, sizeof(mbox));",
" /* Gets the parent mbox in mbox */\n imap_get_parent(mbox, mbox, sizeof(mbox), idata->delim);",
" /* Returns a fully qualified IMAP url */\n imap_qualify_path(output, olen, &mx, mbox);\n FREE(&mx.mbox);\n}",
"/**\n * imap_clean_path - Cleans an IMAP path using imap_fix_path\n * @param path Path to be cleaned\n * @param plen Length of the buffer\n *\n * Does it in place.\n */\nvoid imap_clean_path(char *path, size_t plen)\n{\n struct ImapMbox mx;\n struct ImapData *idata = NULL;\n char mbox[LONG_STRING] = \"\";",
" if (imap_parse_path(path, &mx) < 0)\n return;",
" idata = imap_conn_find(&mx.account, MUTT_IMAP_CONN_NONEW);\n if (!idata)\n return;",
" /* Stores a fixed path in mbox */\n imap_fix_path(idata, mx.mbox, mbox, sizeof(mbox));",
" /* Returns a fully qualified IMAP url */\n imap_qualify_path(path, plen, &mx, mbox);\n}",
"#ifdef USE_HCACHE\n/**\n * imap_hcache_namer - Generate a filename for the header cache\n * @param path Path for the header cache file\n * @param dest Buffer for result\n * @param dlen Length of buffer\n * @retval num Chars written to dest\n */\nstatic int imap_hcache_namer(const char *path, char *dest, size_t dlen)\n{\n return snprintf(dest, dlen, \"%s.hcache\", path);\n}",
"/**\n * imap_hcache_open - Open a header cache\n * @param idata Server data\n * @param path Path to the header cache\n * @retval ptr HeaderCache\n * @retval NULL Failure\n */\nheader_cache_t *imap_hcache_open(struct ImapData *idata, const char *path)\n{\n struct ImapMbox mx;\n struct Url url;\n char cachepath[PATH_MAX];\n char mbox[PATH_MAX];",
" if (path)\n imap_cachepath(idata, path, mbox, sizeof(mbox));\n else\n {\n if (!idata->ctx || imap_parse_path(idata->ctx->path, &mx) < 0)\n return NULL;",
" imap_cachepath(idata, mx.mbox, mbox, sizeof(mbox));\n FREE(&mx.mbox);\n }\n",
" if (strstr(mbox, \"/../\") || (strcmp(mbox, \"..\") == 0) || (strncmp(mbox, \"../\", 3) == 0))\n return NULL;\n size_t len = strlen(mbox);\n if ((len > 3) && (strcmp(mbox + len - 3, \"/..\") == 0))\n return NULL;\n",
" mutt_account_tourl(&idata->conn->account, &url);\n url.path = mbox;\n url_tostring(&url, cachepath, sizeof(cachepath), U_PATH);",
" return mutt_hcache_open(HeaderCache, cachepath, imap_hcache_namer);\n}",
"/**\n * imap_hcache_close - Close the header cache\n * @param idata Server data\n */\nvoid imap_hcache_close(struct ImapData *idata)\n{\n if (!idata->hcache)\n return;",
" mutt_hcache_close(idata->hcache);\n idata->hcache = NULL;\n}",
"/**\n * imap_hcache_get - Get a header cache entry by its UID\n * @param idata Server data\n * @param uid UID to find\n * @retval ptr Email Header\n * @retval NULL Failure\n */\nstruct Header *imap_hcache_get(struct ImapData *idata, unsigned int uid)\n{\n char key[16];\n void *uv = NULL;\n struct Header *h = NULL;",
" if (!idata->hcache)\n return NULL;",
" sprintf(key, \"/%u\", uid);\n uv = mutt_hcache_fetch(idata->hcache, key, imap_hcache_keylen(key));\n if (uv)\n {\n if (*(unsigned int *) uv == idata->uid_validity)\n h = mutt_hcache_restore(uv);\n else\n mutt_debug(3, \"hcache uidvalidity mismatch: %u\\n\", *(unsigned int *) uv);\n mutt_hcache_free(idata->hcache, &uv);\n }",
" return h;\n}",
"/**\n * imap_hcache_put - Add an entry to the header cache\n * @param idata Server data\n * @param h Email Header\n * @retval 0 Success\n * @retval -1 Failure\n */\nint imap_hcache_put(struct ImapData *idata, struct Header *h)\n{\n char key[16];",
" if (!idata->hcache)\n return -1;",
" sprintf(key, \"/%u\", HEADER_DATA(h)->uid);\n return mutt_hcache_store(idata->hcache, key, imap_hcache_keylen(key), h, idata->uid_validity);\n}",
"/**\n * imap_hcache_del - Delete an item from the header cache\n * @param idata Server data\n * @param uid UID of entry to delete\n * @retval 0 Success\n * @retval -1 Failure\n */\nint imap_hcache_del(struct ImapData *idata, unsigned int uid)\n{\n char key[16];",
" if (!idata->hcache)\n return -1;",
" sprintf(key, \"/%u\", uid);\n return mutt_hcache_delete(idata->hcache, key, imap_hcache_keylen(key));\n}\n#endif",
"/**\n * imap_parse_path - Parse an IMAP mailbox name into name,host,port\n * @param path Mailbox path to parse\n * @param mx An IMAP mailbox\n * @retval 0 Success\n * @retval -1 Failure\n *\n * Given an IMAP mailbox name, return host, port and a path IMAP servers will\n * recognize. mx.mbox is malloc'd, caller must free it\n */\nint imap_parse_path(const char *path, struct ImapMbox *mx)\n{\n static unsigned short ImapPort = 0;\n static unsigned short ImapsPort = 0;\n struct servent *service = NULL;\n struct Url url;\n char *c = NULL;",
" if (!ImapPort)\n {\n service = getservbyname(\"imap\", \"tcp\");\n if (service)\n ImapPort = ntohs(service->s_port);\n else\n ImapPort = IMAP_PORT;\n mutt_debug(3, \"Using default IMAP port %d\\n\", ImapPort);\n }\n if (!ImapsPort)\n {\n service = getservbyname(\"imaps\", \"tcp\");\n if (service)\n ImapsPort = ntohs(service->s_port);\n else\n ImapsPort = IMAP_SSL_PORT;\n mutt_debug(3, \"Using default IMAPS port %d\\n\", ImapsPort);\n }",
" /* Defaults */\n memset(&mx->account, 0, sizeof(mx->account));\n mx->account.port = ImapPort;\n mx->account.type = MUTT_ACCT_TYPE_IMAP;",
" c = mutt_str_strdup(path);\n url_parse(&url, c);\n if (url.scheme == U_IMAP || url.scheme == U_IMAPS)\n {\n if (mutt_account_fromurl(&mx->account, &url) < 0 || !*mx->account.host)\n {\n url_free(&url);\n FREE(&c);\n return -1;\n }",
" mx->mbox = mutt_str_strdup(url.path);",
" if (url.scheme == U_IMAPS)\n mx->account.flags |= MUTT_ACCT_SSL;",
" url_free(&url);\n FREE(&c);\n }\n /* old PINE-compatibility code */\n else\n {\n url_free(&url);\n FREE(&c);\n char tmp[128];\n if (sscanf(path, \"{%127[^}]}\", tmp) != 1)\n return -1;",
" c = strchr(path, '}');\n if (!c)\n return -1;\n else\n {\n /* walk past closing '}' */\n mx->mbox = mutt_str_strdup(c + 1);\n }",
" c = strrchr(tmp, '@');\n if (c)\n {\n *c = '\\0';\n mutt_str_strfcpy(mx->account.user, tmp, sizeof(mx->account.user));\n mutt_str_strfcpy(tmp, c + 1, sizeof(tmp));\n mx->account.flags |= MUTT_ACCT_USER;\n }",
" const int n = sscanf(tmp, \"%127[^:/]%127s\", mx->account.host, tmp);\n if (n < 1)\n {\n mutt_debug(1, \"NULL host in %s\\n\", path);\n FREE(&mx->mbox);\n return -1;\n }",
" if (n > 1)\n {\n if (sscanf(tmp, \":%hu%127s\", &(mx->account.port), tmp) >= 1)\n mx->account.flags |= MUTT_ACCT_PORT;\n if (sscanf(tmp, \"/%s\", tmp) == 1)\n {\n if (mutt_str_strncmp(tmp, \"ssl\", 3) == 0)\n mx->account.flags |= MUTT_ACCT_SSL;\n else\n {\n mutt_debug(1, \"Unknown connection type in %s\\n\", path);\n FREE(&mx->mbox);\n return -1;\n }\n }\n }\n }",
" if ((mx->account.flags & MUTT_ACCT_SSL) && !(mx->account.flags & MUTT_ACCT_PORT))\n mx->account.port = ImapsPort;",
" return 0;\n}",
"/**\n * imap_mxcmp - Compare mailbox names, giving priority to INBOX\n * @param mx1 First mailbox name\n * @param mx2 Second mailbox name\n * @retval <0 First mailbox precedes Second mailbox\n * @retval 0 Mailboxes are the same\n * @retval >0 Second mailbox precedes First mailbox\n *\n * Like a normal sort function except that \"INBOX\" will be sorted to the\n * beginning of the list.\n */\nint imap_mxcmp(const char *mx1, const char *mx2)\n{\n char *b1 = NULL;\n char *b2 = NULL;\n int rc;",
" if (!mx1 || !*mx1)\n mx1 = \"INBOX\";\n if (!mx2 || !*mx2)\n mx2 = \"INBOX\";\n if ((mutt_str_strcasecmp(mx1, \"INBOX\") == 0) &&\n (mutt_str_strcasecmp(mx2, \"INBOX\") == 0))\n {\n return 0;\n }",
" b1 = mutt_mem_malloc(strlen(mx1) + 1);\n b2 = mutt_mem_malloc(strlen(mx2) + 1);",
" imap_fix_path(NULL, mx1, b1, strlen(mx1) + 1);\n imap_fix_path(NULL, mx2, b2, strlen(mx2) + 1);",
" rc = mutt_str_strcmp(b1, b2);\n FREE(&b1);\n FREE(&b2);",
" return rc;\n}",
"/**\n * imap_pretty_mailbox - Prettify an IMAP mailbox name\n * @param path Mailbox name to be tidied\n *\n * Called by mutt_pretty_mailbox() to make IMAP paths look nice.\n */\nvoid imap_pretty_mailbox(char *path)\n{\n struct ImapMbox home, target;\n struct Url url;\n char *delim = NULL;\n int tlen;\n int hlen = 0;\n bool home_match = false;",
" if (imap_parse_path(path, &target) < 0)\n return;",
" tlen = mutt_str_strlen(target.mbox);\n /* check whether we can do '=' substitution */\n if (mx_is_imap(Folder) && !imap_parse_path(Folder, &home))\n {\n hlen = mutt_str_strlen(home.mbox);\n if (tlen && mutt_account_match(&home.account, &target.account) &&\n (mutt_str_strncmp(home.mbox, target.mbox, hlen) == 0))\n {\n if (hlen == 0)\n home_match = true;\n else if (ImapDelimChars)\n {\n for (delim = ImapDelimChars; *delim != '\\0'; delim++)\n if (target.mbox[hlen] == *delim)\n home_match = true;\n }\n }\n FREE(&home.mbox);\n }",
" /* do the '=' substitution */\n if (home_match)\n {\n *path++ = '=';\n /* copy remaining path, skipping delimiter */\n if (hlen == 0)\n hlen = -1;\n memcpy(path, target.mbox + hlen + 1, tlen - hlen - 1);\n path[tlen - hlen - 1] = '\\0';\n }\n else\n {\n mutt_account_tourl(&target.account, &url);\n url.path = target.mbox;\n /* FIXME: That hard-coded constant is bogus. But we need the actual\n * size of the buffer from mutt_pretty_mailbox. And these pretty\n * operations usually shrink the result. Still... */\n url_tostring(&url, path, 1024, 0);\n }",
" FREE(&target.mbox);\n}",
"/**\n * imap_continue - display a message and ask the user if they want to go on\n * @param msg Location of the error\n * @param resp Message for user\n * @retval num Result: #MUTT_YES, #MUTT_NO, #MUTT_ABORT\n */\nint imap_continue(const char *msg, const char *resp)\n{\n imap_error(msg, resp);\n return mutt_yesorno(_(\"Continue?\"), 0);\n}",
"/**\n * imap_error - show an error and abort\n * @param where Location of the error\n * @param msg Message for user\n */\nvoid imap_error(const char *where, const char *msg)\n{\n mutt_error(\"%s [%s]\\n\", where, msg);\n}",
"/**\n * imap_new_idata - Allocate and initialise a new ImapData structure\n * @retval NULL Failure (no mem)\n * @retval ptr New ImapData\n */\nstruct ImapData *imap_new_idata(void)\n{\n struct ImapData *idata = mutt_mem_calloc(1, sizeof(struct ImapData));",
" idata->cmdbuf = mutt_buffer_new();\n idata->cmdslots = ImapPipelineDepth + 2;\n idata->cmds = mutt_mem_calloc(idata->cmdslots, sizeof(*idata->cmds));",
" STAILQ_INIT(&idata->flags);\n STAILQ_INIT(&idata->mboxcache);",
" return idata;\n}",
"/**\n * imap_free_idata - Release and clear storage in an ImapData structure\n * @param idata Server data\n */\nvoid imap_free_idata(struct ImapData **idata)\n{\n if (!idata)\n return;",
" FREE(&(*idata)->capstr);\n mutt_list_free(&(*idata)->flags);\n imap_mboxcache_free(*idata);\n mutt_buffer_free(&(*idata)->cmdbuf);\n FREE(&(*idata)->buf);\n mutt_bcache_close(&(*idata)->bcache);\n FREE(&(*idata)->cmds);\n FREE(idata);\n}",
"/**\n * imap_fix_path - Fix up the imap path\n * @param idata Server data\n * @param mailbox Mailbox path\n * @param path Buffer for the result\n * @param plen Length of buffer\n * @retval ptr Fixed-up path\n *\n * This is necessary because the rest of neomutt assumes a hierarchy delimiter of\n * '/', which is not necessarily true in IMAP. Additionally, the filesystem\n * converts multiple hierarchy delimiters into a single one, ie \"///\" is equal\n * to \"/\". IMAP servers are not required to do this.\n * Moreover, IMAP servers may dislike the path ending with the delimiter.\n */\nchar *imap_fix_path(struct ImapData *idata, const char *mailbox, char *path, size_t plen)\n{\n int i = 0;\n char delim = '\\0';",
" if (idata)\n delim = idata->delim;",
" while (mailbox && *mailbox && i < plen - 1)\n {\n if ((ImapDelimChars && strchr(ImapDelimChars, *mailbox)) || (delim && *mailbox == delim))\n {\n /* use connection delimiter if known. Otherwise use user delimiter */\n if (!idata)\n delim = *mailbox;",
" while (*mailbox && ((ImapDelimChars && strchr(ImapDelimChars, *mailbox)) ||\n (delim && *mailbox == delim)))\n {\n mailbox++;\n }\n path[i] = delim;\n }\n else\n {\n path[i] = *mailbox;\n mailbox++;\n }\n i++;\n }\n if (i && path[--i] != delim)\n i++;\n path[i] = '\\0';",
" return path;\n}",
"/**\n * imap_cachepath - Generate a cache path for a mailbox\n * @param idata Server data\n * @param mailbox Mailbox name\n * @param dest Buffer to store cache path\n * @param dlen Length of buffer\n */\nvoid imap_cachepath(struct ImapData *idata, const char *mailbox, char *dest, size_t dlen)\n{\n char *s = NULL;\n const char *p = mailbox;",
" for (s = dest; p && *p && dlen; dlen--)\n {\n if (*p == idata->delim)\n {\n *s = '/';\n /* simple way to avoid collisions with UIDs */\n if (*(p + 1) >= '0' && *(p + 1) <= '9')\n {\n if (--dlen)\n *++s = '_';\n }\n }\n else\n *s = *p;\n p++;\n s++;\n }\n *s = '\\0';\n}",
"/**\n * imap_get_literal_count - write number of bytes in an IMAP literal into bytes\n * @param[in] buf Number as a string\n * @param[out] bytes Resulting number\n * @retval 0 Success\n * @retval -1 Failure\n */\nint imap_get_literal_count(const char *buf, unsigned int *bytes)\n{\n char *pc = NULL;\n char *pn = NULL;",
" if (!buf || !(pc = strchr(buf, '{')))\n return -1;",
" pc++;\n pn = pc;\n while (isdigit((unsigned char) *pc))\n pc++;\n *pc = '\\0';\n if (mutt_str_atoui(pn, bytes) < 0)\n return -1;",
" return 0;\n}",
"/**\n * imap_get_qualifier - Get the qualifier from a tagged response\n * @param buf Command string to process\n * @retval ptr Start of the qualifier\n *\n * In a tagged response, skip tag and status for the qualifier message.\n * Used by imap_copy_message for TRYCREATE\n */\nchar *imap_get_qualifier(char *buf)\n{\n char *s = buf;",
" /* skip tag */\n s = imap_next_word(s);\n /* skip OK/NO/BAD response */\n s = imap_next_word(s);",
" return s;\n}",
"/**\n * imap_next_word - Find where the next IMAP word begins\n * @param s Command string to process\n * @retval ptr Next IMAP word\n */\nchar *imap_next_word(char *s)\n{\n int quoted = 0;",
" while (*s)\n {\n if (*s == '\\\\')\n {\n s++;\n if (*s)\n s++;\n continue;\n }\n if (*s == '\\\"')\n quoted = quoted ? 0 : 1;\n if (!quoted && ISSPACE(*s))\n break;\n s++;\n }",
" SKIPWS(s);\n return s;\n}",
"/**\n * imap_qualify_path - Make an absolute IMAP folder target\n * @param dest Buffer for the result\n * @param len Length of buffer\n * @param mx Imap mailbox\n * @param path Path relative to the mailbox\n *\n * given ImapMbox and relative path.\n */\nvoid imap_qualify_path(char *dest, size_t len, struct ImapMbox *mx, char *path)\n{\n struct Url url;",
" mutt_account_tourl(&mx->account, &url);\n url.path = path;",
" url_tostring(&url, dest, len, 0);\n}",
"/**\n * imap_quote_string - quote string according to IMAP rules\n * @param dest Buffer for the result\n * @param dlen Length of the buffer\n * @param src String to be quoted\n *\n * Surround string with quotes, escape \" and \\ with backslash\n */\nvoid imap_quote_string(char *dest, size_t dlen, const char *src, bool quote_backtick)\n{\n const char *quote = \"`\\\"\\\\\";\n if (!quote_backtick)\n quote++;",
" char *pt = dest;\n const char *s = src;",
" *pt++ = '\"';\n /* save room for trailing quote-char */\n dlen -= 2;",
" for (; *s && dlen; s++)\n {\n if (strchr(quote, *s))\n {\n dlen -= 2;\n if (dlen == 0)\n break;\n *pt++ = '\\\\';\n *pt++ = *s;\n }\n else\n {\n *pt++ = *s;\n dlen--;\n }\n }\n *pt++ = '\"';\n *pt = '\\0';\n}",
"/**\n * imap_unquote_string - equally stupid unquoting routine\n * @param s String to be unquoted\n */\nvoid imap_unquote_string(char *s)\n{\n char *d = s;",
" if (*s == '\\\"')\n s++;\n else\n return;",
" while (*s)\n {\n if (*s == '\\\"')\n {\n *d = '\\0';\n return;\n }\n if (*s == '\\\\')\n {\n s++;\n }\n if (*s)\n {\n *d = *s;\n d++;\n s++;\n }\n }\n *d = '\\0';\n}",
"/**\n * imap_munge_mbox_name - Quote awkward characters in a mailbox name\n * @param idata Server data\n * @param dest Buffer to store safe mailbox name\n * @param dlen Length of buffer\n * @param src Mailbox name\n */\nvoid imap_munge_mbox_name(struct ImapData *idata, char *dest, size_t dlen, const char *src)\n{\n char *buf = mutt_str_strdup(src);\n imap_utf_encode(idata, &buf);",
" imap_quote_string(dest, dlen, buf, false);",
" FREE(&buf);\n}",
"/**\n * imap_unmunge_mbox_name - Remove quoting from a mailbox name\n * @param idata Server data\n * @param s Mailbox name\n *\n * The string will be altered in-place.\n */\nvoid imap_unmunge_mbox_name(struct ImapData *idata, char *s)\n{\n imap_unquote_string(s);",
" char *buf = mutt_str_strdup(s);\n if (buf)\n {\n imap_utf_decode(idata, &buf);\n strncpy(s, buf, strlen(s));\n }",
" FREE(&buf);\n}",
"/**\n * imap_keepalive - poll the current folder to keep the connection alive\n */\nvoid imap_keepalive(void)\n{\n struct Connection *conn = NULL;\n struct ImapData *idata = NULL;\n time_t now = time(NULL);",
" TAILQ_FOREACH(conn, mutt_socket_head(), entries)\n {\n if (conn->account.type == MUTT_ACCT_TYPE_IMAP)\n {\n idata = conn->data;\n if (idata->state >= IMAP_AUTHENTICATED && now >= idata->lastread + ImapKeepalive)\n {\n imap_check(idata, 1);\n }\n }\n }\n}",
"/**\n * imap_wait_keepalive - Wait for a process to change state\n * @param pid Process ID to listen to\n * @retval num 'wstatus' from waitpid()\n */\nint imap_wait_keepalive(pid_t pid)\n{\n struct sigaction oldalrm;\n struct sigaction act;\n sigset_t oldmask;\n int rc;",
" bool imap_passive = ImapPassive;",
" ImapPassive = true;\n OptKeepQuiet = true;",
" sigprocmask(SIG_SETMASK, NULL, &oldmask);",
" sigemptyset(&act.sa_mask);\n act.sa_handler = mutt_sig_empty_handler;\n#ifdef SA_INTERRUPT\n act.sa_flags = SA_INTERRUPT;\n#else\n act.sa_flags = 0;\n#endif",
" sigaction(SIGALRM, &act, &oldalrm);",
" alarm(ImapKeepalive);\n while (waitpid(pid, &rc, 0) < 0 && errno == EINTR)\n {\n alarm(0); /* cancel a possibly pending alarm */\n imap_keepalive();\n alarm(ImapKeepalive);\n }",
" alarm(0); /* cancel a possibly pending alarm */",
" sigaction(SIGALRM, &oldalrm, NULL);\n sigprocmask(SIG_SETMASK, &oldmask, NULL);",
" OptKeepQuiet = false;\n if (!imap_passive)\n ImapPassive = false;",
" return rc;\n}",
"/**\n * imap_allow_reopen - Allow re-opening a folder upon expunge\n * @param ctx Context\n */\nvoid imap_allow_reopen(struct Context *ctx)\n{\n struct ImapData *idata = NULL;\n if (!ctx || !ctx->data || ctx->magic != MUTT_IMAP)\n return;",
" idata = ctx->data;\n if (idata->ctx == ctx)\n idata->reopen |= IMAP_REOPEN_ALLOW;\n}",
"/**\n * imap_disallow_reopen - Disallow re-opening a folder upon expunge\n * @param ctx Context\n */\nvoid imap_disallow_reopen(struct Context *ctx)\n{\n struct ImapData *idata = NULL;\n if (!ctx || !ctx->data || ctx->magic != MUTT_IMAP)\n return;",
" idata = ctx->data;\n if (idata->ctx == ctx)\n idata->reopen &= ~IMAP_REOPEN_ALLOW;\n}",
"/**\n * imap_account_match - Compare two Accounts\n * @param a1 First Account\n * @param a2 Second Account\n * @retval true Accounts match\n */\nint imap_account_match(const struct Account *a1, const struct Account *a2)\n{\n struct ImapData *a1_idata = imap_conn_find(a1, MUTT_IMAP_CONN_NONEW);\n struct ImapData *a2_idata = imap_conn_find(a2, MUTT_IMAP_CONN_NONEW);\n const struct Account *a1_canon = a1_idata == NULL ? a1 : &a1_idata->conn->account;\n const struct Account *a2_canon = a2_idata == NULL ? a2 : &a2_idata->conn->account;",
" return mutt_account_match(a1_canon, a2_canon);\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [247], "buggy_code_start_loc": [247], "filenames": ["imap/util.c"], "fixing_code_end_loc": [254], "fixing_code_start_loc": [248], "message": "An issue was discovered in Mutt before 1.10.1 and NeoMutt before 2018-07-16. imap/util.c mishandles \"..\" directory traversal in a mailbox name.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"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": null}, {"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:mutt:mutt:*:*:*:*:*:*:*:*", "matchCriteriaId": "2FA2C3A6-423C-4BE5-8FA7-0241384D58D0", "versionEndExcluding": "1.10.1", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:a:neomutt:neomutt:*:*:*:*:*:*:*:*", "matchCriteriaId": "1C15CCD1-1752-4913-9506-32035B52A513", "versionEndExcluding": "20180716", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"nodes": [{"cpeMatch": [{"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}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "An issue was discovered in Mutt before 1.10.1 and NeoMutt before 2018-07-16. imap/util.c mishandles \"..\" directory traversal in a mailbox name."}, {"lang": "es", "value": "Se ha descubierto un problema en Mutt en versiones anteriores a la 1.10.1 y NeoMutt en versiones anteriores al 2018-07-16. imap/util.c gestiona de manera incorrecta un salto de directorio \"..\" en un nombre de mailbox."}], "evaluatorComment": null, "id": "CVE-2018-14355", "lastModified": "2020-05-20T01:19:28.847", "metrics": {"cvssMetricV2": [{"acInsufInfo": true, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 5.0, "confidentialityImpact": "PARTIAL", "integrityImpact": "NONE", "vectorString": "AV:N/AC:L/Au:N/C:P/I:N/A:N", "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": "NONE", "baseScore": 5.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 1.4, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2018-07-17T17:29:00.590", "references": [{"source": "cve@mitre.org", "tags": ["Release Notes", "Vendor Advisory"], "url": "http://www.mutt.org/news.html"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/neomutt/neomutt/commit/57971dba06346b2d7179294f4528b8d4427a7c5d"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://gitlab.com/muttmua/mutt/commit/31eef6c766f47df8281942d19f76e35f475c781d"}, {"source": "cve@mitre.org", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2018/08/msg00001.html"}, {"source": "cve@mitre.org", "tags": ["Release Notes", "Vendor Advisory"], "url": "https://neomutt.org/2018/07/16/release"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/201810-07"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://usn.ubuntu.com/3719-3/"}, {"source": "cve@mitre.org", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2018/dsa-4277"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-22"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/neomutt/neomutt/commit/57971dba06346b2d7179294f4528b8d4427a7c5d"}, "type": "CWE-22"}
| 220
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% PPPP RRRR OOO FFFFF IIIII L EEEEE %\n% P P R R O O F I L E %\n% PPPP RRRR O O FFF I L EEE %\n% P R R O O F I L E %\n% P R R OOO F IIIII LLLLL EEEEE %\n% %\n% %\n% MagickCore Image Profile Methods %\n% %\n% Software Design %\n% Cristy %\n% July 1992 %\n% %\n% %\n% Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization %\n% dedicated to making software imaging solutions freely available. %\n% %\n% You may not use this file except in compliance with the License. You may %\n% obtain a copy of the License at %\n% %\n% http://www.imagemagick.org/script/license.php %\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%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%\n*/\n\f\n/*\n Include declarations.\n*/\n#include \"MagickCore/studio.h\"\n#include \"MagickCore/attribute.h\"\n#include \"MagickCore/cache.h\"\n#include \"MagickCore/color.h\"\n#include \"MagickCore/colorspace-private.h\"\n#include \"MagickCore/configure.h\"\n#include \"MagickCore/exception.h\"\n#include \"MagickCore/exception-private.h\"\n#include \"MagickCore/image.h\"\n#include \"MagickCore/linked-list.h\"\n#include \"MagickCore/memory_.h\"\n#include \"MagickCore/monitor.h\"\n#include \"MagickCore/monitor-private.h\"\n#include \"MagickCore/option.h\"\n#include \"MagickCore/option-private.h\"\n#include \"MagickCore/pixel-accessor.h\"\n#include \"MagickCore/profile.h\"\n#include \"MagickCore/profile-private.h\"\n#include \"MagickCore/property.h\"\n#include \"MagickCore/quantum.h\"\n#include \"MagickCore/quantum-private.h\"\n#include \"MagickCore/resource_.h\"\n#include \"MagickCore/splay-tree.h\"\n#include \"MagickCore/string_.h\"\n#include \"MagickCore/thread-private.h\"\n#include \"MagickCore/token.h\"\n#include \"MagickCore/utility.h\"\n#if defined(MAGICKCORE_LCMS_DELEGATE)\n#if defined(MAGICKCORE_HAVE_LCMS_LCMS2_H)\n#include <wchar.h>\n#include <lcms/lcms2.h>\n#else\n#include <wchar.h>\n#include \"lcms2.h\"\n#endif\n#endif\n\f\n/*\n Forward declarations\n*/\nstatic MagickBooleanType\n SetImageProfileInternal(Image *,const char *,const StringInfo *,\n const MagickBooleanType,ExceptionInfo *);",
"static void\n WriteTo8BimProfile(Image *,const char*,const StringInfo *);\n\f\n/*\n Typedef declarations\n*/\nstruct _ProfileInfo\n{\n char\n *name;",
" size_t\n length;",
" unsigned char\n *info;",
" size_t\n signature;\n};",
"typedef struct _CMSExceptionInfo\n{\n Image\n *image;",
" ExceptionInfo\n *exception;\n} CMSExceptionInfo;\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% C l o n e I m a g e P r o f i l e s %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% CloneImageProfiles() clones one or more image profiles.\n%\n% The format of the CloneImageProfiles method is:\n%\n% MagickBooleanType CloneImageProfiles(Image *image,\n% const Image *clone_image)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o clone_image: the clone image.\n%\n*/\nMagickExport MagickBooleanType CloneImageProfiles(Image *image,\n const Image *clone_image)\n{\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n assert(clone_image != (const Image *) NULL);\n assert(clone_image->signature == MagickCoreSignature);\n if (clone_image->profiles != (void *) NULL)\n {\n if (image->profiles != (void *) NULL)\n DestroyImageProfiles(image);\n image->profiles=CloneSplayTree((SplayTreeInfo *) clone_image->profiles,\n (void *(*)(void *)) ConstantString,(void *(*)(void *)) CloneStringInfo);\n }\n return(MagickTrue);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% D e l e t e I m a g e P r o f i l e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% DeleteImageProfile() deletes a profile from the image by its name.\n%\n% The format of the DeleteImageProfile method is:\n%\n% MagickBooleanTyupe DeleteImageProfile(Image *image,const char *name)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o name: the profile name.\n%\n*/\nMagickExport MagickBooleanType DeleteImageProfile(Image *image,const char *name)\n{\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n return(MagickFalse);\n WriteTo8BimProfile(image,name,(StringInfo *) NULL);\n return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->profiles,name));\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% D e s t r o y I m a g e P r o f i l e s %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% DestroyImageProfiles() releases memory associated with an image profile map.\n%\n% The format of the DestroyProfiles method is:\n%\n% void DestroyImageProfiles(Image *image)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n*/\nMagickExport void DestroyImageProfiles(Image *image)\n{\n if (image->profiles != (SplayTreeInfo *) NULL)\n image->profiles=DestroySplayTree((SplayTreeInfo *) image->profiles);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% G e t I m a g e P r o f i l e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% GetImageProfile() gets a profile associated with an image by name.\n%\n% The format of the GetImageProfile method is:\n%\n% const StringInfo *GetImageProfile(const Image *image,const char *name)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o name: the profile name.\n%\n*/\nMagickExport const StringInfo *GetImageProfile(const Image *image,\n const char *name)\n{\n const StringInfo\n *profile;",
" assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n return((StringInfo *) NULL);\n profile=(const StringInfo *) GetValueFromSplayTree((SplayTreeInfo *)\n image->profiles,name);\n return(profile);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% G e t N e x t I m a g e P r o f i l e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% GetNextImageProfile() gets the next profile name for an image.\n%\n% The format of the GetNextImageProfile method is:\n%\n% char *GetNextImageProfile(const Image *image)\n%\n% A description of each parameter follows:\n%\n% o hash_info: the hash info.\n%\n*/\nMagickExport char *GetNextImageProfile(const Image *image)\n{\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n return((char *) NULL);\n return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->profiles));\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% P r o f i l e I m a g e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% ProfileImage() associates, applies, or removes an ICM, IPTC, or generic\n% profile with / to / from an image. If the profile is NULL, it is removed\n% from the image otherwise added or applied. Use a name of '*' and a profile\n% of NULL to remove all profiles from the image.\n%\n% ICC and ICM profiles are handled as follows: If the image does not have\n% an associated color profile, the one you provide is associated with the\n% image and the image pixels are not transformed. Otherwise, the colorspace\n% transform defined by the existing and new profile are applied to the image\n% pixels and the new profile is associated with the image.\n%\n% The format of the ProfileImage method is:\n%\n% MagickBooleanType ProfileImage(Image *image,const char *name,\n% const void *datum,const size_t length,const MagickBooleanType clone)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o name: Name of profile to add or remove: ICC, IPTC, or generic profile.\n%\n% o datum: the profile data.\n%\n% o length: the length of the profile.\n%\n% o clone: should be MagickFalse.\n%\n*/",
"#if defined(MAGICKCORE_LCMS_DELEGATE)\nstatic unsigned short **DestroyPixelThreadSet(unsigned short **pixels)\n{\n register ssize_t\n i;",
" assert(pixels != (unsigned short **) NULL);\n for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)\n if (pixels[i] != (unsigned short *) NULL)\n pixels[i]=(unsigned short *) RelinquishMagickMemory(pixels[i]);\n pixels=(unsigned short **) RelinquishMagickMemory(pixels);\n return(pixels);\n}",
"static unsigned short **AcquirePixelThreadSet(const size_t columns,\n const size_t channels)\n{\n register ssize_t\n i;",
" unsigned short\n **pixels;",
" size_t\n number_threads;",
" number_threads=(size_t) GetMagickResourceLimit(ThreadResource);\n pixels=(unsigned short **) AcquireQuantumMemory(number_threads,\n sizeof(*pixels));\n if (pixels == (unsigned short **) NULL)\n return((unsigned short **) NULL);\n (void) ResetMagickMemory(pixels,0,number_threads*sizeof(*pixels));\n for (i=0; i < (ssize_t) number_threads; i++)\n {\n pixels[i]=(unsigned short *) AcquireQuantumMemory(columns,channels*\n sizeof(**pixels));\n if (pixels[i] == (unsigned short *) NULL)\n return(DestroyPixelThreadSet(pixels));\n }\n return(pixels);\n}",
"static cmsHTRANSFORM *DestroyTransformThreadSet(cmsHTRANSFORM *transform)\n{\n register ssize_t\n i;",
" assert(transform != (cmsHTRANSFORM *) NULL);\n for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)\n if (transform[i] != (cmsHTRANSFORM) NULL)\n cmsDeleteTransform(transform[i]);\n transform=(cmsHTRANSFORM *) RelinquishMagickMemory(transform);\n return(transform);\n}",
"static cmsHTRANSFORM *AcquireTransformThreadSet(Image *image,\n const cmsHPROFILE source_profile,const cmsUInt32Number source_type,\n const cmsHPROFILE target_profile,const cmsUInt32Number target_type,\n const int intent,const cmsUInt32Number flags)\n{\n cmsHTRANSFORM\n *transform;",
" register ssize_t\n i;",
" size_t\n number_threads;",
" number_threads=(size_t) GetMagickResourceLimit(ThreadResource);\n transform=(cmsHTRANSFORM *) AcquireQuantumMemory(number_threads,\n sizeof(*transform));\n if (transform == (cmsHTRANSFORM *) NULL)\n return((cmsHTRANSFORM *) NULL);\n (void) ResetMagickMemory(transform,0,number_threads*sizeof(*transform));\n for (i=0; i < (ssize_t) number_threads; i++)\n {\n transform[i]=cmsCreateTransformTHR((cmsContext) image,source_profile,\n source_type,target_profile,target_type,intent,flags);\n if (transform[i] == (cmsHTRANSFORM) NULL)\n return(DestroyTransformThreadSet(transform));\n }\n return(transform);\n}\n#endif",
"#if defined(MAGICKCORE_LCMS_DELEGATE)\nstatic void CMSExceptionHandler(cmsContext context,cmsUInt32Number severity,\n const char *message)\n{\n CMSExceptionInfo\n *cms_exception;",
" ExceptionInfo\n *exception;",
" Image\n *image;",
" cms_exception=(CMSExceptionInfo *) context;\n if (cms_exception == (CMSExceptionInfo *) NULL)\n return;\n exception=cms_exception->exception;\n if (exception == (ExceptionInfo *) NULL)\n return;\n image=cms_exception->image;\n if (image == (Image *) NULL)\n {\n (void) ThrowMagickException(exception,GetMagickModule(),ImageWarning,\n \"UnableToTransformColorspace\",\"`%s'\",\"unknown context\");\n return;\n }\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TransformEvent,GetMagickModule(),\"lcms: #%u, %s\",\n severity,message != (char *) NULL ? message : \"no message\");\n (void) ThrowMagickException(exception,GetMagickModule(),ImageWarning,\n \"UnableToTransformColorspace\",\"`%s'\",image->filename);\n}\n#endif",
"static MagickBooleanType SetsRGBImageProfile(Image *image,\n ExceptionInfo *exception)\n{\n static unsigned char\n sRGBProfile[] =\n {\n 0x00, 0x00, 0x0c, 0x8c, 0x61, 0x72, 0x67, 0x6c, 0x02, 0x20, 0x00, 0x00,\n 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20,\n 0x07, 0xde, 0x00, 0x01, 0x00, 0x06, 0x00, 0x16, 0x00, 0x0f, 0x00, 0x3a,\n 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54, 0x00, 0x00, 0x00, 0x00,\n 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6,\n 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x61, 0x72, 0x67, 0x6c,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,\n 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x01, 0x50, 0x00, 0x00, 0x00, 0x99,\n 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x01, 0xec, 0x00, 0x00, 0x00, 0x67,\n 0x64, 0x6d, 0x6e, 0x64, 0x00, 0x00, 0x02, 0x54, 0x00, 0x00, 0x00, 0x70,\n 0x64, 0x6d, 0x64, 0x64, 0x00, 0x00, 0x02, 0xc4, 0x00, 0x00, 0x00, 0x88,\n 0x74, 0x65, 0x63, 0x68, 0x00, 0x00, 0x03, 0x4c, 0x00, 0x00, 0x00, 0x0c,\n 0x76, 0x75, 0x65, 0x64, 0x00, 0x00, 0x03, 0x58, 0x00, 0x00, 0x00, 0x67,\n 0x76, 0x69, 0x65, 0x77, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x24,\n 0x6c, 0x75, 0x6d, 0x69, 0x00, 0x00, 0x03, 0xe4, 0x00, 0x00, 0x00, 0x14,\n 0x6d, 0x65, 0x61, 0x73, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x24,\n 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x04, 0x1c, 0x00, 0x00, 0x00, 0x14,\n 0x62, 0x6b, 0x70, 0x74, 0x00, 0x00, 0x04, 0x30, 0x00, 0x00, 0x00, 0x14,\n 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x44, 0x00, 0x00, 0x00, 0x14,\n 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x58, 0x00, 0x00, 0x00, 0x14,\n 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x6c, 0x00, 0x00, 0x00, 0x14,\n 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c,\n 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c,\n 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c,\n 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,\n 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36,\n 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x28, 0x45, 0x71, 0x75, 0x69, 0x76,\n 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x77, 0x77, 0x77,\n 0x2e, 0x73, 0x72, 0x67, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x20, 0x31, 0x39,\n 0x39, 0x38, 0x20, 0x48, 0x50, 0x20, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c,\n 0x65, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x3f, 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31,\n 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x28, 0x45, 0x71, 0x75,\n 0x69, 0x76, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x77,\n 0x77, 0x77, 0x2e, 0x73, 0x72, 0x67, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x20,\n 0x31, 0x39, 0x39, 0x38, 0x20, 0x48, 0x50, 0x20, 0x70, 0x72, 0x6f, 0x66,\n 0x69, 0x6c, 0x65, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x43, 0x72, 0x65, 0x61,\n 0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x47, 0x72, 0x61, 0x65, 0x6d,\n 0x65, 0x20, 0x57, 0x2e, 0x20, 0x47, 0x69, 0x6c, 0x6c, 0x2e, 0x20, 0x52,\n 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x74, 0x6f,\n 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,\n 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x20, 0x4e, 0x6f, 0x20, 0x57,\n 0x61, 0x72, 0x72, 0x61, 0x6e, 0x74, 0x79, 0x2c, 0x20, 0x55, 0x73, 0x65,\n 0x20, 0x61, 0x74, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e,\n 0x20, 0x72, 0x69, 0x73, 0x6b, 0x2e, 0x00, 0x00, 0x64, 0x65, 0x73, 0x63,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x49, 0x45, 0x43, 0x20,\n 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69,\n 0x65, 0x63, 0x2e, 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x16, 0x49, 0x45, 0x43, 0x20, 0x68, 0x74, 0x74,\n 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x65, 0x63, 0x2e,\n 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e,\n 0x49, 0x45, 0x43, 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e,\n 0x31, 0x20, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47,\n 0x42, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x70, 0x61,\n 0x63, 0x65, 0x20, 0x2d, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, 0x49, 0x45, 0x43,\n 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x44,\n 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47, 0x42, 0x20, 0x63,\n 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20,\n 0x2d, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x73, 0x69, 0x67, 0x20, 0x00, 0x00, 0x00, 0x00,\n 0x43, 0x52, 0x54, 0x20, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x0d, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36,\n 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x0d, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36,\n 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x76, 0x69, 0x65, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xa4, 0x7c,\n 0x00, 0x14, 0x5f, 0x30, 0x00, 0x10, 0xce, 0x02, 0x00, 0x03, 0xed, 0xb2,\n 0x00, 0x04, 0x13, 0x0a, 0x00, 0x03, 0x5c, 0x67, 0x00, 0x00, 0x00, 0x01,\n 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x0a, 0x3d,\n 0x00, 0x50, 0x00, 0x00, 0x00, 0x57, 0x1e, 0xb8, 0x6d, 0x65, 0x61, 0x73,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x02, 0x8f, 0x00, 0x00, 0x00, 0x02, 0x58, 0x59, 0x5a, 0x20,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x51, 0x00, 0x01, 0x00, 0x00,\n 0x00, 0x01, 0x16, 0xcc, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xa0,\n 0x00, 0x00, 0x38, 0xf5, 0x00, 0x00, 0x03, 0x90, 0x58, 0x59, 0x5a, 0x20,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x97, 0x00, 0x00, 0xb7, 0x87,\n 0x00, 0x00, 0x18, 0xd9, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x24, 0x9f, 0x00, 0x00, 0x0f, 0x84, 0x00, 0x00, 0xb6, 0xc4,\n 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,\n 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x0f, 0x00, 0x14, 0x00, 0x19,\n 0x00, 0x1e, 0x00, 0x23, 0x00, 0x28, 0x00, 0x2d, 0x00, 0x32, 0x00, 0x37,\n 0x00, 0x3b, 0x00, 0x40, 0x00, 0x45, 0x00, 0x4a, 0x00, 0x4f, 0x00, 0x54,\n 0x00, 0x59, 0x00, 0x5e, 0x00, 0x63, 0x00, 0x68, 0x00, 0x6d, 0x00, 0x72,\n 0x00, 0x77, 0x00, 0x7c, 0x00, 0x81, 0x00, 0x86, 0x00, 0x8b, 0x00, 0x90,\n 0x00, 0x95, 0x00, 0x9a, 0x00, 0x9f, 0x00, 0xa4, 0x00, 0xa9, 0x00, 0xae,\n 0x00, 0xb2, 0x00, 0xb7, 0x00, 0xbc, 0x00, 0xc1, 0x00, 0xc6, 0x00, 0xcb,\n 0x00, 0xd0, 0x00, 0xd5, 0x00, 0xdb, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0xeb,\n 0x00, 0xf0, 0x00, 0xf6, 0x00, 0xfb, 0x01, 0x01, 0x01, 0x07, 0x01, 0x0d,\n 0x01, 0x13, 0x01, 0x19, 0x01, 0x1f, 0x01, 0x25, 0x01, 0x2b, 0x01, 0x32,\n 0x01, 0x38, 0x01, 0x3e, 0x01, 0x45, 0x01, 0x4c, 0x01, 0x52, 0x01, 0x59,\n 0x01, 0x60, 0x01, 0x67, 0x01, 0x6e, 0x01, 0x75, 0x01, 0x7c, 0x01, 0x83,\n 0x01, 0x8b, 0x01, 0x92, 0x01, 0x9a, 0x01, 0xa1, 0x01, 0xa9, 0x01, 0xb1,\n 0x01, 0xb9, 0x01, 0xc1, 0x01, 0xc9, 0x01, 0xd1, 0x01, 0xd9, 0x01, 0xe1,\n 0x01, 0xe9, 0x01, 0xf2, 0x01, 0xfa, 0x02, 0x03, 0x02, 0x0c, 0x02, 0x14,\n 0x02, 0x1d, 0x02, 0x26, 0x02, 0x2f, 0x02, 0x38, 0x02, 0x41, 0x02, 0x4b,\n 0x02, 0x54, 0x02, 0x5d, 0x02, 0x67, 0x02, 0x71, 0x02, 0x7a, 0x02, 0x84,\n 0x02, 0x8e, 0x02, 0x98, 0x02, 0xa2, 0x02, 0xac, 0x02, 0xb6, 0x02, 0xc1,\n 0x02, 0xcb, 0x02, 0xd5, 0x02, 0xe0, 0x02, 0xeb, 0x02, 0xf5, 0x03, 0x00,\n 0x03, 0x0b, 0x03, 0x16, 0x03, 0x21, 0x03, 0x2d, 0x03, 0x38, 0x03, 0x43,\n 0x03, 0x4f, 0x03, 0x5a, 0x03, 0x66, 0x03, 0x72, 0x03, 0x7e, 0x03, 0x8a,\n 0x03, 0x96, 0x03, 0xa2, 0x03, 0xae, 0x03, 0xba, 0x03, 0xc7, 0x03, 0xd3,\n 0x03, 0xe0, 0x03, 0xec, 0x03, 0xf9, 0x04, 0x06, 0x04, 0x13, 0x04, 0x20,\n 0x04, 0x2d, 0x04, 0x3b, 0x04, 0x48, 0x04, 0x55, 0x04, 0x63, 0x04, 0x71,\n 0x04, 0x7e, 0x04, 0x8c, 0x04, 0x9a, 0x04, 0xa8, 0x04, 0xb6, 0x04, 0xc4,\n 0x04, 0xd3, 0x04, 0xe1, 0x04, 0xf0, 0x04, 0xfe, 0x05, 0x0d, 0x05, 0x1c,\n 0x05, 0x2b, 0x05, 0x3a, 0x05, 0x49, 0x05, 0x58, 0x05, 0x67, 0x05, 0x77,\n 0x05, 0x86, 0x05, 0x96, 0x05, 0xa6, 0x05, 0xb5, 0x05, 0xc5, 0x05, 0xd5,\n 0x05, 0xe5, 0x05, 0xf6, 0x06, 0x06, 0x06, 0x16, 0x06, 0x27, 0x06, 0x37,\n 0x06, 0x48, 0x06, 0x59, 0x06, 0x6a, 0x06, 0x7b, 0x06, 0x8c, 0x06, 0x9d,\n 0x06, 0xaf, 0x06, 0xc0, 0x06, 0xd1, 0x06, 0xe3, 0x06, 0xf5, 0x07, 0x07,\n 0x07, 0x19, 0x07, 0x2b, 0x07, 0x3d, 0x07, 0x4f, 0x07, 0x61, 0x07, 0x74,\n 0x07, 0x86, 0x07, 0x99, 0x07, 0xac, 0x07, 0xbf, 0x07, 0xd2, 0x07, 0xe5,\n 0x07, 0xf8, 0x08, 0x0b, 0x08, 0x1f, 0x08, 0x32, 0x08, 0x46, 0x08, 0x5a,\n 0x08, 0x6e, 0x08, 0x82, 0x08, 0x96, 0x08, 0xaa, 0x08, 0xbe, 0x08, 0xd2,\n 0x08, 0xe7, 0x08, 0xfb, 0x09, 0x10, 0x09, 0x25, 0x09, 0x3a, 0x09, 0x4f,\n 0x09, 0x64, 0x09, 0x79, 0x09, 0x8f, 0x09, 0xa4, 0x09, 0xba, 0x09, 0xcf,\n 0x09, 0xe5, 0x09, 0xfb, 0x0a, 0x11, 0x0a, 0x27, 0x0a, 0x3d, 0x0a, 0x54,\n 0x0a, 0x6a, 0x0a, 0x81, 0x0a, 0x98, 0x0a, 0xae, 0x0a, 0xc5, 0x0a, 0xdc,\n 0x0a, 0xf3, 0x0b, 0x0b, 0x0b, 0x22, 0x0b, 0x39, 0x0b, 0x51, 0x0b, 0x69,\n 0x0b, 0x80, 0x0b, 0x98, 0x0b, 0xb0, 0x0b, 0xc8, 0x0b, 0xe1, 0x0b, 0xf9,\n 0x0c, 0x12, 0x0c, 0x2a, 0x0c, 0x43, 0x0c, 0x5c, 0x0c, 0x75, 0x0c, 0x8e,\n 0x0c, 0xa7, 0x0c, 0xc0, 0x0c, 0xd9, 0x0c, 0xf3, 0x0d, 0x0d, 0x0d, 0x26,\n 0x0d, 0x40, 0x0d, 0x5a, 0x0d, 0x74, 0x0d, 0x8e, 0x0d, 0xa9, 0x0d, 0xc3,\n 0x0d, 0xde, 0x0d, 0xf8, 0x0e, 0x13, 0x0e, 0x2e, 0x0e, 0x49, 0x0e, 0x64,\n 0x0e, 0x7f, 0x0e, 0x9b, 0x0e, 0xb6, 0x0e, 0xd2, 0x0e, 0xee, 0x0f, 0x09,\n 0x0f, 0x25, 0x0f, 0x41, 0x0f, 0x5e, 0x0f, 0x7a, 0x0f, 0x96, 0x0f, 0xb3,\n 0x0f, 0xcf, 0x0f, 0xec, 0x10, 0x09, 0x10, 0x26, 0x10, 0x43, 0x10, 0x61,\n 0x10, 0x7e, 0x10, 0x9b, 0x10, 0xb9, 0x10, 0xd7, 0x10, 0xf5, 0x11, 0x13,\n 0x11, 0x31, 0x11, 0x4f, 0x11, 0x6d, 0x11, 0x8c, 0x11, 0xaa, 0x11, 0xc9,\n 0x11, 0xe8, 0x12, 0x07, 0x12, 0x26, 0x12, 0x45, 0x12, 0x64, 0x12, 0x84,\n 0x12, 0xa3, 0x12, 0xc3, 0x12, 0xe3, 0x13, 0x03, 0x13, 0x23, 0x13, 0x43,\n 0x13, 0x63, 0x13, 0x83, 0x13, 0xa4, 0x13, 0xc5, 0x13, 0xe5, 0x14, 0x06,\n 0x14, 0x27, 0x14, 0x49, 0x14, 0x6a, 0x14, 0x8b, 0x14, 0xad, 0x14, 0xce,\n 0x14, 0xf0, 0x15, 0x12, 0x15, 0x34, 0x15, 0x56, 0x15, 0x78, 0x15, 0x9b,\n 0x15, 0xbd, 0x15, 0xe0, 0x16, 0x03, 0x16, 0x26, 0x16, 0x49, 0x16, 0x6c,\n 0x16, 0x8f, 0x16, 0xb2, 0x16, 0xd6, 0x16, 0xfa, 0x17, 0x1d, 0x17, 0x41,\n 0x17, 0x65, 0x17, 0x89, 0x17, 0xae, 0x17, 0xd2, 0x17, 0xf7, 0x18, 0x1b,\n 0x18, 0x40, 0x18, 0x65, 0x18, 0x8a, 0x18, 0xaf, 0x18, 0xd5, 0x18, 0xfa,\n 0x19, 0x20, 0x19, 0x45, 0x19, 0x6b, 0x19, 0x91, 0x19, 0xb7, 0x19, 0xdd,\n 0x1a, 0x04, 0x1a, 0x2a, 0x1a, 0x51, 0x1a, 0x77, 0x1a, 0x9e, 0x1a, 0xc5,\n 0x1a, 0xec, 0x1b, 0x14, 0x1b, 0x3b, 0x1b, 0x63, 0x1b, 0x8a, 0x1b, 0xb2,\n 0x1b, 0xda, 0x1c, 0x02, 0x1c, 0x2a, 0x1c, 0x52, 0x1c, 0x7b, 0x1c, 0xa3,\n 0x1c, 0xcc, 0x1c, 0xf5, 0x1d, 0x1e, 0x1d, 0x47, 0x1d, 0x70, 0x1d, 0x99,\n 0x1d, 0xc3, 0x1d, 0xec, 0x1e, 0x16, 0x1e, 0x40, 0x1e, 0x6a, 0x1e, 0x94,\n 0x1e, 0xbe, 0x1e, 0xe9, 0x1f, 0x13, 0x1f, 0x3e, 0x1f, 0x69, 0x1f, 0x94,\n 0x1f, 0xbf, 0x1f, 0xea, 0x20, 0x15, 0x20, 0x41, 0x20, 0x6c, 0x20, 0x98,\n 0x20, 0xc4, 0x20, 0xf0, 0x21, 0x1c, 0x21, 0x48, 0x21, 0x75, 0x21, 0xa1,\n 0x21, 0xce, 0x21, 0xfb, 0x22, 0x27, 0x22, 0x55, 0x22, 0x82, 0x22, 0xaf,\n 0x22, 0xdd, 0x23, 0x0a, 0x23, 0x38, 0x23, 0x66, 0x23, 0x94, 0x23, 0xc2,\n 0x23, 0xf0, 0x24, 0x1f, 0x24, 0x4d, 0x24, 0x7c, 0x24, 0xab, 0x24, 0xda,\n 0x25, 0x09, 0x25, 0x38, 0x25, 0x68, 0x25, 0x97, 0x25, 0xc7, 0x25, 0xf7,\n 0x26, 0x27, 0x26, 0x57, 0x26, 0x87, 0x26, 0xb7, 0x26, 0xe8, 0x27, 0x18,\n 0x27, 0x49, 0x27, 0x7a, 0x27, 0xab, 0x27, 0xdc, 0x28, 0x0d, 0x28, 0x3f,\n 0x28, 0x71, 0x28, 0xa2, 0x28, 0xd4, 0x29, 0x06, 0x29, 0x38, 0x29, 0x6b,\n 0x29, 0x9d, 0x29, 0xd0, 0x2a, 0x02, 0x2a, 0x35, 0x2a, 0x68, 0x2a, 0x9b,\n 0x2a, 0xcf, 0x2b, 0x02, 0x2b, 0x36, 0x2b, 0x69, 0x2b, 0x9d, 0x2b, 0xd1,\n 0x2c, 0x05, 0x2c, 0x39, 0x2c, 0x6e, 0x2c, 0xa2, 0x2c, 0xd7, 0x2d, 0x0c,\n 0x2d, 0x41, 0x2d, 0x76, 0x2d, 0xab, 0x2d, 0xe1, 0x2e, 0x16, 0x2e, 0x4c,\n 0x2e, 0x82, 0x2e, 0xb7, 0x2e, 0xee, 0x2f, 0x24, 0x2f, 0x5a, 0x2f, 0x91,\n 0x2f, 0xc7, 0x2f, 0xfe, 0x30, 0x35, 0x30, 0x6c, 0x30, 0xa4, 0x30, 0xdb,\n 0x31, 0x12, 0x31, 0x4a, 0x31, 0x82, 0x31, 0xba, 0x31, 0xf2, 0x32, 0x2a,\n 0x32, 0x63, 0x32, 0x9b, 0x32, 0xd4, 0x33, 0x0d, 0x33, 0x46, 0x33, 0x7f,\n 0x33, 0xb8, 0x33, 0xf1, 0x34, 0x2b, 0x34, 0x65, 0x34, 0x9e, 0x34, 0xd8,\n 0x35, 0x13, 0x35, 0x4d, 0x35, 0x87, 0x35, 0xc2, 0x35, 0xfd, 0x36, 0x37,\n 0x36, 0x72, 0x36, 0xae, 0x36, 0xe9, 0x37, 0x24, 0x37, 0x60, 0x37, 0x9c,\n 0x37, 0xd7, 0x38, 0x14, 0x38, 0x50, 0x38, 0x8c, 0x38, 0xc8, 0x39, 0x05,\n 0x39, 0x42, 0x39, 0x7f, 0x39, 0xbc, 0x39, 0xf9, 0x3a, 0x36, 0x3a, 0x74,\n 0x3a, 0xb2, 0x3a, 0xef, 0x3b, 0x2d, 0x3b, 0x6b, 0x3b, 0xaa, 0x3b, 0xe8,\n 0x3c, 0x27, 0x3c, 0x65, 0x3c, 0xa4, 0x3c, 0xe3, 0x3d, 0x22, 0x3d, 0x61,\n 0x3d, 0xa1, 0x3d, 0xe0, 0x3e, 0x20, 0x3e, 0x60, 0x3e, 0xa0, 0x3e, 0xe0,\n 0x3f, 0x21, 0x3f, 0x61, 0x3f, 0xa2, 0x3f, 0xe2, 0x40, 0x23, 0x40, 0x64,\n 0x40, 0xa6, 0x40, 0xe7, 0x41, 0x29, 0x41, 0x6a, 0x41, 0xac, 0x41, 0xee,\n 0x42, 0x30, 0x42, 0x72, 0x42, 0xb5, 0x42, 0xf7, 0x43, 0x3a, 0x43, 0x7d,\n 0x43, 0xc0, 0x44, 0x03, 0x44, 0x47, 0x44, 0x8a, 0x44, 0xce, 0x45, 0x12,\n 0x45, 0x55, 0x45, 0x9a, 0x45, 0xde, 0x46, 0x22, 0x46, 0x67, 0x46, 0xab,\n 0x46, 0xf0, 0x47, 0x35, 0x47, 0x7b, 0x47, 0xc0, 0x48, 0x05, 0x48, 0x4b,\n 0x48, 0x91, 0x48, 0xd7, 0x49, 0x1d, 0x49, 0x63, 0x49, 0xa9, 0x49, 0xf0,\n 0x4a, 0x37, 0x4a, 0x7d, 0x4a, 0xc4, 0x4b, 0x0c, 0x4b, 0x53, 0x4b, 0x9a,\n 0x4b, 0xe2, 0x4c, 0x2a, 0x4c, 0x72, 0x4c, 0xba, 0x4d, 0x02, 0x4d, 0x4a,\n 0x4d, 0x93, 0x4d, 0xdc, 0x4e, 0x25, 0x4e, 0x6e, 0x4e, 0xb7, 0x4f, 0x00,\n 0x4f, 0x49, 0x4f, 0x93, 0x4f, 0xdd, 0x50, 0x27, 0x50, 0x71, 0x50, 0xbb,\n 0x51, 0x06, 0x51, 0x50, 0x51, 0x9b, 0x51, 0xe6, 0x52, 0x31, 0x52, 0x7c,\n 0x52, 0xc7, 0x53, 0x13, 0x53, 0x5f, 0x53, 0xaa, 0x53, 0xf6, 0x54, 0x42,\n 0x54, 0x8f, 0x54, 0xdb, 0x55, 0x28, 0x55, 0x75, 0x55, 0xc2, 0x56, 0x0f,\n 0x56, 0x5c, 0x56, 0xa9, 0x56, 0xf7, 0x57, 0x44, 0x57, 0x92, 0x57, 0xe0,\n 0x58, 0x2f, 0x58, 0x7d, 0x58, 0xcb, 0x59, 0x1a, 0x59, 0x69, 0x59, 0xb8,\n 0x5a, 0x07, 0x5a, 0x56, 0x5a, 0xa6, 0x5a, 0xf5, 0x5b, 0x45, 0x5b, 0x95,\n 0x5b, 0xe5, 0x5c, 0x35, 0x5c, 0x86, 0x5c, 0xd6, 0x5d, 0x27, 0x5d, 0x78,\n 0x5d, 0xc9, 0x5e, 0x1a, 0x5e, 0x6c, 0x5e, 0xbd, 0x5f, 0x0f, 0x5f, 0x61,\n 0x5f, 0xb3, 0x60, 0x05, 0x60, 0x57, 0x60, 0xaa, 0x60, 0xfc, 0x61, 0x4f,\n 0x61, 0xa2, 0x61, 0xf5, 0x62, 0x49, 0x62, 0x9c, 0x62, 0xf0, 0x63, 0x43,\n 0x63, 0x97, 0x63, 0xeb, 0x64, 0x40, 0x64, 0x94, 0x64, 0xe9, 0x65, 0x3d,\n 0x65, 0x92, 0x65, 0xe7, 0x66, 0x3d, 0x66, 0x92, 0x66, 0xe8, 0x67, 0x3d,\n 0x67, 0x93, 0x67, 0xe9, 0x68, 0x3f, 0x68, 0x96, 0x68, 0xec, 0x69, 0x43,\n 0x69, 0x9a, 0x69, 0xf1, 0x6a, 0x48, 0x6a, 0x9f, 0x6a, 0xf7, 0x6b, 0x4f,\n 0x6b, 0xa7, 0x6b, 0xff, 0x6c, 0x57, 0x6c, 0xaf, 0x6d, 0x08, 0x6d, 0x60,\n 0x6d, 0xb9, 0x6e, 0x12, 0x6e, 0x6b, 0x6e, 0xc4, 0x6f, 0x1e, 0x6f, 0x78,\n 0x6f, 0xd1, 0x70, 0x2b, 0x70, 0x86, 0x70, 0xe0, 0x71, 0x3a, 0x71, 0x95,\n 0x71, 0xf0, 0x72, 0x4b, 0x72, 0xa6, 0x73, 0x01, 0x73, 0x5d, 0x73, 0xb8,\n 0x74, 0x14, 0x74, 0x70, 0x74, 0xcc, 0x75, 0x28, 0x75, 0x85, 0x75, 0xe1,\n 0x76, 0x3e, 0x76, 0x9b, 0x76, 0xf8, 0x77, 0x56, 0x77, 0xb3, 0x78, 0x11,\n 0x78, 0x6e, 0x78, 0xcc, 0x79, 0x2a, 0x79, 0x89, 0x79, 0xe7, 0x7a, 0x46,\n 0x7a, 0xa5, 0x7b, 0x04, 0x7b, 0x63, 0x7b, 0xc2, 0x7c, 0x21, 0x7c, 0x81,\n 0x7c, 0xe1, 0x7d, 0x41, 0x7d, 0xa1, 0x7e, 0x01, 0x7e, 0x62, 0x7e, 0xc2,\n 0x7f, 0x23, 0x7f, 0x84, 0x7f, 0xe5, 0x80, 0x47, 0x80, 0xa8, 0x81, 0x0a,\n 0x81, 0x6b, 0x81, 0xcd, 0x82, 0x30, 0x82, 0x92, 0x82, 0xf4, 0x83, 0x57,\n 0x83, 0xba, 0x84, 0x1d, 0x84, 0x80, 0x84, 0xe3, 0x85, 0x47, 0x85, 0xab,\n 0x86, 0x0e, 0x86, 0x72, 0x86, 0xd7, 0x87, 0x3b, 0x87, 0x9f, 0x88, 0x04,\n 0x88, 0x69, 0x88, 0xce, 0x89, 0x33, 0x89, 0x99, 0x89, 0xfe, 0x8a, 0x64,\n 0x8a, 0xca, 0x8b, 0x30, 0x8b, 0x96, 0x8b, 0xfc, 0x8c, 0x63, 0x8c, 0xca,\n 0x8d, 0x31, 0x8d, 0x98, 0x8d, 0xff, 0x8e, 0x66, 0x8e, 0xce, 0x8f, 0x36,\n 0x8f, 0x9e, 0x90, 0x06, 0x90, 0x6e, 0x90, 0xd6, 0x91, 0x3f, 0x91, 0xa8,\n 0x92, 0x11, 0x92, 0x7a, 0x92, 0xe3, 0x93, 0x4d, 0x93, 0xb6, 0x94, 0x20,\n 0x94, 0x8a, 0x94, 0xf4, 0x95, 0x5f, 0x95, 0xc9, 0x96, 0x34, 0x96, 0x9f,\n 0x97, 0x0a, 0x97, 0x75, 0x97, 0xe0, 0x98, 0x4c, 0x98, 0xb8, 0x99, 0x24,\n 0x99, 0x90, 0x99, 0xfc, 0x9a, 0x68, 0x9a, 0xd5, 0x9b, 0x42, 0x9b, 0xaf,\n 0x9c, 0x1c, 0x9c, 0x89, 0x9c, 0xf7, 0x9d, 0x64, 0x9d, 0xd2, 0x9e, 0x40,\n 0x9e, 0xae, 0x9f, 0x1d, 0x9f, 0x8b, 0x9f, 0xfa, 0xa0, 0x69, 0xa0, 0xd8,\n 0xa1, 0x47, 0xa1, 0xb6, 0xa2, 0x26, 0xa2, 0x96, 0xa3, 0x06, 0xa3, 0x76,\n 0xa3, 0xe6, 0xa4, 0x56, 0xa4, 0xc7, 0xa5, 0x38, 0xa5, 0xa9, 0xa6, 0x1a,\n 0xa6, 0x8b, 0xa6, 0xfd, 0xa7, 0x6e, 0xa7, 0xe0, 0xa8, 0x52, 0xa8, 0xc4,\n 0xa9, 0x37, 0xa9, 0xa9, 0xaa, 0x1c, 0xaa, 0x8f, 0xab, 0x02, 0xab, 0x75,\n 0xab, 0xe9, 0xac, 0x5c, 0xac, 0xd0, 0xad, 0x44, 0xad, 0xb8, 0xae, 0x2d,\n 0xae, 0xa1, 0xaf, 0x16, 0xaf, 0x8b, 0xb0, 0x00, 0xb0, 0x75, 0xb0, 0xea,\n 0xb1, 0x60, 0xb1, 0xd6, 0xb2, 0x4b, 0xb2, 0xc2, 0xb3, 0x38, 0xb3, 0xae,\n 0xb4, 0x25, 0xb4, 0x9c, 0xb5, 0x13, 0xb5, 0x8a, 0xb6, 0x01, 0xb6, 0x79,\n 0xb6, 0xf0, 0xb7, 0x68, 0xb7, 0xe0, 0xb8, 0x59, 0xb8, 0xd1, 0xb9, 0x4a,\n 0xb9, 0xc2, 0xba, 0x3b, 0xba, 0xb5, 0xbb, 0x2e, 0xbb, 0xa7, 0xbc, 0x21,\n 0xbc, 0x9b, 0xbd, 0x15, 0xbd, 0x8f, 0xbe, 0x0a, 0xbe, 0x84, 0xbe, 0xff,\n 0xbf, 0x7a, 0xbf, 0xf5, 0xc0, 0x70, 0xc0, 0xec, 0xc1, 0x67, 0xc1, 0xe3,\n 0xc2, 0x5f, 0xc2, 0xdb, 0xc3, 0x58, 0xc3, 0xd4, 0xc4, 0x51, 0xc4, 0xce,\n 0xc5, 0x4b, 0xc5, 0xc8, 0xc6, 0x46, 0xc6, 0xc3, 0xc7, 0x41, 0xc7, 0xbf,\n 0xc8, 0x3d, 0xc8, 0xbc, 0xc9, 0x3a, 0xc9, 0xb9, 0xca, 0x38, 0xca, 0xb7,\n 0xcb, 0x36, 0xcb, 0xb6, 0xcc, 0x35, 0xcc, 0xb5, 0xcd, 0x35, 0xcd, 0xb5,\n 0xce, 0x36, 0xce, 0xb6, 0xcf, 0x37, 0xcf, 0xb8, 0xd0, 0x39, 0xd0, 0xba,\n 0xd1, 0x3c, 0xd1, 0xbe, 0xd2, 0x3f, 0xd2, 0xc1, 0xd3, 0x44, 0xd3, 0xc6,\n 0xd4, 0x49, 0xd4, 0xcb, 0xd5, 0x4e, 0xd5, 0xd1, 0xd6, 0x55, 0xd6, 0xd8,\n 0xd7, 0x5c, 0xd7, 0xe0, 0xd8, 0x64, 0xd8, 0xe8, 0xd9, 0x6c, 0xd9, 0xf1,\n 0xda, 0x76, 0xda, 0xfb, 0xdb, 0x80, 0xdc, 0x05, 0xdc, 0x8a, 0xdd, 0x10,\n 0xdd, 0x96, 0xde, 0x1c, 0xde, 0xa2, 0xdf, 0x29, 0xdf, 0xaf, 0xe0, 0x36,\n 0xe0, 0xbd, 0xe1, 0x44, 0xe1, 0xcc, 0xe2, 0x53, 0xe2, 0xdb, 0xe3, 0x63,\n 0xe3, 0xeb, 0xe4, 0x73, 0xe4, 0xfc, 0xe5, 0x84, 0xe6, 0x0d, 0xe6, 0x96,\n 0xe7, 0x1f, 0xe7, 0xa9, 0xe8, 0x32, 0xe8, 0xbc, 0xe9, 0x46, 0xe9, 0xd0,\n 0xea, 0x5b, 0xea, 0xe5, 0xeb, 0x70, 0xeb, 0xfb, 0xec, 0x86, 0xed, 0x11,\n 0xed, 0x9c, 0xee, 0x28, 0xee, 0xb4, 0xef, 0x40, 0xef, 0xcc, 0xf0, 0x58,\n 0xf0, 0xe5, 0xf1, 0x72, 0xf1, 0xff, 0xf2, 0x8c, 0xf3, 0x19, 0xf3, 0xa7,\n 0xf4, 0x34, 0xf4, 0xc2, 0xf5, 0x50, 0xf5, 0xde, 0xf6, 0x6d, 0xf6, 0xfb,\n 0xf7, 0x8a, 0xf8, 0x19, 0xf8, 0xa8, 0xf9, 0x38, 0xf9, 0xc7, 0xfa, 0x57,\n 0xfa, 0xe7, 0xfb, 0x77, 0xfc, 0x07, 0xfc, 0x98, 0xfd, 0x29, 0xfd, 0xba,\n 0xfe, 0x4b, 0xfe, 0xdc, 0xff, 0x6d, 0xff, 0xff\n };",
" StringInfo\n *profile;",
" MagickBooleanType\n status;",
" assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (GetImageProfile(image,\"icc\") != (const StringInfo *) NULL)\n return(MagickFalse);\n profile=AcquireStringInfo(sizeof(sRGBProfile));\n SetStringInfoDatum(profile,sRGBProfile);\n status=SetImageProfile(image,\"icc\",profile,exception);\n profile=DestroyStringInfo(profile);\n return(status);\n}",
"MagickExport MagickBooleanType ProfileImage(Image *image,const char *name,\n const void *datum,const size_t length,ExceptionInfo *exception)\n{\n#define ProfileImageTag \"Profile/Image\"\n#define ThrowProfileException(severity,tag,context) \\\n{ \\\n if (source_profile != (cmsHPROFILE) NULL) \\\n (void) cmsCloseProfile(source_profile); \\\n if (target_profile != (cmsHPROFILE) NULL) \\\n (void) cmsCloseProfile(target_profile); \\\n ThrowBinaryException(severity,tag,context); \\\n}",
" MagickBooleanType\n status;",
" StringInfo\n *profile;",
" assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n assert(name != (const char *) NULL);\n if ((datum == (const void *) NULL) || (length == 0))\n {\n char\n *next;",
" /*\n Delete image profile(s).\n */\n ResetImageProfileIterator(image);\n for (next=GetNextImageProfile(image); next != (const char *) NULL; )\n {\n if (IsOptionMember(next,name) != MagickFalse)\n {\n (void) DeleteImageProfile(image,next);\n ResetImageProfileIterator(image);\n }\n next=GetNextImageProfile(image);\n }\n return(MagickTrue);\n }\n /*\n Add a ICC, IPTC, or generic profile to the image.\n */\n status=MagickTrue;\n profile=AcquireStringInfo((size_t) length);\n SetStringInfoDatum(profile,(unsigned char *) datum);\n if ((LocaleCompare(name,\"icc\") != 0) && (LocaleCompare(name,\"icm\") != 0))\n status=SetImageProfile(image,name,profile,exception);\n else\n {\n const StringInfo\n *icc_profile;",
" icc_profile=GetImageProfile(image,\"icc\");\n if ((icc_profile != (const StringInfo *) NULL) &&\n (CompareStringInfo(icc_profile,profile) == 0))\n {\n const char\n *value;",
" value=GetImageProperty(image,\"exif:ColorSpace\",exception);\n (void) value;\n if (LocaleCompare(value,\"1\") != 0)\n (void) SetsRGBImageProfile(image,exception);\n value=GetImageProperty(image,\"exif:InteroperabilityIndex\",exception);\n if (LocaleCompare(value,\"R98.\") != 0)\n (void) SetsRGBImageProfile(image,exception);\n /* Future.\n value=GetImageProperty(image,\"exif:InteroperabilityIndex\",exception);\n if (LocaleCompare(value,\"R03.\") != 0)\n (void) SetAdobeRGB1998ImageProfile(image,exception);\n */\n icc_profile=GetImageProfile(image,\"icc\");\n }\n if ((icc_profile != (const StringInfo *) NULL) &&\n (CompareStringInfo(icc_profile,profile) == 0))\n {\n profile=DestroyStringInfo(profile);\n return(MagickTrue);\n }\n#if !defined(MAGICKCORE_LCMS_DELEGATE)\n (void) ThrowMagickException(exception,GetMagickModule(),\n MissingDelegateWarning,\"DelegateLibrarySupportNotBuiltIn\",\n \"'%s' (LCMS)\",image->filename);\n#else\n {\n cmsHPROFILE\n source_profile;",
" CMSExceptionInfo\n cms_exception;",
" /*\n Transform pixel colors as defined by the color profiles.\n */\n cmsSetLogErrorHandler(CMSExceptionHandler);\n cms_exception.image=image;\n cms_exception.exception=exception;\n (void) cms_exception;\n source_profile=cmsOpenProfileFromMemTHR((cmsContext) &cms_exception,\n GetStringInfoDatum(profile),(cmsUInt32Number)\n GetStringInfoLength(profile));\n if (source_profile == (cmsHPROFILE) NULL)\n ThrowBinaryException(ResourceLimitError,\n \"ColorspaceColorProfileMismatch\",name);\n if ((cmsGetDeviceClass(source_profile) != cmsSigLinkClass) &&\n (icc_profile == (StringInfo *) NULL))\n status=SetImageProfile(image,name,profile,exception);\n else\n {\n CacheView\n *image_view;",
" ColorspaceType\n source_colorspace,\n target_colorspace;",
" cmsColorSpaceSignature\n signature;",
" cmsHPROFILE\n target_profile;",
" cmsHTRANSFORM\n *magick_restrict transform;",
" cmsUInt32Number\n flags,\n source_type,\n target_type;",
" int\n intent;",
" MagickOffsetType\n progress;",
" size_t\n source_channels,\n target_channels;",
" ssize_t\n y;",
" unsigned short\n **magick_restrict source_pixels,\n **magick_restrict target_pixels;",
" target_profile=(cmsHPROFILE) NULL;\n if (icc_profile != (StringInfo *) NULL)\n {\n target_profile=source_profile;\n source_profile=cmsOpenProfileFromMemTHR((cmsContext)\n &cms_exception,GetStringInfoDatum(icc_profile),\n (cmsUInt32Number) GetStringInfoLength(icc_profile));\n if (source_profile == (cmsHPROFILE) NULL)\n ThrowProfileException(ResourceLimitError,\n \"ColorspaceColorProfileMismatch\",name);\n }\n switch (cmsGetColorSpace(source_profile))\n {\n case cmsSigCmykData:\n {\n source_colorspace=CMYKColorspace;\n source_type=(cmsUInt32Number) TYPE_CMYK_16;\n source_channels=4;\n break;\n }\n case cmsSigGrayData:\n {\n source_colorspace=GRAYColorspace;\n source_type=(cmsUInt32Number) TYPE_GRAY_16;\n source_channels=1;\n break;\n }\n case cmsSigLabData:\n {\n source_colorspace=LabColorspace;\n source_type=(cmsUInt32Number) TYPE_Lab_16;\n source_channels=3;\n break;\n }\n case cmsSigLuvData:\n {\n source_colorspace=YUVColorspace;\n source_type=(cmsUInt32Number) TYPE_YUV_16;\n source_channels=3;\n break;\n }\n case cmsSigRgbData:\n {\n source_colorspace=sRGBColorspace;\n source_type=(cmsUInt32Number) TYPE_RGB_16;\n source_channels=3;\n break;\n }\n case cmsSigXYZData:\n {\n source_colorspace=XYZColorspace;\n source_type=(cmsUInt32Number) TYPE_XYZ_16;\n source_channels=3;\n break;\n }\n case cmsSigYCbCrData:\n {\n source_colorspace=YCbCrColorspace;\n source_type=(cmsUInt32Number) TYPE_YCbCr_16;\n source_channels=3;\n break;\n }\n default:\n {\n source_colorspace=UndefinedColorspace;\n source_type=(cmsUInt32Number) TYPE_RGB_16;\n source_channels=3;\n break;\n }\n }\n signature=cmsGetPCS(source_profile);\n if (target_profile != (cmsHPROFILE) NULL)\n signature=cmsGetColorSpace(target_profile);\n switch (signature)\n {\n case cmsSigCmykData:\n {\n target_colorspace=CMYKColorspace;\n target_type=(cmsUInt32Number) TYPE_CMYK_16;\n target_channels=4;\n break;\n }\n case cmsSigLabData:\n {\n target_colorspace=LabColorspace;\n target_type=(cmsUInt32Number) TYPE_Lab_16;\n target_channels=3;\n break;\n }\n case cmsSigGrayData:\n {\n target_colorspace=GRAYColorspace;\n target_type=(cmsUInt32Number) TYPE_GRAY_16;\n target_channels=1;\n break;\n }\n case cmsSigLuvData:\n {\n target_colorspace=YUVColorspace;\n target_type=(cmsUInt32Number) TYPE_YUV_16;\n target_channels=3;\n break;\n }\n case cmsSigRgbData:\n {\n target_colorspace=sRGBColorspace;\n target_type=(cmsUInt32Number) TYPE_RGB_16;\n target_channels=3;\n break;\n }\n case cmsSigXYZData:\n {\n target_colorspace=XYZColorspace;\n target_type=(cmsUInt32Number) TYPE_XYZ_16;\n target_channels=3;\n break;\n }\n case cmsSigYCbCrData:\n {\n target_colorspace=YCbCrColorspace;\n target_type=(cmsUInt32Number) TYPE_YCbCr_16;\n target_channels=3;\n break;\n }\n default:\n {\n target_colorspace=UndefinedColorspace;\n target_type=(cmsUInt32Number) TYPE_RGB_16;\n target_channels=3;\n break;\n }\n }\n if ((source_colorspace == UndefinedColorspace) ||\n (target_colorspace == UndefinedColorspace))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n if ((source_colorspace == GRAYColorspace) &&\n (SetImageGray(image,exception) == MagickFalse))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n if ((source_colorspace == CMYKColorspace) &&\n (image->colorspace != CMYKColorspace))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n if ((source_colorspace == XYZColorspace) &&\n (image->colorspace != XYZColorspace))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n if ((source_colorspace == YCbCrColorspace) &&\n (image->colorspace != YCbCrColorspace))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n if ((source_colorspace != CMYKColorspace) &&\n (source_colorspace != LabColorspace) &&\n (source_colorspace != XYZColorspace) &&\n (source_colorspace != YCbCrColorspace) &&\n (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n switch (image->rendering_intent)\n {\n case AbsoluteIntent: intent=INTENT_ABSOLUTE_COLORIMETRIC; break;\n case PerceptualIntent: intent=INTENT_PERCEPTUAL; break;\n case RelativeIntent: intent=INTENT_RELATIVE_COLORIMETRIC; break;\n case SaturationIntent: intent=INTENT_SATURATION; break;\n default: intent=INTENT_PERCEPTUAL; break;\n }\n flags=cmsFLAGS_HIGHRESPRECALC;\n#if defined(cmsFLAGS_BLACKPOINTCOMPENSATION)\n if (image->black_point_compensation != MagickFalse)\n flags|=cmsFLAGS_BLACKPOINTCOMPENSATION;\n#endif\n transform=AcquireTransformThreadSet(image,source_profile,\n source_type,target_profile,target_type,intent,flags);\n if (transform == (cmsHTRANSFORM *) NULL)\n ThrowProfileException(ImageError,\"UnableToCreateColorTransform\",\n name);\n /*\n Transform image as dictated by the source & target image profiles.\n */\n source_pixels=AcquirePixelThreadSet(image->columns,source_channels);\n target_pixels=AcquirePixelThreadSet(image->columns,target_channels);\n if ((source_pixels == (unsigned short **) NULL) ||\n (target_pixels == (unsigned short **) NULL))\n {\n transform=DestroyTransformThreadSet(transform);\n ThrowProfileException(ResourceLimitError,\n \"MemoryAllocationFailed\",image->filename);\n }\n if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)\n {\n target_pixels=DestroyPixelThreadSet(target_pixels);\n source_pixels=DestroyPixelThreadSet(source_pixels);\n transform=DestroyTransformThreadSet(transform);\n if (source_profile != (cmsHPROFILE) NULL)\n (void) cmsCloseProfile(source_profile);\n if (target_profile != (cmsHPROFILE) NULL)\n (void) cmsCloseProfile(target_profile);\n return(MagickFalse);\n }\n if (target_colorspace == CMYKColorspace)\n (void) SetImageColorspace(image,target_colorspace,exception);\n progress=0;\n image_view=AcquireAuthenticCacheView(image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp parallel for schedule(static,4) shared(status) \\\n magick_threads(image,image,image->rows,1)\n#endif\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n const int\n id = GetOpenMPThreadId();",
" MagickBooleanType\n sync;",
" register ssize_t\n x;",
" register Quantum\n *magick_restrict q;",
" register unsigned short\n *p;",
" if (status == MagickFalse)\n continue;\n q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,\n exception);\n if (q == (Quantum *) NULL)\n {\n status=MagickFalse;\n continue;\n }\n p=source_pixels[id];\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n *p++=ScaleQuantumToShort(GetPixelRed(image,q));\n if (source_channels > 1)\n {\n *p++=ScaleQuantumToShort(GetPixelGreen(image,q));\n *p++=ScaleQuantumToShort(GetPixelBlue(image,q));\n }\n if (source_channels > 3)\n *p++=ScaleQuantumToShort(GetPixelBlack(image,q));\n q+=GetPixelChannels(image);\n }\n cmsDoTransform(transform[id],source_pixels[id],target_pixels[id],\n (unsigned int) image->columns);\n p=target_pixels[id];\n q-=GetPixelChannels(image)*image->columns;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (target_channels == 1)\n SetPixelGray(image,ScaleShortToQuantum(*p),q);\n else\n SetPixelRed(image,ScaleShortToQuantum(*p),q);\n p++;\n if (target_channels > 1)\n {\n SetPixelGreen(image,ScaleShortToQuantum(*p),q);\n p++;\n SetPixelBlue(image,ScaleShortToQuantum(*p),q);\n p++;\n }\n if (target_channels > 3)\n {\n SetPixelBlack(image,ScaleShortToQuantum(*p),q);\n p++;\n }\n q+=GetPixelChannels(image);\n }\n sync=SyncCacheViewAuthenticPixels(image_view,exception);\n if (sync == MagickFalse)\n status=MagickFalse;\n if (image->progress_monitor != (MagickProgressMonitor) NULL)\n {\n MagickBooleanType\n proceed;",
"#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp critical (MagickCore_ProfileImage)\n#endif\n proceed=SetImageProgress(image,ProfileImageTag,progress++,\n image->rows);\n if (proceed == MagickFalse)\n status=MagickFalse;\n }\n }\n image_view=DestroyCacheView(image_view);\n (void) SetImageColorspace(image,target_colorspace,exception);\n switch (signature)\n {\n case cmsSigRgbData:\n {\n image->type=image->alpha_trait == UndefinedPixelTrait ?\n TrueColorType : TrueColorAlphaType;\n break;\n }\n case cmsSigCmykData:\n {\n image->type=image->alpha_trait == UndefinedPixelTrait ?\n ColorSeparationType : ColorSeparationAlphaType;\n break;\n }\n case cmsSigGrayData:\n {\n image->type=image->alpha_trait == UndefinedPixelTrait ?\n GrayscaleType : GrayscaleAlphaType;\n break;\n }\n default:\n break;\n }\n target_pixels=DestroyPixelThreadSet(target_pixels);\n source_pixels=DestroyPixelThreadSet(source_pixels);\n transform=DestroyTransformThreadSet(transform);\n if ((status != MagickFalse) &&\n (cmsGetDeviceClass(source_profile) != cmsSigLinkClass))\n status=SetImageProfile(image,name,profile,exception);\n if (target_profile != (cmsHPROFILE) NULL)\n (void) cmsCloseProfile(target_profile);\n }\n (void) cmsCloseProfile(source_profile);\n }\n#endif\n }\n profile=DestroyStringInfo(profile);\n return(status);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% R e m o v e I m a g e P r o f i l e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% RemoveImageProfile() removes a named profile from the image and returns its\n% value.\n%\n% The format of the RemoveImageProfile method is:\n%\n% void *RemoveImageProfile(Image *image,const char *name)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o name: the profile name.\n%\n*/\nMagickExport StringInfo *RemoveImageProfile(Image *image,const char *name)\n{\n StringInfo\n *profile;",
" assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n return((StringInfo *) NULL);\n WriteTo8BimProfile(image,name,(StringInfo *) NULL);\n profile=(StringInfo *) RemoveNodeFromSplayTree((SplayTreeInfo *)\n image->profiles,name);\n return(profile);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% R e s e t P r o f i l e I t e r a t o r %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% ResetImageProfileIterator() resets the image profile iterator. Use it in\n% conjunction with GetNextImageProfile() to iterate over all the profiles\n% associated with an image.\n%\n% The format of the ResetImageProfileIterator method is:\n%\n% ResetImageProfileIterator(Image *image)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n*/\nMagickExport void ResetImageProfileIterator(const Image *image)\n{\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n return;\n ResetSplayTreeIterator((SplayTreeInfo *) image->profiles);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% S e t I m a g e P r o f i l e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% SetImageProfile() adds a named profile to the image. If a profile with the\n% same name already exists, it is replaced. This method differs from the\n% ProfileImage() method in that it does not apply CMS color profiles.\n%\n% The format of the SetImageProfile method is:\n%\n% MagickBooleanType SetImageProfile(Image *image,const char *name,\n% const StringInfo *profile)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o name: the profile name, for example icc, exif, and 8bim (8bim is the\n% Photoshop wrapper for iptc profiles).\n%\n% o profile: A StringInfo structure that contains the named profile.\n%\n*/",
"static void *DestroyProfile(void *profile)\n{\n return((void *) DestroyStringInfo((StringInfo *) profile));\n}",
"static inline const unsigned char *ReadResourceByte(const unsigned char *p,\n unsigned char *quantum)\n{\n *quantum=(*p++);\n return(p);\n}",
"static inline const unsigned char *ReadResourceLong(const unsigned char *p,\n unsigned int *quantum)\n{\n *quantum=(unsigned int) (*p++) << 24;\n *quantum|=(unsigned int) (*p++) << 16;\n *quantum|=(unsigned int) (*p++) << 8;\n *quantum|=(unsigned int) (*p++) << 0;\n return(p);\n}",
"static inline const unsigned char *ReadResourceShort(const unsigned char *p,\n unsigned short *quantum)\n{\n *quantum=(unsigned short) (*p++) << 8;\n *quantum|=(unsigned short) (*p++);\n return(p);\n}",
"static inline void WriteResourceLong(unsigned char *p,\n const unsigned int quantum)\n{\n unsigned char\n buffer[4];",
" buffer[0]=(unsigned char) (quantum >> 24);\n buffer[1]=(unsigned char) (quantum >> 16);\n buffer[2]=(unsigned char) (quantum >> 8);\n buffer[3]=(unsigned char) quantum;\n (void) CopyMagickMemory(p,buffer,4);\n}",
"static void WriteTo8BimProfile(Image *image,const char *name,\n const StringInfo *profile)\n{\n const unsigned char\n *datum,\n *q;",
" register const unsigned char\n *p;",
" size_t\n length;",
" StringInfo\n *profile_8bim;",
" ssize_t\n count;",
" unsigned char\n length_byte;",
" unsigned int\n value;",
" unsigned short\n id,\n profile_id;",
" if (LocaleCompare(name,\"icc\") == 0)\n profile_id=0x040f;\n else\n if (LocaleCompare(name,\"iptc\") == 0)\n profile_id=0x0404;\n else\n if (LocaleCompare(name,\"xmp\") == 0)\n profile_id=0x0424;\n else\n return;\n profile_8bim=(StringInfo *) GetValueFromSplayTree((SplayTreeInfo *)\n image->profiles,\"8bim\");\n if (profile_8bim == (StringInfo *) NULL)\n return;\n datum=GetStringInfoDatum(profile_8bim);\n length=GetStringInfoLength(profile_8bim);\n for (p=datum; p < (datum+length-16); )\n {\n q=p;\n if (LocaleNCompare((char *) p,\"8BIM\",4) != 0)\n break;\n p+=4;\n p=ReadResourceShort(p,&id);\n p=ReadResourceByte(p,&length_byte);\n p+=length_byte;\n if (((length_byte+1) & 0x01) != 0)\n p++;\n if (p > (datum+length-4))\n break;\n p=ReadResourceLong(p,&value);\n count=(ssize_t) value;\n if ((count & 0x01) != 0)\n count++;\n if ((count < 0) || (p > (datum+length-count)) ||\n (count > (ssize_t) length))\n break;\n if (id != profile_id)\n p+=count;\n else\n {\n size_t\n extent,\n offset;",
" ssize_t\n extract_count;",
" StringInfo\n *extract_profile;",
" extract_count=0;\n extent=(datum+length)-(p+count);\n if (profile == (StringInfo *) NULL)\n {\n offset=(q-datum);\n extract_profile=AcquireStringInfo(offset+extent);\n (void) CopyMagickMemory(extract_profile->datum,datum,offset);\n }\n else\n {\n offset=(p-datum);\n extract_count=profile->length;\n if ((extract_count & 0x01) != 0)\n extract_count++;\n extract_profile=AcquireStringInfo(offset+extract_count+extent);\n (void) CopyMagickMemory(extract_profile->datum,datum,offset-4);\n WriteResourceLong(extract_profile->datum+offset-4,\n (unsigned int)profile->length);\n (void) CopyMagickMemory(extract_profile->datum+offset,\n profile->datum,profile->length);\n }\n (void) CopyMagickMemory(extract_profile->datum+offset+extract_count,\n p+count,extent);\n (void) AddValueToSplayTree((SplayTreeInfo *) image->profiles,\n ConstantString(\"8bim\"),CloneStringInfo(extract_profile));\n extract_profile=DestroyStringInfo(extract_profile);\n break;\n }\n }\n}",
"static void GetProfilesFromResourceBlock(Image *image,\n const StringInfo *resource_block,ExceptionInfo *exception)\n{\n const unsigned char\n *datum;",
" register const unsigned char\n *p;",
" size_t\n length;",
" ssize_t\n count;",
" StringInfo\n *profile;",
" unsigned char\n length_byte;",
" unsigned int\n value;",
" unsigned short\n id;",
" datum=GetStringInfoDatum(resource_block);\n length=GetStringInfoLength(resource_block);\n for (p=datum; p < (datum+length-16); )\n {\n if (LocaleNCompare((char *) p,\"8BIM\",4) != 0)\n break;\n p+=4;\n p=ReadResourceShort(p,&id);\n p=ReadResourceByte(p,&length_byte);\n p+=length_byte;\n if (((length_byte+1) & 0x01) != 0)\n p++;\n if (p > (datum+length-4))\n break;\n p=ReadResourceLong(p,&value);\n count=(ssize_t) value;\n if ((p > (datum+length-count)) || (count > (ssize_t) length) ||\n (count < 0))\n break;\n switch (id)\n {\n case 0x03ed:\n {\n unsigned int\n resolution;",
" unsigned short\n units;",
" /*\n Resolution.\n */\n p=ReadResourceLong(p,&resolution);\n image->resolution.x=((double) resolution)/65536.0;\n p=ReadResourceShort(p,&units)+2;\n p=ReadResourceLong(p,&resolution)+4;\n image->resolution.y=((double) resolution)/65536.0;\n /*\n Values are always stored as pixels per inch.\n */\n if ((ResolutionType) units != PixelsPerCentimeterResolution)\n image->units=PixelsPerInchResolution;\n else\n {\n image->units=PixelsPerCentimeterResolution;\n image->resolution.x/=2.54;\n image->resolution.y/=2.54;\n }\n break;\n }\n case 0x0404:\n {\n /*\n IPTC Profile\n */\n profile=AcquireStringInfo(count);\n SetStringInfoDatum(profile,p);\n (void) SetImageProfileInternal(image,\"iptc\",profile,MagickTrue,\n exception);\n profile=DestroyStringInfo(profile);\n p+=count;\n break;\n }\n case 0x040c:\n {\n /*\n Thumbnail.\n */\n p+=count;\n break;\n }\n case 0x040f:\n {\n /*\n ICC Profile.\n */\n profile=AcquireStringInfo(count);\n SetStringInfoDatum(profile,p);\n (void) SetImageProfileInternal(image,\"icc\",profile,MagickTrue,\n exception);\n profile=DestroyStringInfo(profile);\n p+=count;\n break;\n }\n case 0x0422:\n {\n /*\n EXIF Profile.\n */\n profile=AcquireStringInfo(count);\n SetStringInfoDatum(profile,p);\n (void) SetImageProfileInternal(image,\"exif\",profile,MagickTrue,\n exception);\n profile=DestroyStringInfo(profile);\n p+=count;\n break;\n }\n case 0x0424:\n {\n /*\n XMP Profile.\n */\n profile=AcquireStringInfo(count);\n SetStringInfoDatum(profile,p);\n (void) SetImageProfileInternal(image,\"xmp\",profile,MagickTrue,\n exception);\n profile=DestroyStringInfo(profile);\n p+=count;\n break;\n }\n default:\n {\n p+=count;\n break;\n }\n }\n if ((count & 0x01) != 0)\n p++;\n }\n}",
"static MagickBooleanType SetImageProfileInternal(Image *image,const char *name,\n const StringInfo *profile,const MagickBooleanType recursive,\n ExceptionInfo *exception)\n{\n char\n key[MagickPathExtent];",
" MagickBooleanType\n status;",
" assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n image->profiles=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,\n DestroyProfile);\n (void) CopyMagickString(key,name,MagickPathExtent);\n LocaleLower(key);\n status=AddValueToSplayTree((SplayTreeInfo *) image->profiles,\n ConstantString(key),CloneStringInfo(profile));\n if (status != MagickFalse)\n {\n if (LocaleCompare(name,\"8bim\") == 0)\n GetProfilesFromResourceBlock(image,profile,exception);\n else\n if (recursive == MagickFalse)\n WriteTo8BimProfile(image,name,profile);\n }\n return(status);\n}",
"MagickExport MagickBooleanType SetImageProfile(Image *image,const char *name,\n const StringInfo *profile,ExceptionInfo *exception)\n{\n return(SetImageProfileInternal(image,name,profile,MagickFalse,exception));\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% S y n c I m a g e P r o f i l e s %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% SyncImageProfiles() synchronizes image properties with the image profiles.\n% Currently we only support updating the EXIF resolution and orientation.\n%\n% The format of the SyncImageProfiles method is:\n%\n% MagickBooleanType SyncImageProfiles(Image *image)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n*/",
"static inline int ReadProfileByte(unsigned char **p,size_t *length)\n{\n int\n c;",
" if (*length < 1)\n return(EOF);\n c=(int) (*(*p)++);\n (*length)--;\n return(c);\n}",
"static inline signed short ReadProfileShort(const EndianType endian,\n unsigned char *buffer)\n{\n union\n {\n unsigned int\n unsigned_value;",
" signed int\n signed_value;\n } quantum;",
" unsigned short\n value;",
" if (endian == LSBEndian)\n {\n value=(unsigned short) buffer[1] << 8;\n value|=(unsigned short) buffer[0];\n quantum.unsigned_value=value & 0xffff;\n return(quantum.signed_value);\n }\n value=(unsigned short) buffer[0] << 8;\n value|=(unsigned short) buffer[1];\n quantum.unsigned_value=value & 0xffff;\n return(quantum.signed_value);\n}",
"static inline signed int ReadProfileLong(const EndianType endian,\n unsigned char *buffer)\n{\n union\n {\n unsigned int\n unsigned_value;",
" signed int\n signed_value;\n } quantum;",
" unsigned int\n value;",
" if (endian == LSBEndian)\n {\n value=(unsigned int) buffer[3] << 24;\n value|=(unsigned int) buffer[2] << 16;\n value|=(unsigned int) buffer[1] << 8;\n value|=(unsigned int) buffer[0];\n quantum.unsigned_value=value & 0xffffffff;\n return(quantum.signed_value);\n }\n value=(unsigned int) buffer[0] << 24;\n value|=(unsigned int) buffer[1] << 16;\n value|=(unsigned int) buffer[2] << 8;\n value|=(unsigned int) buffer[3];\n quantum.unsigned_value=value & 0xffffffff;\n return(quantum.signed_value);\n}",
"static inline signed int ReadProfileMSBLong(unsigned char **p,size_t *length)\n{\n signed int\n value;",
" if (*length < 4)\n return(0);\n value=ReadProfileLong(MSBEndian,*p);\n (*length)-=4;\n *p+=4;\n return(value);\n}",
"static inline signed short ReadProfileMSBShort(unsigned char **p,\n size_t *length)\n{\n signed short\n value;",
" if (*length < 2)\n return(0);\n value=ReadProfileShort(MSBEndian,*p);\n (*length)-=2;\n *p+=2;\n return(value);\n}",
"static inline void WriteProfileLong(const EndianType endian,\n const size_t value,unsigned char *p)\n{\n unsigned char\n buffer[4];",
" if (endian == LSBEndian)\n {\n buffer[0]=(unsigned char) value;\n buffer[1]=(unsigned char) (value >> 8);\n buffer[2]=(unsigned char) (value >> 16);\n buffer[3]=(unsigned char) (value >> 24);\n (void) CopyMagickMemory(p,buffer,4);\n return;\n }\n buffer[0]=(unsigned char) (value >> 24);\n buffer[1]=(unsigned char) (value >> 16);\n buffer[2]=(unsigned char) (value >> 8);\n buffer[3]=(unsigned char) value;\n (void) CopyMagickMemory(p,buffer,4);\n}",
"static void WriteProfileShort(const EndianType endian,\n const unsigned short value,unsigned char *p)\n{\n unsigned char\n buffer[2];",
" if (endian == LSBEndian)\n {\n buffer[0]=(unsigned char) value;\n buffer[1]=(unsigned char) (value >> 8);\n (void) CopyMagickMemory(p,buffer,2);\n return;\n }\n buffer[0]=(unsigned char) (value >> 8);\n buffer[1]=(unsigned char) value;\n (void) CopyMagickMemory(p,buffer,2);\n}",
"static MagickBooleanType Sync8BimProfile(Image *image,StringInfo *profile)\n{\n size_t\n length;",
" ssize_t\n count;",
" unsigned char\n *p;",
" unsigned short\n id;",
" length=GetStringInfoLength(profile);\n p=GetStringInfoDatum(profile);\n while (length != 0)\n {\n if (ReadProfileByte(&p,&length) != 0x38)\n continue;\n if (ReadProfileByte(&p,&length) != 0x42)\n continue;\n if (ReadProfileByte(&p,&length) != 0x49)\n continue;\n if (ReadProfileByte(&p,&length) != 0x4D)\n continue;\n if (length < 7)\n return(MagickFalse);\n id=ReadProfileMSBShort(&p,&length);\n count=(ssize_t) ReadProfileByte(&p,&length);\n if ((count > (ssize_t) length) || (count < 0))\n return(MagickFalse);\n p+=count;\n if ((*p & 0x01) == 0)\n (void) ReadProfileByte(&p,&length);\n count=(ssize_t) ReadProfileMSBLong(&p,&length);\n if ((count > (ssize_t) length) || (count < 0))\n return(MagickFalse);\n if ((id == 0x3ED) && (count == 16))\n {\n if (image->units == PixelsPerCentimeterResolution)\n WriteProfileLong(MSBEndian, (unsigned int) (image->resolution.x*2.54*\n 65536.0),p);\n else\n WriteProfileLong(MSBEndian, (unsigned int) (image->resolution.x*\n 65536.0),p);\n WriteProfileShort(MSBEndian,(unsigned short) image->units,p+4);\n if (image->units == PixelsPerCentimeterResolution)\n WriteProfileLong(MSBEndian, (unsigned int) (image->resolution.y*2.54*\n 65536.0),p+8);\n else\n WriteProfileLong(MSBEndian, (unsigned int) (image->resolution.y*\n 65536.0),p+8);\n WriteProfileShort(MSBEndian,(unsigned short) image->units,p+12);\n }\n p+=count;\n length-=count;\n }\n return(MagickTrue);\n}",
"MagickBooleanType SyncExifProfile(Image *image,StringInfo *profile)\n{\n#define MaxDirectoryStack 16\n#define EXIF_DELIMITER \"\\n\"\n#define EXIF_NUM_FORMATS 12\n#define TAG_EXIF_OFFSET 0x8769\n#define TAG_INTEROP_OFFSET 0xa005",
" typedef struct _DirectoryInfo\n {\n unsigned char\n *directory;",
" size_t\n entry;\n } DirectoryInfo;",
" DirectoryInfo\n directory_stack[MaxDirectoryStack];",
" EndianType\n endian;",
" size_t\n entry,\n length,\n number_entries;",
" ssize_t\n id,\n level,\n offset;",
" static int\n format_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};",
" unsigned char\n *directory,\n *exif;",
" /*\n Set EXIF resolution tag.\n */\n length=GetStringInfoLength(profile);\n exif=GetStringInfoDatum(profile);\n if (length < 16)\n return(MagickFalse);\n id=(ssize_t) ReadProfileShort(LSBEndian,exif);\n if ((id != 0x4949) && (id != 0x4D4D))\n {\n while (length != 0)\n {\n if (ReadProfileByte(&exif,&length) != 0x45)\n continue;\n if (ReadProfileByte(&exif,&length) != 0x78)\n continue;\n if (ReadProfileByte(&exif,&length) != 0x69)\n continue;\n if (ReadProfileByte(&exif,&length) != 0x66)\n continue;\n if (ReadProfileByte(&exif,&length) != 0x00)\n continue;\n if (ReadProfileByte(&exif,&length) != 0x00)\n continue;\n break;\n }\n if (length < 16)\n return(MagickFalse);\n id=(ssize_t) ReadProfileShort(LSBEndian,exif);\n }\n endian=LSBEndian;\n if (id == 0x4949)\n endian=LSBEndian;\n else\n if (id == 0x4D4D)\n endian=MSBEndian;\n else\n return(MagickFalse);\n if (ReadProfileShort(endian,exif+2) != 0x002a)\n return(MagickFalse);\n /*\n This the offset to the first IFD.\n */\n offset=(ssize_t) ReadProfileLong(endian,exif+4);\n if ((offset < 0) || (size_t) offset >= length)\n return(MagickFalse);\n directory=exif+offset;\n level=0;\n entry=0;\n do\n {\n if (level > 0)\n {\n level--;\n directory=directory_stack[level].directory;\n entry=directory_stack[level].entry;\n }\n if ((directory < exif) || (directory > (exif+length-2)))\n break;\n /*\n Determine how many entries there are in the current IFD.\n */\n number_entries=ReadProfileShort(endian,directory);\n for ( ; entry < number_entries; entry++)\n {\n int\n components;",
" register unsigned char\n *p,\n *q;",
" size_t\n number_bytes;",
" ssize_t\n format,\n tag_value;",
" q=(unsigned char *) (directory+2+(12*entry));\n if (q > (exif+length-12))\n break; /* corrupt EXIF */\n tag_value=(ssize_t) ReadProfileShort(endian,q);\n format=(ssize_t) ReadProfileShort(endian,q+2);\n if ((format < 0) || ((format-1) >= EXIF_NUM_FORMATS))\n break;\n components=(ssize_t) ReadProfileLong(endian,q+4);\n if (components < 0)\n break; /* corrupt EXIF */\n number_bytes=(size_t) components*format_bytes[format];\n if ((ssize_t) number_bytes < components)\n break; /* prevent overflow */\n if (number_bytes <= 4)\n p=q+8;\n else\n {\n /*\n The directory entry contains an offset.\n */\n offset=(ssize_t) ReadProfileLong(endian,q+8);",
" if ((size_t) (offset+number_bytes) > length)",
" continue;\n if (~length < number_bytes)\n continue; /* prevent overflow */\n p=(unsigned char *) (exif+offset);\n }\n switch (tag_value)\n {\n case 0x011a:\n {\n (void) WriteProfileLong(endian,(size_t) (image->resolution.x+0.5),p);\n (void) WriteProfileLong(endian,1UL,p+4);\n break;\n }\n case 0x011b:\n {\n (void) WriteProfileLong(endian,(size_t) (image->resolution.y+0.5),p);\n (void) WriteProfileLong(endian,1UL,p+4);\n break;\n }\n case 0x0112:\n {\n if (number_bytes == 4)\n {\n (void) WriteProfileLong(endian,(size_t) image->orientation,p);\n break;\n }\n (void) WriteProfileShort(endian,(unsigned short) image->orientation,\n p);\n break;\n }\n case 0x0128:\n {\n if (number_bytes == 4)\n {\n (void) WriteProfileLong(endian,(size_t) (image->units+1),p);\n break;\n }\n (void) WriteProfileShort(endian,(unsigned short) (image->units+1),p);\n break;\n }\n default:\n break;\n }\n if ((tag_value == TAG_EXIF_OFFSET) || (tag_value == TAG_INTEROP_OFFSET))\n {\n offset=(ssize_t) ReadProfileLong(endian,p);\n if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))\n {\n directory_stack[level].directory=directory;\n entry++;\n directory_stack[level].entry=entry;\n level++;\n directory_stack[level].directory=exif+offset;\n directory_stack[level].entry=0;\n level++;\n if ((directory+2+(12*number_entries)) > (exif+length))\n break;\n offset=(ssize_t) ReadProfileLong(endian,directory+2+(12*\n number_entries));\n if ((offset != 0) && ((size_t) offset < length) &&\n (level < (MaxDirectoryStack-2)))\n {\n directory_stack[level].directory=exif+offset;\n directory_stack[level].entry=0;\n level++;\n }\n }\n break;\n }\n }\n } while (level > 0);\n return(MagickTrue);\n}",
"MagickPrivate MagickBooleanType SyncImageProfiles(Image *image)\n{\n MagickBooleanType\n status;",
" StringInfo\n *profile;",
" status=MagickTrue;\n profile=(StringInfo *) GetImageProfile(image,\"8BIM\");\n if (profile != (StringInfo *) NULL)\n if (Sync8BimProfile(image,profile) == MagickFalse)\n status=MagickFalse;\n profile=(StringInfo *) GetImageProfile(image,\"EXIF\");\n if (profile != (StringInfo *) NULL)\n if (SyncExifProfile(image,profile) == MagickFalse)\n status=MagickFalse;\n return(status);\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,
0,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [2060], "buggy_code_start_loc": [2059], "filenames": ["MagickCore/profile.c"], "fixing_code_end_loc": [2060], "fixing_code_start_loc": [2059], "message": "Double free vulnerability in magick/profile.c in ImageMagick allows remote attackers to have unspecified impact via a crafted file.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:imagemagick:imagemagick:*:*:*:*:*:*:*:*", "matchCriteriaId": "BE6EA542-A222-4E6A-869B-F3805CAFCDD0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}], "descriptions": [{"lang": "en", "value": "Double free vulnerability in magick/profile.c in ImageMagick allows remote attackers to have unspecified impact via a crafted file."}, {"lang": "es", "value": "La vulnerabilidad de liberaci\u00f3n doble en magick/profile.c en ImageMagick permite a los atacantes remotos tener un impacto no especificado a trav\u00e9s de un archivo manipulado."}], "evaluatorComment": null, "id": "CVE-2017-5506", "lastModified": "2020-10-15T16:08:22.560", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 6.8, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": true}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 7.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2017-03-24T15:59:00.967", "references": [{"source": "security@debian.org", "tags": ["Third Party Advisory"], "url": "http://www.debian.org/security/2017/dsa-3799"}, {"source": "security@debian.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2017/01/16/6"}, {"source": "security@debian.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2017/01/17/5"}, {"source": "security@debian.org", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/95753"}, {"source": "security@debian.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=851383"}, {"source": "security@debian.org", "tags": ["Patch", "Vendor Advisory"], "url": "https://github.com/ImageMagick/ImageMagick/commit/9a069e0f2e027ec5138f998023cf9cb62c04889f"}, {"source": "security@debian.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/ImageMagick/ImageMagick/issues/354"}, {"source": "security@debian.org", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/201702-09"}], "sourceIdentifier": "security@debian.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-415"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/ImageMagick/ImageMagick/commit/9a069e0f2e027ec5138f998023cf9cb62c04889f"}, "type": "CWE-415"}
| 221
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% PPPP RRRR OOO FFFFF IIIII L EEEEE %\n% P P R R O O F I L E %\n% PPPP RRRR O O FFF I L EEE %\n% P R R O O F I L E %\n% P R R OOO F IIIII LLLLL EEEEE %\n% %\n% %\n% MagickCore Image Profile Methods %\n% %\n% Software Design %\n% Cristy %\n% July 1992 %\n% %\n% %\n% Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization %\n% dedicated to making software imaging solutions freely available. %\n% %\n% You may not use this file except in compliance with the License. You may %\n% obtain a copy of the License at %\n% %\n% http://www.imagemagick.org/script/license.php %\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%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n%\n*/\n\f\n/*\n Include declarations.\n*/\n#include \"MagickCore/studio.h\"\n#include \"MagickCore/attribute.h\"\n#include \"MagickCore/cache.h\"\n#include \"MagickCore/color.h\"\n#include \"MagickCore/colorspace-private.h\"\n#include \"MagickCore/configure.h\"\n#include \"MagickCore/exception.h\"\n#include \"MagickCore/exception-private.h\"\n#include \"MagickCore/image.h\"\n#include \"MagickCore/linked-list.h\"\n#include \"MagickCore/memory_.h\"\n#include \"MagickCore/monitor.h\"\n#include \"MagickCore/monitor-private.h\"\n#include \"MagickCore/option.h\"\n#include \"MagickCore/option-private.h\"\n#include \"MagickCore/pixel-accessor.h\"\n#include \"MagickCore/profile.h\"\n#include \"MagickCore/profile-private.h\"\n#include \"MagickCore/property.h\"\n#include \"MagickCore/quantum.h\"\n#include \"MagickCore/quantum-private.h\"\n#include \"MagickCore/resource_.h\"\n#include \"MagickCore/splay-tree.h\"\n#include \"MagickCore/string_.h\"\n#include \"MagickCore/thread-private.h\"\n#include \"MagickCore/token.h\"\n#include \"MagickCore/utility.h\"\n#if defined(MAGICKCORE_LCMS_DELEGATE)\n#if defined(MAGICKCORE_HAVE_LCMS_LCMS2_H)\n#include <wchar.h>\n#include <lcms/lcms2.h>\n#else\n#include <wchar.h>\n#include \"lcms2.h\"\n#endif\n#endif\n\f\n/*\n Forward declarations\n*/\nstatic MagickBooleanType\n SetImageProfileInternal(Image *,const char *,const StringInfo *,\n const MagickBooleanType,ExceptionInfo *);",
"static void\n WriteTo8BimProfile(Image *,const char*,const StringInfo *);\n\f\n/*\n Typedef declarations\n*/\nstruct _ProfileInfo\n{\n char\n *name;",
" size_t\n length;",
" unsigned char\n *info;",
" size_t\n signature;\n};",
"typedef struct _CMSExceptionInfo\n{\n Image\n *image;",
" ExceptionInfo\n *exception;\n} CMSExceptionInfo;\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% C l o n e I m a g e P r o f i l e s %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% CloneImageProfiles() clones one or more image profiles.\n%\n% The format of the CloneImageProfiles method is:\n%\n% MagickBooleanType CloneImageProfiles(Image *image,\n% const Image *clone_image)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o clone_image: the clone image.\n%\n*/\nMagickExport MagickBooleanType CloneImageProfiles(Image *image,\n const Image *clone_image)\n{\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n assert(clone_image != (const Image *) NULL);\n assert(clone_image->signature == MagickCoreSignature);\n if (clone_image->profiles != (void *) NULL)\n {\n if (image->profiles != (void *) NULL)\n DestroyImageProfiles(image);\n image->profiles=CloneSplayTree((SplayTreeInfo *) clone_image->profiles,\n (void *(*)(void *)) ConstantString,(void *(*)(void *)) CloneStringInfo);\n }\n return(MagickTrue);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% D e l e t e I m a g e P r o f i l e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% DeleteImageProfile() deletes a profile from the image by its name.\n%\n% The format of the DeleteImageProfile method is:\n%\n% MagickBooleanTyupe DeleteImageProfile(Image *image,const char *name)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o name: the profile name.\n%\n*/\nMagickExport MagickBooleanType DeleteImageProfile(Image *image,const char *name)\n{\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n return(MagickFalse);\n WriteTo8BimProfile(image,name,(StringInfo *) NULL);\n return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->profiles,name));\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% D e s t r o y I m a g e P r o f i l e s %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% DestroyImageProfiles() releases memory associated with an image profile map.\n%\n% The format of the DestroyProfiles method is:\n%\n% void DestroyImageProfiles(Image *image)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n*/\nMagickExport void DestroyImageProfiles(Image *image)\n{\n if (image->profiles != (SplayTreeInfo *) NULL)\n image->profiles=DestroySplayTree((SplayTreeInfo *) image->profiles);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% G e t I m a g e P r o f i l e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% GetImageProfile() gets a profile associated with an image by name.\n%\n% The format of the GetImageProfile method is:\n%\n% const StringInfo *GetImageProfile(const Image *image,const char *name)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o name: the profile name.\n%\n*/\nMagickExport const StringInfo *GetImageProfile(const Image *image,\n const char *name)\n{\n const StringInfo\n *profile;",
" assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n return((StringInfo *) NULL);\n profile=(const StringInfo *) GetValueFromSplayTree((SplayTreeInfo *)\n image->profiles,name);\n return(profile);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% G e t N e x t I m a g e P r o f i l e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% GetNextImageProfile() gets the next profile name for an image.\n%\n% The format of the GetNextImageProfile method is:\n%\n% char *GetNextImageProfile(const Image *image)\n%\n% A description of each parameter follows:\n%\n% o hash_info: the hash info.\n%\n*/\nMagickExport char *GetNextImageProfile(const Image *image)\n{\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n return((char *) NULL);\n return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->profiles));\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% P r o f i l e I m a g e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% ProfileImage() associates, applies, or removes an ICM, IPTC, or generic\n% profile with / to / from an image. If the profile is NULL, it is removed\n% from the image otherwise added or applied. Use a name of '*' and a profile\n% of NULL to remove all profiles from the image.\n%\n% ICC and ICM profiles are handled as follows: If the image does not have\n% an associated color profile, the one you provide is associated with the\n% image and the image pixels are not transformed. Otherwise, the colorspace\n% transform defined by the existing and new profile are applied to the image\n% pixels and the new profile is associated with the image.\n%\n% The format of the ProfileImage method is:\n%\n% MagickBooleanType ProfileImage(Image *image,const char *name,\n% const void *datum,const size_t length,const MagickBooleanType clone)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o name: Name of profile to add or remove: ICC, IPTC, or generic profile.\n%\n% o datum: the profile data.\n%\n% o length: the length of the profile.\n%\n% o clone: should be MagickFalse.\n%\n*/",
"#if defined(MAGICKCORE_LCMS_DELEGATE)\nstatic unsigned short **DestroyPixelThreadSet(unsigned short **pixels)\n{\n register ssize_t\n i;",
" assert(pixels != (unsigned short **) NULL);\n for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)\n if (pixels[i] != (unsigned short *) NULL)\n pixels[i]=(unsigned short *) RelinquishMagickMemory(pixels[i]);\n pixels=(unsigned short **) RelinquishMagickMemory(pixels);\n return(pixels);\n}",
"static unsigned short **AcquirePixelThreadSet(const size_t columns,\n const size_t channels)\n{\n register ssize_t\n i;",
" unsigned short\n **pixels;",
" size_t\n number_threads;",
" number_threads=(size_t) GetMagickResourceLimit(ThreadResource);\n pixels=(unsigned short **) AcquireQuantumMemory(number_threads,\n sizeof(*pixels));\n if (pixels == (unsigned short **) NULL)\n return((unsigned short **) NULL);\n (void) ResetMagickMemory(pixels,0,number_threads*sizeof(*pixels));\n for (i=0; i < (ssize_t) number_threads; i++)\n {\n pixels[i]=(unsigned short *) AcquireQuantumMemory(columns,channels*\n sizeof(**pixels));\n if (pixels[i] == (unsigned short *) NULL)\n return(DestroyPixelThreadSet(pixels));\n }\n return(pixels);\n}",
"static cmsHTRANSFORM *DestroyTransformThreadSet(cmsHTRANSFORM *transform)\n{\n register ssize_t\n i;",
" assert(transform != (cmsHTRANSFORM *) NULL);\n for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)\n if (transform[i] != (cmsHTRANSFORM) NULL)\n cmsDeleteTransform(transform[i]);\n transform=(cmsHTRANSFORM *) RelinquishMagickMemory(transform);\n return(transform);\n}",
"static cmsHTRANSFORM *AcquireTransformThreadSet(Image *image,\n const cmsHPROFILE source_profile,const cmsUInt32Number source_type,\n const cmsHPROFILE target_profile,const cmsUInt32Number target_type,\n const int intent,const cmsUInt32Number flags)\n{\n cmsHTRANSFORM\n *transform;",
" register ssize_t\n i;",
" size_t\n number_threads;",
" number_threads=(size_t) GetMagickResourceLimit(ThreadResource);\n transform=(cmsHTRANSFORM *) AcquireQuantumMemory(number_threads,\n sizeof(*transform));\n if (transform == (cmsHTRANSFORM *) NULL)\n return((cmsHTRANSFORM *) NULL);\n (void) ResetMagickMemory(transform,0,number_threads*sizeof(*transform));\n for (i=0; i < (ssize_t) number_threads; i++)\n {\n transform[i]=cmsCreateTransformTHR((cmsContext) image,source_profile,\n source_type,target_profile,target_type,intent,flags);\n if (transform[i] == (cmsHTRANSFORM) NULL)\n return(DestroyTransformThreadSet(transform));\n }\n return(transform);\n}\n#endif",
"#if defined(MAGICKCORE_LCMS_DELEGATE)\nstatic void CMSExceptionHandler(cmsContext context,cmsUInt32Number severity,\n const char *message)\n{\n CMSExceptionInfo\n *cms_exception;",
" ExceptionInfo\n *exception;",
" Image\n *image;",
" cms_exception=(CMSExceptionInfo *) context;\n if (cms_exception == (CMSExceptionInfo *) NULL)\n return;\n exception=cms_exception->exception;\n if (exception == (ExceptionInfo *) NULL)\n return;\n image=cms_exception->image;\n if (image == (Image *) NULL)\n {\n (void) ThrowMagickException(exception,GetMagickModule(),ImageWarning,\n \"UnableToTransformColorspace\",\"`%s'\",\"unknown context\");\n return;\n }\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TransformEvent,GetMagickModule(),\"lcms: #%u, %s\",\n severity,message != (char *) NULL ? message : \"no message\");\n (void) ThrowMagickException(exception,GetMagickModule(),ImageWarning,\n \"UnableToTransformColorspace\",\"`%s'\",image->filename);\n}\n#endif",
"static MagickBooleanType SetsRGBImageProfile(Image *image,\n ExceptionInfo *exception)\n{\n static unsigned char\n sRGBProfile[] =\n {\n 0x00, 0x00, 0x0c, 0x8c, 0x61, 0x72, 0x67, 0x6c, 0x02, 0x20, 0x00, 0x00,\n 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20,\n 0x07, 0xde, 0x00, 0x01, 0x00, 0x06, 0x00, 0x16, 0x00, 0x0f, 0x00, 0x3a,\n 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54, 0x00, 0x00, 0x00, 0x00,\n 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6,\n 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x61, 0x72, 0x67, 0x6c,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,\n 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x01, 0x50, 0x00, 0x00, 0x00, 0x99,\n 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x01, 0xec, 0x00, 0x00, 0x00, 0x67,\n 0x64, 0x6d, 0x6e, 0x64, 0x00, 0x00, 0x02, 0x54, 0x00, 0x00, 0x00, 0x70,\n 0x64, 0x6d, 0x64, 0x64, 0x00, 0x00, 0x02, 0xc4, 0x00, 0x00, 0x00, 0x88,\n 0x74, 0x65, 0x63, 0x68, 0x00, 0x00, 0x03, 0x4c, 0x00, 0x00, 0x00, 0x0c,\n 0x76, 0x75, 0x65, 0x64, 0x00, 0x00, 0x03, 0x58, 0x00, 0x00, 0x00, 0x67,\n 0x76, 0x69, 0x65, 0x77, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x24,\n 0x6c, 0x75, 0x6d, 0x69, 0x00, 0x00, 0x03, 0xe4, 0x00, 0x00, 0x00, 0x14,\n 0x6d, 0x65, 0x61, 0x73, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x24,\n 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x04, 0x1c, 0x00, 0x00, 0x00, 0x14,\n 0x62, 0x6b, 0x70, 0x74, 0x00, 0x00, 0x04, 0x30, 0x00, 0x00, 0x00, 0x14,\n 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x44, 0x00, 0x00, 0x00, 0x14,\n 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x58, 0x00, 0x00, 0x00, 0x14,\n 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x04, 0x6c, 0x00, 0x00, 0x00, 0x14,\n 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c,\n 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c,\n 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x08, 0x0c,\n 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,\n 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36,\n 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x28, 0x45, 0x71, 0x75, 0x69, 0x76,\n 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x77, 0x77, 0x77,\n 0x2e, 0x73, 0x72, 0x67, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x20, 0x31, 0x39,\n 0x39, 0x38, 0x20, 0x48, 0x50, 0x20, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c,\n 0x65, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x3f, 0x73, 0x52, 0x47, 0x42, 0x20, 0x49, 0x45, 0x43, 0x36, 0x31,\n 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x28, 0x45, 0x71, 0x75,\n 0x69, 0x76, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x77,\n 0x77, 0x77, 0x2e, 0x73, 0x72, 0x67, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x20,\n 0x31, 0x39, 0x39, 0x38, 0x20, 0x48, 0x50, 0x20, 0x70, 0x72, 0x6f, 0x66,\n 0x69, 0x6c, 0x65, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x43, 0x72, 0x65, 0x61,\n 0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x47, 0x72, 0x61, 0x65, 0x6d,\n 0x65, 0x20, 0x57, 0x2e, 0x20, 0x47, 0x69, 0x6c, 0x6c, 0x2e, 0x20, 0x52,\n 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x74, 0x6f,\n 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,\n 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x20, 0x4e, 0x6f, 0x20, 0x57,\n 0x61, 0x72, 0x72, 0x61, 0x6e, 0x74, 0x79, 0x2c, 0x20, 0x55, 0x73, 0x65,\n 0x20, 0x61, 0x74, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e,\n 0x20, 0x72, 0x69, 0x73, 0x6b, 0x2e, 0x00, 0x00, 0x64, 0x65, 0x73, 0x63,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x49, 0x45, 0x43, 0x20,\n 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69,\n 0x65, 0x63, 0x2e, 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x16, 0x49, 0x45, 0x43, 0x20, 0x68, 0x74, 0x74,\n 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x65, 0x63, 0x2e,\n 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e,\n 0x49, 0x45, 0x43, 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e,\n 0x31, 0x20, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47,\n 0x42, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x70, 0x61,\n 0x63, 0x65, 0x20, 0x2d, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, 0x49, 0x45, 0x43,\n 0x20, 0x36, 0x31, 0x39, 0x36, 0x36, 0x2d, 0x32, 0x2e, 0x31, 0x20, 0x44,\n 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x52, 0x47, 0x42, 0x20, 0x63,\n 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0x20, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20,\n 0x2d, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x73, 0x69, 0x67, 0x20, 0x00, 0x00, 0x00, 0x00,\n 0x43, 0x52, 0x54, 0x20, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x0d, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36,\n 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x0d, 0x49, 0x45, 0x43, 0x36, 0x31, 0x39, 0x36, 0x36,\n 0x2d, 0x32, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x76, 0x69, 0x65, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xa4, 0x7c,\n 0x00, 0x14, 0x5f, 0x30, 0x00, 0x10, 0xce, 0x02, 0x00, 0x03, 0xed, 0xb2,\n 0x00, 0x04, 0x13, 0x0a, 0x00, 0x03, 0x5c, 0x67, 0x00, 0x00, 0x00, 0x01,\n 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x0a, 0x3d,\n 0x00, 0x50, 0x00, 0x00, 0x00, 0x57, 0x1e, 0xb8, 0x6d, 0x65, 0x61, 0x73,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x02, 0x8f, 0x00, 0x00, 0x00, 0x02, 0x58, 0x59, 0x5a, 0x20,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x51, 0x00, 0x01, 0x00, 0x00,\n 0x00, 0x01, 0x16, 0xcc, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xa0,\n 0x00, 0x00, 0x38, 0xf5, 0x00, 0x00, 0x03, 0x90, 0x58, 0x59, 0x5a, 0x20,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x97, 0x00, 0x00, 0xb7, 0x87,\n 0x00, 0x00, 0x18, 0xd9, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x24, 0x9f, 0x00, 0x00, 0x0f, 0x84, 0x00, 0x00, 0xb6, 0xc4,\n 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,\n 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x0f, 0x00, 0x14, 0x00, 0x19,\n 0x00, 0x1e, 0x00, 0x23, 0x00, 0x28, 0x00, 0x2d, 0x00, 0x32, 0x00, 0x37,\n 0x00, 0x3b, 0x00, 0x40, 0x00, 0x45, 0x00, 0x4a, 0x00, 0x4f, 0x00, 0x54,\n 0x00, 0x59, 0x00, 0x5e, 0x00, 0x63, 0x00, 0x68, 0x00, 0x6d, 0x00, 0x72,\n 0x00, 0x77, 0x00, 0x7c, 0x00, 0x81, 0x00, 0x86, 0x00, 0x8b, 0x00, 0x90,\n 0x00, 0x95, 0x00, 0x9a, 0x00, 0x9f, 0x00, 0xa4, 0x00, 0xa9, 0x00, 0xae,\n 0x00, 0xb2, 0x00, 0xb7, 0x00, 0xbc, 0x00, 0xc1, 0x00, 0xc6, 0x00, 0xcb,\n 0x00, 0xd0, 0x00, 0xd5, 0x00, 0xdb, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0xeb,\n 0x00, 0xf0, 0x00, 0xf6, 0x00, 0xfb, 0x01, 0x01, 0x01, 0x07, 0x01, 0x0d,\n 0x01, 0x13, 0x01, 0x19, 0x01, 0x1f, 0x01, 0x25, 0x01, 0x2b, 0x01, 0x32,\n 0x01, 0x38, 0x01, 0x3e, 0x01, 0x45, 0x01, 0x4c, 0x01, 0x52, 0x01, 0x59,\n 0x01, 0x60, 0x01, 0x67, 0x01, 0x6e, 0x01, 0x75, 0x01, 0x7c, 0x01, 0x83,\n 0x01, 0x8b, 0x01, 0x92, 0x01, 0x9a, 0x01, 0xa1, 0x01, 0xa9, 0x01, 0xb1,\n 0x01, 0xb9, 0x01, 0xc1, 0x01, 0xc9, 0x01, 0xd1, 0x01, 0xd9, 0x01, 0xe1,\n 0x01, 0xe9, 0x01, 0xf2, 0x01, 0xfa, 0x02, 0x03, 0x02, 0x0c, 0x02, 0x14,\n 0x02, 0x1d, 0x02, 0x26, 0x02, 0x2f, 0x02, 0x38, 0x02, 0x41, 0x02, 0x4b,\n 0x02, 0x54, 0x02, 0x5d, 0x02, 0x67, 0x02, 0x71, 0x02, 0x7a, 0x02, 0x84,\n 0x02, 0x8e, 0x02, 0x98, 0x02, 0xa2, 0x02, 0xac, 0x02, 0xb6, 0x02, 0xc1,\n 0x02, 0xcb, 0x02, 0xd5, 0x02, 0xe0, 0x02, 0xeb, 0x02, 0xf5, 0x03, 0x00,\n 0x03, 0x0b, 0x03, 0x16, 0x03, 0x21, 0x03, 0x2d, 0x03, 0x38, 0x03, 0x43,\n 0x03, 0x4f, 0x03, 0x5a, 0x03, 0x66, 0x03, 0x72, 0x03, 0x7e, 0x03, 0x8a,\n 0x03, 0x96, 0x03, 0xa2, 0x03, 0xae, 0x03, 0xba, 0x03, 0xc7, 0x03, 0xd3,\n 0x03, 0xe0, 0x03, 0xec, 0x03, 0xf9, 0x04, 0x06, 0x04, 0x13, 0x04, 0x20,\n 0x04, 0x2d, 0x04, 0x3b, 0x04, 0x48, 0x04, 0x55, 0x04, 0x63, 0x04, 0x71,\n 0x04, 0x7e, 0x04, 0x8c, 0x04, 0x9a, 0x04, 0xa8, 0x04, 0xb6, 0x04, 0xc4,\n 0x04, 0xd3, 0x04, 0xe1, 0x04, 0xf0, 0x04, 0xfe, 0x05, 0x0d, 0x05, 0x1c,\n 0x05, 0x2b, 0x05, 0x3a, 0x05, 0x49, 0x05, 0x58, 0x05, 0x67, 0x05, 0x77,\n 0x05, 0x86, 0x05, 0x96, 0x05, 0xa6, 0x05, 0xb5, 0x05, 0xc5, 0x05, 0xd5,\n 0x05, 0xe5, 0x05, 0xf6, 0x06, 0x06, 0x06, 0x16, 0x06, 0x27, 0x06, 0x37,\n 0x06, 0x48, 0x06, 0x59, 0x06, 0x6a, 0x06, 0x7b, 0x06, 0x8c, 0x06, 0x9d,\n 0x06, 0xaf, 0x06, 0xc0, 0x06, 0xd1, 0x06, 0xe3, 0x06, 0xf5, 0x07, 0x07,\n 0x07, 0x19, 0x07, 0x2b, 0x07, 0x3d, 0x07, 0x4f, 0x07, 0x61, 0x07, 0x74,\n 0x07, 0x86, 0x07, 0x99, 0x07, 0xac, 0x07, 0xbf, 0x07, 0xd2, 0x07, 0xe5,\n 0x07, 0xf8, 0x08, 0x0b, 0x08, 0x1f, 0x08, 0x32, 0x08, 0x46, 0x08, 0x5a,\n 0x08, 0x6e, 0x08, 0x82, 0x08, 0x96, 0x08, 0xaa, 0x08, 0xbe, 0x08, 0xd2,\n 0x08, 0xe7, 0x08, 0xfb, 0x09, 0x10, 0x09, 0x25, 0x09, 0x3a, 0x09, 0x4f,\n 0x09, 0x64, 0x09, 0x79, 0x09, 0x8f, 0x09, 0xa4, 0x09, 0xba, 0x09, 0xcf,\n 0x09, 0xe5, 0x09, 0xfb, 0x0a, 0x11, 0x0a, 0x27, 0x0a, 0x3d, 0x0a, 0x54,\n 0x0a, 0x6a, 0x0a, 0x81, 0x0a, 0x98, 0x0a, 0xae, 0x0a, 0xc5, 0x0a, 0xdc,\n 0x0a, 0xf3, 0x0b, 0x0b, 0x0b, 0x22, 0x0b, 0x39, 0x0b, 0x51, 0x0b, 0x69,\n 0x0b, 0x80, 0x0b, 0x98, 0x0b, 0xb0, 0x0b, 0xc8, 0x0b, 0xe1, 0x0b, 0xf9,\n 0x0c, 0x12, 0x0c, 0x2a, 0x0c, 0x43, 0x0c, 0x5c, 0x0c, 0x75, 0x0c, 0x8e,\n 0x0c, 0xa7, 0x0c, 0xc0, 0x0c, 0xd9, 0x0c, 0xf3, 0x0d, 0x0d, 0x0d, 0x26,\n 0x0d, 0x40, 0x0d, 0x5a, 0x0d, 0x74, 0x0d, 0x8e, 0x0d, 0xa9, 0x0d, 0xc3,\n 0x0d, 0xde, 0x0d, 0xf8, 0x0e, 0x13, 0x0e, 0x2e, 0x0e, 0x49, 0x0e, 0x64,\n 0x0e, 0x7f, 0x0e, 0x9b, 0x0e, 0xb6, 0x0e, 0xd2, 0x0e, 0xee, 0x0f, 0x09,\n 0x0f, 0x25, 0x0f, 0x41, 0x0f, 0x5e, 0x0f, 0x7a, 0x0f, 0x96, 0x0f, 0xb3,\n 0x0f, 0xcf, 0x0f, 0xec, 0x10, 0x09, 0x10, 0x26, 0x10, 0x43, 0x10, 0x61,\n 0x10, 0x7e, 0x10, 0x9b, 0x10, 0xb9, 0x10, 0xd7, 0x10, 0xf5, 0x11, 0x13,\n 0x11, 0x31, 0x11, 0x4f, 0x11, 0x6d, 0x11, 0x8c, 0x11, 0xaa, 0x11, 0xc9,\n 0x11, 0xe8, 0x12, 0x07, 0x12, 0x26, 0x12, 0x45, 0x12, 0x64, 0x12, 0x84,\n 0x12, 0xa3, 0x12, 0xc3, 0x12, 0xe3, 0x13, 0x03, 0x13, 0x23, 0x13, 0x43,\n 0x13, 0x63, 0x13, 0x83, 0x13, 0xa4, 0x13, 0xc5, 0x13, 0xe5, 0x14, 0x06,\n 0x14, 0x27, 0x14, 0x49, 0x14, 0x6a, 0x14, 0x8b, 0x14, 0xad, 0x14, 0xce,\n 0x14, 0xf0, 0x15, 0x12, 0x15, 0x34, 0x15, 0x56, 0x15, 0x78, 0x15, 0x9b,\n 0x15, 0xbd, 0x15, 0xe0, 0x16, 0x03, 0x16, 0x26, 0x16, 0x49, 0x16, 0x6c,\n 0x16, 0x8f, 0x16, 0xb2, 0x16, 0xd6, 0x16, 0xfa, 0x17, 0x1d, 0x17, 0x41,\n 0x17, 0x65, 0x17, 0x89, 0x17, 0xae, 0x17, 0xd2, 0x17, 0xf7, 0x18, 0x1b,\n 0x18, 0x40, 0x18, 0x65, 0x18, 0x8a, 0x18, 0xaf, 0x18, 0xd5, 0x18, 0xfa,\n 0x19, 0x20, 0x19, 0x45, 0x19, 0x6b, 0x19, 0x91, 0x19, 0xb7, 0x19, 0xdd,\n 0x1a, 0x04, 0x1a, 0x2a, 0x1a, 0x51, 0x1a, 0x77, 0x1a, 0x9e, 0x1a, 0xc5,\n 0x1a, 0xec, 0x1b, 0x14, 0x1b, 0x3b, 0x1b, 0x63, 0x1b, 0x8a, 0x1b, 0xb2,\n 0x1b, 0xda, 0x1c, 0x02, 0x1c, 0x2a, 0x1c, 0x52, 0x1c, 0x7b, 0x1c, 0xa3,\n 0x1c, 0xcc, 0x1c, 0xf5, 0x1d, 0x1e, 0x1d, 0x47, 0x1d, 0x70, 0x1d, 0x99,\n 0x1d, 0xc3, 0x1d, 0xec, 0x1e, 0x16, 0x1e, 0x40, 0x1e, 0x6a, 0x1e, 0x94,\n 0x1e, 0xbe, 0x1e, 0xe9, 0x1f, 0x13, 0x1f, 0x3e, 0x1f, 0x69, 0x1f, 0x94,\n 0x1f, 0xbf, 0x1f, 0xea, 0x20, 0x15, 0x20, 0x41, 0x20, 0x6c, 0x20, 0x98,\n 0x20, 0xc4, 0x20, 0xf0, 0x21, 0x1c, 0x21, 0x48, 0x21, 0x75, 0x21, 0xa1,\n 0x21, 0xce, 0x21, 0xfb, 0x22, 0x27, 0x22, 0x55, 0x22, 0x82, 0x22, 0xaf,\n 0x22, 0xdd, 0x23, 0x0a, 0x23, 0x38, 0x23, 0x66, 0x23, 0x94, 0x23, 0xc2,\n 0x23, 0xf0, 0x24, 0x1f, 0x24, 0x4d, 0x24, 0x7c, 0x24, 0xab, 0x24, 0xda,\n 0x25, 0x09, 0x25, 0x38, 0x25, 0x68, 0x25, 0x97, 0x25, 0xc7, 0x25, 0xf7,\n 0x26, 0x27, 0x26, 0x57, 0x26, 0x87, 0x26, 0xb7, 0x26, 0xe8, 0x27, 0x18,\n 0x27, 0x49, 0x27, 0x7a, 0x27, 0xab, 0x27, 0xdc, 0x28, 0x0d, 0x28, 0x3f,\n 0x28, 0x71, 0x28, 0xa2, 0x28, 0xd4, 0x29, 0x06, 0x29, 0x38, 0x29, 0x6b,\n 0x29, 0x9d, 0x29, 0xd0, 0x2a, 0x02, 0x2a, 0x35, 0x2a, 0x68, 0x2a, 0x9b,\n 0x2a, 0xcf, 0x2b, 0x02, 0x2b, 0x36, 0x2b, 0x69, 0x2b, 0x9d, 0x2b, 0xd1,\n 0x2c, 0x05, 0x2c, 0x39, 0x2c, 0x6e, 0x2c, 0xa2, 0x2c, 0xd7, 0x2d, 0x0c,\n 0x2d, 0x41, 0x2d, 0x76, 0x2d, 0xab, 0x2d, 0xe1, 0x2e, 0x16, 0x2e, 0x4c,\n 0x2e, 0x82, 0x2e, 0xb7, 0x2e, 0xee, 0x2f, 0x24, 0x2f, 0x5a, 0x2f, 0x91,\n 0x2f, 0xc7, 0x2f, 0xfe, 0x30, 0x35, 0x30, 0x6c, 0x30, 0xa4, 0x30, 0xdb,\n 0x31, 0x12, 0x31, 0x4a, 0x31, 0x82, 0x31, 0xba, 0x31, 0xf2, 0x32, 0x2a,\n 0x32, 0x63, 0x32, 0x9b, 0x32, 0xd4, 0x33, 0x0d, 0x33, 0x46, 0x33, 0x7f,\n 0x33, 0xb8, 0x33, 0xf1, 0x34, 0x2b, 0x34, 0x65, 0x34, 0x9e, 0x34, 0xd8,\n 0x35, 0x13, 0x35, 0x4d, 0x35, 0x87, 0x35, 0xc2, 0x35, 0xfd, 0x36, 0x37,\n 0x36, 0x72, 0x36, 0xae, 0x36, 0xe9, 0x37, 0x24, 0x37, 0x60, 0x37, 0x9c,\n 0x37, 0xd7, 0x38, 0x14, 0x38, 0x50, 0x38, 0x8c, 0x38, 0xc8, 0x39, 0x05,\n 0x39, 0x42, 0x39, 0x7f, 0x39, 0xbc, 0x39, 0xf9, 0x3a, 0x36, 0x3a, 0x74,\n 0x3a, 0xb2, 0x3a, 0xef, 0x3b, 0x2d, 0x3b, 0x6b, 0x3b, 0xaa, 0x3b, 0xe8,\n 0x3c, 0x27, 0x3c, 0x65, 0x3c, 0xa4, 0x3c, 0xe3, 0x3d, 0x22, 0x3d, 0x61,\n 0x3d, 0xa1, 0x3d, 0xe0, 0x3e, 0x20, 0x3e, 0x60, 0x3e, 0xa0, 0x3e, 0xe0,\n 0x3f, 0x21, 0x3f, 0x61, 0x3f, 0xa2, 0x3f, 0xe2, 0x40, 0x23, 0x40, 0x64,\n 0x40, 0xa6, 0x40, 0xe7, 0x41, 0x29, 0x41, 0x6a, 0x41, 0xac, 0x41, 0xee,\n 0x42, 0x30, 0x42, 0x72, 0x42, 0xb5, 0x42, 0xf7, 0x43, 0x3a, 0x43, 0x7d,\n 0x43, 0xc0, 0x44, 0x03, 0x44, 0x47, 0x44, 0x8a, 0x44, 0xce, 0x45, 0x12,\n 0x45, 0x55, 0x45, 0x9a, 0x45, 0xde, 0x46, 0x22, 0x46, 0x67, 0x46, 0xab,\n 0x46, 0xf0, 0x47, 0x35, 0x47, 0x7b, 0x47, 0xc0, 0x48, 0x05, 0x48, 0x4b,\n 0x48, 0x91, 0x48, 0xd7, 0x49, 0x1d, 0x49, 0x63, 0x49, 0xa9, 0x49, 0xf0,\n 0x4a, 0x37, 0x4a, 0x7d, 0x4a, 0xc4, 0x4b, 0x0c, 0x4b, 0x53, 0x4b, 0x9a,\n 0x4b, 0xe2, 0x4c, 0x2a, 0x4c, 0x72, 0x4c, 0xba, 0x4d, 0x02, 0x4d, 0x4a,\n 0x4d, 0x93, 0x4d, 0xdc, 0x4e, 0x25, 0x4e, 0x6e, 0x4e, 0xb7, 0x4f, 0x00,\n 0x4f, 0x49, 0x4f, 0x93, 0x4f, 0xdd, 0x50, 0x27, 0x50, 0x71, 0x50, 0xbb,\n 0x51, 0x06, 0x51, 0x50, 0x51, 0x9b, 0x51, 0xe6, 0x52, 0x31, 0x52, 0x7c,\n 0x52, 0xc7, 0x53, 0x13, 0x53, 0x5f, 0x53, 0xaa, 0x53, 0xf6, 0x54, 0x42,\n 0x54, 0x8f, 0x54, 0xdb, 0x55, 0x28, 0x55, 0x75, 0x55, 0xc2, 0x56, 0x0f,\n 0x56, 0x5c, 0x56, 0xa9, 0x56, 0xf7, 0x57, 0x44, 0x57, 0x92, 0x57, 0xe0,\n 0x58, 0x2f, 0x58, 0x7d, 0x58, 0xcb, 0x59, 0x1a, 0x59, 0x69, 0x59, 0xb8,\n 0x5a, 0x07, 0x5a, 0x56, 0x5a, 0xa6, 0x5a, 0xf5, 0x5b, 0x45, 0x5b, 0x95,\n 0x5b, 0xe5, 0x5c, 0x35, 0x5c, 0x86, 0x5c, 0xd6, 0x5d, 0x27, 0x5d, 0x78,\n 0x5d, 0xc9, 0x5e, 0x1a, 0x5e, 0x6c, 0x5e, 0xbd, 0x5f, 0x0f, 0x5f, 0x61,\n 0x5f, 0xb3, 0x60, 0x05, 0x60, 0x57, 0x60, 0xaa, 0x60, 0xfc, 0x61, 0x4f,\n 0x61, 0xa2, 0x61, 0xf5, 0x62, 0x49, 0x62, 0x9c, 0x62, 0xf0, 0x63, 0x43,\n 0x63, 0x97, 0x63, 0xeb, 0x64, 0x40, 0x64, 0x94, 0x64, 0xe9, 0x65, 0x3d,\n 0x65, 0x92, 0x65, 0xe7, 0x66, 0x3d, 0x66, 0x92, 0x66, 0xe8, 0x67, 0x3d,\n 0x67, 0x93, 0x67, 0xe9, 0x68, 0x3f, 0x68, 0x96, 0x68, 0xec, 0x69, 0x43,\n 0x69, 0x9a, 0x69, 0xf1, 0x6a, 0x48, 0x6a, 0x9f, 0x6a, 0xf7, 0x6b, 0x4f,\n 0x6b, 0xa7, 0x6b, 0xff, 0x6c, 0x57, 0x6c, 0xaf, 0x6d, 0x08, 0x6d, 0x60,\n 0x6d, 0xb9, 0x6e, 0x12, 0x6e, 0x6b, 0x6e, 0xc4, 0x6f, 0x1e, 0x6f, 0x78,\n 0x6f, 0xd1, 0x70, 0x2b, 0x70, 0x86, 0x70, 0xe0, 0x71, 0x3a, 0x71, 0x95,\n 0x71, 0xf0, 0x72, 0x4b, 0x72, 0xa6, 0x73, 0x01, 0x73, 0x5d, 0x73, 0xb8,\n 0x74, 0x14, 0x74, 0x70, 0x74, 0xcc, 0x75, 0x28, 0x75, 0x85, 0x75, 0xe1,\n 0x76, 0x3e, 0x76, 0x9b, 0x76, 0xf8, 0x77, 0x56, 0x77, 0xb3, 0x78, 0x11,\n 0x78, 0x6e, 0x78, 0xcc, 0x79, 0x2a, 0x79, 0x89, 0x79, 0xe7, 0x7a, 0x46,\n 0x7a, 0xa5, 0x7b, 0x04, 0x7b, 0x63, 0x7b, 0xc2, 0x7c, 0x21, 0x7c, 0x81,\n 0x7c, 0xe1, 0x7d, 0x41, 0x7d, 0xa1, 0x7e, 0x01, 0x7e, 0x62, 0x7e, 0xc2,\n 0x7f, 0x23, 0x7f, 0x84, 0x7f, 0xe5, 0x80, 0x47, 0x80, 0xa8, 0x81, 0x0a,\n 0x81, 0x6b, 0x81, 0xcd, 0x82, 0x30, 0x82, 0x92, 0x82, 0xf4, 0x83, 0x57,\n 0x83, 0xba, 0x84, 0x1d, 0x84, 0x80, 0x84, 0xe3, 0x85, 0x47, 0x85, 0xab,\n 0x86, 0x0e, 0x86, 0x72, 0x86, 0xd7, 0x87, 0x3b, 0x87, 0x9f, 0x88, 0x04,\n 0x88, 0x69, 0x88, 0xce, 0x89, 0x33, 0x89, 0x99, 0x89, 0xfe, 0x8a, 0x64,\n 0x8a, 0xca, 0x8b, 0x30, 0x8b, 0x96, 0x8b, 0xfc, 0x8c, 0x63, 0x8c, 0xca,\n 0x8d, 0x31, 0x8d, 0x98, 0x8d, 0xff, 0x8e, 0x66, 0x8e, 0xce, 0x8f, 0x36,\n 0x8f, 0x9e, 0x90, 0x06, 0x90, 0x6e, 0x90, 0xd6, 0x91, 0x3f, 0x91, 0xa8,\n 0x92, 0x11, 0x92, 0x7a, 0x92, 0xe3, 0x93, 0x4d, 0x93, 0xb6, 0x94, 0x20,\n 0x94, 0x8a, 0x94, 0xf4, 0x95, 0x5f, 0x95, 0xc9, 0x96, 0x34, 0x96, 0x9f,\n 0x97, 0x0a, 0x97, 0x75, 0x97, 0xe0, 0x98, 0x4c, 0x98, 0xb8, 0x99, 0x24,\n 0x99, 0x90, 0x99, 0xfc, 0x9a, 0x68, 0x9a, 0xd5, 0x9b, 0x42, 0x9b, 0xaf,\n 0x9c, 0x1c, 0x9c, 0x89, 0x9c, 0xf7, 0x9d, 0x64, 0x9d, 0xd2, 0x9e, 0x40,\n 0x9e, 0xae, 0x9f, 0x1d, 0x9f, 0x8b, 0x9f, 0xfa, 0xa0, 0x69, 0xa0, 0xd8,\n 0xa1, 0x47, 0xa1, 0xb6, 0xa2, 0x26, 0xa2, 0x96, 0xa3, 0x06, 0xa3, 0x76,\n 0xa3, 0xe6, 0xa4, 0x56, 0xa4, 0xc7, 0xa5, 0x38, 0xa5, 0xa9, 0xa6, 0x1a,\n 0xa6, 0x8b, 0xa6, 0xfd, 0xa7, 0x6e, 0xa7, 0xe0, 0xa8, 0x52, 0xa8, 0xc4,\n 0xa9, 0x37, 0xa9, 0xa9, 0xaa, 0x1c, 0xaa, 0x8f, 0xab, 0x02, 0xab, 0x75,\n 0xab, 0xe9, 0xac, 0x5c, 0xac, 0xd0, 0xad, 0x44, 0xad, 0xb8, 0xae, 0x2d,\n 0xae, 0xa1, 0xaf, 0x16, 0xaf, 0x8b, 0xb0, 0x00, 0xb0, 0x75, 0xb0, 0xea,\n 0xb1, 0x60, 0xb1, 0xd6, 0xb2, 0x4b, 0xb2, 0xc2, 0xb3, 0x38, 0xb3, 0xae,\n 0xb4, 0x25, 0xb4, 0x9c, 0xb5, 0x13, 0xb5, 0x8a, 0xb6, 0x01, 0xb6, 0x79,\n 0xb6, 0xf0, 0xb7, 0x68, 0xb7, 0xe0, 0xb8, 0x59, 0xb8, 0xd1, 0xb9, 0x4a,\n 0xb9, 0xc2, 0xba, 0x3b, 0xba, 0xb5, 0xbb, 0x2e, 0xbb, 0xa7, 0xbc, 0x21,\n 0xbc, 0x9b, 0xbd, 0x15, 0xbd, 0x8f, 0xbe, 0x0a, 0xbe, 0x84, 0xbe, 0xff,\n 0xbf, 0x7a, 0xbf, 0xf5, 0xc0, 0x70, 0xc0, 0xec, 0xc1, 0x67, 0xc1, 0xe3,\n 0xc2, 0x5f, 0xc2, 0xdb, 0xc3, 0x58, 0xc3, 0xd4, 0xc4, 0x51, 0xc4, 0xce,\n 0xc5, 0x4b, 0xc5, 0xc8, 0xc6, 0x46, 0xc6, 0xc3, 0xc7, 0x41, 0xc7, 0xbf,\n 0xc8, 0x3d, 0xc8, 0xbc, 0xc9, 0x3a, 0xc9, 0xb9, 0xca, 0x38, 0xca, 0xb7,\n 0xcb, 0x36, 0xcb, 0xb6, 0xcc, 0x35, 0xcc, 0xb5, 0xcd, 0x35, 0xcd, 0xb5,\n 0xce, 0x36, 0xce, 0xb6, 0xcf, 0x37, 0xcf, 0xb8, 0xd0, 0x39, 0xd0, 0xba,\n 0xd1, 0x3c, 0xd1, 0xbe, 0xd2, 0x3f, 0xd2, 0xc1, 0xd3, 0x44, 0xd3, 0xc6,\n 0xd4, 0x49, 0xd4, 0xcb, 0xd5, 0x4e, 0xd5, 0xd1, 0xd6, 0x55, 0xd6, 0xd8,\n 0xd7, 0x5c, 0xd7, 0xe0, 0xd8, 0x64, 0xd8, 0xe8, 0xd9, 0x6c, 0xd9, 0xf1,\n 0xda, 0x76, 0xda, 0xfb, 0xdb, 0x80, 0xdc, 0x05, 0xdc, 0x8a, 0xdd, 0x10,\n 0xdd, 0x96, 0xde, 0x1c, 0xde, 0xa2, 0xdf, 0x29, 0xdf, 0xaf, 0xe0, 0x36,\n 0xe0, 0xbd, 0xe1, 0x44, 0xe1, 0xcc, 0xe2, 0x53, 0xe2, 0xdb, 0xe3, 0x63,\n 0xe3, 0xeb, 0xe4, 0x73, 0xe4, 0xfc, 0xe5, 0x84, 0xe6, 0x0d, 0xe6, 0x96,\n 0xe7, 0x1f, 0xe7, 0xa9, 0xe8, 0x32, 0xe8, 0xbc, 0xe9, 0x46, 0xe9, 0xd0,\n 0xea, 0x5b, 0xea, 0xe5, 0xeb, 0x70, 0xeb, 0xfb, 0xec, 0x86, 0xed, 0x11,\n 0xed, 0x9c, 0xee, 0x28, 0xee, 0xb4, 0xef, 0x40, 0xef, 0xcc, 0xf0, 0x58,\n 0xf0, 0xe5, 0xf1, 0x72, 0xf1, 0xff, 0xf2, 0x8c, 0xf3, 0x19, 0xf3, 0xa7,\n 0xf4, 0x34, 0xf4, 0xc2, 0xf5, 0x50, 0xf5, 0xde, 0xf6, 0x6d, 0xf6, 0xfb,\n 0xf7, 0x8a, 0xf8, 0x19, 0xf8, 0xa8, 0xf9, 0x38, 0xf9, 0xc7, 0xfa, 0x57,\n 0xfa, 0xe7, 0xfb, 0x77, 0xfc, 0x07, 0xfc, 0x98, 0xfd, 0x29, 0xfd, 0xba,\n 0xfe, 0x4b, 0xfe, 0xdc, 0xff, 0x6d, 0xff, 0xff\n };",
" StringInfo\n *profile;",
" MagickBooleanType\n status;",
" assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (GetImageProfile(image,\"icc\") != (const StringInfo *) NULL)\n return(MagickFalse);\n profile=AcquireStringInfo(sizeof(sRGBProfile));\n SetStringInfoDatum(profile,sRGBProfile);\n status=SetImageProfile(image,\"icc\",profile,exception);\n profile=DestroyStringInfo(profile);\n return(status);\n}",
"MagickExport MagickBooleanType ProfileImage(Image *image,const char *name,\n const void *datum,const size_t length,ExceptionInfo *exception)\n{\n#define ProfileImageTag \"Profile/Image\"\n#define ThrowProfileException(severity,tag,context) \\\n{ \\\n if (source_profile != (cmsHPROFILE) NULL) \\\n (void) cmsCloseProfile(source_profile); \\\n if (target_profile != (cmsHPROFILE) NULL) \\\n (void) cmsCloseProfile(target_profile); \\\n ThrowBinaryException(severity,tag,context); \\\n}",
" MagickBooleanType\n status;",
" StringInfo\n *profile;",
" assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n assert(name != (const char *) NULL);\n if ((datum == (const void *) NULL) || (length == 0))\n {\n char\n *next;",
" /*\n Delete image profile(s).\n */\n ResetImageProfileIterator(image);\n for (next=GetNextImageProfile(image); next != (const char *) NULL; )\n {\n if (IsOptionMember(next,name) != MagickFalse)\n {\n (void) DeleteImageProfile(image,next);\n ResetImageProfileIterator(image);\n }\n next=GetNextImageProfile(image);\n }\n return(MagickTrue);\n }\n /*\n Add a ICC, IPTC, or generic profile to the image.\n */\n status=MagickTrue;\n profile=AcquireStringInfo((size_t) length);\n SetStringInfoDatum(profile,(unsigned char *) datum);\n if ((LocaleCompare(name,\"icc\") != 0) && (LocaleCompare(name,\"icm\") != 0))\n status=SetImageProfile(image,name,profile,exception);\n else\n {\n const StringInfo\n *icc_profile;",
" icc_profile=GetImageProfile(image,\"icc\");\n if ((icc_profile != (const StringInfo *) NULL) &&\n (CompareStringInfo(icc_profile,profile) == 0))\n {\n const char\n *value;",
" value=GetImageProperty(image,\"exif:ColorSpace\",exception);\n (void) value;\n if (LocaleCompare(value,\"1\") != 0)\n (void) SetsRGBImageProfile(image,exception);\n value=GetImageProperty(image,\"exif:InteroperabilityIndex\",exception);\n if (LocaleCompare(value,\"R98.\") != 0)\n (void) SetsRGBImageProfile(image,exception);\n /* Future.\n value=GetImageProperty(image,\"exif:InteroperabilityIndex\",exception);\n if (LocaleCompare(value,\"R03.\") != 0)\n (void) SetAdobeRGB1998ImageProfile(image,exception);\n */\n icc_profile=GetImageProfile(image,\"icc\");\n }\n if ((icc_profile != (const StringInfo *) NULL) &&\n (CompareStringInfo(icc_profile,profile) == 0))\n {\n profile=DestroyStringInfo(profile);\n return(MagickTrue);\n }\n#if !defined(MAGICKCORE_LCMS_DELEGATE)\n (void) ThrowMagickException(exception,GetMagickModule(),\n MissingDelegateWarning,\"DelegateLibrarySupportNotBuiltIn\",\n \"'%s' (LCMS)\",image->filename);\n#else\n {\n cmsHPROFILE\n source_profile;",
" CMSExceptionInfo\n cms_exception;",
" /*\n Transform pixel colors as defined by the color profiles.\n */\n cmsSetLogErrorHandler(CMSExceptionHandler);\n cms_exception.image=image;\n cms_exception.exception=exception;\n (void) cms_exception;\n source_profile=cmsOpenProfileFromMemTHR((cmsContext) &cms_exception,\n GetStringInfoDatum(profile),(cmsUInt32Number)\n GetStringInfoLength(profile));\n if (source_profile == (cmsHPROFILE) NULL)\n ThrowBinaryException(ResourceLimitError,\n \"ColorspaceColorProfileMismatch\",name);\n if ((cmsGetDeviceClass(source_profile) != cmsSigLinkClass) &&\n (icc_profile == (StringInfo *) NULL))\n status=SetImageProfile(image,name,profile,exception);\n else\n {\n CacheView\n *image_view;",
" ColorspaceType\n source_colorspace,\n target_colorspace;",
" cmsColorSpaceSignature\n signature;",
" cmsHPROFILE\n target_profile;",
" cmsHTRANSFORM\n *magick_restrict transform;",
" cmsUInt32Number\n flags,\n source_type,\n target_type;",
" int\n intent;",
" MagickOffsetType\n progress;",
" size_t\n source_channels,\n target_channels;",
" ssize_t\n y;",
" unsigned short\n **magick_restrict source_pixels,\n **magick_restrict target_pixels;",
" target_profile=(cmsHPROFILE) NULL;\n if (icc_profile != (StringInfo *) NULL)\n {\n target_profile=source_profile;\n source_profile=cmsOpenProfileFromMemTHR((cmsContext)\n &cms_exception,GetStringInfoDatum(icc_profile),\n (cmsUInt32Number) GetStringInfoLength(icc_profile));\n if (source_profile == (cmsHPROFILE) NULL)\n ThrowProfileException(ResourceLimitError,\n \"ColorspaceColorProfileMismatch\",name);\n }\n switch (cmsGetColorSpace(source_profile))\n {\n case cmsSigCmykData:\n {\n source_colorspace=CMYKColorspace;\n source_type=(cmsUInt32Number) TYPE_CMYK_16;\n source_channels=4;\n break;\n }\n case cmsSigGrayData:\n {\n source_colorspace=GRAYColorspace;\n source_type=(cmsUInt32Number) TYPE_GRAY_16;\n source_channels=1;\n break;\n }\n case cmsSigLabData:\n {\n source_colorspace=LabColorspace;\n source_type=(cmsUInt32Number) TYPE_Lab_16;\n source_channels=3;\n break;\n }\n case cmsSigLuvData:\n {\n source_colorspace=YUVColorspace;\n source_type=(cmsUInt32Number) TYPE_YUV_16;\n source_channels=3;\n break;\n }\n case cmsSigRgbData:\n {\n source_colorspace=sRGBColorspace;\n source_type=(cmsUInt32Number) TYPE_RGB_16;\n source_channels=3;\n break;\n }\n case cmsSigXYZData:\n {\n source_colorspace=XYZColorspace;\n source_type=(cmsUInt32Number) TYPE_XYZ_16;\n source_channels=3;\n break;\n }\n case cmsSigYCbCrData:\n {\n source_colorspace=YCbCrColorspace;\n source_type=(cmsUInt32Number) TYPE_YCbCr_16;\n source_channels=3;\n break;\n }\n default:\n {\n source_colorspace=UndefinedColorspace;\n source_type=(cmsUInt32Number) TYPE_RGB_16;\n source_channels=3;\n break;\n }\n }\n signature=cmsGetPCS(source_profile);\n if (target_profile != (cmsHPROFILE) NULL)\n signature=cmsGetColorSpace(target_profile);\n switch (signature)\n {\n case cmsSigCmykData:\n {\n target_colorspace=CMYKColorspace;\n target_type=(cmsUInt32Number) TYPE_CMYK_16;\n target_channels=4;\n break;\n }\n case cmsSigLabData:\n {\n target_colorspace=LabColorspace;\n target_type=(cmsUInt32Number) TYPE_Lab_16;\n target_channels=3;\n break;\n }\n case cmsSigGrayData:\n {\n target_colorspace=GRAYColorspace;\n target_type=(cmsUInt32Number) TYPE_GRAY_16;\n target_channels=1;\n break;\n }\n case cmsSigLuvData:\n {\n target_colorspace=YUVColorspace;\n target_type=(cmsUInt32Number) TYPE_YUV_16;\n target_channels=3;\n break;\n }\n case cmsSigRgbData:\n {\n target_colorspace=sRGBColorspace;\n target_type=(cmsUInt32Number) TYPE_RGB_16;\n target_channels=3;\n break;\n }\n case cmsSigXYZData:\n {\n target_colorspace=XYZColorspace;\n target_type=(cmsUInt32Number) TYPE_XYZ_16;\n target_channels=3;\n break;\n }\n case cmsSigYCbCrData:\n {\n target_colorspace=YCbCrColorspace;\n target_type=(cmsUInt32Number) TYPE_YCbCr_16;\n target_channels=3;\n break;\n }\n default:\n {\n target_colorspace=UndefinedColorspace;\n target_type=(cmsUInt32Number) TYPE_RGB_16;\n target_channels=3;\n break;\n }\n }\n if ((source_colorspace == UndefinedColorspace) ||\n (target_colorspace == UndefinedColorspace))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n if ((source_colorspace == GRAYColorspace) &&\n (SetImageGray(image,exception) == MagickFalse))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n if ((source_colorspace == CMYKColorspace) &&\n (image->colorspace != CMYKColorspace))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n if ((source_colorspace == XYZColorspace) &&\n (image->colorspace != XYZColorspace))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n if ((source_colorspace == YCbCrColorspace) &&\n (image->colorspace != YCbCrColorspace))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n if ((source_colorspace != CMYKColorspace) &&\n (source_colorspace != LabColorspace) &&\n (source_colorspace != XYZColorspace) &&\n (source_colorspace != YCbCrColorspace) &&\n (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse))\n ThrowProfileException(ImageError,\"ColorspaceColorProfileMismatch\",\n name);\n switch (image->rendering_intent)\n {\n case AbsoluteIntent: intent=INTENT_ABSOLUTE_COLORIMETRIC; break;\n case PerceptualIntent: intent=INTENT_PERCEPTUAL; break;\n case RelativeIntent: intent=INTENT_RELATIVE_COLORIMETRIC; break;\n case SaturationIntent: intent=INTENT_SATURATION; break;\n default: intent=INTENT_PERCEPTUAL; break;\n }\n flags=cmsFLAGS_HIGHRESPRECALC;\n#if defined(cmsFLAGS_BLACKPOINTCOMPENSATION)\n if (image->black_point_compensation != MagickFalse)\n flags|=cmsFLAGS_BLACKPOINTCOMPENSATION;\n#endif\n transform=AcquireTransformThreadSet(image,source_profile,\n source_type,target_profile,target_type,intent,flags);\n if (transform == (cmsHTRANSFORM *) NULL)\n ThrowProfileException(ImageError,\"UnableToCreateColorTransform\",\n name);\n /*\n Transform image as dictated by the source & target image profiles.\n */\n source_pixels=AcquirePixelThreadSet(image->columns,source_channels);\n target_pixels=AcquirePixelThreadSet(image->columns,target_channels);\n if ((source_pixels == (unsigned short **) NULL) ||\n (target_pixels == (unsigned short **) NULL))\n {\n transform=DestroyTransformThreadSet(transform);\n ThrowProfileException(ResourceLimitError,\n \"MemoryAllocationFailed\",image->filename);\n }\n if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)\n {\n target_pixels=DestroyPixelThreadSet(target_pixels);\n source_pixels=DestroyPixelThreadSet(source_pixels);\n transform=DestroyTransformThreadSet(transform);\n if (source_profile != (cmsHPROFILE) NULL)\n (void) cmsCloseProfile(source_profile);\n if (target_profile != (cmsHPROFILE) NULL)\n (void) cmsCloseProfile(target_profile);\n return(MagickFalse);\n }\n if (target_colorspace == CMYKColorspace)\n (void) SetImageColorspace(image,target_colorspace,exception);\n progress=0;\n image_view=AcquireAuthenticCacheView(image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp parallel for schedule(static,4) shared(status) \\\n magick_threads(image,image,image->rows,1)\n#endif\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n const int\n id = GetOpenMPThreadId();",
" MagickBooleanType\n sync;",
" register ssize_t\n x;",
" register Quantum\n *magick_restrict q;",
" register unsigned short\n *p;",
" if (status == MagickFalse)\n continue;\n q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,\n exception);\n if (q == (Quantum *) NULL)\n {\n status=MagickFalse;\n continue;\n }\n p=source_pixels[id];\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n *p++=ScaleQuantumToShort(GetPixelRed(image,q));\n if (source_channels > 1)\n {\n *p++=ScaleQuantumToShort(GetPixelGreen(image,q));\n *p++=ScaleQuantumToShort(GetPixelBlue(image,q));\n }\n if (source_channels > 3)\n *p++=ScaleQuantumToShort(GetPixelBlack(image,q));\n q+=GetPixelChannels(image);\n }\n cmsDoTransform(transform[id],source_pixels[id],target_pixels[id],\n (unsigned int) image->columns);\n p=target_pixels[id];\n q-=GetPixelChannels(image)*image->columns;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (target_channels == 1)\n SetPixelGray(image,ScaleShortToQuantum(*p),q);\n else\n SetPixelRed(image,ScaleShortToQuantum(*p),q);\n p++;\n if (target_channels > 1)\n {\n SetPixelGreen(image,ScaleShortToQuantum(*p),q);\n p++;\n SetPixelBlue(image,ScaleShortToQuantum(*p),q);\n p++;\n }\n if (target_channels > 3)\n {\n SetPixelBlack(image,ScaleShortToQuantum(*p),q);\n p++;\n }\n q+=GetPixelChannels(image);\n }\n sync=SyncCacheViewAuthenticPixels(image_view,exception);\n if (sync == MagickFalse)\n status=MagickFalse;\n if (image->progress_monitor != (MagickProgressMonitor) NULL)\n {\n MagickBooleanType\n proceed;",
"#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp critical (MagickCore_ProfileImage)\n#endif\n proceed=SetImageProgress(image,ProfileImageTag,progress++,\n image->rows);\n if (proceed == MagickFalse)\n status=MagickFalse;\n }\n }\n image_view=DestroyCacheView(image_view);\n (void) SetImageColorspace(image,target_colorspace,exception);\n switch (signature)\n {\n case cmsSigRgbData:\n {\n image->type=image->alpha_trait == UndefinedPixelTrait ?\n TrueColorType : TrueColorAlphaType;\n break;\n }\n case cmsSigCmykData:\n {\n image->type=image->alpha_trait == UndefinedPixelTrait ?\n ColorSeparationType : ColorSeparationAlphaType;\n break;\n }\n case cmsSigGrayData:\n {\n image->type=image->alpha_trait == UndefinedPixelTrait ?\n GrayscaleType : GrayscaleAlphaType;\n break;\n }\n default:\n break;\n }\n target_pixels=DestroyPixelThreadSet(target_pixels);\n source_pixels=DestroyPixelThreadSet(source_pixels);\n transform=DestroyTransformThreadSet(transform);\n if ((status != MagickFalse) &&\n (cmsGetDeviceClass(source_profile) != cmsSigLinkClass))\n status=SetImageProfile(image,name,profile,exception);\n if (target_profile != (cmsHPROFILE) NULL)\n (void) cmsCloseProfile(target_profile);\n }\n (void) cmsCloseProfile(source_profile);\n }\n#endif\n }\n profile=DestroyStringInfo(profile);\n return(status);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% R e m o v e I m a g e P r o f i l e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% RemoveImageProfile() removes a named profile from the image and returns its\n% value.\n%\n% The format of the RemoveImageProfile method is:\n%\n% void *RemoveImageProfile(Image *image,const char *name)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o name: the profile name.\n%\n*/\nMagickExport StringInfo *RemoveImageProfile(Image *image,const char *name)\n{\n StringInfo\n *profile;",
" assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n return((StringInfo *) NULL);\n WriteTo8BimProfile(image,name,(StringInfo *) NULL);\n profile=(StringInfo *) RemoveNodeFromSplayTree((SplayTreeInfo *)\n image->profiles,name);\n return(profile);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% R e s e t P r o f i l e I t e r a t o r %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% ResetImageProfileIterator() resets the image profile iterator. Use it in\n% conjunction with GetNextImageProfile() to iterate over all the profiles\n% associated with an image.\n%\n% The format of the ResetImageProfileIterator method is:\n%\n% ResetImageProfileIterator(Image *image)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n*/\nMagickExport void ResetImageProfileIterator(const Image *image)\n{\n assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n return;\n ResetSplayTreeIterator((SplayTreeInfo *) image->profiles);\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% S e t I m a g e P r o f i l e %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% SetImageProfile() adds a named profile to the image. If a profile with the\n% same name already exists, it is replaced. This method differs from the\n% ProfileImage() method in that it does not apply CMS color profiles.\n%\n% The format of the SetImageProfile method is:\n%\n% MagickBooleanType SetImageProfile(Image *image,const char *name,\n% const StringInfo *profile)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n% o name: the profile name, for example icc, exif, and 8bim (8bim is the\n% Photoshop wrapper for iptc profiles).\n%\n% o profile: A StringInfo structure that contains the named profile.\n%\n*/",
"static void *DestroyProfile(void *profile)\n{\n return((void *) DestroyStringInfo((StringInfo *) profile));\n}",
"static inline const unsigned char *ReadResourceByte(const unsigned char *p,\n unsigned char *quantum)\n{\n *quantum=(*p++);\n return(p);\n}",
"static inline const unsigned char *ReadResourceLong(const unsigned char *p,\n unsigned int *quantum)\n{\n *quantum=(unsigned int) (*p++) << 24;\n *quantum|=(unsigned int) (*p++) << 16;\n *quantum|=(unsigned int) (*p++) << 8;\n *quantum|=(unsigned int) (*p++) << 0;\n return(p);\n}",
"static inline const unsigned char *ReadResourceShort(const unsigned char *p,\n unsigned short *quantum)\n{\n *quantum=(unsigned short) (*p++) << 8;\n *quantum|=(unsigned short) (*p++);\n return(p);\n}",
"static inline void WriteResourceLong(unsigned char *p,\n const unsigned int quantum)\n{\n unsigned char\n buffer[4];",
" buffer[0]=(unsigned char) (quantum >> 24);\n buffer[1]=(unsigned char) (quantum >> 16);\n buffer[2]=(unsigned char) (quantum >> 8);\n buffer[3]=(unsigned char) quantum;\n (void) CopyMagickMemory(p,buffer,4);\n}",
"static void WriteTo8BimProfile(Image *image,const char *name,\n const StringInfo *profile)\n{\n const unsigned char\n *datum,\n *q;",
" register const unsigned char\n *p;",
" size_t\n length;",
" StringInfo\n *profile_8bim;",
" ssize_t\n count;",
" unsigned char\n length_byte;",
" unsigned int\n value;",
" unsigned short\n id,\n profile_id;",
" if (LocaleCompare(name,\"icc\") == 0)\n profile_id=0x040f;\n else\n if (LocaleCompare(name,\"iptc\") == 0)\n profile_id=0x0404;\n else\n if (LocaleCompare(name,\"xmp\") == 0)\n profile_id=0x0424;\n else\n return;\n profile_8bim=(StringInfo *) GetValueFromSplayTree((SplayTreeInfo *)\n image->profiles,\"8bim\");\n if (profile_8bim == (StringInfo *) NULL)\n return;\n datum=GetStringInfoDatum(profile_8bim);\n length=GetStringInfoLength(profile_8bim);\n for (p=datum; p < (datum+length-16); )\n {\n q=p;\n if (LocaleNCompare((char *) p,\"8BIM\",4) != 0)\n break;\n p+=4;\n p=ReadResourceShort(p,&id);\n p=ReadResourceByte(p,&length_byte);\n p+=length_byte;\n if (((length_byte+1) & 0x01) != 0)\n p++;\n if (p > (datum+length-4))\n break;\n p=ReadResourceLong(p,&value);\n count=(ssize_t) value;\n if ((count & 0x01) != 0)\n count++;\n if ((count < 0) || (p > (datum+length-count)) ||\n (count > (ssize_t) length))\n break;\n if (id != profile_id)\n p+=count;\n else\n {\n size_t\n extent,\n offset;",
" ssize_t\n extract_count;",
" StringInfo\n *extract_profile;",
" extract_count=0;\n extent=(datum+length)-(p+count);\n if (profile == (StringInfo *) NULL)\n {\n offset=(q-datum);\n extract_profile=AcquireStringInfo(offset+extent);\n (void) CopyMagickMemory(extract_profile->datum,datum,offset);\n }\n else\n {\n offset=(p-datum);\n extract_count=profile->length;\n if ((extract_count & 0x01) != 0)\n extract_count++;\n extract_profile=AcquireStringInfo(offset+extract_count+extent);\n (void) CopyMagickMemory(extract_profile->datum,datum,offset-4);\n WriteResourceLong(extract_profile->datum+offset-4,\n (unsigned int)profile->length);\n (void) CopyMagickMemory(extract_profile->datum+offset,\n profile->datum,profile->length);\n }\n (void) CopyMagickMemory(extract_profile->datum+offset+extract_count,\n p+count,extent);\n (void) AddValueToSplayTree((SplayTreeInfo *) image->profiles,\n ConstantString(\"8bim\"),CloneStringInfo(extract_profile));\n extract_profile=DestroyStringInfo(extract_profile);\n break;\n }\n }\n}",
"static void GetProfilesFromResourceBlock(Image *image,\n const StringInfo *resource_block,ExceptionInfo *exception)\n{\n const unsigned char\n *datum;",
" register const unsigned char\n *p;",
" size_t\n length;",
" ssize_t\n count;",
" StringInfo\n *profile;",
" unsigned char\n length_byte;",
" unsigned int\n value;",
" unsigned short\n id;",
" datum=GetStringInfoDatum(resource_block);\n length=GetStringInfoLength(resource_block);\n for (p=datum; p < (datum+length-16); )\n {\n if (LocaleNCompare((char *) p,\"8BIM\",4) != 0)\n break;\n p+=4;\n p=ReadResourceShort(p,&id);\n p=ReadResourceByte(p,&length_byte);\n p+=length_byte;\n if (((length_byte+1) & 0x01) != 0)\n p++;\n if (p > (datum+length-4))\n break;\n p=ReadResourceLong(p,&value);\n count=(ssize_t) value;\n if ((p > (datum+length-count)) || (count > (ssize_t) length) ||\n (count < 0))\n break;\n switch (id)\n {\n case 0x03ed:\n {\n unsigned int\n resolution;",
" unsigned short\n units;",
" /*\n Resolution.\n */\n p=ReadResourceLong(p,&resolution);\n image->resolution.x=((double) resolution)/65536.0;\n p=ReadResourceShort(p,&units)+2;\n p=ReadResourceLong(p,&resolution)+4;\n image->resolution.y=((double) resolution)/65536.0;\n /*\n Values are always stored as pixels per inch.\n */\n if ((ResolutionType) units != PixelsPerCentimeterResolution)\n image->units=PixelsPerInchResolution;\n else\n {\n image->units=PixelsPerCentimeterResolution;\n image->resolution.x/=2.54;\n image->resolution.y/=2.54;\n }\n break;\n }\n case 0x0404:\n {\n /*\n IPTC Profile\n */\n profile=AcquireStringInfo(count);\n SetStringInfoDatum(profile,p);\n (void) SetImageProfileInternal(image,\"iptc\",profile,MagickTrue,\n exception);\n profile=DestroyStringInfo(profile);\n p+=count;\n break;\n }\n case 0x040c:\n {\n /*\n Thumbnail.\n */\n p+=count;\n break;\n }\n case 0x040f:\n {\n /*\n ICC Profile.\n */\n profile=AcquireStringInfo(count);\n SetStringInfoDatum(profile,p);\n (void) SetImageProfileInternal(image,\"icc\",profile,MagickTrue,\n exception);\n profile=DestroyStringInfo(profile);\n p+=count;\n break;\n }\n case 0x0422:\n {\n /*\n EXIF Profile.\n */\n profile=AcquireStringInfo(count);\n SetStringInfoDatum(profile,p);\n (void) SetImageProfileInternal(image,\"exif\",profile,MagickTrue,\n exception);\n profile=DestroyStringInfo(profile);\n p+=count;\n break;\n }\n case 0x0424:\n {\n /*\n XMP Profile.\n */\n profile=AcquireStringInfo(count);\n SetStringInfoDatum(profile,p);\n (void) SetImageProfileInternal(image,\"xmp\",profile,MagickTrue,\n exception);\n profile=DestroyStringInfo(profile);\n p+=count;\n break;\n }\n default:\n {\n p+=count;\n break;\n }\n }\n if ((count & 0x01) != 0)\n p++;\n }\n}",
"static MagickBooleanType SetImageProfileInternal(Image *image,const char *name,\n const StringInfo *profile,const MagickBooleanType recursive,\n ExceptionInfo *exception)\n{\n char\n key[MagickPathExtent];",
" MagickBooleanType\n status;",
" assert(image != (Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n if (image->profiles == (SplayTreeInfo *) NULL)\n image->profiles=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,\n DestroyProfile);\n (void) CopyMagickString(key,name,MagickPathExtent);\n LocaleLower(key);\n status=AddValueToSplayTree((SplayTreeInfo *) image->profiles,\n ConstantString(key),CloneStringInfo(profile));\n if (status != MagickFalse)\n {\n if (LocaleCompare(name,\"8bim\") == 0)\n GetProfilesFromResourceBlock(image,profile,exception);\n else\n if (recursive == MagickFalse)\n WriteTo8BimProfile(image,name,profile);\n }\n return(status);\n}",
"MagickExport MagickBooleanType SetImageProfile(Image *image,const char *name,\n const StringInfo *profile,ExceptionInfo *exception)\n{\n return(SetImageProfileInternal(image,name,profile,MagickFalse,exception));\n}\n\f\n/*\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% %\n% %\n% %\n% S y n c I m a g e P r o f i l e s %\n% %\n% %\n% %\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\n% SyncImageProfiles() synchronizes image properties with the image profiles.\n% Currently we only support updating the EXIF resolution and orientation.\n%\n% The format of the SyncImageProfiles method is:\n%\n% MagickBooleanType SyncImageProfiles(Image *image)\n%\n% A description of each parameter follows:\n%\n% o image: the image.\n%\n*/",
"static inline int ReadProfileByte(unsigned char **p,size_t *length)\n{\n int\n c;",
" if (*length < 1)\n return(EOF);\n c=(int) (*(*p)++);\n (*length)--;\n return(c);\n}",
"static inline signed short ReadProfileShort(const EndianType endian,\n unsigned char *buffer)\n{\n union\n {\n unsigned int\n unsigned_value;",
" signed int\n signed_value;\n } quantum;",
" unsigned short\n value;",
" if (endian == LSBEndian)\n {\n value=(unsigned short) buffer[1] << 8;\n value|=(unsigned short) buffer[0];\n quantum.unsigned_value=value & 0xffff;\n return(quantum.signed_value);\n }\n value=(unsigned short) buffer[0] << 8;\n value|=(unsigned short) buffer[1];\n quantum.unsigned_value=value & 0xffff;\n return(quantum.signed_value);\n}",
"static inline signed int ReadProfileLong(const EndianType endian,\n unsigned char *buffer)\n{\n union\n {\n unsigned int\n unsigned_value;",
" signed int\n signed_value;\n } quantum;",
" unsigned int\n value;",
" if (endian == LSBEndian)\n {\n value=(unsigned int) buffer[3] << 24;\n value|=(unsigned int) buffer[2] << 16;\n value|=(unsigned int) buffer[1] << 8;\n value|=(unsigned int) buffer[0];\n quantum.unsigned_value=value & 0xffffffff;\n return(quantum.signed_value);\n }\n value=(unsigned int) buffer[0] << 24;\n value|=(unsigned int) buffer[1] << 16;\n value|=(unsigned int) buffer[2] << 8;\n value|=(unsigned int) buffer[3];\n quantum.unsigned_value=value & 0xffffffff;\n return(quantum.signed_value);\n}",
"static inline signed int ReadProfileMSBLong(unsigned char **p,size_t *length)\n{\n signed int\n value;",
" if (*length < 4)\n return(0);\n value=ReadProfileLong(MSBEndian,*p);\n (*length)-=4;\n *p+=4;\n return(value);\n}",
"static inline signed short ReadProfileMSBShort(unsigned char **p,\n size_t *length)\n{\n signed short\n value;",
" if (*length < 2)\n return(0);\n value=ReadProfileShort(MSBEndian,*p);\n (*length)-=2;\n *p+=2;\n return(value);\n}",
"static inline void WriteProfileLong(const EndianType endian,\n const size_t value,unsigned char *p)\n{\n unsigned char\n buffer[4];",
" if (endian == LSBEndian)\n {\n buffer[0]=(unsigned char) value;\n buffer[1]=(unsigned char) (value >> 8);\n buffer[2]=(unsigned char) (value >> 16);\n buffer[3]=(unsigned char) (value >> 24);\n (void) CopyMagickMemory(p,buffer,4);\n return;\n }\n buffer[0]=(unsigned char) (value >> 24);\n buffer[1]=(unsigned char) (value >> 16);\n buffer[2]=(unsigned char) (value >> 8);\n buffer[3]=(unsigned char) value;\n (void) CopyMagickMemory(p,buffer,4);\n}",
"static void WriteProfileShort(const EndianType endian,\n const unsigned short value,unsigned char *p)\n{\n unsigned char\n buffer[2];",
" if (endian == LSBEndian)\n {\n buffer[0]=(unsigned char) value;\n buffer[1]=(unsigned char) (value >> 8);\n (void) CopyMagickMemory(p,buffer,2);\n return;\n }\n buffer[0]=(unsigned char) (value >> 8);\n buffer[1]=(unsigned char) value;\n (void) CopyMagickMemory(p,buffer,2);\n}",
"static MagickBooleanType Sync8BimProfile(Image *image,StringInfo *profile)\n{\n size_t\n length;",
" ssize_t\n count;",
" unsigned char\n *p;",
" unsigned short\n id;",
" length=GetStringInfoLength(profile);\n p=GetStringInfoDatum(profile);\n while (length != 0)\n {\n if (ReadProfileByte(&p,&length) != 0x38)\n continue;\n if (ReadProfileByte(&p,&length) != 0x42)\n continue;\n if (ReadProfileByte(&p,&length) != 0x49)\n continue;\n if (ReadProfileByte(&p,&length) != 0x4D)\n continue;\n if (length < 7)\n return(MagickFalse);\n id=ReadProfileMSBShort(&p,&length);\n count=(ssize_t) ReadProfileByte(&p,&length);\n if ((count > (ssize_t) length) || (count < 0))\n return(MagickFalse);\n p+=count;\n if ((*p & 0x01) == 0)\n (void) ReadProfileByte(&p,&length);\n count=(ssize_t) ReadProfileMSBLong(&p,&length);\n if ((count > (ssize_t) length) || (count < 0))\n return(MagickFalse);\n if ((id == 0x3ED) && (count == 16))\n {\n if (image->units == PixelsPerCentimeterResolution)\n WriteProfileLong(MSBEndian, (unsigned int) (image->resolution.x*2.54*\n 65536.0),p);\n else\n WriteProfileLong(MSBEndian, (unsigned int) (image->resolution.x*\n 65536.0),p);\n WriteProfileShort(MSBEndian,(unsigned short) image->units,p+4);\n if (image->units == PixelsPerCentimeterResolution)\n WriteProfileLong(MSBEndian, (unsigned int) (image->resolution.y*2.54*\n 65536.0),p+8);\n else\n WriteProfileLong(MSBEndian, (unsigned int) (image->resolution.y*\n 65536.0),p+8);\n WriteProfileShort(MSBEndian,(unsigned short) image->units,p+12);\n }\n p+=count;\n length-=count;\n }\n return(MagickTrue);\n}",
"MagickBooleanType SyncExifProfile(Image *image,StringInfo *profile)\n{\n#define MaxDirectoryStack 16\n#define EXIF_DELIMITER \"\\n\"\n#define EXIF_NUM_FORMATS 12\n#define TAG_EXIF_OFFSET 0x8769\n#define TAG_INTEROP_OFFSET 0xa005",
" typedef struct _DirectoryInfo\n {\n unsigned char\n *directory;",
" size_t\n entry;\n } DirectoryInfo;",
" DirectoryInfo\n directory_stack[MaxDirectoryStack];",
" EndianType\n endian;",
" size_t\n entry,\n length,\n number_entries;",
" ssize_t\n id,\n level,\n offset;",
" static int\n format_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};",
" unsigned char\n *directory,\n *exif;",
" /*\n Set EXIF resolution tag.\n */\n length=GetStringInfoLength(profile);\n exif=GetStringInfoDatum(profile);\n if (length < 16)\n return(MagickFalse);\n id=(ssize_t) ReadProfileShort(LSBEndian,exif);\n if ((id != 0x4949) && (id != 0x4D4D))\n {\n while (length != 0)\n {\n if (ReadProfileByte(&exif,&length) != 0x45)\n continue;\n if (ReadProfileByte(&exif,&length) != 0x78)\n continue;\n if (ReadProfileByte(&exif,&length) != 0x69)\n continue;\n if (ReadProfileByte(&exif,&length) != 0x66)\n continue;\n if (ReadProfileByte(&exif,&length) != 0x00)\n continue;\n if (ReadProfileByte(&exif,&length) != 0x00)\n continue;\n break;\n }\n if (length < 16)\n return(MagickFalse);\n id=(ssize_t) ReadProfileShort(LSBEndian,exif);\n }\n endian=LSBEndian;\n if (id == 0x4949)\n endian=LSBEndian;\n else\n if (id == 0x4D4D)\n endian=MSBEndian;\n else\n return(MagickFalse);\n if (ReadProfileShort(endian,exif+2) != 0x002a)\n return(MagickFalse);\n /*\n This the offset to the first IFD.\n */\n offset=(ssize_t) ReadProfileLong(endian,exif+4);\n if ((offset < 0) || (size_t) offset >= length)\n return(MagickFalse);\n directory=exif+offset;\n level=0;\n entry=0;\n do\n {\n if (level > 0)\n {\n level--;\n directory=directory_stack[level].directory;\n entry=directory_stack[level].entry;\n }\n if ((directory < exif) || (directory > (exif+length-2)))\n break;\n /*\n Determine how many entries there are in the current IFD.\n */\n number_entries=ReadProfileShort(endian,directory);\n for ( ; entry < number_entries; entry++)\n {\n int\n components;",
" register unsigned char\n *p,\n *q;",
" size_t\n number_bytes;",
" ssize_t\n format,\n tag_value;",
" q=(unsigned char *) (directory+2+(12*entry));\n if (q > (exif+length-12))\n break; /* corrupt EXIF */\n tag_value=(ssize_t) ReadProfileShort(endian,q);\n format=(ssize_t) ReadProfileShort(endian,q+2);\n if ((format < 0) || ((format-1) >= EXIF_NUM_FORMATS))\n break;\n components=(ssize_t) ReadProfileLong(endian,q+4);\n if (components < 0)\n break; /* corrupt EXIF */\n number_bytes=(size_t) components*format_bytes[format];\n if ((ssize_t) number_bytes < components)\n break; /* prevent overflow */\n if (number_bytes <= 4)\n p=q+8;\n else\n {\n /*\n The directory entry contains an offset.\n */\n offset=(ssize_t) ReadProfileLong(endian,q+8);",
" if ((offset < 0) || ((size_t) (offset+number_bytes) > length))",
" continue;\n if (~length < number_bytes)\n continue; /* prevent overflow */\n p=(unsigned char *) (exif+offset);\n }\n switch (tag_value)\n {\n case 0x011a:\n {\n (void) WriteProfileLong(endian,(size_t) (image->resolution.x+0.5),p);\n (void) WriteProfileLong(endian,1UL,p+4);\n break;\n }\n case 0x011b:\n {\n (void) WriteProfileLong(endian,(size_t) (image->resolution.y+0.5),p);\n (void) WriteProfileLong(endian,1UL,p+4);\n break;\n }\n case 0x0112:\n {\n if (number_bytes == 4)\n {\n (void) WriteProfileLong(endian,(size_t) image->orientation,p);\n break;\n }\n (void) WriteProfileShort(endian,(unsigned short) image->orientation,\n p);\n break;\n }\n case 0x0128:\n {\n if (number_bytes == 4)\n {\n (void) WriteProfileLong(endian,(size_t) (image->units+1),p);\n break;\n }\n (void) WriteProfileShort(endian,(unsigned short) (image->units+1),p);\n break;\n }\n default:\n break;\n }\n if ((tag_value == TAG_EXIF_OFFSET) || (tag_value == TAG_INTEROP_OFFSET))\n {\n offset=(ssize_t) ReadProfileLong(endian,p);\n if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))\n {\n directory_stack[level].directory=directory;\n entry++;\n directory_stack[level].entry=entry;\n level++;\n directory_stack[level].directory=exif+offset;\n directory_stack[level].entry=0;\n level++;\n if ((directory+2+(12*number_entries)) > (exif+length))\n break;\n offset=(ssize_t) ReadProfileLong(endian,directory+2+(12*\n number_entries));\n if ((offset != 0) && ((size_t) offset < length) &&\n (level < (MaxDirectoryStack-2)))\n {\n directory_stack[level].directory=exif+offset;\n directory_stack[level].entry=0;\n level++;\n }\n }\n break;\n }\n }\n } while (level > 0);\n return(MagickTrue);\n}",
"MagickPrivate MagickBooleanType SyncImageProfiles(Image *image)\n{\n MagickBooleanType\n status;",
" StringInfo\n *profile;",
" status=MagickTrue;\n profile=(StringInfo *) GetImageProfile(image,\"8BIM\");\n if (profile != (StringInfo *) NULL)\n if (Sync8BimProfile(image,profile) == MagickFalse)\n status=MagickFalse;\n profile=(StringInfo *) GetImageProfile(image,\"EXIF\");\n if (profile != (StringInfo *) NULL)\n if (SyncExifProfile(image,profile) == MagickFalse)\n status=MagickFalse;\n return(status);\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [2060], "buggy_code_start_loc": [2059], "filenames": ["MagickCore/profile.c"], "fixing_code_end_loc": [2060], "fixing_code_start_loc": [2059], "message": "Double free vulnerability in magick/profile.c in ImageMagick allows remote attackers to have unspecified impact via a crafted file.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:imagemagick:imagemagick:*:*:*:*:*:*:*:*", "matchCriteriaId": "BE6EA542-A222-4E6A-869B-F3805CAFCDD0", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}], "descriptions": [{"lang": "en", "value": "Double free vulnerability in magick/profile.c in ImageMagick allows remote attackers to have unspecified impact via a crafted file."}, {"lang": "es", "value": "La vulnerabilidad de liberaci\u00f3n doble en magick/profile.c en ImageMagick permite a los atacantes remotos tener un impacto no especificado a trav\u00e9s de un archivo manipulado."}], "evaluatorComment": null, "id": "CVE-2017-5506", "lastModified": "2020-10-15T16:08:22.560", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 6.8, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 8.6, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "nvd@nist.gov", "type": "Primary", "userInteractionRequired": true}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 7.8, "baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 5.9, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2017-03-24T15:59:00.967", "references": [{"source": "security@debian.org", "tags": ["Third Party Advisory"], "url": "http://www.debian.org/security/2017/dsa-3799"}, {"source": "security@debian.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2017/01/16/6"}, {"source": "security@debian.org", "tags": ["Mailing List", "Patch", "Third Party Advisory"], "url": "http://www.openwall.com/lists/oss-security/2017/01/17/5"}, {"source": "security@debian.org", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/95753"}, {"source": "security@debian.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=851383"}, {"source": "security@debian.org", "tags": ["Patch", "Vendor Advisory"], "url": "https://github.com/ImageMagick/ImageMagick/commit/9a069e0f2e027ec5138f998023cf9cb62c04889f"}, {"source": "security@debian.org", "tags": ["Issue Tracking", "Patch", "Third Party Advisory"], "url": "https://github.com/ImageMagick/ImageMagick/issues/354"}, {"source": "security@debian.org", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/201702-09"}], "sourceIdentifier": "security@debian.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-415"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/ImageMagick/ImageMagick/commit/9a069e0f2e027ec5138f998023cf9cb62c04889f"}, "type": "CWE-415"}
| 221
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# frozen_string_literal: true\nrequire 'rubygems'",
"##\n# A collection of text-wrangling methods",
"module Gem::Text",
" ##\n # Remove any non-printable characters and make the text suitable for\n # printing.\n def clean_text(text)",
" text.gsub(/[\\u0000-\\u0008\\u000b-\\u000c\\u000e-\\u001F\\u007f]/, \".\".freeze)",
" end",
" ##\n # Wraps +text+ to +wrap+ characters and optionally indents by +indent+\n # characters",
" def format_text(text, wrap, indent=0)\n result = []\n work = clean_text(text)",
" while work.length > wrap do\n if work =~ /^(.{0,#{wrap}})[ \\n]/ then\n result << $1.rstrip\n work.slice!(0, $&.length)\n else\n result << work.slice!(0, wrap)\n end\n end",
" result << work if work.length.nonzero?\n result.join(\"\\n\").gsub(/^/, \" \" * indent)\n end",
" def min3 a, b, c # :nodoc:\n if a < b && a < c then\n a\n elsif b < c then\n b\n else\n c\n end\n end",
" # This code is based directly on the Text gem implementation\n # Returns a value representing the \"cost\" of transforming str1 into str2\n def levenshtein_distance str1, str2\n s = str1\n t = str2\n n = s.length\n m = t.length",
" return m if (0 == n)\n return n if (0 == m)",
" d = (0..m).to_a\n x = nil",
" str1.each_char.each_with_index do |char1,i|\n e = i+1",
" str2.each_char.each_with_index do |char2,j|\n cost = (char1 == char2) ? 0 : 1\n x = min3(\n d[j+1] + 1, # insertion\n e + 1, # deletion\n d[j] + cost # substitution\n )\n d[j] = e\n e = x\n end",
" d[m] = x\n end",
" return x\n end\nend"
] |
[
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [14, 137, 41], "buggy_code_start_loc": [13, 135, 40], "filenames": ["lib/rubygems/text.rb", "test/rubygems/test_gem_commands_query_command.rb", "test/rubygems/test_gem_text.rb"], "fixing_code_end_loc": [14, 137, 41], "fixing_code_start_loc": [13, 135, 40], "message": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:rubygems:rubygems:*:*:*:*:*:*:*:*", "matchCriteriaId": "1161B0D8-43B3-4123-BD4F-87F260AB8947", "versionEndExcluding": null, "versionEndIncluding": "2.6.12", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}, {"nodes": [{"cpeMatch": [{"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_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_server_aus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D99A687E-EAE6-417E-A88E-D0082BC194CD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_aus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B353CE99-D57C-465B-AAB0-73EF581127D1", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "9EC0D196-F7B8-4BDD-9050-779F7A7FBEE4", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.5:*:*:*:*:*:*:*", "matchCriteriaId": "A4E9DD8A-A68B-4A69-8B01-BFF92A2020A8", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "BF77CDCF-B9C9-427D-B2BF-36650FB2148C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D5F7E11E-FB34-4467-8919-2B6BEAABF665", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B76AA310-FEC7-497F-AF04-C3EC1E76C4CC", "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": null}], "descriptions": [{"lang": "en", "value": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences."}, {"lang": "es", "value": "RubyGems 2.6.12 y anteriores es vulnerable a especificaciones de gemas manipuladas maliciosamente que incluyen caracteres de escapada de terminal. Imprimir la especificaci\u00f3n de las gemas ejecutar\u00eda secuencias de escapada de terminal."}], "evaluatorComment": null, "id": "CVE-2017-0899", "lastModified": "2019-10-09T23:21:09.713", "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-08-31T20:29:00.417", "references": [{"source": "support@hackerone.com", "tags": ["Patch", "Vendor Advisory"], "url": "http://blog.rubygems.org/2017/08/27/2.6.13-released.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/100576"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securitytracker.com/id/1039249"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:3485"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0378"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0583"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0585"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/ef0aa611effb5f54d40c7fba6e8235eb43c5a491"}, {"source": "support@hackerone.com", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://hackerone.com/reports/226335"}, {"source": "support@hackerone.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2018/07/msg00012.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/201710-01"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2017/dsa-3966"}], "sourceIdentifier": "support@hackerone.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-94"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-150"}], "source": "support@hackerone.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, "type": "CWE-94"}
| 222
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# frozen_string_literal: true\nrequire 'rubygems'",
"##\n# A collection of text-wrangling methods",
"module Gem::Text",
" ##\n # Remove any non-printable characters and make the text suitable for\n # printing.\n def clean_text(text)",
" text.gsub(/[\\000-\\b\\v-\\f\\016-\\037\\177]/, \".\".freeze)",
" end",
" ##\n # Wraps +text+ to +wrap+ characters and optionally indents by +indent+\n # characters",
" def format_text(text, wrap, indent=0)\n result = []\n work = clean_text(text)",
" while work.length > wrap do\n if work =~ /^(.{0,#{wrap}})[ \\n]/ then\n result << $1.rstrip\n work.slice!(0, $&.length)\n else\n result << work.slice!(0, wrap)\n end\n end",
" result << work if work.length.nonzero?\n result.join(\"\\n\").gsub(/^/, \" \" * indent)\n end",
" def min3 a, b, c # :nodoc:\n if a < b && a < c then\n a\n elsif b < c then\n b\n else\n c\n end\n end",
" # This code is based directly on the Text gem implementation\n # Returns a value representing the \"cost\" of transforming str1 into str2\n def levenshtein_distance str1, str2\n s = str1\n t = str2\n n = s.length\n m = t.length",
" return m if (0 == n)\n return n if (0 == m)",
" d = (0..m).to_a\n x = nil",
" str1.each_char.each_with_index do |char1,i|\n e = i+1",
" str2.each_char.each_with_index do |char2,j|\n cost = (char1 == char2) ? 0 : 1\n x = min3(\n d[j+1] + 1, # insertion\n e + 1, # deletion\n d[j] + cost # substitution\n )\n d[j] = e\n e = x\n end",
" d[m] = x\n end",
" return x\n end\nend"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [14, 137, 41], "buggy_code_start_loc": [13, 135, 40], "filenames": ["lib/rubygems/text.rb", "test/rubygems/test_gem_commands_query_command.rb", "test/rubygems/test_gem_text.rb"], "fixing_code_end_loc": [14, 137, 41], "fixing_code_start_loc": [13, 135, 40], "message": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:rubygems:rubygems:*:*:*:*:*:*:*:*", "matchCriteriaId": "1161B0D8-43B3-4123-BD4F-87F260AB8947", "versionEndExcluding": null, "versionEndIncluding": "2.6.12", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}, {"nodes": [{"cpeMatch": [{"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_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_server_aus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D99A687E-EAE6-417E-A88E-D0082BC194CD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_aus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B353CE99-D57C-465B-AAB0-73EF581127D1", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "9EC0D196-F7B8-4BDD-9050-779F7A7FBEE4", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.5:*:*:*:*:*:*:*", "matchCriteriaId": "A4E9DD8A-A68B-4A69-8B01-BFF92A2020A8", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "BF77CDCF-B9C9-427D-B2BF-36650FB2148C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D5F7E11E-FB34-4467-8919-2B6BEAABF665", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B76AA310-FEC7-497F-AF04-C3EC1E76C4CC", "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": null}], "descriptions": [{"lang": "en", "value": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences."}, {"lang": "es", "value": "RubyGems 2.6.12 y anteriores es vulnerable a especificaciones de gemas manipuladas maliciosamente que incluyen caracteres de escapada de terminal. Imprimir la especificaci\u00f3n de las gemas ejecutar\u00eda secuencias de escapada de terminal."}], "evaluatorComment": null, "id": "CVE-2017-0899", "lastModified": "2019-10-09T23:21:09.713", "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-08-31T20:29:00.417", "references": [{"source": "support@hackerone.com", "tags": ["Patch", "Vendor Advisory"], "url": "http://blog.rubygems.org/2017/08/27/2.6.13-released.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/100576"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securitytracker.com/id/1039249"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:3485"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0378"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0583"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0585"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/ef0aa611effb5f54d40c7fba6e8235eb43c5a491"}, {"source": "support@hackerone.com", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://hackerone.com/reports/226335"}, {"source": "support@hackerone.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2018/07/msg00012.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/201710-01"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2017/dsa-3966"}], "sourceIdentifier": "support@hackerone.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-94"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-150"}], "source": "support@hackerone.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, "type": "CWE-94"}
| 222
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# frozen_string_literal: true\nrequire 'rubygems/test_case'\nrequire 'rubygems/commands/query_command'",
"module TestGemCommandsQueryCommandSetup\n def setup\n super",
" @cmd = Gem::Commands::QueryCommand.new",
" @specs = add_gems_to_fetcher",
" @fetcher.data[\"#{@gem_repo}Marshal.#{Gem.marshal_version}\"] = proc do\n raise Gem::RemoteFetcher::FetchError\n end\n end\nend",
"class TestGemCommandsQueryCommandWithInstalledGems < Gem::TestCase\n include TestGemCommandsQueryCommandSetup",
" def test_execute\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_all\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r --all]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_all_prerelease\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r --all --prerelease]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_details\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 2 do |s|\n s.summary = 'This is a lot of text. ' * 4\n s.authors = ['Abraham Lincoln', 'Hirohito']\n s.homepage = 'http://a.example.com/'\n end",
" fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r -d]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2)\n Authors: Abraham Lincoln, Hirohito\n Homepage: http://a.example.com/",
" This is a lot of text. This is a lot of text. This is a lot of text.\n This is a lot of text.",
"pl (1)\n Platform: i386-linux\n Author: A User\n Homepage: http://example.com",
" this is a summary\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_details_cleans_text\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 2 do |s|\n s.summary = 'This is a lot of text. ' * 4",
" s.authors = [\"Abraham Lincoln \\u0001\", \"\\u0002 Hirohito\"]\n s.homepage = \"http://a.example.com/\\u0003\"",
" end",
" fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r -d]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2)\n Authors: Abraham Lincoln ., . Hirohito\n Homepage: http://a.example.com/.",
" This is a lot of text. This is a lot of text. This is a lot of text.\n This is a lot of text.",
"pl (1)\n Platform: i386-linux\n Author: A User\n Homepage: http://example.com",
" this is a summary\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_installed\n @cmd.handle_options %w[-n a --installed]",
" assert_raises Gem::MockGemUi::SystemExitException do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"true\\n\", @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_installed_inverse\n @cmd.handle_options %w[-n a --no-installed]",
" e = assert_raises Gem::MockGemUi::TermError do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"false\\n\", @ui.output\n assert_equal '', @ui.error",
" assert_equal 1, e.exit_code\n end",
" def test_execute_installed_inverse_not_installed\n @cmd.handle_options %w[-n not_installed --no-installed]",
" assert_raises Gem::MockGemUi::SystemExitException do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"true\\n\", @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_installed_no_name\n @cmd.handle_options %w[--installed]",
" e = assert_raises Gem::MockGemUi::TermError do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal '', @ui.output\n assert_equal \"ERROR: You must specify a gem name\\n\", @ui.error",
" assert_equal 4, e.exit_code\n end",
" def test_execute_installed_not_installed\n @cmd.handle_options %w[-n not_installed --installed]",
" e = assert_raises Gem::MockGemUi::TermError do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"false\\n\", @ui.output\n assert_equal '', @ui.error",
" assert_equal 1, e.exit_code\n end",
" def test_execute_installed_version\n @cmd.handle_options %w[-n a --installed --version 2]",
" assert_raises Gem::MockGemUi::SystemExitException do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"true\\n\", @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_installed_version_not_installed\n @cmd.handle_options %w[-n c --installed --version 2]",
" e = assert_raises Gem::MockGemUi::TermError do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"false\\n\", @ui.output\n assert_equal '', @ui.error",
" assert_equal 1, e.exit_code\n end",
" def test_execute_local\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.options[:domain] = :local",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"a (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_local_notty\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[]",
" @ui.outs.tty = false",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF\na (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_local_quiet\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.options[:domain] = :local\n Gem.configuration.verbose = false",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF\na (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_no_versions\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r --no-versions]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a\npl\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_notty\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r]",
" @ui.outs.tty = false",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF\na (2)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_prerelease\n @cmd.handle_options %w[-r --prerelease]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (3.a)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_prerelease_local\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-l --prerelease]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"a (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal \"WARNING: prereleases are always shown locally\\n\", @ui.error\n end",
" def test_execute_remote\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.options[:domain] = :remote",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_remote_notty\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[]",
" @ui.outs.tty = false",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF\na (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_remote_quiet\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.options[:domain] = :remote\n Gem.configuration.verbose = false",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF\na (2)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_make_entry\n a_2_name = @specs['a-2'].original_name",
" @fetcher.data.delete \\\n \"#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{a_2_name}.gemspec.rz\"",
" a2 = @specs['a-2']\n entry_tuples = [\n [Gem::NameTuple.new(a2.name, a2.version, a2.platform),\n Gem.sources.first],\n ]",
" platforms = { a2.version => [a2.platform] }",
" entry = @cmd.send :make_entry, entry_tuples, platforms",
" assert_equal 'a (2)', entry\n end",
" # Test for multiple args handling!\n def test_execute_multiple_args\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[a pl]",
" use_ui @ui do\n @cmd.execute\n end",
" assert_match %r%^a %, @ui.output\n assert_match %r%^pl %, @ui.output\n assert_equal '', @ui.error\n end",
" def test_show_gems\n @cmd.options[:name] = //\n @cmd.options[:domain] = :remote",
" use_ui @ui do\n @cmd.send :show_gems, /a/i, false\n end",
" assert_match %r%^a %, @ui.output\n refute_match %r%^pl %, @ui.output\n assert_empty @ui.error\n end",
" private",
" def add_gems_to_fetcher\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 1\n fetcher.spec 'a', 2\n fetcher.spec 'a', '3.a'\n end\n end\nend",
"class TestGemCommandsQueryCommandWithoutInstalledGems < Gem::TestCase\n include TestGemCommandsQueryCommandSetup",
" def test_execute_platform\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 1\n fetcher.spec 'a', 1 do |s|\n s.platform = 'x86-linux'\n end",
" fetcher.spec 'a', 2 do |s|\n s.platform = 'universal-darwin'\n end\n end",
" @cmd.handle_options %w[-r -a]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2 universal-darwin, 1 ruby x86-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_show_default_gems\n spec_fetcher { |fetcher| fetcher.spec 'a', 2 }",
" a1 = new_default_spec 'a', 1\n install_default_specs a1",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"a (2, default: 1)\nEOF",
" assert_equal expected, @ui.output\n end",
" def test_execute_default_details\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 2\n end",
" a1 = new_default_spec 'a', 1\n install_default_specs a1",
" @cmd.handle_options %w[-l -d]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"a (2, 1)\n Author: A User\n Homepage: http://example.com\n Installed at (2): #{@gemhome}\n (1, default): #{a1.base_dir}",
" this is a summary\n EOF",
" assert_equal expected, @ui.output\n end",
" def test_execute_local_details\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 1 do |s|\n s.platform = 'x86-linux'\n end",
" fetcher.spec 'a', 2 do |s|\n s.summary = 'This is a lot of text. ' * 4\n s.authors = ['Abraham Lincoln', 'Hirohito']\n s.homepage = 'http://a.example.com/'\n s.platform = 'universal-darwin'\n end",
" fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-l -d]",
" use_ui @ui do\n @cmd.execute\n end",
" str = @ui.output",
" str.gsub!(/\\(\\d\\): [^\\n]*/, \"-\")\n str.gsub!(/at: [^\\n]*/, \"at: -\")",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"a (2, 1)\n Platforms:\n 1: x86-linux\n 2: universal-darwin\n Authors: Abraham Lincoln, Hirohito\n Homepage: http://a.example.com/\n Installed at -\n -",
" This is a lot of text. This is a lot of text. This is a lot of text.\n This is a lot of text.",
"pl (1)\n Platform: i386-linux\n Author: A User\n Homepage: http://example.com\n Installed at: -",
" this is a summary\n EOF",
" assert_equal expected, @ui.output\n end",
" def test_execute_exact_remote\n spec_fetcher do |fetcher|\n fetcher.spec 'coolgem-omg', 3\n fetcher.spec 'coolgem', '4.2.1'\n fetcher.spec 'wow_coolgem', 1\n end",
" @cmd.handle_options %w[--remote --exact coolgem]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"coolgem (4.2.1)\n EOF",
" assert_equal expected, @ui.output\n end",
" def test_execute_exact_local\n spec_fetcher do |fetcher|\n fetcher.spec 'coolgem-omg', 3\n fetcher.spec 'coolgem', '4.2.1'\n fetcher.spec 'wow_coolgem', 1\n end",
" @cmd.handle_options %w[--exact coolgem]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"coolgem (4.2.1)\n EOF",
" assert_equal expected, @ui.output\n end",
" def test_execute_exact_multiple\n spec_fetcher do |fetcher|\n fetcher.spec 'coolgem-omg', 3\n fetcher.spec 'coolgem', '4.2.1'\n fetcher.spec 'wow_coolgem', 1",
" fetcher.spec 'othergem-omg', 3\n fetcher.spec 'othergem', '1.2.3'\n fetcher.spec 'wow_othergem', 1\n end",
" @cmd.handle_options %w[--exact coolgem othergem]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"coolgem (4.2.1)",
"*** LOCAL GEMS ***",
"othergem (1.2.3)\n EOF",
" assert_equal expected, @ui.output\n end",
" private",
" def add_gems_to_fetcher\n spec_fetcher do |fetcher|\n fetcher.download 'a', 1\n fetcher.download 'a', 2\n fetcher.download 'a', '3.a'\n end\n end\nend"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [14, 137, 41], "buggy_code_start_loc": [13, 135, 40], "filenames": ["lib/rubygems/text.rb", "test/rubygems/test_gem_commands_query_command.rb", "test/rubygems/test_gem_text.rb"], "fixing_code_end_loc": [14, 137, 41], "fixing_code_start_loc": [13, 135, 40], "message": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:rubygems:rubygems:*:*:*:*:*:*:*:*", "matchCriteriaId": "1161B0D8-43B3-4123-BD4F-87F260AB8947", "versionEndExcluding": null, "versionEndIncluding": "2.6.12", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}, {"nodes": [{"cpeMatch": [{"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_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_server_aus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D99A687E-EAE6-417E-A88E-D0082BC194CD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_aus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B353CE99-D57C-465B-AAB0-73EF581127D1", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "9EC0D196-F7B8-4BDD-9050-779F7A7FBEE4", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.5:*:*:*:*:*:*:*", "matchCriteriaId": "A4E9DD8A-A68B-4A69-8B01-BFF92A2020A8", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "BF77CDCF-B9C9-427D-B2BF-36650FB2148C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D5F7E11E-FB34-4467-8919-2B6BEAABF665", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B76AA310-FEC7-497F-AF04-C3EC1E76C4CC", "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": null}], "descriptions": [{"lang": "en", "value": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences."}, {"lang": "es", "value": "RubyGems 2.6.12 y anteriores es vulnerable a especificaciones de gemas manipuladas maliciosamente que incluyen caracteres de escapada de terminal. Imprimir la especificaci\u00f3n de las gemas ejecutar\u00eda secuencias de escapada de terminal."}], "evaluatorComment": null, "id": "CVE-2017-0899", "lastModified": "2019-10-09T23:21:09.713", "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-08-31T20:29:00.417", "references": [{"source": "support@hackerone.com", "tags": ["Patch", "Vendor Advisory"], "url": "http://blog.rubygems.org/2017/08/27/2.6.13-released.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/100576"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securitytracker.com/id/1039249"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:3485"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0378"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0583"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0585"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/ef0aa611effb5f54d40c7fba6e8235eb43c5a491"}, {"source": "support@hackerone.com", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://hackerone.com/reports/226335"}, {"source": "support@hackerone.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2018/07/msg00012.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/201710-01"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2017/dsa-3966"}], "sourceIdentifier": "support@hackerone.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-94"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-150"}], "source": "support@hackerone.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, "type": "CWE-94"}
| 222
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# frozen_string_literal: true\nrequire 'rubygems/test_case'\nrequire 'rubygems/commands/query_command'",
"module TestGemCommandsQueryCommandSetup\n def setup\n super",
" @cmd = Gem::Commands::QueryCommand.new",
" @specs = add_gems_to_fetcher",
" @fetcher.data[\"#{@gem_repo}Marshal.#{Gem.marshal_version}\"] = proc do\n raise Gem::RemoteFetcher::FetchError\n end\n end\nend",
"class TestGemCommandsQueryCommandWithInstalledGems < Gem::TestCase\n include TestGemCommandsQueryCommandSetup",
" def test_execute\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_all\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r --all]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_all_prerelease\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r --all --prerelease]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_details\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 2 do |s|\n s.summary = 'This is a lot of text. ' * 4\n s.authors = ['Abraham Lincoln', 'Hirohito']\n s.homepage = 'http://a.example.com/'\n end",
" fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r -d]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2)\n Authors: Abraham Lincoln, Hirohito\n Homepage: http://a.example.com/",
" This is a lot of text. This is a lot of text. This is a lot of text.\n This is a lot of text.",
"pl (1)\n Platform: i386-linux\n Author: A User\n Homepage: http://example.com",
" this is a summary\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_details_cleans_text\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 2 do |s|\n s.summary = 'This is a lot of text. ' * 4",
" s.authors = [\"Abraham Lincoln \\x01\", \"\\x02 Hirohito\"]\n s.homepage = \"http://a.example.com/\\x03\"",
" end",
" fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r -d]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2)\n Authors: Abraham Lincoln ., . Hirohito\n Homepage: http://a.example.com/.",
" This is a lot of text. This is a lot of text. This is a lot of text.\n This is a lot of text.",
"pl (1)\n Platform: i386-linux\n Author: A User\n Homepage: http://example.com",
" this is a summary\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_installed\n @cmd.handle_options %w[-n a --installed]",
" assert_raises Gem::MockGemUi::SystemExitException do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"true\\n\", @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_installed_inverse\n @cmd.handle_options %w[-n a --no-installed]",
" e = assert_raises Gem::MockGemUi::TermError do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"false\\n\", @ui.output\n assert_equal '', @ui.error",
" assert_equal 1, e.exit_code\n end",
" def test_execute_installed_inverse_not_installed\n @cmd.handle_options %w[-n not_installed --no-installed]",
" assert_raises Gem::MockGemUi::SystemExitException do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"true\\n\", @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_installed_no_name\n @cmd.handle_options %w[--installed]",
" e = assert_raises Gem::MockGemUi::TermError do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal '', @ui.output\n assert_equal \"ERROR: You must specify a gem name\\n\", @ui.error",
" assert_equal 4, e.exit_code\n end",
" def test_execute_installed_not_installed\n @cmd.handle_options %w[-n not_installed --installed]",
" e = assert_raises Gem::MockGemUi::TermError do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"false\\n\", @ui.output\n assert_equal '', @ui.error",
" assert_equal 1, e.exit_code\n end",
" def test_execute_installed_version\n @cmd.handle_options %w[-n a --installed --version 2]",
" assert_raises Gem::MockGemUi::SystemExitException do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"true\\n\", @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_installed_version_not_installed\n @cmd.handle_options %w[-n c --installed --version 2]",
" e = assert_raises Gem::MockGemUi::TermError do\n use_ui @ui do\n @cmd.execute\n end\n end",
" assert_equal \"false\\n\", @ui.output\n assert_equal '', @ui.error",
" assert_equal 1, e.exit_code\n end",
" def test_execute_local\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.options[:domain] = :local",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"a (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_local_notty\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[]",
" @ui.outs.tty = false",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF\na (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_local_quiet\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.options[:domain] = :local\n Gem.configuration.verbose = false",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF\na (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_no_versions\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r --no-versions]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a\npl\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_notty\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-r]",
" @ui.outs.tty = false",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF\na (2)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_prerelease\n @cmd.handle_options %w[-r --prerelease]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (3.a)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_prerelease_local\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-l --prerelease]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"a (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal \"WARNING: prereleases are always shown locally\\n\", @ui.error\n end",
" def test_execute_remote\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.options[:domain] = :remote",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_remote_notty\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[]",
" @ui.outs.tty = false",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF\na (3.a, 2, 1)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_remote_quiet\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.options[:domain] = :remote\n Gem.configuration.verbose = false",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF\na (2)\npl (1 i386-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_make_entry\n a_2_name = @specs['a-2'].original_name",
" @fetcher.data.delete \\\n \"#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{a_2_name}.gemspec.rz\"",
" a2 = @specs['a-2']\n entry_tuples = [\n [Gem::NameTuple.new(a2.name, a2.version, a2.platform),\n Gem.sources.first],\n ]",
" platforms = { a2.version => [a2.platform] }",
" entry = @cmd.send :make_entry, entry_tuples, platforms",
" assert_equal 'a (2)', entry\n end",
" # Test for multiple args handling!\n def test_execute_multiple_args\n spec_fetcher do |fetcher|\n fetcher.legacy_platform\n end",
" @cmd.handle_options %w[a pl]",
" use_ui @ui do\n @cmd.execute\n end",
" assert_match %r%^a %, @ui.output\n assert_match %r%^pl %, @ui.output\n assert_equal '', @ui.error\n end",
" def test_show_gems\n @cmd.options[:name] = //\n @cmd.options[:domain] = :remote",
" use_ui @ui do\n @cmd.send :show_gems, /a/i, false\n end",
" assert_match %r%^a %, @ui.output\n refute_match %r%^pl %, @ui.output\n assert_empty @ui.error\n end",
" private",
" def add_gems_to_fetcher\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 1\n fetcher.spec 'a', 2\n fetcher.spec 'a', '3.a'\n end\n end\nend",
"class TestGemCommandsQueryCommandWithoutInstalledGems < Gem::TestCase\n include TestGemCommandsQueryCommandSetup",
" def test_execute_platform\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 1\n fetcher.spec 'a', 1 do |s|\n s.platform = 'x86-linux'\n end",
" fetcher.spec 'a', 2 do |s|\n s.platform = 'universal-darwin'\n end\n end",
" @cmd.handle_options %w[-r -a]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"a (2 universal-darwin, 1 ruby x86-linux)\n EOF",
" assert_equal expected, @ui.output\n assert_equal '', @ui.error\n end",
" def test_execute_show_default_gems\n spec_fetcher { |fetcher| fetcher.spec 'a', 2 }",
" a1 = new_default_spec 'a', 1\n install_default_specs a1",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"a (2, default: 1)\nEOF",
" assert_equal expected, @ui.output\n end",
" def test_execute_default_details\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 2\n end",
" a1 = new_default_spec 'a', 1\n install_default_specs a1",
" @cmd.handle_options %w[-l -d]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"a (2, 1)\n Author: A User\n Homepage: http://example.com\n Installed at (2): #{@gemhome}\n (1, default): #{a1.base_dir}",
" this is a summary\n EOF",
" assert_equal expected, @ui.output\n end",
" def test_execute_local_details\n spec_fetcher do |fetcher|\n fetcher.spec 'a', 1 do |s|\n s.platform = 'x86-linux'\n end",
" fetcher.spec 'a', 2 do |s|\n s.summary = 'This is a lot of text. ' * 4\n s.authors = ['Abraham Lincoln', 'Hirohito']\n s.homepage = 'http://a.example.com/'\n s.platform = 'universal-darwin'\n end",
" fetcher.legacy_platform\n end",
" @cmd.handle_options %w[-l -d]",
" use_ui @ui do\n @cmd.execute\n end",
" str = @ui.output",
" str.gsub!(/\\(\\d\\): [^\\n]*/, \"-\")\n str.gsub!(/at: [^\\n]*/, \"at: -\")",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"a (2, 1)\n Platforms:\n 1: x86-linux\n 2: universal-darwin\n Authors: Abraham Lincoln, Hirohito\n Homepage: http://a.example.com/\n Installed at -\n -",
" This is a lot of text. This is a lot of text. This is a lot of text.\n This is a lot of text.",
"pl (1)\n Platform: i386-linux\n Author: A User\n Homepage: http://example.com\n Installed at: -",
" this is a summary\n EOF",
" assert_equal expected, @ui.output\n end",
" def test_execute_exact_remote\n spec_fetcher do |fetcher|\n fetcher.spec 'coolgem-omg', 3\n fetcher.spec 'coolgem', '4.2.1'\n fetcher.spec 'wow_coolgem', 1\n end",
" @cmd.handle_options %w[--remote --exact coolgem]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** REMOTE GEMS ***",
"coolgem (4.2.1)\n EOF",
" assert_equal expected, @ui.output\n end",
" def test_execute_exact_local\n spec_fetcher do |fetcher|\n fetcher.spec 'coolgem-omg', 3\n fetcher.spec 'coolgem', '4.2.1'\n fetcher.spec 'wow_coolgem', 1\n end",
" @cmd.handle_options %w[--exact coolgem]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"coolgem (4.2.1)\n EOF",
" assert_equal expected, @ui.output\n end",
" def test_execute_exact_multiple\n spec_fetcher do |fetcher|\n fetcher.spec 'coolgem-omg', 3\n fetcher.spec 'coolgem', '4.2.1'\n fetcher.spec 'wow_coolgem', 1",
" fetcher.spec 'othergem-omg', 3\n fetcher.spec 'othergem', '1.2.3'\n fetcher.spec 'wow_othergem', 1\n end",
" @cmd.handle_options %w[--exact coolgem othergem]",
" use_ui @ui do\n @cmd.execute\n end",
" expected = <<-EOF",
"*** LOCAL GEMS ***",
"coolgem (4.2.1)",
"*** LOCAL GEMS ***",
"othergem (1.2.3)\n EOF",
" assert_equal expected, @ui.output\n end",
" private",
" def add_gems_to_fetcher\n spec_fetcher do |fetcher|\n fetcher.download 'a', 1\n fetcher.download 'a', 2\n fetcher.download 'a', '3.a'\n end\n end\nend"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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": [14, 137, 41], "buggy_code_start_loc": [13, 135, 40], "filenames": ["lib/rubygems/text.rb", "test/rubygems/test_gem_commands_query_command.rb", "test/rubygems/test_gem_text.rb"], "fixing_code_end_loc": [14, 137, 41], "fixing_code_start_loc": [13, 135, 40], "message": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:rubygems:rubygems:*:*:*:*:*:*:*:*", "matchCriteriaId": "1161B0D8-43B3-4123-BD4F-87F260AB8947", "versionEndExcluding": null, "versionEndIncluding": "2.6.12", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}, {"nodes": [{"cpeMatch": [{"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_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_server_aus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D99A687E-EAE6-417E-A88E-D0082BC194CD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_aus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B353CE99-D57C-465B-AAB0-73EF581127D1", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "9EC0D196-F7B8-4BDD-9050-779F7A7FBEE4", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.5:*:*:*:*:*:*:*", "matchCriteriaId": "A4E9DD8A-A68B-4A69-8B01-BFF92A2020A8", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "BF77CDCF-B9C9-427D-B2BF-36650FB2148C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D5F7E11E-FB34-4467-8919-2B6BEAABF665", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B76AA310-FEC7-497F-AF04-C3EC1E76C4CC", "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": null}], "descriptions": [{"lang": "en", "value": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences."}, {"lang": "es", "value": "RubyGems 2.6.12 y anteriores es vulnerable a especificaciones de gemas manipuladas maliciosamente que incluyen caracteres de escapada de terminal. Imprimir la especificaci\u00f3n de las gemas ejecutar\u00eda secuencias de escapada de terminal."}], "evaluatorComment": null, "id": "CVE-2017-0899", "lastModified": "2019-10-09T23:21:09.713", "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-08-31T20:29:00.417", "references": [{"source": "support@hackerone.com", "tags": ["Patch", "Vendor Advisory"], "url": "http://blog.rubygems.org/2017/08/27/2.6.13-released.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/100576"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securitytracker.com/id/1039249"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:3485"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0378"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0583"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0585"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/ef0aa611effb5f54d40c7fba6e8235eb43c5a491"}, {"source": "support@hackerone.com", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://hackerone.com/reports/226335"}, {"source": "support@hackerone.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2018/07/msg00012.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/201710-01"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2017/dsa-3966"}], "sourceIdentifier": "support@hackerone.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-94"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-150"}], "source": "support@hackerone.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, "type": "CWE-94"}
| 222
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# frozen_string_literal: true\nrequire 'rubygems/test_case'\nrequire \"rubygems/text\"",
"class TestGemText < Gem::TestCase\n include Gem::Text",
" def test_format_text\n assert_equal \"text to\\nwrap\", format_text(\"text to wrap\", 8)\n end",
" def test_format_text_indent\n assert_equal \" text to\\n wrap\", format_text(\"text to wrap\", 8, 2)\n end",
" def test_format_text_none\n assert_equal \"text to wrap\", format_text(\"text to wrap\", 40)\n end",
" def test_format_text_none_indent\n assert_equal \" text to wrap\", format_text(\"text to wrap\", 40, 2)\n end",
" def test_format_text_trailing # for two spaces after .\n text = <<-TEXT\nThis line is really, really long. So long, in fact, that it is more than eighty characters long! The purpose of this line is for testing wrapping behavior because sometimes people don't wrap their text to eighty characters. Without the wrapping, the text might not look good in the RSS feed.\n TEXT",
" expected = <<-EXPECTED\nThis line is really, really long. So long, in fact, that it is more than\neighty characters long! The purpose of this line is for testing wrapping\nbehavior because sometimes people don't wrap their text to eighty characters.\nWithout the wrapping, the text might not look good in the RSS feed.\n EXPECTED",
" assert_equal expected, format_text(text, 78)\n end",
" def test_format_removes_nonprintable_characters",
" assert_equal \"text with weird .. stuff\", format_text(\"text with weird \\u001b\\u0002 stuff\", 40)",
" end",
" def test_min3\n assert_equal 1, min3(1, 1, 1)\n assert_equal 1, min3(1, 1, 2)\n assert_equal 1, min3(1, 2, 1)\n assert_equal 1, min3(2, 1, 1)\n assert_equal 1, min3(1, 2, 2)\n assert_equal 1, min3(2, 1, 2)\n assert_equal 1, min3(2, 2, 1)\n assert_equal 1, min3(1, 2, 3)\n assert_equal 1, min3(1, 3, 2)\n assert_equal 1, min3(2, 1, 3)\n assert_equal 1, min3(2, 3, 1)\n assert_equal 1, min3(3, 1, 2)\n assert_equal 1, min3(3, 2, 1)\n end",
" def test_levenshtein_distance_add\n assert_equal 2, levenshtein_distance(\"zentest\", \"zntst\")\n assert_equal 2, levenshtein_distance(\"zntst\", \"zentest\")\n end",
" def test_levenshtein_distance_empty\n assert_equal 5, levenshtein_distance(\"abcde\", \"\")\n assert_equal 5, levenshtein_distance(\"\", \"abcde\")\n end",
" def test_levenshtein_distance_remove\n assert_equal 3, levenshtein_distance(\"zentest\", \"zentestxxx\")\n assert_equal 3, levenshtein_distance(\"zentestxxx\", \"zentest\")\n assert_equal 13, levenshtein_distance(\"cat\", \"thundercatsarego\")\n assert_equal 13, levenshtein_distance(\"thundercatsarego\", \"cat\")\n end",
" def test_levenshtein_distance_replace\n assert_equal 2, levenshtein_distance(\"zentest\", \"ZenTest\")\n assert_equal 7, levenshtein_distance(\"xxxxxxx\", \"ZenTest\")\n assert_equal 7, levenshtein_distance(\"zentest\", \"xxxxxxx\")\n end\nend"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [14, 137, 41], "buggy_code_start_loc": [13, 135, 40], "filenames": ["lib/rubygems/text.rb", "test/rubygems/test_gem_commands_query_command.rb", "test/rubygems/test_gem_text.rb"], "fixing_code_end_loc": [14, 137, 41], "fixing_code_start_loc": [13, 135, 40], "message": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:rubygems:rubygems:*:*:*:*:*:*:*:*", "matchCriteriaId": "1161B0D8-43B3-4123-BD4F-87F260AB8947", "versionEndExcluding": null, "versionEndIncluding": "2.6.12", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}, {"nodes": [{"cpeMatch": [{"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_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_server_aus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D99A687E-EAE6-417E-A88E-D0082BC194CD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_aus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B353CE99-D57C-465B-AAB0-73EF581127D1", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "9EC0D196-F7B8-4BDD-9050-779F7A7FBEE4", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.5:*:*:*:*:*:*:*", "matchCriteriaId": "A4E9DD8A-A68B-4A69-8B01-BFF92A2020A8", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "BF77CDCF-B9C9-427D-B2BF-36650FB2148C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D5F7E11E-FB34-4467-8919-2B6BEAABF665", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B76AA310-FEC7-497F-AF04-C3EC1E76C4CC", "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": null}], "descriptions": [{"lang": "en", "value": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences."}, {"lang": "es", "value": "RubyGems 2.6.12 y anteriores es vulnerable a especificaciones de gemas manipuladas maliciosamente que incluyen caracteres de escapada de terminal. Imprimir la especificaci\u00f3n de las gemas ejecutar\u00eda secuencias de escapada de terminal."}], "evaluatorComment": null, "id": "CVE-2017-0899", "lastModified": "2019-10-09T23:21:09.713", "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-08-31T20:29:00.417", "references": [{"source": "support@hackerone.com", "tags": ["Patch", "Vendor Advisory"], "url": "http://blog.rubygems.org/2017/08/27/2.6.13-released.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/100576"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securitytracker.com/id/1039249"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:3485"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0378"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0583"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0585"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/ef0aa611effb5f54d40c7fba6e8235eb43c5a491"}, {"source": "support@hackerone.com", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://hackerone.com/reports/226335"}, {"source": "support@hackerone.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2018/07/msg00012.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/201710-01"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2017/dsa-3966"}], "sourceIdentifier": "support@hackerone.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-94"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-150"}], "source": "support@hackerone.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, "type": "CWE-94"}
| 222
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"# frozen_string_literal: true\nrequire 'rubygems/test_case'\nrequire \"rubygems/text\"",
"class TestGemText < Gem::TestCase\n include Gem::Text",
" def test_format_text\n assert_equal \"text to\\nwrap\", format_text(\"text to wrap\", 8)\n end",
" def test_format_text_indent\n assert_equal \" text to\\n wrap\", format_text(\"text to wrap\", 8, 2)\n end",
" def test_format_text_none\n assert_equal \"text to wrap\", format_text(\"text to wrap\", 40)\n end",
" def test_format_text_none_indent\n assert_equal \" text to wrap\", format_text(\"text to wrap\", 40, 2)\n end",
" def test_format_text_trailing # for two spaces after .\n text = <<-TEXT\nThis line is really, really long. So long, in fact, that it is more than eighty characters long! The purpose of this line is for testing wrapping behavior because sometimes people don't wrap their text to eighty characters. Without the wrapping, the text might not look good in the RSS feed.\n TEXT",
" expected = <<-EXPECTED\nThis line is really, really long. So long, in fact, that it is more than\neighty characters long! The purpose of this line is for testing wrapping\nbehavior because sometimes people don't wrap their text to eighty characters.\nWithout the wrapping, the text might not look good in the RSS feed.\n EXPECTED",
" assert_equal expected, format_text(text, 78)\n end",
" def test_format_removes_nonprintable_characters",
" assert_equal \"text with weird .. stuff .\", format_text(\"text with weird \\x1b\\x02 stuff \\x7f\", 40)",
" end",
" def test_min3\n assert_equal 1, min3(1, 1, 1)\n assert_equal 1, min3(1, 1, 2)\n assert_equal 1, min3(1, 2, 1)\n assert_equal 1, min3(2, 1, 1)\n assert_equal 1, min3(1, 2, 2)\n assert_equal 1, min3(2, 1, 2)\n assert_equal 1, min3(2, 2, 1)\n assert_equal 1, min3(1, 2, 3)\n assert_equal 1, min3(1, 3, 2)\n assert_equal 1, min3(2, 1, 3)\n assert_equal 1, min3(2, 3, 1)\n assert_equal 1, min3(3, 1, 2)\n assert_equal 1, min3(3, 2, 1)\n end",
" def test_levenshtein_distance_add\n assert_equal 2, levenshtein_distance(\"zentest\", \"zntst\")\n assert_equal 2, levenshtein_distance(\"zntst\", \"zentest\")\n end",
" def test_levenshtein_distance_empty\n assert_equal 5, levenshtein_distance(\"abcde\", \"\")\n assert_equal 5, levenshtein_distance(\"\", \"abcde\")\n end",
" def test_levenshtein_distance_remove\n assert_equal 3, levenshtein_distance(\"zentest\", \"zentestxxx\")\n assert_equal 3, levenshtein_distance(\"zentestxxx\", \"zentest\")\n assert_equal 13, levenshtein_distance(\"cat\", \"thundercatsarego\")\n assert_equal 13, levenshtein_distance(\"thundercatsarego\", \"cat\")\n end",
" def test_levenshtein_distance_replace\n assert_equal 2, levenshtein_distance(\"zentest\", \"ZenTest\")\n assert_equal 7, levenshtein_distance(\"xxxxxxx\", \"ZenTest\")\n assert_equal 7, levenshtein_distance(\"zentest\", \"xxxxxxx\")\n end\nend"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [14, 137, 41], "buggy_code_start_loc": [13, 135, 40], "filenames": ["lib/rubygems/text.rb", "test/rubygems/test_gem_commands_query_command.rb", "test/rubygems/test_gem_text.rb"], "fixing_code_end_loc": [14, 137, 41], "fixing_code_start_loc": [13, 135, 40], "message": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:rubygems:rubygems:*:*:*:*:*:*:*:*", "matchCriteriaId": "1161B0D8-43B3-4123-BD4F-87F260AB8947", "versionEndExcluding": null, "versionEndIncluding": "2.6.12", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}, {"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": null}, {"nodes": [{"cpeMatch": [{"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_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_server_aus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D99A687E-EAE6-417E-A88E-D0082BC194CD", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_aus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B353CE99-D57C-465B-AAB0-73EF581127D1", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "9EC0D196-F7B8-4BDD-9050-779F7A7FBEE4", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.5:*:*:*:*:*:*:*", "matchCriteriaId": "A4E9DD8A-A68B-4A69-8B01-BFF92A2020A8", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_eus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "BF77CDCF-B9C9-427D-B2BF-36650FB2148C", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.4:*:*:*:*:*:*:*", "matchCriteriaId": "D5F7E11E-FB34-4467-8919-2B6BEAABF665", "versionEndExcluding": null, "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}, {"criteria": "cpe:2.3:o:redhat:enterprise_linux_server_tus:7.6:*:*:*:*:*:*:*", "matchCriteriaId": "B76AA310-FEC7-497F-AF04-C3EC1E76C4CC", "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": null}], "descriptions": [{"lang": "en", "value": "RubyGems version 2.6.12 and earlier is vulnerable to maliciously crafted gem specifications that include terminal escape characters. Printing the gem specification would execute terminal escape sequences."}, {"lang": "es", "value": "RubyGems 2.6.12 y anteriores es vulnerable a especificaciones de gemas manipuladas maliciosamente que incluyen caracteres de escapada de terminal. Imprimir la especificaci\u00f3n de las gemas ejecutar\u00eda secuencias de escapada de terminal."}], "evaluatorComment": null, "id": "CVE-2017-0899", "lastModified": "2019-10-09T23:21:09.713", "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-08-31T20:29:00.417", "references": [{"source": "support@hackerone.com", "tags": ["Patch", "Vendor Advisory"], "url": "http://blog.rubygems.org/2017/08/27/2.6.13-released.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securityfocus.com/bid/100576"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory", "VDB Entry"], "url": "http://www.securitytracker.com/id/1039249"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2017:3485"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0378"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0583"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://access.redhat.com/errata/RHSA-2018:0585"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, {"source": "support@hackerone.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/rubygems/rubygems/commit/ef0aa611effb5f54d40c7fba6e8235eb43c5a491"}, {"source": "support@hackerone.com", "tags": ["Exploit", "Patch", "Third Party Advisory"], "url": "https://hackerone.com/reports/226335"}, {"source": "support@hackerone.com", "tags": ["Mailing List", "Third Party Advisory"], "url": "https://lists.debian.org/debian-lts-announce/2018/07/msg00012.html"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://security.gentoo.org/glsa/201710-01"}, {"source": "support@hackerone.com", "tags": ["Third Party Advisory"], "url": "https://www.debian.org/security/2017/dsa-3966"}], "sourceIdentifier": "support@hackerone.com", "vendorComments": null, "vulnStatus": "Modified", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-94"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-150"}], "source": "support@hackerone.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/rubygems/rubygems/commit/1bcbc7fe637b03145401ec9c094066285934a7f1"}, "type": "CWE-94"}
| 222
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n *\t\t\tGPAC - Multimedia Framework C SDK\n *\n *\t\t\tAuthors: Jean Le Feuvre\n *\t\t\tCopyright (c) Telecom ParisTech 2005-2012\n *\n * This file is part of GPAC / MPEG2-TS sub-project\n *\n * GPAC is free software; you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation; either version 2, or (at your option)\n * any later version.\n *\n * GPAC 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 Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; see the file COPYING. If not, write to\n * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.\n *\n */",
"#include <gpac/mpegts.h>",
"\n#ifndef GPAC_DISABLE_MPEG2TS",
"#include <string.h>\n#include <gpac/constants.h>\n#include <gpac/internal/media_dev.h>\n#include <gpac/download.h>",
"\n#ifndef GPAC_DISABLE_STREAMING\n#include <gpac/internal/ietf_dev.h>\n#endif",
"\n#ifdef GPAC_CONFIG_LINUX\n#include <unistd.h>\n#endif",
"#ifdef GPAC_ENABLE_MPE\n#include <gpac/dvb_mpe.h>\n#endif",
"#ifdef GPAC_ENABLE_DSMCC\n#include <gpac/ait.h>\n#endif",
"#define DEBUG_TS_PACKET 0",
"GF_EXPORT\nconst char *gf_m2ts_get_stream_name(u32 streamType)\n{\n\tswitch (streamType) {\n\tcase GF_M2TS_VIDEO_MPEG1:\n\t\treturn \"MPEG-1 Video\";\n\tcase GF_M2TS_VIDEO_MPEG2:\n\t\treturn \"MPEG-2 Video\";\n\tcase GF_M2TS_AUDIO_MPEG1:\n\t\treturn \"MPEG-1 Audio\";\n\tcase GF_M2TS_AUDIO_MPEG2:\n\t\treturn \"MPEG-2 Audio\";\n\tcase GF_M2TS_PRIVATE_SECTION:\n\t\treturn \"Private Section\";\n\tcase GF_M2TS_PRIVATE_DATA:\n\t\treturn \"Private Data\";\n\tcase GF_M2TS_AUDIO_AAC:\n\t\treturn \"AAC Audio\";\n\tcase GF_M2TS_VIDEO_MPEG4:\n\t\treturn \"MPEG-4 Video\";\n\tcase GF_M2TS_VIDEO_H264:\n\t\treturn \"MPEG-4/H264 Video\";\n\tcase GF_M2TS_VIDEO_SVC:\n\t\treturn \"H264-SVC Video\";\n\tcase GF_M2TS_VIDEO_HEVC:\n\t\treturn \"HEVC Video\";\n\tcase GF_M2TS_VIDEO_SHVC:\n\t\treturn \"SHVC Video\";\n\tcase GF_M2TS_VIDEO_SHVC_TEMPORAL:\n\t\treturn \"SHVC Video Temporal Sublayer\";\n\tcase GF_M2TS_VIDEO_MHVC:\n\t\treturn \"MHVC Video\";\n\tcase GF_M2TS_VIDEO_MHVC_TEMPORAL:\n\t\treturn \"MHVC Video Temporal Sublayer\";",
"\tcase GF_M2TS_AUDIO_AC3:\n\t\treturn \"Dolby AC3 Audio\";\n\tcase GF_M2TS_AUDIO_DTS:\n\t\treturn \"Dolby DTS Audio\";\n\tcase GF_M2TS_SUBTITLE_DVB:\n\t\treturn \"DVB Subtitle\";\n\tcase GF_M2TS_SYSTEMS_MPEG4_PES:\n\t\treturn \"MPEG-4 SL (PES)\";\n\tcase GF_M2TS_SYSTEMS_MPEG4_SECTIONS:\n\t\treturn \"MPEG-4 SL (Section)\";\n\tcase GF_M2TS_MPE_SECTIONS:\n\t\treturn \"MPE (Section)\";",
"\tcase GF_M2TS_METADATA_PES:\n\t\treturn \"Metadata (PES)\";\n\tcase GF_M2TS_METADATA_ID3_HLS:\n\t\treturn \"ID3/HLS Metadata (PES)\";",
"\tdefault:\n\t\treturn \"Unknown\";\n\t}\n}",
"\nstatic u32 gf_m2ts_reframe_default(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Bool same_pts, unsigned char *data, u32 data_len, GF_M2TS_PESHeader *pes_hdr)\n{\n\tGF_M2TS_PES_PCK pck;\n\tpck.flags = 0;\n\tif (pes->rap) pck.flags |= GF_M2TS_PES_PCK_RAP;\n\tif (!same_pts) pck.flags |= GF_M2TS_PES_PCK_AU_START;\n\tpck.DTS = pes->DTS;\n\tpck.PTS = pes->PTS;\n\tpck.data = (char *)data;\n\tpck.data_len = data_len;\n\tpck.stream = pes;\n\tts->on_event(ts, GF_M2TS_EVT_PES_PCK, &pck);\n\t/*we consumed all data*/\n\treturn 0;\n}",
"static u32 gf_m2ts_reframe_reset(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Bool same_pts, unsigned char *data, u32 data_len, GF_M2TS_PESHeader *pes_hdr)\n{\n\tif (pes->pck_data) {\n\t\tgf_free(pes->pck_data);\n\t\tpes->pck_data = NULL;\n\t}\n\tpes->pck_data_len = pes->pck_alloc_len = 0;\n\tif (pes->prev_data) {\n\t\tgf_free(pes->prev_data);\n\t\tpes->prev_data = NULL;\n\t}\n\tpes->prev_data_len = 0;\n\tpes->pes_len = 0;\n\tpes->prev_PTS = 0;\n\tpes->reframe = NULL;\n\tpes->cc = -1;\n\tpes->temi_tc_desc_len = 0;\n\treturn 0;\n}",
"static void add_text(char **buffer, u32 *size, u32 *pos, char *msg, u32 msg_len)\n{\n\tif (!msg || !buffer) return;",
"\tif (*pos+msg_len>*size) {\n\t\t*size = *pos+msg_len-*size+256;\n\t\t*buffer = (char *)gf_realloc(*buffer, *size);\n\t}\n\tstrncpy((*buffer)+(*pos), msg, msg_len);\n\t*pos += msg_len;\n}",
"static GF_Err id3_parse_tag(char *data, u32 length, char **output, u32 *output_size, u32 *output_pos)\n{\n\tGF_BitStream *bs;\n\tu32 pos;",
"\tif ((data[0] != 'I') || (data[1] != 'D') || (data[2] != '3'))\n\t\treturn GF_NOT_SUPPORTED;",
"\tbs = gf_bs_new(data, length, GF_BITSTREAM_READ);",
"\tgf_bs_skip_bytes(bs, 3);\n\t/*u8 major = */gf_bs_read_u8(bs);\n\t/*u8 minor = */gf_bs_read_u8(bs);\n\t/*u8 unsync = */gf_bs_read_int(bs, 1);\n\t/*u8 ext_hdr = */ gf_bs_read_int(bs, 1);\n\tgf_bs_read_int(bs, 6);\n\tu32 size = gf_id3_read_size(bs);",
"\tpos = (u32) gf_bs_get_position(bs);\n\tif (size != length-pos)\n\t\tsize = length-pos;",
"\twhile (size && (gf_bs_available(bs)>=10) ) {\n\t\tu32 ftag = gf_bs_read_u32(bs);\n\t\tu32 fsize = gf_id3_read_size(bs);\n\t\t/*u16 fflags = */gf_bs_read_u16(bs);\n\t\tsize -= 10;",
"\t\t//TODO, handle more ID3 tags ?\n\t\tif (ftag==ID3V2_FRAME_TXXX) {\n\t\t\tu32 pos = (u32) gf_bs_get_position(bs);\n\t\t\tchar *text = data+pos;\n\t\t\tadd_text(output, output_size, output_pos, text, fsize);\n\t\t} else {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] ID3 tag not handled, patch welcome\\n\", gf_4cc_to_str(ftag) ) );\n\t\t}\n\t\tgf_bs_skip_bytes(bs, fsize);\n\t}\n\tgf_bs_del(bs);\n\treturn GF_OK;\n}",
"static u32 gf_m2ts_reframe_id3_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Bool same_pts, unsigned char *data, u32 data_len, GF_M2TS_PESHeader *pes_hdr)\n{\n\tchar frame_header[256];\n\tchar *output_text = NULL;\n\tu32 output_len = 0;\n\tu32 pos = 0;\n\tGF_M2TS_PES_PCK pck;\n\tpck.flags = 0;\n\tif (pes->rap) pck.flags |= GF_M2TS_PES_PCK_RAP;\n\tif (!same_pts) pck.flags |= GF_M2TS_PES_PCK_AU_START;\n\tpck.DTS = pes->DTS;\n\tpck.PTS = pes->PTS;\n\tsprintf(frame_header, LLU\" --> NEXT\\n\", pes->PTS);\n\tadd_text(&output_text, &output_len, &pos, frame_header, (u32)strlen(frame_header));\n\tid3_parse_tag((char *)data, data_len, &output_text, &output_len, &pos);\n\tadd_text(&output_text, &output_len, &pos, \"\\n\\n\", 2);\n\tpck.data = (char *)output_text;\n\tpck.data_len = pos;\n\tpck.stream = pes;\n\tts->on_event(ts, GF_M2TS_EVT_PES_PCK, &pck);\n\tgf_free(output_text);\n\t/*we consumed all data*/\n\treturn 0;\n}",
"static u32 gf_m2ts_sync(GF_M2TS_Demuxer *ts, char *data, u32 size, Bool simple_check)\n{\n\tu32 i=0;\n\t/*if first byte is sync assume we're sync*/\n\tif (simple_check && (data[i]==0x47)) return 0;",
"\twhile (i < size) {\n\t\tif (i+192 >= size) return size;\n\t\tif ((data[i]==0x47) && (data[i+188]==0x47))\n\t\t\tbreak;\n\t\tif (i+192 >= size) return size;\n\t\tif ((data[i]==0x47) && (data[i+192]==0x47)) {\n\t\t\tts->prefix_present = 1;\n\t\t\tbreak;\n\t\t}\n\t\ti++;\n\t}\n\tif (i) {\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] re-sync skipped %d bytes\\n\", i) );\n\t}\n\treturn i;\n}",
"GF_EXPORT\nBool gf_m2ts_crc32_check(u8 *data, u32 len)\n{\n\tu32 crc = gf_crc_32(data, len);\n\tu32 crc_val = GF_4CC((u8) data[len], (u8) data[len+1], (u8) data[len+2], (u8) data[len+3]);\n\treturn (crc==crc_val) ? GF_TRUE : GF_FALSE;\n}",
"\nstatic GF_M2TS_SectionFilter *gf_m2ts_section_filter_new(gf_m2ts_section_callback process_section_callback, Bool process_individual)\n{\n\tGF_M2TS_SectionFilter *sec;\n\tGF_SAFEALLOC(sec, GF_M2TS_SectionFilter);\n\tif (!sec) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] gf_m2ts_section_filter_new : OUT OF MEMORY\\n\"));\n\t\treturn NULL;\n\t}\n\tsec->cc = -1;\n\tsec->process_section = process_section_callback;\n\tsec->process_individual = process_individual;\n\treturn sec;\n}",
"static void gf_m2ts_reset_sections(GF_List *sections)\n{\n\tu32 count;\n\tGF_M2TS_Section *section;\n\t//GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Deleting sections\\n\"));",
"\tcount = gf_list_count(sections);\n\twhile (count) {\n\t\tsection = gf_list_get(sections, 0);\n\t\tgf_list_rem(sections, 0);\n\t\tif (section->data) gf_free(section->data);\n\t\tgf_free(section);\n\t\tcount--;\n\t}\n}",
"static void gf_m2ts_section_filter_reset(GF_M2TS_SectionFilter *sf)\n{\n\tif (sf->section) {\n\t\tgf_free(sf->section);\n\t\tsf->section = NULL;\n\t}\n\twhile (sf->table) {\n\t\tGF_M2TS_Table *t = sf->table;\n\t\tsf->table = t->next;\n\t\tgf_m2ts_reset_sections(t->sections);\n\t\tgf_list_del(t->sections);\n\t\tgf_free(t);\n\t}\n\tsf->cc = -1;\n\tsf->length = sf->received = 0;\n\tsf->demux_restarted = 1;",
"}\nstatic void gf_m2ts_section_filter_del(GF_M2TS_SectionFilter *sf)\n{\n\tgf_m2ts_section_filter_reset(sf);\n\tgf_free(sf);\n}",
"\nstatic void gf_m2ts_metadata_descriptor_del(GF_M2TS_MetadataDescriptor *metad)\n{\n\tif (metad) {\n\t\tif (metad->service_id_record) gf_free(metad->service_id_record);\n\t\tif (metad->decoder_config) gf_free(metad->decoder_config);\n\t\tif (metad->decoder_config_id) gf_free(metad->decoder_config_id);\n\t\tgf_free(metad);\n\t}\n}",
"GF_EXPORT\nvoid gf_m2ts_es_del(GF_M2TS_ES *es, GF_M2TS_Demuxer *ts)\n{\n\tgf_list_del_item(es->program->streams, es);",
"\tif (es->flags & GF_M2TS_ES_IS_SECTION) {\n\t\tGF_M2TS_SECTION_ES *ses = (GF_M2TS_SECTION_ES *)es;\n\t\tif (ses->sec) gf_m2ts_section_filter_del(ses->sec);",
"#ifdef GPAC_ENABLE_MPE\n\t\tif (es->flags & GF_M2TS_ES_IS_MPE)\n\t\t\tgf_dvb_mpe_section_del(es);\n#endif",
"\t} else if (es->pid!=es->program->pmt_pid) {\n\t\tGF_M2TS_PES *pes = (GF_M2TS_PES *)es;",
"\t\tif ((pes->flags & GF_M2TS_INHERIT_PCR) && ts->ess[es->program->pcr_pid]==es)\n\t\t\tts->ess[es->program->pcr_pid] = NULL;",
"\t\tif (pes->pck_data) gf_free(pes->pck_data);\n\t\tif (pes->prev_data) gf_free(pes->prev_data);\n\t\tif (pes->buf) gf_free(pes->buf);\n\t\tif (pes->reassemble_buf) gf_free(pes->reassemble_buf);\n\t\tif (pes->temi_tc_desc) gf_free(pes->temi_tc_desc);",
"\t\tif (pes->metadata_descriptor) gf_m2ts_metadata_descriptor_del(pes->metadata_descriptor);",
"\t}\n\tif (es->slcfg) gf_free(es->slcfg);\n\tgf_free(es);\n}",
"static void gf_m2ts_reset_sdt(GF_M2TS_Demuxer *ts)\n{\n\twhile (gf_list_count(ts->SDTs)) {\n\t\tGF_M2TS_SDT *sdt = (GF_M2TS_SDT *)gf_list_last(ts->SDTs);\n\t\tgf_list_rem_last(ts->SDTs);\n\t\tif (sdt->provider) gf_free(sdt->provider);\n\t\tif (sdt->service) gf_free(sdt->service);\n\t\tgf_free(sdt);\n\t}\n}",
"GF_EXPORT\nGF_M2TS_SDT *gf_m2ts_get_sdt_info(GF_M2TS_Demuxer *ts, u32 program_id)\n{\n\tu32 i;\n\tfor (i=0; i<gf_list_count(ts->SDTs); i++) {\n\t\tGF_M2TS_SDT *sdt = (GF_M2TS_SDT *)gf_list_get(ts->SDTs, i);\n\t\tif (sdt->service_id==program_id) return sdt;\n\t}\n\treturn NULL;\n}",
"static void gf_m2ts_section_complete(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter *sec, GF_M2TS_SECTION_ES *ses)\n{\n\t//seek mode, only process PAT and PMT\n\tif (ts->seek_mode && (sec->section[0] != GF_M2TS_TABLE_ID_PAT) && (sec->section[0] != GF_M2TS_TABLE_ID_PMT)) {\n\t\t/*clean-up (including broken sections)*/\n\t\tif (sec->section) gf_free(sec->section);\n\t\tsec->section = NULL;\n\t\tsec->length = sec->received = 0;\n\t\treturn;\n\t}",
"\tif (!sec->process_section) {\n\t\tif ((ts->on_event && (sec->section[0]==GF_M2TS_TABLE_ID_AIT)) ) {\n#ifdef GPAC_ENABLE_DSMCC\n\t\t\tGF_M2TS_SL_PCK pck;\n\t\t\tpck.data_len = sec->length;\n\t\t\tpck.data = sec->section;\n\t\t\tpck.stream = (GF_M2TS_ES *)ses;\n\t\t\t//ts->on_event(ts, GF_M2TS_EVT_AIT_FOUND, &pck);\n\t\t\ton_ait_section(ts, GF_M2TS_EVT_AIT_FOUND, &pck);\n#endif\n\t\t} else if ((ts->on_event && (sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_ENCAPSULATED_DATA\t|| sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_UN_MESSAGE ||\n\t\t sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGE || sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_STREAM_DESCRIPTION || sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_PRIVATE)) ) {",
"#ifdef GPAC_ENABLE_DSMCC\n\t\t\tGF_M2TS_SL_PCK pck;\n\t\t\tpck.data_len = sec->length;\n\t\t\tpck.data = sec->section;\n\t\t\tpck.stream = (GF_M2TS_ES *)ses;\n\t\t\ton_dsmcc_section(ts,GF_M2TS_EVT_DSMCC_FOUND,&pck);\n\t\t\t//ts->on_event(ts, GF_M2TS_EVT_DSMCC_FOUND, &pck);\n#endif\n\t\t}\n#ifdef GPAC_ENABLE_MPE\n\t\telse if (ts->on_mpe_event && ((ses && (ses->flags & GF_M2TS_EVT_DVB_MPE)) || (sec->section[0]==GF_M2TS_TABLE_ID_INT)) ) {\n\t\t\tGF_M2TS_SL_PCK pck;\n\t\t\tpck.data_len = sec->length;\n\t\t\tpck.data = sec->section;\n\t\t\tpck.stream = (GF_M2TS_ES *)ses;\n\t\t\tts->on_mpe_event(ts, GF_M2TS_EVT_DVB_MPE, &pck);\n\t\t}\n#endif\n\t\telse if (ts->on_event) {\n\t\t\tGF_M2TS_SL_PCK pck;\n\t\t\tpck.data_len = sec->length;\n\t\t\tpck.data = sec->section;\n\t\t\tpck.stream = (GF_M2TS_ES *)ses;\n\t\t\tts->on_event(ts, GF_M2TS_EVT_DVB_GENERAL, &pck);\n\t\t}\n\t} else {\n\t\tBool has_syntax_indicator;\n\t\tu8 table_id;\n\t\tu16 extended_table_id;\n\t\tu32 status, section_start, i;\n\t\tGF_M2TS_Table *t, *prev_t;\n\t\tunsigned char *data;\n\t\tBool section_valid = 0;",
"\t\tstatus = 0;\n\t\t/*parse header*/\n\t\tdata = (u8 *)sec->section;",
"\t\t/*look for proper table*/\n\t\ttable_id = data[0];",
"\t\tif (ts->on_event) {\n\t\t\tswitch (table_id) {\n\t\t\tcase GF_M2TS_TABLE_ID_PAT:\n\t\t\tcase GF_M2TS_TABLE_ID_SDT_ACTUAL:\n\t\t\tcase GF_M2TS_TABLE_ID_PMT:\n\t\t\tcase GF_M2TS_TABLE_ID_NIT_ACTUAL:\n\t\t\tcase GF_M2TS_TABLE_ID_TDT:\n\t\t\tcase GF_M2TS_TABLE_ID_TOT:\n\t\t\t{\n\t\t\t\tGF_M2TS_SL_PCK pck;\n\t\t\t\tpck.data_len = sec->length;\n\t\t\t\tpck.data = sec->section;\n\t\t\t\tpck.stream = (GF_M2TS_ES *)ses;\n\t\t\t\tts->on_event(ts, GF_M2TS_EVT_DVB_GENERAL, &pck);\n\t\t\t}\n\t\t\t}\n\t\t}",
"\t\thas_syntax_indicator = (data[1] & 0x80) ? 1 : 0;\n\t\tif (has_syntax_indicator) {\n\t\t\textended_table_id = (data[3]<<8) | data[4];\n\t\t} else {\n\t\t\textended_table_id = 0;\n\t\t}",
"\t\tprev_t = NULL;\n\t\tt = sec->table;\n\t\twhile (t) {\n\t\t\tif ((t->table_id==table_id) && (t->ex_table_id == extended_table_id)) break;\n\t\t\tprev_t = t;\n\t\t\tt = t->next;\n\t\t}",
"\t\t/*create table*/\n\t\tif (!t) {\n\t\t\tGF_SAFEALLOC(t, GF_M2TS_Table);\n\t\t\tif (!t) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Fail to alloc table %d %d\\n\", table_id, extended_table_id));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Creating table %d %d\\n\", table_id, extended_table_id));\n\t\t\tt->table_id = table_id;\n\t\t\tt->ex_table_id = extended_table_id;\n\t\t\tt->last_version_number = 0xFF;\n\t\t\tt->sections = gf_list_new();\n\t\t\tif (prev_t) prev_t->next = t;\n\t\t\telse sec->table = t;\n\t\t}",
"\t\tif (has_syntax_indicator) {\n\t\t\tif (sec->length < 4) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] corrupted section length %d less than CRC \\n\", sec->length));\n\t\t\t} else {\n\t\t\t\t/*remove crc32*/\n\t\t\t\tsec->length -= 4;\n\t\t\t\tif (gf_m2ts_crc32_check((char *)data, sec->length)) {\n\t\t\t\t\ts32 cur_sec_num;\n\t\t\t\t\tt->version_number = (data[5] >> 1) & 0x1f;\n\t\t\t\t\tif (t->last_section_number && t->section_number && (t->version_number != t->last_version_number)) {\n\t\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] table transmission interrupted: previous table (v=%d) %d/%d sections - new table (v=%d) %d/%d sections\\n\", t->last_version_number, t->section_number, t->last_section_number, t->version_number, data[6] + 1, data[7] + 1) );\n\t\t\t\t\t\tgf_m2ts_reset_sections(t->sections);\n\t\t\t\t\t\tt->section_number = 0;\n\t\t\t\t\t}",
"\t\t\t\t\tt->current_next_indicator = (data[5] & 0x1) ? 1 : 0;\n\t\t\t\t\t/*add one to section numbers to detect if we missed or not the first section in the table*/\n\t\t\t\t\tcur_sec_num = data[6] + 1;\n\t\t\t\t\tt->last_section_number = data[7] + 1;\n\t\t\t\t\tsection_start = 8;\n\t\t\t\t\t/*we missed something*/\n\t\t\t\t\tif (!sec->process_individual && t->section_number + 1 != cur_sec_num) {\n\t\t\t\t\t\t/* TODO - Check how to handle sections when the first complete section does\n\t\t\t\t\t\t not have its sec num 0 */\n\t\t\t\t\t\tsection_valid = 0;\n\t\t\t\t\t\tif (t->is_init) {\n\t\t\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] corrupted table (lost section %d)\\n\", cur_sec_num ? cur_sec_num-1 : 31) );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsection_valid = 1;\n\t\t\t\t\t\tt->section_number = cur_sec_num;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] corrupted section (CRC32 failed)\\n\"));\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tsection_valid = 1;\n\t\t\tsection_start = 3;\n\t\t}\n\t\t/*process section*/\n\t\tif (section_valid) {\n\t\t\tGF_M2TS_Section *section;",
"\t\t\tGF_SAFEALLOC(section, GF_M2TS_Section);\n\t\t\tif (!section) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Fail to create section\\n\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsection->data_size = sec->length - section_start;\n\t\t\tsection->data = (unsigned char*)gf_malloc(sizeof(unsigned char)*section->data_size);\n\t\t\tmemcpy(section->data, sec->section + section_start, sizeof(unsigned char)*section->data_size);\n\t\t\tgf_list_add(t->sections, section);",
"\t\t\tif (t->section_number == 1) {\n\t\t\t\tstatus |= GF_M2TS_TABLE_START;\n\t\t\t\tif (t->last_version_number == t->version_number) {\n\t\t\t\t\tt->is_repeat = 1;\n\t\t\t\t} else {\n\t\t\t\t\tt->is_repeat = 0;\n\t\t\t\t}\n\t\t\t\t/*only update version number in the first section of the table*/\n\t\t\t\tt->last_version_number = t->version_number;\n\t\t\t}",
"\t\t\tif (t->is_init) {\n\t\t\t\tif (t->is_repeat) {\n\t\t\t\t\tstatus |= GF_M2TS_TABLE_REPEAT;\n\t\t\t\t} else {\n\t\t\t\t\tstatus |= GF_M2TS_TABLE_UPDATE;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstatus |= GF_M2TS_TABLE_FOUND;\n\t\t\t}",
"\t\t\tif (t->last_section_number == t->section_number) {\n\t\t\t\tu32 table_size;",
"\t\t\t\tstatus |= GF_M2TS_TABLE_END;",
"\t\t\t\ttable_size = 0;\n\t\t\t\tfor (i=0; i<gf_list_count(t->sections); i++) {\n\t\t\t\t\tGF_M2TS_Section *section = gf_list_get(t->sections, i);\n\t\t\t\t\ttable_size += section->data_size;\n\t\t\t\t}\n\t\t\t\tif (t->is_repeat) {\n\t\t\t\t\tif (t->table_size != table_size) {\n\t\t\t\t\t\tstatus |= GF_M2TS_TABLE_UPDATE;\n\t\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Repeated section found with different sizes (old table %d bytes, new table %d bytes)\\n\", t->table_size, table_size) );",
"\t\t\t\t\t\tt->table_size = table_size;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tt->table_size = table_size;\n\t\t\t\t}",
"\t\t\t\tt->is_init = 1;\n\t\t\t\t/*reset section number*/\n\t\t\t\tt->section_number = 0;",
"\t\t\t\tt->is_repeat = 0;",
"\t\t\t}",
"\t\t\tif (sec->process_individual) {\n\t\t\t\t/*send each section of the table and not the aggregated table*/\n\t\t\t\tif (sec->process_section)\n\t\t\t\t\tsec->process_section(ts, ses, t->sections, t->table_id, t->ex_table_id, t->version_number, (u8) (t->last_section_number - 1), status);",
"\t\t\t\tgf_m2ts_reset_sections(t->sections);\n\t\t\t} else {\n\t\t\t\tif (status&GF_M2TS_TABLE_END) {\n\t\t\t\t\tif (sec->process_section)\n\t\t\t\t\t\tsec->process_section(ts, ses, t->sections, t->table_id, t->ex_table_id, t->version_number, (u8) (t->last_section_number - 1), status);",
"\t\t\t\t\tgf_m2ts_reset_sections(t->sections);\n\t\t\t\t}\n\t\t\t}",
"\t\t} else {\n\t\t\tsec->cc = -1;\n\t\t\tt->section_number = 0;\n\t\t}\n\t}\n\t/*clean-up (including broken sections)*/\n\tif (sec->section) gf_free(sec->section);\n\tsec->section = NULL;\n\tsec->length = sec->received = 0;\n}",
"static Bool gf_m2ts_is_long_section(u8 table_id)\n{\n\tswitch (table_id) {\n\tcase GF_M2TS_TABLE_ID_MPEG4_BIFS:\n\tcase GF_M2TS_TABLE_ID_MPEG4_OD:\n\tcase GF_M2TS_TABLE_ID_INT:\n\tcase GF_M2TS_TABLE_ID_EIT_ACTUAL_PF:\n\tcase GF_M2TS_TABLE_ID_EIT_OTHER_PF:\n\tcase GF_M2TS_TABLE_ID_ST:\n\tcase GF_M2TS_TABLE_ID_SIT:\n\tcase GF_M2TS_TABLE_ID_DSM_CC_PRIVATE:\n\tcase GF_M2TS_TABLE_ID_MPE_FEC:\n\tcase GF_M2TS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGE:\n\tcase GF_M2TS_TABLE_ID_DSM_CC_UN_MESSAGE:\n\t\treturn 1;\n\tdefault:\n\t\tif (table_id >= GF_M2TS_TABLE_ID_EIT_SCHEDULE_MIN && table_id <= GF_M2TS_TABLE_ID_EIT_SCHEDULE_MAX)\n\t\t\treturn 1;\n\t\telse\n\t\t\treturn 0;\n\t}\n}",
"static u32 gf_m2ts_get_section_length(char byte0, char byte1, char byte2)\n{\n\tu32 length;\n\tif (gf_m2ts_is_long_section(byte0)) {\n\t\tlength = 3 + ( ((((u32)byte1)<<8) | (byte2&0xff)) & 0xfff );\n\t} else {\n\t\tlength = 3 + ( ((((u32)byte1)<<8) | (byte2&0xff)) & 0x3ff );\n\t}\n\treturn length;\n}",
"static void gf_m2ts_gather_section(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter *sec, GF_M2TS_SECTION_ES *ses, GF_M2TS_Header *hdr, unsigned char *data, u32 data_size)\n{\n\tu32 payload_size = data_size;\n\tu8 expect_cc = (sec->cc<0) ? hdr->continuity_counter : (sec->cc + 1) & 0xf;\n\tBool disc = (expect_cc == hdr->continuity_counter) ? 0 : 1;\n\tsec->cc = expect_cc;",
"\t/*may happen if hdr->adaptation_field=2 no payload in TS packet*/\n\tif (!data_size) return;",
"\tif (hdr->payload_start) {\n\t\tu32 ptr_field;",
"\t\tptr_field = data[0];\n\t\tif (ptr_field+1>data_size) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Invalid section start (@ptr_field=%d, @data_size=%d)\\n\", ptr_field, data_size) );\n\t\t\treturn;\n\t\t}",
"\t\t/*end of previous section*/\n\t\tif (!sec->length && sec->received) {\n\t\t\t/* the length of the section could not be determined from the previous TS packet because we had only 1 or 2 bytes */\n\t\t\tif (sec->received == 1)\n\t\t\t\tsec->length = gf_m2ts_get_section_length(sec->section[0], data[1], data[2]);\n\t\t\telse /* (sec->received == 2) */\n\t\t\t\tsec->length = gf_m2ts_get_section_length(sec->section[0], sec->section[1], data[1]);\n\t\t\tsec->section = (char*)gf_realloc(sec->section, sizeof(char)*sec->length);\n\t\t}",
"\t\tif (sec->length && sec->received + ptr_field >= sec->length) {\n\t\t\tu32 len = sec->length - sec->received;\n\t\t\tmemcpy(sec->section + sec->received, data+1, sizeof(char)*len);\n\t\t\tsec->received += len;\n\t\t\tif (ptr_field > len)\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Invalid pointer field (@ptr_field=%d, @remaining=%d)\\n\", ptr_field, len) );\n\t\t\tgf_m2ts_section_complete(ts, sec, ses);\n\t\t}\n\t\tdata += ptr_field+1;\n\t\tdata_size -= ptr_field+1;\n\t\tpayload_size -= ptr_field+1;",
"aggregated_section:",
"\t\tif (sec->section) gf_free(sec->section);\n\t\tsec->length = sec->received = 0;\n\t\tsec->section = (char*)gf_malloc(sizeof(char)*data_size);\n\t\tmemcpy(sec->section, data, sizeof(char)*data_size);\n\t\tsec->received = data_size;\n\t} else if (disc) {\n\t\tif (sec->section) gf_free(sec->section);\n\t\tsec->section = NULL;\n\t\tsec->received = sec->length = 0;\n\t\treturn;\n\t} else if (!sec->section) {\n\t\treturn;\n\t} else {\n\t\tif (sec->length && sec->received+data_size > sec->length)\n\t\t\tdata_size = sec->length - sec->received;",
"\t\tif (sec->length) {\n\t\t\tmemcpy(sec->section + sec->received, data, sizeof(char)*data_size);\n\t\t} else {\n\t\t\tsec->section = (char*)gf_realloc(sec->section, sizeof(char)*(sec->received+data_size));\n\t\t\tmemcpy(sec->section + sec->received, data, sizeof(char)*data_size);\n\t\t}\n\t\tsec->received += data_size;\n\t}\n\t/*alloc final buffer*/\n\tif (!sec->length && (sec->received >= 3)) {\n\t\tsec->length = gf_m2ts_get_section_length(sec->section[0], sec->section[1], sec->section[2]);\n\t\tsec->section = (char*)gf_realloc(sec->section, sizeof(char)*sec->length);",
"\t\tif (sec->received > sec->length) {\n\t\t\tdata_size -= sec->received - sec->length;\n\t\t\tsec->received = sec->length;\n\t\t}\n\t}\n\tif (!sec->length || sec->received < sec->length) return;",
"\t/*OK done*/\n\tgf_m2ts_section_complete(ts, sec, ses);",
"\tif (payload_size > data_size) {\n\t\tdata += data_size;\n\t\t/* detect padding after previous section */\n\t\tif (data[0] != 0xFF) {\n\t\t\tdata_size = payload_size - data_size;\n\t\t\tpayload_size = data_size;\n\t\t\tgoto aggregated_section;\n\t\t}\n\t}\n}",
"static void gf_m2ts_process_sdt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tu32 pos, evt_type;\n\tu32 nb_sections;\n\tu32 data_size;\n\tunsigned char *data;\n\tGF_M2TS_Section *section;",
"\t/*wait for the last section */\n\tif (!(status&GF_M2TS_TABLE_END)) return;",
"\t/*skip if already received*/\n\tif (status&GF_M2TS_TABLE_REPEAT) {\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_SDT_REPEAT, NULL);\n\t\treturn;\n\t}",
"\tif (table_id != GF_M2TS_TABLE_ID_SDT_ACTUAL) {\n\t\treturn;\n\t}",
"\tgf_m2ts_reset_sdt(ts);",
"\tnb_sections = gf_list_count(sections);\n\tif (nb_sections > 1) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] SDT on multiple sections not supported\\n\"));\n\t}",
"\tsection = (GF_M2TS_Section *)gf_list_get(sections, 0);\n\tdata = section->data;\n\tdata_size = section->data_size;",
"\t//orig_net_id = (data[0] << 8) | data[1];\n\tpos = 3;\n\twhile (pos < data_size) {\n\t\tGF_M2TS_SDT *sdt;\n\t\tu32 descs_size, d_pos, ulen;",
"\t\tGF_SAFEALLOC(sdt, GF_M2TS_SDT);\n\t\tif (!sdt) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Fail to create SDT\\n\"));\n\t\t\treturn;\n\t\t}\n\t\tgf_list_add(ts->SDTs, sdt);",
"\t\tsdt->service_id = (data[pos]<<8) + data[pos+1];\n\t\tsdt->EIT_schedule = (data[pos+2] & 0x2) ? 1 : 0;\n\t\tsdt->EIT_present_following = (data[pos+2] & 0x1);\n\t\tsdt->running_status = (data[pos+3]>>5) & 0x7;\n\t\tsdt->free_CA_mode = (data[pos+3]>>4) & 0x1;\n\t\tdescs_size = ((data[pos+3]&0xf)<<8) | data[pos+4];\n\t\tpos += 5;",
"\t\td_pos = 0;\n\t\twhile (d_pos < descs_size) {\n\t\t\tu8 d_tag = data[pos+d_pos];\n\t\t\tu8 d_len = data[pos+d_pos+1];",
"\t\t\tswitch (d_tag) {\n\t\t\tcase GF_M2TS_DVB_SERVICE_DESCRIPTOR:\n\t\t\t\tif (sdt->provider) gf_free(sdt->provider);\n\t\t\t\tsdt->provider = NULL;\n\t\t\t\tif (sdt->service) gf_free(sdt->service);\n\t\t\t\tsdt->service = NULL;",
"\t\t\t\td_pos+=2;\n\t\t\t\tsdt->service_type = data[pos+d_pos];\n\t\t\t\tulen = data[pos+d_pos+1];\n\t\t\t\td_pos += 2;\n\t\t\t\tsdt->provider = (char*)gf_malloc(sizeof(char)*(ulen+1));\n\t\t\t\tmemcpy(sdt->provider, data+pos+d_pos, sizeof(char)*ulen);\n\t\t\t\tsdt->provider[ulen] = 0;\n\t\t\t\td_pos += ulen;",
"\t\t\t\tulen = data[pos+d_pos];\n\t\t\t\td_pos += 1;\n\t\t\t\tsdt->service = (char*)gf_malloc(sizeof(char)*(ulen+1));\n\t\t\t\tmemcpy(sdt->service, data+pos+d_pos, sizeof(char)*ulen);\n\t\t\t\tsdt->service[ulen] = 0;\n\t\t\t\td_pos += ulen;\n\t\t\t\tbreak;",
"\t\t\tdefault:\n\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Skipping descriptor (0x%x) not supported\\n\", d_tag));\n\t\t\t\td_pos += d_len;\n\t\t\t\tif (d_len == 0) d_pos = descs_size;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tpos += descs_size;\n\t}\n\tevt_type = GF_M2TS_EVT_SDT_FOUND;\n\tif (ts->on_event) ts->on_event(ts, evt_type, NULL);\n}",
"static void gf_m2ts_process_mpeg4section(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *es, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tGF_M2TS_SL_PCK sl_pck;\n\tu32 nb_sections, i;\n\tGF_M2TS_Section *section;",
"\t/*skip if already received*/\n\tif (status & GF_M2TS_TABLE_REPEAT)\n\t\tif (!(es->flags & GF_M2TS_ES_SEND_REPEATED_SECTIONS))\n\t\t\treturn;",
"\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Sections for PID %d\\n\", es->pid) );\n\t/*send all sections (eg SL-packets)*/\n\tnb_sections = gf_list_count(sections);\n\tfor (i=0; i<nb_sections; i++) {\n\t\tsection = (GF_M2TS_Section *)gf_list_get(sections, i);\n\t\tsl_pck.data = (char *)section->data;\n\t\tsl_pck.data_len = section->data_size;\n\t\tsl_pck.stream = (GF_M2TS_ES *)es;\n\t\tsl_pck.version_number = version_number;\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_SL_PCK, &sl_pck);\n\t}\n}",
"static void gf_m2ts_process_nit(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *nit_es, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] NIT table processing (not yet implemented)\"));\n}",
"",
"\nstatic void gf_m2ts_process_tdt_tot(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *tdt_tot_es, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tunsigned char *data;\n\tu32 data_size, nb_sections;\n\tu32 date, yp, mp, k;\n\tGF_M2TS_Section *section;\n\tGF_M2TS_TDT_TOT *time_table;\n\tconst char *table_name;",
"\t/*wait for the last section */\n\tif ( !(status & GF_M2TS_TABLE_END) )\n\t\treturn;",
"\tswitch (table_id) {\n\tcase GF_M2TS_TABLE_ID_TDT:\n\t\ttable_name = \"TDT\";\n\t\tbreak;\n\tcase GF_M2TS_TABLE_ID_TOT:\n\t\ttable_name = \"TOT\";\n\t\tbreak;\n\tdefault:\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Unimplemented table_id %u for PID %u\\n\", table_id, GF_M2TS_PID_TDT_TOT_ST));\n\t\treturn;\n\t}",
"\tnb_sections = gf_list_count(sections);\n\tif (nb_sections > 1) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] %s on multiple sections not supported\\n\", table_name));\n\t}",
"\tsection = (GF_M2TS_Section *)gf_list_get(sections, 0);\n\tdata = section->data;\n\tdata_size = section->data_size;",
"\t/*TOT only contains 40 bits of UTC_time; TDT add descriptors and a CRC*/\n\tif ((table_id==GF_M2TS_TABLE_ID_TDT) && (data_size != 5)) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Corrupted TDT size\\n\", table_name));\n\t}\n\tGF_SAFEALLOC(time_table, GF_M2TS_TDT_TOT);\n\tif (!time_table) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Fail to alloc DVB time table\\n\"));\n\t\treturn;\n\t}",
"\t/*UTC_time - see annex C of DVB-SI ETSI EN 300468*/\n/* decodes an Modified Julian Date (MJD) into a Co-ordinated Universal Time (UTC)\nSee annex C of DVB-SI ETSI EN 300468 */\n\tdate = data[0]*256 + data[1];\n\typ = (u32)((date - 15078.2)/365.25);\n\tmp = (u32)((date - 14956.1 - (u32)(yp * 365.25))/30.6001);\n\ttime_table->day = (u32)(date - 14956 - (u32)(yp * 365.25) - (u32)(mp * 30.6001));\n\tif (mp == 14 || mp == 15) k = 1;\n\telse k = 0;\n\ttime_table->year = yp + k + 1900;\n\ttime_table->month = mp - 1 - k*12;",
"\ttime_table->hour = 10*((data[2]&0xf0)>>4) + (data[2]&0x0f);\n\ttime_table->minute = 10*((data[3]&0xf0)>>4) + (data[3]&0x0f);\n\ttime_table->second = 10*((data[4]&0xf0)>>4) + (data[4]&0x0f);\n\tassert(time_table->hour<24 && time_table->minute<60 && time_table->second<60);\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Stream UTC time is %u/%02u/%02u %02u:%02u:%02u\\n\", time_table->year, time_table->month, time_table->day, time_table->hour, time_table->minute, time_table->second));",
"\tswitch (table_id) {\n\tcase GF_M2TS_TABLE_ID_TDT:\n\t\tif (ts->TDT_time) gf_free(ts->TDT_time);\n\t\tts->TDT_time = time_table;\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TDT, time_table);\n\t\tbreak;\n\tcase GF_M2TS_TABLE_ID_TOT:\n#if 0\n\t{\n\t\tu32 pos, loop_len;\n\t\tloop_len = ((data[5]&0x0f) << 8) | (data[6] & 0xff);\n\t\tdata += 7;\n\t\tpos = 0;\n\t\twhile (pos < loop_len) {\n\t\t\tu8 tag = data[pos];\n\t\t\tpos += 2;\n\t\t\tif (tag == GF_M2TS_DVB_LOCAL_TIME_OFFSET_DESCRIPTOR) {\n\t\t\t\tchar tmp_time[10];\n\t\t\t\tu16 offset_hours, offset_minutes;\n\t\t\t\tnow->country_code[0] = data[pos];\n\t\t\t\tnow->country_code[1] = data[pos+1];\n\t\t\t\tnow->country_code[2] = data[pos+2];\n\t\t\t\tnow->country_region_id = data[pos+3]>>2;",
"\t\t\t\tsprintf(tmp_time, \"%02x\", data[pos+4]);\n\t\t\t\toffset_hours = atoi(tmp_time);\n\t\t\t\tsprintf(tmp_time, \"%02x\", data[pos+5]);\n\t\t\t\toffset_minutes = atoi(tmp_time);\n\t\t\t\tnow->local_time_offset_seconds = (offset_hours * 60 + offset_minutes) * 60;\n\t\t\t\tif (data[pos+3] & 1) now->local_time_offset_seconds *= -1;",
"\t\t\t\tdvb_decode_mjd_to_unix_time(data+pos+6, &now->unix_next_toc);",
"\t\t\t\tsprintf(tmp_time, \"%02x\", data[pos+11]);\n\t\t\t\toffset_hours = atoi(tmp_time);\n\t\t\t\tsprintf(tmp_time, \"%02x\", data[pos+12]);\n\t\t\t\toffset_minutes = atoi(tmp_time);\n\t\t\t\tnow->next_time_offset_seconds = (offset_hours * 60 + offset_minutes) * 60;\n\t\t\t\tif (data[pos+3] & 1) now->next_time_offset_seconds *= -1;\n\t\t\t\tpos+= 13;\n\t\t\t}\n\t\t}\n\t\t/*TODO: check lengths are ok*/\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TOT, time_table);\n\t}\n#endif\n\t/*check CRC32*/\n\tif (ts->tdt_tot->length<4) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] corrupted %s table (less than 4 bytes but CRC32 should be present\\n\", table_name));\n\t\tgoto error_exit;\n\t}\n\tif (!gf_m2ts_crc32_check(ts->tdt_tot->section, ts->tdt_tot->length-4)) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] corrupted %s table (CRC32 failed)\\n\", table_name));\n\t\tgoto error_exit;\n\t}\n\tif (ts->TDT_time) gf_free(ts->TDT_time);\n\tts->TDT_time = time_table;\n\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TOT, time_table);\n\tbreak;\n\tdefault:\n\t\tassert(0);\n\t\tgoto error_exit;\n\t}",
"\treturn; /*success*/",
"error_exit:\n\tgf_free(time_table);\n\treturn;\n}",
"static GF_M2TS_MetadataPointerDescriptor *gf_m2ts_read_metadata_pointer_descriptor(GF_BitStream *bs, u32 length)\n{\n\tu32 size;\n\tGF_M2TS_MetadataPointerDescriptor *d;\n\tGF_SAFEALLOC(d, GF_M2TS_MetadataPointerDescriptor);\n\tif (!d) return NULL;\n\td->application_format = gf_bs_read_u16(bs);\n\tsize = 2;\n\tif (d->application_format == 0xFFFF) {\n\t\td->application_format_identifier = gf_bs_read_u32(bs);\n\t\tsize += 4;\n\t}\n\td->format = gf_bs_read_u8(bs);\n\tsize += 1;\n\tif (d->format == 0xFF) {\n\t\td->format_identifier = gf_bs_read_u32(bs);\n\t\tsize += 4;\n\t}\n\td->service_id = gf_bs_read_u8(bs);\n\td->locator_record_flag = (gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE);\n\td->carriage_flag = (enum metadata_carriage)gf_bs_read_int(bs, 2);\n\tgf_bs_read_int(bs, 5); /*reserved */\n\tsize += 2;\n\tif (d->locator_record_flag) {\n\t\td->locator_length = gf_bs_read_u8(bs);\n\t\td->locator_data = (char *)gf_malloc(d->locator_length);\n\t\tsize += 1 + d->locator_length;\n\t\tgf_bs_read_data(bs, d->locator_data, d->locator_length);\n\t}\n\tif (d->carriage_flag != 3) {\n\t\td->program_number = gf_bs_read_u16(bs);\n\t\tsize += 2;\n\t}\n\tif (d->carriage_flag == 1) {\n\t\td->ts_location = gf_bs_read_u16(bs);\n\t\td->ts_id = gf_bs_read_u16(bs);\n\t\tsize += 4;\n\t}\n\tif (length-size > 0) {\n\t\td->data_size = length-size;\n\t\td->data = (char *)gf_malloc(d->data_size);\n\t\tgf_bs_read_data(bs, d->data, d->data_size);\n\t}\n\treturn d;\n}",
"static void gf_m2ts_metadata_pointer_descriptor_del(GF_M2TS_MetadataPointerDescriptor *metapd)\n{\n\tif (metapd) {\n\t\tif (metapd->locator_data) gf_free(metapd->locator_data);\n\t\tif (metapd->data) gf_free(metapd->data);\n\t\tgf_free(metapd);\n\t}\n}",
"static GF_M2TS_MetadataDescriptor *gf_m2ts_read_metadata_descriptor(GF_BitStream *bs, u32 length)\n{\n\tu32 size;\n\tGF_M2TS_MetadataDescriptor *d;\n\tGF_SAFEALLOC(d, GF_M2TS_MetadataDescriptor);\n\tif (!d) return NULL;\n\td->application_format = gf_bs_read_u16(bs);\n\tsize = 2;\n\tif (d->application_format == 0xFFFF) {\n\t\td->application_format_identifier = gf_bs_read_u32(bs);\n\t\tsize += 4;\n\t}\n\td->format = gf_bs_read_u8(bs);\n\tsize += 1;\n\tif (d->format == 0xFF) {\n\t\td->format_identifier = gf_bs_read_u32(bs);\n\t\tsize += 4;\n\t}\n\td->service_id = gf_bs_read_u8(bs);\n\td->decoder_config_flags = gf_bs_read_int(bs, 3);\n\td->dsmcc_flag = (gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE);\n\tgf_bs_read_int(bs, 4); /* reserved */\n\tsize += 2;\n\tif (d->dsmcc_flag) {\n\t\td->service_id_record_length = gf_bs_read_u8(bs);\n\t\td->service_id_record = (char *)gf_malloc(d->service_id_record_length);\n\t\tsize += 1 + d->service_id_record_length;\n\t\tgf_bs_read_data(bs, d->service_id_record, d->service_id_record_length);\n\t}\n\tif (d->decoder_config_flags == 1) {\n\t\td->decoder_config_length = gf_bs_read_u8(bs);\n\t\td->decoder_config = (char *)gf_malloc(d->decoder_config_length);\n\t\tsize += 1 + d->decoder_config_length;\n\t\tgf_bs_read_data(bs, d->decoder_config, d->decoder_config_length);\n\t}\n\tif (d->decoder_config_flags == 3) {\n\t\td->decoder_config_id_length = gf_bs_read_u8(bs);\n\t\td->decoder_config_id = (char *)gf_malloc(d->decoder_config_id_length);\n\t\tsize += 1 + d->decoder_config_id_length;\n\t\tgf_bs_read_data(bs, d->decoder_config_id, d->decoder_config_id_length);\n\t}\n\tif (d->decoder_config_flags == 4) {\n\t\td->decoder_config_service_id = gf_bs_read_u8(bs);\n\t\tsize++;\n\t}\n\treturn d;\n}",
"\nstatic void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tu32 info_length, pos, desc_len, evt_type, nb_es,i;\n\tu32 nb_sections;\n\tu32 data_size;\n\tu32 nb_hevc, nb_hevc_temp, nb_shvc, nb_shvc_temp, nb_mhvc, nb_mhvc_temp;\n\tunsigned char *data;\n\tGF_M2TS_Section *section;\n\tGF_Err e = GF_OK;",
"\t/*wait for the last section */\n\tif (!(status&GF_M2TS_TABLE_END)) return;",
"\tnb_es = 0;",
"\t/*skip if already received but no update detected (eg same data) */\n\tif ((status&GF_M2TS_TABLE_REPEAT) && !(status&GF_M2TS_TABLE_UPDATE)) {\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);\n\t\treturn;\n\t}",
"\tif (pmt->sec->demux_restarted) {\n\t\tpmt->sec->demux_restarted = 0;\n\t\treturn;\n\t}\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PMT Found or updated\\n\"));",
"\tnb_sections = gf_list_count(sections);\n\tif (nb_sections > 1) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"PMT on multiple sections not supported\\n\"));\n\t}",
"\tsection = (GF_M2TS_Section *)gf_list_get(sections, 0);\n\tdata = section->data;\n\tdata_size = section->data_size;",
"\tpmt->program->pcr_pid = ((data[0] & 0x1f) << 8) | data[1];",
"\tinfo_length = ((data[2]&0xf)<<8) | data[3];",
"\tif (info_length != 0) {",
"\t\t/* ...Read Descriptors ... */\n\t\tu8 tag, len;\n\t\tu32 first_loop_len = 0;\n\t\ttag = data[4];\n\t\tlen = data[5];\n\t\twhile (info_length > first_loop_len) {\n\t\t\tif (tag == GF_M2TS_MPEG4_IOD_DESCRIPTOR) {",
"\t\t\t\tu32 size;\n\t\t\t\tGF_BitStream *iod_bs;\n\t\t\t\tiod_bs = gf_bs_new((char *)data+8, len-2, GF_BITSTREAM_READ);\n\t\t\t\tif (pmt->program->pmt_iod) gf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);\n\t\t\t\te = gf_odf_parse_descriptor(iod_bs , (GF_Descriptor **) &pmt->program->pmt_iod, &size);\n\t\t\t\tgf_bs_del(iod_bs );\n\t\t\t\tif (e==GF_OK) {\n\t\t\t\t\t/*remember program number for service/program selection*/\n\t\t\t\t\tif (pmt->program->pmt_iod) pmt->program->pmt_iod->ServiceID = pmt->program->number;\n\t\t\t\t\t/*if empty IOD (freebox case), discard it and use dynamic declaration of object*/\n\t\t\t\t\tif (!gf_list_count(pmt->program->pmt_iod->ESDescriptors)) {\n\t\t\t\t\t\tgf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);\n\t\t\t\t\t\tpmt->program->pmt_iod = NULL;",
"\t\t\t\t\t}",
"",
"\t\t\t\t}\n\t\t\t} else if (tag == GF_M2TS_METADATA_POINTER_DESCRIPTOR) {\n\t\t\t\tGF_BitStream *metadatapd_bs;\n\t\t\t\tGF_M2TS_MetadataPointerDescriptor *metapd;\n\t\t\t\tmetadatapd_bs = gf_bs_new((char *)data+6, len, GF_BITSTREAM_READ);\n\t\t\t\tmetapd = gf_m2ts_read_metadata_pointer_descriptor(metadatapd_bs, len);\n\t\t\t\tgf_bs_del(metadatapd_bs);\n\t\t\t\tif (metapd->application_format_identifier == GF_M2TS_META_ID3 &&\n\t\t\t\t metapd->format_identifier == GF_M2TS_META_ID3 &&\n\t\t\t\t metapd->carriage_flag == METADATA_CARRIAGE_SAME_TS) {\n\t\t\t\t\t/*HLS ID3 Metadata */\n\t\t\t\t\tpmt->program->metadata_pointer_descriptor = metapd;\n\t\t\t\t} else {\n\t\t\t\t\t/* don't know what to do with it for now, delete */\n\t\t\t\t\tgf_m2ts_metadata_pointer_descriptor_del(metapd);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Skipping descriptor (0x%x) and others not supported\\n\", tag));\n\t\t\t}\n\t\t\tfirst_loop_len += 2 + len;\n\t\t}\n\t}\n\tif (data_size <= 4 + info_length) return;\n\tdata += 4 + info_length;\n\tdata_size -= 4 + info_length;\n\tpos = 0;",
"\t/* count de number of program related PMT received */\n\tfor(i=0; i<gf_list_count(ts->programs); i++) {\n\t\tGF_M2TS_Program *prog = (GF_M2TS_Program *)gf_list_get(ts->programs,i);\n\t\tif(prog->pmt_pid == pmt->pid) {\n\t\t\tbreak;\n\t\t}\n\t}",
"\tnb_hevc = nb_hevc_temp = nb_shvc = nb_shvc_temp = nb_mhvc = nb_mhvc_temp = 0;\n\twhile (pos<data_size) {\n\t\tGF_M2TS_PES *pes = NULL;\n\t\tGF_M2TS_SECTION_ES *ses = NULL;\n\t\tGF_M2TS_ES *es = NULL;\n\t\tBool inherit_pcr = 0;\n\t\tu32 pid, stream_type, reg_desc_format;",
"\t\tif (pos + 5 > data_size) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Broken PMT! size %d but position %d and need at least 5 bytes to declare es\\n\", data_size, pos));\n\t\t\tbreak;\n\t\t}",
"\t\tstream_type = data[0];\n\t\tpid = ((data[1] & 0x1f) << 8) | data[2];\n\t\tdesc_len = ((data[3] & 0xf) << 8) | data[4];",
"\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"stream_type :%d \\n\",stream_type));\n\t\tswitch (stream_type) {",
"\t\t/* PES */\n\t\tcase GF_M2TS_VIDEO_MPEG1:\n\t\tcase GF_M2TS_VIDEO_MPEG2:\n\t\tcase GF_M2TS_VIDEO_DCII:\n\t\tcase GF_M2TS_VIDEO_MPEG4:\n\t\tcase GF_M2TS_SYSTEMS_MPEG4_PES:\n\t\tcase GF_M2TS_VIDEO_H264:\n\t\tcase GF_M2TS_VIDEO_SVC:\n\t\tcase GF_M2TS_VIDEO_MVCD:\n\t\tcase GF_M2TS_VIDEO_HEVC:\n\t\tcase GF_M2TS_VIDEO_HEVC_MCTS:\n\t\tcase GF_M2TS_VIDEO_HEVC_TEMPORAL:\n\t\tcase GF_M2TS_VIDEO_SHVC:\n\t\tcase GF_M2TS_VIDEO_SHVC_TEMPORAL:\n\t\tcase GF_M2TS_VIDEO_MHVC:\n\t\tcase GF_M2TS_VIDEO_MHVC_TEMPORAL:\n\t\t\tinherit_pcr = 1;\n\t\tcase GF_M2TS_AUDIO_MPEG1:\n\t\tcase GF_M2TS_AUDIO_MPEG2:\n\t\tcase GF_M2TS_AUDIO_AAC:\n\t\tcase GF_M2TS_AUDIO_LATM_AAC:\n\t\tcase GF_M2TS_AUDIO_AC3:\n\t\tcase GF_M2TS_AUDIO_DTS:\n\t\tcase GF_M2TS_MHAS_MAIN:\n\t\tcase GF_M2TS_MHAS_AUX:\n\t\tcase GF_M2TS_SUBTITLE_DVB:\n\t\tcase GF_M2TS_METADATA_PES:\n\t\t\tGF_SAFEALLOC(pes, GF_M2TS_PES);\n\t\t\tif (!pes) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG2TS] Failed to allocate ES for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpes->cc = -1;\n\t\t\tpes->flags = GF_M2TS_ES_IS_PES;\n\t\t\tif (inherit_pcr)\n\t\t\t\tpes->flags |= GF_M2TS_INHERIT_PCR;\n\t\t\tes = (GF_M2TS_ES *)pes;\n\t\t\tbreak;\n\t\tcase GF_M2TS_PRIVATE_DATA:\n\t\t\tGF_SAFEALLOC(pes, GF_M2TS_PES);\n\t\t\tif (!pes) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG2TS] Failed to allocate ES for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpes->cc = -1;\n\t\t\tpes->flags = GF_M2TS_ES_IS_PES;\n\t\t\tes = (GF_M2TS_ES *)pes;\n\t\t\tbreak;\n\t\t/* Sections */\n\t\tcase GF_M2TS_SYSTEMS_MPEG4_SECTIONS:\n\t\t\tGF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);\n\t\t\tif (!ses) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG2TS] Failed to allocate ES for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tes = (GF_M2TS_ES *)ses;\n\t\t\tes->flags |= GF_M2TS_ES_IS_SECTION;\n\t\t\t/* carriage of ISO_IEC_14496 data in sections */\n\t\t\tif (stream_type == GF_M2TS_SYSTEMS_MPEG4_SECTIONS) {\n\t\t\t\t/*MPEG-4 sections need to be fully checked: if one section is lost, this means we lost\n\t\t\t\tone SL packet in the AU so we must wait for the complete section again*/\n\t\t\t\tses->sec = gf_m2ts_section_filter_new(gf_m2ts_process_mpeg4section, 0);\n\t\t\t\t/*create OD container*/\n\t\t\t\tif (!pmt->program->additional_ods) {\n\t\t\t\t\tpmt->program->additional_ods = gf_list_new();\n\t\t\t\t\tts->has_4on2 = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;",
"\t\tcase GF_M2TS_13818_6_ANNEX_A:\n\t\tcase GF_M2TS_13818_6_ANNEX_B:\n\t\tcase GF_M2TS_13818_6_ANNEX_C:\n\t\tcase GF_M2TS_13818_6_ANNEX_D:\n\t\tcase GF_M2TS_PRIVATE_SECTION:\n\t\tcase GF_M2TS_QUALITY_SEC:\n\t\tcase GF_M2TS_MORE_SEC:\n\t\t\tGF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);\n\t\t\tif (!ses) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG2TS] Failed to allocate ES for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tes = (GF_M2TS_ES *)ses;\n\t\t\tes->flags |= GF_M2TS_ES_IS_SECTION;\n\t\t\tes->pid = pid;\n\t\t\tes->service_id = pmt->program->number;\n\t\t\tif (stream_type == GF_M2TS_PRIVATE_SECTION) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"AIT sections on pid %d\\n\", pid));\n\t\t\t} else if (stream_type == GF_M2TS_QUALITY_SEC) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"Quality metadata sections on pid %d\\n\", pid));\n\t\t\t} else if (stream_type == GF_M2TS_MORE_SEC) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"MORE sections on pid %d\\n\", pid));\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"stream type DSM CC user private sections on pid %d \\n\", pid));\n\t\t\t}\n\t\t\t/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */\n\t\t\tses->sec = gf_m2ts_section_filter_new(NULL, 1);\n\t\t\t//ses->sec->service_id = pmt->program->number;\n\t\t\tbreak;",
"\t\tcase GF_M2TS_MPE_SECTIONS:\n\t\t\tif (! ts->prefix_present) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"stream type MPE found : pid = %d \\n\", pid));\n#ifdef GPAC_ENABLE_MPE\n\t\t\t\tes = gf_dvb_mpe_section_new();\n\t\t\t\tif (es->flags & GF_M2TS_ES_IS_SECTION) {\n\t\t\t\t\t/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */\n\t\t\t\t\t((GF_M2TS_SECTION_ES*)es)->sec = gf_m2ts_section_filter_new(NULL, 1);\n\t\t\t\t}\n#endif\n\t\t\t\tbreak;\n\t\t\t}",
"\t\tdefault:\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\\n\", stream_type, pid ) );\n\t\t\t//GF_LOG(/*GF_LOG_WARNING*/GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\\n\", stream_type, pid ) );\n\t\t\tbreak;\n\t\t}",
"\t\tif (es) {\n\t\t\tes->stream_type = (stream_type==GF_M2TS_PRIVATE_DATA) ? 0 : stream_type;\n\t\t\tes->program = pmt->program;\n\t\t\tes->pid = pid;\n\t\t\tes->component_tag = -1;\n\t\t}",
"\t\tpos += 5;\n\t\tdata += 5;",
"\t\twhile (desc_len) {\n\t\t\tif (pos + 2 > data_size) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Broken PMT descriptor! size %d but position %d and need at least 2 bytes to parse descritpor\\n\", data_size, pos));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tu8 tag = data[0];\n\t\t\tu32 len = data[1];",
"\t\t\tif (pos + 2 + len > data_size) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Broken PMT descriptor! size %d, desc size %d but position %d\\n\", data_size, len, pos));\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tif (es) {\n\t\t\t\tswitch (tag) {\n\t\t\t\tcase GF_M2TS_ISO_639_LANGUAGE_DESCRIPTOR:\n\t\t\t\t\tif (pes && (len>=3) )\n\t\t\t\t\t\tpes->lang = GF_4CC(' ', data[2], data[3], data[4]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_MPEG4_SL_DESCRIPTOR:\n\t\t\t\t\tif (len>=2) {\n\t\t\t\t\t\tes->mpeg4_es_id = ( (u32) data[2] & 0x1f) << 8 | data[3];\n\t\t\t\t\t\tes->flags |= GF_M2TS_ES_IS_SL;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_REGISTRATION_DESCRIPTOR:\n\t\t\t\t\tif (len>=4) {\n\t\t\t\t\t\treg_desc_format = GF_4CC(data[2], data[3], data[4], data[5]);\n\t\t\t\t\t\t/*cf http://www.smpte-ra.org/mpegreg/mpegreg.html*/\n\t\t\t\t\t\tswitch (reg_desc_format) {\n\t\t\t\t\t\tcase GF_M2TS_RA_STREAM_AC3:\n\t\t\t\t\t\t\tes->stream_type = GF_M2TS_AUDIO_AC3;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase GF_M2TS_RA_STREAM_VC1:\n\t\t\t\t\t\t\tes->stream_type = GF_M2TS_VIDEO_VC1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase GF_M2TS_RA_STREAM_GPAC:\n\t\t\t\t\t\t\tif (len==8) {\n\t\t\t\t\t\t\t\tes->stream_type = GF_4CC(data[6], data[7], data[8], data[9]);\n\t\t\t\t\t\t\t\tes->flags |= GF_M2TS_GPAC_CODEC_ID;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"Unknown registration descriptor %s\\n\", gf_4cc_to_str(reg_desc_format) ));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_EAC3_DESCRIPTOR:\n\t\t\t\t\tes->stream_type = GF_M2TS_AUDIO_EC3;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_DATA_BROADCAST_ID_DESCRIPTOR:\n\t\t\t\t\tif (len>=2) {\n\t\t\t\t\t\tu32 id = data[2]<<8 | data[3];\n\t\t\t\t\t\tif ((id == 0xB) && ses && !ses->sec) {\n\t\t\t\t\t\t\tses->sec = gf_m2ts_section_filter_new(NULL, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_SUBTITLING_DESCRIPTOR:\n\t\t\t\t\tif (pes && (len>=8)) {\n\t\t\t\t\t\tpes->sub.language[0] = data[2];\n\t\t\t\t\t\tpes->sub.language[1] = data[3];\n\t\t\t\t\t\tpes->sub.language[2] = data[4];\n\t\t\t\t\t\tpes->sub.type = data[5];\n\t\t\t\t\t\tpes->sub.composition_page_id = (data[6]<<8) | data[7];\n\t\t\t\t\t\tpes->sub.ancillary_page_id = (data[8]<<8) | data[9];\n\t\t\t\t\t}\n\t\t\t\t\tes->stream_type = GF_M2TS_DVB_SUBTITLE;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_STREAM_IDENTIFIER_DESCRIPTOR:\n\t\t\t\t\tif (len>=1) {\n\t\t\t\t\t\tes->component_tag = data[2];\n\t\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"Component Tag: %d on Program %d\\n\", es->component_tag, es->program->number));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_TELETEXT_DESCRIPTOR:\n\t\t\t\t\tes->stream_type = GF_M2TS_DVB_TELETEXT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_VBI_DATA_DESCRIPTOR:\n\t\t\t\t\tes->stream_type = GF_M2TS_DVB_VBI;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_HIERARCHY_DESCRIPTOR:\n\t\t\t\t\tif (pes && (len>=4)) {\n\t\t\t\t\t\tu8 hierarchy_embedded_layer_index;\n\t\t\t\t\t\tGF_BitStream *hbs = gf_bs_new((const char *)data, data_size, GF_BITSTREAM_READ);\n\t\t\t\t\t\t/*u32 skip = */gf_bs_read_int(hbs, 16);\n\t\t\t\t\t\t/*u8 res1 = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\t/*u8 temp_scal = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\t/*u8 spatial_scal = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\t/*u8 quality_scal = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\t/*u8 hierarchy_type = */gf_bs_read_int(hbs, 4);\n\t\t\t\t\t\t/*u8 res2 = */gf_bs_read_int(hbs, 2);\n\t\t\t\t\t\t/*u8 hierarchy_layer_index = */gf_bs_read_int(hbs, 6);\n\t\t\t\t\t\t/*u8 tref_not_present = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\t/*u8 res3 = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\thierarchy_embedded_layer_index = gf_bs_read_int(hbs, 6);\n\t\t\t\t\t\t/*u8 res4 = */gf_bs_read_int(hbs, 2);\n\t\t\t\t\t\t/*u8 hierarchy_channel = */gf_bs_read_int(hbs, 6);\n\t\t\t\t\t\tgf_bs_del(hbs);",
"\t\t\t\t\t\tpes->depends_on_pid = 1+hierarchy_embedded_layer_index;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_METADATA_DESCRIPTOR:\n\t\t\t\t{\n\t\t\t\t\tGF_BitStream *metadatad_bs;\n\t\t\t\t\tGF_M2TS_MetadataDescriptor *metad;\n\t\t\t\t\tmetadatad_bs = gf_bs_new((char *)data+2, len, GF_BITSTREAM_READ);\n\t\t\t\t\tmetad = gf_m2ts_read_metadata_descriptor(metadatad_bs, len);\n\t\t\t\t\tgf_bs_del(metadatad_bs);\n\t\t\t\t\tif (metad->application_format_identifier == GF_M2TS_META_ID3 &&\n\t\t\t\t\t metad->format_identifier == GF_M2TS_META_ID3) {\n\t\t\t\t\t\t/*HLS ID3 Metadata */\n\t\t\t\t\t\tif (pes) {\n\t\t\t\t\t\t\tpes->metadata_descriptor = metad;\n\t\t\t\t\t\t\tpes->stream_type = GF_M2TS_METADATA_ID3_HLS;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/* don't know what to do with it for now, delete */\n\t\t\t\t\t\tgf_m2ts_metadata_descriptor_del(metad);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\t\tdefault:\n\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] skipping descriptor (0x%x) not supported\\n\", tag));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tdata += len+2;\n\t\t\tpos += len+2;\n\t\t\tif (desc_len < len+2) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Invalid PMT es descriptor size for PID %d\\n\", pid ) );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdesc_len-=len+2;\n\t\t}",
"\t\tif (es && !es->stream_type) {\n\t\t\tgf_free(es);\n\t\t\tes = NULL;\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Private Stream type (0x%x) for PID %d not supported\\n\", stream_type, pid ) );\n\t\t}",
"\t\tif (!es) continue;",
"\t\tif (ts->ess[pid]) {\n\t\t\t//this is component reuse across programs, overwrite the previously declared stream ...\n\t\t\tif (status & GF_M2TS_TABLE_FOUND) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d reused across programs %d and %d, not completely supported\\n\", pid, ts->ess[pid]->program->number, es->program->number ) );",
"\t\t\t\t//add stream to program but don't reassign the pid table until the stream is playing (>GF_M2TS_PES_FRAMING_SKIP)\n\t\t\t\tgf_list_add(pmt->program->streams, es);\n\t\t\t\tif (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);",
"\t\t\t\tnb_es++;\n\t\t\t\t//skip assignment below\n\t\t\t\tes = NULL;\n\t\t\t}\n\t\t\t/*watchout for pmt update - FIXME this likely won't work in most cases*/\n\t\t\telse {",
"\t\t\t\tGF_M2TS_ES *o_es = ts->ess[es->pid];",
"\t\t\t\tif ((o_es->stream_type == es->stream_type)\n\t\t\t\t && ((o_es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK) == (es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK))\n\t\t\t\t && (o_es->mpeg4_es_id == es->mpeg4_es_id)\n\t\t\t\t && ((o_es->flags & GF_M2TS_ES_IS_SECTION) || ((GF_M2TS_PES *)o_es)->lang == ((GF_M2TS_PES *)es)->lang)\n\t\t\t\t ) {\n\t\t\t\t\tgf_free(es);\n\t\t\t\t\tes = NULL;\n\t\t\t\t} else {\n\t\t\t\t\tgf_m2ts_es_del(o_es, ts);\n\t\t\t\t\tts->ess[es->pid] = NULL;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"\t\tif (es) {\n\t\t\tts->ess[es->pid] = es;\n\t\t\tgf_list_add(pmt->program->streams, es);\n\t\t\tif (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);",
"\t\t\tnb_es++;",
"\t\t\tif (es->stream_type == GF_M2TS_VIDEO_HEVC) nb_hevc++;\n\t\t\telse if (es->stream_type == GF_M2TS_VIDEO_HEVC_TEMPORAL) nb_hevc_temp++;\n\t\t\telse if (es->stream_type == GF_M2TS_VIDEO_SHVC) nb_shvc++;\n\t\t\telse if (es->stream_type == GF_M2TS_VIDEO_SHVC_TEMPORAL) nb_shvc_temp++;\n\t\t\telse if (es->stream_type == GF_M2TS_VIDEO_MHVC) nb_mhvc++;\n\t\t\telse if (es->stream_type == GF_M2TS_VIDEO_MHVC_TEMPORAL) nb_mhvc_temp++;\n\t\t}\n\t}",
"\t//Table 2-139, implied hierarchy indexes\n\tif (nb_hevc_temp + nb_shvc + nb_shvc_temp + nb_mhvc+ nb_mhvc_temp) {\n\t\tfor (i=0; i<gf_list_count(pmt->program->streams); i++) {\n\t\t\tGF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);\n\t\t\tif ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;\n\t\t\tif (es->depends_on_pid) continue;",
"\t\t\tswitch (es->stream_type) {\n\t\t\tcase GF_M2TS_VIDEO_HEVC_TEMPORAL:\n\t\t\t\tes->depends_on_pid = 1;\n\t\t\t\tbreak;\n\t\t\tcase GF_M2TS_VIDEO_SHVC:\n\t\t\t\tif (!nb_hevc_temp) es->depends_on_pid = 1;\n\t\t\t\telse es->depends_on_pid = 2;\n\t\t\t\tbreak;\n\t\t\tcase GF_M2TS_VIDEO_SHVC_TEMPORAL:\n\t\t\t\tes->depends_on_pid = 3;\n\t\t\t\tbreak;\n\t\t\tcase GF_M2TS_VIDEO_MHVC:\n\t\t\t\tif (!nb_hevc_temp) es->depends_on_pid = 1;\n\t\t\t\telse es->depends_on_pid = 2;\n\t\t\t\tbreak;\n\t\t\tcase GF_M2TS_VIDEO_MHVC_TEMPORAL:\n\t\t\t\tif (!nb_hevc_temp) es->depends_on_pid = 2;\n\t\t\t\telse es->depends_on_pid = 3;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}",
"\tif (nb_es) {\n\t\tu32 i;",
"\t\t//translate hierarchy descriptors indexes into PIDs - check whether the PMT-index rules are the same for HEVC\n\t\tfor (i=0; i<gf_list_count(pmt->program->streams); i++) {\n\t\t\tGF_M2TS_PES *an_es = NULL;\n\t\t\tGF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);\n\t\t\tif ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;\n\t\t\tif (!es->depends_on_pid) continue;",
"\t\t\t//fixeme we are not always assured that hierarchy_layer_index matches the stream index...\n\t\t\t//+1 is because our first stream is the PMT\n\t\t\tan_es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, es->depends_on_pid);\n\t\t\tif (an_es) {\n\t\t\t\tes->depends_on_pid = an_es->pid;\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[M2TS] Wrong dependency index in hierarchy descriptor, assuming non-scalable stream\\n\"));\n\t\t\t\tes->depends_on_pid = 0;\n\t\t\t}\n\t\t}",
"\t\tevt_type = (status&GF_M2TS_TABLE_FOUND) ? GF_M2TS_EVT_PMT_FOUND : GF_M2TS_EVT_PMT_UPDATE;\n\t\tif (ts->on_event) ts->on_event(ts, evt_type, pmt->program);\n\t} else {\n\t\t/* if we found no new ES it's simply a repeat of the PMT */\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);\n\t}\n}",
"static void gf_m2ts_process_pat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tGF_M2TS_Program *prog;\n\tGF_M2TS_SECTION_ES *pmt;\n\tu32 i, nb_progs, evt_type;\n\tu32 nb_sections;\n\tu32 data_size;\n\tunsigned char *data;\n\tGF_M2TS_Section *section;",
"\t/*wait for the last section */\n\tif (!(status&GF_M2TS_TABLE_END)) return;",
"\t/*skip if already received*/\n\tif (status&GF_M2TS_TABLE_REPEAT) {\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PAT_REPEAT, NULL);\n\t\treturn;\n\t}",
"\tnb_sections = gf_list_count(sections);\n\tif (nb_sections > 1) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"PAT on multiple sections not supported\\n\"));\n\t}",
"\tsection = (GF_M2TS_Section *)gf_list_get(sections, 0);\n\tdata = section->data;\n\tdata_size = section->data_size;",
"\tif (!(status&GF_M2TS_TABLE_UPDATE) && gf_list_count(ts->programs)) {\n\t\tif (ts->pat->demux_restarted) {\n\t\t\tts->pat->demux_restarted = 0;\n\t\t} else {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Multiple different PAT on single TS found, ignoring new PAT declaration (table id %d - extended table id %d)\\n\", table_id, ex_table_id));\n\t\t}\n\t\treturn;\n\t}\n\tnb_progs = data_size / 4;",
"\tfor (i=0; i<nb_progs; i++) {\n\t\tu16 number, pid;\n\t\tnumber = (data[0]<<8) | data[1];\n\t\tpid = (data[2]&0x1f)<<8 | data[3];\n\t\tdata += 4;\n\t\tif (number==0) {\n\t\t\tif (!ts->nit) {\n\t\t\t\tts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0);\n\t\t\t}\n\t\t} else {\n\t\t\tGF_SAFEALLOC(prog, GF_M2TS_Program);\n\t\t\tif (!prog) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Fail to allocate program for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tprog->streams = gf_list_new();\n\t\t\tprog->pmt_pid = pid;\n\t\t\tprog->number = number;\n\t\t\tprog->ts = ts;\n\t\t\tgf_list_add(ts->programs, prog);\n\t\t\tGF_SAFEALLOC(pmt, GF_M2TS_SECTION_ES);\n\t\t\tif (!pmt) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Fail to allocate pmt filter for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpmt->flags = GF_M2TS_ES_IS_SECTION;\n\t\t\tgf_list_add(prog->streams, pmt);\n\t\t\tpmt->pid = prog->pmt_pid;\n\t\t\tpmt->program = prog;\n\t\t\tts->ess[pmt->pid] = (GF_M2TS_ES *)pmt;\n\t\t\tpmt->sec = gf_m2ts_section_filter_new(gf_m2ts_process_pmt, 0);\n\t\t}\n\t}",
"\tevt_type = (status&GF_M2TS_TABLE_UPDATE) ? GF_M2TS_EVT_PAT_UPDATE : GF_M2TS_EVT_PAT_FOUND;\n\tif (ts->on_event) ts->on_event(ts, evt_type, NULL);\n}",
"static void gf_m2ts_process_cat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tu32 evt_type;\n\t/*\n\t\tGF_M2TS_Program *prog;\n\t\tGF_M2TS_SECTION_ES *pmt;\n\t\tu32 i, nb_progs;\n\t\tu32 nb_sections;\n\t\tu32 data_size;\n\t\tunsigned char *data;\n\t\tGF_M2TS_Section *section;\n\t*/",
"\t/*wait for the last section */\n\tif (!(status&GF_M2TS_TABLE_END)) return;",
"\t/*skip if already received*/\n\tif (status&GF_M2TS_TABLE_REPEAT) {\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_CAT_REPEAT, NULL);\n\t\treturn;\n\t}\n\t/*\n\t\tnb_sections = gf_list_count(sections);\n\t\tif (nb_sections > 1) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"CAT on multiple sections not supported\\n\"));\n\t\t}",
"\t\tsection = (GF_M2TS_Section *)gf_list_get(sections, 0);\n\t\tdata = section->data;\n\t\tdata_size = section->data_size;",
"\t\tnb_progs = data_size / 4;",
"\t\tfor (i=0; i<nb_progs; i++) {\n\t\t\tu16 number, pid;\n\t\t\tnumber = (data[0]<<8) | data[1];\n\t\t\tpid = (data[2]&0x1f)<<8 | data[3];\n\t\t\tdata += 4;\n\t\t\tif (number==0) {\n\t\t\t\tif (!ts->nit) {\n\t\t\t\t\tts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tGF_SAFEALLOC(prog, GF_M2TS_Program);\n\t\t\t\tprog->streams = gf_list_new();\n\t\t\t\tprog->pmt_pid = pid;\n\t\t\t\tprog->number = number;\n\t\t\t\tgf_list_add(ts->programs, prog);\n\t\t\t\tGF_SAFEALLOC(pmt, GF_M2TS_SECTION_ES);\n\t\t\t\tpmt->flags = GF_M2TS_ES_IS_SECTION;\n\t\t\t\tgf_list_add(prog->streams, pmt);\n\t\t\t\tpmt->pid = prog->pmt_pid;\n\t\t\t\tpmt->program = prog;\n\t\t\t\tts->ess[pmt->pid] = (GF_M2TS_ES *)pmt;\n\t\t\t\tpmt->sec = gf_m2ts_section_filter_new(gf_m2ts_process_pmt, 0);\n\t\t\t}\n\t\t}\n\t*/",
"\tevt_type = (status&GF_M2TS_TABLE_UPDATE) ? GF_M2TS_EVT_CAT_UPDATE : GF_M2TS_EVT_CAT_FOUND;\n\tif (ts->on_event) ts->on_event(ts, evt_type, NULL);\n}",
"u64 gf_m2ts_get_pts(unsigned char *data)\n{\n\tu64 pts;\n\tu32 val;\n\tpts = (u64)((data[0] >> 1) & 0x07) << 30;\n\tval = (data[1] << 8) | data[2];\n\tpts |= (u64)(val >> 1) << 15;\n\tval = (data[3] << 8) | data[4];\n\tpts |= (u64)(val >> 1);\n\treturn pts;\n}",
"void gf_m2ts_pes_header(GF_M2TS_PES *pes, unsigned char *data, u32 data_size, GF_M2TS_PESHeader *pesh)\n{\n\tu32 has_pts, has_dts;\n\tu32 len_check;\n\tmemset(pesh, 0, sizeof(GF_M2TS_PESHeader));",
"\tlen_check = 0;",
"\tpesh->id = data[0];\n\tpesh->pck_len = (data[1]<<8) | data[2];\n\t/*\n\t\t2bits\n\t\tscrambling_control\t\t= gf_bs_read_int(bs,2);\n\t\tpriority\t\t\t\t= gf_bs_read_int(bs,1);\n\t*/\n\tpesh->data_alignment = (data[3] & 0x4) ? 1 : 0;\n\t/*\n\t\tcopyright\t\t\t\t= gf_bs_read_int(bs,1);\n\t\toriginal\t\t\t\t= gf_bs_read_int(bs,1);\n\t*/\n\thas_pts = (data[4]&0x80);\n\thas_dts = has_pts ? (data[4]&0x40) : 0;\n\t/*\n\t\tESCR_flag\t\t\t\t= gf_bs_read_int(bs,1);\n\t\tES_rate_flag\t\t\t= gf_bs_read_int(bs,1);\n\t\tDSM_flag\t\t\t\t= gf_bs_read_int(bs,1);\n\t\tadditional_copy_flag\t= gf_bs_read_int(bs,1);\n\t\tprev_crc_flag\t\t\t= gf_bs_read_int(bs,1);\n\t\textension_flag\t\t\t= gf_bs_read_int(bs,1);\n\t*/",
"\tpesh->hdr_data_len = data[5];",
"\tdata += 6;\n\tif (has_pts) {\n\t\tpesh->PTS = gf_m2ts_get_pts(data);\n\t\tdata+=5;\n\t\tlen_check += 5;\n\t}\n\tif (has_dts) {\n\t\tpesh->DTS = gf_m2ts_get_pts(data);\n\t\t//data+=5;\n\t\tlen_check += 5;\n\t} else {\n\t\tpesh->DTS = pesh->PTS;\n\t}\n\tif (len_check < pesh->hdr_data_len) {\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d Skipping %d bytes in pes header\\n\", pes->pid, pesh->hdr_data_len - len_check));\n\t} else if (len_check > pesh->hdr_data_len) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d Wrong pes_header_data_length field %d bytes - read %d\\n\", pes->pid, pesh->hdr_data_len, len_check));\n\t}",
"\tif ((pesh->PTS<90000) && ((s32)pesh->DTS<0)) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d Wrong DTS %d negative for PTS %d - forcing to 0\\n\", pes->pid, pesh->DTS, pesh->PTS));\n\t\tpesh->DTS=0;\n\t}\n}",
"static void gf_m2ts_store_temi(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes)\n{\n\tGF_BitStream *bs = gf_bs_new(pes->temi_tc_desc, pes->temi_tc_desc_len, GF_BITSTREAM_READ);\n\tu32 has_timestamp = gf_bs_read_int(bs, 2);\n\tBool has_ntp = (Bool) gf_bs_read_int(bs, 1);\n\t/*u32 has_ptp = */gf_bs_read_int(bs, 1);\n\t/*u32 has_timecode = */gf_bs_read_int(bs, 2);",
"\tmemset(&pes->temi_tc, 0, sizeof(GF_M2TS_TemiTimecodeDescriptor));\n\tpes->temi_tc.force_reload = gf_bs_read_int(bs, 1);\n\tpes->temi_tc.is_paused = gf_bs_read_int(bs, 1);\n\tpes->temi_tc.is_discontinuity = gf_bs_read_int(bs, 1);\n\tgf_bs_read_int(bs, 7);\n\tpes->temi_tc.timeline_id = gf_bs_read_int(bs, 8);\n\tif (has_timestamp) {\n\t\tpes->temi_tc.media_timescale = gf_bs_read_u32(bs);\n\t\tif (has_timestamp==2)\n\t\t\tpes->temi_tc.media_timestamp = gf_bs_read_u64(bs);\n\t\telse\n\t\t\tpes->temi_tc.media_timestamp = gf_bs_read_u32(bs);\n\t}\n\tif (has_ntp) {\n\t\tpes->temi_tc.ntp = gf_bs_read_u64(bs);\n\t}\n\tgf_bs_del(bs);\n\tpes->temi_tc_desc_len = 0;\n\tpes->temi_pending = 1;\n}",
"void gf_m2ts_flush_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes)\n{\n\tGF_M2TS_PESHeader pesh;\n\tif (!ts) return;",
"\t/*we need at least a full, valid start code and PES header !!*/\n\tif ((pes->pck_data_len >= 4) && !pes->pck_data[0] && !pes->pck_data[1] && (pes->pck_data[2] == 0x1)) {\n\t\tu32 len;\n\t\tBool has_pes_header = GF_TRUE;\n\t\tu32 stream_id = pes->pck_data[3];\n\t\tBool same_pts = GF_FALSE;",
"\t\tswitch (stream_id) {\n\t\tcase GF_M2_STREAMID_PROGRAM_STREAM_MAP:\n\t\tcase GF_M2_STREAMID_PADDING:\n\t\tcase GF_M2_STREAMID_PRIVATE_2:\n\t\tcase GF_M2_STREAMID_ECM:\n\t\tcase GF_M2_STREAMID_EMM:\n\t\tcase GF_M2_STREAMID_PROGRAM_STREAM_DIRECTORY:\n\t\tcase GF_M2_STREAMID_DSMCC:\n\t\tcase GF_M2_STREAMID_H222_TYPE_E:\n\t\t\thas_pes_header = GF_FALSE;\n\t\t\tbreak;\n\t\t}",
"\t\tif (has_pes_header) {",
"\t\t\t/*OK read header*/\n\t\t\tgf_m2ts_pes_header(pes, pes->pck_data + 3, pes->pck_data_len - 3, &pesh);",
"\t\t\t/*send PES timing*/\n\t\t\tif (ts->notify_pes_timing) {\n\t\t\t\tGF_M2TS_PES_PCK pck;\n\t\t\t\tmemset(&pck, 0, sizeof(GF_M2TS_PES_PCK));\n\t\t\t\tpck.PTS = pesh.PTS;\n\t\t\t\tpck.DTS = pesh.DTS;\n\t\t\t\tpck.stream = pes;\n\t\t\t\tif (pes->rap) pck.flags |= GF_M2TS_PES_PCK_RAP;\n\t\t\t\tpes->pes_end_packet_number = ts->pck_number;\n\t\t\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PES_TIMING, &pck);\n\t\t\t}\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d Got PES header DTS %d PTS %d\\n\", pes->pid, pesh.DTS, pesh.PTS));",
"\t\t\tif (pesh.PTS) {\n\t\t\t\tif (pesh.PTS == pes->PTS) {\n\t\t\t\t\tsame_pts = GF_TRUE;\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d - same PTS \"LLU\" for two consecutive PES packets \\n\", pes->pid, pes->PTS));\n\t\t\t\t}\n\t#ifndef GPAC_DISABLE_LOG\n\t\t\t\t/*FIXME - this test should only be done for non bi-directionnally coded media\n\t\t\t\telse if (pesh.PTS < pes->PTS) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d - PTS \"LLU\" less than previous packet PTS \"LLU\"\\n\", pes->pid, pesh.PTS, pes->PTS) );\n\t\t\t\t}\n\t\t\t\t*/\n\t#endif",
"\t\t\t\tpes->PTS = pesh.PTS;\n\t#ifndef GPAC_DISABLE_LOG\n\t\t\t\t{\n\t\t\t\t\tif (pes->DTS && (pesh.DTS == pes->DTS)) {\n\t\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d - same DTS \"LLU\" for two consecutive PES packets \\n\", pes->pid, pes->DTS));\n\t\t\t\t\t}\n\t\t\t\t\tif (pesh.DTS < pes->DTS) {\n\t\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d - DTS \"LLU\" less than previous DTS \"LLU\"\\n\", pes->pid, pesh.DTS, pes->DTS));\n\t\t\t\t\t}\n\t\t\t\t}\n\t#endif\n\t\t\t\tpes->DTS = pesh.DTS;\n\t\t\t}\n\t\t\t/*no PTSs were coded, same time*/\n\t\t\telse if (!pesh.hdr_data_len) {\n\t\t\t\tsame_pts = GF_TRUE;\n\t\t\t}",
"\n\t\t\t/*3-byte start-code + 6 bytes header + hdr extensions*/\n\t\t\tlen = 9 + pesh.hdr_data_len;",
"\t\t} else {\n\t\t\t/*3-byte start-code + 1 byte streamid*/\n\t\t\tlen = 4;\n\t\t\tmemset(&pesh, 0, sizeof(pesh));\n\t\t}",
"\t\tif ((u8) pes->pck_data[3]==0xfa) {\n\t\t\tGF_M2TS_SL_PCK sl_pck;",
"\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] SL Packet in PES for %d - ES ID %d\\n\", pes->pid, pes->mpeg4_es_id));",
"\t\t\tif (pes->pck_data_len > len) {\n\t\t\t\tsl_pck.data = (char *)pes->pck_data + len;\n\t\t\t\tsl_pck.data_len = pes->pck_data_len - len;\n\t\t\t\tsl_pck.stream = (GF_M2TS_ES *)pes;\n\t\t\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_SL_PCK, &sl_pck);\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Bad SL Packet size: (%d indicated < %d header)\\n\", pes->pid, pes->pck_data_len, len));\n\t\t\t}\n\t\t} else if (pes->reframe) {\n\t\t\tu32 remain = 0;\n\t\t\tu32 offset = len;",
"\t\t\tif (pesh.pck_len && (pesh.pck_len-3-pesh.hdr_data_len != pes->pck_data_len-len)) {\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PES payload size %d but received %d bytes\\n\", pes->pid, (u32) ( pesh.pck_len-3-pesh.hdr_data_len), pes->pck_data_len-len));\n\t\t\t}\n\t\t\t//copy over the remaining of previous PES payload before start of this PES payload\n\t\t\tif (pes->prev_data_len) {\n\t\t\t\tif (pes->prev_data_len < len) {\n\t\t\t\t\toffset = len - pes->prev_data_len;\n\t\t\t\t\tmemcpy(pes->pck_data + offset, pes->prev_data, pes->prev_data_len);\n\t\t\t\t} else {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PES reassembly buffer overflow (%d bytes not processed from previous PES) - discarding prev data\\n\", pes->pid, pes->prev_data_len ));\n\t\t\t\t}\n\t\t\t}",
"\t\t\tif (!pes->temi_pending && pes->temi_tc_desc_len) {\n\t\t\t\tgf_m2ts_store_temi(ts, pes);\n\t\t\t}",
"\t\t\tif (pes->temi_pending) {\n\t\t\t\tpes->temi_pending = 0;\n\t\t\t\tpes->temi_tc.pes_pts = pes->PTS;\n\t\t\t\tif (ts->on_event)\n\t\t\t\t\tts->on_event(ts, GF_M2TS_EVT_TEMI_TIMECODE, &pes->temi_tc);\n\t\t\t}",
"\t\t\tif (! ts->seek_mode)\n\t\t\t\tremain = pes->reframe(ts, pes, same_pts, pes->pck_data+offset, pes->pck_data_len-offset, &pesh);",
"\t\t\t//CLEANUP alloc stuff\n\t\t\tif (pes->prev_data) gf_free(pes->prev_data);\n\t\t\tpes->prev_data = NULL;\n\t\t\tpes->prev_data_len = 0;\n\t\t\tif (remain) {\n\t\t\t\tpes->prev_data = gf_malloc(sizeof(char)*remain);\n\t\t\t\tassert(pes->pck_data_len >= remain);\n\t\t\t\tmemcpy(pes->prev_data, pes->pck_data + pes->pck_data_len - remain, remain);\n\t\t\t\tpes->prev_data_len = remain;\n\t\t\t}\n\t\t}\n\t} else if (pes->pck_data_len) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PES %d: Bad PES Header, discarding packet (maybe stream is encrypted ?)\\n\", pes->pid));\n\t}\n\tpes->pck_data_len = 0;\n\tpes->pes_len = 0;\n\tpes->rap = 0;\n}",
"static void gf_m2ts_process_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, GF_M2TS_Header *hdr, unsigned char *data, u32 data_size, GF_M2TS_AdaptationField *paf)\n{\n\tu8 expect_cc;\n\tBool disc=0;\n\tBool flush_pes = 0;",
"\t/*duplicated packet, NOT A DISCONTINUITY, we should discard the packet - however we may encounter this configuration in DASH at segment boundaries.\n\tIf payload start is set, ignore duplication*/\n\tif (hdr->continuity_counter==pes->cc) {\n\t\tif (!hdr->payload_start || (hdr->adaptation_field!=3) ) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PES %d: Duplicated Packet found (CC %d) - skipping\\n\", pes->pid, pes->cc));\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\texpect_cc = (pes->cc<0) ? hdr->continuity_counter : (pes->cc + 1) & 0xf;\n\t\tif (expect_cc != hdr->continuity_counter)\n\t\t\tdisc = 1;\n\t}\n\tpes->cc = hdr->continuity_counter;",
"\tif (disc) {\n\t\tif (pes->flags & GF_M2TS_ES_IGNORE_NEXT_DISCONTINUITY) {\n\t\t\tpes->flags &= ~GF_M2TS_ES_IGNORE_NEXT_DISCONTINUITY;\n\t\t\tdisc = 0;\n\t\t}\n\t\tif (disc) {\n\t\t\tif (hdr->payload_start) {\n\t\t\t\tif (pes->pck_data_len) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PES %d: Packet discontinuity (%d expected - got %d) - may have lost end of previous PES\\n\", pes->pid, expect_cc, hdr->continuity_counter));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (pes->pck_data_len) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PES %d: Packet discontinuity (%d expected - got %d) - trashing PES packet\\n\", pes->pid, expect_cc, hdr->continuity_counter));\n\t\t\t\t}\n\t\t\t\tpes->pck_data_len = 0;\n\t\t\t\tpes->pes_len = 0;\n\t\t\t\tpes->cc = -1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}",
"\tif (!pes->reframe) return;",
"\tif (hdr->payload_start) {\n\t\tflush_pes = 1;\n\t\tpes->pes_start_packet_number = ts->pck_number;\n\t\tpes->before_last_pcr_value = pes->program->before_last_pcr_value;\n\t\tpes->before_last_pcr_value_pck_number = pes->program->before_last_pcr_value_pck_number;\n\t\tpes->last_pcr_value = pes->program->last_pcr_value;\n\t\tpes->last_pcr_value_pck_number = pes->program->last_pcr_value_pck_number;\n\t} else if (pes->pes_len && (pes->pck_data_len + data_size == pes->pes_len + 6)) {\n\t\t/* 6 = startcode+stream_id+length*/\n\t\t/*reassemble pes*/\n\t\tif (pes->pck_data_len + data_size > pes->pck_alloc_len) {\n\t\t\tpes->pck_alloc_len = pes->pck_data_len + data_size;\n\t\t\tpes->pck_data = (u8*)gf_realloc(pes->pck_data, pes->pck_alloc_len);\n\t\t}\n\t\tmemcpy(pes->pck_data+pes->pck_data_len, data, data_size);\n\t\tpes->pck_data_len += data_size;\n\t\t/*force discard*/\n\t\tdata_size = 0;\n\t\tflush_pes = 1;\n\t}",
"\t/*PES first fragment: flush previous packet*/\n\tif (flush_pes && pes->pck_data_len) {\n\t\tgf_m2ts_flush_pes(ts, pes);\n\t\tif (!data_size) return;\n\t}\n\t/*we need to wait for first packet of PES*/\n\tif (!pes->pck_data_len && !hdr->payload_start) {\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Waiting for PES header, trashing data\\n\", hdr->pid));\n\t\treturn;\n\t}\n\t/*reassemble*/\n\tif (pes->pck_data_len + data_size > pes->pck_alloc_len ) {\n\t\tpes->pck_alloc_len = pes->pck_data_len + data_size;\n\t\tpes->pck_data = (u8*)gf_realloc(pes->pck_data, pes->pck_alloc_len);\n\t}\n\tmemcpy(pes->pck_data + pes->pck_data_len, data, data_size);\n\tpes->pck_data_len += data_size;",
"\tif (paf && paf->random_access_indicator) pes->rap = 1;\n\tif (hdr->payload_start && !pes->pes_len && (pes->pck_data_len>=6)) {\n\t\tpes->pes_len = (pes->pck_data[4]<<8) | pes->pck_data[5];\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Got PES packet len %d\\n\", pes->pid, pes->pes_len));",
"\t\tif (pes->pes_len + 6 == pes->pck_data_len) {\n\t\t\tgf_m2ts_flush_pes(ts, pes);\n\t\t}\n\t}\n}",
"\nstatic void gf_m2ts_get_adaptation_field(GF_M2TS_Demuxer *ts, GF_M2TS_AdaptationField *paf, unsigned char *data, u32 size, u32 pid)\n{\n\tunsigned char *af_extension;\n\tpaf->discontinuity_indicator = (data[0] & 0x80) ? 1 : 0;\n\tpaf->random_access_indicator = (data[0] & 0x40) ? 1 : 0;\n\tpaf->priority_indicator = (data[0] & 0x20) ? 1 : 0;\n\tpaf->PCR_flag = (data[0] & 0x10) ? 1 : 0;\n\tpaf->OPCR_flag = (data[0] & 0x8) ? 1 : 0;\n\tpaf->splicing_point_flag = (data[0] & 0x4) ? 1 : 0;\n\tpaf->transport_private_data_flag = (data[0] & 0x2) ? 1 : 0;\n\tpaf->adaptation_field_extension_flag = (data[0] & 0x1) ? 1 : 0;",
"\taf_extension = data + 1;\n\tif (paf->PCR_flag == 1) {\n\t\tu32 base = ((u32)data[1] << 24) | ((u32)data[2] << 16) | ((u32)data[3] << 8) | (u32)data[4];\n\t\tu64 PCR = (u64) base;\n\t\tpaf->PCR_base = (PCR << 1) | (data[5] >> 7);\n\t\tpaf->PCR_ext = ((data[5] & 1) << 8) | data[6];\n\t\taf_extension += 6;\n\t}",
"\tif (paf->adaptation_field_extension_flag) {\n\t\tu32 afext_bytes;\n\t\tBool ltw_flag, pwr_flag, seamless_flag, af_desc_not_present;\n\t\tif (paf->OPCR_flag) {\n\t\t\taf_extension += 6;\n\t\t}\n\t\tif (paf->splicing_point_flag) {\n\t\t\taf_extension += 1;\n\t\t}\n\t\tif (paf->transport_private_data_flag) {\n\t\t\tu32 priv_bytes = af_extension[0];\n\t\t\taf_extension += 1 + priv_bytes;\n\t\t}",
"\t\tafext_bytes = af_extension[0];\n\t\tltw_flag = af_extension[1] & 0x80 ? 1 : 0;\n\t\tpwr_flag = af_extension[1] & 0x40 ? 1 : 0;\n\t\tseamless_flag = af_extension[1] & 0x20 ? 1 : 0;\n\t\taf_desc_not_present = af_extension[1] & 0x10 ? 1 : 0;\n\t\taf_extension += 2;\n\t\tif (!afext_bytes) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Bad Adaptation Extension found\\n\", pid));\n\t\t\treturn;\n\t\t}\n\t\tafext_bytes-=1;\n\t\tif (ltw_flag) {\n\t\t\taf_extension += 2;\n\t\t\tif (afext_bytes<2) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Bad Adaptation Extension found\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tafext_bytes-=2;\n\t\t}\n\t\tif (pwr_flag) {\n\t\t\taf_extension += 3;\n\t\t\tif (afext_bytes<3) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Bad Adaptation Extension found\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tafext_bytes-=3;\n\t\t}\n\t\tif (seamless_flag) {\n\t\t\taf_extension += 3;\n\t\t\tif (afext_bytes<3) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Bad Adaptation Extension found\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tafext_bytes-=3;\n\t\t}",
"\t\tif (! af_desc_not_present) {\n\t\t\twhile (afext_bytes) {\n\t\t\t\tGF_BitStream *bs;\n\t\t\t\tchar *desc;\n\t\t\t\tu8 desc_tag = af_extension[0];\n\t\t\t\tu8 desc_len = af_extension[1];\n\t\t\t\tif (!desc_len || (u32) desc_len+2 > afext_bytes) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Bad Adaptation Descriptor found (tag %d) size is %d but only %d bytes available\\n\", pid, desc_tag, desc_len, afext_bytes));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdesc = (char *) af_extension+2;",
"\t\t\t\tbs = gf_bs_new(desc, desc_len, GF_BITSTREAM_READ);\n\t\t\t\tswitch (desc_tag) {\n\t\t\t\tcase GF_M2TS_AFDESC_LOCATION_DESCRIPTOR:\n\t\t\t\t{\n\t\t\t\t\tBool use_base_temi_url;\n\t\t\t\t\tchar URL[255];\n\t\t\t\t\tGF_M2TS_TemiLocationDescriptor temi_loc;\n\t\t\t\t\tmemset(&temi_loc, 0, sizeof(GF_M2TS_TemiLocationDescriptor) );\n\t\t\t\t\ttemi_loc.reload_external = gf_bs_read_int(bs, 1);\n\t\t\t\t\ttemi_loc.is_announce = gf_bs_read_int(bs, 1);\n\t\t\t\t\ttemi_loc.is_splicing = gf_bs_read_int(bs, 1);\n\t\t\t\t\tuse_base_temi_url = gf_bs_read_int(bs, 1);\n\t\t\t\t\tgf_bs_read_int(bs, 5); //reserved\n\t\t\t\t\ttemi_loc.timeline_id = gf_bs_read_int(bs, 7);\n\t\t\t\t\tif (!use_base_temi_url) {\n\t\t\t\t\t\tchar *_url = URL;\n\t\t\t\t\t\tu8 scheme = gf_bs_read_int(bs, 8);\n\t\t\t\t\t\tu8 url_len = gf_bs_read_int(bs, 8);\n\t\t\t\t\t\tswitch (scheme) {\n\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\t\tstrcpy(URL, \"http://\");\n\t\t\t\t\t\t\t_url = URL+7;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\tstrcpy(URL, \"https://\");\n\t\t\t\t\t\t\t_url = URL+8;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgf_bs_read_data(bs, _url, url_len);\n\t\t\t\t\t\t_url[url_len] = 0;\n\t\t\t\t\t}\n\t\t\t\t\ttemi_loc.external_URL = URL;",
"\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d AF Location descriptor found - URL %s\\n\", pid, URL));\n\t\t\t\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TEMI_LOCATION, &temi_loc);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_AFDESC_TIMELINE_DESCRIPTOR:\n\t\t\t\t\tif (ts->ess[pid] && (ts->ess[pid]->flags & GF_M2TS_ES_IS_PES)) {\n\t\t\t\t\t\tGF_M2TS_PES *pes = (GF_M2TS_PES *) ts->ess[pid];",
"\t\t\t\t\t\tif (pes->temi_tc_desc_len)\n\t\t\t\t\t\t\tgf_m2ts_store_temi(ts, pes);",
"\t\t\t\t\t\tif (pes->temi_tc_desc_alloc_size < desc_len) {\n\t\t\t\t\t\t\tpes->temi_tc_desc = gf_realloc(pes->temi_tc_desc, desc_len);\n\t\t\t\t\t\t\tpes->temi_tc_desc_alloc_size = desc_len;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(pes->temi_tc_desc, desc, desc_len);\n\t\t\t\t\t\tpes->temi_tc_desc_len = desc_len;",
"\t\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d AF Timeline descriptor found\\n\", pid));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tgf_bs_del(bs);",
"\t\t\t\taf_extension += 2+desc_len;\n\t\t\t\tafext_bytes -= 2+desc_len;\n\t\t\t}",
"\t\t}\n\t}",
"\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Adaptation Field found: Discontinuity %d - RAP %d - PCR: \"LLD\"\\n\", pid, paf->discontinuity_indicator, paf->random_access_indicator, paf->PCR_flag ? paf->PCR_base * 300 + paf->PCR_ext : 0));\n}",
"static GF_Err gf_m2ts_process_packet(GF_M2TS_Demuxer *ts, unsigned char *data)\n{\n\tGF_M2TS_ES *es;\n\tGF_M2TS_Header hdr;\n\tGF_M2TS_AdaptationField af, *paf;\n\tu32 payload_size, af_size;\n\tu32 pos = 0;",
"\tts->pck_number++;",
"\t/* read TS packet header*/\n\thdr.sync = data[0];\n\tif (hdr.sync != 0x47) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d does not start with sync marker\\n\", ts->pck_number));\n\t\treturn GF_CORRUPTED_DATA;\n\t}\n\thdr.error = (data[1] & 0x80) ? 1 : 0;\n\thdr.payload_start = (data[1] & 0x40) ? 1 : 0;\n\thdr.priority = (data[1] & 0x20) ? 1 : 0;\n\thdr.pid = ( (data[1]&0x1f) << 8) | data[2];\n\thdr.scrambling_ctrl = (data[3] >> 6) & 0x3;\n\thdr.adaptation_field = (data[3] >> 4) & 0x3;\n\thdr.continuity_counter = data[3] & 0xf;",
"\tif (hdr.error) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d has error (PID could be %d)\\n\", ts->pck_number, hdr.pid));\n\t\treturn GF_CORRUPTED_DATA;\n\t}\n//#if DEBUG_TS_PACKET\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d PID %d CC %d Encrypted %d\\n\", ts->pck_number, hdr.pid, hdr.continuity_counter, hdr.scrambling_ctrl));\n//#endif",
"\tif (hdr.scrambling_ctrl) {\n\t\t//TODO add decyphering\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d is scrambled - not supported\\n\", ts->pck_number, hdr.pid));\n\t\treturn GF_NOT_SUPPORTED;\n\t}",
"\tpaf = NULL;\n\tpayload_size = 184;\n\tpos = 4;\n\tswitch (hdr.adaptation_field) {\n\t/*adaptation+data*/\n\tcase 3:\n\t\taf_size = data[4];\n\t\tif (af_size>183) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d AF field larger than 183 !\\n\", ts->pck_number));\n\t\t\t//error\n\t\t\treturn GF_CORRUPTED_DATA;\n\t\t}\n\t\tpaf = ⁡\n\t\tmemset(paf, 0, sizeof(GF_M2TS_AdaptationField));\n\t\t//this will stop you when processing invalid (yet existing) mpeg2ts streams in debug\n\t\tassert( af_size<=183);\n\t\tif (af_size>183)\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d Detected wrong adaption field size %u when control value is 3\\n\", ts->pck_number, af_size));\n\t\tif (af_size) gf_m2ts_get_adaptation_field(ts, paf, data+5, af_size, hdr.pid);\n\t\tpos += 1+af_size;\n\t\tpayload_size = 183 - af_size;\n\t\tbreak;\n\t/*adaptation only - still process in case of PCR*/\n\tcase 2:\n\t\taf_size = data[4];\n\t\tif (af_size != 183) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d AF size is %d when it must be 183 for AF type 2\\n\", ts->pck_number, af_size));\n\t\t\treturn GF_CORRUPTED_DATA;\n\t\t}\n\t\tpaf = ⁡\n\t\tmemset(paf, 0, sizeof(GF_M2TS_AdaptationField));\n\t\tgf_m2ts_get_adaptation_field(ts, paf, data+5, af_size, hdr.pid);\n\t\tpayload_size = 0;\n\t\t/*no payload and no PCR, return*/\n\t\tif (!paf->PCR_flag)\n\t\t\treturn GF_OK;\n\t\tbreak;\n\t/*reserved*/\n\tcase 0:\n\t\treturn GF_OK;\n\tdefault:\n\t\tbreak;\n\t}\n\tdata += pos;",
"\t/*PAT*/\n\tif (hdr.pid == GF_M2TS_PID_PAT) {\n\t\tgf_m2ts_gather_section(ts, ts->pat, NULL, &hdr, data, payload_size);\n\t\treturn GF_OK;\n\t} else if (hdr.pid == GF_M2TS_PID_CAT) {\n\t\tgf_m2ts_gather_section(ts, ts->cat, NULL, &hdr, data, payload_size);\n\t\treturn GF_OK;\n\t}",
"\tes = ts->ess[hdr.pid];\n\tif (paf && paf->PCR_flag) {\n\t\tif (!es) {\n\t\t\tu32 i, j;\n\t\t\tfor(i=0; i<gf_list_count(ts->programs); i++) {\n\t\t\t\tGF_M2TS_PES *first_pes = NULL;\n\t\t\t\tGF_M2TS_Program *program = (GF_M2TS_Program *)gf_list_get(ts->programs,i);\n\t\t\t\tif(program->pcr_pid != hdr.pid) continue;\n\t\t\t\tfor (j=0; j<gf_list_count(program->streams); j++) {\n\t\t\t\t\tGF_M2TS_PES *pes = (GF_M2TS_PES *) gf_list_get(program->streams, j);\n\t\t\t\t\tif (pes->flags & GF_M2TS_INHERIT_PCR) {\n\t\t\t\t\t\tts->ess[hdr.pid] = (GF_M2TS_ES *) pes;\n\t\t\t\t\t\tpes->flags |= GF_M2TS_FAKE_PCR;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (pes->flags & GF_M2TS_ES_IS_PES) {\n\t\t\t\t\t\tfirst_pes = pes;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//non found, use the first media stream as a PCR destination - Q: is it legal to have PCR only streams not declared in PMT ?\n\t\t\t\tif (!es && first_pes) {\n\t\t\t\t\tes = (GF_M2TS_ES *) first_pes;\n\t\t\t\t\tfirst_pes->flags |= GF_M2TS_FAKE_PCR;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!es)\n\t\t\t\tes = ts->ess[hdr.pid];\n\t\t}\n\t\tif (es) {\n\t\t\tGF_M2TS_PES_PCK pck;\n\t\t\ts64 prev_diff_in_us;\n\t\t\tBool discontinuity;\n\t\t\ts32 cc = -1;",
"\t\t\tif (es->flags & GF_M2TS_FAKE_PCR) {\n\t\t\t\tcc = es->program->pcr_cc;\n\t\t\t\tes->program->pcr_cc = hdr.continuity_counter;\n\t\t\t}\n\t\t\telse if (es->flags & GF_M2TS_ES_IS_PES) cc = ((GF_M2TS_PES*)es)->cc;\n\t\t\telse if (((GF_M2TS_SECTION_ES*)es)->sec) cc = ((GF_M2TS_SECTION_ES*)es)->sec->cc;",
"\t\t\tdiscontinuity = paf->discontinuity_indicator;\n\t\t\tif ((cc>=0) && es->program->before_last_pcr_value) {\n\t\t\t\t//no increment of CC if AF only packet\n\t\t\t\tif (hdr.adaptation_field == 2) {\n\t\t\t\t\tif (hdr.continuity_counter != cc) {\n\t\t\t\t\t\tdiscontinuity = GF_TRUE;\n\t\t\t\t\t}\n\t\t\t\t} else if (hdr.continuity_counter != ((cc + 1) & 0xF)) {\n\t\t\t\t\tdiscontinuity = GF_TRUE;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tmemset(&pck, 0, sizeof(GF_M2TS_PES_PCK));\n\t\t\tprev_diff_in_us = (s64) (es->program->last_pcr_value /27- es->program->before_last_pcr_value/27);\n\t\t\tes->program->before_last_pcr_value = es->program->last_pcr_value;\n\t\t\tes->program->before_last_pcr_value_pck_number = es->program->last_pcr_value_pck_number;\n\t\t\tes->program->last_pcr_value_pck_number = ts->pck_number;\n\t\t\tes->program->last_pcr_value = paf->PCR_base * 300 + paf->PCR_ext;\n\t\t\tif (!es->program->last_pcr_value) es->program->last_pcr_value = 1;",
"\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR found \"LLU\" (\"LLU\" at 90kHz) - PCR diff is %d us\\n\", hdr.pid, es->program->last_pcr_value, es->program->last_pcr_value/300, (s32) (es->program->last_pcr_value - es->program->before_last_pcr_value)/27 ));",
"\t\t\tpck.PTS = es->program->last_pcr_value;\n\t\t\tpck.stream = (GF_M2TS_PES *)es;",
"\t\t\t//try to ignore all discontinuities that are less than 200 ms (seen in some HLS setup ...)\n\t\t\tif (discontinuity) {\n\t\t\t\ts64 diff_in_us = (s64) (es->program->last_pcr_value - es->program->before_last_pcr_value) / 27;\n\t\t\t\tu64 diff = ABS(diff_in_us - prev_diff_in_us);",
"\t\t\t\tif ((diff_in_us<0) && (diff_in_us >= -200000)) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d new PCR, with discontinuity signaled, is less than previously received PCR (diff %d us) but not too large, trying to ignore discontinuity\\n\", hdr.pid, diff_in_us));\n\t\t\t\t}",
"\t\t\t\t//ignore PCR discontinuity indicator if PCR found is larger than previously received PCR and diffence between PCR before and after discontinuity indicator is smaller than 50ms\n\t\t\t\telse if ((diff_in_us > 0) && (diff < 200000)) {\n\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR discontinuity signaled but diff is small (diff %d us - PCR diff %d vs prev PCR diff %d) - ignore it\\n\", hdr.pid, diff, diff_in_us, prev_diff_in_us));\n\t\t\t\t} else if (paf->discontinuity_indicator) {\n\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR discontinuity signaled (diff %d us - PCR diff %d vs prev PCR diff %d)\\n\", hdr.pid, diff, diff_in_us, prev_diff_in_us));\n\t\t\t\t\tpck.flags = GF_M2TS_PES_PCK_DISCONTINUITY;\n\t\t\t\t} else {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR discontinuity not signaled (diff %d us - PCR diff %d vs prev PCR diff %d)\\n\", hdr.pid, diff, diff_in_us, prev_diff_in_us));\n\t\t\t\t\tpck.flags = GF_M2TS_PES_PCK_DISCONTINUITY;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( (es->program->last_pcr_value < es->program->before_last_pcr_value) ) {\n\t\t\t\ts64 diff_in_us = (s64) (es->program->last_pcr_value - es->program->before_last_pcr_value) / 27;\n\t\t\t\t//if less than 200 ms before PCR loop at the last PCR, this is a PCR loop\n\t\t\t\tif (GF_M2TS_MAX_PCR - es->program->before_last_pcr_value < 5400000 /*2*2700000*/) {\n\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR loop found from \"LLU\" to \"LLU\" \\n\", hdr.pid, es->program->before_last_pcr_value, es->program->last_pcr_value));\n\t\t\t\t} else if ((diff_in_us<0) && (diff_in_us >= -200000)) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d new PCR, without discontinuity signaled, is less than previously received PCR (diff %d us) but not too large, trying to ignore discontinuity\\n\", hdr.pid, diff_in_us));\n\t\t\t\t} else {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR found \"LLU\" is less than previously received PCR \"LLU\" (PCR diff %g sec) but no discontinuity signaled\\n\", hdr.pid, es->program->last_pcr_value, es->program->before_last_pcr_value, (GF_M2TS_MAX_PCR - es->program->before_last_pcr_value + es->program->last_pcr_value) / 27000000.0));",
"\t\t\t\t\tpck.flags = GF_M2TS_PES_PCK_DISCONTINUITY;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tif (pck.flags & GF_M2TS_PES_PCK_DISCONTINUITY) {\n\t\t\t\tgf_m2ts_reset_parsers_for_program(ts, es->program);\n\t\t\t}",
"\t\t\tif (ts->on_event) {\n\t\t\t\tts->on_event(ts, GF_M2TS_EVT_PES_PCR, &pck);\n\t\t\t}\n\t\t}\n\t}",
"\t/*check for DVB reserved PIDs*/\n\tif (!es) {\n\t\tif (hdr.pid == GF_M2TS_PID_SDT_BAT_ST) {\n\t\t\tgf_m2ts_gather_section(ts, ts->sdt, NULL, &hdr, data, payload_size);\n\t\t\treturn GF_OK;\n\t\t} else if (hdr.pid == GF_M2TS_PID_NIT_ST) {\n\t\t\t/*ignore them, unused at application level*/\n\t\t\tgf_m2ts_gather_section(ts, ts->nit, NULL, &hdr, data, payload_size);\n\t\t\treturn GF_OK;\n\t\t} else if (hdr.pid == GF_M2TS_PID_EIT_ST_CIT) {\n\t\t\t/* ignore EIT messages for the moment */\n\t\t\tgf_m2ts_gather_section(ts, ts->eit, NULL, &hdr, data, payload_size);\n\t\t\treturn GF_OK;\n\t\t} else if (hdr.pid == GF_M2TS_PID_TDT_TOT_ST) {\n\t\t\tgf_m2ts_gather_section(ts, ts->tdt_tot, NULL, &hdr, data, payload_size);\n\t\t} else {\n\t\t\t/* ignore packet */\n\t\t}\n\t} else if (es->flags & GF_M2TS_ES_IS_SECTION) { \t/* The stream uses sections to carry its payload */\n\t\tGF_M2TS_SECTION_ES *ses = (GF_M2TS_SECTION_ES *)es;\n\t\tif (ses->sec) gf_m2ts_gather_section(ts, ses->sec, ses, &hdr, data, payload_size);\n\t} else {\n\t\tGF_M2TS_PES *pes = (GF_M2TS_PES *)es;\n\t\t/* regular stream using PES packets */\n\t\tif (pes->reframe && payload_size) gf_m2ts_process_pes(ts, pes, &hdr, data, payload_size, paf);\n\t}",
"\treturn GF_OK;\n}",
"GF_EXPORT\nGF_Err gf_m2ts_process_data(GF_M2TS_Demuxer *ts, u8 *data, u32 data_size)\n{\n\tGF_Err e=GF_OK;\n\tu32 pos, pck_size;\n\tBool is_align = 1;",
"\tif (ts->buffer_size) {\n\t\t//we are sync, copy remaining bytes\n\t\tif ( (ts->buffer[0]==0x47) && (ts->buffer_size<200)) {\n\t\t\tu32 pck_size = ts->prefix_present ? 192 : 188;",
"\t\t\tif (ts->alloc_size < 200) {\n\t\t\t\tts->alloc_size = 200;\n\t\t\t\tts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*ts->alloc_size);\n\t\t\t}\n\t\t\tmemcpy(ts->buffer + ts->buffer_size, data, pck_size - ts->buffer_size);\n\t\t\te |= gf_m2ts_process_packet(ts, (unsigned char *)ts->buffer);\n\t\t\tdata += (pck_size - ts->buffer_size);\n\t\t\tdata_size = data_size - (pck_size - ts->buffer_size);\n\t\t}\n\t\t//not sync, copy over the complete buffer\n\t\telse {\n\t\t\tif (ts->alloc_size < ts->buffer_size+data_size) {\n\t\t\t\tts->alloc_size = ts->buffer_size+data_size;\n\t\t\t\tts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*ts->alloc_size);\n\t\t\t}\n\t\t\tmemcpy(ts->buffer + ts->buffer_size, data, sizeof(char)*data_size);\n\t\t\tts->buffer_size += data_size;\n\t\t\tis_align = 0;\n\t\t\tdata = ts->buffer;\n\t\t\tdata_size = ts->buffer_size;\n\t\t}\n\t}",
"\t/*sync input data*/\n\tpos = gf_m2ts_sync(ts, data, data_size, is_align);\n\tif (pos==data_size) {\n\t\tif (is_align) {\n\t\t\tif (ts->alloc_size<data_size) {\n\t\t\t\tts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*data_size);\n\t\t\t\tts->alloc_size = data_size;\n\t\t\t}\n\t\t\tmemcpy(ts->buffer, data, sizeof(char)*data_size);\n\t\t\tts->buffer_size = data_size;\n\t\t}\n\t\treturn GF_OK;\n\t}\n\tpck_size = ts->prefix_present ? 192 : 188;\n\tfor (;;) {\n\t\t/*wait for a complete packet*/\n\t\tif (data_size < pos + pck_size) {\n\t\t\tts->buffer_size = data_size - pos;\n\t\t\tdata += pos;\n\t\t\tif (!ts->buffer_size) {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t\tassert(ts->buffer_size<pck_size);",
"\t\t\tif (is_align) {\n\t\t\t\tu32 s = ts->buffer_size;\n\t\t\t\tif (s<200) s = 200;",
"\t\t\t\tif (ts->alloc_size < s) {\n\t\t\t\t\tts->alloc_size = s;\n\t\t\t\t\tts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*ts->alloc_size);\n\t\t\t\t}\n\t\t\t\tmemcpy(ts->buffer, data, sizeof(char)*ts->buffer_size);\n\t\t\t} else {\n\t\t\t\tmemmove(ts->buffer, data, sizeof(char)*ts->buffer_size);\n\t\t\t}\n\t\t\treturn e;\n\t\t}\n\t\t/*process*/\n\t\te |= gf_m2ts_process_packet(ts, (unsigned char *)data + pos);\n\t\tpos += pck_size;\n\t}\n\treturn e;\n}",
"//unused\n#if 0\nGF_ESD *gf_m2ts_get_esd(GF_M2TS_ES *es)\n{\n\tGF_ESD *esd;\n\tu32 k, esd_count;",
"\tesd = NULL;\n\tif (es->program->pmt_iod && es->program->pmt_iod->ESDescriptors) {\n\t\tesd_count = gf_list_count(es->program->pmt_iod->ESDescriptors);\n\t\tfor (k = 0; k < esd_count; k++) {\n\t\t\tGF_ESD *esd_tmp = (GF_ESD *)gf_list_get(es->program->pmt_iod->ESDescriptors, k);\n\t\t\tif (esd_tmp->ESID != es->mpeg4_es_id) continue;\n\t\t\tesd = esd_tmp;\n\t\t\tbreak;\n\t\t}\n\t}",
"\tif (!esd && es->program->additional_ods) {\n\t\tu32 od_count, od_index;\n\t\tod_count = gf_list_count(es->program->additional_ods);\n\t\tfor (od_index = 0; od_index < od_count; od_index++) {\n\t\t\tGF_ObjectDescriptor *od = (GF_ObjectDescriptor *)gf_list_get(es->program->additional_ods, od_index);\n\t\t\tesd_count = gf_list_count(od->ESDescriptors);\n\t\t\tfor (k = 0; k < esd_count; k++) {\n\t\t\t\tGF_ESD *esd_tmp = (GF_ESD *)gf_list_get(od->ESDescriptors, k);\n\t\t\t\tif (esd_tmp->ESID != es->mpeg4_es_id) continue;\n\t\t\t\tesd = esd_tmp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}",
"\treturn esd;\n}\nvoid gf_m2ts_set_segment_switch(GF_M2TS_Demuxer *ts)\n{\n\tu32 i;\n\tfor (i=0; i<GF_M2TS_MAX_STREAMS; i++) {\n\t\tGF_M2TS_ES *es = (GF_M2TS_ES *) ts->ess[i];\n\t\tif (!es) continue;\n\t\tes->flags |= GF_M2TS_ES_IGNORE_NEXT_DISCONTINUITY;\n\t}\n}",
"\n#endif",
"\nGF_EXPORT\nvoid gf_m2ts_reset_parsers_for_program(GF_M2TS_Demuxer *ts, GF_M2TS_Program *prog)\n{\n\tu32 i;",
"\tfor (i=0; i<GF_M2TS_MAX_STREAMS; i++) {\n\t\tGF_M2TS_ES *es = (GF_M2TS_ES *) ts->ess[i];\n\t\tif (!es) continue;\n\t\tif (prog && (es->program != prog) ) continue;",
"\t\tif (es->flags & GF_M2TS_ES_IS_SECTION) {\n\t\t\tGF_M2TS_SECTION_ES *ses = (GF_M2TS_SECTION_ES *)es;\n\t\t\tgf_m2ts_section_filter_reset(ses->sec);\n\t\t} else {\n\t\t\tGF_M2TS_PES *pes = (GF_M2TS_PES *)es;\n\t\t\tif (!pes || (pes->pid==pes->program->pmt_pid)) continue;\n\t\t\tpes->cc = -1;\n\t\t\tpes->frame_state = 0;\n\t\t\tpes->pck_data_len = 0;\n\t\t\tif (pes->prev_data) gf_free(pes->prev_data);\n\t\t\tpes->prev_data = NULL;\n\t\t\tpes->prev_data_len = 0;\n\t\t\tpes->PTS = pes->DTS = 0;\n//\t\t\tpes->prev_PTS = 0;\n//\t\t\tpes->first_dts = 0;\n\t\t\tpes->pes_len = pes->pes_end_packet_number = pes->pes_start_packet_number = 0;\n\t\t\tif (pes->buf) gf_free(pes->buf);\n\t\t\tpes->buf = NULL;\n\t\t\tif (pes->temi_tc_desc) gf_free(pes->temi_tc_desc);\n\t\t\tpes->temi_tc_desc = NULL;\n\t\t\tpes->temi_tc_desc_len = pes->temi_tc_desc_alloc_size = 0;",
"\t\t\tpes->before_last_pcr_value = pes->before_last_pcr_value_pck_number = 0;\n\t\t\tpes->last_pcr_value = pes->last_pcr_value_pck_number = 0;\n\t\t\tif (pes->program->pcr_pid==pes->pid) {\n\t\t\t\tpes->program->last_pcr_value = pes->program->last_pcr_value_pck_number = 0;\n\t\t\t\tpes->program->before_last_pcr_value = pes->program->before_last_pcr_value_pck_number = 0;\n\t\t\t}\n\t\t}\n\t}\n}",
"GF_EXPORT\nvoid gf_m2ts_reset_parsers(GF_M2TS_Demuxer *ts)\n{\n\tgf_m2ts_reset_parsers_for_program(ts, NULL);",
"\tts->pck_number = 0;",
"\tgf_m2ts_section_filter_reset(ts->cat);\n\tgf_m2ts_section_filter_reset(ts->pat);\n\tgf_m2ts_section_filter_reset(ts->sdt);\n\tgf_m2ts_section_filter_reset(ts->nit);\n\tgf_m2ts_section_filter_reset(ts->eit);\n\tgf_m2ts_section_filter_reset(ts->tdt_tot);",
"}",
"\n#if 0 //unused\nu32 gf_m2ts_pes_get_framing_mode(GF_M2TS_PES *pes)\n{\n\tif (pes->flags & GF_M2TS_ES_IS_SECTION) {\n\t\tif (pes->flags & GF_M2TS_ES_IS_SL) {\n\t\t\tif ( ((GF_M2TS_SECTION_ES *)pes)->sec->process_section == NULL)\n\t\t\t\treturn GF_M2TS_PES_FRAMING_DEFAULT;",
"\t\t}\n\t\treturn GF_M2TS_PES_FRAMING_SKIP_NO_RESET;\n\t}",
"\tif (!pes->reframe ) return GF_M2TS_PES_FRAMING_SKIP_NO_RESET;\n\tif (pes->reframe == gf_m2ts_reframe_default) return GF_M2TS_PES_FRAMING_RAW;\n\tif (pes->reframe == gf_m2ts_reframe_reset) return GF_M2TS_PES_FRAMING_SKIP;\n\treturn GF_M2TS_PES_FRAMING_DEFAULT;\n}\n#endif",
"\nGF_EXPORT\nGF_Err gf_m2ts_set_pes_framing(GF_M2TS_PES *pes, u32 mode)\n{\n\tif (!pes) return GF_BAD_PARAM;",
"\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Setting pes framing mode of PID %d to %d\\n\", pes->pid, mode) );\n\t/*ignore request for section PIDs*/\n\tif (pes->flags & GF_M2TS_ES_IS_SECTION) {\n\t\tif (pes->flags & GF_M2TS_ES_IS_SL) {\n\t\t\tif (mode==GF_M2TS_PES_FRAMING_DEFAULT) {\n\t\t\t\t((GF_M2TS_SECTION_ES *)pes)->sec->process_section = gf_m2ts_process_mpeg4section;\n\t\t\t} else {\n\t\t\t\t((GF_M2TS_SECTION_ES *)pes)->sec->process_section = NULL;\n\t\t\t}\n\t\t}\n\t\treturn GF_OK;\n\t}",
"\tif (pes->pid==pes->program->pmt_pid) return GF_BAD_PARAM;",
"\t//if component reuse, disable previous pes\n\tif ((mode > GF_M2TS_PES_FRAMING_SKIP) && (pes->program->ts->ess[pes->pid] != (GF_M2TS_ES *) pes)) {\n\t\tGF_M2TS_PES *o_pes = (GF_M2TS_PES *) pes->program->ts->ess[pes->pid];\n\t\tif (o_pes->flags & GF_M2TS_ES_IS_PES)\n\t\t\tgf_m2ts_set_pes_framing(o_pes, GF_M2TS_PES_FRAMING_SKIP);",
"\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Reassinging PID %d from program %d to program %d\\n\", pes->pid, o_pes->program->number, pes->program->number) );\n\t\tpes->program->ts->ess[pes->pid] = (GF_M2TS_ES *) pes;\n\t}",
"\tswitch (mode) {\n\tcase GF_M2TS_PES_FRAMING_RAW:\n\t\tpes->reframe = gf_m2ts_reframe_default;\n\t\tbreak;\n\tcase GF_M2TS_PES_FRAMING_SKIP:\n\t\tpes->reframe = gf_m2ts_reframe_reset;\n\t\tbreak;\n\tcase GF_M2TS_PES_FRAMING_SKIP_NO_RESET:\n\t\tpes->reframe = NULL;\n\t\tbreak;\n\tcase GF_M2TS_PES_FRAMING_DEFAULT:\n\tdefault:\n\t\tswitch (pes->stream_type) {\n\t\tcase GF_M2TS_VIDEO_MPEG1:\n\t\tcase GF_M2TS_VIDEO_MPEG2:\n\t\tcase GF_M2TS_VIDEO_H264:\n\t\tcase GF_M2TS_VIDEO_SVC:\n\t\tcase GF_M2TS_VIDEO_HEVC:\n\t\tcase GF_M2TS_VIDEO_HEVC_TEMPORAL:\n\t\tcase GF_M2TS_VIDEO_HEVC_MCTS:\n\t\tcase GF_M2TS_VIDEO_SHVC:\n\t\tcase GF_M2TS_VIDEO_SHVC_TEMPORAL:\n\t\tcase GF_M2TS_VIDEO_MHVC:\n\t\tcase GF_M2TS_VIDEO_MHVC_TEMPORAL:\n\t\tcase GF_M2TS_AUDIO_MPEG1:\n\t\tcase GF_M2TS_AUDIO_MPEG2:\n\t\tcase GF_M2TS_AUDIO_AAC:\n\t\tcase GF_M2TS_AUDIO_LATM_AAC:\n\t\tcase GF_M2TS_AUDIO_AC3:\n\t\tcase GF_M2TS_AUDIO_EC3:\n\t\t\t//for all our supported codec types, use a reframer filter\n\t\t\tpes->reframe = gf_m2ts_reframe_default;\n\t\t\tbreak;",
"\t\tcase GF_M2TS_PRIVATE_DATA:\n\t\t\t/* TODO: handle DVB subtitle streams */\n\t\t\tbreak;\n\t\tcase GF_M2TS_METADATA_ID3_HLS:\n\t\t\t//TODO\n\t\t\tpes->reframe = gf_m2ts_reframe_id3_pes;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tpes->reframe = gf_m2ts_reframe_default;\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\t}\n\treturn GF_OK;\n}",
"GF_EXPORT\nGF_M2TS_Demuxer *gf_m2ts_demux_new()\n{\n\tGF_M2TS_Demuxer *ts;",
"\tGF_SAFEALLOC(ts, GF_M2TS_Demuxer);\n\tif (!ts) return NULL;\n\tts->programs = gf_list_new();\n\tts->SDTs = gf_list_new();",
"\tts->pat = gf_m2ts_section_filter_new(gf_m2ts_process_pat, 0);\n\tts->cat = gf_m2ts_section_filter_new(gf_m2ts_process_cat, 0);\n\tts->sdt = gf_m2ts_section_filter_new(gf_m2ts_process_sdt, 1);\n\tts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0);\n\tts->eit = gf_m2ts_section_filter_new(NULL/*gf_m2ts_process_eit*/, 1);\n\tts->tdt_tot = gf_m2ts_section_filter_new(gf_m2ts_process_tdt_tot, 1);",
"#ifdef GPAC_ENABLE_MPE\n\tgf_dvb_mpe_init(ts);\n#endif",
"\tts->nb_prog_pmt_received = 0;\n\tts->ChannelAppList = gf_list_new();\n\treturn ts;\n}",
"GF_EXPORT\nvoid gf_m2ts_demux_dmscc_init(GF_M2TS_Demuxer *ts) {",
"\tchar temp_dir[GF_MAX_PATH];\n\tu32 length;\n\tGF_Err e;",
"\tts->dsmcc_controler = gf_list_new();\n\tts->process_dmscc = 1;",
"\tstrcpy(temp_dir, gf_get_default_cache_directory() );\n\tlength = (u32) strlen(temp_dir);\n\tif(temp_dir[length-1] == GF_PATH_SEPARATOR) {\n\t\ttemp_dir[length-1] = 0;\n\t}",
"\tts->dsmcc_root_dir = (char*)gf_calloc(strlen(temp_dir)+strlen(\"CarouselData\")+2,sizeof(char));\n\tsprintf(ts->dsmcc_root_dir,\"%s%cCarouselData\",temp_dir,GF_PATH_SEPARATOR);\n\te = gf_mkdir(ts->dsmcc_root_dir);\n\tif(e) {\n\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[Process DSMCC] Error during the creation of the directory %s \\n\",ts->dsmcc_root_dir));\n\t}",
"}",
"GF_EXPORT\nvoid gf_m2ts_demux_del(GF_M2TS_Demuxer *ts)\n{\n\tu32 i;\n\tif (ts->pat) gf_m2ts_section_filter_del(ts->pat);\n\tif (ts->cat) gf_m2ts_section_filter_del(ts->cat);\n\tif (ts->sdt) gf_m2ts_section_filter_del(ts->sdt);\n\tif (ts->nit) gf_m2ts_section_filter_del(ts->nit);\n\tif (ts->eit) gf_m2ts_section_filter_del(ts->eit);\n\tif (ts->tdt_tot) gf_m2ts_section_filter_del(ts->tdt_tot);",
"\tfor (i=0; i<GF_M2TS_MAX_STREAMS; i++) {\n\t\t//bacause of pure PCR streams, en ES might be reassigned on 2 PIDs, one for the ES and one for the PCR\n\t\tif (ts->ess[i] && (ts->ess[i]->pid==i)) gf_m2ts_es_del(ts->ess[i], ts);\n\t}\n\tif (ts->buffer) gf_free(ts->buffer);\n\twhile (gf_list_count(ts->programs)) {\n\t\tGF_M2TS_Program *p = (GF_M2TS_Program *)gf_list_last(ts->programs);\n\t\tgf_list_rem_last(ts->programs);\n\t\tgf_list_del(p->streams);\n\t\t/*reset OD list*/\n\t\tif (p->additional_ods) {\n\t\t\tgf_odf_desc_list_del(p->additional_ods);\n\t\t\tgf_list_del(p->additional_ods);\n\t\t}\n\t\tif (p->pmt_iod) gf_odf_desc_del((GF_Descriptor *)p->pmt_iod);\n\t\tif (p->metadata_pointer_descriptor)\tgf_m2ts_metadata_pointer_descriptor_del(p->metadata_pointer_descriptor);\n\t\tgf_free(p);\n\t}\n\tgf_list_del(ts->programs);",
"\tif (ts->TDT_time) gf_free(ts->TDT_time);\n\tgf_m2ts_reset_sdt(ts);\n\tif (ts->tdt_tot)\n\t\tgf_list_del(ts->SDTs);",
"#ifdef GPAC_ENABLE_MPE\n\tgf_dvb_mpe_shutdown(ts);\n#endif",
"\tif (ts->dsmcc_controler) {\n\t\tif (gf_list_count(ts->dsmcc_controler)) {\n#ifdef GPAC_ENABLE_DSMCC\n\t\t\tGF_M2TS_DSMCC_OVERLORD* dsmcc_overlord = (GF_M2TS_DSMCC_OVERLORD*)gf_list_get(ts->dsmcc_controler,0);\n\t\t\tgf_cleanup_dir(dsmcc_overlord->root_dir);\n\t\t\tgf_rmdir(dsmcc_overlord->root_dir);\n\t\t\tgf_m2ts_delete_dsmcc_overlord(dsmcc_overlord);\n\t\t\tif(ts->dsmcc_root_dir) {\n\t\t\t\tgf_free(ts->dsmcc_root_dir);\n\t\t\t}\n#endif\n\t\t}\n\t\tgf_list_del(ts->dsmcc_controler);\n\t}",
"\twhile(gf_list_count(ts->ChannelAppList)) {\n#ifdef GPAC_ENABLE_DSMCC\n\t\tGF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo = (GF_M2TS_CHANNEL_APPLICATION_INFO*)gf_list_get(ts->ChannelAppList,0);\n\t\tgf_m2ts_delete_channel_application_info(ChanAppInfo);\n\t\tgf_list_rem(ts->ChannelAppList,0);\n#endif\n\t}\n\tgf_list_del(ts->ChannelAppList);",
"\tif (ts->dsmcc_root_dir) gf_free(ts->dsmcc_root_dir);\n\tgf_free(ts);\n}",
"#if 0//unused\nvoid gf_m2ts_print_info(GF_M2TS_Demuxer *ts)\n{\n#ifdef GPAC_ENABLE_MPE\n\tgf_m2ts_print_mpe_info(ts);\n#endif\n}\n#endif",
"",
"#define M2TS_PROBE_SIZE\t188000\nstatic Bool gf_m2ts_probe_buffer(char *buf, u32 size)\n{\n\tGF_Err e;\n\tGF_M2TS_Demuxer *ts;\n\tu32 lt;",
"\tlt = gf_log_get_tool_level(GF_LOG_CONTAINER);\n\tgf_log_set_tool_level(GF_LOG_CONTAINER, GF_LOG_QUIET);",
"\tts = gf_m2ts_demux_new();\n\te = gf_m2ts_process_data(ts, buf, size);\n\tif (!ts->pck_number) e = GF_BAD_PARAM;\n\tgf_m2ts_demux_del(ts);",
"\tgf_log_set_tool_level(GF_LOG_CONTAINER, lt);",
"\tif (e) return GF_FALSE;\n\treturn GF_TRUE;",
"}\nGF_EXPORT\nBool gf_m2ts_probe_file(const char *fileName)\n{\n\tchar buf[M2TS_PROBE_SIZE];\n\tu32 size;\n\tFILE *t;",
"\tif (!strncmp(fileName, \"gmem://\", 7)) {\n\t\tu8 *mem_address;\n\t\tif (gf_blob_get_data(fileName, &mem_address, &size) != GF_OK) {\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\tif (size>M2TS_PROBE_SIZE) size = M2TS_PROBE_SIZE;\n\t\tmemcpy(buf, mem_address, size);\n\t} else {\n\t\tt = gf_fopen(fileName, \"rb\");\n\t\tif (!t) return 0;\n\t\tsize = (u32) fread(buf, 1, M2TS_PROBE_SIZE, t);\n\t\tgf_fclose(t);\n\t\tif ((s32) size <= 0) return 0;\n\t}\n\treturn gf_m2ts_probe_buffer(buf, size);\n}",
"GF_EXPORT\nBool gf_m2ts_probe_data(const u8 *data, u32 size)\n{\n\tsize /= 188;\n\tsize *= 188;\n\treturn gf_m2ts_probe_buffer((char *) data, size);\n}",
"\nstatic void rewrite_pts_dts(unsigned char *ptr, u64 TS)\n{\n\tptr[0] &= 0xf1;\n\tptr[0] |= (unsigned char)((TS&0x1c0000000ULL)>>29);\n\tptr[1] = (unsigned char)((TS&0x03fc00000ULL)>>22);\n\tptr[2] &= 0x1;\n\tptr[2] |= (unsigned char)((TS&0x0003f8000ULL)>>14);\n\tptr[3] = (unsigned char)((TS&0x000007f80ULL)>>7);\n\tptr[4] &= 0x1;\n\tptr[4] |= (unsigned char)((TS&0x00000007fULL)<<1);",
"\tassert(((u64)(ptr[0]&0xe)<<29) + ((u64)ptr[1]<<22) + ((u64)(ptr[2]&0xfe)<<14) + ((u64)ptr[3]<<7) + ((ptr[4]&0xfe)>>1) == TS);\n}",
"#define ADJUST_TIMESTAMP(_TS) \\\n\tif (_TS < (u64) -ts_shift) _TS = pcr_mod + _TS + ts_shift; \\\n\telse _TS = _TS + ts_shift; \\\n\twhile (_TS > pcr_mod) _TS -= pcr_mod; \\",
"GF_EXPORT\nGF_Err gf_m2ts_restamp(u8 *buffer, u32 size, s64 ts_shift, u8 *is_pes)\n{\n\tu32 done = 0;\n\tu64 pcr_mod;\n//\tif (!ts_shift) return GF_OK;",
"\tpcr_mod = 0x80000000;\n\tpcr_mod*=4;\n\twhile (done + 188 <= size) {\n\t\tu8 *pesh;\n\t\tu8 *pck;\n\t\tu64 pcr_base=0, pcr_ext=0;\n\t\tu16 pid;\n\t\tu8 adaptation_field, adaptation_field_length;",
"\t\tpck = (u8*) buffer+done;\n\t\tif (pck[0]!=0x47) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[M2TS Restamp] Invalid sync byte %X\\n\", pck[0]));\n\t\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t\t}\n\t\tpid = ((pck[1] & 0x1f) <<8 ) + pck[2];",
"\t\tadaptation_field_length = 0;\n\t\tadaptation_field = (pck[3] >> 4) & 0x3;\n\t\tif ((adaptation_field==2) || (adaptation_field==3)) {\n\t\t\tadaptation_field_length = pck[4];\n\t\t\tif ( pck[5]&0x10 /*PCR_flag*/) {\n\t\t\t\tpcr_base = (((u64)pck[6])<<25) + (pck[7]<<17) + (pck[8]<<9) + (pck[9]<<1) + (pck[10]>>7);\n\t\t\t\tpcr_ext = ((pck[10]&1)<<8) + pck[11];",
"\t\t\t\tADJUST_TIMESTAMP(pcr_base);",
"\t\t\t\tpck[6] = (unsigned char)(0xff&(pcr_base>>25));\n\t\t\t\tpck[7] = (unsigned char)(0xff&(pcr_base>>17));\n\t\t\t\tpck[8] = (unsigned char)(0xff&(pcr_base>>9));\n\t\t\t\tpck[9] = (unsigned char)(0xff&(pcr_base>>1));\n\t\t\t\tpck[10] = (unsigned char)(((0x1&pcr_base)<<7) | 0x7e | ((0x100&pcr_ext)>>8));\n\t\t\t\tif (pcr_ext != ((pck[10]&1)<<8) + pck[11]) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[M2TS Restamp] Sanity check failed for PCR restamping\\n\"));\n\t\t\t\t\treturn GF_IO_ERR;\n\t\t\t\t}\n\t\t\t\tpck[11] = (unsigned char)(0xff&pcr_ext);\n\t\t\t}\n\t\t\t/*add adaptation_field_length field*/\n\t\t\tadaptation_field_length++;\n\t\t}\n\t\tif (!is_pes[pid] || !(pck[1]&0x40)) {\n\t\t\tdone+=188;\n\t\t\tcontinue;\n\t\t}",
"\t\tpesh = &pck[4+adaptation_field_length];",
"\t\tif ((pesh[0]==0x00) && (pesh[1]==0x00) && (pesh[2]==0x01)) {\n\t\t\tBool has_pts, has_dts;\n\t\t\tif ((pesh[6]&0xc0)!=0x80) {\n\t\t\t\tdone+=188;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\thas_pts = (pesh[7]&0x80);\n\t\t\thas_dts = has_pts ? (pesh[7]&0x40) : 0;",
"\t\t\tif (has_pts) {\n\t\t\t\tu64 PTS;\n\t\t\t\tif (((pesh[9]&0xe0)>>4)!=0x2) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[M2TS Restamp] PID %4d: Wrong PES header, PTS decoding: '0010' expected\\n\", pid));\n\t\t\t\t\tdone+=188;\n\t\t\t\t\tcontinue;\n\t\t\t\t}",
"\t\t\t\tPTS = gf_m2ts_get_pts(pesh + 9);\n\t\t\t\tADJUST_TIMESTAMP(PTS);\n\t\t\t\trewrite_pts_dts(pesh+9, PTS);\n\t\t\t}",
"\t\t\tif (has_dts) {\n\t\t\t\tu64 DTS = gf_m2ts_get_pts(pesh + 14);\n\t\t\t\tADJUST_TIMESTAMP(DTS);\n\t\t\t\trewrite_pts_dts(pesh+14, DTS);\n\t\t\t}\n\t\t} else {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[M2TS Restamp] PID %4d: Wrong PES not beginning with start code\\n\", pid));\n\t\t}\n\t\tdone+=188;\n\t}\n\treturn GF_OK;\n}",
"#endif /*GPAC_DISABLE_MPEG2TS*/"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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": [1176], "buggy_code_start_loc": [1155], "filenames": ["src/media_tools/mpegts.c"], "fixing_code_end_loc": [1184], "fixing_code_start_loc": [1155], "message": "An issue was discovered in libgpac.a in GPAC before 0.8.0, as demonstrated by MP4Box. It contains a Use-After-Free vulnerability in gf_m2ts_process_pmt in media_tools/mpegts.c that can cause a denial of service via a crafted MP4 file.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*", "matchCriteriaId": "123D0430-86B1-40BF-9B43-C782CC2EDDE8", "versionEndExcluding": "0.8.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "An issue was discovered in libgpac.a in GPAC before 0.8.0, as demonstrated by MP4Box. It contains a Use-After-Free vulnerability in gf_m2ts_process_pmt in media_tools/mpegts.c that can cause a denial of service via a crafted MP4 file."}, {"lang": "es", "value": "Se detect\u00f3 un problema en libgpac.a en GPAC versiones anteriores a 0.8.0, como es demostrado por MP4Box. Contiene una vulnerabilidad de Uso de la Memoria Previamente Liberada en la funci\u00f3n gf_m2ts_process_pmt en el archivo media_tools/mpegts.c que puede causar una denegaci\u00f3n de servicio por medio de un archivo MP4 dise\u00f1ado."}], "evaluatorComment": null, "id": "CVE-2019-20628", "lastModified": "2020-03-25T13:51:32.640", "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": true}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2020-03-24T19:15:20.947", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/gpac/gpac/commit/1ab4860609f2e7a35634930571e7d0531297e090"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/gpac/gpac/commit/98b727637e32d1d4824101d8947e2dbd573d4fc8"}, {"source": "cve@mitre.org", "tags": ["Exploit", "Third Party Advisory"], "url": "https://github.com/gpac/gpac/issues/1269"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-416"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/gpac/gpac/commit/1ab4860609f2e7a35634930571e7d0531297e090"}, "type": "CWE-416"}
| 223
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n *\t\t\tGPAC - Multimedia Framework C SDK\n *\n *\t\t\tAuthors: Jean Le Feuvre\n *\t\t\tCopyright (c) Telecom ParisTech 2005-2012\n *\n * This file is part of GPAC / MPEG2-TS sub-project\n *\n * GPAC is free software; you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation; either version 2, or (at your option)\n * any later version.\n *\n * GPAC 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 Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; see the file COPYING. If not, write to\n * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.\n *\n */",
"#include <gpac/mpegts.h>",
"\n#ifndef GPAC_DISABLE_MPEG2TS",
"#include <string.h>\n#include <gpac/constants.h>\n#include <gpac/internal/media_dev.h>\n#include <gpac/download.h>",
"\n#ifndef GPAC_DISABLE_STREAMING\n#include <gpac/internal/ietf_dev.h>\n#endif",
"\n#ifdef GPAC_CONFIG_LINUX\n#include <unistd.h>\n#endif",
"#ifdef GPAC_ENABLE_MPE\n#include <gpac/dvb_mpe.h>\n#endif",
"#ifdef GPAC_ENABLE_DSMCC\n#include <gpac/ait.h>\n#endif",
"#define DEBUG_TS_PACKET 0",
"GF_EXPORT\nconst char *gf_m2ts_get_stream_name(u32 streamType)\n{\n\tswitch (streamType) {\n\tcase GF_M2TS_VIDEO_MPEG1:\n\t\treturn \"MPEG-1 Video\";\n\tcase GF_M2TS_VIDEO_MPEG2:\n\t\treturn \"MPEG-2 Video\";\n\tcase GF_M2TS_AUDIO_MPEG1:\n\t\treturn \"MPEG-1 Audio\";\n\tcase GF_M2TS_AUDIO_MPEG2:\n\t\treturn \"MPEG-2 Audio\";\n\tcase GF_M2TS_PRIVATE_SECTION:\n\t\treturn \"Private Section\";\n\tcase GF_M2TS_PRIVATE_DATA:\n\t\treturn \"Private Data\";\n\tcase GF_M2TS_AUDIO_AAC:\n\t\treturn \"AAC Audio\";\n\tcase GF_M2TS_VIDEO_MPEG4:\n\t\treturn \"MPEG-4 Video\";\n\tcase GF_M2TS_VIDEO_H264:\n\t\treturn \"MPEG-4/H264 Video\";\n\tcase GF_M2TS_VIDEO_SVC:\n\t\treturn \"H264-SVC Video\";\n\tcase GF_M2TS_VIDEO_HEVC:\n\t\treturn \"HEVC Video\";\n\tcase GF_M2TS_VIDEO_SHVC:\n\t\treturn \"SHVC Video\";\n\tcase GF_M2TS_VIDEO_SHVC_TEMPORAL:\n\t\treturn \"SHVC Video Temporal Sublayer\";\n\tcase GF_M2TS_VIDEO_MHVC:\n\t\treturn \"MHVC Video\";\n\tcase GF_M2TS_VIDEO_MHVC_TEMPORAL:\n\t\treturn \"MHVC Video Temporal Sublayer\";",
"\tcase GF_M2TS_AUDIO_AC3:\n\t\treturn \"Dolby AC3 Audio\";\n\tcase GF_M2TS_AUDIO_DTS:\n\t\treturn \"Dolby DTS Audio\";\n\tcase GF_M2TS_SUBTITLE_DVB:\n\t\treturn \"DVB Subtitle\";\n\tcase GF_M2TS_SYSTEMS_MPEG4_PES:\n\t\treturn \"MPEG-4 SL (PES)\";\n\tcase GF_M2TS_SYSTEMS_MPEG4_SECTIONS:\n\t\treturn \"MPEG-4 SL (Section)\";\n\tcase GF_M2TS_MPE_SECTIONS:\n\t\treturn \"MPE (Section)\";",
"\tcase GF_M2TS_METADATA_PES:\n\t\treturn \"Metadata (PES)\";\n\tcase GF_M2TS_METADATA_ID3_HLS:\n\t\treturn \"ID3/HLS Metadata (PES)\";",
"\tdefault:\n\t\treturn \"Unknown\";\n\t}\n}",
"\nstatic u32 gf_m2ts_reframe_default(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Bool same_pts, unsigned char *data, u32 data_len, GF_M2TS_PESHeader *pes_hdr)\n{\n\tGF_M2TS_PES_PCK pck;\n\tpck.flags = 0;\n\tif (pes->rap) pck.flags |= GF_M2TS_PES_PCK_RAP;\n\tif (!same_pts) pck.flags |= GF_M2TS_PES_PCK_AU_START;\n\tpck.DTS = pes->DTS;\n\tpck.PTS = pes->PTS;\n\tpck.data = (char *)data;\n\tpck.data_len = data_len;\n\tpck.stream = pes;\n\tts->on_event(ts, GF_M2TS_EVT_PES_PCK, &pck);\n\t/*we consumed all data*/\n\treturn 0;\n}",
"static u32 gf_m2ts_reframe_reset(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Bool same_pts, unsigned char *data, u32 data_len, GF_M2TS_PESHeader *pes_hdr)\n{\n\tif (pes->pck_data) {\n\t\tgf_free(pes->pck_data);\n\t\tpes->pck_data = NULL;\n\t}\n\tpes->pck_data_len = pes->pck_alloc_len = 0;\n\tif (pes->prev_data) {\n\t\tgf_free(pes->prev_data);\n\t\tpes->prev_data = NULL;\n\t}\n\tpes->prev_data_len = 0;\n\tpes->pes_len = 0;\n\tpes->prev_PTS = 0;\n\tpes->reframe = NULL;\n\tpes->cc = -1;\n\tpes->temi_tc_desc_len = 0;\n\treturn 0;\n}",
"static void add_text(char **buffer, u32 *size, u32 *pos, char *msg, u32 msg_len)\n{\n\tif (!msg || !buffer) return;",
"\tif (*pos+msg_len>*size) {\n\t\t*size = *pos+msg_len-*size+256;\n\t\t*buffer = (char *)gf_realloc(*buffer, *size);\n\t}\n\tstrncpy((*buffer)+(*pos), msg, msg_len);\n\t*pos += msg_len;\n}",
"static GF_Err id3_parse_tag(char *data, u32 length, char **output, u32 *output_size, u32 *output_pos)\n{\n\tGF_BitStream *bs;\n\tu32 pos;",
"\tif ((data[0] != 'I') || (data[1] != 'D') || (data[2] != '3'))\n\t\treturn GF_NOT_SUPPORTED;",
"\tbs = gf_bs_new(data, length, GF_BITSTREAM_READ);",
"\tgf_bs_skip_bytes(bs, 3);\n\t/*u8 major = */gf_bs_read_u8(bs);\n\t/*u8 minor = */gf_bs_read_u8(bs);\n\t/*u8 unsync = */gf_bs_read_int(bs, 1);\n\t/*u8 ext_hdr = */ gf_bs_read_int(bs, 1);\n\tgf_bs_read_int(bs, 6);\n\tu32 size = gf_id3_read_size(bs);",
"\tpos = (u32) gf_bs_get_position(bs);\n\tif (size != length-pos)\n\t\tsize = length-pos;",
"\twhile (size && (gf_bs_available(bs)>=10) ) {\n\t\tu32 ftag = gf_bs_read_u32(bs);\n\t\tu32 fsize = gf_id3_read_size(bs);\n\t\t/*u16 fflags = */gf_bs_read_u16(bs);\n\t\tsize -= 10;",
"\t\t//TODO, handle more ID3 tags ?\n\t\tif (ftag==ID3V2_FRAME_TXXX) {\n\t\t\tu32 pos = (u32) gf_bs_get_position(bs);\n\t\t\tchar *text = data+pos;\n\t\t\tadd_text(output, output_size, output_pos, text, fsize);\n\t\t} else {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] ID3 tag not handled, patch welcome\\n\", gf_4cc_to_str(ftag) ) );\n\t\t}\n\t\tgf_bs_skip_bytes(bs, fsize);\n\t}\n\tgf_bs_del(bs);\n\treturn GF_OK;\n}",
"static u32 gf_m2ts_reframe_id3_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Bool same_pts, unsigned char *data, u32 data_len, GF_M2TS_PESHeader *pes_hdr)\n{\n\tchar frame_header[256];\n\tchar *output_text = NULL;\n\tu32 output_len = 0;\n\tu32 pos = 0;\n\tGF_M2TS_PES_PCK pck;\n\tpck.flags = 0;\n\tif (pes->rap) pck.flags |= GF_M2TS_PES_PCK_RAP;\n\tif (!same_pts) pck.flags |= GF_M2TS_PES_PCK_AU_START;\n\tpck.DTS = pes->DTS;\n\tpck.PTS = pes->PTS;\n\tsprintf(frame_header, LLU\" --> NEXT\\n\", pes->PTS);\n\tadd_text(&output_text, &output_len, &pos, frame_header, (u32)strlen(frame_header));\n\tid3_parse_tag((char *)data, data_len, &output_text, &output_len, &pos);\n\tadd_text(&output_text, &output_len, &pos, \"\\n\\n\", 2);\n\tpck.data = (char *)output_text;\n\tpck.data_len = pos;\n\tpck.stream = pes;\n\tts->on_event(ts, GF_M2TS_EVT_PES_PCK, &pck);\n\tgf_free(output_text);\n\t/*we consumed all data*/\n\treturn 0;\n}",
"static u32 gf_m2ts_sync(GF_M2TS_Demuxer *ts, char *data, u32 size, Bool simple_check)\n{\n\tu32 i=0;\n\t/*if first byte is sync assume we're sync*/\n\tif (simple_check && (data[i]==0x47)) return 0;",
"\twhile (i < size) {\n\t\tif (i+192 >= size) return size;\n\t\tif ((data[i]==0x47) && (data[i+188]==0x47))\n\t\t\tbreak;\n\t\tif (i+192 >= size) return size;\n\t\tif ((data[i]==0x47) && (data[i+192]==0x47)) {\n\t\t\tts->prefix_present = 1;\n\t\t\tbreak;\n\t\t}\n\t\ti++;\n\t}\n\tif (i) {\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] re-sync skipped %d bytes\\n\", i) );\n\t}\n\treturn i;\n}",
"GF_EXPORT\nBool gf_m2ts_crc32_check(u8 *data, u32 len)\n{\n\tu32 crc = gf_crc_32(data, len);\n\tu32 crc_val = GF_4CC((u8) data[len], (u8) data[len+1], (u8) data[len+2], (u8) data[len+3]);\n\treturn (crc==crc_val) ? GF_TRUE : GF_FALSE;\n}",
"\nstatic GF_M2TS_SectionFilter *gf_m2ts_section_filter_new(gf_m2ts_section_callback process_section_callback, Bool process_individual)\n{\n\tGF_M2TS_SectionFilter *sec;\n\tGF_SAFEALLOC(sec, GF_M2TS_SectionFilter);\n\tif (!sec) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] gf_m2ts_section_filter_new : OUT OF MEMORY\\n\"));\n\t\treturn NULL;\n\t}\n\tsec->cc = -1;\n\tsec->process_section = process_section_callback;\n\tsec->process_individual = process_individual;\n\treturn sec;\n}",
"static void gf_m2ts_reset_sections(GF_List *sections)\n{\n\tu32 count;\n\tGF_M2TS_Section *section;\n\t//GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Deleting sections\\n\"));",
"\tcount = gf_list_count(sections);\n\twhile (count) {\n\t\tsection = gf_list_get(sections, 0);\n\t\tgf_list_rem(sections, 0);\n\t\tif (section->data) gf_free(section->data);\n\t\tgf_free(section);\n\t\tcount--;\n\t}\n}",
"static void gf_m2ts_section_filter_reset(GF_M2TS_SectionFilter *sf)\n{\n\tif (sf->section) {\n\t\tgf_free(sf->section);\n\t\tsf->section = NULL;\n\t}\n\twhile (sf->table) {\n\t\tGF_M2TS_Table *t = sf->table;\n\t\tsf->table = t->next;\n\t\tgf_m2ts_reset_sections(t->sections);\n\t\tgf_list_del(t->sections);\n\t\tgf_free(t);\n\t}\n\tsf->cc = -1;\n\tsf->length = sf->received = 0;\n\tsf->demux_restarted = 1;",
"}\nstatic void gf_m2ts_section_filter_del(GF_M2TS_SectionFilter *sf)\n{\n\tgf_m2ts_section_filter_reset(sf);\n\tgf_free(sf);\n}",
"\nstatic void gf_m2ts_metadata_descriptor_del(GF_M2TS_MetadataDescriptor *metad)\n{\n\tif (metad) {\n\t\tif (metad->service_id_record) gf_free(metad->service_id_record);\n\t\tif (metad->decoder_config) gf_free(metad->decoder_config);\n\t\tif (metad->decoder_config_id) gf_free(metad->decoder_config_id);\n\t\tgf_free(metad);\n\t}\n}",
"GF_EXPORT\nvoid gf_m2ts_es_del(GF_M2TS_ES *es, GF_M2TS_Demuxer *ts)\n{\n\tgf_list_del_item(es->program->streams, es);",
"\tif (es->flags & GF_M2TS_ES_IS_SECTION) {\n\t\tGF_M2TS_SECTION_ES *ses = (GF_M2TS_SECTION_ES *)es;\n\t\tif (ses->sec) gf_m2ts_section_filter_del(ses->sec);",
"#ifdef GPAC_ENABLE_MPE\n\t\tif (es->flags & GF_M2TS_ES_IS_MPE)\n\t\t\tgf_dvb_mpe_section_del(es);\n#endif",
"\t} else if (es->pid!=es->program->pmt_pid) {\n\t\tGF_M2TS_PES *pes = (GF_M2TS_PES *)es;",
"\t\tif ((pes->flags & GF_M2TS_INHERIT_PCR) && ts->ess[es->program->pcr_pid]==es)\n\t\t\tts->ess[es->program->pcr_pid] = NULL;",
"\t\tif (pes->pck_data) gf_free(pes->pck_data);\n\t\tif (pes->prev_data) gf_free(pes->prev_data);\n\t\tif (pes->buf) gf_free(pes->buf);\n\t\tif (pes->reassemble_buf) gf_free(pes->reassemble_buf);\n\t\tif (pes->temi_tc_desc) gf_free(pes->temi_tc_desc);",
"\t\tif (pes->metadata_descriptor) gf_m2ts_metadata_descriptor_del(pes->metadata_descriptor);",
"\t}\n\tif (es->slcfg) gf_free(es->slcfg);\n\tgf_free(es);\n}",
"static void gf_m2ts_reset_sdt(GF_M2TS_Demuxer *ts)\n{\n\twhile (gf_list_count(ts->SDTs)) {\n\t\tGF_M2TS_SDT *sdt = (GF_M2TS_SDT *)gf_list_last(ts->SDTs);\n\t\tgf_list_rem_last(ts->SDTs);\n\t\tif (sdt->provider) gf_free(sdt->provider);\n\t\tif (sdt->service) gf_free(sdt->service);\n\t\tgf_free(sdt);\n\t}\n}",
"GF_EXPORT\nGF_M2TS_SDT *gf_m2ts_get_sdt_info(GF_M2TS_Demuxer *ts, u32 program_id)\n{\n\tu32 i;\n\tfor (i=0; i<gf_list_count(ts->SDTs); i++) {\n\t\tGF_M2TS_SDT *sdt = (GF_M2TS_SDT *)gf_list_get(ts->SDTs, i);\n\t\tif (sdt->service_id==program_id) return sdt;\n\t}\n\treturn NULL;\n}",
"static void gf_m2ts_section_complete(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter *sec, GF_M2TS_SECTION_ES *ses)\n{\n\t//seek mode, only process PAT and PMT\n\tif (ts->seek_mode && (sec->section[0] != GF_M2TS_TABLE_ID_PAT) && (sec->section[0] != GF_M2TS_TABLE_ID_PMT)) {\n\t\t/*clean-up (including broken sections)*/\n\t\tif (sec->section) gf_free(sec->section);\n\t\tsec->section = NULL;\n\t\tsec->length = sec->received = 0;\n\t\treturn;\n\t}",
"\tif (!sec->process_section) {\n\t\tif ((ts->on_event && (sec->section[0]==GF_M2TS_TABLE_ID_AIT)) ) {\n#ifdef GPAC_ENABLE_DSMCC\n\t\t\tGF_M2TS_SL_PCK pck;\n\t\t\tpck.data_len = sec->length;\n\t\t\tpck.data = sec->section;\n\t\t\tpck.stream = (GF_M2TS_ES *)ses;\n\t\t\t//ts->on_event(ts, GF_M2TS_EVT_AIT_FOUND, &pck);\n\t\t\ton_ait_section(ts, GF_M2TS_EVT_AIT_FOUND, &pck);\n#endif\n\t\t} else if ((ts->on_event && (sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_ENCAPSULATED_DATA\t|| sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_UN_MESSAGE ||\n\t\t sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGE || sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_STREAM_DESCRIPTION || sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_PRIVATE)) ) {",
"#ifdef GPAC_ENABLE_DSMCC\n\t\t\tGF_M2TS_SL_PCK pck;\n\t\t\tpck.data_len = sec->length;\n\t\t\tpck.data = sec->section;\n\t\t\tpck.stream = (GF_M2TS_ES *)ses;\n\t\t\ton_dsmcc_section(ts,GF_M2TS_EVT_DSMCC_FOUND,&pck);\n\t\t\t//ts->on_event(ts, GF_M2TS_EVT_DSMCC_FOUND, &pck);\n#endif\n\t\t}\n#ifdef GPAC_ENABLE_MPE\n\t\telse if (ts->on_mpe_event && ((ses && (ses->flags & GF_M2TS_EVT_DVB_MPE)) || (sec->section[0]==GF_M2TS_TABLE_ID_INT)) ) {\n\t\t\tGF_M2TS_SL_PCK pck;\n\t\t\tpck.data_len = sec->length;\n\t\t\tpck.data = sec->section;\n\t\t\tpck.stream = (GF_M2TS_ES *)ses;\n\t\t\tts->on_mpe_event(ts, GF_M2TS_EVT_DVB_MPE, &pck);\n\t\t}\n#endif\n\t\telse if (ts->on_event) {\n\t\t\tGF_M2TS_SL_PCK pck;\n\t\t\tpck.data_len = sec->length;\n\t\t\tpck.data = sec->section;\n\t\t\tpck.stream = (GF_M2TS_ES *)ses;\n\t\t\tts->on_event(ts, GF_M2TS_EVT_DVB_GENERAL, &pck);\n\t\t}\n\t} else {\n\t\tBool has_syntax_indicator;\n\t\tu8 table_id;\n\t\tu16 extended_table_id;\n\t\tu32 status, section_start, i;\n\t\tGF_M2TS_Table *t, *prev_t;\n\t\tunsigned char *data;\n\t\tBool section_valid = 0;",
"\t\tstatus = 0;\n\t\t/*parse header*/\n\t\tdata = (u8 *)sec->section;",
"\t\t/*look for proper table*/\n\t\ttable_id = data[0];",
"\t\tif (ts->on_event) {\n\t\t\tswitch (table_id) {\n\t\t\tcase GF_M2TS_TABLE_ID_PAT:\n\t\t\tcase GF_M2TS_TABLE_ID_SDT_ACTUAL:\n\t\t\tcase GF_M2TS_TABLE_ID_PMT:\n\t\t\tcase GF_M2TS_TABLE_ID_NIT_ACTUAL:\n\t\t\tcase GF_M2TS_TABLE_ID_TDT:\n\t\t\tcase GF_M2TS_TABLE_ID_TOT:\n\t\t\t{\n\t\t\t\tGF_M2TS_SL_PCK pck;\n\t\t\t\tpck.data_len = sec->length;\n\t\t\t\tpck.data = sec->section;\n\t\t\t\tpck.stream = (GF_M2TS_ES *)ses;\n\t\t\t\tts->on_event(ts, GF_M2TS_EVT_DVB_GENERAL, &pck);\n\t\t\t}\n\t\t\t}\n\t\t}",
"\t\thas_syntax_indicator = (data[1] & 0x80) ? 1 : 0;\n\t\tif (has_syntax_indicator) {\n\t\t\textended_table_id = (data[3]<<8) | data[4];\n\t\t} else {\n\t\t\textended_table_id = 0;\n\t\t}",
"\t\tprev_t = NULL;\n\t\tt = sec->table;\n\t\twhile (t) {\n\t\t\tif ((t->table_id==table_id) && (t->ex_table_id == extended_table_id)) break;\n\t\t\tprev_t = t;\n\t\t\tt = t->next;\n\t\t}",
"\t\t/*create table*/\n\t\tif (!t) {\n\t\t\tGF_SAFEALLOC(t, GF_M2TS_Table);\n\t\t\tif (!t) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Fail to alloc table %d %d\\n\", table_id, extended_table_id));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Creating table %d %d\\n\", table_id, extended_table_id));\n\t\t\tt->table_id = table_id;\n\t\t\tt->ex_table_id = extended_table_id;\n\t\t\tt->last_version_number = 0xFF;\n\t\t\tt->sections = gf_list_new();\n\t\t\tif (prev_t) prev_t->next = t;\n\t\t\telse sec->table = t;\n\t\t}",
"\t\tif (has_syntax_indicator) {\n\t\t\tif (sec->length < 4) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] corrupted section length %d less than CRC \\n\", sec->length));\n\t\t\t} else {\n\t\t\t\t/*remove crc32*/\n\t\t\t\tsec->length -= 4;\n\t\t\t\tif (gf_m2ts_crc32_check((char *)data, sec->length)) {\n\t\t\t\t\ts32 cur_sec_num;\n\t\t\t\t\tt->version_number = (data[5] >> 1) & 0x1f;\n\t\t\t\t\tif (t->last_section_number && t->section_number && (t->version_number != t->last_version_number)) {\n\t\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] table transmission interrupted: previous table (v=%d) %d/%d sections - new table (v=%d) %d/%d sections\\n\", t->last_version_number, t->section_number, t->last_section_number, t->version_number, data[6] + 1, data[7] + 1) );\n\t\t\t\t\t\tgf_m2ts_reset_sections(t->sections);\n\t\t\t\t\t\tt->section_number = 0;\n\t\t\t\t\t}",
"\t\t\t\t\tt->current_next_indicator = (data[5] & 0x1) ? 1 : 0;\n\t\t\t\t\t/*add one to section numbers to detect if we missed or not the first section in the table*/\n\t\t\t\t\tcur_sec_num = data[6] + 1;\n\t\t\t\t\tt->last_section_number = data[7] + 1;\n\t\t\t\t\tsection_start = 8;\n\t\t\t\t\t/*we missed something*/\n\t\t\t\t\tif (!sec->process_individual && t->section_number + 1 != cur_sec_num) {\n\t\t\t\t\t\t/* TODO - Check how to handle sections when the first complete section does\n\t\t\t\t\t\t not have its sec num 0 */\n\t\t\t\t\t\tsection_valid = 0;\n\t\t\t\t\t\tif (t->is_init) {\n\t\t\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] corrupted table (lost section %d)\\n\", cur_sec_num ? cur_sec_num-1 : 31) );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsection_valid = 1;\n\t\t\t\t\t\tt->section_number = cur_sec_num;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] corrupted section (CRC32 failed)\\n\"));\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tsection_valid = 1;\n\t\t\tsection_start = 3;\n\t\t}\n\t\t/*process section*/\n\t\tif (section_valid) {\n\t\t\tGF_M2TS_Section *section;",
"\t\t\tGF_SAFEALLOC(section, GF_M2TS_Section);\n\t\t\tif (!section) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Fail to create section\\n\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsection->data_size = sec->length - section_start;\n\t\t\tsection->data = (unsigned char*)gf_malloc(sizeof(unsigned char)*section->data_size);\n\t\t\tmemcpy(section->data, sec->section + section_start, sizeof(unsigned char)*section->data_size);\n\t\t\tgf_list_add(t->sections, section);",
"\t\t\tif (t->section_number == 1) {\n\t\t\t\tstatus |= GF_M2TS_TABLE_START;\n\t\t\t\tif (t->last_version_number == t->version_number) {\n\t\t\t\t\tt->is_repeat = 1;\n\t\t\t\t} else {\n\t\t\t\t\tt->is_repeat = 0;\n\t\t\t\t}\n\t\t\t\t/*only update version number in the first section of the table*/\n\t\t\t\tt->last_version_number = t->version_number;\n\t\t\t}",
"\t\t\tif (t->is_init) {\n\t\t\t\tif (t->is_repeat) {\n\t\t\t\t\tstatus |= GF_M2TS_TABLE_REPEAT;\n\t\t\t\t} else {\n\t\t\t\t\tstatus |= GF_M2TS_TABLE_UPDATE;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstatus |= GF_M2TS_TABLE_FOUND;\n\t\t\t}",
"\t\t\tif (t->last_section_number == t->section_number) {\n\t\t\t\tu32 table_size;",
"\t\t\t\tstatus |= GF_M2TS_TABLE_END;",
"\t\t\t\ttable_size = 0;\n\t\t\t\tfor (i=0; i<gf_list_count(t->sections); i++) {\n\t\t\t\t\tGF_M2TS_Section *section = gf_list_get(t->sections, i);\n\t\t\t\t\ttable_size += section->data_size;\n\t\t\t\t}\n\t\t\t\tif (t->is_repeat) {\n\t\t\t\t\tif (t->table_size != table_size) {\n\t\t\t\t\t\tstatus |= GF_M2TS_TABLE_UPDATE;\n\t\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Repeated section found with different sizes (old table %d bytes, new table %d bytes)\\n\", t->table_size, table_size) );",
"\t\t\t\t\t\tt->table_size = table_size;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tt->table_size = table_size;\n\t\t\t\t}",
"\t\t\t\tt->is_init = 1;\n\t\t\t\t/*reset section number*/\n\t\t\t\tt->section_number = 0;",
"\t\t\t\tt->is_repeat = 0;",
"\t\t\t}",
"\t\t\tif (sec->process_individual) {\n\t\t\t\t/*send each section of the table and not the aggregated table*/\n\t\t\t\tif (sec->process_section)\n\t\t\t\t\tsec->process_section(ts, ses, t->sections, t->table_id, t->ex_table_id, t->version_number, (u8) (t->last_section_number - 1), status);",
"\t\t\t\tgf_m2ts_reset_sections(t->sections);\n\t\t\t} else {\n\t\t\t\tif (status&GF_M2TS_TABLE_END) {\n\t\t\t\t\tif (sec->process_section)\n\t\t\t\t\t\tsec->process_section(ts, ses, t->sections, t->table_id, t->ex_table_id, t->version_number, (u8) (t->last_section_number - 1), status);",
"\t\t\t\t\tgf_m2ts_reset_sections(t->sections);\n\t\t\t\t}\n\t\t\t}",
"\t\t} else {\n\t\t\tsec->cc = -1;\n\t\t\tt->section_number = 0;\n\t\t}\n\t}\n\t/*clean-up (including broken sections)*/\n\tif (sec->section) gf_free(sec->section);\n\tsec->section = NULL;\n\tsec->length = sec->received = 0;\n}",
"static Bool gf_m2ts_is_long_section(u8 table_id)\n{\n\tswitch (table_id) {\n\tcase GF_M2TS_TABLE_ID_MPEG4_BIFS:\n\tcase GF_M2TS_TABLE_ID_MPEG4_OD:\n\tcase GF_M2TS_TABLE_ID_INT:\n\tcase GF_M2TS_TABLE_ID_EIT_ACTUAL_PF:\n\tcase GF_M2TS_TABLE_ID_EIT_OTHER_PF:\n\tcase GF_M2TS_TABLE_ID_ST:\n\tcase GF_M2TS_TABLE_ID_SIT:\n\tcase GF_M2TS_TABLE_ID_DSM_CC_PRIVATE:\n\tcase GF_M2TS_TABLE_ID_MPE_FEC:\n\tcase GF_M2TS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGE:\n\tcase GF_M2TS_TABLE_ID_DSM_CC_UN_MESSAGE:\n\t\treturn 1;\n\tdefault:\n\t\tif (table_id >= GF_M2TS_TABLE_ID_EIT_SCHEDULE_MIN && table_id <= GF_M2TS_TABLE_ID_EIT_SCHEDULE_MAX)\n\t\t\treturn 1;\n\t\telse\n\t\t\treturn 0;\n\t}\n}",
"static u32 gf_m2ts_get_section_length(char byte0, char byte1, char byte2)\n{\n\tu32 length;\n\tif (gf_m2ts_is_long_section(byte0)) {\n\t\tlength = 3 + ( ((((u32)byte1)<<8) | (byte2&0xff)) & 0xfff );\n\t} else {\n\t\tlength = 3 + ( ((((u32)byte1)<<8) | (byte2&0xff)) & 0x3ff );\n\t}\n\treturn length;\n}",
"static void gf_m2ts_gather_section(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter *sec, GF_M2TS_SECTION_ES *ses, GF_M2TS_Header *hdr, unsigned char *data, u32 data_size)\n{\n\tu32 payload_size = data_size;\n\tu8 expect_cc = (sec->cc<0) ? hdr->continuity_counter : (sec->cc + 1) & 0xf;\n\tBool disc = (expect_cc == hdr->continuity_counter) ? 0 : 1;\n\tsec->cc = expect_cc;",
"\t/*may happen if hdr->adaptation_field=2 no payload in TS packet*/\n\tif (!data_size) return;",
"\tif (hdr->payload_start) {\n\t\tu32 ptr_field;",
"\t\tptr_field = data[0];\n\t\tif (ptr_field+1>data_size) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Invalid section start (@ptr_field=%d, @data_size=%d)\\n\", ptr_field, data_size) );\n\t\t\treturn;\n\t\t}",
"\t\t/*end of previous section*/\n\t\tif (!sec->length && sec->received) {\n\t\t\t/* the length of the section could not be determined from the previous TS packet because we had only 1 or 2 bytes */\n\t\t\tif (sec->received == 1)\n\t\t\t\tsec->length = gf_m2ts_get_section_length(sec->section[0], data[1], data[2]);\n\t\t\telse /* (sec->received == 2) */\n\t\t\t\tsec->length = gf_m2ts_get_section_length(sec->section[0], sec->section[1], data[1]);\n\t\t\tsec->section = (char*)gf_realloc(sec->section, sizeof(char)*sec->length);\n\t\t}",
"\t\tif (sec->length && sec->received + ptr_field >= sec->length) {\n\t\t\tu32 len = sec->length - sec->received;\n\t\t\tmemcpy(sec->section + sec->received, data+1, sizeof(char)*len);\n\t\t\tsec->received += len;\n\t\t\tif (ptr_field > len)\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Invalid pointer field (@ptr_field=%d, @remaining=%d)\\n\", ptr_field, len) );\n\t\t\tgf_m2ts_section_complete(ts, sec, ses);\n\t\t}\n\t\tdata += ptr_field+1;\n\t\tdata_size -= ptr_field+1;\n\t\tpayload_size -= ptr_field+1;",
"aggregated_section:",
"\t\tif (sec->section) gf_free(sec->section);\n\t\tsec->length = sec->received = 0;\n\t\tsec->section = (char*)gf_malloc(sizeof(char)*data_size);\n\t\tmemcpy(sec->section, data, sizeof(char)*data_size);\n\t\tsec->received = data_size;\n\t} else if (disc) {\n\t\tif (sec->section) gf_free(sec->section);\n\t\tsec->section = NULL;\n\t\tsec->received = sec->length = 0;\n\t\treturn;\n\t} else if (!sec->section) {\n\t\treturn;\n\t} else {\n\t\tif (sec->length && sec->received+data_size > sec->length)\n\t\t\tdata_size = sec->length - sec->received;",
"\t\tif (sec->length) {\n\t\t\tmemcpy(sec->section + sec->received, data, sizeof(char)*data_size);\n\t\t} else {\n\t\t\tsec->section = (char*)gf_realloc(sec->section, sizeof(char)*(sec->received+data_size));\n\t\t\tmemcpy(sec->section + sec->received, data, sizeof(char)*data_size);\n\t\t}\n\t\tsec->received += data_size;\n\t}\n\t/*alloc final buffer*/\n\tif (!sec->length && (sec->received >= 3)) {\n\t\tsec->length = gf_m2ts_get_section_length(sec->section[0], sec->section[1], sec->section[2]);\n\t\tsec->section = (char*)gf_realloc(sec->section, sizeof(char)*sec->length);",
"\t\tif (sec->received > sec->length) {\n\t\t\tdata_size -= sec->received - sec->length;\n\t\t\tsec->received = sec->length;\n\t\t}\n\t}\n\tif (!sec->length || sec->received < sec->length) return;",
"\t/*OK done*/\n\tgf_m2ts_section_complete(ts, sec, ses);",
"\tif (payload_size > data_size) {\n\t\tdata += data_size;\n\t\t/* detect padding after previous section */\n\t\tif (data[0] != 0xFF) {\n\t\t\tdata_size = payload_size - data_size;\n\t\t\tpayload_size = data_size;\n\t\t\tgoto aggregated_section;\n\t\t}\n\t}\n}",
"static void gf_m2ts_process_sdt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tu32 pos, evt_type;\n\tu32 nb_sections;\n\tu32 data_size;\n\tunsigned char *data;\n\tGF_M2TS_Section *section;",
"\t/*wait for the last section */\n\tif (!(status&GF_M2TS_TABLE_END)) return;",
"\t/*skip if already received*/\n\tif (status&GF_M2TS_TABLE_REPEAT) {\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_SDT_REPEAT, NULL);\n\t\treturn;\n\t}",
"\tif (table_id != GF_M2TS_TABLE_ID_SDT_ACTUAL) {\n\t\treturn;\n\t}",
"\tgf_m2ts_reset_sdt(ts);",
"\tnb_sections = gf_list_count(sections);\n\tif (nb_sections > 1) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] SDT on multiple sections not supported\\n\"));\n\t}",
"\tsection = (GF_M2TS_Section *)gf_list_get(sections, 0);\n\tdata = section->data;\n\tdata_size = section->data_size;",
"\t//orig_net_id = (data[0] << 8) | data[1];\n\tpos = 3;\n\twhile (pos < data_size) {\n\t\tGF_M2TS_SDT *sdt;\n\t\tu32 descs_size, d_pos, ulen;",
"\t\tGF_SAFEALLOC(sdt, GF_M2TS_SDT);\n\t\tif (!sdt) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Fail to create SDT\\n\"));\n\t\t\treturn;\n\t\t}\n\t\tgf_list_add(ts->SDTs, sdt);",
"\t\tsdt->service_id = (data[pos]<<8) + data[pos+1];\n\t\tsdt->EIT_schedule = (data[pos+2] & 0x2) ? 1 : 0;\n\t\tsdt->EIT_present_following = (data[pos+2] & 0x1);\n\t\tsdt->running_status = (data[pos+3]>>5) & 0x7;\n\t\tsdt->free_CA_mode = (data[pos+3]>>4) & 0x1;\n\t\tdescs_size = ((data[pos+3]&0xf)<<8) | data[pos+4];\n\t\tpos += 5;",
"\t\td_pos = 0;\n\t\twhile (d_pos < descs_size) {\n\t\t\tu8 d_tag = data[pos+d_pos];\n\t\t\tu8 d_len = data[pos+d_pos+1];",
"\t\t\tswitch (d_tag) {\n\t\t\tcase GF_M2TS_DVB_SERVICE_DESCRIPTOR:\n\t\t\t\tif (sdt->provider) gf_free(sdt->provider);\n\t\t\t\tsdt->provider = NULL;\n\t\t\t\tif (sdt->service) gf_free(sdt->service);\n\t\t\t\tsdt->service = NULL;",
"\t\t\t\td_pos+=2;\n\t\t\t\tsdt->service_type = data[pos+d_pos];\n\t\t\t\tulen = data[pos+d_pos+1];\n\t\t\t\td_pos += 2;\n\t\t\t\tsdt->provider = (char*)gf_malloc(sizeof(char)*(ulen+1));\n\t\t\t\tmemcpy(sdt->provider, data+pos+d_pos, sizeof(char)*ulen);\n\t\t\t\tsdt->provider[ulen] = 0;\n\t\t\t\td_pos += ulen;",
"\t\t\t\tulen = data[pos+d_pos];\n\t\t\t\td_pos += 1;\n\t\t\t\tsdt->service = (char*)gf_malloc(sizeof(char)*(ulen+1));\n\t\t\t\tmemcpy(sdt->service, data+pos+d_pos, sizeof(char)*ulen);\n\t\t\t\tsdt->service[ulen] = 0;\n\t\t\t\td_pos += ulen;\n\t\t\t\tbreak;",
"\t\t\tdefault:\n\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Skipping descriptor (0x%x) not supported\\n\", d_tag));\n\t\t\t\td_pos += d_len;\n\t\t\t\tif (d_len == 0) d_pos = descs_size;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tpos += descs_size;\n\t}\n\tevt_type = GF_M2TS_EVT_SDT_FOUND;\n\tif (ts->on_event) ts->on_event(ts, evt_type, NULL);\n}",
"static void gf_m2ts_process_mpeg4section(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *es, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tGF_M2TS_SL_PCK sl_pck;\n\tu32 nb_sections, i;\n\tGF_M2TS_Section *section;",
"\t/*skip if already received*/\n\tif (status & GF_M2TS_TABLE_REPEAT)\n\t\tif (!(es->flags & GF_M2TS_ES_SEND_REPEATED_SECTIONS))\n\t\t\treturn;",
"\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Sections for PID %d\\n\", es->pid) );\n\t/*send all sections (eg SL-packets)*/\n\tnb_sections = gf_list_count(sections);\n\tfor (i=0; i<nb_sections; i++) {\n\t\tsection = (GF_M2TS_Section *)gf_list_get(sections, i);\n\t\tsl_pck.data = (char *)section->data;\n\t\tsl_pck.data_len = section->data_size;\n\t\tsl_pck.stream = (GF_M2TS_ES *)es;\n\t\tsl_pck.version_number = version_number;\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_SL_PCK, &sl_pck);\n\t}\n}",
"static void gf_m2ts_process_nit(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *nit_es, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] NIT table processing (not yet implemented)\"));\n}",
"",
"\nstatic void gf_m2ts_process_tdt_tot(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *tdt_tot_es, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tunsigned char *data;\n\tu32 data_size, nb_sections;\n\tu32 date, yp, mp, k;\n\tGF_M2TS_Section *section;\n\tGF_M2TS_TDT_TOT *time_table;\n\tconst char *table_name;",
"\t/*wait for the last section */\n\tif ( !(status & GF_M2TS_TABLE_END) )\n\t\treturn;",
"\tswitch (table_id) {\n\tcase GF_M2TS_TABLE_ID_TDT:\n\t\ttable_name = \"TDT\";\n\t\tbreak;\n\tcase GF_M2TS_TABLE_ID_TOT:\n\t\ttable_name = \"TOT\";\n\t\tbreak;\n\tdefault:\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Unimplemented table_id %u for PID %u\\n\", table_id, GF_M2TS_PID_TDT_TOT_ST));\n\t\treturn;\n\t}",
"\tnb_sections = gf_list_count(sections);\n\tif (nb_sections > 1) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] %s on multiple sections not supported\\n\", table_name));\n\t}",
"\tsection = (GF_M2TS_Section *)gf_list_get(sections, 0);\n\tdata = section->data;\n\tdata_size = section->data_size;",
"\t/*TOT only contains 40 bits of UTC_time; TDT add descriptors and a CRC*/\n\tif ((table_id==GF_M2TS_TABLE_ID_TDT) && (data_size != 5)) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Corrupted TDT size\\n\", table_name));\n\t}\n\tGF_SAFEALLOC(time_table, GF_M2TS_TDT_TOT);\n\tif (!time_table) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Fail to alloc DVB time table\\n\"));\n\t\treturn;\n\t}",
"\t/*UTC_time - see annex C of DVB-SI ETSI EN 300468*/\n/* decodes an Modified Julian Date (MJD) into a Co-ordinated Universal Time (UTC)\nSee annex C of DVB-SI ETSI EN 300468 */\n\tdate = data[0]*256 + data[1];\n\typ = (u32)((date - 15078.2)/365.25);\n\tmp = (u32)((date - 14956.1 - (u32)(yp * 365.25))/30.6001);\n\ttime_table->day = (u32)(date - 14956 - (u32)(yp * 365.25) - (u32)(mp * 30.6001));\n\tif (mp == 14 || mp == 15) k = 1;\n\telse k = 0;\n\ttime_table->year = yp + k + 1900;\n\ttime_table->month = mp - 1 - k*12;",
"\ttime_table->hour = 10*((data[2]&0xf0)>>4) + (data[2]&0x0f);\n\ttime_table->minute = 10*((data[3]&0xf0)>>4) + (data[3]&0x0f);\n\ttime_table->second = 10*((data[4]&0xf0)>>4) + (data[4]&0x0f);\n\tassert(time_table->hour<24 && time_table->minute<60 && time_table->second<60);\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Stream UTC time is %u/%02u/%02u %02u:%02u:%02u\\n\", time_table->year, time_table->month, time_table->day, time_table->hour, time_table->minute, time_table->second));",
"\tswitch (table_id) {\n\tcase GF_M2TS_TABLE_ID_TDT:\n\t\tif (ts->TDT_time) gf_free(ts->TDT_time);\n\t\tts->TDT_time = time_table;\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TDT, time_table);\n\t\tbreak;\n\tcase GF_M2TS_TABLE_ID_TOT:\n#if 0\n\t{\n\t\tu32 pos, loop_len;\n\t\tloop_len = ((data[5]&0x0f) << 8) | (data[6] & 0xff);\n\t\tdata += 7;\n\t\tpos = 0;\n\t\twhile (pos < loop_len) {\n\t\t\tu8 tag = data[pos];\n\t\t\tpos += 2;\n\t\t\tif (tag == GF_M2TS_DVB_LOCAL_TIME_OFFSET_DESCRIPTOR) {\n\t\t\t\tchar tmp_time[10];\n\t\t\t\tu16 offset_hours, offset_minutes;\n\t\t\t\tnow->country_code[0] = data[pos];\n\t\t\t\tnow->country_code[1] = data[pos+1];\n\t\t\t\tnow->country_code[2] = data[pos+2];\n\t\t\t\tnow->country_region_id = data[pos+3]>>2;",
"\t\t\t\tsprintf(tmp_time, \"%02x\", data[pos+4]);\n\t\t\t\toffset_hours = atoi(tmp_time);\n\t\t\t\tsprintf(tmp_time, \"%02x\", data[pos+5]);\n\t\t\t\toffset_minutes = atoi(tmp_time);\n\t\t\t\tnow->local_time_offset_seconds = (offset_hours * 60 + offset_minutes) * 60;\n\t\t\t\tif (data[pos+3] & 1) now->local_time_offset_seconds *= -1;",
"\t\t\t\tdvb_decode_mjd_to_unix_time(data+pos+6, &now->unix_next_toc);",
"\t\t\t\tsprintf(tmp_time, \"%02x\", data[pos+11]);\n\t\t\t\toffset_hours = atoi(tmp_time);\n\t\t\t\tsprintf(tmp_time, \"%02x\", data[pos+12]);\n\t\t\t\toffset_minutes = atoi(tmp_time);\n\t\t\t\tnow->next_time_offset_seconds = (offset_hours * 60 + offset_minutes) * 60;\n\t\t\t\tif (data[pos+3] & 1) now->next_time_offset_seconds *= -1;\n\t\t\t\tpos+= 13;\n\t\t\t}\n\t\t}\n\t\t/*TODO: check lengths are ok*/\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TOT, time_table);\n\t}\n#endif\n\t/*check CRC32*/\n\tif (ts->tdt_tot->length<4) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] corrupted %s table (less than 4 bytes but CRC32 should be present\\n\", table_name));\n\t\tgoto error_exit;\n\t}\n\tif (!gf_m2ts_crc32_check(ts->tdt_tot->section, ts->tdt_tot->length-4)) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] corrupted %s table (CRC32 failed)\\n\", table_name));\n\t\tgoto error_exit;\n\t}\n\tif (ts->TDT_time) gf_free(ts->TDT_time);\n\tts->TDT_time = time_table;\n\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TOT, time_table);\n\tbreak;\n\tdefault:\n\t\tassert(0);\n\t\tgoto error_exit;\n\t}",
"\treturn; /*success*/",
"error_exit:\n\tgf_free(time_table);\n\treturn;\n}",
"static GF_M2TS_MetadataPointerDescriptor *gf_m2ts_read_metadata_pointer_descriptor(GF_BitStream *bs, u32 length)\n{\n\tu32 size;\n\tGF_M2TS_MetadataPointerDescriptor *d;\n\tGF_SAFEALLOC(d, GF_M2TS_MetadataPointerDescriptor);\n\tif (!d) return NULL;\n\td->application_format = gf_bs_read_u16(bs);\n\tsize = 2;\n\tif (d->application_format == 0xFFFF) {\n\t\td->application_format_identifier = gf_bs_read_u32(bs);\n\t\tsize += 4;\n\t}\n\td->format = gf_bs_read_u8(bs);\n\tsize += 1;\n\tif (d->format == 0xFF) {\n\t\td->format_identifier = gf_bs_read_u32(bs);\n\t\tsize += 4;\n\t}\n\td->service_id = gf_bs_read_u8(bs);\n\td->locator_record_flag = (gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE);\n\td->carriage_flag = (enum metadata_carriage)gf_bs_read_int(bs, 2);\n\tgf_bs_read_int(bs, 5); /*reserved */\n\tsize += 2;\n\tif (d->locator_record_flag) {\n\t\td->locator_length = gf_bs_read_u8(bs);\n\t\td->locator_data = (char *)gf_malloc(d->locator_length);\n\t\tsize += 1 + d->locator_length;\n\t\tgf_bs_read_data(bs, d->locator_data, d->locator_length);\n\t}\n\tif (d->carriage_flag != 3) {\n\t\td->program_number = gf_bs_read_u16(bs);\n\t\tsize += 2;\n\t}\n\tif (d->carriage_flag == 1) {\n\t\td->ts_location = gf_bs_read_u16(bs);\n\t\td->ts_id = gf_bs_read_u16(bs);\n\t\tsize += 4;\n\t}\n\tif (length-size > 0) {\n\t\td->data_size = length-size;\n\t\td->data = (char *)gf_malloc(d->data_size);\n\t\tgf_bs_read_data(bs, d->data, d->data_size);\n\t}\n\treturn d;\n}",
"static void gf_m2ts_metadata_pointer_descriptor_del(GF_M2TS_MetadataPointerDescriptor *metapd)\n{\n\tif (metapd) {\n\t\tif (metapd->locator_data) gf_free(metapd->locator_data);\n\t\tif (metapd->data) gf_free(metapd->data);\n\t\tgf_free(metapd);\n\t}\n}",
"static GF_M2TS_MetadataDescriptor *gf_m2ts_read_metadata_descriptor(GF_BitStream *bs, u32 length)\n{\n\tu32 size;\n\tGF_M2TS_MetadataDescriptor *d;\n\tGF_SAFEALLOC(d, GF_M2TS_MetadataDescriptor);\n\tif (!d) return NULL;\n\td->application_format = gf_bs_read_u16(bs);\n\tsize = 2;\n\tif (d->application_format == 0xFFFF) {\n\t\td->application_format_identifier = gf_bs_read_u32(bs);\n\t\tsize += 4;\n\t}\n\td->format = gf_bs_read_u8(bs);\n\tsize += 1;\n\tif (d->format == 0xFF) {\n\t\td->format_identifier = gf_bs_read_u32(bs);\n\t\tsize += 4;\n\t}\n\td->service_id = gf_bs_read_u8(bs);\n\td->decoder_config_flags = gf_bs_read_int(bs, 3);\n\td->dsmcc_flag = (gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE);\n\tgf_bs_read_int(bs, 4); /* reserved */\n\tsize += 2;\n\tif (d->dsmcc_flag) {\n\t\td->service_id_record_length = gf_bs_read_u8(bs);\n\t\td->service_id_record = (char *)gf_malloc(d->service_id_record_length);\n\t\tsize += 1 + d->service_id_record_length;\n\t\tgf_bs_read_data(bs, d->service_id_record, d->service_id_record_length);\n\t}\n\tif (d->decoder_config_flags == 1) {\n\t\td->decoder_config_length = gf_bs_read_u8(bs);\n\t\td->decoder_config = (char *)gf_malloc(d->decoder_config_length);\n\t\tsize += 1 + d->decoder_config_length;\n\t\tgf_bs_read_data(bs, d->decoder_config, d->decoder_config_length);\n\t}\n\tif (d->decoder_config_flags == 3) {\n\t\td->decoder_config_id_length = gf_bs_read_u8(bs);\n\t\td->decoder_config_id = (char *)gf_malloc(d->decoder_config_id_length);\n\t\tsize += 1 + d->decoder_config_id_length;\n\t\tgf_bs_read_data(bs, d->decoder_config_id, d->decoder_config_id_length);\n\t}\n\tif (d->decoder_config_flags == 4) {\n\t\td->decoder_config_service_id = gf_bs_read_u8(bs);\n\t\tsize++;\n\t}\n\treturn d;\n}",
"\nstatic void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tu32 info_length, pos, desc_len, evt_type, nb_es,i;\n\tu32 nb_sections;\n\tu32 data_size;\n\tu32 nb_hevc, nb_hevc_temp, nb_shvc, nb_shvc_temp, nb_mhvc, nb_mhvc_temp;\n\tunsigned char *data;\n\tGF_M2TS_Section *section;\n\tGF_Err e = GF_OK;",
"\t/*wait for the last section */\n\tif (!(status&GF_M2TS_TABLE_END)) return;",
"\tnb_es = 0;",
"\t/*skip if already received but no update detected (eg same data) */\n\tif ((status&GF_M2TS_TABLE_REPEAT) && !(status&GF_M2TS_TABLE_UPDATE)) {\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);\n\t\treturn;\n\t}",
"\tif (pmt->sec->demux_restarted) {\n\t\tpmt->sec->demux_restarted = 0;\n\t\treturn;\n\t}\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PMT Found or updated\\n\"));",
"\tnb_sections = gf_list_count(sections);\n\tif (nb_sections > 1) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"PMT on multiple sections not supported\\n\"));\n\t}",
"\tsection = (GF_M2TS_Section *)gf_list_get(sections, 0);\n\tdata = section->data;\n\tdata_size = section->data_size;",
"\tpmt->program->pcr_pid = ((data[0] & 0x1f) << 8) | data[1];",
"\tinfo_length = ((data[2]&0xf)<<8) | data[3];",
"\tif (info_length + 4 > data_size) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Broken PMT first loop, %d bytes avail but first loop size %d\\n\", data_size, info_length));\n\t\treturn;\n\t} else if (info_length != 0) {",
"\t\t/* ...Read Descriptors ... */\n\t\tu8 tag, len;\n\t\tu32 first_loop_len = 0;\n\t\ttag = data[4];\n\t\tlen = data[5];\n\t\twhile (info_length > first_loop_len) {\n\t\t\tif (tag == GF_M2TS_MPEG4_IOD_DESCRIPTOR) {",
"\t\t\t\tif ((len>2) && (len - 2 <= info_length)) {\n\t\t\t\t\tu32 size;\n\t\t\t\t\tGF_BitStream *iod_bs;\n\t\t\t\t\tiod_bs = gf_bs_new((char *)data+8, len-2, GF_BITSTREAM_READ);\n\t\t\t\t\tif (pmt->program->pmt_iod) gf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);\n\t\t\t\t\te = gf_odf_parse_descriptor(iod_bs , (GF_Descriptor **) &pmt->program->pmt_iod, &size);\n\t\t\t\t\tgf_bs_del(iod_bs );\n\t\t\t\t\tif (e==GF_OK) {\n\t\t\t\t\t\t/*remember program number for service/program selection*/\n\t\t\t\t\t\tif (pmt->program->pmt_iod) pmt->program->pmt_iod->ServiceID = pmt->program->number;\n\t\t\t\t\t\t/*if empty IOD (freebox case), discard it and use dynamic declaration of object*/\n\t\t\t\t\t\tif (!gf_list_count(pmt->program->pmt_iod->ESDescriptors)) {\n\t\t\t\t\t\t\tgf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);\n\t\t\t\t\t\t\tpmt->program->pmt_iod = NULL;\n\t\t\t\t\t\t}",
"\t\t\t\t\t}",
"\t\t\t\t} else {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Broken IOD! len %d less than 2 bytes to declare IOD\\n\", len));",
"\t\t\t\t}\n\t\t\t} else if (tag == GF_M2TS_METADATA_POINTER_DESCRIPTOR) {\n\t\t\t\tGF_BitStream *metadatapd_bs;\n\t\t\t\tGF_M2TS_MetadataPointerDescriptor *metapd;\n\t\t\t\tmetadatapd_bs = gf_bs_new((char *)data+6, len, GF_BITSTREAM_READ);\n\t\t\t\tmetapd = gf_m2ts_read_metadata_pointer_descriptor(metadatapd_bs, len);\n\t\t\t\tgf_bs_del(metadatapd_bs);\n\t\t\t\tif (metapd->application_format_identifier == GF_M2TS_META_ID3 &&\n\t\t\t\t metapd->format_identifier == GF_M2TS_META_ID3 &&\n\t\t\t\t metapd->carriage_flag == METADATA_CARRIAGE_SAME_TS) {\n\t\t\t\t\t/*HLS ID3 Metadata */\n\t\t\t\t\tpmt->program->metadata_pointer_descriptor = metapd;\n\t\t\t\t} else {\n\t\t\t\t\t/* don't know what to do with it for now, delete */\n\t\t\t\t\tgf_m2ts_metadata_pointer_descriptor_del(metapd);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Skipping descriptor (0x%x) and others not supported\\n\", tag));\n\t\t\t}\n\t\t\tfirst_loop_len += 2 + len;\n\t\t}\n\t}\n\tif (data_size <= 4 + info_length) return;\n\tdata += 4 + info_length;\n\tdata_size -= 4 + info_length;\n\tpos = 0;",
"\t/* count de number of program related PMT received */\n\tfor(i=0; i<gf_list_count(ts->programs); i++) {\n\t\tGF_M2TS_Program *prog = (GF_M2TS_Program *)gf_list_get(ts->programs,i);\n\t\tif(prog->pmt_pid == pmt->pid) {\n\t\t\tbreak;\n\t\t}\n\t}",
"\tnb_hevc = nb_hevc_temp = nb_shvc = nb_shvc_temp = nb_mhvc = nb_mhvc_temp = 0;\n\twhile (pos<data_size) {\n\t\tGF_M2TS_PES *pes = NULL;\n\t\tGF_M2TS_SECTION_ES *ses = NULL;\n\t\tGF_M2TS_ES *es = NULL;\n\t\tBool inherit_pcr = 0;\n\t\tu32 pid, stream_type, reg_desc_format;",
"\t\tif (pos + 5 > data_size) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Broken PMT! size %d but position %d and need at least 5 bytes to declare es\\n\", data_size, pos));\n\t\t\tbreak;\n\t\t}",
"\t\tstream_type = data[0];\n\t\tpid = ((data[1] & 0x1f) << 8) | data[2];\n\t\tdesc_len = ((data[3] & 0xf) << 8) | data[4];",
"\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"stream_type :%d \\n\",stream_type));\n\t\tswitch (stream_type) {",
"\t\t/* PES */\n\t\tcase GF_M2TS_VIDEO_MPEG1:\n\t\tcase GF_M2TS_VIDEO_MPEG2:\n\t\tcase GF_M2TS_VIDEO_DCII:\n\t\tcase GF_M2TS_VIDEO_MPEG4:\n\t\tcase GF_M2TS_SYSTEMS_MPEG4_PES:\n\t\tcase GF_M2TS_VIDEO_H264:\n\t\tcase GF_M2TS_VIDEO_SVC:\n\t\tcase GF_M2TS_VIDEO_MVCD:\n\t\tcase GF_M2TS_VIDEO_HEVC:\n\t\tcase GF_M2TS_VIDEO_HEVC_MCTS:\n\t\tcase GF_M2TS_VIDEO_HEVC_TEMPORAL:\n\t\tcase GF_M2TS_VIDEO_SHVC:\n\t\tcase GF_M2TS_VIDEO_SHVC_TEMPORAL:\n\t\tcase GF_M2TS_VIDEO_MHVC:\n\t\tcase GF_M2TS_VIDEO_MHVC_TEMPORAL:\n\t\t\tinherit_pcr = 1;\n\t\tcase GF_M2TS_AUDIO_MPEG1:\n\t\tcase GF_M2TS_AUDIO_MPEG2:\n\t\tcase GF_M2TS_AUDIO_AAC:\n\t\tcase GF_M2TS_AUDIO_LATM_AAC:\n\t\tcase GF_M2TS_AUDIO_AC3:\n\t\tcase GF_M2TS_AUDIO_DTS:\n\t\tcase GF_M2TS_MHAS_MAIN:\n\t\tcase GF_M2TS_MHAS_AUX:\n\t\tcase GF_M2TS_SUBTITLE_DVB:\n\t\tcase GF_M2TS_METADATA_PES:\n\t\t\tGF_SAFEALLOC(pes, GF_M2TS_PES);\n\t\t\tif (!pes) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG2TS] Failed to allocate ES for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpes->cc = -1;\n\t\t\tpes->flags = GF_M2TS_ES_IS_PES;\n\t\t\tif (inherit_pcr)\n\t\t\t\tpes->flags |= GF_M2TS_INHERIT_PCR;\n\t\t\tes = (GF_M2TS_ES *)pes;\n\t\t\tbreak;\n\t\tcase GF_M2TS_PRIVATE_DATA:\n\t\t\tGF_SAFEALLOC(pes, GF_M2TS_PES);\n\t\t\tif (!pes) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG2TS] Failed to allocate ES for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpes->cc = -1;\n\t\t\tpes->flags = GF_M2TS_ES_IS_PES;\n\t\t\tes = (GF_M2TS_ES *)pes;\n\t\t\tbreak;\n\t\t/* Sections */\n\t\tcase GF_M2TS_SYSTEMS_MPEG4_SECTIONS:\n\t\t\tGF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);\n\t\t\tif (!ses) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG2TS] Failed to allocate ES for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tes = (GF_M2TS_ES *)ses;\n\t\t\tes->flags |= GF_M2TS_ES_IS_SECTION;\n\t\t\t/* carriage of ISO_IEC_14496 data in sections */\n\t\t\tif (stream_type == GF_M2TS_SYSTEMS_MPEG4_SECTIONS) {\n\t\t\t\t/*MPEG-4 sections need to be fully checked: if one section is lost, this means we lost\n\t\t\t\tone SL packet in the AU so we must wait for the complete section again*/\n\t\t\t\tses->sec = gf_m2ts_section_filter_new(gf_m2ts_process_mpeg4section, 0);\n\t\t\t\t/*create OD container*/\n\t\t\t\tif (!pmt->program->additional_ods) {\n\t\t\t\t\tpmt->program->additional_ods = gf_list_new();\n\t\t\t\t\tts->has_4on2 = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;",
"\t\tcase GF_M2TS_13818_6_ANNEX_A:\n\t\tcase GF_M2TS_13818_6_ANNEX_B:\n\t\tcase GF_M2TS_13818_6_ANNEX_C:\n\t\tcase GF_M2TS_13818_6_ANNEX_D:\n\t\tcase GF_M2TS_PRIVATE_SECTION:\n\t\tcase GF_M2TS_QUALITY_SEC:\n\t\tcase GF_M2TS_MORE_SEC:\n\t\t\tGF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);\n\t\t\tif (!ses) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG2TS] Failed to allocate ES for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tes = (GF_M2TS_ES *)ses;\n\t\t\tes->flags |= GF_M2TS_ES_IS_SECTION;\n\t\t\tes->pid = pid;\n\t\t\tes->service_id = pmt->program->number;\n\t\t\tif (stream_type == GF_M2TS_PRIVATE_SECTION) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"AIT sections on pid %d\\n\", pid));\n\t\t\t} else if (stream_type == GF_M2TS_QUALITY_SEC) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"Quality metadata sections on pid %d\\n\", pid));\n\t\t\t} else if (stream_type == GF_M2TS_MORE_SEC) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"MORE sections on pid %d\\n\", pid));\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"stream type DSM CC user private sections on pid %d \\n\", pid));\n\t\t\t}\n\t\t\t/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */\n\t\t\tses->sec = gf_m2ts_section_filter_new(NULL, 1);\n\t\t\t//ses->sec->service_id = pmt->program->number;\n\t\t\tbreak;",
"\t\tcase GF_M2TS_MPE_SECTIONS:\n\t\t\tif (! ts->prefix_present) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"stream type MPE found : pid = %d \\n\", pid));\n#ifdef GPAC_ENABLE_MPE\n\t\t\t\tes = gf_dvb_mpe_section_new();\n\t\t\t\tif (es->flags & GF_M2TS_ES_IS_SECTION) {\n\t\t\t\t\t/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */\n\t\t\t\t\t((GF_M2TS_SECTION_ES*)es)->sec = gf_m2ts_section_filter_new(NULL, 1);\n\t\t\t\t}\n#endif\n\t\t\t\tbreak;\n\t\t\t}",
"\t\tdefault:\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\\n\", stream_type, pid ) );\n\t\t\t//GF_LOG(/*GF_LOG_WARNING*/GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\\n\", stream_type, pid ) );\n\t\t\tbreak;\n\t\t}",
"\t\tif (es) {\n\t\t\tes->stream_type = (stream_type==GF_M2TS_PRIVATE_DATA) ? 0 : stream_type;\n\t\t\tes->program = pmt->program;\n\t\t\tes->pid = pid;\n\t\t\tes->component_tag = -1;\n\t\t}",
"\t\tpos += 5;\n\t\tdata += 5;",
"\t\twhile (desc_len) {\n\t\t\tif (pos + 2 > data_size) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Broken PMT descriptor! size %d but position %d and need at least 2 bytes to parse descritpor\\n\", data_size, pos));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tu8 tag = data[0];\n\t\t\tu32 len = data[1];",
"\t\t\tif (pos + 2 + len > data_size) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Broken PMT descriptor! size %d, desc size %d but position %d\\n\", data_size, len, pos));\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tif (es) {\n\t\t\t\tswitch (tag) {\n\t\t\t\tcase GF_M2TS_ISO_639_LANGUAGE_DESCRIPTOR:\n\t\t\t\t\tif (pes && (len>=3) )\n\t\t\t\t\t\tpes->lang = GF_4CC(' ', data[2], data[3], data[4]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_MPEG4_SL_DESCRIPTOR:\n\t\t\t\t\tif (len>=2) {\n\t\t\t\t\t\tes->mpeg4_es_id = ( (u32) data[2] & 0x1f) << 8 | data[3];\n\t\t\t\t\t\tes->flags |= GF_M2TS_ES_IS_SL;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_REGISTRATION_DESCRIPTOR:\n\t\t\t\t\tif (len>=4) {\n\t\t\t\t\t\treg_desc_format = GF_4CC(data[2], data[3], data[4], data[5]);\n\t\t\t\t\t\t/*cf http://www.smpte-ra.org/mpegreg/mpegreg.html*/\n\t\t\t\t\t\tswitch (reg_desc_format) {\n\t\t\t\t\t\tcase GF_M2TS_RA_STREAM_AC3:\n\t\t\t\t\t\t\tes->stream_type = GF_M2TS_AUDIO_AC3;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase GF_M2TS_RA_STREAM_VC1:\n\t\t\t\t\t\t\tes->stream_type = GF_M2TS_VIDEO_VC1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase GF_M2TS_RA_STREAM_GPAC:\n\t\t\t\t\t\t\tif (len==8) {\n\t\t\t\t\t\t\t\tes->stream_type = GF_4CC(data[6], data[7], data[8], data[9]);\n\t\t\t\t\t\t\t\tes->flags |= GF_M2TS_GPAC_CODEC_ID;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"Unknown registration descriptor %s\\n\", gf_4cc_to_str(reg_desc_format) ));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_EAC3_DESCRIPTOR:\n\t\t\t\t\tes->stream_type = GF_M2TS_AUDIO_EC3;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_DATA_BROADCAST_ID_DESCRIPTOR:\n\t\t\t\t\tif (len>=2) {\n\t\t\t\t\t\tu32 id = data[2]<<8 | data[3];\n\t\t\t\t\t\tif ((id == 0xB) && ses && !ses->sec) {\n\t\t\t\t\t\t\tses->sec = gf_m2ts_section_filter_new(NULL, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_SUBTITLING_DESCRIPTOR:\n\t\t\t\t\tif (pes && (len>=8)) {\n\t\t\t\t\t\tpes->sub.language[0] = data[2];\n\t\t\t\t\t\tpes->sub.language[1] = data[3];\n\t\t\t\t\t\tpes->sub.language[2] = data[4];\n\t\t\t\t\t\tpes->sub.type = data[5];\n\t\t\t\t\t\tpes->sub.composition_page_id = (data[6]<<8) | data[7];\n\t\t\t\t\t\tpes->sub.ancillary_page_id = (data[8]<<8) | data[9];\n\t\t\t\t\t}\n\t\t\t\t\tes->stream_type = GF_M2TS_DVB_SUBTITLE;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_STREAM_IDENTIFIER_DESCRIPTOR:\n\t\t\t\t\tif (len>=1) {\n\t\t\t\t\t\tes->component_tag = data[2];\n\t\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"Component Tag: %d on Program %d\\n\", es->component_tag, es->program->number));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_TELETEXT_DESCRIPTOR:\n\t\t\t\t\tes->stream_type = GF_M2TS_DVB_TELETEXT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_DVB_VBI_DATA_DESCRIPTOR:\n\t\t\t\t\tes->stream_type = GF_M2TS_DVB_VBI;\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_HIERARCHY_DESCRIPTOR:\n\t\t\t\t\tif (pes && (len>=4)) {\n\t\t\t\t\t\tu8 hierarchy_embedded_layer_index;\n\t\t\t\t\t\tGF_BitStream *hbs = gf_bs_new((const char *)data, data_size, GF_BITSTREAM_READ);\n\t\t\t\t\t\t/*u32 skip = */gf_bs_read_int(hbs, 16);\n\t\t\t\t\t\t/*u8 res1 = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\t/*u8 temp_scal = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\t/*u8 spatial_scal = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\t/*u8 quality_scal = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\t/*u8 hierarchy_type = */gf_bs_read_int(hbs, 4);\n\t\t\t\t\t\t/*u8 res2 = */gf_bs_read_int(hbs, 2);\n\t\t\t\t\t\t/*u8 hierarchy_layer_index = */gf_bs_read_int(hbs, 6);\n\t\t\t\t\t\t/*u8 tref_not_present = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\t/*u8 res3 = */gf_bs_read_int(hbs, 1);\n\t\t\t\t\t\thierarchy_embedded_layer_index = gf_bs_read_int(hbs, 6);\n\t\t\t\t\t\t/*u8 res4 = */gf_bs_read_int(hbs, 2);\n\t\t\t\t\t\t/*u8 hierarchy_channel = */gf_bs_read_int(hbs, 6);\n\t\t\t\t\t\tgf_bs_del(hbs);",
"\t\t\t\t\t\tpes->depends_on_pid = 1+hierarchy_embedded_layer_index;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_METADATA_DESCRIPTOR:\n\t\t\t\t{\n\t\t\t\t\tGF_BitStream *metadatad_bs;\n\t\t\t\t\tGF_M2TS_MetadataDescriptor *metad;\n\t\t\t\t\tmetadatad_bs = gf_bs_new((char *)data+2, len, GF_BITSTREAM_READ);\n\t\t\t\t\tmetad = gf_m2ts_read_metadata_descriptor(metadatad_bs, len);\n\t\t\t\t\tgf_bs_del(metadatad_bs);\n\t\t\t\t\tif (metad->application_format_identifier == GF_M2TS_META_ID3 &&\n\t\t\t\t\t metad->format_identifier == GF_M2TS_META_ID3) {\n\t\t\t\t\t\t/*HLS ID3 Metadata */\n\t\t\t\t\t\tif (pes) {\n\t\t\t\t\t\t\tpes->metadata_descriptor = metad;\n\t\t\t\t\t\t\tpes->stream_type = GF_M2TS_METADATA_ID3_HLS;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/* don't know what to do with it for now, delete */\n\t\t\t\t\t\tgf_m2ts_metadata_descriptor_del(metad);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\t\tdefault:\n\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] skipping descriptor (0x%x) not supported\\n\", tag));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tdata += len+2;\n\t\t\tpos += len+2;\n\t\t\tif (desc_len < len+2) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Invalid PMT es descriptor size for PID %d\\n\", pid ) );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdesc_len-=len+2;\n\t\t}",
"\t\tif (es && !es->stream_type) {\n\t\t\tgf_free(es);\n\t\t\tes = NULL;\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Private Stream type (0x%x) for PID %d not supported\\n\", stream_type, pid ) );\n\t\t}",
"\t\tif (!es) continue;",
"\t\tif (ts->ess[pid]) {\n\t\t\t//this is component reuse across programs, overwrite the previously declared stream ...\n\t\t\tif (status & GF_M2TS_TABLE_FOUND) {\n\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d reused across programs %d and %d, not completely supported\\n\", pid, ts->ess[pid]->program->number, es->program->number ) );",
"\t\t\t\t//add stream to program but don't reassign the pid table until the stream is playing (>GF_M2TS_PES_FRAMING_SKIP)\n\t\t\t\tgf_list_add(pmt->program->streams, es);\n\t\t\t\tif (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);",
"\t\t\t\tnb_es++;\n\t\t\t\t//skip assignment below\n\t\t\t\tes = NULL;\n\t\t\t}\n\t\t\t/*watchout for pmt update - FIXME this likely won't work in most cases*/\n\t\t\telse {",
"\t\t\t\tGF_M2TS_ES *o_es = ts->ess[es->pid];",
"\t\t\t\tif ((o_es->stream_type == es->stream_type)\n\t\t\t\t && ((o_es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK) == (es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK))\n\t\t\t\t && (o_es->mpeg4_es_id == es->mpeg4_es_id)\n\t\t\t\t && ((o_es->flags & GF_M2TS_ES_IS_SECTION) || ((GF_M2TS_PES *)o_es)->lang == ((GF_M2TS_PES *)es)->lang)\n\t\t\t\t ) {\n\t\t\t\t\tgf_free(es);\n\t\t\t\t\tes = NULL;\n\t\t\t\t} else {\n\t\t\t\t\tgf_m2ts_es_del(o_es, ts);\n\t\t\t\t\tts->ess[es->pid] = NULL;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"\t\tif (es) {\n\t\t\tts->ess[es->pid] = es;\n\t\t\tgf_list_add(pmt->program->streams, es);\n\t\t\tif (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);",
"\t\t\tnb_es++;",
"\t\t\tif (es->stream_type == GF_M2TS_VIDEO_HEVC) nb_hevc++;\n\t\t\telse if (es->stream_type == GF_M2TS_VIDEO_HEVC_TEMPORAL) nb_hevc_temp++;\n\t\t\telse if (es->stream_type == GF_M2TS_VIDEO_SHVC) nb_shvc++;\n\t\t\telse if (es->stream_type == GF_M2TS_VIDEO_SHVC_TEMPORAL) nb_shvc_temp++;\n\t\t\telse if (es->stream_type == GF_M2TS_VIDEO_MHVC) nb_mhvc++;\n\t\t\telse if (es->stream_type == GF_M2TS_VIDEO_MHVC_TEMPORAL) nb_mhvc_temp++;\n\t\t}\n\t}",
"\t//Table 2-139, implied hierarchy indexes\n\tif (nb_hevc_temp + nb_shvc + nb_shvc_temp + nb_mhvc+ nb_mhvc_temp) {\n\t\tfor (i=0; i<gf_list_count(pmt->program->streams); i++) {\n\t\t\tGF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);\n\t\t\tif ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;\n\t\t\tif (es->depends_on_pid) continue;",
"\t\t\tswitch (es->stream_type) {\n\t\t\tcase GF_M2TS_VIDEO_HEVC_TEMPORAL:\n\t\t\t\tes->depends_on_pid = 1;\n\t\t\t\tbreak;\n\t\t\tcase GF_M2TS_VIDEO_SHVC:\n\t\t\t\tif (!nb_hevc_temp) es->depends_on_pid = 1;\n\t\t\t\telse es->depends_on_pid = 2;\n\t\t\t\tbreak;\n\t\t\tcase GF_M2TS_VIDEO_SHVC_TEMPORAL:\n\t\t\t\tes->depends_on_pid = 3;\n\t\t\t\tbreak;\n\t\t\tcase GF_M2TS_VIDEO_MHVC:\n\t\t\t\tif (!nb_hevc_temp) es->depends_on_pid = 1;\n\t\t\t\telse es->depends_on_pid = 2;\n\t\t\t\tbreak;\n\t\t\tcase GF_M2TS_VIDEO_MHVC_TEMPORAL:\n\t\t\t\tif (!nb_hevc_temp) es->depends_on_pid = 2;\n\t\t\t\telse es->depends_on_pid = 3;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}",
"\tif (nb_es) {\n\t\tu32 i;",
"\t\t//translate hierarchy descriptors indexes into PIDs - check whether the PMT-index rules are the same for HEVC\n\t\tfor (i=0; i<gf_list_count(pmt->program->streams); i++) {\n\t\t\tGF_M2TS_PES *an_es = NULL;\n\t\t\tGF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);\n\t\t\tif ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;\n\t\t\tif (!es->depends_on_pid) continue;",
"\t\t\t//fixeme we are not always assured that hierarchy_layer_index matches the stream index...\n\t\t\t//+1 is because our first stream is the PMT\n\t\t\tan_es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, es->depends_on_pid);\n\t\t\tif (an_es) {\n\t\t\t\tes->depends_on_pid = an_es->pid;\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[M2TS] Wrong dependency index in hierarchy descriptor, assuming non-scalable stream\\n\"));\n\t\t\t\tes->depends_on_pid = 0;\n\t\t\t}\n\t\t}",
"\t\tevt_type = (status&GF_M2TS_TABLE_FOUND) ? GF_M2TS_EVT_PMT_FOUND : GF_M2TS_EVT_PMT_UPDATE;\n\t\tif (ts->on_event) ts->on_event(ts, evt_type, pmt->program);\n\t} else {\n\t\t/* if we found no new ES it's simply a repeat of the PMT */\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);\n\t}\n}",
"static void gf_m2ts_process_pat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tGF_M2TS_Program *prog;\n\tGF_M2TS_SECTION_ES *pmt;\n\tu32 i, nb_progs, evt_type;\n\tu32 nb_sections;\n\tu32 data_size;\n\tunsigned char *data;\n\tGF_M2TS_Section *section;",
"\t/*wait for the last section */\n\tif (!(status&GF_M2TS_TABLE_END)) return;",
"\t/*skip if already received*/\n\tif (status&GF_M2TS_TABLE_REPEAT) {\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PAT_REPEAT, NULL);\n\t\treturn;\n\t}",
"\tnb_sections = gf_list_count(sections);\n\tif (nb_sections > 1) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"PAT on multiple sections not supported\\n\"));\n\t}",
"\tsection = (GF_M2TS_Section *)gf_list_get(sections, 0);\n\tdata = section->data;\n\tdata_size = section->data_size;",
"\tif (!(status&GF_M2TS_TABLE_UPDATE) && gf_list_count(ts->programs)) {\n\t\tif (ts->pat->demux_restarted) {\n\t\t\tts->pat->demux_restarted = 0;\n\t\t} else {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Multiple different PAT on single TS found, ignoring new PAT declaration (table id %d - extended table id %d)\\n\", table_id, ex_table_id));\n\t\t}\n\t\treturn;\n\t}\n\tnb_progs = data_size / 4;",
"\tfor (i=0; i<nb_progs; i++) {\n\t\tu16 number, pid;\n\t\tnumber = (data[0]<<8) | data[1];\n\t\tpid = (data[2]&0x1f)<<8 | data[3];\n\t\tdata += 4;\n\t\tif (number==0) {\n\t\t\tif (!ts->nit) {\n\t\t\t\tts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0);\n\t\t\t}\n\t\t} else {\n\t\t\tGF_SAFEALLOC(prog, GF_M2TS_Program);\n\t\t\tif (!prog) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Fail to allocate program for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tprog->streams = gf_list_new();\n\t\t\tprog->pmt_pid = pid;\n\t\t\tprog->number = number;\n\t\t\tprog->ts = ts;\n\t\t\tgf_list_add(ts->programs, prog);\n\t\t\tGF_SAFEALLOC(pmt, GF_M2TS_SECTION_ES);\n\t\t\tif (!pmt) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"Fail to allocate pmt filter for pid %d\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpmt->flags = GF_M2TS_ES_IS_SECTION;\n\t\t\tgf_list_add(prog->streams, pmt);\n\t\t\tpmt->pid = prog->pmt_pid;\n\t\t\tpmt->program = prog;\n\t\t\tts->ess[pmt->pid] = (GF_M2TS_ES *)pmt;\n\t\t\tpmt->sec = gf_m2ts_section_filter_new(gf_m2ts_process_pmt, 0);\n\t\t}\n\t}",
"\tevt_type = (status&GF_M2TS_TABLE_UPDATE) ? GF_M2TS_EVT_PAT_UPDATE : GF_M2TS_EVT_PAT_FOUND;\n\tif (ts->on_event) ts->on_event(ts, evt_type, NULL);\n}",
"static void gf_m2ts_process_cat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)\n{\n\tu32 evt_type;\n\t/*\n\t\tGF_M2TS_Program *prog;\n\t\tGF_M2TS_SECTION_ES *pmt;\n\t\tu32 i, nb_progs;\n\t\tu32 nb_sections;\n\t\tu32 data_size;\n\t\tunsigned char *data;\n\t\tGF_M2TS_Section *section;\n\t*/",
"\t/*wait for the last section */\n\tif (!(status&GF_M2TS_TABLE_END)) return;",
"\t/*skip if already received*/\n\tif (status&GF_M2TS_TABLE_REPEAT) {\n\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_CAT_REPEAT, NULL);\n\t\treturn;\n\t}\n\t/*\n\t\tnb_sections = gf_list_count(sections);\n\t\tif (nb_sections > 1) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"CAT on multiple sections not supported\\n\"));\n\t\t}",
"\t\tsection = (GF_M2TS_Section *)gf_list_get(sections, 0);\n\t\tdata = section->data;\n\t\tdata_size = section->data_size;",
"\t\tnb_progs = data_size / 4;",
"\t\tfor (i=0; i<nb_progs; i++) {\n\t\t\tu16 number, pid;\n\t\t\tnumber = (data[0]<<8) | data[1];\n\t\t\tpid = (data[2]&0x1f)<<8 | data[3];\n\t\t\tdata += 4;\n\t\t\tif (number==0) {\n\t\t\t\tif (!ts->nit) {\n\t\t\t\t\tts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tGF_SAFEALLOC(prog, GF_M2TS_Program);\n\t\t\t\tprog->streams = gf_list_new();\n\t\t\t\tprog->pmt_pid = pid;\n\t\t\t\tprog->number = number;\n\t\t\t\tgf_list_add(ts->programs, prog);\n\t\t\t\tGF_SAFEALLOC(pmt, GF_M2TS_SECTION_ES);\n\t\t\t\tpmt->flags = GF_M2TS_ES_IS_SECTION;\n\t\t\t\tgf_list_add(prog->streams, pmt);\n\t\t\t\tpmt->pid = prog->pmt_pid;\n\t\t\t\tpmt->program = prog;\n\t\t\t\tts->ess[pmt->pid] = (GF_M2TS_ES *)pmt;\n\t\t\t\tpmt->sec = gf_m2ts_section_filter_new(gf_m2ts_process_pmt, 0);\n\t\t\t}\n\t\t}\n\t*/",
"\tevt_type = (status&GF_M2TS_TABLE_UPDATE) ? GF_M2TS_EVT_CAT_UPDATE : GF_M2TS_EVT_CAT_FOUND;\n\tif (ts->on_event) ts->on_event(ts, evt_type, NULL);\n}",
"u64 gf_m2ts_get_pts(unsigned char *data)\n{\n\tu64 pts;\n\tu32 val;\n\tpts = (u64)((data[0] >> 1) & 0x07) << 30;\n\tval = (data[1] << 8) | data[2];\n\tpts |= (u64)(val >> 1) << 15;\n\tval = (data[3] << 8) | data[4];\n\tpts |= (u64)(val >> 1);\n\treturn pts;\n}",
"void gf_m2ts_pes_header(GF_M2TS_PES *pes, unsigned char *data, u32 data_size, GF_M2TS_PESHeader *pesh)\n{\n\tu32 has_pts, has_dts;\n\tu32 len_check;\n\tmemset(pesh, 0, sizeof(GF_M2TS_PESHeader));",
"\tlen_check = 0;",
"\tpesh->id = data[0];\n\tpesh->pck_len = (data[1]<<8) | data[2];\n\t/*\n\t\t2bits\n\t\tscrambling_control\t\t= gf_bs_read_int(bs,2);\n\t\tpriority\t\t\t\t= gf_bs_read_int(bs,1);\n\t*/\n\tpesh->data_alignment = (data[3] & 0x4) ? 1 : 0;\n\t/*\n\t\tcopyright\t\t\t\t= gf_bs_read_int(bs,1);\n\t\toriginal\t\t\t\t= gf_bs_read_int(bs,1);\n\t*/\n\thas_pts = (data[4]&0x80);\n\thas_dts = has_pts ? (data[4]&0x40) : 0;\n\t/*\n\t\tESCR_flag\t\t\t\t= gf_bs_read_int(bs,1);\n\t\tES_rate_flag\t\t\t= gf_bs_read_int(bs,1);\n\t\tDSM_flag\t\t\t\t= gf_bs_read_int(bs,1);\n\t\tadditional_copy_flag\t= gf_bs_read_int(bs,1);\n\t\tprev_crc_flag\t\t\t= gf_bs_read_int(bs,1);\n\t\textension_flag\t\t\t= gf_bs_read_int(bs,1);\n\t*/",
"\tpesh->hdr_data_len = data[5];",
"\tdata += 6;\n\tif (has_pts) {\n\t\tpesh->PTS = gf_m2ts_get_pts(data);\n\t\tdata+=5;\n\t\tlen_check += 5;\n\t}\n\tif (has_dts) {\n\t\tpesh->DTS = gf_m2ts_get_pts(data);\n\t\t//data+=5;\n\t\tlen_check += 5;\n\t} else {\n\t\tpesh->DTS = pesh->PTS;\n\t}\n\tif (len_check < pesh->hdr_data_len) {\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d Skipping %d bytes in pes header\\n\", pes->pid, pesh->hdr_data_len - len_check));\n\t} else if (len_check > pesh->hdr_data_len) {\n\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d Wrong pes_header_data_length field %d bytes - read %d\\n\", pes->pid, pesh->hdr_data_len, len_check));\n\t}",
"\tif ((pesh->PTS<90000) && ((s32)pesh->DTS<0)) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d Wrong DTS %d negative for PTS %d - forcing to 0\\n\", pes->pid, pesh->DTS, pesh->PTS));\n\t\tpesh->DTS=0;\n\t}\n}",
"static void gf_m2ts_store_temi(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes)\n{\n\tGF_BitStream *bs = gf_bs_new(pes->temi_tc_desc, pes->temi_tc_desc_len, GF_BITSTREAM_READ);\n\tu32 has_timestamp = gf_bs_read_int(bs, 2);\n\tBool has_ntp = (Bool) gf_bs_read_int(bs, 1);\n\t/*u32 has_ptp = */gf_bs_read_int(bs, 1);\n\t/*u32 has_timecode = */gf_bs_read_int(bs, 2);",
"\tmemset(&pes->temi_tc, 0, sizeof(GF_M2TS_TemiTimecodeDescriptor));\n\tpes->temi_tc.force_reload = gf_bs_read_int(bs, 1);\n\tpes->temi_tc.is_paused = gf_bs_read_int(bs, 1);\n\tpes->temi_tc.is_discontinuity = gf_bs_read_int(bs, 1);\n\tgf_bs_read_int(bs, 7);\n\tpes->temi_tc.timeline_id = gf_bs_read_int(bs, 8);\n\tif (has_timestamp) {\n\t\tpes->temi_tc.media_timescale = gf_bs_read_u32(bs);\n\t\tif (has_timestamp==2)\n\t\t\tpes->temi_tc.media_timestamp = gf_bs_read_u64(bs);\n\t\telse\n\t\t\tpes->temi_tc.media_timestamp = gf_bs_read_u32(bs);\n\t}\n\tif (has_ntp) {\n\t\tpes->temi_tc.ntp = gf_bs_read_u64(bs);\n\t}\n\tgf_bs_del(bs);\n\tpes->temi_tc_desc_len = 0;\n\tpes->temi_pending = 1;\n}",
"void gf_m2ts_flush_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes)\n{\n\tGF_M2TS_PESHeader pesh;\n\tif (!ts) return;",
"\t/*we need at least a full, valid start code and PES header !!*/\n\tif ((pes->pck_data_len >= 4) && !pes->pck_data[0] && !pes->pck_data[1] && (pes->pck_data[2] == 0x1)) {\n\t\tu32 len;\n\t\tBool has_pes_header = GF_TRUE;\n\t\tu32 stream_id = pes->pck_data[3];\n\t\tBool same_pts = GF_FALSE;",
"\t\tswitch (stream_id) {\n\t\tcase GF_M2_STREAMID_PROGRAM_STREAM_MAP:\n\t\tcase GF_M2_STREAMID_PADDING:\n\t\tcase GF_M2_STREAMID_PRIVATE_2:\n\t\tcase GF_M2_STREAMID_ECM:\n\t\tcase GF_M2_STREAMID_EMM:\n\t\tcase GF_M2_STREAMID_PROGRAM_STREAM_DIRECTORY:\n\t\tcase GF_M2_STREAMID_DSMCC:\n\t\tcase GF_M2_STREAMID_H222_TYPE_E:\n\t\t\thas_pes_header = GF_FALSE;\n\t\t\tbreak;\n\t\t}",
"\t\tif (has_pes_header) {",
"\t\t\t/*OK read header*/\n\t\t\tgf_m2ts_pes_header(pes, pes->pck_data + 3, pes->pck_data_len - 3, &pesh);",
"\t\t\t/*send PES timing*/\n\t\t\tif (ts->notify_pes_timing) {\n\t\t\t\tGF_M2TS_PES_PCK pck;\n\t\t\t\tmemset(&pck, 0, sizeof(GF_M2TS_PES_PCK));\n\t\t\t\tpck.PTS = pesh.PTS;\n\t\t\t\tpck.DTS = pesh.DTS;\n\t\t\t\tpck.stream = pes;\n\t\t\t\tif (pes->rap) pck.flags |= GF_M2TS_PES_PCK_RAP;\n\t\t\t\tpes->pes_end_packet_number = ts->pck_number;\n\t\t\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PES_TIMING, &pck);\n\t\t\t}\n\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d Got PES header DTS %d PTS %d\\n\", pes->pid, pesh.DTS, pesh.PTS));",
"\t\t\tif (pesh.PTS) {\n\t\t\t\tif (pesh.PTS == pes->PTS) {\n\t\t\t\t\tsame_pts = GF_TRUE;\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d - same PTS \"LLU\" for two consecutive PES packets \\n\", pes->pid, pes->PTS));\n\t\t\t\t}\n\t#ifndef GPAC_DISABLE_LOG\n\t\t\t\t/*FIXME - this test should only be done for non bi-directionnally coded media\n\t\t\t\telse if (pesh.PTS < pes->PTS) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d - PTS \"LLU\" less than previous packet PTS \"LLU\"\\n\", pes->pid, pesh.PTS, pes->PTS) );\n\t\t\t\t}\n\t\t\t\t*/\n\t#endif",
"\t\t\t\tpes->PTS = pesh.PTS;\n\t#ifndef GPAC_DISABLE_LOG\n\t\t\t\t{\n\t\t\t\t\tif (pes->DTS && (pesh.DTS == pes->DTS)) {\n\t\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d - same DTS \"LLU\" for two consecutive PES packets \\n\", pes->pid, pes->DTS));\n\t\t\t\t\t}\n\t\t\t\t\tif (pesh.DTS < pes->DTS) {\n\t\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d - DTS \"LLU\" less than previous DTS \"LLU\"\\n\", pes->pid, pesh.DTS, pes->DTS));\n\t\t\t\t\t}\n\t\t\t\t}\n\t#endif\n\t\t\t\tpes->DTS = pesh.DTS;\n\t\t\t}\n\t\t\t/*no PTSs were coded, same time*/\n\t\t\telse if (!pesh.hdr_data_len) {\n\t\t\t\tsame_pts = GF_TRUE;\n\t\t\t}",
"\n\t\t\t/*3-byte start-code + 6 bytes header + hdr extensions*/\n\t\t\tlen = 9 + pesh.hdr_data_len;",
"\t\t} else {\n\t\t\t/*3-byte start-code + 1 byte streamid*/\n\t\t\tlen = 4;\n\t\t\tmemset(&pesh, 0, sizeof(pesh));\n\t\t}",
"\t\tif ((u8) pes->pck_data[3]==0xfa) {\n\t\t\tGF_M2TS_SL_PCK sl_pck;",
"\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] SL Packet in PES for %d - ES ID %d\\n\", pes->pid, pes->mpeg4_es_id));",
"\t\t\tif (pes->pck_data_len > len) {\n\t\t\t\tsl_pck.data = (char *)pes->pck_data + len;\n\t\t\t\tsl_pck.data_len = pes->pck_data_len - len;\n\t\t\t\tsl_pck.stream = (GF_M2TS_ES *)pes;\n\t\t\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_SL_PCK, &sl_pck);\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Bad SL Packet size: (%d indicated < %d header)\\n\", pes->pid, pes->pck_data_len, len));\n\t\t\t}\n\t\t} else if (pes->reframe) {\n\t\t\tu32 remain = 0;\n\t\t\tu32 offset = len;",
"\t\t\tif (pesh.pck_len && (pesh.pck_len-3-pesh.hdr_data_len != pes->pck_data_len-len)) {\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PES payload size %d but received %d bytes\\n\", pes->pid, (u32) ( pesh.pck_len-3-pesh.hdr_data_len), pes->pck_data_len-len));\n\t\t\t}\n\t\t\t//copy over the remaining of previous PES payload before start of this PES payload\n\t\t\tif (pes->prev_data_len) {\n\t\t\t\tif (pes->prev_data_len < len) {\n\t\t\t\t\toffset = len - pes->prev_data_len;\n\t\t\t\t\tmemcpy(pes->pck_data + offset, pes->prev_data, pes->prev_data_len);\n\t\t\t\t} else {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PES reassembly buffer overflow (%d bytes not processed from previous PES) - discarding prev data\\n\", pes->pid, pes->prev_data_len ));\n\t\t\t\t}\n\t\t\t}",
"\t\t\tif (!pes->temi_pending && pes->temi_tc_desc_len) {\n\t\t\t\tgf_m2ts_store_temi(ts, pes);\n\t\t\t}",
"\t\t\tif (pes->temi_pending) {\n\t\t\t\tpes->temi_pending = 0;\n\t\t\t\tpes->temi_tc.pes_pts = pes->PTS;\n\t\t\t\tif (ts->on_event)\n\t\t\t\t\tts->on_event(ts, GF_M2TS_EVT_TEMI_TIMECODE, &pes->temi_tc);\n\t\t\t}",
"\t\t\tif (! ts->seek_mode)\n\t\t\t\tremain = pes->reframe(ts, pes, same_pts, pes->pck_data+offset, pes->pck_data_len-offset, &pesh);",
"\t\t\t//CLEANUP alloc stuff\n\t\t\tif (pes->prev_data) gf_free(pes->prev_data);\n\t\t\tpes->prev_data = NULL;\n\t\t\tpes->prev_data_len = 0;\n\t\t\tif (remain) {\n\t\t\t\tpes->prev_data = gf_malloc(sizeof(char)*remain);\n\t\t\t\tassert(pes->pck_data_len >= remain);\n\t\t\t\tmemcpy(pes->prev_data, pes->pck_data + pes->pck_data_len - remain, remain);\n\t\t\t\tpes->prev_data_len = remain;\n\t\t\t}\n\t\t}\n\t} else if (pes->pck_data_len) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PES %d: Bad PES Header, discarding packet (maybe stream is encrypted ?)\\n\", pes->pid));\n\t}\n\tpes->pck_data_len = 0;\n\tpes->pes_len = 0;\n\tpes->rap = 0;\n}",
"static void gf_m2ts_process_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, GF_M2TS_Header *hdr, unsigned char *data, u32 data_size, GF_M2TS_AdaptationField *paf)\n{\n\tu8 expect_cc;\n\tBool disc=0;\n\tBool flush_pes = 0;",
"\t/*duplicated packet, NOT A DISCONTINUITY, we should discard the packet - however we may encounter this configuration in DASH at segment boundaries.\n\tIf payload start is set, ignore duplication*/\n\tif (hdr->continuity_counter==pes->cc) {\n\t\tif (!hdr->payload_start || (hdr->adaptation_field!=3) ) {\n\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PES %d: Duplicated Packet found (CC %d) - skipping\\n\", pes->pid, pes->cc));\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\texpect_cc = (pes->cc<0) ? hdr->continuity_counter : (pes->cc + 1) & 0xf;\n\t\tif (expect_cc != hdr->continuity_counter)\n\t\t\tdisc = 1;\n\t}\n\tpes->cc = hdr->continuity_counter;",
"\tif (disc) {\n\t\tif (pes->flags & GF_M2TS_ES_IGNORE_NEXT_DISCONTINUITY) {\n\t\t\tpes->flags &= ~GF_M2TS_ES_IGNORE_NEXT_DISCONTINUITY;\n\t\t\tdisc = 0;\n\t\t}\n\t\tif (disc) {\n\t\t\tif (hdr->payload_start) {\n\t\t\t\tif (pes->pck_data_len) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PES %d: Packet discontinuity (%d expected - got %d) - may have lost end of previous PES\\n\", pes->pid, expect_cc, hdr->continuity_counter));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (pes->pck_data_len) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PES %d: Packet discontinuity (%d expected - got %d) - trashing PES packet\\n\", pes->pid, expect_cc, hdr->continuity_counter));\n\t\t\t\t}\n\t\t\t\tpes->pck_data_len = 0;\n\t\t\t\tpes->pes_len = 0;\n\t\t\t\tpes->cc = -1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}",
"\tif (!pes->reframe) return;",
"\tif (hdr->payload_start) {\n\t\tflush_pes = 1;\n\t\tpes->pes_start_packet_number = ts->pck_number;\n\t\tpes->before_last_pcr_value = pes->program->before_last_pcr_value;\n\t\tpes->before_last_pcr_value_pck_number = pes->program->before_last_pcr_value_pck_number;\n\t\tpes->last_pcr_value = pes->program->last_pcr_value;\n\t\tpes->last_pcr_value_pck_number = pes->program->last_pcr_value_pck_number;\n\t} else if (pes->pes_len && (pes->pck_data_len + data_size == pes->pes_len + 6)) {\n\t\t/* 6 = startcode+stream_id+length*/\n\t\t/*reassemble pes*/\n\t\tif (pes->pck_data_len + data_size > pes->pck_alloc_len) {\n\t\t\tpes->pck_alloc_len = pes->pck_data_len + data_size;\n\t\t\tpes->pck_data = (u8*)gf_realloc(pes->pck_data, pes->pck_alloc_len);\n\t\t}\n\t\tmemcpy(pes->pck_data+pes->pck_data_len, data, data_size);\n\t\tpes->pck_data_len += data_size;\n\t\t/*force discard*/\n\t\tdata_size = 0;\n\t\tflush_pes = 1;\n\t}",
"\t/*PES first fragment: flush previous packet*/\n\tif (flush_pes && pes->pck_data_len) {\n\t\tgf_m2ts_flush_pes(ts, pes);\n\t\tif (!data_size) return;\n\t}\n\t/*we need to wait for first packet of PES*/\n\tif (!pes->pck_data_len && !hdr->payload_start) {\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Waiting for PES header, trashing data\\n\", hdr->pid));\n\t\treturn;\n\t}\n\t/*reassemble*/\n\tif (pes->pck_data_len + data_size > pes->pck_alloc_len ) {\n\t\tpes->pck_alloc_len = pes->pck_data_len + data_size;\n\t\tpes->pck_data = (u8*)gf_realloc(pes->pck_data, pes->pck_alloc_len);\n\t}\n\tmemcpy(pes->pck_data + pes->pck_data_len, data, data_size);\n\tpes->pck_data_len += data_size;",
"\tif (paf && paf->random_access_indicator) pes->rap = 1;\n\tif (hdr->payload_start && !pes->pes_len && (pes->pck_data_len>=6)) {\n\t\tpes->pes_len = (pes->pck_data[4]<<8) | pes->pck_data[5];\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Got PES packet len %d\\n\", pes->pid, pes->pes_len));",
"\t\tif (pes->pes_len + 6 == pes->pck_data_len) {\n\t\t\tgf_m2ts_flush_pes(ts, pes);\n\t\t}\n\t}\n}",
"\nstatic void gf_m2ts_get_adaptation_field(GF_M2TS_Demuxer *ts, GF_M2TS_AdaptationField *paf, unsigned char *data, u32 size, u32 pid)\n{\n\tunsigned char *af_extension;\n\tpaf->discontinuity_indicator = (data[0] & 0x80) ? 1 : 0;\n\tpaf->random_access_indicator = (data[0] & 0x40) ? 1 : 0;\n\tpaf->priority_indicator = (data[0] & 0x20) ? 1 : 0;\n\tpaf->PCR_flag = (data[0] & 0x10) ? 1 : 0;\n\tpaf->OPCR_flag = (data[0] & 0x8) ? 1 : 0;\n\tpaf->splicing_point_flag = (data[0] & 0x4) ? 1 : 0;\n\tpaf->transport_private_data_flag = (data[0] & 0x2) ? 1 : 0;\n\tpaf->adaptation_field_extension_flag = (data[0] & 0x1) ? 1 : 0;",
"\taf_extension = data + 1;\n\tif (paf->PCR_flag == 1) {\n\t\tu32 base = ((u32)data[1] << 24) | ((u32)data[2] << 16) | ((u32)data[3] << 8) | (u32)data[4];\n\t\tu64 PCR = (u64) base;\n\t\tpaf->PCR_base = (PCR << 1) | (data[5] >> 7);\n\t\tpaf->PCR_ext = ((data[5] & 1) << 8) | data[6];\n\t\taf_extension += 6;\n\t}",
"\tif (paf->adaptation_field_extension_flag) {\n\t\tu32 afext_bytes;\n\t\tBool ltw_flag, pwr_flag, seamless_flag, af_desc_not_present;\n\t\tif (paf->OPCR_flag) {\n\t\t\taf_extension += 6;\n\t\t}\n\t\tif (paf->splicing_point_flag) {\n\t\t\taf_extension += 1;\n\t\t}\n\t\tif (paf->transport_private_data_flag) {\n\t\t\tu32 priv_bytes = af_extension[0];\n\t\t\taf_extension += 1 + priv_bytes;\n\t\t}",
"\t\tafext_bytes = af_extension[0];\n\t\tltw_flag = af_extension[1] & 0x80 ? 1 : 0;\n\t\tpwr_flag = af_extension[1] & 0x40 ? 1 : 0;\n\t\tseamless_flag = af_extension[1] & 0x20 ? 1 : 0;\n\t\taf_desc_not_present = af_extension[1] & 0x10 ? 1 : 0;\n\t\taf_extension += 2;\n\t\tif (!afext_bytes) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Bad Adaptation Extension found\\n\", pid));\n\t\t\treturn;\n\t\t}\n\t\tafext_bytes-=1;\n\t\tif (ltw_flag) {\n\t\t\taf_extension += 2;\n\t\t\tif (afext_bytes<2) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Bad Adaptation Extension found\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tafext_bytes-=2;\n\t\t}\n\t\tif (pwr_flag) {\n\t\t\taf_extension += 3;\n\t\t\tif (afext_bytes<3) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Bad Adaptation Extension found\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tafext_bytes-=3;\n\t\t}\n\t\tif (seamless_flag) {\n\t\t\taf_extension += 3;\n\t\t\tif (afext_bytes<3) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Bad Adaptation Extension found\\n\", pid));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tafext_bytes-=3;\n\t\t}",
"\t\tif (! af_desc_not_present) {\n\t\t\twhile (afext_bytes) {\n\t\t\t\tGF_BitStream *bs;\n\t\t\t\tchar *desc;\n\t\t\t\tu8 desc_tag = af_extension[0];\n\t\t\t\tu8 desc_len = af_extension[1];\n\t\t\t\tif (!desc_len || (u32) desc_len+2 > afext_bytes) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Bad Adaptation Descriptor found (tag %d) size is %d but only %d bytes available\\n\", pid, desc_tag, desc_len, afext_bytes));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdesc = (char *) af_extension+2;",
"\t\t\t\tbs = gf_bs_new(desc, desc_len, GF_BITSTREAM_READ);\n\t\t\t\tswitch (desc_tag) {\n\t\t\t\tcase GF_M2TS_AFDESC_LOCATION_DESCRIPTOR:\n\t\t\t\t{\n\t\t\t\t\tBool use_base_temi_url;\n\t\t\t\t\tchar URL[255];\n\t\t\t\t\tGF_M2TS_TemiLocationDescriptor temi_loc;\n\t\t\t\t\tmemset(&temi_loc, 0, sizeof(GF_M2TS_TemiLocationDescriptor) );\n\t\t\t\t\ttemi_loc.reload_external = gf_bs_read_int(bs, 1);\n\t\t\t\t\ttemi_loc.is_announce = gf_bs_read_int(bs, 1);\n\t\t\t\t\ttemi_loc.is_splicing = gf_bs_read_int(bs, 1);\n\t\t\t\t\tuse_base_temi_url = gf_bs_read_int(bs, 1);\n\t\t\t\t\tgf_bs_read_int(bs, 5); //reserved\n\t\t\t\t\ttemi_loc.timeline_id = gf_bs_read_int(bs, 7);\n\t\t\t\t\tif (!use_base_temi_url) {\n\t\t\t\t\t\tchar *_url = URL;\n\t\t\t\t\t\tu8 scheme = gf_bs_read_int(bs, 8);\n\t\t\t\t\t\tu8 url_len = gf_bs_read_int(bs, 8);\n\t\t\t\t\t\tswitch (scheme) {\n\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\t\tstrcpy(URL, \"http://\");\n\t\t\t\t\t\t\t_url = URL+7;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\tstrcpy(URL, \"https://\");\n\t\t\t\t\t\t\t_url = URL+8;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgf_bs_read_data(bs, _url, url_len);\n\t\t\t\t\t\t_url[url_len] = 0;\n\t\t\t\t\t}\n\t\t\t\t\ttemi_loc.external_URL = URL;",
"\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d AF Location descriptor found - URL %s\\n\", pid, URL));\n\t\t\t\t\tif (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TEMI_LOCATION, &temi_loc);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\tcase GF_M2TS_AFDESC_TIMELINE_DESCRIPTOR:\n\t\t\t\t\tif (ts->ess[pid] && (ts->ess[pid]->flags & GF_M2TS_ES_IS_PES)) {\n\t\t\t\t\t\tGF_M2TS_PES *pes = (GF_M2TS_PES *) ts->ess[pid];",
"\t\t\t\t\t\tif (pes->temi_tc_desc_len)\n\t\t\t\t\t\t\tgf_m2ts_store_temi(ts, pes);",
"\t\t\t\t\t\tif (pes->temi_tc_desc_alloc_size < desc_len) {\n\t\t\t\t\t\t\tpes->temi_tc_desc = gf_realloc(pes->temi_tc_desc, desc_len);\n\t\t\t\t\t\t\tpes->temi_tc_desc_alloc_size = desc_len;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(pes->temi_tc_desc, desc, desc_len);\n\t\t\t\t\t\tpes->temi_tc_desc_len = desc_len;",
"\t\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d AF Timeline descriptor found\\n\", pid));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tgf_bs_del(bs);",
"\t\t\t\taf_extension += 2+desc_len;\n\t\t\t\tafext_bytes -= 2+desc_len;\n\t\t\t}",
"\t\t}\n\t}",
"\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d: Adaptation Field found: Discontinuity %d - RAP %d - PCR: \"LLD\"\\n\", pid, paf->discontinuity_indicator, paf->random_access_indicator, paf->PCR_flag ? paf->PCR_base * 300 + paf->PCR_ext : 0));\n}",
"static GF_Err gf_m2ts_process_packet(GF_M2TS_Demuxer *ts, unsigned char *data)\n{\n\tGF_M2TS_ES *es;\n\tGF_M2TS_Header hdr;\n\tGF_M2TS_AdaptationField af, *paf;\n\tu32 payload_size, af_size;\n\tu32 pos = 0;",
"\tts->pck_number++;",
"\t/* read TS packet header*/\n\thdr.sync = data[0];\n\tif (hdr.sync != 0x47) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d does not start with sync marker\\n\", ts->pck_number));\n\t\treturn GF_CORRUPTED_DATA;\n\t}\n\thdr.error = (data[1] & 0x80) ? 1 : 0;\n\thdr.payload_start = (data[1] & 0x40) ? 1 : 0;\n\thdr.priority = (data[1] & 0x20) ? 1 : 0;\n\thdr.pid = ( (data[1]&0x1f) << 8) | data[2];\n\thdr.scrambling_ctrl = (data[3] >> 6) & 0x3;\n\thdr.adaptation_field = (data[3] >> 4) & 0x3;\n\thdr.continuity_counter = data[3] & 0xf;",
"\tif (hdr.error) {\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d has error (PID could be %d)\\n\", ts->pck_number, hdr.pid));\n\t\treturn GF_CORRUPTED_DATA;\n\t}\n//#if DEBUG_TS_PACKET\n\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d PID %d CC %d Encrypted %d\\n\", ts->pck_number, hdr.pid, hdr.continuity_counter, hdr.scrambling_ctrl));\n//#endif",
"\tif (hdr.scrambling_ctrl) {\n\t\t//TODO add decyphering\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d is scrambled - not supported\\n\", ts->pck_number, hdr.pid));\n\t\treturn GF_NOT_SUPPORTED;\n\t}",
"\tpaf = NULL;\n\tpayload_size = 184;\n\tpos = 4;\n\tswitch (hdr.adaptation_field) {\n\t/*adaptation+data*/\n\tcase 3:\n\t\taf_size = data[4];\n\t\tif (af_size>183) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d AF field larger than 183 !\\n\", ts->pck_number));\n\t\t\t//error\n\t\t\treturn GF_CORRUPTED_DATA;\n\t\t}\n\t\tpaf = ⁡\n\t\tmemset(paf, 0, sizeof(GF_M2TS_AdaptationField));\n\t\t//this will stop you when processing invalid (yet existing) mpeg2ts streams in debug\n\t\tassert( af_size<=183);\n\t\tif (af_size>183)\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d Detected wrong adaption field size %u when control value is 3\\n\", ts->pck_number, af_size));\n\t\tif (af_size) gf_m2ts_get_adaptation_field(ts, paf, data+5, af_size, hdr.pid);\n\t\tpos += 1+af_size;\n\t\tpayload_size = 183 - af_size;\n\t\tbreak;\n\t/*adaptation only - still process in case of PCR*/\n\tcase 2:\n\t\taf_size = data[4];\n\t\tif (af_size != 183) {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] TS Packet %d AF size is %d when it must be 183 for AF type 2\\n\", ts->pck_number, af_size));\n\t\t\treturn GF_CORRUPTED_DATA;\n\t\t}\n\t\tpaf = ⁡\n\t\tmemset(paf, 0, sizeof(GF_M2TS_AdaptationField));\n\t\tgf_m2ts_get_adaptation_field(ts, paf, data+5, af_size, hdr.pid);\n\t\tpayload_size = 0;\n\t\t/*no payload and no PCR, return*/\n\t\tif (!paf->PCR_flag)\n\t\t\treturn GF_OK;\n\t\tbreak;\n\t/*reserved*/\n\tcase 0:\n\t\treturn GF_OK;\n\tdefault:\n\t\tbreak;\n\t}\n\tdata += pos;",
"\t/*PAT*/\n\tif (hdr.pid == GF_M2TS_PID_PAT) {\n\t\tgf_m2ts_gather_section(ts, ts->pat, NULL, &hdr, data, payload_size);\n\t\treturn GF_OK;\n\t} else if (hdr.pid == GF_M2TS_PID_CAT) {\n\t\tgf_m2ts_gather_section(ts, ts->cat, NULL, &hdr, data, payload_size);\n\t\treturn GF_OK;\n\t}",
"\tes = ts->ess[hdr.pid];\n\tif (paf && paf->PCR_flag) {\n\t\tif (!es) {\n\t\t\tu32 i, j;\n\t\t\tfor(i=0; i<gf_list_count(ts->programs); i++) {\n\t\t\t\tGF_M2TS_PES *first_pes = NULL;\n\t\t\t\tGF_M2TS_Program *program = (GF_M2TS_Program *)gf_list_get(ts->programs,i);\n\t\t\t\tif(program->pcr_pid != hdr.pid) continue;\n\t\t\t\tfor (j=0; j<gf_list_count(program->streams); j++) {\n\t\t\t\t\tGF_M2TS_PES *pes = (GF_M2TS_PES *) gf_list_get(program->streams, j);\n\t\t\t\t\tif (pes->flags & GF_M2TS_INHERIT_PCR) {\n\t\t\t\t\t\tts->ess[hdr.pid] = (GF_M2TS_ES *) pes;\n\t\t\t\t\t\tpes->flags |= GF_M2TS_FAKE_PCR;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (pes->flags & GF_M2TS_ES_IS_PES) {\n\t\t\t\t\t\tfirst_pes = pes;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//non found, use the first media stream as a PCR destination - Q: is it legal to have PCR only streams not declared in PMT ?\n\t\t\t\tif (!es && first_pes) {\n\t\t\t\t\tes = (GF_M2TS_ES *) first_pes;\n\t\t\t\t\tfirst_pes->flags |= GF_M2TS_FAKE_PCR;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!es)\n\t\t\t\tes = ts->ess[hdr.pid];\n\t\t}\n\t\tif (es) {\n\t\t\tGF_M2TS_PES_PCK pck;\n\t\t\ts64 prev_diff_in_us;\n\t\t\tBool discontinuity;\n\t\t\ts32 cc = -1;",
"\t\t\tif (es->flags & GF_M2TS_FAKE_PCR) {\n\t\t\t\tcc = es->program->pcr_cc;\n\t\t\t\tes->program->pcr_cc = hdr.continuity_counter;\n\t\t\t}\n\t\t\telse if (es->flags & GF_M2TS_ES_IS_PES) cc = ((GF_M2TS_PES*)es)->cc;\n\t\t\telse if (((GF_M2TS_SECTION_ES*)es)->sec) cc = ((GF_M2TS_SECTION_ES*)es)->sec->cc;",
"\t\t\tdiscontinuity = paf->discontinuity_indicator;\n\t\t\tif ((cc>=0) && es->program->before_last_pcr_value) {\n\t\t\t\t//no increment of CC if AF only packet\n\t\t\t\tif (hdr.adaptation_field == 2) {\n\t\t\t\t\tif (hdr.continuity_counter != cc) {\n\t\t\t\t\t\tdiscontinuity = GF_TRUE;\n\t\t\t\t\t}\n\t\t\t\t} else if (hdr.continuity_counter != ((cc + 1) & 0xF)) {\n\t\t\t\t\tdiscontinuity = GF_TRUE;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tmemset(&pck, 0, sizeof(GF_M2TS_PES_PCK));\n\t\t\tprev_diff_in_us = (s64) (es->program->last_pcr_value /27- es->program->before_last_pcr_value/27);\n\t\t\tes->program->before_last_pcr_value = es->program->last_pcr_value;\n\t\t\tes->program->before_last_pcr_value_pck_number = es->program->last_pcr_value_pck_number;\n\t\t\tes->program->last_pcr_value_pck_number = ts->pck_number;\n\t\t\tes->program->last_pcr_value = paf->PCR_base * 300 + paf->PCR_ext;\n\t\t\tif (!es->program->last_pcr_value) es->program->last_pcr_value = 1;",
"\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR found \"LLU\" (\"LLU\" at 90kHz) - PCR diff is %d us\\n\", hdr.pid, es->program->last_pcr_value, es->program->last_pcr_value/300, (s32) (es->program->last_pcr_value - es->program->before_last_pcr_value)/27 ));",
"\t\t\tpck.PTS = es->program->last_pcr_value;\n\t\t\tpck.stream = (GF_M2TS_PES *)es;",
"\t\t\t//try to ignore all discontinuities that are less than 200 ms (seen in some HLS setup ...)\n\t\t\tif (discontinuity) {\n\t\t\t\ts64 diff_in_us = (s64) (es->program->last_pcr_value - es->program->before_last_pcr_value) / 27;\n\t\t\t\tu64 diff = ABS(diff_in_us - prev_diff_in_us);",
"\t\t\t\tif ((diff_in_us<0) && (diff_in_us >= -200000)) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d new PCR, with discontinuity signaled, is less than previously received PCR (diff %d us) but not too large, trying to ignore discontinuity\\n\", hdr.pid, diff_in_us));\n\t\t\t\t}",
"\t\t\t\t//ignore PCR discontinuity indicator if PCR found is larger than previously received PCR and diffence between PCR before and after discontinuity indicator is smaller than 50ms\n\t\t\t\telse if ((diff_in_us > 0) && (diff < 200000)) {\n\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR discontinuity signaled but diff is small (diff %d us - PCR diff %d vs prev PCR diff %d) - ignore it\\n\", hdr.pid, diff, diff_in_us, prev_diff_in_us));\n\t\t\t\t} else if (paf->discontinuity_indicator) {\n\t\t\t\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR discontinuity signaled (diff %d us - PCR diff %d vs prev PCR diff %d)\\n\", hdr.pid, diff, diff_in_us, prev_diff_in_us));\n\t\t\t\t\tpck.flags = GF_M2TS_PES_PCK_DISCONTINUITY;\n\t\t\t\t} else {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR discontinuity not signaled (diff %d us - PCR diff %d vs prev PCR diff %d)\\n\", hdr.pid, diff, diff_in_us, prev_diff_in_us));\n\t\t\t\t\tpck.flags = GF_M2TS_PES_PCK_DISCONTINUITY;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( (es->program->last_pcr_value < es->program->before_last_pcr_value) ) {\n\t\t\t\ts64 diff_in_us = (s64) (es->program->last_pcr_value - es->program->before_last_pcr_value) / 27;\n\t\t\t\t//if less than 200 ms before PCR loop at the last PCR, this is a PCR loop\n\t\t\t\tif (GF_M2TS_MAX_PCR - es->program->before_last_pcr_value < 5400000 /*2*2700000*/) {\n\t\t\t\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR loop found from \"LLU\" to \"LLU\" \\n\", hdr.pid, es->program->before_last_pcr_value, es->program->last_pcr_value));\n\t\t\t\t} else if ((diff_in_us<0) && (diff_in_us >= -200000)) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d new PCR, without discontinuity signaled, is less than previously received PCR (diff %d us) but not too large, trying to ignore discontinuity\\n\", hdr.pid, diff_in_us));\n\t\t\t\t} else {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[MPEG-2 TS] PID %d PCR found \"LLU\" is less than previously received PCR \"LLU\" (PCR diff %g sec) but no discontinuity signaled\\n\", hdr.pid, es->program->last_pcr_value, es->program->before_last_pcr_value, (GF_M2TS_MAX_PCR - es->program->before_last_pcr_value + es->program->last_pcr_value) / 27000000.0));",
"\t\t\t\t\tpck.flags = GF_M2TS_PES_PCK_DISCONTINUITY;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tif (pck.flags & GF_M2TS_PES_PCK_DISCONTINUITY) {\n\t\t\t\tgf_m2ts_reset_parsers_for_program(ts, es->program);\n\t\t\t}",
"\t\t\tif (ts->on_event) {\n\t\t\t\tts->on_event(ts, GF_M2TS_EVT_PES_PCR, &pck);\n\t\t\t}\n\t\t}\n\t}",
"\t/*check for DVB reserved PIDs*/\n\tif (!es) {\n\t\tif (hdr.pid == GF_M2TS_PID_SDT_BAT_ST) {\n\t\t\tgf_m2ts_gather_section(ts, ts->sdt, NULL, &hdr, data, payload_size);\n\t\t\treturn GF_OK;\n\t\t} else if (hdr.pid == GF_M2TS_PID_NIT_ST) {\n\t\t\t/*ignore them, unused at application level*/\n\t\t\tgf_m2ts_gather_section(ts, ts->nit, NULL, &hdr, data, payload_size);\n\t\t\treturn GF_OK;\n\t\t} else if (hdr.pid == GF_M2TS_PID_EIT_ST_CIT) {\n\t\t\t/* ignore EIT messages for the moment */\n\t\t\tgf_m2ts_gather_section(ts, ts->eit, NULL, &hdr, data, payload_size);\n\t\t\treturn GF_OK;\n\t\t} else if (hdr.pid == GF_M2TS_PID_TDT_TOT_ST) {\n\t\t\tgf_m2ts_gather_section(ts, ts->tdt_tot, NULL, &hdr, data, payload_size);\n\t\t} else {\n\t\t\t/* ignore packet */\n\t\t}\n\t} else if (es->flags & GF_M2TS_ES_IS_SECTION) { \t/* The stream uses sections to carry its payload */\n\t\tGF_M2TS_SECTION_ES *ses = (GF_M2TS_SECTION_ES *)es;\n\t\tif (ses->sec) gf_m2ts_gather_section(ts, ses->sec, ses, &hdr, data, payload_size);\n\t} else {\n\t\tGF_M2TS_PES *pes = (GF_M2TS_PES *)es;\n\t\t/* regular stream using PES packets */\n\t\tif (pes->reframe && payload_size) gf_m2ts_process_pes(ts, pes, &hdr, data, payload_size, paf);\n\t}",
"\treturn GF_OK;\n}",
"GF_EXPORT\nGF_Err gf_m2ts_process_data(GF_M2TS_Demuxer *ts, u8 *data, u32 data_size)\n{\n\tGF_Err e=GF_OK;\n\tu32 pos, pck_size;\n\tBool is_align = 1;",
"\tif (ts->buffer_size) {\n\t\t//we are sync, copy remaining bytes\n\t\tif ( (ts->buffer[0]==0x47) && (ts->buffer_size<200)) {\n\t\t\tu32 pck_size = ts->prefix_present ? 192 : 188;",
"\t\t\tif (ts->alloc_size < 200) {\n\t\t\t\tts->alloc_size = 200;\n\t\t\t\tts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*ts->alloc_size);\n\t\t\t}\n\t\t\tmemcpy(ts->buffer + ts->buffer_size, data, pck_size - ts->buffer_size);\n\t\t\te |= gf_m2ts_process_packet(ts, (unsigned char *)ts->buffer);\n\t\t\tdata += (pck_size - ts->buffer_size);\n\t\t\tdata_size = data_size - (pck_size - ts->buffer_size);\n\t\t}\n\t\t//not sync, copy over the complete buffer\n\t\telse {\n\t\t\tif (ts->alloc_size < ts->buffer_size+data_size) {\n\t\t\t\tts->alloc_size = ts->buffer_size+data_size;\n\t\t\t\tts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*ts->alloc_size);\n\t\t\t}\n\t\t\tmemcpy(ts->buffer + ts->buffer_size, data, sizeof(char)*data_size);\n\t\t\tts->buffer_size += data_size;\n\t\t\tis_align = 0;\n\t\t\tdata = ts->buffer;\n\t\t\tdata_size = ts->buffer_size;\n\t\t}\n\t}",
"\t/*sync input data*/\n\tpos = gf_m2ts_sync(ts, data, data_size, is_align);\n\tif (pos==data_size) {\n\t\tif (is_align) {\n\t\t\tif (ts->alloc_size<data_size) {\n\t\t\t\tts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*data_size);\n\t\t\t\tts->alloc_size = data_size;\n\t\t\t}\n\t\t\tmemcpy(ts->buffer, data, sizeof(char)*data_size);\n\t\t\tts->buffer_size = data_size;\n\t\t}\n\t\treturn GF_OK;\n\t}\n\tpck_size = ts->prefix_present ? 192 : 188;\n\tfor (;;) {\n\t\t/*wait for a complete packet*/\n\t\tif (data_size < pos + pck_size) {\n\t\t\tts->buffer_size = data_size - pos;\n\t\t\tdata += pos;\n\t\t\tif (!ts->buffer_size) {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t\tassert(ts->buffer_size<pck_size);",
"\t\t\tif (is_align) {\n\t\t\t\tu32 s = ts->buffer_size;\n\t\t\t\tif (s<200) s = 200;",
"\t\t\t\tif (ts->alloc_size < s) {\n\t\t\t\t\tts->alloc_size = s;\n\t\t\t\t\tts->buffer = (char*)gf_realloc(ts->buffer, sizeof(char)*ts->alloc_size);\n\t\t\t\t}\n\t\t\t\tmemcpy(ts->buffer, data, sizeof(char)*ts->buffer_size);\n\t\t\t} else {\n\t\t\t\tmemmove(ts->buffer, data, sizeof(char)*ts->buffer_size);\n\t\t\t}\n\t\t\treturn e;\n\t\t}\n\t\t/*process*/\n\t\te |= gf_m2ts_process_packet(ts, (unsigned char *)data + pos);\n\t\tpos += pck_size;\n\t}\n\treturn e;\n}",
"//unused\n#if 0\nGF_ESD *gf_m2ts_get_esd(GF_M2TS_ES *es)\n{\n\tGF_ESD *esd;\n\tu32 k, esd_count;",
"\tesd = NULL;\n\tif (es->program->pmt_iod && es->program->pmt_iod->ESDescriptors) {\n\t\tesd_count = gf_list_count(es->program->pmt_iod->ESDescriptors);\n\t\tfor (k = 0; k < esd_count; k++) {\n\t\t\tGF_ESD *esd_tmp = (GF_ESD *)gf_list_get(es->program->pmt_iod->ESDescriptors, k);\n\t\t\tif (esd_tmp->ESID != es->mpeg4_es_id) continue;\n\t\t\tesd = esd_tmp;\n\t\t\tbreak;\n\t\t}\n\t}",
"\tif (!esd && es->program->additional_ods) {\n\t\tu32 od_count, od_index;\n\t\tod_count = gf_list_count(es->program->additional_ods);\n\t\tfor (od_index = 0; od_index < od_count; od_index++) {\n\t\t\tGF_ObjectDescriptor *od = (GF_ObjectDescriptor *)gf_list_get(es->program->additional_ods, od_index);\n\t\t\tesd_count = gf_list_count(od->ESDescriptors);\n\t\t\tfor (k = 0; k < esd_count; k++) {\n\t\t\t\tGF_ESD *esd_tmp = (GF_ESD *)gf_list_get(od->ESDescriptors, k);\n\t\t\t\tif (esd_tmp->ESID != es->mpeg4_es_id) continue;\n\t\t\t\tesd = esd_tmp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}",
"\treturn esd;\n}\nvoid gf_m2ts_set_segment_switch(GF_M2TS_Demuxer *ts)\n{\n\tu32 i;\n\tfor (i=0; i<GF_M2TS_MAX_STREAMS; i++) {\n\t\tGF_M2TS_ES *es = (GF_M2TS_ES *) ts->ess[i];\n\t\tif (!es) continue;\n\t\tes->flags |= GF_M2TS_ES_IGNORE_NEXT_DISCONTINUITY;\n\t}\n}",
"\n#endif",
"\nGF_EXPORT\nvoid gf_m2ts_reset_parsers_for_program(GF_M2TS_Demuxer *ts, GF_M2TS_Program *prog)\n{\n\tu32 i;",
"\tfor (i=0; i<GF_M2TS_MAX_STREAMS; i++) {\n\t\tGF_M2TS_ES *es = (GF_M2TS_ES *) ts->ess[i];\n\t\tif (!es) continue;\n\t\tif (prog && (es->program != prog) ) continue;",
"\t\tif (es->flags & GF_M2TS_ES_IS_SECTION) {\n\t\t\tGF_M2TS_SECTION_ES *ses = (GF_M2TS_SECTION_ES *)es;\n\t\t\tgf_m2ts_section_filter_reset(ses->sec);\n\t\t} else {\n\t\t\tGF_M2TS_PES *pes = (GF_M2TS_PES *)es;\n\t\t\tif (!pes || (pes->pid==pes->program->pmt_pid)) continue;\n\t\t\tpes->cc = -1;\n\t\t\tpes->frame_state = 0;\n\t\t\tpes->pck_data_len = 0;\n\t\t\tif (pes->prev_data) gf_free(pes->prev_data);\n\t\t\tpes->prev_data = NULL;\n\t\t\tpes->prev_data_len = 0;\n\t\t\tpes->PTS = pes->DTS = 0;\n//\t\t\tpes->prev_PTS = 0;\n//\t\t\tpes->first_dts = 0;\n\t\t\tpes->pes_len = pes->pes_end_packet_number = pes->pes_start_packet_number = 0;\n\t\t\tif (pes->buf) gf_free(pes->buf);\n\t\t\tpes->buf = NULL;\n\t\t\tif (pes->temi_tc_desc) gf_free(pes->temi_tc_desc);\n\t\t\tpes->temi_tc_desc = NULL;\n\t\t\tpes->temi_tc_desc_len = pes->temi_tc_desc_alloc_size = 0;",
"\t\t\tpes->before_last_pcr_value = pes->before_last_pcr_value_pck_number = 0;\n\t\t\tpes->last_pcr_value = pes->last_pcr_value_pck_number = 0;\n\t\t\tif (pes->program->pcr_pid==pes->pid) {\n\t\t\t\tpes->program->last_pcr_value = pes->program->last_pcr_value_pck_number = 0;\n\t\t\t\tpes->program->before_last_pcr_value = pes->program->before_last_pcr_value_pck_number = 0;\n\t\t\t}\n\t\t}\n\t}\n}",
"GF_EXPORT\nvoid gf_m2ts_reset_parsers(GF_M2TS_Demuxer *ts)\n{\n\tgf_m2ts_reset_parsers_for_program(ts, NULL);",
"\tts->pck_number = 0;",
"\tgf_m2ts_section_filter_reset(ts->cat);\n\tgf_m2ts_section_filter_reset(ts->pat);\n\tgf_m2ts_section_filter_reset(ts->sdt);\n\tgf_m2ts_section_filter_reset(ts->nit);\n\tgf_m2ts_section_filter_reset(ts->eit);\n\tgf_m2ts_section_filter_reset(ts->tdt_tot);",
"}",
"\n#if 0 //unused\nu32 gf_m2ts_pes_get_framing_mode(GF_M2TS_PES *pes)\n{\n\tif (pes->flags & GF_M2TS_ES_IS_SECTION) {\n\t\tif (pes->flags & GF_M2TS_ES_IS_SL) {\n\t\t\tif ( ((GF_M2TS_SECTION_ES *)pes)->sec->process_section == NULL)\n\t\t\t\treturn GF_M2TS_PES_FRAMING_DEFAULT;",
"\t\t}\n\t\treturn GF_M2TS_PES_FRAMING_SKIP_NO_RESET;\n\t}",
"\tif (!pes->reframe ) return GF_M2TS_PES_FRAMING_SKIP_NO_RESET;\n\tif (pes->reframe == gf_m2ts_reframe_default) return GF_M2TS_PES_FRAMING_RAW;\n\tif (pes->reframe == gf_m2ts_reframe_reset) return GF_M2TS_PES_FRAMING_SKIP;\n\treturn GF_M2TS_PES_FRAMING_DEFAULT;\n}\n#endif",
"\nGF_EXPORT\nGF_Err gf_m2ts_set_pes_framing(GF_M2TS_PES *pes, u32 mode)\n{\n\tif (!pes) return GF_BAD_PARAM;",
"\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Setting pes framing mode of PID %d to %d\\n\", pes->pid, mode) );\n\t/*ignore request for section PIDs*/\n\tif (pes->flags & GF_M2TS_ES_IS_SECTION) {\n\t\tif (pes->flags & GF_M2TS_ES_IS_SL) {\n\t\t\tif (mode==GF_M2TS_PES_FRAMING_DEFAULT) {\n\t\t\t\t((GF_M2TS_SECTION_ES *)pes)->sec->process_section = gf_m2ts_process_mpeg4section;\n\t\t\t} else {\n\t\t\t\t((GF_M2TS_SECTION_ES *)pes)->sec->process_section = NULL;\n\t\t\t}\n\t\t}\n\t\treturn GF_OK;\n\t}",
"\tif (pes->pid==pes->program->pmt_pid) return GF_BAD_PARAM;",
"\t//if component reuse, disable previous pes\n\tif ((mode > GF_M2TS_PES_FRAMING_SKIP) && (pes->program->ts->ess[pes->pid] != (GF_M2TS_ES *) pes)) {\n\t\tGF_M2TS_PES *o_pes = (GF_M2TS_PES *) pes->program->ts->ess[pes->pid];\n\t\tif (o_pes->flags & GF_M2TS_ES_IS_PES)\n\t\t\tgf_m2ts_set_pes_framing(o_pes, GF_M2TS_PES_FRAMING_SKIP);",
"\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[MPEG-2 TS] Reassinging PID %d from program %d to program %d\\n\", pes->pid, o_pes->program->number, pes->program->number) );\n\t\tpes->program->ts->ess[pes->pid] = (GF_M2TS_ES *) pes;\n\t}",
"\tswitch (mode) {\n\tcase GF_M2TS_PES_FRAMING_RAW:\n\t\tpes->reframe = gf_m2ts_reframe_default;\n\t\tbreak;\n\tcase GF_M2TS_PES_FRAMING_SKIP:\n\t\tpes->reframe = gf_m2ts_reframe_reset;\n\t\tbreak;\n\tcase GF_M2TS_PES_FRAMING_SKIP_NO_RESET:\n\t\tpes->reframe = NULL;\n\t\tbreak;\n\tcase GF_M2TS_PES_FRAMING_DEFAULT:\n\tdefault:\n\t\tswitch (pes->stream_type) {\n\t\tcase GF_M2TS_VIDEO_MPEG1:\n\t\tcase GF_M2TS_VIDEO_MPEG2:\n\t\tcase GF_M2TS_VIDEO_H264:\n\t\tcase GF_M2TS_VIDEO_SVC:\n\t\tcase GF_M2TS_VIDEO_HEVC:\n\t\tcase GF_M2TS_VIDEO_HEVC_TEMPORAL:\n\t\tcase GF_M2TS_VIDEO_HEVC_MCTS:\n\t\tcase GF_M2TS_VIDEO_SHVC:\n\t\tcase GF_M2TS_VIDEO_SHVC_TEMPORAL:\n\t\tcase GF_M2TS_VIDEO_MHVC:\n\t\tcase GF_M2TS_VIDEO_MHVC_TEMPORAL:\n\t\tcase GF_M2TS_AUDIO_MPEG1:\n\t\tcase GF_M2TS_AUDIO_MPEG2:\n\t\tcase GF_M2TS_AUDIO_AAC:\n\t\tcase GF_M2TS_AUDIO_LATM_AAC:\n\t\tcase GF_M2TS_AUDIO_AC3:\n\t\tcase GF_M2TS_AUDIO_EC3:\n\t\t\t//for all our supported codec types, use a reframer filter\n\t\t\tpes->reframe = gf_m2ts_reframe_default;\n\t\t\tbreak;",
"\t\tcase GF_M2TS_PRIVATE_DATA:\n\t\t\t/* TODO: handle DVB subtitle streams */\n\t\t\tbreak;\n\t\tcase GF_M2TS_METADATA_ID3_HLS:\n\t\t\t//TODO\n\t\t\tpes->reframe = gf_m2ts_reframe_id3_pes;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tpes->reframe = gf_m2ts_reframe_default;\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\t}\n\treturn GF_OK;\n}",
"GF_EXPORT\nGF_M2TS_Demuxer *gf_m2ts_demux_new()\n{\n\tGF_M2TS_Demuxer *ts;",
"\tGF_SAFEALLOC(ts, GF_M2TS_Demuxer);\n\tif (!ts) return NULL;\n\tts->programs = gf_list_new();\n\tts->SDTs = gf_list_new();",
"\tts->pat = gf_m2ts_section_filter_new(gf_m2ts_process_pat, 0);\n\tts->cat = gf_m2ts_section_filter_new(gf_m2ts_process_cat, 0);\n\tts->sdt = gf_m2ts_section_filter_new(gf_m2ts_process_sdt, 1);\n\tts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0);\n\tts->eit = gf_m2ts_section_filter_new(NULL/*gf_m2ts_process_eit*/, 1);\n\tts->tdt_tot = gf_m2ts_section_filter_new(gf_m2ts_process_tdt_tot, 1);",
"#ifdef GPAC_ENABLE_MPE\n\tgf_dvb_mpe_init(ts);\n#endif",
"\tts->nb_prog_pmt_received = 0;\n\tts->ChannelAppList = gf_list_new();\n\treturn ts;\n}",
"GF_EXPORT\nvoid gf_m2ts_demux_dmscc_init(GF_M2TS_Demuxer *ts) {",
"\tchar temp_dir[GF_MAX_PATH];\n\tu32 length;\n\tGF_Err e;",
"\tts->dsmcc_controler = gf_list_new();\n\tts->process_dmscc = 1;",
"\tstrcpy(temp_dir, gf_get_default_cache_directory() );\n\tlength = (u32) strlen(temp_dir);\n\tif(temp_dir[length-1] == GF_PATH_SEPARATOR) {\n\t\ttemp_dir[length-1] = 0;\n\t}",
"\tts->dsmcc_root_dir = (char*)gf_calloc(strlen(temp_dir)+strlen(\"CarouselData\")+2,sizeof(char));\n\tsprintf(ts->dsmcc_root_dir,\"%s%cCarouselData\",temp_dir,GF_PATH_SEPARATOR);\n\te = gf_mkdir(ts->dsmcc_root_dir);\n\tif(e) {\n\t\tGF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, (\"[Process DSMCC] Error during the creation of the directory %s \\n\",ts->dsmcc_root_dir));\n\t}",
"}",
"GF_EXPORT\nvoid gf_m2ts_demux_del(GF_M2TS_Demuxer *ts)\n{\n\tu32 i;\n\tif (ts->pat) gf_m2ts_section_filter_del(ts->pat);\n\tif (ts->cat) gf_m2ts_section_filter_del(ts->cat);\n\tif (ts->sdt) gf_m2ts_section_filter_del(ts->sdt);\n\tif (ts->nit) gf_m2ts_section_filter_del(ts->nit);\n\tif (ts->eit) gf_m2ts_section_filter_del(ts->eit);\n\tif (ts->tdt_tot) gf_m2ts_section_filter_del(ts->tdt_tot);",
"\tfor (i=0; i<GF_M2TS_MAX_STREAMS; i++) {\n\t\t//bacause of pure PCR streams, en ES might be reassigned on 2 PIDs, one for the ES and one for the PCR\n\t\tif (ts->ess[i] && (ts->ess[i]->pid==i)) gf_m2ts_es_del(ts->ess[i], ts);\n\t}\n\tif (ts->buffer) gf_free(ts->buffer);\n\twhile (gf_list_count(ts->programs)) {\n\t\tGF_M2TS_Program *p = (GF_M2TS_Program *)gf_list_last(ts->programs);\n\t\tgf_list_rem_last(ts->programs);\n\t\tgf_list_del(p->streams);\n\t\t/*reset OD list*/\n\t\tif (p->additional_ods) {\n\t\t\tgf_odf_desc_list_del(p->additional_ods);\n\t\t\tgf_list_del(p->additional_ods);\n\t\t}\n\t\tif (p->pmt_iod) gf_odf_desc_del((GF_Descriptor *)p->pmt_iod);\n\t\tif (p->metadata_pointer_descriptor)\tgf_m2ts_metadata_pointer_descriptor_del(p->metadata_pointer_descriptor);\n\t\tgf_free(p);\n\t}\n\tgf_list_del(ts->programs);",
"\tif (ts->TDT_time) gf_free(ts->TDT_time);\n\tgf_m2ts_reset_sdt(ts);\n\tif (ts->tdt_tot)\n\t\tgf_list_del(ts->SDTs);",
"#ifdef GPAC_ENABLE_MPE\n\tgf_dvb_mpe_shutdown(ts);\n#endif",
"\tif (ts->dsmcc_controler) {\n\t\tif (gf_list_count(ts->dsmcc_controler)) {\n#ifdef GPAC_ENABLE_DSMCC\n\t\t\tGF_M2TS_DSMCC_OVERLORD* dsmcc_overlord = (GF_M2TS_DSMCC_OVERLORD*)gf_list_get(ts->dsmcc_controler,0);\n\t\t\tgf_cleanup_dir(dsmcc_overlord->root_dir);\n\t\t\tgf_rmdir(dsmcc_overlord->root_dir);\n\t\t\tgf_m2ts_delete_dsmcc_overlord(dsmcc_overlord);\n\t\t\tif(ts->dsmcc_root_dir) {\n\t\t\t\tgf_free(ts->dsmcc_root_dir);\n\t\t\t}\n#endif\n\t\t}\n\t\tgf_list_del(ts->dsmcc_controler);\n\t}",
"\twhile(gf_list_count(ts->ChannelAppList)) {\n#ifdef GPAC_ENABLE_DSMCC\n\t\tGF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo = (GF_M2TS_CHANNEL_APPLICATION_INFO*)gf_list_get(ts->ChannelAppList,0);\n\t\tgf_m2ts_delete_channel_application_info(ChanAppInfo);\n\t\tgf_list_rem(ts->ChannelAppList,0);\n#endif\n\t}\n\tgf_list_del(ts->ChannelAppList);",
"\tif (ts->dsmcc_root_dir) gf_free(ts->dsmcc_root_dir);\n\tgf_free(ts);\n}",
"#if 0//unused\nvoid gf_m2ts_print_info(GF_M2TS_Demuxer *ts)\n{\n#ifdef GPAC_ENABLE_MPE\n\tgf_m2ts_print_mpe_info(ts);\n#endif\n}\n#endif",
"",
"#define M2TS_PROBE_SIZE\t188000\nstatic Bool gf_m2ts_probe_buffer(char *buf, u32 size)\n{\n\tGF_Err e;\n\tGF_M2TS_Demuxer *ts;\n\tu32 lt;",
"\tlt = gf_log_get_tool_level(GF_LOG_CONTAINER);\n\tgf_log_set_tool_level(GF_LOG_CONTAINER, GF_LOG_QUIET);",
"\tts = gf_m2ts_demux_new();\n\te = gf_m2ts_process_data(ts, buf, size);\n\tif (!ts->pck_number) e = GF_BAD_PARAM;\n\tgf_m2ts_demux_del(ts);",
"\tgf_log_set_tool_level(GF_LOG_CONTAINER, lt);",
"\tif (e) return GF_FALSE;\n\treturn GF_TRUE;",
"}\nGF_EXPORT\nBool gf_m2ts_probe_file(const char *fileName)\n{\n\tchar buf[M2TS_PROBE_SIZE];\n\tu32 size;\n\tFILE *t;",
"\tif (!strncmp(fileName, \"gmem://\", 7)) {\n\t\tu8 *mem_address;\n\t\tif (gf_blob_get_data(fileName, &mem_address, &size) != GF_OK) {\n\t\t\treturn GF_FALSE;\n\t\t}\n\t\tif (size>M2TS_PROBE_SIZE) size = M2TS_PROBE_SIZE;\n\t\tmemcpy(buf, mem_address, size);\n\t} else {\n\t\tt = gf_fopen(fileName, \"rb\");\n\t\tif (!t) return 0;\n\t\tsize = (u32) fread(buf, 1, M2TS_PROBE_SIZE, t);\n\t\tgf_fclose(t);\n\t\tif ((s32) size <= 0) return 0;\n\t}\n\treturn gf_m2ts_probe_buffer(buf, size);\n}",
"GF_EXPORT\nBool gf_m2ts_probe_data(const u8 *data, u32 size)\n{\n\tsize /= 188;\n\tsize *= 188;\n\treturn gf_m2ts_probe_buffer((char *) data, size);\n}",
"\nstatic void rewrite_pts_dts(unsigned char *ptr, u64 TS)\n{\n\tptr[0] &= 0xf1;\n\tptr[0] |= (unsigned char)((TS&0x1c0000000ULL)>>29);\n\tptr[1] = (unsigned char)((TS&0x03fc00000ULL)>>22);\n\tptr[2] &= 0x1;\n\tptr[2] |= (unsigned char)((TS&0x0003f8000ULL)>>14);\n\tptr[3] = (unsigned char)((TS&0x000007f80ULL)>>7);\n\tptr[4] &= 0x1;\n\tptr[4] |= (unsigned char)((TS&0x00000007fULL)<<1);",
"\tassert(((u64)(ptr[0]&0xe)<<29) + ((u64)ptr[1]<<22) + ((u64)(ptr[2]&0xfe)<<14) + ((u64)ptr[3]<<7) + ((ptr[4]&0xfe)>>1) == TS);\n}",
"#define ADJUST_TIMESTAMP(_TS) \\\n\tif (_TS < (u64) -ts_shift) _TS = pcr_mod + _TS + ts_shift; \\\n\telse _TS = _TS + ts_shift; \\\n\twhile (_TS > pcr_mod) _TS -= pcr_mod; \\",
"GF_EXPORT\nGF_Err gf_m2ts_restamp(u8 *buffer, u32 size, s64 ts_shift, u8 *is_pes)\n{\n\tu32 done = 0;\n\tu64 pcr_mod;\n//\tif (!ts_shift) return GF_OK;",
"\tpcr_mod = 0x80000000;\n\tpcr_mod*=4;\n\twhile (done + 188 <= size) {\n\t\tu8 *pesh;\n\t\tu8 *pck;\n\t\tu64 pcr_base=0, pcr_ext=0;\n\t\tu16 pid;\n\t\tu8 adaptation_field, adaptation_field_length;",
"\t\tpck = (u8*) buffer+done;\n\t\tif (pck[0]!=0x47) {\n\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[M2TS Restamp] Invalid sync byte %X\\n\", pck[0]));\n\t\t\treturn GF_NON_COMPLIANT_BITSTREAM;\n\t\t}\n\t\tpid = ((pck[1] & 0x1f) <<8 ) + pck[2];",
"\t\tadaptation_field_length = 0;\n\t\tadaptation_field = (pck[3] >> 4) & 0x3;\n\t\tif ((adaptation_field==2) || (adaptation_field==3)) {\n\t\t\tadaptation_field_length = pck[4];\n\t\t\tif ( pck[5]&0x10 /*PCR_flag*/) {\n\t\t\t\tpcr_base = (((u64)pck[6])<<25) + (pck[7]<<17) + (pck[8]<<9) + (pck[9]<<1) + (pck[10]>>7);\n\t\t\t\tpcr_ext = ((pck[10]&1)<<8) + pck[11];",
"\t\t\t\tADJUST_TIMESTAMP(pcr_base);",
"\t\t\t\tpck[6] = (unsigned char)(0xff&(pcr_base>>25));\n\t\t\t\tpck[7] = (unsigned char)(0xff&(pcr_base>>17));\n\t\t\t\tpck[8] = (unsigned char)(0xff&(pcr_base>>9));\n\t\t\t\tpck[9] = (unsigned char)(0xff&(pcr_base>>1));\n\t\t\t\tpck[10] = (unsigned char)(((0x1&pcr_base)<<7) | 0x7e | ((0x100&pcr_ext)>>8));\n\t\t\t\tif (pcr_ext != ((pck[10]&1)<<8) + pck[11]) {\n\t\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, (\"[M2TS Restamp] Sanity check failed for PCR restamping\\n\"));\n\t\t\t\t\treturn GF_IO_ERR;\n\t\t\t\t}\n\t\t\t\tpck[11] = (unsigned char)(0xff&pcr_ext);\n\t\t\t}\n\t\t\t/*add adaptation_field_length field*/\n\t\t\tadaptation_field_length++;\n\t\t}\n\t\tif (!is_pes[pid] || !(pck[1]&0x40)) {\n\t\t\tdone+=188;\n\t\t\tcontinue;\n\t\t}",
"\t\tpesh = &pck[4+adaptation_field_length];",
"\t\tif ((pesh[0]==0x00) && (pesh[1]==0x00) && (pesh[2]==0x01)) {\n\t\t\tBool has_pts, has_dts;\n\t\t\tif ((pesh[6]&0xc0)!=0x80) {\n\t\t\t\tdone+=188;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\thas_pts = (pesh[7]&0x80);\n\t\t\thas_dts = has_pts ? (pesh[7]&0x40) : 0;",
"\t\t\tif (has_pts) {\n\t\t\t\tu64 PTS;\n\t\t\t\tif (((pesh[9]&0xe0)>>4)!=0x2) {\n\t\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[M2TS Restamp] PID %4d: Wrong PES header, PTS decoding: '0010' expected\\n\", pid));\n\t\t\t\t\tdone+=188;\n\t\t\t\t\tcontinue;\n\t\t\t\t}",
"\t\t\t\tPTS = gf_m2ts_get_pts(pesh + 9);\n\t\t\t\tADJUST_TIMESTAMP(PTS);\n\t\t\t\trewrite_pts_dts(pesh+9, PTS);\n\t\t\t}",
"\t\t\tif (has_dts) {\n\t\t\t\tu64 DTS = gf_m2ts_get_pts(pesh + 14);\n\t\t\t\tADJUST_TIMESTAMP(DTS);\n\t\t\t\trewrite_pts_dts(pesh+14, DTS);\n\t\t\t}\n\t\t} else {\n\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[M2TS Restamp] PID %4d: Wrong PES not beginning with start code\\n\", pid));\n\t\t}\n\t\tdone+=188;\n\t}\n\treturn GF_OK;\n}",
"#endif /*GPAC_DISABLE_MPEG2TS*/"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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": [1176], "buggy_code_start_loc": [1155], "filenames": ["src/media_tools/mpegts.c"], "fixing_code_end_loc": [1184], "fixing_code_start_loc": [1155], "message": "An issue was discovered in libgpac.a in GPAC before 0.8.0, as demonstrated by MP4Box. It contains a Use-After-Free vulnerability in gf_m2ts_process_pmt in media_tools/mpegts.c that can cause a denial of service via a crafted MP4 file.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*", "matchCriteriaId": "123D0430-86B1-40BF-9B43-C782CC2EDDE8", "versionEndExcluding": "0.8.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "An issue was discovered in libgpac.a in GPAC before 0.8.0, as demonstrated by MP4Box. It contains a Use-After-Free vulnerability in gf_m2ts_process_pmt in media_tools/mpegts.c that can cause a denial of service via a crafted MP4 file."}, {"lang": "es", "value": "Se detect\u00f3 un problema en libgpac.a en GPAC versiones anteriores a 0.8.0, como es demostrado por MP4Box. Contiene una vulnerabilidad de Uso de la Memoria Previamente Liberada en la funci\u00f3n gf_m2ts_process_pmt en el archivo media_tools/mpegts.c que puede causar una denegaci\u00f3n de servicio por medio de un archivo MP4 dise\u00f1ado."}], "evaluatorComment": null, "id": "CVE-2019-20628", "lastModified": "2020-03-25T13:51:32.640", "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": true}], "cvssMetricV30": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 5.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H", "version": "3.1"}, "exploitabilityScore": 1.8, "impactScore": 3.6, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2020-03-24T19:15:20.947", "references": [{"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/gpac/gpac/commit/1ab4860609f2e7a35634930571e7d0531297e090"}, {"source": "cve@mitre.org", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/gpac/gpac/commit/98b727637e32d1d4824101d8947e2dbd573d4fc8"}, {"source": "cve@mitre.org", "tags": ["Exploit", "Third Party Advisory"], "url": "https://github.com/gpac/gpac/issues/1269"}], "sourceIdentifier": "cve@mitre.org", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-416"}], "source": "nvd@nist.gov", "type": "Primary"}]}, "github_commit_url": "https://github.com/gpac/gpac/commit/1ab4860609f2e7a35634930571e7d0531297e090"}, "type": "CWE-416"}
| 223
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"## [Unreleased]",
"",
"\n## 1.11.0 - 2020-03-13\n### Added",
"*Nothing has been added for this version*",
"### Removed\n- MiddlewareMixin\n- Python 3.4 support\n- Django 2.1 support\n- `mock` dependency",
"### Changed\n- `extra_requires` are now listed in lowercase. This is to workaround a bug in `pip`.\n- Use `trimmed` option on `blocktrans` to avoid garbage newlines in translations.\n- `random_hex` from `django_otp` 0.8.0 will always return a `str`, don't try to decode it.",
"## 1.10.0 - 2019-12-13\n### Added\n- Support for Django 3.0.\n- Optionally install full or light phonenumbers library.",
"### Removed\n- Python 2 support.",
"### Changed\n- Updated translations.",
"## 1.9.1 - 2019-07-07\n### Changed\n- 1.9.0 got pushed with incorrect changelog, no other changes.",
"## 1.9.0 - 2019-07-07\n### Added\n- Support for Django 2.2.\n- Ability to create `PhoneDevice` from Django admin.\n- Support for Python 3.7.",
"## 1.8.0 - 2018-08-03\n### Added\n- Support for Django 2.1.\n- Support for QRcode library up to 6.\n- Translation: Romanian.",
"### Changed\n- Replace `ValidationError` with `SuspiciousOperation` in views.\n- Change the wording in 2FA disable template.\n- Updated translations.",
"## 1.7.0 - 2017-12-19\n### Added\n- Support for Django 2.0.",
"### Removed\n- Django <1.11 support.",
"### Changed\n- Do not list phone method if it is not supported (#225).\n- Pass request kwarg to authentication form (#227).",
"## 1.6.2 - 2017-07-29\n### Fixed\n- Twilio client 6.0 usage (#211).",
"### Changed\n- Updated translation: Russian.",
"## 1.6.1 - 2017-05-11\n### Added\n- Support Twilio client 6.0 (#203).",
"### Fixed\n- `redirect_to` after successful login (#204)",
"### Changed\n- Updated translation: Norwegian Bokmål",
"## 1.6.0 - 2017-04-08\n### Added\n- Support for Django 1.11 (#188).",
"### Removed\n- Django 1.9 support.",
"### Fixed\n- Allow setting `LOGIN_REDIRECT_URL` to a URL (#192).\n- `DisableView` should also take `success_url` parameter (#187).",
"## 1.5.0 - 2017-01-04\n### Added\n- Django 1.10’s MIDDLEWARE support.\n- Allow `success_url` overrides from `urls.py`.\n- Autofocus token input during authentication.\n- Translations: Polish, Italian, Hungarian, Finnish and Danish.",
"### Removed\n- Dropped Python 3.2 and 3.3 support.",
"### Changed\n- Renamed `redirect_url` properties to `success_url` to be consistent with Django.",
"### Fixed\n- Allow Firefox users to enter backup tokens (#177).\n- Allow multiple requests for QR code (#99).\n- Don't add phone number without gateway (#92).\n- Redirect to 2FA profile page after removing a phone (#159)."
] |
[
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
] |
PreciseBugs
|
{"buggy_code_end_loc": [1, 75, 334, 193, 166], "buggy_code_start_loc": [1, 75, 0, 4, 2], "filenames": ["CHANGELOG.md", "docs/configuration.rst", "tests/test_views_login.py", "two_factor/views/core.py", "two_factor/views/utils.py"], "fixing_code_end_loc": [10, 83, 414, 264, 197], "fixing_code_start_loc": [2, 76, 1, 5, 3], "message": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:django_two-factor_authentication_project:django_two-factor_authentication:*:*:*:*:*:*:*:*", "matchCriteriaId": "7D3A415A-770B-405A-9C77-72D6142C79C4", "versionEndExcluding": "1.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading."}, {"lang": "es", "value": "Django Two-Factor Authentication versiones anteriores a 1.12, almacena la contrase\u00f1a del usuario en texto sin cifrar en la sesi\u00f3n del usuario (codificada en base64). La contrase\u00f1a es almacenada en la sesi\u00f3n cuando el usuario introduce su nombre de usuario y contrase\u00f1a, y se elimina una vez que completa la autenticaci\u00f3n al ingresar un c\u00f3digo de autenticaci\u00f3n de dos factores. Esto quiere decir que la contrase\u00f1a es almacenada en texto sin cifrar en la sesi\u00f3n durante un per\u00edodo de tiempo arbitrario, y potencialmente para siempre si el usuario comienza el proceso de inicio de sesi\u00f3n ingresando su nombre de usuario y contrase\u00f1a y luego se sale antes de ingresar su c\u00f3digo de autenticaci\u00f3n de dos factores. La gravedad de este problema depende del tipo de almacenamiento de sesi\u00f3n que haya configurado: en el peor de los casos, si est\u00e1 usando el almacenamiento de sesi\u00f3n de base de datos predeterminado de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en su base de datos. En el mejor de los casos, si est\u00e1 utilizando la sesi\u00f3n de cookies firmada de Django, las contrase\u00f1as de los usuarios solo son almacenadas en texto sin cifrar dentro de la tienda de cookies de su navegador. En el caso com\u00fan de usar el almac\u00e9n de sesiones de cach\u00e9 de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en cualquier almacenamiento de cach\u00e9 que haya configurado (generalmente Memcached o Redis). Esto ha sido corregido en la versi\u00f3n 1.12. Despu\u00e9s de la actualizaci\u00f3n, los usuarios deben asegurarse de eliminar las contrase\u00f1as de texto sin cifrar que hayan sido almacenadas. Por ejemplo, si est\u00e1 usando el back-end de sesi\u00f3n de la base de datos, es probable que quiera eliminar cualquier registro de sesi\u00f3n de la base de datos y purgar esos datos de cualquier copia de seguridad o r\u00e9plica de la base de datos. Adicionalmente, las organizaciones afectadas que han sufrido una violaci\u00f3n de la base de datos al usar una versi\u00f3n afectada deben reportar a sus usuarios que sus contrase\u00f1as de texto sin cifrar han sido comprometidas. Todas las organizaciones deben exhortar a los usuarios cuyas contrase\u00f1as son almacenadas de forma no segura para que cambien estas contrase\u00f1as en los sitios donde se utilizaron. Como soluci\u00f3n alternativa, cambiar el almacenamiento de sesi\u00f3n de Django para usar cookies firmadas en lugar de la base de datos o cach\u00e9 disminuye el impacto de este problema, pero no se debe hacer sin un conocimiento profundo de las compensaciones de seguridad del uso de cookies firmadas en lugar de un almacenamiento de sesi\u00f3n del lado del servidor. No existe manera de mitigar completamente el problema sin actualizar"}], "evaluatorComment": null, "id": "CVE-2020-15105", "lastModified": "2020-07-21T18:06:03.230", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 3.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 3.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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2020-07-10T21:15:10.950", "references": [{"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/blob/master/CHANGELOG.md#112---2020-07-08"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/security/advisories/GHSA-vhr6-pvjm-9qwf"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-312"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-312"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, "type": "CWE-312"}
| 224
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"## [Unreleased]",
"### Added\n- It is possible to set a timeout between a user authenticiating in the LoginView and them needing to re-authenticate. By default this is 10 minutes.",
"### Removed\n- The final step in the LoginView no longer re-validates a user's credentials",
"### Changed\n- Security Fix: LoginView no longer stores credentials in plaintext in the session store",
"\n## 1.11.0 - 2020-03-13\n### Added",
"*Nothing has been added for this version*",
"### Removed\n- MiddlewareMixin\n- Python 3.4 support\n- Django 2.1 support\n- `mock` dependency",
"### Changed\n- `extra_requires` are now listed in lowercase. This is to workaround a bug in `pip`.\n- Use `trimmed` option on `blocktrans` to avoid garbage newlines in translations.\n- `random_hex` from `django_otp` 0.8.0 will always return a `str`, don't try to decode it.",
"## 1.10.0 - 2019-12-13\n### Added\n- Support for Django 3.0.\n- Optionally install full or light phonenumbers library.",
"### Removed\n- Python 2 support.",
"### Changed\n- Updated translations.",
"## 1.9.1 - 2019-07-07\n### Changed\n- 1.9.0 got pushed with incorrect changelog, no other changes.",
"## 1.9.0 - 2019-07-07\n### Added\n- Support for Django 2.2.\n- Ability to create `PhoneDevice` from Django admin.\n- Support for Python 3.7.",
"## 1.8.0 - 2018-08-03\n### Added\n- Support for Django 2.1.\n- Support for QRcode library up to 6.\n- Translation: Romanian.",
"### Changed\n- Replace `ValidationError` with `SuspiciousOperation` in views.\n- Change the wording in 2FA disable template.\n- Updated translations.",
"## 1.7.0 - 2017-12-19\n### Added\n- Support for Django 2.0.",
"### Removed\n- Django <1.11 support.",
"### Changed\n- Do not list phone method if it is not supported (#225).\n- Pass request kwarg to authentication form (#227).",
"## 1.6.2 - 2017-07-29\n### Fixed\n- Twilio client 6.0 usage (#211).",
"### Changed\n- Updated translation: Russian.",
"## 1.6.1 - 2017-05-11\n### Added\n- Support Twilio client 6.0 (#203).",
"### Fixed\n- `redirect_to` after successful login (#204)",
"### Changed\n- Updated translation: Norwegian Bokmål",
"## 1.6.0 - 2017-04-08\n### Added\n- Support for Django 1.11 (#188).",
"### Removed\n- Django 1.9 support.",
"### Fixed\n- Allow setting `LOGIN_REDIRECT_URL` to a URL (#192).\n- `DisableView` should also take `success_url` parameter (#187).",
"## 1.5.0 - 2017-01-04\n### Added\n- Django 1.10’s MIDDLEWARE support.\n- Allow `success_url` overrides from `urls.py`.\n- Autofocus token input during authentication.\n- Translations: Polish, Italian, Hungarian, Finnish and Danish.",
"### Removed\n- Dropped Python 3.2 and 3.3 support.",
"### Changed\n- Renamed `redirect_url` properties to `success_url` to be consistent with Django.",
"### Fixed\n- Allow Firefox users to enter backup tokens (#177).\n- Allow multiple requests for QR code (#99).\n- Don't add phone number without gateway (#92).\n- Redirect to 2FA profile page after removing a phone (#159)."
] |
[
1,
1,
1,
1,
1,
1,
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, 75, 334, 193, 166], "buggy_code_start_loc": [1, 75, 0, 4, 2], "filenames": ["CHANGELOG.md", "docs/configuration.rst", "tests/test_views_login.py", "two_factor/views/core.py", "two_factor/views/utils.py"], "fixing_code_end_loc": [10, 83, 414, 264, 197], "fixing_code_start_loc": [2, 76, 1, 5, 3], "message": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:django_two-factor_authentication_project:django_two-factor_authentication:*:*:*:*:*:*:*:*", "matchCriteriaId": "7D3A415A-770B-405A-9C77-72D6142C79C4", "versionEndExcluding": "1.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading."}, {"lang": "es", "value": "Django Two-Factor Authentication versiones anteriores a 1.12, almacena la contrase\u00f1a del usuario en texto sin cifrar en la sesi\u00f3n del usuario (codificada en base64). La contrase\u00f1a es almacenada en la sesi\u00f3n cuando el usuario introduce su nombre de usuario y contrase\u00f1a, y se elimina una vez que completa la autenticaci\u00f3n al ingresar un c\u00f3digo de autenticaci\u00f3n de dos factores. Esto quiere decir que la contrase\u00f1a es almacenada en texto sin cifrar en la sesi\u00f3n durante un per\u00edodo de tiempo arbitrario, y potencialmente para siempre si el usuario comienza el proceso de inicio de sesi\u00f3n ingresando su nombre de usuario y contrase\u00f1a y luego se sale antes de ingresar su c\u00f3digo de autenticaci\u00f3n de dos factores. La gravedad de este problema depende del tipo de almacenamiento de sesi\u00f3n que haya configurado: en el peor de los casos, si est\u00e1 usando el almacenamiento de sesi\u00f3n de base de datos predeterminado de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en su base de datos. En el mejor de los casos, si est\u00e1 utilizando la sesi\u00f3n de cookies firmada de Django, las contrase\u00f1as de los usuarios solo son almacenadas en texto sin cifrar dentro de la tienda de cookies de su navegador. En el caso com\u00fan de usar el almac\u00e9n de sesiones de cach\u00e9 de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en cualquier almacenamiento de cach\u00e9 que haya configurado (generalmente Memcached o Redis). Esto ha sido corregido en la versi\u00f3n 1.12. Despu\u00e9s de la actualizaci\u00f3n, los usuarios deben asegurarse de eliminar las contrase\u00f1as de texto sin cifrar que hayan sido almacenadas. Por ejemplo, si est\u00e1 usando el back-end de sesi\u00f3n de la base de datos, es probable que quiera eliminar cualquier registro de sesi\u00f3n de la base de datos y purgar esos datos de cualquier copia de seguridad o r\u00e9plica de la base de datos. Adicionalmente, las organizaciones afectadas que han sufrido una violaci\u00f3n de la base de datos al usar una versi\u00f3n afectada deben reportar a sus usuarios que sus contrase\u00f1as de texto sin cifrar han sido comprometidas. Todas las organizaciones deben exhortar a los usuarios cuyas contrase\u00f1as son almacenadas de forma no segura para que cambien estas contrase\u00f1as en los sitios donde se utilizaron. Como soluci\u00f3n alternativa, cambiar el almacenamiento de sesi\u00f3n de Django para usar cookies firmadas en lugar de la base de datos o cach\u00e9 disminuye el impacto de este problema, pero no se debe hacer sin un conocimiento profundo de las compensaciones de seguridad del uso de cookies firmadas en lugar de un almacenamiento de sesi\u00f3n del lado del servidor. No existe manera de mitigar completamente el problema sin actualizar"}], "evaluatorComment": null, "id": "CVE-2020-15105", "lastModified": "2020-07-21T18:06:03.230", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 3.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 3.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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2020-07-10T21:15:10.950", "references": [{"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/blob/master/CHANGELOG.md#112---2020-07-08"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/security/advisories/GHSA-vhr6-pvjm-9qwf"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-312"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-312"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, "type": "CWE-312"}
| 224
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"Configuration\n=============",
"General Settings\n----------------",
"``TWO_FACTOR_PATCH_ADMIN`` (default: ``True``)\n Whether the Django admin is patched to use the default login view.",
" .. warning::\n The admin currently does not enforce one-time passwords being set for\n admin users.",
"``TWO_FACTOR_CALL_GATEWAY`` (default: ``None``)\n Which gateway to use for making phone calls. Should be set to a module or\n object providing a ``make_call`` method. Currently two gateways are bundled:",
" * ``'two_factor.gateways.twilio.gateway.Twilio'`` for making real phone calls using\n Twilio_.\n * ``'two_factor.gateways.fake.Fake'`` for development, recording tokens to the\n default logger.",
"``TWO_FACTOR_SMS_GATEWAY`` (default: ``None``)\n Which gateway to use for sending text messages. Should be set to a module or\n object providing a ``send_sms`` method. Currently two gateways are bundled:",
" * ``'two_factor.gateways.twilio.gateway.Twilio'`` for sending real text messages using\n Twilio_.\n * ``'two_factor.gateways.fake.Fake'`` for development, recording tokens to the\n default logger.",
"``LOGIN_URL``\n Should point to the login view provided by this application as described in\n setup. This login view handles password authentication followed by a one-time\n password exchange if enabled for that account. This can be a URL path or URL\n name as defined in the Django documentation.",
" See also LOGIN_URL_.",
"``LOGIN_REDIRECT_URL``\n This application provides a basic page for managing one's account. This view\n is entirely optional and could be implemented in a custom view. This can be a\n URL path or URL name as defined in the Django documentation.",
" See also LOGIN_REDIRECT_URL_.",
"``LOGOUT_REDIRECT_URL``\n Should point to a view that the user is redirected to after loging out. It was\n added in Django 1.10, and also adapted by this application. This can be a\n URL path or URL name as defined in the Django documentation.",
" See also LOGOUT_REDIRECT_URL_.",
"``TWO_FACTOR_QR_FACTORY``\n The default generator for the QR code images is set to SVG. This\n does not require any further dependencies, however it does not work\n on IE8 and below. If you have PIL, Pillow or pyimaging installed\n you may wish to use PNG images instead.",
" * ``'qrcode.image.pil.PilImage'`` may be used for PIL/Pillow\n * ``'qrcode.image.pure.PymagingImage'`` may be used for pyimaging",
" For more QR factories that are available see python-qrcode_.",
"``TWO_FACTOR_TOTP_DIGITS`` (default: ``6``)\n The number of digits to use for TOTP tokens, can be set to 6 or 8. This\n setting will be used for tokens delivered by phone call or text message and\n newly configured token generators. Existing token generator devices will not\n be affected.",
" .. warning::\n The Google Authenticator app does not support 8 digit codes (see\n `the upstream ticket`_). Don't set this option to 8 unless all of your\n users use a 8 digit compatible token generator app.\n",
"",
"``PHONENUMBER_DEFAULT_REGION`` (default: ``None``)\n The default region for parsing phone numbers. If your application's primary\n audience is a certain country, setting the region to that country allows\n entering phone numbers without that country's country code.",
"Twilio Gateway\n--------------\nTo use the Twilio gateway, you need first to install the `Twilio client`_:",
".. code-block:: console",
" $ pip install twilio",
"Next, add additional urls to your config:",
".. code-block:: python",
" # urls.py\n from two_factor.gateways.twilio.urls import urlpatterns as tf_twilio_urls\n urlpatterns = [\n url(r'', include(tf_twilio_urls)),\n ...\n ]",
"Additionally, you need to enable the ``ThreadLocals`` middleware:",
".. code-block:: python",
" MIDDLEWARE = (\n ...",
" # Always include for two-factor auth\n 'django_otp.middleware.OTPMiddleware',",
" # Include for twilio gateway\n 'two_factor.middleware.threadlocals.ThreadLocals',\n )",
"\n.. autoclass:: two_factor.gateways.twilio.gateway.Twilio",
"Fake Gateway\n------------\n.. autoclass:: two_factor.gateways.fake.Fake",
".. _LOGIN_URL: https://docs.djangoproject.com/en/dev/ref/settings/#login-url\n.. _LOGIN_REDIRECT_URL: https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url\n.. _LOGOUT_REDIRECT_URL: https://docs.djangoproject.com/en/dev/ref/settings/#logout-redirect-url\n.. _Twilio: http://www.twilio.com/\n.. _`Twilio client`: https://pypi.python.org/pypi/twilio\n.. _python-qrcode: https://pypi.python.org/pypi/qrcode\n.. _`the upstream ticket`: https://code.google.com/p/google-authenticator/issues/detail?id=327"
] |
[
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": [1, 75, 334, 193, 166], "buggy_code_start_loc": [1, 75, 0, 4, 2], "filenames": ["CHANGELOG.md", "docs/configuration.rst", "tests/test_views_login.py", "two_factor/views/core.py", "two_factor/views/utils.py"], "fixing_code_end_loc": [10, 83, 414, 264, 197], "fixing_code_start_loc": [2, 76, 1, 5, 3], "message": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:django_two-factor_authentication_project:django_two-factor_authentication:*:*:*:*:*:*:*:*", "matchCriteriaId": "7D3A415A-770B-405A-9C77-72D6142C79C4", "versionEndExcluding": "1.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading."}, {"lang": "es", "value": "Django Two-Factor Authentication versiones anteriores a 1.12, almacena la contrase\u00f1a del usuario en texto sin cifrar en la sesi\u00f3n del usuario (codificada en base64). La contrase\u00f1a es almacenada en la sesi\u00f3n cuando el usuario introduce su nombre de usuario y contrase\u00f1a, y se elimina una vez que completa la autenticaci\u00f3n al ingresar un c\u00f3digo de autenticaci\u00f3n de dos factores. Esto quiere decir que la contrase\u00f1a es almacenada en texto sin cifrar en la sesi\u00f3n durante un per\u00edodo de tiempo arbitrario, y potencialmente para siempre si el usuario comienza el proceso de inicio de sesi\u00f3n ingresando su nombre de usuario y contrase\u00f1a y luego se sale antes de ingresar su c\u00f3digo de autenticaci\u00f3n de dos factores. La gravedad de este problema depende del tipo de almacenamiento de sesi\u00f3n que haya configurado: en el peor de los casos, si est\u00e1 usando el almacenamiento de sesi\u00f3n de base de datos predeterminado de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en su base de datos. En el mejor de los casos, si est\u00e1 utilizando la sesi\u00f3n de cookies firmada de Django, las contrase\u00f1as de los usuarios solo son almacenadas en texto sin cifrar dentro de la tienda de cookies de su navegador. En el caso com\u00fan de usar el almac\u00e9n de sesiones de cach\u00e9 de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en cualquier almacenamiento de cach\u00e9 que haya configurado (generalmente Memcached o Redis). Esto ha sido corregido en la versi\u00f3n 1.12. Despu\u00e9s de la actualizaci\u00f3n, los usuarios deben asegurarse de eliminar las contrase\u00f1as de texto sin cifrar que hayan sido almacenadas. Por ejemplo, si est\u00e1 usando el back-end de sesi\u00f3n de la base de datos, es probable que quiera eliminar cualquier registro de sesi\u00f3n de la base de datos y purgar esos datos de cualquier copia de seguridad o r\u00e9plica de la base de datos. Adicionalmente, las organizaciones afectadas que han sufrido una violaci\u00f3n de la base de datos al usar una versi\u00f3n afectada deben reportar a sus usuarios que sus contrase\u00f1as de texto sin cifrar han sido comprometidas. Todas las organizaciones deben exhortar a los usuarios cuyas contrase\u00f1as son almacenadas de forma no segura para que cambien estas contrase\u00f1as en los sitios donde se utilizaron. Como soluci\u00f3n alternativa, cambiar el almacenamiento de sesi\u00f3n de Django para usar cookies firmadas en lugar de la base de datos o cach\u00e9 disminuye el impacto de este problema, pero no se debe hacer sin un conocimiento profundo de las compensaciones de seguridad del uso de cookies firmadas en lugar de un almacenamiento de sesi\u00f3n del lado del servidor. No existe manera de mitigar completamente el problema sin actualizar"}], "evaluatorComment": null, "id": "CVE-2020-15105", "lastModified": "2020-07-21T18:06:03.230", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 3.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 3.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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2020-07-10T21:15:10.950", "references": [{"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/blob/master/CHANGELOG.md#112---2020-07-08"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/security/advisories/GHSA-vhr6-pvjm-9qwf"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-312"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-312"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, "type": "CWE-312"}
| 224
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"Configuration\n=============",
"General Settings\n----------------",
"``TWO_FACTOR_PATCH_ADMIN`` (default: ``True``)\n Whether the Django admin is patched to use the default login view.",
" .. warning::\n The admin currently does not enforce one-time passwords being set for\n admin users.",
"``TWO_FACTOR_CALL_GATEWAY`` (default: ``None``)\n Which gateway to use for making phone calls. Should be set to a module or\n object providing a ``make_call`` method. Currently two gateways are bundled:",
" * ``'two_factor.gateways.twilio.gateway.Twilio'`` for making real phone calls using\n Twilio_.\n * ``'two_factor.gateways.fake.Fake'`` for development, recording tokens to the\n default logger.",
"``TWO_FACTOR_SMS_GATEWAY`` (default: ``None``)\n Which gateway to use for sending text messages. Should be set to a module or\n object providing a ``send_sms`` method. Currently two gateways are bundled:",
" * ``'two_factor.gateways.twilio.gateway.Twilio'`` for sending real text messages using\n Twilio_.\n * ``'two_factor.gateways.fake.Fake'`` for development, recording tokens to the\n default logger.",
"``LOGIN_URL``\n Should point to the login view provided by this application as described in\n setup. This login view handles password authentication followed by a one-time\n password exchange if enabled for that account. This can be a URL path or URL\n name as defined in the Django documentation.",
" See also LOGIN_URL_.",
"``LOGIN_REDIRECT_URL``\n This application provides a basic page for managing one's account. This view\n is entirely optional and could be implemented in a custom view. This can be a\n URL path or URL name as defined in the Django documentation.",
" See also LOGIN_REDIRECT_URL_.",
"``LOGOUT_REDIRECT_URL``\n Should point to a view that the user is redirected to after loging out. It was\n added in Django 1.10, and also adapted by this application. This can be a\n URL path or URL name as defined in the Django documentation.",
" See also LOGOUT_REDIRECT_URL_.",
"``TWO_FACTOR_QR_FACTORY``\n The default generator for the QR code images is set to SVG. This\n does not require any further dependencies, however it does not work\n on IE8 and below. If you have PIL, Pillow or pyimaging installed\n you may wish to use PNG images instead.",
" * ``'qrcode.image.pil.PilImage'`` may be used for PIL/Pillow\n * ``'qrcode.image.pure.PymagingImage'`` may be used for pyimaging",
" For more QR factories that are available see python-qrcode_.",
"``TWO_FACTOR_TOTP_DIGITS`` (default: ``6``)\n The number of digits to use for TOTP tokens, can be set to 6 or 8. This\n setting will be used for tokens delivered by phone call or text message and\n newly configured token generators. Existing token generator devices will not\n be affected.",
" .. warning::\n The Google Authenticator app does not support 8 digit codes (see\n `the upstream ticket`_). Don't set this option to 8 unless all of your\n users use a 8 digit compatible token generator app.\n",
"``TWO_FACTOR_LOGIN_TIMEOUT`` (default ``600``)\n The number of seconds between a user successfully passing the \"authentication\"\n step (usually by entering a valid username and password) and them having to\n restart the login flow and re-authenticate. This ensures that users can't sit\n indefinately in a state of having entered their password successfully but not\n having passed two factor authentication. Set to ``0`` to disable.\n",
"``PHONENUMBER_DEFAULT_REGION`` (default: ``None``)\n The default region for parsing phone numbers. If your application's primary\n audience is a certain country, setting the region to that country allows\n entering phone numbers without that country's country code.",
"Twilio Gateway\n--------------\nTo use the Twilio gateway, you need first to install the `Twilio client`_:",
".. code-block:: console",
" $ pip install twilio",
"Next, add additional urls to your config:",
".. code-block:: python",
" # urls.py\n from two_factor.gateways.twilio.urls import urlpatterns as tf_twilio_urls\n urlpatterns = [\n url(r'', include(tf_twilio_urls)),\n ...\n ]",
"Additionally, you need to enable the ``ThreadLocals`` middleware:",
".. code-block:: python",
" MIDDLEWARE = (\n ...",
" # Always include for two-factor auth\n 'django_otp.middleware.OTPMiddleware',",
" # Include for twilio gateway\n 'two_factor.middleware.threadlocals.ThreadLocals',\n )",
"\n.. autoclass:: two_factor.gateways.twilio.gateway.Twilio",
"Fake Gateway\n------------\n.. autoclass:: two_factor.gateways.fake.Fake",
".. _LOGIN_URL: https://docs.djangoproject.com/en/dev/ref/settings/#login-url\n.. _LOGIN_REDIRECT_URL: https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url\n.. _LOGOUT_REDIRECT_URL: https://docs.djangoproject.com/en/dev/ref/settings/#logout-redirect-url\n.. _Twilio: http://www.twilio.com/\n.. _`Twilio client`: https://pypi.python.org/pypi/twilio\n.. _python-qrcode: https://pypi.python.org/pypi/qrcode\n.. _`the upstream ticket`: https://code.google.com/p/google-authenticator/issues/detail?id=327"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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, 75, 334, 193, 166], "buggy_code_start_loc": [1, 75, 0, 4, 2], "filenames": ["CHANGELOG.md", "docs/configuration.rst", "tests/test_views_login.py", "two_factor/views/core.py", "two_factor/views/utils.py"], "fixing_code_end_loc": [10, 83, 414, 264, 197], "fixing_code_start_loc": [2, 76, 1, 5, 3], "message": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:django_two-factor_authentication_project:django_two-factor_authentication:*:*:*:*:*:*:*:*", "matchCriteriaId": "7D3A415A-770B-405A-9C77-72D6142C79C4", "versionEndExcluding": "1.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading."}, {"lang": "es", "value": "Django Two-Factor Authentication versiones anteriores a 1.12, almacena la contrase\u00f1a del usuario en texto sin cifrar en la sesi\u00f3n del usuario (codificada en base64). La contrase\u00f1a es almacenada en la sesi\u00f3n cuando el usuario introduce su nombre de usuario y contrase\u00f1a, y se elimina una vez que completa la autenticaci\u00f3n al ingresar un c\u00f3digo de autenticaci\u00f3n de dos factores. Esto quiere decir que la contrase\u00f1a es almacenada en texto sin cifrar en la sesi\u00f3n durante un per\u00edodo de tiempo arbitrario, y potencialmente para siempre si el usuario comienza el proceso de inicio de sesi\u00f3n ingresando su nombre de usuario y contrase\u00f1a y luego se sale antes de ingresar su c\u00f3digo de autenticaci\u00f3n de dos factores. La gravedad de este problema depende del tipo de almacenamiento de sesi\u00f3n que haya configurado: en el peor de los casos, si est\u00e1 usando el almacenamiento de sesi\u00f3n de base de datos predeterminado de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en su base de datos. En el mejor de los casos, si est\u00e1 utilizando la sesi\u00f3n de cookies firmada de Django, las contrase\u00f1as de los usuarios solo son almacenadas en texto sin cifrar dentro de la tienda de cookies de su navegador. En el caso com\u00fan de usar el almac\u00e9n de sesiones de cach\u00e9 de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en cualquier almacenamiento de cach\u00e9 que haya configurado (generalmente Memcached o Redis). Esto ha sido corregido en la versi\u00f3n 1.12. Despu\u00e9s de la actualizaci\u00f3n, los usuarios deben asegurarse de eliminar las contrase\u00f1as de texto sin cifrar que hayan sido almacenadas. Por ejemplo, si est\u00e1 usando el back-end de sesi\u00f3n de la base de datos, es probable que quiera eliminar cualquier registro de sesi\u00f3n de la base de datos y purgar esos datos de cualquier copia de seguridad o r\u00e9plica de la base de datos. Adicionalmente, las organizaciones afectadas que han sufrido una violaci\u00f3n de la base de datos al usar una versi\u00f3n afectada deben reportar a sus usuarios que sus contrase\u00f1as de texto sin cifrar han sido comprometidas. Todas las organizaciones deben exhortar a los usuarios cuyas contrase\u00f1as son almacenadas de forma no segura para que cambien estas contrase\u00f1as en los sitios donde se utilizaron. Como soluci\u00f3n alternativa, cambiar el almacenamiento de sesi\u00f3n de Django para usar cookies firmadas en lugar de la base de datos o cach\u00e9 disminuye el impacto de este problema, pero no se debe hacer sin un conocimiento profundo de las compensaciones de seguridad del uso de cookies firmadas en lugar de un almacenamiento de sesi\u00f3n del lado del servidor. No existe manera de mitigar completamente el problema sin actualizar"}], "evaluatorComment": null, "id": "CVE-2020-15105", "lastModified": "2020-07-21T18:06:03.230", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 3.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 3.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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2020-07-10T21:15:10.950", "references": [{"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/blob/master/CHANGELOG.md#112---2020-07-08"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/security/advisories/GHSA-vhr6-pvjm-9qwf"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-312"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-312"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, "type": "CWE-312"}
| 224
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"",
"from unittest import mock",
"from django.conf import settings\nfrom django.shortcuts import resolve_url\nfrom django.test import TestCase\nfrom django.test.utils import override_settings\nfrom django.urls import reverse\nfrom django_otp import DEVICE_ID_SESSION_KEY\nfrom django_otp.oath import totp",
"from two_factor.models import random_hex_str",
"from .utils import UserMixin",
"\nclass LoginTest(UserMixin, TestCase):\n def _post(self, data=None):\n return self.client.post(reverse('two_factor:login'), data=data)",
" def test_form(self):\n response = self.client.get(reverse('two_factor:login'))\n self.assertContains(response, 'Password:')",
" def test_invalid_login(self):\n response = self._post({'auth-username': 'unknown',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Please enter a correct')\n self.assertContains(response, 'and password.')",
" @mock.patch('two_factor.views.core.signals.user_verified.send')\n def test_valid_login(self, mock_signal):\n self.create_user()\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))",
" # No signal should be fired for non-verified user logins.\n self.assertFalse(mock_signal.called)",
" def test_valid_login_with_custom_redirect(self):\n redirect_url = reverse('two_factor:setup')\n self.create_user()\n response = self.client.post(\n '%s?%s' % (reverse('two_factor:login'), 'next=' + redirect_url),\n {'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, redirect_url)",
" def test_valid_login_with_custom_post_redirect(self):\n redirect_url = reverse('two_factor:setup')\n self.create_user()\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth',\n 'next': redirect_url})\n self.assertRedirects(response, redirect_url)",
" def test_valid_login_with_redirect_field_name(self):\n redirect_url = reverse('two_factor:setup')\n self.create_user()\n response = self.client.post(\n '%s?%s' % (reverse('custom-field-name-login'), 'next_page=' + redirect_url),\n {'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, redirect_url)",
" def test_valid_login_with_allowed_external_redirect(self):\n redirect_url = 'https://test.allowed-success-url.com'\n self.create_user()\n response = self.client.post(\n '%s?%s' % (reverse('custom-allowed-success-url-login'), 'next=' + redirect_url),\n {'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, redirect_url, fetch_redirect_response=False)",
" def test_valid_login_with_disallowed_external_redirect(self):\n redirect_url = 'https://test.disallowed-success-url.com'\n self.create_user()\n response = self.client.post(\n '%s?%s' % (reverse('custom-allowed-success-url-login'), 'next=' + redirect_url),\n {'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, reverse('two_factor:profile'), fetch_redirect_response=False)\n",
"",
"\n def test_valid_login_with_redirect_authenticated_user(self):\n user = self.create_user()\n response = self.client.get(\n reverse('custom-redirect-authenticated-user-login')\n )\n self.assertEqual(response.status_code, 200)\n self.client.force_login(user)\n response = self.client.get(\n reverse('custom-redirect-authenticated-user-login')\n )\n self.assertRedirects(response, reverse('two_factor:profile'))",
" def test_valid_login_with_redirect_authenticated_user_loop(self):\n redirect_url = reverse('custom-redirect-authenticated-user-login')\n user = self.create_user()\n self.client.force_login(user)\n with self.assertRaises(ValueError):\n self.client.get(\n '%s?%s' % (reverse('custom-redirect-authenticated-user-login'), 'next=' + redirect_url),\n )",
" @mock.patch('two_factor.views.core.signals.user_verified.send')\n def test_with_generator(self, mock_signal):\n user = self.create_user()\n device = user.totpdevice_set.create(name='default',\n key=random_hex_str())",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Token:')",
" response = self._post({'token-otp_token': '123456',\n 'login_view-current_step': 'token'})\n self.assertEqual(response.context_data['wizard']['form'].errors,\n {'__all__': ['Invalid token. Please make sure you '\n 'have entered it correctly.']})",
" # reset throttle because we're not testing that\n device.throttle_reset()",
" response = self._post({'token-otp_token': totp(device.bin_key),\n 'login_view-current_step': 'token'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))",
" self.assertEqual(device.persistent_id,\n self.client.session.get(DEVICE_ID_SESSION_KEY))",
" # Check that the signal was fired.\n mock_signal.assert_called_with(sender=mock.ANY, request=mock.ANY, user=user, device=device)",
" @mock.patch('two_factor.views.core.signals.user_verified.send')\n def test_throttle_with_generator(self, mock_signal):\n user = self.create_user()\n device = user.totpdevice_set.create(name='default',\n key=random_hex_str())",
" self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})",
" # throttle device\n device.throttle_increment()",
" response = self._post({'token-otp_token': totp(device.bin_key),\n 'login_view-current_step': 'token'})\n self.assertEqual(response.context_data['wizard']['form'].errors,\n {'__all__': ['Invalid token. Please make sure you '\n 'have entered it correctly.']})",
" @mock.patch('two_factor.gateways.fake.Fake')\n @mock.patch('two_factor.views.core.signals.user_verified.send')\n @override_settings(\n TWO_FACTOR_SMS_GATEWAY='two_factor.gateways.fake.Fake',\n TWO_FACTOR_CALL_GATEWAY='two_factor.gateways.fake.Fake',\n )\n def test_with_backup_phone(self, mock_signal, fake):\n user = self.create_user()\n for no_digits in (6, 8):\n with self.settings(TWO_FACTOR_TOTP_DIGITS=no_digits):\n user.totpdevice_set.create(name='default', key=random_hex_str(),\n digits=no_digits)\n device = user.phonedevice_set.create(name='backup', number='+31101234567',\n method='sms',\n key=random_hex_str())",
" # Backup phones should be listed on the login form\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Send text message to +31 ** *** **67')",
" # Ask for challenge on invalid device\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'challenge_device': 'MALICIOUS/INPUT/666'})\n self.assertContains(response, 'Send text message to +31 ** *** **67')",
" # Ask for SMS challenge\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'challenge_device': device.persistent_id})\n self.assertContains(response, 'We sent you a text message')\n fake.return_value.send_sms.assert_called_with(\n device=device,\n token=str(totp(device.bin_key, digits=no_digits)).zfill(no_digits))",
" # Ask for phone challenge\n device.method = 'call'\n device.save()\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'challenge_device': device.persistent_id})\n self.assertContains(response, 'We are calling your phone right now')\n fake.return_value.make_call.assert_called_with(\n device=device,\n token=str(totp(device.bin_key, digits=no_digits)).zfill(no_digits))",
" # Valid token should be accepted.\n response = self._post({'token-otp_token': totp(device.bin_key),\n 'login_view-current_step': 'token'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))\n self.assertEqual(device.persistent_id,\n self.client.session.get(DEVICE_ID_SESSION_KEY))",
" # Check that the signal was fired.\n mock_signal.assert_called_with(sender=mock.ANY, request=mock.ANY, user=user, device=device)",
" @mock.patch('two_factor.views.core.signals.user_verified.send')\n def test_with_backup_token(self, mock_signal):\n user = self.create_user()\n user.totpdevice_set.create(name='default', key=random_hex_str())\n device = user.staticdevice_set.create(name='backup')\n device.token_set.create(token='abcdef123')",
" # Backup phones should be listed on the login form\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Backup Token')",
" # Should be able to go to backup tokens step in wizard\n response = self._post({'wizard_goto_step': 'backup'})\n self.assertContains(response, 'backup tokens')",
" # Wrong codes should not be accepted\n response = self._post({'backup-otp_token': 'WRONG',\n 'login_view-current_step': 'backup'})\n self.assertEqual(response.context_data['wizard']['form'].errors,\n {'__all__': ['Invalid token. Please make sure you '\n 'have entered it correctly.']})\n # static devices are throttled\n device.throttle_reset()",
" # Valid token should be accepted.\n response = self._post({'backup-otp_token': 'abcdef123',\n 'login_view-current_step': 'backup'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))",
" # Check that the signal was fired.\n mock_signal.assert_called_with(sender=mock.ANY, request=mock.ANY, user=user, device=device)",
" @mock.patch('two_factor.views.utils.logger')",
" def test_change_password_in_between(self, mock_logger):\n \"\"\"\n When the password of the user is changed while trying to login, should\n not result in errors. Refs #63.\n \"\"\"\n user = self.create_user()\n self.enable_otp()",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Token:')",
" # Now, the password is changed. When the form is submitted, the\n # credentials should be checked again. If that's the case, the\n # login form should note that the credentials are invalid.\n user.set_password('secret2')\n user.save()\n response = self._post({'login_view-current_step': 'token'})\n self.assertContains(response, 'Please enter a correct')\n self.assertContains(response, 'and password.')",
" # Check that a message was logged.\n mock_logger.warning.assert_called_with(\n \"Current step '%s' is no longer valid, returning to last valid \"\n \"step in the wizard.\",\n 'token')",
" @mock.patch('two_factor.views.utils.logger')",
" def test_reset_wizard_state(self, mock_logger):\n self.create_user()\n self.enable_otp()",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Token:')",
" # A GET request resets the state of the wizard...\n self.client.get(reverse('two_factor:login'))",
" # ...so there is no user in this request anymore. As the login flow\n # depends on a user being present, this should be handled gracefully.\n response = self._post({'token-otp_token': '123456',\n 'login_view-current_step': 'token'})\n self.assertContains(response, 'Password:')",
" # Check that a message was logged.\n mock_logger.warning.assert_called_with(\n \"Requested step '%s' is no longer valid, returning to last valid \"\n \"step in the wizard.\",\n 'token')",
" @mock.patch('two_factor.views.utils.logger')\n def test_login_different_user_on_existing_session(self, mock_logger):\n \"\"\"\n This test reproduces the issue where a user is logged in and a different user\n attempts to login.\n \"\"\"\n self.create_user()\n self.create_user(username='vedran@example.com')",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))",
" response = self._post({'auth-username': 'vedran@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))",
" def test_missing_management_data(self):\n # missing management data\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret'})",
" # view should return HTTP 400 Bad Request\n self.assertEqual(response.status_code, 400)\n",
"",
"\nclass BackupTokensTest(UserMixin, TestCase):\n def setUp(self):\n super().setUp()\n self.create_user()\n self.enable_otp()\n self.login_user()",
" def test_empty(self):\n response = self.client.get(reverse('two_factor:backup_tokens'))\n self.assertContains(response, 'You don\\'t have any backup codes yet.')",
" def test_generate(self):\n url = reverse('two_factor:backup_tokens')",
" response = self.client.post(url)\n self.assertRedirects(response, url)",
" response = self.client.get(url)\n first_set = set([token.token for token in\n response.context_data['device'].token_set.all()])\n self.assertNotContains(response, 'You don\\'t have any backup codes '\n 'yet.')\n self.assertEqual(10, len(first_set))",
" # Generating the tokens should give a fresh set\n self.client.post(url)\n response = self.client.get(url)\n second_set = set([token.token for token in\n response.context_data['device'].token_set.all()])\n self.assertNotEqual(first_set, second_set)"
] |
[
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,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1, 75, 334, 193, 166], "buggy_code_start_loc": [1, 75, 0, 4, 2], "filenames": ["CHANGELOG.md", "docs/configuration.rst", "tests/test_views_login.py", "two_factor/views/core.py", "two_factor/views/utils.py"], "fixing_code_end_loc": [10, 83, 414, 264, 197], "fixing_code_start_loc": [2, 76, 1, 5, 3], "message": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:django_two-factor_authentication_project:django_two-factor_authentication:*:*:*:*:*:*:*:*", "matchCriteriaId": "7D3A415A-770B-405A-9C77-72D6142C79C4", "versionEndExcluding": "1.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading."}, {"lang": "es", "value": "Django Two-Factor Authentication versiones anteriores a 1.12, almacena la contrase\u00f1a del usuario en texto sin cifrar en la sesi\u00f3n del usuario (codificada en base64). La contrase\u00f1a es almacenada en la sesi\u00f3n cuando el usuario introduce su nombre de usuario y contrase\u00f1a, y se elimina una vez que completa la autenticaci\u00f3n al ingresar un c\u00f3digo de autenticaci\u00f3n de dos factores. Esto quiere decir que la contrase\u00f1a es almacenada en texto sin cifrar en la sesi\u00f3n durante un per\u00edodo de tiempo arbitrario, y potencialmente para siempre si el usuario comienza el proceso de inicio de sesi\u00f3n ingresando su nombre de usuario y contrase\u00f1a y luego se sale antes de ingresar su c\u00f3digo de autenticaci\u00f3n de dos factores. La gravedad de este problema depende del tipo de almacenamiento de sesi\u00f3n que haya configurado: en el peor de los casos, si est\u00e1 usando el almacenamiento de sesi\u00f3n de base de datos predeterminado de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en su base de datos. En el mejor de los casos, si est\u00e1 utilizando la sesi\u00f3n de cookies firmada de Django, las contrase\u00f1as de los usuarios solo son almacenadas en texto sin cifrar dentro de la tienda de cookies de su navegador. En el caso com\u00fan de usar el almac\u00e9n de sesiones de cach\u00e9 de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en cualquier almacenamiento de cach\u00e9 que haya configurado (generalmente Memcached o Redis). Esto ha sido corregido en la versi\u00f3n 1.12. Despu\u00e9s de la actualizaci\u00f3n, los usuarios deben asegurarse de eliminar las contrase\u00f1as de texto sin cifrar que hayan sido almacenadas. Por ejemplo, si est\u00e1 usando el back-end de sesi\u00f3n de la base de datos, es probable que quiera eliminar cualquier registro de sesi\u00f3n de la base de datos y purgar esos datos de cualquier copia de seguridad o r\u00e9plica de la base de datos. Adicionalmente, las organizaciones afectadas que han sufrido una violaci\u00f3n de la base de datos al usar una versi\u00f3n afectada deben reportar a sus usuarios que sus contrase\u00f1as de texto sin cifrar han sido comprometidas. Todas las organizaciones deben exhortar a los usuarios cuyas contrase\u00f1as son almacenadas de forma no segura para que cambien estas contrase\u00f1as en los sitios donde se utilizaron. Como soluci\u00f3n alternativa, cambiar el almacenamiento de sesi\u00f3n de Django para usar cookies firmadas en lugar de la base de datos o cach\u00e9 disminuye el impacto de este problema, pero no se debe hacer sin un conocimiento profundo de las compensaciones de seguridad del uso de cookies firmadas en lugar de un almacenamiento de sesi\u00f3n del lado del servidor. No existe manera de mitigar completamente el problema sin actualizar"}], "evaluatorComment": null, "id": "CVE-2020-15105", "lastModified": "2020-07-21T18:06:03.230", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 3.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 3.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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2020-07-10T21:15:10.950", "references": [{"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/blob/master/CHANGELOG.md#112---2020-07-08"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/security/advisories/GHSA-vhr6-pvjm-9qwf"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-312"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-312"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, "type": "CWE-312"}
| 224
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"import json",
"from unittest import mock",
"from django.conf import settings\nfrom django.shortcuts import resolve_url\nfrom django.test import TestCase\nfrom django.test.utils import override_settings\nfrom django.urls import reverse\nfrom django_otp import DEVICE_ID_SESSION_KEY\nfrom django_otp.oath import totp",
"from two_factor.models import random_hex_str",
"from .utils import UserMixin",
"\nclass LoginTest(UserMixin, TestCase):\n def _post(self, data=None):\n return self.client.post(reverse('two_factor:login'), data=data)",
" def test_form(self):\n response = self.client.get(reverse('two_factor:login'))\n self.assertContains(response, 'Password:')",
" def test_invalid_login(self):\n response = self._post({'auth-username': 'unknown',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Please enter a correct')\n self.assertContains(response, 'and password.')",
" @mock.patch('two_factor.views.core.signals.user_verified.send')\n def test_valid_login(self, mock_signal):\n self.create_user()\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))",
" # No signal should be fired for non-verified user logins.\n self.assertFalse(mock_signal.called)",
" def test_valid_login_with_custom_redirect(self):\n redirect_url = reverse('two_factor:setup')\n self.create_user()\n response = self.client.post(\n '%s?%s' % (reverse('two_factor:login'), 'next=' + redirect_url),\n {'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, redirect_url)",
" def test_valid_login_with_custom_post_redirect(self):\n redirect_url = reverse('two_factor:setup')\n self.create_user()\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth',\n 'next': redirect_url})\n self.assertRedirects(response, redirect_url)",
" def test_valid_login_with_redirect_field_name(self):\n redirect_url = reverse('two_factor:setup')\n self.create_user()\n response = self.client.post(\n '%s?%s' % (reverse('custom-field-name-login'), 'next_page=' + redirect_url),\n {'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, redirect_url)",
" def test_valid_login_with_allowed_external_redirect(self):\n redirect_url = 'https://test.allowed-success-url.com'\n self.create_user()\n response = self.client.post(\n '%s?%s' % (reverse('custom-allowed-success-url-login'), 'next=' + redirect_url),\n {'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, redirect_url, fetch_redirect_response=False)",
" def test_valid_login_with_disallowed_external_redirect(self):\n redirect_url = 'https://test.disallowed-success-url.com'\n self.create_user()\n response = self.client.post(\n '%s?%s' % (reverse('custom-allowed-success-url-login'), 'next=' + redirect_url),\n {'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, reverse('two_factor:profile'), fetch_redirect_response=False)\n",
" @mock.patch('two_factor.views.core.time')\n def test_valid_login_primary_key_stored(self, mock_time):\n mock_time.time.return_value = 12345.12\n user = self.create_user()\n user.totpdevice_set.create(name='default',\n key=random_hex_str())",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Token:')",
" self.assertEqual(self.client.session['wizard_login_view']['user_pk'], str(user.pk))\n self.assertEqual(\n self.client.session['wizard_login_view']['user_backend'],\n 'django.contrib.auth.backends.ModelBackend')\n self.assertEqual(self.client.session['wizard_login_view']['authentication_time'], 12345)",
" @mock.patch('two_factor.views.core.time')\n def test_valid_login_post_auth_session_clear_of_form_data(self, mock_time):\n mock_time.time.return_value = 12345.12\n user = self.create_user()\n user.totpdevice_set.create(name='default',\n key=random_hex_str())",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Token:')",
" self.assertEqual(self.client.session['wizard_login_view']['user_pk'], str(user.pk))\n self.assertEqual(self.client.session['wizard_login_view']['step'], 'token')\n self.assertEqual(self.client.session['wizard_login_view']['step_data'], {'auth': None})\n self.assertEqual(self.client.session['wizard_login_view']['step_files'], {'auth': {}})\n self.assertEqual(self.client.session['wizard_login_view']['validated_step_data'], {})",
" @mock.patch('two_factor.views.core.logger')\n @mock.patch('two_factor.views.core.time')\n def test_valid_login_expired(self, mock_time, mock_logger):\n mock_time.time.return_value = 12345.12\n user = self.create_user()\n device = user.totpdevice_set.create(name='default',\n key=random_hex_str())",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Token:')",
" self.assertEqual(self.client.session['wizard_login_view']['user_pk'], str(user.pk))\n self.assertEqual(\n self.client.session['wizard_login_view']['user_backend'],\n 'django.contrib.auth.backends.ModelBackend')\n self.assertEqual(self.client.session['wizard_login_view']['authentication_time'], 12345)",
" mock_time.time.return_value = 20345.12",
" response = self._post({'token-otp_token': totp(device.bin_key),\n 'login_view-current_step': 'token'})\n self.assertEqual(response.status_code, 200)\n self.assertNotContains(response, 'Token:')\n self.assertContains(response, 'Password:')\n self.assertContains(response, 'Your session has timed out. Please login again.')",
" # Check that a message was logged.\n mock_logger.info.assert_called_with(\n \"User's authentication flow has timed out. The user \"\n \"has been redirected to the initial auth form.\")",
" @override_settings(TWO_FACTOR_LOGIN_TIMEOUT=0)\n @mock.patch('two_factor.views.core.time')\n def test_valid_login_no_timeout(self, mock_time):\n mock_time.time.return_value = 12345.12\n user = self.create_user()\n device = user.totpdevice_set.create(name='default',\n key=random_hex_str())",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Token:')",
" self.assertEqual(self.client.session['wizard_login_view']['user_pk'], str(user.pk))\n self.assertEqual(\n self.client.session['wizard_login_view']['user_backend'],\n 'django.contrib.auth.backends.ModelBackend')\n self.assertEqual(self.client.session['wizard_login_view']['authentication_time'], 12345)",
" mock_time.time.return_value = 20345.12",
" response = self._post({'token-otp_token': totp(device.bin_key),\n 'login_view-current_step': 'token'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))\n self.assertEqual(self.client.session['_auth_user_id'], str(user.pk))",
"\n def test_valid_login_with_redirect_authenticated_user(self):\n user = self.create_user()\n response = self.client.get(\n reverse('custom-redirect-authenticated-user-login')\n )\n self.assertEqual(response.status_code, 200)\n self.client.force_login(user)\n response = self.client.get(\n reverse('custom-redirect-authenticated-user-login')\n )\n self.assertRedirects(response, reverse('two_factor:profile'))",
" def test_valid_login_with_redirect_authenticated_user_loop(self):\n redirect_url = reverse('custom-redirect-authenticated-user-login')\n user = self.create_user()\n self.client.force_login(user)\n with self.assertRaises(ValueError):\n self.client.get(\n '%s?%s' % (reverse('custom-redirect-authenticated-user-login'), 'next=' + redirect_url),\n )",
" @mock.patch('two_factor.views.core.signals.user_verified.send')\n def test_with_generator(self, mock_signal):\n user = self.create_user()\n device = user.totpdevice_set.create(name='default',\n key=random_hex_str())",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Token:')",
" response = self._post({'token-otp_token': '123456',\n 'login_view-current_step': 'token'})\n self.assertEqual(response.context_data['wizard']['form'].errors,\n {'__all__': ['Invalid token. Please make sure you '\n 'have entered it correctly.']})",
" # reset throttle because we're not testing that\n device.throttle_reset()",
" response = self._post({'token-otp_token': totp(device.bin_key),\n 'login_view-current_step': 'token'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))",
" self.assertEqual(device.persistent_id,\n self.client.session.get(DEVICE_ID_SESSION_KEY))",
" # Check that the signal was fired.\n mock_signal.assert_called_with(sender=mock.ANY, request=mock.ANY, user=user, device=device)",
" @mock.patch('two_factor.views.core.signals.user_verified.send')\n def test_throttle_with_generator(self, mock_signal):\n user = self.create_user()\n device = user.totpdevice_set.create(name='default',\n key=random_hex_str())",
" self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})",
" # throttle device\n device.throttle_increment()",
" response = self._post({'token-otp_token': totp(device.bin_key),\n 'login_view-current_step': 'token'})\n self.assertEqual(response.context_data['wizard']['form'].errors,\n {'__all__': ['Invalid token. Please make sure you '\n 'have entered it correctly.']})",
" @mock.patch('two_factor.gateways.fake.Fake')\n @mock.patch('two_factor.views.core.signals.user_verified.send')\n @override_settings(\n TWO_FACTOR_SMS_GATEWAY='two_factor.gateways.fake.Fake',\n TWO_FACTOR_CALL_GATEWAY='two_factor.gateways.fake.Fake',\n )\n def test_with_backup_phone(self, mock_signal, fake):\n user = self.create_user()\n for no_digits in (6, 8):\n with self.settings(TWO_FACTOR_TOTP_DIGITS=no_digits):\n user.totpdevice_set.create(name='default', key=random_hex_str(),\n digits=no_digits)\n device = user.phonedevice_set.create(name='backup', number='+31101234567',\n method='sms',\n key=random_hex_str())",
" # Backup phones should be listed on the login form\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Send text message to +31 ** *** **67')",
" # Ask for challenge on invalid device\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'challenge_device': 'MALICIOUS/INPUT/666'})\n self.assertContains(response, 'Send text message to +31 ** *** **67')",
" # Ask for SMS challenge\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'challenge_device': device.persistent_id})\n self.assertContains(response, 'We sent you a text message')\n fake.return_value.send_sms.assert_called_with(\n device=device,\n token=str(totp(device.bin_key, digits=no_digits)).zfill(no_digits))",
" # Ask for phone challenge\n device.method = 'call'\n device.save()\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'challenge_device': device.persistent_id})\n self.assertContains(response, 'We are calling your phone right now')\n fake.return_value.make_call.assert_called_with(\n device=device,\n token=str(totp(device.bin_key, digits=no_digits)).zfill(no_digits))",
" # Valid token should be accepted.\n response = self._post({'token-otp_token': totp(device.bin_key),\n 'login_view-current_step': 'token'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))\n self.assertEqual(device.persistent_id,\n self.client.session.get(DEVICE_ID_SESSION_KEY))",
" # Check that the signal was fired.\n mock_signal.assert_called_with(sender=mock.ANY, request=mock.ANY, user=user, device=device)",
" @mock.patch('two_factor.views.core.signals.user_verified.send')\n def test_with_backup_token(self, mock_signal):\n user = self.create_user()\n user.totpdevice_set.create(name='default', key=random_hex_str())\n device = user.staticdevice_set.create(name='backup')\n device.token_set.create(token='abcdef123')",
" # Backup phones should be listed on the login form\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Backup Token')",
" # Should be able to go to backup tokens step in wizard\n response = self._post({'wizard_goto_step': 'backup'})\n self.assertContains(response, 'backup tokens')",
" # Wrong codes should not be accepted\n response = self._post({'backup-otp_token': 'WRONG',\n 'login_view-current_step': 'backup'})\n self.assertEqual(response.context_data['wizard']['form'].errors,\n {'__all__': ['Invalid token. Please make sure you '\n 'have entered it correctly.']})\n # static devices are throttled\n device.throttle_reset()",
" # Valid token should be accepted.\n response = self._post({'backup-otp_token': 'abcdef123',\n 'login_view-current_step': 'backup'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))",
" # Check that the signal was fired.\n mock_signal.assert_called_with(sender=mock.ANY, request=mock.ANY, user=user, device=device)",
" @mock.patch('two_factor.views.utils.logger')",
"",
" def test_reset_wizard_state(self, mock_logger):\n self.create_user()\n self.enable_otp()",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Token:')",
" # A GET request resets the state of the wizard...\n self.client.get(reverse('two_factor:login'))",
" # ...so there is no user in this request anymore. As the login flow\n # depends on a user being present, this should be handled gracefully.\n response = self._post({'token-otp_token': '123456',\n 'login_view-current_step': 'token'})\n self.assertContains(response, 'Password:')",
" # Check that a message was logged.\n mock_logger.warning.assert_called_with(\n \"Requested step '%s' is no longer valid, returning to last valid \"\n \"step in the wizard.\",\n 'token')",
" @mock.patch('two_factor.views.utils.logger')\n def test_login_different_user_on_existing_session(self, mock_logger):\n \"\"\"\n This test reproduces the issue where a user is logged in and a different user\n attempts to login.\n \"\"\"\n self.create_user()\n self.create_user(username='vedran@example.com')",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))",
" response = self._post({'auth-username': 'vedran@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertRedirects(response, resolve_url(settings.LOGIN_REDIRECT_URL))",
" def test_missing_management_data(self):\n # missing management data\n response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret'})",
" # view should return HTTP 400 Bad Request\n self.assertEqual(response.status_code, 400)\n",
" def test_no_password_in_session(self):\n self.create_user()\n self.enable_otp()",
" response = self._post({'auth-username': 'bouke@example.com',\n 'auth-password': 'secret',\n 'login_view-current_step': 'auth'})\n self.assertContains(response, 'Token:')",
" session_contents = json.dumps(list(self.client.session.items()))",
" self.assertNotIn('secret', session_contents)\n",
"\nclass BackupTokensTest(UserMixin, TestCase):\n def setUp(self):\n super().setUp()\n self.create_user()\n self.enable_otp()\n self.login_user()",
" def test_empty(self):\n response = self.client.get(reverse('two_factor:backup_tokens'))\n self.assertContains(response, 'You don\\'t have any backup codes yet.')",
" def test_generate(self):\n url = reverse('two_factor:backup_tokens')",
" response = self.client.post(url)\n self.assertRedirects(response, url)",
" response = self.client.get(url)\n first_set = set([token.token for token in\n response.context_data['device'].token_set.all()])\n self.assertNotContains(response, 'You don\\'t have any backup codes '\n 'yet.')\n self.assertEqual(10, len(first_set))",
" # Generating the tokens should give a fresh set\n self.client.post(url)\n response = self.client.get(url)\n second_set = set([token.token for token in\n response.context_data['device'].token_set.all()])\n self.assertNotEqual(first_set, second_set)"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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, 75, 334, 193, 166], "buggy_code_start_loc": [1, 75, 0, 4, 2], "filenames": ["CHANGELOG.md", "docs/configuration.rst", "tests/test_views_login.py", "two_factor/views/core.py", "two_factor/views/utils.py"], "fixing_code_end_loc": [10, 83, 414, 264, 197], "fixing_code_start_loc": [2, 76, 1, 5, 3], "message": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:django_two-factor_authentication_project:django_two-factor_authentication:*:*:*:*:*:*:*:*", "matchCriteriaId": "7D3A415A-770B-405A-9C77-72D6142C79C4", "versionEndExcluding": "1.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading."}, {"lang": "es", "value": "Django Two-Factor Authentication versiones anteriores a 1.12, almacena la contrase\u00f1a del usuario en texto sin cifrar en la sesi\u00f3n del usuario (codificada en base64). La contrase\u00f1a es almacenada en la sesi\u00f3n cuando el usuario introduce su nombre de usuario y contrase\u00f1a, y se elimina una vez que completa la autenticaci\u00f3n al ingresar un c\u00f3digo de autenticaci\u00f3n de dos factores. Esto quiere decir que la contrase\u00f1a es almacenada en texto sin cifrar en la sesi\u00f3n durante un per\u00edodo de tiempo arbitrario, y potencialmente para siempre si el usuario comienza el proceso de inicio de sesi\u00f3n ingresando su nombre de usuario y contrase\u00f1a y luego se sale antes de ingresar su c\u00f3digo de autenticaci\u00f3n de dos factores. La gravedad de este problema depende del tipo de almacenamiento de sesi\u00f3n que haya configurado: en el peor de los casos, si est\u00e1 usando el almacenamiento de sesi\u00f3n de base de datos predeterminado de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en su base de datos. En el mejor de los casos, si est\u00e1 utilizando la sesi\u00f3n de cookies firmada de Django, las contrase\u00f1as de los usuarios solo son almacenadas en texto sin cifrar dentro de la tienda de cookies de su navegador. En el caso com\u00fan de usar el almac\u00e9n de sesiones de cach\u00e9 de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en cualquier almacenamiento de cach\u00e9 que haya configurado (generalmente Memcached o Redis). Esto ha sido corregido en la versi\u00f3n 1.12. Despu\u00e9s de la actualizaci\u00f3n, los usuarios deben asegurarse de eliminar las contrase\u00f1as de texto sin cifrar que hayan sido almacenadas. Por ejemplo, si est\u00e1 usando el back-end de sesi\u00f3n de la base de datos, es probable que quiera eliminar cualquier registro de sesi\u00f3n de la base de datos y purgar esos datos de cualquier copia de seguridad o r\u00e9plica de la base de datos. Adicionalmente, las organizaciones afectadas que han sufrido una violaci\u00f3n de la base de datos al usar una versi\u00f3n afectada deben reportar a sus usuarios que sus contrase\u00f1as de texto sin cifrar han sido comprometidas. Todas las organizaciones deben exhortar a los usuarios cuyas contrase\u00f1as son almacenadas de forma no segura para que cambien estas contrase\u00f1as en los sitios donde se utilizaron. Como soluci\u00f3n alternativa, cambiar el almacenamiento de sesi\u00f3n de Django para usar cookies firmadas en lugar de la base de datos o cach\u00e9 disminuye el impacto de este problema, pero no se debe hacer sin un conocimiento profundo de las compensaciones de seguridad del uso de cookies firmadas en lugar de un almacenamiento de sesi\u00f3n del lado del servidor. No existe manera de mitigar completamente el problema sin actualizar"}], "evaluatorComment": null, "id": "CVE-2020-15105", "lastModified": "2020-07-21T18:06:03.230", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 3.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 3.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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2020-07-10T21:15:10.950", "references": [{"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/blob/master/CHANGELOG.md#112---2020-07-08"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/security/advisories/GHSA-vhr6-pvjm-9qwf"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-312"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-312"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, "type": "CWE-312"}
| 224
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"import logging\nimport warnings\nfrom base64 import b32encode\nfrom binascii import unhexlify",
"",
"\nimport django_otp\nimport qrcode\nimport qrcode.image.svg\nfrom django.conf import settings\nfrom django.contrib.auth import REDIRECT_FIELD_NAME, login\nfrom django.contrib.auth.decorators import login_required\nfrom django.contrib.auth.forms import AuthenticationForm\nfrom django.contrib.auth.views import SuccessURLAllowedHostsMixin\nfrom django.contrib.sites.shortcuts import get_current_site",
"from django.forms import Form",
"from django.http import Http404, HttpResponse, HttpResponseRedirect\nfrom django.shortcuts import redirect, resolve_url\nfrom django.urls import reverse\nfrom django.utils.decorators import method_decorator",
"",
"from django.utils.http import is_safe_url\nfrom django.utils.module_loading import import_string",
"",
"from django.views.decorators.cache import never_cache\nfrom django.views.decorators.csrf import csrf_protect\nfrom django.views.decorators.debug import sensitive_post_parameters\nfrom django.views.generic import DeleteView, FormView, TemplateView\nfrom django.views.generic.base import View\nfrom django_otp.decorators import otp_required\nfrom django_otp.plugins.otp_static.models import StaticDevice, StaticToken",
"from two_factor import signals\nfrom two_factor.models import get_available_methods, random_hex_str\nfrom two_factor.utils import totp_digits",
"from ..forms import (\n AuthenticationTokenForm, BackupTokenForm, DeviceValidationForm, MethodForm,\n PhoneNumberForm, PhoneNumberMethodForm, TOTPDeviceForm, YubiKeyDeviceForm,\n)\nfrom ..models import PhoneDevice, get_available_phone_methods\nfrom ..utils import backup_phones, default_device, get_otpauth_url\nfrom .utils import IdempotentSessionWizardView, class_view_decorator",
"try:\n from otp_yubikey.models import ValidationService, RemoteYubikeyDevice\nexcept ImportError:\n ValidationService = RemoteYubikeyDevice = None",
"\nlogger = logging.getLogger(__name__)",
"\n@class_view_decorator(sensitive_post_parameters())\n@class_view_decorator(never_cache)\nclass LoginView(SuccessURLAllowedHostsMixin, IdempotentSessionWizardView):\n \"\"\"\n View for handling the login process, including OTP verification.",
" The login process is composed like a wizard. The first step asks for the\n user's credentials. If the credentials are correct, the wizard proceeds to\n the OTP verification step. If the user has a default OTP device configured,\n that device is asked to generate a token (send sms / call phone) and the\n user is asked to provide the generated token. The backup devices are also\n listed, allowing the user to select a backup device for verification.\n \"\"\"\n template_name = 'two_factor/core/login.html'\n form_list = (\n ('auth', AuthenticationForm),\n ('token', AuthenticationTokenForm),\n ('backup', BackupTokenForm),\n )\n idempotent_dict = {\n 'token': False,\n 'backup': False,\n }\n redirect_authenticated_user = False",
"",
"\n def has_token_step(self):\n return default_device(self.get_user())",
" def has_backup_step(self):\n return default_device(self.get_user()) and \\\n 'token' not in self.storage.validated_step_data",
"",
"\n condition_dict = {\n 'token': has_token_step,\n 'backup': has_backup_step,\n }\n redirect_field_name = REDIRECT_FIELD_NAME",
" def __init__(self, **kwargs):\n super().__init__(**kwargs)\n self.user_cache = None\n self.device_cache = None",
"",
"\n def post(self, *args, **kwargs):\n \"\"\"\n The user can select a particular device to challenge, being the backup\n devices added to the account.\n \"\"\"",
"",
" # Generating a challenge doesn't require to validate the form.\n if 'challenge_device' in self.request.POST:\n return self.render_goto_step('token')",
" return super().post(*args, **kwargs)",
" def done(self, form_list, **kwargs):\n \"\"\"\n Login the user and redirect to the desired page.\n \"\"\"\n login(self.request, self.get_user())",
" redirect_to = self.get_success_url()",
" device = getattr(self.get_user(), 'otp_device', None)\n if device:\n signals.user_verified.send(sender=__name__, request=self.request,\n user=self.get_user(), device=device)\n return redirect(redirect_to)",
" # Copied from django.conrib.auth.views.LoginView (Branch: stable/1.11.x)\n # https://github.com/django/django/blob/58df8aa40fe88f753ba79e091a52f236246260b3/django/contrib/auth/views.py#L63\n def get_success_url(self):\n url = self.get_redirect_url()\n return url or resolve_url(settings.LOGIN_REDIRECT_URL)",
" # Copied from django.conrib.auth.views.LoginView (Branch: stable/1.11.x)\n # https://github.com/django/django/blob/58df8aa40fe88f753ba79e091a52f236246260b3/django/contrib/auth/views.py#L67\n def get_redirect_url(self):\n \"\"\"Return the user-originating redirect URL if it's safe.\"\"\"\n redirect_to = self.request.POST.get(\n self.redirect_field_name,\n self.request.GET.get(self.redirect_field_name, '')\n )\n url_is_safe = is_safe_url(\n url=redirect_to,\n allowed_hosts=self.get_success_url_allowed_hosts(),\n require_https=self.request.is_secure(),\n )\n return redirect_to if url_is_safe else ''",
" def get_form_kwargs(self, step=None):\n \"\"\"\n AuthenticationTokenForm requires the user kwarg.\n \"\"\"\n if step == 'auth':\n return {\n 'request': self.request\n }\n if step in ('token', 'backup'):\n return {\n 'user': self.get_user(),\n 'initial_device': self.get_device(step),\n }\n return {}",
"",
"\n def get_device(self, step=None):\n \"\"\"\n Returns the OTP device selected by the user, or his default device.\n \"\"\"\n if not self.device_cache:\n challenge_device_id = self.request.POST.get('challenge_device', None)\n if challenge_device_id:\n for device in backup_phones(self.get_user()):\n if device.persistent_id == challenge_device_id:\n self.device_cache = device\n break\n if step == 'backup':\n try:\n self.device_cache = self.get_user().staticdevice_set.get(name='backup')\n except StaticDevice.DoesNotExist:\n pass\n if not self.device_cache:\n self.device_cache = default_device(self.get_user())\n return self.device_cache",
" def render(self, form=None, **kwargs):\n \"\"\"\n If the user selected a device, ask the device to generate a challenge;\n either making a phone call or sending a text message.\n \"\"\"\n if self.steps.current == 'token':\n self.get_device().generate_challenge()\n return super().render(form, **kwargs)",
" def get_user(self):\n \"\"\"\n Returns the user authenticated by the AuthenticationForm. Returns False\n if not a valid user; see also issue #65.\n \"\"\"\n if not self.user_cache:",
" form_obj = self.get_form(step='auth',\n data=self.storage.get_step_data('auth'))\n self.user_cache = form_obj.is_valid() and form_obj.user_cache",
" return self.user_cache",
" def get_context_data(self, form, **kwargs):\n \"\"\"\n Adds user's default and backup OTP devices to the context.\n \"\"\"\n context = super().get_context_data(form, **kwargs)\n if self.steps.current == 'token':\n context['device'] = self.get_device()\n context['other_devices'] = [\n phone for phone in backup_phones(self.get_user())\n if phone != self.get_device()]\n try:\n context['backup_tokens'] = self.get_user().staticdevice_set\\\n .get(name='backup').token_set.count()\n except StaticDevice.DoesNotExist:\n context['backup_tokens'] = 0",
" if getattr(settings, 'LOGOUT_REDIRECT_URL', None):\n context['cancel_url'] = resolve_url(settings.LOGOUT_REDIRECT_URL)\n elif getattr(settings, 'LOGOUT_URL', None):\n warnings.warn(\n \"LOGOUT_URL has been replaced by LOGOUT_REDIRECT_URL, please \"\n \"review the URL and update your settings.\",\n DeprecationWarning)\n context['cancel_url'] = resolve_url(settings.LOGOUT_URL)\n return context",
" # Copied from django.conrib.auth.views.LoginView (Branch: stable/1.11.x)\n # https://github.com/django/django/blob/58df8aa40fe88f753ba79e091a52f236246260b3/django/contrib/auth/views.py#L49\n @method_decorator(sensitive_post_parameters())\n @method_decorator(csrf_protect)\n @method_decorator(never_cache)\n def dispatch(self, request, *args, **kwargs):\n if self.redirect_authenticated_user and self.request.user.is_authenticated:\n redirect_to = self.get_success_url()\n if redirect_to == self.request.path:\n raise ValueError(\n \"Redirection loop for authenticated user detected. Check that \"\n \"your LOGIN_REDIRECT_URL doesn't point to a login page.\"\n )\n return HttpResponseRedirect(redirect_to)\n return super().dispatch(request, *args, **kwargs)",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(login_required)\nclass SetupView(IdempotentSessionWizardView):\n \"\"\"\n View for handling OTP setup using a wizard.",
" The first step of the wizard shows an introduction text, explaining how OTP\n works and why it should be enabled. The user has to select the verification\n method (generator / call / sms) in the second step. Depending on the method\n selected, the third step configures the device. For the generator method, a\n QR code is shown which can be scanned using a mobile phone app and the user\n is asked to provide a generated token. For call and sms methods, the user\n provides the phone number which is then validated in the final step.\n \"\"\"\n success_url = 'two_factor:setup_complete'\n qrcode_url = 'two_factor:qr'\n template_name = 'two_factor/core/setup.html'\n session_key_name = 'django_two_factor-qr_secret_key'\n initial_dict = {}\n form_list = (\n ('welcome', Form),\n ('method', MethodForm),\n ('generator', TOTPDeviceForm),\n ('sms', PhoneNumberForm),\n ('call', PhoneNumberForm),\n ('validation', DeviceValidationForm),\n ('yubikey', YubiKeyDeviceForm),\n )\n condition_dict = {\n 'generator': lambda self: self.get_method() == 'generator',\n 'call': lambda self: self.get_method() == 'call',\n 'sms': lambda self: self.get_method() == 'sms',\n 'validation': lambda self: self.get_method() in ('sms', 'call'),\n 'yubikey': lambda self: self.get_method() == 'yubikey',\n }\n idempotent_dict = {\n 'yubikey': False,\n }",
" def get_method(self):\n method_data = self.storage.validated_step_data.get('method', {})\n return method_data.get('method', None)",
" def get(self, request, *args, **kwargs):\n \"\"\"\n Start the setup wizard. Redirect if already enabled.\n \"\"\"\n if default_device(self.request.user):\n return redirect(self.success_url)\n return super().get(request, *args, **kwargs)",
" def get_form_list(self):\n \"\"\"\n Check if there is only one method, then skip the MethodForm from form_list\n \"\"\"\n form_list = super().get_form_list()\n available_methods = get_available_methods()\n if len(available_methods) == 1:\n form_list.pop('method', None)\n method_key, _ = available_methods[0]\n self.storage.validated_step_data['method'] = {'method': method_key}\n return form_list",
" def render_next_step(self, form, **kwargs):\n \"\"\"\n In the validation step, ask the device to generate a challenge.\n \"\"\"\n next_step = self.steps.next\n if next_step == 'validation':\n try:\n self.get_device().generate_challenge()\n kwargs[\"challenge_succeeded\"] = True\n except Exception:\n logger.exception(\"Could not generate challenge\")\n kwargs[\"challenge_succeeded\"] = False\n return super().render_next_step(form, **kwargs)",
" def done(self, form_list, **kwargs):\n \"\"\"\n Finish the wizard. Save all forms and redirect.\n \"\"\"\n # Remove secret key used for QR code generation\n try:\n del self.request.session[self.session_key_name]\n except KeyError:\n pass",
" # TOTPDeviceForm\n if self.get_method() == 'generator':\n form = [form for form in form_list if isinstance(form, TOTPDeviceForm)][0]\n device = form.save()",
" # PhoneNumberForm / YubiKeyDeviceForm\n elif self.get_method() in ('call', 'sms', 'yubikey'):\n device = self.get_device()\n device.save()",
" else:\n raise NotImplementedError(\"Unknown method '%s'\" % self.get_method())",
" django_otp.login(self.request, device)\n return redirect(self.success_url)",
" def get_form_kwargs(self, step=None):\n kwargs = {}\n if step == 'generator':\n kwargs.update({\n 'key': self.get_key(step),\n 'user': self.request.user,\n })\n if step in ('validation', 'yubikey'):\n kwargs.update({\n 'device': self.get_device()\n })\n metadata = self.get_form_metadata(step)\n if metadata:\n kwargs.update({\n 'metadata': metadata,\n })\n return kwargs",
" def get_device(self, **kwargs):\n \"\"\"\n Uses the data from the setup step and generated key to recreate device.",
" Only used for call / sms -- generator uses other procedure.\n \"\"\"\n method = self.get_method()\n kwargs = kwargs or {}\n kwargs['name'] = 'default'\n kwargs['user'] = self.request.user",
" if method in ('call', 'sms'):\n kwargs['method'] = method\n kwargs['number'] = self.storage.validated_step_data\\\n .get(method, {}).get('number')\n return PhoneDevice(key=self.get_key(method), **kwargs)",
" if method == 'yubikey':\n kwargs['public_id'] = self.storage.validated_step_data\\\n .get('yubikey', {}).get('token', '')[:-32]\n try:\n kwargs['service'] = ValidationService.objects.get(name='default')\n except ValidationService.DoesNotExist:\n raise KeyError(\"No ValidationService found with name 'default'\")\n except ValidationService.MultipleObjectsReturned:\n raise KeyError(\"Multiple ValidationService found with name 'default'\")\n return RemoteYubikeyDevice(**kwargs)",
" def get_key(self, step):\n self.storage.extra_data.setdefault('keys', {})\n if step in self.storage.extra_data['keys']:\n return self.storage.extra_data['keys'].get(step)\n key = random_hex_str(20)\n self.storage.extra_data['keys'][step] = key\n return key",
" def get_context_data(self, form, **kwargs):\n context = super().get_context_data(form, **kwargs)\n if self.steps.current == 'generator':\n key = self.get_key('generator')\n rawkey = unhexlify(key.encode('ascii'))\n b32key = b32encode(rawkey).decode('utf-8')\n self.request.session[self.session_key_name] = b32key\n context.update({\n 'QR_URL': reverse(self.qrcode_url)\n })\n elif self.steps.current == 'validation':\n context['device'] = self.get_device()\n context['cancel_url'] = resolve_url(settings.LOGIN_REDIRECT_URL)\n return context",
" def process_step(self, form):\n if hasattr(form, 'metadata'):\n self.storage.extra_data.setdefault('forms', {})\n self.storage.extra_data['forms'][self.steps.current] = form.metadata\n return super().process_step(form)",
" def get_form_metadata(self, step):\n self.storage.extra_data.setdefault('forms', {})\n return self.storage.extra_data['forms'].get(step, None)",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(otp_required)\nclass BackupTokensView(FormView):\n \"\"\"\n View for listing and generating backup tokens.",
" A user can generate a number of static backup tokens. When the user loses\n its phone, these backup tokens can be used for verification. These backup\n tokens should be stored in a safe location; either in a safe or underneath\n a pillow ;-).\n \"\"\"\n form_class = Form\n success_url = 'two_factor:backup_tokens'\n template_name = 'two_factor/core/backup_tokens.html'\n number_of_tokens = 10",
" def get_device(self):\n return self.request.user.staticdevice_set.get_or_create(name='backup')[0]",
" def get_context_data(self, **kwargs):\n context = super().get_context_data(**kwargs)\n context['device'] = self.get_device()\n return context",
" def form_valid(self, form):\n \"\"\"\n Delete existing backup codes and generate new ones.\n \"\"\"\n device = self.get_device()\n device.token_set.all().delete()\n for n in range(self.number_of_tokens):\n device.token_set.create(token=StaticToken.random_token())",
" return redirect(self.success_url)",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(otp_required)\nclass PhoneSetupView(IdempotentSessionWizardView):\n \"\"\"\n View for configuring a phone number for receiving tokens.",
" A user can have multiple backup :class:`~two_factor.models.PhoneDevice`\n for receiving OTP tokens. If the primary phone number is not available, as\n the battery might have drained or the phone is lost, these backup phone\n numbers can be used for verification.\n \"\"\"\n template_name = 'two_factor/core/phone_register.html'\n success_url = settings.LOGIN_REDIRECT_URL\n form_list = (\n ('setup', PhoneNumberMethodForm),\n ('validation', DeviceValidationForm),\n )\n key_name = 'key'",
" def get(self, request, *args, **kwargs):\n \"\"\"\n Start the setup wizard. Redirect if no phone methods available.\n \"\"\"\n if not get_available_phone_methods():\n return redirect(self.success_url)\n return super().get(request, *args, **kwargs)",
" def done(self, form_list, **kwargs):\n \"\"\"\n Store the device and redirect to profile page.\n \"\"\"\n self.get_device(user=self.request.user, name='backup').save()\n return redirect(self.success_url)",
" def render_next_step(self, form, **kwargs):\n \"\"\"\n In the validation step, ask the device to generate a challenge.\n \"\"\"\n next_step = self.steps.next\n if next_step == 'validation':\n self.get_device().generate_challenge()\n return super().render_next_step(form, **kwargs)",
" def get_form_kwargs(self, step=None):\n \"\"\"\n Provide the device to the DeviceValidationForm.\n \"\"\"\n if step == 'validation':\n return {'device': self.get_device()}\n return {}",
" def get_device(self, **kwargs):\n \"\"\"\n Uses the data from the setup step and generated key to recreate device.\n \"\"\"\n kwargs = kwargs or {}\n kwargs.update(self.storage.validated_step_data.get('setup', {}))\n return PhoneDevice(key=self.get_key(), **kwargs)",
" def get_key(self):\n \"\"\"\n The key is preserved between steps and stored as ascii in the session.\n \"\"\"\n if self.key_name not in self.storage.extra_data:\n key = random_hex_str(20)\n self.storage.extra_data[self.key_name] = key\n return self.storage.extra_data[self.key_name]",
" def get_context_data(self, form, **kwargs):\n kwargs.setdefault('cancel_url', resolve_url(self.success_url))\n return super().get_context_data(form, **kwargs)",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(otp_required)\nclass PhoneDeleteView(DeleteView):\n \"\"\"\n View for removing a phone number used for verification.\n \"\"\"\n success_url = settings.LOGIN_REDIRECT_URL",
" def get_queryset(self):\n return self.request.user.phonedevice_set.filter(name='backup')",
" def get_success_url(self):\n return resolve_url(self.success_url)",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(otp_required)\nclass SetupCompleteView(TemplateView):\n \"\"\"\n View congratulation the user when OTP setup has completed.\n \"\"\"\n template_name = 'two_factor/core/setup_complete.html'",
" def get_context_data(self):\n return {\n 'phone_methods': get_available_phone_methods(),\n }",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(login_required)\nclass QRGeneratorView(View):\n \"\"\"\n View returns an SVG image with the OTP token information\n \"\"\"\n http_method_names = ['get']\n default_qr_factory = 'qrcode.image.svg.SvgPathImage'\n session_key_name = 'django_two_factor-qr_secret_key'",
" # The qrcode library only supports PNG and SVG for now\n image_content_types = {\n 'PNG': 'image/png',\n 'SVG': 'image/svg+xml; charset=utf-8',\n }",
" def get_issuer(self):\n return get_current_site(self.request).name",
" def get(self, request, *args, **kwargs):\n # Get the data from the session\n try:\n key = self.request.session[self.session_key_name]\n except KeyError:\n raise Http404()",
" # Get data for qrcode\n image_factory_string = getattr(settings, 'TWO_FACTOR_QR_FACTORY', self.default_qr_factory)\n image_factory = import_string(image_factory_string)\n content_type = self.image_content_types[image_factory.kind]\n try:\n username = self.request.user.get_username()\n except AttributeError:\n username = self.request.user.username",
" otpauth_url = get_otpauth_url(accountname=username,\n issuer=self.get_issuer(),\n secret=key,\n digits=totp_digits())",
" # Make and return QR code\n img = qrcode.make(otpauth_url, image_factory=image_factory)\n resp = HttpResponse(content_type=content_type)\n img.save(resp)\n return resp"
] |
[
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
0,
1,
0,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1, 75, 334, 193, 166], "buggy_code_start_loc": [1, 75, 0, 4, 2], "filenames": ["CHANGELOG.md", "docs/configuration.rst", "tests/test_views_login.py", "two_factor/views/core.py", "two_factor/views/utils.py"], "fixing_code_end_loc": [10, 83, 414, 264, 197], "fixing_code_start_loc": [2, 76, 1, 5, 3], "message": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:django_two-factor_authentication_project:django_two-factor_authentication:*:*:*:*:*:*:*:*", "matchCriteriaId": "7D3A415A-770B-405A-9C77-72D6142C79C4", "versionEndExcluding": "1.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading."}, {"lang": "es", "value": "Django Two-Factor Authentication versiones anteriores a 1.12, almacena la contrase\u00f1a del usuario en texto sin cifrar en la sesi\u00f3n del usuario (codificada en base64). La contrase\u00f1a es almacenada en la sesi\u00f3n cuando el usuario introduce su nombre de usuario y contrase\u00f1a, y se elimina una vez que completa la autenticaci\u00f3n al ingresar un c\u00f3digo de autenticaci\u00f3n de dos factores. Esto quiere decir que la contrase\u00f1a es almacenada en texto sin cifrar en la sesi\u00f3n durante un per\u00edodo de tiempo arbitrario, y potencialmente para siempre si el usuario comienza el proceso de inicio de sesi\u00f3n ingresando su nombre de usuario y contrase\u00f1a y luego se sale antes de ingresar su c\u00f3digo de autenticaci\u00f3n de dos factores. La gravedad de este problema depende del tipo de almacenamiento de sesi\u00f3n que haya configurado: en el peor de los casos, si est\u00e1 usando el almacenamiento de sesi\u00f3n de base de datos predeterminado de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en su base de datos. En el mejor de los casos, si est\u00e1 utilizando la sesi\u00f3n de cookies firmada de Django, las contrase\u00f1as de los usuarios solo son almacenadas en texto sin cifrar dentro de la tienda de cookies de su navegador. En el caso com\u00fan de usar el almac\u00e9n de sesiones de cach\u00e9 de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en cualquier almacenamiento de cach\u00e9 que haya configurado (generalmente Memcached o Redis). Esto ha sido corregido en la versi\u00f3n 1.12. Despu\u00e9s de la actualizaci\u00f3n, los usuarios deben asegurarse de eliminar las contrase\u00f1as de texto sin cifrar que hayan sido almacenadas. Por ejemplo, si est\u00e1 usando el back-end de sesi\u00f3n de la base de datos, es probable que quiera eliminar cualquier registro de sesi\u00f3n de la base de datos y purgar esos datos de cualquier copia de seguridad o r\u00e9plica de la base de datos. Adicionalmente, las organizaciones afectadas que han sufrido una violaci\u00f3n de la base de datos al usar una versi\u00f3n afectada deben reportar a sus usuarios que sus contrase\u00f1as de texto sin cifrar han sido comprometidas. Todas las organizaciones deben exhortar a los usuarios cuyas contrase\u00f1as son almacenadas de forma no segura para que cambien estas contrase\u00f1as en los sitios donde se utilizaron. Como soluci\u00f3n alternativa, cambiar el almacenamiento de sesi\u00f3n de Django para usar cookies firmadas en lugar de la base de datos o cach\u00e9 disminuye el impacto de este problema, pero no se debe hacer sin un conocimiento profundo de las compensaciones de seguridad del uso de cookies firmadas en lugar de un almacenamiento de sesi\u00f3n del lado del servidor. No existe manera de mitigar completamente el problema sin actualizar"}], "evaluatorComment": null, "id": "CVE-2020-15105", "lastModified": "2020-07-21T18:06:03.230", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 3.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 3.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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2020-07-10T21:15:10.950", "references": [{"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/blob/master/CHANGELOG.md#112---2020-07-08"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/security/advisories/GHSA-vhr6-pvjm-9qwf"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-312"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-312"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, "type": "CWE-312"}
| 224
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"import logging\nimport warnings\nfrom base64 import b32encode\nfrom binascii import unhexlify",
"import time",
"\nimport django_otp\nimport qrcode\nimport qrcode.image.svg\nfrom django.conf import settings\nfrom django.contrib.auth import REDIRECT_FIELD_NAME, login\nfrom django.contrib.auth.decorators import login_required\nfrom django.contrib.auth.forms import AuthenticationForm\nfrom django.contrib.auth.views import SuccessURLAllowedHostsMixin\nfrom django.contrib.sites.shortcuts import get_current_site",
"from django.forms import Form, ValidationError",
"from django.http import Http404, HttpResponse, HttpResponseRedirect\nfrom django.shortcuts import redirect, resolve_url\nfrom django.urls import reverse\nfrom django.utils.decorators import method_decorator",
"from django.utils.functional import cached_property",
"from django.utils.http import is_safe_url\nfrom django.utils.module_loading import import_string",
"from django.utils.translation import gettext as _",
"from django.views.decorators.cache import never_cache\nfrom django.views.decorators.csrf import csrf_protect\nfrom django.views.decorators.debug import sensitive_post_parameters\nfrom django.views.generic import DeleteView, FormView, TemplateView\nfrom django.views.generic.base import View\nfrom django_otp.decorators import otp_required\nfrom django_otp.plugins.otp_static.models import StaticDevice, StaticToken",
"from two_factor import signals\nfrom two_factor.models import get_available_methods, random_hex_str\nfrom two_factor.utils import totp_digits",
"from ..forms import (\n AuthenticationTokenForm, BackupTokenForm, DeviceValidationForm, MethodForm,\n PhoneNumberForm, PhoneNumberMethodForm, TOTPDeviceForm, YubiKeyDeviceForm,\n)\nfrom ..models import PhoneDevice, get_available_phone_methods\nfrom ..utils import backup_phones, default_device, get_otpauth_url\nfrom .utils import IdempotentSessionWizardView, class_view_decorator",
"try:\n from otp_yubikey.models import ValidationService, RemoteYubikeyDevice\nexcept ImportError:\n ValidationService = RemoteYubikeyDevice = None",
"\nlogger = logging.getLogger(__name__)",
"\n@class_view_decorator(sensitive_post_parameters())\n@class_view_decorator(never_cache)\nclass LoginView(SuccessURLAllowedHostsMixin, IdempotentSessionWizardView):\n \"\"\"\n View for handling the login process, including OTP verification.",
" The login process is composed like a wizard. The first step asks for the\n user's credentials. If the credentials are correct, the wizard proceeds to\n the OTP verification step. If the user has a default OTP device configured,\n that device is asked to generate a token (send sms / call phone) and the\n user is asked to provide the generated token. The backup devices are also\n listed, allowing the user to select a backup device for verification.\n \"\"\"\n template_name = 'two_factor/core/login.html'\n form_list = (\n ('auth', AuthenticationForm),\n ('token', AuthenticationTokenForm),\n ('backup', BackupTokenForm),\n )\n idempotent_dict = {\n 'token': False,\n 'backup': False,\n }\n redirect_authenticated_user = False",
" storage_name = 'two_factor.views.utils.LoginStorage'",
"\n def has_token_step(self):\n return default_device(self.get_user())",
" def has_backup_step(self):\n return default_device(self.get_user()) and \\\n 'token' not in self.storage.validated_step_data",
"\n @cached_property\n def expired(self):\n login_timeout = getattr(settings, 'TWO_FACTOR_LOGIN_TIMEOUT', 600)\n if login_timeout == 0:\n return False\n expiration_time = self.storage.data.get(\"authentication_time\", 0) + login_timeout\n return int(time.time()) > expiration_time",
"\n condition_dict = {\n 'token': has_token_step,\n 'backup': has_backup_step,\n }\n redirect_field_name = REDIRECT_FIELD_NAME",
" def __init__(self, **kwargs):\n super().__init__(**kwargs)\n self.user_cache = None\n self.device_cache = None",
" self.show_timeout_error = False",
"\n def post(self, *args, **kwargs):\n \"\"\"\n The user can select a particular device to challenge, being the backup\n devices added to the account.\n \"\"\"",
" wizard_goto_step = self.request.POST.get('wizard_goto_step', None)",
" if wizard_goto_step == 'auth':\n self.storage.reset()",
" if self.expired and self.steps.current != 'auth':\n logger.info(\"User's authentication flow has timed out. The user \"\n \"has been redirected to the initial auth form.\")\n self.storage.reset()\n self.show_timeout_error = True\n return self.render_goto_step('auth')\n",
" # Generating a challenge doesn't require to validate the form.\n if 'challenge_device' in self.request.POST:\n return self.render_goto_step('token')",
" return super().post(*args, **kwargs)",
" def done(self, form_list, **kwargs):\n \"\"\"\n Login the user and redirect to the desired page.\n \"\"\"\n login(self.request, self.get_user())",
" redirect_to = self.get_success_url()",
" device = getattr(self.get_user(), 'otp_device', None)\n if device:\n signals.user_verified.send(sender=__name__, request=self.request,\n user=self.get_user(), device=device)\n return redirect(redirect_to)",
" # Copied from django.conrib.auth.views.LoginView (Branch: stable/1.11.x)\n # https://github.com/django/django/blob/58df8aa40fe88f753ba79e091a52f236246260b3/django/contrib/auth/views.py#L63\n def get_success_url(self):\n url = self.get_redirect_url()\n return url or resolve_url(settings.LOGIN_REDIRECT_URL)",
" # Copied from django.conrib.auth.views.LoginView (Branch: stable/1.11.x)\n # https://github.com/django/django/blob/58df8aa40fe88f753ba79e091a52f236246260b3/django/contrib/auth/views.py#L67\n def get_redirect_url(self):\n \"\"\"Return the user-originating redirect URL if it's safe.\"\"\"\n redirect_to = self.request.POST.get(\n self.redirect_field_name,\n self.request.GET.get(self.redirect_field_name, '')\n )\n url_is_safe = is_safe_url(\n url=redirect_to,\n allowed_hosts=self.get_success_url_allowed_hosts(),\n require_https=self.request.is_secure(),\n )\n return redirect_to if url_is_safe else ''",
" def get_form_kwargs(self, step=None):\n \"\"\"\n AuthenticationTokenForm requires the user kwarg.\n \"\"\"\n if step == 'auth':\n return {\n 'request': self.request\n }\n if step in ('token', 'backup'):\n return {\n 'user': self.get_user(),\n 'initial_device': self.get_device(step),\n }\n return {}",
"\n def get_done_form_list(self):\n \"\"\"\n Return the forms that should be processed during the final step\n \"\"\"\n # Intentionally do not process the auth form on the final step. We\n # haven't stored this data, and it isn't required to login the user\n form_list = self.get_form_list()\n form_list.pop('auth')\n return form_list",
" def process_step(self, form):\n \"\"\"\n Process an individual step in the flow\n \"\"\"\n # To prevent saving any private auth data to the session store, we\n # validate the authentication form, determine the resulting user, then\n # only store the minimum needed to login that user (the user's primary\n # key and the backend used)\n if self.steps.current == 'auth':\n user = form.is_valid() and form.user_cache\n self.storage.reset()\n self.storage.authenticated_user = user\n self.storage.data[\"authentication_time\"] = int(time.time())",
" # By returning None when the user clicks the \"back\" button to the\n # auth step the form will be blank with validation warnings\n return None",
" return super().process_step(form)",
" def process_step_files(self, form):\n \"\"\"\n Process the files submitted from a specific test\n \"\"\"\n if self.steps.current == 'auth':\n return {}\n return super().process_step_files(form)",
" def get_form(self, *args, **kwargs):\n \"\"\"\n Returns the form for the step\n \"\"\"\n form = super().get_form(*args, **kwargs)\n if self.show_timeout_error:\n form.cleaned_data = getattr(form, 'cleaned_data', {})\n form.add_error(None, ValidationError(_('Your session has timed out. Please login again.')))\n return form",
"\n def get_device(self, step=None):\n \"\"\"\n Returns the OTP device selected by the user, or his default device.\n \"\"\"\n if not self.device_cache:\n challenge_device_id = self.request.POST.get('challenge_device', None)\n if challenge_device_id:\n for device in backup_phones(self.get_user()):\n if device.persistent_id == challenge_device_id:\n self.device_cache = device\n break\n if step == 'backup':\n try:\n self.device_cache = self.get_user().staticdevice_set.get(name='backup')\n except StaticDevice.DoesNotExist:\n pass\n if not self.device_cache:\n self.device_cache = default_device(self.get_user())\n return self.device_cache",
" def render(self, form=None, **kwargs):\n \"\"\"\n If the user selected a device, ask the device to generate a challenge;\n either making a phone call or sending a text message.\n \"\"\"\n if self.steps.current == 'token':\n self.get_device().generate_challenge()\n return super().render(form, **kwargs)",
" def get_user(self):\n \"\"\"\n Returns the user authenticated by the AuthenticationForm. Returns False\n if not a valid user; see also issue #65.\n \"\"\"\n if not self.user_cache:",
" self.user_cache = self.storage.authenticated_user",
" return self.user_cache",
" def get_context_data(self, form, **kwargs):\n \"\"\"\n Adds user's default and backup OTP devices to the context.\n \"\"\"\n context = super().get_context_data(form, **kwargs)\n if self.steps.current == 'token':\n context['device'] = self.get_device()\n context['other_devices'] = [\n phone for phone in backup_phones(self.get_user())\n if phone != self.get_device()]\n try:\n context['backup_tokens'] = self.get_user().staticdevice_set\\\n .get(name='backup').token_set.count()\n except StaticDevice.DoesNotExist:\n context['backup_tokens'] = 0",
" if getattr(settings, 'LOGOUT_REDIRECT_URL', None):\n context['cancel_url'] = resolve_url(settings.LOGOUT_REDIRECT_URL)\n elif getattr(settings, 'LOGOUT_URL', None):\n warnings.warn(\n \"LOGOUT_URL has been replaced by LOGOUT_REDIRECT_URL, please \"\n \"review the URL and update your settings.\",\n DeprecationWarning)\n context['cancel_url'] = resolve_url(settings.LOGOUT_URL)\n return context",
" # Copied from django.conrib.auth.views.LoginView (Branch: stable/1.11.x)\n # https://github.com/django/django/blob/58df8aa40fe88f753ba79e091a52f236246260b3/django/contrib/auth/views.py#L49\n @method_decorator(sensitive_post_parameters())\n @method_decorator(csrf_protect)\n @method_decorator(never_cache)\n def dispatch(self, request, *args, **kwargs):\n if self.redirect_authenticated_user and self.request.user.is_authenticated:\n redirect_to = self.get_success_url()\n if redirect_to == self.request.path:\n raise ValueError(\n \"Redirection loop for authenticated user detected. Check that \"\n \"your LOGIN_REDIRECT_URL doesn't point to a login page.\"\n )\n return HttpResponseRedirect(redirect_to)\n return super().dispatch(request, *args, **kwargs)",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(login_required)\nclass SetupView(IdempotentSessionWizardView):\n \"\"\"\n View for handling OTP setup using a wizard.",
" The first step of the wizard shows an introduction text, explaining how OTP\n works and why it should be enabled. The user has to select the verification\n method (generator / call / sms) in the second step. Depending on the method\n selected, the third step configures the device. For the generator method, a\n QR code is shown which can be scanned using a mobile phone app and the user\n is asked to provide a generated token. For call and sms methods, the user\n provides the phone number which is then validated in the final step.\n \"\"\"\n success_url = 'two_factor:setup_complete'\n qrcode_url = 'two_factor:qr'\n template_name = 'two_factor/core/setup.html'\n session_key_name = 'django_two_factor-qr_secret_key'\n initial_dict = {}\n form_list = (\n ('welcome', Form),\n ('method', MethodForm),\n ('generator', TOTPDeviceForm),\n ('sms', PhoneNumberForm),\n ('call', PhoneNumberForm),\n ('validation', DeviceValidationForm),\n ('yubikey', YubiKeyDeviceForm),\n )\n condition_dict = {\n 'generator': lambda self: self.get_method() == 'generator',\n 'call': lambda self: self.get_method() == 'call',\n 'sms': lambda self: self.get_method() == 'sms',\n 'validation': lambda self: self.get_method() in ('sms', 'call'),\n 'yubikey': lambda self: self.get_method() == 'yubikey',\n }\n idempotent_dict = {\n 'yubikey': False,\n }",
" def get_method(self):\n method_data = self.storage.validated_step_data.get('method', {})\n return method_data.get('method', None)",
" def get(self, request, *args, **kwargs):\n \"\"\"\n Start the setup wizard. Redirect if already enabled.\n \"\"\"\n if default_device(self.request.user):\n return redirect(self.success_url)\n return super().get(request, *args, **kwargs)",
" def get_form_list(self):\n \"\"\"\n Check if there is only one method, then skip the MethodForm from form_list\n \"\"\"\n form_list = super().get_form_list()\n available_methods = get_available_methods()\n if len(available_methods) == 1:\n form_list.pop('method', None)\n method_key, _ = available_methods[0]\n self.storage.validated_step_data['method'] = {'method': method_key}\n return form_list",
" def render_next_step(self, form, **kwargs):\n \"\"\"\n In the validation step, ask the device to generate a challenge.\n \"\"\"\n next_step = self.steps.next\n if next_step == 'validation':\n try:\n self.get_device().generate_challenge()\n kwargs[\"challenge_succeeded\"] = True\n except Exception:\n logger.exception(\"Could not generate challenge\")\n kwargs[\"challenge_succeeded\"] = False\n return super().render_next_step(form, **kwargs)",
" def done(self, form_list, **kwargs):\n \"\"\"\n Finish the wizard. Save all forms and redirect.\n \"\"\"\n # Remove secret key used for QR code generation\n try:\n del self.request.session[self.session_key_name]\n except KeyError:\n pass",
" # TOTPDeviceForm\n if self.get_method() == 'generator':\n form = [form for form in form_list if isinstance(form, TOTPDeviceForm)][0]\n device = form.save()",
" # PhoneNumberForm / YubiKeyDeviceForm\n elif self.get_method() in ('call', 'sms', 'yubikey'):\n device = self.get_device()\n device.save()",
" else:\n raise NotImplementedError(\"Unknown method '%s'\" % self.get_method())",
" django_otp.login(self.request, device)\n return redirect(self.success_url)",
" def get_form_kwargs(self, step=None):\n kwargs = {}\n if step == 'generator':\n kwargs.update({\n 'key': self.get_key(step),\n 'user': self.request.user,\n })\n if step in ('validation', 'yubikey'):\n kwargs.update({\n 'device': self.get_device()\n })\n metadata = self.get_form_metadata(step)\n if metadata:\n kwargs.update({\n 'metadata': metadata,\n })\n return kwargs",
" def get_device(self, **kwargs):\n \"\"\"\n Uses the data from the setup step and generated key to recreate device.",
" Only used for call / sms -- generator uses other procedure.\n \"\"\"\n method = self.get_method()\n kwargs = kwargs or {}\n kwargs['name'] = 'default'\n kwargs['user'] = self.request.user",
" if method in ('call', 'sms'):\n kwargs['method'] = method\n kwargs['number'] = self.storage.validated_step_data\\\n .get(method, {}).get('number')\n return PhoneDevice(key=self.get_key(method), **kwargs)",
" if method == 'yubikey':\n kwargs['public_id'] = self.storage.validated_step_data\\\n .get('yubikey', {}).get('token', '')[:-32]\n try:\n kwargs['service'] = ValidationService.objects.get(name='default')\n except ValidationService.DoesNotExist:\n raise KeyError(\"No ValidationService found with name 'default'\")\n except ValidationService.MultipleObjectsReturned:\n raise KeyError(\"Multiple ValidationService found with name 'default'\")\n return RemoteYubikeyDevice(**kwargs)",
" def get_key(self, step):\n self.storage.extra_data.setdefault('keys', {})\n if step in self.storage.extra_data['keys']:\n return self.storage.extra_data['keys'].get(step)\n key = random_hex_str(20)\n self.storage.extra_data['keys'][step] = key\n return key",
" def get_context_data(self, form, **kwargs):\n context = super().get_context_data(form, **kwargs)\n if self.steps.current == 'generator':\n key = self.get_key('generator')\n rawkey = unhexlify(key.encode('ascii'))\n b32key = b32encode(rawkey).decode('utf-8')\n self.request.session[self.session_key_name] = b32key\n context.update({\n 'QR_URL': reverse(self.qrcode_url)\n })\n elif self.steps.current == 'validation':\n context['device'] = self.get_device()\n context['cancel_url'] = resolve_url(settings.LOGIN_REDIRECT_URL)\n return context",
" def process_step(self, form):\n if hasattr(form, 'metadata'):\n self.storage.extra_data.setdefault('forms', {})\n self.storage.extra_data['forms'][self.steps.current] = form.metadata\n return super().process_step(form)",
" def get_form_metadata(self, step):\n self.storage.extra_data.setdefault('forms', {})\n return self.storage.extra_data['forms'].get(step, None)",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(otp_required)\nclass BackupTokensView(FormView):\n \"\"\"\n View for listing and generating backup tokens.",
" A user can generate a number of static backup tokens. When the user loses\n its phone, these backup tokens can be used for verification. These backup\n tokens should be stored in a safe location; either in a safe or underneath\n a pillow ;-).\n \"\"\"\n form_class = Form\n success_url = 'two_factor:backup_tokens'\n template_name = 'two_factor/core/backup_tokens.html'\n number_of_tokens = 10",
" def get_device(self):\n return self.request.user.staticdevice_set.get_or_create(name='backup')[0]",
" def get_context_data(self, **kwargs):\n context = super().get_context_data(**kwargs)\n context['device'] = self.get_device()\n return context",
" def form_valid(self, form):\n \"\"\"\n Delete existing backup codes and generate new ones.\n \"\"\"\n device = self.get_device()\n device.token_set.all().delete()\n for n in range(self.number_of_tokens):\n device.token_set.create(token=StaticToken.random_token())",
" return redirect(self.success_url)",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(otp_required)\nclass PhoneSetupView(IdempotentSessionWizardView):\n \"\"\"\n View for configuring a phone number for receiving tokens.",
" A user can have multiple backup :class:`~two_factor.models.PhoneDevice`\n for receiving OTP tokens. If the primary phone number is not available, as\n the battery might have drained or the phone is lost, these backup phone\n numbers can be used for verification.\n \"\"\"\n template_name = 'two_factor/core/phone_register.html'\n success_url = settings.LOGIN_REDIRECT_URL\n form_list = (\n ('setup', PhoneNumberMethodForm),\n ('validation', DeviceValidationForm),\n )\n key_name = 'key'",
" def get(self, request, *args, **kwargs):\n \"\"\"\n Start the setup wizard. Redirect if no phone methods available.\n \"\"\"\n if not get_available_phone_methods():\n return redirect(self.success_url)\n return super().get(request, *args, **kwargs)",
" def done(self, form_list, **kwargs):\n \"\"\"\n Store the device and redirect to profile page.\n \"\"\"\n self.get_device(user=self.request.user, name='backup').save()\n return redirect(self.success_url)",
" def render_next_step(self, form, **kwargs):\n \"\"\"\n In the validation step, ask the device to generate a challenge.\n \"\"\"\n next_step = self.steps.next\n if next_step == 'validation':\n self.get_device().generate_challenge()\n return super().render_next_step(form, **kwargs)",
" def get_form_kwargs(self, step=None):\n \"\"\"\n Provide the device to the DeviceValidationForm.\n \"\"\"\n if step == 'validation':\n return {'device': self.get_device()}\n return {}",
" def get_device(self, **kwargs):\n \"\"\"\n Uses the data from the setup step and generated key to recreate device.\n \"\"\"\n kwargs = kwargs or {}\n kwargs.update(self.storage.validated_step_data.get('setup', {}))\n return PhoneDevice(key=self.get_key(), **kwargs)",
" def get_key(self):\n \"\"\"\n The key is preserved between steps and stored as ascii in the session.\n \"\"\"\n if self.key_name not in self.storage.extra_data:\n key = random_hex_str(20)\n self.storage.extra_data[self.key_name] = key\n return self.storage.extra_data[self.key_name]",
" def get_context_data(self, form, **kwargs):\n kwargs.setdefault('cancel_url', resolve_url(self.success_url))\n return super().get_context_data(form, **kwargs)",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(otp_required)\nclass PhoneDeleteView(DeleteView):\n \"\"\"\n View for removing a phone number used for verification.\n \"\"\"\n success_url = settings.LOGIN_REDIRECT_URL",
" def get_queryset(self):\n return self.request.user.phonedevice_set.filter(name='backup')",
" def get_success_url(self):\n return resolve_url(self.success_url)",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(otp_required)\nclass SetupCompleteView(TemplateView):\n \"\"\"\n View congratulation the user when OTP setup has completed.\n \"\"\"\n template_name = 'two_factor/core/setup_complete.html'",
" def get_context_data(self):\n return {\n 'phone_methods': get_available_phone_methods(),\n }",
"\n@class_view_decorator(never_cache)\n@class_view_decorator(login_required)\nclass QRGeneratorView(View):\n \"\"\"\n View returns an SVG image with the OTP token information\n \"\"\"\n http_method_names = ['get']\n default_qr_factory = 'qrcode.image.svg.SvgPathImage'\n session_key_name = 'django_two_factor-qr_secret_key'",
" # The qrcode library only supports PNG and SVG for now\n image_content_types = {\n 'PNG': 'image/png',\n 'SVG': 'image/svg+xml; charset=utf-8',\n }",
" def get_issuer(self):\n return get_current_site(self.request).name",
" def get(self, request, *args, **kwargs):\n # Get the data from the session\n try:\n key = self.request.session[self.session_key_name]\n except KeyError:\n raise Http404()",
" # Get data for qrcode\n image_factory_string = getattr(settings, 'TWO_FACTOR_QR_FACTORY', self.default_qr_factory)\n image_factory = import_string(image_factory_string)\n content_type = self.image_content_types[image_factory.kind]\n try:\n username = self.request.user.get_username()\n except AttributeError:\n username = self.request.user.username",
" otpauth_url = get_otpauth_url(accountname=username,\n issuer=self.get_issuer(),\n secret=key,\n digits=totp_digits())",
" # Make and return QR code\n img = qrcode.make(otpauth_url, image_factory=image_factory)\n resp = HttpResponse(content_type=content_type)\n img.save(resp)\n return resp"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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, 75, 334, 193, 166], "buggy_code_start_loc": [1, 75, 0, 4, 2], "filenames": ["CHANGELOG.md", "docs/configuration.rst", "tests/test_views_login.py", "two_factor/views/core.py", "two_factor/views/utils.py"], "fixing_code_end_loc": [10, 83, 414, 264, 197], "fixing_code_start_loc": [2, 76, 1, 5, 3], "message": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:django_two-factor_authentication_project:django_two-factor_authentication:*:*:*:*:*:*:*:*", "matchCriteriaId": "7D3A415A-770B-405A-9C77-72D6142C79C4", "versionEndExcluding": "1.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading."}, {"lang": "es", "value": "Django Two-Factor Authentication versiones anteriores a 1.12, almacena la contrase\u00f1a del usuario en texto sin cifrar en la sesi\u00f3n del usuario (codificada en base64). La contrase\u00f1a es almacenada en la sesi\u00f3n cuando el usuario introduce su nombre de usuario y contrase\u00f1a, y se elimina una vez que completa la autenticaci\u00f3n al ingresar un c\u00f3digo de autenticaci\u00f3n de dos factores. Esto quiere decir que la contrase\u00f1a es almacenada en texto sin cifrar en la sesi\u00f3n durante un per\u00edodo de tiempo arbitrario, y potencialmente para siempre si el usuario comienza el proceso de inicio de sesi\u00f3n ingresando su nombre de usuario y contrase\u00f1a y luego se sale antes de ingresar su c\u00f3digo de autenticaci\u00f3n de dos factores. La gravedad de este problema depende del tipo de almacenamiento de sesi\u00f3n que haya configurado: en el peor de los casos, si est\u00e1 usando el almacenamiento de sesi\u00f3n de base de datos predeterminado de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en su base de datos. En el mejor de los casos, si est\u00e1 utilizando la sesi\u00f3n de cookies firmada de Django, las contrase\u00f1as de los usuarios solo son almacenadas en texto sin cifrar dentro de la tienda de cookies de su navegador. En el caso com\u00fan de usar el almac\u00e9n de sesiones de cach\u00e9 de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en cualquier almacenamiento de cach\u00e9 que haya configurado (generalmente Memcached o Redis). Esto ha sido corregido en la versi\u00f3n 1.12. Despu\u00e9s de la actualizaci\u00f3n, los usuarios deben asegurarse de eliminar las contrase\u00f1as de texto sin cifrar que hayan sido almacenadas. Por ejemplo, si est\u00e1 usando el back-end de sesi\u00f3n de la base de datos, es probable que quiera eliminar cualquier registro de sesi\u00f3n de la base de datos y purgar esos datos de cualquier copia de seguridad o r\u00e9plica de la base de datos. Adicionalmente, las organizaciones afectadas que han sufrido una violaci\u00f3n de la base de datos al usar una versi\u00f3n afectada deben reportar a sus usuarios que sus contrase\u00f1as de texto sin cifrar han sido comprometidas. Todas las organizaciones deben exhortar a los usuarios cuyas contrase\u00f1as son almacenadas de forma no segura para que cambien estas contrase\u00f1as en los sitios donde se utilizaron. Como soluci\u00f3n alternativa, cambiar el almacenamiento de sesi\u00f3n de Django para usar cookies firmadas en lugar de la base de datos o cach\u00e9 disminuye el impacto de este problema, pero no se debe hacer sin un conocimiento profundo de las compensaciones de seguridad del uso de cookies firmadas en lugar de un almacenamiento de sesi\u00f3n del lado del servidor. No existe manera de mitigar completamente el problema sin actualizar"}], "evaluatorComment": null, "id": "CVE-2020-15105", "lastModified": "2020-07-21T18:06:03.230", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 3.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 3.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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2020-07-10T21:15:10.950", "references": [{"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/blob/master/CHANGELOG.md#112---2020-07-08"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/security/advisories/GHSA-vhr6-pvjm-9qwf"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-312"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-312"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, "type": "CWE-312"}
| 224
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"import logging\n",
"",
"from django.core.exceptions import SuspiciousOperation\nfrom django.utils.decorators import method_decorator\nfrom django.utils.translation import gettext as _\nfrom formtools.wizard.forms import ManagementForm\nfrom formtools.wizard.storage.session import SessionStorage\nfrom formtools.wizard.views import SessionWizardView",
"logger = logging.getLogger(__name__)",
"\nclass ExtraSessionStorage(SessionStorage):\n \"\"\"\n SessionStorage that includes the property `validated_step_data` for storing\n cleaned form data per step.\n \"\"\"\n validated_step_data_key = 'validated_step_data'",
" def init_data(self):\n super().init_data()\n self.data[self.validated_step_data_key] = {}",
" def reset(self):\n if self.prefix in self.request.session:\n super().reset()\n else:\n self.init_data()",
" def _get_validated_step_data(self):\n return self.data[self.validated_step_data_key]",
" def _set_validated_step_data(self, validated_step_data):\n self.data[self.validated_step_data_key] = validated_step_data",
" validated_step_data = property(_get_validated_step_data,\n _set_validated_step_data)",
"",
"",
"class IdempotentSessionWizardView(SessionWizardView):\n \"\"\"\n WizardView that allows certain steps to be marked non-idempotent, in which\n case the form is only validated once and the cleaned values stored.\n \"\"\"\n storage_name = 'two_factor.views.utils.ExtraSessionStorage'\n idempotent_dict = {}",
" def is_step_visible(self, step):\n \"\"\"\n Returns whether the given `step` should be included in the wizard; it\n is included if either the form is idempotent or not filled in before.\n \"\"\"\n return self.idempotent_dict.get(step, True) or \\\n step not in self.storage.validated_step_data",
" def get_prev_step(self, step=None):\n \"\"\"\n Returns the previous step before the given `step`. If there are no\n steps available, None will be returned. If the `step` argument is\n None, the current step will be determined automatically.\n \"\"\"\n if step is None:\n step = self.steps.current\n form_list = self.get_form_list()\n keys = list(form_list.keys())\n key = keys.index(step) - 1\n if key >= 0:\n for prev_step in keys[key::-1]:\n if self.is_step_visible(prev_step):\n return prev_step\n return None",
" def get_next_step(self, step=None):\n \"\"\"\n Returns the next step after the given `step`. If no more steps are\n available, None will be returned. If the `step` argument is None, the\n current step will be determined automatically.\n \"\"\"\n if step is None:\n step = self.steps.current\n form_list = self.get_form_list()\n keys = list(form_list.keys())\n key = keys.index(step) + 1\n for next_step in keys[key:]:\n if self.is_step_visible(next_step):\n return next_step\n return None",
" def post(self, *args, **kwargs):\n \"\"\"\n Check if the current step is still available. It might not be if\n conditions have changed.\n \"\"\"\n if self.steps.current not in self.steps.all:\n logger.warning(\"Current step '%s' is no longer valid, returning \"\n \"to last valid step in the wizard.\",\n self.steps.current)\n return self.render_goto_step(self.steps.all[-1])",
" # -- Duplicated code from upstream\n # Look for a wizard_goto_step element in the posted data which\n # contains a valid step name. If one was found, render the requested\n # form. (This makes stepping back a lot easier).\n wizard_goto_step = self.request.POST.get('wizard_goto_step', None)\n if wizard_goto_step and wizard_goto_step in self.get_form_list():\n return self.render_goto_step(wizard_goto_step)",
" # Check if form was refreshed\n management_form = ManagementForm(self.request.POST, prefix=self.prefix)\n if not management_form.is_valid():\n raise SuspiciousOperation(_('ManagementForm data is missing or has been tampered with'))",
" form_current_step = management_form.cleaned_data['current_step']\n if (form_current_step != self.steps.current\n and self.storage.current_step is not None):\n # form refreshed, change current step\n self.storage.current_step = form_current_step\n # -- End duplicated code from upstream",
" # This is different from the first check, as this checks\n # if the new step is available. See issue #65.\n if self.steps.current not in self.steps.all:\n logger.warning(\"Requested step '%s' is no longer valid, returning \"\n \"to last valid step in the wizard.\",\n self.steps.current)\n return self.render_goto_step(self.steps.all[-1])",
" return super().post(*args, **kwargs)",
" def process_step(self, form):\n \"\"\"\n Stores the validated data for `form` and cleans out validated forms\n for next steps, as those might be affected by the current step. Note\n that this behaviour is relied upon by the `LoginView` to prevent users\n from bypassing the `TokenForm` by going steps back and changing\n credentials.\n \"\"\"\n step = self.steps.current",
" # If the form is not-idempotent (cannot be validated multiple times),\n # the cleaned data should be stored; marking the form as validated.\n self.storage.validated_step_data[step] = form.cleaned_data",
" # It is assumed that earlier steps affect later steps; so even though\n # those forms might not be idempotent, we'll remove the validated data\n # to force re-entry.\n # form_list = self.get_form_list(idempotent=False)\n form_list = self.get_form_list()\n keys = list(form_list.keys())\n key = keys.index(step) + 1\n for next_step in keys[key:]:\n self.storage.validated_step_data.pop(next_step, None)",
" return super().process_step(form)\n",
"",
" def render_done(self, form, **kwargs):\n \"\"\"\n This method gets called when all forms passed. The method should also\n re-validate all steps to prevent manipulation. If any form don't\n validate, `render_revalidation_failure` should get called.\n If everything is fine call `done`.\n \"\"\"\n final_form_list = []\n # walk through the form list and try to validate the data again.",
" for form_key in self.get_form_list():",
" form_obj = self.get_form(step=form_key,\n data=self.storage.get_step_data(form_key),\n files=self.storage.get_step_files(\n form_key))\n if not (form_key in self.idempotent_dict or form_obj.is_valid()):\n return self.render_revalidation_failure(form_key, form_obj,\n **kwargs)\n final_form_list.append(form_obj)",
" # render the done view and reset the wizard before returning the\n # response. This is needed to prevent from rendering done with the\n # same data twice.\n done_response = self.done(final_form_list, **kwargs)\n self.storage.reset()\n return done_response",
"\ndef class_view_decorator(function_decorator):\n \"\"\"\n Converts a function based decorator into a class based decorator usable\n on class based Views.",
" Can't subclass the `View` as it breaks inheritance (super in particular),\n so we monkey-patch instead.",
" From: http://stackoverflow.com/a/8429311/58107\n \"\"\"\n def simple_decorator(View):\n View.dispatch = method_decorator(function_decorator)(View.dispatch)\n return View\n return simple_decorator"
] |
[
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,
0,
1,
0,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [1, 75, 334, 193, 166], "buggy_code_start_loc": [1, 75, 0, 4, 2], "filenames": ["CHANGELOG.md", "docs/configuration.rst", "tests/test_views_login.py", "two_factor/views/core.py", "two_factor/views/utils.py"], "fixing_code_end_loc": [10, 83, 414, 264, 197], "fixing_code_start_loc": [2, 76, 1, 5, 3], "message": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:django_two-factor_authentication_project:django_two-factor_authentication:*:*:*:*:*:*:*:*", "matchCriteriaId": "7D3A415A-770B-405A-9C77-72D6142C79C4", "versionEndExcluding": "1.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading."}, {"lang": "es", "value": "Django Two-Factor Authentication versiones anteriores a 1.12, almacena la contrase\u00f1a del usuario en texto sin cifrar en la sesi\u00f3n del usuario (codificada en base64). La contrase\u00f1a es almacenada en la sesi\u00f3n cuando el usuario introduce su nombre de usuario y contrase\u00f1a, y se elimina una vez que completa la autenticaci\u00f3n al ingresar un c\u00f3digo de autenticaci\u00f3n de dos factores. Esto quiere decir que la contrase\u00f1a es almacenada en texto sin cifrar en la sesi\u00f3n durante un per\u00edodo de tiempo arbitrario, y potencialmente para siempre si el usuario comienza el proceso de inicio de sesi\u00f3n ingresando su nombre de usuario y contrase\u00f1a y luego se sale antes de ingresar su c\u00f3digo de autenticaci\u00f3n de dos factores. La gravedad de este problema depende del tipo de almacenamiento de sesi\u00f3n que haya configurado: en el peor de los casos, si est\u00e1 usando el almacenamiento de sesi\u00f3n de base de datos predeterminado de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en su base de datos. En el mejor de los casos, si est\u00e1 utilizando la sesi\u00f3n de cookies firmada de Django, las contrase\u00f1as de los usuarios solo son almacenadas en texto sin cifrar dentro de la tienda de cookies de su navegador. En el caso com\u00fan de usar el almac\u00e9n de sesiones de cach\u00e9 de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en cualquier almacenamiento de cach\u00e9 que haya configurado (generalmente Memcached o Redis). Esto ha sido corregido en la versi\u00f3n 1.12. Despu\u00e9s de la actualizaci\u00f3n, los usuarios deben asegurarse de eliminar las contrase\u00f1as de texto sin cifrar que hayan sido almacenadas. Por ejemplo, si est\u00e1 usando el back-end de sesi\u00f3n de la base de datos, es probable que quiera eliminar cualquier registro de sesi\u00f3n de la base de datos y purgar esos datos de cualquier copia de seguridad o r\u00e9plica de la base de datos. Adicionalmente, las organizaciones afectadas que han sufrido una violaci\u00f3n de la base de datos al usar una versi\u00f3n afectada deben reportar a sus usuarios que sus contrase\u00f1as de texto sin cifrar han sido comprometidas. Todas las organizaciones deben exhortar a los usuarios cuyas contrase\u00f1as son almacenadas de forma no segura para que cambien estas contrase\u00f1as en los sitios donde se utilizaron. Como soluci\u00f3n alternativa, cambiar el almacenamiento de sesi\u00f3n de Django para usar cookies firmadas en lugar de la base de datos o cach\u00e9 disminuye el impacto de este problema, pero no se debe hacer sin un conocimiento profundo de las compensaciones de seguridad del uso de cookies firmadas en lugar de un almacenamiento de sesi\u00f3n del lado del servidor. No existe manera de mitigar completamente el problema sin actualizar"}], "evaluatorComment": null, "id": "CVE-2020-15105", "lastModified": "2020-07-21T18:06:03.230", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 3.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 3.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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2020-07-10T21:15:10.950", "references": [{"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/blob/master/CHANGELOG.md#112---2020-07-08"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/security/advisories/GHSA-vhr6-pvjm-9qwf"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-312"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-312"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, "type": "CWE-312"}
| 224
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"import logging\n",
"from django.contrib.auth import load_backend",
"from django.core.exceptions import SuspiciousOperation\nfrom django.utils.decorators import method_decorator\nfrom django.utils.translation import gettext as _\nfrom formtools.wizard.forms import ManagementForm\nfrom formtools.wizard.storage.session import SessionStorage\nfrom formtools.wizard.views import SessionWizardView",
"logger = logging.getLogger(__name__)",
"\nclass ExtraSessionStorage(SessionStorage):\n \"\"\"\n SessionStorage that includes the property `validated_step_data` for storing\n cleaned form data per step.\n \"\"\"\n validated_step_data_key = 'validated_step_data'",
" def init_data(self):\n super().init_data()\n self.data[self.validated_step_data_key] = {}",
" def reset(self):\n if self.prefix in self.request.session:\n super().reset()\n else:\n self.init_data()",
" def _get_validated_step_data(self):\n return self.data[self.validated_step_data_key]",
" def _set_validated_step_data(self, validated_step_data):\n self.data[self.validated_step_data_key] = validated_step_data",
" validated_step_data = property(_get_validated_step_data,\n _set_validated_step_data)",
"",
"class LoginStorage(ExtraSessionStorage):\n \"\"\"\n SessionStorage that includes the property 'authenticated_user' for storing\n backend authenticated users while logging in.\n \"\"\"\n def _get_authenticated_user(self):\n # Ensure that both user_pk and user_backend exist in the session\n if not all([self.data.get(\"user_pk\"), self.data.get(\"user_backend\")]):\n return False\n # Acquire the user the same way django.contrib.auth.get_user does\n backend = load_backend(self.data[\"user_backend\"])\n user = backend.get_user(self.data[\"user_pk\"])\n if not user:\n return False\n # Set user.backend to the dotted path version of the backend for login()\n user.backend = self.data[\"user_backend\"]\n return user",
" def _set_authenticated_user(self, user):\n # Acquire the PK the same way django's auth middleware does\n self.data[\"user_pk\"] = user._meta.pk.value_to_string(user)\n self.data[\"user_backend\"] = user.backend",
" authenticated_user = property(_get_authenticated_user,\n _set_authenticated_user)",
"",
"class IdempotentSessionWizardView(SessionWizardView):\n \"\"\"\n WizardView that allows certain steps to be marked non-idempotent, in which\n case the form is only validated once and the cleaned values stored.\n \"\"\"\n storage_name = 'two_factor.views.utils.ExtraSessionStorage'\n idempotent_dict = {}",
" def is_step_visible(self, step):\n \"\"\"\n Returns whether the given `step` should be included in the wizard; it\n is included if either the form is idempotent or not filled in before.\n \"\"\"\n return self.idempotent_dict.get(step, True) or \\\n step not in self.storage.validated_step_data",
" def get_prev_step(self, step=None):\n \"\"\"\n Returns the previous step before the given `step`. If there are no\n steps available, None will be returned. If the `step` argument is\n None, the current step will be determined automatically.\n \"\"\"\n if step is None:\n step = self.steps.current\n form_list = self.get_form_list()\n keys = list(form_list.keys())\n key = keys.index(step) - 1\n if key >= 0:\n for prev_step in keys[key::-1]:\n if self.is_step_visible(prev_step):\n return prev_step\n return None",
" def get_next_step(self, step=None):\n \"\"\"\n Returns the next step after the given `step`. If no more steps are\n available, None will be returned. If the `step` argument is None, the\n current step will be determined automatically.\n \"\"\"\n if step is None:\n step = self.steps.current\n form_list = self.get_form_list()\n keys = list(form_list.keys())\n key = keys.index(step) + 1\n for next_step in keys[key:]:\n if self.is_step_visible(next_step):\n return next_step\n return None",
" def post(self, *args, **kwargs):\n \"\"\"\n Check if the current step is still available. It might not be if\n conditions have changed.\n \"\"\"\n if self.steps.current not in self.steps.all:\n logger.warning(\"Current step '%s' is no longer valid, returning \"\n \"to last valid step in the wizard.\",\n self.steps.current)\n return self.render_goto_step(self.steps.all[-1])",
" # -- Duplicated code from upstream\n # Look for a wizard_goto_step element in the posted data which\n # contains a valid step name. If one was found, render the requested\n # form. (This makes stepping back a lot easier).\n wizard_goto_step = self.request.POST.get('wizard_goto_step', None)\n if wizard_goto_step and wizard_goto_step in self.get_form_list():\n return self.render_goto_step(wizard_goto_step)",
" # Check if form was refreshed\n management_form = ManagementForm(self.request.POST, prefix=self.prefix)\n if not management_form.is_valid():\n raise SuspiciousOperation(_('ManagementForm data is missing or has been tampered with'))",
" form_current_step = management_form.cleaned_data['current_step']\n if (form_current_step != self.steps.current\n and self.storage.current_step is not None):\n # form refreshed, change current step\n self.storage.current_step = form_current_step\n # -- End duplicated code from upstream",
" # This is different from the first check, as this checks\n # if the new step is available. See issue #65.\n if self.steps.current not in self.steps.all:\n logger.warning(\"Requested step '%s' is no longer valid, returning \"\n \"to last valid step in the wizard.\",\n self.steps.current)\n return self.render_goto_step(self.steps.all[-1])",
" return super().post(*args, **kwargs)",
" def process_step(self, form):\n \"\"\"\n Stores the validated data for `form` and cleans out validated forms\n for next steps, as those might be affected by the current step. Note\n that this behaviour is relied upon by the `LoginView` to prevent users\n from bypassing the `TokenForm` by going steps back and changing\n credentials.\n \"\"\"\n step = self.steps.current",
" # If the form is not-idempotent (cannot be validated multiple times),\n # the cleaned data should be stored; marking the form as validated.\n self.storage.validated_step_data[step] = form.cleaned_data",
" # It is assumed that earlier steps affect later steps; so even though\n # those forms might not be idempotent, we'll remove the validated data\n # to force re-entry.\n # form_list = self.get_form_list(idempotent=False)\n form_list = self.get_form_list()\n keys = list(form_list.keys())\n key = keys.index(step) + 1\n for next_step in keys[key:]:\n self.storage.validated_step_data.pop(next_step, None)",
" return super().process_step(form)\n",
" def get_done_form_list(self):\n return self.get_form_list()\n",
" def render_done(self, form, **kwargs):\n \"\"\"\n This method gets called when all forms passed. The method should also\n re-validate all steps to prevent manipulation. If any form don't\n validate, `render_revalidation_failure` should get called.\n If everything is fine call `done`.\n \"\"\"\n final_form_list = []\n # walk through the form list and try to validate the data again.",
" for form_key in self.get_done_form_list():",
" form_obj = self.get_form(step=form_key,\n data=self.storage.get_step_data(form_key),\n files=self.storage.get_step_files(\n form_key))\n if not (form_key in self.idempotent_dict or form_obj.is_valid()):\n return self.render_revalidation_failure(form_key, form_obj,\n **kwargs)\n final_form_list.append(form_obj)",
" # render the done view and reset the wizard before returning the\n # response. This is needed to prevent from rendering done with the\n # same data twice.\n done_response = self.done(final_form_list, **kwargs)\n self.storage.reset()\n return done_response",
"\ndef class_view_decorator(function_decorator):\n \"\"\"\n Converts a function based decorator into a class based decorator usable\n on class based Views.",
" Can't subclass the `View` as it breaks inheritance (super in particular),\n so we monkey-patch instead.",
" From: http://stackoverflow.com/a/8429311/58107\n \"\"\"\n def simple_decorator(View):\n View.dispatch = method_decorator(function_decorator)(View.dispatch)\n return View\n return simple_decorator"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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, 75, 334, 193, 166], "buggy_code_start_loc": [1, 75, 0, 4, 2], "filenames": ["CHANGELOG.md", "docs/configuration.rst", "tests/test_views_login.py", "two_factor/views/core.py", "two_factor/views/utils.py"], "fixing_code_end_loc": [10, 83, 414, 264, 197], "fixing_code_start_loc": [2, 76, 1, 5, 3], "message": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:django_two-factor_authentication_project:django_two-factor_authentication:*:*:*:*:*:*:*:*", "matchCriteriaId": "7D3A415A-770B-405A-9C77-72D6142C79C4", "versionEndExcluding": "1.12", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading."}, {"lang": "es", "value": "Django Two-Factor Authentication versiones anteriores a 1.12, almacena la contrase\u00f1a del usuario en texto sin cifrar en la sesi\u00f3n del usuario (codificada en base64). La contrase\u00f1a es almacenada en la sesi\u00f3n cuando el usuario introduce su nombre de usuario y contrase\u00f1a, y se elimina una vez que completa la autenticaci\u00f3n al ingresar un c\u00f3digo de autenticaci\u00f3n de dos factores. Esto quiere decir que la contrase\u00f1a es almacenada en texto sin cifrar en la sesi\u00f3n durante un per\u00edodo de tiempo arbitrario, y potencialmente para siempre si el usuario comienza el proceso de inicio de sesi\u00f3n ingresando su nombre de usuario y contrase\u00f1a y luego se sale antes de ingresar su c\u00f3digo de autenticaci\u00f3n de dos factores. La gravedad de este problema depende del tipo de almacenamiento de sesi\u00f3n que haya configurado: en el peor de los casos, si est\u00e1 usando el almacenamiento de sesi\u00f3n de base de datos predeterminado de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en su base de datos. En el mejor de los casos, si est\u00e1 utilizando la sesi\u00f3n de cookies firmada de Django, las contrase\u00f1as de los usuarios solo son almacenadas en texto sin cifrar dentro de la tienda de cookies de su navegador. En el caso com\u00fan de usar el almac\u00e9n de sesiones de cach\u00e9 de Django, las contrase\u00f1as de los usuarios son almacenadas en texto sin cifrar en cualquier almacenamiento de cach\u00e9 que haya configurado (generalmente Memcached o Redis). Esto ha sido corregido en la versi\u00f3n 1.12. Despu\u00e9s de la actualizaci\u00f3n, los usuarios deben asegurarse de eliminar las contrase\u00f1as de texto sin cifrar que hayan sido almacenadas. Por ejemplo, si est\u00e1 usando el back-end de sesi\u00f3n de la base de datos, es probable que quiera eliminar cualquier registro de sesi\u00f3n de la base de datos y purgar esos datos de cualquier copia de seguridad o r\u00e9plica de la base de datos. Adicionalmente, las organizaciones afectadas que han sufrido una violaci\u00f3n de la base de datos al usar una versi\u00f3n afectada deben reportar a sus usuarios que sus contrase\u00f1as de texto sin cifrar han sido comprometidas. Todas las organizaciones deben exhortar a los usuarios cuyas contrase\u00f1as son almacenadas de forma no segura para que cambien estas contrase\u00f1as en los sitios donde se utilizaron. Como soluci\u00f3n alternativa, cambiar el almacenamiento de sesi\u00f3n de Django para usar cookies firmadas en lugar de la base de datos o cach\u00e9 disminuye el impacto de este problema, pero no se debe hacer sin un conocimiento profundo de las compensaciones de seguridad del uso de cookies firmadas en lugar de un almacenamiento de sesi\u00f3n del lado del servidor. No existe manera de mitigar completamente el problema sin actualizar"}], "evaluatorComment": null, "id": "CVE-2020-15105", "lastModified": "2020-07-21T18:06:03.230", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "NONE", "baseScore": 3.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:N", "version": "2.0"}, "exploitabilityScore": 3.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": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 5.4, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 4.2, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2020-07-10T21:15:10.950", "references": [{"source": "security-advisories@github.com", "tags": ["Release Notes", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/blob/master/CHANGELOG.md#112---2020-07-08"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/Bouke/django-two-factor-auth/security/advisories/GHSA-vhr6-pvjm-9qwf"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-312"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-312"}], "source": "security-advisories@github.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/Bouke/django-two-factor-auth/commit/454fd9842fa6e8bb772dbf0943976bc8e3335359"}, "type": "CWE-312"}
| 224
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Ayttm\n *\n * Copyright (C) 2003, 2009 the Ayttm team\n * \n * Ayttm is a derivative of Everybuddy\n * Copyright (C) 1998-1999, Torrey Searle\n * proxy featured by Seb C.\n *\n * This program 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 program 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 program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n */",
"/* this is a little piece of code to handle proxy connection */\n/* it is intended to : 1st handle http proxy, using the CONNECT command\n , 2nd provide an easy way to add socks support */",
"#include \"intl.h\"",
"#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>",
"#ifdef __MINGW32__\n#include <winsock2.h>\n#else\n#include <sys/socket.h>\n#include <netdb.h>\n#include <netinet/in.h>\n#include <arpa/inet.h>\n#endif",
"#include \"proxy.h\"\n#include \"proxy_private.h\"\n#include \"common.h\"\n#include \"net_constants.h\"",
"#include <glib.h>",
"#ifdef __MINGW32__\n#define sleep(a)\t\tSleep(1000*a)",
"#define bcopy(a,b,c)\tmemcpy(b,a,c)\n#define bzero(a,b)\t\tmemset(a,0,b)",
"#define ECONNREFUSED\tWSAECONNREFUSED\n#endif",
"/* Prototypes */\nstatic char *encode_proxy_auth_str(AyProxyData *proxy);",
"#define debug_print printf",
"/* \n * External function to use to set the proxy settings\n */\nint ay_proxy_set_default(AyProxyType type, const char *host, int port,\n\tchar *username, char *password)\n{\n\tif (!default_proxy)\n\t\tdefault_proxy = g_new0(AyProxyData, 1);",
"\tdefault_proxy->type = type;",
"\tif (type == PROXY_NONE) {\n\t\tif (default_proxy->host)\n\t\t\tfree(default_proxy->host);",
"\t\tif (default_proxy->username)\n\t\t\tfree(default_proxy->username);",
"\t\tif (default_proxy->password)\n\t\t\tfree(default_proxy->password);",
"\t\tg_free(default_proxy);\n\t\tdefault_proxy = NULL;\n\t} else {\n\t\tdefault_proxy->port = 0;",
"\t\tif (host != NULL && host[0]) {\n\t\t\tdefault_proxy->host = strdup(host);\n\t\t\tdefault_proxy->port = port;\n\t\t}\n\t\tif (default_proxy->port == 0)\n\t\t\tdefault_proxy->port = 3128;",
"\t\tif (username && username[0])\n\t\t\tdefault_proxy->username = strdup(username);",
"\t\tif (password && password[0])\n\t\t\tdefault_proxy->password = strdup(password);",
"\t}\n#ifdef __MINGW32__\n\t{\n\t\tWSADATA wsaData;\n\t\tWSAStartup(MAKEWORD(2, 0), &wsaData);\n\t}\n#endif\n\treturn (0);\n}",
"/* http://archive.socks.permeo.com/protocol/socks4.protocol */\nint socks4_connect(int sock, const char *host, int port, AyProxyData *proxy)\n{\n\tint i, packetlen;",
"\tunsigned char *packet = NULL;\n\tstruct addrinfo *result = NULL;",
"\tint retval = 0;",
"\tif (proxy->username && proxy->username[0])\n\t\tpacketlen = 9 + strlen(proxy->username);\n\telse\n\t\tpacketlen = 9;",
"\tresult = lookup_address(host, port, AF_INET);",
"\tif (!result)\n\t\treturn AY_HOSTNAME_LOOKUP_FAIL;",
"\tpacket = (unsigned char *)calloc(packetlen, sizeof(unsigned char));",
"\tpacket[0] = 4;\t\t/* Version */\n\tpacket[1] = 1;\t\t/* CONNECT */\n\tpacket[2] = (((unsigned short)port) >> 8);\t/* DESTPORT */\n\tpacket[3] = (((unsigned short)port) & 0xff);\t/* DESTPORT */",
"\t/* DESTIP */\n\tbcopy(packet + 4, &(((struct sockaddr_in *)result->ai_addr)->sin_addr),\n\t\t4);",
"\tfreeaddrinfo(result);",
"\tif (proxy->username && proxy->username[0]) {\n\t\tfor (i = 0; proxy->username[i]; i++) {\n\t\t\tpacket[i + 8] = (unsigned char)proxy->username[i];\t/* AUTH */\n\t\t}\n\t}\n\tpacket[packetlen - 1] = 0;\t/* END */\n\tdebug_print(\"Sending \\\"%s\\\"\\n\", packet);\n\tif (write(sock, packet, packetlen) == packetlen) {\n\t\tbzero(packet, sizeof(packet));\n\t\t/* Check response - return as SOCKS4 if its valid */\n\t\tif (read(sock, packet, 9) >= 4) {\n\t\t\tif (packet[1] == 90) {\n\t\t\t\treturn 0;\n\t\t\t} else if (packet[1] == 91)\n\t\t\t\tretval = AY_SOCKS4_UNKNOWN;\n\t\t\telse if (packet[1] == 92)\n\t\t\t\tretval = AY_SOCKS4_IDENTD_FAIL;\n\t\t\telse if (packet[1] == 93)\n\t\t\t\tretval = AY_SOCKS4_IDENT_USER_DIFF;\n\t\t\telse {\n\t\t\t\tretval = AY_SOCKS4_INCOMPATIBLE_ERROR;\n\t\t\t\tprintf(\"=>>%d\\n\", packet[1]);\n\t\t\t}\n\t\t} else {\n\t\t\tprintf(\"short read %s\\n\", packet);\n\t\t}\n\t}\n\tclose(sock);",
"\treturn retval;\n}",
"/* http://archive.socks.permeo.com/rfc/rfc1928.txt */\n/* http://archive.socks.permeo.com/rfc/rfc1929.txt */",
"/* \n * Removed support for datagram connections because we're not even using it now. \n * I'll add it back if/when it is needed or if I feel like being very correct \n * some time later...\n */\nint socks5_connect(int sockfd, const char *host, int port, AyProxyData *proxy)\n{\n\tint i;\n\tchar buff[530];\n\tint need_auth = 0;\n\tstruct addrinfo *result = NULL;\n\tint j;",
"\tbuff[0] = 0x05;\t\t/* use socks v5 */\n\tif (proxy->username && proxy->username[0]) {\n\t\tbuff[1] = 0x02;\t/* we support (no authentication & username/pass) */\n\t\tbuff[2] = 0x00;\t/* we support the method type \"no authentication\" */\n\t\tbuff[3] = 0x02;\t/* we support the method type \"username/passw\" */\n\t\tneed_auth = 1;\n\t} else {\n\t\tbuff[1] = 0x01;\t/* we support (no authentication) */\n\t\tbuff[2] = 0x00;\t/* we support the method type \"no authentication\" */\n\t}",
"\twrite(sockfd, buff, 3 + ((proxy->username\n\t\t\t\t&& proxy->username[0]) ? 1 : 0));",
"\tif (read(sockfd, buff, 2) < 0) {\n\t\tclose(sockfd);\n\t\treturn AY_SOCKS5_CONNECT_FAIL;\n\t}\n\tif (buff[1] == 0x00)\n\t\tneed_auth = 0;\n\telse if (buff[1] == 0x02 && proxy->username && proxy->username[0])\n\t\tneed_auth = 1;\n\telse {\n\t\tfprintf(stderr, \"No Acceptable Methods\");\n\t\treturn AY_SOCKS5_CONNECT_FAIL;\n\t}\n\tif (((proxy->username && proxy->username[0]) ? 1 : 0)) {\n\t\t/* subneg start */\n\t\tbuff[0] = 0x01;\t/* subneg version */\n\t\tprintf(\"[%d]\", buff[0]);\n\t\tbuff[1] = strlen(proxy->username);\t/* username length */\n\t\tprintf(\"[%d]\", buff[1]);\n\t\tfor (i = 0; proxy->username[i] && i < 255; i++) {\n\t\t\tbuff[i + 2] = proxy->username[i];\t/* AUTH */\n\t\t\tprintf(\"%c\", buff[i + 2]);\n\t\t}\n\t\ti += 2;\n\t\tbuff[i] = strlen(proxy->password);\n\t\tprintf(\"[%d]\", buff[i]);\n\t\ti++;\n\t\tfor (j = 0; j < proxy->password[j] && j < 255; j++) {\n\t\t\tbuff[i + j] = proxy->password[j];\t/* AUTH */\n\t\t\tprintf(\"%c\", buff[i + j]);\n\t\t}\n\t\ti += (j);\n\t\tbuff[i] = 0;",
"\t\twrite(sockfd, buff, i);",
"\t\tif (read(sockfd, buff, 2) < 0) {\n\t\t\tclose(sockfd);\n\t\t\treturn AY_SOCKS5_CONNECT_FAIL;\n\t\t}",
"\t\tif (buff[1] != 0)\n\t\t\treturn AY_PROXY_PERMISSION_DENIED;\n\t}",
"\tbuff[0] = 0x05;\t\t/* use socks5 */\n\tbuff[1] = 0x01;\t\t/* connect only SOCK_STREAM for now */\n\tbuff[2] = 0x00;\t\t/* reserved */\n\tbuff[3] = 0x01;\t\t/* ipv4 address */",
"\tif ((result = lookup_address(host, port, AF_UNSPEC)) == NULL)\n\t\treturn AY_HOSTNAME_LOOKUP_FAIL;",
"\tmemcpy(buff + 4, &(((struct sockaddr_in *)result->ai_addr)->sin_addr),\n\t\t4);\n\tmemcpy((buff + 8), &(((struct sockaddr_in *)result->ai_addr)->sin_port),\n\t\t2);",
"\tfreeaddrinfo(result);",
"\twrite(sockfd, buff, 10);",
"\tif (read(sockfd, buff, 10) < 0) {\n\t\tclose(sockfd);\n\t\treturn AY_SOCKS5_CONNECT_FAIL;\n\t}",
"\tif (buff[1] != 0x00) {\n\t\tfor (i = 0; i < 8; i++)\n\t\t\tprintf(\"%03d \", buff[i]);",
"\t\tprintf(\"%d\", ntohs(*(unsigned short *)&buff[8]));\n\t\tprintf(\"\\n\");\n\t\tfprintf(stderr, \"SOCKS error number %d\\n\", buff[1]);\n\t\tclose(sockfd);\n\t\treturn AY_CONNECTION_REFUSED;\n\t}",
"\treturn AY_NONE;\n}",
"int http_connect(int sockfd, const char *host, int port, AyProxyData *proxy)\n{\n\t/* step two : do proxy tunneling init */\n\tchar cmd[512];\n\tchar *inputline = NULL;\n\tchar *proxy_auth = NULL;",
"\tchar debug_buff[512];",
"\tint remaining = sizeof(cmd) - 1;",
"\tremaining -= snprintf(cmd, sizeof(cmd), \"CONNECT %s:%d HTTP/1.1\\r\\n\", host, port);\n\tif (proxy->username && proxy->username[0]) {\n\t\tproxy_auth = encode_proxy_auth_str(proxy);",
"\t\tstrncat(cmd, \"Proxy-Authorization: Basic \", remaining);\n\t\tremaining -= 27;\n\t\tstrncat(cmd, proxy_auth, remaining);\n\t\tremaining -= strlen(proxy_auth);\n\t\tstrncat(cmd, \"\\r\\n\", remaining);\n\t\tremaining -= 2;\n\t}\n\tstrncat(cmd, \"\\r\\n\", remaining);",
"#ifndef DEBUG\n\tsnprintf(debug_buff, sizeof(debug_buff), \"<%s>\\n\", cmd);\n\tdebug_print(debug_buff);",
"#endif\n\tif (send(sockfd, cmd, strlen(cmd), 0) < 0)\n\t\treturn AY_CONNECTION_REFUSED;\n\tif (ay_recv_line(sockfd, &inputline) < 0)\n\t\treturn AY_CONNECTION_REFUSED;",
"#ifndef DEBUG\n\tsnprintf(debug_buff, sizeof(debug_buff), \"<%s>\\n\", inputline);\n\tdebug_print(debug_buff);",
"#endif\n\tif (!strstr(inputline, \"200\")) {\n\t\t/* Check if proxy authorization needed */\n\t\tif (strstr(inputline, \"407\")) {\n\t\t\twhile (ay_recv_line(sockfd, &inputline) > 0) {\n\t\t\t\tfree(inputline);\n\t\t\t}\n\t\t\treturn AY_PROXY_AUTH_REQUIRED;\n\t\t}\n\t\tif (strstr(inputline, \"403\")) {\n\t\t\twhile (ay_recv_line(sockfd, &inputline) > 0) {\n\t\t\t\tfree(inputline);\n\t\t\t}\n\t\t\treturn AY_PROXY_PERMISSION_DENIED;\n\t\t}\n\t\tfree(inputline);\n\t\treturn AY_CONNECTION_REFUSED;\n\t}",
"\twhile (strlen(inputline) > 1) {\n\t\tfree(inputline);\n\t\tif (ay_recv_line(sockfd, &inputline) < 0) {\n\t\t\treturn AY_CONNECTION_REFUSED;\n\t\t}",
"#ifndef DEBUG\n\t\tsnprintf(debug_buff, sizeof(debug_buff), \"<%s>\\n\", inputline);\n\t\tdebug_print(debug_buff);",
"#endif\n\t}\n\tfree(inputline);",
"\tg_free(proxy_auth);",
"\treturn 0;\n}",
"static char *encode_proxy_auth_str(AyProxyData *proxy)\n{\n\tchar *buff = NULL;\n\tchar *ret = NULL;",
"\tif (proxy->username == NULL)\n\t\treturn NULL;",
"\tbuff = g_strdup_printf(\"%s:%s\", proxy->username, proxy->password);",
"\tret = g_base64_encode((unsigned char *)buff, strlen(buff));\n\tg_free (buff);",
"\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,
0,
1,
1,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [350], "buggy_code_start_loc": [297], "filenames": ["libproxy/proxy.c"], "fixing_code_end_loc": [346], "fixing_code_start_loc": [296], "message": "A vulnerability, which was classified as critical, was found in ayttm up to 0.5.0.89. This affects the function http_connect in the library libproxy/proxy.c. The manipulation leads to format string. It is possible to initiate the attack remotely. The name of the patch is 40e04680018614a7d2b68566b261b061a0597046. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-222267.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:ayttm_project:ayttm:*:*:*:*:*:*:*:*", "matchCriteriaId": "50590714-3CEF-4C65-906E-B7CCC8E8F618", "versionEndExcluding": null, "versionEndIncluding": "0.5.0-89", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as critical, was found in ayttm up to 0.5.0.89. This affects the function http_connect in the library libproxy/proxy.c. The manipulation leads to format string. It is possible to initiate the attack remotely. The name of the patch is 40e04680018614a7d2b68566b261b061a0597046. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-222267."}], "evaluatorComment": null, "id": "CVE-2015-10088", "lastModified": "2023-03-13T16:55:56.763", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "PARTIAL", "baseScore": 4.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "LOW", "baseScore": 5.0, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 1.6, "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-03-05T05:15:09.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/ayttm/ayttm/commit/40e04680018614a7d2b68566b261b061a0597046"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://sourceforge.net/p/ayttm/mailman/message/34397158/"}, {"source": "cna@vuldb.com", "tags": ["Permissions Required"], "url": "https://vuldb.com/?ctiid.222267"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.222267"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-134"}], "source": "cna@vuldb.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/ayttm/ayttm/commit/40e04680018614a7d2b68566b261b061a0597046"}, "type": "CWE-134"}
| 225
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\n * Ayttm\n *\n * Copyright (C) 2003, 2009 the Ayttm team\n * \n * Ayttm is a derivative of Everybuddy\n * Copyright (C) 1998-1999, Torrey Searle\n * proxy featured by Seb C.\n *\n * This program 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 program 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 program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n */",
"/* this is a little piece of code to handle proxy connection */\n/* it is intended to : 1st handle http proxy, using the CONNECT command\n , 2nd provide an easy way to add socks support */",
"#include \"intl.h\"",
"#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>",
"#ifdef __MINGW32__\n#include <winsock2.h>\n#else\n#include <sys/socket.h>\n#include <netdb.h>\n#include <netinet/in.h>\n#include <arpa/inet.h>\n#endif",
"#include \"proxy.h\"\n#include \"proxy_private.h\"\n#include \"common.h\"\n#include \"net_constants.h\"",
"#include <glib.h>",
"#ifdef __MINGW32__\n#define sleep(a)\t\tSleep(1000*a)",
"#define bcopy(a,b,c)\tmemcpy(b,a,c)\n#define bzero(a,b)\t\tmemset(a,0,b)",
"#define ECONNREFUSED\tWSAECONNREFUSED\n#endif",
"/* Prototypes */\nstatic char *encode_proxy_auth_str(AyProxyData *proxy);",
"#define debug_print printf",
"/* \n * External function to use to set the proxy settings\n */\nint ay_proxy_set_default(AyProxyType type, const char *host, int port,\n\tchar *username, char *password)\n{\n\tif (!default_proxy)\n\t\tdefault_proxy = g_new0(AyProxyData, 1);",
"\tdefault_proxy->type = type;",
"\tif (type == PROXY_NONE) {\n\t\tif (default_proxy->host)\n\t\t\tfree(default_proxy->host);",
"\t\tif (default_proxy->username)\n\t\t\tfree(default_proxy->username);",
"\t\tif (default_proxy->password)\n\t\t\tfree(default_proxy->password);",
"\t\tg_free(default_proxy);\n\t\tdefault_proxy = NULL;\n\t} else {\n\t\tdefault_proxy->port = 0;",
"\t\tif (host != NULL && host[0]) {\n\t\t\tdefault_proxy->host = strdup(host);\n\t\t\tdefault_proxy->port = port;\n\t\t}\n\t\tif (default_proxy->port == 0)\n\t\t\tdefault_proxy->port = 3128;",
"\t\tif (username && username[0])\n\t\t\tdefault_proxy->username = strdup(username);",
"\t\tif (password && password[0])\n\t\t\tdefault_proxy->password = strdup(password);",
"\t}\n#ifdef __MINGW32__\n\t{\n\t\tWSADATA wsaData;\n\t\tWSAStartup(MAKEWORD(2, 0), &wsaData);\n\t}\n#endif\n\treturn (0);\n}",
"/* http://archive.socks.permeo.com/protocol/socks4.protocol */\nint socks4_connect(int sock, const char *host, int port, AyProxyData *proxy)\n{\n\tint i, packetlen;",
"\tunsigned char *packet = NULL;\n\tstruct addrinfo *result = NULL;",
"\tint retval = 0;",
"\tif (proxy->username && proxy->username[0])\n\t\tpacketlen = 9 + strlen(proxy->username);\n\telse\n\t\tpacketlen = 9;",
"\tresult = lookup_address(host, port, AF_INET);",
"\tif (!result)\n\t\treturn AY_HOSTNAME_LOOKUP_FAIL;",
"\tpacket = (unsigned char *)calloc(packetlen, sizeof(unsigned char));",
"\tpacket[0] = 4;\t\t/* Version */\n\tpacket[1] = 1;\t\t/* CONNECT */\n\tpacket[2] = (((unsigned short)port) >> 8);\t/* DESTPORT */\n\tpacket[3] = (((unsigned short)port) & 0xff);\t/* DESTPORT */",
"\t/* DESTIP */\n\tbcopy(packet + 4, &(((struct sockaddr_in *)result->ai_addr)->sin_addr),\n\t\t4);",
"\tfreeaddrinfo(result);",
"\tif (proxy->username && proxy->username[0]) {\n\t\tfor (i = 0; proxy->username[i]; i++) {\n\t\t\tpacket[i + 8] = (unsigned char)proxy->username[i];\t/* AUTH */\n\t\t}\n\t}\n\tpacket[packetlen - 1] = 0;\t/* END */\n\tdebug_print(\"Sending \\\"%s\\\"\\n\", packet);\n\tif (write(sock, packet, packetlen) == packetlen) {\n\t\tbzero(packet, sizeof(packet));\n\t\t/* Check response - return as SOCKS4 if its valid */\n\t\tif (read(sock, packet, 9) >= 4) {\n\t\t\tif (packet[1] == 90) {\n\t\t\t\treturn 0;\n\t\t\t} else if (packet[1] == 91)\n\t\t\t\tretval = AY_SOCKS4_UNKNOWN;\n\t\t\telse if (packet[1] == 92)\n\t\t\t\tretval = AY_SOCKS4_IDENTD_FAIL;\n\t\t\telse if (packet[1] == 93)\n\t\t\t\tretval = AY_SOCKS4_IDENT_USER_DIFF;\n\t\t\telse {\n\t\t\t\tretval = AY_SOCKS4_INCOMPATIBLE_ERROR;\n\t\t\t\tprintf(\"=>>%d\\n\", packet[1]);\n\t\t\t}\n\t\t} else {\n\t\t\tprintf(\"short read %s\\n\", packet);\n\t\t}\n\t}\n\tclose(sock);",
"\treturn retval;\n}",
"/* http://archive.socks.permeo.com/rfc/rfc1928.txt */\n/* http://archive.socks.permeo.com/rfc/rfc1929.txt */",
"/* \n * Removed support for datagram connections because we're not even using it now. \n * I'll add it back if/when it is needed or if I feel like being very correct \n * some time later...\n */\nint socks5_connect(int sockfd, const char *host, int port, AyProxyData *proxy)\n{\n\tint i;\n\tchar buff[530];\n\tint need_auth = 0;\n\tstruct addrinfo *result = NULL;\n\tint j;",
"\tbuff[0] = 0x05;\t\t/* use socks v5 */\n\tif (proxy->username && proxy->username[0]) {\n\t\tbuff[1] = 0x02;\t/* we support (no authentication & username/pass) */\n\t\tbuff[2] = 0x00;\t/* we support the method type \"no authentication\" */\n\t\tbuff[3] = 0x02;\t/* we support the method type \"username/passw\" */\n\t\tneed_auth = 1;\n\t} else {\n\t\tbuff[1] = 0x01;\t/* we support (no authentication) */\n\t\tbuff[2] = 0x00;\t/* we support the method type \"no authentication\" */\n\t}",
"\twrite(sockfd, buff, 3 + ((proxy->username\n\t\t\t\t&& proxy->username[0]) ? 1 : 0));",
"\tif (read(sockfd, buff, 2) < 0) {\n\t\tclose(sockfd);\n\t\treturn AY_SOCKS5_CONNECT_FAIL;\n\t}\n\tif (buff[1] == 0x00)\n\t\tneed_auth = 0;\n\telse if (buff[1] == 0x02 && proxy->username && proxy->username[0])\n\t\tneed_auth = 1;\n\telse {\n\t\tfprintf(stderr, \"No Acceptable Methods\");\n\t\treturn AY_SOCKS5_CONNECT_FAIL;\n\t}\n\tif (((proxy->username && proxy->username[0]) ? 1 : 0)) {\n\t\t/* subneg start */\n\t\tbuff[0] = 0x01;\t/* subneg version */\n\t\tprintf(\"[%d]\", buff[0]);\n\t\tbuff[1] = strlen(proxy->username);\t/* username length */\n\t\tprintf(\"[%d]\", buff[1]);\n\t\tfor (i = 0; proxy->username[i] && i < 255; i++) {\n\t\t\tbuff[i + 2] = proxy->username[i];\t/* AUTH */\n\t\t\tprintf(\"%c\", buff[i + 2]);\n\t\t}\n\t\ti += 2;\n\t\tbuff[i] = strlen(proxy->password);\n\t\tprintf(\"[%d]\", buff[i]);\n\t\ti++;\n\t\tfor (j = 0; j < proxy->password[j] && j < 255; j++) {\n\t\t\tbuff[i + j] = proxy->password[j];\t/* AUTH */\n\t\t\tprintf(\"%c\", buff[i + j]);\n\t\t}\n\t\ti += (j);\n\t\tbuff[i] = 0;",
"\t\twrite(sockfd, buff, i);",
"\t\tif (read(sockfd, buff, 2) < 0) {\n\t\t\tclose(sockfd);\n\t\t\treturn AY_SOCKS5_CONNECT_FAIL;\n\t\t}",
"\t\tif (buff[1] != 0)\n\t\t\treturn AY_PROXY_PERMISSION_DENIED;\n\t}",
"\tbuff[0] = 0x05;\t\t/* use socks5 */\n\tbuff[1] = 0x01;\t\t/* connect only SOCK_STREAM for now */\n\tbuff[2] = 0x00;\t\t/* reserved */\n\tbuff[3] = 0x01;\t\t/* ipv4 address */",
"\tif ((result = lookup_address(host, port, AF_UNSPEC)) == NULL)\n\t\treturn AY_HOSTNAME_LOOKUP_FAIL;",
"\tmemcpy(buff + 4, &(((struct sockaddr_in *)result->ai_addr)->sin_addr),\n\t\t4);\n\tmemcpy((buff + 8), &(((struct sockaddr_in *)result->ai_addr)->sin_port),\n\t\t2);",
"\tfreeaddrinfo(result);",
"\twrite(sockfd, buff, 10);",
"\tif (read(sockfd, buff, 10) < 0) {\n\t\tclose(sockfd);\n\t\treturn AY_SOCKS5_CONNECT_FAIL;\n\t}",
"\tif (buff[1] != 0x00) {\n\t\tfor (i = 0; i < 8; i++)\n\t\t\tprintf(\"%03d \", buff[i]);",
"\t\tprintf(\"%d\", ntohs(*(unsigned short *)&buff[8]));\n\t\tprintf(\"\\n\");\n\t\tfprintf(stderr, \"SOCKS error number %d\\n\", buff[1]);\n\t\tclose(sockfd);\n\t\treturn AY_CONNECTION_REFUSED;\n\t}",
"\treturn AY_NONE;\n}",
"int http_connect(int sockfd, const char *host, int port, AyProxyData *proxy)\n{\n\t/* step two : do proxy tunneling init */\n\tchar cmd[512];\n\tchar *inputline = NULL;\n\tchar *proxy_auth = NULL;",
"",
"\tint remaining = sizeof(cmd) - 1;",
"\tremaining -= snprintf(cmd, sizeof(cmd), \"CONNECT %s:%d HTTP/1.1\\r\\n\", host, port);\n\tif (proxy->username && proxy->username[0]) {\n\t\tproxy_auth = encode_proxy_auth_str(proxy);",
"\t\tstrncat(cmd, \"Proxy-Authorization: Basic \", remaining);\n\t\tremaining -= 27;\n\t\tstrncat(cmd, proxy_auth, remaining);\n\t\tremaining -= strlen(proxy_auth);\n\t\tstrncat(cmd, \"\\r\\n\", remaining);\n\t\tremaining -= 2;\n\t}\n\tstrncat(cmd, \"\\r\\n\", remaining);",
"#ifdef DEBUG\n\tdebug_print(\"<%s>\\n\", cmd);",
"#endif\n\tif (send(sockfd, cmd, strlen(cmd), 0) < 0)\n\t\treturn AY_CONNECTION_REFUSED;\n\tif (ay_recv_line(sockfd, &inputline) < 0)\n\t\treturn AY_CONNECTION_REFUSED;",
"#ifdef DEBUG\n\tdebug_print(\"<%s>\\n\", inputline);",
"#endif\n\tif (!strstr(inputline, \"200\")) {\n\t\t/* Check if proxy authorization needed */\n\t\tif (strstr(inputline, \"407\")) {\n\t\t\twhile (ay_recv_line(sockfd, &inputline) > 0) {\n\t\t\t\tfree(inputline);\n\t\t\t}\n\t\t\treturn AY_PROXY_AUTH_REQUIRED;\n\t\t}\n\t\tif (strstr(inputline, \"403\")) {\n\t\t\twhile (ay_recv_line(sockfd, &inputline) > 0) {\n\t\t\t\tfree(inputline);\n\t\t\t}\n\t\t\treturn AY_PROXY_PERMISSION_DENIED;\n\t\t}\n\t\tfree(inputline);\n\t\treturn AY_CONNECTION_REFUSED;\n\t}",
"\twhile (strlen(inputline) > 1) {\n\t\tfree(inputline);\n\t\tif (ay_recv_line(sockfd, &inputline) < 0) {\n\t\t\treturn AY_CONNECTION_REFUSED;\n\t\t}",
"#ifdef DEBUG\n\t\tdebug_print(\"<%s>\\n\", inputline);",
"#endif\n\t}\n\tfree(inputline);",
"\tg_free(proxy_auth);",
"\treturn 0;\n}",
"static char *encode_proxy_auth_str(AyProxyData *proxy)\n{\n\tchar *buff = NULL;\n\tchar *ret = NULL;",
"\tif (proxy->username == NULL)\n\t\treturn NULL;",
"\tbuff = g_strdup_printf(\"%s:%s\", proxy->username, proxy->password);",
"\tret = g_base64_encode((unsigned char *)buff, strlen(buff));\n\tg_free (buff);",
"\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [350], "buggy_code_start_loc": [297], "filenames": ["libproxy/proxy.c"], "fixing_code_end_loc": [346], "fixing_code_start_loc": [296], "message": "A vulnerability, which was classified as critical, was found in ayttm up to 0.5.0.89. This affects the function http_connect in the library libproxy/proxy.c. The manipulation leads to format string. It is possible to initiate the attack remotely. The name of the patch is 40e04680018614a7d2b68566b261b061a0597046. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-222267.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:ayttm_project:ayttm:*:*:*:*:*:*:*:*", "matchCriteriaId": "50590714-3CEF-4C65-906E-B7CCC8E8F618", "versionEndExcluding": null, "versionEndIncluding": "0.5.0-89", "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as critical, was found in ayttm up to 0.5.0.89. This affects the function http_connect in the library libproxy/proxy.c. The manipulation leads to format string. It is possible to initiate the attack remotely. The name of the patch is 40e04680018614a7d2b68566b261b061a0597046. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-222267."}], "evaluatorComment": null, "id": "CVE-2015-10088", "lastModified": "2023-03-13T16:55:56.763", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "HIGH", "accessVector": "NETWORK", "authentication": "SINGLE", "availabilityImpact": "PARTIAL", "baseScore": 4.6, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:H/Au:S/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 3.9, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "LOW", "baseScore": 5.0, "baseSeverity": "MEDIUM", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 1.6, "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-03-05T05:15:09.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/ayttm/ayttm/commit/40e04680018614a7d2b68566b261b061a0597046"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://sourceforge.net/p/ayttm/mailman/message/34397158/"}, {"source": "cna@vuldb.com", "tags": ["Permissions Required"], "url": "https://vuldb.com/?ctiid.222267"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.222267"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-134"}], "source": "cna@vuldb.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/ayttm/ayttm/commit/40e04680018614a7d2b68566b261b061a0597046"}, "type": "CWE-134"}
| 225
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\nCopyright 2015, 2016 OpenMarket Ltd\nCopyright 2018 New Vector Ltd",
"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*/",
"import React, {createRef} from 'react';\nimport PropTypes from 'prop-types';\nimport filesize from 'filesize';\nimport {MatrixClientPeg} from '../../../MatrixClientPeg';\nimport * as sdk from '../../../index';\nimport { _t } from '../../../languageHandler';\nimport {decryptFile} from '../../../utils/DecryptFile';\nimport Tinter from '../../../Tinter';\nimport request from 'browser-request';\nimport Modal from '../../../Modal';\nimport AccessibleButton from \"../elements/AccessibleButton\";",
"\n// A cached tinted copy of require(\"../../../../res/img/download.svg\")\nlet tintedDownloadImageURL;\n// Track a list of mounted MFileBody instances so that we can update\n// the require(\"../../../../res/img/download.svg\") when the tint changes.\nlet nextMountId = 0;\nconst mounts = {};",
"/**\n * Updates the tinted copy of require(\"../../../../res/img/download.svg\") when the tint changes.\n */\nfunction updateTintedDownloadImage() {\n // Download the svg as an XML document.\n // We could cache the XML response here, but since the tint rarely changes\n // it's probably not worth it.\n // Also note that we can't use fetch here because fetch doesn't support\n // file URLs, which the download image will be if we're running from\n // the filesystem (like in an Electron wrapper).\n request({uri: require(\"../../../../res/img/download.svg\")}, (err, response, body) => {\n if (err) return;",
" const svg = new DOMParser().parseFromString(body, \"image/svg+xml\");\n // Apply the fixups to the XML.\n const fixups = Tinter.calcSvgFixups([{contentDocument: svg}]);\n Tinter.applySvgFixups(fixups);\n // Encoded the fixed up SVG as a data URL.\n const svgString = new XMLSerializer().serializeToString(svg);\n tintedDownloadImageURL = \"data:image/svg+xml;base64,\" + window.btoa(svgString);\n // Notify each mounted MFileBody that the URL has changed.\n Object.keys(mounts).forEach(function(id) {\n mounts[id].tint();\n });\n });\n}",
"Tinter.registerTintable(updateTintedDownloadImage);",
"// User supplied content can contain scripts, we have to be careful that\n// we don't accidentally run those script within the same origin as the\n// client. Otherwise those scripts written by remote users can read\n// the access token and end-to-end keys that are in local storage.\n//\n// For attachments downloaded directly from the homeserver we can use\n// Content-Security-Policy headers to disable script execution.\n//\n// But attachments with end-to-end encryption are more difficult to handle.\n// We need to decrypt the attachment on the client and then display it.\n// To display the attachment we need to turn the decrypted bytes into a URL.\n//\n// There are two ways to turn bytes into URLs, data URL and blob URLs.\n// Data URLs aren't suitable for downloading a file because Chrome has a\n// 2MB limit on the size of URLs that can be viewed in the browser or\n// downloaded. This limit does not seem to apply when the url is used as\n// the source attribute of an image tag.\n//\n// Blob URLs are generated using window.URL.createObjectURL and unfortunately\n// for our purposes they inherit the origin of the page that created them.\n// This means that any scripts that run when the URL is viewed will be able\n// to access local storage.\n//\n// The easiest solution is to host the code that generates the blob URL on\n// a different domain to the client.\n// Another possibility is to generate the blob URL within a sandboxed iframe.\n// The downside of using a second domain is that it complicates hosting,\n// the downside of using a sandboxed iframe is that the browers are overly\n// restrictive in what you are allowed to do with the generated URL.",
"/**\n * Get the current CSS style for a DOMElement.\n * @param {HTMLElement} element The element to get the current style of.\n * @return {string} The CSS style encoded as a string.\n */\nfunction computedStyle(element) {\n if (!element) {\n return \"\";\n }\n const style = window.getComputedStyle(element, null);\n let cssText = style.cssText;\n if (cssText == \"\") {\n // Firefox doesn't implement \".cssText\" for computed styles.\n // https://bugzilla.mozilla.org/show_bug.cgi?id=137687\n for (let i = 0; i < style.length; i++) {\n cssText += style[i] + \":\";\n cssText += style.getPropertyValue(style[i]) + \";\";\n }\n }\n return cssText;\n}",
"export default class MFileBody extends React.Component {\n static propTypes = {\n /* the MatrixEvent to show */\n mxEvent: PropTypes.object.isRequired,\n /* already decrypted blob */\n decryptedBlob: PropTypes.object,\n /* called when the download link iframe is shown */\n onHeightChanged: PropTypes.func,\n /* the shape of the tile, used */\n tileShape: PropTypes.string,\n };",
" constructor(props) {\n super(props);",
" this.state = {\n decryptedBlob: (this.props.decryptedBlob ? this.props.decryptedBlob : null),\n };",
" this._iframe = createRef();\n this._dummyLink = createRef();\n this._downloadImage = createRef();\n }",
" /**\n * Extracts a human readable label for the file attachment to use as\n * link text.\n *\n * @param {Object} content The \"content\" key of the matrix event.\n * @return {string} the human readable link text for the attachment.\n */\n presentableTextForFile(content) {\n let linkText = _t(\"Attachment\");\n if (content.body && content.body.length > 0) {\n // The content body should be the name of the file including a\n // file extension.\n linkText = content.body;\n }",
" if (content.info && content.info.size) {\n // If we know the size of the file then add it as human readable\n // string to the end of the link text so that the user knows how\n // big a file they are downloading.\n // The content.info also contains a MIME-type but we don't display\n // it since it is \"ugly\", users generally aren't aware what it\n // means and the type of the attachment can usually be inferrered\n // from the file extension.\n linkText += ' (' + filesize(content.info.size) + ')';\n }\n return linkText;\n }",
" _getContentUrl() {\n const content = this.props.mxEvent.getContent();\n return MatrixClientPeg.get().mxcUrlToHttp(content.url);\n }",
" componentDidMount() {\n // Add this to the list of mounted components to receive notifications\n // when the tint changes.\n this.id = nextMountId++;\n mounts[this.id] = this;\n this.tint();\n }",
" componentDidUpdate(prevProps, prevState) {\n if (this.props.onHeightChanged && !prevState.decryptedBlob && this.state.decryptedBlob) {\n this.props.onHeightChanged();\n }\n }",
" componentWillUnmount() {\n // Remove this from the list of mounted components\n delete mounts[this.id];\n }",
" tint = () => {\n // Update our tinted copy of require(\"../../../../res/img/download.svg\")\n if (this._downloadImage.current) {\n this._downloadImage.current.src = tintedDownloadImageURL;\n }\n if (this._iframe.current) {\n // If the attachment is encrypted then the download image\n // will be inside the iframe so we wont be able to update\n // it directly.\n this._iframe.current.contentWindow.postMessage({\n imgSrc: tintedDownloadImageURL,\n style: computedStyle(this._dummyLink.current),\n }, \"*\");\n }\n };",
" render() {\n const content = this.props.mxEvent.getContent();\n const text = this.presentableTextForFile(content);\n const isEncrypted = content.file !== undefined;\n const fileName = content.body && content.body.length > 0 ? content.body : _t(\"Attachment\");\n const contentUrl = this._getContentUrl();\n const ErrorDialog = sdk.getComponent(\"dialogs.ErrorDialog\");\n const fileSize = content.info ? content.info.size : null;\n const fileType = content.info ? content.info.mimetype : \"application/octet-stream\";",
" if (isEncrypted) {\n if (this.state.decryptedBlob === null) {\n // Need to decrypt the attachment\n // Wait for the user to click on the link before downloading\n // and decrypting the attachment.\n let decrypting = false;\n const decrypt = (e) => {\n if (decrypting) {\n return false;\n }\n decrypting = true;\n decryptFile(content.file).then((blob) => {\n this.setState({\n decryptedBlob: blob,\n });\n }).catch((err) => {\n console.warn(\"Unable to decrypt attachment: \", err);\n Modal.createTrackedDialog('Error decrypting attachment', '', ErrorDialog, {\n title: _t(\"Error\"),\n description: _t(\"Error decrypting attachment\"),\n });\n }).finally(() => {\n decrypting = false;\n });\n };",
" // This button should actually Download because usercontent/ will try to click itself\n // but it is not guaranteed between various browsers' settings.\n return (\n <span className=\"mx_MFileBody\">\n <div className=\"mx_MFileBody_download\">\n <AccessibleButton onClick={decrypt}>\n { _t(\"Decrypt %(text)s\", { text: text }) }\n </AccessibleButton>\n </div>\n </span>\n );\n }",
" // When the iframe loads we tell it to render a download link\n const onIframeLoad = (ev) => {\n ev.target.contentWindow.postMessage({\n imgSrc: tintedDownloadImageURL,\n style: computedStyle(this._dummyLink.current),\n blob: this.state.decryptedBlob,\n // Set a download attribute for encrypted files so that the file\n // will have the correct name when the user tries to download it.\n // We can't provide a Content-Disposition header like we would for HTTP.\n download: fileName,\n textContent: _t(\"Download %(text)s\", { text: text }),\n // only auto-download if a user triggered this iframe explicitly\n auto: !this.props.decryptedBlob,\n }, \"*\");\n };",
" const url = \"usercontent/\"; // XXX: this path should probably be passed from the skin",
" // If the attachment is encrypted then put the link inside an iframe.\n return (\n <span className=\"mx_MFileBody\">\n <div className=\"mx_MFileBody_download\">\n <div style={{display: \"none\"}}>\n { /*\n * Add dummy copy of the \"a\" tag\n * We'll use it to learn how the download link\n * would have been styled if it was rendered inline.\n */ }\n <a ref={this._dummyLink} />\n </div>\n <iframe",
" src={`${url}?origin=${encodeURIComponent(window.location.origin)}`}",
" onLoad={onIframeLoad}\n ref={this._iframe}\n sandbox=\"allow-scripts allow-downloads allow-downloads-without-user-activation\" />\n </div>\n </span>\n );\n } else if (contentUrl) {\n const downloadProps = {\n target: \"_blank\",\n rel: \"noreferrer noopener\",",
" // We set the href regardless of whether or not we intercept the download\n // because we don't really want to convert the file to a blob eagerly, and\n // still want \"open in new tab\" and \"save link as\" to work.\n href: contentUrl,\n };",
" // Blobs can only have up to 500mb, so if the file reports as being too large then\n // we won't try and convert it. Likewise, if the file size is unknown then we'll assume\n // it is too big. There is the risk of the reported file size and the actual file size\n // being different, however the user shouldn't normally run into this problem.\n const fileTooBig = typeof(fileSize) === 'number' ? fileSize > 524288000 : true;",
" if ([\"application/pdf\"].includes(fileType) && !fileTooBig) {\n // We want to force a download on this type, so use an onClick handler.\n downloadProps[\"onClick\"] = (e) => {\n console.log(`Downloading ${fileType} as blob (unencrypted)`);",
" // Avoid letting the <a> do its thing\n e.preventDefault();\n e.stopPropagation();",
" // Start a fetch for the download\n // Based upon https://stackoverflow.com/a/49500465\n fetch(contentUrl).then((response) => response.blob()).then((blob) => {\n const blobUrl = URL.createObjectURL(blob);",
" // We have to create an anchor to download the file\n const tempAnchor = document.createElement('a');\n tempAnchor.download = fileName;\n tempAnchor.href = blobUrl;\n document.body.appendChild(tempAnchor); // for firefox: https://stackoverflow.com/a/32226068\n tempAnchor.click();\n tempAnchor.remove();\n });\n };\n } else {\n // Else we are hoping the browser will do the right thing\n downloadProps[\"download\"] = fileName;\n }",
" // If the attachment is not encrypted then we check whether we\n // are being displayed in the room timeline or in a list of\n // files in the right hand side of the screen.\n if (this.props.tileShape === \"file_grid\") {\n return (\n <span className=\"mx_MFileBody\">\n <div className=\"mx_MFileBody_download\">\n <a className=\"mx_MFileBody_downloadLink\" {...downloadProps}>\n { fileName }\n </a>\n <div className=\"mx_MImageBody_size\">\n { content.info && content.info.size ? filesize(content.info.size) : \"\" }\n </div>\n </div>\n </span>\n );\n } else {\n return (\n <span className=\"mx_MFileBody\">\n <div className=\"mx_MFileBody_download\">\n <a {...downloadProps}>\n <img src={tintedDownloadImageURL} width=\"12\" height=\"14\" ref={this._downloadImage} />\n { _t(\"Download %(text)s\", { text: text }) }\n </a>\n </div>\n </span>\n );\n }\n } else {\n const extra = text ? (': ' + text) : '';\n return <span className=\"mx_MFileBody\">\n { _t(\"Invalid file%(extra)s\", { extra: extra }) }\n </span>;\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,
0,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [292, 49], "buggy_code_start_loc": [291, 1], "filenames": ["src/components/views/messages/MFileBody.js", "src/usercontent/index.js"], "fixing_code_end_loc": [292, 42], "fixing_code_start_loc": [291, 0], "message": "matrix-react-sdk is an npm package which is a Matrix SDK for React Javascript. In matrix-react-sdk before version 3.15.0, the user content sandbox can be abused to trick users into opening unexpected documents. The content is opened with a `blob` origin that cannot access Matrix user data, so messages and secrets are not at risk. This has been fixed in version 3.15.0.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:matrix-react-sdk_project:matrix-react-sdk:*:*:*:*:*:node.js:*:*", "matchCriteriaId": "AFAB6F64-94AF-40C9-9D0F-960483AED3F5", "versionEndExcluding": "3.15.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "matrix-react-sdk is an npm package which is a Matrix SDK for React Javascript. In matrix-react-sdk before version 3.15.0, the user content sandbox can be abused to trick users into opening unexpected documents. The content is opened with a `blob` origin that cannot access Matrix user data, so messages and secrets are not at risk. This has been fixed in version 3.15.0."}, {"lang": "es", "value": "matrix-react-sdk es un paquete npm que es un Matrix SDK para React Javascript. En matrix-react-sdk anterior a la versi\u00f3n 3.15.0, el sandbox del contenido del usuario puede ser abusado para enga\u00f1ar a los usuarios para que abran documentos inesperados. El contenido es abierto con un origen \"blob\" que no puede acceder a los datos del usuario de Matrix, por lo que los mensajes y secretos no est\u00e1n en riesgo. Esto ha sido corregido en la versi\u00f3n 3.15.0"}], "evaluatorComment": null, "id": "CVE-2021-21320", "lastModified": "2021-03-08T19:39:42.740", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 2.6, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 1.4, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2021-03-02T03:15:13.213", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/commit/b386f0c73b95ecbb6ea7f8f79c6ff5171a8dedd1"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/pull/5657"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/security/advisories/GHSA-52mq-6jcv-j79x"}, {"source": "security-advisories@github.com", "tags": ["Product", "Third Party Advisory"], "url": "https://www.npmjs.com/package/matrix-react-sdk"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-345"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/matrix-org/matrix-react-sdk/commit/b386f0c73b95ecbb6ea7f8f79c6ff5171a8dedd1"}, "type": "CWE-345"}
| 226
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"/*\nCopyright 2015, 2016 OpenMarket Ltd\nCopyright 2018 New Vector Ltd",
"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*/",
"import React, {createRef} from 'react';\nimport PropTypes from 'prop-types';\nimport filesize from 'filesize';\nimport {MatrixClientPeg} from '../../../MatrixClientPeg';\nimport * as sdk from '../../../index';\nimport { _t } from '../../../languageHandler';\nimport {decryptFile} from '../../../utils/DecryptFile';\nimport Tinter from '../../../Tinter';\nimport request from 'browser-request';\nimport Modal from '../../../Modal';\nimport AccessibleButton from \"../elements/AccessibleButton\";",
"\n// A cached tinted copy of require(\"../../../../res/img/download.svg\")\nlet tintedDownloadImageURL;\n// Track a list of mounted MFileBody instances so that we can update\n// the require(\"../../../../res/img/download.svg\") when the tint changes.\nlet nextMountId = 0;\nconst mounts = {};",
"/**\n * Updates the tinted copy of require(\"../../../../res/img/download.svg\") when the tint changes.\n */\nfunction updateTintedDownloadImage() {\n // Download the svg as an XML document.\n // We could cache the XML response here, but since the tint rarely changes\n // it's probably not worth it.\n // Also note that we can't use fetch here because fetch doesn't support\n // file URLs, which the download image will be if we're running from\n // the filesystem (like in an Electron wrapper).\n request({uri: require(\"../../../../res/img/download.svg\")}, (err, response, body) => {\n if (err) return;",
" const svg = new DOMParser().parseFromString(body, \"image/svg+xml\");\n // Apply the fixups to the XML.\n const fixups = Tinter.calcSvgFixups([{contentDocument: svg}]);\n Tinter.applySvgFixups(fixups);\n // Encoded the fixed up SVG as a data URL.\n const svgString = new XMLSerializer().serializeToString(svg);\n tintedDownloadImageURL = \"data:image/svg+xml;base64,\" + window.btoa(svgString);\n // Notify each mounted MFileBody that the URL has changed.\n Object.keys(mounts).forEach(function(id) {\n mounts[id].tint();\n });\n });\n}",
"Tinter.registerTintable(updateTintedDownloadImage);",
"// User supplied content can contain scripts, we have to be careful that\n// we don't accidentally run those script within the same origin as the\n// client. Otherwise those scripts written by remote users can read\n// the access token and end-to-end keys that are in local storage.\n//\n// For attachments downloaded directly from the homeserver we can use\n// Content-Security-Policy headers to disable script execution.\n//\n// But attachments with end-to-end encryption are more difficult to handle.\n// We need to decrypt the attachment on the client and then display it.\n// To display the attachment we need to turn the decrypted bytes into a URL.\n//\n// There are two ways to turn bytes into URLs, data URL and blob URLs.\n// Data URLs aren't suitable for downloading a file because Chrome has a\n// 2MB limit on the size of URLs that can be viewed in the browser or\n// downloaded. This limit does not seem to apply when the url is used as\n// the source attribute of an image tag.\n//\n// Blob URLs are generated using window.URL.createObjectURL and unfortunately\n// for our purposes they inherit the origin of the page that created them.\n// This means that any scripts that run when the URL is viewed will be able\n// to access local storage.\n//\n// The easiest solution is to host the code that generates the blob URL on\n// a different domain to the client.\n// Another possibility is to generate the blob URL within a sandboxed iframe.\n// The downside of using a second domain is that it complicates hosting,\n// the downside of using a sandboxed iframe is that the browers are overly\n// restrictive in what you are allowed to do with the generated URL.",
"/**\n * Get the current CSS style for a DOMElement.\n * @param {HTMLElement} element The element to get the current style of.\n * @return {string} The CSS style encoded as a string.\n */\nfunction computedStyle(element) {\n if (!element) {\n return \"\";\n }\n const style = window.getComputedStyle(element, null);\n let cssText = style.cssText;\n if (cssText == \"\") {\n // Firefox doesn't implement \".cssText\" for computed styles.\n // https://bugzilla.mozilla.org/show_bug.cgi?id=137687\n for (let i = 0; i < style.length; i++) {\n cssText += style[i] + \":\";\n cssText += style.getPropertyValue(style[i]) + \";\";\n }\n }\n return cssText;\n}",
"export default class MFileBody extends React.Component {\n static propTypes = {\n /* the MatrixEvent to show */\n mxEvent: PropTypes.object.isRequired,\n /* already decrypted blob */\n decryptedBlob: PropTypes.object,\n /* called when the download link iframe is shown */\n onHeightChanged: PropTypes.func,\n /* the shape of the tile, used */\n tileShape: PropTypes.string,\n };",
" constructor(props) {\n super(props);",
" this.state = {\n decryptedBlob: (this.props.decryptedBlob ? this.props.decryptedBlob : null),\n };",
" this._iframe = createRef();\n this._dummyLink = createRef();\n this._downloadImage = createRef();\n }",
" /**\n * Extracts a human readable label for the file attachment to use as\n * link text.\n *\n * @param {Object} content The \"content\" key of the matrix event.\n * @return {string} the human readable link text for the attachment.\n */\n presentableTextForFile(content) {\n let linkText = _t(\"Attachment\");\n if (content.body && content.body.length > 0) {\n // The content body should be the name of the file including a\n // file extension.\n linkText = content.body;\n }",
" if (content.info && content.info.size) {\n // If we know the size of the file then add it as human readable\n // string to the end of the link text so that the user knows how\n // big a file they are downloading.\n // The content.info also contains a MIME-type but we don't display\n // it since it is \"ugly\", users generally aren't aware what it\n // means and the type of the attachment can usually be inferrered\n // from the file extension.\n linkText += ' (' + filesize(content.info.size) + ')';\n }\n return linkText;\n }",
" _getContentUrl() {\n const content = this.props.mxEvent.getContent();\n return MatrixClientPeg.get().mxcUrlToHttp(content.url);\n }",
" componentDidMount() {\n // Add this to the list of mounted components to receive notifications\n // when the tint changes.\n this.id = nextMountId++;\n mounts[this.id] = this;\n this.tint();\n }",
" componentDidUpdate(prevProps, prevState) {\n if (this.props.onHeightChanged && !prevState.decryptedBlob && this.state.decryptedBlob) {\n this.props.onHeightChanged();\n }\n }",
" componentWillUnmount() {\n // Remove this from the list of mounted components\n delete mounts[this.id];\n }",
" tint = () => {\n // Update our tinted copy of require(\"../../../../res/img/download.svg\")\n if (this._downloadImage.current) {\n this._downloadImage.current.src = tintedDownloadImageURL;\n }\n if (this._iframe.current) {\n // If the attachment is encrypted then the download image\n // will be inside the iframe so we wont be able to update\n // it directly.\n this._iframe.current.contentWindow.postMessage({\n imgSrc: tintedDownloadImageURL,\n style: computedStyle(this._dummyLink.current),\n }, \"*\");\n }\n };",
" render() {\n const content = this.props.mxEvent.getContent();\n const text = this.presentableTextForFile(content);\n const isEncrypted = content.file !== undefined;\n const fileName = content.body && content.body.length > 0 ? content.body : _t(\"Attachment\");\n const contentUrl = this._getContentUrl();\n const ErrorDialog = sdk.getComponent(\"dialogs.ErrorDialog\");\n const fileSize = content.info ? content.info.size : null;\n const fileType = content.info ? content.info.mimetype : \"application/octet-stream\";",
" if (isEncrypted) {\n if (this.state.decryptedBlob === null) {\n // Need to decrypt the attachment\n // Wait for the user to click on the link before downloading\n // and decrypting the attachment.\n let decrypting = false;\n const decrypt = (e) => {\n if (decrypting) {\n return false;\n }\n decrypting = true;\n decryptFile(content.file).then((blob) => {\n this.setState({\n decryptedBlob: blob,\n });\n }).catch((err) => {\n console.warn(\"Unable to decrypt attachment: \", err);\n Modal.createTrackedDialog('Error decrypting attachment', '', ErrorDialog, {\n title: _t(\"Error\"),\n description: _t(\"Error decrypting attachment\"),\n });\n }).finally(() => {\n decrypting = false;\n });\n };",
" // This button should actually Download because usercontent/ will try to click itself\n // but it is not guaranteed between various browsers' settings.\n return (\n <span className=\"mx_MFileBody\">\n <div className=\"mx_MFileBody_download\">\n <AccessibleButton onClick={decrypt}>\n { _t(\"Decrypt %(text)s\", { text: text }) }\n </AccessibleButton>\n </div>\n </span>\n );\n }",
" // When the iframe loads we tell it to render a download link\n const onIframeLoad = (ev) => {\n ev.target.contentWindow.postMessage({\n imgSrc: tintedDownloadImageURL,\n style: computedStyle(this._dummyLink.current),\n blob: this.state.decryptedBlob,\n // Set a download attribute for encrypted files so that the file\n // will have the correct name when the user tries to download it.\n // We can't provide a Content-Disposition header like we would for HTTP.\n download: fileName,\n textContent: _t(\"Download %(text)s\", { text: text }),\n // only auto-download if a user triggered this iframe explicitly\n auto: !this.props.decryptedBlob,\n }, \"*\");\n };",
" const url = \"usercontent/\"; // XXX: this path should probably be passed from the skin",
" // If the attachment is encrypted then put the link inside an iframe.\n return (\n <span className=\"mx_MFileBody\">\n <div className=\"mx_MFileBody_download\">\n <div style={{display: \"none\"}}>\n { /*\n * Add dummy copy of the \"a\" tag\n * We'll use it to learn how the download link\n * would have been styled if it was rendered inline.\n */ }\n <a ref={this._dummyLink} />\n </div>\n <iframe",
" src={url}",
" onLoad={onIframeLoad}\n ref={this._iframe}\n sandbox=\"allow-scripts allow-downloads allow-downloads-without-user-activation\" />\n </div>\n </span>\n );\n } else if (contentUrl) {\n const downloadProps = {\n target: \"_blank\",\n rel: \"noreferrer noopener\",",
" // We set the href regardless of whether or not we intercept the download\n // because we don't really want to convert the file to a blob eagerly, and\n // still want \"open in new tab\" and \"save link as\" to work.\n href: contentUrl,\n };",
" // Blobs can only have up to 500mb, so if the file reports as being too large then\n // we won't try and convert it. Likewise, if the file size is unknown then we'll assume\n // it is too big. There is the risk of the reported file size and the actual file size\n // being different, however the user shouldn't normally run into this problem.\n const fileTooBig = typeof(fileSize) === 'number' ? fileSize > 524288000 : true;",
" if ([\"application/pdf\"].includes(fileType) && !fileTooBig) {\n // We want to force a download on this type, so use an onClick handler.\n downloadProps[\"onClick\"] = (e) => {\n console.log(`Downloading ${fileType} as blob (unencrypted)`);",
" // Avoid letting the <a> do its thing\n e.preventDefault();\n e.stopPropagation();",
" // Start a fetch for the download\n // Based upon https://stackoverflow.com/a/49500465\n fetch(contentUrl).then((response) => response.blob()).then((blob) => {\n const blobUrl = URL.createObjectURL(blob);",
" // We have to create an anchor to download the file\n const tempAnchor = document.createElement('a');\n tempAnchor.download = fileName;\n tempAnchor.href = blobUrl;\n document.body.appendChild(tempAnchor); // for firefox: https://stackoverflow.com/a/32226068\n tempAnchor.click();\n tempAnchor.remove();\n });\n };\n } else {\n // Else we are hoping the browser will do the right thing\n downloadProps[\"download\"] = fileName;\n }",
" // If the attachment is not encrypted then we check whether we\n // are being displayed in the room timeline or in a list of\n // files in the right hand side of the screen.\n if (this.props.tileShape === \"file_grid\") {\n return (\n <span className=\"mx_MFileBody\">\n <div className=\"mx_MFileBody_download\">\n <a className=\"mx_MFileBody_downloadLink\" {...downloadProps}>\n { fileName }\n </a>\n <div className=\"mx_MImageBody_size\">\n { content.info && content.info.size ? filesize(content.info.size) : \"\" }\n </div>\n </div>\n </span>\n );\n } else {\n return (\n <span className=\"mx_MFileBody\">\n <div className=\"mx_MFileBody_download\">\n <a {...downloadProps}>\n <img src={tintedDownloadImageURL} width=\"12\" height=\"14\" ref={this._downloadImage} />\n { _t(\"Download %(text)s\", { text: text }) }\n </a>\n </div>\n </span>\n );\n }\n } else {\n const extra = text ? (': ' + text) : '';\n return <span className=\"mx_MFileBody\">\n { _t(\"Invalid file%(extra)s\", { extra: extra }) }\n </span>;\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [292, 49], "buggy_code_start_loc": [291, 1], "filenames": ["src/components/views/messages/MFileBody.js", "src/usercontent/index.js"], "fixing_code_end_loc": [292, 42], "fixing_code_start_loc": [291, 0], "message": "matrix-react-sdk is an npm package which is a Matrix SDK for React Javascript. In matrix-react-sdk before version 3.15.0, the user content sandbox can be abused to trick users into opening unexpected documents. The content is opened with a `blob` origin that cannot access Matrix user data, so messages and secrets are not at risk. This has been fixed in version 3.15.0.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:matrix-react-sdk_project:matrix-react-sdk:*:*:*:*:*:node.js:*:*", "matchCriteriaId": "AFAB6F64-94AF-40C9-9D0F-960483AED3F5", "versionEndExcluding": "3.15.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "matrix-react-sdk is an npm package which is a Matrix SDK for React Javascript. In matrix-react-sdk before version 3.15.0, the user content sandbox can be abused to trick users into opening unexpected documents. The content is opened with a `blob` origin that cannot access Matrix user data, so messages and secrets are not at risk. This has been fixed in version 3.15.0."}, {"lang": "es", "value": "matrix-react-sdk es un paquete npm que es un Matrix SDK para React Javascript. En matrix-react-sdk anterior a la versi\u00f3n 3.15.0, el sandbox del contenido del usuario puede ser abusado para enga\u00f1ar a los usuarios para que abran documentos inesperados. El contenido es abierto con un origen \"blob\" que no puede acceder a los datos del usuario de Matrix, por lo que los mensajes y secretos no est\u00e1n en riesgo. Esto ha sido corregido en la versi\u00f3n 3.15.0"}], "evaluatorComment": null, "id": "CVE-2021-21320", "lastModified": "2021-03-08T19:39:42.740", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 2.6, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 1.4, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2021-03-02T03:15:13.213", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/commit/b386f0c73b95ecbb6ea7f8f79c6ff5171a8dedd1"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/pull/5657"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/security/advisories/GHSA-52mq-6jcv-j79x"}, {"source": "security-advisories@github.com", "tags": ["Product", "Third Party Advisory"], "url": "https://www.npmjs.com/package/matrix-react-sdk"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-345"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/matrix-org/matrix-react-sdk/commit/b386f0c73b95ecbb6ea7f8f79c6ff5171a8dedd1"}, "type": "CWE-345"}
| 226
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"const params = window.location.search.substring(1).split('&');\nlet lockOrigin;\nfor (let i = 0; i < params.length; ++i) {\n const parts = params[i].split('=');\n if (parts[0] === 'origin') lockOrigin = decodeURIComponent(parts[1]);\n}\n",
"function remoteRender(event) {\n const data = event.data;",
" const img = document.createElement(\"img\");\n img.id = \"img\";\n img.src = data.imgSrc;\n img.style = data.imgStyle;",
" const a = document.createElement(\"a\");\n a.id = \"a\";\n a.rel = \"noreferrer noopener\";\n a.download = data.download;\n a.style = data.style;\n a.style.fontFamily = \"Arial, Helvetica, Sans-Serif\";\n a.href = window.URL.createObjectURL(data.blob);\n a.appendChild(img);\n a.appendChild(document.createTextNode(data.textContent));",
" const body = document.body;\n // Don't display scrollbars if the link takes more than one line to display.\n body.style = \"margin: 0px; overflow: hidden\";\n body.appendChild(a);",
" if (event.data.auto) {\n a.click(); // try to trigger download automatically\n }\n}",
"function remoteSetTint(event) {\n const data = event.data;",
" const img = document.getElementById(\"img\");\n img.src = data.imgSrc;\n img.style = data.imgStyle;",
" const a = document.getElementById(\"a\");\n a.style = data.style;\n}",
"window.onmessage = function(e) {",
" if (e.origin === lockOrigin) {",
" if (e.data.blob) remoteRender(e);\n else remoteSetTint(e);\n }\n};"
] |
[
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [292, 49], "buggy_code_start_loc": [291, 1], "filenames": ["src/components/views/messages/MFileBody.js", "src/usercontent/index.js"], "fixing_code_end_loc": [292, 42], "fixing_code_start_loc": [291, 0], "message": "matrix-react-sdk is an npm package which is a Matrix SDK for React Javascript. In matrix-react-sdk before version 3.15.0, the user content sandbox can be abused to trick users into opening unexpected documents. The content is opened with a `blob` origin that cannot access Matrix user data, so messages and secrets are not at risk. This has been fixed in version 3.15.0.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:matrix-react-sdk_project:matrix-react-sdk:*:*:*:*:*:node.js:*:*", "matchCriteriaId": "AFAB6F64-94AF-40C9-9D0F-960483AED3F5", "versionEndExcluding": "3.15.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "matrix-react-sdk is an npm package which is a Matrix SDK for React Javascript. In matrix-react-sdk before version 3.15.0, the user content sandbox can be abused to trick users into opening unexpected documents. The content is opened with a `blob` origin that cannot access Matrix user data, so messages and secrets are not at risk. This has been fixed in version 3.15.0."}, {"lang": "es", "value": "matrix-react-sdk es un paquete npm que es un Matrix SDK para React Javascript. En matrix-react-sdk anterior a la versi\u00f3n 3.15.0, el sandbox del contenido del usuario puede ser abusado para enga\u00f1ar a los usuarios para que abran documentos inesperados. El contenido es abierto con un origen \"blob\" que no puede acceder a los datos del usuario de Matrix, por lo que los mensajes y secretos no est\u00e1n en riesgo. Esto ha sido corregido en la versi\u00f3n 3.15.0"}], "evaluatorComment": null, "id": "CVE-2021-21320", "lastModified": "2021-03-08T19:39:42.740", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 2.6, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 1.4, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2021-03-02T03:15:13.213", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/commit/b386f0c73b95ecbb6ea7f8f79c6ff5171a8dedd1"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/pull/5657"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/security/advisories/GHSA-52mq-6jcv-j79x"}, {"source": "security-advisories@github.com", "tags": ["Product", "Third Party Advisory"], "url": "https://www.npmjs.com/package/matrix-react-sdk"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-345"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/matrix-org/matrix-react-sdk/commit/b386f0c73b95ecbb6ea7f8f79c6ff5171a8dedd1"}, "type": "CWE-345"}
| 226
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"",
"function remoteRender(event) {\n const data = event.data;",
" const img = document.createElement(\"img\");\n img.id = \"img\";\n img.src = data.imgSrc;\n img.style = data.imgStyle;",
" const a = document.createElement(\"a\");\n a.id = \"a\";\n a.rel = \"noreferrer noopener\";\n a.download = data.download;\n a.style = data.style;\n a.style.fontFamily = \"Arial, Helvetica, Sans-Serif\";\n a.href = window.URL.createObjectURL(data.blob);\n a.appendChild(img);\n a.appendChild(document.createTextNode(data.textContent));",
" const body = document.body;\n // Don't display scrollbars if the link takes more than one line to display.\n body.style = \"margin: 0px; overflow: hidden\";\n body.appendChild(a);",
" if (event.data.auto) {\n a.click(); // try to trigger download automatically\n }\n}",
"function remoteSetTint(event) {\n const data = event.data;",
" const img = document.getElementById(\"img\");\n img.src = data.imgSrc;\n img.style = data.imgStyle;",
" const a = document.getElementById(\"a\");\n a.style = data.style;\n}",
"window.onmessage = function(e) {",
" if (e.origin === window.location.origin) {",
" if (e.data.blob) remoteRender(e);\n else remoteSetTint(e);\n }\n};"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [292, 49], "buggy_code_start_loc": [291, 1], "filenames": ["src/components/views/messages/MFileBody.js", "src/usercontent/index.js"], "fixing_code_end_loc": [292, 42], "fixing_code_start_loc": [291, 0], "message": "matrix-react-sdk is an npm package which is a Matrix SDK for React Javascript. In matrix-react-sdk before version 3.15.0, the user content sandbox can be abused to trick users into opening unexpected documents. The content is opened with a `blob` origin that cannot access Matrix user data, so messages and secrets are not at risk. This has been fixed in version 3.15.0.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:matrix-react-sdk_project:matrix-react-sdk:*:*:*:*:*:node.js:*:*", "matchCriteriaId": "AFAB6F64-94AF-40C9-9D0F-960483AED3F5", "versionEndExcluding": "3.15.0", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "matrix-react-sdk is an npm package which is a Matrix SDK for React Javascript. In matrix-react-sdk before version 3.15.0, the user content sandbox can be abused to trick users into opening unexpected documents. The content is opened with a `blob` origin that cannot access Matrix user data, so messages and secrets are not at risk. This has been fixed in version 3.15.0."}, {"lang": "es", "value": "matrix-react-sdk es un paquete npm que es un Matrix SDK para React Javascript. En matrix-react-sdk anterior a la versi\u00f3n 3.15.0, el sandbox del contenido del usuario puede ser abusado para enga\u00f1ar a los usuarios para que abran documentos inesperados. El contenido es abierto con un origen \"blob\" que no puede acceder a los datos del usuario de Matrix, por lo que los mensajes y secretos no est\u00e1n en riesgo. Esto ha sido corregido en la versi\u00f3n 3.15.0"}], "evaluatorComment": null, "id": "CVE-2021-21320", "lastModified": "2021-03-08T19:39:42.740", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "MEDIUM", "cvssData": {"accessComplexity": "MEDIUM", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "NONE", "baseScore": 4.3, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:M/Au:N/C:N/I:P/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": null, "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 4.3, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 2.8, "impactScore": 1.4, "source": "nvd@nist.gov", "type": "Primary"}, {"cvssData": {"attackComplexity": "HIGH", "attackVector": "NETWORK", "availabilityImpact": "NONE", "baseScore": 2.6, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:N", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 1.4, "source": "security-advisories@github.com", "type": "Secondary"}]}, "published": "2021-03-02T03:15:13.213", "references": [{"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/commit/b386f0c73b95ecbb6ea7f8f79c6ff5171a8dedd1"}, {"source": "security-advisories@github.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/pull/5657"}, {"source": "security-advisories@github.com", "tags": ["Third Party Advisory"], "url": "https://github.com/matrix-org/matrix-react-sdk/security/advisories/GHSA-52mq-6jcv-j79x"}, {"source": "security-advisories@github.com", "tags": ["Product", "Third Party Advisory"], "url": "https://www.npmjs.com/package/matrix-react-sdk"}], "sourceIdentifier": "security-advisories@github.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-345"}], "source": "security-advisories@github.com", "type": "Primary"}]}, "github_commit_url": "https://github.com/matrix-org/matrix-react-sdk/commit/b386f0c73b95ecbb6ea7f8f79c6ff5171a8dedd1"}, "type": "CWE-345"}
| 226
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Collections.Grades = Backbone.Collection.extend({\n initialize: function (options) {\n // this.owner = options[\"owner\"];\n this.course_id = options[\"course_id\"]\n this.url = \"api/users/\" + options[\"user_id\"] + \"/grades\"\n },",
" model: MerlinsBoard.Models.Grade,\n",
" getOrFetch: function (id) {",
" var grade = this.get(id);\n var grades = this;",
" if (!grade) {\n grade = new MerlinsBoard.Models.Grade({id: id});\n grade.fetch({ success: function () {\n this.add(grade);\n }\n })\n } else {\n grade.fetch();\n }",
" return grade\n },",
" fetch: function(options) {\n if (!options) {\n options = {};\n }",
" //some logic here to check if \"data\" was already passed in, and fusing that to the data parameter...\n",
" _.extend(options,{ data: $.param({ course_id: this.course_id}) }); //options is changed\n //with this, I might always have to bind fetch - be mindful of this in case I need to fetch more data",
" return Backbone.Collection.prototype.fetch.call(this, options);\n },\n",
"",
" parse: function (resp) {",
" this.student = new MerlinsBoard.Models.User({fname: resp.student_fname,lname: resp.student_lname});",
"\n resp.student_fname.delete //is there a better way to clean this up?\n resp.student_fname.delete",
"",
" return resp.grades\n }",
"})"
] |
[
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Collections.Grades = Backbone.Collection.extend({\n initialize: function (options) {\n // this.owner = options[\"owner\"];\n this.course_id = options[\"course_id\"]\n this.url = \"api/users/\" + options[\"user_id\"] + \"/grades\"\n },",
" model: MerlinsBoard.Models.Grade,\n",
" getOrFetch: function (id, course_id) {",
" var grade = this.get(id);\n var grades = this;",
" if (!grade) {\n grade = new MerlinsBoard.Models.Grade({id: id});\n grade.fetch({ success: function () {\n this.add(grade);\n }\n })\n } else {\n grade.fetch();\n }",
" return grade\n },",
" fetch: function(options) {\n if (!options) {\n options = {};\n }",
" //some logic here to check if \"data\" was already passed in, and fusing that to the data parameter...\n",
" _.extend(options,{ data: $.param({ course_id: this.course_id}) });",
" return Backbone.Collection.prototype.fetch.call(this, options);\n },\n",
" student: function () {\n if (!this._student) {\n this._student = new MerlinsBoard.Models.User();\n }",
" return this._student\n },\n",
" parse: function (resp) {",
" this.student().set({fname: resp.student_fname,lname: resp.student_lname});\n // this.course_id = resp.course_id should only set once and then never again",
"\n resp.student_fname.delete //is there a better way to clean this up?\n resp.student_fname.delete",
" resp.course_id.delete\n",
" return resp.grades\n }",
"})"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Models.Grade = Backbone.Model.extend({\n urlRoot: 'api/grades',\n validate: function () {}\n})"
] |
[
0
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Models.Grade = Backbone.Model.extend({\n urlRoot: 'api/grades',\n validate: function () {}\n})"
] |
[
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Routers.Router = Backbone.Router.extend({\n initialize: function (options) {\n this.$rootEl = options[\"rootEl\"];\n this.$sideNav = options[\"sideNav\"];\n this.$tabNav = options[\"tabNav\"];\n this.currentUser = MerlinsBoard.CurrentUser",
" var courseTabs = new MerlinsBoard.Views.CourseTabs({collection: this.currentUser.courses()})\n var courseDetails = new MerlinsBoard.Views.CourseDetails();",
" this.currentUser.fetch();",
" this.$tabNav.html(courseTabs.$el)\n this.$sideNav.html(courseDetails.$el)\n },",
"\troutes: {\n //course resources\n \"course/search\" : \"enrollcourses\",\n \"course/:id/enroll\" : \"showcourse\",\n \"course/new\": \"newcourse\",\n \"course/:id/edit\": \"editcourse\",\n \"course/taught\": \"taughtcourses\",\n //announcement resources\n \"\" : \"homeAnnouncements\",\n \"course/:id/announcements/new\": \"newAnnouncement\",\n \"course/:course_id/announcements/:id/edit\":\"editAnnouncement\",\n \"course/:id/announcements\" : \"courseAnnouncements\", //shows announcements for course + navView\n //assignment resources\n \"course/:id/assignments/new\" : \"newAssignment\",\n \"course/:id/assignments\" : \"showAssignments\",\n \"course/:course_id/assignments/:id/edit\" : \"editAssignment\",\n //grades\n \"course/:id/grades/student-search\" : \"gradeSearch\",",
" \"course/:course_id/grades/user/:user_id\" : \"gradesShow\"",
" //misc\n// \"user/:id\": \"showuser\"\n //\":wildcard\": \"does not exist\" --self explanatory\n\t},",
"\n //course resources\n\tenrollcourses: function () {\n var allcourses = new MerlinsBoard.Collections.Courses([],{owner: this.currentUser});\n",
" allcourses.fetch();",
"",
" var enrollView = new MerlinsBoard.Views.CoursesEnroll({collection: allcourses,model: this.currentUser});",
" this.swapView(enrollView);\n },",
"\tshowuser: function () {\n var userView = new MerlinsBoard.Views.UserShow({model: this.currentUser});\n this.swapView(userView);\n },",
"\tnewcourse: function () {\n var newcourse = new MerlinsBoard.Models.Course();\n var courseform = new MerlinsBoard.Views.CourseForm({model: newcourse});\n this.swapView(courseform);\n },",
"\teditcourse: function (id) {\n var course = MerlinsBoard.Courses.getOrFetch(id);\n var courseform = new MerlinsBoard.Views.CourseForm({model: course});\n this.swapView(courseform);\n },",
"\tshowcourse: function (id) {\n var course = MerlinsBoard.Courses.getOrFetch(id); //here\n var showCourse = new MerlinsBoard.Views.CoursesShow({model: course});\n this.swapView(showCourse);\n },",
" taughtcourses: function () {\n var taughtCourses = this.currentUser.taughtcourses();\n var taughtCourseView = new MerlinsBoard.Views.CoursesTaught({collection: taughtCourses});\n this.swapView(taughtCourseView);\n },",
" //announcements\n homeAnnouncements: function () {\n this.currentUser.fetch()",
" var allAnnouncements = this.currentUser.announcements();\n var allAnnouncementsView = new MerlinsBoard.Views.announcementHome({collection: allAnnouncements});\n this.swapView(allAnnouncementsView)",
" MerlinsBoard.Vent.trigger(\"homeRender\");\n },",
" courseAnnouncements: function (id) {\n //course detail nav should be instantiated here + announcements!\n var course = MerlinsBoard.Courses.getOrFetch(id);\n var announcements = course.announcements();",
"\n var courseAnnouncements = new MerlinsBoard.Views.announcementList({collection: announcements});\n this.swapView(courseAnnouncements);",
" MerlinsBoard.Vent.trigger(\"courseRender\",{courseID: id}); //for more functionality - it should pass in the reference to the course model instead\n },",
" newAnnouncement: function (id) {\n var newAnnouncement = new MerlinsBoard.Models.Announcement();\n var announcementForm = new MerlinsBoard.Views.announcementForm({model: newAnnouncement, course_id: id});\n this.swapView(announcementForm);\n },",
" editAnnouncement: function (course_id,id) {\n var announcement = new MerlinsBoard.Models.Announcement({id: id})\n announcement.fetch()",
" var announcementForm = new MerlinsBoard.Views.announcementForm({model: announcement, course_id: course_id});\n this.swapView(announcementForm);\n },",
" //assignments",
" showAssignments: function (id) {\n var course = MerlinsBoard.Courses.getOrFetch(id);\n var assignments = course.assignments();",
" var courseAssignments = new MerlinsBoard.Views.assignmentList({collection: assignments});\n this.swapView(courseAssignments);",
" MerlinsBoard.Vent.trigger(\"courseRender\",{courseID: id});\n },",
" newAssignment: function (id) {\n var newAssignment = new MerlinsBoard.Models.Assignment();\n var assignmentForm = new MerlinsBoard.Views.assignmentForm({model: newAssignment, course_id: id});\n this.swapView(assignmentForm);\n },",
" editAssignment: function (course_id,id) {\n var assignment = new MerlinsBoard.Models.Assignment({id: id});\n assignment.fetch();",
" var assignmentForm = new MerlinsBoard.Views.assignmentForm({model: assignment, course_id: course_id});\n this.swapView(assignmentForm);\n },",
" //grades",
" gradeSearch: function () {\n //I will have to call the course fetch here to determine privileges\n var course = MerlinsBoard.Courses.getOrFetch(id);\n var users = course.users()",
" // var usersList = MerlinsBoard.Views.\n },",
" gradeShow: function (course_id, user_id) {\n // var course = MerlinsBoard.Courses.getOrFetch(id);\n var grades = new MerlinsBoard.Collections.Grades({course_id: course_id, user_id: user_id});",
"",
" grades.fetch();",
" var gradesList = new MerlinsBoard.Views.GradesStudent({collection: grades});\n this.swapView(gradesList)\n },",
" // utils\n resourceNotFound: function () {\n //this.swapView();\n },",
" swapView: function (newView, navView) {\n if (!this._currentView) {\n this._currentView = newView;\n } else {\n this._currentView.remove();\n this._currentView = newView;\n }",
" this.$rootEl.html(newView.render().$el);\n }\n})",
"//var course = new MerlinsBoard.Models.Course({id: course_id})\n//course.fetch()"
] |
[
1,
1,
1,
1,
1,
0,
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,
0,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Routers.Router = Backbone.Router.extend({\n initialize: function (options) {\n this.$rootEl = options[\"rootEl\"];\n this.$sideNav = options[\"sideNav\"];\n this.$tabNav = options[\"tabNav\"];\n this.currentUser = MerlinsBoard.CurrentUser",
" var courseTabs = new MerlinsBoard.Views.CourseTabs({collection: this.currentUser.courses()})\n var courseDetails = new MerlinsBoard.Views.CourseDetails();",
" this.currentUser.fetch();",
" this.$tabNav.html(courseTabs.$el)\n this.$sideNav.html(courseDetails.$el)\n },",
"\troutes: {\n //course resources\n \"course/search\" : \"enrollcourses\",\n \"course/:id/enroll\" : \"showcourse\",\n \"course/new\": \"newcourse\",\n \"course/:id/edit\": \"editcourse\",\n \"course/taught\": \"taughtcourses\",\n //announcement resources\n \"\" : \"homeAnnouncements\",\n \"course/:id/announcements/new\": \"newAnnouncement\",\n \"course/:course_id/announcements/:id/edit\":\"editAnnouncement\",\n \"course/:id/announcements\" : \"courseAnnouncements\", //shows announcements for course + navView\n //assignment resources\n \"course/:id/assignments/new\" : \"newAssignment\",\n \"course/:id/assignments\" : \"showAssignments\",\n \"course/:course_id/assignments/:id/edit\" : \"editAssignment\",\n //grades\n \"course/:id/grades/student-search\" : \"gradeSearch\",",
" \"course/:course_id/grades/user/:user_id\" : \"gradeShow\"",
" //misc\n// \"user/:id\": \"showuser\"\n //\":wildcard\": \"does not exist\" --self explanatory\n\t},",
"\n //course resources\n\tenrollcourses: function () {\n var allcourses = new MerlinsBoard.Collections.Courses([],{owner: this.currentUser});\n",
" this.currentUser.fetch()",
"",
" var enrollView = new MerlinsBoard.Views.CoursesEnroll({model: this.currentUser});",
" this.swapView(enrollView);\n },",
"\tshowuser: function () {\n var userView = new MerlinsBoard.Views.UserShow({model: this.currentUser});\n this.swapView(userView);\n },",
"\tnewcourse: function () {\n var newcourse = new MerlinsBoard.Models.Course();\n var courseform = new MerlinsBoard.Views.CourseForm({model: newcourse});\n this.swapView(courseform);\n },",
"\teditcourse: function (id) {\n var course = MerlinsBoard.Courses.getOrFetch(id);\n var courseform = new MerlinsBoard.Views.CourseForm({model: course});\n this.swapView(courseform);\n },",
"\tshowcourse: function (id) {\n var course = MerlinsBoard.Courses.getOrFetch(id); //here\n var showCourse = new MerlinsBoard.Views.CoursesShow({model: course});\n this.swapView(showCourse);\n },",
" taughtcourses: function () {\n var taughtCourses = this.currentUser.taughtcourses();\n var taughtCourseView = new MerlinsBoard.Views.CoursesTaught({collection: taughtCourses});\n this.swapView(taughtCourseView);\n },",
" //announcements\n homeAnnouncements: function () {\n this.currentUser.fetch()",
" var allAnnouncements = this.currentUser.announcements();\n var allAnnouncementsView = new MerlinsBoard.Views.announcementHome({collection: allAnnouncements});\n this.swapView(allAnnouncementsView)",
" MerlinsBoard.Vent.trigger(\"homeRender\");\n },",
" courseAnnouncements: function (id) {\n //course detail nav should be instantiated here + announcements!\n var course = MerlinsBoard.Courses.getOrFetch(id);\n var announcements = course.announcements();",
"\n var courseAnnouncements = new MerlinsBoard.Views.announcementList({collection: announcements});\n this.swapView(courseAnnouncements);",
" MerlinsBoard.Vent.trigger(\"courseRender\",{courseID: id}); //for more functionality - it should pass in the reference to the course model instead\n },",
" newAnnouncement: function (id) {\n var newAnnouncement = new MerlinsBoard.Models.Announcement();\n var announcementForm = new MerlinsBoard.Views.announcementForm({model: newAnnouncement, course_id: id});\n this.swapView(announcementForm);\n },",
" editAnnouncement: function (course_id,id) {\n var announcement = new MerlinsBoard.Models.Announcement({id: id})\n announcement.fetch()",
" var announcementForm = new MerlinsBoard.Views.announcementForm({model: announcement, course_id: course_id});\n this.swapView(announcementForm);\n },",
" //assignments",
" showAssignments: function (id) {\n var course = MerlinsBoard.Courses.getOrFetch(id);\n var assignments = course.assignments();",
" var courseAssignments = new MerlinsBoard.Views.assignmentList({collection: assignments});\n this.swapView(courseAssignments);",
" MerlinsBoard.Vent.trigger(\"courseRender\",{courseID: id});\n },",
" newAssignment: function (id) {\n var newAssignment = new MerlinsBoard.Models.Assignment();\n var assignmentForm = new MerlinsBoard.Views.assignmentForm({model: newAssignment, course_id: id});\n this.swapView(assignmentForm);\n },",
" editAssignment: function (course_id,id) {\n var assignment = new MerlinsBoard.Models.Assignment({id: id});\n assignment.fetch();",
" var assignmentForm = new MerlinsBoard.Views.assignmentForm({model: assignment, course_id: course_id});\n this.swapView(assignmentForm);\n },",
" //grades",
" gradeSearch: function () {\n //I will have to call the course fetch here to determine privileges\n var course = MerlinsBoard.Courses.getOrFetch(id);\n var users = course.users()",
" // var usersList = MerlinsBoard.Views.\n },",
" gradeShow: function (course_id, user_id) {\n // var course = MerlinsBoard.Courses.getOrFetch(id);\n var grades = new MerlinsBoard.Collections.Grades({course_id: course_id, user_id: user_id});",
"",
" grades.fetch();",
" var gradesList = new MerlinsBoard.Views.GradesStudent({collection: grades});\n this.swapView(gradesList)\n },",
" // utils\n resourceNotFound: function () {\n //this.swapView();\n },",
" swapView: function (newView, navView) {\n if (!this._currentView) {\n this._currentView = newView;\n } else {\n this._currentView.remove();\n this._currentView = newView;\n }",
" this.$rootEl.html(newView.render().$el);\n }\n})",
"//var course = new MerlinsBoard.Models.Course({id: course_id})\n//course.fetch()"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Views.CourseForm = Backbone.View.extend({\n initialize: function () {",
" this.listenTo(this.model,\"sync\",this.render)\n },",
"\ttemplate: JST[\"courses/form\"],",
"\trender: function () {\n\t\tvar renderedContent = this.template({course: this.model})\n this.$el.html(renderedContent);\n return this\n\t},",
"\tevents: {\n\t\t\"submit form.course-form\": \"submitform\"\n\t},",
"\tsubmitform: function (event) {\n\t\tevent.preventDefault();\n\t\tvar attrs = $(event.target).serializeJSON();\n debugger\n\t\tthis.model.save(attrs, {\n\t\t\tsuccess: function () {\n\t\t\t\tMerlinsBoard.Courses.add(this.model,{merge: true})",
"\t\t\t\tBackbone.history.navigate(\"\",{trigger: true}) //instead do a \"course created/saved\"",
"\t\t\t}.bind(this),\n\t\t\terror: function (model,resp) {\n\t\t\t\tvar errorArray = resp.responseJSON;\n var $errorList = $(\"<ul>\").addClass(\"errors\");\n _.each(errorArray, function (error) {\n var $error = $(\"<li>\").text(error).addClass(\"error\");\n $errorList.append($error);\n })",
" $(\"section.form-errors\").html($errorList);\n\t\t\t}\n\t\t})\n\t}",
" //should refactor the above by abstracting with \".bindAll\"..or just abstracting\n})"
] |
[
1,
1,
1,
1,
1,
1,
0,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Views.CourseForm = Backbone.View.extend({\n initialize: function () {",
" this.listenTo(this.model,\"sync\",this.render)\n },",
"\ttemplate: JST[\"courses/form\"],",
"\trender: function () {\n\t\tvar renderedContent = this.template({course: this.model})\n this.$el.html(renderedContent);\n return this\n\t},",
"\tevents: {\n\t\t\"submit form.course-form\": \"submitform\"\n\t},",
"\tsubmitform: function (event) {\n\t\tevent.preventDefault();\n\t\tvar attrs = $(event.target).serializeJSON();\n debugger\n\t\tthis.model.save(attrs, {\n\t\t\tsuccess: function () {\n\t\t\t\tMerlinsBoard.Courses.add(this.model,{merge: true})",
"\t\t\t\tBackbone.history.navigate(\"course/search\",{trigger: true}) ",
"\t\t\t}.bind(this),\n\t\t\terror: function (model,resp) {\n\t\t\t\tvar errorArray = resp.responseJSON;\n var $errorList = $(\"<ul>\").addClass(\"errors\");\n _.each(errorArray, function (error) {\n var $error = $(\"<li>\").text(error).addClass(\"error\");\n $errorList.append($error);\n })",
" $(\"section.form-errors\").html($errorList);\n\t\t\t}\n\t\t})\n\t}",
" //should refactor the above by abstracting with \".bindAll\"..or just abstracting\n})"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Views.CoursesList = Backbone.View.extend({\n\tinitialize: function () {",
" \t\tthis.listenTo(this.collection, \"add remove sync\", this.render);",
"\t},",
"",
"\n\ttemplate: JST[\"courses/list\"],",
"\ttagName: \"ul\",",
"\tclassName: \"course-list\",",
"\trender: function () {\n\t\tvar renderedContent = this.template({courses: this.collection});\n\t\tthis.$el.html(renderedContent);\n\t\treturn this\n\t}",
"})"
] |
[
1,
0,
1,
0,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Views.CoursesList = Backbone.View.extend({\n\tinitialize: function () {",
" \t\tthis.listenTo(this.collection, \"reset add sync\", this.render);",
"\t},",
"",
"\n\ttemplate: JST[\"courses/list\"],",
"\ttagName: \"ul\",",
"\tclassName: \"course-list\",",
"\trender: function () {\n\t\tvar renderedContent = this.template({courses: this.collection});\n\t\tthis.$el.html(renderedContent);\n\t\treturn this\n\t}",
"})"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Views.CoursesSearch = Backbone.View.extend({\n\tinitialize: function () {",
"\t\tthis.searchCollection = new MerlinsBoard.Collections.CoursesSearch();",
"\t},",
"\ttemplate: JST[\"courses/coursesearch\"],",
"\trender: function () {\n\t\tvar renderedContent = this.template({courses: this.collection});\n\t\tthis.$el.html(renderedContent);\n\t\treturn this\n\t},\n",
"",
" tagName: \"section\",",
" className: \"course-search\",",
"\tevents: {\n\t\t\"submit form.course-find\":\"search\"\n\t},\n",
"\t// search: function (event) {\n\t// \tevent.preventDefault();\n // var query = $(\"input.course-find-input\").val();\n //\n // var filtered = this.collection.filter(function (course) {\n // var pattern = new RegExp(query, \"gi\");\n // var result = course.get(\"name\").match(pattern);\n // return result\n // })\n //\n // var filteredCollection = new MerlinsBoard.Collections.Courses([],{owner: MerlinsBoard.CurrentUser});\n // filteredCollection.set(filtered);\n //\n // var searchList = new MerlinsBoard.Views.CoursesList({collection: filteredCollection});\n\t// \tthis.$('section.course-results').html(searchList.render().$el);\n\t// }\n",
"\tsearch: function (event) {\n\t\tevent.preventDefault();\n\t var queryCourse = $(\"input.course-find-input\").val();",
"\t\tthis.searchCollection.fetch({data: $.param(query: queryCourse)});",
"",
"\t\tvar searchList = new MerlinsBoard.Views.CoursesList({collection: this.searchCollection});\n\t\t$('section.course-results').html(searchList.render.$el); //needs to be global from DOM.",
"\t}",
"})"
] |
[
1,
0,
1,
1,
1,
0,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Views.CoursesSearch = Backbone.View.extend({\n\tinitialize: function () {",
"",
"\t},",
"\ttemplate: JST[\"courses/coursesearch\"],",
"\trender: function () {\n\t\tvar renderedContent = this.template({courses: this.collection});\n\t\tthis.$el.html(renderedContent);\n\t\treturn this\n\t},\n",
"\tsearchCollection: function () {\n\t\tif (!this._searchCollection) {\n\t\t\tthis._searchCollection = new MerlinsBoard.Collections.CoursesSearch();\n\t\t}",
"\t\treturn this._searchCollection\n\t},\n",
" tagName: \"section\",",
" className: \"course-search\",",
"\tevents: {\n\t\t\"submit form.course-find\":\"search\"\n\t},\n",
"",
"\tsearch: function (event) {\n\t\tevent.preventDefault();\n\t var queryCourse = $(\"input.course-find-input\").val();",
"\t\tthis.searchCollection().fetch({data: $.param({query: queryCourse})});",
"",
"\t\tvar searchList = new MerlinsBoard.Views.CoursesList({collection: this.searchCollection()});\n\t\t//want to call remove on search results\n\t\t$('section.course-results').html(searchList.render().$el);",
"\t}",
"})"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Views.CoursesEnroll = Backbone.View.extend({\n\tinitialize: function () {",
"\t\tthis.coursesearchView = new MerlinsBoard.Views.CoursesSearch({collection: this.collection}); //render will put these in manually",
"\t\tthis.usercoursesView = new MerlinsBoard.Views.CoursesList({collection: this.model.courses()});\n\t\tthis.usertaughtcoursesView = new MerlinsBoard.Views.CoursesList({collection: this.model.taughtcourses()});\n\t},",
"\t",
" template: JST['courses/enroll'],",
"\t",
"\trender: function () {\n\t\tthis.$el.html(this.template());",
" ",
" this.$(\"section.courses-attended\").html(this.usercoursesView.render().$el);\n this.$(\"section.courses-taught\").html(this.usertaughtcoursesView.render().$el);\n this.$(\"section.course-search\").html(this.coursesearchView.render().$el);",
"\t\t",
" return this",
"\t},\n \n //below two, again - hardcode URLs instead\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\tshow: function (event) {\n\t\tevent.preventDefault();\n\t\tvar id = $(event.currentTarget).data(\"id\");\n\t\tBackbone.history.navigate(\"course/\" + id + \"/enroll\", {trigger:true})\n\t},",
"\tevents: {\n\t\t\"click a\": \"show\"",
"\t}",
"});"
] |
[
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Views.CoursesEnroll = Backbone.View.extend({\n\tinitialize: function () {",
"\t\tthis.coursesearchView = new MerlinsBoard.Views.CoursesSearch();",
"\t\tthis.usercoursesView = new MerlinsBoard.Views.CoursesList({collection: this.model.courses()});\n\t\tthis.usertaughtcoursesView = new MerlinsBoard.Views.CoursesList({collection: this.model.taughtcourses()});\n\t},",
"",
" template: JST['courses/enroll'],",
"",
"\trender: function () {\n\t\tthis.$el.html(this.template());",
"",
" this.$(\"section.courses-attended\").html(this.usercoursesView.render().$el);\n this.$(\"section.courses-taught\").html(this.usertaughtcoursesView.render().$el);\n this.$(\"section.course-search\").html(this.coursesearchView.render().$el);",
"",
" return this",
"",
"\t}",
"});"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Views.SearchStudent = Backbone.View.extend({",
" initialize: function () {\n this.listenTo(this.collection, \"add remove reset\", this.render)\n },\n",
" className: \"grades-studentsearch\",",
"\n template: JST[\"grades/grades-student-search\"],",
" render: function () {\n var renderedContent = this.template({students: this.collection});\n this.$el.html(renderedContent);\n return this.$el\n }\n})"
] |
[
0,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"MerlinsBoard.Views.SearchStudentGradesResults = Backbone.View.extend({",
" initialize: function () {\n this.listenTo(this.collection, \"add remove reset\", this.render)\n },\n",
" className: \"grades-student-search\",",
"\n template: JST[\"grades/grades-student-search\"],",
" render: function () {\n var renderedContent = this.template({students: this.collection});\n this.$el.html(renderedContent);\n return this.$el\n }\n})"
] |
[
1,
1,
1,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"//Lists a students grade - an admin has access to this view to edit grades\nMerlinsBoard.Views.GradesStudent = Backbone.View.extend({\n initialize: function () {",
" this.listenTo(this.collection, \"add change:grade remove\", this.render)",
" _.bindAll(this, \"gradeSaveCallback\", \"gradeSaveErrorCallback\")",
" //for jbuidler - nest each of a student's grade under them along with basic information about the assignment",
" },\n",
" template: JST[\"grades/grades-student\"],",
"\n events: {\n \"click .grade-number\":\"editGrade\",\n \"blur .grade-input\": \"saveGrade\"\n },",
" className: \"grade-list\",",
" tagName: \"section\",",
" render: function () {",
" var renderedContent = this.template({grades: this.collection});",
" this.$el.html(renderedContent);",
" return this.$el",
" },",
" editGrade: function (event) {",
" var gradeString = $(event.currentTarget).text();",
" var num = parseInt(gradeString);",
" var $input = $(\"<input type='number'>\").addClass('grade-input').val(num);\n",
" this.modelNumber = $(event.currentTarget).data('id');",
"\n $(\".grade-number\").html(input)",
" },",
" saveGrade: function (event) {\n var editedGrade = this.collection.getOrFetch(this.modelNumber);",
" var newGrade = $('input.grade-input').val();",
" var courseID = this.collection.course_id;\n",
"",
" editedGrade.set({grade: newGrade});",
" //two options, send in the params with the model and strong params takes care of it\n //or send it in as an option for the save option\n editedGrade.save({},{success: this.gradeSaveCallback,\n error: this.gradeSaveErrorCallback,\n data: $.param({course_id: courseID})",
" });\n },\n",
" gradeSaveCallback: function () {\n this.collection.add(editedGrade,{merge: true})//this should be a closure - also editedGrade I think should persist as a variable...\n // $(\".grade-number\").html(editedGrade.get('grade')); this wont work because I'm inspecific, but I may not need it anyway to rerender",
" },\n",
" gradeSaveErrorCallback: function (model, response) {",
" var errorArray = resp.responseJSON\n var $errorList = $(\"<ul>\").addClass('errors');\n _.each(errorArray, function (error) {\n var $error = $(\"<li>\").text(error).addClass('error');\n $errorList.append($error);\n })",
" $(\"section.grade-errors\").html($errorList);\n }\n})"
] |
[
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
0,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Determine whether the {function_name} code is vulnerable or not.
|
[
"//Lists a students grade - an admin has access to this view to edit grades\nMerlinsBoard.Views.GradesStudent = Backbone.View.extend({\n initialize: function () {",
" this.listenTo(this.collection, \"add change:grade remove sync\", this.render)",
" _.bindAll(this, \"gradeSaveCallback\", \"gradeSaveErrorCallback\")",
" //for jbuidler - nest each of a student's grade under them along with basic information about the assignmen",
" },\n",
" template: JST[\"grades/grades-student-list\"],",
"\n events: {\n \"click .grade-number\":\"editGrade\",\n \"blur .grade-input\": \"saveGrade\"\n },",
" className: \"grade-list\",",
" tagName: \"section\",",
" render: function () {",
" var renderedContent = this.template({grades: this.collection, student: this.collection.student()});",
" this.$el.html(renderedContent);",
" return this",
" },",
" editGrade: function (event) {",
" var gradeString = $(event.currentTarget).val();",
" var num = parseInt(gradeString);",
" var $input = $(\"<input type='number' min='0' step='1' max='100'>\").addClass('grade-input').val(num);",
" this.modelNumber = $(event.currentTarget).data('id');",
" $(\".grade-number[data-id=\".concat(this.modelNumber,\"]\")).html($input)",
" },",
" saveGrade: function (event) {\n var editedGrade = this.collection.getOrFetch(this.modelNumber);",
" var newGrade = parseInt($('input.grade-input').val());",
" var courseID = this.collection.course_id;\n",
" debugger\n",
" editedGrade.set({grade: newGrade});",
" editedGrade.save({course_id: courseID},{success: this.gradeSaveCallback(editedGrade),\n error: this.gradeSaveErrorCallback",
" });\n },\n",
" gradeSaveCallback: function (editedGrade) {\n this.collection.fetch(); //unideal - needs to be banished with composite view paradigm.\n // this.collection.add(editedGrade,{merge: true});",
" },\n",
" gradeSaveErrorCallback: function (model, resp) {\n",
" var errorArray = resp.responseJSON\n var $errorList = $(\"<ul>\").addClass('errors');\n _.each(errorArray, function (error) {\n var $error = $(\"<li>\").text(error).addClass('error');\n $errorList.append($error);\n })",
" $(\"section.grade-errors\").html($errorList);\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
] |
PreciseBugs
|
{"buggy_code_end_loc": [43, 5, 156, 27, 6, 46, 30, 7, 56, 14, 4, 13, 49, 17, 17, 11], "buggy_code_start_loc": [10, 4, 35, 26, 3, 3, 3, 1, 4, 13, 2, 1, 2, 1, 17, 11], "filenames": ["app/assets/javascripts/collections/grades.js", "app/assets/javascripts/models/grade.js", "app/assets/javascripts/routers/router.js", "app/assets/javascripts/views/courses/course-form.js", "app/assets/javascripts/views/courses/course-list.js", "app/assets/javascripts/views/courses/course_search.js", "app/assets/javascripts/views/courses/courses_enroll.js", "app/assets/javascripts/views/grades/grade-search-student.js", "app/assets/javascripts/views/grades/grades-student.js", "app/assets/templates/courses/coursesearch.jst.ejs", "app/assets/templates/courses/list.jst.ejs", "app/assets/templates/grades/grades-student-list.jst.ejs", "app/controllers/api/grades_controller.rb", "app/views/api/grades/index.json.jbuilder", "config/routes.rb", "db/seeds.rb"], "fixing_code_end_loc": [54, 5, 158, 27, 4, 37, 17, 7, 54, 12, 4, 10, 57, 18, 19, 14], "fixing_code_start_loc": [10, 4, 35, 26, 3, 2, 3, 1, 4, 12, 2, 1, 2, 2, 18, 12], "message": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability.", "other": {"cve": {"cisaActionDue": null, "cisaExploitAdd": null, "cisaRequiredAction": null, "cisaVulnerabilityName": null, "configurations": [{"nodes": [{"cpeMatch": [{"criteria": "cpe:2.3:a:merlinsboard_project:merlinsboard:*:*:*:*:*:*:*:*", "matchCriteriaId": "9414ED47-1FC1-4072-BDB9-DF7C47A53F84", "versionEndExcluding": "2015-03-19", "versionEndIncluding": null, "versionStartExcluding": null, "versionStartIncluding": null, "vulnerable": true}], "negate": false, "operator": "OR"}], "operator": null}], "descriptions": [{"lang": "en", "value": "A vulnerability, which was classified as problematic, was found in jvvlee MerlinsBoard. This affects an unknown part of the component Grade Handler. The manipulation leads to improper authorization. The name of the patch is 134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5. It is recommended to apply a patch to fix this issue. The identifier VDB-217713 was assigned to this vulnerability."}], "evaluatorComment": null, "id": "CVE-2015-10033", "lastModified": "2023-01-13T18:21:16.730", "metrics": {"cvssMetricV2": [{"acInsufInfo": false, "baseSeverity": "LOW", "cvssData": {"accessComplexity": "LOW", "accessVector": "ADJACENT_NETWORK", "authentication": "MULTIPLE", "availabilityImpact": "PARTIAL", "baseScore": 3.7, "confidentialityImpact": "NONE", "integrityImpact": "PARTIAL", "vectorString": "AV:A/AC:L/Au:M/C:N/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 4.1, "impactScore": 4.9, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "source": "cna@vuldb.com", "type": "Secondary", "userInteractionRequired": false}], "cvssMetricV30": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "ADJACENT_NETWORK", "availabilityImpact": "LOW", "baseScore": 3.5, "baseSeverity": "LOW", "confidentialityImpact": "NONE", "integrityImpact": "LOW", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.0/AV:A/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:L", "version": "3.0"}, "exploitabilityScore": 0.9, "impactScore": 2.5, "source": "cna@vuldb.com", "type": "Secondary"}], "cvssMetricV31": [{"cvssData": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 6.5, "baseSeverity": "MEDIUM", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "privilegesRequired": "HIGH", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 1.2, "impactScore": 5.2, "source": "nvd@nist.gov", "type": "Primary"}]}, "published": "2023-01-09T21:15:10.210", "references": [{"source": "cna@vuldb.com", "tags": ["Patch", "Third Party Advisory"], "url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?ctiid.217713"}, {"source": "cna@vuldb.com", "tags": ["Third Party Advisory"], "url": "https://vuldb.com/?id.217713"}], "sourceIdentifier": "cna@vuldb.com", "vendorComments": null, "vulnStatus": "Analyzed", "weaknesses": [{"description": [{"lang": "en", "value": "CWE-863"}], "source": "nvd@nist.gov", "type": "Primary"}, {"description": [{"lang": "en", "value": "CWE-285"}], "source": "cna@vuldb.com", "type": "Secondary"}]}, "github_commit_url": "https://github.com/jvvlee/MerlinsBoard/commit/134f5481e2914b7f096cd92a22b1e6bcb8e6dfe5"}, "type": "CWE-863"}
| 227
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.