Added a size argument to hex2bin.
This avoids buffer overflows and related bad things.
This commit is contained in:
parent
f59a282db1
commit
43146709b2
5 changed files with 6 additions and 7 deletions
|
@ -30,12 +30,11 @@
|
|||
#include "tox-weechat-utils.h"
|
||||
|
||||
void
|
||||
tox_weechat_hex2bin(const char *hex, char *out)
|
||||
tox_weechat_hex2bin(const char *hex, size_t length, char *out)
|
||||
{
|
||||
size_t length = strlen(hex) / 2;
|
||||
const char *position = hex;
|
||||
|
||||
for (size_t i = 0; i < length; ++i)
|
||||
for (size_t i = 0; i < length / 2; ++i)
|
||||
{
|
||||
sscanf(position, "%2hhx", &out[i]);
|
||||
position += 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue