CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
56 lines
1.7 KiB
C
56 lines
1.7 KiB
C
// Test strict_string_checks option in atol function
|
|
// RUN: %clang_asan %s -o %t
|
|
// RUN: %run %t test1 2>&1
|
|
// RUN: %env_asan_opts=strict_string_checks=false %run %t test1 2>&1
|
|
// RUN: %env_asan_opts=strict_string_checks=true not %run %t test1 2>&1 | FileCheck %s --check-prefix=CHECK1
|
|
// RUN: %run %t test2 2>&1
|
|
// RUN: %env_asan_opts=strict_string_checks=false %run %t test2 2>&1
|
|
// RUN: %env_asan_opts=strict_string_checks=true not %run %t test2 2>&1 | FileCheck %s --check-prefix=CHECK2
|
|
// RUN: %run %t test3 2>&1
|
|
// RUN: %env_asan_opts=strict_string_checks=false %run %t test3 2>&1
|
|
// RUN: %env_asan_opts=strict_string_checks=true not %run %t test3 2>&1 | FileCheck %s --check-prefix=CHECK3
|
|
|
|
#include <assert.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
void test1(char *array) {
|
|
// Last symbol is non-digit
|
|
memset(array, '1', 10);
|
|
array[9] = 'a';
|
|
long r = atol(array);
|
|
assert(r == 111111111);
|
|
}
|
|
|
|
void test2(char *array) {
|
|
// Single non-digit symbol
|
|
array[9] = 'a';
|
|
long r = atol(array + 9);
|
|
assert(r == 0);
|
|
}
|
|
|
|
void test3(char *array) {
|
|
// Incorrect number format
|
|
memset(array, ' ', 10);
|
|
array[9] = '-';
|
|
array[8] = '-';
|
|
long r = atol(array);
|
|
assert(r == 0);
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
char *array = (char*)malloc(10);
|
|
if (argc != 2) return 1;
|
|
if (!strcmp(argv[1], "test1")) test1(array);
|
|
// CHECK1: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}}
|
|
// CHECK1: READ of size 11
|
|
if (!strcmp(argv[1], "test2")) test2(array);
|
|
// CHECK2: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}}
|
|
// CHECK2: READ of size 2
|
|
if (!strcmp(argv[1], "test3")) test3(array);
|
|
// CHECK3: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}}
|
|
// CHECK3: READ of size 11
|
|
free(array);
|
|
return 0;
|
|
}
|