Added a size argument to hex2bin.

This avoids buffer overflows and related bad things.
This commit is contained in:
Håvard Pettersson 2014-09-20 20:28:03 +02:00
parent f59a282db1
commit 43146709b2
5 changed files with 6 additions and 7 deletions

View file

@ -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;