Skip to content

Commit 71b888c

Browse files
committed
Fix CI
1 parent 563201a commit 71b888c

File tree

2 files changed

+64
-49
lines changed

2 files changed

+64
-49
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ jobs:
3434
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
3535
sudo apt-get -o Dpkg::Use-Pty=0 update
3636
sudo rm -f /var/lib/man-db/auto-update
37-
sudo apt-get -o Dpkg::Use-Pty=0 install -y cmake clang ninja-build
37+
sudo apt-get -o Dpkg::Use-Pty=0 install -y \
38+
cmake clang ninja-build protobuf-compiler libprotobuf-dev
3839
3940
- name: Compile mainline
4041
env:
@@ -54,7 +55,8 @@ jobs:
5455
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
5556
sudo apt-get -o Dpkg::Use-Pty=0 update
5657
sudo rm -f /var/lib/man-db/auto-update
57-
sudo apt-get -o Dpkg::Use-Pty=0 install -y cmake clang ninja-build
58+
sudo apt-get -o Dpkg::Use-Pty=0 install -y \
59+
cmake clang ninja-build protobuf-compiler libprotobuf-dev
5860
5961
- name: Compile deps target
6062
run: ./scripts/compile_target.sh deps

curl_fuzzer_scenario.cc

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -330,41 +330,47 @@ void DestroyScenarioState(void *ptr) {
330330
}
331331

332332
long ProtoToLong(const curl::fuzzer::proto::SetOption &option) {
333-
if(option.has_int32_value()) {
334-
return static_cast<long>(option.int32_value());
335-
}
336-
if(option.has_uint32_value()) {
337-
return static_cast<long>(option.uint32_value());
338-
}
339-
if(option.has_int64_value()) {
340-
return static_cast<long>(option.int64_value());
341-
}
342-
if(option.has_uint64_value()) {
343-
return static_cast<long>(option.uint64_value());
344-
}
345-
if(option.has_bool_value()) {
346-
return option.bool_value() ? 1L : 0L;
347-
}
348-
if(option.has_double_value()) {
349-
return static_cast<long>(option.double_value());
333+
switch(option.value_case()) {
334+
case curl::fuzzer::proto::SetOption::kInt32Value:
335+
return static_cast<long>(option.int32_value());
336+
case curl::fuzzer::proto::SetOption::kUint32Value:
337+
return static_cast<long>(option.uint32_value());
338+
case curl::fuzzer::proto::SetOption::kInt64Value:
339+
return static_cast<long>(option.int64_value());
340+
case curl::fuzzer::proto::SetOption::kUint64Value:
341+
return static_cast<long>(option.uint64_value());
342+
case curl::fuzzer::proto::SetOption::kBoolValue:
343+
return option.bool_value() ? 1L : 0L;
344+
case curl::fuzzer::proto::SetOption::kDoubleValue:
345+
return static_cast<long>(option.double_value());
346+
case curl::fuzzer::proto::SetOption::kStringValue:
347+
case curl::fuzzer::proto::SetOption::kBytesValue:
348+
case curl::fuzzer::proto::SetOption::VALUE_NOT_SET:
349+
return 0L;
350+
default:
351+
return 0L;
350352
}
351-
return 0L;
352353
}
353354

354355
curl_off_t ProtoToOffT(const curl::fuzzer::proto::SetOption &option) {
355-
if(option.has_uint64_value()) {
356-
return static_cast<curl_off_t>(option.uint64_value());
357-
}
358-
if(option.has_int64_value()) {
359-
return static_cast<curl_off_t>(option.int64_value());
360-
}
361-
if(option.has_uint32_value()) {
362-
return static_cast<curl_off_t>(option.uint32_value());
363-
}
364-
if(option.has_int32_value()) {
365-
return static_cast<curl_off_t>(option.int32_value());
356+
switch(option.value_case()) {
357+
case curl::fuzzer::proto::SetOption::kUint64Value:
358+
return static_cast<curl_off_t>(option.uint64_value());
359+
case curl::fuzzer::proto::SetOption::kInt64Value:
360+
return static_cast<curl_off_t>(option.int64_value());
361+
case curl::fuzzer::proto::SetOption::kUint32Value:
362+
return static_cast<curl_off_t>(option.uint32_value());
363+
case curl::fuzzer::proto::SetOption::kInt32Value:
364+
return static_cast<curl_off_t>(option.int32_value());
365+
case curl::fuzzer::proto::SetOption::kBoolValue:
366+
case curl::fuzzer::proto::SetOption::kDoubleValue:
367+
case curl::fuzzer::proto::SetOption::kStringValue:
368+
case curl::fuzzer::proto::SetOption::kBytesValue:
369+
case curl::fuzzer::proto::SetOption::VALUE_NOT_SET:
370+
return static_cast<curl_off_t>(ProtoToLong(option));
371+
default:
372+
return static_cast<curl_off_t>(ProtoToLong(option));
366373
}
367-
return static_cast<curl_off_t>(ProtoToLong(option));
368374
}
369375

370376
int EnsureOptionUnset(FUZZ_DATA *fuzz, CURLoption opt, const OptionDescriptor *desc) {
@@ -426,23 +432,28 @@ int ApplySetOption(const curl::fuzzer::proto::SetOption &option,
426432
case OptionValueKind::kString: {
427433
const char *value = nullptr;
428434
std::string detail;
429-
if(option.has_string_value()) {
430-
detail = std::string("string ") + SummarizeText(option.string_value());
431-
value = state->CopyString(option.string_value());
432-
}
433-
else if(option.has_bytes_value()) {
434-
detail = std::string("bytes ") + SummarizeBinary(option.bytes_value());
435-
auto view = state->CopyBytes(option.bytes_value());
436-
if(view.second == 0 || view.first == nullptr) {
437-
value = state->CopyString("");
435+
switch(option.value_case()) {
436+
case curl::fuzzer::proto::SetOption::kStringValue: {
437+
detail = std::string("string ") + SummarizeText(option.string_value());
438+
value = state->CopyString(option.string_value());
439+
break;
438440
}
439-
else {
440-
value = state->CopyString(std::string_view(reinterpret_cast<const char *>(view.first), view.second));
441+
case curl::fuzzer::proto::SetOption::kBytesValue: {
442+
detail = std::string("bytes ") + SummarizeBinary(option.bytes_value());
443+
auto view = state->CopyBytes(option.bytes_value());
444+
if(view.second == 0 || view.first == nullptr) {
445+
value = state->CopyString("");
446+
}
447+
else {
448+
value = state->CopyString(std::string_view(reinterpret_cast<const char *>(view.first), view.second));
449+
}
450+
break;
451+
}
452+
default: {
453+
detail = "string <empty>";
454+
value = state->CopyString("");
455+
break;
441456
}
442-
}
443-
else {
444-
detail = "string <empty>";
445-
value = state->CopyString("");
446457
}
447458
rc = EnsureOptionUnset(fuzz, desc->curlopt, desc);
448459
if(rc != 0) {
@@ -497,11 +508,13 @@ int ApplySetOption(const curl::fuzzer::proto::SetOption &option,
497508
if(rc != 0) {
498509
return rc;
499510
}
500-
long value = option.has_bool_value() ? (option.bool_value() ? 1L : 0L) : ProtoToLong(option);
511+
const bool has_bool_value =
512+
option.value_case() == curl::fuzzer::proto::SetOption::kBoolValue;
513+
long value = has_bool_value ? (option.bool_value() ? 1L : 0L) : ProtoToLong(option);
501514
rc = ApplyLongOption(fuzz, desc, value);
502515
if(rc == 0 && fuzz->verbose) {
503516
std::string detail;
504-
if(option.has_bool_value()) {
517+
if(has_bool_value) {
505518
detail = std::string("bool=") + (option.bool_value() ? "true" : "false");
506519
}
507520
else {

0 commit comments

Comments
 (0)