Skip to content

Commit 3a9d52f

Browse files
authored
Merge pull request #277 from casperisfine/remove_deprecated_taint-followup
Remove deprecated taint followup
2 parents b6a9d73 + 19d0486 commit 3a9d52f

File tree

6 files changed

+17
-29
lines changed

6 files changed

+17
-29
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: ruby
22
cache: bundler
33
before_install:
4-
- gem update --system
5-
- gem install bundler
4+
- gem update --system 2.7.7
5+
- gem install bundler -v 1.16.2
66
addons:
77
apt:
88
packages:
@@ -25,6 +25,8 @@ rvm:
2525
- 2.3
2626
- 2.4
2727
- 2.5
28+
- 2.6
29+
- 2.7
2830
- ruby-head
2931
matrix:
3032
allow_failures:

ext/sqlite3/database.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ static VALUE rb_sqlite3_open_v2(VALUE self, VALUE file, VALUE mode, VALUE zvfs)
4040

4141
Data_Get_Struct(self, sqlite3Ruby, ctx);
4242

43+
#if defined TAINTING_SUPPORT
4344
#if defined StringValueCStr
4445
StringValuePtr(file);
4546
rb_check_safe_obj(file);
4647
#else
4748
Check_SafeStr(file);
49+
#endif
4850
#endif
4951

5052
status = sqlite3_open_v2(
@@ -213,16 +215,16 @@ VALUE sqlite3val2rb(sqlite3_value * val)
213215
return rb_float_new(sqlite3_value_double(val));
214216
break;
215217
case SQLITE_TEXT:
216-
return rb_tainted_str_new2((const char *)sqlite3_value_text(val));
218+
return rb_str_new2((const char *)sqlite3_value_text(val));
217219
break;
218220
case SQLITE_BLOB: {
219221
/* Sqlite warns calling sqlite3_value_bytes may invalidate pointer from sqlite3_value_blob,
220222
so we explicitly get the length before getting blob pointer.
221-
Note that rb_str_new and rb_tainted_str_new apparently create string with ASCII-8BIT (BINARY) encoding,
223+
Note that rb_str_new apparently create string with ASCII-8BIT (BINARY) encoding,
222224
which is what we want, as blobs are binary
223225
*/
224226
int len = sqlite3_value_bytes(val);
225-
return rb_tainted_str_new((const char *)sqlite3_value_blob(val), len);
227+
return rb_str_new((const char *)sqlite3_value_blob(val), len);
226228
break;
227229
}
228230
case SQLITE_NULL:
@@ -761,11 +763,13 @@ static VALUE rb_sqlite3_open16(VALUE self, VALUE file)
761763

762764
Data_Get_Struct(self, sqlite3Ruby, ctx);
763765

766+
#if defined TAINTING_SUPPORT
764767
#if defined StringValueCStr
765768
StringValuePtr(file);
766769
rb_check_safe_obj(file);
767770
#else
768771
Check_SafeStr(file);
772+
#endif
769773
#endif
770774

771775
status = sqlite3_open16(utf16_string_value_ptr(file), &ctx->db);

ext/sqlite3/extconf.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
$CFLAGS << ' -W3'
4848
end
4949

50+
if RUBY_VERSION < '2.7'
51+
$CFLAGS << ' -DTAINTING_SUPPORT'
52+
end
53+
5054
def asplode missing
5155
if RUBY_PLATFORM =~ /mingw|mswin/
5256
abort "#{missing} is missing. Install SQLite3 from " +

ext/sqlite3/statement.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static VALUE step(VALUE self)
151151
break;
152152
case SQLITE_TEXT:
153153
{
154-
VALUE str = rb_tainted_str_new(
154+
VALUE str = rb_str_new(
155155
(const char *)sqlite3_column_text(stmt, i),
156156
(long)sqlite3_column_bytes(stmt, i)
157157
);
@@ -163,7 +163,7 @@ static VALUE step(VALUE self)
163163
break;
164164
case SQLITE_BLOB:
165165
{
166-
VALUE str = rb_tainted_str_new(
166+
VALUE str = rb_str_new(
167167
(const char *)sqlite3_column_blob(stmt, i),
168168
(long)sqlite3_column_bytes(stmt, i)
169169
);

test/test_integration_resultset.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,6 @@ def test_next_results_as_hash
105105
assert_equal hash[1], "foo"
106106
end
107107

108-
def test_tainted_results_as_hash
109-
@db.results_as_hash = true
110-
@result.reset( 1 )
111-
row = @result.next
112-
row.each do |_, v|
113-
assert(v.tainted?) if String === v
114-
end
115-
end
116-
117-
def test_tainted_row_values
118-
@result.reset( 1 )
119-
row = @result.next
120-
row.each do |v|
121-
assert(v.tainted?) if String === v
122-
end
123-
end
124-
125108
def test_each
126109
called = 0
127110
@result.reset( 1, 2 )

test/test_statement.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,6 @@ def test_step
198198
assert_equal ['foo'], r
199199
end
200200

201-
def test_tainted
202-
r = @stmt.step
203-
assert r.first.tainted?
204-
end
205-
206201
def test_step_twice
207202
assert_not_nil @stmt.step
208203
assert !@stmt.done?

0 commit comments

Comments
 (0)