Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

MagicNumber[1] in OCI_NumberToString is not handled properly #121

Closed
dbpm opened this issue Nov 24, 2017 · 4 comments
Closed

MagicNumber[1] in OCI_NumberToString is not handled properly #121

dbpm opened this issue Nov 24, 2017 · 4 comments
Assignees

Comments

@dbpm
Copy link

dbpm commented Nov 24, 2017

file src/number.c, line #457 is defined as

        if (memcmp(number, mag_num->number, sizeof(mag_num->number)) == 0)

while it should compare 3 bytes for magic number #0 and two bytes for magic number #1,
it will be better to fix next way:

        if (memcmp(number, mag_num->number,  mag_num->number[0] + 1) == 0)
@vrogier
Copy link
Owner

vrogier commented Nov 27, 2017

Hi,

Why ? Oracle number (OCINumber) is a struct containing an array of 22 byte.
The comparison function assume the input number is a valid initialized OCINumber.
Thus comparing 3 bytes still does the job in any case (regarding current checked values)

Regards,

Vincent

@dbpm
Copy link
Author

dbpm commented Nov 27, 2017

Tailing bytes in the 22 byte array (bytes after the first two 0x01,0x00) are undefined and can be any, not zeroes only.
External libraries can pass you practically any value in non-valuable "tail" part and it still be valid Oracle number, OCI handles it properly.

@vrogier
Copy link
Owner

vrogier commented Nov 28, 2017

OK, if using external OCINumber (from OCILIB point of view) is a use case, then I will update the implementation for next release.

vrogier added a commit that referenced this issue Nov 28, 2017
@vrogier
Copy link
Owner

vrogier commented Nov 28, 2017

Issue addressed

@vrogier vrogier closed this as completed Nov 28, 2017
@vrogier vrogier self-assigned this Jan 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants