contrib: More fixes for flags and logging migration

PiperOrigin-RevId: 483656661
Change-Id: I5b8783de3f9f48056779fcce832a5b23df74cb72
This commit is contained in:
Christian Blichmann 2022-10-25 06:33:13 -07:00 committed by Copybara-Service
parent 6fbfb8f9bd
commit 6222ffe04f
4 changed files with 20 additions and 13 deletions

View File

@ -14,8 +14,6 @@
#include "libidn2_sapi.h" // NOLINT(build/include)
#include <gflags/gflags.h>
#include <cstdlib>
#include <fstream>
#include <iostream>
@ -39,7 +37,7 @@ absl::StatusOr<std::string> IDN2Lib::ProcessErrors(
}
return absl::InvalidArgumentError("Unexpected error");
}
::sapi::v::RemotePtr p(reinterpret_cast<void*>(ptr.GetValue()));
sapi::v::RemotePtr p(reinterpret_cast<void*>(ptr.GetValue()));
auto maybe_untrusted_name = sandbox_->GetCString(p, kMaxDomainNameLength);
SAPI_RETURN_IF_ERROR(sandbox_->Free(&p));
if (!maybe_untrusted_name.ok()) {
@ -53,11 +51,16 @@ absl::StatusOr<std::string> IDN2Lib::ProcessErrors(
absl::StatusOr<std::string> IDN2Lib::idn2_register_u8(const char* ulabel,
const char* alabel) {
::std::optional<::sapi::v::ConstCStr> alabel_ptr, ulabel_ptr;
if (ulabel) ulabel_ptr.emplace(ulabel);
if (alabel) alabel_ptr.emplace(alabel);
::sapi::v::GenericPtr ptr;
::sapi::v::NullPtr null_ptr;
std::optional<sapi::v::ConstCStr> alabel_ptr;
std::optional<sapi::v::ConstCStr> ulabel_ptr;
if (ulabel) {
ulabel_ptr.emplace(ulabel);
}
if (alabel) {
alabel_ptr.emplace(alabel);
}
sapi::v::GenericPtr ptr;
sapi::v::NullPtr null_ptr;
const auto untrusted_res = api_.idn2_register_u8(
ulabel ? ulabel_ptr->PtrBefore() : &null_ptr,
alabel ? alabel_ptr->PtrBefore() : &null_ptr, ptr.PtrAfter(),
@ -69,8 +72,8 @@ absl::StatusOr<std::string> IDN2Lib::SapiGeneric(
const char* data,
absl::StatusOr<int> (IDN2Api::*cb)(sapi::v::Ptr* input,
sapi::v::Ptr* output, int flags)) {
::sapi::v::ConstCStr src(data);
::sapi::v::GenericPtr ptr;
sapi::v::ConstCStr src(data);
sapi::v::GenericPtr ptr;
absl::StatusOr<int> untrusted_res = ((api_).*(cb))(
src.PtrBefore(), ptr.PtrAfter(), IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL);

View File

@ -99,8 +99,8 @@ class LibXlsWorkbook {
private:
LibXlsWorkbook(LibxlsSapiSandbox* sandbox, xlsWorkBook* rwb, size_t count)
: sandbox_(CHECK_NOTNULL(sandbox)),
rwb_(CHECK_NOTNULL(rwb)),
: sandbox_(ABSL_DIE_IF_NULL(sandbox)),
rwb_(ABSL_DIE_IF_NULL(rwb)),
sheet_count_(count) {}
LibxlsSapiSandbox* sandbox_;

View File

@ -19,6 +19,7 @@ if(SAPI_BUILD_EXAMPLES)
helpers.cc
)
target_link_libraries(lodepng_unsandboxed PRIVATE
absl::check
lodepng
sapi::sapi
sapi::temp_file
@ -33,6 +34,7 @@ if(SAPI_BUILD_EXAMPLES)
helpers.cc
)
target_link_libraries(lodepng_sandboxed PRIVATE
absl::check
sapi_contrib::lodepng
sapi::sapi
sapi::temp_file
@ -49,6 +51,7 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
)
target_link_libraries(main_unit_test PRIVATE
sapi_contrib::lodepng
absl::check
absl::strings
absl::time
sapi::sapi

View File

@ -14,6 +14,7 @@
#include "helpers.h" // NOLINT(build/include)
#include "absl/log/check.h"
#include "absl/status/statusor.h"
#include "sandboxed_api/util/temp_file.h"
@ -39,6 +40,6 @@ std::string CreateTempDirAtCWD() {
cwd.append("/");
absl::StatusOr<std::string> result = sapi::CreateTempDir(cwd);
CHECK(result.ok()) << "Could not create temporary directory";
CHECK_OK(result) << "Could not create temporary directory";
return result.value();
}