Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Crash when using Samaritan letter #37

Closed
brody4hire opened this issue Apr 19, 2018 · 1 comment
Closed

Crash when using Samaritan letter #37

brody4hire opened this issue Apr 19, 2018 · 1 comment

Comments

@brody4hire
Copy link

Attempt to execute SQL statement that returns result with Samaritan letter will trigger a crash due to a bug in litehelpers / Android-sqlite-evcore-native-driver-free recently spotted by @brodybits. Here is a reproduction test case with Samaritan Bit letter (ref: https://www.compart.com/en/unicode/U+0801):

        it(suiteName + 'string parameter value manipulation test with UTF-8 3-byte character Samaritan Bit (\\U+0801)', function(done) {
          var db = openDatabase("UTF8-0801-string-upper-value-test.db", "1.0", "Demo", DEFAULT_SIZE);

          db.transaction(function(tx) {

            tx.executeSql('SELECT UPPER(?) AS myresult', ['a\u0801.'], function(ignored, rs) {
              expect(rs).toBeDefined();
              expect(rs.rows).toBeDefined();
              expect(rs.rows.length).toBe(1);
              expect(rs.rows.item(0).myresult).toBe('Aࠁ.');

              // Close (plugin only) & finish:
              (isWebSql) ? done() : db.close(done, done);
            });
          }, function(error) {
            // NOT EXPECTED:
            expect(false).toBe(true);
            expect(error.message).toBe('--');
            // Close (plugin only) & finish:
            (isWebSql) ? done() : db.close(done, done);
          });
        }, MYTIMEOUT);

The following patch to litehelpers / Android-sqlite-evcore-native-driver-free would resolve this issue:

diff --git a/native/sqlc.c b/native/sqlc.c
index 2ad1092..cfbe29f 100644
--- a/native/sqlc.c
+++ b/native/sqlc.c
@@ -491,7 +491,7 @@ const char *sqlc_evcore_qc_execute(sqlc_handle_t qc, const char * batch_json, in
                     pi += 1;
                   } else if (pc >= 32 && pc < 127) {
                     rr[rrlen++] = pptext[pi++];
-                  } else if (pc > 0xe0) {
+                  } else if (pc >= 0xe0) {
                     rr[rrlen++] = pptext[pi++];
                     rr[rrlen++] = pptext[pi++];
                     rr[rrlen++] = pptext[pi++];
brody4hire pushed a commit to storesafe/cordova-sqlite-storage that referenced this issue May 24, 2018
brody4hire pushed a commit that referenced this issue May 25, 2018
brody4hire pushed a commit to brody4hire/Cordova-sqlite-evcore-extbuild-free-dev that referenced this issue Jul 12, 2018
brody4hire pushed a commit to storesafe/android-sqlite-evcore-ndk-driver-free that referenced this issue Oct 11, 2018
brody4hire pushed a commit to brody4hire/cordova-sqlite-evcore-free-dependencies that referenced this issue Oct 12, 2018
brody4hire pushed a commit that referenced this issue Oct 21, 2018
for 4-byte UTF-8 characters

and crash bug fix for Samaritan characters

from cordova-sqlite-evcore-free-dependencies 0.8.6

ref:
- #7
- #37

(cordova-sqlite-evcore-extbuild-free 0.9.9-rc1)
@brody4hire
Copy link
Author

Now resolved

brody4hire pushed a commit that referenced this issue Nov 6, 2018
in cordova-sqlite-evcore-common-free version branch

with workaround for 4-byte UTF-8 crash bug ref:
- #44
- #7

and crash bug fix for Samaritan characters ref:
- #37

(cordova-sqlite-evcore-common-free 0.0.4)
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant