Constrain the range of the buffer and the integer input to fit UINT32_MAX and INT32_MIN, avoid buffer overflow.