CVC: Do not let "perm" be incremented before "trans", because it may lead to serious memory errors, since our code blindly passes the same vector twice.
| 3474 | // CVC: Do not let "perm" be incremented before "trans", because it may lead to serious memory errors, |
| 3475 | // since our code blindly passes the same vector twice. |
| 3476 | void makePermanentVector(ISC_STATUS* perm, const ISC_STATUS* trans) throw() |
| 3477 | { |
| 3478 | try |
| 3479 | { |
| 3480 | while (true) |
| 3481 | { |
| 3482 | const ISC_STATUS type = *perm++ = *trans++; |
| 3483 | |
| 3484 | switch (type) |
| 3485 | { |
| 3486 | case isc_arg_end: |
| 3487 | return; |
| 3488 | |
| 3489 | case isc_arg_cstring: |
| 3490 | { |
| 3491 | perm [-1] = isc_arg_string; |
| 3492 | const size_t len = *trans++; |
| 3493 | const char* temp = reinterpret_cast<char*>(*trans++); |
| 3494 | *perm++ = (ISC_STATUS)(IPTR) circularAlloc(temp, len); |
| 3495 | } |
| 3496 | break; |
| 3497 | |
| 3498 | case isc_arg_string: |
| 3499 | case isc_arg_interpreted: |
| 3500 | case isc_arg_sql_state: |
| 3501 | { |
| 3502 | const char* temp = reinterpret_cast<char*>(*trans++); |
| 3503 | const size_t len = strlen(temp); |
| 3504 | *perm++ = (ISC_STATUS)(IPTR) circularAlloc(temp, len); |
| 3505 | } |
| 3506 | break; |
| 3507 | |
| 3508 | default: |
| 3509 | *perm++ = *trans++; |
| 3510 | break; |
| 3511 | } |
| 3512 | } |
| 3513 | } |
| 3514 | catch (const system_call_failed& ex) |
| 3515 | { |
| 3516 | memcpy(perm, ex.value(), sizeof(ISC_STATUS_ARRAY)); |
| 3517 | } |
| 3518 | catch (const BadAlloc&) |
| 3519 | { |
| 3520 | *perm++ = isc_arg_gds; |
| 3521 | *perm++ = isc_virmemexh; |
| 3522 | *perm++ = isc_arg_end; |
| 3523 | } |
| 3524 | catch (...) |
| 3525 | { |
| 3526 | *perm++ = isc_arg_gds; |
| 3527 | *perm++ = isc_random; |
| 3528 | *perm++ = isc_arg_string; |
| 3529 | *perm++ = (ISC_STATUS)(IPTR) "Unexpected exception in makePermanentVector()"; |
| 3530 | *perm++ = isc_arg_end; |
| 3531 | } |
| 3532 | } |
| 3533 |
no test coverage detected