@@ -36,10 +36,11 @@ def createTestTable(cls):
36
36
data_binary varbinary(40),
37
37
decimal_no decimal(38,2),
38
38
numeric_no numeric(38,8),
39
- stamp_time timestamp
39
+ stamp_time timestamp,
40
+ bin_data varbinary(16)
40
41
)""" )
41
42
cls .tableCreated = True
42
- cls .testTableColCount = 15
43
+ cls .testTableColCount = 16
43
44
except _mssql .MSSQLDatabaseException as e :
44
45
if e .number != 2714 :
45
46
raise
@@ -64,16 +65,18 @@ def insertSampleData(self):
64
65
comment_text,
65
66
comment_nvch,
66
67
decimal_no,
67
- numeric_no
68
+ numeric_no,
69
+ bin_data
68
70
) VALUES (
69
71
%d, %d, %d, getdate(), %d,
70
72
'comment %d',
71
73
'detail %d',
72
74
'hmm',
73
75
'bhmme',
74
76
234.99,
75
- 894123.09
76
- );""" % (y , y , y , (y % 2 ), y , y )
77
+ 894123.09,
78
+ %#x
79
+ );""" % (y , y , y , (y % 2 ), y , y , y )
77
80
self .mssql .execute_non_query (query )
78
81
79
82
def test01SimpleSelect (self ):
@@ -112,3 +115,8 @@ def test19MultipleResults(self):
112
115
113
116
rows = tuple (self .mssql )
114
117
self .assertEquals (rows [0 ][0 ], 'ret3' )
118
+
119
+ def test04BinaryTypeSqlInjection (self ):
120
+ self .mssql .execute_query ('SELECT * FROM pymssql WHERE bin_data=%s' , ('0x OR 1=1;' ,))
121
+ rows = tuple (self .mssql )
122
+ self .assertEqual (len (rows ), 0 )
0 commit comments