version 1.67, 2002/08/21 00:15:44
|
version 1.68, 2002/08/22 20:08:33
|
|
|
#include "CIMObject.h" | #include "CIMObject.h" |
#include "CIMParamValue.h" | #include "CIMParamValue.h" |
| |
|
#define PEGASUS_SINT64_MIN (-PEGASUS_SINT64_LITERAL(9223372036854775808)) |
|
#define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(18446744073709551615) |
|
|
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
while (isxdigit(*p)) | while (isxdigit(*p)) |
{ | { |
// Make sure we won't overflow when we multiply by 16 | // Make sure we won't overflow when we multiply by 16 |
if (x < PEGASUS_LLONG_MIN/16) |
if (x < PEGASUS_SINT64_MIN/16) |
{ | { |
return false; | return false; |
} | } |
|
|
| |
// Make sure we don't overflow when we add the next digit | // Make sure we don't overflow when we add the next digit |
Sint64 newDigit = Sint64(_hexCharToNumeric(*p++)); | Sint64 newDigit = Sint64(_hexCharToNumeric(*p++)); |
if (PEGASUS_LLONG_MIN - x > -newDigit) |
if (PEGASUS_SINT64_MIN - x > -newDigit) |
{ | { |
return false; | return false; |
} | } |
|
|
// overflow error | // overflow error |
if (!negative) | if (!negative) |
{ | { |
if (x == PEGASUS_LLONG_MIN) |
if (x == PEGASUS_SINT64_MIN) |
{ | { |
return false; | return false; |
} | } |
|
|
while (isdigit(*p)) | while (isdigit(*p)) |
{ | { |
// Make sure we won't overflow when we multiply by 10 | // Make sure we won't overflow when we multiply by 10 |
if (x < PEGASUS_LLONG_MIN/10) |
if (x < PEGASUS_SINT64_MIN/10) |
{ | { |
return false; | return false; |
} | } |
|
|
| |
// Make sure we won't overflow when we add the next digit | // Make sure we won't overflow when we add the next digit |
Sint64 newDigit = (*p++ - '0'); | Sint64 newDigit = (*p++ - '0'); |
if (PEGASUS_LLONG_MIN - x > -newDigit) |
if (PEGASUS_SINT64_MIN - x > -newDigit) |
{ | { |
return false; | return false; |
} | } |
|
|
// overflow error | // overflow error |
if (!negative) | if (!negative) |
{ | { |
if (x == PEGASUS_LLONG_MIN) |
if (x == PEGASUS_SINT64_MIN) |
{ | { |
return false; | return false; |
} | } |
|
|
while (isxdigit(*p)) | while (isxdigit(*p)) |
{ | { |
// Make sure we won't overflow when we multiply by 16 | // Make sure we won't overflow when we multiply by 16 |
if (x > PEGASUS_ULLONG_MAX/16) |
if (x > PEGASUS_UINT64_MAX/16) |
{ | { |
return false; | return false; |
} | } |
|
|
| |
// We can't overflow when we add the next digit | // We can't overflow when we add the next digit |
Uint64 newDigit = Uint64(_hexCharToNumeric(*p++)); | Uint64 newDigit = Uint64(_hexCharToNumeric(*p++)); |
if (PEGASUS_ULLONG_MAX - x < newDigit) |
if (PEGASUS_UINT64_MAX - x < newDigit) |
{ | { |
return false; | return false; |
} | } |
|
|
while (isdigit(*p)) | while (isdigit(*p)) |
{ | { |
// Make sure we won't overflow when we multiply by 10 | // Make sure we won't overflow when we multiply by 10 |
if (x > PEGASUS_ULLONG_MAX/10) |
if (x > PEGASUS_UINT64_MAX/10) |
{ | { |
return false; | return false; |
} | } |
|
|
| |
// Make sure we won't overflow when we add the next digit | // Make sure we won't overflow when we add the next digit |
Uint64 newDigit = (*p++ - '0'); | Uint64 newDigit = (*p++ - '0'); |
if (PEGASUS_ULLONG_MAX - x < newDigit) |
if (PEGASUS_UINT64_MAX - x < newDigit) |
{ | { |
return false; | return false; |
} | } |