Closed vadim-perco closed 4 years ago
Same issue here
Actually, the buffer overflow happens in many SDK functions, when using library on Ubuntu 18.04 64 bit platform.
System: OS: Ubuntu 18.04.3 LTS OS type: 64-bit Memory: 8GB
Biostar SDK library version: 2.6.3.16 (have also tried 2.6.3.13 an 2.6.3.19 beta release) - results are always the same
Few examples:
Test case No.1 =============================================
void* _pBiostarContext = NULL;
int main(){
printf("Application started!\n");
_pBiostarContext = BS2_AllocateContext();
if(_pBiostarContext != NULL){
int nResult = BS2_Initialize(_pBiostarContext);
if(nResult != BS_SDK_SUCCESS){
printf("Failed to initialize context!\n");
BS2_ReleaseContext(_pBiostarContext);
return EXIT_FAILURE;
}
printf("Using Biostar library version %s\n", BS2_Version());
}
else{
printf("Failed to allocate context!\n");
return EXIT_FAILURE;
}
BS2_ReleaseContext(_pBiostarContext); // <-- Can not get past this
printf("Application finished!\n");
return EXIT_SUCCESS;
}
Expected output:
Application started! Using Biostar library version 2.6.3.16 Application finished!
Actual output:
Application started! Using Biostar library version 2.6.3.16 buffer overflow detected
Test case No.2 (failed reader connection) =============================================
void* _pBiostarContext = NULL;
const char* _cHost = "<Invalid reader IP here>";
int _nPort = 51211;.
int _nbiostarDeviceId = 0;
int main(){
printf("Application started!\n");
_pBiostarContext = BS2_AllocateContext();
if(_pBiostarContext != NULL){
int nResult = BS2_Initialize(_pBiostarContext);
if(nResult != BS_SDK_SUCCESS){
printf("Failed to initialize context!\n");
BS2_ReleaseContext(_pBiostarContext);
return EXIT_FAILURE;
}
printf("Using Biostar library version %s\n", BS2_Version());
}
else{
printf("Failed to allocate context!\n");
return EXIT_FAILURE;
}
printf("Connecting to reader\n");
while(BS_SDK_SUCCESS != BS2_ConnectDeviceViaIP(_pBiostarContext,
_cHost, _nPort, &_nBiostarDeviceId)) // <-- Buffer overflow if the connection does not succeed
{
printf("Retrying reader connection\n"); // <-- Never gets here
}
printf("Connected to reader\n");
/*Rest of the application code
..........
*/
BS2_ReleaseContext(_pBiostarContext);
printf("Application finished!\n");
return EXIT_SUCCESS;
}
Expected output:
Application started! Using Biostar library version 2.6.3.16 Connecting to reader! Retrying reader connection Retrying reader connection And so on....
Actual output:
Using Biostar library version 2.6.3.16 Connecting to reader buffer overflow detected
This problem solved in SDK 2.6.3.23
Error message: buffer overflow detected My platform is Linux Ubuntu 18.04 I use 64-bit version of library from BioStar2_device_SDK/Lib/Linux/lib/x64/libBS_SDK_V2.so