addressed amb1230 - BfReadString() erroring on something that should be perfectly valid
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401756
This commit is contained in:
parent
6533e16019
commit
dcb77e0918
@ -484,6 +484,7 @@ static cell_t smn_BfReadString(IPluginContext *pCtx, const cell_t *params)
|
|||||||
HandleError herr;
|
HandleError herr;
|
||||||
HandleSecurity sec;
|
HandleSecurity sec;
|
||||||
bf_read *pBitBuf;
|
bf_read *pBitBuf;
|
||||||
|
int numChars = 0;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
sec.pOwner = NULL;
|
sec.pOwner = NULL;
|
||||||
@ -496,12 +497,14 @@ static cell_t smn_BfReadString(IPluginContext *pCtx, const cell_t *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pCtx->LocalToPhysAddr(params[2], (cell_t **)&buf);
|
pCtx->LocalToPhysAddr(params[2], (cell_t **)&buf);
|
||||||
if (!pBitBuf->ReadString(buf, params[3], params[4] ? true : false))
|
pBitBuf->ReadString(buf, params[3], params[4], &numChars);
|
||||||
|
|
||||||
|
if (pBitBuf->IsOverflowed())
|
||||||
{
|
{
|
||||||
return pCtx->ThrowNativeError("Destination string buffer is too short, try increasing its size");
|
return -numChars - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return numChars;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell_t smn_BfReadEntity(IPluginContext *pCtx, const cell_t *params)
|
static cell_t smn_BfReadEntity(IPluginContext *pCtx, const cell_t *params)
|
||||||
|
@ -181,7 +181,7 @@ native BfWriteAngles(Handle:bf, Float:angles[3]);
|
|||||||
* Reads a single bit from a readable bitbuffer (bf_read).
|
* Reads a single bit from a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @return Bit value read.
|
* @return Bit value read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native bool:BfReadBool(Handle:bf);
|
native bool:BfReadBool(Handle:bf);
|
||||||
@ -190,7 +190,7 @@ native bool:BfReadBool(Handle:bf);
|
|||||||
* Reads a byte from a readable bitbuffer (bf_read).
|
* Reads a byte from a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @return Byte value read (read as 8bit).
|
* @return Byte value read (read as 8bit).
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadByte(Handle:bf);
|
native BfReadByte(Handle:bf);
|
||||||
@ -199,7 +199,7 @@ native BfReadByte(Handle:bf);
|
|||||||
* Reads a character from a readable bitbuffer (bf_read).
|
* Reads a character from a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @return Character value read.
|
* @return Character value read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadChar(Handle:bf);
|
native BfReadChar(Handle:bf);
|
||||||
@ -208,7 +208,7 @@ native BfReadChar(Handle:bf);
|
|||||||
* Reads a 16bit integer from a readable bitbuffer (bf_read).
|
* Reads a 16bit integer from a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @return Integer value read (read as 16bit).
|
* @return Integer value read (read as 16bit).
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadShort(Handle:bf);
|
native BfReadShort(Handle:bf);
|
||||||
@ -217,7 +217,7 @@ native BfReadShort(Handle:bf);
|
|||||||
* Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
|
* Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @return Integer value read (read as 16bit).
|
* @return Integer value read (read as 16bit).
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadWord(Handle:bf);
|
native BfReadWord(Handle:bf);
|
||||||
@ -226,7 +226,7 @@ native BfReadWord(Handle:bf);
|
|||||||
* Reads a normal integer to a readable bitbuffer (bf_read).
|
* Reads a normal integer to a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @return Integer value read (read as 32bit).
|
* @return Integer value read (read as 32bit).
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadNum(Handle:bf);
|
native BfReadNum(Handle:bf);
|
||||||
@ -235,7 +235,7 @@ native BfReadNum(Handle:bf);
|
|||||||
* Reads a floating point number from a readable bitbuffer (bf_read).
|
* Reads a floating point number from a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @return Floating point value read.
|
* @return Floating point value read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native Float:BfReadFloat(Handle:bf);
|
native Float:BfReadFloat(Handle:bf);
|
||||||
@ -247,8 +247,12 @@ native Float:BfReadFloat(Handle:bf);
|
|||||||
* @param buffer Destination string buffer.
|
* @param buffer Destination string buffer.
|
||||||
* @param maxlength Maximum length of output string buffer.
|
* @param maxlength Maximum length of output string buffer.
|
||||||
* @param line If true the buffer will be copied until it reaches a '\n' or a null terminator.
|
* @param line If true the buffer will be copied until it reaches a '\n' or a null terminator.
|
||||||
* @noreturn
|
* @return Number of bytes written to the buffer. If the bitbuffer stream overflowed,
|
||||||
* @error Invalid or incorrect Handle, destination string buffer was too short.
|
* that is, had no terminator before the end of the stream, then a negative
|
||||||
|
* number will be returned equal to the number of characters written to the
|
||||||
|
* buffer minus 1. The buffer will be null terminated regardless of the
|
||||||
|
* return value.
|
||||||
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
|
native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
|
||||||
|
|
||||||
@ -257,7 +261,7 @@ native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
|
|||||||
* @note This is a wrapper around BfReadShort().
|
* @note This is a wrapper around BfReadShort().
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @return Entity index read.
|
* @return Entity index read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadEntity(Handle:bf);
|
native BfReadEntity(Handle:bf);
|
||||||
@ -267,7 +271,7 @@ native BfReadEntity(Handle:bf);
|
|||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @param numBits Optional number of bits to use.
|
* @param numBits Optional number of bits to use.
|
||||||
* @return Angle read.
|
* @return Angle read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native Float:BfReadAngle(Handle:bf, numBits=8);
|
native Float:BfReadAngle(Handle:bf, numBits=8);
|
||||||
@ -276,7 +280,7 @@ native Float:BfReadAngle(Handle:bf, numBits=8);
|
|||||||
* Reads a coordinate from a readable bitbuffer (bf_read).
|
* Reads a coordinate from a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @return Coordinate read.
|
* @return Coordinate read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native Float:BfReadCoord(Handle:bf);
|
native Float:BfReadCoord(Handle:bf);
|
||||||
|
@ -195,7 +195,12 @@ public Action:UserMsg_VGUIMenu(UserMsg:msg_id, Handle:bf, const players[], playe
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl String:type[15];
|
decl String:type[15];
|
||||||
BfReadString(bf, type, sizeof(type));
|
|
||||||
|
/* If we don't get a valid string, bail out. */
|
||||||
|
if (BfReadString(bf, type, sizeof(type)) < 0)
|
||||||
|
{
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
if (BfReadByte(bf) == 1 && BfReadByte(bf) == 0 && (strcmp(type, "scores", false) == 0))
|
if (BfReadByte(bf) == 1 && BfReadByte(bf) == 0 && (strcmp(type, "scores", false) == 0))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user