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
82 lines
2.3 KiB
C++
82 lines
2.3 KiB
C++
// RUN: %clangxx_msan -O0 %s -o %t && %run %t
|
|
// RUN: not %run %t NTOP_READ 2>&1 | FileCheck %s --check-prefix=NTOP_READ
|
|
// RUN: not %run %t PTON_READ 2>&1 | FileCheck %s --check-prefix=PTON_READ
|
|
|
|
#include <assert.h>
|
|
#include <resolv.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <sanitizer/msan_interface.h>
|
|
|
|
int main(int iArgc, char *szArgv[]) {
|
|
char* test = nullptr;
|
|
if (iArgc > 1) {
|
|
test = szArgv[1];
|
|
}
|
|
|
|
if (test == nullptr) {
|
|
// Check NTOP writing
|
|
const char *src = "base64 test data";
|
|
size_t src_len = strlen(src);
|
|
size_t dst_len = ((src_len + 2) / 3) * 4 + 1;
|
|
char dst[dst_len];
|
|
int res = b64_ntop(reinterpret_cast<const unsigned char *>(src), src_len,
|
|
dst, dst_len);
|
|
assert(res >= 0);
|
|
__msan_check_mem_is_initialized(dst, res);
|
|
|
|
// Check PTON writing
|
|
unsigned char target[dst_len];
|
|
res = b64_pton(dst, target, dst_len);
|
|
assert(res >= 0);
|
|
__msan_check_mem_is_initialized(target, res);
|
|
|
|
// Check NTOP writing for zero length src
|
|
src = "";
|
|
src_len = strlen(src);
|
|
assert(((src_len + 2) / 3) * 4 + 1 < dst_len);
|
|
res = b64_ntop(reinterpret_cast<const unsigned char *>(src), src_len,
|
|
dst, dst_len);
|
|
assert(res >= 0);
|
|
__msan_check_mem_is_initialized(dst, res);
|
|
|
|
// Check PTON writing for zero length src
|
|
dst[0] = '\0';
|
|
res = b64_pton(dst, target, dst_len);
|
|
assert(res >= 0);
|
|
__msan_check_mem_is_initialized(target, res);
|
|
|
|
return 0;
|
|
}
|
|
|
|
if (strcmp(test, "NTOP_READ") == 0) {
|
|
// Check NTOP reading
|
|
size_t src_len = 80;
|
|
char src[src_len];
|
|
__msan_poison(src, src_len);
|
|
size_t dst_len = ((src_len + 2) / 3) * 4 + 1;
|
|
char dst[dst_len];
|
|
int res = b64_ntop(reinterpret_cast<const unsigned char *>(src), src_len,
|
|
dst, dst_len);
|
|
// NTOP_READ: Uninitialized bytes in __b64_ntop
|
|
return 0;
|
|
}
|
|
|
|
if (strcmp(test, "PTON_READ") == 0) {
|
|
// Check PTON reading
|
|
size_t src_len = 80;
|
|
char src[src_len];
|
|
strcpy(src, "junk longer than zero");
|
|
// pretend it is uninitialized
|
|
__msan_poison(src, src_len);
|
|
unsigned char target[src_len];
|
|
int res = b64_pton(src, target, src_len);
|
|
// PTON_READ: Uninitialized bytes in __b64_pton
|
|
return 0;
|
|
}
|
|
|
|
return 0;
|
|
}
|