ASCII->POLY: rm obsolete trailing NULL byte

Since we use memcpy in conjunction with a call to
get_int_to_bin_str().
This commit is contained in:
hasufell 2014-06-09 13:09:44 +02:00
parent df7386847f
commit 56484e939a
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
1 changed files with 5 additions and 7 deletions

View File

@ -45,12 +45,13 @@
/**
* Convert an integer to it's binary representation
* as a string and return it.
* as a char array and return it (not NULL terminated).
*
* As in: 90 => "10110101"
*
* @param value the integer to convert
* @return the binary representation as a newly allocated string
* @return the binary representation as a newly allocated char array
* (not NULL terminated)
*/
static char *
get_int_to_bin_str(uint8_t value);
@ -62,12 +63,9 @@ static char *
get_int_to_bin_str(uint8_t value)
{
int i;
const size_t bin_string_size = ASCII_BITS + 1;
const size_t bin_string_size = ASCII_BITS;
char *bin_string = ntru_malloc(sizeof(*bin_string) *
(bin_string_size)); /* account for trailing null-byte */
/* terminate properly */
bin_string[bin_string_size - 1] = '\0';
(bin_string_size));
for (i = ASCII_BITS - 1; i >= 0; --i, value >>= 1)
bin_string[i] = (value & 1) + '0';