Skip to content

Commit

Permalink
Fix several logic issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Jul 10, 2024
1 parent a97cf32 commit 50a07e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions suite/cstest/src/test_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ static bool compare_asm_text(const char *asm_text, const char *expected) {
replace_negative(asm_copy, sizeof(asm_copy));

char expected_copy[MAX_ASM_TXT_MEM] = { 0 };
strncpy(asm_copy, expected, sizeof(expected_copy));
strncpy(expected_copy, expected, sizeof(expected_copy));
trim_str(expected_copy);
replace_hex(expected_copy, sizeof(expected_copy));
replace_negative(expected_copy, sizeof(expected_copy));

if (strcmp(asm_copy, expected) == 0) {
if (strcmp(asm_copy, expected_copy) == 0) {
return true;
}

Expand Down
10 changes: 5 additions & 5 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,20 @@ void append_to_str_lower(char *str, size_t str_size, const char *src) {

/// @brief Appends the string @p src to the string @p str. @p src is put to lower case.
/// @param str The string to append to.
/// @param str_size The length of @p str
/// @param str_buf_size Size of buffer @p str.
/// @param src The string to append.
void append_to_str(char *str, size_t str_size, const char *src) {
void append_to_str(char *str, size_t str_buf_size, const char *src) {
char *dest = strchr(str, '\0');
if (dest - str >= str_size) {
if (dest - str >= str_buf_size) {
assert("str_size does not match actual string length." && 0);
return;
}

int i = dest - str;
for (int j = 0; (i < str_size) && (j < strlen(src)); ++i, ++j) {
for (int j = 0; (i < str_buf_size) && (j < strlen(src)); ++i, ++j) {
str[i] = src[j];
}
str[i-1] = '\0';
str[str_buf_size-1] = '\0';
}

/// Returns the given byte sequence @bytes as a string of the
Expand Down

0 comments on commit 50a07e5

Please sign in to comment.