Back out changes in #366 and introduce read_argv_int/float()
* Revert "Extend "read_argv" native"
This reverts commit aaa2934595
.
This broke binary compatibility with either older, already compiled
plugins, or newly compiled plugins if you forgot to update .inc headers.
This happened because read_argv used to receive maxlen by value, and
after
this commit it receives it by reference. This causes read_argv either
to fail, or worse, to buffer overflow, resulting in a security vulnerability.
Newly introduced functionality for read_argv should be added with a new,
separate native.
* Add "read_argv_int" & "read_argv_float" natives
This commit is contained in:
committed by
Vincent Herbet
parent
a9557fe53d
commit
732a05dde0
@ -1318,32 +1318,39 @@ native get_playersnum(flag = 0);
|
||||
native get_players(players[MAX_PLAYERS], &num, const flags[] = "", const team[] = "");
|
||||
|
||||
/**
|
||||
* Retrieves argument of client command.
|
||||
* Retrieves argument of client command as string.
|
||||
*
|
||||
* @note Should only be used inside of the client_command() forward.
|
||||
* @note Usage examples:
|
||||
* value = read_argv(1);
|
||||
* read_argv(2, floatvalue);
|
||||
* written = read_argv(3, buffer, buffersize);
|
||||
*
|
||||
* @param id Argument index starting from 1, 0 returns the command itself
|
||||
* @param ... Changes the native's behavior depending on how many
|
||||
* additional parameters are provided:
|
||||
* 0 - Return the argument integer value directly
|
||||
* 1 - Store the argument float value in the variable passed
|
||||
* as the second parameter
|
||||
* 2 - Copy the argument string value to the buffer provided
|
||||
* in the second parameter, using the third as the
|
||||
* maximum buffer size
|
||||
* @param output Buffer to copy command argument to
|
||||
* @param len Maximum buffer size
|
||||
*
|
||||
* @return Changes depending on how many additional parameters are
|
||||
* provided:
|
||||
* 0 - Returns the argument integer value
|
||||
* 1 - Returns the argument float value, converted
|
||||
* (truncated) to an integer
|
||||
* 2 - Returns the number of cells written to the buffer
|
||||
* @return Number of cells written to buffer
|
||||
*/
|
||||
native read_argv(id, any:...);
|
||||
native read_argv(id, output[], len);
|
||||
|
||||
/**
|
||||
* Retrieves argument of client command as integer value.
|
||||
*
|
||||
* @note Should only be used inside of the client_command() forward.
|
||||
*
|
||||
* @param id Argument index starting from 1
|
||||
*
|
||||
* @return Integer value
|
||||
*/
|
||||
native read_argv_int(id);
|
||||
|
||||
/**
|
||||
* Retrieves argument of client command as float value.
|
||||
*
|
||||
* @note Should only be used inside of the client_command() forward.
|
||||
*
|
||||
* @param id Argument index starting from 1
|
||||
*
|
||||
* @return Float value
|
||||
*/
|
||||
native Float:read_argv_float(id);
|
||||
|
||||
/**
|
||||
* Retrieves full client command string.
|
||||
|
Reference in New Issue
Block a user