mirror of
https://github.com/siemens-mobile-hacks/capstone.git
synced 2026-11-25 22:27:31 +00:00
* Fix CID 508418 - Uninitialized struct * Fix CID 509089 - Fix OOB read and write * Fix CID 509088 - OOB. Also adds tests and to ensure no OOB access. * Fix CID 509085 - Resource leak. * Fix CID 508414 and companions - Using undefined values. * Fix CID 508405 - Use of uninitialized value * Remove unnecessary and badly implemented dev fuzz code. * Fix CID 508396 - Uninitialzied variable. * Fix CID 508393, 508365 -- OOB read. * Fix CID 432207 - OVerlapping memory access. * Remove unused functions * Fix CID 432170 - Overlapping memory access. * Fix CID 166022 - Check for negative index * Let strncat not depend n src operand. * Fix 509083 and 509084 - NULL dereference * Remove duplicated code. * Initialize sysop * Fix resource leak * Remove unreachable code. * Remove duplicate code. * Add assert to check return value of cmoack * Fixed: d should be a signed value, since it is checked against < 0 * Add missing break. * Add NULL check * Fix signs of binary search comparisons. * Add explicit cast of or result * Fix correct scope of case. * Handle invalid integer type. * Return UINT_MAX instead of implicitly casted -1 * Remove dead code * Fix type of im * Fix type of d * Remove duplicated code. * Add returns after CS_ASSERTS * Check for len == 0 case. * Ensure shift operates on uint64 * Replace strcpy with strncpy. * Handle edge cases for 32bit rotate * Fix some out of enum warnings * Replace a strcpy with strncpy. * Fix increment of address * Skip some linting * Fix: set instruction id * Remove unused enum * Replace the last usages of strcpy with SStream functions. * Increase number of allowed AArch64 operands. * Check safety of incrementing t the next operand. * Fix naming of operand * Update python constants * Fix option setup of CS_OPT_DETAIL_REAL * Document DETAIL_REAL has to be used with CS_OPT_ON. * Run Coverity scan every Monday. * Remove dead code * Fix OOB read * Rename macro to reflect it is only used with sstreams * Fix rebase issues
76 lines
1.7 KiB
C
76 lines
1.7 KiB
C
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
|
// SPDX-License-Identifier: BSD-3
|
|
|
|
#include "unit_test.h"
|
|
#include "../utils.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
static bool test_str_append_no_realloc()
|
|
{
|
|
printf("Test test_str_append_no_realloc\n");
|
|
|
|
char str_a[] = "AAAA\0\0\0\0\0";
|
|
char str_b[] = "BBBB";
|
|
char str_c[] = "\0\0\0\0\0";
|
|
|
|
CHECK_NULL_RET_FALSE(str_append(NULL, NULL));
|
|
CHECK_NULL_RET_FALSE(str_append(str_a, NULL));
|
|
CHECK_NULL_RET_FALSE(str_append(NULL, str_b));
|
|
|
|
str_append_no_realloc(str_a, sizeof(str_a), str_c);
|
|
CHECK_STR_EQUAL_RET_FALSE(str_a, "AAAA");
|
|
|
|
str_append_no_realloc(str_a, sizeof(str_a), str_b);
|
|
CHECK_STR_EQUAL_RET_FALSE(str_a, "AAAABBBB");
|
|
|
|
str_append_no_realloc(str_c, sizeof(str_c), str_b);
|
|
CHECK_STR_EQUAL_RET_FALSE(str_c, "BBBB");
|
|
|
|
str_append_no_realloc(str_b, sizeof(str_b), str_c);
|
|
CHECK_STR_EQUAL_RET_FALSE(str_b, "BBBB");
|
|
|
|
return true;
|
|
}
|
|
|
|
static bool test_str_append()
|
|
{
|
|
printf("Test test_str_append\n");
|
|
char *str_a = NULL;
|
|
char *str_b = NULL;
|
|
CHECK_NULL_RET_FALSE(str_append(str_a, str_b));
|
|
|
|
str_a = calloc(5, sizeof(char));
|
|
memcpy(str_a, "AAAA", 5);
|
|
CHECK_NULL_RET_FALSE(str_append(str_a, str_b));
|
|
|
|
str_b = calloc(5, sizeof(char));
|
|
str_a = str_append(str_a, str_b);
|
|
CHECK_STR_EQUAL_RET_FALSE(str_a, "AAAA");
|
|
|
|
memcpy(str_b, "BBBB", 5);
|
|
str_a = str_append(str_a, str_b);
|
|
CHECK_STR_EQUAL_RET_FALSE(str_a, "AAAABBBB");
|
|
|
|
memset(str_a, 0, strlen(str_a) + 1);
|
|
str_a = str_append(str_a, str_b);
|
|
CHECK_STR_EQUAL_RET_FALSE(str_a, "BBBB");
|
|
free(str_a);
|
|
free(str_b);
|
|
|
|
return true;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
bool result = true;
|
|
result &= test_str_append();
|
|
result &= test_str_append_no_realloc();
|
|
|
|
if (result) {
|
|
printf("All tests passed.\n");
|
|
} else {
|
|
printf("Some tests failed.\n");
|
|
}
|
|
return result ? 0 : -1;
|
|
}
|