| 1039 | } |
| 1040 | |
| 1041 | bool ParseInt32(const std::string& str, int32_t *out) |
| 1042 | { |
| 1043 | if (!ParsePrechecks(str)) |
| 1044 | return false; |
| 1045 | char *endp = nullptr; |
| 1046 | errno = 0; // strtol will not set errno if valid |
| 1047 | long int n = strtol(str.c_str(), &endp, 10); |
| 1048 | if(out) *out = (int32_t)n; |
| 1049 | // Note that strtol returns a *long int*, so even if strtol doesn't report an over/underflow |
| 1050 | // we still have to check that the returned value is within the range of an *int32_t*. On 64-bit |
| 1051 | // platforms the size of these types may be different. |
| 1052 | return endp && *endp == 0 && !errno && |
| 1053 | n >= std::numeric_limits<int32_t>::min() && |
| 1054 | n <= std::numeric_limits<int32_t>::max(); |
| 1055 | } |
| 1056 | |
| 1057 | bool ConvertPermsToString(uint64_t perms, uint8_t total_perms_count, string& permsList) { |
| 1058 | ostringstream s; |
no test coverage detected