oss-fuzz/projects/openvswitch/ofp_print_target.c

54 lines
1.5 KiB
C
Raw Normal View History

/*
# Copyright 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
*/
#include "dp-packet.h"
#include "openvswitch/ofpbuf.h"
#include "openvswitch/ofp-print.h"
Ovs syslog disable (#1557) * OpenvSwitch integration: First commit * OpenvSwitch integration: Fixed typo in Dockerfile * OpenvSwitch integration: Fixed typo in build file * OpenvSwitch integration: Fixed issues copying dict and fuzzer opetions * OpenvSwitch integration: Added one more target and streamlined build * Revert "OpenvSwitch integration: Added one more target and streamlined build" This reverts commit c5945ff8ce3d14097d15a4e8b69dbee81a3b44b9. * Revert "Revert "OpenvSwitch integration: Added one more target and streamlined build"" This reverts commit 43127a82c0314a82185ee7755015948170cc0675. * Revert "Revert "Revert "OpenvSwitch integration: Added one more target and streamlined build""" This reverts commit 7fcb9a2470defb4b05d34c94bbebe9e54bca7e79. * Revert "OpenvSwitch integration: Fixed issues copying dict and fuzzer opetions" This reverts commit dc356a9d46ec23e966d200031f0b57e220332208. * Revert "OpenvSwitch integration: Fixed typo in build file" This reverts commit 83e4a95a59ffbccc8db96ad14abd21f69d3e8176. * Revert "OpenvSwitch integration: Fixed typo in Dockerfile" This reverts commit dcbdb2c485183448bba91c1d25682a1d8723a915. * Revert "OpenvSwitch integration: First commit" This reverts commit 2faf845b27d482522952f71d29c1008dc8f85c85. * openvswitch: OSS-Fuzz integration * Openvswitch: Fix indenting and newlines * Addressing comments by jonathanmetzman * Openvswitch: Added json dict and seperated fuzzer options per target * Openvswitch: Disables logging so that syslog is not spammed while fuzzing
2018-06-23 23:40:18 +00:00
#include "openvswitch/vlog.h"
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
struct ofpbuf b;
if (size < sizeof(struct ofp_header)) return 0;
Ovs syslog disable (#1557) * OpenvSwitch integration: First commit * OpenvSwitch integration: Fixed typo in Dockerfile * OpenvSwitch integration: Fixed typo in build file * OpenvSwitch integration: Fixed issues copying dict and fuzzer opetions * OpenvSwitch integration: Added one more target and streamlined build * Revert "OpenvSwitch integration: Added one more target and streamlined build" This reverts commit c5945ff8ce3d14097d15a4e8b69dbee81a3b44b9. * Revert "Revert "OpenvSwitch integration: Added one more target and streamlined build"" This reverts commit 43127a82c0314a82185ee7755015948170cc0675. * Revert "Revert "Revert "OpenvSwitch integration: Added one more target and streamlined build""" This reverts commit 7fcb9a2470defb4b05d34c94bbebe9e54bca7e79. * Revert "OpenvSwitch integration: Fixed issues copying dict and fuzzer opetions" This reverts commit dc356a9d46ec23e966d200031f0b57e220332208. * Revert "OpenvSwitch integration: Fixed typo in build file" This reverts commit 83e4a95a59ffbccc8db96ad14abd21f69d3e8176. * Revert "OpenvSwitch integration: Fixed typo in Dockerfile" This reverts commit dcbdb2c485183448bba91c1d25682a1d8723a915. * Revert "OpenvSwitch integration: First commit" This reverts commit 2faf845b27d482522952f71d29c1008dc8f85c85. * openvswitch: OSS-Fuzz integration * Openvswitch: Fix indenting and newlines * Addressing comments by jonathanmetzman * Openvswitch: Added json dict and seperated fuzzer options per target * Openvswitch: Disables logging so that syslog is not spammed while fuzzing
2018-06-23 23:40:18 +00:00
vlog_set_verbosity("off");
ofpbuf_use_const(&b, data, size);
for (;;) {
struct ofp_header *oh;
size_t length, tail_len;
void *tail;
// Check if ofpbuf contains ofp header
oh = (struct ofp_header *)ofpbuf_at(&b, 0, sizeof *oh);
if (!oh) break;
// Check if length is geq than lower bound
length = ntohs(oh->length);
if (length < sizeof *oh) break;
// Check if ofpbuf contains payload
tail_len = length - sizeof *oh;
tail = ofpbuf_at(&b, sizeof *oh, tail_len);
if (!tail) break;
ofp_print(stdout, ofpbuf_pull(&b, length), length, NULL, NULL, 2);
}
ofpbuf_uninit(&b);
return 0;
Ovs syslog disable (#1557) * OpenvSwitch integration: First commit * OpenvSwitch integration: Fixed typo in Dockerfile * OpenvSwitch integration: Fixed typo in build file * OpenvSwitch integration: Fixed issues copying dict and fuzzer opetions * OpenvSwitch integration: Added one more target and streamlined build * Revert "OpenvSwitch integration: Added one more target and streamlined build" This reverts commit c5945ff8ce3d14097d15a4e8b69dbee81a3b44b9. * Revert "Revert "OpenvSwitch integration: Added one more target and streamlined build"" This reverts commit 43127a82c0314a82185ee7755015948170cc0675. * Revert "Revert "Revert "OpenvSwitch integration: Added one more target and streamlined build""" This reverts commit 7fcb9a2470defb4b05d34c94bbebe9e54bca7e79. * Revert "OpenvSwitch integration: Fixed issues copying dict and fuzzer opetions" This reverts commit dc356a9d46ec23e966d200031f0b57e220332208. * Revert "OpenvSwitch integration: Fixed typo in build file" This reverts commit 83e4a95a59ffbccc8db96ad14abd21f69d3e8176. * Revert "OpenvSwitch integration: Fixed typo in Dockerfile" This reverts commit dcbdb2c485183448bba91c1d25682a1d8723a915. * Revert "OpenvSwitch integration: First commit" This reverts commit 2faf845b27d482522952f71d29c1008dc8f85c85. * openvswitch: OSS-Fuzz integration * Openvswitch: Fix indenting and newlines * Addressing comments by jonathanmetzman * Openvswitch: Added json dict and seperated fuzzer options per target * Openvswitch: Disables logging so that syslog is not spammed while fuzzing
2018-06-23 23:40:18 +00:00
}