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:
committed by
Lauri Kasanen
parent
346fccb96c
commit
259f1055cb
@@ -146,7 +146,7 @@ void RegKey::setString(const TCHAR* valname, const TCHAR* value) const {
|
||||
if (result != ERROR_SUCCESS) throw rdr::SystemException("setString", result);
|
||||
}
|
||||
|
||||
void RegKey::setBinary(const TCHAR* valname, const void* value, int length) const {
|
||||
void RegKey::setBinary(const TCHAR* valname, const void* value, size_t length) const {
|
||||
LONG result = RegSetValueEx(key, valname, 0, REG_BINARY, (const BYTE*)value, length);
|
||||
if (result != ERROR_SUCCESS) throw rdr::SystemException("setBinary", result);
|
||||
}
|
||||
@@ -169,12 +169,12 @@ TCHAR* RegKey::getString(const TCHAR* valname, const TCHAR* def) const {
|
||||
}
|
||||
}
|
||||
|
||||
void RegKey::getBinary(const TCHAR* valname, void** data, int* length) const {
|
||||
void RegKey::getBinary(const TCHAR* valname, void** data, size_t* length) const {
|
||||
TCharArray hex(getRepresentation(valname));
|
||||
if (!rdr::HexInStream::hexStrToBin(CStr(hex.buf), (char**)data, length))
|
||||
throw rdr::Exception("getBinary failed");
|
||||
}
|
||||
void RegKey::getBinary(const TCHAR* valname, void** data, int* length, void* def, int deflen) const {
|
||||
void RegKey::getBinary(const TCHAR* valname, void** data, size_t* length, void* def, size_t deflen) const {
|
||||
try {
|
||||
getBinary(valname, data, length);
|
||||
} catch(rdr::Exception&) {
|
||||
|
||||
@@ -71,15 +71,15 @@ namespace rfb {
|
||||
|
||||
void setExpandString(const TCHAR* valname, const TCHAR* s) const;
|
||||
void setString(const TCHAR* valname, const TCHAR* s) const;
|
||||
void setBinary(const TCHAR* valname, const void* data, int length) const;
|
||||
void setBinary(const TCHAR* valname, const void* data, size_t length) const;
|
||||
void setInt(const TCHAR* valname, int i) const;
|
||||
void setBool(const TCHAR* valname, bool b) const;
|
||||
|
||||
TCHAR* getString(const TCHAR* valname) const;
|
||||
TCHAR* getString(const TCHAR* valname, const TCHAR* def) const;
|
||||
|
||||
void getBinary(const TCHAR* valname, void** data, int* length) const;
|
||||
void getBinary(const TCHAR* valname, void** data, int* length, void* def, int deflength) const;
|
||||
void getBinary(const TCHAR* valname, void** data, size_t* length) const;
|
||||
void getBinary(const TCHAR* valname, void** data, size_t* length, void* def, size_t deflength) const;
|
||||
|
||||
int getInt(const TCHAR* valname) const;
|
||||
int getInt(const TCHAR* valname, int def) const;
|
||||
|
||||
Reference in New Issue
Block a user