rubygem-sqlite3/Remove-deprecated-taint-followup.patch
2022-01-27 14:46:09 +08:00

109 lines
3.5 KiB
Diff

diff -Nur a/ext/sqlite3/database.c b/ext/sqlite3/database.c
--- a/ext/sqlite3/database.c 2022-01-27 14:30:56.122375149 +0800
+++ b/ext/sqlite3/database.c 2022-01-27 14:30:45.214194939 +0800
@@ -57,7 +57,9 @@
rb_scan_args(argc, argv, "12", &file, &opts, &zvfs);
#if defined StringValueCStr
StringValuePtr(file);
+#if defined TAINTING_SUPPORT
rb_check_safe_obj(file);
+#endif
#else
Check_SafeStr(file);
#endif
@@ -307,7 +309,7 @@
return rb_float_new(sqlite3_value_double(val));
break;
case SQLITE_TEXT:
- return rb_tainted_str_new2((const char *)sqlite3_value_text(val));
+ return rb_str_new2((const char *)sqlite3_value_text(val));
break;
case SQLITE_BLOB: {
/* Sqlite warns calling sqlite3_value_bytes may invalidate pointer from sqlite3_value_blob,
@@ -317,7 +319,7 @@
*/
int len = sqlite3_value_bytes(val);
#ifdef HAVE_RUBY_ENCODING_H
- return rb_tainted_str_new((const char *)sqlite3_value_blob(val), len);
+ return rb_str_new((const char *)sqlite3_value_blob(val), len);
#else
/* When encoding is not available, make it class SQLite3::Blob. */
VALUE strargv[1];
diff -Nur a/ext/sqlite3/extconf.rb b/ext/sqlite3/extconf.rb
--- a/ext/sqlite3/extconf.rb 2022-01-27 14:30:56.122375149 +0800
+++ b/ext/sqlite3/extconf.rb 2022-01-27 14:29:34.125020499 +0800
@@ -33,6 +33,10 @@
$CFLAGS << ' -W3'
end
+if RUBY_VERSION < '2.7'
+ $CFLAGS << ' -DTAINTING_SUPPORT'
+end
+
def asplode missing
if RUBY_PLATFORM =~ /mingw|mswin/
abort "#{missing} is missing. Install SQLite3 from " +
diff -Nur a/ext/sqlite3/statement.c b/ext/sqlite3/statement.c
--- a/ext/sqlite3/statement.c 2022-01-27 14:30:56.126375215 +0800
+++ b/ext/sqlite3/statement.c 2022-01-27 14:29:34.125020499 +0800
@@ -148,7 +148,7 @@
break;
case SQLITE_TEXT:
{
- VALUE str = rb_tainted_str_new(
+ VALUE str = rb_str_new(
(const char *)sqlite3_column_text(stmt, i),
(long)sqlite3_column_bytes(stmt, i)
);
@@ -162,7 +162,7 @@
break;
case SQLITE_BLOB:
{
- VALUE str = rb_tainted_str_new(
+ VALUE str = rb_str_new(
(const char *)sqlite3_column_blob(stmt, i),
(long)sqlite3_column_bytes(stmt, i)
);
diff -Nur a/test/test_integration_resultset.rb b/test/test_integration_resultset.rb
--- a/test/test_integration_resultset.rb 2022-01-27 14:30:56.134375348 +0800
+++ b/test/test_integration_resultset.rb 2022-01-27 14:29:34.125020499 +0800
@@ -105,23 +105,6 @@
assert_equal hash[1], "foo"
end
- def test_tainted_results_as_hash
- @db.results_as_hash = true
- @result.reset( 1 )
- row = @result.next
- row.each do |_, v|
- assert(v.tainted?) if String === v
- end
- end
-
- def test_tainted_row_values
- @result.reset( 1 )
- row = @result.next
- row.each do |v|
- assert(v.tainted?) if String === v
- end
- end
-
def test_each
called = 0
@result.reset( 1, 2 )
diff -Nur a/test/test_statement.rb b/test/test_statement.rb
--- a/test/test_statement.rb 2022-01-27 14:30:56.138375414 +0800
+++ b/test/test_statement.rb 2022-01-27 14:29:34.125020499 +0800
@@ -190,11 +190,6 @@
assert_equal ['foo'], r
end
- def test_tainted
- r = @stmt.step
- assert r.first.tainted?
- end
-
def test_step_twice
assert_not_nil @stmt.step
assert !@stmt.done?