Skip to content

Commit

Permalink
Add pointer null checks, and -fanalyzer switch for Debug CMake build
Browse files Browse the repository at this point in the history
  • Loading branch information
szszszsz committed Jun 20, 2023
1 parent e4167bd commit 579cba2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-guess-branch-probability -Wdate-time -f
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gno-record-gcc-switches ")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdebug-prefix-map=${CMAKE_CURRENT_BINARY_DIR}=heads")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fanalyzer")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "-O1 -fsanitize=address")

Expand Down
3 changes: 3 additions & 0 deletions src/operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ bool verify_base32(const char *string, size_t len) {
}

int set_secret_on_device(struct Device *dev, const char *OTP_secret_base32, const char *admin_PIN, const uint64_t hotp_counter) {
rassert(OTP_secret_base32 != nullptr);
rassert(dev != nullptr);
rassert(admin_PIN != nullptr);
int res;
//Make sure secret is parsable
const size_t base32_string_length_limit = BASE32_LEN(HOTP_SECRET_SIZE_BYTES);
Expand Down

0 comments on commit 579cba2

Please sign in to comment.