prompt stringclasses 1 value | completions listlengths 2 1.33k | labels listlengths 2 1.33k | source stringclasses 1 value | other_info dict | index int64 0 719 | cwe stringclasses 9 values | language stringclasses 6 values |
|---|---|---|---|---|---|---|---|
Determine whether the {function_name} code is vulnerable or not. | [
"def shame_add(name):\n shame = shame_ask(name)\n db = db_connect()\n cursor = db.cursor()\n if shame is None:\n try:\n cursor.execute('''",
" INSERT INTO people(name,karma,shame) VALUES('{}',0,1)\n '''.format(name))",
" db.commit()\n logger.debug('Inserted into karmadb 1 shame for {}'.format(name))\n db.close()\n return 1\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise",
" else:\n shame = shame + 1\n try:\n cursor.execute('''",
" UPDATE people SET shame = {0} WHERE name = '{1}'\n '''.format(shame, name))",
" db.commit()\n logger.debug('Inserted into karmadb {} shame for {}'.format(\n shame, name))\n db.close()\n return shame\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise"
] | [
1,
0,
1,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 230,
"char_start": 222,
"chars": "%(name)s"
},
{
"char_end": 257,
"char_start": 255,
"chars": ", "
},
{
"char_end": 264,
"char_start": 262,
"chars": ", "
},
{
"char_end": 664,
"char_start": 655,
"chars": "%(karma)s"
},
{
"char_end": 686,
"char_start": 678,
"chars": "%(name)s"
},
{
"char_end": 707,
"char_start": 706,
"chars": " "
},
{
"char_end": 725,
"char_start": 708,
"chars": "\n "
},
{
"char_end": 747,
"char_start": 731,
"chars": "\n "
},
{
"char_end": 766,
"char_start": 752,
"chars": ",\n "
}
],
"deleted": [
{
"char_end": 226,
"char_start": 222,
"chars": "'{}'"
},
{
"char_end": 258,
"char_start": 251,
"chars": ".format"
},
{
"char_end": 657,
"char_start": 654,
"chars": "{0}"
},
{
"char_end": 676,
"char_start": 671,
"chars": "'{1}'"
},
{
"char_end": 703,
"char_start": 696,
"chars": ".format"
}
]
},
"commit_link": "github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a",
"file_name": "KarmaBoi/dbopts.py",
"func_name": "shame_add",
"line_changes": {
"added": [
{
"char_end": 236,
"char_start": 162,
"line": " INSERT INTO people(name,karma,shame) VALUES(%(name)s,0,1)\n",
"line_no": 8
},
{
"char_end": 267,
"char_start": 236,
"line": " ''', (name, ))\n",
"line_no": 9
},
{
"char_end": 687,
"char_start": 613,
"line": " UPDATE people SET shame = %(karma)s WHERE name = %(name)s\n",
"line_no": 22
},
{
"char_end": 709,
"char_start": 687,
"line": " ''' (\n",
"line_no": 23
},
{
"char_end": 732,
"char_start": 709,
"line": " shame,\n",
"line_no": 24
},
{
"char_end": 754,
"char_start": 732,
"line": " name,\n",
"line_no": 25
},
{
"char_end": 769,
"char_start": 754,
"line": " ))\n",
"line_no": 26
}
],
"deleted": [
{
"char_end": 232,
"char_start": 162,
"line": " INSERT INTO people(name,karma,shame) VALUES('{}',0,1)\n",
"line_no": 8
},
{
"char_end": 266,
"char_start": 232,
"line": " '''.format(name))\n",
"line_no": 9
},
{
"char_end": 677,
"char_start": 612,
"line": " UPDATE people SET shame = {0} WHERE name = '{1}'\n",
"line_no": 22
},
{
"char_end": 718,
"char_start": 677,
"line": " '''.format(shame, name))\n",
"line_no": 23
}
]
},
"vul_type": "cwe-089"
} | 350 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def shame_add(name):\n shame = shame_ask(name)\n db = db_connect()\n cursor = db.cursor()\n if shame is None:\n try:\n cursor.execute('''",
" INSERT INTO people(name,karma,shame) VALUES(%(name)s,0,1)\n ''', (name, ))",
" db.commit()\n logger.debug('Inserted into karmadb 1 shame for {}'.format(name))\n db.close()\n return 1\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise",
" else:\n shame = shame + 1\n try:\n cursor.execute('''",
" UPDATE people SET shame = %(karma)s WHERE name = %(name)s\n ''' (\n shame,\n name,\n ))",
" db.commit()\n logger.debug('Inserted into karmadb {} shame for {}'.format(\n shame, name))\n db.close()\n return shame\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise"
] | [
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 230,
"char_start": 222,
"chars": "%(name)s"
},
{
"char_end": 257,
"char_start": 255,
"chars": ", "
},
{
"char_end": 264,
"char_start": 262,
"chars": ", "
},
{
"char_end": 664,
"char_start": 655,
"chars": "%(karma)s"
},
{
"char_end": 686,
"char_start": 678,
"chars": "%(name)s"
},
{
"char_end": 707,
"char_start": 706,
"chars": " "
},
{
"char_end": 725,
"char_start": 708,
"chars": "\n "
},
{
"char_end": 747,
"char_start": 731,
"chars": "\n "
},
{
"char_end": 766,
"char_start": 752,
"chars": ",\n "
}
],
"deleted": [
{
"char_end": 226,
"char_start": 222,
"chars": "'{}'"
},
{
"char_end": 258,
"char_start": 251,
"chars": ".format"
},
{
"char_end": 657,
"char_start": 654,
"chars": "{0}"
},
{
"char_end": 676,
"char_start": 671,
"chars": "'{1}'"
},
{
"char_end": 703,
"char_start": 696,
"chars": ".format"
}
]
},
"commit_link": "github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a",
"file_name": "KarmaBoi/dbopts.py",
"func_name": "shame_add",
"line_changes": {
"added": [
{
"char_end": 236,
"char_start": 162,
"line": " INSERT INTO people(name,karma,shame) VALUES(%(name)s,0,1)\n",
"line_no": 8
},
{
"char_end": 267,
"char_start": 236,
"line": " ''', (name, ))\n",
"line_no": 9
},
{
"char_end": 687,
"char_start": 613,
"line": " UPDATE people SET shame = %(karma)s WHERE name = %(name)s\n",
"line_no": 22
},
{
"char_end": 709,
"char_start": 687,
"line": " ''' (\n",
"line_no": 23
},
{
"char_end": 732,
"char_start": 709,
"line": " shame,\n",
"line_no": 24
},
{
"char_end": 754,
"char_start": 732,
"line": " name,\n",
"line_no": 25
},
{
"char_end": 769,
"char_start": 754,
"line": " ))\n",
"line_no": 26
}
],
"deleted": [
{
"char_end": 232,
"char_start": 162,
"line": " INSERT INTO people(name,karma,shame) VALUES('{}',0,1)\n",
"line_no": 8
},
{
"char_end": 266,
"char_start": 232,
"line": " '''.format(name))\n",
"line_no": 9
},
{
"char_end": 677,
"char_start": 612,
"line": " UPDATE people SET shame = {0} WHERE name = '{1}'\n",
"line_no": 22
},
{
"char_end": 718,
"char_start": 677,
"line": " '''.format(shame, name))\n",
"line_no": 23
}
]
},
"vul_type": "cwe-089"
} | 350 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def can_user_pass_that_amount_of_money(self, user_id, money):",
" self.cursor.execute(\"SELECT count(id) FROM kickstarter.users where id = %s and money >= %s\" % (user_id, money))",
" return self.cursor.fetchall()[0][0]"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 166,
"char_start": 165,
"chars": ","
}
],
"deleted": [
{
"char_end": 167,
"char_start": 165,
"chars": " %"
}
]
},
"commit_link": "github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b",
"file_name": "backend/transactions/TransactionConnector.py",
"func_name": "can_user_pass_that_amount_of_money",
"line_changes": {
"added": [
{
"char_end": 185,
"char_start": 66,
"line": " self.cursor.execute(\"SELECT count(id) FROM kickstarter.users where id = %s and money >= %s\", (user_id, money))\n",
"line_no": 2
}
],
"deleted": [
{
"char_end": 186,
"char_start": 66,
"line": " self.cursor.execute(\"SELECT count(id) FROM kickstarter.users where id = %s and money >= %s\" % (user_id, money))\n",
"line_no": 2
}
]
},
"vul_type": "cwe-089"
} | 351 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def can_user_pass_that_amount_of_money(self, user_id, money):",
" self.cursor.execute(\"SELECT count(id) FROM kickstarter.users where id = %s and money >= %s\", (user_id, money))",
" return self.cursor.fetchall()[0][0]"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 166,
"char_start": 165,
"chars": ","
}
],
"deleted": [
{
"char_end": 167,
"char_start": 165,
"chars": " %"
}
]
},
"commit_link": "github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b",
"file_name": "backend/transactions/TransactionConnector.py",
"func_name": "can_user_pass_that_amount_of_money",
"line_changes": {
"added": [
{
"char_end": 185,
"char_start": 66,
"line": " self.cursor.execute(\"SELECT count(id) FROM kickstarter.users where id = %s and money >= %s\", (user_id, money))\n",
"line_no": 2
}
],
"deleted": [
{
"char_end": 186,
"char_start": 66,
"line": " self.cursor.execute(\"SELECT count(id) FROM kickstarter.users where id = %s and money >= %s\" % (user_id, money))\n",
"line_no": 2
}
]
},
"vul_type": "cwe-089"
} | 351 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@endpoints.route(\"/placings\")\ndef placings():\n if db == None:\n init()",
" tag = request.args.get('tag', default='christmas mike')",
" # Get all the urls that this player has participated in",
" sql = \"SELECT * FROM placings WHERE player = '{}'\".format(tag)\n results = list(db.exec(sql))",
" results.sort(key=lambda x: int(x[2]))",
" return json.dumps(results)"
] | [
1,
1,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 256,
"char_start": 253,
"chars": "tag"
},
{
"char_end": 265,
"char_start": 259,
"chars": "\n a"
},
{
"char_end": 273,
"char_start": 266,
"chars": "gs = {'"
},
{
"char_end": 279,
"char_start": 274,
"chars": "ag': "
},
{
"char_end": 283,
"char_start": 282,
"chars": "}"
},
{
"char_end": 320,
"char_start": 314,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 259,
"char_start": 256,
"chars": ".fo"
},
{
"char_end": 261,
"char_start": 260,
"chars": "m"
},
{
"char_end": 264,
"char_start": 262,
"chars": "t("
},
{
"char_end": 268,
"char_start": 267,
"chars": ")"
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "endpoints.py",
"func_name": "placings",
"line_changes": {
"added": [
{
"char_end": 260,
"char_start": 202,
"line": " sql = \"SELECT * FROM placings WHERE player = '{tag}'\"\n",
"line_no": 9
},
{
"char_end": 284,
"char_start": 260,
"line": " args = {'tag': tag}\n",
"line_no": 10
},
{
"char_end": 323,
"char_start": 284,
"line": " results = list(db.exec(sql, args))\n",
"line_no": 11
}
],
"deleted": [
{
"char_end": 269,
"char_start": 202,
"line": " sql = \"SELECT * FROM placings WHERE player = '{}'\".format(tag)\n",
"line_no": 9
},
{
"char_end": 302,
"char_start": 269,
"line": " results = list(db.exec(sql))\n",
"line_no": 10
}
]
},
"vul_type": "cwe-089"
} | 352 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@endpoints.route(\"/placings\")\ndef placings():\n if db == None:\n init()",
" tag = request.args.get('tag', default='christmas mike')",
" # Get all the urls that this player has participated in",
" sql = \"SELECT * FROM placings WHERE player = '{tag}'\"\n args = {'tag': tag}\n results = list(db.exec(sql, args))",
" results.sort(key=lambda x: int(x[2]))",
" return json.dumps(results)"
] | [
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 256,
"char_start": 253,
"chars": "tag"
},
{
"char_end": 265,
"char_start": 259,
"chars": "\n a"
},
{
"char_end": 273,
"char_start": 266,
"chars": "gs = {'"
},
{
"char_end": 279,
"char_start": 274,
"chars": "ag': "
},
{
"char_end": 283,
"char_start": 282,
"chars": "}"
},
{
"char_end": 320,
"char_start": 314,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 259,
"char_start": 256,
"chars": ".fo"
},
{
"char_end": 261,
"char_start": 260,
"chars": "m"
},
{
"char_end": 264,
"char_start": 262,
"chars": "t("
},
{
"char_end": 268,
"char_start": 267,
"chars": ")"
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "endpoints.py",
"func_name": "placings",
"line_changes": {
"added": [
{
"char_end": 260,
"char_start": 202,
"line": " sql = \"SELECT * FROM placings WHERE player = '{tag}'\"\n",
"line_no": 9
},
{
"char_end": 284,
"char_start": 260,
"line": " args = {'tag': tag}\n",
"line_no": 10
},
{
"char_end": 323,
"char_start": 284,
"line": " results = list(db.exec(sql, args))\n",
"line_no": 11
}
],
"deleted": [
{
"char_end": 269,
"char_start": 202,
"line": " sql = \"SELECT * FROM placings WHERE player = '{}'\".format(tag)\n",
"line_no": 9
},
{
"char_end": 302,
"char_start": 269,
"line": " results = list(db.exec(sql))\n",
"line_no": 10
}
]
},
"vul_type": "cwe-089"
} | 352 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def markTokenUsedExternal(token, optStr=\"\"):\n conn, c = connectDB()",
" req = \"UPDATE {} SET \\\"options_selected\\\"='{}' WHERE token='{}'\".format(CFG(\"tokens_table_name\"), \\\n optStr, token)\n c.execute(req)",
" closeDB(conn)"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 118,
"char_start": 117,
"chars": "?"
},
{
"char_end": 132,
"char_start": 131,
"chars": "?"
},
{
"char_end": 166,
"char_start": 165,
"chars": ")"
},
{
"char_end": 185,
"char_start": 171,
"chars": "c.execute(req,"
},
{
"char_end": 187,
"char_start": 186,
"chars": "("
},
{
"char_end": 201,
"char_start": 200,
"chars": ","
}
],
"deleted": [
{
"char_end": 121,
"char_start": 117,
"chars": "'{}'"
},
{
"char_end": 138,
"char_start": 134,
"chars": "'{}'"
},
{
"char_end": 174,
"char_start": 171,
"chars": ", \\"
},
{
"char_end": 177,
"char_start": 175,
"chars": " "
},
{
"char_end": 182,
"char_start": 181,
"chars": " "
},
{
"char_end": 195,
"char_start": 183,
"chars": " "
},
{
"char_end": 227,
"char_start": 209,
"chars": "\n c.execute(req"
}
]
},
"commit_link": "github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109",
"file_name": "database.py",
"func_name": "markTokenUsedExternal",
"line_changes": {
"added": [
{
"char_end": 167,
"char_start": 71,
"line": " req = \"UPDATE {} SET \\\"options_selected\\\"=? WHERE token=?\".format(CFG(\"tokens_table_name\"))\n",
"line_no": 3
},
{
"char_end": 204,
"char_start": 167,
"line": " c.execute(req, (optStr, token,))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 175,
"char_start": 71,
"line": " req = \"UPDATE {} SET \\\"options_selected\\\"='{}' WHERE token='{}'\".format(CFG(\"tokens_table_name\"), \\\n",
"line_no": 3
},
{
"char_end": 210,
"char_start": 175,
"line": " optStr, token)\n",
"line_no": 4
},
{
"char_end": 229,
"char_start": 210,
"line": " c.execute(req)\n",
"line_no": 5
}
]
},
"vul_type": "cwe-089"
} | 353 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def markTokenUsedExternal(token, optStr=\"\"):\n conn, c = connectDB()",
" req = \"UPDATE {} SET \\\"options_selected\\\"=? WHERE token=?\".format(CFG(\"tokens_table_name\"))\n c.execute(req, (optStr, token,))",
" closeDB(conn)"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 118,
"char_start": 117,
"chars": "?"
},
{
"char_end": 132,
"char_start": 131,
"chars": "?"
},
{
"char_end": 166,
"char_start": 165,
"chars": ")"
},
{
"char_end": 185,
"char_start": 171,
"chars": "c.execute(req,"
},
{
"char_end": 187,
"char_start": 186,
"chars": "("
},
{
"char_end": 201,
"char_start": 200,
"chars": ","
}
],
"deleted": [
{
"char_end": 121,
"char_start": 117,
"chars": "'{}'"
},
{
"char_end": 138,
"char_start": 134,
"chars": "'{}'"
},
{
"char_end": 174,
"char_start": 171,
"chars": ", \\"
},
{
"char_end": 177,
"char_start": 175,
"chars": " "
},
{
"char_end": 182,
"char_start": 181,
"chars": " "
},
{
"char_end": 195,
"char_start": 183,
"chars": " "
},
{
"char_end": 227,
"char_start": 209,
"chars": "\n c.execute(req"
}
]
},
"commit_link": "github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109",
"file_name": "database.py",
"func_name": "markTokenUsedExternal",
"line_changes": {
"added": [
{
"char_end": 167,
"char_start": 71,
"line": " req = \"UPDATE {} SET \\\"options_selected\\\"=? WHERE token=?\".format(CFG(\"tokens_table_name\"))\n",
"line_no": 3
},
{
"char_end": 204,
"char_start": 167,
"line": " c.execute(req, (optStr, token,))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 175,
"char_start": 71,
"line": " req = \"UPDATE {} SET \\\"options_selected\\\"='{}' WHERE token='{}'\".format(CFG(\"tokens_table_name\"), \\\n",
"line_no": 3
},
{
"char_end": 210,
"char_start": 175,
"line": " optStr, token)\n",
"line_no": 4
},
{
"char_end": 229,
"char_start": 210,
"line": " c.execute(req)\n",
"line_no": 5
}
]
},
"vul_type": "cwe-089"
} | 353 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_roster(self, server_id):",
" sql = \"\"\"SELECT username, role\n FROM roles\n WHERE roles.server_id = {0};\n \"\"\".format(server_id)\n self.cur.execute(sql)",
" return self.cur.fetchall()"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 69,
"char_start": 54,
"chars": "\n "
},
{
"char_end": 156,
"char_start": 154,
"chars": "%s"
},
{
"char_end": 218,
"char_start": 204,
"chars": ", (server_id,)"
}
],
"deleted": [
{
"char_end": 77,
"char_start": 76,
"chars": " "
},
{
"char_end": 93,
"char_start": 91,
"chars": " "
},
{
"char_end": 107,
"char_start": 104,
"chars": " "
},
{
"char_end": 148,
"char_start": 145,
"chars": "{0}"
},
{
"char_end": 153,
"char_start": 150,
"chars": " "
},
{
"char_end": 188,
"char_start": 170,
"chars": ".format(server_id)"
}
]
},
"commit_link": "github.com/jgayfer/spirit/commit/01c846c534c8d3cf6763f8b7444a0efe2caa3799",
"file_name": "db/dbase.py",
"func_name": "get_roster",
"line_changes": {
"added": [
{
"char_end": 55,
"char_start": 37,
"line": " sql = \"\"\"\n",
"line_no": 2
},
{
"char_end": 91,
"char_start": 55,
"line": " SELECT username, role\n",
"line_no": 3
},
{
"char_end": 116,
"char_start": 91,
"line": " FROM roles\n",
"line_no": 4
},
{
"char_end": 158,
"char_start": 116,
"line": " WHERE roles.server_id = %s;\n",
"line_no": 5
},
{
"char_end": 176,
"char_start": 158,
"line": " \"\"\"\n",
"line_no": 6
},
{
"char_end": 220,
"char_start": 176,
"line": " self.cur.execute(sql, (server_id,))\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 76,
"char_start": 37,
"line": " sql = \"\"\"SELECT username, role\n",
"line_no": 2
},
{
"char_end": 104,
"char_start": 76,
"line": " FROM roles\n",
"line_no": 3
},
{
"char_end": 150,
"char_start": 104,
"line": " WHERE roles.server_id = {0};\n",
"line_no": 4
},
{
"char_end": 189,
"char_start": 150,
"line": " \"\"\".format(server_id)\n",
"line_no": 5
},
{
"char_end": 219,
"char_start": 189,
"line": " self.cur.execute(sql)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 354 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_roster(self, server_id):",
" sql = \"\"\"\n SELECT username, role\n FROM roles\n WHERE roles.server_id = %s;\n \"\"\"\n self.cur.execute(sql, (server_id,))",
" return self.cur.fetchall()"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 69,
"char_start": 54,
"chars": "\n "
},
{
"char_end": 156,
"char_start": 154,
"chars": "%s"
},
{
"char_end": 218,
"char_start": 204,
"chars": ", (server_id,)"
}
],
"deleted": [
{
"char_end": 77,
"char_start": 76,
"chars": " "
},
{
"char_end": 93,
"char_start": 91,
"chars": " "
},
{
"char_end": 107,
"char_start": 104,
"chars": " "
},
{
"char_end": 148,
"char_start": 145,
"chars": "{0}"
},
{
"char_end": 153,
"char_start": 150,
"chars": " "
},
{
"char_end": 188,
"char_start": 170,
"chars": ".format(server_id)"
}
]
},
"commit_link": "github.com/jgayfer/spirit/commit/01c846c534c8d3cf6763f8b7444a0efe2caa3799",
"file_name": "db/dbase.py",
"func_name": "get_roster",
"line_changes": {
"added": [
{
"char_end": 55,
"char_start": 37,
"line": " sql = \"\"\"\n",
"line_no": 2
},
{
"char_end": 91,
"char_start": 55,
"line": " SELECT username, role\n",
"line_no": 3
},
{
"char_end": 116,
"char_start": 91,
"line": " FROM roles\n",
"line_no": 4
},
{
"char_end": 158,
"char_start": 116,
"line": " WHERE roles.server_id = %s;\n",
"line_no": 5
},
{
"char_end": 176,
"char_start": 158,
"line": " \"\"\"\n",
"line_no": 6
},
{
"char_end": 220,
"char_start": 176,
"line": " self.cur.execute(sql, (server_id,))\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 76,
"char_start": 37,
"line": " sql = \"\"\"SELECT username, role\n",
"line_no": 2
},
{
"char_end": 104,
"char_start": 76,
"line": " FROM roles\n",
"line_no": 3
},
{
"char_end": 150,
"char_start": 104,
"line": " WHERE roles.server_id = {0};\n",
"line_no": 4
},
{
"char_end": 189,
"char_start": 150,
"line": " \"\"\".format(server_id)\n",
"line_no": 5
},
{
"char_end": 219,
"char_start": 189,
"line": " self.cur.execute(sql)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 354 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def retrieve_video(id, playlist_id, db):",
" db.execute(\"SELECT id, position from video WHERE id={id} and playlist_id={playlist_id};\".format(\n id=id, playlist_id=playlist_id))",
" row = db.fetchone()\n return row"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 65,
"char_start": 56,
"chars": "\n "
},
{
"char_end": 108,
"char_start": 106,
"chars": "%s"
},
{
"char_end": 126,
"char_start": 125,
"chars": "%"
},
{
"char_end": 130,
"char_start": 129,
"chars": ","
},
{
"char_end": 132,
"char_start": 131,
"chars": "("
}
],
"deleted": [
{
"char_end": 101,
"char_start": 97,
"chars": "{id}"
},
{
"char_end": 125,
"char_start": 118,
"chars": "{playli"
},
{
"char_end": 131,
"char_start": 126,
"chars": "t_id}"
},
{
"char_end": 140,
"char_start": 133,
"chars": ".format"
},
{
"char_end": 153,
"char_start": 141,
"chars": "\n id="
},
{
"char_end": 169,
"char_start": 157,
"chars": "playlist_id="
}
]
},
"commit_link": "github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6",
"file_name": "video/video_repository.py",
"func_name": "retrieve_video",
"line_changes": {
"added": [
{
"char_end": 57,
"char_start": 41,
"line": " db.execute(\n",
"line_no": 2
},
{
"char_end": 150,
"char_start": 57,
"line": " \"SELECT id, position from video WHERE id=%s and playlist_id=%s;\", (id, playlist_id))\n",
"line_no": 3
}
],
"deleted": [
{
"char_end": 142,
"char_start": 41,
"line": " db.execute(\"SELECT id, position from video WHERE id={id} and playlist_id={playlist_id};\".format(\n",
"line_no": 2
},
{
"char_end": 183,
"char_start": 142,
"line": " id=id, playlist_id=playlist_id))\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 355 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def retrieve_video(id, playlist_id, db):",
" db.execute(\n \"SELECT id, position from video WHERE id=%s and playlist_id=%s;\", (id, playlist_id))",
" row = db.fetchone()\n return row"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 65,
"char_start": 56,
"chars": "\n "
},
{
"char_end": 108,
"char_start": 106,
"chars": "%s"
},
{
"char_end": 126,
"char_start": 125,
"chars": "%"
},
{
"char_end": 130,
"char_start": 129,
"chars": ","
},
{
"char_end": 132,
"char_start": 131,
"chars": "("
}
],
"deleted": [
{
"char_end": 101,
"char_start": 97,
"chars": "{id}"
},
{
"char_end": 125,
"char_start": 118,
"chars": "{playli"
},
{
"char_end": 131,
"char_start": 126,
"chars": "t_id}"
},
{
"char_end": 140,
"char_start": 133,
"chars": ".format"
},
{
"char_end": 153,
"char_start": 141,
"chars": "\n id="
},
{
"char_end": 169,
"char_start": 157,
"chars": "playlist_id="
}
]
},
"commit_link": "github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6",
"file_name": "video/video_repository.py",
"func_name": "retrieve_video",
"line_changes": {
"added": [
{
"char_end": 57,
"char_start": 41,
"line": " db.execute(\n",
"line_no": 2
},
{
"char_end": 150,
"char_start": 57,
"line": " \"SELECT id, position from video WHERE id=%s and playlist_id=%s;\", (id, playlist_id))\n",
"line_no": 3
}
],
"deleted": [
{
"char_end": 142,
"char_start": 41,
"line": " db.execute(\"SELECT id, position from video WHERE id={id} and playlist_id={playlist_id};\".format(\n",
"line_no": 2
},
{
"char_end": 183,
"char_start": 142,
"line": " id=id, playlist_id=playlist_id))\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 355 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def followFriends(self,userid,friendid):",
" sqlText=\"insert into friends values(%d,%d);\"%(friendid,userid)\n result=sql.insertDB(self.conn,sqlText)",
" return result;"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 91,
"char_start": 90,
"chars": "s"
},
{
"char_end": 94,
"char_start": 93,
"chars": "s"
},
{
"char_end": 114,
"char_start": 97,
"chars": "\n params=["
},
{
"char_end": 130,
"char_start": 129,
"chars": "]"
},
{
"char_end": 183,
"char_start": 176,
"chars": ",params"
}
],
"deleted": [
{
"char_end": 91,
"char_start": 90,
"chars": "d"
},
{
"char_end": 94,
"char_start": 93,
"chars": "d"
},
{
"char_end": 99,
"char_start": 97,
"chars": "%("
},
{
"char_end": 115,
"char_start": 114,
"chars": ")"
}
]
},
"commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9",
"file_name": "modules/users.py",
"func_name": "followFriends",
"line_changes": {
"added": [
{
"char_end": 98,
"char_start": 45,
"line": " sqlText=\"insert into friends values(%s,%s);\"\n",
"line_no": 2
},
{
"char_end": 131,
"char_start": 98,
"line": " params=[friendid,userid]\n",
"line_no": 3
},
{
"char_end": 185,
"char_start": 131,
"line": " result=sql.insertDB(self.conn,sqlText,params)\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 116,
"char_start": 45,
"line": " sqlText=\"insert into friends values(%d,%d);\"%(friendid,userid)\n",
"line_no": 2
},
{
"char_end": 163,
"char_start": 116,
"line": " result=sql.insertDB(self.conn,sqlText)\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 356 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def followFriends(self,userid,friendid):",
" sqlText=\"insert into friends values(%s,%s);\"\n params=[friendid,userid]\n result=sql.insertDB(self.conn,sqlText,params)",
" return result;"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 91,
"char_start": 90,
"chars": "s"
},
{
"char_end": 94,
"char_start": 93,
"chars": "s"
},
{
"char_end": 114,
"char_start": 97,
"chars": "\n params=["
},
{
"char_end": 130,
"char_start": 129,
"chars": "]"
},
{
"char_end": 183,
"char_start": 176,
"chars": ",params"
}
],
"deleted": [
{
"char_end": 91,
"char_start": 90,
"chars": "d"
},
{
"char_end": 94,
"char_start": 93,
"chars": "d"
},
{
"char_end": 99,
"char_start": 97,
"chars": "%("
},
{
"char_end": 115,
"char_start": 114,
"chars": ")"
}
]
},
"commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9",
"file_name": "modules/users.py",
"func_name": "followFriends",
"line_changes": {
"added": [
{
"char_end": 98,
"char_start": 45,
"line": " sqlText=\"insert into friends values(%s,%s);\"\n",
"line_no": 2
},
{
"char_end": 131,
"char_start": 98,
"line": " params=[friendid,userid]\n",
"line_no": 3
},
{
"char_end": 185,
"char_start": 131,
"line": " result=sql.insertDB(self.conn,sqlText,params)\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 116,
"char_start": 45,
"line": " sqlText=\"insert into friends values(%d,%d);\"%(friendid,userid)\n",
"line_no": 2
},
{
"char_end": 163,
"char_start": 116,
"line": " result=sql.insertDB(self.conn,sqlText)\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 356 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def getGameID(ID):",
"\tdb.execute(\"SELECT * FROM games WHERE ID = %i\" % ID)",
"\tID = db.fetchone()\n\treturn ID"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 64,
"char_start": 63,
"chars": "?"
},
{
"char_end": 66,
"char_start": 65,
"chars": ","
}
],
"deleted": [
{
"char_end": 65,
"char_start": 63,
"chars": "%i"
},
{
"char_end": 68,
"char_start": 66,
"chars": " %"
}
]
},
"commit_link": "github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2",
"file_name": "plugins/database.py",
"func_name": "getGameID",
"line_changes": {
"added": [
{
"char_end": 71,
"char_start": 19,
"line": "\tdb.execute(\"SELECT * FROM games WHERE ID = ?\", ID)\n",
"line_no": 2
}
],
"deleted": [
{
"char_end": 73,
"char_start": 19,
"line": "\tdb.execute(\"SELECT * FROM games WHERE ID = %i\" % ID)\n",
"line_no": 2
}
]
},
"vul_type": "cwe-089"
} | 357 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def getGameID(ID):",
"\tdb.execute(\"SELECT * FROM games WHERE ID = ?\", ID)",
"\tID = db.fetchone()\n\treturn ID"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 64,
"char_start": 63,
"chars": "?"
},
{
"char_end": 66,
"char_start": 65,
"chars": ","
}
],
"deleted": [
{
"char_end": 65,
"char_start": 63,
"chars": "%i"
},
{
"char_end": 68,
"char_start": 66,
"chars": " %"
}
]
},
"commit_link": "github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2",
"file_name": "plugins/database.py",
"func_name": "getGameID",
"line_changes": {
"added": [
{
"char_end": 71,
"char_start": 19,
"line": "\tdb.execute(\"SELECT * FROM games WHERE ID = ?\", ID)\n",
"line_no": 2
}
],
"deleted": [
{
"char_end": 73,
"char_start": 19,
"line": "\tdb.execute(\"SELECT * FROM games WHERE ID = %i\" % ID)\n",
"line_no": 2
}
]
},
"vul_type": "cwe-089"
} | 357 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/top_proxies')\ndef top_proxies():\n con = psycopg2.connect(**config.POSTGRES)\n cur = con.cursor()",
" query = \"SELECT sum(amount) FROM holders\"\n cur.execute(query)\n total = cur.fetchone()\n total_votes = total[0]",
" query = \"SELECT voting_as FROM holders WHERE voting_as<>'1.2.5' group by voting_as\"\n cur.execute(query)\n results = cur.fetchall()\n #con.close()",
" proxies = []",
" for p in range(0, len(results)):",
" proxy_line = [0] * 5",
" proxy_id = results[p][0]\n proxy_line[0] = proxy_id\n",
" query = \"SELECT account_name, amount FROM holders WHERE account_id='\"+proxy_id+\"' LIMIT 1\"\n cur.execute(query)",
" proxy = cur.fetchone()",
" try:\n proxy_name = proxy[0]\n proxy_amount = proxy[1]\n except:\n proxy_name = \"unknown\"\n proxy_amount = 0",
"\n proxy_line[1] = proxy_name\n",
" query = \"SELECT amount, account_id FROM holders WHERE voting_as='\"+proxy_id+\"'\"\n cur.execute(query)",
" results2 = cur.fetchall()",
" proxy_line[2] = int(proxy_amount)",
" for p2 in range(0, len(results2)):\n amount = results2[p2][0]\n account_id = results2[p2][1]\n proxy_line[2] = proxy_line[2] + int(amount) # total proxy votes\n proxy_line[3] = proxy_line[3] + 1 # followers",
" if proxy_line[3] > 2:\n percentage = float(float(proxy_line[2]) * 100.0/ float(total_votes))\n proxy_line[4] = percentage\n proxies.append(proxy_line)",
" con.close()",
" proxies = sorted(proxies, key=lambda k: int(k[2]))\n r_proxies = proxies[::-1]",
" return jsonify(filter(None, r_proxies))"
] | [
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 628,
"char_start": 626,
"chars": "%s"
},
{
"char_end": 676,
"char_start": 663,
"chars": ", (proxy_id,)"
},
{
"char_end": 985,
"char_start": 983,
"chars": "%s"
},
{
"char_end": 1025,
"char_start": 1012,
"chars": ", (proxy_id,)"
}
],
"deleted": [
{
"char_end": 640,
"char_start": 626,
"chars": "'\"+proxy_id+\"'"
},
{
"char_end": 996,
"char_start": 982,
"chars": "'\"+proxy_id+\"'"
}
]
},
"commit_link": "github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60",
"file_name": "api.py",
"func_name": "top_proxies",
"line_changes": {
"added": [
{
"char_end": 638,
"char_start": 551,
"line": " query = \"SELECT account_name, amount FROM holders WHERE account_id=%s LIMIT 1\"\n",
"line_no": 25
},
{
"char_end": 678,
"char_start": 638,
"line": " cur.execute(query, (proxy_id,))\n",
"line_no": 26
},
{
"char_end": 987,
"char_start": 911,
"line": " query = \"SELECT amount, account_id FROM holders WHERE voting_as=%s\"\n",
"line_no": 39
},
{
"char_end": 1027,
"char_start": 987,
"line": " cur.execute(query, (proxy_id,))\n",
"line_no": 40
}
],
"deleted": [
{
"char_end": 650,
"char_start": 551,
"line": " query = \"SELECT account_name, amount FROM holders WHERE account_id='\"+proxy_id+\"' LIMIT 1\"\n",
"line_no": 25
},
{
"char_end": 677,
"char_start": 650,
"line": " cur.execute(query)\n",
"line_no": 26
},
{
"char_end": 998,
"char_start": 910,
"line": " query = \"SELECT amount, account_id FROM holders WHERE voting_as='\"+proxy_id+\"'\"\n",
"line_no": 39
},
{
"char_end": 1025,
"char_start": 998,
"line": " cur.execute(query)\n",
"line_no": 40
}
]
},
"vul_type": "cwe-089"
} | 358 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/top_proxies')\ndef top_proxies():\n con = psycopg2.connect(**config.POSTGRES)\n cur = con.cursor()",
" query = \"SELECT sum(amount) FROM holders\"\n cur.execute(query)\n total = cur.fetchone()\n total_votes = total[0]",
" query = \"SELECT voting_as FROM holders WHERE voting_as<>'1.2.5' group by voting_as\"\n cur.execute(query)\n results = cur.fetchall()\n #con.close()",
" proxies = []",
" for p in range(0, len(results)):",
" proxy_line = [0] * 5",
" proxy_id = results[p][0]\n proxy_line[0] = proxy_id\n",
" query = \"SELECT account_name, amount FROM holders WHERE account_id=%s LIMIT 1\"\n cur.execute(query, (proxy_id,))",
" proxy = cur.fetchone()",
" try:\n proxy_name = proxy[0]\n proxy_amount = proxy[1]\n except:\n proxy_name = \"unknown\"\n proxy_amount = 0",
"\n proxy_line[1] = proxy_name\n",
" query = \"SELECT amount, account_id FROM holders WHERE voting_as=%s\"\n cur.execute(query, (proxy_id,))",
" results2 = cur.fetchall()",
" proxy_line[2] = int(proxy_amount)",
" for p2 in range(0, len(results2)):\n amount = results2[p2][0]\n account_id = results2[p2][1]\n proxy_line[2] = proxy_line[2] + int(amount) # total proxy votes\n proxy_line[3] = proxy_line[3] + 1 # followers",
" if proxy_line[3] > 2:\n percentage = float(float(proxy_line[2]) * 100.0/ float(total_votes))\n proxy_line[4] = percentage\n proxies.append(proxy_line)",
" con.close()",
" proxies = sorted(proxies, key=lambda k: int(k[2]))\n r_proxies = proxies[::-1]",
" return jsonify(filter(None, r_proxies))"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 628,
"char_start": 626,
"chars": "%s"
},
{
"char_end": 676,
"char_start": 663,
"chars": ", (proxy_id,)"
},
{
"char_end": 985,
"char_start": 983,
"chars": "%s"
},
{
"char_end": 1025,
"char_start": 1012,
"chars": ", (proxy_id,)"
}
],
"deleted": [
{
"char_end": 640,
"char_start": 626,
"chars": "'\"+proxy_id+\"'"
},
{
"char_end": 996,
"char_start": 982,
"chars": "'\"+proxy_id+\"'"
}
]
},
"commit_link": "github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60",
"file_name": "api.py",
"func_name": "top_proxies",
"line_changes": {
"added": [
{
"char_end": 638,
"char_start": 551,
"line": " query = \"SELECT account_name, amount FROM holders WHERE account_id=%s LIMIT 1\"\n",
"line_no": 25
},
{
"char_end": 678,
"char_start": 638,
"line": " cur.execute(query, (proxy_id,))\n",
"line_no": 26
},
{
"char_end": 987,
"char_start": 911,
"line": " query = \"SELECT amount, account_id FROM holders WHERE voting_as=%s\"\n",
"line_no": 39
},
{
"char_end": 1027,
"char_start": 987,
"line": " cur.execute(query, (proxy_id,))\n",
"line_no": 40
}
],
"deleted": [
{
"char_end": 650,
"char_start": 551,
"line": " query = \"SELECT account_name, amount FROM holders WHERE account_id='\"+proxy_id+\"' LIMIT 1\"\n",
"line_no": 25
},
{
"char_end": 677,
"char_start": 650,
"line": " cur.execute(query)\n",
"line_no": 26
},
{
"char_end": 998,
"char_start": 910,
"line": " query = \"SELECT amount, account_id FROM holders WHERE voting_as='\"+proxy_id+\"'\"\n",
"line_no": 39
},
{
"char_end": 1025,
"char_start": 998,
"line": " cur.execute(query)\n",
"line_no": 40
}
]
},
"vul_type": "cwe-089"
} | 358 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def userLogin(self):\n",
" sqlName=\"select count(*) from users where name='%s' and \\\n password='%s';\"%(self.name,self.password)\n checkName=sql.queryDB(self.conn,sqlName)\n",
" result=checkName[0][0]\n if result == 0:\n self.clean()\n return False\n else:\n return True"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 120,
"char_start": 101,
"chars": "\n params = ["
},
{
"char_end": 144,
"char_start": 143,
"chars": "]"
},
{
"char_end": 199,
"char_start": 192,
"chars": ",params"
}
],
"deleted": [
{
"char_end": 82,
"char_start": 81,
"chars": "'"
},
{
"char_end": 85,
"char_start": 84,
"chars": "'"
},
{
"char_end": 91,
"char_start": 90,
"chars": "\\"
},
{
"char_end": 100,
"char_start": 92,
"chars": " "
},
{
"char_end": 116,
"char_start": 111,
"chars": "sword"
},
{
"char_end": 125,
"char_start": 117,
"chars": "'%s';\"%("
},
{
"char_end": 149,
"char_start": 148,
"chars": ")"
},
{
"char_end": 199,
"char_start": 198,
"chars": "\n"
}
]
},
"commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9",
"file_name": "modules/users.py",
"func_name": "userLogin",
"line_changes": {
"added": [
{
"char_end": 102,
"char_start": 26,
"line": " sqlName=\"select count(*) from users where name=%s and password=%s;\"\n",
"line_no": 3
},
{
"char_end": 145,
"char_start": 102,
"line": " params = [self.name,self.password]\n",
"line_no": 4
},
{
"char_end": 201,
"char_start": 145,
"line": " checkName=sql.queryDB(self.conn,sqlName,params)\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 92,
"char_start": 26,
"line": " sqlName=\"select count(*) from users where name='%s' and \\\n",
"line_no": 3
},
{
"char_end": 150,
"char_start": 92,
"line": " password='%s';\"%(self.name,self.password)\n",
"line_no": 4
},
{
"char_end": 199,
"char_start": 150,
"line": " checkName=sql.queryDB(self.conn,sqlName)\n",
"line_no": 5
},
{
"char_end": 200,
"char_start": 199,
"line": "\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 359 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def userLogin(self):\n",
" sqlName=\"select count(*) from users where name=%s and password=%s;\"\n params = [self.name,self.password]\n checkName=sql.queryDB(self.conn,sqlName,params)",
" result=checkName[0][0]\n if result == 0:\n self.clean()\n return False\n else:\n return True"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 120,
"char_start": 101,
"chars": "\n params = ["
},
{
"char_end": 144,
"char_start": 143,
"chars": "]"
},
{
"char_end": 199,
"char_start": 192,
"chars": ",params"
}
],
"deleted": [
{
"char_end": 82,
"char_start": 81,
"chars": "'"
},
{
"char_end": 85,
"char_start": 84,
"chars": "'"
},
{
"char_end": 91,
"char_start": 90,
"chars": "\\"
},
{
"char_end": 100,
"char_start": 92,
"chars": " "
},
{
"char_end": 116,
"char_start": 111,
"chars": "sword"
},
{
"char_end": 125,
"char_start": 117,
"chars": "'%s';\"%("
},
{
"char_end": 149,
"char_start": 148,
"chars": ")"
},
{
"char_end": 199,
"char_start": 198,
"chars": "\n"
}
]
},
"commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9",
"file_name": "modules/users.py",
"func_name": "userLogin",
"line_changes": {
"added": [
{
"char_end": 102,
"char_start": 26,
"line": " sqlName=\"select count(*) from users where name=%s and password=%s;\"\n",
"line_no": 3
},
{
"char_end": 145,
"char_start": 102,
"line": " params = [self.name,self.password]\n",
"line_no": 4
},
{
"char_end": 201,
"char_start": 145,
"line": " checkName=sql.queryDB(self.conn,sqlName,params)\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 92,
"char_start": 26,
"line": " sqlName=\"select count(*) from users where name='%s' and \\\n",
"line_no": 3
},
{
"char_end": 150,
"char_start": 92,
"line": " password='%s';\"%(self.name,self.password)\n",
"line_no": 4
},
{
"char_end": 199,
"char_start": 150,
"line": " checkName=sql.queryDB(self.conn,sqlName)\n",
"line_no": 5
},
{
"char_end": 200,
"char_start": 199,
"line": "\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 359 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route(\"/search\", methods = [\"POST\"])\ndef search_pages():\n search = request.form.get(\"search\")",
" page = db.query(\"select title from page where title = '%s'\" % search).namedresult()",
" if len(page) == 0:\n return redirect(\"/%s\" % search)\n else:\n return place_holder(search)"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 162,
"char_start": 160,
"chars": "$1"
},
{
"char_end": 164,
"char_start": 163,
"chars": ","
}
],
"deleted": [
{
"char_end": 164,
"char_start": 160,
"chars": "'%s'"
},
{
"char_end": 167,
"char_start": 165,
"chars": " %"
}
]
},
"commit_link": "github.com/jcortes0309/wiki_flask/commit/a6bf5316abe2eb528adf36c8241a013fd02c5ffa",
"file_name": "server.py",
"func_name": "search_pages",
"line_changes": {
"added": [
{
"char_end": 187,
"char_start": 102,
"line": " page = db.query(\"select title from page where title = $1\", search).namedresult()\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 190,
"char_start": 102,
"line": " page = db.query(\"select title from page where title = '%s'\" % search).namedresult()\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 360 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route(\"/search\", methods = [\"POST\"])\ndef search_pages():\n search = request.form.get(\"search\")",
" page = db.query(\"select title from page where title = $1\", search).namedresult()",
" if len(page) == 0:\n return redirect(\"/%s\" % search)\n else:\n return place_holder(search)"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 162,
"char_start": 160,
"chars": "$1"
},
{
"char_end": 164,
"char_start": 163,
"chars": ","
}
],
"deleted": [
{
"char_end": 164,
"char_start": 160,
"chars": "'%s'"
},
{
"char_end": 167,
"char_start": 165,
"chars": " %"
}
]
},
"commit_link": "github.com/jcortes0309/wiki_flask/commit/a6bf5316abe2eb528adf36c8241a013fd02c5ffa",
"file_name": "server.py",
"func_name": "search_pages",
"line_changes": {
"added": [
{
"char_end": 187,
"char_start": 102,
"line": " page = db.query(\"select title from page where title = $1\", search).namedresult()\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 190,
"char_start": 102,
"line": " page = db.query(\"select title from page where title = '%s'\" % search).namedresult()\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 360 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_articles_by_subject(subject):\n with conn.cursor(cursor_factory=DictCursor) as cur:",
" query = \"SELECT * FROM articles WHERE subject='\" + subject + \"' ORDER BY last_submitted DESC\"\n cur.execute(query)",
" articles = cur.fetchall()\n return articles"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 149,
"char_start": 148,
"chars": "%"
},
{
"char_end": 218,
"char_start": 206,
"chars": ", (subject,)"
}
],
"deleted": [
{
"char_end": 153,
"char_start": 148,
"chars": "'\" + "
},
{
"char_end": 165,
"char_start": 154,
"chars": "ubject + \"'"
}
]
},
"commit_link": "github.com/sepehr125/arxiv-doc2vec-recommender/commit/f23a4c32e6192b145017f64734b0a9a384c9123a",
"file_name": "app.py",
"func_name": "get_articles_by_subject",
"line_changes": {
"added": [
{
"char_end": 181,
"char_start": 94,
"line": " query = \"SELECT * FROM articles WHERE subject=%s ORDER BY last_submitted DESC\"\n",
"line_no": 3
},
{
"char_end": 220,
"char_start": 181,
"line": " cur.execute(query, (subject,))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 196,
"char_start": 94,
"line": " query = \"SELECT * FROM articles WHERE subject='\" + subject + \"' ORDER BY last_submitted DESC\"\n",
"line_no": 3
},
{
"char_end": 223,
"char_start": 196,
"line": " cur.execute(query)\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 361 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_articles_by_subject(subject):\n with conn.cursor(cursor_factory=DictCursor) as cur:",
" query = \"SELECT * FROM articles WHERE subject=%s ORDER BY last_submitted DESC\"\n cur.execute(query, (subject,))",
" articles = cur.fetchall()\n return articles"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 149,
"char_start": 148,
"chars": "%"
},
{
"char_end": 218,
"char_start": 206,
"chars": ", (subject,)"
}
],
"deleted": [
{
"char_end": 153,
"char_start": 148,
"chars": "'\" + "
},
{
"char_end": 165,
"char_start": 154,
"chars": "ubject + \"'"
}
]
},
"commit_link": "github.com/sepehr125/arxiv-doc2vec-recommender/commit/f23a4c32e6192b145017f64734b0a9a384c9123a",
"file_name": "app.py",
"func_name": "get_articles_by_subject",
"line_changes": {
"added": [
{
"char_end": 181,
"char_start": 94,
"line": " query = \"SELECT * FROM articles WHERE subject=%s ORDER BY last_submitted DESC\"\n",
"line_no": 3
},
{
"char_end": 220,
"char_start": 181,
"line": " cur.execute(query, (subject,))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 196,
"char_start": 94,
"line": " query = \"SELECT * FROM articles WHERE subject='\" + subject + \"' ORDER BY last_submitted DESC\"\n",
"line_no": 3
},
{
"char_end": 223,
"char_start": 196,
"line": " cur.execute(query)\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 361 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def getQueue(self, numberOfLinks=10):",
" self.cursor.execute(\"SELECT url FROM queue WHERE visited = '0' LIMIT {};\".format(numberOfLinks))",
" result = self.cursor.fetchall()\n self.remove(result)\n return result"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 120,
"char_start": 119,
"chars": "?"
},
{
"char_end": 124,
"char_start": 122,
"chars": ", "
}
],
"deleted": [
{
"char_end": 121,
"char_start": 119,
"chars": "{}"
},
{
"char_end": 131,
"char_start": 123,
"chars": ".format("
},
{
"char_end": 145,
"char_start": 144,
"chars": ")"
}
]
},
"commit_link": "github.com/jappe999/WebScraper/commit/46a4e0843aa44d903293637afad53dfcbc37b480",
"file_name": "beta/database.py",
"func_name": "getQueue",
"line_changes": {
"added": [
{
"char_end": 139,
"char_start": 42,
"line": " self.cursor.execute(\"SELECT url FROM queue WHERE visited = '0' LIMIT ?;\", numberOfLinks)\n",
"line_no": 2
}
],
"deleted": [
{
"char_end": 147,
"char_start": 42,
"line": " self.cursor.execute(\"SELECT url FROM queue WHERE visited = '0' LIMIT {};\".format(numberOfLinks))\n",
"line_no": 2
}
]
},
"vul_type": "cwe-089"
} | 362 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def getQueue(self, numberOfLinks=10):",
" self.cursor.execute(\"SELECT url FROM queue WHERE visited = '0' LIMIT ?;\", numberOfLinks)",
" result = self.cursor.fetchall()\n self.remove(result)\n return result"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 120,
"char_start": 119,
"chars": "?"
},
{
"char_end": 124,
"char_start": 122,
"chars": ", "
}
],
"deleted": [
{
"char_end": 121,
"char_start": 119,
"chars": "{}"
},
{
"char_end": 131,
"char_start": 123,
"chars": ".format("
},
{
"char_end": 145,
"char_start": 144,
"chars": ")"
}
]
},
"commit_link": "github.com/jappe999/WebScraper/commit/46a4e0843aa44d903293637afad53dfcbc37b480",
"file_name": "beta/database.py",
"func_name": "getQueue",
"line_changes": {
"added": [
{
"char_end": 139,
"char_start": 42,
"line": " self.cursor.execute(\"SELECT url FROM queue WHERE visited = '0' LIMIT ?;\", numberOfLinks)\n",
"line_no": 2
}
],
"deleted": [
{
"char_end": 147,
"char_start": 42,
"line": " self.cursor.execute(\"SELECT url FROM queue WHERE visited = '0' LIMIT {};\".format(numberOfLinks))\n",
"line_no": 2
}
]
},
"vul_type": "cwe-089"
} | 362 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@hook.command(autohelp=False)\ndef showPoll(pollID, db=None):\n \"\"\"Shows the answers for a given poll.\"\"\"\n if not db_ready: db_init(db)\n if pollID == None:\n poll = db.execute(\"SELECT pollID, question FROM polls WHERE active = 1\")\n if len(poll) == 0:\n reply(\"There's no poll open.\")\n return\n else:",
" poll = db.execute(\"SELECT pollID, question FROM polls WHERE pollID = '{}'\".format(pollID))",
" if len(poll) == 0:\n reply(\"No such poll found.\")\n return\n pollID = poll[0][0]\n question = poll[0][1]\n reply(question)",
" for (index, answer, votes) in db.execute(\"SELECT 'index', answer, count(voteID) FROM answers LEFT JOIN votes ON votes.answerID = answers.answerID WHERE pollID = {} GROUP BY answers.answerID, 'index', answer ORDER BY 'index' ASC\".format(pollID, )):",
" reply(\"%s. %s (%s)\" % (index, answer, votes))"
] | [
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 421,
"char_start": 420,
"chars": "?"
},
{
"char_end": 424,
"char_start": 422,
"chars": ", "
},
{
"char_end": 432,
"char_start": 431,
"chars": ","
},
{
"char_end": 758,
"char_start": 757,
"chars": "?"
},
{
"char_end": 825,
"char_start": 823,
"chars": ", "
}
],
"deleted": [
{
"char_end": 424,
"char_start": 420,
"chars": "'{}'"
},
{
"char_end": 432,
"char_start": 425,
"chars": ".format"
},
{
"char_end": 766,
"char_start": 764,
"chars": "{}"
},
{
"char_end": 838,
"char_start": 831,
"chars": ".format"
}
]
},
"commit_link": "github.com/FrozenPigs/Taigabot/commit/ea9b83a66ae1f0f38a1895f3e8dfa2833d77e3a6",
"file_name": "plugins/poll.py",
"func_name": "showPoll",
"line_changes": {
"added": [
{
"char_end": 435,
"char_start": 343,
"line": " poll = db.execute(\"SELECT pollID, question FROM polls WHERE pollID = ?\", (pollID,))\n",
"line_no": 11
},
{
"char_end": 838,
"char_start": 592,
"line": " for (index, answer, votes) in db.execute(\"SELECT 'index', answer, count(voteID) FROM answers LEFT JOIN votes ON votes.answerID = answers.answerID WHERE pollID = ? GROUP BY answers.answerID, 'index', answer ORDER BY 'index' ASC\", (pollID, )):\n",
"line_no": 18
}
],
"deleted": [
{
"char_end": 442,
"char_start": 343,
"line": " poll = db.execute(\"SELECT pollID, question FROM polls WHERE pollID = '{}'\".format(pollID))\n",
"line_no": 11
},
{
"char_end": 851,
"char_start": 599,
"line": " for (index, answer, votes) in db.execute(\"SELECT 'index', answer, count(voteID) FROM answers LEFT JOIN votes ON votes.answerID = answers.answerID WHERE pollID = {} GROUP BY answers.answerID, 'index', answer ORDER BY 'index' ASC\".format(pollID, )):\n",
"line_no": 18
}
]
},
"vul_type": "cwe-089"
} | 363 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@hook.command(autohelp=False)\ndef showPoll(pollID, db=None):\n \"\"\"Shows the answers for a given poll.\"\"\"\n if not db_ready: db_init(db)\n if pollID == None:\n poll = db.execute(\"SELECT pollID, question FROM polls WHERE active = 1\")\n if len(poll) == 0:\n reply(\"There's no poll open.\")\n return\n else:",
" poll = db.execute(\"SELECT pollID, question FROM polls WHERE pollID = ?\", (pollID,))",
" if len(poll) == 0:\n reply(\"No such poll found.\")\n return\n pollID = poll[0][0]\n question = poll[0][1]\n reply(question)",
" for (index, answer, votes) in db.execute(\"SELECT 'index', answer, count(voteID) FROM answers LEFT JOIN votes ON votes.answerID = answers.answerID WHERE pollID = ? GROUP BY answers.answerID, 'index', answer ORDER BY 'index' ASC\", (pollID, )):",
" reply(\"%s. %s (%s)\" % (index, answer, votes))"
] | [
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 421,
"char_start": 420,
"chars": "?"
},
{
"char_end": 424,
"char_start": 422,
"chars": ", "
},
{
"char_end": 432,
"char_start": 431,
"chars": ","
},
{
"char_end": 758,
"char_start": 757,
"chars": "?"
},
{
"char_end": 825,
"char_start": 823,
"chars": ", "
}
],
"deleted": [
{
"char_end": 424,
"char_start": 420,
"chars": "'{}'"
},
{
"char_end": 432,
"char_start": 425,
"chars": ".format"
},
{
"char_end": 766,
"char_start": 764,
"chars": "{}"
},
{
"char_end": 838,
"char_start": 831,
"chars": ".format"
}
]
},
"commit_link": "github.com/FrozenPigs/Taigabot/commit/ea9b83a66ae1f0f38a1895f3e8dfa2833d77e3a6",
"file_name": "plugins/poll.py",
"func_name": "showPoll",
"line_changes": {
"added": [
{
"char_end": 435,
"char_start": 343,
"line": " poll = db.execute(\"SELECT pollID, question FROM polls WHERE pollID = ?\", (pollID,))\n",
"line_no": 11
},
{
"char_end": 838,
"char_start": 592,
"line": " for (index, answer, votes) in db.execute(\"SELECT 'index', answer, count(voteID) FROM answers LEFT JOIN votes ON votes.answerID = answers.answerID WHERE pollID = ? GROUP BY answers.answerID, 'index', answer ORDER BY 'index' ASC\", (pollID, )):\n",
"line_no": 18
}
],
"deleted": [
{
"char_end": 442,
"char_start": 343,
"line": " poll = db.execute(\"SELECT pollID, question FROM polls WHERE pollID = '{}'\".format(pollID))\n",
"line_no": 11
},
{
"char_end": 851,
"char_start": 599,
"line": " for (index, answer, votes) in db.execute(\"SELECT 'index', answer, count(voteID) FROM answers LEFT JOIN votes ON votes.answerID = answers.answerID WHERE pollID = {} GROUP BY answers.answerID, 'index', answer ORDER BY 'index' ASC\".format(pollID, )):\n",
"line_no": 18
}
]
},
"vul_type": "cwe-089"
} | 363 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def process_ranks(self, scene, urls, recent_date):\n PLAYER1 = 0\n PLAYER2 = 1\n WINNER = 2\n DATE = 3\n SCENE = 4",
" # make sure if we already have calculated ranks for these players at this time, we do not do it again",
" sql = \"SELECT * FROM ranks WHERE scene = '{}' AND date='{}';\".format(str(scene), recent_date)\n res = self.db.exec(sql)",
" if len(res) > 0:\n LOG.info('We have already calculated ranks for {} on date {}. SKipping'.format(scene, recent_date))\n return",
" matches = bracket_utils.get_matches_from_urls(self.db, urls)\n LOG.info('About to start processing ranks for scene {} on {}'.format(scene, recent_date))",
" # Iterate through each match, and build up our dict\n win_loss_dict = {}\n for match in matches:\n p1 = match[PLAYER1]\n p2 = match[PLAYER2]\n winner = match[WINNER]\n date = match[DATE]",
" #Add p1 to the dict\n if p1 not in win_loss_dict:\n win_loss_dict[p1] = {}",
" if p2 not in win_loss_dict[p1]:\n win_loss_dict[p1][p2] = []",
" # Add an entry to represent this match to p1\n win_loss_dict[p1][p2].append((date, winner == p1))",
" # add p2 to the dict\n if p2 not in win_loss_dict:\n win_loss_dict[p2] = {}",
" if p1 not in win_loss_dict[p2]:\n win_loss_dict[p2][p1] = []",
" win_loss_dict[p2][p1].append((date, winner == p2))",
" ranks = get_ranks(win_loss_dict)",
" tag_rank_map = {}\n for i, x in enumerate(ranks):\n points, player = x\n rank = len(ranks) - i\n",
" sql = \"INSERT INTO ranks (scene, player, rank, points, date) VALUES ('{}', '{}', '{}', '{}', '{}');\"\\\n .format(str(scene), str(player), int(rank), str(points), str(recent_date))\n self.db.exec(sql)",
"\n # Only count this player if this is the scene he/she belongs to",
" sql = \"SELECT scene FROM players WHERE tag='{}';\".format(player)\n res = self.db.exec(sql)",
"\n if len(res) == 0 or res[0][0] == scene:\n # Also create a list to update the player web\n map = {'rank':rank, 'total_ranked':len(ranks)}\n tag_rank_map[player] = map",
" player_web.update_ranks(tag_rank_map)"
] | [
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 316,
"char_start": 311,
"chars": "scene"
},
{
"char_end": 334,
"char_start": 330,
"chars": "date"
},
{
"char_end": 348,
"char_start": 338,
"chars": "\n a"
},
{
"char_end": 356,
"char_start": 349,
"chars": "gs = {'"
},
{
"char_end": 364,
"char_start": 357,
"chars": "cene': "
},
{
"char_end": 379,
"char_start": 371,
"chars": "'date': "
},
{
"char_end": 391,
"char_start": 390,
"chars": "}"
},
{
"char_end": 428,
"char_start": 422,
"chars": ", args"
},
{
"char_end": 1849,
"char_start": 1844,
"chars": "scene"
},
{
"char_end": 1861,
"char_start": 1855,
"chars": "player"
},
{
"char_end": 1871,
"char_start": 1867,
"chars": "rank"
},
{
"char_end": 1883,
"char_start": 1877,
"chars": "points"
},
{
"char_end": 1900,
"char_start": 1889,
"chars": "recent_date"
},
{
"char_end": 1922,
"char_start": 1918,
"chars": "args"
},
{
"char_end": 1924,
"char_start": 1923,
"chars": "="
},
{
"char_end": 1927,
"char_start": 1925,
"chars": "{'"
},
{
"char_end": 1935,
"char_start": 1928,
"chars": "cene': "
},
{
"char_end": 1948,
"char_start": 1942,
"chars": "'playe"
},
{
"char_end": 1952,
"char_start": 1949,
"chars": "': "
},
{
"char_end": 1963,
"char_start": 1960,
"chars": "'ra"
},
{
"char_end": 1968,
"char_start": 1964,
"chars": "k': "
},
{
"char_end": 1980,
"char_start": 1974,
"chars": "'point"
},
{
"char_end": 1984,
"char_start": 1981,
"chars": "': "
},
{
"char_end": 1993,
"char_start": 1992,
"chars": "'"
},
{
"char_end": 2007,
"char_start": 1994,
"chars": "ecent_date': "
},
{
"char_end": 2019,
"char_start": 2018,
"chars": "}"
},
{
"char_end": 2054,
"char_start": 2048,
"chars": ", args"
},
{
"char_end": 2196,
"char_start": 2190,
"chars": "player"
},
{
"char_end": 2214,
"char_start": 2200,
"chars": "\n a"
},
{
"char_end": 2224,
"char_start": 2215,
"chars": "gs = {'pl"
},
{
"char_end": 2231,
"char_start": 2225,
"chars": "yer': "
},
{
"char_end": 2238,
"char_start": 2237,
"chars": "}"
},
{
"char_end": 2279,
"char_start": 2273,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 334,
"char_start": 329,
"chars": ".form"
},
{
"char_end": 339,
"char_start": 335,
"chars": "t(st"
},
{
"char_end": 341,
"char_start": 340,
"chars": "("
},
{
"char_end": 347,
"char_start": 346,
"chars": ")"
},
{
"char_end": 361,
"char_start": 360,
"chars": ")"
},
{
"char_end": 1838,
"char_start": 1837,
"chars": "\\"
},
{
"char_end": 1857,
"char_start": 1853,
"chars": " "
},
{
"char_end": 1871,
"char_start": 1858,
"chars": " .format(str("
},
{
"char_end": 1877,
"char_start": 1876,
"chars": ")"
},
{
"char_end": 1881,
"char_start": 1879,
"chars": "st"
},
{
"char_end": 1883,
"char_start": 1882,
"chars": "("
},
{
"char_end": 1890,
"char_start": 1889,
"chars": ")"
},
{
"char_end": 1893,
"char_start": 1892,
"chars": "i"
},
{
"char_end": 1896,
"char_start": 1894,
"chars": "t("
},
{
"char_end": 1901,
"char_start": 1900,
"chars": ")"
},
{
"char_end": 1904,
"char_start": 1903,
"chars": "s"
},
{
"char_end": 1907,
"char_start": 1905,
"chars": "r("
},
{
"char_end": 1914,
"char_start": 1913,
"chars": ")"
},
{
"char_end": 1917,
"char_start": 1916,
"chars": "s"
},
{
"char_end": 1920,
"char_start": 1918,
"chars": "r("
},
{
"char_end": 1933,
"char_start": 1931,
"chars": "))"
},
{
"char_end": 2105,
"char_start": 2102,
"chars": ".fo"
},
{
"char_end": 2107,
"char_start": 2106,
"chars": "m"
},
{
"char_end": 2110,
"char_start": 2108,
"chars": "t("
},
{
"char_end": 2117,
"char_start": 2116,
"chars": ")"
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "process_data.py",
"func_name": "process_ranks",
"line_changes": {
"added": [
{
"char_end": 339,
"char_start": 260,
"line": " sql = \"SELECT * FROM ranks WHERE scene = '{scene}' AND date='{date}';\"\n",
"line_no": 9
},
{
"char_end": 392,
"char_start": 339,
"line": " args = {'scene': scene, 'date': recent_date}\n",
"line_no": 10
},
{
"char_end": 430,
"char_start": 392,
"line": " res = self.db.exec(sql, args)\n",
"line_no": 11
},
{
"char_end": 1906,
"char_start": 1761,
"line": " sql = \"INSERT INTO ranks (scene, player, rank, points, date) VALUES ('{scene}', '{player}', '{rank}', '{points}', '{recent_date}');\"\n",
"line_no": 53
},
{
"char_end": 2020,
"char_start": 1906,
"line": " args = {'scene': scene, 'player': player, 'rank': rank, 'points': points, 'recent_date': recent_date}\n",
"line_no": 54
},
{
"char_end": 2056,
"char_start": 2020,
"line": " self.db.exec(sql, args)\n",
"line_no": 55
},
{
"char_end": 2201,
"char_start": 2133,
"line": " sql = \"SELECT scene FROM players WHERE tag='{player}';\"\n",
"line_no": 58
},
{
"char_end": 2239,
"char_start": 2201,
"line": " args = {'player': player}\n",
"line_no": 59
},
{
"char_end": 2281,
"char_start": 2239,
"line": " res = self.db.exec(sql, args)\n",
"line_no": 60
}
],
"deleted": [
{
"char_end": 362,
"char_start": 260,
"line": " sql = \"SELECT * FROM ranks WHERE scene = '{}' AND date='{}';\".format(str(scene), recent_date)\n",
"line_no": 9
},
{
"char_end": 394,
"char_start": 362,
"line": " res = self.db.exec(sql)\n",
"line_no": 10
},
{
"char_end": 1839,
"char_start": 1725,
"line": " sql = \"INSERT INTO ranks (scene, player, rank, points, date) VALUES ('{}', '{}', '{}', '{}', '{}');\"\\\n",
"line_no": 52
},
{
"char_end": 1934,
"char_start": 1839,
"line": " .format(str(scene), str(player), int(rank), str(points), str(recent_date))\n",
"line_no": 53
},
{
"char_end": 1964,
"char_start": 1934,
"line": " self.db.exec(sql)\n",
"line_no": 54
},
{
"char_end": 2118,
"char_start": 2041,
"line": " sql = \"SELECT scene FROM players WHERE tag='{}';\".format(player)\n",
"line_no": 57
},
{
"char_end": 2154,
"char_start": 2118,
"line": " res = self.db.exec(sql)\n",
"line_no": 58
}
]
},
"vul_type": "cwe-089"
} | 364 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def process_ranks(self, scene, urls, recent_date):\n PLAYER1 = 0\n PLAYER2 = 1\n WINNER = 2\n DATE = 3\n SCENE = 4",
" # make sure if we already have calculated ranks for these players at this time, we do not do it again",
" sql = \"SELECT * FROM ranks WHERE scene = '{scene}' AND date='{date}';\"\n args = {'scene': scene, 'date': recent_date}\n res = self.db.exec(sql, args)",
" if len(res) > 0:\n LOG.info('We have already calculated ranks for {} on date {}. SKipping'.format(scene, recent_date))\n return",
" matches = bracket_utils.get_matches_from_urls(self.db, urls)\n LOG.info('About to start processing ranks for scene {} on {}'.format(scene, recent_date))",
" # Iterate through each match, and build up our dict\n win_loss_dict = {}\n for match in matches:\n p1 = match[PLAYER1]\n p2 = match[PLAYER2]\n winner = match[WINNER]\n date = match[DATE]",
" #Add p1 to the dict\n if p1 not in win_loss_dict:\n win_loss_dict[p1] = {}",
" if p2 not in win_loss_dict[p1]:\n win_loss_dict[p1][p2] = []",
" # Add an entry to represent this match to p1\n win_loss_dict[p1][p2].append((date, winner == p1))",
" # add p2 to the dict\n if p2 not in win_loss_dict:\n win_loss_dict[p2] = {}",
" if p1 not in win_loss_dict[p2]:\n win_loss_dict[p2][p1] = []",
" win_loss_dict[p2][p1].append((date, winner == p2))",
" ranks = get_ranks(win_loss_dict)",
" tag_rank_map = {}\n for i, x in enumerate(ranks):\n points, player = x\n rank = len(ranks) - i\n",
" sql = \"INSERT INTO ranks (scene, player, rank, points, date) VALUES ('{scene}', '{player}', '{rank}', '{points}', '{recent_date}');\"\n args = {'scene': scene, 'player': player, 'rank': rank, 'points': points, 'recent_date': recent_date}\n self.db.exec(sql, args)",
"\n # Only count this player if this is the scene he/she belongs to",
" sql = \"SELECT scene FROM players WHERE tag='{player}';\"\n args = {'player': player}\n res = self.db.exec(sql, args)",
"\n if len(res) == 0 or res[0][0] == scene:\n # Also create a list to update the player web\n map = {'rank':rank, 'total_ranked':len(ranks)}\n tag_rank_map[player] = map",
" player_web.update_ranks(tag_rank_map)"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 316,
"char_start": 311,
"chars": "scene"
},
{
"char_end": 334,
"char_start": 330,
"chars": "date"
},
{
"char_end": 348,
"char_start": 338,
"chars": "\n a"
},
{
"char_end": 356,
"char_start": 349,
"chars": "gs = {'"
},
{
"char_end": 364,
"char_start": 357,
"chars": "cene': "
},
{
"char_end": 379,
"char_start": 371,
"chars": "'date': "
},
{
"char_end": 391,
"char_start": 390,
"chars": "}"
},
{
"char_end": 428,
"char_start": 422,
"chars": ", args"
},
{
"char_end": 1849,
"char_start": 1844,
"chars": "scene"
},
{
"char_end": 1861,
"char_start": 1855,
"chars": "player"
},
{
"char_end": 1871,
"char_start": 1867,
"chars": "rank"
},
{
"char_end": 1883,
"char_start": 1877,
"chars": "points"
},
{
"char_end": 1900,
"char_start": 1889,
"chars": "recent_date"
},
{
"char_end": 1922,
"char_start": 1918,
"chars": "args"
},
{
"char_end": 1924,
"char_start": 1923,
"chars": "="
},
{
"char_end": 1927,
"char_start": 1925,
"chars": "{'"
},
{
"char_end": 1935,
"char_start": 1928,
"chars": "cene': "
},
{
"char_end": 1948,
"char_start": 1942,
"chars": "'playe"
},
{
"char_end": 1952,
"char_start": 1949,
"chars": "': "
},
{
"char_end": 1963,
"char_start": 1960,
"chars": "'ra"
},
{
"char_end": 1968,
"char_start": 1964,
"chars": "k': "
},
{
"char_end": 1980,
"char_start": 1974,
"chars": "'point"
},
{
"char_end": 1984,
"char_start": 1981,
"chars": "': "
},
{
"char_end": 1993,
"char_start": 1992,
"chars": "'"
},
{
"char_end": 2007,
"char_start": 1994,
"chars": "ecent_date': "
},
{
"char_end": 2019,
"char_start": 2018,
"chars": "}"
},
{
"char_end": 2054,
"char_start": 2048,
"chars": ", args"
},
{
"char_end": 2196,
"char_start": 2190,
"chars": "player"
},
{
"char_end": 2214,
"char_start": 2200,
"chars": "\n a"
},
{
"char_end": 2224,
"char_start": 2215,
"chars": "gs = {'pl"
},
{
"char_end": 2231,
"char_start": 2225,
"chars": "yer': "
},
{
"char_end": 2238,
"char_start": 2237,
"chars": "}"
},
{
"char_end": 2279,
"char_start": 2273,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 334,
"char_start": 329,
"chars": ".form"
},
{
"char_end": 339,
"char_start": 335,
"chars": "t(st"
},
{
"char_end": 341,
"char_start": 340,
"chars": "("
},
{
"char_end": 347,
"char_start": 346,
"chars": ")"
},
{
"char_end": 361,
"char_start": 360,
"chars": ")"
},
{
"char_end": 1838,
"char_start": 1837,
"chars": "\\"
},
{
"char_end": 1857,
"char_start": 1853,
"chars": " "
},
{
"char_end": 1871,
"char_start": 1858,
"chars": " .format(str("
},
{
"char_end": 1877,
"char_start": 1876,
"chars": ")"
},
{
"char_end": 1881,
"char_start": 1879,
"chars": "st"
},
{
"char_end": 1883,
"char_start": 1882,
"chars": "("
},
{
"char_end": 1890,
"char_start": 1889,
"chars": ")"
},
{
"char_end": 1893,
"char_start": 1892,
"chars": "i"
},
{
"char_end": 1896,
"char_start": 1894,
"chars": "t("
},
{
"char_end": 1901,
"char_start": 1900,
"chars": ")"
},
{
"char_end": 1904,
"char_start": 1903,
"chars": "s"
},
{
"char_end": 1907,
"char_start": 1905,
"chars": "r("
},
{
"char_end": 1914,
"char_start": 1913,
"chars": ")"
},
{
"char_end": 1917,
"char_start": 1916,
"chars": "s"
},
{
"char_end": 1920,
"char_start": 1918,
"chars": "r("
},
{
"char_end": 1933,
"char_start": 1931,
"chars": "))"
},
{
"char_end": 2105,
"char_start": 2102,
"chars": ".fo"
},
{
"char_end": 2107,
"char_start": 2106,
"chars": "m"
},
{
"char_end": 2110,
"char_start": 2108,
"chars": "t("
},
{
"char_end": 2117,
"char_start": 2116,
"chars": ")"
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "process_data.py",
"func_name": "process_ranks",
"line_changes": {
"added": [
{
"char_end": 339,
"char_start": 260,
"line": " sql = \"SELECT * FROM ranks WHERE scene = '{scene}' AND date='{date}';\"\n",
"line_no": 9
},
{
"char_end": 392,
"char_start": 339,
"line": " args = {'scene': scene, 'date': recent_date}\n",
"line_no": 10
},
{
"char_end": 430,
"char_start": 392,
"line": " res = self.db.exec(sql, args)\n",
"line_no": 11
},
{
"char_end": 1906,
"char_start": 1761,
"line": " sql = \"INSERT INTO ranks (scene, player, rank, points, date) VALUES ('{scene}', '{player}', '{rank}', '{points}', '{recent_date}');\"\n",
"line_no": 53
},
{
"char_end": 2020,
"char_start": 1906,
"line": " args = {'scene': scene, 'player': player, 'rank': rank, 'points': points, 'recent_date': recent_date}\n",
"line_no": 54
},
{
"char_end": 2056,
"char_start": 2020,
"line": " self.db.exec(sql, args)\n",
"line_no": 55
},
{
"char_end": 2201,
"char_start": 2133,
"line": " sql = \"SELECT scene FROM players WHERE tag='{player}';\"\n",
"line_no": 58
},
{
"char_end": 2239,
"char_start": 2201,
"line": " args = {'player': player}\n",
"line_no": 59
},
{
"char_end": 2281,
"char_start": 2239,
"line": " res = self.db.exec(sql, args)\n",
"line_no": 60
}
],
"deleted": [
{
"char_end": 362,
"char_start": 260,
"line": " sql = \"SELECT * FROM ranks WHERE scene = '{}' AND date='{}';\".format(str(scene), recent_date)\n",
"line_no": 9
},
{
"char_end": 394,
"char_start": 362,
"line": " res = self.db.exec(sql)\n",
"line_no": 10
},
{
"char_end": 1839,
"char_start": 1725,
"line": " sql = \"INSERT INTO ranks (scene, player, rank, points, date) VALUES ('{}', '{}', '{}', '{}', '{}');\"\\\n",
"line_no": 52
},
{
"char_end": 1934,
"char_start": 1839,
"line": " .format(str(scene), str(player), int(rank), str(points), str(recent_date))\n",
"line_no": 53
},
{
"char_end": 1964,
"char_start": 1934,
"line": " self.db.exec(sql)\n",
"line_no": 54
},
{
"char_end": 2118,
"char_start": 2041,
"line": " sql = \"SELECT scene FROM players WHERE tag='{}';\".format(player)\n",
"line_no": 57
},
{
"char_end": 2154,
"char_start": 2118,
"line": " res = self.db.exec(sql)\n",
"line_no": 58
}
]
},
"vul_type": "cwe-089"
} | 364 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def analyze_smashgg(self, urls, name):\n LOG.info('we are about to analyze scene {} with {} brackets'.format(name, len(urls)))\n for url in urls:\n # Before we process this URL, check to see if we already have",
" sql = \"SELECT * FROM analyzed where base_url='{}'\".format(url)\n res = self.db.exec(sql)",
" if len(res) == 0:",
" display_name = bracket_utils.get_display_base(url)",
" # We don't care about doubles tournaments\n if 'doubles' in display_name.lower() or 'dubs' in display_name.lower():\n LOG.info('We are skipping the tournament {} because it is a doubles tournament'.format(display_name))\n continue",
" LOG.info('About to process pro bracket {}'.format(url))\n self.data_processor.process(url, name, display_name)\n else:\n LOG.info(\"Skpping pro bracket because it has already been analyzed: {}\".format(url))"
] | [
1,
0,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 298,
"char_start": 295,
"chars": "url"
},
{
"char_end": 324,
"char_start": 301,
"chars": "\n args = {'u"
},
{
"char_end": 328,
"char_start": 325,
"chars": "l':"
},
{
"char_end": 332,
"char_start": 331,
"chars": "}"
},
{
"char_end": 373,
"char_start": 367,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 303,
"char_start": 298,
"chars": ".form"
},
{
"char_end": 306,
"char_start": 304,
"chars": "t("
},
{
"char_end": 310,
"char_start": 309,
"chars": ")"
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "validURLs.py",
"func_name": "analyze_smashgg",
"line_changes": {
"added": [
{
"char_end": 302,
"char_start": 236,
"line": " sql = \"SELECT * FROM analyzed where base_url='{url}'\"\n",
"line_no": 5
},
{
"char_end": 333,
"char_start": 302,
"line": " args = {'url':url}\n",
"line_no": 6
},
{
"char_end": 375,
"char_start": 333,
"line": " res = self.db.exec(sql, args)\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 311,
"char_start": 236,
"line": " sql = \"SELECT * FROM analyzed where base_url='{}'\".format(url)\n",
"line_no": 5
},
{
"char_end": 347,
"char_start": 311,
"line": " res = self.db.exec(sql)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 365 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def analyze_smashgg(self, urls, name):\n LOG.info('we are about to analyze scene {} with {} brackets'.format(name, len(urls)))\n for url in urls:\n # Before we process this URL, check to see if we already have",
" sql = \"SELECT * FROM analyzed where base_url='{url}'\"\n args = {'url':url}\n res = self.db.exec(sql, args)",
" if len(res) == 0:",
" display_name = bracket_utils.get_display_base(url)",
" # We don't care about doubles tournaments\n if 'doubles' in display_name.lower() or 'dubs' in display_name.lower():\n LOG.info('We are skipping the tournament {} because it is a doubles tournament'.format(display_name))\n continue",
" LOG.info('About to process pro bracket {}'.format(url))\n self.data_processor.process(url, name, display_name)\n else:\n LOG.info(\"Skpping pro bracket because it has already been analyzed: {}\".format(url))"
] | [
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 298,
"char_start": 295,
"chars": "url"
},
{
"char_end": 324,
"char_start": 301,
"chars": "\n args = {'u"
},
{
"char_end": 328,
"char_start": 325,
"chars": "l':"
},
{
"char_end": 332,
"char_start": 331,
"chars": "}"
},
{
"char_end": 373,
"char_start": 367,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 303,
"char_start": 298,
"chars": ".form"
},
{
"char_end": 306,
"char_start": 304,
"chars": "t("
},
{
"char_end": 310,
"char_start": 309,
"chars": ")"
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "validURLs.py",
"func_name": "analyze_smashgg",
"line_changes": {
"added": [
{
"char_end": 302,
"char_start": 236,
"line": " sql = \"SELECT * FROM analyzed where base_url='{url}'\"\n",
"line_no": 5
},
{
"char_end": 333,
"char_start": 302,
"line": " args = {'url':url}\n",
"line_no": 6
},
{
"char_end": 375,
"char_start": 333,
"line": " res = self.db.exec(sql, args)\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 311,
"char_start": 236,
"line": " sql = \"SELECT * FROM analyzed where base_url='{}'\".format(url)\n",
"line_no": 5
},
{
"char_end": 347,
"char_start": 311,
"line": " res = self.db.exec(sql)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 365 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@mod.route('/test', methods=['GET', 'POST'])\ndef test():\n user_id = session['logged_id']",
" sql = 'SELECT * FROM message where user_id = %d ORDER BY c_time DESC' \\\n % (user_id)\n cursor.execute(sql)",
" m = cursor.fetchall()\n print(m)"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 99,
"char_start": 96,
"chars": "cur"
},
{
"char_end": 111,
"char_start": 100,
"chars": "or.execute("
},
{
"char_end": 152,
"char_start": 151,
"chars": "s"
},
{
"char_end": 175,
"char_start": 174,
"chars": ","
},
{
"char_end": 185,
"char_start": 184,
"chars": ","
}
],
"deleted": [
{
"char_end": 102,
"char_start": 97,
"chars": "ql = "
},
{
"char_end": 143,
"char_start": 142,
"chars": "d"
},
{
"char_end": 177,
"char_start": 165,
"chars": " \\\n %"
},
{
"char_end": 210,
"char_start": 187,
"chars": "\n cursor.execute(sql"
}
]
},
"commit_link": "github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9",
"file_name": "flaskr/flaskr/views/message.py",
"func_name": "test",
"line_changes": {
"added": [
{
"char_end": 188,
"char_start": 92,
"line": " cursor.execute('SELECT * FROM message where user_id = %s ORDER BY c_time DESC', (user_id,))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 168,
"char_start": 92,
"line": " sql = 'SELECT * FROM message where user_id = %d ORDER BY c_time DESC' \\\n",
"line_no": 4
},
{
"char_end": 188,
"char_start": 168,
"line": " % (user_id)\n",
"line_no": 5
},
{
"char_end": 212,
"char_start": 188,
"line": " cursor.execute(sql)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 366 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@mod.route('/test', methods=['GET', 'POST'])\ndef test():\n user_id = session['logged_id']",
" cursor.execute('SELECT * FROM message where user_id = %s ORDER BY c_time DESC', (user_id,))",
" m = cursor.fetchall()\n print(m)"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 99,
"char_start": 96,
"chars": "cur"
},
{
"char_end": 111,
"char_start": 100,
"chars": "or.execute("
},
{
"char_end": 152,
"char_start": 151,
"chars": "s"
},
{
"char_end": 175,
"char_start": 174,
"chars": ","
},
{
"char_end": 185,
"char_start": 184,
"chars": ","
}
],
"deleted": [
{
"char_end": 102,
"char_start": 97,
"chars": "ql = "
},
{
"char_end": 143,
"char_start": 142,
"chars": "d"
},
{
"char_end": 177,
"char_start": 165,
"chars": " \\\n %"
},
{
"char_end": 210,
"char_start": 187,
"chars": "\n cursor.execute(sql"
}
]
},
"commit_link": "github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9",
"file_name": "flaskr/flaskr/views/message.py",
"func_name": "test",
"line_changes": {
"added": [
{
"char_end": 188,
"char_start": 92,
"line": " cursor.execute('SELECT * FROM message where user_id = %s ORDER BY c_time DESC', (user_id,))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 168,
"char_start": 92,
"line": " sql = 'SELECT * FROM message where user_id = %d ORDER BY c_time DESC' \\\n",
"line_no": 4
},
{
"char_end": 188,
"char_start": 168,
"line": " % (user_id)\n",
"line_no": 5
},
{
"char_end": 212,
"char_start": 188,
"line": " cursor.execute(sql)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 366 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@staticmethod\n def get_last_active_users(limit):\n \"\"\"\n Get from the database a tuple of users who have been recently using\n the bot\n :param limit: integer that specifies how much users to get\n :return: tuple of tuples with users info\n \"\"\"\n log.info('Evaluating last active users with date of '\n 'last time when they used bot...')",
" # From photo_queries_table2 we take chat_id of the last\n # active users and from 'users' table we take info about these\n # users by chat_id which is a foreign key\n query = ('SELECT p.chat_id, u.first_name, u.nickname, u.last_name, '\n 'u.language '\n 'FROM photo_queries_table2 p '\n 'INNER JOIN users u '\n 'ON p.chat_id = u.chat_id '\n 'GROUP BY u.chat_id, u.first_name, u.nickname, u.last_name, '\n 'u.language '\n 'ORDER BY MAX(time)'",
" f'DESC LIMIT {limit}')",
"\n try:",
" cursor = db.execute_query(query)",
" except DatabaseConnectionError:\n log.error(\"Cannot get the last active users because of some \"\n \"problems with the database\")\n raise",
" last_active_users = cursor.fetchall()\n return last_active_users"
] | [
1,
1,
0,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1033,
"char_start": 1006,
"chars": "%s')\n\n parameters = "
},
{
"char_end": 1039,
"char_start": 1038,
"chars": ","
},
{
"char_end": 1109,
"char_start": 1097,
"chars": ", parameters"
}
],
"deleted": [
{
"char_end": 1007,
"char_start": 1006,
"chars": "{"
},
{
"char_end": 1015,
"char_start": 1012,
"chars": "}')"
}
]
},
"commit_link": "github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a",
"file_name": "photogpsbot/users.py",
"func_name": "get_last_active_users",
"line_changes": {
"added": [
{
"char_end": 1011,
"char_start": 976,
"line": " f'DESC LIMIT %s')\n",
"line_no": 23
},
{
"char_end": 1012,
"char_start": 1011,
"line": "\n",
"line_no": 24
},
{
"char_end": 1040,
"char_start": 1012,
"line": " parameters = limit,\n",
"line_no": 25
},
{
"char_end": 1111,
"char_start": 1054,
"line": " cursor = db.execute_query(query, parameters)\n",
"line_no": 28
}
],
"deleted": [
{
"char_end": 1016,
"char_start": 976,
"line": " f'DESC LIMIT {limit}')\n",
"line_no": 23
},
{
"char_end": 1075,
"char_start": 1030,
"line": " cursor = db.execute_query(query)\n",
"line_no": 26
}
]
},
"vul_type": "cwe-089"
} | 367 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@staticmethod\n def get_last_active_users(limit):\n \"\"\"\n Get from the database a tuple of users who have been recently using\n the bot\n :param limit: integer that specifies how much users to get\n :return: tuple of tuples with users info\n \"\"\"\n log.info('Evaluating last active users with date of '\n 'last time when they used bot...')",
" # From photo_queries_table2 we take chat_id of the last\n # active users and from 'users' table we take info about these\n # users by chat_id which is a foreign key\n query = ('SELECT p.chat_id, u.first_name, u.nickname, u.last_name, '\n 'u.language '\n 'FROM photo_queries_table2 p '\n 'INNER JOIN users u '\n 'ON p.chat_id = u.chat_id '\n 'GROUP BY u.chat_id, u.first_name, u.nickname, u.last_name, '\n 'u.language '\n 'ORDER BY MAX(time)'",
" f'DESC LIMIT %s')",
" parameters = limit,",
"\n try:",
" cursor = db.execute_query(query, parameters)",
" except DatabaseConnectionError:\n log.error(\"Cannot get the last active users because of some \"\n \"problems with the database\")\n raise",
" last_active_users = cursor.fetchall()\n return last_active_users"
] | [
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1033,
"char_start": 1006,
"chars": "%s')\n\n parameters = "
},
{
"char_end": 1039,
"char_start": 1038,
"chars": ","
},
{
"char_end": 1109,
"char_start": 1097,
"chars": ", parameters"
}
],
"deleted": [
{
"char_end": 1007,
"char_start": 1006,
"chars": "{"
},
{
"char_end": 1015,
"char_start": 1012,
"chars": "}')"
}
]
},
"commit_link": "github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a",
"file_name": "photogpsbot/users.py",
"func_name": "get_last_active_users",
"line_changes": {
"added": [
{
"char_end": 1011,
"char_start": 976,
"line": " f'DESC LIMIT %s')\n",
"line_no": 23
},
{
"char_end": 1012,
"char_start": 1011,
"line": "\n",
"line_no": 24
},
{
"char_end": 1040,
"char_start": 1012,
"line": " parameters = limit,\n",
"line_no": 25
},
{
"char_end": 1111,
"char_start": 1054,
"line": " cursor = db.execute_query(query, parameters)\n",
"line_no": 28
}
],
"deleted": [
{
"char_end": 1016,
"char_start": 976,
"line": " f'DESC LIMIT {limit}')\n",
"line_no": 23
},
{
"char_end": 1075,
"char_start": 1030,
"line": " cursor = db.execute_query(query)\n",
"line_no": 26
}
]
},
"vul_type": "cwe-089"
} | 367 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def on_save(self):\n connection = get_connection()\n cursor = connection.cursor()\n cursor.execute(",
" f\"insert into visitors (ip_address, user_agent, referrer, full_path, visit_time) values ('{self.ip_address}', '{self.user_agent}', '{self.referrer}', '{self.full_path}', '{self.visit_time}');\")",
" connection.commit()\n connection.close()\n return 0"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 262,
"char_start": 222,
"chars": "%s, %s, %s, %s, %s);\",\n (str("
},
{
"char_end": 278,
"char_start": 277,
"chars": ")"
},
{
"char_end": 284,
"char_start": 280,
"chars": "str("
},
{
"char_end": 300,
"char_start": 299,
"chars": ")"
},
{
"char_end": 306,
"char_start": 302,
"chars": "str("
},
{
"char_end": 320,
"char_start": 319,
"chars": ")"
},
{
"char_end": 326,
"char_start": 322,
"chars": "str("
},
{
"char_end": 341,
"char_start": 340,
"chars": ")"
}
],
"deleted": [
{
"char_end": 135,
"char_start": 134,
"chars": "f"
},
{
"char_end": 225,
"char_start": 223,
"chars": "'{"
},
{
"char_end": 242,
"char_start": 240,
"chars": "}'"
},
{
"char_end": 246,
"char_start": 244,
"chars": "'{"
},
{
"char_end": 263,
"char_start": 261,
"chars": "}'"
},
{
"char_end": 267,
"char_start": 265,
"chars": "'{"
},
{
"char_end": 282,
"char_start": 280,
"chars": "}'"
},
{
"char_end": 286,
"char_start": 284,
"chars": "'{"
},
{
"char_end": 302,
"char_start": 300,
"chars": "}'"
},
{
"char_end": 306,
"char_start": 304,
"chars": "'{"
},
{
"char_end": 323,
"char_start": 321,
"chars": "}'"
},
{
"char_end": 326,
"char_start": 324,
"chars": ";\""
}
]
},
"commit_link": "github.com/onewyoming/onewyoming/commit/54fc7b076fda2de74eeb55e6b75b28e09ef231c2",
"file_name": "experimental/python/buford/model/visitor.py",
"func_name": "on_save",
"line_changes": {
"added": [
{
"char_end": 245,
"char_start": 122,
"line": " \"insert into visitors (ip_address, user_agent, referrer, full_path, visit_time) values (%s, %s, %s, %s, %s);\",\n",
"line_no": 5
},
{
"char_end": 361,
"char_start": 245,
"line": " (str(self.ip_address), str(self.user_agent), str(self.referrer), str(self.full_path), self.visit_time))\n",
"line_no": 6
}
],
"deleted": [
{
"char_end": 328,
"char_start": 122,
"line": " f\"insert into visitors (ip_address, user_agent, referrer, full_path, visit_time) values ('{self.ip_address}', '{self.user_agent}', '{self.referrer}', '{self.full_path}', '{self.visit_time}');\")\n",
"line_no": 5
}
]
},
"vul_type": "cwe-089"
} | 368 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def on_save(self):\n connection = get_connection()\n cursor = connection.cursor()\n cursor.execute(",
" \"insert into visitors (ip_address, user_agent, referrer, full_path, visit_time) values (%s, %s, %s, %s, %s);\",\n (str(self.ip_address), str(self.user_agent), str(self.referrer), str(self.full_path), self.visit_time))",
" connection.commit()\n connection.close()\n return 0"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 262,
"char_start": 222,
"chars": "%s, %s, %s, %s, %s);\",\n (str("
},
{
"char_end": 278,
"char_start": 277,
"chars": ")"
},
{
"char_end": 284,
"char_start": 280,
"chars": "str("
},
{
"char_end": 300,
"char_start": 299,
"chars": ")"
},
{
"char_end": 306,
"char_start": 302,
"chars": "str("
},
{
"char_end": 320,
"char_start": 319,
"chars": ")"
},
{
"char_end": 326,
"char_start": 322,
"chars": "str("
},
{
"char_end": 341,
"char_start": 340,
"chars": ")"
}
],
"deleted": [
{
"char_end": 135,
"char_start": 134,
"chars": "f"
},
{
"char_end": 225,
"char_start": 223,
"chars": "'{"
},
{
"char_end": 242,
"char_start": 240,
"chars": "}'"
},
{
"char_end": 246,
"char_start": 244,
"chars": "'{"
},
{
"char_end": 263,
"char_start": 261,
"chars": "}'"
},
{
"char_end": 267,
"char_start": 265,
"chars": "'{"
},
{
"char_end": 282,
"char_start": 280,
"chars": "}'"
},
{
"char_end": 286,
"char_start": 284,
"chars": "'{"
},
{
"char_end": 302,
"char_start": 300,
"chars": "}'"
},
{
"char_end": 306,
"char_start": 304,
"chars": "'{"
},
{
"char_end": 323,
"char_start": 321,
"chars": "}'"
},
{
"char_end": 326,
"char_start": 324,
"chars": ";\""
}
]
},
"commit_link": "github.com/onewyoming/onewyoming/commit/54fc7b076fda2de74eeb55e6b75b28e09ef231c2",
"file_name": "experimental/python/buford/model/visitor.py",
"func_name": "on_save",
"line_changes": {
"added": [
{
"char_end": 245,
"char_start": 122,
"line": " \"insert into visitors (ip_address, user_agent, referrer, full_path, visit_time) values (%s, %s, %s, %s, %s);\",\n",
"line_no": 5
},
{
"char_end": 361,
"char_start": 245,
"line": " (str(self.ip_address), str(self.user_agent), str(self.referrer), str(self.full_path), self.visit_time))\n",
"line_no": 6
}
],
"deleted": [
{
"char_end": 328,
"char_start": 122,
"line": " f\"insert into visitors (ip_address, user_agent, referrer, full_path, visit_time) values ('{self.ip_address}', '{self.user_agent}', '{self.referrer}', '{self.full_path}', '{self.visit_time}');\")\n",
"line_no": 5
}
]
},
"vul_type": "cwe-089"
} | 368 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def update_institutions(conn, sqlite, k10plus, ai):\n \"\"\"\n Update the institution table.\n \"\"\"\n current_institutions = get_all_current_institutions(k10plus, ai)\n old_institutions = get_all_old_institutions(conn, sqlite)",
" # Check if the institution table is allready filled and this is not the first checkup\n institution_table_is_filled = len(old_institutions) > 10",
" for old_institution in old_institutions:\n if institution_table_is_filled and old_institution not in current_institutions:\n message = \"Die ISIL %s ist im aktuellen Import nicht mehr vorhanden.\\nWenn dies beabsichtigt ist, bitte die Institution aus der Datenbank loeschen.\" % old_institution\n send_message(message)",
" for current_institution in current_institutions:\n if current_institution == \" \" or '\"' in current_institution:\n continue\n if current_institution not in old_institutions:\n message = \"The institution %s is new in Solr.\" % current_institution\n if institution_table_is_filled:\n send_message(message)\n else:\n logging.info(message)",
" sql = \"INSERT INTO institution (institution) VALUES ('%s')\" % current_institution\n sqlite.execute(sql)",
" conn.commit()"
] | [
1,
1,
1,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1221,
"char_start": 1220,
"chars": "?"
},
{
"char_end": 1278,
"char_start": 1254,
"chars": ", (current_institution,)"
}
],
"deleted": [
{
"char_end": 1224,
"char_start": 1220,
"chars": "'%s'"
},
{
"char_end": 1248,
"char_start": 1226,
"chars": " % current_institution"
}
]
},
"commit_link": "github.com/miku/siskin/commit/7fa398d2fea72bf2e8b4808f75df4b3d35ae959a",
"file_name": "bin/solrcheckup.py",
"func_name": "update_institutions",
"line_changes": {
"added": [
{
"char_end": 1224,
"char_start": 1155,
"line": " sql = \"INSERT INTO institution (institution) VALUES (?)\"\n",
"line_no": 25
},
{
"char_end": 1280,
"char_start": 1224,
"line": " sqlite.execute(sql, (current_institution,))\n",
"line_no": 26
}
],
"deleted": [
{
"char_end": 1249,
"char_start": 1155,
"line": " sql = \"INSERT INTO institution (institution) VALUES ('%s')\" % current_institution\n",
"line_no": 25
},
{
"char_end": 1281,
"char_start": 1249,
"line": " sqlite.execute(sql)\n",
"line_no": 26
}
]
},
"vul_type": "cwe-089"
} | 369 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def update_institutions(conn, sqlite, k10plus, ai):\n \"\"\"\n Update the institution table.\n \"\"\"\n current_institutions = get_all_current_institutions(k10plus, ai)\n old_institutions = get_all_old_institutions(conn, sqlite)",
" # Check if the institution table is allready filled and this is not the first checkup\n institution_table_is_filled = len(old_institutions) > 10",
" for old_institution in old_institutions:\n if institution_table_is_filled and old_institution not in current_institutions:\n message = \"Die ISIL %s ist im aktuellen Import nicht mehr vorhanden.\\nWenn dies beabsichtigt ist, bitte die Institution aus der Datenbank loeschen.\" % old_institution\n send_message(message)",
" for current_institution in current_institutions:\n if current_institution == \" \" or '\"' in current_institution:\n continue\n if current_institution not in old_institutions:\n message = \"The institution %s is new in Solr.\" % current_institution\n if institution_table_is_filled:\n send_message(message)\n else:\n logging.info(message)",
" sql = \"INSERT INTO institution (institution) VALUES (?)\"\n sqlite.execute(sql, (current_institution,))",
" conn.commit()"
] | [
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1221,
"char_start": 1220,
"chars": "?"
},
{
"char_end": 1278,
"char_start": 1254,
"chars": ", (current_institution,)"
}
],
"deleted": [
{
"char_end": 1224,
"char_start": 1220,
"chars": "'%s'"
},
{
"char_end": 1248,
"char_start": 1226,
"chars": " % current_institution"
}
]
},
"commit_link": "github.com/miku/siskin/commit/7fa398d2fea72bf2e8b4808f75df4b3d35ae959a",
"file_name": "bin/solrcheckup.py",
"func_name": "update_institutions",
"line_changes": {
"added": [
{
"char_end": 1224,
"char_start": 1155,
"line": " sql = \"INSERT INTO institution (institution) VALUES (?)\"\n",
"line_no": 25
},
{
"char_end": 1280,
"char_start": 1224,
"line": " sqlite.execute(sql, (current_institution,))\n",
"line_no": 26
}
],
"deleted": [
{
"char_end": 1249,
"char_start": 1155,
"line": " sql = \"INSERT INTO institution (institution) VALUES ('%s')\" % current_institution\n",
"line_no": 25
},
{
"char_end": 1281,
"char_start": 1249,
"line": " sqlite.execute(sql)\n",
"line_no": 26
}
]
},
"vul_type": "cwe-089"
} | 369 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@staticmethod\n def _add_to_db(user):\n \"\"\"\n Adds User object to the database\n :param user: User object with info about user\n :return: None\n \"\"\"\n query = (\"INSERT INTO users (chat_id, first_name, nickname, \"\n \"last_name, language) \"",
" f\"VALUES ({user.chat_id}, '{user.first_name}', \"\n f\"'{user.nickname}', '{user.last_name}', '{user.language}')\")",
" try:",
" db.add(query)",
" except DatabaseError:\n log.error(\"Cannot add user to the database\")\n else:\n log.info(f\"User {user} was successfully added to the users db\")"
] | [
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 368,
"char_start": 323,
"chars": "%s, %s, %s, %s, %s)\")\n\n parameters = ("
},
{
"char_end": 413,
"char_start": 399,
"chars": "user.nickname,"
},
{
"char_end": 435,
"char_start": 431,
"chars": " "
},
{
"char_end": 467,
"char_start": 466,
"chars": "\n"
},
{
"char_end": 517,
"char_start": 505,
"chars": ", parameters"
}
],
"deleted": [
{
"char_end": 324,
"char_start": 323,
"chars": "{"
},
{
"char_end": 337,
"char_start": 336,
"chars": "}"
},
{
"char_end": 341,
"char_start": 339,
"chars": "'{"
},
{
"char_end": 358,
"char_start": 356,
"chars": "}'"
},
{
"char_end": 361,
"char_start": 360,
"chars": "\""
},
{
"char_end": 399,
"char_start": 379,
"chars": "f\"'{user.nickname}',"
},
{
"char_end": 402,
"char_start": 400,
"chars": "'{"
},
{
"char_end": 418,
"char_start": 416,
"chars": "}'"
},
{
"char_end": 422,
"char_start": 420,
"chars": "'{"
},
{
"char_end": 437,
"char_start": 435,
"chars": "}'"
},
{
"char_end": 440,
"char_start": 438,
"chars": "\")"
}
]
},
"commit_link": "github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a",
"file_name": "photogpsbot/users.py",
"func_name": "_add_to_db",
"line_changes": {
"added": [
{
"char_end": 345,
"char_start": 296,
"line": " f\"VALUES (%s, %s, %s, %s, %s)\")\n",
"line_no": 10
},
{
"char_end": 346,
"char_start": 345,
"line": "\n",
"line_no": 11
},
{
"char_end": 414,
"char_start": 346,
"line": " parameters = (user.chat_id, user.first_name, user.nickname,\n",
"line_no": 12
},
{
"char_end": 467,
"char_start": 414,
"line": " user.last_name, user.language)\n",
"line_no": 13
},
{
"char_end": 468,
"char_start": 467,
"line": "\n",
"line_no": 14
},
{
"char_end": 519,
"char_start": 481,
"line": " db.add(query, parameters)\n",
"line_no": 16
}
],
"deleted": [
{
"char_end": 362,
"char_start": 296,
"line": " f\"VALUES ({user.chat_id}, '{user.first_name}', \"\n",
"line_no": 10
},
{
"char_end": 441,
"char_start": 362,
"line": " f\"'{user.nickname}', '{user.last_name}', '{user.language}')\")\n",
"line_no": 11
},
{
"char_end": 480,
"char_start": 454,
"line": " db.add(query)\n",
"line_no": 13
}
]
},
"vul_type": "cwe-089"
} | 370 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@staticmethod\n def _add_to_db(user):\n \"\"\"\n Adds User object to the database\n :param user: User object with info about user\n :return: None\n \"\"\"\n query = (\"INSERT INTO users (chat_id, first_name, nickname, \"\n \"last_name, language) \"",
" f\"VALUES (%s, %s, %s, %s, %s)\")",
" parameters = (user.chat_id, user.first_name, user.nickname,\n user.last_name, user.language)\n",
" try:",
" db.add(query, parameters)",
" except DatabaseError:\n log.error(\"Cannot add user to the database\")\n else:\n log.info(f\"User {user} was successfully added to the users db\")"
] | [
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 368,
"char_start": 323,
"chars": "%s, %s, %s, %s, %s)\")\n\n parameters = ("
},
{
"char_end": 413,
"char_start": 399,
"chars": "user.nickname,"
},
{
"char_end": 435,
"char_start": 431,
"chars": " "
},
{
"char_end": 467,
"char_start": 466,
"chars": "\n"
},
{
"char_end": 517,
"char_start": 505,
"chars": ", parameters"
}
],
"deleted": [
{
"char_end": 324,
"char_start": 323,
"chars": "{"
},
{
"char_end": 337,
"char_start": 336,
"chars": "}"
},
{
"char_end": 341,
"char_start": 339,
"chars": "'{"
},
{
"char_end": 358,
"char_start": 356,
"chars": "}'"
},
{
"char_end": 361,
"char_start": 360,
"chars": "\""
},
{
"char_end": 399,
"char_start": 379,
"chars": "f\"'{user.nickname}',"
},
{
"char_end": 402,
"char_start": 400,
"chars": "'{"
},
{
"char_end": 418,
"char_start": 416,
"chars": "}'"
},
{
"char_end": 422,
"char_start": 420,
"chars": "'{"
},
{
"char_end": 437,
"char_start": 435,
"chars": "}'"
},
{
"char_end": 440,
"char_start": 438,
"chars": "\")"
}
]
},
"commit_link": "github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a",
"file_name": "photogpsbot/users.py",
"func_name": "_add_to_db",
"line_changes": {
"added": [
{
"char_end": 345,
"char_start": 296,
"line": " f\"VALUES (%s, %s, %s, %s, %s)\")\n",
"line_no": 10
},
{
"char_end": 346,
"char_start": 345,
"line": "\n",
"line_no": 11
},
{
"char_end": 414,
"char_start": 346,
"line": " parameters = (user.chat_id, user.first_name, user.nickname,\n",
"line_no": 12
},
{
"char_end": 467,
"char_start": 414,
"line": " user.last_name, user.language)\n",
"line_no": 13
},
{
"char_end": 468,
"char_start": 467,
"line": "\n",
"line_no": 14
},
{
"char_end": 519,
"char_start": 481,
"line": " db.add(query, parameters)\n",
"line_no": 16
}
],
"deleted": [
{
"char_end": 362,
"char_start": 296,
"line": " f\"VALUES ({user.chat_id}, '{user.first_name}', \"\n",
"line_no": 10
},
{
"char_end": 441,
"char_start": 362,
"line": " f\"'{user.nickname}', '{user.last_name}', '{user.language}')\")\n",
"line_no": 11
},
{
"char_end": 480,
"char_start": 454,
"line": " db.add(query)\n",
"line_no": 13
}
]
},
"vul_type": "cwe-089"
} | 370 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def deletePost(self,postid):",
" sqlText=\"delete from post where post.postid=%d\"%(postid)\n result=sql.deleteDB(self.conn,sqlText)",
" return result;"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 87,
"char_start": 86,
"chars": "s"
},
{
"char_end": 105,
"char_start": 88,
"chars": "\n params=["
},
{
"char_end": 112,
"char_start": 111,
"chars": "]"
},
{
"char_end": 165,
"char_start": 158,
"chars": ",params"
}
],
"deleted": [
{
"char_end": 87,
"char_start": 86,
"chars": "d"
},
{
"char_end": 90,
"char_start": 88,
"chars": "%("
},
{
"char_end": 97,
"char_start": 96,
"chars": ")"
}
]
},
"commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9",
"file_name": "modules/post.py",
"func_name": "deletePost",
"line_changes": {
"added": [
{
"char_end": 89,
"char_start": 33,
"line": " sqlText=\"delete from post where post.postid=%s\"\n",
"line_no": 2
},
{
"char_end": 113,
"char_start": 89,
"line": " params=[postid]\n",
"line_no": 3
},
{
"char_end": 167,
"char_start": 113,
"line": " result=sql.deleteDB(self.conn,sqlText,params)\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 98,
"char_start": 33,
"line": " sqlText=\"delete from post where post.postid=%d\"%(postid)\n",
"line_no": 2
},
{
"char_end": 145,
"char_start": 98,
"line": " result=sql.deleteDB(self.conn,sqlText)\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 371 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def deletePost(self,postid):",
" sqlText=\"delete from post where post.postid=%s\"\n params=[postid]\n result=sql.deleteDB(self.conn,sqlText,params)",
" return result;"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 87,
"char_start": 86,
"chars": "s"
},
{
"char_end": 105,
"char_start": 88,
"chars": "\n params=["
},
{
"char_end": 112,
"char_start": 111,
"chars": "]"
},
{
"char_end": 165,
"char_start": 158,
"chars": ",params"
}
],
"deleted": [
{
"char_end": 87,
"char_start": 86,
"chars": "d"
},
{
"char_end": 90,
"char_start": 88,
"chars": "%("
},
{
"char_end": 97,
"char_start": 96,
"chars": ")"
}
]
},
"commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9",
"file_name": "modules/post.py",
"func_name": "deletePost",
"line_changes": {
"added": [
{
"char_end": 89,
"char_start": 33,
"line": " sqlText=\"delete from post where post.postid=%s\"\n",
"line_no": 2
},
{
"char_end": 113,
"char_start": 89,
"line": " params=[postid]\n",
"line_no": 3
},
{
"char_end": 167,
"char_start": 113,
"line": " result=sql.deleteDB(self.conn,sqlText,params)\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 98,
"char_start": 33,
"line": " sqlText=\"delete from post where post.postid=%d\"%(postid)\n",
"line_no": 2
},
{
"char_end": 145,
"char_start": 98,
"line": " result=sql.deleteDB(self.conn,sqlText)\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 371 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/sloka')\ndef sloka():",
" sloka_number = request.args.get('sloka_number')",
" sloka_number_parts = sloka_number.split('.')",
" sloka_number_previous = \"%s.%s.%d\" % (sloka_number_parts[0], sloka_number_parts[1], int(sloka_number_parts[2])-1)\n sloka_number_next = \"%s.%s.%d\" % (sloka_number_parts[0], sloka_number_parts[1], int(sloka_number_parts[2])+1)",
" try:\n with sql.connect('amara.db') as con:\n con.row_factory = sql.Row\n cur = con.cursor()",
" cur.execute(\"select * from mula where sloka_number = '%s' order by sloka_line;\" % sloka_number)",
" mula = cur.fetchall();\n",
" cur.execute(\"select * from pada where sloka_number = '%s' order by id;\" % sloka_number)",
" pada = cur.fetchall();",
" varga = \"\"\n if len(pada) > 0:\n varga = pada[0][\"varga\"]",
" return render_template('sloka.html', mula=mula, pada=pada, varga=varga, sloka_number=sloka_number, sloka_number_previous=sloka_number_previous, sloka_number_next=sloka_number_next)\n finally:\n con.close()"
] | [
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 560,
"char_start": 559,
"chars": "?"
},
{
"char_end": 583,
"char_start": 582,
"chars": ","
},
{
"char_end": 585,
"char_start": 584,
"chars": "["
},
{
"char_end": 598,
"char_start": 597,
"chars": "]"
},
{
"char_end": 702,
"char_start": 701,
"chars": "?"
},
{
"char_end": 717,
"char_start": 716,
"chars": ","
},
{
"char_end": 719,
"char_start": 718,
"chars": "["
},
{
"char_end": 732,
"char_start": 731,
"chars": "]"
}
],
"deleted": [
{
"char_end": 563,
"char_start": 559,
"chars": "'%s'"
},
{
"char_end": 587,
"char_start": 585,
"chars": " %"
},
{
"char_end": 707,
"char_start": 703,
"chars": "'%s'"
},
{
"char_end": 723,
"char_start": 721,
"chars": " %"
}
]
},
"commit_link": "github.com/aupasana/amara-quiz/commit/6ceb5dc8ec38b4a3f1399e578ab970f7e3354922",
"file_name": "docker/app.py",
"func_name": "sloka",
"line_changes": {
"added": [
{
"char_end": 600,
"char_start": 494,
"line": " cur.execute(\"select * from mula where sloka_number = ? order by sloka_line;\", [sloka_number])\n",
"line_no": 15
},
{
"char_end": 734,
"char_start": 636,
"line": " cur.execute(\"select * from pada where sloka_number = ? order by id;\", [sloka_number])\n",
"line_no": 18
}
],
"deleted": [
{
"char_end": 602,
"char_start": 494,
"line": " cur.execute(\"select * from mula where sloka_number = '%s' order by sloka_line;\" % sloka_number)\n",
"line_no": 15
},
{
"char_end": 738,
"char_start": 638,
"line": " cur.execute(\"select * from pada where sloka_number = '%s' order by id;\" % sloka_number)\n",
"line_no": 18
}
]
},
"vul_type": "cwe-089"
} | 372 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/sloka')\ndef sloka():",
" sloka_number = request.args.get('sloka_number')",
" sloka_number_parts = sloka_number.split('.')",
" sloka_number_previous = \"%s.%s.%d\" % (sloka_number_parts[0], sloka_number_parts[1], int(sloka_number_parts[2])-1)\n sloka_number_next = \"%s.%s.%d\" % (sloka_number_parts[0], sloka_number_parts[1], int(sloka_number_parts[2])+1)",
" try:\n with sql.connect('amara.db') as con:\n con.row_factory = sql.Row\n cur = con.cursor()",
" cur.execute(\"select * from mula where sloka_number = ? order by sloka_line;\", [sloka_number])",
" mula = cur.fetchall();\n",
" cur.execute(\"select * from pada where sloka_number = ? order by id;\", [sloka_number])",
" pada = cur.fetchall();",
" varga = \"\"\n if len(pada) > 0:\n varga = pada[0][\"varga\"]",
" return render_template('sloka.html', mula=mula, pada=pada, varga=varga, sloka_number=sloka_number, sloka_number_previous=sloka_number_previous, sloka_number_next=sloka_number_next)\n finally:\n con.close()"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 560,
"char_start": 559,
"chars": "?"
},
{
"char_end": 583,
"char_start": 582,
"chars": ","
},
{
"char_end": 585,
"char_start": 584,
"chars": "["
},
{
"char_end": 598,
"char_start": 597,
"chars": "]"
},
{
"char_end": 702,
"char_start": 701,
"chars": "?"
},
{
"char_end": 717,
"char_start": 716,
"chars": ","
},
{
"char_end": 719,
"char_start": 718,
"chars": "["
},
{
"char_end": 732,
"char_start": 731,
"chars": "]"
}
],
"deleted": [
{
"char_end": 563,
"char_start": 559,
"chars": "'%s'"
},
{
"char_end": 587,
"char_start": 585,
"chars": " %"
},
{
"char_end": 707,
"char_start": 703,
"chars": "'%s'"
},
{
"char_end": 723,
"char_start": 721,
"chars": " %"
}
]
},
"commit_link": "github.com/aupasana/amara-quiz/commit/6ceb5dc8ec38b4a3f1399e578ab970f7e3354922",
"file_name": "docker/app.py",
"func_name": "sloka",
"line_changes": {
"added": [
{
"char_end": 600,
"char_start": 494,
"line": " cur.execute(\"select * from mula where sloka_number = ? order by sloka_line;\", [sloka_number])\n",
"line_no": 15
},
{
"char_end": 734,
"char_start": 636,
"line": " cur.execute(\"select * from pada where sloka_number = ? order by id;\", [sloka_number])\n",
"line_no": 18
}
],
"deleted": [
{
"char_end": 602,
"char_start": 494,
"line": " cur.execute(\"select * from mula where sloka_number = '%s' order by sloka_line;\" % sloka_number)\n",
"line_no": 15
},
{
"char_end": 738,
"char_start": 638,
"line": " cur.execute(\"select * from pada where sloka_number = '%s' order by id;\" % sloka_number)\n",
"line_no": 18
}
]
},
"vul_type": "cwe-089"
} | 372 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def update_title(self, title = None):\n if (not self.title):\n self.title = title\n",
"",
" # This will fall to a sql injection ",
" sql = \"UPDATE jdk_entries SET title = '\" + self.title + \"'\" + \\\n \"WHERE jdk_entries.id = '\" + self.entry_id + \"';\" ",
"",
" db_execute(sql)",
" \n self.update_date_modified()",
" return None"
] | [
1,
0,
1,
0,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 140,
"char_start": 95,
"chars": "quote_tuple = self.title, self.entry_id\n\n "
},
{
"char_end": 220,
"char_start": 219,
"chars": "?"
},
{
"char_end": 261,
"char_start": 260,
"chars": "?"
},
{
"char_end": 297,
"char_start": 284,
"chars": ", quote_tuple"
}
],
"deleted": [
{
"char_end": 194,
"char_start": 174,
"chars": "'\" + self.title + \"'"
},
{
"char_end": 257,
"char_start": 234,
"chars": "'\" + self.entry_id + \"'"
}
]
},
"commit_link": "github.com/peterlebrun/jdk/commit/000238566fbe55ba09676c3d57af04ae207235ae",
"file_name": "entry.py",
"func_name": "update_title",
"line_changes": {
"added": [
{
"char_end": 135,
"char_start": 91,
"line": " quote_tuple = self.title, self.entry_id\n",
"line_no": 5
},
{
"char_end": 136,
"char_start": 135,
"line": "\n",
"line_no": 6
},
{
"char_end": 226,
"char_start": 177,
"line": " sql = \"UPDATE jdk_entries SET title = ?\" + \\\n",
"line_no": 8
},
{
"char_end": 265,
"char_start": 226,
"line": " \"WHERE jdk_entries.id = ?;\" \n",
"line_no": 9
},
{
"char_end": 299,
"char_start": 266,
"line": " db_execute(sql, quote_tuple)\n",
"line_no": 11
}
],
"deleted": [
{
"char_end": 200,
"char_start": 132,
"line": " sql = \"UPDATE jdk_entries SET title = '\" + self.title + \"'\" + \\\n",
"line_no": 6
},
{
"char_end": 261,
"char_start": 200,
"line": " \"WHERE jdk_entries.id = '\" + self.entry_id + \"';\" \n",
"line_no": 7
},
{
"char_end": 282,
"char_start": 262,
"line": " db_execute(sql)\n",
"line_no": 9
}
]
},
"vul_type": "cwe-089"
} | 373 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def update_title(self, title = None):\n if (not self.title):\n self.title = title\n",
" quote_tuple = self.title, self.entry_id\n",
" # This will fall to a sql injection ",
" sql = \"UPDATE jdk_entries SET title = ?\" + \\\n \"WHERE jdk_entries.id = ?;\" ",
"",
" db_execute(sql, quote_tuple)",
" \n self.update_date_modified()",
" return None"
] | [
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 140,
"char_start": 95,
"chars": "quote_tuple = self.title, self.entry_id\n\n "
},
{
"char_end": 220,
"char_start": 219,
"chars": "?"
},
{
"char_end": 261,
"char_start": 260,
"chars": "?"
},
{
"char_end": 297,
"char_start": 284,
"chars": ", quote_tuple"
}
],
"deleted": [
{
"char_end": 194,
"char_start": 174,
"chars": "'\" + self.title + \"'"
},
{
"char_end": 257,
"char_start": 234,
"chars": "'\" + self.entry_id + \"'"
}
]
},
"commit_link": "github.com/peterlebrun/jdk/commit/000238566fbe55ba09676c3d57af04ae207235ae",
"file_name": "entry.py",
"func_name": "update_title",
"line_changes": {
"added": [
{
"char_end": 135,
"char_start": 91,
"line": " quote_tuple = self.title, self.entry_id\n",
"line_no": 5
},
{
"char_end": 136,
"char_start": 135,
"line": "\n",
"line_no": 6
},
{
"char_end": 226,
"char_start": 177,
"line": " sql = \"UPDATE jdk_entries SET title = ?\" + \\\n",
"line_no": 8
},
{
"char_end": 265,
"char_start": 226,
"line": " \"WHERE jdk_entries.id = ?;\" \n",
"line_no": 9
},
{
"char_end": 299,
"char_start": 266,
"line": " db_execute(sql, quote_tuple)\n",
"line_no": 11
}
],
"deleted": [
{
"char_end": 200,
"char_start": 132,
"line": " sql = \"UPDATE jdk_entries SET title = '\" + self.title + \"'\" + \\\n",
"line_no": 6
},
{
"char_end": 261,
"char_start": 200,
"line": " \"WHERE jdk_entries.id = '\" + self.entry_id + \"';\" \n",
"line_no": 7
},
{
"char_end": 282,
"char_start": 262,
"line": " db_execute(sql)\n",
"line_no": 9
}
]
},
"vul_type": "cwe-089"
} | 373 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def add_language(self, language):\n \"\"\"\"Add new language for item translations.\"\"\"\n if self.connection:",
" self.cursor.execute('insert into itemlanguage (language) values (\"%s\")' % language[0])",
" self.connection.commit()"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 165,
"char_start": 133,
"chars": "t = (language[0], )\n "
},
{
"char_end": 231,
"char_start": 230,
"chars": "?"
},
{
"char_end": 234,
"char_start": 233,
"chars": ","
},
{
"char_end": 236,
"char_start": 235,
"chars": "t"
}
],
"deleted": [
{
"char_end": 202,
"char_start": 198,
"chars": "\"%s\""
},
{
"char_end": 206,
"char_start": 204,
"chars": " %"
},
{
"char_end": 218,
"char_start": 207,
"chars": "language[0]"
}
]
},
"commit_link": "github.com/ecosl-developers/ecosl/commit/8af050a513338bf68ff2a243e4a2482d24e9aa3a",
"file_name": "ecosldb/ecosldb.py",
"func_name": "add_language",
"line_changes": {
"added": [
{
"char_end": 153,
"char_start": 121,
"line": " t = (language[0], )\n",
"line_no": 4
},
{
"char_end": 238,
"char_start": 153,
"line": " self.cursor.execute('insert into itemlanguage (language) values (?)', t)\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 220,
"char_start": 121,
"line": " self.cursor.execute('insert into itemlanguage (language) values (\"%s\")' % language[0])\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 374 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def add_language(self, language):\n \"\"\"\"Add new language for item translations.\"\"\"\n if self.connection:",
" t = (language[0], )\n self.cursor.execute('insert into itemlanguage (language) values (?)', t)",
" self.connection.commit()"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 165,
"char_start": 133,
"chars": "t = (language[0], )\n "
},
{
"char_end": 231,
"char_start": 230,
"chars": "?"
},
{
"char_end": 234,
"char_start": 233,
"chars": ","
},
{
"char_end": 236,
"char_start": 235,
"chars": "t"
}
],
"deleted": [
{
"char_end": 202,
"char_start": 198,
"chars": "\"%s\""
},
{
"char_end": 206,
"char_start": 204,
"chars": " %"
},
{
"char_end": 218,
"char_start": 207,
"chars": "language[0]"
}
]
},
"commit_link": "github.com/ecosl-developers/ecosl/commit/8af050a513338bf68ff2a243e4a2482d24e9aa3a",
"file_name": "ecosldb/ecosldb.py",
"func_name": "add_language",
"line_changes": {
"added": [
{
"char_end": 153,
"char_start": 121,
"line": " t = (language[0], )\n",
"line_no": 4
},
{
"char_end": 238,
"char_start": 153,
"line": " self.cursor.execute('insert into itemlanguage (language) values (?)', t)\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 220,
"char_start": 121,
"line": " self.cursor.execute('insert into itemlanguage (language) values (\"%s\")' % language[0])\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 374 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"MagickExport Image *AdaptiveThresholdImage(const Image *image,\n const size_t width,const size_t height,const ssize_t offset,\n ExceptionInfo *exception)\n{\n#define ThresholdImageTag \"Threshold/Image\"",
" CacheView\n *image_view,\n *threshold_view;",
" Image\n *threshold_image;",
" MagickBooleanType\n status;",
" MagickOffsetType\n progress;",
" MagickPixelPacket\n zero;",
" MagickRealType\n number_pixels;",
" ssize_t\n y;",
" assert(image != (const Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickCoreSignature);\n threshold_image=CloneImage(image,0,0,MagickTrue,exception);\n if (threshold_image == (Image *) NULL)\n return((Image *) NULL);",
"",
" if (SetImageStorageClass(threshold_image,DirectClass) == MagickFalse)\n {\n InheritException(exception,&threshold_image->exception);\n threshold_image=DestroyImage(threshold_image);\n return((Image *) NULL);\n }\n /*\n Local adaptive threshold.\n */\n status=MagickTrue;\n progress=0;\n GetMagickPixelPacket(image,&zero);\n number_pixels=(MagickRealType) (width*height);\n image_view=AcquireVirtualCacheView(image,exception);\n threshold_view=AcquireAuthenticCacheView(threshold_image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp parallel for schedule(static) shared(progress,status) \\\n magick_number_threads(image,threshold_image,image->rows,1)\n#endif\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n MagickBooleanType\n sync;",
" MagickPixelPacket\n channel_bias,\n channel_sum;",
" register const IndexPacket\n *magick_restrict indexes;",
" register const PixelPacket\n *magick_restrict p,\n *magick_restrict r;",
" register IndexPacket\n *magick_restrict threshold_indexes;",
" register PixelPacket\n *magick_restrict q;",
" register ssize_t\n x;",
" ssize_t\n u,\n v;",
" if (status == MagickFalse)\n continue;\n p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t)\n height/2L,image->columns+width,height,exception);\n q=GetCacheViewAuthenticPixels(threshold_view,0,y,threshold_image->columns,1,\n exception);\n if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))\n {\n status=MagickFalse;\n continue;\n }\n indexes=GetCacheViewVirtualIndexQueue(image_view);\n threshold_indexes=GetCacheViewAuthenticIndexQueue(threshold_view);\n channel_bias=zero;\n channel_sum=zero;\n r=p;\n for (v=0; v < (ssize_t) height; v++)\n {\n for (u=0; u < (ssize_t) width; u++)\n {\n if (u == (ssize_t) (width-1))\n {\n channel_bias.red+=r[u].red;\n channel_bias.green+=r[u].green;\n channel_bias.blue+=r[u].blue;\n channel_bias.opacity+=r[u].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_bias.index=(MagickRealType)\n GetPixelIndex(indexes+(r-p)+u);\n }\n channel_sum.red+=r[u].red;\n channel_sum.green+=r[u].green;\n channel_sum.blue+=r[u].blue;\n channel_sum.opacity+=r[u].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_sum.index=(MagickRealType) GetPixelIndex(indexes+(r-p)+u);\n }\n r+=image->columns+width;\n }\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n MagickPixelPacket\n mean;",
" mean=zero;\n r=p;\n channel_sum.red-=channel_bias.red;\n channel_sum.green-=channel_bias.green;\n channel_sum.blue-=channel_bias.blue;\n channel_sum.opacity-=channel_bias.opacity;\n channel_sum.index-=channel_bias.index;\n channel_bias=zero;\n for (v=0; v < (ssize_t) height; v++)\n {\n channel_bias.red+=r[0].red;\n channel_bias.green+=r[0].green;\n channel_bias.blue+=r[0].blue;\n channel_bias.opacity+=r[0].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_bias.index=(MagickRealType) GetPixelIndex(indexes+x+(r-p)+0);\n channel_sum.red+=r[width-1].red;\n channel_sum.green+=r[width-1].green;\n channel_sum.blue+=r[width-1].blue;\n channel_sum.opacity+=r[width-1].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_sum.index=(MagickRealType) GetPixelIndex(indexes+x+(r-p)+\n width-1);\n r+=image->columns+width;\n }\n mean.red=(MagickRealType) (channel_sum.red/number_pixels+offset);\n mean.green=(MagickRealType) (channel_sum.green/number_pixels+offset);\n mean.blue=(MagickRealType) (channel_sum.blue/number_pixels+offset);\n mean.opacity=(MagickRealType) (channel_sum.opacity/number_pixels+offset);\n if (image->colorspace == CMYKColorspace)\n mean.index=(MagickRealType) (channel_sum.index/number_pixels+offset);\n SetPixelRed(q,((MagickRealType) GetPixelRed(q) <= mean.red) ?\n 0 : QuantumRange);\n SetPixelGreen(q,((MagickRealType) GetPixelGreen(q) <= mean.green) ?\n 0 : QuantumRange);\n SetPixelBlue(q,((MagickRealType) GetPixelBlue(q) <= mean.blue) ?\n 0 : QuantumRange);\n SetPixelOpacity(q,((MagickRealType) GetPixelOpacity(q) <= mean.opacity) ?\n 0 : QuantumRange);\n if (image->colorspace == CMYKColorspace)\n SetPixelIndex(threshold_indexes+x,(((MagickRealType) GetPixelIndex(\n threshold_indexes+x) <= mean.index) ? 0 : QuantumRange));\n p++;\n q++;\n }\n sync=SyncCacheViewAuthenticPixels(threshold_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 atomic\n#endif\n progress++;\n proceed=SetImageProgress(image,ThresholdImageTag,progress,image->rows);\n if (proceed == MagickFalse)\n status=MagickFalse;\n }\n }\n threshold_view=DestroyCacheView(threshold_view);\n image_view=DestroyCacheView(image_view);\n if (status == MagickFalse)\n threshold_image=DestroyImage(threshold_image);\n return(threshold_image);\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 928,
"char_start": 881,
"chars": "width == 0)\n return(threshold_image);\n if ("
}
],
"deleted": []
},
"commit_link": "github.com/ImageMagick/ImageMagick6/commit/55e6dc49f1a381d9d511ee2f888fdc3e3c3e3953",
"file_name": "magick/threshold.c",
"func_name": "AdaptiveThresholdImage",
"line_changes": {
"added": [
{
"char_end": 893,
"char_start": 875,
"line": " if (width == 0)\n",
"line_no": 38
},
{
"char_end": 922,
"char_start": 893,
"line": " return(threshold_image);\n",
"line_no": 39
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 375 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"MagickExport Image *AdaptiveThresholdImage(const Image *image,\n const size_t width,const size_t height,const ssize_t offset,\n ExceptionInfo *exception)\n{\n#define ThresholdImageTag \"Threshold/Image\"",
" CacheView\n *image_view,\n *threshold_view;",
" Image\n *threshold_image;",
" MagickBooleanType\n status;",
" MagickOffsetType\n progress;",
" MagickPixelPacket\n zero;",
" MagickRealType\n number_pixels;",
" ssize_t\n y;",
" assert(image != (const Image *) NULL);\n assert(image->signature == MagickCoreSignature);\n if (image->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",image->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickCoreSignature);\n threshold_image=CloneImage(image,0,0,MagickTrue,exception);\n if (threshold_image == (Image *) NULL)\n return((Image *) NULL);",
" if (width == 0)\n return(threshold_image);",
" if (SetImageStorageClass(threshold_image,DirectClass) == MagickFalse)\n {\n InheritException(exception,&threshold_image->exception);\n threshold_image=DestroyImage(threshold_image);\n return((Image *) NULL);\n }\n /*\n Local adaptive threshold.\n */\n status=MagickTrue;\n progress=0;\n GetMagickPixelPacket(image,&zero);\n number_pixels=(MagickRealType) (width*height);\n image_view=AcquireVirtualCacheView(image,exception);\n threshold_view=AcquireAuthenticCacheView(threshold_image,exception);\n#if defined(MAGICKCORE_OPENMP_SUPPORT)\n #pragma omp parallel for schedule(static) shared(progress,status) \\\n magick_number_threads(image,threshold_image,image->rows,1)\n#endif\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n MagickBooleanType\n sync;",
" MagickPixelPacket\n channel_bias,\n channel_sum;",
" register const IndexPacket\n *magick_restrict indexes;",
" register const PixelPacket\n *magick_restrict p,\n *magick_restrict r;",
" register IndexPacket\n *magick_restrict threshold_indexes;",
" register PixelPacket\n *magick_restrict q;",
" register ssize_t\n x;",
" ssize_t\n u,\n v;",
" if (status == MagickFalse)\n continue;\n p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t)\n height/2L,image->columns+width,height,exception);\n q=GetCacheViewAuthenticPixels(threshold_view,0,y,threshold_image->columns,1,\n exception);\n if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))\n {\n status=MagickFalse;\n continue;\n }\n indexes=GetCacheViewVirtualIndexQueue(image_view);\n threshold_indexes=GetCacheViewAuthenticIndexQueue(threshold_view);\n channel_bias=zero;\n channel_sum=zero;\n r=p;\n for (v=0; v < (ssize_t) height; v++)\n {\n for (u=0; u < (ssize_t) width; u++)\n {\n if (u == (ssize_t) (width-1))\n {\n channel_bias.red+=r[u].red;\n channel_bias.green+=r[u].green;\n channel_bias.blue+=r[u].blue;\n channel_bias.opacity+=r[u].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_bias.index=(MagickRealType)\n GetPixelIndex(indexes+(r-p)+u);\n }\n channel_sum.red+=r[u].red;\n channel_sum.green+=r[u].green;\n channel_sum.blue+=r[u].blue;\n channel_sum.opacity+=r[u].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_sum.index=(MagickRealType) GetPixelIndex(indexes+(r-p)+u);\n }\n r+=image->columns+width;\n }\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n MagickPixelPacket\n mean;",
" mean=zero;\n r=p;\n channel_sum.red-=channel_bias.red;\n channel_sum.green-=channel_bias.green;\n channel_sum.blue-=channel_bias.blue;\n channel_sum.opacity-=channel_bias.opacity;\n channel_sum.index-=channel_bias.index;\n channel_bias=zero;\n for (v=0; v < (ssize_t) height; v++)\n {\n channel_bias.red+=r[0].red;\n channel_bias.green+=r[0].green;\n channel_bias.blue+=r[0].blue;\n channel_bias.opacity+=r[0].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_bias.index=(MagickRealType) GetPixelIndex(indexes+x+(r-p)+0);\n channel_sum.red+=r[width-1].red;\n channel_sum.green+=r[width-1].green;\n channel_sum.blue+=r[width-1].blue;\n channel_sum.opacity+=r[width-1].opacity;\n if (image->colorspace == CMYKColorspace)\n channel_sum.index=(MagickRealType) GetPixelIndex(indexes+x+(r-p)+\n width-1);\n r+=image->columns+width;\n }\n mean.red=(MagickRealType) (channel_sum.red/number_pixels+offset);\n mean.green=(MagickRealType) (channel_sum.green/number_pixels+offset);\n mean.blue=(MagickRealType) (channel_sum.blue/number_pixels+offset);\n mean.opacity=(MagickRealType) (channel_sum.opacity/number_pixels+offset);\n if (image->colorspace == CMYKColorspace)\n mean.index=(MagickRealType) (channel_sum.index/number_pixels+offset);\n SetPixelRed(q,((MagickRealType) GetPixelRed(q) <= mean.red) ?\n 0 : QuantumRange);\n SetPixelGreen(q,((MagickRealType) GetPixelGreen(q) <= mean.green) ?\n 0 : QuantumRange);\n SetPixelBlue(q,((MagickRealType) GetPixelBlue(q) <= mean.blue) ?\n 0 : QuantumRange);\n SetPixelOpacity(q,((MagickRealType) GetPixelOpacity(q) <= mean.opacity) ?\n 0 : QuantumRange);\n if (image->colorspace == CMYKColorspace)\n SetPixelIndex(threshold_indexes+x,(((MagickRealType) GetPixelIndex(\n threshold_indexes+x) <= mean.index) ? 0 : QuantumRange));\n p++;\n q++;\n }\n sync=SyncCacheViewAuthenticPixels(threshold_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 atomic\n#endif\n progress++;\n proceed=SetImageProgress(image,ThresholdImageTag,progress,image->rows);\n if (proceed == MagickFalse)\n status=MagickFalse;\n }\n }\n threshold_view=DestroyCacheView(threshold_view);\n image_view=DestroyCacheView(image_view);\n if (status == MagickFalse)\n threshold_image=DestroyImage(threshold_image);\n return(threshold_image);\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 928,
"char_start": 881,
"chars": "width == 0)\n return(threshold_image);\n if ("
}
],
"deleted": []
},
"commit_link": "github.com/ImageMagick/ImageMagick6/commit/55e6dc49f1a381d9d511ee2f888fdc3e3c3e3953",
"file_name": "magick/threshold.c",
"func_name": "AdaptiveThresholdImage",
"line_changes": {
"added": [
{
"char_end": 893,
"char_start": 875,
"line": " if (width == 0)\n",
"line_no": 38
},
{
"char_end": 922,
"char_start": 893,
"line": " return(threshold_image);\n",
"line_no": 39
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 375 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"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);",
" if ((format-1) >= EXIF_NUM_FORMATS)",
" 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);\n if ((size_t) (offset+number_bytes) > length)\n 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}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 2784,
"char_start": 2767,
"chars": " < 0) || ((format"
},
{
"char_end": 2808,
"char_start": 2807,
"chars": ")"
}
],
"deleted": []
},
"commit_link": "github.com/ImageMagick/ImageMagick/commit/a7bb158b7bedd1449a34432feb3a67c8f1873bfa",
"file_name": "MagickCore/profile.c",
"func_name": "SyncExifProfile",
"line_changes": {
"added": [
{
"char_end": 2810,
"char_start": 2750,
"line": " if ((format < 0) || ((format-1) >= EXIF_NUM_FORMATS))\n",
"line_no": 125
}
],
"deleted": [
{
"char_end": 2792,
"char_start": 2750,
"line": " if ((format-1) >= EXIF_NUM_FORMATS)\n",
"line_no": 125
}
]
},
"vul_type": "cwe-125"
} | 376 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"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);",
" if ((format < 0) || ((format-1) >= EXIF_NUM_FORMATS))",
" 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);\n if ((size_t) (offset+number_bytes) > length)\n 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}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 2784,
"char_start": 2767,
"chars": " < 0) || ((format"
},
{
"char_end": 2808,
"char_start": 2807,
"chars": ")"
}
],
"deleted": []
},
"commit_link": "github.com/ImageMagick/ImageMagick/commit/a7bb158b7bedd1449a34432feb3a67c8f1873bfa",
"file_name": "MagickCore/profile.c",
"func_name": "SyncExifProfile",
"line_changes": {
"added": [
{
"char_end": 2810,
"char_start": 2750,
"line": " if ((format < 0) || ((format-1) >= EXIF_NUM_FORMATS))\n",
"line_no": 125
}
],
"deleted": [
{
"char_end": 2792,
"char_start": 2750,
"line": " if ((format-1) >= EXIF_NUM_FORMATS)\n",
"line_no": 125
}
]
},
"vul_type": "cwe-125"
} | 376 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static int ng_pkt(git_pkt **out, const char *line, size_t len)\n{\n\tgit_pkt_ng *pkt;\n\tconst char *ptr;\n\tsize_t alloclen;",
"\tpkt = git__malloc(sizeof(*pkt));\n\tGITERR_CHECK_ALLOC(pkt);",
"\tpkt->ref = NULL;\n\tpkt->type = GIT_PKT_NG;\n",
"",
"\tline += 3; /* skip \"ng \" */",
"\tif (!(ptr = strchr(line, ' ')))",
"\t\tgoto out_err;\n\tlen = ptr - line;",
"\tGITERR_CHECK_ALLOC_ADD(&alloclen, len, 1);\n\tpkt->ref = git__malloc(alloclen);\n\tGITERR_CHECK_ALLOC(pkt->ref);",
"\tmemcpy(pkt->ref, line, len);\n\tpkt->ref[len] = '\\0';\n",
"",
"\tline = ptr + 1;",
"\tif (!(ptr = strchr(line, '\\n')))",
"\t\tgoto out_err;\n\tlen = ptr - line;",
"\tGITERR_CHECK_ALLOC_ADD(&alloclen, len, 1);\n\tpkt->msg = git__malloc(alloclen);\n\tGITERR_CHECK_ALLOC(pkt->msg);",
"\tmemcpy(pkt->msg, line, len);\n\tpkt->msg[len] = '\\0';",
"\t*out = (git_pkt *)pkt;\n\treturn 0;",
"out_err:\n\tgiterr_set(GITERR_NET, \"invalid packet line\");\n\tgit__free(pkt->ref);\n\tgit__free(pkt);\n\treturn -1;\n}"
] | [
1,
1,
1,
0,
1,
0,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 256,
"char_start": 226,
"chars": "if (len < 3)\n\t\tgoto out_err;\n\t"
},
{
"char_end": 296,
"char_start": 285,
"chars": "len -= 3;\n\t"
},
{
"char_end": 311,
"char_start": 308,
"chars": "mem"
},
{
"char_end": 329,
"char_start": 324,
"chars": ", len"
},
{
"char_end": 565,
"char_start": 535,
"chars": "if (len < 1)\n\t\tgoto out_err;\n\t"
},
{
"char_end": 593,
"char_start": 582,
"chars": "len -= 1;\n\t"
},
{
"char_end": 608,
"char_start": 605,
"chars": "mem"
},
{
"char_end": 627,
"char_start": 622,
"chars": ", len"
}
],
"deleted": [
{
"char_end": 270,
"char_start": 267,
"chars": "str"
},
{
"char_end": 521,
"char_start": 518,
"chars": "str"
}
]
},
"commit_link": "github.com/libgit2/libgit2/commit/1f9a8510e1d2f20ed7334eeeddb92c4dd8e7c649",
"file_name": "src/transports/smart_pkt.c",
"func_name": "ng_pkt",
"line_changes": {
"added": [
{
"char_end": 239,
"char_start": 225,
"line": "\tif (len < 3)\n",
"line_no": 13
},
{
"char_end": 255,
"char_start": 239,
"line": "\t\tgoto out_err;\n",
"line_no": 14
},
{
"char_end": 295,
"char_start": 284,
"line": "\tlen -= 3;\n",
"line_no": 16
},
{
"char_end": 333,
"char_start": 295,
"line": "\tif (!(ptr = memchr(line, ' ', len)))\n",
"line_no": 17
},
{
"char_end": 548,
"char_start": 534,
"line": "\tif (len < 1)\n",
"line_no": 28
},
{
"char_end": 564,
"char_start": 548,
"line": "\t\tgoto out_err;\n",
"line_no": 29
},
{
"char_end": 592,
"char_start": 581,
"line": "\tlen -= 1;\n",
"line_no": 31
},
{
"char_end": 631,
"char_start": 592,
"line": "\tif (!(ptr = memchr(line, '\\n', len)))\n",
"line_no": 32
}
],
"deleted": [
{
"char_end": 287,
"char_start": 254,
"line": "\tif (!(ptr = strchr(line, ' ')))\n",
"line_no": 14
},
{
"char_end": 539,
"char_start": 505,
"line": "\tif (!(ptr = strchr(line, '\\n')))\n",
"line_no": 26
}
]
},
"vul_type": "cwe-125"
} | 377 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static int ng_pkt(git_pkt **out, const char *line, size_t len)\n{\n\tgit_pkt_ng *pkt;\n\tconst char *ptr;\n\tsize_t alloclen;",
"\tpkt = git__malloc(sizeof(*pkt));\n\tGITERR_CHECK_ALLOC(pkt);",
"\tpkt->ref = NULL;\n\tpkt->type = GIT_PKT_NG;\n",
"\tif (len < 3)\n\t\tgoto out_err;",
"\tline += 3; /* skip \"ng \" */",
"\tlen -= 3;\n\tif (!(ptr = memchr(line, ' ', len)))",
"\t\tgoto out_err;\n\tlen = ptr - line;",
"\tGITERR_CHECK_ALLOC_ADD(&alloclen, len, 1);\n\tpkt->ref = git__malloc(alloclen);\n\tGITERR_CHECK_ALLOC(pkt->ref);",
"\tmemcpy(pkt->ref, line, len);\n\tpkt->ref[len] = '\\0';\n",
"\tif (len < 1)\n\t\tgoto out_err;",
"\tline = ptr + 1;",
"\tlen -= 1;\n\tif (!(ptr = memchr(line, '\\n', len)))",
"\t\tgoto out_err;\n\tlen = ptr - line;",
"\tGITERR_CHECK_ALLOC_ADD(&alloclen, len, 1);\n\tpkt->msg = git__malloc(alloclen);\n\tGITERR_CHECK_ALLOC(pkt->msg);",
"\tmemcpy(pkt->msg, line, len);\n\tpkt->msg[len] = '\\0';",
"\t*out = (git_pkt *)pkt;\n\treturn 0;",
"out_err:\n\tgiterr_set(GITERR_NET, \"invalid packet line\");\n\tgit__free(pkt->ref);\n\tgit__free(pkt);\n\treturn -1;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 256,
"char_start": 226,
"chars": "if (len < 3)\n\t\tgoto out_err;\n\t"
},
{
"char_end": 296,
"char_start": 285,
"chars": "len -= 3;\n\t"
},
{
"char_end": 311,
"char_start": 308,
"chars": "mem"
},
{
"char_end": 329,
"char_start": 324,
"chars": ", len"
},
{
"char_end": 565,
"char_start": 535,
"chars": "if (len < 1)\n\t\tgoto out_err;\n\t"
},
{
"char_end": 593,
"char_start": 582,
"chars": "len -= 1;\n\t"
},
{
"char_end": 608,
"char_start": 605,
"chars": "mem"
},
{
"char_end": 627,
"char_start": 622,
"chars": ", len"
}
],
"deleted": [
{
"char_end": 270,
"char_start": 267,
"chars": "str"
},
{
"char_end": 521,
"char_start": 518,
"chars": "str"
}
]
},
"commit_link": "github.com/libgit2/libgit2/commit/1f9a8510e1d2f20ed7334eeeddb92c4dd8e7c649",
"file_name": "src/transports/smart_pkt.c",
"func_name": "ng_pkt",
"line_changes": {
"added": [
{
"char_end": 239,
"char_start": 225,
"line": "\tif (len < 3)\n",
"line_no": 13
},
{
"char_end": 255,
"char_start": 239,
"line": "\t\tgoto out_err;\n",
"line_no": 14
},
{
"char_end": 295,
"char_start": 284,
"line": "\tlen -= 3;\n",
"line_no": 16
},
{
"char_end": 333,
"char_start": 295,
"line": "\tif (!(ptr = memchr(line, ' ', len)))\n",
"line_no": 17
},
{
"char_end": 548,
"char_start": 534,
"line": "\tif (len < 1)\n",
"line_no": 28
},
{
"char_end": 564,
"char_start": 548,
"line": "\t\tgoto out_err;\n",
"line_no": 29
},
{
"char_end": 592,
"char_start": 581,
"line": "\tlen -= 1;\n",
"line_no": 31
},
{
"char_end": 631,
"char_start": 592,
"line": "\tif (!(ptr = memchr(line, '\\n', len)))\n",
"line_no": 32
}
],
"deleted": [
{
"char_end": 287,
"char_start": 254,
"line": "\tif (!(ptr = strchr(line, ' ')))\n",
"line_no": 14
},
{
"char_end": 539,
"char_start": 505,
"line": "\tif (!(ptr = strchr(line, '\\n')))\n",
"line_no": 26
}
]
},
"vul_type": "cwe-125"
} | 377 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"lha_read_file_header_1(struct archive_read *a, struct lha *lha)\n{\n\tconst unsigned char *p;\n\tsize_t extdsize;\n\tint i, err, err2;\n\tint namelen, padding;\n\tunsigned char headersum, sum_calculated;",
"\terr = ARCHIVE_OK;",
"\tif ((p = __archive_read_ahead(a, H1_FIXED_SIZE, NULL)) == NULL)\n\t\treturn (truncated_error(a));",
"\tlha->header_size = p[H1_HEADER_SIZE_OFFSET] + 2;\n\theadersum = p[H1_HEADER_SUM_OFFSET];\n\t/* Note: An extended header size is included in a compsize. */\n\tlha->compsize = archive_le32dec(p + H1_COMP_SIZE_OFFSET);\n\tlha->origsize = archive_le32dec(p + H1_ORIG_SIZE_OFFSET);\n\tlha->mtime = lha_dos_time(p + H1_DOS_TIME_OFFSET);\n\tnamelen = p[H1_NAME_LEN_OFFSET];\n\t/* Calculate a padding size. The result will be normally 0 only(?) */\n\tpadding = ((int)lha->header_size) - H1_FIXED_SIZE - namelen;",
"\tif (namelen > 230 || padding < 0)\n\t\tgoto invalid;",
"\tif ((p = __archive_read_ahead(a, lha->header_size, NULL)) == NULL)\n\t\treturn (truncated_error(a));",
"\tfor (i = 0; i < namelen; i++) {\n\t\tif (p[i + H1_FILE_NAME_OFFSET] == 0xff)\n\t\t\tgoto invalid;/* Invalid filename. */\n\t}\n\tarchive_strncpy(&lha->filename, p + H1_FILE_NAME_OFFSET, namelen);\n\tlha->crc = archive_le16dec(p + H1_FILE_NAME_OFFSET + namelen);\n\tlha->setflag |= CRC_IS_SET;",
"\tsum_calculated = lha_calcsum(0, p, 2, lha->header_size - 2);\n\t/* Consume used bytes but not include `next header size' data\n\t * since it will be consumed in lha_read_file_extended_header(). */\n\t__archive_read_consume(a, lha->header_size - 2);",
"\t/* Read extended headers */\n\terr2 = lha_read_file_extended_header(a, lha, NULL, 2,\n\t (size_t)(lha->compsize + 2), &extdsize);\n\tif (err2 < ARCHIVE_WARN)\n\t\treturn (err2);\n\tif (err2 < err)\n\t\terr = err2;\n\t/* Get a real compressed file size. */\n\tlha->compsize -= extdsize - 2;\n",
"",
"\tif (sum_calculated != headersum) {\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t \"LHa header sum error\");\n\t\treturn (ARCHIVE_FATAL);\n\t}\n\treturn (err);\ninvalid:\n\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,\n\t \"Invalid LHa header\");\n\treturn (ARCHIVE_FATAL);\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1836,
"char_start": 1760,
"chars": "lha->compsize < 0)\n\t\tgoto invalid;\t/* Invalid compressed file size */\n\n\tif ("
}
],
"deleted": []
},
"commit_link": "github.com/libarchive/libarchive/commit/98dcbbf0bf4854bf987557e55e55fff7abbf3ea9",
"file_name": "libarchive/archive_read_support_format_lha.c",
"func_name": "lha_read_file_header_1",
"line_changes": {
"added": [
{
"char_end": 1779,
"char_start": 1755,
"line": "\tif (lha->compsize < 0)\n",
"line_no": 53
},
{
"char_end": 1830,
"char_start": 1779,
"line": "\t\tgoto invalid;\t/* Invalid compressed file size */\n",
"line_no": 54
},
{
"char_end": 1831,
"char_start": 1830,
"line": "\n",
"line_no": 55
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 378 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"lha_read_file_header_1(struct archive_read *a, struct lha *lha)\n{\n\tconst unsigned char *p;\n\tsize_t extdsize;\n\tint i, err, err2;\n\tint namelen, padding;\n\tunsigned char headersum, sum_calculated;",
"\terr = ARCHIVE_OK;",
"\tif ((p = __archive_read_ahead(a, H1_FIXED_SIZE, NULL)) == NULL)\n\t\treturn (truncated_error(a));",
"\tlha->header_size = p[H1_HEADER_SIZE_OFFSET] + 2;\n\theadersum = p[H1_HEADER_SUM_OFFSET];\n\t/* Note: An extended header size is included in a compsize. */\n\tlha->compsize = archive_le32dec(p + H1_COMP_SIZE_OFFSET);\n\tlha->origsize = archive_le32dec(p + H1_ORIG_SIZE_OFFSET);\n\tlha->mtime = lha_dos_time(p + H1_DOS_TIME_OFFSET);\n\tnamelen = p[H1_NAME_LEN_OFFSET];\n\t/* Calculate a padding size. The result will be normally 0 only(?) */\n\tpadding = ((int)lha->header_size) - H1_FIXED_SIZE - namelen;",
"\tif (namelen > 230 || padding < 0)\n\t\tgoto invalid;",
"\tif ((p = __archive_read_ahead(a, lha->header_size, NULL)) == NULL)\n\t\treturn (truncated_error(a));",
"\tfor (i = 0; i < namelen; i++) {\n\t\tif (p[i + H1_FILE_NAME_OFFSET] == 0xff)\n\t\t\tgoto invalid;/* Invalid filename. */\n\t}\n\tarchive_strncpy(&lha->filename, p + H1_FILE_NAME_OFFSET, namelen);\n\tlha->crc = archive_le16dec(p + H1_FILE_NAME_OFFSET + namelen);\n\tlha->setflag |= CRC_IS_SET;",
"\tsum_calculated = lha_calcsum(0, p, 2, lha->header_size - 2);\n\t/* Consume used bytes but not include `next header size' data\n\t * since it will be consumed in lha_read_file_extended_header(). */\n\t__archive_read_consume(a, lha->header_size - 2);",
"\t/* Read extended headers */\n\terr2 = lha_read_file_extended_header(a, lha, NULL, 2,\n\t (size_t)(lha->compsize + 2), &extdsize);\n\tif (err2 < ARCHIVE_WARN)\n\t\treturn (err2);\n\tif (err2 < err)\n\t\terr = err2;\n\t/* Get a real compressed file size. */\n\tlha->compsize -= extdsize - 2;\n",
"\tif (lha->compsize < 0)\n\t\tgoto invalid;\t/* Invalid compressed file size */\n",
"\tif (sum_calculated != headersum) {\n\t\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,\n\t\t \"LHa header sum error\");\n\t\treturn (ARCHIVE_FATAL);\n\t}\n\treturn (err);\ninvalid:\n\tarchive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,\n\t \"Invalid LHa header\");\n\treturn (ARCHIVE_FATAL);\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1836,
"char_start": 1760,
"chars": "lha->compsize < 0)\n\t\tgoto invalid;\t/* Invalid compressed file size */\n\n\tif ("
}
],
"deleted": []
},
"commit_link": "github.com/libarchive/libarchive/commit/98dcbbf0bf4854bf987557e55e55fff7abbf3ea9",
"file_name": "libarchive/archive_read_support_format_lha.c",
"func_name": "lha_read_file_header_1",
"line_changes": {
"added": [
{
"char_end": 1779,
"char_start": 1755,
"line": "\tif (lha->compsize < 0)\n",
"line_no": 53
},
{
"char_end": 1830,
"char_start": 1779,
"line": "\t\tgoto invalid;\t/* Invalid compressed file size */\n",
"line_no": 54
},
{
"char_end": 1831,
"char_start": 1830,
"line": "\n",
"line_no": 55
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 378 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)\n{\n AC3HeaderInfo *hdr = NULL;\n struct eac3_info *info;\n int num_blocks, ret;",
" if (!track->eac3_priv && !(track->eac3_priv = av_mallocz(sizeof(*info))))\n return AVERROR(ENOMEM);\n info = track->eac3_priv;",
" if (avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) < 0) {\n /* drop the packets until we see a good one */\n if (!track->entry) {\n av_log(mov, AV_LOG_WARNING, \"Dropping invalid packet from start of the stream\\n\");\n ret = 0;\n } else\n ret = AVERROR_INVALIDDATA;\n goto end;\n }",
" info->data_rate = FFMAX(info->data_rate, hdr->bit_rate / 1000);\n num_blocks = hdr->num_blocks;",
" if (!info->ec3_done) {\n /* AC-3 substream must be the first one */\n if (hdr->bitstream_id <= 10 && hdr->substreamid != 0) {\n ret = AVERROR(EINVAL);\n goto end;\n }",
" /* this should always be the case, given that our AC-3 parser\n * concatenates dependent frames to their independent parent */\n if (hdr->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {\n /* substream ids must be incremental */\n if (hdr->substreamid > info->num_ind_sub + 1) {\n ret = AVERROR(EINVAL);\n goto end;\n }",
" if (hdr->substreamid == info->num_ind_sub + 1) {\n //info->num_ind_sub++;",
" avpriv_request_sample(track->par, \"Multiple independent substreams\");",
" ret = AVERROR_PATCHWELCOME;\n goto end;\n } else if (hdr->substreamid < info->num_ind_sub ||\n hdr->substreamid == 0 && info->substream[0].bsid) {\n info->ec3_done = 1;\n goto concatenate;\n }\n } else {\n if (hdr->substreamid != 0) {\n avpriv_request_sample(mov->fc, \"Multiple non EAC3 independent substreams\");\n ret = AVERROR_PATCHWELCOME;\n goto end;\n }\n }",
" /* fill the info needed for the \"dec3\" atom */\n info->substream[hdr->substreamid].fscod = hdr->sr_code;\n info->substream[hdr->substreamid].bsid = hdr->bitstream_id;\n info->substream[hdr->substreamid].bsmod = hdr->bitstream_mode;\n info->substream[hdr->substreamid].acmod = hdr->channel_mode;\n info->substream[hdr->substreamid].lfeon = hdr->lfe_on;",
" /* Parse dependent substream(s), if any */\n if (pkt->size != hdr->frame_size) {\n int cumul_size = hdr->frame_size;\n int parent = hdr->substreamid;",
" while (cumul_size != pkt->size) {\n GetBitContext gbc;\n int i;\n ret = avpriv_ac3_parse_header(&hdr, pkt->data + cumul_size, pkt->size - cumul_size);\n if (ret < 0)\n goto end;\n if (hdr->frame_type != EAC3_FRAME_TYPE_DEPENDENT) {\n ret = AVERROR(EINVAL);\n goto end;\n }\n info->substream[parent].num_dep_sub++;\n ret /= 8;",
" /* header is parsed up to lfeon, but custom channel map may be needed */\n init_get_bits8(&gbc, pkt->data + cumul_size + ret, pkt->size - cumul_size - ret);\n /* skip bsid */\n skip_bits(&gbc, 5);\n /* skip volume control params */\n for (i = 0; i < (hdr->channel_mode ? 1 : 2); i++) {\n skip_bits(&gbc, 5); // skip dialog normalization\n if (get_bits1(&gbc)) {\n skip_bits(&gbc, 8); // skip compression gain word\n }\n }\n /* get the dependent stream channel map, if exists */\n if (get_bits1(&gbc))\n info->substream[parent].chan_loc |= (get_bits(&gbc, 16) >> 5) & 0x1f;\n else\n info->substream[parent].chan_loc |= hdr->channel_mode;\n cumul_size += hdr->frame_size;\n }\n }\n }",
"concatenate:\n if (!info->num_blocks && num_blocks == 6) {\n ret = pkt->size;\n goto end;\n }\n else if (info->num_blocks + num_blocks > 6) {\n ret = AVERROR_INVALIDDATA;\n goto end;\n }",
" if (!info->num_blocks) {\n ret = av_packet_ref(&info->pkt, pkt);\n if (!ret)\n info->num_blocks = num_blocks;\n goto end;\n } else {\n if ((ret = av_grow_packet(&info->pkt, pkt->size)) < 0)\n goto end;\n memcpy(info->pkt.data + info->pkt.size - pkt->size, pkt->data, pkt->size);\n info->num_blocks += num_blocks;\n info->pkt.duration += pkt->duration;\n if ((ret = av_copy_packet_side_data(&info->pkt, pkt)) < 0)\n goto end;\n if (info->num_blocks != 6)\n goto end;\n av_packet_unref(pkt);\n av_packet_move_ref(pkt, &info->pkt);\n info->num_blocks = 0;\n }\n ret = pkt->size;",
"end:\n av_free(hdr);",
" return ret;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1498,
"char_start": 1495,
"chars": "mov"
},
{
"char_end": 1502,
"char_start": 1500,
"chars": "fc"
}
],
"deleted": [
{
"char_end": 1500,
"char_start": 1495,
"chars": "track"
},
{
"char_end": 1505,
"char_start": 1502,
"chars": "par"
}
]
},
"commit_link": "github.com/FFmpeg/FFmpeg/commit/95556e27e2c1d56d9e18f5db34d6f756f3011148",
"file_name": "libavformat/movenc.c",
"func_name": "handle_eac3",
"line_changes": {
"added": [
{
"char_end": 1540,
"char_start": 1457,
"line": " avpriv_request_sample(mov->fc, \"Multiple independent substreams\");\n",
"line_no": 42
}
],
"deleted": [
{
"char_end": 1543,
"char_start": 1457,
"line": " avpriv_request_sample(track->par, \"Multiple independent substreams\");\n",
"line_no": 42
}
]
},
"vul_type": "cwe-125"
} | 379 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)\n{\n AC3HeaderInfo *hdr = NULL;\n struct eac3_info *info;\n int num_blocks, ret;",
" if (!track->eac3_priv && !(track->eac3_priv = av_mallocz(sizeof(*info))))\n return AVERROR(ENOMEM);\n info = track->eac3_priv;",
" if (avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) < 0) {\n /* drop the packets until we see a good one */\n if (!track->entry) {\n av_log(mov, AV_LOG_WARNING, \"Dropping invalid packet from start of the stream\\n\");\n ret = 0;\n } else\n ret = AVERROR_INVALIDDATA;\n goto end;\n }",
" info->data_rate = FFMAX(info->data_rate, hdr->bit_rate / 1000);\n num_blocks = hdr->num_blocks;",
" if (!info->ec3_done) {\n /* AC-3 substream must be the first one */\n if (hdr->bitstream_id <= 10 && hdr->substreamid != 0) {\n ret = AVERROR(EINVAL);\n goto end;\n }",
" /* this should always be the case, given that our AC-3 parser\n * concatenates dependent frames to their independent parent */\n if (hdr->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {\n /* substream ids must be incremental */\n if (hdr->substreamid > info->num_ind_sub + 1) {\n ret = AVERROR(EINVAL);\n goto end;\n }",
" if (hdr->substreamid == info->num_ind_sub + 1) {\n //info->num_ind_sub++;",
" avpriv_request_sample(mov->fc, \"Multiple independent substreams\");",
" ret = AVERROR_PATCHWELCOME;\n goto end;\n } else if (hdr->substreamid < info->num_ind_sub ||\n hdr->substreamid == 0 && info->substream[0].bsid) {\n info->ec3_done = 1;\n goto concatenate;\n }\n } else {\n if (hdr->substreamid != 0) {\n avpriv_request_sample(mov->fc, \"Multiple non EAC3 independent substreams\");\n ret = AVERROR_PATCHWELCOME;\n goto end;\n }\n }",
" /* fill the info needed for the \"dec3\" atom */\n info->substream[hdr->substreamid].fscod = hdr->sr_code;\n info->substream[hdr->substreamid].bsid = hdr->bitstream_id;\n info->substream[hdr->substreamid].bsmod = hdr->bitstream_mode;\n info->substream[hdr->substreamid].acmod = hdr->channel_mode;\n info->substream[hdr->substreamid].lfeon = hdr->lfe_on;",
" /* Parse dependent substream(s), if any */\n if (pkt->size != hdr->frame_size) {\n int cumul_size = hdr->frame_size;\n int parent = hdr->substreamid;",
" while (cumul_size != pkt->size) {\n GetBitContext gbc;\n int i;\n ret = avpriv_ac3_parse_header(&hdr, pkt->data + cumul_size, pkt->size - cumul_size);\n if (ret < 0)\n goto end;\n if (hdr->frame_type != EAC3_FRAME_TYPE_DEPENDENT) {\n ret = AVERROR(EINVAL);\n goto end;\n }\n info->substream[parent].num_dep_sub++;\n ret /= 8;",
" /* header is parsed up to lfeon, but custom channel map may be needed */\n init_get_bits8(&gbc, pkt->data + cumul_size + ret, pkt->size - cumul_size - ret);\n /* skip bsid */\n skip_bits(&gbc, 5);\n /* skip volume control params */\n for (i = 0; i < (hdr->channel_mode ? 1 : 2); i++) {\n skip_bits(&gbc, 5); // skip dialog normalization\n if (get_bits1(&gbc)) {\n skip_bits(&gbc, 8); // skip compression gain word\n }\n }\n /* get the dependent stream channel map, if exists */\n if (get_bits1(&gbc))\n info->substream[parent].chan_loc |= (get_bits(&gbc, 16) >> 5) & 0x1f;\n else\n info->substream[parent].chan_loc |= hdr->channel_mode;\n cumul_size += hdr->frame_size;\n }\n }\n }",
"concatenate:\n if (!info->num_blocks && num_blocks == 6) {\n ret = pkt->size;\n goto end;\n }\n else if (info->num_blocks + num_blocks > 6) {\n ret = AVERROR_INVALIDDATA;\n goto end;\n }",
" if (!info->num_blocks) {\n ret = av_packet_ref(&info->pkt, pkt);\n if (!ret)\n info->num_blocks = num_blocks;\n goto end;\n } else {\n if ((ret = av_grow_packet(&info->pkt, pkt->size)) < 0)\n goto end;\n memcpy(info->pkt.data + info->pkt.size - pkt->size, pkt->data, pkt->size);\n info->num_blocks += num_blocks;\n info->pkt.duration += pkt->duration;\n if ((ret = av_copy_packet_side_data(&info->pkt, pkt)) < 0)\n goto end;\n if (info->num_blocks != 6)\n goto end;\n av_packet_unref(pkt);\n av_packet_move_ref(pkt, &info->pkt);\n info->num_blocks = 0;\n }\n ret = pkt->size;",
"end:\n av_free(hdr);",
" return ret;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1498,
"char_start": 1495,
"chars": "mov"
},
{
"char_end": 1502,
"char_start": 1500,
"chars": "fc"
}
],
"deleted": [
{
"char_end": 1500,
"char_start": 1495,
"chars": "track"
},
{
"char_end": 1505,
"char_start": 1502,
"chars": "par"
}
]
},
"commit_link": "github.com/FFmpeg/FFmpeg/commit/95556e27e2c1d56d9e18f5db34d6f756f3011148",
"file_name": "libavformat/movenc.c",
"func_name": "handle_eac3",
"line_changes": {
"added": [
{
"char_end": 1540,
"char_start": 1457,
"line": " avpriv_request_sample(mov->fc, \"Multiple independent substreams\");\n",
"line_no": 42
}
],
"deleted": [
{
"char_end": 1543,
"char_start": 1457,
"line": " avpriv_request_sample(track->par, \"Multiple independent substreams\");\n",
"line_no": 42
}
]
},
"vul_type": "cwe-125"
} | 379 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static void set_fdc(int drive)\n{",
"",
"\tif (drive >= 0 && drive < N_DRIVE) {",
"\t\tfdc = FDC(drive);",
"\t\tcurrent_drive = drive;\n\t}",
"\tif (fdc != 1 && fdc != 0) {",
"\t\tpr_info(\"bad fdc value\\n\");\n\t\treturn;\n\t}",
"",
"\tset_dor(fdc, ~0, 8);\n#if N_FDC > 1\n\tset_dor(1 - fdc, ~8, 0);\n#endif\n\tif (FDCS->rawcmd == 2)\n\t\treset_fdc_info(1);\n\tif (fd_inb(FD_STATUS) != STATUS_READY)\n\t\tFDCS->reset = 1;\n}"
] | [
1,
0,
1,
0,
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 64,
"char_start": 34,
"chars": "unsigned int new_fdc = fdc;\n\n\t"
},
{
"char_end": 107,
"char_start": 103,
"chars": "new_"
},
{
"char_end": 162,
"char_start": 158,
"chars": "new_"
},
{
"char_end": 167,
"char_start": 166,
"chars": ">"
},
{
"char_end": 174,
"char_start": 169,
"chars": "N_FDC"
},
{
"char_end": 236,
"char_start": 220,
"chars": "\n\tfdc = new_fdc;"
}
],
"deleted": [
{
"char_end": 129,
"char_start": 128,
"chars": "!"
},
{
"char_end": 144,
"char_start": 131,
"chars": "1 && fdc != 0"
}
]
},
"commit_link": "github.com/torvalds/linux/commit/2e90ca68b0d2f5548804f22f0dd61145516171e3",
"file_name": "drivers/block/floppy.c",
"func_name": "set_fdc",
"line_changes": {
"added": [
{
"char_end": 62,
"char_start": 33,
"line": "\tunsigned int new_fdc = fdc;\n",
"line_no": 3
},
{
"char_end": 63,
"char_start": 62,
"line": "\n",
"line_no": 4
},
{
"char_end": 125,
"char_start": 101,
"line": "\t\tnew_fdc = FDC(drive);\n",
"line_no": 6
},
{
"char_end": 178,
"char_start": 153,
"line": "\tif (new_fdc >= N_FDC) {\n",
"line_no": 9
},
{
"char_end": 237,
"char_start": 221,
"line": "\tfdc = new_fdc;\n",
"line_no": 13
}
],
"deleted": [
{
"char_end": 91,
"char_start": 71,
"line": "\t\tfdc = FDC(drive);\n",
"line_no": 4
},
{
"char_end": 148,
"char_start": 119,
"line": "\tif (fdc != 1 && fdc != 0) {\n",
"line_no": 7
}
]
},
"vul_type": "cwe-125"
} | 380 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static void set_fdc(int drive)\n{",
"\tunsigned int new_fdc = fdc;\n",
"\tif (drive >= 0 && drive < N_DRIVE) {",
"\t\tnew_fdc = FDC(drive);",
"\t\tcurrent_drive = drive;\n\t}",
"\tif (new_fdc >= N_FDC) {",
"\t\tpr_info(\"bad fdc value\\n\");\n\t\treturn;\n\t}",
"\tfdc = new_fdc;",
"\tset_dor(fdc, ~0, 8);\n#if N_FDC > 1\n\tset_dor(1 - fdc, ~8, 0);\n#endif\n\tif (FDCS->rawcmd == 2)\n\t\treset_fdc_info(1);\n\tif (fd_inb(FD_STATUS) != STATUS_READY)\n\t\tFDCS->reset = 1;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 64,
"char_start": 34,
"chars": "unsigned int new_fdc = fdc;\n\n\t"
},
{
"char_end": 107,
"char_start": 103,
"chars": "new_"
},
{
"char_end": 162,
"char_start": 158,
"chars": "new_"
},
{
"char_end": 167,
"char_start": 166,
"chars": ">"
},
{
"char_end": 174,
"char_start": 169,
"chars": "N_FDC"
},
{
"char_end": 236,
"char_start": 220,
"chars": "\n\tfdc = new_fdc;"
}
],
"deleted": [
{
"char_end": 129,
"char_start": 128,
"chars": "!"
},
{
"char_end": 144,
"char_start": 131,
"chars": "1 && fdc != 0"
}
]
},
"commit_link": "github.com/torvalds/linux/commit/2e90ca68b0d2f5548804f22f0dd61145516171e3",
"file_name": "drivers/block/floppy.c",
"func_name": "set_fdc",
"line_changes": {
"added": [
{
"char_end": 62,
"char_start": 33,
"line": "\tunsigned int new_fdc = fdc;\n",
"line_no": 3
},
{
"char_end": 63,
"char_start": 62,
"line": "\n",
"line_no": 4
},
{
"char_end": 125,
"char_start": 101,
"line": "\t\tnew_fdc = FDC(drive);\n",
"line_no": 6
},
{
"char_end": 178,
"char_start": 153,
"line": "\tif (new_fdc >= N_FDC) {\n",
"line_no": 9
},
{
"char_end": 237,
"char_start": 221,
"line": "\tfdc = new_fdc;\n",
"line_no": 13
}
],
"deleted": [
{
"char_end": 91,
"char_start": 71,
"line": "\t\tfdc = FDC(drive);\n",
"line_no": 4
},
{
"char_end": 148,
"char_start": 119,
"line": "\tif (fdc != 1 && fdc != 0) {\n",
"line_no": 7
}
]
},
"vul_type": "cwe-125"
} | 380 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static int opmov(RAsm *a, ut8 *data, const Opcode *op) {\n\tint l = 0;\n\tst64 offset = 0;\n\tint mod = 0;\n\tint base = 0;\n\tint rex = 0;\n\tut64 immediate = 0;\n\tif (op->operands[1].type & OT_CONSTANT) {\n\t\tif (!op->operands[1].is_good_flag) {\n\t\t\treturn -1;\n\t\t}\n\t\tif (op->operands[1].immediate == -1) {\n\t\t\treturn -1;\n\t\t}\n\t\timmediate = op->operands[1].immediate * op->operands[1].sign;\n\t\tif (op->operands[0].type & OT_GPREG && !(op->operands[0].type & OT_MEMORY)) {\n\t\t\tif (a->bits == 64 && ((op->operands[0].type & OT_QWORD) | (op->operands[1].type & OT_QWORD))) {\n\t\t\t\tif (!(op->operands[1].type & OT_CONSTANT) && op->operands[1].extended) {\n\t\t\t\t\tdata[l++] = 0x49;\n\t\t\t\t} else {\n\t\t\t\t\tdata[l++] = 0x48;\n\t\t\t\t}\n\t\t\t} else if (op->operands[0].extended) {\n\t\t\t\tdata[l++] = 0x41;\n\t\t\t}\n\t\t\tif (op->operands[0].type & OT_WORD) {\n\t\t\t\tif (a->bits > 16) {\n\t\t\t\t\tdata[l++] = 0x66;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (op->operands[0].type & OT_BYTE) {\n\t\t\t\tdata[l++] = 0xb0 | op->operands[0].reg;\n\t\t\t\tdata[l++] = immediate;\n\t\t\t} else {\n\t\t\t\tif (a->bits == 64 &&\n\t\t\t\t\t((op->operands[0].type & OT_QWORD) |\n\t\t\t\t\t(op->operands[1].type & OT_QWORD)) &&\n\t\t\t\t\timmediate < UT32_MAX) {\n\t\t\t\t\t\tdata[l++] = 0xc7;\n\t\t\t\t \t\tdata[l++] = 0xc0 | op->operands[0].reg;\n\t\t\t\t} else {\n\t\t\t\t\tdata[l++] = 0xb8 | op->operands[0].reg;\n\t\t\t\t}\n\t\t\t\tdata[l++] = immediate;\n\t\t\t\tdata[l++] = immediate >> 8;\n\t\t\t\tif (!(op->operands[0].type & OT_WORD)) {\n\t\t\t\t\tdata[l++] = immediate >> 16;\n\t\t\t\t\tdata[l++] = immediate >> 24;\n\t\t\t\t}\n\t\t\t\tif (a->bits == 64 && immediate > UT32_MAX) {\n\t\t\t\t\tdata[l++] = immediate >> 32;\n\t\t\t\t\tdata[l++] = immediate >> 40;\n\t\t\t\t\tdata[l++] = immediate >> 48;\n\t\t\t\t\tdata[l++] = immediate >> 56;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (op->operands[0].type & OT_MEMORY) {\n\t\t\tif (!op->operands[0].explicit_size) {\n\t\t\t\tif (op->operands[0].type & OT_GPREG) {\n\t\t\t\t\t((Opcode *)op)->operands[0].dest_size = op->operands[0].reg_size;\n\t\t\t\t} else {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tint dest_bits = 8 * ((op->operands[0].dest_size & ALL_SIZE) >> OPSIZE_SHIFT);\n\t\t\tint reg_bits = 8 * ((op->operands[0].reg_size & ALL_SIZE) >> OPSIZE_SHIFT);\n\t\t\tint offset = op->operands[0].offset * op->operands[0].offset_sign;",
"\t\t\t//addr_size_override prefix\n\t\t\tbool use_aso = false;\n\t\t\tif (reg_bits < a->bits) {\n\t\t\t\tuse_aso = true;\n\t\t\t}",
"\t\t\t//op_size_override prefix\n\t\t\tbool use_oso = false;\n\t\t\tif (dest_bits == 16) {\n\t\t\t\tuse_oso = true;\n\t\t\t}",
"\t\t\tbool rip_rel = op->operands[0].regs[0] == X86R_RIP;",
"\t\t\t//rex prefix\n\t\t\tint rex = 1 << 6;\n\t\t\tbool use_rex = false;\n\t\t\tif (dest_bits == 64) {\t\t\t//W field\n\t\t\t\tuse_rex = true;\n\t\t\t\trex |= 1 << 3;\n\t\t\t}\n\t\t\tif (op->operands[0].extended) {\t\t//B field\n\t\t\t\tuse_rex = true;\n\t\t\t\trex |= 1;\n\t\t\t}",
"\t\t\t//opcode selection\n\t\t\tint opcode;\n\t\t\tif (dest_bits == 8) {\n\t\t\t\topcode = 0xc6;\n\t\t\t} else {\n\t\t\t\topcode = 0xc7;\n\t\t\t}",
"\t\t\t//modrm and SIB selection\n\t\t\tint modrm = 0;\n\t\t\tint mod;\n\t\t\tint reg = 0;\n\t\t\tint rm;\n\t\t\tbool use_sib = false;\n\t\t\tint sib;\n\t\t\t//mod\n\t\t\tif (offset == 0) {\n\t\t\t\tmod = 0;\n\t\t\t} else if (offset < 128 && offset > -129) {\n\t\t\t\tmod = 1;\n\t\t\t} else {\n\t\t\t\tmod = 2;\n\t\t\t}",
"\t\t\tif (reg_bits == 16) {\n\t\t\t\tif (op->operands[0].regs[0] == X86R_BX && op->operands[0].regs[1] == X86R_SI) {\n\t\t\t\t\trm = B0000;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_BX && op->operands[0].regs[1] == X86R_DI) {\n\t\t\t\t\trm = B0001;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_BP && op->operands[0].regs[1] == X86R_SI) {\n\t\t\t\t\trm = B0010;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_BP && op->operands[0].regs[1] == X86R_DI) {\n\t\t\t\t\trm = B0011;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_SI && op->operands[0].regs[1] == -1) {\n\t\t\t\t\trm = B0100;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_DI && op->operands[0].regs[1] == -1) {\n\t\t\t\t\trm = B0101;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_BX && op->operands[0].regs[1] == -1) {\n\t\t\t\t\trm = B0111;\n\t\t\t\t} else {\n\t\t\t\t\t//TODO allow for displacement only when parser is reworked\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tmodrm = (mod << 6) | (reg << 3) | rm;\n\t\t\t} else {\n\t\t\t\t//rm\n\t\t\t\tif (op->operands[0].extended) {\n\t\t\t\t\trm = op->operands[0].reg;\n\t\t\t\t} else {\n\t\t\t\t\trm = op->operands[0].regs[0];\n\t\t\t\t}\n\t\t\t\t//[epb] alone is illegal, so we need to fake a [ebp+0]\n\t\t\t\tif (rm == 5 && mod == 0) {\n\t\t\t\t\tmod = 1;\n\t\t\t\t}",
"\t\t\t\t//sib\n\t\t\t\tint index = op->operands[0].regs[1];\n\t\t\t\tint scale = getsib(op->operands[0].scale[1]);\n\t\t\t\tif (index != -1) {\n\t\t\t\t\tuse_sib = true;\n\t\t\t\t\tsib = (scale << 6) | (index << 3) | rm;\n\t\t\t\t} else if (rm == 4) {\n\t\t\t\t\tuse_sib = true;\n\t\t\t\t\tsib = 0x24;\n\t\t\t\t}\n\t\t\t\tif (use_sib) {\n\t\t\t\t\trm = B0100;\n\t\t\t\t}\n\t\t\t\tif (rip_rel) {\n\t\t\t\t\tmodrm = (B0000 << 6) | (reg << 3) | B0101;\n\t\t\t\t\tsib = (scale << 6) | (B0100 << 3) | B0101;\n\t\t\t\t} else {\n\t\t\t\t\tmodrm = (mod << 6) | (reg << 3) | rm;\n\t\t\t\t}\n\t\t\t}",
"\t\t\t//build the final result\n\t\t\tif (use_aso) {\n\t\t\t\tdata[l++] = 0x67;\n\t\t\t}\n\t\t\tif (use_oso) {\n\t\t\t\tdata[l++] = 0x66;\n\t\t\t}\n\t\t\tif (use_rex) {\n\t\t\t\tdata[l++] = rex;\n\t\t\t}\n\t\t\tdata[l++] = opcode;\n\t\t\tdata[l++] = modrm;\n\t\t\tif (use_sib) {\n\t\t\t\tdata[l++] = sib;\n\t\t\t}\n\t\t\t//offset\n\t\t\tif (mod == 1) {\n\t\t\t\tdata[l++] = offset;\n\t\t\t} else if (reg_bits == 16 && mod == 2) {\n\t\t\t\tdata[l++] = offset;\n\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t} else if (mod == 2 || rip_rel) {\n\t\t\t\tdata[l++] = offset;\n\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\tdata[l++] = offset >> 24;\n\t\t\t}\n\t\t\t//immediate\n\t\t\tint byte;\n\t\t\tfor (byte = 0; byte < dest_bits && byte < 32; byte += 8) {\n\t\t\t\tdata[l++] = (immediate >> byte);\n\t\t\t}\n\t\t}\n\t} else if (op->operands[1].type & OT_REGALL &&\n\t\t\t !(op->operands[1].type & OT_MEMORY)) {\n\t\tif (op->operands[0].type & OT_CONSTANT) {\n\t\t\treturn -1;\n\t\t}\n\t\tif (op->operands[0].type & OT_REGTYPE & OT_SEGMENTREG &&\n\t\t op->operands[1].type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\t\treturn -1;\n\t\t}\n\t\t// Check reg sizes match\n\t\tif (op->operands[0].type & OT_REGTYPE && op->operands[1].type & OT_REGTYPE) {\n\t\t\tif (!((op->operands[0].type & ALL_SIZE) &\n\t\t\t(op->operands[1].type & ALL_SIZE))) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}",
"\t\tif (a->bits == 64) {\n\t\t\tif (op->operands[0].extended) {\n\t\t\t\trex = 1;\n\t\t\t}\n\t\t\tif (op->operands[1].extended) {\n\t\t\t\trex += 4;\n\t\t\t}\n\t\t\tif (op->operands[1].type & OT_QWORD) {\n\t\t\t\tif (!(op->operands[0].type & OT_QWORD)) {\n\t\t\t\t\tdata[l++] = 0x67;\n\t\t\t\t\tdata[l++] = 0x48;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (op->operands[1].type & OT_QWORD &&\n\t\t\t\top->operands[0].type & OT_QWORD) {\n\t\t\t\tdata[l++] = 0x48 | rex;\n\t\t\t}\n\t\t\tif (op->operands[1].type & OT_DWORD &&\n\t\t\t\top->operands[0].type & OT_DWORD) {\n\t\t\t\tdata[l++] = 0x40 | rex;\n\t\t\t}\n\t\t} else if (op->operands[0].extended && op->operands[1].extended) {\n\t\t\tdata[l++] = 0x45;\n\t\t}\n\t\toffset = op->operands[0].offset * op->operands[0].offset_sign;\n\t\tif (op->operands[1].type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\tdata[l++] = 0x8c;\n\t\t} else {\n\t\t\tif (op->operands[0].type & OT_WORD) {\n\t\t\t\tdata[l++] = 0x66;\n\t\t\t}\n\t\t\tdata[l++] = (op->operands[0].type & OT_BYTE) ? 0x88 : 0x89;\n\t\t}",
"\t\tif (op->operands[0].scale[0] > 1) {\n\t\t\t\tdata[l++] = op->operands[1].reg << 3 | 4;\n\t\t\t\tdata[l++] = getsib (op->operands[0].scale[0]) << 6 |\n\t\t\t\t\t\t op->operands[0].regs[0] << 3 | 5;",
"\t\t\t\tdata[l++] = offset;\n\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\tdata[l++] = offset >> 24;",
"\t\t\t\treturn l;\n\t\t\t}",
"\t\tif (!(op->operands[0].type & OT_MEMORY)) {\n\t\t\tif (op->operands[0].reg == X86R_UNDEFINED ||\n\t\t\t\top->operands[1].reg == X86R_UNDEFINED) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tmod = 0x3;\n\t\t\tdata[l++] = mod << 6 | op->operands[1].reg << 3 | op->operands[0].reg;\n\t\t} else if (op->operands[0].regs[0] == X86R_UNDEFINED) {\n\t\t\tdata[l++] = op->operands[1].reg << 3 | 0x5;\n\t\t\tdata[l++] = offset;\n\t\t\tdata[l++] = offset >> 8;\n\t\t\tdata[l++] = offset >> 16;\n\t\t\tdata[l++] = offset >> 24;\n\t\t} else {\n\t\t\tif (op->operands[0].type & OT_MEMORY) {\n\t\t\t\tif (op->operands[0].regs[1] != X86R_UNDEFINED) {\n\t\t\t\t\tdata[l++] = op->operands[1].reg << 3 | 0x4;\n\t\t\t\t\tdata[l++] = op->operands[0].regs[1] << 3 | op->operands[0].regs[0];\n\t\t\t\t\treturn l;\n\t\t\t\t}\n\t\t\t\tif (offset) {\n\t\t\t\t\tmod = (offset > 128 || offset < -129) ? 0x2 : 0x1;\n\t\t\t\t}\n\t\t\t\tif (op->operands[0].regs[0] == X86R_EBP) {\n\t\t\t\t\tmod = 0x2;\n\t\t\t\t}\n\t\t\t\tdata[l++] = mod << 6 | op->operands[1].reg << 3 | op->operands[0].regs[0];\n\t\t\t\tif (op->operands[0].regs[0] == X86R_ESP) {\n\t\t\t\t\tdata[l++] = 0x24;\n\t\t\t\t}\n\t\t\t\tif (offset) {\n\t\t\t\t\tdata[l++] = offset;\n\t\t\t\t}\n\t\t\t\tif (mod == 2) {\n\t\t\t\t\t// warning C4293: '>>': shift count negative or too big, undefined behavior\n\t\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\t\tdata[l++] = offset >> 24;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (op->operands[1].type & OT_MEMORY) {\n\t\tif (op->operands[0].type & OT_MEMORY) {\n\t\t\treturn -1;\n\t\t}\n\t\toffset = op->operands[1].offset * op->operands[1].offset_sign;\n\t\tif (op->operands[0].reg == X86R_EAX && op->operands[1].regs[0] == X86R_UNDEFINED) {\n\t\t\tif (a->bits == 64) {\n\t\t\t\tdata[l++] = 0x48;\n\t\t\t}\n\t\t\tif (op->operands[0].type & OT_BYTE) {\n\t\t\t\tdata[l++] = 0xa0;\n\t\t\t} else {\n\t\t\t\tdata[l++] = 0xa1;\n\t\t\t}\n\t\t\tdata[l++] = offset;\n\t\t\tdata[l++] = offset >> 8;\n\t\t\tdata[l++] = offset >> 16;\n\t\t\tdata[l++] = offset >> 24;\n\t\t\tif (a->bits == 64) {\n\t\t\t\tdata[l++] = offset >> 32;\n\t\t\t\tdata[l++] = offset >> 40;\n\t\t\t\tdata[l++] = offset >> 48;\n\t\t\t\tdata[l++] = offset >> 54;\n\t\t\t}\n\t\t\treturn l;\n\t\t}\n\t\tif (op->operands[0].type & OT_BYTE && a->bits == 64 && op->operands[1].regs[0]) {\n\t\t\tif (op->operands[1].regs[0] >= X86R_R8 &&\n\t\t\t op->operands[0].reg < 4) {\n\t\t\t\tdata[l++] = 0x41;\n\t\t\t\tdata[l++] = 0x8a;\n\t\t\t\tdata[l++] = op->operands[0].reg << 3 | (op->operands[1].regs[0] - 8);\n\t\t\t\treturn l;\n\t\t\t}\n\t\t\treturn -1;\n\t\t}",
"\t\tif (op->operands[1].type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\tif (op->operands[1].scale[0] == 0) {\n\t\t\t\treturn -1;\n\t\t\t}",
"\t\t\tdata[l++] = SEG_REG_PREFIXES[op->operands[1].regs[0]];",
"\t\t\tdata[l++] = 0x8b;",
"\t\t\tdata[l++] = op->operands[0].reg << 3 | 0x5;",
"\t\t\tdata[l++] = offset;\n\t\t\tdata[l++] = offset >> 8;\n\t\t\tdata[l++] = offset >> 16;\n\t\t\tdata[l++] = offset >> 24;\n\t\t\treturn l;\n\t\t}",
"\t\tif (a->bits == 64) {\n\t\t\tif (op->operands[0].type & OT_QWORD) {\n\t\t\t\tif (!(op->operands[1].type & OT_QWORD)) {\n\t\t\t\t\tif (op->operands[1].regs[0] != -1) {\n\t\t\t\t\t\tdata[l++] = 0x67;\n\t\t\t\t\t}\n\t\t\t\t\tdata[l++] = 0x48;\n\t\t\t\t}\n\t\t\t} else if (op->operands[1].type & OT_DWORD) {\n\t\t\t\tdata[l++] = 0x44;\n\t\t\t} else if (!(op->operands[1].type & OT_QWORD)) {\n\t\t\t\tdata[l++] = 0x67;\n\t\t\t}\n\t\t\tif (op->operands[1].type & OT_QWORD &&\n\t\t\t\top->operands[0].type & OT_QWORD) {\n\t\t\t\tdata[l++] = 0x48;\n\t\t\t}\n\t\t}",
"\t\tif (op->operands[0].type & OT_WORD) {\n\t\t\tdata[l++] = 0x66;\n\t\t\tdata[l++] = op->operands[1].type & OT_BYTE ? 0x8a : 0x8b;\n\t\t} else {\n\t\t\tdata[l++] = (op->operands[1].type & OT_BYTE ||\n\t\t\t\top->operands[0].type & OT_BYTE) ?\n\t\t\t\t0x8a : 0x8b;\n\t\t}",
"\t\tif (op->operands[1].regs[0] == X86R_UNDEFINED) {\n\t\t\tif (a->bits == 64) {\n\t\t\t\tdata[l++] = op->operands[0].reg << 3 | 0x4;\n\t\t\t\tdata[l++] = 0x25;\n\t\t\t} else {\n\t\t\t\tdata[l++] = op->operands[0].reg << 3 | 0x5;\n\t\t\t}\n\t\t\tdata[l++] = offset;\n\t\t\tdata[l++] = offset >> 8;\n\t\t\tdata[l++] = offset >> 16;\n\t\t\tdata[l++] = offset >> 24;\n\t\t} else {\n\t\t\tif (op->operands[1].scale[0] > 1) {\n\t\t\t\tdata[l++] = op->operands[0].reg << 3 | 4;",
"\t\t\t\tif (op->operands[1].scale[0] >= 2) {\n\t\t\t\t\tbase = 5;\n\t\t\t\t}\n\t\t\t\tif (base) {\n\t\t\t\t\tdata[l++] = getsib (op->operands[1].scale[0]) << 6 | op->operands[1].regs[0] << 3 | base;\n\t\t\t\t} else {\n\t\t\t\t\tdata[l++] = getsib (op->operands[1].scale[0]) << 3 | op->operands[1].regs[0];\n\t\t\t\t}\n\t\t\t\tif (offset || base) {\n\t\t\t\t\tdata[l++] = offset;\n\t\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\t\tdata[l++] = offset >> 24;\n\t\t\t\t}\n\t\t\t\treturn l;\n\t\t\t}\n\t\t\tif (op->operands[1].regs[1] != X86R_UNDEFINED) {\n\t\t\t\tdata[l++] = op->operands[0].reg << 3 | 0x4;\n\t\t\t\tdata[l++] = op->operands[1].regs[1] << 3 | op->operands[1].regs[0];\n\t\t\t\treturn l;\n\t\t\t}",
"\t\t\tif (offset || op->operands[1].regs[0] == X86R_EBP) {\n\t\t\t\tmod = 0x2;\n\t\t\t\tif (op->operands[1].offset > 127) {\n\t\t\t\t\tmod = 0x4;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (a->bits == 64 && offset && op->operands[0].type & OT_QWORD) {\n\t\t\t\tif (op->operands[1].regs[0] == X86R_RIP) {\n\t\t\t\t\tdata[l++] = 0x5;\n\t\t\t\t} else {\n\t\t\t\t\tif (op->operands[1].offset > 127) {\n\t\t\t\t\t\tdata[l++] = 0x80 | op->operands[0].reg << 3 | op->operands[1].regs[0];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdata[l++] = 0x40 | op->operands[1].regs[0];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (op->operands[1].offset > 127) {\n\t\t\t\t\tmod = 0x1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (op->operands[1].regs[0] == X86R_EIP && (op->operands[0].type & OT_DWORD)) {\n\t\t\t\t\tdata[l++] = 0x0d;\n\t\t\t\t} else if (op->operands[1].regs[0] == X86R_RIP && (op->operands[0].type & OT_QWORD)) {\n\t\t\t\t\tdata[l++] = 0x05;\n\t\t\t\t} else {\n\t\t\t\t\tdata[l++] = mod << 5 | op->operands[0].reg << 3 | op->operands[1].regs[0];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (op->operands[1].regs[0] == X86R_ESP) {\n\t\t\t\tdata[l++] = 0x24;\n\t\t\t}\n\t\t\tif (mod >= 0x2) {\n\t\t\t\tdata[l++] = offset;\n\t\t\t\tif (op->operands[1].offset > 128 || op->operands[1].regs[0] == X86R_EIP) {\n\t\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\t\tdata[l++] = offset >> 24;\n\t\t\t\t}\n\t\t\t} else if (a->bits == 64 && (offset || op->operands[1].regs[0] == X86R_RIP)) {\n\t\t\t\tdata[l++] = offset;\n\t\t\t\tif (op->operands[1].offset > 127 || op->operands[1].regs[0] == X86R_RIP) {\n\t\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\t\tdata[l++] = offset >> 24;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn l;\n}"
] | [
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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 9494,
"char_start": 9490,
"chars": " % 6"
},
{
"char_end": 9541,
"char_start": 9533,
"chars": "(((ut32)"
},
{
"char_end": 9561,
"char_start": 9560,
"chars": ")"
},
{
"char_end": 9567,
"char_start": 9566,
"chars": ")"
}
],
"deleted": []
},
"commit_link": "github.com/radare/radare2/commit/f17bfd9f1da05f30f23a4dd05e9d2363e1406948",
"file_name": "libr/asm/p/asm_x86_nz.c",
"func_name": "opmov",
"line_changes": {
"added": [
{
"char_end": 9497,
"char_start": 9435,
"line": "\t\t\tdata[l++] = SEG_REG_PREFIXES[op->operands[1].regs[0] % 6];\n",
"line_no": 352
},
{
"char_end": 9575,
"char_start": 9518,
"line": "\t\t\tdata[l++] = (((ut32)op->operands[0].reg) << 3) | 0x5;\n",
"line_no": 354
}
],
"deleted": [
{
"char_end": 9493,
"char_start": 9435,
"line": "\t\t\tdata[l++] = SEG_REG_PREFIXES[op->operands[1].regs[0]];\n",
"line_no": 352
},
{
"char_end": 9561,
"char_start": 9514,
"line": "\t\t\tdata[l++] = op->operands[0].reg << 3 | 0x5;\n",
"line_no": 354
}
]
},
"vul_type": "cwe-125"
} | 381 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static int opmov(RAsm *a, ut8 *data, const Opcode *op) {\n\tint l = 0;\n\tst64 offset = 0;\n\tint mod = 0;\n\tint base = 0;\n\tint rex = 0;\n\tut64 immediate = 0;\n\tif (op->operands[1].type & OT_CONSTANT) {\n\t\tif (!op->operands[1].is_good_flag) {\n\t\t\treturn -1;\n\t\t}\n\t\tif (op->operands[1].immediate == -1) {\n\t\t\treturn -1;\n\t\t}\n\t\timmediate = op->operands[1].immediate * op->operands[1].sign;\n\t\tif (op->operands[0].type & OT_GPREG && !(op->operands[0].type & OT_MEMORY)) {\n\t\t\tif (a->bits == 64 && ((op->operands[0].type & OT_QWORD) | (op->operands[1].type & OT_QWORD))) {\n\t\t\t\tif (!(op->operands[1].type & OT_CONSTANT) && op->operands[1].extended) {\n\t\t\t\t\tdata[l++] = 0x49;\n\t\t\t\t} else {\n\t\t\t\t\tdata[l++] = 0x48;\n\t\t\t\t}\n\t\t\t} else if (op->operands[0].extended) {\n\t\t\t\tdata[l++] = 0x41;\n\t\t\t}\n\t\t\tif (op->operands[0].type & OT_WORD) {\n\t\t\t\tif (a->bits > 16) {\n\t\t\t\t\tdata[l++] = 0x66;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (op->operands[0].type & OT_BYTE) {\n\t\t\t\tdata[l++] = 0xb0 | op->operands[0].reg;\n\t\t\t\tdata[l++] = immediate;\n\t\t\t} else {\n\t\t\t\tif (a->bits == 64 &&\n\t\t\t\t\t((op->operands[0].type & OT_QWORD) |\n\t\t\t\t\t(op->operands[1].type & OT_QWORD)) &&\n\t\t\t\t\timmediate < UT32_MAX) {\n\t\t\t\t\t\tdata[l++] = 0xc7;\n\t\t\t\t \t\tdata[l++] = 0xc0 | op->operands[0].reg;\n\t\t\t\t} else {\n\t\t\t\t\tdata[l++] = 0xb8 | op->operands[0].reg;\n\t\t\t\t}\n\t\t\t\tdata[l++] = immediate;\n\t\t\t\tdata[l++] = immediate >> 8;\n\t\t\t\tif (!(op->operands[0].type & OT_WORD)) {\n\t\t\t\t\tdata[l++] = immediate >> 16;\n\t\t\t\t\tdata[l++] = immediate >> 24;\n\t\t\t\t}\n\t\t\t\tif (a->bits == 64 && immediate > UT32_MAX) {\n\t\t\t\t\tdata[l++] = immediate >> 32;\n\t\t\t\t\tdata[l++] = immediate >> 40;\n\t\t\t\t\tdata[l++] = immediate >> 48;\n\t\t\t\t\tdata[l++] = immediate >> 56;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (op->operands[0].type & OT_MEMORY) {\n\t\t\tif (!op->operands[0].explicit_size) {\n\t\t\t\tif (op->operands[0].type & OT_GPREG) {\n\t\t\t\t\t((Opcode *)op)->operands[0].dest_size = op->operands[0].reg_size;\n\t\t\t\t} else {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tint dest_bits = 8 * ((op->operands[0].dest_size & ALL_SIZE) >> OPSIZE_SHIFT);\n\t\t\tint reg_bits = 8 * ((op->operands[0].reg_size & ALL_SIZE) >> OPSIZE_SHIFT);\n\t\t\tint offset = op->operands[0].offset * op->operands[0].offset_sign;",
"\t\t\t//addr_size_override prefix\n\t\t\tbool use_aso = false;\n\t\t\tif (reg_bits < a->bits) {\n\t\t\t\tuse_aso = true;\n\t\t\t}",
"\t\t\t//op_size_override prefix\n\t\t\tbool use_oso = false;\n\t\t\tif (dest_bits == 16) {\n\t\t\t\tuse_oso = true;\n\t\t\t}",
"\t\t\tbool rip_rel = op->operands[0].regs[0] == X86R_RIP;",
"\t\t\t//rex prefix\n\t\t\tint rex = 1 << 6;\n\t\t\tbool use_rex = false;\n\t\t\tif (dest_bits == 64) {\t\t\t//W field\n\t\t\t\tuse_rex = true;\n\t\t\t\trex |= 1 << 3;\n\t\t\t}\n\t\t\tif (op->operands[0].extended) {\t\t//B field\n\t\t\t\tuse_rex = true;\n\t\t\t\trex |= 1;\n\t\t\t}",
"\t\t\t//opcode selection\n\t\t\tint opcode;\n\t\t\tif (dest_bits == 8) {\n\t\t\t\topcode = 0xc6;\n\t\t\t} else {\n\t\t\t\topcode = 0xc7;\n\t\t\t}",
"\t\t\t//modrm and SIB selection\n\t\t\tint modrm = 0;\n\t\t\tint mod;\n\t\t\tint reg = 0;\n\t\t\tint rm;\n\t\t\tbool use_sib = false;\n\t\t\tint sib;\n\t\t\t//mod\n\t\t\tif (offset == 0) {\n\t\t\t\tmod = 0;\n\t\t\t} else if (offset < 128 && offset > -129) {\n\t\t\t\tmod = 1;\n\t\t\t} else {\n\t\t\t\tmod = 2;\n\t\t\t}",
"\t\t\tif (reg_bits == 16) {\n\t\t\t\tif (op->operands[0].regs[0] == X86R_BX && op->operands[0].regs[1] == X86R_SI) {\n\t\t\t\t\trm = B0000;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_BX && op->operands[0].regs[1] == X86R_DI) {\n\t\t\t\t\trm = B0001;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_BP && op->operands[0].regs[1] == X86R_SI) {\n\t\t\t\t\trm = B0010;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_BP && op->operands[0].regs[1] == X86R_DI) {\n\t\t\t\t\trm = B0011;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_SI && op->operands[0].regs[1] == -1) {\n\t\t\t\t\trm = B0100;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_DI && op->operands[0].regs[1] == -1) {\n\t\t\t\t\trm = B0101;\n\t\t\t\t} else if (op->operands[0].regs[0] == X86R_BX && op->operands[0].regs[1] == -1) {\n\t\t\t\t\trm = B0111;\n\t\t\t\t} else {\n\t\t\t\t\t//TODO allow for displacement only when parser is reworked\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tmodrm = (mod << 6) | (reg << 3) | rm;\n\t\t\t} else {\n\t\t\t\t//rm\n\t\t\t\tif (op->operands[0].extended) {\n\t\t\t\t\trm = op->operands[0].reg;\n\t\t\t\t} else {\n\t\t\t\t\trm = op->operands[0].regs[0];\n\t\t\t\t}\n\t\t\t\t//[epb] alone is illegal, so we need to fake a [ebp+0]\n\t\t\t\tif (rm == 5 && mod == 0) {\n\t\t\t\t\tmod = 1;\n\t\t\t\t}",
"\t\t\t\t//sib\n\t\t\t\tint index = op->operands[0].regs[1];\n\t\t\t\tint scale = getsib(op->operands[0].scale[1]);\n\t\t\t\tif (index != -1) {\n\t\t\t\t\tuse_sib = true;\n\t\t\t\t\tsib = (scale << 6) | (index << 3) | rm;\n\t\t\t\t} else if (rm == 4) {\n\t\t\t\t\tuse_sib = true;\n\t\t\t\t\tsib = 0x24;\n\t\t\t\t}\n\t\t\t\tif (use_sib) {\n\t\t\t\t\trm = B0100;\n\t\t\t\t}\n\t\t\t\tif (rip_rel) {\n\t\t\t\t\tmodrm = (B0000 << 6) | (reg << 3) | B0101;\n\t\t\t\t\tsib = (scale << 6) | (B0100 << 3) | B0101;\n\t\t\t\t} else {\n\t\t\t\t\tmodrm = (mod << 6) | (reg << 3) | rm;\n\t\t\t\t}\n\t\t\t}",
"\t\t\t//build the final result\n\t\t\tif (use_aso) {\n\t\t\t\tdata[l++] = 0x67;\n\t\t\t}\n\t\t\tif (use_oso) {\n\t\t\t\tdata[l++] = 0x66;\n\t\t\t}\n\t\t\tif (use_rex) {\n\t\t\t\tdata[l++] = rex;\n\t\t\t}\n\t\t\tdata[l++] = opcode;\n\t\t\tdata[l++] = modrm;\n\t\t\tif (use_sib) {\n\t\t\t\tdata[l++] = sib;\n\t\t\t}\n\t\t\t//offset\n\t\t\tif (mod == 1) {\n\t\t\t\tdata[l++] = offset;\n\t\t\t} else if (reg_bits == 16 && mod == 2) {\n\t\t\t\tdata[l++] = offset;\n\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t} else if (mod == 2 || rip_rel) {\n\t\t\t\tdata[l++] = offset;\n\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\tdata[l++] = offset >> 24;\n\t\t\t}\n\t\t\t//immediate\n\t\t\tint byte;\n\t\t\tfor (byte = 0; byte < dest_bits && byte < 32; byte += 8) {\n\t\t\t\tdata[l++] = (immediate >> byte);\n\t\t\t}\n\t\t}\n\t} else if (op->operands[1].type & OT_REGALL &&\n\t\t\t !(op->operands[1].type & OT_MEMORY)) {\n\t\tif (op->operands[0].type & OT_CONSTANT) {\n\t\t\treturn -1;\n\t\t}\n\t\tif (op->operands[0].type & OT_REGTYPE & OT_SEGMENTREG &&\n\t\t op->operands[1].type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\t\treturn -1;\n\t\t}\n\t\t// Check reg sizes match\n\t\tif (op->operands[0].type & OT_REGTYPE && op->operands[1].type & OT_REGTYPE) {\n\t\t\tif (!((op->operands[0].type & ALL_SIZE) &\n\t\t\t(op->operands[1].type & ALL_SIZE))) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}",
"\t\tif (a->bits == 64) {\n\t\t\tif (op->operands[0].extended) {\n\t\t\t\trex = 1;\n\t\t\t}\n\t\t\tif (op->operands[1].extended) {\n\t\t\t\trex += 4;\n\t\t\t}\n\t\t\tif (op->operands[1].type & OT_QWORD) {\n\t\t\t\tif (!(op->operands[0].type & OT_QWORD)) {\n\t\t\t\t\tdata[l++] = 0x67;\n\t\t\t\t\tdata[l++] = 0x48;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (op->operands[1].type & OT_QWORD &&\n\t\t\t\top->operands[0].type & OT_QWORD) {\n\t\t\t\tdata[l++] = 0x48 | rex;\n\t\t\t}\n\t\t\tif (op->operands[1].type & OT_DWORD &&\n\t\t\t\top->operands[0].type & OT_DWORD) {\n\t\t\t\tdata[l++] = 0x40 | rex;\n\t\t\t}\n\t\t} else if (op->operands[0].extended && op->operands[1].extended) {\n\t\t\tdata[l++] = 0x45;\n\t\t}\n\t\toffset = op->operands[0].offset * op->operands[0].offset_sign;\n\t\tif (op->operands[1].type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\tdata[l++] = 0x8c;\n\t\t} else {\n\t\t\tif (op->operands[0].type & OT_WORD) {\n\t\t\t\tdata[l++] = 0x66;\n\t\t\t}\n\t\t\tdata[l++] = (op->operands[0].type & OT_BYTE) ? 0x88 : 0x89;\n\t\t}",
"\t\tif (op->operands[0].scale[0] > 1) {\n\t\t\t\tdata[l++] = op->operands[1].reg << 3 | 4;\n\t\t\t\tdata[l++] = getsib (op->operands[0].scale[0]) << 6 |\n\t\t\t\t\t\t op->operands[0].regs[0] << 3 | 5;",
"\t\t\t\tdata[l++] = offset;\n\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\tdata[l++] = offset >> 24;",
"\t\t\t\treturn l;\n\t\t\t}",
"\t\tif (!(op->operands[0].type & OT_MEMORY)) {\n\t\t\tif (op->operands[0].reg == X86R_UNDEFINED ||\n\t\t\t\top->operands[1].reg == X86R_UNDEFINED) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tmod = 0x3;\n\t\t\tdata[l++] = mod << 6 | op->operands[1].reg << 3 | op->operands[0].reg;\n\t\t} else if (op->operands[0].regs[0] == X86R_UNDEFINED) {\n\t\t\tdata[l++] = op->operands[1].reg << 3 | 0x5;\n\t\t\tdata[l++] = offset;\n\t\t\tdata[l++] = offset >> 8;\n\t\t\tdata[l++] = offset >> 16;\n\t\t\tdata[l++] = offset >> 24;\n\t\t} else {\n\t\t\tif (op->operands[0].type & OT_MEMORY) {\n\t\t\t\tif (op->operands[0].regs[1] != X86R_UNDEFINED) {\n\t\t\t\t\tdata[l++] = op->operands[1].reg << 3 | 0x4;\n\t\t\t\t\tdata[l++] = op->operands[0].regs[1] << 3 | op->operands[0].regs[0];\n\t\t\t\t\treturn l;\n\t\t\t\t}\n\t\t\t\tif (offset) {\n\t\t\t\t\tmod = (offset > 128 || offset < -129) ? 0x2 : 0x1;\n\t\t\t\t}\n\t\t\t\tif (op->operands[0].regs[0] == X86R_EBP) {\n\t\t\t\t\tmod = 0x2;\n\t\t\t\t}\n\t\t\t\tdata[l++] = mod << 6 | op->operands[1].reg << 3 | op->operands[0].regs[0];\n\t\t\t\tif (op->operands[0].regs[0] == X86R_ESP) {\n\t\t\t\t\tdata[l++] = 0x24;\n\t\t\t\t}\n\t\t\t\tif (offset) {\n\t\t\t\t\tdata[l++] = offset;\n\t\t\t\t}\n\t\t\t\tif (mod == 2) {\n\t\t\t\t\t// warning C4293: '>>': shift count negative or too big, undefined behavior\n\t\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\t\tdata[l++] = offset >> 24;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (op->operands[1].type & OT_MEMORY) {\n\t\tif (op->operands[0].type & OT_MEMORY) {\n\t\t\treturn -1;\n\t\t}\n\t\toffset = op->operands[1].offset * op->operands[1].offset_sign;\n\t\tif (op->operands[0].reg == X86R_EAX && op->operands[1].regs[0] == X86R_UNDEFINED) {\n\t\t\tif (a->bits == 64) {\n\t\t\t\tdata[l++] = 0x48;\n\t\t\t}\n\t\t\tif (op->operands[0].type & OT_BYTE) {\n\t\t\t\tdata[l++] = 0xa0;\n\t\t\t} else {\n\t\t\t\tdata[l++] = 0xa1;\n\t\t\t}\n\t\t\tdata[l++] = offset;\n\t\t\tdata[l++] = offset >> 8;\n\t\t\tdata[l++] = offset >> 16;\n\t\t\tdata[l++] = offset >> 24;\n\t\t\tif (a->bits == 64) {\n\t\t\t\tdata[l++] = offset >> 32;\n\t\t\t\tdata[l++] = offset >> 40;\n\t\t\t\tdata[l++] = offset >> 48;\n\t\t\t\tdata[l++] = offset >> 54;\n\t\t\t}\n\t\t\treturn l;\n\t\t}\n\t\tif (op->operands[0].type & OT_BYTE && a->bits == 64 && op->operands[1].regs[0]) {\n\t\t\tif (op->operands[1].regs[0] >= X86R_R8 &&\n\t\t\t op->operands[0].reg < 4) {\n\t\t\t\tdata[l++] = 0x41;\n\t\t\t\tdata[l++] = 0x8a;\n\t\t\t\tdata[l++] = op->operands[0].reg << 3 | (op->operands[1].regs[0] - 8);\n\t\t\t\treturn l;\n\t\t\t}\n\t\t\treturn -1;\n\t\t}",
"\t\tif (op->operands[1].type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\tif (op->operands[1].scale[0] == 0) {\n\t\t\t\treturn -1;\n\t\t\t}",
"\t\t\tdata[l++] = SEG_REG_PREFIXES[op->operands[1].regs[0] % 6];",
"\t\t\tdata[l++] = 0x8b;",
"\t\t\tdata[l++] = (((ut32)op->operands[0].reg) << 3) | 0x5;",
"\t\t\tdata[l++] = offset;\n\t\t\tdata[l++] = offset >> 8;\n\t\t\tdata[l++] = offset >> 16;\n\t\t\tdata[l++] = offset >> 24;\n\t\t\treturn l;\n\t\t}",
"\t\tif (a->bits == 64) {\n\t\t\tif (op->operands[0].type & OT_QWORD) {\n\t\t\t\tif (!(op->operands[1].type & OT_QWORD)) {\n\t\t\t\t\tif (op->operands[1].regs[0] != -1) {\n\t\t\t\t\t\tdata[l++] = 0x67;\n\t\t\t\t\t}\n\t\t\t\t\tdata[l++] = 0x48;\n\t\t\t\t}\n\t\t\t} else if (op->operands[1].type & OT_DWORD) {\n\t\t\t\tdata[l++] = 0x44;\n\t\t\t} else if (!(op->operands[1].type & OT_QWORD)) {\n\t\t\t\tdata[l++] = 0x67;\n\t\t\t}\n\t\t\tif (op->operands[1].type & OT_QWORD &&\n\t\t\t\top->operands[0].type & OT_QWORD) {\n\t\t\t\tdata[l++] = 0x48;\n\t\t\t}\n\t\t}",
"\t\tif (op->operands[0].type & OT_WORD) {\n\t\t\tdata[l++] = 0x66;\n\t\t\tdata[l++] = op->operands[1].type & OT_BYTE ? 0x8a : 0x8b;\n\t\t} else {\n\t\t\tdata[l++] = (op->operands[1].type & OT_BYTE ||\n\t\t\t\top->operands[0].type & OT_BYTE) ?\n\t\t\t\t0x8a : 0x8b;\n\t\t}",
"\t\tif (op->operands[1].regs[0] == X86R_UNDEFINED) {\n\t\t\tif (a->bits == 64) {\n\t\t\t\tdata[l++] = op->operands[0].reg << 3 | 0x4;\n\t\t\t\tdata[l++] = 0x25;\n\t\t\t} else {\n\t\t\t\tdata[l++] = op->operands[0].reg << 3 | 0x5;\n\t\t\t}\n\t\t\tdata[l++] = offset;\n\t\t\tdata[l++] = offset >> 8;\n\t\t\tdata[l++] = offset >> 16;\n\t\t\tdata[l++] = offset >> 24;\n\t\t} else {\n\t\t\tif (op->operands[1].scale[0] > 1) {\n\t\t\t\tdata[l++] = op->operands[0].reg << 3 | 4;",
"\t\t\t\tif (op->operands[1].scale[0] >= 2) {\n\t\t\t\t\tbase = 5;\n\t\t\t\t}\n\t\t\t\tif (base) {\n\t\t\t\t\tdata[l++] = getsib (op->operands[1].scale[0]) << 6 | op->operands[1].regs[0] << 3 | base;\n\t\t\t\t} else {\n\t\t\t\t\tdata[l++] = getsib (op->operands[1].scale[0]) << 3 | op->operands[1].regs[0];\n\t\t\t\t}\n\t\t\t\tif (offset || base) {\n\t\t\t\t\tdata[l++] = offset;\n\t\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\t\tdata[l++] = offset >> 24;\n\t\t\t\t}\n\t\t\t\treturn l;\n\t\t\t}\n\t\t\tif (op->operands[1].regs[1] != X86R_UNDEFINED) {\n\t\t\t\tdata[l++] = op->operands[0].reg << 3 | 0x4;\n\t\t\t\tdata[l++] = op->operands[1].regs[1] << 3 | op->operands[1].regs[0];\n\t\t\t\treturn l;\n\t\t\t}",
"\t\t\tif (offset || op->operands[1].regs[0] == X86R_EBP) {\n\t\t\t\tmod = 0x2;\n\t\t\t\tif (op->operands[1].offset > 127) {\n\t\t\t\t\tmod = 0x4;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (a->bits == 64 && offset && op->operands[0].type & OT_QWORD) {\n\t\t\t\tif (op->operands[1].regs[0] == X86R_RIP) {\n\t\t\t\t\tdata[l++] = 0x5;\n\t\t\t\t} else {\n\t\t\t\t\tif (op->operands[1].offset > 127) {\n\t\t\t\t\t\tdata[l++] = 0x80 | op->operands[0].reg << 3 | op->operands[1].regs[0];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdata[l++] = 0x40 | op->operands[1].regs[0];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (op->operands[1].offset > 127) {\n\t\t\t\t\tmod = 0x1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (op->operands[1].regs[0] == X86R_EIP && (op->operands[0].type & OT_DWORD)) {\n\t\t\t\t\tdata[l++] = 0x0d;\n\t\t\t\t} else if (op->operands[1].regs[0] == X86R_RIP && (op->operands[0].type & OT_QWORD)) {\n\t\t\t\t\tdata[l++] = 0x05;\n\t\t\t\t} else {\n\t\t\t\t\tdata[l++] = mod << 5 | op->operands[0].reg << 3 | op->operands[1].regs[0];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (op->operands[1].regs[0] == X86R_ESP) {\n\t\t\t\tdata[l++] = 0x24;\n\t\t\t}\n\t\t\tif (mod >= 0x2) {\n\t\t\t\tdata[l++] = offset;\n\t\t\t\tif (op->operands[1].offset > 128 || op->operands[1].regs[0] == X86R_EIP) {\n\t\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\t\tdata[l++] = offset >> 24;\n\t\t\t\t}\n\t\t\t} else if (a->bits == 64 && (offset || op->operands[1].regs[0] == X86R_RIP)) {\n\t\t\t\tdata[l++] = offset;\n\t\t\t\tif (op->operands[1].offset > 127 || op->operands[1].regs[0] == X86R_RIP) {\n\t\t\t\t\tdata[l++] = offset >> 8;\n\t\t\t\t\tdata[l++] = offset >> 16;\n\t\t\t\t\tdata[l++] = offset >> 24;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn l;\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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 9494,
"char_start": 9490,
"chars": " % 6"
},
{
"char_end": 9541,
"char_start": 9533,
"chars": "(((ut32)"
},
{
"char_end": 9561,
"char_start": 9560,
"chars": ")"
},
{
"char_end": 9567,
"char_start": 9566,
"chars": ")"
}
],
"deleted": []
},
"commit_link": "github.com/radare/radare2/commit/f17bfd9f1da05f30f23a4dd05e9d2363e1406948",
"file_name": "libr/asm/p/asm_x86_nz.c",
"func_name": "opmov",
"line_changes": {
"added": [
{
"char_end": 9497,
"char_start": 9435,
"line": "\t\t\tdata[l++] = SEG_REG_PREFIXES[op->operands[1].regs[0] % 6];\n",
"line_no": 352
},
{
"char_end": 9575,
"char_start": 9518,
"line": "\t\t\tdata[l++] = (((ut32)op->operands[0].reg) << 3) | 0x5;\n",
"line_no": 354
}
],
"deleted": [
{
"char_end": 9493,
"char_start": 9435,
"line": "\t\t\tdata[l++] = SEG_REG_PREFIXES[op->operands[1].regs[0]];\n",
"line_no": 352
},
{
"char_end": 9561,
"char_start": 9514,
"line": "\t\t\tdata[l++] = op->operands[0].reg << 3 | 0x5;\n",
"line_no": 354
}
]
},
"vul_type": "cwe-125"
} | 381 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"int ares_parse_a_reply(const unsigned char *abuf, int alen,\n\t\t struct hostent **host)\n{\n unsigned int qdcount, ancount;\n int status, i, rr_type, rr_class, rr_len, naddrs;\n long int len;\n int naliases;\n const unsigned char *aptr;\n char *hostname, *rr_name, *rr_data, **aliases;\n struct in_addr *addrs;\n struct hostent *hostent;",
" /* Set *host to NULL for all failure cases. */\n *host = NULL;",
" /* Give up if abuf doesn't have room for a header. */\n if (alen < HFIXEDSZ)\n return ARES_EBADRESP;",
" /* Fetch the question and answer count from the header. */\n qdcount = DNS_HEADER_QDCOUNT(abuf);\n ancount = DNS_HEADER_ANCOUNT(abuf);\n if (qdcount != 1)\n return ARES_EBADRESP;",
" /* Expand the name from the question, and skip past the question. */\n aptr = abuf + HFIXEDSZ;\n status = ares_expand_name(aptr, abuf, alen, &hostname, &len);\n if (status != ARES_SUCCESS)\n return status;\n if (aptr + len + QFIXEDSZ > abuf + alen)\n {\n free(hostname);\n return ARES_EBADRESP;\n }\n aptr += len + QFIXEDSZ;",
" /* Allocate addresses and aliases; ancount gives an upper bound for both. */\n addrs = malloc(ancount * sizeof(struct in_addr));\n if (!addrs)\n {\n free(hostname);\n return ARES_ENOMEM;\n }\n aliases = malloc((ancount + 1) * sizeof(char *));\n if (!aliases)\n {\n free(hostname);\n free(addrs);\n return ARES_ENOMEM;\n }\n naddrs = 0;\n naliases = 0;",
" /* Examine each answer resource record (RR) in turn. */\n for (i = 0; i < (int)ancount; i++)\n {\n /* Decode the RR up to the data field. */\n status = ares_expand_name(aptr, abuf, alen, &rr_name, &len);\n if (status != ARES_SUCCESS)\n\tbreak;\n aptr += len;\n if (aptr + RRFIXEDSZ > abuf + alen)\n\t{\n\t free(rr_name);\n\t status = ARES_EBADRESP;\n\t break;\n\t}\n rr_type = DNS_RR_TYPE(aptr);\n rr_class = DNS_RR_CLASS(aptr);\n rr_len = DNS_RR_LEN(aptr);\n aptr += RRFIXEDSZ;",
"",
"\n if (rr_class == C_IN && rr_type == T_A\n\t && rr_len == sizeof(struct in_addr)\n\t && strcasecmp(rr_name, hostname) == 0)\n\t{\n\t memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr));\n\t naddrs++;\n\t status = ARES_SUCCESS;\n\t}",
" if (rr_class == C_IN && rr_type == T_CNAME)\n\t{\n\t /* Record the RR name as an alias. */\n\t aliases[naliases] = rr_name;\n\t naliases++;",
"\t /* Decode the RR data and replace the hostname with it. */\n\t status = ares_expand_name(aptr, abuf, alen, &rr_data, &len);\n\t if (status != ARES_SUCCESS)\n\t break;\n\t free(hostname);\n\t hostname = rr_data;\n\t}\n else\n\tfree(rr_name);",
" aptr += rr_len;\n if (aptr > abuf + alen)\n\t{\n\t status = ARES_EBADRESP;\n\t break;\n\t}\n }",
" if (status == ARES_SUCCESS && naddrs == 0)\n status = ARES_ENODATA;\n if (status == ARES_SUCCESS)\n {\n /* We got our answer. Allocate memory to build the host entry. */\n aliases[naliases] = NULL;\n hostent = malloc(sizeof(struct hostent));\n if (hostent)\n\t{\n\t hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));\n\t if (hostent->h_addr_list)\n\t {\n\t /* Fill in the hostent and return successfully. */\n\t hostent->h_name = hostname;\n\t hostent->h_aliases = aliases;\n\t hostent->h_addrtype = AF_INET;\n\t hostent->h_length = sizeof(struct in_addr);\n\t for (i = 0; i < naddrs; i++)\n\t\thostent->h_addr_list[i] = (char *) &addrs[i];\n\t hostent->h_addr_list[naddrs] = NULL;\n\t *host = hostent;\n\t return ARES_SUCCESS;\n\t }\n\t free(hostent);\n\t}\n status = ARES_ENOMEM;\n }\n for (i = 0; i < naliases; i++)\n free(aliases[i]);\n free(aliases);\n free(addrs);\n free(hostname);\n return status;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 2033,
"char_start": 1933,
"chars": " if (aptr + rr_len > abuf + alen)\n\t{\n\t free(rr_name);\n\t status = ARES_EBADRESP;\n\t break;\n\t}\n"
}
],
"deleted": []
},
"commit_link": "github.com/resiprocate/resiprocate/commit/d67a9ca6fd06ca65d23e313bdbad1ef4dd3aa0df",
"file_name": "rutil/dns/ares/ares_parse_a_reply.c",
"func_name": "ares_parse_a_reply",
"line_changes": {
"added": [
{
"char_end": 1972,
"char_start": 1933,
"line": " if (aptr + rr_len > abuf + alen)\n",
"line_no": 73
},
{
"char_end": 1975,
"char_start": 1972,
"line": "\t{\n",
"line_no": 74
},
{
"char_end": 1993,
"char_start": 1975,
"line": "\t free(rr_name);\n",
"line_no": 75
},
{
"char_end": 2020,
"char_start": 1993,
"line": "\t status = ARES_EBADRESP;\n",
"line_no": 76
},
{
"char_end": 2030,
"char_start": 2020,
"line": "\t break;\n",
"line_no": 77
},
{
"char_end": 2033,
"char_start": 2030,
"line": "\t}\n",
"line_no": 78
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 382 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"int ares_parse_a_reply(const unsigned char *abuf, int alen,\n\t\t struct hostent **host)\n{\n unsigned int qdcount, ancount;\n int status, i, rr_type, rr_class, rr_len, naddrs;\n long int len;\n int naliases;\n const unsigned char *aptr;\n char *hostname, *rr_name, *rr_data, **aliases;\n struct in_addr *addrs;\n struct hostent *hostent;",
" /* Set *host to NULL for all failure cases. */\n *host = NULL;",
" /* Give up if abuf doesn't have room for a header. */\n if (alen < HFIXEDSZ)\n return ARES_EBADRESP;",
" /* Fetch the question and answer count from the header. */\n qdcount = DNS_HEADER_QDCOUNT(abuf);\n ancount = DNS_HEADER_ANCOUNT(abuf);\n if (qdcount != 1)\n return ARES_EBADRESP;",
" /* Expand the name from the question, and skip past the question. */\n aptr = abuf + HFIXEDSZ;\n status = ares_expand_name(aptr, abuf, alen, &hostname, &len);\n if (status != ARES_SUCCESS)\n return status;\n if (aptr + len + QFIXEDSZ > abuf + alen)\n {\n free(hostname);\n return ARES_EBADRESP;\n }\n aptr += len + QFIXEDSZ;",
" /* Allocate addresses and aliases; ancount gives an upper bound for both. */\n addrs = malloc(ancount * sizeof(struct in_addr));\n if (!addrs)\n {\n free(hostname);\n return ARES_ENOMEM;\n }\n aliases = malloc((ancount + 1) * sizeof(char *));\n if (!aliases)\n {\n free(hostname);\n free(addrs);\n return ARES_ENOMEM;\n }\n naddrs = 0;\n naliases = 0;",
" /* Examine each answer resource record (RR) in turn. */\n for (i = 0; i < (int)ancount; i++)\n {\n /* Decode the RR up to the data field. */\n status = ares_expand_name(aptr, abuf, alen, &rr_name, &len);\n if (status != ARES_SUCCESS)\n\tbreak;\n aptr += len;\n if (aptr + RRFIXEDSZ > abuf + alen)\n\t{\n\t free(rr_name);\n\t status = ARES_EBADRESP;\n\t break;\n\t}\n rr_type = DNS_RR_TYPE(aptr);\n rr_class = DNS_RR_CLASS(aptr);\n rr_len = DNS_RR_LEN(aptr);\n aptr += RRFIXEDSZ;",
" if (aptr + rr_len > abuf + alen)\n\t{\n\t free(rr_name);\n\t status = ARES_EBADRESP;\n\t break;\n\t}",
"\n if (rr_class == C_IN && rr_type == T_A\n\t && rr_len == sizeof(struct in_addr)\n\t && strcasecmp(rr_name, hostname) == 0)\n\t{\n\t memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr));\n\t naddrs++;\n\t status = ARES_SUCCESS;\n\t}",
" if (rr_class == C_IN && rr_type == T_CNAME)\n\t{\n\t /* Record the RR name as an alias. */\n\t aliases[naliases] = rr_name;\n\t naliases++;",
"\t /* Decode the RR data and replace the hostname with it. */\n\t status = ares_expand_name(aptr, abuf, alen, &rr_data, &len);\n\t if (status != ARES_SUCCESS)\n\t break;\n\t free(hostname);\n\t hostname = rr_data;\n\t}\n else\n\tfree(rr_name);",
" aptr += rr_len;\n if (aptr > abuf + alen)\n\t{\n\t status = ARES_EBADRESP;\n\t break;\n\t}\n }",
" if (status == ARES_SUCCESS && naddrs == 0)\n status = ARES_ENODATA;\n if (status == ARES_SUCCESS)\n {\n /* We got our answer. Allocate memory to build the host entry. */\n aliases[naliases] = NULL;\n hostent = malloc(sizeof(struct hostent));\n if (hostent)\n\t{\n\t hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));\n\t if (hostent->h_addr_list)\n\t {\n\t /* Fill in the hostent and return successfully. */\n\t hostent->h_name = hostname;\n\t hostent->h_aliases = aliases;\n\t hostent->h_addrtype = AF_INET;\n\t hostent->h_length = sizeof(struct in_addr);\n\t for (i = 0; i < naddrs; i++)\n\t\thostent->h_addr_list[i] = (char *) &addrs[i];\n\t hostent->h_addr_list[naddrs] = NULL;\n\t *host = hostent;\n\t return ARES_SUCCESS;\n\t }\n\t free(hostent);\n\t}\n status = ARES_ENOMEM;\n }\n for (i = 0; i < naliases; i++)\n free(aliases[i]);\n free(aliases);\n free(addrs);\n free(hostname);\n return status;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 2033,
"char_start": 1933,
"chars": " if (aptr + rr_len > abuf + alen)\n\t{\n\t free(rr_name);\n\t status = ARES_EBADRESP;\n\t break;\n\t}\n"
}
],
"deleted": []
},
"commit_link": "github.com/resiprocate/resiprocate/commit/d67a9ca6fd06ca65d23e313bdbad1ef4dd3aa0df",
"file_name": "rutil/dns/ares/ares_parse_a_reply.c",
"func_name": "ares_parse_a_reply",
"line_changes": {
"added": [
{
"char_end": 1972,
"char_start": 1933,
"line": " if (aptr + rr_len > abuf + alen)\n",
"line_no": 73
},
{
"char_end": 1975,
"char_start": 1972,
"line": "\t{\n",
"line_no": 74
},
{
"char_end": 1993,
"char_start": 1975,
"line": "\t free(rr_name);\n",
"line_no": 75
},
{
"char_end": 2020,
"char_start": 1993,
"line": "\t status = ARES_EBADRESP;\n",
"line_no": 76
},
{
"char_end": 2030,
"char_start": 2020,
"line": "\t break;\n",
"line_no": 77
},
{
"char_end": 2033,
"char_start": 2030,
"line": "\t}\n",
"line_no": 78
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 382 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,\n MagickOffsetType PS_Offset,ssize_t PS_Size,ExceptionInfo *exception)\n{\n char\n postscript_file[MaxTextExtent];",
" const MagicInfo\n *magic_info;",
" FILE\n *ps_file;",
" ImageInfo\n *clone_info;",
" Image\n *image2;",
" unsigned char\n magick[2*MaxTextExtent];",
"\n if ((clone_info=CloneImageInfo(image_info)) == NULL)\n return(image);\n clone_info->blob=(void *) NULL;\n clone_info->length=0;",
" /* Obtain temporary file */\n (void) AcquireUniqueFilename(postscript_file);\n ps_file=fopen_utf8(postscript_file,\"wb\");\n if (ps_file == (FILE *) NULL)\n goto FINISH;",
" /* Copy postscript to temporary file */\n (void) SeekBlob(image,PS_Offset,SEEK_SET);\n (void) ReadBlob(image, 2*MaxTextExtent, magick);",
" (void) SeekBlob(image,PS_Offset,SEEK_SET);\n while(PS_Size-- > 0)\n {\n (void) fputc(ReadBlobByte(image),ps_file);\n }\n (void) fclose(ps_file);",
" /* Detect file format - Check magic.mgk configuration file. */\n magic_info=GetMagicInfo(magick,2*MaxTextExtent,exception);\n if(magic_info == (const MagicInfo *) NULL) goto FINISH_UNL;\n /* printf(\"Detected:%s \\n\",magic_info->name); */\n if(exception->severity != UndefinedException) goto FINISH_UNL;\n if(magic_info->name == (char *) NULL) goto FINISH_UNL;\n",
" (void) CopyMagickMemory(clone_info->magick,magic_info->name,MaxTextExtent);",
"\n /* Read nested image */\n /*FormatString(clone_info->filename,\"%s:%s\",magic_info->name,postscript_file);*/\n FormatLocaleString(clone_info->filename,MaxTextExtent,\"%s\",postscript_file);\n image2=ReadImage(clone_info,exception);",
" if (!image2)\n goto FINISH_UNL;",
" /*\n Replace current image with new image while copying base image\n attributes.\n */\n (void) CopyMagickMemory(image2->filename,image->filename,MaxTextExtent);\n (void) CopyMagickMemory(image2->magick_filename,image->magick_filename,MaxTextExtent);\n (void) CopyMagickMemory(image2->magick,image->magick,MaxTextExtent);\n image2->depth=image->depth;\n DestroyBlob(image2);\n image2->blob=ReferenceBlob(image->blob);",
" if ((image->rows == 0) || (image->columns == 0))\n DeleteImageFromList(&image);",
" AppendImageToList(&image,image2);",
" FINISH_UNL:\n (void) RelinquishUniqueFileResource(postscript_file);\n FINISH:\n DestroyImageInfo(clone_info);\n return(image);\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1329,
"char_start": 1327,
"chars": "st"
},
{
"char_end": 1333,
"char_start": 1330,
"chars": "ncp"
}
],
"deleted": [
{
"char_end": 1329,
"char_start": 1327,
"chars": "Co"
},
{
"char_end": 1342,
"char_start": 1330,
"chars": "yMagickMemor"
}
]
},
"commit_link": "github.com/ImageMagick/ImageMagick/commit/a251039393f423c7858e63cab6aa98d17b8b7a41",
"file_name": "coders/wpg.c",
"func_name": "ExtractPostscript",
"line_changes": {
"added": [
{
"char_end": 1387,
"char_start": 1318,
"line": " (void) strncpy(clone_info->magick,magic_info->name,MaxTextExtent);\n",
"line_no": 52
}
],
"deleted": [
{
"char_end": 1396,
"char_start": 1318,
"line": " (void) CopyMagickMemory(clone_info->magick,magic_info->name,MaxTextExtent);\n",
"line_no": 52
}
]
},
"vul_type": "cwe-125"
} | 383 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,\n MagickOffsetType PS_Offset,ssize_t PS_Size,ExceptionInfo *exception)\n{\n char\n postscript_file[MaxTextExtent];",
" const MagicInfo\n *magic_info;",
" FILE\n *ps_file;",
" ImageInfo\n *clone_info;",
" Image\n *image2;",
" unsigned char\n magick[2*MaxTextExtent];",
"\n if ((clone_info=CloneImageInfo(image_info)) == NULL)\n return(image);\n clone_info->blob=(void *) NULL;\n clone_info->length=0;",
" /* Obtain temporary file */\n (void) AcquireUniqueFilename(postscript_file);\n ps_file=fopen_utf8(postscript_file,\"wb\");\n if (ps_file == (FILE *) NULL)\n goto FINISH;",
" /* Copy postscript to temporary file */\n (void) SeekBlob(image,PS_Offset,SEEK_SET);\n (void) ReadBlob(image, 2*MaxTextExtent, magick);",
" (void) SeekBlob(image,PS_Offset,SEEK_SET);\n while(PS_Size-- > 0)\n {\n (void) fputc(ReadBlobByte(image),ps_file);\n }\n (void) fclose(ps_file);",
" /* Detect file format - Check magic.mgk configuration file. */\n magic_info=GetMagicInfo(magick,2*MaxTextExtent,exception);\n if(magic_info == (const MagicInfo *) NULL) goto FINISH_UNL;\n /* printf(\"Detected:%s \\n\",magic_info->name); */\n if(exception->severity != UndefinedException) goto FINISH_UNL;\n if(magic_info->name == (char *) NULL) goto FINISH_UNL;\n",
" (void) strncpy(clone_info->magick,magic_info->name,MaxTextExtent);",
"\n /* Read nested image */\n /*FormatString(clone_info->filename,\"%s:%s\",magic_info->name,postscript_file);*/\n FormatLocaleString(clone_info->filename,MaxTextExtent,\"%s\",postscript_file);\n image2=ReadImage(clone_info,exception);",
" if (!image2)\n goto FINISH_UNL;",
" /*\n Replace current image with new image while copying base image\n attributes.\n */\n (void) CopyMagickMemory(image2->filename,image->filename,MaxTextExtent);\n (void) CopyMagickMemory(image2->magick_filename,image->magick_filename,MaxTextExtent);\n (void) CopyMagickMemory(image2->magick,image->magick,MaxTextExtent);\n image2->depth=image->depth;\n DestroyBlob(image2);\n image2->blob=ReferenceBlob(image->blob);",
" if ((image->rows == 0) || (image->columns == 0))\n DeleteImageFromList(&image);",
" AppendImageToList(&image,image2);",
" FINISH_UNL:\n (void) RelinquishUniqueFileResource(postscript_file);\n FINISH:\n DestroyImageInfo(clone_info);\n return(image);\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1329,
"char_start": 1327,
"chars": "st"
},
{
"char_end": 1333,
"char_start": 1330,
"chars": "ncp"
}
],
"deleted": [
{
"char_end": 1329,
"char_start": 1327,
"chars": "Co"
},
{
"char_end": 1342,
"char_start": 1330,
"chars": "yMagickMemor"
}
]
},
"commit_link": "github.com/ImageMagick/ImageMagick/commit/a251039393f423c7858e63cab6aa98d17b8b7a41",
"file_name": "coders/wpg.c",
"func_name": "ExtractPostscript",
"line_changes": {
"added": [
{
"char_end": 1387,
"char_start": 1318,
"line": " (void) strncpy(clone_info->magick,magic_info->name,MaxTextExtent);\n",
"line_no": 52
}
],
"deleted": [
{
"char_end": 1396,
"char_start": 1318,
"line": " (void) CopyMagickMemory(clone_info->magick,magic_info->name,MaxTextExtent);\n",
"line_no": 52
}
]
},
"vul_type": "cwe-125"
} | 383 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"int usb_get_bos_descriptor(struct usb_device *dev)\n{\n\tstruct device *ddev = &dev->dev;\n\tstruct usb_bos_descriptor *bos;\n\tstruct usb_dev_cap_header *cap;\n\tunsigned char *buffer;\n\tint length, total_len, num, i;\n\tint ret;",
"\tbos = kzalloc(sizeof(struct usb_bos_descriptor), GFP_KERNEL);\n\tif (!bos)\n\t\treturn -ENOMEM;",
"\t/* Get BOS descriptor */\n\tret = usb_get_descriptor(dev, USB_DT_BOS, 0, bos, USB_DT_BOS_SIZE);\n\tif (ret < USB_DT_BOS_SIZE) {\n\t\tdev_err(ddev, \"unable to get BOS descriptor\\n\");\n\t\tif (ret >= 0)\n\t\t\tret = -ENOMSG;\n\t\tkfree(bos);\n\t\treturn ret;\n\t}",
"\tlength = bos->bLength;\n\ttotal_len = le16_to_cpu(bos->wTotalLength);\n\tnum = bos->bNumDeviceCaps;\n\tkfree(bos);\n\tif (total_len < length)\n\t\treturn -EINVAL;",
"\tdev->bos = kzalloc(sizeof(struct usb_host_bos), GFP_KERNEL);\n\tif (!dev->bos)\n\t\treturn -ENOMEM;",
"\t/* Now let's get the whole BOS descriptor set */\n\tbuffer = kzalloc(total_len, GFP_KERNEL);\n\tif (!buffer) {\n\t\tret = -ENOMEM;\n\t\tgoto err;\n\t}\n\tdev->bos->desc = (struct usb_bos_descriptor *)buffer;",
"\tret = usb_get_descriptor(dev, USB_DT_BOS, 0, buffer, total_len);\n\tif (ret < total_len) {\n\t\tdev_err(ddev, \"unable to get BOS descriptor set\\n\");\n\t\tif (ret >= 0)\n\t\t\tret = -ENOMSG;\n\t\tgoto err;\n\t}\n\ttotal_len -= length;",
"\tfor (i = 0; i < num; i++) {\n\t\tbuffer += length;\n\t\tcap = (struct usb_dev_cap_header *)buffer;",
"",
"\t\tlength = cap->bLength;",
"\n\t\tif (total_len < length)\n\t\t\tbreak;",
"\t\ttotal_len -= length;",
"\t\tif (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {\n\t\t\tdev_warn(ddev, \"descriptor type invalid, skip\\n\");\n\t\t\tcontinue;\n\t\t}",
"\t\tswitch (cap->bDevCapabilityType) {\n\t\tcase USB_CAP_TYPE_WIRELESS_USB:\n\t\t\t/* Wireless USB cap descriptor is handled by wusb */\n\t\t\tbreak;\n\t\tcase USB_CAP_TYPE_EXT:\n\t\t\tdev->bos->ext_cap =\n\t\t\t\t(struct usb_ext_cap_descriptor *)buffer;\n\t\t\tbreak;\n\t\tcase USB_SS_CAP_TYPE:\n\t\t\tdev->bos->ss_cap =\n\t\t\t\t(struct usb_ss_cap_descriptor *)buffer;\n\t\t\tbreak;\n\t\tcase USB_SSP_CAP_TYPE:\n\t\t\tdev->bos->ssp_cap =\n\t\t\t\t(struct usb_ssp_cap_descriptor *)buffer;\n\t\t\tbreak;\n\t\tcase CONTAINER_ID_TYPE:\n\t\t\tdev->bos->ss_id =\n\t\t\t\t(struct usb_ss_container_id_descriptor *)buffer;\n\t\t\tbreak;\n\t\tcase USB_PTM_CAP_TYPE:\n\t\t\tdev->bos->ptm_cap =\n\t\t\t\t(struct usb_ptm_cap_descriptor *)buffer;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}",
"\treturn 0;",
"err:\n\tusb_release_bos_descriptor(dev);\n\treturn ret;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1314,
"char_start": 1313,
"chars": "\n"
},
{
"char_end": 1326,
"char_start": 1316,
"chars": "if (total_"
},
{
"char_end": 1331,
"char_start": 1330,
"chars": "<"
},
{
"char_end": 1340,
"char_start": 1332,
"chars": "sizeof(*"
},
{
"char_end": 1347,
"char_start": 1343,
"chars": ") ||"
},
{
"char_end": 1367,
"char_start": 1360,
"chars": "cap->bL"
},
{
"char_end": 1414,
"char_start": 1373,
"chars": " {\n\t\t\tdev->bos->desc->bNumDeviceCaps = i;"
},
{
"char_end": 1452,
"char_start": 1423,
"chars": ";\n\t\t}\n\t\tlength = cap->bLength"
}
],
"deleted": [
{
"char_end": 1321,
"char_start": 1318,
"chars": "gth"
},
{
"char_end": 1323,
"char_start": 1322,
"chars": "="
},
{
"char_end": 1343,
"char_start": 1327,
"chars": "->bLength;\n\n\t\tif"
},
{
"char_end": 1345,
"char_start": 1344,
"chars": "("
},
{
"char_end": 1358,
"char_start": 1357,
"chars": "l"
}
]
},
"commit_link": "github.com/torvalds/linux/commit/1c0edc3633b56000e18d82fc241e3995ca18a69e",
"file_name": "drivers/usb/core/config.c",
"func_name": "usb_get_bos_descriptor",
"line_changes": {
"added": [
{
"char_end": 1376,
"char_start": 1314,
"line": "\t\tif (total_len < sizeof(*cap) || total_len < cap->bLength) {\n",
"line_no": 56
},
{
"char_end": 1415,
"char_start": 1376,
"line": "\t\t\tdev->bos->desc->bNumDeviceCaps = i;\n",
"line_no": 57
},
{
"char_end": 1429,
"char_start": 1425,
"line": "\t\t}\n",
"line_no": 59
},
{
"char_end": 1454,
"char_start": 1429,
"line": "\t\tlength = cap->bLength;\n",
"line_no": 60
}
],
"deleted": [
{
"char_end": 1338,
"char_start": 1313,
"line": "\t\tlength = cap->bLength;\n",
"line_no": 55
},
{
"char_end": 1365,
"char_start": 1339,
"line": "\t\tif (total_len < length)\n",
"line_no": 57
}
]
},
"vul_type": "cwe-125"
} | 384 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"int usb_get_bos_descriptor(struct usb_device *dev)\n{\n\tstruct device *ddev = &dev->dev;\n\tstruct usb_bos_descriptor *bos;\n\tstruct usb_dev_cap_header *cap;\n\tunsigned char *buffer;\n\tint length, total_len, num, i;\n\tint ret;",
"\tbos = kzalloc(sizeof(struct usb_bos_descriptor), GFP_KERNEL);\n\tif (!bos)\n\t\treturn -ENOMEM;",
"\t/* Get BOS descriptor */\n\tret = usb_get_descriptor(dev, USB_DT_BOS, 0, bos, USB_DT_BOS_SIZE);\n\tif (ret < USB_DT_BOS_SIZE) {\n\t\tdev_err(ddev, \"unable to get BOS descriptor\\n\");\n\t\tif (ret >= 0)\n\t\t\tret = -ENOMSG;\n\t\tkfree(bos);\n\t\treturn ret;\n\t}",
"\tlength = bos->bLength;\n\ttotal_len = le16_to_cpu(bos->wTotalLength);\n\tnum = bos->bNumDeviceCaps;\n\tkfree(bos);\n\tif (total_len < length)\n\t\treturn -EINVAL;",
"\tdev->bos = kzalloc(sizeof(struct usb_host_bos), GFP_KERNEL);\n\tif (!dev->bos)\n\t\treturn -ENOMEM;",
"\t/* Now let's get the whole BOS descriptor set */\n\tbuffer = kzalloc(total_len, GFP_KERNEL);\n\tif (!buffer) {\n\t\tret = -ENOMEM;\n\t\tgoto err;\n\t}\n\tdev->bos->desc = (struct usb_bos_descriptor *)buffer;",
"\tret = usb_get_descriptor(dev, USB_DT_BOS, 0, buffer, total_len);\n\tif (ret < total_len) {\n\t\tdev_err(ddev, \"unable to get BOS descriptor set\\n\");\n\t\tif (ret >= 0)\n\t\t\tret = -ENOMSG;\n\t\tgoto err;\n\t}\n\ttotal_len -= length;",
"\tfor (i = 0; i < num; i++) {\n\t\tbuffer += length;\n\t\tcap = (struct usb_dev_cap_header *)buffer;",
"\n\t\tif (total_len < sizeof(*cap) || total_len < cap->bLength) {\n\t\t\tdev->bos->desc->bNumDeviceCaps = i;\n\t\t\tbreak;\n\t\t}",
"\t\tlength = cap->bLength;",
"",
"\t\ttotal_len -= length;",
"\t\tif (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {\n\t\t\tdev_warn(ddev, \"descriptor type invalid, skip\\n\");\n\t\t\tcontinue;\n\t\t}",
"\t\tswitch (cap->bDevCapabilityType) {\n\t\tcase USB_CAP_TYPE_WIRELESS_USB:\n\t\t\t/* Wireless USB cap descriptor is handled by wusb */\n\t\t\tbreak;\n\t\tcase USB_CAP_TYPE_EXT:\n\t\t\tdev->bos->ext_cap =\n\t\t\t\t(struct usb_ext_cap_descriptor *)buffer;\n\t\t\tbreak;\n\t\tcase USB_SS_CAP_TYPE:\n\t\t\tdev->bos->ss_cap =\n\t\t\t\t(struct usb_ss_cap_descriptor *)buffer;\n\t\t\tbreak;\n\t\tcase USB_SSP_CAP_TYPE:\n\t\t\tdev->bos->ssp_cap =\n\t\t\t\t(struct usb_ssp_cap_descriptor *)buffer;\n\t\t\tbreak;\n\t\tcase CONTAINER_ID_TYPE:\n\t\t\tdev->bos->ss_id =\n\t\t\t\t(struct usb_ss_container_id_descriptor *)buffer;\n\t\t\tbreak;\n\t\tcase USB_PTM_CAP_TYPE:\n\t\t\tdev->bos->ptm_cap =\n\t\t\t\t(struct usb_ptm_cap_descriptor *)buffer;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}",
"\treturn 0;",
"err:\n\tusb_release_bos_descriptor(dev);\n\treturn ret;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1314,
"char_start": 1313,
"chars": "\n"
},
{
"char_end": 1326,
"char_start": 1316,
"chars": "if (total_"
},
{
"char_end": 1331,
"char_start": 1330,
"chars": "<"
},
{
"char_end": 1340,
"char_start": 1332,
"chars": "sizeof(*"
},
{
"char_end": 1347,
"char_start": 1343,
"chars": ") ||"
},
{
"char_end": 1367,
"char_start": 1360,
"chars": "cap->bL"
},
{
"char_end": 1414,
"char_start": 1373,
"chars": " {\n\t\t\tdev->bos->desc->bNumDeviceCaps = i;"
},
{
"char_end": 1452,
"char_start": 1423,
"chars": ";\n\t\t}\n\t\tlength = cap->bLength"
}
],
"deleted": [
{
"char_end": 1321,
"char_start": 1318,
"chars": "gth"
},
{
"char_end": 1323,
"char_start": 1322,
"chars": "="
},
{
"char_end": 1343,
"char_start": 1327,
"chars": "->bLength;\n\n\t\tif"
},
{
"char_end": 1345,
"char_start": 1344,
"chars": "("
},
{
"char_end": 1358,
"char_start": 1357,
"chars": "l"
}
]
},
"commit_link": "github.com/torvalds/linux/commit/1c0edc3633b56000e18d82fc241e3995ca18a69e",
"file_name": "drivers/usb/core/config.c",
"func_name": "usb_get_bos_descriptor",
"line_changes": {
"added": [
{
"char_end": 1376,
"char_start": 1314,
"line": "\t\tif (total_len < sizeof(*cap) || total_len < cap->bLength) {\n",
"line_no": 56
},
{
"char_end": 1415,
"char_start": 1376,
"line": "\t\t\tdev->bos->desc->bNumDeviceCaps = i;\n",
"line_no": 57
},
{
"char_end": 1429,
"char_start": 1425,
"line": "\t\t}\n",
"line_no": 59
},
{
"char_end": 1454,
"char_start": 1429,
"line": "\t\tlength = cap->bLength;\n",
"line_no": 60
}
],
"deleted": [
{
"char_end": 1338,
"char_start": 1313,
"line": "\t\tlength = cap->bLength;\n",
"line_no": 55
},
{
"char_end": 1365,
"char_start": 1339,
"line": "\t\tif (total_len < length)\n",
"line_no": 57
}
]
},
"vul_type": "cwe-125"
} | 384 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"Mat_VarReadNextInfo4(mat_t *mat)\n{\n int M,O,data_type,class_type;\n mat_int32_t tmp;\n long nBytes;\n size_t readresult;\n matvar_t *matvar = NULL;\n union {\n mat_uint32_t u;\n mat_uint8_t c[4];\n } endian;",
" if ( mat == NULL || mat->fp == NULL )\n return NULL;\n else if ( NULL == (matvar = Mat_VarCalloc()) )\n return NULL;",
" readresult = fread(&tmp,sizeof(int),1,(FILE*)mat->fp);\n if ( 1 != readresult ) {\n Mat_VarFree(matvar);\n return NULL;\n }",
" endian.u = 0x01020304;",
" /* See if MOPT may need byteswapping */\n if ( tmp < 0 || tmp > 4052 ) {\n if ( Mat_int32Swap(&tmp) > 4052 ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n }",
" M = (int)floor(tmp / 1000.0);\n switch ( M ) {\n case 0:\n /* IEEE little endian */\n mat->byteswap = endian.c[0] != 4;\n break;\n case 1:\n /* IEEE big endian */\n mat->byteswap = endian.c[0] != 1;\n break;\n default:\n /* VAX, Cray, or bogus */\n Mat_VarFree(matvar);\n return NULL;\n }",
" tmp -= M*1000;\n O = (int)floor(tmp / 100.0);\n /* O must be zero */\n if ( 0 != O ) {\n Mat_VarFree(matvar);\n return NULL;\n }",
" tmp -= O*100;\n data_type = (int)floor(tmp / 10.0);\n /* Convert the V4 data type */\n switch ( data_type ) {\n case 0:\n matvar->data_type = MAT_T_DOUBLE;\n break;\n case 1:\n matvar->data_type = MAT_T_SINGLE;\n break;\n case 2:\n matvar->data_type = MAT_T_INT32;\n break;\n case 3:\n matvar->data_type = MAT_T_INT16;\n break;\n case 4:\n matvar->data_type = MAT_T_UINT16;\n break;\n case 5:\n matvar->data_type = MAT_T_UINT8;\n break;\n default:\n Mat_VarFree(matvar);\n return NULL;\n }",
" tmp -= data_type*10;\n class_type = (int)floor(tmp / 1.0);\n switch ( class_type ) {\n case 0:\n matvar->class_type = MAT_C_DOUBLE;\n break;\n case 1:\n matvar->class_type = MAT_C_CHAR;\n break;\n case 2:\n matvar->class_type = MAT_C_SPARSE;\n break;\n default:\n Mat_VarFree(matvar);\n return NULL;\n }",
" matvar->rank = 2;\n matvar->dims = (size_t*)calloc(2, sizeof(*matvar->dims));\n if ( NULL == matvar->dims ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n readresult = fread(&tmp,sizeof(int),1,(FILE*)mat->fp);\n if ( mat->byteswap )\n Mat_int32Swap(&tmp);\n matvar->dims[0] = tmp;\n if ( 1 != readresult ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n readresult = fread(&tmp,sizeof(int),1,(FILE*)mat->fp);\n if ( mat->byteswap )\n Mat_int32Swap(&tmp);\n matvar->dims[1] = tmp;\n if ( 1 != readresult ) {\n Mat_VarFree(matvar);\n return NULL;\n }",
" readresult = fread(&(matvar->isComplex),sizeof(int),1,(FILE*)mat->fp);\n if ( 1 != readresult ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n if ( matvar->isComplex && MAT_C_CHAR == matvar->class_type ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n readresult = fread(&tmp,sizeof(int),1,(FILE*)mat->fp);\n if ( 1 != readresult ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n if ( mat->byteswap )\n Mat_int32Swap(&tmp);\n /* Check that the length of the variable name is at least 1 */\n if ( tmp < 1 ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n matvar->name = (char*)malloc(tmp);\n if ( NULL == matvar->name ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n readresult = fread(matvar->name,1,tmp,(FILE*)mat->fp);\n if ( tmp != readresult ) {\n Mat_VarFree(matvar);\n return NULL;",
"",
" }",
" matvar->internal->datapos = ftell((FILE*)mat->fp);\n if ( matvar->internal->datapos == -1L ) {\n Mat_VarFree(matvar);\n Mat_Critical(\"Couldn't determine file position\");\n return NULL;\n }\n {\n int err;\n size_t tmp2 = Mat_SizeOf(matvar->data_type);\n if ( matvar->isComplex )\n tmp2 *= 2;\n err = SafeMulDims(matvar, &tmp2);\n if ( err ) {\n Mat_VarFree(matvar);\n Mat_Critical(\"Integer multiplication overflow\");\n return NULL;\n }",
" nBytes = (long)tmp2;\n }\n (void)fseek((FILE*)mat->fp,nBytes,SEEK_CUR);",
" return matvar;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 3997,
"char_start": 3946,
"chars": " else {\n matvar->name[tmp - 1] = '\\0';\n }"
}
],
"deleted": []
},
"commit_link": "github.com/tbeu/matio/commit/651a8e28099edb5fbb9e4e1d4d3238848f446c9a",
"file_name": "src/mat4.c",
"func_name": "Mat_VarReadNextInfo4",
"line_changes": {
"added": [
{
"char_end": 3954,
"char_start": 3941,
"line": " } else {\n",
"line_no": 155
},
{
"char_end": 3992,
"char_start": 3954,
"line": " matvar->name[tmp - 1] = '\\0';\n",
"line_no": 156
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 385 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"Mat_VarReadNextInfo4(mat_t *mat)\n{\n int M,O,data_type,class_type;\n mat_int32_t tmp;\n long nBytes;\n size_t readresult;\n matvar_t *matvar = NULL;\n union {\n mat_uint32_t u;\n mat_uint8_t c[4];\n } endian;",
" if ( mat == NULL || mat->fp == NULL )\n return NULL;\n else if ( NULL == (matvar = Mat_VarCalloc()) )\n return NULL;",
" readresult = fread(&tmp,sizeof(int),1,(FILE*)mat->fp);\n if ( 1 != readresult ) {\n Mat_VarFree(matvar);\n return NULL;\n }",
" endian.u = 0x01020304;",
" /* See if MOPT may need byteswapping */\n if ( tmp < 0 || tmp > 4052 ) {\n if ( Mat_int32Swap(&tmp) > 4052 ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n }",
" M = (int)floor(tmp / 1000.0);\n switch ( M ) {\n case 0:\n /* IEEE little endian */\n mat->byteswap = endian.c[0] != 4;\n break;\n case 1:\n /* IEEE big endian */\n mat->byteswap = endian.c[0] != 1;\n break;\n default:\n /* VAX, Cray, or bogus */\n Mat_VarFree(matvar);\n return NULL;\n }",
" tmp -= M*1000;\n O = (int)floor(tmp / 100.0);\n /* O must be zero */\n if ( 0 != O ) {\n Mat_VarFree(matvar);\n return NULL;\n }",
" tmp -= O*100;\n data_type = (int)floor(tmp / 10.0);\n /* Convert the V4 data type */\n switch ( data_type ) {\n case 0:\n matvar->data_type = MAT_T_DOUBLE;\n break;\n case 1:\n matvar->data_type = MAT_T_SINGLE;\n break;\n case 2:\n matvar->data_type = MAT_T_INT32;\n break;\n case 3:\n matvar->data_type = MAT_T_INT16;\n break;\n case 4:\n matvar->data_type = MAT_T_UINT16;\n break;\n case 5:\n matvar->data_type = MAT_T_UINT8;\n break;\n default:\n Mat_VarFree(matvar);\n return NULL;\n }",
" tmp -= data_type*10;\n class_type = (int)floor(tmp / 1.0);\n switch ( class_type ) {\n case 0:\n matvar->class_type = MAT_C_DOUBLE;\n break;\n case 1:\n matvar->class_type = MAT_C_CHAR;\n break;\n case 2:\n matvar->class_type = MAT_C_SPARSE;\n break;\n default:\n Mat_VarFree(matvar);\n return NULL;\n }",
" matvar->rank = 2;\n matvar->dims = (size_t*)calloc(2, sizeof(*matvar->dims));\n if ( NULL == matvar->dims ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n readresult = fread(&tmp,sizeof(int),1,(FILE*)mat->fp);\n if ( mat->byteswap )\n Mat_int32Swap(&tmp);\n matvar->dims[0] = tmp;\n if ( 1 != readresult ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n readresult = fread(&tmp,sizeof(int),1,(FILE*)mat->fp);\n if ( mat->byteswap )\n Mat_int32Swap(&tmp);\n matvar->dims[1] = tmp;\n if ( 1 != readresult ) {\n Mat_VarFree(matvar);\n return NULL;\n }",
" readresult = fread(&(matvar->isComplex),sizeof(int),1,(FILE*)mat->fp);\n if ( 1 != readresult ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n if ( matvar->isComplex && MAT_C_CHAR == matvar->class_type ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n readresult = fread(&tmp,sizeof(int),1,(FILE*)mat->fp);\n if ( 1 != readresult ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n if ( mat->byteswap )\n Mat_int32Swap(&tmp);\n /* Check that the length of the variable name is at least 1 */\n if ( tmp < 1 ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n matvar->name = (char*)malloc(tmp);\n if ( NULL == matvar->name ) {\n Mat_VarFree(matvar);\n return NULL;\n }\n readresult = fread(matvar->name,1,tmp,(FILE*)mat->fp);\n if ( tmp != readresult ) {\n Mat_VarFree(matvar);\n return NULL;",
" } else {\n matvar->name[tmp - 1] = '\\0';",
" }",
" matvar->internal->datapos = ftell((FILE*)mat->fp);\n if ( matvar->internal->datapos == -1L ) {\n Mat_VarFree(matvar);\n Mat_Critical(\"Couldn't determine file position\");\n return NULL;\n }\n {\n int err;\n size_t tmp2 = Mat_SizeOf(matvar->data_type);\n if ( matvar->isComplex )\n tmp2 *= 2;\n err = SafeMulDims(matvar, &tmp2);\n if ( err ) {\n Mat_VarFree(matvar);\n Mat_Critical(\"Integer multiplication overflow\");\n return NULL;\n }",
" nBytes = (long)tmp2;\n }\n (void)fseek((FILE*)mat->fp,nBytes,SEEK_CUR);",
" return matvar;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 3997,
"char_start": 3946,
"chars": " else {\n matvar->name[tmp - 1] = '\\0';\n }"
}
],
"deleted": []
},
"commit_link": "github.com/tbeu/matio/commit/651a8e28099edb5fbb9e4e1d4d3238848f446c9a",
"file_name": "src/mat4.c",
"func_name": "Mat_VarReadNextInfo4",
"line_changes": {
"added": [
{
"char_end": 3954,
"char_start": 3941,
"line": " } else {\n",
"line_no": 155
},
{
"char_end": 3992,
"char_start": 3954,
"line": " matvar->name[tmp - 1] = '\\0';\n",
"line_no": 156
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 385 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static x86newTokenType getToken(const char *str, size_t *begin, size_t *end) {",
"",
"\t// Skip whitespace",
"\twhile (begin && isspace ((ut8)str[*begin])) {",
"\t\t++(*begin);\n\t}",
"\tif (!str[*begin]) { // null byte\n\t\t*end = *begin;\n\t\treturn TT_EOF;",
"\t} else if (isalpha ((ut8)str[*begin])) { // word token",
"\t\t*end = *begin;",
"\t\twhile (end && isalnum ((ut8)str[*end])) {",
"\t\t\t++(*end);\n\t\t}\n\t\treturn TT_WORD;",
"\t} else if (isdigit ((ut8)str[*begin])) { // number token",
"\t\t*end = *begin;\n\t\twhile (end && isalnum ((ut8)str[*end])) { // accept alphanumeric characters, because hex.\n\t\t\t++(*end);\n\t\t}\n\t\treturn TT_NUMBER;\n\t} else { // special character: [, ], +, *, ...\n\t\t*end = *begin + 1;\n\t\treturn TT_SPECIAL;\n\t}\n}"
] | [
1,
0,
1,
0,
1,
1,
0,
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 130,
"char_start": 80,
"chars": "if (*begin > strlen (str)) {\n\t\treturn TT_EOF;\n\t}\n\t"
},
{
"char_end": 177,
"char_start": 162,
"chars": " && str[*begin]"
},
{
"char_end": 316,
"char_start": 314,
"chars": "\n\t"
},
{
"char_end": 408,
"char_start": 395,
"chars": " && str[*end]"
},
{
"char_end": 479,
"char_start": 477,
"chars": "\n\t"
}
],
"deleted": [
{
"char_end": 255,
"char_start": 249,
"chars": " else "
},
{
"char_end": 409,
"char_start": 403,
"chars": " else "
}
]
},
"commit_link": "github.com/radare/radare2/commit/66191f780863ea8c66ace4040d0d04a8842e8432",
"file_name": "libr/asm/p/asm_x86_nz.c",
"func_name": "getToken",
"line_changes": {
"added": [
{
"char_end": 109,
"char_start": 79,
"line": "\tif (*begin > strlen (str)) {\n",
"line_no": 2
},
{
"char_end": 126,
"char_start": 109,
"line": "\t\treturn TT_EOF;\n",
"line_no": 3
},
{
"char_end": 129,
"char_start": 126,
"line": "\t}\n",
"line_no": 4
},
{
"char_end": 211,
"char_start": 149,
"line": "\twhile (begin && str[*begin] && isspace ((ut8)str[*begin])) {\n",
"line_no": 6
},
{
"char_end": 315,
"char_start": 312,
"line": "\t}\n",
"line_no": 13
},
{
"char_end": 366,
"char_start": 315,
"line": "\tif (isalpha ((ut8)str[*begin])) { // word token\n",
"line_no": 14
},
{
"char_end": 440,
"char_start": 383,
"line": "\t\twhile (end && str[*end] && isalnum ((ut8)str[*end])) {\n",
"line_no": 16
},
{
"char_end": 478,
"char_start": 475,
"line": "\t}\n",
"line_no": 20
},
{
"char_end": 531,
"char_start": 478,
"line": "\tif (isdigit ((ut8)str[*begin])) { // number token\n",
"line_no": 21
}
],
"deleted": [
{
"char_end": 146,
"char_start": 99,
"line": "\twhile (begin && isspace ((ut8)str[*begin])) {\n",
"line_no": 3
},
{
"char_end": 305,
"char_start": 247,
"line": "\t} else if (isalpha ((ut8)str[*begin])) { // word token\n",
"line_no": 10
},
{
"char_end": 366,
"char_start": 322,
"line": "\t\twhile (end && isalnum ((ut8)str[*end])) {\n",
"line_no": 12
},
{
"char_end": 461,
"char_start": 401,
"line": "\t} else if (isdigit ((ut8)str[*begin])) { // number token\n",
"line_no": 16
}
]
},
"vul_type": "cwe-125"
} | 386 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static x86newTokenType getToken(const char *str, size_t *begin, size_t *end) {",
"\tif (*begin > strlen (str)) {\n\t\treturn TT_EOF;\n\t}",
"\t// Skip whitespace",
"\twhile (begin && str[*begin] && isspace ((ut8)str[*begin])) {",
"\t\t++(*begin);\n\t}",
"\tif (!str[*begin]) { // null byte\n\t\t*end = *begin;\n\t\treturn TT_EOF;",
"\t}\n\tif (isalpha ((ut8)str[*begin])) { // word token",
"\t\t*end = *begin;",
"\t\twhile (end && str[*end] && isalnum ((ut8)str[*end])) {",
"\t\t\t++(*end);\n\t\t}\n\t\treturn TT_WORD;",
"\t}\n\tif (isdigit ((ut8)str[*begin])) { // number token",
"\t\t*end = *begin;\n\t\twhile (end && isalnum ((ut8)str[*end])) { // accept alphanumeric characters, because hex.\n\t\t\t++(*end);\n\t\t}\n\t\treturn TT_NUMBER;\n\t} else { // special character: [, ], +, *, ...\n\t\t*end = *begin + 1;\n\t\treturn TT_SPECIAL;\n\t}\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 130,
"char_start": 80,
"chars": "if (*begin > strlen (str)) {\n\t\treturn TT_EOF;\n\t}\n\t"
},
{
"char_end": 177,
"char_start": 162,
"chars": " && str[*begin]"
},
{
"char_end": 316,
"char_start": 314,
"chars": "\n\t"
},
{
"char_end": 408,
"char_start": 395,
"chars": " && str[*end]"
},
{
"char_end": 479,
"char_start": 477,
"chars": "\n\t"
}
],
"deleted": [
{
"char_end": 255,
"char_start": 249,
"chars": " else "
},
{
"char_end": 409,
"char_start": 403,
"chars": " else "
}
]
},
"commit_link": "github.com/radare/radare2/commit/66191f780863ea8c66ace4040d0d04a8842e8432",
"file_name": "libr/asm/p/asm_x86_nz.c",
"func_name": "getToken",
"line_changes": {
"added": [
{
"char_end": 109,
"char_start": 79,
"line": "\tif (*begin > strlen (str)) {\n",
"line_no": 2
},
{
"char_end": 126,
"char_start": 109,
"line": "\t\treturn TT_EOF;\n",
"line_no": 3
},
{
"char_end": 129,
"char_start": 126,
"line": "\t}\n",
"line_no": 4
},
{
"char_end": 211,
"char_start": 149,
"line": "\twhile (begin && str[*begin] && isspace ((ut8)str[*begin])) {\n",
"line_no": 6
},
{
"char_end": 315,
"char_start": 312,
"line": "\t}\n",
"line_no": 13
},
{
"char_end": 366,
"char_start": 315,
"line": "\tif (isalpha ((ut8)str[*begin])) { // word token\n",
"line_no": 14
},
{
"char_end": 440,
"char_start": 383,
"line": "\t\twhile (end && str[*end] && isalnum ((ut8)str[*end])) {\n",
"line_no": 16
},
{
"char_end": 478,
"char_start": 475,
"line": "\t}\n",
"line_no": 20
},
{
"char_end": 531,
"char_start": 478,
"line": "\tif (isdigit ((ut8)str[*begin])) { // number token\n",
"line_no": 21
}
],
"deleted": [
{
"char_end": 146,
"char_start": 99,
"line": "\twhile (begin && isspace ((ut8)str[*begin])) {\n",
"line_no": 3
},
{
"char_end": 305,
"char_start": 247,
"line": "\t} else if (isalpha ((ut8)str[*begin])) { // word token\n",
"line_no": 10
},
{
"char_end": 366,
"char_start": 322,
"line": "\t\twhile (end && isalnum ((ut8)str[*end])) {\n",
"line_no": 12
},
{
"char_end": 461,
"char_start": 401,
"line": "\t} else if (isdigit ((ut8)str[*begin])) { // number token\n",
"line_no": 16
}
]
},
"vul_type": "cwe-125"
} | 386 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mrb_bool resume, mrb_bool vmexec)\n{\n struct mrb_context *c = fiber_check(mrb, self);\n struct mrb_context *old_c = mrb->c;",
"",
" mrb_value value;",
" fiber_check_cfunc(mrb, c);",
" if (resume && c->status == MRB_FIBER_TRANSFERRED) {",
" mrb_raise(mrb, E_FIBER_ERROR, \"resuming transferred fiber\");\n }",
" if (c->status == MRB_FIBER_RUNNING || c->status == MRB_FIBER_RESUMED) {",
" mrb_raise(mrb, E_FIBER_ERROR, \"double resume (fib)\");\n }",
" if (c->status == MRB_FIBER_TERMINATED) {",
" mrb_raise(mrb, E_FIBER_ERROR, \"resuming dead fiber\");\n }",
" mrb->c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;",
" c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);",
" if (c->status == MRB_FIBER_CREATED) {",
" mrb_value *b, *e;\n",
" if (len >= c->stend - c->stack) {\n mrb_raise(mrb, E_FIBER_ERROR, \"too many arguments to fiber\");\n }",
" b = c->stack+1;\n e = b + len;\n while (b<e) {\n *b++ = *a++;\n }\n c->cibase->argc = (int)len;\n value = c->stack[0] = MRB_PROC_ENV(c->ci->proc)->stack[0];\n }\n else {\n value = fiber_result(mrb, a, len);\n }",
" fiber_switch_context(mrb, c);",
"\n if (vmexec) {\n c->vmexec = TRUE;\n value = mrb_vm_exec(mrb, c->ci[-1].proc, c->ci->pc);\n mrb->c = old_c;\n }\n else {\n MARK_CONTEXT_MODIFY(c);\n }\n return value;\n}"
] | [
1,
0,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 235,
"char_start": 204,
"chars": "enum mrb_fiber_state status;\n "
},
{
"char_end": 306,
"char_start": 284,
"chars": "status = c->status;\n "
},
{
"char_end": 662,
"char_start": 658,
"chars": "old_"
},
{
"char_end": 825,
"char_start": 793,
"chars": "fiber_switch_context(mrb, c);\n "
},
{
"char_end": 891,
"char_start": 887,
"chars": "mrb_"
},
{
"char_end": 903,
"char_start": 898,
"chars": "xtend"
},
{
"char_end": 910,
"char_start": 909,
"chars": "l"
},
{
"char_end": 916,
"char_start": 912,
"chars": "+2);"
},
{
"char_end": 919,
"char_start": 917,
"chars": "/*"
},
{
"char_end": 928,
"char_start": 921,
"chars": "or rece"
},
{
"char_end": 930,
"char_start": 929,
"chars": "v"
},
{
"char_end": 936,
"char_start": 933,
"chars": "and"
},
{
"char_end": 947,
"char_start": 937,
"chars": "(optional)"
},
{
"char_end": 953,
"char_start": 948,
"chars": "block"
},
{
"char_end": 956,
"char_start": 954,
"chars": "*/"
}
],
"deleted": [
{
"char_end": 270,
"char_start": 267,
"chars": "c->"
},
{
"char_end": 383,
"char_start": 380,
"chars": "c->"
},
{
"char_end": 417,
"char_start": 414,
"chars": "c->"
},
{
"char_end": 519,
"char_start": 516,
"chars": "c->"
},
{
"char_end": 622,
"char_start": 617,
"chars": "mrb->"
},
{
"char_end": 760,
"char_start": 757,
"chars": "c->"
},
{
"char_end": 843,
"char_start": 818,
"chars": "if (len >= c->stend - c->"
},
{
"char_end": 861,
"char_start": 848,
"chars": ") {\n mrb"
},
{
"char_end": 866,
"char_start": 862,
"chars": "rais"
},
{
"char_end": 887,
"char_start": 873,
"chars": "E_FIBER_ERROR,"
},
{
"char_end": 891,
"char_start": 888,
"chars": "\"to"
},
{
"char_end": 897,
"char_start": 893,
"chars": "many"
},
{
"char_end": 904,
"char_start": 899,
"chars": "rgume"
},
{
"char_end": 907,
"char_start": 905,
"chars": "ts"
},
{
"char_end": 909,
"char_start": 908,
"chars": "t"
},
{
"char_end": 912,
"char_start": 910,
"chars": " f"
},
{
"char_end": 917,
"char_start": 913,
"chars": "ber\""
},
{
"char_end": 920,
"char_start": 918,
"chars": ";\n"
},
{
"char_end": 923,
"char_start": 921,
"chars": " "
},
{
"char_end": 925,
"char_start": 924,
"chars": "}"
},
{
"char_end": 1188,
"char_start": 1156,
"chars": "\n fiber_switch_context(mrb, c);"
}
]
},
"commit_link": "github.com/mruby/mruby/commit/778500563a9f7ceba996937dc886bd8cde29b42b",
"file_name": "mrbgems/mruby-fiber/src/fiber.c",
"func_name": "fiber_switch",
"line_changes": {
"added": [
{
"char_end": 233,
"char_start": 202,
"line": " enum mrb_fiber_state status;\n",
"line_no": 5
},
{
"char_end": 304,
"char_start": 282,
"line": " status = c->status;\n",
"line_no": 9
},
{
"char_end": 355,
"char_start": 304,
"line": " if (resume && status == MRB_FIBER_TRANSFERRED) {\n",
"line_no": 10
},
{
"char_end": 492,
"char_start": 424,
"line": " if (status == MRB_FIBER_RUNNING || status == MRB_FIBER_RESUMED) {\n",
"line_no": 13
},
{
"char_end": 594,
"char_start": 554,
"line": " if (status == MRB_FIBER_TERMINATED) {\n",
"line_no": 16
},
{
"char_end": 726,
"char_start": 656,
"line": " old_c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;\n",
"line_no": 19
},
{
"char_end": 823,
"char_start": 791,
"line": " fiber_switch_context(mrb, c);\n",
"line_no": 21
},
{
"char_end": 860,
"char_start": 823,
"line": " if (status == MRB_FIBER_CREATED) {\n",
"line_no": 22
},
{
"char_end": 957,
"char_start": 883,
"line": " mrb_stack_extend(mrb, len+2); /* for receiver and (optional) block */\n",
"line_no": 25
}
],
"deleted": [
{
"char_end": 305,
"char_start": 251,
"line": " if (resume && c->status == MRB_FIBER_TRANSFERRED) {\n",
"line_no": 8
},
{
"char_end": 448,
"char_start": 374,
"line": " if (c->status == MRB_FIBER_RUNNING || c->status == MRB_FIBER_RESUMED) {\n",
"line_no": 11
},
{
"char_end": 553,
"char_start": 510,
"line": " if (c->status == MRB_FIBER_TERMINATED) {\n",
"line_no": 14
},
{
"char_end": 686,
"char_start": 615,
"line": " mrb->c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;\n",
"line_no": 17
},
{
"char_end": 791,
"char_start": 751,
"line": " if (c->status == MRB_FIBER_CREATED) {\n",
"line_no": 19
},
{
"char_end": 852,
"char_start": 814,
"line": " if (len >= c->stend - c->stack) {\n",
"line_no": 22
},
{
"char_end": 920,
"char_start": 852,
"line": " mrb_raise(mrb, E_FIBER_ERROR, \"too many arguments to fiber\");\n",
"line_no": 23
},
{
"char_end": 926,
"char_start": 920,
"line": " }\n",
"line_no": 24
},
{
"char_end": 1189,
"char_start": 1157,
"line": " fiber_switch_context(mrb, c);\n",
"line_no": 36
}
]
},
"vul_type": "cwe-125"
} | 387 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mrb_bool resume, mrb_bool vmexec)\n{\n struct mrb_context *c = fiber_check(mrb, self);\n struct mrb_context *old_c = mrb->c;",
" enum mrb_fiber_state status;",
" mrb_value value;",
" fiber_check_cfunc(mrb, c);",
" status = c->status;\n if (resume && status == MRB_FIBER_TRANSFERRED) {",
" mrb_raise(mrb, E_FIBER_ERROR, \"resuming transferred fiber\");\n }",
" if (status == MRB_FIBER_RUNNING || status == MRB_FIBER_RESUMED) {",
" mrb_raise(mrb, E_FIBER_ERROR, \"double resume (fib)\");\n }",
" if (status == MRB_FIBER_TERMINATED) {",
" mrb_raise(mrb, E_FIBER_ERROR, \"resuming dead fiber\");\n }",
" old_c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;",
" c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);",
" fiber_switch_context(mrb, c);\n if (status == MRB_FIBER_CREATED) {",
" mrb_value *b, *e;\n",
" mrb_stack_extend(mrb, len+2); /* for receiver and (optional) block */",
" b = c->stack+1;\n e = b + len;\n while (b<e) {\n *b++ = *a++;\n }\n c->cibase->argc = (int)len;\n value = c->stack[0] = MRB_PROC_ENV(c->ci->proc)->stack[0];\n }\n else {\n value = fiber_result(mrb, a, len);\n }",
"",
"\n if (vmexec) {\n c->vmexec = TRUE;\n value = mrb_vm_exec(mrb, c->ci[-1].proc, c->ci->pc);\n mrb->c = old_c;\n }\n else {\n MARK_CONTEXT_MODIFY(c);\n }\n return value;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 235,
"char_start": 204,
"chars": "enum mrb_fiber_state status;\n "
},
{
"char_end": 306,
"char_start": 284,
"chars": "status = c->status;\n "
},
{
"char_end": 662,
"char_start": 658,
"chars": "old_"
},
{
"char_end": 825,
"char_start": 793,
"chars": "fiber_switch_context(mrb, c);\n "
},
{
"char_end": 891,
"char_start": 887,
"chars": "mrb_"
},
{
"char_end": 903,
"char_start": 898,
"chars": "xtend"
},
{
"char_end": 910,
"char_start": 909,
"chars": "l"
},
{
"char_end": 916,
"char_start": 912,
"chars": "+2);"
},
{
"char_end": 919,
"char_start": 917,
"chars": "/*"
},
{
"char_end": 928,
"char_start": 921,
"chars": "or rece"
},
{
"char_end": 930,
"char_start": 929,
"chars": "v"
},
{
"char_end": 936,
"char_start": 933,
"chars": "and"
},
{
"char_end": 947,
"char_start": 937,
"chars": "(optional)"
},
{
"char_end": 953,
"char_start": 948,
"chars": "block"
},
{
"char_end": 956,
"char_start": 954,
"chars": "*/"
}
],
"deleted": [
{
"char_end": 270,
"char_start": 267,
"chars": "c->"
},
{
"char_end": 383,
"char_start": 380,
"chars": "c->"
},
{
"char_end": 417,
"char_start": 414,
"chars": "c->"
},
{
"char_end": 519,
"char_start": 516,
"chars": "c->"
},
{
"char_end": 622,
"char_start": 617,
"chars": "mrb->"
},
{
"char_end": 760,
"char_start": 757,
"chars": "c->"
},
{
"char_end": 843,
"char_start": 818,
"chars": "if (len >= c->stend - c->"
},
{
"char_end": 861,
"char_start": 848,
"chars": ") {\n mrb"
},
{
"char_end": 866,
"char_start": 862,
"chars": "rais"
},
{
"char_end": 887,
"char_start": 873,
"chars": "E_FIBER_ERROR,"
},
{
"char_end": 891,
"char_start": 888,
"chars": "\"to"
},
{
"char_end": 897,
"char_start": 893,
"chars": "many"
},
{
"char_end": 904,
"char_start": 899,
"chars": "rgume"
},
{
"char_end": 907,
"char_start": 905,
"chars": "ts"
},
{
"char_end": 909,
"char_start": 908,
"chars": "t"
},
{
"char_end": 912,
"char_start": 910,
"chars": " f"
},
{
"char_end": 917,
"char_start": 913,
"chars": "ber\""
},
{
"char_end": 920,
"char_start": 918,
"chars": ";\n"
},
{
"char_end": 923,
"char_start": 921,
"chars": " "
},
{
"char_end": 925,
"char_start": 924,
"chars": "}"
},
{
"char_end": 1188,
"char_start": 1156,
"chars": "\n fiber_switch_context(mrb, c);"
}
]
},
"commit_link": "github.com/mruby/mruby/commit/778500563a9f7ceba996937dc886bd8cde29b42b",
"file_name": "mrbgems/mruby-fiber/src/fiber.c",
"func_name": "fiber_switch",
"line_changes": {
"added": [
{
"char_end": 233,
"char_start": 202,
"line": " enum mrb_fiber_state status;\n",
"line_no": 5
},
{
"char_end": 304,
"char_start": 282,
"line": " status = c->status;\n",
"line_no": 9
},
{
"char_end": 355,
"char_start": 304,
"line": " if (resume && status == MRB_FIBER_TRANSFERRED) {\n",
"line_no": 10
},
{
"char_end": 492,
"char_start": 424,
"line": " if (status == MRB_FIBER_RUNNING || status == MRB_FIBER_RESUMED) {\n",
"line_no": 13
},
{
"char_end": 594,
"char_start": 554,
"line": " if (status == MRB_FIBER_TERMINATED) {\n",
"line_no": 16
},
{
"char_end": 726,
"char_start": 656,
"line": " old_c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;\n",
"line_no": 19
},
{
"char_end": 823,
"char_start": 791,
"line": " fiber_switch_context(mrb, c);\n",
"line_no": 21
},
{
"char_end": 860,
"char_start": 823,
"line": " if (status == MRB_FIBER_CREATED) {\n",
"line_no": 22
},
{
"char_end": 957,
"char_start": 883,
"line": " mrb_stack_extend(mrb, len+2); /* for receiver and (optional) block */\n",
"line_no": 25
}
],
"deleted": [
{
"char_end": 305,
"char_start": 251,
"line": " if (resume && c->status == MRB_FIBER_TRANSFERRED) {\n",
"line_no": 8
},
{
"char_end": 448,
"char_start": 374,
"line": " if (c->status == MRB_FIBER_RUNNING || c->status == MRB_FIBER_RESUMED) {\n",
"line_no": 11
},
{
"char_end": 553,
"char_start": 510,
"line": " if (c->status == MRB_FIBER_TERMINATED) {\n",
"line_no": 14
},
{
"char_end": 686,
"char_start": 615,
"line": " mrb->c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;\n",
"line_no": 17
},
{
"char_end": 791,
"char_start": 751,
"line": " if (c->status == MRB_FIBER_CREATED) {\n",
"line_no": 19
},
{
"char_end": 852,
"char_start": 814,
"line": " if (len >= c->stend - c->stack) {\n",
"line_no": 22
},
{
"char_end": 920,
"char_start": 852,
"line": " mrb_raise(mrb, E_FIBER_ERROR, \"too many arguments to fiber\");\n",
"line_no": 23
},
{
"char_end": 926,
"char_start": 920,
"line": " }\n",
"line_no": 24
},
{
"char_end": 1189,
"char_start": 1157,
"line": " fiber_switch_context(mrb, c);\n",
"line_no": 36
}
]
},
"vul_type": "cwe-125"
} | 387 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)\n{\n ppm_source_ptr source = (ppm_source_ptr)sinfo;\n int c;\n unsigned int w, h, maxval;\n boolean need_iobuffer, use_raw_buffer, need_rescale;",
" if (getc(source->pub.input_file) != 'P')\n ERREXIT(cinfo, JERR_PPM_NOT);",
" c = getc(source->pub.input_file); /* subformat discriminator character */",
" /* detect unsupported variants (ie, PBM) before trying to read header */\n switch (c) {\n case '2': /* it's a text-format PGM file */\n case '3': /* it's a text-format PPM file */\n case '5': /* it's a raw-format PGM file */\n case '6': /* it's a raw-format PPM file */\n break;\n default:\n ERREXIT(cinfo, JERR_PPM_NOT);\n break;\n }",
" /* fetch the remaining header info */\n w = read_pbm_integer(cinfo, source->pub.input_file, 65535);\n h = read_pbm_integer(cinfo, source->pub.input_file, 65535);\n maxval = read_pbm_integer(cinfo, source->pub.input_file, 65535);",
" if (w <= 0 || h <= 0 || maxval <= 0) /* error check */\n ERREXIT(cinfo, JERR_PPM_NOT);",
" cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */\n cinfo->image_width = (JDIMENSION)w;\n cinfo->image_height = (JDIMENSION)h;\n source->maxval = maxval;",
" /* initialize flags to most common settings */\n need_iobuffer = TRUE; /* do we need an I/O buffer? */\n use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */\n need_rescale = TRUE; /* do we need a rescale array? */",
" switch (c) {\n case '2': /* it's a text-format PGM file */\n if (cinfo->in_color_space == JCS_UNKNOWN)\n cinfo->in_color_space = JCS_GRAYSCALE;\n TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h);\n if (cinfo->in_color_space == JCS_GRAYSCALE)\n source->pub.get_pixel_rows = get_text_gray_row;\n else if (IsExtRGB(cinfo->in_color_space))\n source->pub.get_pixel_rows = get_text_gray_rgb_row;\n else if (cinfo->in_color_space == JCS_CMYK)\n source->pub.get_pixel_rows = get_text_gray_cmyk_row;\n else\n ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n need_iobuffer = FALSE;\n break;",
" case '3': /* it's a text-format PPM file */\n if (cinfo->in_color_space == JCS_UNKNOWN)\n cinfo->in_color_space = JCS_EXT_RGB;\n TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h);\n if (IsExtRGB(cinfo->in_color_space))\n source->pub.get_pixel_rows = get_text_rgb_row;\n else if (cinfo->in_color_space == JCS_CMYK)\n source->pub.get_pixel_rows = get_text_rgb_cmyk_row;\n else\n ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n need_iobuffer = FALSE;\n break;",
" case '5': /* it's a raw-format PGM file */\n if (cinfo->in_color_space == JCS_UNKNOWN)\n cinfo->in_color_space = JCS_GRAYSCALE;\n TRACEMS2(cinfo, 1, JTRC_PGM, w, h);\n if (maxval > 255) {\n source->pub.get_pixel_rows = get_word_gray_row;\n } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR) &&\n cinfo->in_color_space == JCS_GRAYSCALE) {\n source->pub.get_pixel_rows = get_raw_row;\n use_raw_buffer = TRUE;\n need_rescale = FALSE;\n } else {\n if (cinfo->in_color_space == JCS_GRAYSCALE)\n source->pub.get_pixel_rows = get_scaled_gray_row;\n else if (IsExtRGB(cinfo->in_color_space))\n source->pub.get_pixel_rows = get_gray_rgb_row;\n else if (cinfo->in_color_space == JCS_CMYK)\n source->pub.get_pixel_rows = get_gray_cmyk_row;\n else\n ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n }\n break;",
" case '6': /* it's a raw-format PPM file */\n if (cinfo->in_color_space == JCS_UNKNOWN)\n cinfo->in_color_space = JCS_EXT_RGB;\n TRACEMS2(cinfo, 1, JTRC_PPM, w, h);\n if (maxval > 255) {\n source->pub.get_pixel_rows = get_word_rgb_row;\n } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR) &&\n (cinfo->in_color_space == JCS_EXT_RGB\n#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3\n || cinfo->in_color_space == JCS_RGB\n#endif\n )) {\n source->pub.get_pixel_rows = get_raw_row;\n use_raw_buffer = TRUE;\n need_rescale = FALSE;\n } else {\n if (IsExtRGB(cinfo->in_color_space))\n source->pub.get_pixel_rows = get_rgb_row;\n else if (cinfo->in_color_space == JCS_CMYK)\n source->pub.get_pixel_rows = get_rgb_cmyk_row;\n else\n ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n }\n break;\n }",
" if (IsExtRGB(cinfo->in_color_space))\n cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];\n else if (cinfo->in_color_space == JCS_GRAYSCALE)\n cinfo->input_components = 1;\n else if (cinfo->in_color_space == JCS_CMYK)\n cinfo->input_components = 4;",
" /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */\n if (need_iobuffer) {\n if (c == '6')\n source->buffer_width = (size_t)w * 3 *\n ((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));\n else\n source->buffer_width = (size_t)w *\n ((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));\n source->iobuffer = (U_CHAR *)\n (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,\n source->buffer_width);\n }",
" /* Create compressor input buffer. */\n if (use_raw_buffer) {\n /* For unscaled raw-input case, we can just map it onto the I/O buffer. */\n /* Synthesize a JSAMPARRAY pointer structure */\n source->pixrow = (JSAMPROW)source->iobuffer;\n source->pub.buffer = &source->pixrow;\n source->pub.buffer_height = 1;\n } else {\n /* Need to translate anyway, so make a separate sample buffer. */\n source->pub.buffer = (*cinfo->mem->alloc_sarray)\n ((j_common_ptr)cinfo, JPOOL_IMAGE,\n (JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);\n source->pub.buffer_height = 1;\n }",
" /* Compute the rescaling array if required. */\n if (need_rescale) {\n long val, half_maxval;",
" /* On 16-bit-int machines we have to be careful of maxval = 65535 */\n source->rescale = (JSAMPLE *)\n (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,",
" (size_t)(((long)maxval + 1L) *",
" sizeof(JSAMPLE)));\n half_maxval = maxval / 2;\n for (val = 0; val <= (long)maxval; val++) {\n /* The multiplication here must be done in 32 bits to avoid overflow */\n source->rescale[val] = (JSAMPLE)((val * MAXJSAMPLE + half_maxval) /\n maxval);\n }\n }\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 6241,
"char_start": 6237,
"chars": "MAX("
},
{
"char_end": 6253,
"char_start": 6247,
"chars": ", 255)"
}
],
"deleted": []
},
"commit_link": "github.com/libjpeg-turbo/libjpeg-turbo/commit/3de15e0c344d11d4b90f4a47136467053eb2d09a",
"file_name": "rdppm.c",
"func_name": "start_input_ppm",
"line_changes": {
"added": [
{
"char_end": 6262,
"char_start": 6187,
"line": " (size_t)(((long)MAX(maxval, 255) + 1L) *\n",
"line_no": 163
}
],
"deleted": [
{
"char_end": 6252,
"char_start": 6187,
"line": " (size_t)(((long)maxval + 1L) *\n",
"line_no": 163
}
]
},
"vul_type": "cwe-125"
} | 388 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)\n{\n ppm_source_ptr source = (ppm_source_ptr)sinfo;\n int c;\n unsigned int w, h, maxval;\n boolean need_iobuffer, use_raw_buffer, need_rescale;",
" if (getc(source->pub.input_file) != 'P')\n ERREXIT(cinfo, JERR_PPM_NOT);",
" c = getc(source->pub.input_file); /* subformat discriminator character */",
" /* detect unsupported variants (ie, PBM) before trying to read header */\n switch (c) {\n case '2': /* it's a text-format PGM file */\n case '3': /* it's a text-format PPM file */\n case '5': /* it's a raw-format PGM file */\n case '6': /* it's a raw-format PPM file */\n break;\n default:\n ERREXIT(cinfo, JERR_PPM_NOT);\n break;\n }",
" /* fetch the remaining header info */\n w = read_pbm_integer(cinfo, source->pub.input_file, 65535);\n h = read_pbm_integer(cinfo, source->pub.input_file, 65535);\n maxval = read_pbm_integer(cinfo, source->pub.input_file, 65535);",
" if (w <= 0 || h <= 0 || maxval <= 0) /* error check */\n ERREXIT(cinfo, JERR_PPM_NOT);",
" cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */\n cinfo->image_width = (JDIMENSION)w;\n cinfo->image_height = (JDIMENSION)h;\n source->maxval = maxval;",
" /* initialize flags to most common settings */\n need_iobuffer = TRUE; /* do we need an I/O buffer? */\n use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */\n need_rescale = TRUE; /* do we need a rescale array? */",
" switch (c) {\n case '2': /* it's a text-format PGM file */\n if (cinfo->in_color_space == JCS_UNKNOWN)\n cinfo->in_color_space = JCS_GRAYSCALE;\n TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h);\n if (cinfo->in_color_space == JCS_GRAYSCALE)\n source->pub.get_pixel_rows = get_text_gray_row;\n else if (IsExtRGB(cinfo->in_color_space))\n source->pub.get_pixel_rows = get_text_gray_rgb_row;\n else if (cinfo->in_color_space == JCS_CMYK)\n source->pub.get_pixel_rows = get_text_gray_cmyk_row;\n else\n ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n need_iobuffer = FALSE;\n break;",
" case '3': /* it's a text-format PPM file */\n if (cinfo->in_color_space == JCS_UNKNOWN)\n cinfo->in_color_space = JCS_EXT_RGB;\n TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h);\n if (IsExtRGB(cinfo->in_color_space))\n source->pub.get_pixel_rows = get_text_rgb_row;\n else if (cinfo->in_color_space == JCS_CMYK)\n source->pub.get_pixel_rows = get_text_rgb_cmyk_row;\n else\n ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n need_iobuffer = FALSE;\n break;",
" case '5': /* it's a raw-format PGM file */\n if (cinfo->in_color_space == JCS_UNKNOWN)\n cinfo->in_color_space = JCS_GRAYSCALE;\n TRACEMS2(cinfo, 1, JTRC_PGM, w, h);\n if (maxval > 255) {\n source->pub.get_pixel_rows = get_word_gray_row;\n } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR) &&\n cinfo->in_color_space == JCS_GRAYSCALE) {\n source->pub.get_pixel_rows = get_raw_row;\n use_raw_buffer = TRUE;\n need_rescale = FALSE;\n } else {\n if (cinfo->in_color_space == JCS_GRAYSCALE)\n source->pub.get_pixel_rows = get_scaled_gray_row;\n else if (IsExtRGB(cinfo->in_color_space))\n source->pub.get_pixel_rows = get_gray_rgb_row;\n else if (cinfo->in_color_space == JCS_CMYK)\n source->pub.get_pixel_rows = get_gray_cmyk_row;\n else\n ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n }\n break;",
" case '6': /* it's a raw-format PPM file */\n if (cinfo->in_color_space == JCS_UNKNOWN)\n cinfo->in_color_space = JCS_EXT_RGB;\n TRACEMS2(cinfo, 1, JTRC_PPM, w, h);\n if (maxval > 255) {\n source->pub.get_pixel_rows = get_word_rgb_row;\n } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR) &&\n (cinfo->in_color_space == JCS_EXT_RGB\n#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3\n || cinfo->in_color_space == JCS_RGB\n#endif\n )) {\n source->pub.get_pixel_rows = get_raw_row;\n use_raw_buffer = TRUE;\n need_rescale = FALSE;\n } else {\n if (IsExtRGB(cinfo->in_color_space))\n source->pub.get_pixel_rows = get_rgb_row;\n else if (cinfo->in_color_space == JCS_CMYK)\n source->pub.get_pixel_rows = get_rgb_cmyk_row;\n else\n ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n }\n break;\n }",
" if (IsExtRGB(cinfo->in_color_space))\n cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];\n else if (cinfo->in_color_space == JCS_GRAYSCALE)\n cinfo->input_components = 1;\n else if (cinfo->in_color_space == JCS_CMYK)\n cinfo->input_components = 4;",
" /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */\n if (need_iobuffer) {\n if (c == '6')\n source->buffer_width = (size_t)w * 3 *\n ((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));\n else\n source->buffer_width = (size_t)w *\n ((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));\n source->iobuffer = (U_CHAR *)\n (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,\n source->buffer_width);\n }",
" /* Create compressor input buffer. */\n if (use_raw_buffer) {\n /* For unscaled raw-input case, we can just map it onto the I/O buffer. */\n /* Synthesize a JSAMPARRAY pointer structure */\n source->pixrow = (JSAMPROW)source->iobuffer;\n source->pub.buffer = &source->pixrow;\n source->pub.buffer_height = 1;\n } else {\n /* Need to translate anyway, so make a separate sample buffer. */\n source->pub.buffer = (*cinfo->mem->alloc_sarray)\n ((j_common_ptr)cinfo, JPOOL_IMAGE,\n (JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);\n source->pub.buffer_height = 1;\n }",
" /* Compute the rescaling array if required. */\n if (need_rescale) {\n long val, half_maxval;",
" /* On 16-bit-int machines we have to be careful of maxval = 65535 */\n source->rescale = (JSAMPLE *)\n (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,",
" (size_t)(((long)MAX(maxval, 255) + 1L) *",
" sizeof(JSAMPLE)));\n half_maxval = maxval / 2;\n for (val = 0; val <= (long)maxval; val++) {\n /* The multiplication here must be done in 32 bits to avoid overflow */\n source->rescale[val] = (JSAMPLE)((val * MAXJSAMPLE + half_maxval) /\n maxval);\n }\n }\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 6241,
"char_start": 6237,
"chars": "MAX("
},
{
"char_end": 6253,
"char_start": 6247,
"chars": ", 255)"
}
],
"deleted": []
},
"commit_link": "github.com/libjpeg-turbo/libjpeg-turbo/commit/3de15e0c344d11d4b90f4a47136467053eb2d09a",
"file_name": "rdppm.c",
"func_name": "start_input_ppm",
"line_changes": {
"added": [
{
"char_end": 6262,
"char_start": 6187,
"line": " (size_t)(((long)MAX(maxval, 255) + 1L) *\n",
"line_no": 163
}
],
"deleted": [
{
"char_end": 6252,
"char_start": 6187,
"line": " (size_t)(((long)maxval + 1L) *\n",
"line_no": 163
}
]
},
"vul_type": "cwe-125"
} | 388 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)\n{\n\tstruct usb_device *dev = chip->dev;\n\tstruct usb_host_interface *host_iface;\n\tstruct usb_interface_descriptor *altsd;\n\tvoid *control_header;\n\tint i, protocol;",
"",
"\n\t/* find audiocontrol interface */\n\thost_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0];\n\tcontrol_header = snd_usb_find_csint_desc(host_iface->extra,\n\t\t\t\t\t\t host_iface->extralen,\n\t\t\t\t\t\t NULL, UAC_HEADER);\n\taltsd = get_iface_desc(host_iface);\n\tprotocol = altsd->bInterfaceProtocol;",
"\tif (!control_header) {\n\t\tdev_err(&dev->dev, \"cannot find UAC_HEADER\\n\");\n\t\treturn -EINVAL;\n\t}\n",
"",
"\tswitch (protocol) {\n\tdefault:\n\t\tdev_warn(&dev->dev,\n\t\t\t \"unknown interface protocol %#02x, assuming v1\\n\",\n\t\t\t protocol);\n\t\t/* fall through */",
"\tcase UAC_VERSION_1: {\n\t\tstruct uac1_ac_header_descriptor *h1 = control_header;\n",
"",
"\t\tif (!h1->bInCollection) {\n\t\t\tdev_info(&dev->dev, \"skipping empty audio interface (v1)\\n\");",
"",
"\t\t\treturn -EINVAL;\n\t\t}",
"\t\tif (h1->bLength < sizeof(*h1) + h1->bInCollection) {\n\t\t\tdev_err(&dev->dev, \"invalid UAC_HEADER (v1)\\n\");\n\t\t\treturn -EINVAL;\n\t\t}",
"\t\tfor (i = 0; i < h1->bInCollection; i++)\n\t\t\tsnd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]);",
"\t\tbreak;\n\t}",
"\tcase UAC_VERSION_2: {\n\t\tstruct usb_interface_assoc_descriptor *assoc =\n\t\t\tusb_ifnum_to_if(dev, ctrlif)->intf_assoc;",
"\t\tif (!assoc) {\n\t\t\t/*\n\t\t\t * Firmware writers cannot count to three. So to find\n\t\t\t * the IAD on the NuForce UDH-100, also check the next\n\t\t\t * interface.\n\t\t\t */\n\t\t\tstruct usb_interface *iface =\n\t\t\t\tusb_ifnum_to_if(dev, ctrlif + 1);\n\t\t\tif (iface &&\n\t\t\t iface->intf_assoc &&\n\t\t\t iface->intf_assoc->bFunctionClass == USB_CLASS_AUDIO &&\n\t\t\t iface->intf_assoc->bFunctionProtocol == UAC_VERSION_2)\n\t\t\t\tassoc = iface->intf_assoc;\n\t\t}",
"\t\tif (!assoc) {\n\t\t\tdev_err(&dev->dev, \"Audio class v2 interfaces need an interface association\\n\");\n\t\t\treturn -EINVAL;\n\t\t}",
"\t\tfor (i = 0; i < assoc->bInterfaceCount; i++) {\n\t\t\tint intf = assoc->bFirstInterface + i;",
"\t\t\tif (intf != ctrlif)\n\t\t\t\tsnd_usb_create_stream(chip, ctrlif, intf);\n\t\t}",
"\t\tbreak;\n\t}\n\t}",
"\treturn 0;\n}"
] | [
1,
0,
1,
1,
0,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 252,
"char_start": 235,
"chars": "\tint rest_bytes;\n"
},
{
"char_end": 872,
"char_start": 638,
"chars": "rest_bytes = (void *)(host_iface->extra + host_iface->extralen) -\n\t\tcontrol_header;\n\n\t/* just to be sure -- this shouldn't hit at all */\n\tif (rest_bytes <= 0) {\n\t\tdev_err(&dev->dev, \"invalid control header\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t"
},
{
"char_end": 1220,
"char_start": 1103,
"chars": "rest_bytes < sizeof(*h1)) {\n\t\t\tdev_err(&dev->dev, \"too short v1 buffer descriptor\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif ("
},
{
"char_end": 1409,
"char_start": 1296,
"chars": " (v1)\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (rest_bytes < h1->bLength) {\n\t\t\tdev_err(&dev->dev, \"invalid buffer length"
}
],
"deleted": []
},
"commit_link": "github.com/torvalds/linux/commit/bfc81a8bc18e3c4ba0cbaa7666ff76be2f998991",
"file_name": "sound/usb/card.c",
"func_name": "snd_usb_create_streams",
"line_changes": {
"added": [
{
"char_end": 252,
"char_start": 235,
"line": "\tint rest_bytes;\n",
"line_no": 8
},
{
"char_end": 704,
"char_start": 637,
"line": "\trest_bytes = (void *)(host_iface->extra + host_iface->extralen) -\n",
"line_no": 23
},
{
"char_end": 722,
"char_start": 704,
"line": "\t\tcontrol_header;\n",
"line_no": 24
},
{
"char_end": 723,
"char_start": 722,
"line": "\n",
"line_no": 25
},
{
"char_end": 775,
"char_start": 723,
"line": "\t/* just to be sure -- this shouldn't hit at all */\n",
"line_no": 26
},
{
"char_end": 799,
"char_start": 775,
"line": "\tif (rest_bytes <= 0) {\n",
"line_no": 27
},
{
"char_end": 849,
"char_start": 799,
"line": "\t\tdev_err(&dev->dev, \"invalid control header\\n\");\n",
"line_no": 28
},
{
"char_end": 867,
"char_start": 849,
"line": "\t\treturn -EINVAL;\n",
"line_no": 29
},
{
"char_end": 870,
"char_start": 867,
"line": "\t}\n",
"line_no": 30
},
{
"char_end": 871,
"char_start": 870,
"line": "\n",
"line_no": 31
},
{
"char_end": 1131,
"char_start": 1097,
"line": "\t\tif (rest_bytes < sizeof(*h1)) {\n",
"line_no": 42
},
{
"char_end": 1190,
"char_start": 1131,
"line": "\t\t\tdev_err(&dev->dev, \"too short v1 buffer descriptor\\n\");\n",
"line_no": 43
},
{
"char_end": 1209,
"char_start": 1190,
"line": "\t\t\treturn -EINVAL;\n",
"line_no": 44
},
{
"char_end": 1213,
"char_start": 1209,
"line": "\t\t}\n",
"line_no": 45
},
{
"char_end": 1214,
"char_start": 1213,
"line": "\n",
"line_no": 46
},
{
"char_end": 1365,
"char_start": 1331,
"line": "\t\tif (rest_bytes < h1->bLength) {\n",
"line_no": 52
},
{
"char_end": 1420,
"char_start": 1365,
"line": "\t\t\tdev_err(&dev->dev, \"invalid buffer length (v1)\\n\");\n",
"line_no": 53
},
{
"char_end": 1439,
"char_start": 1420,
"line": "\t\t\treturn -EINVAL;\n",
"line_no": 54
},
{
"char_end": 1443,
"char_start": 1439,
"line": "\t\t}\n",
"line_no": 55
},
{
"char_end": 1444,
"char_start": 1443,
"line": "\n",
"line_no": 56
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 389 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)\n{\n\tstruct usb_device *dev = chip->dev;\n\tstruct usb_host_interface *host_iface;\n\tstruct usb_interface_descriptor *altsd;\n\tvoid *control_header;\n\tint i, protocol;",
"\tint rest_bytes;",
"\n\t/* find audiocontrol interface */\n\thost_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0];\n\tcontrol_header = snd_usb_find_csint_desc(host_iface->extra,\n\t\t\t\t\t\t host_iface->extralen,\n\t\t\t\t\t\t NULL, UAC_HEADER);\n\taltsd = get_iface_desc(host_iface);\n\tprotocol = altsd->bInterfaceProtocol;",
"\tif (!control_header) {\n\t\tdev_err(&dev->dev, \"cannot find UAC_HEADER\\n\");\n\t\treturn -EINVAL;\n\t}\n",
"\trest_bytes = (void *)(host_iface->extra + host_iface->extralen) -\n\t\tcontrol_header;",
"\t/* just to be sure -- this shouldn't hit at all */\n\tif (rest_bytes <= 0) {\n\t\tdev_err(&dev->dev, \"invalid control header\\n\");\n\t\treturn -EINVAL;\n\t}\n",
"\tswitch (protocol) {\n\tdefault:\n\t\tdev_warn(&dev->dev,\n\t\t\t \"unknown interface protocol %#02x, assuming v1\\n\",\n\t\t\t protocol);\n\t\t/* fall through */",
"\tcase UAC_VERSION_1: {\n\t\tstruct uac1_ac_header_descriptor *h1 = control_header;\n",
"\t\tif (rest_bytes < sizeof(*h1)) {\n\t\t\tdev_err(&dev->dev, \"too short v1 buffer descriptor\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n",
"\t\tif (!h1->bInCollection) {\n\t\t\tdev_info(&dev->dev, \"skipping empty audio interface (v1)\\n\");",
"\t\t\treturn -EINVAL;\n\t\t}",
"\t\tif (rest_bytes < h1->bLength) {\n\t\t\tdev_err(&dev->dev, \"invalid buffer length (v1)\\n\");",
"\t\t\treturn -EINVAL;\n\t\t}",
"\t\tif (h1->bLength < sizeof(*h1) + h1->bInCollection) {\n\t\t\tdev_err(&dev->dev, \"invalid UAC_HEADER (v1)\\n\");\n\t\t\treturn -EINVAL;\n\t\t}",
"\t\tfor (i = 0; i < h1->bInCollection; i++)\n\t\t\tsnd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]);",
"\t\tbreak;\n\t}",
"\tcase UAC_VERSION_2: {\n\t\tstruct usb_interface_assoc_descriptor *assoc =\n\t\t\tusb_ifnum_to_if(dev, ctrlif)->intf_assoc;",
"\t\tif (!assoc) {\n\t\t\t/*\n\t\t\t * Firmware writers cannot count to three. So to find\n\t\t\t * the IAD on the NuForce UDH-100, also check the next\n\t\t\t * interface.\n\t\t\t */\n\t\t\tstruct usb_interface *iface =\n\t\t\t\tusb_ifnum_to_if(dev, ctrlif + 1);\n\t\t\tif (iface &&\n\t\t\t iface->intf_assoc &&\n\t\t\t iface->intf_assoc->bFunctionClass == USB_CLASS_AUDIO &&\n\t\t\t iface->intf_assoc->bFunctionProtocol == UAC_VERSION_2)\n\t\t\t\tassoc = iface->intf_assoc;\n\t\t}",
"\t\tif (!assoc) {\n\t\t\tdev_err(&dev->dev, \"Audio class v2 interfaces need an interface association\\n\");\n\t\t\treturn -EINVAL;\n\t\t}",
"\t\tfor (i = 0; i < assoc->bInterfaceCount; i++) {\n\t\t\tint intf = assoc->bFirstInterface + i;",
"\t\t\tif (intf != ctrlif)\n\t\t\t\tsnd_usb_create_stream(chip, ctrlif, intf);\n\t\t}",
"\t\tbreak;\n\t}\n\t}",
"\treturn 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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 252,
"char_start": 235,
"chars": "\tint rest_bytes;\n"
},
{
"char_end": 872,
"char_start": 638,
"chars": "rest_bytes = (void *)(host_iface->extra + host_iface->extralen) -\n\t\tcontrol_header;\n\n\t/* just to be sure -- this shouldn't hit at all */\n\tif (rest_bytes <= 0) {\n\t\tdev_err(&dev->dev, \"invalid control header\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t"
},
{
"char_end": 1220,
"char_start": 1103,
"chars": "rest_bytes < sizeof(*h1)) {\n\t\t\tdev_err(&dev->dev, \"too short v1 buffer descriptor\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif ("
},
{
"char_end": 1409,
"char_start": 1296,
"chars": " (v1)\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif (rest_bytes < h1->bLength) {\n\t\t\tdev_err(&dev->dev, \"invalid buffer length"
}
],
"deleted": []
},
"commit_link": "github.com/torvalds/linux/commit/bfc81a8bc18e3c4ba0cbaa7666ff76be2f998991",
"file_name": "sound/usb/card.c",
"func_name": "snd_usb_create_streams",
"line_changes": {
"added": [
{
"char_end": 252,
"char_start": 235,
"line": "\tint rest_bytes;\n",
"line_no": 8
},
{
"char_end": 704,
"char_start": 637,
"line": "\trest_bytes = (void *)(host_iface->extra + host_iface->extralen) -\n",
"line_no": 23
},
{
"char_end": 722,
"char_start": 704,
"line": "\t\tcontrol_header;\n",
"line_no": 24
},
{
"char_end": 723,
"char_start": 722,
"line": "\n",
"line_no": 25
},
{
"char_end": 775,
"char_start": 723,
"line": "\t/* just to be sure -- this shouldn't hit at all */\n",
"line_no": 26
},
{
"char_end": 799,
"char_start": 775,
"line": "\tif (rest_bytes <= 0) {\n",
"line_no": 27
},
{
"char_end": 849,
"char_start": 799,
"line": "\t\tdev_err(&dev->dev, \"invalid control header\\n\");\n",
"line_no": 28
},
{
"char_end": 867,
"char_start": 849,
"line": "\t\treturn -EINVAL;\n",
"line_no": 29
},
{
"char_end": 870,
"char_start": 867,
"line": "\t}\n",
"line_no": 30
},
{
"char_end": 871,
"char_start": 870,
"line": "\n",
"line_no": 31
},
{
"char_end": 1131,
"char_start": 1097,
"line": "\t\tif (rest_bytes < sizeof(*h1)) {\n",
"line_no": 42
},
{
"char_end": 1190,
"char_start": 1131,
"line": "\t\t\tdev_err(&dev->dev, \"too short v1 buffer descriptor\\n\");\n",
"line_no": 43
},
{
"char_end": 1209,
"char_start": 1190,
"line": "\t\t\treturn -EINVAL;\n",
"line_no": 44
},
{
"char_end": 1213,
"char_start": 1209,
"line": "\t\t}\n",
"line_no": 45
},
{
"char_end": 1214,
"char_start": 1213,
"line": "\n",
"line_no": 46
},
{
"char_end": 1365,
"char_start": 1331,
"line": "\t\tif (rest_bytes < h1->bLength) {\n",
"line_no": 52
},
{
"char_end": 1420,
"char_start": 1365,
"line": "\t\t\tdev_err(&dev->dev, \"invalid buffer length (v1)\\n\");\n",
"line_no": 53
},
{
"char_end": 1439,
"char_start": 1420,
"line": "\t\t\treturn -EINVAL;\n",
"line_no": 54
},
{
"char_end": 1443,
"char_start": 1439,
"line": "\t\t}\n",
"line_no": 55
},
{
"char_end": 1444,
"char_start": 1443,
"line": "\n",
"line_no": 56
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 389 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"void process_packet_tail(struct msg_digest *md)\n{\n\tstruct state *st = md->st;\n\tenum state_kind from_state = md->v1_from_state;\n\tconst struct state_v1_microcode *smc = md->smc;\n\tbool new_iv_set = md->new_iv_set;\n\tbool self_delete = FALSE;",
"\tif (md->hdr.isa_flags & ISAKMP_FLAGS_v1_ENCRYPTION) {\n\t\tendpoint_buf b;\n\t\tdbg(\"received encrypted packet from %s\", str_endpoint(&md->sender, &b));",
"\t\tif (st == NULL) {\n\t\t\tlibreswan_log(\n\t\t\t\t\"discarding encrypted message for an unknown ISAKMP SA\");\n\t\t\treturn;\n\t\t}\n\t\tif (st->st_skeyid_e_nss == NULL) {\n\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\"discarding encrypted message because we haven't yet negotiated keying material\");\n\t\t\treturn;\n\t\t}",
"\t\t/* Mark as encrypted */\n\t\tmd->encrypted = TRUE;",
"\t\t/* do the specified decryption\n\t\t *\n\t\t * IV is from st->st_iv or (if new_iv_set) st->st_new_iv.\n\t\t * The new IV is placed in st->st_new_iv\n\t\t *\n\t\t * See RFC 2409 \"IKE\" Appendix B\n\t\t *\n\t\t * XXX The IV should only be updated really if the packet\n\t\t * is successfully processed.\n\t\t * We should keep this value, check for a success return\n\t\t * value from the parsing routines and then replace.\n\t\t *\n\t\t * Each post phase 1 exchange generates IVs from\n\t\t * the last phase 1 block, not the last block sent.\n\t\t */\n\t\tconst struct encrypt_desc *e = st->st_oakley.ta_encrypt;",
"\t\tif (pbs_left(&md->message_pbs) % e->enc_blocksize != 0) {\n\t\t\tloglog(RC_LOG_SERIOUS, \"malformed message: not a multiple of encryption blocksize\");\n\t\t\treturn;\n\t\t}",
"\t\t/* XXX Detect weak keys */",
"\t\t/* grab a copy of raw packet (for duplicate packet detection) */\n\t\tmd->raw_packet = clone_bytes_as_chunk(md->packet_pbs.start,\n\t\t\t\t\t\t pbs_room(&md->packet_pbs),\n\t\t\t\t\t\t \"raw packet\");",
"\t\t/* Decrypt everything after header */\n\t\tif (!new_iv_set) {\n\t\t\tif (st->st_v1_iv.len == 0) {\n\t\t\t\tinit_phase2_iv(st, &md->hdr.isa_msgid);\n\t\t\t} else {\n\t\t\t\t/* use old IV */\n\t\t\t\trestore_new_iv(st, st->st_v1_iv);\n\t\t\t}\n\t\t}",
"\t\tpassert(st->st_v1_new_iv.len >= e->enc_blocksize);\n\t\tst->st_v1_new_iv.len = e->enc_blocksize; /* truncate */",
"\t\tif (DBGP(DBG_CRYPT)) {\n\t\t\tDBG_log(\"decrypting %u bytes using algorithm %s\",\n\t\t\t\t(unsigned) pbs_left(&md->message_pbs),\n\t\t\t\tst->st_oakley.ta_encrypt->common.fqn);\n\t\t\tDBG_dump_hunk(\"IV before:\", st->st_v1_new_iv);\n\t\t}\n\t\te->encrypt_ops->do_crypt(e, md->message_pbs.cur,\n\t\t\t\t\t pbs_left(&md->message_pbs),\n\t\t\t\t\t st->st_enc_key_nss,\n\t\t\t\t\t st->st_v1_new_iv.ptr, FALSE);\n\t\tif (DBGP(DBG_CRYPT)) {\n\t\t\tDBG_dump_hunk(\"IV after:\", st->st_v1_new_iv);\n\t\t\tDBG_log(\"decrypted payload (starts at offset %td):\",\n\t\t\t\tmd->message_pbs.cur - md->message_pbs.roof);\n\t\t\tDBG_dump(NULL, md->message_pbs.start,\n\t\t\t\t md->message_pbs.roof - md->message_pbs.start);\n\t\t}\n\t} else {\n\t\t/* packet was not encryped -- should it have been? */",
"\t\tif (smc->flags & SMF_INPUT_ENCRYPTED) {\n\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t \"packet rejected: should have been encrypted\");\n\t\t\tSEND_NOTIFICATION(INVALID_FLAGS);\n\t\t\treturn;\n\t\t}\n\t}",
"\t/* Digest the message.\n\t * Padding must be removed to make hashing work.\n\t * Padding comes from encryption (so this code must be after decryption).\n\t * Padding rules are described before the definition of\n\t * struct isakmp_hdr in packet.h.\n\t */\n\t{\n\t\tenum next_payload_types_ikev1 np = md->hdr.isa_np;\n\t\tlset_t needed = smc->req_payloads;\n\t\tconst char *excuse =\n\t\t\tLIN(SMF_PSK_AUTH | SMF_FIRST_ENCRYPTED_INPUT,\n\t\t\t smc->flags) ?\n\t\t\t\"probable authentication failure (mismatch of preshared secrets?): \"\n\t\t\t:\n\t\t\t\"\";",
"\t\twhile (np != ISAKMP_NEXT_NONE) {\n\t\t\tstruct_desc *sd = v1_payload_desc(np);",
"\t\t\tif (md->digest_roof >= elemsof(md->digest)) {\n\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t \"more than %zu payloads in message; ignored\",\n\t\t\t\t elemsof(md->digest));\n\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstruct payload_digest *const pd = md->digest + md->digest_roof;",
"\t\t\t/*\n\t\t\t * only do this in main mode. In aggressive mode, there\n\t\t\t * is no negotiation of NAT-T method. Get it right.\n\t\t\t */\n\t\t\tif (st != NULL && st->st_connection != NULL &&\n\t\t\t (st->st_connection->policy & POLICY_AGGRESSIVE) == LEMPTY)\n\t\t\t{\n\t\t\t\tswitch (np) {\n\t\t\t\tcase ISAKMP_NEXT_NATD_RFC:\n\t\t\t\tcase ISAKMP_NEXT_NATOA_RFC:\n\t\t\t\t\tif ((st->hidden_variables.st_nat_traversal & NAT_T_WITH_RFC_VALUES) == LEMPTY) {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * don't accept NAT-D/NAT-OA reloc directly in message,\n\t\t\t\t\t\t * unless we're using NAT-T RFC\n\t\t\t\t\t\t */\n\t\t\t\t\t\tDBG(DBG_NATT,\n\t\t\t\t\t\t DBG_log(\"st_nat_traversal was: %s\",\n\t\t\t\t\t\t\t bitnamesof(natt_bit_names,\n\t\t\t\t\t\t\t\t st->hidden_variables.st_nat_traversal)));\n\t\t\t\t\t\tsd = NULL;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tif (sd == NULL) {\n\t\t\t\t/* payload type is out of range or requires special handling */\n\t\t\t\tswitch (np) {\n\t\t\t\tcase ISAKMP_NEXT_ID:\n\t\t\t\t\t/* ??? two kinds of ID payloads */\n\t\t\t\t\tsd = (IS_PHASE1(from_state) ||\n\t\t\t\t\t IS_PHASE15(from_state)) ?\n\t\t\t\t\t\t&isakmp_identification_desc :\n\t\t\t\t\t\t&isakmp_ipsec_identification_desc;\n\t\t\t\t\tbreak;",
"\t\t\t\tcase ISAKMP_NEXT_NATD_DRAFTS: /* out of range */\n\t\t\t\t\t/*\n\t\t\t\t\t * ISAKMP_NEXT_NATD_DRAFTS was a private use type before RFC-3947.\n\t\t\t\t\t * Since it has the same format as ISAKMP_NEXT_NATD_RFC,\n\t\t\t\t\t * just rewrite np and sd, and carry on.\n\t\t\t\t\t */\n\t\t\t\t\tnp = ISAKMP_NEXT_NATD_RFC;\n\t\t\t\t\tsd = &isakmp_nat_d_drafts;\n\t\t\t\t\tbreak;",
"\t\t\t\tcase ISAKMP_NEXT_NATOA_DRAFTS: /* out of range */\n\t\t\t\t\t/* NAT-OA was a private use type before RFC-3947 -- same format */\n\t\t\t\t\tnp = ISAKMP_NEXT_NATOA_RFC;\n\t\t\t\t\tsd = &isakmp_nat_oa_drafts;\n\t\t\t\t\tbreak;",
"\t\t\t\tcase ISAKMP_NEXT_SAK: /* or ISAKMP_NEXT_NATD_BADDRAFTS */\n\t\t\t\t\t/*\n\t\t\t\t\t * Official standards say that this is ISAKMP_NEXT_SAK,\n\t\t\t\t\t * a part of Group DOI, something we don't implement.\n\t\t\t\t\t * Old non-updated Cisco gear abused this number in ancient NAT drafts.\n\t\t\t\t\t * We ignore (rather than reject) this in support of people\n\t\t\t\t\t * with crufty Cisco machines.\n\t\t\t\t\t */\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t\"%smessage with unsupported payload ISAKMP_NEXT_SAK (or ISAKMP_NEXT_NATD_BADDRAFTS) ignored\",\n\t\t\t\t\t\texcuse);\n\t\t\t\t\t/*\n\t\t\t\t\t * Hack to discard payload, whatever it was.\n\t\t\t\t\t * Since we are skipping the rest of the loop\n\t\t\t\t\t * body we must do some things ourself:\n\t\t\t\t\t * - demarshall the payload\n\t\t\t\t\t * - grab the next payload number (np)\n\t\t\t\t\t * - don't keep payload (don't increment pd)\n\t\t\t\t\t * - skip rest of loop body\n\t\t\t\t\t */\n\t\t\t\t\tif (!in_struct(&pd->payload, &isakmp_ignore_desc, &md->message_pbs,\n\t\t\t\t\t\t &pd->pbs)) {\n\t\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t \"%smalformed payload in packet\",\n\t\t\t\t\t\t excuse);\n\t\t\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tnp = pd->payload.generic.isag_np;\n\t\t\t\t\t/* NOTE: we do not increment pd! */\n\t\t\t\t\tcontinue; /* skip rest of the loop */",
"\t\t\t\tdefault:\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t\"%smessage ignored because it contains an unknown or unexpected payload type (%s) at the outermost level\",\n\t\t\t\t\t excuse,\n\t\t\t\t\t enum_show(&ikev1_payload_names, np));\n\t\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\t\tSEND_NOTIFICATION(INVALID_PAYLOAD_TYPE);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tpassert(sd != NULL);\n\t\t\t}",
"\t\t\tpassert(np < LELEM_ROOF);",
"\t\t\t{\n\t\t\t\tlset_t s = LELEM(np);",
"\t\t\t\tif (LDISJOINT(s,\n\t\t\t\t\t needed | smc->opt_payloads |\n\t\t\t\t\t LELEM(ISAKMP_NEXT_VID) |\n\t\t\t\t\t LELEM(ISAKMP_NEXT_N) |\n\t\t\t\t\t LELEM(ISAKMP_NEXT_D) |\n\t\t\t\t\t LELEM(ISAKMP_NEXT_CR) |\n\t\t\t\t\t LELEM(ISAKMP_NEXT_CERT))) {\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t\"%smessage ignored because it contains a payload type (%s) unexpected by state %s\",\n\t\t\t\t\t\texcuse,\n\t\t\t\t\t\tenum_show(&ikev1_payload_names, np),",
"\t\t\t\t\t\tst->st_state->name);",
"\t\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\t\tSEND_NOTIFICATION(INVALID_PAYLOAD_TYPE);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}",
"\t\t\t\tDBG(DBG_PARSING,\n\t\t\t\t DBG_log(\"got payload 0x%\" PRIxLSET\" (%s) needed: 0x%\" PRIxLSET \" opt: 0x%\" PRIxLSET,\n\t\t\t\t\t s, enum_show(&ikev1_payload_names, np),\n\t\t\t\t\t needed, smc->opt_payloads));\n\t\t\t\tneeded &= ~s;\n\t\t\t}",
"\t\t\t/*\n\t\t\t * Read in the payload recording what type it\n\t\t\t * should be\n\t\t\t */\n\t\t\tpd->payload_type = np;\n\t\t\tif (!in_struct(&pd->payload, sd, &md->message_pbs,\n\t\t\t\t &pd->pbs)) {\n\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t \"%smalformed payload in packet\",\n\t\t\t\t excuse);\n\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}",
"\t\t\t/* do payload-type specific debugging */\n\t\t\tswitch (np) {\n\t\t\tcase ISAKMP_NEXT_ID:\n\t\t\tcase ISAKMP_NEXT_NATOA_RFC:\n\t\t\t\t/* dump ID section */\n\t\t\t\tDBG(DBG_PARSING,\n\t\t\t\t DBG_dump(\" obj: \", pd->pbs.cur,\n\t\t\t\t\t pbs_left(&pd->pbs)));\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}",
"\n\t\t\t/*\n\t\t\t * Place payload at the end of the chain for this type.\n\t\t\t * This code appears in ikev1.c and ikev2.c.\n\t\t\t */\n\t\t\t{\n\t\t\t\t/* np is a proper subscript for chain[] */\n\t\t\t\tpassert(np < elemsof(md->chain));\n\t\t\t\tstruct payload_digest **p = &md->chain[np];",
"\t\t\t\twhile (*p != NULL)\n\t\t\t\t\tp = &(*p)->next;\n\t\t\t\t*p = pd;\n\t\t\t\tpd->next = NULL;\n\t\t\t}",
"\t\t\tnp = pd->payload.generic.isag_np;\n\t\t\tmd->digest_roof++;",
"\t\t\t/* since we've digested one payload happily, it is probably\n\t\t\t * the case that any decryption worked. So we will not suggest\n\t\t\t * encryption failure as an excuse for subsequent payload\n\t\t\t * problems.\n\t\t\t */\n\t\t\texcuse = \"\";\n\t\t}",
"\t\tDBG(DBG_PARSING, {\n\t\t\t if (pbs_left(&md->message_pbs) != 0)\n\t\t\t\t DBG_log(\"removing %d bytes of padding\",\n\t\t\t\t\t (int) pbs_left(&md->message_pbs));\n\t\t });",
"\t\tmd->message_pbs.roof = md->message_pbs.cur;",
"\t\t/* check that all mandatory payloads appeared */",
"\t\tif (needed != 0) {\n\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t \"message for %s is missing payloads %s\",\n\t\t\t finite_states[from_state]->name,\n\t\t\t bitnamesof(payload_name_ikev1, needed));\n\t\t\tif (!md->encrypted) {\n\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}",
"\tif (!check_v1_HASH(smc->hash_type, smc->message, st, md)) {\n\t\t/*SEND_NOTIFICATION(INVALID_HASH_INFORMATION);*/\n\t\treturn;\n\t}",
"\t/* more sanity checking: enforce most ordering constraints */",
"\tif (IS_PHASE1(from_state) || IS_PHASE15(from_state)) {\n\t\t/* rfc2409: The Internet Key Exchange (IKE), 5 Exchanges:\n\t\t * \"The SA payload MUST precede all other payloads in a phase 1 exchange.\"\n\t\t */\n\t\tif (md->chain[ISAKMP_NEXT_SA] != NULL &&\n\t\t md->hdr.isa_np != ISAKMP_NEXT_SA) {\n\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t \"malformed Phase 1 message: does not start with an SA payload\");\n\t\t\tif (!md->encrypted) {\n\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t} else if (IS_QUICK(from_state)) {\n\t\t/* rfc2409: The Internet Key Exchange (IKE), 5.5 Phase 2 - Quick Mode\n\t\t *\n\t\t * \"In Quick Mode, a HASH payload MUST immediately follow the ISAKMP\n\t\t * header and a SA payload MUST immediately follow the HASH.\"\n\t\t * [NOTE: there may be more than one SA payload, so this is not\n\t\t * totally reasonable. Probably all SAs should be so constrained.]\n\t\t *\n\t\t * \"If ISAKMP is acting as a client negotiator on behalf of another\n\t\t * party, the identities of the parties MUST be passed as IDci and\n\t\t * then IDcr.\"\n\t\t *\n\t\t * \"With the exception of the HASH, SA, and the optional ID payloads,\n\t\t * there are no payload ordering restrictions on Quick Mode.\"\n\t\t */",
"\t\tif (md->hdr.isa_np != ISAKMP_NEXT_HASH) {\n\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t \"malformed Quick Mode message: does not start with a HASH payload\");\n\t\t\tif (!md->encrypted) {\n\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t}\n\t\t\treturn;\n\t\t}",
"\t\t{\n\t\t\tstruct payload_digest *p;\n\t\t\tint i;",
"\t\t\tp = md->chain[ISAKMP_NEXT_SA];\n\t\t\ti = 1;\n\t\t\twhile (p != NULL) {\n\t\t\t\tif (p != &md->digest[i]) {\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t \"malformed Quick Mode message: SA payload is in wrong position\");\n\t\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tp = p->next;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}",
"\t\t/* rfc2409: The Internet Key Exchange (IKE), 5.5 Phase 2 - Quick Mode:\n\t\t * \"If ISAKMP is acting as a client negotiator on behalf of another\n\t\t * party, the identities of the parties MUST be passed as IDci and\n\t\t * then IDcr.\"\n\t\t */\n\t\t{\n\t\t\tstruct payload_digest *id = md->chain[ISAKMP_NEXT_ID];",
"\t\t\tif (id != NULL) {\n\t\t\t\tif (id->next == NULL ||\n\t\t\t\t id->next->next != NULL) {\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t\"malformed Quick Mode message: if any ID payload is present, there must be exactly two\");\n\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (id + 1 != id->next) {\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t\"malformed Quick Mode message: the ID payloads are not adjacent\");\n\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"\t/*\n\t * Ignore payloads that we don't handle:\n\t */\n\t/* XXX Handle Notifications */\n\t{\n\t\tstruct payload_digest *p = md->chain[ISAKMP_NEXT_N];",
"\t\twhile (p != NULL) {\n\t\t\tswitch (p->payload.notification.isan_type) {\n\t\t\tcase R_U_THERE:\n\t\t\tcase R_U_THERE_ACK:\n\t\t\tcase ISAKMP_N_CISCO_LOAD_BALANCE:\n\t\t\tcase PAYLOAD_MALFORMED:\n\t\t\tcase INVALID_MESSAGE_ID:\n\t\t\tcase IPSEC_RESPONDER_LIFETIME:\n\t\t\t\tif (md->hdr.isa_xchg == ISAKMP_XCHG_INFO) {\n\t\t\t\t\t/* these are handled later on in informational() */\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t/* FALL THROUGH */\n\t\t\tdefault:\n\t\t\t\tif (st == NULL) {\n\t\t\t\t\tDBG(DBG_CONTROL, DBG_log(\n\t\t\t\t\t \"ignoring informational payload %s, no corresponding state\",\n\t\t\t\t\t enum_show(& ikev1_notify_names,\n\t\t\t\t\t\t\t p->payload.notification.isan_type)));\n\t\t\t\t} else {\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t \"ignoring informational payload %s, msgid=%08\" PRIx32 \", length=%d\",\n\t\t\t\t\t enum_show(&ikev1_notify_names,\n\t\t\t\t\t\t\t p->payload.notification.isan_type),\n\t\t\t\t\t st->st_v1_msgid.id,\n\t\t\t\t\t p->payload.notification.isan_length);\n\t\t\t\t\tDBG_dump_pbs(&p->pbs);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (DBGP(DBG_BASE)) {\n\t\t\t\tDBG_dump(\"info:\", p->pbs.cur,\n\t\t\t\t\t pbs_left(&p->pbs));\n\t\t\t}",
"\t\t\tp = p->next;\n\t\t}",
"\t\tp = md->chain[ISAKMP_NEXT_D];\n\t\twhile (p != NULL) {\n\t\t\tself_delete |= accept_delete(md, p);\n\t\t\tif (DBGP(DBG_BASE)) {\n\t\t\t\tDBG_dump(\"del:\", p->pbs.cur,\n\t\t\t\t\t pbs_left(&p->pbs));\n\t\t\t}\n\t\t\tif (md->st != st) {\n\t\t\t\tpexpect(md->st == NULL);\n\t\t\t\tdbg(\"zapping ST as accept_delete() zapped MD.ST\");\n\t\t\t\tst = md->st;\n\t\t\t}\n\t\t\tp = p->next;\n\t\t}",
"\t\tp = md->chain[ISAKMP_NEXT_VID];\n\t\twhile (p != NULL) {\n\t\t\thandle_vendorid(md, (char *)p->pbs.cur,\n\t\t\t\t\tpbs_left(&p->pbs), FALSE);\n\t\t\tp = p->next;\n\t\t}\n\t}",
"\tif (self_delete) {\n\t\taccept_self_delete(md);\n\t\tst = md->st;\n\t\t/* note: st ought to be NULL from here on */\n\t}",
"\tpexpect(st == md->st);\n\tstatetime_t start = statetime_start(md->st);\n\t/*\n\t * XXX: danger - the .informational() processor deletes ST;\n\t * and then tunnels this loss through MD.ST.\n\t */\n\tcomplete_v1_state_transition(md, smc->processor(st, md));\n\tstatetime_stop(&start, \"%s()\", __func__);\n\t/* our caller will release_any_md(mdp); */\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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 7566,
"char_start": 7559,
"chars": "finite_"
},
{
"char_end": 7576,
"char_start": 7568,
"chars": "ates[smc"
},
{
"char_end": 7584,
"char_start": 7583,
"chars": "]"
}
],
"deleted": [
{
"char_end": 7568,
"char_start": 7565,
"chars": "_st"
}
]
},
"commit_link": "github.com/libreswan/libreswan/commit/471a3e41a449d7c753bc4edbba4239501bb62ba8",
"file_name": "programs/pluto/ikev1.c",
"func_name": "process_packet_tail",
"line_changes": {
"added": [
{
"char_end": 7593,
"char_start": 7553,
"line": "\t\t\t\t\t\tfinite_states[smc->state]->name);\n",
"line_no": 244
}
],
"deleted": [
{
"char_end": 7580,
"char_start": 7553,
"line": "\t\t\t\t\t\tst->st_state->name);\n",
"line_no": 244
}
]
},
"vul_type": "cwe-125"
} | 390 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"void process_packet_tail(struct msg_digest *md)\n{\n\tstruct state *st = md->st;\n\tenum state_kind from_state = md->v1_from_state;\n\tconst struct state_v1_microcode *smc = md->smc;\n\tbool new_iv_set = md->new_iv_set;\n\tbool self_delete = FALSE;",
"\tif (md->hdr.isa_flags & ISAKMP_FLAGS_v1_ENCRYPTION) {\n\t\tendpoint_buf b;\n\t\tdbg(\"received encrypted packet from %s\", str_endpoint(&md->sender, &b));",
"\t\tif (st == NULL) {\n\t\t\tlibreswan_log(\n\t\t\t\t\"discarding encrypted message for an unknown ISAKMP SA\");\n\t\t\treturn;\n\t\t}\n\t\tif (st->st_skeyid_e_nss == NULL) {\n\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\"discarding encrypted message because we haven't yet negotiated keying material\");\n\t\t\treturn;\n\t\t}",
"\t\t/* Mark as encrypted */\n\t\tmd->encrypted = TRUE;",
"\t\t/* do the specified decryption\n\t\t *\n\t\t * IV is from st->st_iv or (if new_iv_set) st->st_new_iv.\n\t\t * The new IV is placed in st->st_new_iv\n\t\t *\n\t\t * See RFC 2409 \"IKE\" Appendix B\n\t\t *\n\t\t * XXX The IV should only be updated really if the packet\n\t\t * is successfully processed.\n\t\t * We should keep this value, check for a success return\n\t\t * value from the parsing routines and then replace.\n\t\t *\n\t\t * Each post phase 1 exchange generates IVs from\n\t\t * the last phase 1 block, not the last block sent.\n\t\t */\n\t\tconst struct encrypt_desc *e = st->st_oakley.ta_encrypt;",
"\t\tif (pbs_left(&md->message_pbs) % e->enc_blocksize != 0) {\n\t\t\tloglog(RC_LOG_SERIOUS, \"malformed message: not a multiple of encryption blocksize\");\n\t\t\treturn;\n\t\t}",
"\t\t/* XXX Detect weak keys */",
"\t\t/* grab a copy of raw packet (for duplicate packet detection) */\n\t\tmd->raw_packet = clone_bytes_as_chunk(md->packet_pbs.start,\n\t\t\t\t\t\t pbs_room(&md->packet_pbs),\n\t\t\t\t\t\t \"raw packet\");",
"\t\t/* Decrypt everything after header */\n\t\tif (!new_iv_set) {\n\t\t\tif (st->st_v1_iv.len == 0) {\n\t\t\t\tinit_phase2_iv(st, &md->hdr.isa_msgid);\n\t\t\t} else {\n\t\t\t\t/* use old IV */\n\t\t\t\trestore_new_iv(st, st->st_v1_iv);\n\t\t\t}\n\t\t}",
"\t\tpassert(st->st_v1_new_iv.len >= e->enc_blocksize);\n\t\tst->st_v1_new_iv.len = e->enc_blocksize; /* truncate */",
"\t\tif (DBGP(DBG_CRYPT)) {\n\t\t\tDBG_log(\"decrypting %u bytes using algorithm %s\",\n\t\t\t\t(unsigned) pbs_left(&md->message_pbs),\n\t\t\t\tst->st_oakley.ta_encrypt->common.fqn);\n\t\t\tDBG_dump_hunk(\"IV before:\", st->st_v1_new_iv);\n\t\t}\n\t\te->encrypt_ops->do_crypt(e, md->message_pbs.cur,\n\t\t\t\t\t pbs_left(&md->message_pbs),\n\t\t\t\t\t st->st_enc_key_nss,\n\t\t\t\t\t st->st_v1_new_iv.ptr, FALSE);\n\t\tif (DBGP(DBG_CRYPT)) {\n\t\t\tDBG_dump_hunk(\"IV after:\", st->st_v1_new_iv);\n\t\t\tDBG_log(\"decrypted payload (starts at offset %td):\",\n\t\t\t\tmd->message_pbs.cur - md->message_pbs.roof);\n\t\t\tDBG_dump(NULL, md->message_pbs.start,\n\t\t\t\t md->message_pbs.roof - md->message_pbs.start);\n\t\t}\n\t} else {\n\t\t/* packet was not encryped -- should it have been? */",
"\t\tif (smc->flags & SMF_INPUT_ENCRYPTED) {\n\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t \"packet rejected: should have been encrypted\");\n\t\t\tSEND_NOTIFICATION(INVALID_FLAGS);\n\t\t\treturn;\n\t\t}\n\t}",
"\t/* Digest the message.\n\t * Padding must be removed to make hashing work.\n\t * Padding comes from encryption (so this code must be after decryption).\n\t * Padding rules are described before the definition of\n\t * struct isakmp_hdr in packet.h.\n\t */\n\t{\n\t\tenum next_payload_types_ikev1 np = md->hdr.isa_np;\n\t\tlset_t needed = smc->req_payloads;\n\t\tconst char *excuse =\n\t\t\tLIN(SMF_PSK_AUTH | SMF_FIRST_ENCRYPTED_INPUT,\n\t\t\t smc->flags) ?\n\t\t\t\"probable authentication failure (mismatch of preshared secrets?): \"\n\t\t\t:\n\t\t\t\"\";",
"\t\twhile (np != ISAKMP_NEXT_NONE) {\n\t\t\tstruct_desc *sd = v1_payload_desc(np);",
"\t\t\tif (md->digest_roof >= elemsof(md->digest)) {\n\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t \"more than %zu payloads in message; ignored\",\n\t\t\t\t elemsof(md->digest));\n\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstruct payload_digest *const pd = md->digest + md->digest_roof;",
"\t\t\t/*\n\t\t\t * only do this in main mode. In aggressive mode, there\n\t\t\t * is no negotiation of NAT-T method. Get it right.\n\t\t\t */\n\t\t\tif (st != NULL && st->st_connection != NULL &&\n\t\t\t (st->st_connection->policy & POLICY_AGGRESSIVE) == LEMPTY)\n\t\t\t{\n\t\t\t\tswitch (np) {\n\t\t\t\tcase ISAKMP_NEXT_NATD_RFC:\n\t\t\t\tcase ISAKMP_NEXT_NATOA_RFC:\n\t\t\t\t\tif ((st->hidden_variables.st_nat_traversal & NAT_T_WITH_RFC_VALUES) == LEMPTY) {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * don't accept NAT-D/NAT-OA reloc directly in message,\n\t\t\t\t\t\t * unless we're using NAT-T RFC\n\t\t\t\t\t\t */\n\t\t\t\t\t\tDBG(DBG_NATT,\n\t\t\t\t\t\t DBG_log(\"st_nat_traversal was: %s\",\n\t\t\t\t\t\t\t bitnamesof(natt_bit_names,\n\t\t\t\t\t\t\t\t st->hidden_variables.st_nat_traversal)));\n\t\t\t\t\t\tsd = NULL;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tif (sd == NULL) {\n\t\t\t\t/* payload type is out of range or requires special handling */\n\t\t\t\tswitch (np) {\n\t\t\t\tcase ISAKMP_NEXT_ID:\n\t\t\t\t\t/* ??? two kinds of ID payloads */\n\t\t\t\t\tsd = (IS_PHASE1(from_state) ||\n\t\t\t\t\t IS_PHASE15(from_state)) ?\n\t\t\t\t\t\t&isakmp_identification_desc :\n\t\t\t\t\t\t&isakmp_ipsec_identification_desc;\n\t\t\t\t\tbreak;",
"\t\t\t\tcase ISAKMP_NEXT_NATD_DRAFTS: /* out of range */\n\t\t\t\t\t/*\n\t\t\t\t\t * ISAKMP_NEXT_NATD_DRAFTS was a private use type before RFC-3947.\n\t\t\t\t\t * Since it has the same format as ISAKMP_NEXT_NATD_RFC,\n\t\t\t\t\t * just rewrite np and sd, and carry on.\n\t\t\t\t\t */\n\t\t\t\t\tnp = ISAKMP_NEXT_NATD_RFC;\n\t\t\t\t\tsd = &isakmp_nat_d_drafts;\n\t\t\t\t\tbreak;",
"\t\t\t\tcase ISAKMP_NEXT_NATOA_DRAFTS: /* out of range */\n\t\t\t\t\t/* NAT-OA was a private use type before RFC-3947 -- same format */\n\t\t\t\t\tnp = ISAKMP_NEXT_NATOA_RFC;\n\t\t\t\t\tsd = &isakmp_nat_oa_drafts;\n\t\t\t\t\tbreak;",
"\t\t\t\tcase ISAKMP_NEXT_SAK: /* or ISAKMP_NEXT_NATD_BADDRAFTS */\n\t\t\t\t\t/*\n\t\t\t\t\t * Official standards say that this is ISAKMP_NEXT_SAK,\n\t\t\t\t\t * a part of Group DOI, something we don't implement.\n\t\t\t\t\t * Old non-updated Cisco gear abused this number in ancient NAT drafts.\n\t\t\t\t\t * We ignore (rather than reject) this in support of people\n\t\t\t\t\t * with crufty Cisco machines.\n\t\t\t\t\t */\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t\"%smessage with unsupported payload ISAKMP_NEXT_SAK (or ISAKMP_NEXT_NATD_BADDRAFTS) ignored\",\n\t\t\t\t\t\texcuse);\n\t\t\t\t\t/*\n\t\t\t\t\t * Hack to discard payload, whatever it was.\n\t\t\t\t\t * Since we are skipping the rest of the loop\n\t\t\t\t\t * body we must do some things ourself:\n\t\t\t\t\t * - demarshall the payload\n\t\t\t\t\t * - grab the next payload number (np)\n\t\t\t\t\t * - don't keep payload (don't increment pd)\n\t\t\t\t\t * - skip rest of loop body\n\t\t\t\t\t */\n\t\t\t\t\tif (!in_struct(&pd->payload, &isakmp_ignore_desc, &md->message_pbs,\n\t\t\t\t\t\t &pd->pbs)) {\n\t\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t \"%smalformed payload in packet\",\n\t\t\t\t\t\t excuse);\n\t\t\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tnp = pd->payload.generic.isag_np;\n\t\t\t\t\t/* NOTE: we do not increment pd! */\n\t\t\t\t\tcontinue; /* skip rest of the loop */",
"\t\t\t\tdefault:\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t\"%smessage ignored because it contains an unknown or unexpected payload type (%s) at the outermost level\",\n\t\t\t\t\t excuse,\n\t\t\t\t\t enum_show(&ikev1_payload_names, np));\n\t\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\t\tSEND_NOTIFICATION(INVALID_PAYLOAD_TYPE);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tpassert(sd != NULL);\n\t\t\t}",
"\t\t\tpassert(np < LELEM_ROOF);",
"\t\t\t{\n\t\t\t\tlset_t s = LELEM(np);",
"\t\t\t\tif (LDISJOINT(s,\n\t\t\t\t\t needed | smc->opt_payloads |\n\t\t\t\t\t LELEM(ISAKMP_NEXT_VID) |\n\t\t\t\t\t LELEM(ISAKMP_NEXT_N) |\n\t\t\t\t\t LELEM(ISAKMP_NEXT_D) |\n\t\t\t\t\t LELEM(ISAKMP_NEXT_CR) |\n\t\t\t\t\t LELEM(ISAKMP_NEXT_CERT))) {\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t\"%smessage ignored because it contains a payload type (%s) unexpected by state %s\",\n\t\t\t\t\t\texcuse,\n\t\t\t\t\t\tenum_show(&ikev1_payload_names, np),",
"\t\t\t\t\t\tfinite_states[smc->state]->name);",
"\t\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\t\tSEND_NOTIFICATION(INVALID_PAYLOAD_TYPE);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}",
"\t\t\t\tDBG(DBG_PARSING,\n\t\t\t\t DBG_log(\"got payload 0x%\" PRIxLSET\" (%s) needed: 0x%\" PRIxLSET \" opt: 0x%\" PRIxLSET,\n\t\t\t\t\t s, enum_show(&ikev1_payload_names, np),\n\t\t\t\t\t needed, smc->opt_payloads));\n\t\t\t\tneeded &= ~s;\n\t\t\t}",
"\t\t\t/*\n\t\t\t * Read in the payload recording what type it\n\t\t\t * should be\n\t\t\t */\n\t\t\tpd->payload_type = np;\n\t\t\tif (!in_struct(&pd->payload, sd, &md->message_pbs,\n\t\t\t\t &pd->pbs)) {\n\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t \"%smalformed payload in packet\",\n\t\t\t\t excuse);\n\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}",
"\t\t\t/* do payload-type specific debugging */\n\t\t\tswitch (np) {\n\t\t\tcase ISAKMP_NEXT_ID:\n\t\t\tcase ISAKMP_NEXT_NATOA_RFC:\n\t\t\t\t/* dump ID section */\n\t\t\t\tDBG(DBG_PARSING,\n\t\t\t\t DBG_dump(\" obj: \", pd->pbs.cur,\n\t\t\t\t\t pbs_left(&pd->pbs)));\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}",
"\n\t\t\t/*\n\t\t\t * Place payload at the end of the chain for this type.\n\t\t\t * This code appears in ikev1.c and ikev2.c.\n\t\t\t */\n\t\t\t{\n\t\t\t\t/* np is a proper subscript for chain[] */\n\t\t\t\tpassert(np < elemsof(md->chain));\n\t\t\t\tstruct payload_digest **p = &md->chain[np];",
"\t\t\t\twhile (*p != NULL)\n\t\t\t\t\tp = &(*p)->next;\n\t\t\t\t*p = pd;\n\t\t\t\tpd->next = NULL;\n\t\t\t}",
"\t\t\tnp = pd->payload.generic.isag_np;\n\t\t\tmd->digest_roof++;",
"\t\t\t/* since we've digested one payload happily, it is probably\n\t\t\t * the case that any decryption worked. So we will not suggest\n\t\t\t * encryption failure as an excuse for subsequent payload\n\t\t\t * problems.\n\t\t\t */\n\t\t\texcuse = \"\";\n\t\t}",
"\t\tDBG(DBG_PARSING, {\n\t\t\t if (pbs_left(&md->message_pbs) != 0)\n\t\t\t\t DBG_log(\"removing %d bytes of padding\",\n\t\t\t\t\t (int) pbs_left(&md->message_pbs));\n\t\t });",
"\t\tmd->message_pbs.roof = md->message_pbs.cur;",
"\t\t/* check that all mandatory payloads appeared */",
"\t\tif (needed != 0) {\n\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t \"message for %s is missing payloads %s\",\n\t\t\t finite_states[from_state]->name,\n\t\t\t bitnamesof(payload_name_ikev1, needed));\n\t\t\tif (!md->encrypted) {\n\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}",
"\tif (!check_v1_HASH(smc->hash_type, smc->message, st, md)) {\n\t\t/*SEND_NOTIFICATION(INVALID_HASH_INFORMATION);*/\n\t\treturn;\n\t}",
"\t/* more sanity checking: enforce most ordering constraints */",
"\tif (IS_PHASE1(from_state) || IS_PHASE15(from_state)) {\n\t\t/* rfc2409: The Internet Key Exchange (IKE), 5 Exchanges:\n\t\t * \"The SA payload MUST precede all other payloads in a phase 1 exchange.\"\n\t\t */\n\t\tif (md->chain[ISAKMP_NEXT_SA] != NULL &&\n\t\t md->hdr.isa_np != ISAKMP_NEXT_SA) {\n\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t \"malformed Phase 1 message: does not start with an SA payload\");\n\t\t\tif (!md->encrypted) {\n\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t} else if (IS_QUICK(from_state)) {\n\t\t/* rfc2409: The Internet Key Exchange (IKE), 5.5 Phase 2 - Quick Mode\n\t\t *\n\t\t * \"In Quick Mode, a HASH payload MUST immediately follow the ISAKMP\n\t\t * header and a SA payload MUST immediately follow the HASH.\"\n\t\t * [NOTE: there may be more than one SA payload, so this is not\n\t\t * totally reasonable. Probably all SAs should be so constrained.]\n\t\t *\n\t\t * \"If ISAKMP is acting as a client negotiator on behalf of another\n\t\t * party, the identities of the parties MUST be passed as IDci and\n\t\t * then IDcr.\"\n\t\t *\n\t\t * \"With the exception of the HASH, SA, and the optional ID payloads,\n\t\t * there are no payload ordering restrictions on Quick Mode.\"\n\t\t */",
"\t\tif (md->hdr.isa_np != ISAKMP_NEXT_HASH) {\n\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t \"malformed Quick Mode message: does not start with a HASH payload\");\n\t\t\tif (!md->encrypted) {\n\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t}\n\t\t\treturn;\n\t\t}",
"\t\t{\n\t\t\tstruct payload_digest *p;\n\t\t\tint i;",
"\t\t\tp = md->chain[ISAKMP_NEXT_SA];\n\t\t\ti = 1;\n\t\t\twhile (p != NULL) {\n\t\t\t\tif (p != &md->digest[i]) {\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t \"malformed Quick Mode message: SA payload is in wrong position\");\n\t\t\t\t\tif (!md->encrypted) {\n\t\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tp = p->next;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}",
"\t\t/* rfc2409: The Internet Key Exchange (IKE), 5.5 Phase 2 - Quick Mode:\n\t\t * \"If ISAKMP is acting as a client negotiator on behalf of another\n\t\t * party, the identities of the parties MUST be passed as IDci and\n\t\t * then IDcr.\"\n\t\t */\n\t\t{\n\t\t\tstruct payload_digest *id = md->chain[ISAKMP_NEXT_ID];",
"\t\t\tif (id != NULL) {\n\t\t\t\tif (id->next == NULL ||\n\t\t\t\t id->next->next != NULL) {\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t\"malformed Quick Mode message: if any ID payload is present, there must be exactly two\");\n\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (id + 1 != id->next) {\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t\t\"malformed Quick Mode message: the ID payloads are not adjacent\");\n\t\t\t\t\tSEND_NOTIFICATION(PAYLOAD_MALFORMED);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"\t/*\n\t * Ignore payloads that we don't handle:\n\t */\n\t/* XXX Handle Notifications */\n\t{\n\t\tstruct payload_digest *p = md->chain[ISAKMP_NEXT_N];",
"\t\twhile (p != NULL) {\n\t\t\tswitch (p->payload.notification.isan_type) {\n\t\t\tcase R_U_THERE:\n\t\t\tcase R_U_THERE_ACK:\n\t\t\tcase ISAKMP_N_CISCO_LOAD_BALANCE:\n\t\t\tcase PAYLOAD_MALFORMED:\n\t\t\tcase INVALID_MESSAGE_ID:\n\t\t\tcase IPSEC_RESPONDER_LIFETIME:\n\t\t\t\tif (md->hdr.isa_xchg == ISAKMP_XCHG_INFO) {\n\t\t\t\t\t/* these are handled later on in informational() */\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t/* FALL THROUGH */\n\t\t\tdefault:\n\t\t\t\tif (st == NULL) {\n\t\t\t\t\tDBG(DBG_CONTROL, DBG_log(\n\t\t\t\t\t \"ignoring informational payload %s, no corresponding state\",\n\t\t\t\t\t enum_show(& ikev1_notify_names,\n\t\t\t\t\t\t\t p->payload.notification.isan_type)));\n\t\t\t\t} else {\n\t\t\t\t\tloglog(RC_LOG_SERIOUS,\n\t\t\t\t\t \"ignoring informational payload %s, msgid=%08\" PRIx32 \", length=%d\",\n\t\t\t\t\t enum_show(&ikev1_notify_names,\n\t\t\t\t\t\t\t p->payload.notification.isan_type),\n\t\t\t\t\t st->st_v1_msgid.id,\n\t\t\t\t\t p->payload.notification.isan_length);\n\t\t\t\t\tDBG_dump_pbs(&p->pbs);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (DBGP(DBG_BASE)) {\n\t\t\t\tDBG_dump(\"info:\", p->pbs.cur,\n\t\t\t\t\t pbs_left(&p->pbs));\n\t\t\t}",
"\t\t\tp = p->next;\n\t\t}",
"\t\tp = md->chain[ISAKMP_NEXT_D];\n\t\twhile (p != NULL) {\n\t\t\tself_delete |= accept_delete(md, p);\n\t\t\tif (DBGP(DBG_BASE)) {\n\t\t\t\tDBG_dump(\"del:\", p->pbs.cur,\n\t\t\t\t\t pbs_left(&p->pbs));\n\t\t\t}\n\t\t\tif (md->st != st) {\n\t\t\t\tpexpect(md->st == NULL);\n\t\t\t\tdbg(\"zapping ST as accept_delete() zapped MD.ST\");\n\t\t\t\tst = md->st;\n\t\t\t}\n\t\t\tp = p->next;\n\t\t}",
"\t\tp = md->chain[ISAKMP_NEXT_VID];\n\t\twhile (p != NULL) {\n\t\t\thandle_vendorid(md, (char *)p->pbs.cur,\n\t\t\t\t\tpbs_left(&p->pbs), FALSE);\n\t\t\tp = p->next;\n\t\t}\n\t}",
"\tif (self_delete) {\n\t\taccept_self_delete(md);\n\t\tst = md->st;\n\t\t/* note: st ought to be NULL from here on */\n\t}",
"\tpexpect(st == md->st);\n\tstatetime_t start = statetime_start(md->st);\n\t/*\n\t * XXX: danger - the .informational() processor deletes ST;\n\t * and then tunnels this loss through MD.ST.\n\t */\n\tcomplete_v1_state_transition(md, smc->processor(st, md));\n\tstatetime_stop(&start, \"%s()\", __func__);\n\t/* our caller will release_any_md(mdp); */\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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 7566,
"char_start": 7559,
"chars": "finite_"
},
{
"char_end": 7576,
"char_start": 7568,
"chars": "ates[smc"
},
{
"char_end": 7584,
"char_start": 7583,
"chars": "]"
}
],
"deleted": [
{
"char_end": 7568,
"char_start": 7565,
"chars": "_st"
}
]
},
"commit_link": "github.com/libreswan/libreswan/commit/471a3e41a449d7c753bc4edbba4239501bb62ba8",
"file_name": "programs/pluto/ikev1.c",
"func_name": "process_packet_tail",
"line_changes": {
"added": [
{
"char_end": 7593,
"char_start": 7553,
"line": "\t\t\t\t\t\tfinite_states[smc->state]->name);\n",
"line_no": 244
}
],
"deleted": [
{
"char_end": 7580,
"char_start": 7553,
"line": "\t\t\t\t\t\tst->st_state->name);\n",
"line_no": 244
}
]
},
"vul_type": "cwe-125"
} | 390 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"std::vector<GetLengthType> CSoundFile::GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target)\n{\n\tstd::vector<GetLengthType> results;\n\tGetLengthType retval;\n\tretval.startOrder = target.startOrder;\n\tretval.startRow = target.startRow;",
"\t// Are we trying to reach a certain pattern position?\n\tconst bool hasSearchTarget = target.mode != GetLengthTarget::NoTarget;\n\tconst bool adjustSamplePos = (adjustMode & eAdjustSamplePositions) == eAdjustSamplePositions;",
"\tSEQUENCEINDEX sequence = target.sequence;\n\tif(sequence >= Order.GetNumSequences()) sequence = Order.GetCurrentSequenceIndex();\n\tconst ModSequence &orderList = Order(sequence);",
"\tGetLengthMemory memory(*this);\n\tCSoundFile::PlayState &playState = *memory.state;\n\t// Temporary visited rows vector (so that GetLength() won't interfere with the player code if the module is playing at the same time)\n\tRowVisitor visitedRows(*this, sequence);",
"\tplayState.m_nNextRow = playState.m_nRow = target.startRow;\n\tplayState.m_nNextOrder = playState.m_nCurrentOrder = target.startOrder;",
"\t// Fast LUTs for commands that are too weird / complicated / whatever to emulate in sample position adjust mode.\n\tstd::bitset<MAX_EFFECTS> forbiddenCommands;\n\tstd::bitset<MAX_VOLCMDS> forbiddenVolCommands;",
"\tif(adjustSamplePos)\n\t{\n\t\tforbiddenCommands.set(CMD_ARPEGGIO); forbiddenCommands.set(CMD_PORTAMENTOUP);\n\t\tforbiddenCommands.set(CMD_PORTAMENTODOWN); forbiddenCommands.set(CMD_XFINEPORTAUPDOWN);\n\t\tforbiddenCommands.set(CMD_NOTESLIDEUP); forbiddenCommands.set(CMD_NOTESLIDEUPRETRIG);\n\t\tforbiddenCommands.set(CMD_NOTESLIDEDOWN); forbiddenCommands.set(CMD_NOTESLIDEDOWNRETRIG);\n\t\tforbiddenVolCommands.set(VOLCMD_PORTAUP); forbiddenVolCommands.set(VOLCMD_PORTADOWN);",
"\t\t// Optimize away channels for which it's pointless to adjust sample positions\n\t\tfor(CHANNELINDEX i = 0; i < GetNumChannels(); i++)\n\t\t{\n\t\t\tif(ChnSettings[i].dwFlags[CHN_MUTE]) memory.chnSettings[i].ticksToRender = GetLengthMemory::IGNORE_CHANNEL;\n\t\t}\n\t\tif(target.mode == GetLengthTarget::SeekPosition && target.pos.order < orderList.size())\n\t\t{\n\t\t\t// If we know where to seek, we can directly rule out any channels on which a new note would be triggered right at the start.\n\t\t\tconst PATTERNINDEX seekPat = orderList[target.pos.order];\n\t\t\tif(Patterns.IsValidPat(seekPat) && Patterns[seekPat].IsValidRow(target.pos.row))\n\t\t\t{\n\t\t\t\tconst ModCommand *m = Patterns[seekPat].GetRow(target.pos.row);\n\t\t\t\tfor(CHANNELINDEX i = 0; i < GetNumChannels(); i++, m++)\n\t\t\t\t{\n\t\t\t\t\tif(m->note == NOTE_NOTECUT || m->note == NOTE_KEYOFF || (m->note == NOTE_FADE && GetNumInstruments())\n\t\t\t\t\t\t|| (m->IsNote() && !m->IsPortamento()))\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.chnSettings[i].ticksToRender = GetLengthMemory::IGNORE_CHANNEL;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"\t// If samples are being synced, force them to resync if tick duration changes\n\tuint32 oldTickDuration = 0;",
"\tfor (;;)\n\t{\n\t\t// Time target reached.\n\t\tif(target.mode == GetLengthTarget::SeekSeconds && memory.elapsedTime >= target.time)\n\t\t{\n\t\t\tretval.targetReached = true;\n\t\t\tbreak;\n\t\t}",
"\t\tuint32 rowDelay = 0, tickDelay = 0;\n\t\tplayState.m_nRow = playState.m_nNextRow;\n\t\tplayState.m_nCurrentOrder = playState.m_nNextOrder;",
"\t\tif(orderList.IsValidPat(playState.m_nCurrentOrder) && playState.m_nRow >= Patterns[orderList[playState.m_nCurrentOrder]].GetNumRows())\n\t\t{\n\t\t\tplayState.m_nRow = 0;\n\t\t\tif(m_playBehaviour[kFT2LoopE60Restart])\n\t\t\t{\n\t\t\t\tplayState.m_nRow = playState.m_nNextPatStartRow;\n\t\t\t\tplayState.m_nNextPatStartRow = 0;\n\t\t\t}\n\t\t\tplayState.m_nCurrentOrder = ++playState.m_nNextOrder;\n\t\t}",
"\t\t// Check if pattern is valid\n\t\tplayState.m_nPattern = playState.m_nCurrentOrder < orderList.size() ? orderList[playState.m_nCurrentOrder] : orderList.GetInvalidPatIndex();\n\t\tbool positionJumpOnThisRow = false;\n\t\tbool patternBreakOnThisRow = false;\n\t\tbool patternLoopEndedOnThisRow = false, patternLoopStartedOnThisRow = false;",
"\t\tif(!Patterns.IsValidPat(playState.m_nPattern) && playState.m_nPattern != orderList.GetInvalidPatIndex() && target.mode == GetLengthTarget::SeekPosition && playState.m_nCurrentOrder == target.pos.order)\n\t\t{\n\t\t\t// Early test: Target is inside +++ or non-existing pattern\n\t\t\tretval.targetReached = true;\n\t\t\tbreak;\n\t\t}",
"\t\twhile(playState.m_nPattern >= Patterns.Size())\n\t\t{\n\t\t\t// End of song?\n\t\t\tif((playState.m_nPattern == orderList.GetInvalidPatIndex()) || (playState.m_nCurrentOrder >= orderList.size()))\n\t\t\t{\n\t\t\t\tif(playState.m_nCurrentOrder == orderList.GetRestartPos())\n\t\t\t\t\tbreak;\n\t\t\t\telse\n\t\t\t\t\tplayState.m_nCurrentOrder = orderList.GetRestartPos();\n\t\t\t} else\n\t\t\t{\n\t\t\t\tplayState.m_nCurrentOrder++;\n\t\t\t}\n\t\t\tplayState.m_nPattern = (playState.m_nCurrentOrder < orderList.size()) ? orderList[playState.m_nCurrentOrder] : orderList.GetInvalidPatIndex();\n\t\t\tplayState.m_nNextOrder = playState.m_nCurrentOrder;\n\t\t\tif((!Patterns.IsValidPat(playState.m_nPattern)) && visitedRows.IsVisited(playState.m_nCurrentOrder, 0, true))\n\t\t\t{\n\t\t\t\tif(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(playState.m_nNextOrder, playState.m_nRow, true))\n\t\t\t\t{\n\t\t\t\t\t// We aren't searching for a specific row, or we couldn't find any more unvisited rows.\n\t\t\t\t\tbreak;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\t// We haven't found the target row yet, but we found some other unplayed row... continue searching from here.\n\t\t\t\t\tretval.duration = memory.elapsedTime;\n\t\t\t\t\tresults.push_back(retval);\n\t\t\t\t\tretval.startRow = playState.m_nRow;\n\t\t\t\t\tretval.startOrder = playState.m_nNextOrder;\n\t\t\t\t\tmemory.Reset();",
"\t\t\t\t\tplayState.m_nCurrentOrder = playState.m_nNextOrder;\n\t\t\t\t\tplayState.m_nPattern = orderList[playState.m_nCurrentOrder];\n\t\t\t\t\tplayState.m_nNextRow = playState.m_nRow;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(playState.m_nNextOrder == ORDERINDEX_INVALID)\n\t\t{\n\t\t\t// GetFirstUnvisitedRow failed, so there is nothing more to play\n\t\t\tbreak;\n\t\t}",
"\t\t// Skip non-existing patterns\n\t\tif(!Patterns.IsValidPat(playState.m_nPattern))\n\t\t{\n\t\t\t// If there isn't even a tune, we should probably stop here.\n\t\t\tif(playState.m_nCurrentOrder == orderList.GetRestartPos())\n\t\t\t{\n\t\t\t\tif(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(playState.m_nNextOrder, playState.m_nRow, true))\n\t\t\t\t{\n\t\t\t\t\t// We aren't searching for a specific row, or we couldn't find any more unvisited rows.\n\t\t\t\t\tbreak;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\t// We haven't found the target row yet, but we found some other unplayed row... continue searching from here.\n\t\t\t\t\tretval.duration = memory.elapsedTime;\n\t\t\t\t\tresults.push_back(retval);\n\t\t\t\t\tretval.startRow = playState.m_nRow;\n\t\t\t\t\tretval.startOrder = playState.m_nNextOrder;\n\t\t\t\t\tmemory.Reset();\n\t\t\t\t\tplayState.m_nNextRow = playState.m_nRow;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tplayState.m_nNextOrder = playState.m_nCurrentOrder + 1;\n\t\t\tcontinue;\n\t\t}\n\t\t// Should never happen\n\t\tif(playState.m_nRow >= Patterns[playState.m_nPattern].GetNumRows())\n\t\t\tplayState.m_nRow = 0;",
"\t\t// Check whether target was reached.\n\t\tif(target.mode == GetLengthTarget::SeekPosition && playState.m_nCurrentOrder == target.pos.order && playState.m_nRow == target.pos.row)\n\t\t{\n\t\t\tretval.targetReached = true;\n\t\t\tbreak;\n\t\t}",
"\t\tif(visitedRows.IsVisited(playState.m_nCurrentOrder, playState.m_nRow, true))\n\t\t{\n\t\t\tif(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(playState.m_nNextOrder, playState.m_nRow, true))\n\t\t\t{\n\t\t\t\t// We aren't searching for a specific row, or we couldn't find any more unvisited rows.\n\t\t\t\tbreak;\n\t\t\t} else\n\t\t\t{\n\t\t\t\t// We haven't found the target row yet, but we found some other unplayed row... continue searching from here.\n\t\t\t\tretval.duration = memory.elapsedTime;\n\t\t\t\tresults.push_back(retval);\n\t\t\t\tretval.startRow = playState.m_nRow;\n\t\t\t\tretval.startOrder = playState.m_nNextOrder;\n\t\t\t\tmemory.Reset();\n\t\t\t\tplayState.m_nNextRow = playState.m_nRow;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}",
"\t\tretval.endOrder = playState.m_nCurrentOrder;\n\t\tretval.endRow = playState.m_nRow;",
"\t\t// Update next position\n\t\tplayState.m_nNextRow = playState.m_nRow + 1;",
"\t\t// Jumped to invalid pattern row?\n\t\tif(playState.m_nRow >= Patterns[playState.m_nPattern].GetNumRows())\n\t\t{\n\t\t\tplayState.m_nRow = 0;\n\t\t}\n\t\t// New pattern?\n\t\tif(!playState.m_nRow)\n\t\t{\n\t\t\tfor(CHANNELINDEX chn = 0; chn < GetNumChannels(); chn++)\n\t\t\t{\n\t\t\t\tmemory.chnSettings[chn].patLoop = memory.elapsedTime;\n\t\t\t\tmemory.chnSettings[chn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t}\n\t\t}",
"\t\tModChannel *pChn = playState.Chn;\n\t\t\n\t\t// For various effects, we need to know first how many ticks there are in this row.\n\t\tconst ModCommand *p = Patterns[playState.m_nPattern].GetpModCommand(playState.m_nRow, 0);\n\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, p++)\n\t\t{\n\t\t\tif(m_playBehaviour[kST3NoMutedChannels] && ChnSettings[nChn].dwFlags[CHN_MUTE])\t// not even effects are processed on muted S3M channels\n\t\t\t\tcontinue;\n\t\t\tif(p->IsPcNote())\n\t\t\t{\n#ifndef NO_PLUGINS\n\t\t\t\tif((adjustMode & eAdjust) && p->instr > 0 && p->instr <= MAX_MIXPLUGINS)\n\t\t\t\t{\n\t\t\t\t\tmemory.plugParams[std::make_pair(p->instr, p->GetValueVolCol())] = p->GetValueEffectCol();\n\t\t\t\t}\n#endif // NO_PLUGINS\n\t\t\t\tpChn[nChn].rowCommand.Clear();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tpChn[nChn].rowCommand = *p;\n\t\t\tswitch(p->command)\n\t\t\t{\n\t\t\tcase CMD_SPEED:\n\t\t\t\tSetSpeed(playState, p->param);\n\t\t\t\tbreak;",
"\t\t\tcase CMD_TEMPO:\n\t\t\t\tif(m_playBehaviour[kMODVBlankTiming])\n\t\t\t\t{\n\t\t\t\t\t// ProTracker MODs with VBlank timing: All Fxx parameters set the tick count.\n\t\t\t\t\tif(p->param != 0) SetSpeed(playState, p->param);\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\tif((p->param & 0xF0) == 0x60)\n\t\t\t\t{\n\t\t\t\t\t// Fine Pattern Delay\n\t\t\t\t\ttickDelay += (p->param & 0x0F);\n\t\t\t\t} else if((p->param & 0xF0) == 0xE0 && !rowDelay)\n\t\t\t\t{\n\t\t\t\t\t// Pattern Delay\n\t\t\t\t\tif(!(GetType() & MOD_TYPE_S3M) || (p->param & 0x0F) != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t// While Impulse Tracker *does* count S60 as a valid row delay (and thus ignores any other row delay commands on the right),\n\t\t\t\t\t\t// Scream Tracker 3 simply ignores such commands.\n\t\t\t\t\t\trowDelay = 1 + (p->param & 0x0F);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_MODCMDEX:\n\t\t\t\tif((p->param & 0xF0) == 0xE0)\n\t\t\t\t{\n\t\t\t\t\t// Pattern Delay\n\t\t\t\t\trowDelay = 1 + (p->param & 0x0F);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(rowDelay == 0) rowDelay = 1;\n\t\tconst uint32 numTicks = (playState.m_nMusicSpeed + tickDelay) * rowDelay;\n\t\tconst uint32 nonRowTicks = numTicks - rowDelay;",
"\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); pChn++, nChn++) if(!pChn->rowCommand.IsEmpty())\n\t\t{\n\t\t\tif(m_playBehaviour[kST3NoMutedChannels] && ChnSettings[nChn].dwFlags[CHN_MUTE])\t// not even effects are processed on muted S3M channels\n\t\t\t\tcontinue;\n\t\t\tModCommand::COMMAND command = pChn->rowCommand.command;\n\t\t\tModCommand::PARAM param = pChn->rowCommand.param;\n\t\t\tModCommand::NOTE note = pChn->rowCommand.note;",
"\t\t\tif (pChn->rowCommand.instr)\n\t\t\t{\n\t\t\t\tpChn->nNewIns = pChn->rowCommand.instr;\n\t\t\t\tpChn->nLastNote = NOTE_NONE;\n\t\t\t\tmemory.chnSettings[nChn].vol = 0xFF;\n\t\t\t}\n\t\t\tif (pChn->rowCommand.IsNote()) pChn->nLastNote = note;",
"\t\t\t// Update channel panning\n\t\t\tif(pChn->rowCommand.IsNote() || pChn->rowCommand.instr)\n\t\t\t{\n\t\t\t\tSAMPLEINDEX smp = 0;\n\t\t\t\tif(GetNumInstruments())\n\t\t\t\t{\n\t\t\t\t\tModInstrument *pIns;\n\t\t\t\t\tif(pChn->nNewIns <= GetNumInstruments() && (pIns = Instruments[pChn->nNewIns]) != nullptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(pIns->dwFlags[INS_SETPANNING])\n\t\t\t\t\t\t\tpChn->nPan = pIns->nPan;\n\t\t\t\t\t\tif(ModCommand::IsNote(note))\n\t\t\t\t\t\t\tsmp = pIns->Keyboard[note - NOTE_MIN];\n\t\t\t\t\t}\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tsmp = pChn->nNewIns;\n\t\t\t\t}\n\t\t\t\tif(smp > 0 && smp <= GetNumSamples() && Samples[smp].uFlags[CHN_PANNING])\n\t\t\t\t{\n\t\t\t\t\tpChn->nPan = Samples[smp].nPan;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tswitch(pChn->rowCommand.volcmd)\n\t\t\t{\n\t\t\tcase VOLCMD_VOLUME:\n\t\t\t\tmemory.chnSettings[nChn].vol = pChn->rowCommand.vol;\n\t\t\t\tbreak;\n\t\t\tcase VOLCMD_VOLSLIDEUP:\n\t\t\tcase VOLCMD_VOLSLIDEDOWN:\n\t\t\t\tif(pChn->rowCommand.vol != 0)\n\t\t\t\t\tpChn->nOldVolParam = pChn->rowCommand.vol;\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tswitch(command)\n\t\t\t{\n\t\t\t// Position Jump\n\t\t\tcase CMD_POSITIONJUMP:\n\t\t\t\tpositionJumpOnThisRow = true;\n\t\t\t\tplayState.m_nNextOrder = static_cast<ORDERINDEX>(CalculateXParam(playState.m_nPattern, playState.m_nRow, nChn));\n\t\t\t\tplayState.m_nNextPatStartRow = 0; // FT2 E60 bug\n\t\t\t\t// see https://forum.openmpt.org/index.php?topic=2769.0 - FastTracker resets Dxx if Bxx is called _after_ Dxx\n\t\t\t\t// Test case: PatternJump.mod\n\t\t\t\tif(!patternBreakOnThisRow || (GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)))\n\t\t\t\t\tplayState.m_nNextRow = 0;",
"\t\t\t\tif (adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\tpChn->nPatternLoopCount = 0;\n\t\t\t\t\tpChn->nPatternLoop = 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// Pattern Break\n\t\t\tcase CMD_PATTERNBREAK:\n\t\t\t\t{\n\t\t\t\t\tROWINDEX row = PatternBreak(playState, nChn, param);\n\t\t\t\t\tif(row != ROWINDEX_INVALID)\n\t\t\t\t\t{\n\t\t\t\t\t\tpatternBreakOnThisRow = true;\n\t\t\t\t\t\tplayState.m_nNextRow = row;",
"\t\t\t\t\t\tif(!positionJumpOnThisRow)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tplayState.m_nNextOrder = playState.m_nCurrentOrder + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpChn->nPatternLoopCount = 0;\n\t\t\t\t\t\t\tpChn->nPatternLoop = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// Set Tempo\n\t\t\tcase CMD_TEMPO:\n\t\t\t\tif(!m_playBehaviour[kMODVBlankTiming])\n\t\t\t\t{\n\t\t\t\t\tTEMPO tempo(CalculateXParam(playState.m_nPattern, playState.m_nRow, nChn), 0);\n\t\t\t\t\tif ((adjustMode & eAdjust) && (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (tempo.GetInt()) pChn->nOldTempo = static_cast<uint8>(tempo.GetInt()); else tempo.Set(pChn->nOldTempo);\n\t\t\t\t\t}",
"\t\t\t\t\tif (tempo.GetInt() >= 0x20) playState.m_nMusicTempo = tempo;\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// Tempo Slide\n\t\t\t\t\t\tTEMPO tempoDiff((tempo.GetInt() & 0x0F) * nonRowTicks, 0);\n\t\t\t\t\t\tif ((tempo.GetInt() & 0xF0) == 0x10)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tplayState.m_nMusicTempo += tempoDiff;\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(tempoDiff < playState.m_nMusicTempo)\n\t\t\t\t\t\t\t\tplayState.m_nMusicTempo -= tempoDiff;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tplayState.m_nMusicTempo.Set(0);\n\t\t\t\t\t\t}\n\t\t\t\t\t}",
"\t\t\t\t\tTEMPO tempoMin = GetModSpecifications().GetTempoMin(), tempoMax = GetModSpecifications().GetTempoMax();\n\t\t\t\t\tif(m_playBehaviour[kTempoClamp])\t// clamp tempo correctly in compatible mode\n\t\t\t\t\t{\n\t\t\t\t\t\ttempoMax.Set(255);\n\t\t\t\t\t}\n\t\t\t\t\tLimit(playState.m_nMusicTempo, tempoMin, tempoMax);\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\tswitch(param & 0xF0)\n\t\t\t\t{\n\t\t\t\tcase 0x90:\n\t\t\t\t\tif(param <= 0x91)\n\t\t\t\t\t{\n\t\t\t\t\t\tpChn->dwFlags.set(CHN_SURROUND, param == 0x91);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;",
"\t\t\t\tcase 0xA0:\n\t\t\t\t\t// High sample offset\n\t\t\t\t\tpChn->nOldHiOffset = param & 0x0F;\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcase 0xB0:\n\t\t\t\t\t// Pattern Loop\n\t\t\t\t\tif (param & 0x0F)\n\t\t\t\t\t{\n\t\t\t\t\t\tpatternLoopEndedOnThisRow = true;\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tCHANNELINDEX firstChn = nChn, lastChn = nChn;\n\t\t\t\t\t\tif(GetType() == MOD_TYPE_S3M)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// ST3 has only one global loop memory.\n\t\t\t\t\t\t\tfirstChn = 0;\n\t\t\t\t\t\t\tlastChn = GetNumChannels() - 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor(CHANNELINDEX c = firstChn; c <= lastChn; c++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemory.chnSettings[c].patLoop = memory.elapsedTime;\n\t\t\t\t\t\t\tmemory.chnSettings[c].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t\t\tmemory.chnSettings[c].patLoopStart = playState.m_nRow;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpatternLoopStartedOnThisRow = true;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;",
"\t\t\t\tcase 0xF0:\n\t\t\t\t\t// Active macro\n\t\t\t\t\tpChn->nActiveMacro = param & 0x0F;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_MODCMDEX:\n\t\t\t\tswitch(param & 0xF0)\n\t\t\t\t{\n\t\t\t\tcase 0x60:\n\t\t\t\t\t// Pattern Loop\n\t\t\t\t\tif (param & 0x0F)\n\t\t\t\t\t{\n\t\t\t\t\t\tplayState.m_nNextPatStartRow = memory.chnSettings[nChn].patLoopStart; // FT2 E60 bug\n\t\t\t\t\t\tpatternLoopEndedOnThisRow = true;\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tpatternLoopStartedOnThisRow = true;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoop = memory.elapsedTime;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopStart = playState.m_nRow;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;",
"\t\t\t\tcase 0xF0:\n\t\t\t\t\t// Active macro\n\t\t\t\t\tpChn->nActiveMacro = param & 0x0F;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_XFINEPORTAUPDOWN:\n\t\t\t\t// ignore high offset in compatible mode\n\t\t\t\tif(((param & 0xF0) == 0xA0) && !m_playBehaviour[kFT2RestrictXCommand]) pChn->nOldHiOffset = param & 0x0F;\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\t// The following calculations are not interesting if we just want to get the song length.\n\t\t\tif (!(adjustMode & eAdjust)) continue;\n\t\t\tswitch(command)\n\t\t\t{\n\t\t\t// Portamento Up/Down\n\t\t\tcase CMD_PORTAMENTOUP:\n\t\t\t\tif(param)\n\t\t\t\t{\n\t\t\t\t\t// FT2 compatibility: Separate effect memory for all portamento commands\n\t\t\t\t\t// Test case: Porta-LinkMem.xm\n\t\t\t\t\tif(!m_playBehaviour[kFT2PortaUpDownMemory])\n\t\t\t\t\t\tpChn->nOldPortaDown = param;\n\t\t\t\t\tpChn->nOldPortaUp = param;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CMD_PORTAMENTODOWN:\n\t\t\t\tif(param)\n\t\t\t\t{\n\t\t\t\t\t// FT2 compatibility: Separate effect memory for all portamento commands\n\t\t\t\t\t// Test case: Porta-LinkMem.xm\n\t\t\t\t\tif(!m_playBehaviour[kFT2PortaUpDownMemory])\n\t\t\t\t\t\tpChn->nOldPortaUp = param;\n\t\t\t\t\tpChn->nOldPortaDown = param;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// Tone-Portamento\n\t\t\tcase CMD_TONEPORTAMENTO:\n\t\t\t\tif (param) pChn->nPortamentoSlide = param << 2;\n\t\t\t\tbreak;\n\t\t\t// Offset\n\t\t\tcase CMD_OFFSET:\n\t\t\t\tif (param) pChn->oldOffset = param << 8;\n\t\t\t\tbreak;\n\t\t\t// Volume Slide\n\t\t\tcase CMD_VOLUMESLIDE:\n\t\t\tcase CMD_TONEPORTAVOL:\n\t\t\t\tif (param) pChn->nOldVolumeSlide = param;\n\t\t\t\tbreak;\n\t\t\t// Set Volume\n\t\t\tcase CMD_VOLUME:\n\t\t\t\tmemory.chnSettings[nChn].vol = param;\n\t\t\t\tbreak;\n\t\t\t// Global Volume\n\t\t\tcase CMD_GLOBALVOLUME:\n\t\t\t\tif(!(GetType() & GLOBALVOL_7BIT_FORMATS) && param < 128) param *= 2;\n\t\t\t\t// IT compatibility 16. ST3 and IT ignore out-of-range values\n\t\t\t\tif(param <= 128)\n\t\t\t\t{\n\t\t\t\t\tplayState.m_nGlobalVolume = param * 2;\n\t\t\t\t} else if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_S3M)))\n\t\t\t\t{\n\t\t\t\t\tplayState.m_nGlobalVolume = 256;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// Global Volume Slide\n\t\t\tcase CMD_GLOBALVOLSLIDE:\n\t\t\t\tif(m_playBehaviour[kPerChannelGlobalVolSlide])\n\t\t\t\t{\n\t\t\t\t\t// IT compatibility 16. Global volume slide params are stored per channel (FT2/IT)\n\t\t\t\t\tif (param) pChn->nOldGlobalVolSlide = param; else param = pChn->nOldGlobalVolSlide;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tif (param) playState.Chn[0].nOldGlobalVolSlide = param; else param = playState.Chn[0].nOldGlobalVolSlide;\n\t\t\t\t}\n\t\t\t\tif (((param & 0x0F) == 0x0F) && (param & 0xF0))\n\t\t\t\t{\n\t\t\t\t\tparam >>= 4;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume += param << 1;\n\t\t\t\t} else if (((param & 0xF0) == 0xF0) && (param & 0x0F))\n\t\t\t\t{\n\t\t\t\t\tparam = (param & 0x0F) << 1;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume -= param;\n\t\t\t\t} else if (param & 0xF0)\n\t\t\t\t{\n\t\t\t\t\tparam >>= 4;\n\t\t\t\t\tparam <<= 1;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume += param * nonRowTicks;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tparam = (param & 0x0F) << 1;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume -= param * nonRowTicks;\n\t\t\t\t}\n\t\t\t\tLimit(playState.m_nGlobalVolume, 0, 256);\n\t\t\t\tbreak;\n\t\t\tcase CMD_CHANNELVOLUME:\n\t\t\t\tif (param <= 64) pChn->nGlobalVol = param;\n\t\t\t\tbreak;\n\t\t\tcase CMD_CHANNELVOLSLIDE:\n\t\t\t\t{\n\t\t\t\t\tif (param) pChn->nOldChnVolSlide = param; else param = pChn->nOldChnVolSlide;\n\t\t\t\t\tint32 volume = pChn->nGlobalVol;\n\t\t\t\t\tif((param & 0x0F) == 0x0F && (param & 0xF0))\n\t\t\t\t\t\tvolume += (param >> 4);\t\t// Fine Up\n\t\t\t\t\telse if((param & 0xF0) == 0xF0 && (param & 0x0F))\n\t\t\t\t\t\tvolume -= (param & 0x0F);\t// Fine Down\n\t\t\t\t\telse if(param & 0x0F)\t\t\t// Down\n\t\t\t\t\t\tvolume -= (param & 0x0F) * nonRowTicks;\n\t\t\t\t\telse\t\t\t\t\t\t\t// Up\n\t\t\t\t\t\tvolume += ((param & 0xF0) >> 4) * nonRowTicks;\n\t\t\t\t\tLimit(volume, 0, 64);\n\t\t\t\t\tpChn->nGlobalVol = volume;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CMD_PANNING8:\n\t\t\t\tPanning(pChn, param, Pan8bit);\n\t\t\t\tbreak;\n\t\t\tcase CMD_MODCMDEX:\n\t\t\t\tif(param < 0x10)\n\t\t\t\t{\n\t\t\t\t\t// LED filter\n\t\t\t\t\tfor(CHANNELINDEX chn = 0; chn < GetNumChannels(); chn++)\n\t\t\t\t\t{\n\t\t\t\t\t\tplayState.Chn[chn].dwFlags.set(CHN_AMIGAFILTER, !(param & 1));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tMPT_FALLTHROUGH;\n\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\tif((param & 0xF0) == 0x80)\n\t\t\t\t{\n\t\t\t\t\tPanning(pChn, (param & 0x0F), Pan4bit);\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_VIBRATOVOL:\n\t\t\t\tif (param) pChn->nOldVolumeSlide = param;\n\t\t\t\tparam = 0;\n\t\t\t\tMPT_FALLTHROUGH;\n\t\t\tcase CMD_VIBRATO:\n\t\t\t\tVibrato(pChn, param);\n\t\t\t\tbreak;\n\t\t\tcase CMD_FINEVIBRATO:\n\t\t\t\tFineVibrato(pChn, param);\n\t\t\t\tbreak;\n\t\t\tcase CMD_TREMOLO:\n\t\t\t\tTremolo(pChn, param);\n\t\t\t\tbreak;\n\t\t\tcase CMD_PANBRELLO:\n\t\t\t\tPanbrello(pChn, param);\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tswitch(pChn->rowCommand.volcmd)\n\t\t\t{\n\t\t\tcase VOLCMD_PANNING:\n\t\t\t\tPanning(pChn, pChn->rowCommand.vol, Pan6bit);\n\t\t\t\tbreak;",
"\t\t\tcase VOLCMD_VIBRATOSPEED:\n\t\t\t\t// FT2 does not automatically enable vibrato with the \"set vibrato speed\" command\n\t\t\t\tif(m_playBehaviour[kFT2VolColVibrato])\n\t\t\t\t\tpChn->nVibratoSpeed = pChn->rowCommand.vol & 0x0F;\n\t\t\t\telse\n\t\t\t\t\tVibrato(pChn, pChn->rowCommand.vol << 4);\n\t\t\t\tbreak;\n\t\t\tcase VOLCMD_VIBRATODEPTH:\n\t\t\t\tVibrato(pChn, pChn->rowCommand.vol);\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\t// Process vibrato / tremolo / panbrello\n\t\t\tswitch(pChn->rowCommand.command)\n\t\t\t{\n\t\t\tcase CMD_VIBRATO:\n\t\t\tcase CMD_FINEVIBRATO:\n\t\t\tcase CMD_VIBRATOVOL:\n\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\tuint32 vibTicks = ((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && !m_SongFlags[SONG_ITOLDEFFECTS]) ? numTicks : nonRowTicks;\n\t\t\t\t\tuint32 inc = pChn->nVibratoSpeed * vibTicks;\n\t\t\t\t\tif(m_playBehaviour[kITVibratoTremoloPanbrello])\n\t\t\t\t\t\tinc *= 4;\n\t\t\t\t\tpChn->nVibratoPos += static_cast<uint8>(inc);\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_TREMOLO:\n\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\tuint32 tremTicks = ((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && !m_SongFlags[SONG_ITOLDEFFECTS]) ? numTicks : nonRowTicks;\n\t\t\t\t\tuint32 inc = pChn->nTremoloSpeed * tremTicks;\n\t\t\t\t\tif(m_playBehaviour[kITVibratoTremoloPanbrello])\n\t\t\t\t\t\tinc *= 4;\n\t\t\t\t\tpChn->nTremoloPos += static_cast<uint8>(inc);\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_PANBRELLO:\n\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\t// Panbrello effect is permanent in compatible mode, so actually apply panbrello for the last tick of this row\n\t\t\t\t\tpChn->nPanbrelloPos += static_cast<uint8>(pChn->nPanbrelloSpeed * (numTicks - 1));\n\t\t\t\t\tProcessPanbrello(pChn);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\t// Interpret F00 effect in XM files as \"stop song\"\n\t\tif(GetType() == MOD_TYPE_XM && playState.m_nMusicSpeed == uint16_max)\n\t\t{\n\t\t\tbreak;\n\t\t}",
"\t\tplayState.m_nCurrentRowsPerBeat = m_nDefaultRowsPerBeat;\n\t\tif(Patterns[playState.m_nPattern].GetOverrideSignature())\n\t\t{\n\t\t\tplayState.m_nCurrentRowsPerBeat = Patterns[playState.m_nPattern].GetRowsPerBeat();\n\t\t}",
"\t\tconst uint32 tickDuration = GetTickDuration(playState);\n\t\tconst uint32 rowDuration = tickDuration * numTicks;\n\t\tmemory.elapsedTime += static_cast<double>(rowDuration) / static_cast<double>(m_MixerSettings.gdwMixingFreq);\n\t\tplayState.m_lTotalSampleCount += rowDuration;",
"\t\tif(adjustSamplePos)\n\t\t{\n\t\t\t// Super experimental and dirty sample seeking\n\t\t\tpChn = playState.Chn;\n\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); pChn++, nChn++)\n\t\t\t{\n\t\t\t\tif(memory.chnSettings[nChn].ticksToRender == GetLengthMemory::IGNORE_CHANNEL)\n\t\t\t\t\tcontinue;",
"\t\t\t\tuint32 startTick = 0;\n\t\t\t\tconst ModCommand &m = pChn->rowCommand;\n\t\t\t\tuint32 paramHi = m.param >> 4, paramLo = m.param & 0x0F;\n\t\t\t\tbool porta = m.command == CMD_TONEPORTAMENTO || m.command == CMD_TONEPORTAVOL || m.volcmd == VOLCMD_TONEPORTAMENTO;\n\t\t\t\tbool stopNote = patternLoopStartedOnThisRow;\t// It's too much trouble to keep those pattern loops in sync...",
"\t\t\t\tif(m.instr) pChn->proTrackerOffset = 0;\n\t\t\t\tif(m.IsNote())\n\t\t\t\t{\n\t\t\t\t\tif(porta && memory.chnSettings[nChn].incChanged)\n\t\t\t\t\t{\n\t\t\t\t\t\t// If there's a portamento, the current channel increment mustn't be 0 in NoteChange()\n\t\t\t\t\t\tpChn->increment = GetChannelIncrement(pChn, pChn->nPeriod, 0);\n\t\t\t\t\t}\n\t\t\t\t\tint32 setPan = pChn->nPan;\n\t\t\t\t\tpChn->nNewNote = pChn->nLastNote;\n\t\t\t\t\tif(pChn->nNewIns != 0) InstrumentChange(pChn, pChn->nNewIns, porta);\n\t\t\t\t\tNoteChange(pChn, m.note, porta);\n\t\t\t\t\tmemory.chnSettings[nChn].incChanged = true;",
"\t\t\t\t\tif((m.command == CMD_MODCMDEX || m.command == CMD_S3MCMDEX) && (m.param & 0xF0) == 0xD0 && paramLo < numTicks)\n\t\t\t\t\t{\n\t\t\t\t\t\tstartTick = paramLo;\n\t\t\t\t\t} else if(m.command == CMD_DELAYCUT && paramHi < numTicks)\n\t\t\t\t\t{\n\t\t\t\t\t\tstartTick = paramHi;\n\t\t\t\t\t}\n\t\t\t\t\tif(rowDelay > 1 && startTick != 0 && (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)))\n\t\t\t\t\t{\n\t\t\t\t\t\tstartTick += (playState.m_nMusicSpeed + tickDelay) * (rowDelay - 1);\n\t\t\t\t\t}\n\t\t\t\t\tif(!porta) memory.chnSettings[nChn].ticksToRender = 0;",
"\t\t\t\t\t// Panning commands have to be re-applied after a note change with potential pan change.\n\t\t\t\t\tif(m.command == CMD_PANNING8\n\t\t\t\t\t\t|| ((m.command == CMD_MODCMDEX || m.command == CMD_S3MCMDEX) && paramHi == 0x8)\n\t\t\t\t\t\t|| m.volcmd == VOLCMD_PANNING)\n\t\t\t\t\t{\n\t\t\t\t\t\tpChn->nPan = setPan;\n\t\t\t\t\t}",
"\t\t\t\t\tif(m.command == CMD_OFFSET)\n\t\t\t\t\t{\n\t\t\t\t\t\tbool isExtended = false;\n\t\t\t\t\t\tSmpLength offset = CalculateXParam(playState.m_nPattern, playState.m_nRow, nChn, &isExtended);\n\t\t\t\t\t\tif(!isExtended)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toffset <<= 8;\n\t\t\t\t\t\t\tif(offset == 0) offset = pChn->oldOffset;\n\t\t\t\t\t\t\toffset += static_cast<SmpLength>(pChn->nOldHiOffset) << 16;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tSampleOffset(*pChn, offset);\n\t\t\t\t\t} else if(m.command == CMD_OFFSETPERCENTAGE)\n\t\t\t\t\t{\n\t\t\t\t\t\tSampleOffset(*pChn, Util::muldiv_unsigned(pChn->nLength, m.param, 255));\n\t\t\t\t\t} else if(m.command == CMD_REVERSEOFFSET && pChn->pModSample != nullptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t// Re-sync what we've got so far\n\t\t\t\t\t\tReverseSampleOffset(*pChn, m.param);\n\t\t\t\t\t\tstartTick = playState.m_nMusicSpeed - 1;\n\t\t\t\t\t} else if(m.volcmd == VOLCMD_OFFSET)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(m.vol <= CountOf(pChn->pModSample->cues) && pChn->pModSample != nullptr)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSmpLength offset;\n\t\t\t\t\t\t\tif(m.vol == 0)\n\t\t\t\t\t\t\t\toffset = pChn->oldOffset;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\toffset = pChn->oldOffset = pChn->pModSample->cues[m.vol - 1];\n\t\t\t\t\t\t\tSampleOffset(*pChn, offset);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}",
"\t\t\t\tif(m.note == NOTE_KEYOFF || m.note == NOTE_NOTECUT || (m.note == NOTE_FADE && GetNumInstruments())\n\t\t\t\t\t|| ((m.command == CMD_MODCMDEX || m.command == CMD_S3MCMDEX) && (m.param & 0xF0) == 0xC0 && paramLo < numTicks)\n\t\t\t\t\t|| (m.command == CMD_DELAYCUT && paramLo != 0 && startTick + paramLo < numTicks))\n\t\t\t\t{\n\t\t\t\t\tstopNote = true;\n\t\t\t\t}",
"\t\t\t\tif(m.command == CMD_VOLUME)\n\t\t\t\t{\n\t\t\t\t\tpChn->nVolume = m.param * 4;\n\t\t\t\t} else if(m.volcmd == VOLCMD_VOLUME)\n\t\t\t\t{\n\t\t\t\t\tpChn->nVolume = m.vol * 4;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(pChn->pModSample && !stopNote)\n\t\t\t\t{\n\t\t\t\t\t// Check if we don't want to emulate some effect and thus stop processing.\n\t\t\t\t\tif(m.command < MAX_EFFECTS)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(forbiddenCommands[m.command])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstopNote = true;\n\t\t\t\t\t\t} else if(m.command == CMD_MODCMDEX)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Special case: Slides using extended commands\n\t\t\t\t\t\t\tswitch(m.param & 0xF0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase 0x10:\n\t\t\t\t\t\t\tcase 0x20:\n\t\t\t\t\t\t\t\tstopNote = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}",
"\t\t\t\t\tif(m.volcmd < forbiddenVolCommands.size() && forbiddenVolCommands[m.volcmd])\n\t\t\t\t\t{\n\t\t\t\t\t\tstopNote = true;\n\t\t\t\t\t}\n\t\t\t\t}",
"\t\t\t\tif(stopNote)\n\t\t\t\t{\n\t\t\t\t\tpChn->Stop();\n\t\t\t\t\tmemory.chnSettings[nChn].ticksToRender = 0;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tif(oldTickDuration != tickDuration && oldTickDuration != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t// Re-sync what we've got so far\n\t\t\t\t\t}",
"\t\t\t\t\tswitch(m.command)\n\t\t\t\t\t{\n\t\t\t\t\tcase CMD_TONEPORTAVOL:\n\t\t\t\t\tcase CMD_VOLUMESLIDE:\n\t\t\t\t\tcase CMD_VIBRATOVOL:\n\t\t\t\t\t\tif(m.param || (GetType() != MOD_TYPE_MOD))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor(uint32 i = 0; i < numTicks; i++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tpChn->isFirstTick = (i == 0);\n\t\t\t\t\t\t\t\tVolumeSlide(pChn, m.param);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;",
"\t\t\t\t\tcase CMD_MODCMDEX:\n\t\t\t\t\t\tif((m.param & 0x0F) || (GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpChn->isFirstTick = true;\n\t\t\t\t\t\t\tswitch(m.param & 0xF0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase 0xA0: FineVolumeUp(pChn, m.param & 0x0F, false); break;\n\t\t\t\t\t\t\tcase 0xB0: FineVolumeDown(pChn, m.param & 0x0F, false); break;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;",
"\t\t\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\t\t\tif(m.param == 0x9E)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Play forward\n\t\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t// Re-sync what we've got so far\n\t\t\t\t\t\t\tpChn->dwFlags.reset(CHN_PINGPONGFLAG);\n\t\t\t\t\t\t} else if(m.param == 0x9F)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Reverse\n\t\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t// Re-sync what we've got so far\n\t\t\t\t\t\t\tpChn->dwFlags.set(CHN_PINGPONGFLAG);\n\t\t\t\t\t\t\tif(!pChn->position.GetInt() && pChn->nLength && (m.IsNote() || !pChn->dwFlags[CHN_LOOP]))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tpChn->position.Set(pChn->nLength - 1, SamplePosition::fractMax);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if((m.param & 0xF0) == 0x70)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// TODO\n\t\t\t\t\t\t\t//ExtendedS3MCommands(nChn, param);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tpChn->isFirstTick = true;\n\t\t\t\t\tswitch(m.volcmd)\n\t\t\t\t\t{\n\t\t\t\t\tcase VOLCMD_FINEVOLUP:\t\tFineVolumeUp(pChn, m.vol, m_playBehaviour[kITVolColMemory]); break;\n\t\t\t\t\tcase VOLCMD_FINEVOLDOWN:\tFineVolumeDown(pChn, m.vol, m_playBehaviour[kITVolColMemory]); break;\n\t\t\t\t\tcase VOLCMD_VOLSLIDEUP:\n\t\t\t\t\tcase VOLCMD_VOLSLIDEDOWN:\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// IT Compatibility: Volume column volume slides have their own memory\n\t\t\t\t\t\t\t// Test case: VolColMemory.it\n\t\t\t\t\t\t\tModCommand::VOL vol = m.vol;\n\t\t\t\t\t\t\tif(vol == 0 && m_playBehaviour[kITVolColMemory])\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvol = pChn->nOldVolParam;\n\t\t\t\t\t\t\t\tif(vol == 0)\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(m.volcmd == VOLCMD_VOLSLIDEUP)\n\t\t\t\t\t\t\t\tvol <<= 4;\n\t\t\t\t\t\t\tfor(uint32 i = 0; i < numTicks; i++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tpChn->isFirstTick = (i == 0);\n\t\t\t\t\t\t\t\tVolumeSlide(pChn, vol);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}",
"\t\t\t\t\tif(porta)\n\t\t\t\t\t{\n\t\t\t\t\t\t// Portamento needs immediate syncing, as the pitch changes on each tick\n\t\t\t\t\t\tuint32 portaTick = memory.chnSettings[nChn].ticksToRender + startTick + 1;\n\t\t\t\t\t\tmemory.chnSettings[nChn].ticksToRender += numTicks;\n\t\t\t\t\t\tmemory.RenderChannel(nChn, tickDuration, portaTick);\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.chnSettings[nChn].ticksToRender += (numTicks - startTick);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\toldTickDuration = tickDuration;",
"\t\t// Pattern loop is not executed in FT2 if there are any position jump or pattern break commands on the same row.\n\t\t// Pattern loop is not executed in IT if there are any position jump commands on the same row.\n\t\t// Test case for FT2 exception: PatLoop-Jumps.xm, PatLoop-Various.xm\n\t\t// Test case for IT: exception: LoopBreak.it\n\t\tif(patternLoopEndedOnThisRow\n\t\t\t&& (!m_playBehaviour[kFT2PatternLoopWithJumps] || !(positionJumpOnThisRow || patternBreakOnThisRow))\n\t\t\t&& (!m_playBehaviour[kITPatternLoopWithJumps] || !positionJumpOnThisRow))\n\t\t{\n\t\t\tstd::map<double, int> startTimes;\n\t\t\t// This is really just a simple estimation for nested pattern loops. It should handle cases correctly where all parallel loops start and end on the same row.\n\t\t\t// If one of them starts or ends \"in between\", it will most likely calculate a wrong duration.\n\t\t\t// For S3M files, it's also way off.\n\t\t\tpChn = playState.Chn;\n\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)\n\t\t\t{\n\t\t\t\tModCommand::COMMAND command = pChn->rowCommand.command;\n\t\t\t\tModCommand::PARAM param = pChn->rowCommand.param;\n\t\t\t\tif((command == CMD_S3MCMDEX && param >= 0xB1 && param <= 0xBF)\n\t\t\t\t\t|| (command == CMD_MODCMDEX && param >= 0x61 && param <= 0x6F))\n\t\t\t\t{\n\t\t\t\t\tconst double start = memory.chnSettings[nChn].patLoop;\n\t\t\t\t\tif(!startTimes[start]) startTimes[start] = 1;\n\t\t\t\t\tstartTimes[start] = mpt::lcm(startTimes[start], 1 + (param & 0x0F));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(const auto &i : startTimes)\n\t\t\t{\n\t\t\t\tmemory.elapsedTime += (memory.elapsedTime - i.first) * (double)(i.second - 1);\n\t\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)\n\t\t\t\t{\n\t\t\t\t\tif(memory.chnSettings[nChn].patLoop == i.first)\n\t\t\t\t\t{\n\t\t\t\t\t\tplayState.m_lTotalSampleCount += (playState.m_lTotalSampleCount - memory.chnSettings[nChn].patLoopSmp) * (i.second - 1);\n\t\t\t\t\t\tif(m_playBehaviour[kITPatternLoopTargetReset] || (GetType() == MOD_TYPE_S3M))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemory.chnSettings[nChn].patLoop = memory.elapsedTime;\n\t\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopStart = playState.m_nRow + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(GetType() == MOD_TYPE_IT)\n\t\t\t{\n\t\t\t\t// IT pattern loop start row update - at the end of a pattern loop, set pattern loop start to next row (for upcoming pattern loops with missing SB0)",
"\t\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++)",
"\t\t\t\t{\n\t\t\t\t\tif((pChn->rowCommand.command == CMD_S3MCMDEX && pChn->rowCommand.param >= 0xB1 && pChn->rowCommand.param <= 0xBF))\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoop = memory.elapsedTime;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"\t// Now advance the sample positions for sample seeking on channels that are still playing\n\tif(adjustSamplePos)\n\t{\n\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++)\n\t\t{\n\t\t\tif(memory.chnSettings[nChn].ticksToRender != GetLengthMemory::IGNORE_CHANNEL)\n\t\t\t{\n\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\n\t\t\t}\n\t\t}\n\t}",
"\tif(retval.targetReached || target.mode == GetLengthTarget::NoTarget)\n\t{\n\t\tretval.lastOrder = playState.m_nCurrentOrder;\n\t\tretval.lastRow = playState.m_nRow;\n\t}\n\tretval.duration = memory.elapsedTime;\n\tresults.push_back(retval);",
"\t// Store final variables\n\tif(adjustMode & eAdjust)\n\t{\n\t\tif(retval.targetReached || target.mode == GetLengthTarget::NoTarget)\n\t\t{\n\t\t\t// Target found, or there is no target (i.e. play whole song)...\n\t\t\tm_PlayState = std::move(playState);\n\t\t\tm_PlayState.m_nNextRow = m_PlayState.m_nRow;\n\t\t\tm_PlayState.m_nFrameDelay = m_PlayState.m_nPatternDelay = 0;\n\t\t\tm_PlayState.m_nTickCount = Util::MaxValueOfType(m_PlayState.m_nTickCount) - 1;\n\t\t\tm_PlayState.m_bPositionChanged = true;\n\t\t\tfor(CHANNELINDEX n = 0; n < GetNumChannels(); n++)\n\t\t\t{\n\t\t\t\tif(m_PlayState.Chn[n].nLastNote != NOTE_NONE)\n\t\t\t\t{\n\t\t\t\t\tm_PlayState.Chn[n].nNewNote = m_PlayState.Chn[n].nLastNote;\n\t\t\t\t}\n\t\t\t\tif(memory.chnSettings[n].vol != 0xFF && !adjustSamplePos)\n\t\t\t\t{\n\t\t\t\t\tm_PlayState.Chn[n].nVolume = std::min(memory.chnSettings[n].vol, uint8(64)) * 4;\n\t\t\t\t}\n\t\t\t}",
"#ifndef NO_PLUGINS\n\t\t\t// If there were any PC events, update plugin parameters to their latest value.\n\t\t\tstd::bitset<MAX_MIXPLUGINS> plugSetProgram;\n\t\t\tfor(const auto ¶m : memory.plugParams)\n\t\t\t{\n\t\t\t\tPLUGINDEX plug = param.first.first - 1;\n\t\t\t\tIMixPlugin *plugin = m_MixPlugins[plug].pMixPlugin;\n\t\t\t\tif(plugin != nullptr)\n\t\t\t\t{\n\t\t\t\t\tif(!plugSetProgram[plug])\n\t\t\t\t\t{\n\t\t\t\t\t\t// Used for bridged plugins to avoid sending out individual messages for each parameter.\n\t\t\t\t\t\tplugSetProgram.set(plug);\n\t\t\t\t\t\tplugin->BeginSetProgram();\n\t\t\t\t\t}\n\t\t\t\t\tplugin->SetParameter(param.first.second, param.second / PlugParamValue(ModCommand::maxColumnValue));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(plugSetProgram.any())\n\t\t\t{\n\t\t\t\tfor(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++)\n\t\t\t\t{\n\t\t\t\t\tif(plugSetProgram[i])\n\t\t\t\t\t{\n\t\t\t\t\t\tm_MixPlugins[i].pMixPlugin->EndSetProgram();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n#endif // NO_PLUGINS\n\t\t} else if(adjustMode != eAdjustOnSuccess)\n\t\t{\n\t\t\t// Target not found (e.g. when jumping to a hidden sub song), reset global variables...\n\t\t\tm_PlayState.m_nMusicSpeed = m_nDefaultSpeed;\n\t\t\tm_PlayState.m_nMusicTempo = m_nDefaultTempo;\n\t\t\tm_PlayState.m_nGlobalVolume = m_nDefaultGlobalVolume;\n\t\t}\n\t\t// When adjusting the playback status, we will also want to update the visited rows vector according to the current position.\n\t\tif(sequence != Order.GetCurrentSequenceIndex())\n\t\t{\n\t\t\tOrder.SetSequence(sequence);\n\t\t}\n\t\tvisitedSongRows.Set(visitedRows);\n\t}",
"\treturn results;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 32025,
"char_start": 31999,
"chars": "pChn = playState.Chn;\n\t\t\t\t"
},
{
"char_end": 32086,
"char_start": 32078,
"chars": "Chn++, p"
}
],
"deleted": []
},
"commit_link": "github.com/OpenMPT/openmpt/commit/492022c7297ede682161d9c0ec2de15526424e76",
"file_name": "soundlib/Snd_fx.cpp",
"func_name": "CSoundFile::GetLength",
"line_changes": {
"added": [
{
"char_end": 32021,
"char_start": 31995,
"line": "\t\t\t\tpChn = playState.Chn;\n",
"line_no": 978
},
{
"char_end": 32093,
"char_start": 32021,
"line": "\t\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)\n",
"line_no": 979
}
],
"deleted": [
{
"char_end": 32059,
"char_start": 31995,
"line": "\t\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++)\n",
"line_no": 978
}
]
},
"vul_type": "cwe-125"
} | 391 | cwe-125 | cpp |
Determine whether the {function_name} code is vulnerable or not. | [
"std::vector<GetLengthType> CSoundFile::GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target)\n{\n\tstd::vector<GetLengthType> results;\n\tGetLengthType retval;\n\tretval.startOrder = target.startOrder;\n\tretval.startRow = target.startRow;",
"\t// Are we trying to reach a certain pattern position?\n\tconst bool hasSearchTarget = target.mode != GetLengthTarget::NoTarget;\n\tconst bool adjustSamplePos = (adjustMode & eAdjustSamplePositions) == eAdjustSamplePositions;",
"\tSEQUENCEINDEX sequence = target.sequence;\n\tif(sequence >= Order.GetNumSequences()) sequence = Order.GetCurrentSequenceIndex();\n\tconst ModSequence &orderList = Order(sequence);",
"\tGetLengthMemory memory(*this);\n\tCSoundFile::PlayState &playState = *memory.state;\n\t// Temporary visited rows vector (so that GetLength() won't interfere with the player code if the module is playing at the same time)\n\tRowVisitor visitedRows(*this, sequence);",
"\tplayState.m_nNextRow = playState.m_nRow = target.startRow;\n\tplayState.m_nNextOrder = playState.m_nCurrentOrder = target.startOrder;",
"\t// Fast LUTs for commands that are too weird / complicated / whatever to emulate in sample position adjust mode.\n\tstd::bitset<MAX_EFFECTS> forbiddenCommands;\n\tstd::bitset<MAX_VOLCMDS> forbiddenVolCommands;",
"\tif(adjustSamplePos)\n\t{\n\t\tforbiddenCommands.set(CMD_ARPEGGIO); forbiddenCommands.set(CMD_PORTAMENTOUP);\n\t\tforbiddenCommands.set(CMD_PORTAMENTODOWN); forbiddenCommands.set(CMD_XFINEPORTAUPDOWN);\n\t\tforbiddenCommands.set(CMD_NOTESLIDEUP); forbiddenCommands.set(CMD_NOTESLIDEUPRETRIG);\n\t\tforbiddenCommands.set(CMD_NOTESLIDEDOWN); forbiddenCommands.set(CMD_NOTESLIDEDOWNRETRIG);\n\t\tforbiddenVolCommands.set(VOLCMD_PORTAUP); forbiddenVolCommands.set(VOLCMD_PORTADOWN);",
"\t\t// Optimize away channels for which it's pointless to adjust sample positions\n\t\tfor(CHANNELINDEX i = 0; i < GetNumChannels(); i++)\n\t\t{\n\t\t\tif(ChnSettings[i].dwFlags[CHN_MUTE]) memory.chnSettings[i].ticksToRender = GetLengthMemory::IGNORE_CHANNEL;\n\t\t}\n\t\tif(target.mode == GetLengthTarget::SeekPosition && target.pos.order < orderList.size())\n\t\t{\n\t\t\t// If we know where to seek, we can directly rule out any channels on which a new note would be triggered right at the start.\n\t\t\tconst PATTERNINDEX seekPat = orderList[target.pos.order];\n\t\t\tif(Patterns.IsValidPat(seekPat) && Patterns[seekPat].IsValidRow(target.pos.row))\n\t\t\t{\n\t\t\t\tconst ModCommand *m = Patterns[seekPat].GetRow(target.pos.row);\n\t\t\t\tfor(CHANNELINDEX i = 0; i < GetNumChannels(); i++, m++)\n\t\t\t\t{\n\t\t\t\t\tif(m->note == NOTE_NOTECUT || m->note == NOTE_KEYOFF || (m->note == NOTE_FADE && GetNumInstruments())\n\t\t\t\t\t\t|| (m->IsNote() && !m->IsPortamento()))\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.chnSettings[i].ticksToRender = GetLengthMemory::IGNORE_CHANNEL;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"\t// If samples are being synced, force them to resync if tick duration changes\n\tuint32 oldTickDuration = 0;",
"\tfor (;;)\n\t{\n\t\t// Time target reached.\n\t\tif(target.mode == GetLengthTarget::SeekSeconds && memory.elapsedTime >= target.time)\n\t\t{\n\t\t\tretval.targetReached = true;\n\t\t\tbreak;\n\t\t}",
"\t\tuint32 rowDelay = 0, tickDelay = 0;\n\t\tplayState.m_nRow = playState.m_nNextRow;\n\t\tplayState.m_nCurrentOrder = playState.m_nNextOrder;",
"\t\tif(orderList.IsValidPat(playState.m_nCurrentOrder) && playState.m_nRow >= Patterns[orderList[playState.m_nCurrentOrder]].GetNumRows())\n\t\t{\n\t\t\tplayState.m_nRow = 0;\n\t\t\tif(m_playBehaviour[kFT2LoopE60Restart])\n\t\t\t{\n\t\t\t\tplayState.m_nRow = playState.m_nNextPatStartRow;\n\t\t\t\tplayState.m_nNextPatStartRow = 0;\n\t\t\t}\n\t\t\tplayState.m_nCurrentOrder = ++playState.m_nNextOrder;\n\t\t}",
"\t\t// Check if pattern is valid\n\t\tplayState.m_nPattern = playState.m_nCurrentOrder < orderList.size() ? orderList[playState.m_nCurrentOrder] : orderList.GetInvalidPatIndex();\n\t\tbool positionJumpOnThisRow = false;\n\t\tbool patternBreakOnThisRow = false;\n\t\tbool patternLoopEndedOnThisRow = false, patternLoopStartedOnThisRow = false;",
"\t\tif(!Patterns.IsValidPat(playState.m_nPattern) && playState.m_nPattern != orderList.GetInvalidPatIndex() && target.mode == GetLengthTarget::SeekPosition && playState.m_nCurrentOrder == target.pos.order)\n\t\t{\n\t\t\t// Early test: Target is inside +++ or non-existing pattern\n\t\t\tretval.targetReached = true;\n\t\t\tbreak;\n\t\t}",
"\t\twhile(playState.m_nPattern >= Patterns.Size())\n\t\t{\n\t\t\t// End of song?\n\t\t\tif((playState.m_nPattern == orderList.GetInvalidPatIndex()) || (playState.m_nCurrentOrder >= orderList.size()))\n\t\t\t{\n\t\t\t\tif(playState.m_nCurrentOrder == orderList.GetRestartPos())\n\t\t\t\t\tbreak;\n\t\t\t\telse\n\t\t\t\t\tplayState.m_nCurrentOrder = orderList.GetRestartPos();\n\t\t\t} else\n\t\t\t{\n\t\t\t\tplayState.m_nCurrentOrder++;\n\t\t\t}\n\t\t\tplayState.m_nPattern = (playState.m_nCurrentOrder < orderList.size()) ? orderList[playState.m_nCurrentOrder] : orderList.GetInvalidPatIndex();\n\t\t\tplayState.m_nNextOrder = playState.m_nCurrentOrder;\n\t\t\tif((!Patterns.IsValidPat(playState.m_nPattern)) && visitedRows.IsVisited(playState.m_nCurrentOrder, 0, true))\n\t\t\t{\n\t\t\t\tif(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(playState.m_nNextOrder, playState.m_nRow, true))\n\t\t\t\t{\n\t\t\t\t\t// We aren't searching for a specific row, or we couldn't find any more unvisited rows.\n\t\t\t\t\tbreak;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\t// We haven't found the target row yet, but we found some other unplayed row... continue searching from here.\n\t\t\t\t\tretval.duration = memory.elapsedTime;\n\t\t\t\t\tresults.push_back(retval);\n\t\t\t\t\tretval.startRow = playState.m_nRow;\n\t\t\t\t\tretval.startOrder = playState.m_nNextOrder;\n\t\t\t\t\tmemory.Reset();",
"\t\t\t\t\tplayState.m_nCurrentOrder = playState.m_nNextOrder;\n\t\t\t\t\tplayState.m_nPattern = orderList[playState.m_nCurrentOrder];\n\t\t\t\t\tplayState.m_nNextRow = playState.m_nRow;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(playState.m_nNextOrder == ORDERINDEX_INVALID)\n\t\t{\n\t\t\t// GetFirstUnvisitedRow failed, so there is nothing more to play\n\t\t\tbreak;\n\t\t}",
"\t\t// Skip non-existing patterns\n\t\tif(!Patterns.IsValidPat(playState.m_nPattern))\n\t\t{\n\t\t\t// If there isn't even a tune, we should probably stop here.\n\t\t\tif(playState.m_nCurrentOrder == orderList.GetRestartPos())\n\t\t\t{\n\t\t\t\tif(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(playState.m_nNextOrder, playState.m_nRow, true))\n\t\t\t\t{\n\t\t\t\t\t// We aren't searching for a specific row, or we couldn't find any more unvisited rows.\n\t\t\t\t\tbreak;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\t// We haven't found the target row yet, but we found some other unplayed row... continue searching from here.\n\t\t\t\t\tretval.duration = memory.elapsedTime;\n\t\t\t\t\tresults.push_back(retval);\n\t\t\t\t\tretval.startRow = playState.m_nRow;\n\t\t\t\t\tretval.startOrder = playState.m_nNextOrder;\n\t\t\t\t\tmemory.Reset();\n\t\t\t\t\tplayState.m_nNextRow = playState.m_nRow;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tplayState.m_nNextOrder = playState.m_nCurrentOrder + 1;\n\t\t\tcontinue;\n\t\t}\n\t\t// Should never happen\n\t\tif(playState.m_nRow >= Patterns[playState.m_nPattern].GetNumRows())\n\t\t\tplayState.m_nRow = 0;",
"\t\t// Check whether target was reached.\n\t\tif(target.mode == GetLengthTarget::SeekPosition && playState.m_nCurrentOrder == target.pos.order && playState.m_nRow == target.pos.row)\n\t\t{\n\t\t\tretval.targetReached = true;\n\t\t\tbreak;\n\t\t}",
"\t\tif(visitedRows.IsVisited(playState.m_nCurrentOrder, playState.m_nRow, true))\n\t\t{\n\t\t\tif(!hasSearchTarget || !visitedRows.GetFirstUnvisitedRow(playState.m_nNextOrder, playState.m_nRow, true))\n\t\t\t{\n\t\t\t\t// We aren't searching for a specific row, or we couldn't find any more unvisited rows.\n\t\t\t\tbreak;\n\t\t\t} else\n\t\t\t{\n\t\t\t\t// We haven't found the target row yet, but we found some other unplayed row... continue searching from here.\n\t\t\t\tretval.duration = memory.elapsedTime;\n\t\t\t\tresults.push_back(retval);\n\t\t\t\tretval.startRow = playState.m_nRow;\n\t\t\t\tretval.startOrder = playState.m_nNextOrder;\n\t\t\t\tmemory.Reset();\n\t\t\t\tplayState.m_nNextRow = playState.m_nRow;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}",
"\t\tretval.endOrder = playState.m_nCurrentOrder;\n\t\tretval.endRow = playState.m_nRow;",
"\t\t// Update next position\n\t\tplayState.m_nNextRow = playState.m_nRow + 1;",
"\t\t// Jumped to invalid pattern row?\n\t\tif(playState.m_nRow >= Patterns[playState.m_nPattern].GetNumRows())\n\t\t{\n\t\t\tplayState.m_nRow = 0;\n\t\t}\n\t\t// New pattern?\n\t\tif(!playState.m_nRow)\n\t\t{\n\t\t\tfor(CHANNELINDEX chn = 0; chn < GetNumChannels(); chn++)\n\t\t\t{\n\t\t\t\tmemory.chnSettings[chn].patLoop = memory.elapsedTime;\n\t\t\t\tmemory.chnSettings[chn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t}\n\t\t}",
"\t\tModChannel *pChn = playState.Chn;\n\t\t\n\t\t// For various effects, we need to know first how many ticks there are in this row.\n\t\tconst ModCommand *p = Patterns[playState.m_nPattern].GetpModCommand(playState.m_nRow, 0);\n\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, p++)\n\t\t{\n\t\t\tif(m_playBehaviour[kST3NoMutedChannels] && ChnSettings[nChn].dwFlags[CHN_MUTE])\t// not even effects are processed on muted S3M channels\n\t\t\t\tcontinue;\n\t\t\tif(p->IsPcNote())\n\t\t\t{\n#ifndef NO_PLUGINS\n\t\t\t\tif((adjustMode & eAdjust) && p->instr > 0 && p->instr <= MAX_MIXPLUGINS)\n\t\t\t\t{\n\t\t\t\t\tmemory.plugParams[std::make_pair(p->instr, p->GetValueVolCol())] = p->GetValueEffectCol();\n\t\t\t\t}\n#endif // NO_PLUGINS\n\t\t\t\tpChn[nChn].rowCommand.Clear();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tpChn[nChn].rowCommand = *p;\n\t\t\tswitch(p->command)\n\t\t\t{\n\t\t\tcase CMD_SPEED:\n\t\t\t\tSetSpeed(playState, p->param);\n\t\t\t\tbreak;",
"\t\t\tcase CMD_TEMPO:\n\t\t\t\tif(m_playBehaviour[kMODVBlankTiming])\n\t\t\t\t{\n\t\t\t\t\t// ProTracker MODs with VBlank timing: All Fxx parameters set the tick count.\n\t\t\t\t\tif(p->param != 0) SetSpeed(playState, p->param);\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\tif((p->param & 0xF0) == 0x60)\n\t\t\t\t{\n\t\t\t\t\t// Fine Pattern Delay\n\t\t\t\t\ttickDelay += (p->param & 0x0F);\n\t\t\t\t} else if((p->param & 0xF0) == 0xE0 && !rowDelay)\n\t\t\t\t{\n\t\t\t\t\t// Pattern Delay\n\t\t\t\t\tif(!(GetType() & MOD_TYPE_S3M) || (p->param & 0x0F) != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t// While Impulse Tracker *does* count S60 as a valid row delay (and thus ignores any other row delay commands on the right),\n\t\t\t\t\t\t// Scream Tracker 3 simply ignores such commands.\n\t\t\t\t\t\trowDelay = 1 + (p->param & 0x0F);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_MODCMDEX:\n\t\t\t\tif((p->param & 0xF0) == 0xE0)\n\t\t\t\t{\n\t\t\t\t\t// Pattern Delay\n\t\t\t\t\trowDelay = 1 + (p->param & 0x0F);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(rowDelay == 0) rowDelay = 1;\n\t\tconst uint32 numTicks = (playState.m_nMusicSpeed + tickDelay) * rowDelay;\n\t\tconst uint32 nonRowTicks = numTicks - rowDelay;",
"\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); pChn++, nChn++) if(!pChn->rowCommand.IsEmpty())\n\t\t{\n\t\t\tif(m_playBehaviour[kST3NoMutedChannels] && ChnSettings[nChn].dwFlags[CHN_MUTE])\t// not even effects are processed on muted S3M channels\n\t\t\t\tcontinue;\n\t\t\tModCommand::COMMAND command = pChn->rowCommand.command;\n\t\t\tModCommand::PARAM param = pChn->rowCommand.param;\n\t\t\tModCommand::NOTE note = pChn->rowCommand.note;",
"\t\t\tif (pChn->rowCommand.instr)\n\t\t\t{\n\t\t\t\tpChn->nNewIns = pChn->rowCommand.instr;\n\t\t\t\tpChn->nLastNote = NOTE_NONE;\n\t\t\t\tmemory.chnSettings[nChn].vol = 0xFF;\n\t\t\t}\n\t\t\tif (pChn->rowCommand.IsNote()) pChn->nLastNote = note;",
"\t\t\t// Update channel panning\n\t\t\tif(pChn->rowCommand.IsNote() || pChn->rowCommand.instr)\n\t\t\t{\n\t\t\t\tSAMPLEINDEX smp = 0;\n\t\t\t\tif(GetNumInstruments())\n\t\t\t\t{\n\t\t\t\t\tModInstrument *pIns;\n\t\t\t\t\tif(pChn->nNewIns <= GetNumInstruments() && (pIns = Instruments[pChn->nNewIns]) != nullptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(pIns->dwFlags[INS_SETPANNING])\n\t\t\t\t\t\t\tpChn->nPan = pIns->nPan;\n\t\t\t\t\t\tif(ModCommand::IsNote(note))\n\t\t\t\t\t\t\tsmp = pIns->Keyboard[note - NOTE_MIN];\n\t\t\t\t\t}\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tsmp = pChn->nNewIns;\n\t\t\t\t}\n\t\t\t\tif(smp > 0 && smp <= GetNumSamples() && Samples[smp].uFlags[CHN_PANNING])\n\t\t\t\t{\n\t\t\t\t\tpChn->nPan = Samples[smp].nPan;\n\t\t\t\t}\n\t\t\t}",
"\t\t\tswitch(pChn->rowCommand.volcmd)\n\t\t\t{\n\t\t\tcase VOLCMD_VOLUME:\n\t\t\t\tmemory.chnSettings[nChn].vol = pChn->rowCommand.vol;\n\t\t\t\tbreak;\n\t\t\tcase VOLCMD_VOLSLIDEUP:\n\t\t\tcase VOLCMD_VOLSLIDEDOWN:\n\t\t\t\tif(pChn->rowCommand.vol != 0)\n\t\t\t\t\tpChn->nOldVolParam = pChn->rowCommand.vol;\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tswitch(command)\n\t\t\t{\n\t\t\t// Position Jump\n\t\t\tcase CMD_POSITIONJUMP:\n\t\t\t\tpositionJumpOnThisRow = true;\n\t\t\t\tplayState.m_nNextOrder = static_cast<ORDERINDEX>(CalculateXParam(playState.m_nPattern, playState.m_nRow, nChn));\n\t\t\t\tplayState.m_nNextPatStartRow = 0; // FT2 E60 bug\n\t\t\t\t// see https://forum.openmpt.org/index.php?topic=2769.0 - FastTracker resets Dxx if Bxx is called _after_ Dxx\n\t\t\t\t// Test case: PatternJump.mod\n\t\t\t\tif(!patternBreakOnThisRow || (GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)))\n\t\t\t\t\tplayState.m_nNextRow = 0;",
"\t\t\t\tif (adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\tpChn->nPatternLoopCount = 0;\n\t\t\t\t\tpChn->nPatternLoop = 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// Pattern Break\n\t\t\tcase CMD_PATTERNBREAK:\n\t\t\t\t{\n\t\t\t\t\tROWINDEX row = PatternBreak(playState, nChn, param);\n\t\t\t\t\tif(row != ROWINDEX_INVALID)\n\t\t\t\t\t{\n\t\t\t\t\t\tpatternBreakOnThisRow = true;\n\t\t\t\t\t\tplayState.m_nNextRow = row;",
"\t\t\t\t\t\tif(!positionJumpOnThisRow)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tplayState.m_nNextOrder = playState.m_nCurrentOrder + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpChn->nPatternLoopCount = 0;\n\t\t\t\t\t\t\tpChn->nPatternLoop = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// Set Tempo\n\t\t\tcase CMD_TEMPO:\n\t\t\t\tif(!m_playBehaviour[kMODVBlankTiming])\n\t\t\t\t{\n\t\t\t\t\tTEMPO tempo(CalculateXParam(playState.m_nPattern, playState.m_nRow, nChn), 0);\n\t\t\t\t\tif ((adjustMode & eAdjust) && (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (tempo.GetInt()) pChn->nOldTempo = static_cast<uint8>(tempo.GetInt()); else tempo.Set(pChn->nOldTempo);\n\t\t\t\t\t}",
"\t\t\t\t\tif (tempo.GetInt() >= 0x20) playState.m_nMusicTempo = tempo;\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// Tempo Slide\n\t\t\t\t\t\tTEMPO tempoDiff((tempo.GetInt() & 0x0F) * nonRowTicks, 0);\n\t\t\t\t\t\tif ((tempo.GetInt() & 0xF0) == 0x10)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tplayState.m_nMusicTempo += tempoDiff;\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(tempoDiff < playState.m_nMusicTempo)\n\t\t\t\t\t\t\t\tplayState.m_nMusicTempo -= tempoDiff;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tplayState.m_nMusicTempo.Set(0);\n\t\t\t\t\t\t}\n\t\t\t\t\t}",
"\t\t\t\t\tTEMPO tempoMin = GetModSpecifications().GetTempoMin(), tempoMax = GetModSpecifications().GetTempoMax();\n\t\t\t\t\tif(m_playBehaviour[kTempoClamp])\t// clamp tempo correctly in compatible mode\n\t\t\t\t\t{\n\t\t\t\t\t\ttempoMax.Set(255);\n\t\t\t\t\t}\n\t\t\t\t\tLimit(playState.m_nMusicTempo, tempoMin, tempoMax);\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\tswitch(param & 0xF0)\n\t\t\t\t{\n\t\t\t\tcase 0x90:\n\t\t\t\t\tif(param <= 0x91)\n\t\t\t\t\t{\n\t\t\t\t\t\tpChn->dwFlags.set(CHN_SURROUND, param == 0x91);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;",
"\t\t\t\tcase 0xA0:\n\t\t\t\t\t// High sample offset\n\t\t\t\t\tpChn->nOldHiOffset = param & 0x0F;\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcase 0xB0:\n\t\t\t\t\t// Pattern Loop\n\t\t\t\t\tif (param & 0x0F)\n\t\t\t\t\t{\n\t\t\t\t\t\tpatternLoopEndedOnThisRow = true;\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tCHANNELINDEX firstChn = nChn, lastChn = nChn;\n\t\t\t\t\t\tif(GetType() == MOD_TYPE_S3M)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// ST3 has only one global loop memory.\n\t\t\t\t\t\t\tfirstChn = 0;\n\t\t\t\t\t\t\tlastChn = GetNumChannels() - 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor(CHANNELINDEX c = firstChn; c <= lastChn; c++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemory.chnSettings[c].patLoop = memory.elapsedTime;\n\t\t\t\t\t\t\tmemory.chnSettings[c].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t\t\tmemory.chnSettings[c].patLoopStart = playState.m_nRow;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpatternLoopStartedOnThisRow = true;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;",
"\t\t\t\tcase 0xF0:\n\t\t\t\t\t// Active macro\n\t\t\t\t\tpChn->nActiveMacro = param & 0x0F;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_MODCMDEX:\n\t\t\t\tswitch(param & 0xF0)\n\t\t\t\t{\n\t\t\t\tcase 0x60:\n\t\t\t\t\t// Pattern Loop\n\t\t\t\t\tif (param & 0x0F)\n\t\t\t\t\t{\n\t\t\t\t\t\tplayState.m_nNextPatStartRow = memory.chnSettings[nChn].patLoopStart; // FT2 E60 bug\n\t\t\t\t\t\tpatternLoopEndedOnThisRow = true;\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tpatternLoopStartedOnThisRow = true;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoop = memory.elapsedTime;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopStart = playState.m_nRow;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;",
"\t\t\t\tcase 0xF0:\n\t\t\t\t\t// Active macro\n\t\t\t\t\tpChn->nActiveMacro = param & 0x0F;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_XFINEPORTAUPDOWN:\n\t\t\t\t// ignore high offset in compatible mode\n\t\t\t\tif(((param & 0xF0) == 0xA0) && !m_playBehaviour[kFT2RestrictXCommand]) pChn->nOldHiOffset = param & 0x0F;\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\t// The following calculations are not interesting if we just want to get the song length.\n\t\t\tif (!(adjustMode & eAdjust)) continue;\n\t\t\tswitch(command)\n\t\t\t{\n\t\t\t// Portamento Up/Down\n\t\t\tcase CMD_PORTAMENTOUP:\n\t\t\t\tif(param)\n\t\t\t\t{\n\t\t\t\t\t// FT2 compatibility: Separate effect memory for all portamento commands\n\t\t\t\t\t// Test case: Porta-LinkMem.xm\n\t\t\t\t\tif(!m_playBehaviour[kFT2PortaUpDownMemory])\n\t\t\t\t\t\tpChn->nOldPortaDown = param;\n\t\t\t\t\tpChn->nOldPortaUp = param;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CMD_PORTAMENTODOWN:\n\t\t\t\tif(param)\n\t\t\t\t{\n\t\t\t\t\t// FT2 compatibility: Separate effect memory for all portamento commands\n\t\t\t\t\t// Test case: Porta-LinkMem.xm\n\t\t\t\t\tif(!m_playBehaviour[kFT2PortaUpDownMemory])\n\t\t\t\t\t\tpChn->nOldPortaUp = param;\n\t\t\t\t\tpChn->nOldPortaDown = param;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// Tone-Portamento\n\t\t\tcase CMD_TONEPORTAMENTO:\n\t\t\t\tif (param) pChn->nPortamentoSlide = param << 2;\n\t\t\t\tbreak;\n\t\t\t// Offset\n\t\t\tcase CMD_OFFSET:\n\t\t\t\tif (param) pChn->oldOffset = param << 8;\n\t\t\t\tbreak;\n\t\t\t// Volume Slide\n\t\t\tcase CMD_VOLUMESLIDE:\n\t\t\tcase CMD_TONEPORTAVOL:\n\t\t\t\tif (param) pChn->nOldVolumeSlide = param;\n\t\t\t\tbreak;\n\t\t\t// Set Volume\n\t\t\tcase CMD_VOLUME:\n\t\t\t\tmemory.chnSettings[nChn].vol = param;\n\t\t\t\tbreak;\n\t\t\t// Global Volume\n\t\t\tcase CMD_GLOBALVOLUME:\n\t\t\t\tif(!(GetType() & GLOBALVOL_7BIT_FORMATS) && param < 128) param *= 2;\n\t\t\t\t// IT compatibility 16. ST3 and IT ignore out-of-range values\n\t\t\t\tif(param <= 128)\n\t\t\t\t{\n\t\t\t\t\tplayState.m_nGlobalVolume = param * 2;\n\t\t\t\t} else if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_S3M)))\n\t\t\t\t{\n\t\t\t\t\tplayState.m_nGlobalVolume = 256;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// Global Volume Slide\n\t\t\tcase CMD_GLOBALVOLSLIDE:\n\t\t\t\tif(m_playBehaviour[kPerChannelGlobalVolSlide])\n\t\t\t\t{\n\t\t\t\t\t// IT compatibility 16. Global volume slide params are stored per channel (FT2/IT)\n\t\t\t\t\tif (param) pChn->nOldGlobalVolSlide = param; else param = pChn->nOldGlobalVolSlide;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tif (param) playState.Chn[0].nOldGlobalVolSlide = param; else param = playState.Chn[0].nOldGlobalVolSlide;\n\t\t\t\t}\n\t\t\t\tif (((param & 0x0F) == 0x0F) && (param & 0xF0))\n\t\t\t\t{\n\t\t\t\t\tparam >>= 4;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume += param << 1;\n\t\t\t\t} else if (((param & 0xF0) == 0xF0) && (param & 0x0F))\n\t\t\t\t{\n\t\t\t\t\tparam = (param & 0x0F) << 1;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume -= param;\n\t\t\t\t} else if (param & 0xF0)\n\t\t\t\t{\n\t\t\t\t\tparam >>= 4;\n\t\t\t\t\tparam <<= 1;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume += param * nonRowTicks;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tparam = (param & 0x0F) << 1;\n\t\t\t\t\tif (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;\n\t\t\t\t\tplayState.m_nGlobalVolume -= param * nonRowTicks;\n\t\t\t\t}\n\t\t\t\tLimit(playState.m_nGlobalVolume, 0, 256);\n\t\t\t\tbreak;\n\t\t\tcase CMD_CHANNELVOLUME:\n\t\t\t\tif (param <= 64) pChn->nGlobalVol = param;\n\t\t\t\tbreak;\n\t\t\tcase CMD_CHANNELVOLSLIDE:\n\t\t\t\t{\n\t\t\t\t\tif (param) pChn->nOldChnVolSlide = param; else param = pChn->nOldChnVolSlide;\n\t\t\t\t\tint32 volume = pChn->nGlobalVol;\n\t\t\t\t\tif((param & 0x0F) == 0x0F && (param & 0xF0))\n\t\t\t\t\t\tvolume += (param >> 4);\t\t// Fine Up\n\t\t\t\t\telse if((param & 0xF0) == 0xF0 && (param & 0x0F))\n\t\t\t\t\t\tvolume -= (param & 0x0F);\t// Fine Down\n\t\t\t\t\telse if(param & 0x0F)\t\t\t// Down\n\t\t\t\t\t\tvolume -= (param & 0x0F) * nonRowTicks;\n\t\t\t\t\telse\t\t\t\t\t\t\t// Up\n\t\t\t\t\t\tvolume += ((param & 0xF0) >> 4) * nonRowTicks;\n\t\t\t\t\tLimit(volume, 0, 64);\n\t\t\t\t\tpChn->nGlobalVol = volume;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CMD_PANNING8:\n\t\t\t\tPanning(pChn, param, Pan8bit);\n\t\t\t\tbreak;\n\t\t\tcase CMD_MODCMDEX:\n\t\t\t\tif(param < 0x10)\n\t\t\t\t{\n\t\t\t\t\t// LED filter\n\t\t\t\t\tfor(CHANNELINDEX chn = 0; chn < GetNumChannels(); chn++)\n\t\t\t\t\t{\n\t\t\t\t\t\tplayState.Chn[chn].dwFlags.set(CHN_AMIGAFILTER, !(param & 1));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tMPT_FALLTHROUGH;\n\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\tif((param & 0xF0) == 0x80)\n\t\t\t\t{\n\t\t\t\t\tPanning(pChn, (param & 0x0F), Pan4bit);\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_VIBRATOVOL:\n\t\t\t\tif (param) pChn->nOldVolumeSlide = param;\n\t\t\t\tparam = 0;\n\t\t\t\tMPT_FALLTHROUGH;\n\t\t\tcase CMD_VIBRATO:\n\t\t\t\tVibrato(pChn, param);\n\t\t\t\tbreak;\n\t\t\tcase CMD_FINEVIBRATO:\n\t\t\t\tFineVibrato(pChn, param);\n\t\t\t\tbreak;\n\t\t\tcase CMD_TREMOLO:\n\t\t\t\tTremolo(pChn, param);\n\t\t\t\tbreak;\n\t\t\tcase CMD_PANBRELLO:\n\t\t\t\tPanbrello(pChn, param);\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\tswitch(pChn->rowCommand.volcmd)\n\t\t\t{\n\t\t\tcase VOLCMD_PANNING:\n\t\t\t\tPanning(pChn, pChn->rowCommand.vol, Pan6bit);\n\t\t\t\tbreak;",
"\t\t\tcase VOLCMD_VIBRATOSPEED:\n\t\t\t\t// FT2 does not automatically enable vibrato with the \"set vibrato speed\" command\n\t\t\t\tif(m_playBehaviour[kFT2VolColVibrato])\n\t\t\t\t\tpChn->nVibratoSpeed = pChn->rowCommand.vol & 0x0F;\n\t\t\t\telse\n\t\t\t\t\tVibrato(pChn, pChn->rowCommand.vol << 4);\n\t\t\t\tbreak;\n\t\t\tcase VOLCMD_VIBRATODEPTH:\n\t\t\t\tVibrato(pChn, pChn->rowCommand.vol);\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t\t// Process vibrato / tremolo / panbrello\n\t\t\tswitch(pChn->rowCommand.command)\n\t\t\t{\n\t\t\tcase CMD_VIBRATO:\n\t\t\tcase CMD_FINEVIBRATO:\n\t\t\tcase CMD_VIBRATOVOL:\n\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\tuint32 vibTicks = ((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && !m_SongFlags[SONG_ITOLDEFFECTS]) ? numTicks : nonRowTicks;\n\t\t\t\t\tuint32 inc = pChn->nVibratoSpeed * vibTicks;\n\t\t\t\t\tif(m_playBehaviour[kITVibratoTremoloPanbrello])\n\t\t\t\t\t\tinc *= 4;\n\t\t\t\t\tpChn->nVibratoPos += static_cast<uint8>(inc);\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_TREMOLO:\n\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\tuint32 tremTicks = ((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && !m_SongFlags[SONG_ITOLDEFFECTS]) ? numTicks : nonRowTicks;\n\t\t\t\t\tuint32 inc = pChn->nTremoloSpeed * tremTicks;\n\t\t\t\t\tif(m_playBehaviour[kITVibratoTremoloPanbrello])\n\t\t\t\t\t\tinc *= 4;\n\t\t\t\t\tpChn->nTremoloPos += static_cast<uint8>(inc);\n\t\t\t\t}\n\t\t\t\tbreak;",
"\t\t\tcase CMD_PANBRELLO:\n\t\t\t\tif(adjustMode & eAdjust)\n\t\t\t\t{\n\t\t\t\t\t// Panbrello effect is permanent in compatible mode, so actually apply panbrello for the last tick of this row\n\t\t\t\t\tpChn->nPanbrelloPos += static_cast<uint8>(pChn->nPanbrelloSpeed * (numTicks - 1));\n\t\t\t\t\tProcessPanbrello(pChn);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\t// Interpret F00 effect in XM files as \"stop song\"\n\t\tif(GetType() == MOD_TYPE_XM && playState.m_nMusicSpeed == uint16_max)\n\t\t{\n\t\t\tbreak;\n\t\t}",
"\t\tplayState.m_nCurrentRowsPerBeat = m_nDefaultRowsPerBeat;\n\t\tif(Patterns[playState.m_nPattern].GetOverrideSignature())\n\t\t{\n\t\t\tplayState.m_nCurrentRowsPerBeat = Patterns[playState.m_nPattern].GetRowsPerBeat();\n\t\t}",
"\t\tconst uint32 tickDuration = GetTickDuration(playState);\n\t\tconst uint32 rowDuration = tickDuration * numTicks;\n\t\tmemory.elapsedTime += static_cast<double>(rowDuration) / static_cast<double>(m_MixerSettings.gdwMixingFreq);\n\t\tplayState.m_lTotalSampleCount += rowDuration;",
"\t\tif(adjustSamplePos)\n\t\t{\n\t\t\t// Super experimental and dirty sample seeking\n\t\t\tpChn = playState.Chn;\n\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); pChn++, nChn++)\n\t\t\t{\n\t\t\t\tif(memory.chnSettings[nChn].ticksToRender == GetLengthMemory::IGNORE_CHANNEL)\n\t\t\t\t\tcontinue;",
"\t\t\t\tuint32 startTick = 0;\n\t\t\t\tconst ModCommand &m = pChn->rowCommand;\n\t\t\t\tuint32 paramHi = m.param >> 4, paramLo = m.param & 0x0F;\n\t\t\t\tbool porta = m.command == CMD_TONEPORTAMENTO || m.command == CMD_TONEPORTAVOL || m.volcmd == VOLCMD_TONEPORTAMENTO;\n\t\t\t\tbool stopNote = patternLoopStartedOnThisRow;\t// It's too much trouble to keep those pattern loops in sync...",
"\t\t\t\tif(m.instr) pChn->proTrackerOffset = 0;\n\t\t\t\tif(m.IsNote())\n\t\t\t\t{\n\t\t\t\t\tif(porta && memory.chnSettings[nChn].incChanged)\n\t\t\t\t\t{\n\t\t\t\t\t\t// If there's a portamento, the current channel increment mustn't be 0 in NoteChange()\n\t\t\t\t\t\tpChn->increment = GetChannelIncrement(pChn, pChn->nPeriod, 0);\n\t\t\t\t\t}\n\t\t\t\t\tint32 setPan = pChn->nPan;\n\t\t\t\t\tpChn->nNewNote = pChn->nLastNote;\n\t\t\t\t\tif(pChn->nNewIns != 0) InstrumentChange(pChn, pChn->nNewIns, porta);\n\t\t\t\t\tNoteChange(pChn, m.note, porta);\n\t\t\t\t\tmemory.chnSettings[nChn].incChanged = true;",
"\t\t\t\t\tif((m.command == CMD_MODCMDEX || m.command == CMD_S3MCMDEX) && (m.param & 0xF0) == 0xD0 && paramLo < numTicks)\n\t\t\t\t\t{\n\t\t\t\t\t\tstartTick = paramLo;\n\t\t\t\t\t} else if(m.command == CMD_DELAYCUT && paramHi < numTicks)\n\t\t\t\t\t{\n\t\t\t\t\t\tstartTick = paramHi;\n\t\t\t\t\t}\n\t\t\t\t\tif(rowDelay > 1 && startTick != 0 && (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)))\n\t\t\t\t\t{\n\t\t\t\t\t\tstartTick += (playState.m_nMusicSpeed + tickDelay) * (rowDelay - 1);\n\t\t\t\t\t}\n\t\t\t\t\tif(!porta) memory.chnSettings[nChn].ticksToRender = 0;",
"\t\t\t\t\t// Panning commands have to be re-applied after a note change with potential pan change.\n\t\t\t\t\tif(m.command == CMD_PANNING8\n\t\t\t\t\t\t|| ((m.command == CMD_MODCMDEX || m.command == CMD_S3MCMDEX) && paramHi == 0x8)\n\t\t\t\t\t\t|| m.volcmd == VOLCMD_PANNING)\n\t\t\t\t\t{\n\t\t\t\t\t\tpChn->nPan = setPan;\n\t\t\t\t\t}",
"\t\t\t\t\tif(m.command == CMD_OFFSET)\n\t\t\t\t\t{\n\t\t\t\t\t\tbool isExtended = false;\n\t\t\t\t\t\tSmpLength offset = CalculateXParam(playState.m_nPattern, playState.m_nRow, nChn, &isExtended);\n\t\t\t\t\t\tif(!isExtended)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toffset <<= 8;\n\t\t\t\t\t\t\tif(offset == 0) offset = pChn->oldOffset;\n\t\t\t\t\t\t\toffset += static_cast<SmpLength>(pChn->nOldHiOffset) << 16;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tSampleOffset(*pChn, offset);\n\t\t\t\t\t} else if(m.command == CMD_OFFSETPERCENTAGE)\n\t\t\t\t\t{\n\t\t\t\t\t\tSampleOffset(*pChn, Util::muldiv_unsigned(pChn->nLength, m.param, 255));\n\t\t\t\t\t} else if(m.command == CMD_REVERSEOFFSET && pChn->pModSample != nullptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t// Re-sync what we've got so far\n\t\t\t\t\t\tReverseSampleOffset(*pChn, m.param);\n\t\t\t\t\t\tstartTick = playState.m_nMusicSpeed - 1;\n\t\t\t\t\t} else if(m.volcmd == VOLCMD_OFFSET)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(m.vol <= CountOf(pChn->pModSample->cues) && pChn->pModSample != nullptr)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSmpLength offset;\n\t\t\t\t\t\t\tif(m.vol == 0)\n\t\t\t\t\t\t\t\toffset = pChn->oldOffset;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\toffset = pChn->oldOffset = pChn->pModSample->cues[m.vol - 1];\n\t\t\t\t\t\t\tSampleOffset(*pChn, offset);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}",
"\t\t\t\tif(m.note == NOTE_KEYOFF || m.note == NOTE_NOTECUT || (m.note == NOTE_FADE && GetNumInstruments())\n\t\t\t\t\t|| ((m.command == CMD_MODCMDEX || m.command == CMD_S3MCMDEX) && (m.param & 0xF0) == 0xC0 && paramLo < numTicks)\n\t\t\t\t\t|| (m.command == CMD_DELAYCUT && paramLo != 0 && startTick + paramLo < numTicks))\n\t\t\t\t{\n\t\t\t\t\tstopNote = true;\n\t\t\t\t}",
"\t\t\t\tif(m.command == CMD_VOLUME)\n\t\t\t\t{\n\t\t\t\t\tpChn->nVolume = m.param * 4;\n\t\t\t\t} else if(m.volcmd == VOLCMD_VOLUME)\n\t\t\t\t{\n\t\t\t\t\tpChn->nVolume = m.vol * 4;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(pChn->pModSample && !stopNote)\n\t\t\t\t{\n\t\t\t\t\t// Check if we don't want to emulate some effect and thus stop processing.\n\t\t\t\t\tif(m.command < MAX_EFFECTS)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(forbiddenCommands[m.command])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstopNote = true;\n\t\t\t\t\t\t} else if(m.command == CMD_MODCMDEX)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Special case: Slides using extended commands\n\t\t\t\t\t\t\tswitch(m.param & 0xF0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase 0x10:\n\t\t\t\t\t\t\tcase 0x20:\n\t\t\t\t\t\t\t\tstopNote = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}",
"\t\t\t\t\tif(m.volcmd < forbiddenVolCommands.size() && forbiddenVolCommands[m.volcmd])\n\t\t\t\t\t{\n\t\t\t\t\t\tstopNote = true;\n\t\t\t\t\t}\n\t\t\t\t}",
"\t\t\t\tif(stopNote)\n\t\t\t\t{\n\t\t\t\t\tpChn->Stop();\n\t\t\t\t\tmemory.chnSettings[nChn].ticksToRender = 0;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tif(oldTickDuration != tickDuration && oldTickDuration != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t// Re-sync what we've got so far\n\t\t\t\t\t}",
"\t\t\t\t\tswitch(m.command)\n\t\t\t\t\t{\n\t\t\t\t\tcase CMD_TONEPORTAVOL:\n\t\t\t\t\tcase CMD_VOLUMESLIDE:\n\t\t\t\t\tcase CMD_VIBRATOVOL:\n\t\t\t\t\t\tif(m.param || (GetType() != MOD_TYPE_MOD))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor(uint32 i = 0; i < numTicks; i++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tpChn->isFirstTick = (i == 0);\n\t\t\t\t\t\t\t\tVolumeSlide(pChn, m.param);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;",
"\t\t\t\t\tcase CMD_MODCMDEX:\n\t\t\t\t\t\tif((m.param & 0x0F) || (GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpChn->isFirstTick = true;\n\t\t\t\t\t\t\tswitch(m.param & 0xF0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase 0xA0: FineVolumeUp(pChn, m.param & 0x0F, false); break;\n\t\t\t\t\t\t\tcase 0xB0: FineVolumeDown(pChn, m.param & 0x0F, false); break;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;",
"\t\t\t\t\tcase CMD_S3MCMDEX:\n\t\t\t\t\t\tif(m.param == 0x9E)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Play forward\n\t\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t// Re-sync what we've got so far\n\t\t\t\t\t\t\tpChn->dwFlags.reset(CHN_PINGPONGFLAG);\n\t\t\t\t\t\t} else if(m.param == 0x9F)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Reverse\n\t\t\t\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\t// Re-sync what we've got so far\n\t\t\t\t\t\t\tpChn->dwFlags.set(CHN_PINGPONGFLAG);\n\t\t\t\t\t\t\tif(!pChn->position.GetInt() && pChn->nLength && (m.IsNote() || !pChn->dwFlags[CHN_LOOP]))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tpChn->position.Set(pChn->nLength - 1, SamplePosition::fractMax);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if((m.param & 0xF0) == 0x70)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// TODO\n\t\t\t\t\t\t\t//ExtendedS3MCommands(nChn, param);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tpChn->isFirstTick = true;\n\t\t\t\t\tswitch(m.volcmd)\n\t\t\t\t\t{\n\t\t\t\t\tcase VOLCMD_FINEVOLUP:\t\tFineVolumeUp(pChn, m.vol, m_playBehaviour[kITVolColMemory]); break;\n\t\t\t\t\tcase VOLCMD_FINEVOLDOWN:\tFineVolumeDown(pChn, m.vol, m_playBehaviour[kITVolColMemory]); break;\n\t\t\t\t\tcase VOLCMD_VOLSLIDEUP:\n\t\t\t\t\tcase VOLCMD_VOLSLIDEDOWN:\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// IT Compatibility: Volume column volume slides have their own memory\n\t\t\t\t\t\t\t// Test case: VolColMemory.it\n\t\t\t\t\t\t\tModCommand::VOL vol = m.vol;\n\t\t\t\t\t\t\tif(vol == 0 && m_playBehaviour[kITVolColMemory])\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvol = pChn->nOldVolParam;\n\t\t\t\t\t\t\t\tif(vol == 0)\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(m.volcmd == VOLCMD_VOLSLIDEUP)\n\t\t\t\t\t\t\t\tvol <<= 4;\n\t\t\t\t\t\t\tfor(uint32 i = 0; i < numTicks; i++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tpChn->isFirstTick = (i == 0);\n\t\t\t\t\t\t\t\tVolumeSlide(pChn, vol);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}",
"\t\t\t\t\tif(porta)\n\t\t\t\t\t{\n\t\t\t\t\t\t// Portamento needs immediate syncing, as the pitch changes on each tick\n\t\t\t\t\t\tuint32 portaTick = memory.chnSettings[nChn].ticksToRender + startTick + 1;\n\t\t\t\t\t\tmemory.chnSettings[nChn].ticksToRender += numTicks;\n\t\t\t\t\t\tmemory.RenderChannel(nChn, tickDuration, portaTick);\n\t\t\t\t\t} else\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.chnSettings[nChn].ticksToRender += (numTicks - startTick);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\toldTickDuration = tickDuration;",
"\t\t// Pattern loop is not executed in FT2 if there are any position jump or pattern break commands on the same row.\n\t\t// Pattern loop is not executed in IT if there are any position jump commands on the same row.\n\t\t// Test case for FT2 exception: PatLoop-Jumps.xm, PatLoop-Various.xm\n\t\t// Test case for IT: exception: LoopBreak.it\n\t\tif(patternLoopEndedOnThisRow\n\t\t\t&& (!m_playBehaviour[kFT2PatternLoopWithJumps] || !(positionJumpOnThisRow || patternBreakOnThisRow))\n\t\t\t&& (!m_playBehaviour[kITPatternLoopWithJumps] || !positionJumpOnThisRow))\n\t\t{\n\t\t\tstd::map<double, int> startTimes;\n\t\t\t// This is really just a simple estimation for nested pattern loops. It should handle cases correctly where all parallel loops start and end on the same row.\n\t\t\t// If one of them starts or ends \"in between\", it will most likely calculate a wrong duration.\n\t\t\t// For S3M files, it's also way off.\n\t\t\tpChn = playState.Chn;\n\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)\n\t\t\t{\n\t\t\t\tModCommand::COMMAND command = pChn->rowCommand.command;\n\t\t\t\tModCommand::PARAM param = pChn->rowCommand.param;\n\t\t\t\tif((command == CMD_S3MCMDEX && param >= 0xB1 && param <= 0xBF)\n\t\t\t\t\t|| (command == CMD_MODCMDEX && param >= 0x61 && param <= 0x6F))\n\t\t\t\t{\n\t\t\t\t\tconst double start = memory.chnSettings[nChn].patLoop;\n\t\t\t\t\tif(!startTimes[start]) startTimes[start] = 1;\n\t\t\t\t\tstartTimes[start] = mpt::lcm(startTimes[start], 1 + (param & 0x0F));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(const auto &i : startTimes)\n\t\t\t{\n\t\t\t\tmemory.elapsedTime += (memory.elapsedTime - i.first) * (double)(i.second - 1);\n\t\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)\n\t\t\t\t{\n\t\t\t\t\tif(memory.chnSettings[nChn].patLoop == i.first)\n\t\t\t\t\t{\n\t\t\t\t\t\tplayState.m_lTotalSampleCount += (playState.m_lTotalSampleCount - memory.chnSettings[nChn].patLoopSmp) * (i.second - 1);\n\t\t\t\t\t\tif(m_playBehaviour[kITPatternLoopTargetReset] || (GetType() == MOD_TYPE_S3M))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmemory.chnSettings[nChn].patLoop = memory.elapsedTime;\n\t\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopStart = playState.m_nRow + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(GetType() == MOD_TYPE_IT)\n\t\t\t{\n\t\t\t\t// IT pattern loop start row update - at the end of a pattern loop, set pattern loop start to next row (for upcoming pattern loops with missing SB0)",
"\t\t\t\tpChn = playState.Chn;\n\t\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)",
"\t\t\t\t{\n\t\t\t\t\tif((pChn->rowCommand.command == CMD_S3MCMDEX && pChn->rowCommand.param >= 0xB1 && pChn->rowCommand.param <= 0xBF))\n\t\t\t\t\t{\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoop = memory.elapsedTime;\n\t\t\t\t\t\tmemory.chnSettings[nChn].patLoopSmp = playState.m_lTotalSampleCount;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"\t// Now advance the sample positions for sample seeking on channels that are still playing\n\tif(adjustSamplePos)\n\t{\n\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++)\n\t\t{\n\t\t\tif(memory.chnSettings[nChn].ticksToRender != GetLengthMemory::IGNORE_CHANNEL)\n\t\t\t{\n\t\t\t\tmemory.RenderChannel(nChn, oldTickDuration);\n\t\t\t}\n\t\t}\n\t}",
"\tif(retval.targetReached || target.mode == GetLengthTarget::NoTarget)\n\t{\n\t\tretval.lastOrder = playState.m_nCurrentOrder;\n\t\tretval.lastRow = playState.m_nRow;\n\t}\n\tretval.duration = memory.elapsedTime;\n\tresults.push_back(retval);",
"\t// Store final variables\n\tif(adjustMode & eAdjust)\n\t{\n\t\tif(retval.targetReached || target.mode == GetLengthTarget::NoTarget)\n\t\t{\n\t\t\t// Target found, or there is no target (i.e. play whole song)...\n\t\t\tm_PlayState = std::move(playState);\n\t\t\tm_PlayState.m_nNextRow = m_PlayState.m_nRow;\n\t\t\tm_PlayState.m_nFrameDelay = m_PlayState.m_nPatternDelay = 0;\n\t\t\tm_PlayState.m_nTickCount = Util::MaxValueOfType(m_PlayState.m_nTickCount) - 1;\n\t\t\tm_PlayState.m_bPositionChanged = true;\n\t\t\tfor(CHANNELINDEX n = 0; n < GetNumChannels(); n++)\n\t\t\t{\n\t\t\t\tif(m_PlayState.Chn[n].nLastNote != NOTE_NONE)\n\t\t\t\t{\n\t\t\t\t\tm_PlayState.Chn[n].nNewNote = m_PlayState.Chn[n].nLastNote;\n\t\t\t\t}\n\t\t\t\tif(memory.chnSettings[n].vol != 0xFF && !adjustSamplePos)\n\t\t\t\t{\n\t\t\t\t\tm_PlayState.Chn[n].nVolume = std::min(memory.chnSettings[n].vol, uint8(64)) * 4;\n\t\t\t\t}\n\t\t\t}",
"#ifndef NO_PLUGINS\n\t\t\t// If there were any PC events, update plugin parameters to their latest value.\n\t\t\tstd::bitset<MAX_MIXPLUGINS> plugSetProgram;\n\t\t\tfor(const auto ¶m : memory.plugParams)\n\t\t\t{\n\t\t\t\tPLUGINDEX plug = param.first.first - 1;\n\t\t\t\tIMixPlugin *plugin = m_MixPlugins[plug].pMixPlugin;\n\t\t\t\tif(plugin != nullptr)\n\t\t\t\t{\n\t\t\t\t\tif(!plugSetProgram[plug])\n\t\t\t\t\t{\n\t\t\t\t\t\t// Used for bridged plugins to avoid sending out individual messages for each parameter.\n\t\t\t\t\t\tplugSetProgram.set(plug);\n\t\t\t\t\t\tplugin->BeginSetProgram();\n\t\t\t\t\t}\n\t\t\t\t\tplugin->SetParameter(param.first.second, param.second / PlugParamValue(ModCommand::maxColumnValue));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(plugSetProgram.any())\n\t\t\t{\n\t\t\t\tfor(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++)\n\t\t\t\t{\n\t\t\t\t\tif(plugSetProgram[i])\n\t\t\t\t\t{\n\t\t\t\t\t\tm_MixPlugins[i].pMixPlugin->EndSetProgram();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n#endif // NO_PLUGINS\n\t\t} else if(adjustMode != eAdjustOnSuccess)\n\t\t{\n\t\t\t// Target not found (e.g. when jumping to a hidden sub song), reset global variables...\n\t\t\tm_PlayState.m_nMusicSpeed = m_nDefaultSpeed;\n\t\t\tm_PlayState.m_nMusicTempo = m_nDefaultTempo;\n\t\t\tm_PlayState.m_nGlobalVolume = m_nDefaultGlobalVolume;\n\t\t}\n\t\t// When adjusting the playback status, we will also want to update the visited rows vector according to the current position.\n\t\tif(sequence != Order.GetCurrentSequenceIndex())\n\t\t{\n\t\t\tOrder.SetSequence(sequence);\n\t\t}\n\t\tvisitedSongRows.Set(visitedRows);\n\t}",
"\treturn results;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 32025,
"char_start": 31999,
"chars": "pChn = playState.Chn;\n\t\t\t\t"
},
{
"char_end": 32086,
"char_start": 32078,
"chars": "Chn++, p"
}
],
"deleted": []
},
"commit_link": "github.com/OpenMPT/openmpt/commit/492022c7297ede682161d9c0ec2de15526424e76",
"file_name": "soundlib/Snd_fx.cpp",
"func_name": "CSoundFile::GetLength",
"line_changes": {
"added": [
{
"char_end": 32021,
"char_start": 31995,
"line": "\t\t\t\tpChn = playState.Chn;\n",
"line_no": 978
},
{
"char_end": 32093,
"char_start": 32021,
"line": "\t\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)\n",
"line_no": 979
}
],
"deleted": [
{
"char_end": 32059,
"char_start": 31995,
"line": "\t\t\t\tfor(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++)\n",
"line_no": 978
}
]
},
"vul_type": "cwe-125"
} | 391 | cwe-125 | cpp |
Determine whether the {function_name} code is vulnerable or not. | [
"static inline size_t GetPSDRowSize(Image *image)\n{\n if (image->depth == 1)",
" return((image->columns+7)/8);",
" else\n return(image->columns*GetPSDPacketSize(image));\n}"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 89,
"char_start": 88,
"chars": "("
},
{
"char_end": 133,
"char_start": 108,
"chars": ")*GetPSDPacketSize(image)"
}
],
"deleted": []
},
"commit_link": "github.com/ImageMagick/ImageMagick/commit/5f16640725b1225e6337c62526e6577f0f88edb8",
"file_name": "coders/psd.c",
"func_name": "GetPSDRowSize",
"line_changes": {
"added": [
{
"char_end": 136,
"char_start": 76,
"line": " return(((image->columns+7)/8)*GetPSDPacketSize(image));\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 110,
"char_start": 76,
"line": " return((image->columns+7)/8);\n",
"line_no": 4
}
]
},
"vul_type": "cwe-125"
} | 392 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static inline size_t GetPSDRowSize(Image *image)\n{\n if (image->depth == 1)",
" return(((image->columns+7)/8)*GetPSDPacketSize(image));",
" else\n return(image->columns*GetPSDPacketSize(image));\n}"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 89,
"char_start": 88,
"chars": "("
},
{
"char_end": 133,
"char_start": 108,
"chars": ")*GetPSDPacketSize(image)"
}
],
"deleted": []
},
"commit_link": "github.com/ImageMagick/ImageMagick/commit/5f16640725b1225e6337c62526e6577f0f88edb8",
"file_name": "coders/psd.c",
"func_name": "GetPSDRowSize",
"line_changes": {
"added": [
{
"char_end": 136,
"char_start": 76,
"line": " return(((image->columns+7)/8)*GetPSDPacketSize(image));\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 110,
"char_start": 76,
"line": " return((image->columns+7)/8);\n",
"line_no": 4
}
]
},
"vul_type": "cwe-125"
} | 392 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static int dex_loadcode(RBinFile *arch, RBinDexObj *bin) {\n\tstruct r_bin_t *rbin = arch->rbin;\n\tint i;\n\tint *methods = NULL;\n\tint sym_count = 0;",
"\t// doublecheck??\n\tif (!bin || bin->methods_list) {\n\t\treturn false;\n\t}\n\tbin->code_from = UT64_MAX;\n\tbin->code_to = 0;\n\tbin->methods_list = r_list_newf ((RListFree)free);\n\tif (!bin->methods_list) {\n\t\treturn false;\n\t}\n\tbin->imports_list = r_list_newf ((RListFree)free);\n\tif (!bin->imports_list) {\n\t\tr_list_free (bin->methods_list);\n\t\treturn false;\n\t}\n\tbin->classes_list = r_list_newf ((RListFree)__r_bin_class_free);\n\tif (!bin->classes_list) {\n\t\tr_list_free (bin->methods_list);\n\t\tr_list_free (bin->imports_list);\n\t\treturn false;\n\t}",
"\tif (bin->header.method_size>bin->size) {\n\t\tbin->header.method_size = 0;\n\t\treturn false;\n\t}",
"\t/* WrapDown the header sizes to avoid huge allocations */\n\tbin->header.method_size = R_MIN (bin->header.method_size, bin->size);\n\tbin->header.class_size = R_MIN (bin->header.class_size, bin->size);\n\tbin->header.strings_size = R_MIN (bin->header.strings_size, bin->size);",
"\t// TODO: is this posible after R_MIN ??\n\tif (bin->header.strings_size > bin->size) {\n\t\teprintf (\"Invalid strings size\\n\");\n\t\treturn false;\n\t}",
"\tif (bin->classes) {\n\t\tut64 amount = sizeof (int) * bin->header.method_size;\n\t\tif (amount > UT32_MAX || amount < bin->header.method_size) {\n\t\t\treturn false;\n\t\t}\n\t\tmethods = calloc (1, amount + 1);\n\t\tfor (i = 0; i < bin->header.class_size; i++) {\n\t\t\tchar *super_name, *class_name;\n\t\t\tstruct dex_class_t *c = &bin->classes[i];\n\t\t\tclass_name = dex_class_name (bin, c);\n\t\t\tsuper_name = dex_class_super_name (bin, c);\n\t\t\tif (dexdump) { \n\t\t\t\trbin->cb_printf (\"Class #%d -\\n\", i);\n\t\t\t}\n\t\t\tparse_class (arch, bin, c, i, methods, &sym_count);\n\t\t\tfree (class_name);\n\t\t\tfree (super_name);\n\t\t}\n\t}",
"\tif (methods) {\n\t\tint import_count = 0;\n\t\tint sym_count = bin->methods_list->length;",
"\t\tfor (i = 0; i < bin->header.method_size; i++) {\n\t\t\tint len = 0;\n\t\t\tif (methods[i]) {\n\t\t\t\tcontinue;\n\t\t\t}\n",
"\t\t\tif (bin->methods[i].class_id > bin->header.types_size - 1) {",
"\t\t\t\tcontinue;\n\t\t\t}",
"\t\t\tif (is_class_idx_in_code_classes(bin, bin->methods[i].class_id)) {\n\t\t\t\tcontinue;\n\t\t\t}",
"\t\t\tchar *class_name = getstr (\n\t\t\t\tbin, bin->types[bin->methods[i].class_id]\n\t\t\t\t\t\t.descriptor_id);\n\t\t\tif (!class_name) {\n\t\t\t\tfree (class_name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlen = strlen (class_name);\n\t\t\tif (len < 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tclass_name[len - 1] = 0; // remove last char \";\"\n\t\t\tchar *method_name = dex_method_name (bin, i);\n\t\t\tchar *signature = dex_method_signature (bin, i);\n\t\t\tif (method_name && *method_name) {\n\t\t\t\tRBinImport *imp = R_NEW0 (RBinImport);\n\t\t\t\timp->name = r_str_newf (\"%s.method.%s%s\", class_name, method_name, signature);\n\t\t\t\timp->type = r_str_const (\"FUNC\");\n\t\t\t\timp->bind = r_str_const (\"NONE\");\n\t\t\t\timp->ordinal = import_count++;\n\t\t\t\tr_list_append (bin->imports_list, imp);",
"\t\t\t\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\t\t\t\tsym->name = r_str_newf (\"imp.%s\", imp->name);\n\t\t\t\tsym->type = r_str_const (\"FUNC\");\n\t\t\t\tsym->bind = r_str_const (\"NONE\");\n\t\t\t\t//XXX so damn unsafe check buffer boundaries!!!!\n\t\t\t\t//XXX use r_buf API!!\n\t\t\t\tsym->paddr = sym->vaddr = bin->b->base + bin->header.method_offset + (sizeof (struct dex_method_t) * i) ;\n\t\t\t\tsym->ordinal = sym_count++;\n\t\t\t\tr_list_append (bin->methods_list, sym);\n\t\t\t\tsdb_num_set (mdb, sdb_fmt (0, \"method.%d\", i), sym->paddr, 0);\n\t\t\t}\n\t\t\tfree (method_name);\n\t\t\tfree (signature);\n\t\t\tfree (class_name);\n\t\t}\n\t\tfree (methods);\n\t}\n\treturn true;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [],
"deleted": [
{
"char_end": 2038,
"char_start": 2034,
"chars": " - 1"
}
]
},
"commit_link": "github.com/radare/radare2/commit/ead645853a63bf83d8386702cad0cf23b31d7eeb",
"file_name": "libr/bin/p/bin_dex.c",
"func_name": "dex_loadcode",
"line_changes": {
"added": [
{
"char_end": 2038,
"char_start": 1978,
"line": "\t\t\tif (bin->methods[i].class_id > bin->header.types_size) {\n",
"line_no": 75
}
],
"deleted": [
{
"char_end": 2042,
"char_start": 1978,
"line": "\t\t\tif (bin->methods[i].class_id > bin->header.types_size - 1) {\n",
"line_no": 75
}
]
},
"vul_type": "cwe-125"
} | 393 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static int dex_loadcode(RBinFile *arch, RBinDexObj *bin) {\n\tstruct r_bin_t *rbin = arch->rbin;\n\tint i;\n\tint *methods = NULL;\n\tint sym_count = 0;",
"\t// doublecheck??\n\tif (!bin || bin->methods_list) {\n\t\treturn false;\n\t}\n\tbin->code_from = UT64_MAX;\n\tbin->code_to = 0;\n\tbin->methods_list = r_list_newf ((RListFree)free);\n\tif (!bin->methods_list) {\n\t\treturn false;\n\t}\n\tbin->imports_list = r_list_newf ((RListFree)free);\n\tif (!bin->imports_list) {\n\t\tr_list_free (bin->methods_list);\n\t\treturn false;\n\t}\n\tbin->classes_list = r_list_newf ((RListFree)__r_bin_class_free);\n\tif (!bin->classes_list) {\n\t\tr_list_free (bin->methods_list);\n\t\tr_list_free (bin->imports_list);\n\t\treturn false;\n\t}",
"\tif (bin->header.method_size>bin->size) {\n\t\tbin->header.method_size = 0;\n\t\treturn false;\n\t}",
"\t/* WrapDown the header sizes to avoid huge allocations */\n\tbin->header.method_size = R_MIN (bin->header.method_size, bin->size);\n\tbin->header.class_size = R_MIN (bin->header.class_size, bin->size);\n\tbin->header.strings_size = R_MIN (bin->header.strings_size, bin->size);",
"\t// TODO: is this posible after R_MIN ??\n\tif (bin->header.strings_size > bin->size) {\n\t\teprintf (\"Invalid strings size\\n\");\n\t\treturn false;\n\t}",
"\tif (bin->classes) {\n\t\tut64 amount = sizeof (int) * bin->header.method_size;\n\t\tif (amount > UT32_MAX || amount < bin->header.method_size) {\n\t\t\treturn false;\n\t\t}\n\t\tmethods = calloc (1, amount + 1);\n\t\tfor (i = 0; i < bin->header.class_size; i++) {\n\t\t\tchar *super_name, *class_name;\n\t\t\tstruct dex_class_t *c = &bin->classes[i];\n\t\t\tclass_name = dex_class_name (bin, c);\n\t\t\tsuper_name = dex_class_super_name (bin, c);\n\t\t\tif (dexdump) { \n\t\t\t\trbin->cb_printf (\"Class #%d -\\n\", i);\n\t\t\t}\n\t\t\tparse_class (arch, bin, c, i, methods, &sym_count);\n\t\t\tfree (class_name);\n\t\t\tfree (super_name);\n\t\t}\n\t}",
"\tif (methods) {\n\t\tint import_count = 0;\n\t\tint sym_count = bin->methods_list->length;",
"\t\tfor (i = 0; i < bin->header.method_size; i++) {\n\t\t\tint len = 0;\n\t\t\tif (methods[i]) {\n\t\t\t\tcontinue;\n\t\t\t}\n",
"\t\t\tif (bin->methods[i].class_id > bin->header.types_size) {",
"\t\t\t\tcontinue;\n\t\t\t}",
"\t\t\tif (is_class_idx_in_code_classes(bin, bin->methods[i].class_id)) {\n\t\t\t\tcontinue;\n\t\t\t}",
"\t\t\tchar *class_name = getstr (\n\t\t\t\tbin, bin->types[bin->methods[i].class_id]\n\t\t\t\t\t\t.descriptor_id);\n\t\t\tif (!class_name) {\n\t\t\t\tfree (class_name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlen = strlen (class_name);\n\t\t\tif (len < 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tclass_name[len - 1] = 0; // remove last char \";\"\n\t\t\tchar *method_name = dex_method_name (bin, i);\n\t\t\tchar *signature = dex_method_signature (bin, i);\n\t\t\tif (method_name && *method_name) {\n\t\t\t\tRBinImport *imp = R_NEW0 (RBinImport);\n\t\t\t\timp->name = r_str_newf (\"%s.method.%s%s\", class_name, method_name, signature);\n\t\t\t\timp->type = r_str_const (\"FUNC\");\n\t\t\t\timp->bind = r_str_const (\"NONE\");\n\t\t\t\timp->ordinal = import_count++;\n\t\t\t\tr_list_append (bin->imports_list, imp);",
"\t\t\t\tRBinSymbol *sym = R_NEW0 (RBinSymbol);\n\t\t\t\tsym->name = r_str_newf (\"imp.%s\", imp->name);\n\t\t\t\tsym->type = r_str_const (\"FUNC\");\n\t\t\t\tsym->bind = r_str_const (\"NONE\");\n\t\t\t\t//XXX so damn unsafe check buffer boundaries!!!!\n\t\t\t\t//XXX use r_buf API!!\n\t\t\t\tsym->paddr = sym->vaddr = bin->b->base + bin->header.method_offset + (sizeof (struct dex_method_t) * i) ;\n\t\t\t\tsym->ordinal = sym_count++;\n\t\t\t\tr_list_append (bin->methods_list, sym);\n\t\t\t\tsdb_num_set (mdb, sdb_fmt (0, \"method.%d\", i), sym->paddr, 0);\n\t\t\t}\n\t\t\tfree (method_name);\n\t\t\tfree (signature);\n\t\t\tfree (class_name);\n\t\t}\n\t\tfree (methods);\n\t}\n\treturn true;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [],
"deleted": [
{
"char_end": 2038,
"char_start": 2034,
"chars": " - 1"
}
]
},
"commit_link": "github.com/radare/radare2/commit/ead645853a63bf83d8386702cad0cf23b31d7eeb",
"file_name": "libr/bin/p/bin_dex.c",
"func_name": "dex_loadcode",
"line_changes": {
"added": [
{
"char_end": 2038,
"char_start": 1978,
"line": "\t\t\tif (bin->methods[i].class_id > bin->header.types_size) {\n",
"line_no": 75
}
],
"deleted": [
{
"char_end": 2042,
"char_start": 1978,
"line": "\t\t\tif (bin->methods[i].class_id > bin->header.types_size - 1) {\n",
"line_no": 75
}
]
},
"vul_type": "cwe-125"
} | 393 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define RMT_EQUAL_RGB 1\n#define RMT_NONE 0\n#define RMT_RAW 2\n#define RT_STANDARD 1\n#define RT_ENCODED 2\n#define RT_FORMAT_RGB 3",
" typedef struct _SUNInfo\n {\n unsigned int\n magic,\n width,\n height,\n depth,\n length,\n type,\n maptype,\n maplength;\n } SUNInfo;",
" Image\n *image;",
" int\n bit;",
" MagickBooleanType\n status;",
" MagickSizeType\n number_pixels;",
" register Quantum\n *q;",
" register ssize_t\n i,\n x;",
" register unsigned char\n *p;",
" size_t\n bytes_per_line,\n extent,\n height,\n length;",
" ssize_t\n count,\n y;",
" SUNInfo\n sun_info;",
" unsigned char\n *sun_data,\n *sun_pixels;",
" /*\n Open image file.\n */\n assert(image_info != (const ImageInfo *) NULL);\n assert(image_info->signature == MagickSignature);\n if (image_info->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n image_info->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickSignature);\n image=AcquireImage(image_info,exception);\n status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n if (status == MagickFalse)\n {\n image=DestroyImageList(image);\n return((Image *) NULL);\n }\n /*\n Read SUN raster header.\n */\n (void) ResetMagickMemory(&sun_info,0,sizeof(sun_info));\n sun_info.magic=ReadBlobMSBLong(image);\n do\n {\n /*\n Verify SUN identifier.\n */\n if (sun_info.magic != 0x59a66a95)\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n sun_info.width=ReadBlobMSBLong(image);\n sun_info.height=ReadBlobMSBLong(image);\n sun_info.depth=ReadBlobMSBLong(image);\n sun_info.length=ReadBlobMSBLong(image);\n sun_info.type=ReadBlobMSBLong(image);\n sun_info.maptype=ReadBlobMSBLong(image);\n sun_info.maplength=ReadBlobMSBLong(image);\n extent=sun_info.height*sun_info.width;\n if ((sun_info.height != 0) && (sun_info.width != extent/sun_info.height))\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n if ((sun_info.type != RT_STANDARD) && (sun_info.type != RT_ENCODED) &&\n (sun_info.type != RT_FORMAT_RGB))\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n if ((sun_info.maptype == RMT_NONE) && (sun_info.maplength != 0))\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n if ((sun_info.depth == 0) || (sun_info.depth > 32))\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n if ((sun_info.maptype != RMT_NONE) && (sun_info.maptype != RMT_EQUAL_RGB) &&\n (sun_info.maptype != RMT_RAW))\n ThrowReaderException(CoderError,\"ColormapTypeNotSupported\");\n image->columns=sun_info.width;\n image->rows=sun_info.height;\n image->depth=sun_info.depth <= 8 ? sun_info.depth :\n MAGICKCORE_QUANTUM_DEPTH;\n if (sun_info.depth < 24)\n {\n size_t\n one;",
" image->colors=sun_info.maplength;\n one=1;\n if (sun_info.maptype == RMT_NONE)\n image->colors=one << sun_info.depth;\n if (sun_info.maptype == RMT_EQUAL_RGB)\n image->colors=sun_info.maplength/3;\n if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n }\n switch (sun_info.maptype)\n {\n case RMT_NONE:\n break;\n case RMT_EQUAL_RGB:\n {\n unsigned char\n *sun_colormap;",
" /*\n Read SUN raster colormap.\n */\n sun_colormap=(unsigned char *) AcquireQuantumMemory(image->colors,\n sizeof(*sun_colormap));\n if (sun_colormap == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n count=ReadBlob(image,image->colors,sun_colormap);\n if (count != (ssize_t) image->colors)\n ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n for (i=0; i < (ssize_t) image->colors; i++)\n image->colormap[i].red=(MagickRealType) ScaleCharToQuantum(\n sun_colormap[i]);\n count=ReadBlob(image,image->colors,sun_colormap);\n if (count != (ssize_t) image->colors)\n ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n for (i=0; i < (ssize_t) image->colors; i++)\n image->colormap[i].green=(MagickRealType) ScaleCharToQuantum(\n sun_colormap[i]);\n count=ReadBlob(image,image->colors,sun_colormap);\n if (count != (ssize_t) image->colors)\n ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n for (i=0; i < (ssize_t) image->colors; i++)\n image->colormap[i].blue=(MagickRealType) ScaleCharToQuantum(\n sun_colormap[i]);\n sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);\n break;\n }\n case RMT_RAW:\n {\n unsigned char\n *sun_colormap;",
" /*\n Read SUN raster colormap.\n */\n sun_colormap=(unsigned char *) AcquireQuantumMemory(sun_info.maplength,\n sizeof(*sun_colormap));\n if (sun_colormap == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n count=ReadBlob(image,sun_info.maplength,sun_colormap);\n if (count != (ssize_t) sun_info.maplength)\n ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);\n break;\n }\n default:\n ThrowReaderException(CoderError,\"ColormapTypeNotSupported\");\n }\n image->alpha_trait=sun_info.depth == 32 ? BlendPixelTrait :\n UndefinedPixelTrait;\n image->columns=sun_info.width;\n image->rows=sun_info.height;\n if (image_info->ping != MagickFalse)\n {\n (void) CloseBlob(image);\n return(GetFirstImageInList(image));\n }\n status=SetImageExtent(image,image->columns,image->rows,exception);\n if (status == MagickFalse)\n return(DestroyImageList(image));\n if ((sun_info.length*sizeof(*sun_data))/sizeof(*sun_data) !=\n sun_info.length || !sun_info.length)",
" ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");",
" number_pixels=(MagickSizeType) image->columns*image->rows;\n if ((sun_info.type != RT_ENCODED) && \n ((number_pixels*sun_info.depth) > (8*sun_info.length)))\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n bytes_per_line=sun_info.width*sun_info.depth;\n sun_data=(unsigned char *) AcquireQuantumMemory((size_t) MagickMax(\n sun_info.length,bytes_per_line*sun_info.width),sizeof(*sun_data));\n if (sun_data == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n count=(ssize_t) ReadBlob(image,sun_info.length,sun_data);\n if (count != (ssize_t) sun_info.length)\n ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n height=sun_info.height;\n if ((height == 0) || (sun_info.width == 0) || (sun_info.depth == 0) ||\n ((bytes_per_line/sun_info.depth) != sun_info.width))",
" ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");",
" bytes_per_line+=15;\n bytes_per_line<<=1;\n if ((bytes_per_line >> 1) != (sun_info.width*sun_info.depth+15))",
" ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");",
" bytes_per_line>>=4;\n sun_pixels=(unsigned char *) AcquireQuantumMemory(height,\n bytes_per_line*sizeof(*sun_pixels));\n if (sun_pixels == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n if (sun_info.type == RT_ENCODED)\n (void) DecodeImage(sun_data,sun_info.length,sun_pixels,bytes_per_line*\n height);",
"",
" sun_data=(unsigned char *) RelinquishMagickMemory(sun_data);\n /*\n Convert SUN raster image to pixel packets.\n */\n p=sun_pixels;\n if (sun_info.depth == 1)\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n if (q == (Quantum *) NULL)\n break;\n for (x=0; x < ((ssize_t) image->columns-7); x+=8)\n {\n for (bit=7; bit >= 0; bit--)\n {\n SetPixelIndex(image,(Quantum) ((*p) & (0x01 << bit) ? 0x00 : 0x01),\n q);\n q+=GetPixelChannels(image);\n }\n p++;\n }\n if ((image->columns % 8) != 0)\n {\n for (bit=7; bit >= (int) (8-(image->columns % 8)); bit--)\n {\n SetPixelIndex(image,(Quantum) ((*p) & (0x01 << bit) ? 0x00 :\n 0x01),q);\n q+=GetPixelChannels(image);\n }\n p++;\n }\n if ((((image->columns/8)+(image->columns % 8 ? 1 : 0)) % 2) != 0)\n p++;\n if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n if (image->previous == (Image *) NULL)\n {\n status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n image->rows);\n if (status == MagickFalse)\n break;\n }\n }\n else\n if (image->storage_class == PseudoClass)\n {\n if (bytes_per_line == 0)\n bytes_per_line=image->columns;\n length=image->rows*(image->columns+image->columns % 2);\n if (((sun_info.type == RT_ENCODED) &&\n (length > (bytes_per_line*image->rows))) ||\n ((sun_info.type != RT_ENCODED) && (length > sun_info.length)))\n ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n if (q == (Quantum *) NULL)\n break;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n SetPixelIndex(image,*p++,q);\n q+=GetPixelChannels(image);\n }\n if ((image->columns % 2) != 0)\n p++;\n if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n if (image->previous == (Image *) NULL)\n {\n status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n image->rows);\n if (status == MagickFalse)\n break;\n }\n }\n }\n else\n {\n size_t\n bytes_per_pixel;",
" bytes_per_pixel=3;\n if (image->alpha_trait != UndefinedPixelTrait)\n bytes_per_pixel++;\n if (bytes_per_line == 0)\n bytes_per_line=bytes_per_pixel*image->columns;\n length=image->rows*(bytes_per_line+bytes_per_line % 2);\n if (((sun_info.type == RT_ENCODED) &&\n (length > (bytes_per_line*image->rows))) ||\n ((sun_info.type != RT_ENCODED) && (length > sun_info.length)))\n ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n if (q == (Quantum *) NULL)\n break;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (image->alpha_trait != UndefinedPixelTrait)\n SetPixelAlpha(image,ScaleCharToQuantum(*p++),q);\n if (sun_info.type == RT_STANDARD)\n {\n SetPixelBlue(image,ScaleCharToQuantum(*p++),q);\n SetPixelGreen(image,ScaleCharToQuantum(*p++),q);\n SetPixelRed(image,ScaleCharToQuantum(*p++),q);\n }\n else\n {\n SetPixelRed(image,ScaleCharToQuantum(*p++),q);\n SetPixelGreen(image,ScaleCharToQuantum(*p++),q);\n SetPixelBlue(image,ScaleCharToQuantum(*p++),q);\n }\n if (image->colors != 0)\n {\n SetPixelRed(image,ClampToQuantum(image->colormap[(ssize_t)\n GetPixelRed(image,q)].red),q);\n SetPixelGreen(image,ClampToQuantum(image->colormap[(ssize_t)\n GetPixelGreen(image,q)].green),q);\n SetPixelBlue(image,ClampToQuantum(image->colormap[(ssize_t)\n GetPixelBlue(image,q)].blue),q);\n }\n q+=GetPixelChannels(image);\n }\n if (((bytes_per_pixel*image->columns) % 2) != 0)\n p++;\n if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n if (image->previous == (Image *) NULL)\n {\n status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n image->rows);\n if (status == MagickFalse)\n break;\n }\n }\n }\n if (image->storage_class == PseudoClass)\n (void) SyncImage(image,exception);\n sun_pixels=(unsigned char *) RelinquishMagickMemory(sun_pixels);\n if (EOFBlob(image) != MagickFalse)\n {\n ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n image->filename);\n break;\n }\n /*\n Proceed to next image.\n */\n if (image_info->number_scenes != 0)\n if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n break;\n sun_info.magic=ReadBlobMSBLong(image);\n if (sun_info.magic == 0x59a66a95)\n {\n /*\n Allocate next image structure.\n */\n AcquireNextImage(image_info,image,exception);\n if (GetNextImageInList(image) == (Image *) NULL)\n {\n image=DestroyImageList(image);\n return((Image *) NULL);\n }\n image=SyncNextImageInList(image);\n status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n GetBlobSize(image));\n if (status == MagickFalse)\n break;\n }\n } while (sun_info.magic == 0x59a66a95);\n (void) CloseBlob(image);\n return(GetFirstImageInList(image));\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 6285,
"char_start": 6284,
"chars": "I"
},
{
"char_end": 6287,
"char_start": 6286,
"chars": "p"
},
{
"char_end": 6294,
"char_start": 6289,
"chars": "perIm"
},
{
"char_end": 6298,
"char_start": 6295,
"chars": "geH"
},
{
"char_end": 6300,
"char_start": 6299,
"chars": "a"
},
{
"char_end": 6303,
"char_start": 6301,
"chars": "er"
},
{
"char_end": 7246,
"char_start": 7245,
"chars": "I"
},
{
"char_end": 7248,
"char_start": 7247,
"chars": "p"
},
{
"char_end": 7255,
"char_start": 7250,
"chars": "perIm"
},
{
"char_end": 7259,
"char_start": 7256,
"chars": "geH"
},
{
"char_end": 7261,
"char_start": 7260,
"chars": "a"
},
{
"char_end": 7264,
"char_start": 7262,
"chars": "er"
},
{
"char_end": 7433,
"char_start": 7432,
"chars": "I"
},
{
"char_end": 7435,
"char_start": 7434,
"chars": "p"
},
{
"char_end": 7442,
"char_start": 7437,
"chars": "perIm"
},
{
"char_end": 7446,
"char_start": 7443,
"chars": "geH"
},
{
"char_end": 7448,
"char_start": 7447,
"chars": "a"
},
{
"char_end": 7451,
"char_start": 7449,
"chars": "er"
},
{
"char_end": 8057,
"char_start": 7833,
"chars": "\n else\n {\n if (sun_info.length > (height*bytes_per_line))\n ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n (void) CopyMagickMemory(sun_pixels,sun_data,sun_info.length);\n }"
}
],
"deleted": [
{
"char_end": 6286,
"char_start": 6284,
"chars": "Me"
},
{
"char_end": 6295,
"char_start": 6289,
"chars": "yAlloc"
},
{
"char_end": 6304,
"char_start": 6296,
"chars": "tionFail"
},
{
"char_end": 7250,
"char_start": 7248,
"chars": "Me"
},
{
"char_end": 7259,
"char_start": 7253,
"chars": "yAlloc"
},
{
"char_end": 7268,
"char_start": 7260,
"chars": "tionFail"
},
{
"char_end": 7440,
"char_start": 7438,
"chars": "Me"
},
{
"char_end": 7449,
"char_start": 7443,
"chars": "yAlloc"
},
{
"char_end": 7458,
"char_start": 7450,
"chars": "tionFail"
},
{
"char_end": 7826,
"char_start": 7826,
"chars": ""
}
]
},
"commit_link": "github.com/ImageMagick/ImageMagick/commit/6b4aff0f117b978502ee5bcd6e753c17aec5a961",
"file_name": "coders/sun.c",
"func_name": "ReadSUNImage",
"line_changes": {
"added": [
{
"char_end": 6307,
"char_start": 6237,
"line": " ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n",
"line_no": 201
},
{
"char_end": 7268,
"char_start": 7198,
"line": " ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n",
"line_no": 217
},
{
"char_end": 7455,
"char_start": 7385,
"line": " ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n",
"line_no": 221
},
{
"char_end": 7843,
"char_start": 7834,
"line": " else\n",
"line_no": 230
},
{
"char_end": 7851,
"char_start": 7843,
"line": " {\n",
"line_no": 231
},
{
"char_end": 7906,
"char_start": 7851,
"line": " if (sun_info.length > (height*bytes_per_line))\n",
"line_no": 232
},
{
"char_end": 7980,
"char_start": 7906,
"line": " ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n",
"line_no": 233
},
{
"char_end": 8050,
"char_start": 7980,
"line": " (void) CopyMagickMemory(sun_pixels,sun_data,sun_info.length);\n",
"line_no": 234
},
{
"char_end": 8058,
"char_start": 8050,
"line": " }\n",
"line_no": 235
}
],
"deleted": [
{
"char_end": 6310,
"char_start": 6237,
"line": " ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n",
"line_no": 201
},
{
"char_end": 7274,
"char_start": 7201,
"line": " ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n",
"line_no": 217
},
{
"char_end": 7464,
"char_start": 7391,
"line": " ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n",
"line_no": 221
}
]
},
"vul_type": "cwe-125"
} | 394 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n#define RMT_EQUAL_RGB 1\n#define RMT_NONE 0\n#define RMT_RAW 2\n#define RT_STANDARD 1\n#define RT_ENCODED 2\n#define RT_FORMAT_RGB 3",
" typedef struct _SUNInfo\n {\n unsigned int\n magic,\n width,\n height,\n depth,\n length,\n type,\n maptype,\n maplength;\n } SUNInfo;",
" Image\n *image;",
" int\n bit;",
" MagickBooleanType\n status;",
" MagickSizeType\n number_pixels;",
" register Quantum\n *q;",
" register ssize_t\n i,\n x;",
" register unsigned char\n *p;",
" size_t\n bytes_per_line,\n extent,\n height,\n length;",
" ssize_t\n count,\n y;",
" SUNInfo\n sun_info;",
" unsigned char\n *sun_data,\n *sun_pixels;",
" /*\n Open image file.\n */\n assert(image_info != (const ImageInfo *) NULL);\n assert(image_info->signature == MagickSignature);\n if (image_info->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n image_info->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickSignature);\n image=AcquireImage(image_info,exception);\n status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n if (status == MagickFalse)\n {\n image=DestroyImageList(image);\n return((Image *) NULL);\n }\n /*\n Read SUN raster header.\n */\n (void) ResetMagickMemory(&sun_info,0,sizeof(sun_info));\n sun_info.magic=ReadBlobMSBLong(image);\n do\n {\n /*\n Verify SUN identifier.\n */\n if (sun_info.magic != 0x59a66a95)\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n sun_info.width=ReadBlobMSBLong(image);\n sun_info.height=ReadBlobMSBLong(image);\n sun_info.depth=ReadBlobMSBLong(image);\n sun_info.length=ReadBlobMSBLong(image);\n sun_info.type=ReadBlobMSBLong(image);\n sun_info.maptype=ReadBlobMSBLong(image);\n sun_info.maplength=ReadBlobMSBLong(image);\n extent=sun_info.height*sun_info.width;\n if ((sun_info.height != 0) && (sun_info.width != extent/sun_info.height))\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n if ((sun_info.type != RT_STANDARD) && (sun_info.type != RT_ENCODED) &&\n (sun_info.type != RT_FORMAT_RGB))\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n if ((sun_info.maptype == RMT_NONE) && (sun_info.maplength != 0))\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n if ((sun_info.depth == 0) || (sun_info.depth > 32))\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n if ((sun_info.maptype != RMT_NONE) && (sun_info.maptype != RMT_EQUAL_RGB) &&\n (sun_info.maptype != RMT_RAW))\n ThrowReaderException(CoderError,\"ColormapTypeNotSupported\");\n image->columns=sun_info.width;\n image->rows=sun_info.height;\n image->depth=sun_info.depth <= 8 ? sun_info.depth :\n MAGICKCORE_QUANTUM_DEPTH;\n if (sun_info.depth < 24)\n {\n size_t\n one;",
" image->colors=sun_info.maplength;\n one=1;\n if (sun_info.maptype == RMT_NONE)\n image->colors=one << sun_info.depth;\n if (sun_info.maptype == RMT_EQUAL_RGB)\n image->colors=sun_info.maplength/3;\n if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n }\n switch (sun_info.maptype)\n {\n case RMT_NONE:\n break;\n case RMT_EQUAL_RGB:\n {\n unsigned char\n *sun_colormap;",
" /*\n Read SUN raster colormap.\n */\n sun_colormap=(unsigned char *) AcquireQuantumMemory(image->colors,\n sizeof(*sun_colormap));\n if (sun_colormap == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n count=ReadBlob(image,image->colors,sun_colormap);\n if (count != (ssize_t) image->colors)\n ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n for (i=0; i < (ssize_t) image->colors; i++)\n image->colormap[i].red=(MagickRealType) ScaleCharToQuantum(\n sun_colormap[i]);\n count=ReadBlob(image,image->colors,sun_colormap);\n if (count != (ssize_t) image->colors)\n ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n for (i=0; i < (ssize_t) image->colors; i++)\n image->colormap[i].green=(MagickRealType) ScaleCharToQuantum(\n sun_colormap[i]);\n count=ReadBlob(image,image->colors,sun_colormap);\n if (count != (ssize_t) image->colors)\n ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n for (i=0; i < (ssize_t) image->colors; i++)\n image->colormap[i].blue=(MagickRealType) ScaleCharToQuantum(\n sun_colormap[i]);\n sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);\n break;\n }\n case RMT_RAW:\n {\n unsigned char\n *sun_colormap;",
" /*\n Read SUN raster colormap.\n */\n sun_colormap=(unsigned char *) AcquireQuantumMemory(sun_info.maplength,\n sizeof(*sun_colormap));\n if (sun_colormap == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n count=ReadBlob(image,sun_info.maplength,sun_colormap);\n if (count != (ssize_t) sun_info.maplength)\n ThrowReaderException(CorruptImageError,\"UnexpectedEndOfFile\");\n sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);\n break;\n }\n default:\n ThrowReaderException(CoderError,\"ColormapTypeNotSupported\");\n }\n image->alpha_trait=sun_info.depth == 32 ? BlendPixelTrait :\n UndefinedPixelTrait;\n image->columns=sun_info.width;\n image->rows=sun_info.height;\n if (image_info->ping != MagickFalse)\n {\n (void) CloseBlob(image);\n return(GetFirstImageInList(image));\n }\n status=SetImageExtent(image,image->columns,image->rows,exception);\n if (status == MagickFalse)\n return(DestroyImageList(image));\n if ((sun_info.length*sizeof(*sun_data))/sizeof(*sun_data) !=\n sun_info.length || !sun_info.length)",
" ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");",
" number_pixels=(MagickSizeType) image->columns*image->rows;\n if ((sun_info.type != RT_ENCODED) && \n ((number_pixels*sun_info.depth) > (8*sun_info.length)))\n ThrowReaderException(CorruptImageError,\"ImproperImageHeader\");\n bytes_per_line=sun_info.width*sun_info.depth;\n sun_data=(unsigned char *) AcquireQuantumMemory((size_t) MagickMax(\n sun_info.length,bytes_per_line*sun_info.width),sizeof(*sun_data));\n if (sun_data == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n count=(ssize_t) ReadBlob(image,sun_info.length,sun_data);\n if (count != (ssize_t) sun_info.length)\n ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n height=sun_info.height;\n if ((height == 0) || (sun_info.width == 0) || (sun_info.depth == 0) ||\n ((bytes_per_line/sun_info.depth) != sun_info.width))",
" ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");",
" bytes_per_line+=15;\n bytes_per_line<<=1;\n if ((bytes_per_line >> 1) != (sun_info.width*sun_info.depth+15))",
" ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");",
" bytes_per_line>>=4;\n sun_pixels=(unsigned char *) AcquireQuantumMemory(height,\n bytes_per_line*sizeof(*sun_pixels));\n if (sun_pixels == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n if (sun_info.type == RT_ENCODED)\n (void) DecodeImage(sun_data,sun_info.length,sun_pixels,bytes_per_line*\n height);",
" else\n {\n if (sun_info.length > (height*bytes_per_line))\n ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n (void) CopyMagickMemory(sun_pixels,sun_data,sun_info.length);\n }",
" sun_data=(unsigned char *) RelinquishMagickMemory(sun_data);\n /*\n Convert SUN raster image to pixel packets.\n */\n p=sun_pixels;\n if (sun_info.depth == 1)\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n if (q == (Quantum *) NULL)\n break;\n for (x=0; x < ((ssize_t) image->columns-7); x+=8)\n {\n for (bit=7; bit >= 0; bit--)\n {\n SetPixelIndex(image,(Quantum) ((*p) & (0x01 << bit) ? 0x00 : 0x01),\n q);\n q+=GetPixelChannels(image);\n }\n p++;\n }\n if ((image->columns % 8) != 0)\n {\n for (bit=7; bit >= (int) (8-(image->columns % 8)); bit--)\n {\n SetPixelIndex(image,(Quantum) ((*p) & (0x01 << bit) ? 0x00 :\n 0x01),q);\n q+=GetPixelChannels(image);\n }\n p++;\n }\n if ((((image->columns/8)+(image->columns % 8 ? 1 : 0)) % 2) != 0)\n p++;\n if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n if (image->previous == (Image *) NULL)\n {\n status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n image->rows);\n if (status == MagickFalse)\n break;\n }\n }\n else\n if (image->storage_class == PseudoClass)\n {\n if (bytes_per_line == 0)\n bytes_per_line=image->columns;\n length=image->rows*(image->columns+image->columns % 2);\n if (((sun_info.type == RT_ENCODED) &&\n (length > (bytes_per_line*image->rows))) ||\n ((sun_info.type != RT_ENCODED) && (length > sun_info.length)))\n ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n if (q == (Quantum *) NULL)\n break;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n SetPixelIndex(image,*p++,q);\n q+=GetPixelChannels(image);\n }\n if ((image->columns % 2) != 0)\n p++;\n if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n if (image->previous == (Image *) NULL)\n {\n status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n image->rows);\n if (status == MagickFalse)\n break;\n }\n }\n }\n else\n {\n size_t\n bytes_per_pixel;",
" bytes_per_pixel=3;\n if (image->alpha_trait != UndefinedPixelTrait)\n bytes_per_pixel++;\n if (bytes_per_line == 0)\n bytes_per_line=bytes_per_pixel*image->columns;\n length=image->rows*(bytes_per_line+bytes_per_line % 2);\n if (((sun_info.type == RT_ENCODED) &&\n (length > (bytes_per_line*image->rows))) ||\n ((sun_info.type != RT_ENCODED) && (length > sun_info.length)))\n ThrowReaderException(CorruptImageError,\"UnableToReadImageData\");\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n if (q == (Quantum *) NULL)\n break;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (image->alpha_trait != UndefinedPixelTrait)\n SetPixelAlpha(image,ScaleCharToQuantum(*p++),q);\n if (sun_info.type == RT_STANDARD)\n {\n SetPixelBlue(image,ScaleCharToQuantum(*p++),q);\n SetPixelGreen(image,ScaleCharToQuantum(*p++),q);\n SetPixelRed(image,ScaleCharToQuantum(*p++),q);\n }\n else\n {\n SetPixelRed(image,ScaleCharToQuantum(*p++),q);\n SetPixelGreen(image,ScaleCharToQuantum(*p++),q);\n SetPixelBlue(image,ScaleCharToQuantum(*p++),q);\n }\n if (image->colors != 0)\n {\n SetPixelRed(image,ClampToQuantum(image->colormap[(ssize_t)\n GetPixelRed(image,q)].red),q);\n SetPixelGreen(image,ClampToQuantum(image->colormap[(ssize_t)\n GetPixelGreen(image,q)].green),q);\n SetPixelBlue(image,ClampToQuantum(image->colormap[(ssize_t)\n GetPixelBlue(image,q)].blue),q);\n }\n q+=GetPixelChannels(image);\n }\n if (((bytes_per_pixel*image->columns) % 2) != 0)\n p++;\n if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n if (image->previous == (Image *) NULL)\n {\n status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n image->rows);\n if (status == MagickFalse)\n break;\n }\n }\n }\n if (image->storage_class == PseudoClass)\n (void) SyncImage(image,exception);\n sun_pixels=(unsigned char *) RelinquishMagickMemory(sun_pixels);\n if (EOFBlob(image) != MagickFalse)\n {\n ThrowFileException(exception,CorruptImageError,\"UnexpectedEndOfFile\",\n image->filename);\n break;\n }\n /*\n Proceed to next image.\n */\n if (image_info->number_scenes != 0)\n if (image->scene >= (image_info->scene+image_info->number_scenes-1))\n break;\n sun_info.magic=ReadBlobMSBLong(image);\n if (sun_info.magic == 0x59a66a95)\n {\n /*\n Allocate next image structure.\n */\n AcquireNextImage(image_info,image,exception);\n if (GetNextImageInList(image) == (Image *) NULL)\n {\n image=DestroyImageList(image);\n return((Image *) NULL);\n }\n image=SyncNextImageInList(image);\n status=SetImageProgress(image,LoadImagesTag,TellBlob(image),\n GetBlobSize(image));\n if (status == MagickFalse)\n break;\n }\n } while (sun_info.magic == 0x59a66a95);\n (void) CloseBlob(image);\n return(GetFirstImageInList(image));\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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 6285,
"char_start": 6284,
"chars": "I"
},
{
"char_end": 6287,
"char_start": 6286,
"chars": "p"
},
{
"char_end": 6294,
"char_start": 6289,
"chars": "perIm"
},
{
"char_end": 6298,
"char_start": 6295,
"chars": "geH"
},
{
"char_end": 6300,
"char_start": 6299,
"chars": "a"
},
{
"char_end": 6303,
"char_start": 6301,
"chars": "er"
},
{
"char_end": 7246,
"char_start": 7245,
"chars": "I"
},
{
"char_end": 7248,
"char_start": 7247,
"chars": "p"
},
{
"char_end": 7255,
"char_start": 7250,
"chars": "perIm"
},
{
"char_end": 7259,
"char_start": 7256,
"chars": "geH"
},
{
"char_end": 7261,
"char_start": 7260,
"chars": "a"
},
{
"char_end": 7264,
"char_start": 7262,
"chars": "er"
},
{
"char_end": 7433,
"char_start": 7432,
"chars": "I"
},
{
"char_end": 7435,
"char_start": 7434,
"chars": "p"
},
{
"char_end": 7442,
"char_start": 7437,
"chars": "perIm"
},
{
"char_end": 7446,
"char_start": 7443,
"chars": "geH"
},
{
"char_end": 7448,
"char_start": 7447,
"chars": "a"
},
{
"char_end": 7451,
"char_start": 7449,
"chars": "er"
},
{
"char_end": 8057,
"char_start": 7833,
"chars": "\n else\n {\n if (sun_info.length > (height*bytes_per_line))\n ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n (void) CopyMagickMemory(sun_pixels,sun_data,sun_info.length);\n }"
}
],
"deleted": [
{
"char_end": 6286,
"char_start": 6284,
"chars": "Me"
},
{
"char_end": 6295,
"char_start": 6289,
"chars": "yAlloc"
},
{
"char_end": 6304,
"char_start": 6296,
"chars": "tionFail"
},
{
"char_end": 7250,
"char_start": 7248,
"chars": "Me"
},
{
"char_end": 7259,
"char_start": 7253,
"chars": "yAlloc"
},
{
"char_end": 7268,
"char_start": 7260,
"chars": "tionFail"
},
{
"char_end": 7440,
"char_start": 7438,
"chars": "Me"
},
{
"char_end": 7449,
"char_start": 7443,
"chars": "yAlloc"
},
{
"char_end": 7458,
"char_start": 7450,
"chars": "tionFail"
},
{
"char_end": 7826,
"char_start": 7826,
"chars": ""
}
]
},
"commit_link": "github.com/ImageMagick/ImageMagick/commit/6b4aff0f117b978502ee5bcd6e753c17aec5a961",
"file_name": "coders/sun.c",
"func_name": "ReadSUNImage",
"line_changes": {
"added": [
{
"char_end": 6307,
"char_start": 6237,
"line": " ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n",
"line_no": 201
},
{
"char_end": 7268,
"char_start": 7198,
"line": " ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n",
"line_no": 217
},
{
"char_end": 7455,
"char_start": 7385,
"line": " ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n",
"line_no": 221
},
{
"char_end": 7843,
"char_start": 7834,
"line": " else\n",
"line_no": 230
},
{
"char_end": 7851,
"char_start": 7843,
"line": " {\n",
"line_no": 231
},
{
"char_end": 7906,
"char_start": 7851,
"line": " if (sun_info.length > (height*bytes_per_line))\n",
"line_no": 232
},
{
"char_end": 7980,
"char_start": 7906,
"line": " ThrowReaderException(ResourceLimitError,\"ImproperImageHeader\");\n",
"line_no": 233
},
{
"char_end": 8050,
"char_start": 7980,
"line": " (void) CopyMagickMemory(sun_pixels,sun_data,sun_info.length);\n",
"line_no": 234
},
{
"char_end": 8058,
"char_start": 8050,
"line": " }\n",
"line_no": 235
}
],
"deleted": [
{
"char_end": 6310,
"char_start": 6237,
"line": " ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n",
"line_no": 201
},
{
"char_end": 7274,
"char_start": 7201,
"line": " ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n",
"line_no": 217
},
{
"char_end": 7464,
"char_start": 7391,
"line": " ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n",
"line_no": 221
}
]
},
"vul_type": "cwe-125"
} | 394 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"*/\nstatic void php_wddx_push_element(void *user_data, const XML_Char *name, const XML_Char **atts)\n{\n\tst_entry ent;\n\twddx_stack *stack = (wddx_stack *)user_data;",
"\tif (!strcmp(name, EL_PACKET)) {\n\t\tint i;",
"\t\tif (atts) for (i=0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], EL_VERSION)) {\n\t\t\t\t/* nothing for now */\n\t\t\t}\n\t\t}\n\t} else if (!strcmp(name, EL_STRING)) {\n\t\tent.type = ST_STRING;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\tZ_TYPE_P(ent.data) = IS_STRING;\n\t\tZ_STRVAL_P(ent.data) = STR_EMPTY_ALLOC();\n\t\tZ_STRLEN_P(ent.data) = 0;\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_BINARY)) {\n\t\tent.type = ST_BINARY;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\tZ_TYPE_P(ent.data) = IS_STRING;\n\t\tZ_STRVAL_P(ent.data) = STR_EMPTY_ALLOC();\n\t\tZ_STRLEN_P(ent.data) = 0;\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_CHAR)) {\n\t\tint i;",
"\t\tif (atts) for (i = 0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], EL_CHAR_CODE) && atts[i+1] && atts[i+1][0]) {\n\t\t\t\tchar tmp_buf[2];",
"\t\t\t\tsnprintf(tmp_buf, sizeof(tmp_buf), \"%c\", (char)strtol(atts[i+1], NULL, 16));\n\t\t\t\tphp_wddx_process_data(user_data, tmp_buf, strlen(tmp_buf));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else if (!strcmp(name, EL_NUMBER)) {\n\t\tent.type = ST_NUMBER;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\tZ_TYPE_P(ent.data) = IS_LONG;\n\t\tZ_LVAL_P(ent.data) = 0;\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_BOOLEAN)) {\n\t\tint i;",
"\t\tif (atts) for (i = 0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], EL_VALUE) && atts[i+1] && atts[i+1][0]) {\n\t\t\t\tent.type = ST_BOOLEAN;\n\t\t\t\tSET_STACK_VARNAME;",
"\t\t\t\tALLOC_ZVAL(ent.data);\n\t\t\t\tINIT_PZVAL(ent.data);\n\t\t\t\tZ_TYPE_P(ent.data) = IS_BOOL;\n\t\t\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t\t\t\tphp_wddx_process_data(user_data, atts[i+1], strlen(atts[i+1]));\n\t\t\t\tbreak;\n\t\t\t}",
"",
"\t\t}\n\t} else if (!strcmp(name, EL_NULL)) {\n\t\tent.type = ST_NULL;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\tZVAL_NULL(ent.data);",
"\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_ARRAY)) {\n\t\tent.type = ST_ARRAY;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tarray_init(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_STRUCT)) {\n\t\tent.type = ST_STRUCT;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tarray_init(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_VAR)) {\n\t\tint i;",
"\t\tif (atts) for (i = 0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], EL_NAME) && atts[i+1] && atts[i+1][0]) {\n\t\t\t\tif (stack->varname) efree(stack->varname);\n\t\t\t\tstack->varname = estrdup(atts[i+1]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else if (!strcmp(name, EL_RECORDSET)) {\n\t\tint i;",
"\t\tent.type = ST_RECORDSET;\n\t\tSET_STACK_VARNAME;\n\t\tMAKE_STD_ZVAL(ent.data);\n\t\tarray_init(ent.data);",
"\t\tif (atts) for (i = 0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], \"fieldNames\") && atts[i+1] && atts[i+1][0]) {\n\t\t\t\tzval *tmp;\n\t\t\t\tchar *key;\n\t\t\t\tchar *p1, *p2, *endp;",
"\t\t\t\ti++;\n\t\t\t\tendp = (char *)atts[i] + strlen(atts[i]);\n\t\t\t\tp1 = (char *)atts[i];\n\t\t\t\twhile ((p2 = php_memnstr(p1, \",\", sizeof(\",\")-1, endp)) != NULL) {\n\t\t\t\t\tkey = estrndup(p1, p2 - p1);\n\t\t\t\t\tMAKE_STD_ZVAL(tmp);\n\t\t\t\t\tarray_init(tmp);\n\t\t\t\t\tadd_assoc_zval_ex(ent.data, key, p2 - p1 + 1, tmp);\n\t\t\t\t\tp1 = p2 + sizeof(\",\")-1;\n\t\t\t\t\tefree(key);\n\t\t\t\t}",
"\t\t\t\tif (p1 <= endp) {\n\t\t\t\t\tMAKE_STD_ZVAL(tmp);\n\t\t\t\t\tarray_init(tmp);\n\t\t\t\t\tadd_assoc_zval_ex(ent.data, p1, endp - p1 + 1, tmp);\n\t\t\t\t}",
"\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_FIELD)) {\n\t\tint i;\n\t\tst_entry ent;",
"\t\tent.type = ST_FIELD;\n\t\tent.varname = NULL;\n\t\tent.data = NULL;",
"\t\tif (atts) for (i = 0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], EL_NAME) && atts[i+1] && atts[i+1][0]) {\n\t\t\t\tst_entry *recordset;\n\t\t\t\tzval **field;",
"\t\t\t\tif (wddx_stack_top(stack, (void**)&recordset) == SUCCESS &&\n\t\t\t\t\trecordset->type == ST_RECORDSET &&\n\t\t\t\t\tzend_hash_find(Z_ARRVAL_P(recordset->data), (char*)atts[i+1], strlen(atts[i+1])+1, (void**)&field) == SUCCESS) {\n\t\t\t\t\tent.data = *field;\n\t\t\t\t}",
"\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_DATETIME)) {\n\t\tent.type = ST_DATETIME;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\tZ_TYPE_P(ent.data) = IS_LONG;\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t}"
] | [
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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 2125,
"char_start": 1975,
"chars": " else {\n\t\t\tent.type = ST_BOOLEAN;\n\t\t\tSET_STACK_VARNAME;\n\t\t\tZVAL_FALSE(&ent.data);\n\t\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t\t}"
}
],
"deleted": []
},
"commit_link": "github.com/php/php-src/commit/66fd44209d5ffcb9b3d1bc1b9fd8e35b485040c0",
"file_name": "ext/wddx/wddx.c",
"func_name": "php_wddx_push_element",
"line_changes": {
"added": [
{
"char_end": 1983,
"char_start": 1972,
"line": "\t\t} else {\n",
"line_no": 71
},
{
"char_end": 2009,
"char_start": 1983,
"line": "\t\t\tent.type = ST_BOOLEAN;\n",
"line_no": 72
},
{
"char_end": 2031,
"char_start": 2009,
"line": "\t\t\tSET_STACK_VARNAME;\n",
"line_no": 73
},
{
"char_end": 2057,
"char_start": 2031,
"line": "\t\t\tZVAL_FALSE(&ent.data);\n",
"line_no": 74
},
{
"char_end": 2122,
"char_start": 2057,
"line": "\t\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n",
"line_no": 75
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 395 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"*/\nstatic void php_wddx_push_element(void *user_data, const XML_Char *name, const XML_Char **atts)\n{\n\tst_entry ent;\n\twddx_stack *stack = (wddx_stack *)user_data;",
"\tif (!strcmp(name, EL_PACKET)) {\n\t\tint i;",
"\t\tif (atts) for (i=0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], EL_VERSION)) {\n\t\t\t\t/* nothing for now */\n\t\t\t}\n\t\t}\n\t} else if (!strcmp(name, EL_STRING)) {\n\t\tent.type = ST_STRING;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\tZ_TYPE_P(ent.data) = IS_STRING;\n\t\tZ_STRVAL_P(ent.data) = STR_EMPTY_ALLOC();\n\t\tZ_STRLEN_P(ent.data) = 0;\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_BINARY)) {\n\t\tent.type = ST_BINARY;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\tZ_TYPE_P(ent.data) = IS_STRING;\n\t\tZ_STRVAL_P(ent.data) = STR_EMPTY_ALLOC();\n\t\tZ_STRLEN_P(ent.data) = 0;\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_CHAR)) {\n\t\tint i;",
"\t\tif (atts) for (i = 0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], EL_CHAR_CODE) && atts[i+1] && atts[i+1][0]) {\n\t\t\t\tchar tmp_buf[2];",
"\t\t\t\tsnprintf(tmp_buf, sizeof(tmp_buf), \"%c\", (char)strtol(atts[i+1], NULL, 16));\n\t\t\t\tphp_wddx_process_data(user_data, tmp_buf, strlen(tmp_buf));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else if (!strcmp(name, EL_NUMBER)) {\n\t\tent.type = ST_NUMBER;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\tZ_TYPE_P(ent.data) = IS_LONG;\n\t\tZ_LVAL_P(ent.data) = 0;\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_BOOLEAN)) {\n\t\tint i;",
"\t\tif (atts) for (i = 0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], EL_VALUE) && atts[i+1] && atts[i+1][0]) {\n\t\t\t\tent.type = ST_BOOLEAN;\n\t\t\t\tSET_STACK_VARNAME;",
"\t\t\t\tALLOC_ZVAL(ent.data);\n\t\t\t\tINIT_PZVAL(ent.data);\n\t\t\t\tZ_TYPE_P(ent.data) = IS_BOOL;\n\t\t\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t\t\t\tphp_wddx_process_data(user_data, atts[i+1], strlen(atts[i+1]));\n\t\t\t\tbreak;\n\t\t\t}",
"\t\t} else {\n\t\t\tent.type = ST_BOOLEAN;\n\t\t\tSET_STACK_VARNAME;\n\t\t\tZVAL_FALSE(&ent.data);\n\t\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));",
"\t\t}\n\t} else if (!strcmp(name, EL_NULL)) {\n\t\tent.type = ST_NULL;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\tZVAL_NULL(ent.data);",
"\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_ARRAY)) {\n\t\tent.type = ST_ARRAY;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tarray_init(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_STRUCT)) {\n\t\tent.type = ST_STRUCT;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tarray_init(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_VAR)) {\n\t\tint i;",
"\t\tif (atts) for (i = 0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], EL_NAME) && atts[i+1] && atts[i+1][0]) {\n\t\t\t\tif (stack->varname) efree(stack->varname);\n\t\t\t\tstack->varname = estrdup(atts[i+1]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else if (!strcmp(name, EL_RECORDSET)) {\n\t\tint i;",
"\t\tent.type = ST_RECORDSET;\n\t\tSET_STACK_VARNAME;\n\t\tMAKE_STD_ZVAL(ent.data);\n\t\tarray_init(ent.data);",
"\t\tif (atts) for (i = 0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], \"fieldNames\") && atts[i+1] && atts[i+1][0]) {\n\t\t\t\tzval *tmp;\n\t\t\t\tchar *key;\n\t\t\t\tchar *p1, *p2, *endp;",
"\t\t\t\ti++;\n\t\t\t\tendp = (char *)atts[i] + strlen(atts[i]);\n\t\t\t\tp1 = (char *)atts[i];\n\t\t\t\twhile ((p2 = php_memnstr(p1, \",\", sizeof(\",\")-1, endp)) != NULL) {\n\t\t\t\t\tkey = estrndup(p1, p2 - p1);\n\t\t\t\t\tMAKE_STD_ZVAL(tmp);\n\t\t\t\t\tarray_init(tmp);\n\t\t\t\t\tadd_assoc_zval_ex(ent.data, key, p2 - p1 + 1, tmp);\n\t\t\t\t\tp1 = p2 + sizeof(\",\")-1;\n\t\t\t\t\tefree(key);\n\t\t\t\t}",
"\t\t\t\tif (p1 <= endp) {\n\t\t\t\t\tMAKE_STD_ZVAL(tmp);\n\t\t\t\t\tarray_init(tmp);\n\t\t\t\t\tadd_assoc_zval_ex(ent.data, p1, endp - p1 + 1, tmp);\n\t\t\t\t}",
"\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_FIELD)) {\n\t\tint i;\n\t\tst_entry ent;",
"\t\tent.type = ST_FIELD;\n\t\tent.varname = NULL;\n\t\tent.data = NULL;",
"\t\tif (atts) for (i = 0; atts[i]; i++) {\n\t\t\tif (!strcmp(atts[i], EL_NAME) && atts[i+1] && atts[i+1][0]) {\n\t\t\t\tst_entry *recordset;\n\t\t\t\tzval **field;",
"\t\t\t\tif (wddx_stack_top(stack, (void**)&recordset) == SUCCESS &&\n\t\t\t\t\trecordset->type == ST_RECORDSET &&\n\t\t\t\t\tzend_hash_find(Z_ARRVAL_P(recordset->data), (char*)atts[i+1], strlen(atts[i+1])+1, (void**)&field) == SUCCESS) {\n\t\t\t\t\tent.data = *field;\n\t\t\t\t}",
"\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t} else if (!strcmp(name, EL_DATETIME)) {\n\t\tent.type = ST_DATETIME;\n\t\tSET_STACK_VARNAME;",
"\t\tALLOC_ZVAL(ent.data);\n\t\tINIT_PZVAL(ent.data);\n\t\tZ_TYPE_P(ent.data) = IS_LONG;\n\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 2125,
"char_start": 1975,
"chars": " else {\n\t\t\tent.type = ST_BOOLEAN;\n\t\t\tSET_STACK_VARNAME;\n\t\t\tZVAL_FALSE(&ent.data);\n\t\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n\t\t}"
}
],
"deleted": []
},
"commit_link": "github.com/php/php-src/commit/66fd44209d5ffcb9b3d1bc1b9fd8e35b485040c0",
"file_name": "ext/wddx/wddx.c",
"func_name": "php_wddx_push_element",
"line_changes": {
"added": [
{
"char_end": 1983,
"char_start": 1972,
"line": "\t\t} else {\n",
"line_no": 71
},
{
"char_end": 2009,
"char_start": 1983,
"line": "\t\t\tent.type = ST_BOOLEAN;\n",
"line_no": 72
},
{
"char_end": 2031,
"char_start": 2009,
"line": "\t\t\tSET_STACK_VARNAME;\n",
"line_no": 73
},
{
"char_end": 2057,
"char_start": 2031,
"line": "\t\t\tZVAL_FALSE(&ent.data);\n",
"line_no": 74
},
{
"char_end": 2122,
"char_start": 2057,
"line": "\t\t\twddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));\n",
"line_no": 75
}
],
"deleted": []
},
"vul_type": "cwe-125"
} | 395 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)\n{\n\tstruct smb_rqst rqst;\n\tstruct smb2_negotiate_req *req;\n\tstruct smb2_negotiate_rsp *rsp;\n\tstruct kvec iov[1];\n\tstruct kvec rsp_iov;\n\tint rc = 0;\n\tint resp_buftype;\n\tstruct TCP_Server_Info *server = ses->server;\n\tint blob_offset, blob_length;\n\tchar *security_blob;\n\tint flags = CIFS_NEG_OP;\n\tunsigned int total_len;",
"\tcifs_dbg(FYI, \"Negotiate protocol\\n\");",
"\tif (!server) {\n\t\tWARN(1, \"%s: server is NULL!\\n\", __func__);\n\t\treturn -EIO;\n\t}",
"\trc = smb2_plain_req_init(SMB2_NEGOTIATE, NULL, (void **) &req, &total_len);\n\tif (rc)\n\t\treturn rc;",
"\treq->sync_hdr.SessionId = 0;",
"\tmemset(server->preauth_sha_hash, 0, SMB2_PREAUTH_HASH_SIZE);\n\tmemset(ses->preauth_sha_hash, 0, SMB2_PREAUTH_HASH_SIZE);",
"\tif (strcmp(ses->server->vals->version_string,\n\t\t SMB3ANY_VERSION_STRING) == 0) {\n\t\treq->Dialects[0] = cpu_to_le16(SMB30_PROT_ID);\n\t\treq->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);\n\t\treq->DialectCount = cpu_to_le16(2);\n\t\ttotal_len += 4;\n\t} else if (strcmp(ses->server->vals->version_string,\n\t\t SMBDEFAULT_VERSION_STRING) == 0) {\n\t\treq->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);\n\t\treq->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);\n\t\treq->Dialects[2] = cpu_to_le16(SMB302_PROT_ID);\n\t\treq->Dialects[3] = cpu_to_le16(SMB311_PROT_ID);\n\t\treq->DialectCount = cpu_to_le16(4);\n\t\ttotal_len += 8;\n\t} else {\n\t\t/* otherwise send specific dialect */\n\t\treq->Dialects[0] = cpu_to_le16(ses->server->vals->protocol_id);\n\t\treq->DialectCount = cpu_to_le16(1);\n\t\ttotal_len += 2;\n\t}",
"\t/* only one of SMB2 signing flags may be set in SMB2 request */\n\tif (ses->sign)\n\t\treq->SecurityMode = cpu_to_le16(SMB2_NEGOTIATE_SIGNING_REQUIRED);\n\telse if (global_secflags & CIFSSEC_MAY_SIGN)\n\t\treq->SecurityMode = cpu_to_le16(SMB2_NEGOTIATE_SIGNING_ENABLED);\n\telse\n\t\treq->SecurityMode = 0;",
"\treq->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities);",
"\t/* ClientGUID must be zero for SMB2.02 dialect */\n\tif (ses->server->vals->protocol_id == SMB20_PROT_ID)\n\t\tmemset(req->ClientGUID, 0, SMB2_CLIENT_GUID_SIZE);\n\telse {\n\t\tmemcpy(req->ClientGUID, server->client_guid,\n\t\t\tSMB2_CLIENT_GUID_SIZE);\n\t\tif ((ses->server->vals->protocol_id == SMB311_PROT_ID) ||\n\t\t (strcmp(ses->server->vals->version_string,\n\t\t SMBDEFAULT_VERSION_STRING) == 0))\n\t\t\tassemble_neg_contexts(req, &total_len);\n\t}\n\tiov[0].iov_base = (char *)req;\n\tiov[0].iov_len = total_len;",
"\tmemset(&rqst, 0, sizeof(struct smb_rqst));\n\trqst.rq_iov = iov;\n\trqst.rq_nvec = 1;",
"\trc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);\n\tcifs_small_buf_release(req);\n\trsp = (struct smb2_negotiate_rsp *)rsp_iov.iov_base;\n\t/*\n\t * No tcon so can't do\n\t * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]);\n\t */\n\tif (rc == -EOPNOTSUPP) {\n\t\tcifs_dbg(VFS, \"Dialect not supported by server. Consider \"\n\t\t\t\"specifying vers=1.0 or vers=2.0 on mount for accessing\"\n\t\t\t\" older servers\\n\");\n\t\tgoto neg_exit;\n\t} else if (rc != 0)\n\t\tgoto neg_exit;",
"\tif (strcmp(ses->server->vals->version_string,\n\t\t SMB3ANY_VERSION_STRING) == 0) {\n\t\tif (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {\n\t\t\tcifs_dbg(VFS,\n\t\t\t\t\"SMB2 dialect returned but not requested\\n\");\n\t\t\treturn -EIO;\n\t\t} else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {\n\t\t\tcifs_dbg(VFS,\n\t\t\t\t\"SMB2.1 dialect returned but not requested\\n\");\n\t\t\treturn -EIO;\n\t\t}\n\t} else if (strcmp(ses->server->vals->version_string,\n\t\t SMBDEFAULT_VERSION_STRING) == 0) {\n\t\tif (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {\n\t\t\tcifs_dbg(VFS,\n\t\t\t\t\"SMB2 dialect returned but not requested\\n\");\n\t\t\treturn -EIO;\n\t\t} else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {\n\t\t\t/* ops set to 3.0 by default for default so update */\n\t\t\tses->server->ops = &smb21_operations;",
"\t\t} else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID))",
"\t\t\tses->server->ops = &smb311_operations;",
"",
"\t} else if (le16_to_cpu(rsp->DialectRevision) !=\n\t\t\t\tses->server->vals->protocol_id) {\n\t\t/* if requested single dialect ensure returned dialect matched */\n\t\tcifs_dbg(VFS, \"Illegal 0x%x dialect returned: not requested\\n\",\n\t\t\tle16_to_cpu(rsp->DialectRevision));\n\t\treturn -EIO;\n\t}",
"\tcifs_dbg(FYI, \"mode 0x%x\\n\", rsp->SecurityMode);",
"\tif (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID))\n\t\tcifs_dbg(FYI, \"negotiated smb2.0 dialect\\n\");\n\telse if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID))\n\t\tcifs_dbg(FYI, \"negotiated smb2.1 dialect\\n\");\n\telse if (rsp->DialectRevision == cpu_to_le16(SMB30_PROT_ID))\n\t\tcifs_dbg(FYI, \"negotiated smb3.0 dialect\\n\");\n\telse if (rsp->DialectRevision == cpu_to_le16(SMB302_PROT_ID))\n\t\tcifs_dbg(FYI, \"negotiated smb3.02 dialect\\n\");\n\telse if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID))\n\t\tcifs_dbg(FYI, \"negotiated smb3.1.1 dialect\\n\");\n\telse {\n\t\tcifs_dbg(VFS, \"Illegal dialect returned by server 0x%x\\n\",\n\t\t\t le16_to_cpu(rsp->DialectRevision));\n\t\trc = -EIO;\n\t\tgoto neg_exit;\n\t}\n\tserver->dialect = le16_to_cpu(rsp->DialectRevision);",
"\t/*\n\t * Keep a copy of the hash after negprot. This hash will be\n\t * the starting hash value for all sessions made from this\n\t * server.\n\t */\n\tmemcpy(server->preauth_sha_hash, ses->preauth_sha_hash,\n\t SMB2_PREAUTH_HASH_SIZE);",
"\t/* SMB2 only has an extended negflavor */\n\tserver->negflavor = CIFS_NEGFLAVOR_EXTENDED;\n\t/* set it to the maximum buffer size value we can send with 1 credit */\n\tserver->maxBuf = min_t(unsigned int, le32_to_cpu(rsp->MaxTransactSize),\n\t\t\t SMB2_MAX_BUFFER_SIZE);\n\tserver->max_read = le32_to_cpu(rsp->MaxReadSize);\n\tserver->max_write = le32_to_cpu(rsp->MaxWriteSize);\n\tserver->sec_mode = le16_to_cpu(rsp->SecurityMode);\n\tif ((server->sec_mode & SMB2_SEC_MODE_FLAGS_ALL) != server->sec_mode)\n\t\tcifs_dbg(FYI, \"Server returned unexpected security mode 0x%x\\n\",\n\t\t\t\tserver->sec_mode);\n\tserver->capabilities = le32_to_cpu(rsp->Capabilities);\n\t/* Internal types */\n\tserver->capabilities |= SMB2_NT_FIND | SMB2_LARGE_FILES;",
"\tsecurity_blob = smb2_get_data_area_len(&blob_offset, &blob_length,\n\t\t\t\t\t (struct smb2_sync_hdr *)rsp);\n\t/*\n\t * See MS-SMB2 section 2.2.4: if no blob, client picks default which\n\t * for us will be\n\t *\tses->sectype = RawNTLMSSP;\n\t * but for time being this is our only auth choice so doesn't matter.\n\t * We just found a server which sets blob length to zero expecting raw.\n\t */\n\tif (blob_length == 0) {\n\t\tcifs_dbg(FYI, \"missing security blob on negprot\\n\");\n\t\tserver->sec_ntlmssp = true;\n\t}",
"\trc = cifs_enable_signing(server, ses->sign);\n\tif (rc)\n\t\tgoto neg_exit;\n\tif (blob_length) {\n\t\trc = decode_negTokenInit(security_blob, blob_length, server);\n\t\tif (rc == 1)\n\t\t\trc = 0;\n\t\telse if (rc == 0)\n\t\t\trc = -EIO;\n\t}",
"\tif (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) {\n\t\tif (rsp->NegotiateContextCount)\n\t\t\trc = smb311_decode_neg_context(rsp, server,\n\t\t\t\t\t\t rsp_iov.iov_len);\n\t\telse\n\t\t\tcifs_dbg(VFS, \"Missing expected negotiate contexts\\n\");\n\t}\nneg_exit:\n\tfree_rsp_buf(resp_buftype, rsp);\n\treturn rc;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 3773,
"char_start": 3735,
"chars": "\tses->server->vals = &smb21_values;\n\t\t"
},
{
"char_end": 3838,
"char_start": 3836,
"chars": " {"
},
{
"char_end": 3923,
"char_start": 3880,
"chars": "\n\t\t\tses->server->vals = &smb311_values;\n\t\t}"
}
],
"deleted": []
},
"commit_link": "github.com/torvalds/linux/commit/b57a55e2200ede754e4dc9cce4ba9402544b9365",
"file_name": "fs/cifs/smb2pdu.c",
"func_name": "SMB2_negotiate",
"line_changes": {
"added": [
{
"char_end": 3771,
"char_start": 3733,
"line": "\t\t\tses->server->vals = &smb21_values;\n",
"line_no": 116
},
{
"char_end": 3839,
"char_start": 3771,
"line": "\t\t} else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) {\n",
"line_no": 117
},
{
"char_end": 3920,
"char_start": 3881,
"line": "\t\t\tses->server->vals = &smb311_values;\n",
"line_no": 119
},
{
"char_end": 3924,
"char_start": 3920,
"line": "\t\t}\n",
"line_no": 120
}
],
"deleted": [
{
"char_end": 3799,
"char_start": 3733,
"line": "\t\t} else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID))\n",
"line_no": 116
}
]
},
"vul_type": "cwe-125"
} | 396 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)\n{\n\tstruct smb_rqst rqst;\n\tstruct smb2_negotiate_req *req;\n\tstruct smb2_negotiate_rsp *rsp;\n\tstruct kvec iov[1];\n\tstruct kvec rsp_iov;\n\tint rc = 0;\n\tint resp_buftype;\n\tstruct TCP_Server_Info *server = ses->server;\n\tint blob_offset, blob_length;\n\tchar *security_blob;\n\tint flags = CIFS_NEG_OP;\n\tunsigned int total_len;",
"\tcifs_dbg(FYI, \"Negotiate protocol\\n\");",
"\tif (!server) {\n\t\tWARN(1, \"%s: server is NULL!\\n\", __func__);\n\t\treturn -EIO;\n\t}",
"\trc = smb2_plain_req_init(SMB2_NEGOTIATE, NULL, (void **) &req, &total_len);\n\tif (rc)\n\t\treturn rc;",
"\treq->sync_hdr.SessionId = 0;",
"\tmemset(server->preauth_sha_hash, 0, SMB2_PREAUTH_HASH_SIZE);\n\tmemset(ses->preauth_sha_hash, 0, SMB2_PREAUTH_HASH_SIZE);",
"\tif (strcmp(ses->server->vals->version_string,\n\t\t SMB3ANY_VERSION_STRING) == 0) {\n\t\treq->Dialects[0] = cpu_to_le16(SMB30_PROT_ID);\n\t\treq->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);\n\t\treq->DialectCount = cpu_to_le16(2);\n\t\ttotal_len += 4;\n\t} else if (strcmp(ses->server->vals->version_string,\n\t\t SMBDEFAULT_VERSION_STRING) == 0) {\n\t\treq->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);\n\t\treq->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);\n\t\treq->Dialects[2] = cpu_to_le16(SMB302_PROT_ID);\n\t\treq->Dialects[3] = cpu_to_le16(SMB311_PROT_ID);\n\t\treq->DialectCount = cpu_to_le16(4);\n\t\ttotal_len += 8;\n\t} else {\n\t\t/* otherwise send specific dialect */\n\t\treq->Dialects[0] = cpu_to_le16(ses->server->vals->protocol_id);\n\t\treq->DialectCount = cpu_to_le16(1);\n\t\ttotal_len += 2;\n\t}",
"\t/* only one of SMB2 signing flags may be set in SMB2 request */\n\tif (ses->sign)\n\t\treq->SecurityMode = cpu_to_le16(SMB2_NEGOTIATE_SIGNING_REQUIRED);\n\telse if (global_secflags & CIFSSEC_MAY_SIGN)\n\t\treq->SecurityMode = cpu_to_le16(SMB2_NEGOTIATE_SIGNING_ENABLED);\n\telse\n\t\treq->SecurityMode = 0;",
"\treq->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities);",
"\t/* ClientGUID must be zero for SMB2.02 dialect */\n\tif (ses->server->vals->protocol_id == SMB20_PROT_ID)\n\t\tmemset(req->ClientGUID, 0, SMB2_CLIENT_GUID_SIZE);\n\telse {\n\t\tmemcpy(req->ClientGUID, server->client_guid,\n\t\t\tSMB2_CLIENT_GUID_SIZE);\n\t\tif ((ses->server->vals->protocol_id == SMB311_PROT_ID) ||\n\t\t (strcmp(ses->server->vals->version_string,\n\t\t SMBDEFAULT_VERSION_STRING) == 0))\n\t\t\tassemble_neg_contexts(req, &total_len);\n\t}\n\tiov[0].iov_base = (char *)req;\n\tiov[0].iov_len = total_len;",
"\tmemset(&rqst, 0, sizeof(struct smb_rqst));\n\trqst.rq_iov = iov;\n\trqst.rq_nvec = 1;",
"\trc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);\n\tcifs_small_buf_release(req);\n\trsp = (struct smb2_negotiate_rsp *)rsp_iov.iov_base;\n\t/*\n\t * No tcon so can't do\n\t * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]);\n\t */\n\tif (rc == -EOPNOTSUPP) {\n\t\tcifs_dbg(VFS, \"Dialect not supported by server. Consider \"\n\t\t\t\"specifying vers=1.0 or vers=2.0 on mount for accessing\"\n\t\t\t\" older servers\\n\");\n\t\tgoto neg_exit;\n\t} else if (rc != 0)\n\t\tgoto neg_exit;",
"\tif (strcmp(ses->server->vals->version_string,\n\t\t SMB3ANY_VERSION_STRING) == 0) {\n\t\tif (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {\n\t\t\tcifs_dbg(VFS,\n\t\t\t\t\"SMB2 dialect returned but not requested\\n\");\n\t\t\treturn -EIO;\n\t\t} else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {\n\t\t\tcifs_dbg(VFS,\n\t\t\t\t\"SMB2.1 dialect returned but not requested\\n\");\n\t\t\treturn -EIO;\n\t\t}\n\t} else if (strcmp(ses->server->vals->version_string,\n\t\t SMBDEFAULT_VERSION_STRING) == 0) {\n\t\tif (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {\n\t\t\tcifs_dbg(VFS,\n\t\t\t\t\"SMB2 dialect returned but not requested\\n\");\n\t\t\treturn -EIO;\n\t\t} else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {\n\t\t\t/* ops set to 3.0 by default for default so update */\n\t\t\tses->server->ops = &smb21_operations;",
"\t\t\tses->server->vals = &smb21_values;\n\t\t} else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) {",
"\t\t\tses->server->ops = &smb311_operations;",
"\t\t\tses->server->vals = &smb311_values;\n\t\t}",
"\t} else if (le16_to_cpu(rsp->DialectRevision) !=\n\t\t\t\tses->server->vals->protocol_id) {\n\t\t/* if requested single dialect ensure returned dialect matched */\n\t\tcifs_dbg(VFS, \"Illegal 0x%x dialect returned: not requested\\n\",\n\t\t\tle16_to_cpu(rsp->DialectRevision));\n\t\treturn -EIO;\n\t}",
"\tcifs_dbg(FYI, \"mode 0x%x\\n\", rsp->SecurityMode);",
"\tif (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID))\n\t\tcifs_dbg(FYI, \"negotiated smb2.0 dialect\\n\");\n\telse if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID))\n\t\tcifs_dbg(FYI, \"negotiated smb2.1 dialect\\n\");\n\telse if (rsp->DialectRevision == cpu_to_le16(SMB30_PROT_ID))\n\t\tcifs_dbg(FYI, \"negotiated smb3.0 dialect\\n\");\n\telse if (rsp->DialectRevision == cpu_to_le16(SMB302_PROT_ID))\n\t\tcifs_dbg(FYI, \"negotiated smb3.02 dialect\\n\");\n\telse if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID))\n\t\tcifs_dbg(FYI, \"negotiated smb3.1.1 dialect\\n\");\n\telse {\n\t\tcifs_dbg(VFS, \"Illegal dialect returned by server 0x%x\\n\",\n\t\t\t le16_to_cpu(rsp->DialectRevision));\n\t\trc = -EIO;\n\t\tgoto neg_exit;\n\t}\n\tserver->dialect = le16_to_cpu(rsp->DialectRevision);",
"\t/*\n\t * Keep a copy of the hash after negprot. This hash will be\n\t * the starting hash value for all sessions made from this\n\t * server.\n\t */\n\tmemcpy(server->preauth_sha_hash, ses->preauth_sha_hash,\n\t SMB2_PREAUTH_HASH_SIZE);",
"\t/* SMB2 only has an extended negflavor */\n\tserver->negflavor = CIFS_NEGFLAVOR_EXTENDED;\n\t/* set it to the maximum buffer size value we can send with 1 credit */\n\tserver->maxBuf = min_t(unsigned int, le32_to_cpu(rsp->MaxTransactSize),\n\t\t\t SMB2_MAX_BUFFER_SIZE);\n\tserver->max_read = le32_to_cpu(rsp->MaxReadSize);\n\tserver->max_write = le32_to_cpu(rsp->MaxWriteSize);\n\tserver->sec_mode = le16_to_cpu(rsp->SecurityMode);\n\tif ((server->sec_mode & SMB2_SEC_MODE_FLAGS_ALL) != server->sec_mode)\n\t\tcifs_dbg(FYI, \"Server returned unexpected security mode 0x%x\\n\",\n\t\t\t\tserver->sec_mode);\n\tserver->capabilities = le32_to_cpu(rsp->Capabilities);\n\t/* Internal types */\n\tserver->capabilities |= SMB2_NT_FIND | SMB2_LARGE_FILES;",
"\tsecurity_blob = smb2_get_data_area_len(&blob_offset, &blob_length,\n\t\t\t\t\t (struct smb2_sync_hdr *)rsp);\n\t/*\n\t * See MS-SMB2 section 2.2.4: if no blob, client picks default which\n\t * for us will be\n\t *\tses->sectype = RawNTLMSSP;\n\t * but for time being this is our only auth choice so doesn't matter.\n\t * We just found a server which sets blob length to zero expecting raw.\n\t */\n\tif (blob_length == 0) {\n\t\tcifs_dbg(FYI, \"missing security blob on negprot\\n\");\n\t\tserver->sec_ntlmssp = true;\n\t}",
"\trc = cifs_enable_signing(server, ses->sign);\n\tif (rc)\n\t\tgoto neg_exit;\n\tif (blob_length) {\n\t\trc = decode_negTokenInit(security_blob, blob_length, server);\n\t\tif (rc == 1)\n\t\t\trc = 0;\n\t\telse if (rc == 0)\n\t\t\trc = -EIO;\n\t}",
"\tif (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) {\n\t\tif (rsp->NegotiateContextCount)\n\t\t\trc = smb311_decode_neg_context(rsp, server,\n\t\t\t\t\t\t rsp_iov.iov_len);\n\t\telse\n\t\t\tcifs_dbg(VFS, \"Missing expected negotiate contexts\\n\");\n\t}\nneg_exit:\n\tfree_rsp_buf(resp_buftype, rsp);\n\treturn rc;\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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 3773,
"char_start": 3735,
"chars": "\tses->server->vals = &smb21_values;\n\t\t"
},
{
"char_end": 3838,
"char_start": 3836,
"chars": " {"
},
{
"char_end": 3923,
"char_start": 3880,
"chars": "\n\t\t\tses->server->vals = &smb311_values;\n\t\t}"
}
],
"deleted": []
},
"commit_link": "github.com/torvalds/linux/commit/b57a55e2200ede754e4dc9cce4ba9402544b9365",
"file_name": "fs/cifs/smb2pdu.c",
"func_name": "SMB2_negotiate",
"line_changes": {
"added": [
{
"char_end": 3771,
"char_start": 3733,
"line": "\t\t\tses->server->vals = &smb21_values;\n",
"line_no": 116
},
{
"char_end": 3839,
"char_start": 3771,
"line": "\t\t} else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) {\n",
"line_no": 117
},
{
"char_end": 3920,
"char_start": 3881,
"line": "\t\t\tses->server->vals = &smb311_values;\n",
"line_no": 119
},
{
"char_end": 3924,
"char_start": 3920,
"line": "\t\t}\n",
"line_no": 120
}
],
"deleted": [
{
"char_end": 3799,
"char_start": 3733,
"line": "\t\t} else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID))\n",
"line_no": 116
}
]
},
"vul_type": "cwe-125"
} | 396 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static ssize_t parse8BIM(Image *ifile, Image *ofile)\n{\n char\n brkused,\n quoted,\n *line,\n *token,\n *newstr,\n *name;",
" int\n state,\n next;",
" unsigned char\n dataset;",
" unsigned int\n recnum;",
" int\n inputlen = MaxTextExtent;",
" MagickOffsetType\n savedpos,\n currentpos;",
" ssize_t\n savedolen = 0L,\n outputlen = 0L;",
" TokenInfo\n *token_info;",
" dataset = 0;\n recnum = 0;\n line = (char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*line));\n if (line == (char *) NULL)\n return(-1);\n newstr = name = token = (char *) NULL;\n savedpos = 0;\n token_info=AcquireTokenInfo();\n while (super_fgets(&line,&inputlen,ifile)!=NULL)\n {\n state=0;\n next=0;",
" token=(char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*token));\n if (token == (char *) NULL)\n break;\n newstr=(char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*newstr));\n if (newstr == (char *) NULL)\n break;\n while (Tokenizer(token_info,0,token,(size_t) inputlen,line,\"\",\"=\",\"\\\"\",0,\n &brkused,&next,"ed)==0)\n {\n if (state == 0)\n {\n int\n state,\n next;",
" char\n brkused,\n quoted;",
" state=0;\n next=0;\n while (Tokenizer(token_info,0,newstr,(size_t) inputlen,token,\"\",\"#\",\n \"\", 0,&brkused,&next,"ed)==0)\n {\n switch (state)\n {\n case 0:\n if (strcmp(newstr,\"8BIM\")==0)\n dataset = 255;\n else\n dataset = (unsigned char) StringToLong(newstr);\n break;\n case 1:\n recnum = (unsigned int) StringToUnsignedLong(newstr);\n break;\n case 2:\n name=(char *) AcquireQuantumMemory(strlen(newstr)+MaxTextExtent,\n sizeof(*name));\n if (name)\n (void) strcpy(name,newstr);\n break;\n }\n state++;\n }\n }\n else\n if (state == 1)\n {\n int\n next;",
" ssize_t\n len;",
" char\n brkused,\n quoted;",
" next=0;\n len = (ssize_t) strlen(token);\n while (Tokenizer(token_info,0,newstr,(size_t) inputlen,token,\"\",\"&\",\n \"\",0,&brkused,&next,"ed)==0)\n {\n if (brkused && next > 0)\n {\n char\n *s = &token[next-1];",
" len -= (ssize_t) convertHTMLcodes(s,(int) strlen(s));\n }\n }",
" if (dataset == 255)\n {\n unsigned char\n nlen = 0;",
" int\n i;",
" if (savedolen > 0)\n {\n MagickOffsetType\n offset;",
" ssize_t diff = outputlen - savedolen;\n currentpos = TellBlob(ofile);\n if (currentpos < 0)\n return(-1);\n offset=SeekBlob(ofile,savedpos,SEEK_SET);\n if (offset < 0)\n return(-1);\n (void) WriteBlobMSBLong(ofile,(unsigned int) diff);\n offset=SeekBlob(ofile,currentpos,SEEK_SET);\n if (offset < 0)\n return(-1);\n savedolen = 0L;\n }\n if (outputlen & 1)\n {\n (void) WriteBlobByte(ofile,0x00);\n outputlen++;\n }\n (void) WriteBlobString(ofile,\"8BIM\");\n (void) WriteBlobMSBShort(ofile,(unsigned short) recnum);\n outputlen += 6;\n if (name)\n nlen = (unsigned char) strlen(name);\n (void) WriteBlobByte(ofile,nlen);\n outputlen++;\n for (i=0; i<nlen; i++)\n (void) WriteBlobByte(ofile,(unsigned char) name[i]);\n outputlen += nlen;\n if ((nlen & 0x01) == 0)\n {\n (void) WriteBlobByte(ofile,0x00);\n outputlen++;\n }\n if (recnum != IPTC_ID)\n {\n (void) WriteBlobMSBLong(ofile, (unsigned int) len);\n outputlen += 4;",
" next=0;\n outputlen += len;",
" while (len--)",
" (void) WriteBlobByte(ofile,(unsigned char) token[next++]);",
" if (outputlen & 1)\n {\n (void) WriteBlobByte(ofile,0x00);\n outputlen++;\n }\n }\n else\n {\n /* patch in a fake length for now and fix it later */\n savedpos = TellBlob(ofile);\n if (savedpos < 0)\n return(-1);\n (void) WriteBlobMSBLong(ofile,0xFFFFFFFFU);\n outputlen += 4;\n savedolen = outputlen;\n }\n }\n else\n {\n if (len <= 0x7FFF)\n {\n (void) WriteBlobByte(ofile,0x1c);\n (void) WriteBlobByte(ofile,(unsigned char) dataset);\n (void) WriteBlobByte(ofile,(unsigned char) (recnum & 0xff));\n (void) WriteBlobMSBShort(ofile,(unsigned short) len);\n outputlen += 5;\n next=0;\n outputlen += len;",
" while (len--)",
" (void) WriteBlobByte(ofile,(unsigned char) token[next++]);\n }\n }\n }\n state++;\n }\n if (token != (char *) NULL)\n token=DestroyString(token);\n if (newstr != (char *) NULL)\n newstr=DestroyString(newstr);\n if (name != (char *) NULL)\n name=DestroyString(name);\n }\n token_info=DestroyTokenInfo(token_info);\n if (token != (char *) NULL)\n token=DestroyString(token);\n if (newstr != (char *) NULL)\n newstr=DestroyString(newstr);\n if (name != (char *) NULL)\n name=DestroyString(name);\n line=DestroyString(line);\n if (savedolen > 0)\n {\n MagickOffsetType\n offset;",
" ssize_t diff = outputlen - savedolen;",
" currentpos = TellBlob(ofile);\n if (currentpos < 0)\n return(-1);\n offset=SeekBlob(ofile,savedpos,SEEK_SET);\n if (offset < 0)\n return(-1);\n (void) WriteBlobMSBLong(ofile,(unsigned int) diff);\n offset=SeekBlob(ofile,currentpos,SEEK_SET);\n if (offset < 0)\n return(-1);\n savedolen = 0L;\n }\n return(outputlen);\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 4574,
"char_start": 4570,
"chars": " > 0"
},
{
"char_end": 5782,
"char_start": 5778,
"chars": " > 0"
}
],
"deleted": []
},
"commit_link": "github.com/ImageMagick/ImageMagick/commit/97c9f438a9b3454d085895f4d1f66389fd22a0fb",
"file_name": "coders/meta.c",
"func_name": "parse8BIM",
"line_changes": {
"added": [
{
"char_end": 4576,
"char_start": 4538,
"line": " while (len-- > 0)\n",
"line_no": 173
},
{
"char_end": 5784,
"char_start": 5746,
"line": " while (len-- > 0)\n",
"line_no": 204
}
],
"deleted": [
{
"char_end": 4572,
"char_start": 4538,
"line": " while (len--)\n",
"line_no": 173
},
{
"char_end": 5776,
"char_start": 5742,
"line": " while (len--)\n",
"line_no": 204
}
]
},
"vul_type": "cwe-125"
} | 397 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"static ssize_t parse8BIM(Image *ifile, Image *ofile)\n{\n char\n brkused,\n quoted,\n *line,\n *token,\n *newstr,\n *name;",
" int\n state,\n next;",
" unsigned char\n dataset;",
" unsigned int\n recnum;",
" int\n inputlen = MaxTextExtent;",
" MagickOffsetType\n savedpos,\n currentpos;",
" ssize_t\n savedolen = 0L,\n outputlen = 0L;",
" TokenInfo\n *token_info;",
" dataset = 0;\n recnum = 0;\n line = (char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*line));\n if (line == (char *) NULL)\n return(-1);\n newstr = name = token = (char *) NULL;\n savedpos = 0;\n token_info=AcquireTokenInfo();\n while (super_fgets(&line,&inputlen,ifile)!=NULL)\n {\n state=0;\n next=0;",
" token=(char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*token));\n if (token == (char *) NULL)\n break;\n newstr=(char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*newstr));\n if (newstr == (char *) NULL)\n break;\n while (Tokenizer(token_info,0,token,(size_t) inputlen,line,\"\",\"=\",\"\\\"\",0,\n &brkused,&next,"ed)==0)\n {\n if (state == 0)\n {\n int\n state,\n next;",
" char\n brkused,\n quoted;",
" state=0;\n next=0;\n while (Tokenizer(token_info,0,newstr,(size_t) inputlen,token,\"\",\"#\",\n \"\", 0,&brkused,&next,"ed)==0)\n {\n switch (state)\n {\n case 0:\n if (strcmp(newstr,\"8BIM\")==0)\n dataset = 255;\n else\n dataset = (unsigned char) StringToLong(newstr);\n break;\n case 1:\n recnum = (unsigned int) StringToUnsignedLong(newstr);\n break;\n case 2:\n name=(char *) AcquireQuantumMemory(strlen(newstr)+MaxTextExtent,\n sizeof(*name));\n if (name)\n (void) strcpy(name,newstr);\n break;\n }\n state++;\n }\n }\n else\n if (state == 1)\n {\n int\n next;",
" ssize_t\n len;",
" char\n brkused,\n quoted;",
" next=0;\n len = (ssize_t) strlen(token);\n while (Tokenizer(token_info,0,newstr,(size_t) inputlen,token,\"\",\"&\",\n \"\",0,&brkused,&next,"ed)==0)\n {\n if (brkused && next > 0)\n {\n char\n *s = &token[next-1];",
" len -= (ssize_t) convertHTMLcodes(s,(int) strlen(s));\n }\n }",
" if (dataset == 255)\n {\n unsigned char\n nlen = 0;",
" int\n i;",
" if (savedolen > 0)\n {\n MagickOffsetType\n offset;",
" ssize_t diff = outputlen - savedolen;\n currentpos = TellBlob(ofile);\n if (currentpos < 0)\n return(-1);\n offset=SeekBlob(ofile,savedpos,SEEK_SET);\n if (offset < 0)\n return(-1);\n (void) WriteBlobMSBLong(ofile,(unsigned int) diff);\n offset=SeekBlob(ofile,currentpos,SEEK_SET);\n if (offset < 0)\n return(-1);\n savedolen = 0L;\n }\n if (outputlen & 1)\n {\n (void) WriteBlobByte(ofile,0x00);\n outputlen++;\n }\n (void) WriteBlobString(ofile,\"8BIM\");\n (void) WriteBlobMSBShort(ofile,(unsigned short) recnum);\n outputlen += 6;\n if (name)\n nlen = (unsigned char) strlen(name);\n (void) WriteBlobByte(ofile,nlen);\n outputlen++;\n for (i=0; i<nlen; i++)\n (void) WriteBlobByte(ofile,(unsigned char) name[i]);\n outputlen += nlen;\n if ((nlen & 0x01) == 0)\n {\n (void) WriteBlobByte(ofile,0x00);\n outputlen++;\n }\n if (recnum != IPTC_ID)\n {\n (void) WriteBlobMSBLong(ofile, (unsigned int) len);\n outputlen += 4;",
" next=0;\n outputlen += len;",
" while (len-- > 0)",
" (void) WriteBlobByte(ofile,(unsigned char) token[next++]);",
" if (outputlen & 1)\n {\n (void) WriteBlobByte(ofile,0x00);\n outputlen++;\n }\n }\n else\n {\n /* patch in a fake length for now and fix it later */\n savedpos = TellBlob(ofile);\n if (savedpos < 0)\n return(-1);\n (void) WriteBlobMSBLong(ofile,0xFFFFFFFFU);\n outputlen += 4;\n savedolen = outputlen;\n }\n }\n else\n {\n if (len <= 0x7FFF)\n {\n (void) WriteBlobByte(ofile,0x1c);\n (void) WriteBlobByte(ofile,(unsigned char) dataset);\n (void) WriteBlobByte(ofile,(unsigned char) (recnum & 0xff));\n (void) WriteBlobMSBShort(ofile,(unsigned short) len);\n outputlen += 5;\n next=0;\n outputlen += len;",
" while (len-- > 0)",
" (void) WriteBlobByte(ofile,(unsigned char) token[next++]);\n }\n }\n }\n state++;\n }\n if (token != (char *) NULL)\n token=DestroyString(token);\n if (newstr != (char *) NULL)\n newstr=DestroyString(newstr);\n if (name != (char *) NULL)\n name=DestroyString(name);\n }\n token_info=DestroyTokenInfo(token_info);\n if (token != (char *) NULL)\n token=DestroyString(token);\n if (newstr != (char *) NULL)\n newstr=DestroyString(newstr);\n if (name != (char *) NULL)\n name=DestroyString(name);\n line=DestroyString(line);\n if (savedolen > 0)\n {\n MagickOffsetType\n offset;",
" ssize_t diff = outputlen - savedolen;",
" currentpos = TellBlob(ofile);\n if (currentpos < 0)\n return(-1);\n offset=SeekBlob(ofile,savedpos,SEEK_SET);\n if (offset < 0)\n return(-1);\n (void) WriteBlobMSBLong(ofile,(unsigned int) diff);\n offset=SeekBlob(ofile,currentpos,SEEK_SET);\n if (offset < 0)\n return(-1);\n savedolen = 0L;\n }\n return(outputlen);\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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 4574,
"char_start": 4570,
"chars": " > 0"
},
{
"char_end": 5782,
"char_start": 5778,
"chars": " > 0"
}
],
"deleted": []
},
"commit_link": "github.com/ImageMagick/ImageMagick/commit/97c9f438a9b3454d085895f4d1f66389fd22a0fb",
"file_name": "coders/meta.c",
"func_name": "parse8BIM",
"line_changes": {
"added": [
{
"char_end": 4576,
"char_start": 4538,
"line": " while (len-- > 0)\n",
"line_no": 173
},
{
"char_end": 5784,
"char_start": 5746,
"line": " while (len-- > 0)\n",
"line_no": 204
}
],
"deleted": [
{
"char_end": 4572,
"char_start": 4538,
"line": " while (len--)\n",
"line_no": 173
},
{
"char_end": 5776,
"char_start": 5742,
"line": " while (len--)\n",
"line_no": 204
}
]
},
"vul_type": "cwe-125"
} | 397 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, WavpackContext *wpc, WavpackConfig *config)\n{\n int64_t infilesize, total_samples;\n DFFFileHeader dff_file_header;\n DFFChunkHeader dff_chunk_header;\n uint32_t bcount;",
" infilesize = DoGetFileSize (infile);\n memcpy (&dff_file_header, fourcc, 4);",
" if ((!DoReadFile (infile, ((char *) &dff_file_header) + 4, sizeof (DFFFileHeader) - 4, &bcount) ||\n bcount != sizeof (DFFFileHeader) - 4) || strncmp (dff_file_header.formType, \"DSD \", 4)) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }\n else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&\n !WavpackAddWrapper (wpc, &dff_file_header, sizeof (DFFFileHeader))) {\n error_line (\"%s\", WavpackGetErrorMessage (wpc));\n return WAVPACK_SOFT_ERROR;\n }",
"#if 1 // this might be a little too picky...\n WavpackBigEndianToNative (&dff_file_header, DFFFileHeaderFormat);",
" if (infilesize && !(config->qmode & QMODE_IGNORE_LENGTH) &&\n dff_file_header.ckDataSize && dff_file_header.ckDataSize + 1 && dff_file_header.ckDataSize + 12 != infilesize) {\n error_line (\"%s is not a valid .DFF file (by total size)!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }",
" if (debug_logging_mode)\n error_line (\"file header indicated length = %lld\", dff_file_header.ckDataSize);",
"#endif",
" // loop through all elements of the DSDIFF header\n // (until the data chuck) and copy them to the output file",
" while (1) {\n if (!DoReadFile (infile, &dff_chunk_header, sizeof (DFFChunkHeader), &bcount) ||\n bcount != sizeof (DFFChunkHeader)) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }\n else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&\n !WavpackAddWrapper (wpc, &dff_chunk_header, sizeof (DFFChunkHeader))) {\n error_line (\"%s\", WavpackGetErrorMessage (wpc));\n return WAVPACK_SOFT_ERROR;\n }",
" WavpackBigEndianToNative (&dff_chunk_header, DFFChunkHeaderFormat);",
" if (debug_logging_mode)\n error_line (\"chunk header indicated length = %lld\", dff_chunk_header.ckDataSize);",
" if (!strncmp (dff_chunk_header.ckID, \"FVER\", 4)) {\n uint32_t version;",
" if (dff_chunk_header.ckDataSize != sizeof (version) ||\n !DoReadFile (infile, &version, sizeof (version), &bcount) ||\n bcount != sizeof (version)) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }\n else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&\n !WavpackAddWrapper (wpc, &version, sizeof (version))) {\n error_line (\"%s\", WavpackGetErrorMessage (wpc));\n return WAVPACK_SOFT_ERROR;\n }",
" WavpackBigEndianToNative (&version, \"L\");",
" if (debug_logging_mode)\n error_line (\"dsdiff file version = 0x%08x\", version);\n }\n else if (!strncmp (dff_chunk_header.ckID, \"PROP\", 4)) {",
" char *prop_chunk = malloc ((size_t) dff_chunk_header.ckDataSize);",
"\n if (!DoReadFile (infile, prop_chunk, (uint32_t) dff_chunk_header.ckDataSize, &bcount) ||\n bcount != dff_chunk_header.ckDataSize) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n free (prop_chunk);\n return WAVPACK_SOFT_ERROR;\n }\n else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&\n !WavpackAddWrapper (wpc, prop_chunk, (uint32_t) dff_chunk_header.ckDataSize)) {\n error_line (\"%s\", WavpackGetErrorMessage (wpc));\n free (prop_chunk);\n return WAVPACK_SOFT_ERROR;\n }",
" if (!strncmp (prop_chunk, \"SND \", 4)) {\n char *cptr = prop_chunk + 4, *eptr = prop_chunk + dff_chunk_header.ckDataSize;\n uint16_t numChannels, chansSpecified, chanMask = 0;\n uint32_t sampleRate;",
" while (eptr - cptr >= sizeof (dff_chunk_header)) {\n memcpy (&dff_chunk_header, cptr, sizeof (dff_chunk_header));\n cptr += sizeof (dff_chunk_header);\n WavpackBigEndianToNative (&dff_chunk_header, DFFChunkHeaderFormat);",
" if (eptr - cptr >= dff_chunk_header.ckDataSize) {\n if (!strncmp (dff_chunk_header.ckID, \"FS \", 4) && dff_chunk_header.ckDataSize == 4) {\n memcpy (&sampleRate, cptr, sizeof (sampleRate));\n WavpackBigEndianToNative (&sampleRate, \"L\");\n cptr += dff_chunk_header.ckDataSize;",
" if (debug_logging_mode)\n error_line (\"got sample rate of %u Hz\", sampleRate);\n }\n else if (!strncmp (dff_chunk_header.ckID, \"CHNL\", 4) && dff_chunk_header.ckDataSize >= 2) {\n memcpy (&numChannels, cptr, sizeof (numChannels));\n WavpackBigEndianToNative (&numChannels, \"S\");\n cptr += sizeof (numChannels);",
" chansSpecified = (int)(dff_chunk_header.ckDataSize - sizeof (numChannels)) / 4;",
" while (chansSpecified--) {\n if (!strncmp (cptr, \"SLFT\", 4) || !strncmp (cptr, \"MLFT\", 4))\n chanMask |= 0x1;\n else if (!strncmp (cptr, \"SRGT\", 4) || !strncmp (cptr, \"MRGT\", 4))\n chanMask |= 0x2;\n else if (!strncmp (cptr, \"LS \", 4))\n chanMask |= 0x10;\n else if (!strncmp (cptr, \"RS \", 4))\n chanMask |= 0x20;\n else if (!strncmp (cptr, \"C \", 4))\n chanMask |= 0x4;\n else if (!strncmp (cptr, \"LFE \", 4))\n chanMask |= 0x8;\n else\n if (debug_logging_mode)\n error_line (\"undefined channel ID %c%c%c%c\", cptr [0], cptr [1], cptr [2], cptr [3]);",
" cptr += 4;\n }",
" if (debug_logging_mode)\n error_line (\"%d channels, mask = 0x%08x\", numChannels, chanMask);\n }\n else if (!strncmp (dff_chunk_header.ckID, \"CMPR\", 4) && dff_chunk_header.ckDataSize >= 4) {\n if (strncmp (cptr, \"DSD \", 4)) {\n error_line (\"DSDIFF files must be uncompressed, not \\\"%c%c%c%c\\\"!\",\n cptr [0], cptr [1], cptr [2], cptr [3]);\n free (prop_chunk);\n return WAVPACK_SOFT_ERROR;\n }",
" cptr += dff_chunk_header.ckDataSize;\n }\n else {\n if (debug_logging_mode)\n error_line (\"got PROP/SND chunk type \\\"%c%c%c%c\\\" of %d bytes\", dff_chunk_header.ckID [0],\n dff_chunk_header.ckID [1], dff_chunk_header.ckID [2], dff_chunk_header.ckID [3], dff_chunk_header.ckDataSize);",
" cptr += dff_chunk_header.ckDataSize;\n }\n }\n else {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n free (prop_chunk);\n return WAVPACK_SOFT_ERROR;\n }\n }",
" if (chanMask && (config->channel_mask || (config->qmode & QMODE_CHANS_UNASSIGNED))) {\n error_line (\"this DSDIFF file already has channel order information!\");\n free (prop_chunk);\n return WAVPACK_SOFT_ERROR;\n }\n else if (chanMask)\n config->channel_mask = chanMask;",
" config->bits_per_sample = 8;\n config->bytes_per_sample = 1;\n config->num_channels = numChannels;\n config->sample_rate = sampleRate / 8;\n config->qmode |= QMODE_DSD_MSB_FIRST;\n }\n else if (debug_logging_mode)\n error_line (\"got unknown PROP chunk type \\\"%c%c%c%c\\\" of %d bytes\",\n prop_chunk [0], prop_chunk [1], prop_chunk [2], prop_chunk [3], dff_chunk_header.ckDataSize);",
" free (prop_chunk);\n }\n else if (!strncmp (dff_chunk_header.ckID, \"DSD \", 4)) {\n total_samples = dff_chunk_header.ckDataSize / config->num_channels;\n break;\n }\n else { // just copy unknown chunks to output file",
" int bytes_to_copy = (int)(((dff_chunk_header.ckDataSize) + 1) & ~(int64_t)1);\n char *buff = malloc (bytes_to_copy);",
" if (debug_logging_mode)\n error_line (\"extra unknown chunk \\\"%c%c%c%c\\\" of %d bytes\",\n dff_chunk_header.ckID [0], dff_chunk_header.ckID [1], dff_chunk_header.ckID [2],\n dff_chunk_header.ckID [3], dff_chunk_header.ckDataSize);",
" if (!DoReadFile (infile, buff, bytes_to_copy, &bcount) ||\n bcount != bytes_to_copy ||\n (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&\n !WavpackAddWrapper (wpc, buff, bytes_to_copy))) {\n error_line (\"%s\", WavpackGetErrorMessage (wpc));\n free (buff);\n return WAVPACK_SOFT_ERROR;\n }",
" free (buff);\n }\n }",
" if (debug_logging_mode)\n error_line (\"setting configuration with %lld samples\", total_samples);",
" if (!WavpackSetConfiguration64 (wpc, config, total_samples, NULL)) {\n error_line (\"%s: %s\", infilename, WavpackGetErrorMessage (wpc));\n return WAVPACK_SOFT_ERROR;\n }",
" return WAVPACK_NO_ERROR;\n}"
] | [
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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 3654,
"char_start": 3272,
"chars": ";\n\n if (dff_chunk_header.ckDataSize < 4 || dff_chunk_header.ckDataSize > 1024) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }\n\n if (debug_logging_mode)\n error_line (\"got PROP chunk of %d bytes total\", (int) dff_chunk_header.ckDataSize);\n\n prop_chunk"
}
],
"deleted": []
},
"commit_link": "github.com/dbry/WavPack/commit/36a24c7881427d2e1e4dc1cef58f19eee0d13aec",
"file_name": "cli/dsdiff.c",
"func_name": "ParseDsdiffHeaderConfig",
"line_changes": {
"added": [
{
"char_end": 3274,
"char_start": 3244,
"line": " char *prop_chunk;\n",
"line_no": 77
},
{
"char_end": 3275,
"char_start": 3274,
"line": "\n",
"line_no": 78
},
{
"char_end": 3364,
"char_start": 3275,
"line": " if (dff_chunk_header.ckDataSize < 4 || dff_chunk_header.ckDataSize > 1024) {\n",
"line_no": 79
},
{
"char_end": 3437,
"char_start": 3364,
"line": " error_line (\"%s is not a valid .DFF file!\", infilename);\n",
"line_no": 80
},
{
"char_end": 3480,
"char_start": 3437,
"line": " return WAVPACK_SOFT_ERROR;\n",
"line_no": 81
},
{
"char_end": 3494,
"char_start": 3480,
"line": " }\n",
"line_no": 82
},
{
"char_end": 3495,
"char_start": 3494,
"line": "\n",
"line_no": 83
},
{
"char_end": 3531,
"char_start": 3495,
"line": " if (debug_logging_mode)\n",
"line_no": 84
},
{
"char_end": 3631,
"char_start": 3531,
"line": " error_line (\"got PROP chunk of %d bytes total\", (int) dff_chunk_header.ckDataSize);\n",
"line_no": 85
},
{
"char_end": 3632,
"char_start": 3631,
"line": "\n",
"line_no": 86
},
{
"char_end": 3704,
"char_start": 3632,
"line": " prop_chunk = malloc ((size_t) dff_chunk_header.ckDataSize);\n",
"line_no": 87
}
],
"deleted": [
{
"char_end": 3322,
"char_start": 3244,
"line": " char *prop_chunk = malloc ((size_t) dff_chunk_header.ckDataSize);\n",
"line_no": 77
}
]
},
"vul_type": "cwe-125"
} | 398 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, WavpackContext *wpc, WavpackConfig *config)\n{\n int64_t infilesize, total_samples;\n DFFFileHeader dff_file_header;\n DFFChunkHeader dff_chunk_header;\n uint32_t bcount;",
" infilesize = DoGetFileSize (infile);\n memcpy (&dff_file_header, fourcc, 4);",
" if ((!DoReadFile (infile, ((char *) &dff_file_header) + 4, sizeof (DFFFileHeader) - 4, &bcount) ||\n bcount != sizeof (DFFFileHeader) - 4) || strncmp (dff_file_header.formType, \"DSD \", 4)) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }\n else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&\n !WavpackAddWrapper (wpc, &dff_file_header, sizeof (DFFFileHeader))) {\n error_line (\"%s\", WavpackGetErrorMessage (wpc));\n return WAVPACK_SOFT_ERROR;\n }",
"#if 1 // this might be a little too picky...\n WavpackBigEndianToNative (&dff_file_header, DFFFileHeaderFormat);",
" if (infilesize && !(config->qmode & QMODE_IGNORE_LENGTH) &&\n dff_file_header.ckDataSize && dff_file_header.ckDataSize + 1 && dff_file_header.ckDataSize + 12 != infilesize) {\n error_line (\"%s is not a valid .DFF file (by total size)!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }",
" if (debug_logging_mode)\n error_line (\"file header indicated length = %lld\", dff_file_header.ckDataSize);",
"#endif",
" // loop through all elements of the DSDIFF header\n // (until the data chuck) and copy them to the output file",
" while (1) {\n if (!DoReadFile (infile, &dff_chunk_header, sizeof (DFFChunkHeader), &bcount) ||\n bcount != sizeof (DFFChunkHeader)) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }\n else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&\n !WavpackAddWrapper (wpc, &dff_chunk_header, sizeof (DFFChunkHeader))) {\n error_line (\"%s\", WavpackGetErrorMessage (wpc));\n return WAVPACK_SOFT_ERROR;\n }",
" WavpackBigEndianToNative (&dff_chunk_header, DFFChunkHeaderFormat);",
" if (debug_logging_mode)\n error_line (\"chunk header indicated length = %lld\", dff_chunk_header.ckDataSize);",
" if (!strncmp (dff_chunk_header.ckID, \"FVER\", 4)) {\n uint32_t version;",
" if (dff_chunk_header.ckDataSize != sizeof (version) ||\n !DoReadFile (infile, &version, sizeof (version), &bcount) ||\n bcount != sizeof (version)) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }\n else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&\n !WavpackAddWrapper (wpc, &version, sizeof (version))) {\n error_line (\"%s\", WavpackGetErrorMessage (wpc));\n return WAVPACK_SOFT_ERROR;\n }",
" WavpackBigEndianToNative (&version, \"L\");",
" if (debug_logging_mode)\n error_line (\"dsdiff file version = 0x%08x\", version);\n }\n else if (!strncmp (dff_chunk_header.ckID, \"PROP\", 4)) {",
" char *prop_chunk;",
" if (dff_chunk_header.ckDataSize < 4 || dff_chunk_header.ckDataSize > 1024) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }",
" if (debug_logging_mode)\n error_line (\"got PROP chunk of %d bytes total\", (int) dff_chunk_header.ckDataSize);",
" prop_chunk = malloc ((size_t) dff_chunk_header.ckDataSize);",
"\n if (!DoReadFile (infile, prop_chunk, (uint32_t) dff_chunk_header.ckDataSize, &bcount) ||\n bcount != dff_chunk_header.ckDataSize) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n free (prop_chunk);\n return WAVPACK_SOFT_ERROR;\n }\n else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&\n !WavpackAddWrapper (wpc, prop_chunk, (uint32_t) dff_chunk_header.ckDataSize)) {\n error_line (\"%s\", WavpackGetErrorMessage (wpc));\n free (prop_chunk);\n return WAVPACK_SOFT_ERROR;\n }",
" if (!strncmp (prop_chunk, \"SND \", 4)) {\n char *cptr = prop_chunk + 4, *eptr = prop_chunk + dff_chunk_header.ckDataSize;\n uint16_t numChannels, chansSpecified, chanMask = 0;\n uint32_t sampleRate;",
" while (eptr - cptr >= sizeof (dff_chunk_header)) {\n memcpy (&dff_chunk_header, cptr, sizeof (dff_chunk_header));\n cptr += sizeof (dff_chunk_header);\n WavpackBigEndianToNative (&dff_chunk_header, DFFChunkHeaderFormat);",
" if (eptr - cptr >= dff_chunk_header.ckDataSize) {\n if (!strncmp (dff_chunk_header.ckID, \"FS \", 4) && dff_chunk_header.ckDataSize == 4) {\n memcpy (&sampleRate, cptr, sizeof (sampleRate));\n WavpackBigEndianToNative (&sampleRate, \"L\");\n cptr += dff_chunk_header.ckDataSize;",
" if (debug_logging_mode)\n error_line (\"got sample rate of %u Hz\", sampleRate);\n }\n else if (!strncmp (dff_chunk_header.ckID, \"CHNL\", 4) && dff_chunk_header.ckDataSize >= 2) {\n memcpy (&numChannels, cptr, sizeof (numChannels));\n WavpackBigEndianToNative (&numChannels, \"S\");\n cptr += sizeof (numChannels);",
" chansSpecified = (int)(dff_chunk_header.ckDataSize - sizeof (numChannels)) / 4;",
" while (chansSpecified--) {\n if (!strncmp (cptr, \"SLFT\", 4) || !strncmp (cptr, \"MLFT\", 4))\n chanMask |= 0x1;\n else if (!strncmp (cptr, \"SRGT\", 4) || !strncmp (cptr, \"MRGT\", 4))\n chanMask |= 0x2;\n else if (!strncmp (cptr, \"LS \", 4))\n chanMask |= 0x10;\n else if (!strncmp (cptr, \"RS \", 4))\n chanMask |= 0x20;\n else if (!strncmp (cptr, \"C \", 4))\n chanMask |= 0x4;\n else if (!strncmp (cptr, \"LFE \", 4))\n chanMask |= 0x8;\n else\n if (debug_logging_mode)\n error_line (\"undefined channel ID %c%c%c%c\", cptr [0], cptr [1], cptr [2], cptr [3]);",
" cptr += 4;\n }",
" if (debug_logging_mode)\n error_line (\"%d channels, mask = 0x%08x\", numChannels, chanMask);\n }\n else if (!strncmp (dff_chunk_header.ckID, \"CMPR\", 4) && dff_chunk_header.ckDataSize >= 4) {\n if (strncmp (cptr, \"DSD \", 4)) {\n error_line (\"DSDIFF files must be uncompressed, not \\\"%c%c%c%c\\\"!\",\n cptr [0], cptr [1], cptr [2], cptr [3]);\n free (prop_chunk);\n return WAVPACK_SOFT_ERROR;\n }",
" cptr += dff_chunk_header.ckDataSize;\n }\n else {\n if (debug_logging_mode)\n error_line (\"got PROP/SND chunk type \\\"%c%c%c%c\\\" of %d bytes\", dff_chunk_header.ckID [0],\n dff_chunk_header.ckID [1], dff_chunk_header.ckID [2], dff_chunk_header.ckID [3], dff_chunk_header.ckDataSize);",
" cptr += dff_chunk_header.ckDataSize;\n }\n }\n else {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n free (prop_chunk);\n return WAVPACK_SOFT_ERROR;\n }\n }",
" if (chanMask && (config->channel_mask || (config->qmode & QMODE_CHANS_UNASSIGNED))) {\n error_line (\"this DSDIFF file already has channel order information!\");\n free (prop_chunk);\n return WAVPACK_SOFT_ERROR;\n }\n else if (chanMask)\n config->channel_mask = chanMask;",
" config->bits_per_sample = 8;\n config->bytes_per_sample = 1;\n config->num_channels = numChannels;\n config->sample_rate = sampleRate / 8;\n config->qmode |= QMODE_DSD_MSB_FIRST;\n }\n else if (debug_logging_mode)\n error_line (\"got unknown PROP chunk type \\\"%c%c%c%c\\\" of %d bytes\",\n prop_chunk [0], prop_chunk [1], prop_chunk [2], prop_chunk [3], dff_chunk_header.ckDataSize);",
" free (prop_chunk);\n }\n else if (!strncmp (dff_chunk_header.ckID, \"DSD \", 4)) {\n total_samples = dff_chunk_header.ckDataSize / config->num_channels;\n break;\n }\n else { // just copy unknown chunks to output file",
" int bytes_to_copy = (int)(((dff_chunk_header.ckDataSize) + 1) & ~(int64_t)1);\n char *buff = malloc (bytes_to_copy);",
" if (debug_logging_mode)\n error_line (\"extra unknown chunk \\\"%c%c%c%c\\\" of %d bytes\",\n dff_chunk_header.ckID [0], dff_chunk_header.ckID [1], dff_chunk_header.ckID [2],\n dff_chunk_header.ckID [3], dff_chunk_header.ckDataSize);",
" if (!DoReadFile (infile, buff, bytes_to_copy, &bcount) ||\n bcount != bytes_to_copy ||\n (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&\n !WavpackAddWrapper (wpc, buff, bytes_to_copy))) {\n error_line (\"%s\", WavpackGetErrorMessage (wpc));\n free (buff);\n return WAVPACK_SOFT_ERROR;\n }",
" free (buff);\n }\n }",
" if (debug_logging_mode)\n error_line (\"setting configuration with %lld samples\", total_samples);",
" if (!WavpackSetConfiguration64 (wpc, config, total_samples, NULL)) {\n error_line (\"%s: %s\", infilename, WavpackGetErrorMessage (wpc));\n return WAVPACK_SOFT_ERROR;\n }",
" return WAVPACK_NO_ERROR;\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
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 3654,
"char_start": 3272,
"chars": ";\n\n if (dff_chunk_header.ckDataSize < 4 || dff_chunk_header.ckDataSize > 1024) {\n error_line (\"%s is not a valid .DFF file!\", infilename);\n return WAVPACK_SOFT_ERROR;\n }\n\n if (debug_logging_mode)\n error_line (\"got PROP chunk of %d bytes total\", (int) dff_chunk_header.ckDataSize);\n\n prop_chunk"
}
],
"deleted": []
},
"commit_link": "github.com/dbry/WavPack/commit/36a24c7881427d2e1e4dc1cef58f19eee0d13aec",
"file_name": "cli/dsdiff.c",
"func_name": "ParseDsdiffHeaderConfig",
"line_changes": {
"added": [
{
"char_end": 3274,
"char_start": 3244,
"line": " char *prop_chunk;\n",
"line_no": 77
},
{
"char_end": 3275,
"char_start": 3274,
"line": "\n",
"line_no": 78
},
{
"char_end": 3364,
"char_start": 3275,
"line": " if (dff_chunk_header.ckDataSize < 4 || dff_chunk_header.ckDataSize > 1024) {\n",
"line_no": 79
},
{
"char_end": 3437,
"char_start": 3364,
"line": " error_line (\"%s is not a valid .DFF file!\", infilename);\n",
"line_no": 80
},
{
"char_end": 3480,
"char_start": 3437,
"line": " return WAVPACK_SOFT_ERROR;\n",
"line_no": 81
},
{
"char_end": 3494,
"char_start": 3480,
"line": " }\n",
"line_no": 82
},
{
"char_end": 3495,
"char_start": 3494,
"line": "\n",
"line_no": 83
},
{
"char_end": 3531,
"char_start": 3495,
"line": " if (debug_logging_mode)\n",
"line_no": 84
},
{
"char_end": 3631,
"char_start": 3531,
"line": " error_line (\"got PROP chunk of %d bytes total\", (int) dff_chunk_header.ckDataSize);\n",
"line_no": 85
},
{
"char_end": 3632,
"char_start": 3631,
"line": "\n",
"line_no": 86
},
{
"char_end": 3704,
"char_start": 3632,
"line": " prop_chunk = malloc ((size_t) dff_chunk_header.ckDataSize);\n",
"line_no": 87
}
],
"deleted": [
{
"char_end": 3322,
"char_start": 3244,
"line": " char *prop_chunk = malloc ((size_t) dff_chunk_header.ckDataSize);\n",
"line_no": 77
}
]
},
"vul_type": "cwe-125"
} | 398 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"name_parse(u8 *packet, int length, int *idx, char *name_out, int name_out_len) {\n\tint name_end = -1;\n\tint j = *idx;\n\tint ptr_count = 0;\n#define GET32(x) do { if (j + 4 > length) goto err; memcpy(&t32_, packet + j, 4); j += 4; x = ntohl(t32_); } while (0)\n#define GET16(x) do { if (j + 2 > length) goto err; memcpy(&t_, packet + j, 2); j += 2; x = ntohs(t_); } while (0)\n#define GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while (0)",
"\tchar *cp = name_out;\n\tconst char *const end = name_out + name_out_len;",
"\t/* Normally, names are a series of length prefixed strings terminated */\n\t/* with a length of 0 (the lengths are u8's < 63). */\n\t/* However, the length can start with a pair of 1 bits and that */\n\t/* means that the next 14 bits are a pointer within the current */\n\t/* packet. */",
"\tfor (;;) {\n\t\tu8 label_len;",
"\t\tif (j >= length) return -1;",
"\t\tGET8(label_len);\n\t\tif (!label_len) break;\n\t\tif (label_len & 0xc0) {\n\t\t\tu8 ptr_low;\n\t\t\tGET8(ptr_low);\n\t\t\tif (name_end < 0) name_end = j;\n\t\t\tj = (((int)label_len & 0x3f) << 8) + ptr_low;\n\t\t\t/* Make sure that the target offset is in-bounds. */\n\t\t\tif (j < 0 || j >= length) return -1;\n\t\t\t/* If we've jumped more times than there are characters in the\n\t\t\t * message, we must have a loop. */\n\t\t\tif (++ptr_count > length) return -1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (label_len > 63) return -1;\n\t\tif (cp != name_out) {\n\t\t\tif (cp + 1 >= end) return -1;\n\t\t\t*cp++ = '.';\n\t\t}\n\t\tif (cp + label_len >= end) return -1;",
"",
"\t\tmemcpy(cp, packet + j, label_len);\n\t\tcp += label_len;\n\t\tj += label_len;\n\t}\n\tif (cp >= end) return -1;\n\t*cp = '\\0';\n\tif (name_end < 0)\n\t\t*idx = j;\n\telse\n\t\t*idx = name_end;\n\treturn 0;\n err:\n\treturn -1;\n}"
] | [
1,
1,
1,
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1453,
"char_start": 1412,
"chars": ") return -1;\n\t\tif (j + label_len > length"
}
],
"deleted": [
{
"char_end": 862,
"char_start": 832,
"chars": "if (j >= length) return -1;\n\t\t"
}
]
},
"commit_link": "github.com/libevent/libevent/commit/96f64a022014a208105ead6c8a7066018449d86d",
"file_name": "evdns.c",
"func_name": "name_parse",
"line_changes": {
"added": [
{
"char_end": 1466,
"char_start": 1425,
"line": "\t\tif (j + label_len > length) return -1;\n",
"line_no": 40
}
],
"deleted": [
{
"char_end": 860,
"char_start": 830,
"line": "\t\tif (j >= length) return -1;\n",
"line_no": 20
}
]
},
"vul_type": "cwe-125"
} | 399 | cwe-125 | c |
Determine whether the {function_name} code is vulnerable or not. | [
"name_parse(u8 *packet, int length, int *idx, char *name_out, int name_out_len) {\n\tint name_end = -1;\n\tint j = *idx;\n\tint ptr_count = 0;\n#define GET32(x) do { if (j + 4 > length) goto err; memcpy(&t32_, packet + j, 4); j += 4; x = ntohl(t32_); } while (0)\n#define GET16(x) do { if (j + 2 > length) goto err; memcpy(&t_, packet + j, 2); j += 2; x = ntohs(t_); } while (0)\n#define GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while (0)",
"\tchar *cp = name_out;\n\tconst char *const end = name_out + name_out_len;",
"\t/* Normally, names are a series of length prefixed strings terminated */\n\t/* with a length of 0 (the lengths are u8's < 63). */\n\t/* However, the length can start with a pair of 1 bits and that */\n\t/* means that the next 14 bits are a pointer within the current */\n\t/* packet. */",
"\tfor (;;) {\n\t\tu8 label_len;",
"",
"\t\tGET8(label_len);\n\t\tif (!label_len) break;\n\t\tif (label_len & 0xc0) {\n\t\t\tu8 ptr_low;\n\t\t\tGET8(ptr_low);\n\t\t\tif (name_end < 0) name_end = j;\n\t\t\tj = (((int)label_len & 0x3f) << 8) + ptr_low;\n\t\t\t/* Make sure that the target offset is in-bounds. */\n\t\t\tif (j < 0 || j >= length) return -1;\n\t\t\t/* If we've jumped more times than there are characters in the\n\t\t\t * message, we must have a loop. */\n\t\t\tif (++ptr_count > length) return -1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (label_len > 63) return -1;\n\t\tif (cp != name_out) {\n\t\t\tif (cp + 1 >= end) return -1;\n\t\t\t*cp++ = '.';\n\t\t}\n\t\tif (cp + label_len >= end) return -1;",
"\t\tif (j + label_len > length) return -1;",
"\t\tmemcpy(cp, packet + j, label_len);\n\t\tcp += label_len;\n\t\tj += label_len;\n\t}\n\tif (cp >= end) return -1;\n\t*cp = '\\0';\n\tif (name_end < 0)\n\t\t*idx = j;\n\telse\n\t\t*idx = name_end;\n\treturn 0;\n err:\n\treturn -1;\n}"
] | [
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1453,
"char_start": 1412,
"chars": ") return -1;\n\t\tif (j + label_len > length"
}
],
"deleted": [
{
"char_end": 862,
"char_start": 832,
"chars": "if (j >= length) return -1;\n\t\t"
}
]
},
"commit_link": "github.com/libevent/libevent/commit/96f64a022014a208105ead6c8a7066018449d86d",
"file_name": "evdns.c",
"func_name": "name_parse",
"line_changes": {
"added": [
{
"char_end": 1466,
"char_start": 1425,
"line": "\t\tif (j + label_len > length) return -1;\n",
"line_no": 40
}
],
"deleted": [
{
"char_end": 860,
"char_start": 830,
"line": "\t\tif (j >= length) return -1;\n",
"line_no": 20
}
]
},
"vul_type": "cwe-125"
} | 399 | cwe-125 | c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.