mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
contrib: More fixes for flags and logging migration
PiperOrigin-RevId: 483656661 Change-Id: I5b8783de3f9f48056779fcce832a5b23df74cb72
This commit is contained in:
parent
6fbfb8f9bd
commit
6222ffe04f
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
#include "libidn2_sapi.h" // NOLINT(build/include)
|
#include "libidn2_sapi.h" // NOLINT(build/include)
|
||||||
|
|
||||||
#include <gflags/gflags.h>
|
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -39,7 +37,7 @@ absl::StatusOr<std::string> IDN2Lib::ProcessErrors(
|
||||||
}
|
}
|
||||||
return absl::InvalidArgumentError("Unexpected error");
|
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);
|
auto maybe_untrusted_name = sandbox_->GetCString(p, kMaxDomainNameLength);
|
||||||
SAPI_RETURN_IF_ERROR(sandbox_->Free(&p));
|
SAPI_RETURN_IF_ERROR(sandbox_->Free(&p));
|
||||||
if (!maybe_untrusted_name.ok()) {
|
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,
|
absl::StatusOr<std::string> IDN2Lib::idn2_register_u8(const char* ulabel,
|
||||||
const char* alabel) {
|
const char* alabel) {
|
||||||
::std::optional<::sapi::v::ConstCStr> alabel_ptr, ulabel_ptr;
|
std::optional<sapi::v::ConstCStr> alabel_ptr;
|
||||||
if (ulabel) ulabel_ptr.emplace(ulabel);
|
std::optional<sapi::v::ConstCStr> ulabel_ptr;
|
||||||
if (alabel) alabel_ptr.emplace(alabel);
|
if (ulabel) {
|
||||||
::sapi::v::GenericPtr ptr;
|
ulabel_ptr.emplace(ulabel);
|
||||||
::sapi::v::NullPtr null_ptr;
|
}
|
||||||
|
if (alabel) {
|
||||||
|
alabel_ptr.emplace(alabel);
|
||||||
|
}
|
||||||
|
sapi::v::GenericPtr ptr;
|
||||||
|
sapi::v::NullPtr null_ptr;
|
||||||
const auto untrusted_res = api_.idn2_register_u8(
|
const auto untrusted_res = api_.idn2_register_u8(
|
||||||
ulabel ? ulabel_ptr->PtrBefore() : &null_ptr,
|
ulabel ? ulabel_ptr->PtrBefore() : &null_ptr,
|
||||||
alabel ? alabel_ptr->PtrBefore() : &null_ptr, ptr.PtrAfter(),
|
alabel ? alabel_ptr->PtrBefore() : &null_ptr, ptr.PtrAfter(),
|
||||||
|
@ -69,8 +72,8 @@ absl::StatusOr<std::string> IDN2Lib::SapiGeneric(
|
||||||
const char* data,
|
const char* data,
|
||||||
absl::StatusOr<int> (IDN2Api::*cb)(sapi::v::Ptr* input,
|
absl::StatusOr<int> (IDN2Api::*cb)(sapi::v::Ptr* input,
|
||||||
sapi::v::Ptr* output, int flags)) {
|
sapi::v::Ptr* output, int flags)) {
|
||||||
::sapi::v::ConstCStr src(data);
|
sapi::v::ConstCStr src(data);
|
||||||
::sapi::v::GenericPtr ptr;
|
sapi::v::GenericPtr ptr;
|
||||||
|
|
||||||
absl::StatusOr<int> untrusted_res = ((api_).*(cb))(
|
absl::StatusOr<int> untrusted_res = ((api_).*(cb))(
|
||||||
src.PtrBefore(), ptr.PtrAfter(), IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL);
|
src.PtrBefore(), ptr.PtrAfter(), IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL);
|
||||||
|
|
|
@ -99,8 +99,8 @@ class LibXlsWorkbook {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LibXlsWorkbook(LibxlsSapiSandbox* sandbox, xlsWorkBook* rwb, size_t count)
|
LibXlsWorkbook(LibxlsSapiSandbox* sandbox, xlsWorkBook* rwb, size_t count)
|
||||||
: sandbox_(CHECK_NOTNULL(sandbox)),
|
: sandbox_(ABSL_DIE_IF_NULL(sandbox)),
|
||||||
rwb_(CHECK_NOTNULL(rwb)),
|
rwb_(ABSL_DIE_IF_NULL(rwb)),
|
||||||
sheet_count_(count) {}
|
sheet_count_(count) {}
|
||||||
|
|
||||||
LibxlsSapiSandbox* sandbox_;
|
LibxlsSapiSandbox* sandbox_;
|
||||||
|
|
|
@ -19,6 +19,7 @@ if(SAPI_BUILD_EXAMPLES)
|
||||||
helpers.cc
|
helpers.cc
|
||||||
)
|
)
|
||||||
target_link_libraries(lodepng_unsandboxed PRIVATE
|
target_link_libraries(lodepng_unsandboxed PRIVATE
|
||||||
|
absl::check
|
||||||
lodepng
|
lodepng
|
||||||
sapi::sapi
|
sapi::sapi
|
||||||
sapi::temp_file
|
sapi::temp_file
|
||||||
|
@ -33,6 +34,7 @@ if(SAPI_BUILD_EXAMPLES)
|
||||||
helpers.cc
|
helpers.cc
|
||||||
)
|
)
|
||||||
target_link_libraries(lodepng_sandboxed PRIVATE
|
target_link_libraries(lodepng_sandboxed PRIVATE
|
||||||
|
absl::check
|
||||||
sapi_contrib::lodepng
|
sapi_contrib::lodepng
|
||||||
sapi::sapi
|
sapi::sapi
|
||||||
sapi::temp_file
|
sapi::temp_file
|
||||||
|
@ -49,6 +51,7 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
|
||||||
)
|
)
|
||||||
target_link_libraries(main_unit_test PRIVATE
|
target_link_libraries(main_unit_test PRIVATE
|
||||||
sapi_contrib::lodepng
|
sapi_contrib::lodepng
|
||||||
|
absl::check
|
||||||
absl::strings
|
absl::strings
|
||||||
absl::time
|
absl::time
|
||||||
sapi::sapi
|
sapi::sapi
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "helpers.h" // NOLINT(build/include)
|
#include "helpers.h" // NOLINT(build/include)
|
||||||
|
|
||||||
|
#include "absl/log/check.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "sandboxed_api/util/temp_file.h"
|
#include "sandboxed_api/util/temp_file.h"
|
||||||
|
|
||||||
|
@ -39,6 +40,6 @@ std::string CreateTempDirAtCWD() {
|
||||||
cwd.append("/");
|
cwd.append("/");
|
||||||
|
|
||||||
absl::StatusOr<std::string> result = sapi::CreateTempDir(cwd);
|
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();
|
return result.value();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user