Use size_t for lengths in stream objects

Provides safety against them accidentally becoming negative because
of bugs in the calculations.

Also does the same to CharArray and friends as they were strongly
connection to the stream objects.
This commit is contained in:
Pierre Ossman
2019-09-23 11:00:17 +02:00
committed by Lauri Kasanen
parent 346fccb96c
commit 259f1055cb
31 changed files with 180 additions and 178 deletions

View File

@@ -454,7 +454,7 @@ StringParameter::operator const char *() const {
// -=- BinaryParameter
BinaryParameter::BinaryParameter(const char* name_, const char* desc_,
const void* v, int l, ConfigurationObject co)
const void* v, size_t l, ConfigurationObject co)
: VoidParameter(name_, desc_, co), value(0), length(0), def_value((char*)v), def_length(l) {
if (l) {
value = new char[l];
@@ -474,7 +474,7 @@ bool BinaryParameter::setParam(const char* v) {
return rdr::HexInStream::hexStrToBin(v, &value, &length);
}
void BinaryParameter::setParam(const void* v, int len) {
void BinaryParameter::setParam(const void* v, size_t len) {
LOCK_CONFIG;
if (immutable) return;
vlog.debug("set %s(Binary)", getName());
@@ -495,7 +495,7 @@ char* BinaryParameter::getValueStr() const {
return rdr::HexOutStream::binToHexStr(value, length);
}
void BinaryParameter::getData(void** data_, int* length_) const {
void BinaryParameter::getData(void** data_, size_t* length_) const {
LOCK_CONFIG;
if (length_) *length_ = length;
if (data_) {