diff options
-rw-r--r-- | include/util/token.h | 5 | ||||
-rw-r--r-- | types/wlr_xdg_activation_v1.c | 4 | ||||
-rw-r--r-- | util/token.c | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/include/util/token.h b/include/util/token.h index bdfdaf45..9e6282d4 100644 --- a/include/util/token.h +++ b/include/util/token.h @@ -3,7 +3,8 @@ #include <stdbool.h> -#define TOKEN_STRLEN 33 -bool generate_token(char out[static TOKEN_STRLEN]); +#define TOKEN_SIZE 33 + +bool generate_token(char out[static TOKEN_SIZE]); #endif diff --git a/types/wlr_xdg_activation_v1.c b/types/wlr_xdg_activation_v1.c index 74ac0a8e..cd382713 100644 --- a/types/wlr_xdg_activation_v1.c +++ b/types/wlr_xdg_activation_v1.c @@ -60,7 +60,7 @@ static void token_handle_destroy(struct wl_client *client, } static bool token_init( struct wlr_xdg_activation_token_v1 *token) { - char token_str[TOKEN_STRLEN + 1] = {0}; + char token_str[TOKEN_SIZE] = {0}; if (!generate_token(token_str)) { return false; } @@ -137,7 +137,7 @@ static void token_handle_commit(struct wl_client *client, error:; // Here we send a generated token, but it's invalid and can't be used to // request activation. - char token_str[TOKEN_STRLEN + 1] = {0}; + char token_str[TOKEN_SIZE] = {0}; if (!generate_token(token_str)) { wl_client_post_no_memory(client); return; diff --git a/util/token.c b/util/token.c index 1b839aaa..09702e55 100644 --- a/util/token.c +++ b/util/token.c @@ -11,7 +11,7 @@ #include <sys/stat.h> #include <unistd.h> -bool generate_token(char out[static TOKEN_STRLEN]) { +bool generate_token(char out[static TOKEN_SIZE]) { static FILE *urandom = NULL; uint64_t data[2]; @@ -31,7 +31,7 @@ bool generate_token(char out[static TOKEN_STRLEN]) { wlr_log_errno(WLR_ERROR, "Failed to read from random device"); return false; } - if (snprintf(out, TOKEN_STRLEN, "%016" PRIx64 "%016" PRIx64, data[0], data[1]) != TOKEN_STRLEN - 1) { + if (snprintf(out, TOKEN_SIZE, "%016" PRIx64 "%016" PRIx64, data[0], data[1]) != TOKEN_SIZE - 1) { wlr_log_errno(WLR_ERROR, "Failed to format hex string token"); return false; } |