Skip to content

Commit

Permalink
[Fuzzing] oss-fuzz cifuzz (#587)
Browse files Browse the repository at this point in the history
* [Fuzzing] oss-fuzz cifuzz

Signed-off-by: Arjun Singh <ajsinghyadav00@gmail.com>
  • Loading branch information
0x34d committed Jun 3, 2023
1 parent dc13f3e commit 93a40b3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sanitizer: [address, undefined, memory]
steps:
- name: Build Fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'lldpd'
dry-run: false
language: c
sanitizer: ${{ matrix.sanitizer }}
- name: Run Fuzzers (${{ matrix.sanitizer }})
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'lldpd'
dry-run: false
language: c
fuzz-seconds: 300
sanitizer: ${{ matrix.sanitizer }}
- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure() && steps.build.outcome == 'success'
with:
name: ${{ matrix.sanitizer }}-artifacts
path: ./out/artifacts
6 changes: 3 additions & 3 deletions src/daemon/protocols/edp.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,14 @@ edp_decode(struct lldpd *cfg, char *frame, int s, struct lldpd_hardware *hardwar
edp_slot = PEEK_UINT16;
edp_port = PEEK_UINT16;
free(port->p_id);
if (asprintf(&port->p_id, "%d/%d", edp_slot + 1,
edp_port + 1) == -1) {
port->p_id_len =
asprintf(&port->p_id, "%d/%d", edp_slot + 1, edp_port + 1);
if (port->p_id_len == -1) {
log_warn("edp",
"unable to allocate memory for "
"port ID");
goto malformed;
}
port->p_id_len = strlen(port->p_id);
free(port->p_descr);
if (asprintf(&port->p_descr, "Slot %d / Port %d", edp_slot + 1,
edp_port + 1) == -1) {
Expand Down
6 changes: 4 additions & 2 deletions src/daemon/protocols/sonmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,14 @@ sonmp_decode(struct lldpd *cfg, char *frame, int s, struct lldpd_hardware *hardw
port->p_ttl = (port->p_ttl + 999) / 1000;

port->p_id_subtype = LLDP_PORTID_SUBTYPE_LOCAL;
if (asprintf(&port->p_id, "%02x-%02x-%02x", seg[0], seg[1], seg[2]) == -1) {

port->p_id_len =
asprintf(&port->p_id, "%02x-%02x-%02x", seg[0], seg[1], seg[2]);
if (port->p_id_len == -1) {
log_warn("sonmp", "unable to allocate memory for port id on %s",
hardware->h_ifname);
goto malformed;
}
port->p_id_len = strlen(port->p_id);

/* Port description depend on the number of segments */
if ((seg[0] == 0) && (seg[1] == 0)) {
Expand Down
2 changes: 1 addition & 1 deletion src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static void
vlog(int pri, const char *token, const char *fmt, va_list ap)
{
if (logh) {
char *result;
char *result = NULL;
if (vasprintf(&result, fmt, ap) != -1) {
logh(pri, result);
free(result);
Expand Down

0 comments on commit 93a40b3

Please sign in to comment.