allow zero length to return FKO_SUCCESS from zero_buf() call
This commit is contained in:
+6
-2
@@ -58,7 +58,8 @@ static void clean_exit(fko_ctx_t ctx, fko_cli_options_t *opts,
|
||||
char *key, int *key_len, char *hmac_key, int *hmac_key_len,
|
||||
unsigned int exit_status);
|
||||
static void zero_buf_wrapper(char *buf, int len);
|
||||
static int is_hostname_str_with_port(const char *str, char *hostname, size_t hostname_bufsize, int *port);
|
||||
static int is_hostname_str_with_port(const char *str,
|
||||
char *hostname, size_t hostname_bufsize, int *port);
|
||||
|
||||
#define MAX_CMDLINE_ARGS 50 /*!< should be way more than enough */
|
||||
#define IPV4_STR_TEMPLATE "%u.%u.%u.%u" /*!< Template for a string as an ipv4 address with sscanf */
|
||||
@@ -1276,7 +1277,10 @@ static void
|
||||
zero_buf_wrapper(char *buf, int len)
|
||||
{
|
||||
|
||||
if(zero_buf(buf, len) != FKO_SUCCESS)
|
||||
if(buf == NULL || len == 0)
|
||||
return;
|
||||
|
||||
if(zero_buf(buf, len) == FKO_ERROR_ZERO_OUT_DATA)
|
||||
log_msg(LOG_VERBOSITY_ERROR,
|
||||
"[*] Could not zero out sensitive data buffer.");
|
||||
|
||||
|
||||
+6
-2
@@ -423,10 +423,14 @@ zero_buf(char *buf, int len)
|
||||
{
|
||||
int i, res = FKO_SUCCESS;
|
||||
|
||||
if(len <= 0 || len > MAX_SPA_ENCODED_MSG_SIZE)
|
||||
if(buf == NULL || len == 0)
|
||||
return res;
|
||||
|
||||
if(len < 0 || len > MAX_SPA_ENCODED_MSG_SIZE)
|
||||
return FKO_ERROR_ZERO_OUT_DATA;
|
||||
|
||||
memset(buf, 0x0, len);
|
||||
for(i=0; i < len; i++)
|
||||
buf[i] = 0x0;
|
||||
|
||||
for(i=0; i < len; i++)
|
||||
if(buf[i] != 0x0)
|
||||
|
||||
Reference in New Issue
Block a user