more warnings
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
124612d5030a2191fe4dc2e8b486c0f52ae6a716- Parents
-
57c2bc7 - Tree
e36ddfa
124612d
124612d5030a2191fe4dc2e8b486c0f52ae6a71657c2bc7
e36ddfa| Status | File | + | - |
|---|---|---|---|
| M |
src/accounts.c
|
2 | 2 |
| M |
src/config.c
|
4 | 4 |
| M |
src/git_ops.c
|
7 | 7 |
| M |
src/utils.c
|
5 | 5 |
src/accounts.cmodified@@ -762,8 +762,8 @@ static int validate_gpg_key_availability(const char *gpg_key_id) { | ||
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | /* Try to find the key in the GPG keyring */ |
| 765 | - if (SAFE_SNPRINTF(command, sizeof(command), "gpg --list-secret-keys %s >/dev/null 2>&1", | |
| 766 | - gpg_key_id) != 0) { | |
| 765 | + if ((size_t)snprintf(command, sizeof(command), "gpg --list-secret-keys %s >/dev/null 2>&1", | |
| 766 | + gpg_key_id) >= sizeof(command)) { | |
| 767 | 767 | log_error("GPG command too long"); |
| 768 | 768 | return -1; |
| 769 | 769 | } |
src/config.cmodified@@ -171,7 +171,7 @@ int config_save(const gitswitch_ctx_t *ctx, const char *config_path) { | ||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /* Create temporary file path for atomic write */ |
| 174 | - if (SAFE_SNPRINTF(temp_path, sizeof(temp_path), "%s.tmp", config_path) != 0) { | |
| 174 | + if ((size_t)snprintf(temp_path, sizeof(temp_path), "%s.tmp", config_path) >= sizeof(temp_path)) { | |
| 175 | 175 | set_error(ERR_INVALID_ARGS, "Temporary file path too long"); |
| 176 | 176 | return -1; |
| 177 | 177 | } |
@@ -504,8 +504,8 @@ int config_backup(const char *config_path) { | ||
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /* Create backup path */ |
| 507 | - if (SAFE_SNPRINTF(backup_path, sizeof(backup_path), "%s.backup.%s", | |
| 508 | - config_path, timestamp) != 0) { | |
| 507 | + if ((size_t)snprintf(backup_path, sizeof(backup_path), "%s.backup.%s", | |
| 508 | + config_path, timestamp) >= sizeof(backup_path)) { | |
| 509 | 509 | set_error(ERR_INVALID_ARGS, "Backup path too long"); |
| 510 | 510 | return -1; |
| 511 | 511 | } |
@@ -773,7 +773,7 @@ static int save_accounts_to_toml(const gitswitch_ctx_t *ctx, toml_document_t *do | ||
| 773 | 773 | const account_t *account = &ctx->accounts[i]; |
| 774 | 774 | |
| 775 | 775 | /* Create section name */ |
| 776 | - if (SAFE_SNPRINTF(section_name, sizeof(section_name), "accounts.%u", account->id) != 0) { | |
| 776 | + if ((size_t)snprintf(section_name, sizeof(section_name), "accounts.%u", account->id) >= sizeof(section_name)) { | |
| 777 | 777 | set_error(ERR_ACCOUNT_INVALID, "Account ID too large: %u", account->id); |
| 778 | 778 | return -1; |
| 779 | 779 | } |
src/git_ops.cmodified@@ -340,8 +340,8 @@ int git_set_config_value(const char *key, const char *value, git_scope_t scope) | ||
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /* Build git config command */ |
| 343 | - if (SAFE_SNPRINTF(command, sizeof(command), "config %s '%s' '%s'", | |
| 344 | - scope_flag, key, value) != 0) { | |
| 343 | + if ((size_t)snprintf(command, sizeof(command), "config %s '%s' '%s'", | |
| 344 | + scope_flag, key, value) >= sizeof(command)) { | |
| 345 | 345 | set_error(ERR_INVALID_ARGS, "Git config command too long"); |
| 346 | 346 | return -1; |
| 347 | 347 | } |
@@ -374,7 +374,7 @@ int git_get_config_value(const char *key, char *value, size_t value_size, git_sc | ||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /* Build git config command */ |
| 377 | - if (SAFE_SNPRINTF(command, sizeof(command), "config %s '%s'", scope_flag, key) != 0) { | |
| 377 | + if ((size_t)snprintf(command, sizeof(command), "config %s '%s'", scope_flag, key) >= sizeof(command)) { | |
| 378 | 378 | set_error(ERR_INVALID_ARGS, "Git config command too long"); |
| 379 | 379 | return -1; |
| 380 | 380 | } |
@@ -410,8 +410,8 @@ int git_unset_config_value(const char *key, git_scope_t scope) { | ||
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /* Build git config unset command */ |
| 413 | - if (SAFE_SNPRINTF(command, sizeof(command), "config %s --unset '%s'", | |
| 414 | - scope_flag, key) != 0) { | |
| 413 | + if ((size_t)snprintf(command, sizeof(command), "config %s --unset '%s'", | |
| 414 | + scope_flag, key) >= sizeof(command)) { | |
| 415 | 415 | set_error(ERR_INVALID_ARGS, "Git config command too long"); |
| 416 | 416 | return -1; |
| 417 | 417 | } |
@@ -441,7 +441,7 @@ int git_list_config(git_scope_t scope, char *output, size_t output_size) { | ||
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | /* Build git config list command */ |
| 444 | - if (SAFE_SNPRINTF(command, sizeof(command), "config %s --list", scope_flag) != 0) { | |
| 444 | + if ((size_t)snprintf(command, sizeof(command), "config %s --list", scope_flag) >= sizeof(command)) { | |
| 445 | 445 | set_error(ERR_INVALID_ARGS, "Git config command too long"); |
| 446 | 446 | return -1; |
| 447 | 447 | } |
@@ -571,7 +571,7 @@ static int execute_git_command(const char *args, char *output, size_t output_siz | ||
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /* Build full git command */ |
| 574 | - if (SAFE_SNPRINTF(command, sizeof(command), "git %s 2>&1", args) != 0) { | |
| 574 | + if ((size_t)snprintf(command, sizeof(command), "git %s 2>&1", args) >= sizeof(command)) { | |
| 575 | 575 | set_error(ERR_INVALID_ARGS, "Git command too long"); |
| 576 | 576 | return -1; |
| 577 | 577 | } |
src/utils.cmodified@@ -223,7 +223,7 @@ int create_directory_recursive(const char *path, mode_t mode) { | ||
| 223 | 223 | char *p = NULL; |
| 224 | 224 | size_t len; |
| 225 | 225 | |
| 226 | - if (SAFE_SNPRINTF(temp_path, sizeof(temp_path), "%s", path) != 0) { | |
| 226 | + if ((size_t)snprintf(temp_path, sizeof(temp_path), "%s", path) >= sizeof(temp_path)) { | |
| 227 | 227 | set_error(ERR_INVALID_ARGS, "Path too long"); |
| 228 | 228 | return -1; |
| 229 | 229 | } |
@@ -406,8 +406,8 @@ int backup_file(const char *file_path, const char *backup_suffix) { | ||
| 406 | 406 | return -1; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if (SAFE_SNPRINTF(backup_path, sizeof(backup_path), "%s%s", | |
| 410 | - file_path, backup_suffix) != 0) { | |
| 409 | + if ((size_t)snprintf(backup_path, sizeof(backup_path), "%s%s", | |
| 410 | + file_path, backup_suffix) >= sizeof(backup_path)) { | |
| 411 | 411 | set_error(ERR_INVALID_ARGS, "Backup path too long"); |
| 412 | 412 | return -1; |
| 413 | 413 | } |
@@ -520,8 +520,8 @@ bool command_exists(const char *command) { | ||
| 520 | 520 | |
| 521 | 521 | if (!command) return false; |
| 522 | 522 | |
| 523 | - if (SAFE_SNPRINTF(test_command, sizeof(test_command), | |
| 524 | - "command -v %s >/dev/null 2>&1", command) != 0) { | |
| 523 | + if ((size_t)snprintf(test_command, sizeof(test_command), | |
| 524 | + "command -v %s >/dev/null 2>&1", command) >= sizeof(test_command)) { | |
| 525 | 525 | return false; |
| 526 | 526 | } |
| 527 | 527 | |