Skip to content

Commit c472595

Browse files
committed
test fuzzing.
1 parent bf16652 commit c472595

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

.github/workflows/cifuzz.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
steps:
1414
- name: Build Fuzzers
1515
id: build
16-
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
16+
uses: Li-Aaron/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
1717
with:
1818
oss-fuzz-project-name: 'libspdm'
1919
- name: Run Fuzzers
20-
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
20+
uses: Li-Aaron/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
2121
with:
2222
oss-fuzz-project-name: 'libspdm'
2323
fuzz-seconds: 600

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ execute_process(COMMAND uname OUTPUT_VARIABLE uname)
882882
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR uname MATCHES "^MINGW")
883883
add_custom_command(TARGET copy_sample_key
884884
PRE_BUILD
885-
COMMAND cp -r -f ${LIBSPDM_DIR}/unit_test/sample_key/* ${EXECUTABLE_OUTPUT_PATH})
885+
COMMAND cp -r -v -f ${LIBSPDM_DIR}/unit_test/sample_key/* ${EXECUTABLE_OUTPUT_PATH})
886886
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
887887
string(REPLACE "/" "\\" SRC ${LIBSPDM_DIR}/unit_test/sample_key/*)
888888
if(CMAKE_GENERATOR MATCHES "^Visual Studio")

library/spdm_responder_lib/libspdm_rsp_encap_challenge.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ libspdm_return_t libspdm_process_encap_response_challenge_auth(
261261
spdm_context, false, signature, signature_size);
262262
if (!result) {
263263
return LIBSPDM_STATUS_VERIF_FAIL;
264+
} else {
265+
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "aaaaaa\n"));
264266
}
265267

266268
libspdm_set_connection_state(spdm_context,

unit_test/fuzzing/spdm_unit_fuzzing_common/common.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,36 @@ bool libspdm_read_input_file(const char *file_name, void **file_data,
120120
FILE *fp_in;
121121
size_t temp_result;
122122

123+
printf("File name: %s\n", file_name);
124+
125+
char cwd[1024];
126+
if (getcwd(cwd, sizeof(cwd)) != NULL) {
127+
printf("Current working directory: %s\n", cwd);
128+
} else {
129+
perror("getcwd() error");
130+
}
131+
132+
printf("Listing current directory:\n");
133+
system("ls -l");
134+
/* List all directories in the current directory */
135+
FILE *ls_pipe = popen("ls -l | awk '/^d/ {print $9}'", "r");
136+
if (ls_pipe != NULL) {
137+
char dir_name[1024];
138+
printf("Listing subdirectories:\n");
139+
while (fgets(dir_name, sizeof(dir_name), ls_pipe) != NULL) {
140+
/* Remove trailing newline */
141+
size_t len = strlen(dir_name);
142+
if (len > 0 && dir_name[len - 1] == '\n') {
143+
dir_name[len - 1] = '\0';
144+
}
145+
printf("ls -l %s:\n", dir_name);
146+
char cmd[1060];
147+
snprintf(cmd, sizeof(cmd), "ls -l \"%s\"", dir_name);
148+
system(cmd);
149+
}
150+
pclose(ls_pipe);
151+
}
152+
123153
if ((fp_in = fopen(file_name, "rb")) == NULL) {
124154
printf("Unable to open file %s\n", file_name);
125155
*file_data = NULL;

unit_test/fuzzing/spdm_unit_fuzzing_common/spdm_unit_fuzzing.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
#ifndef __SPDM_UNIT_FUZZING_H__
88
#define __SPDM_UNIT_FUZZING_H__
9-
9+
#define _GNU_SOURCE
1010
#include <string.h>
1111
#include <stdarg.h>
1212
#include <stddef.h>
1313
#include <setjmp.h>
1414
#include <stdint.h>
1515
#include <stdlib.h>
1616
#include <stdio.h>
17+
#include <unistd.h>
1718

1819
#include "hal/base.h"
1920
#include "hal/library/memlib.h"

0 commit comments

Comments
 (0)