NativeScript / ios-jsc

NativeScript for iOS using JavaScriptCore
http://docs.nativescript.org/runtimes/ios
Apache License 2.0
298 stars 59 forks source link

Objective-C functions returning unsigned char * are not correctly interpreted in {N} #1196

Closed tbozhikov closed 4 years ago

tbozhikov commented 5 years ago

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

Describe the bug Using the following iOS API from {N}:

extern unsigned char CC_SHA256(const void data, CC_LONG len, unsigned char *md);

returns a result that is interpreted as buffer of signed ints, which ends up working with wrong results.

To Reproduce See this {N} Playground. The following line is the workaround that rescues the situation:

let buffer = new interop.Reference(interop.types.uint8, sha256buffer);

Without it, the result from CC_SHA256 is treated as signed integers and that can lead to wrong results.