mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
PtrBefore/PtrBoth/PtrAfter
This commit is contained in:
parent
418bc3f356
commit
b6a47abf01
|
@ -196,7 +196,7 @@ absl::Status LibTIFFMain(const absl::string_view srcfile) {
|
||||||
sapi::v::UShort v;
|
sapi::v::UShort v;
|
||||||
SAPI_ASSIGN_OR_RETURN(int return_value,
|
SAPI_ASSIGN_OR_RETURN(int return_value,
|
||||||
api.TIFFGetField2(&tif, TIFFTAG_YCBCRSUBSAMPLING,
|
api.TIFFGetField2(&tif, TIFFTAG_YCBCRSUBSAMPLING,
|
||||||
h.PtrBoth(), v.PtrBoth()));
|
h.PtrAfter(), v.PtrAfter()));
|
||||||
if (return_value == 0 || h.GetValue() != 2 || v.GetValue() != 2) {
|
if (return_value == 0 || h.GetValue() != 2 || v.GetValue() != 2) {
|
||||||
return absl::InternalError("Could not retrieve subsampling tag");
|
return absl::InternalError("Could not retrieve subsampling tag");
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ absl::Status LibTIFFMain(const absl::string_view srcfile) {
|
||||||
// Read a tile in decompressed form, but still YCbCr subsampled
|
// Read a tile in decompressed form, but still YCbCr subsampled
|
||||||
SAPI_ASSIGN_OR_RETURN(
|
SAPI_ASSIGN_OR_RETURN(
|
||||||
tsize_t new_sz,
|
tsize_t new_sz,
|
||||||
api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer.PtrBoth(), sz));
|
api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer.PtrAfter(), sz));
|
||||||
if (new_sz != sz) {
|
if (new_sz != sz) {
|
||||||
return absl::InternalError(absl::StrCat(
|
return absl::InternalError(absl::StrCat(
|
||||||
"Did not get expected result code from TIFFReadEncodedTile(): ", new_sz,
|
"Did not get expected result code from TIFFReadEncodedTile(): ", new_sz,
|
||||||
|
@ -246,10 +246,10 @@ absl::Status LibTIFFMain(const absl::string_view srcfile) {
|
||||||
kChannelsInPixel * kImageSize, " bytes"));
|
kChannelsInPixel * kImageSize, " bytes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sapi::v::Array<uint8_t> buffer2_(sz);
|
sapi::v::Array<uint8_t> buffer2(sz);
|
||||||
SAPI_ASSIGN_OR_RETURN(
|
SAPI_ASSIGN_OR_RETURN(
|
||||||
new_sz,
|
new_sz,
|
||||||
api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer2_.PtrBoth(), sz));
|
api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer2.PtrAfter(), sz));
|
||||||
if (new_sz != sz) {
|
if (new_sz != sz) {
|
||||||
return absl::InternalError(absl::StrCat(
|
return absl::InternalError(absl::StrCat(
|
||||||
"Did not get expected result code from TIFFReadEncodedTile(): ", new_sz,
|
"Did not get expected result code from TIFFReadEncodedTile(): ", new_sz,
|
||||||
|
@ -258,7 +258,7 @@ absl::Status LibTIFFMain(const absl::string_view srcfile) {
|
||||||
|
|
||||||
bool pixel_status_ok = true;
|
bool pixel_status_ok = true;
|
||||||
for (const auto& [id, data] : kLimits) {
|
for (const auto& [id, data] : kLimits) {
|
||||||
if (status = CheckRgbPixel(id, data, buffer2_); !status.ok()) {
|
if (status = CheckRgbPixel(id, data, buffer2); !status.ok()) {
|
||||||
LOG(ERROR) << "CheckRgbPixel failed:\n" << status.ToString() << '\n';
|
LOG(ERROR) << "CheckRgbPixel failed:\n" << status.ToString() << '\n';
|
||||||
}
|
}
|
||||||
pixel_status_ok &= status.ok();
|
pixel_status_ok &= status.ok();
|
||||||
|
@ -279,7 +279,7 @@ absl::Status LibTIFFMain(const absl::string_view srcfile) {
|
||||||
// read as rgba
|
// read as rgba
|
||||||
SAPI_ASSIGN_OR_RETURN(
|
SAPI_ASSIGN_OR_RETURN(
|
||||||
return_value,
|
return_value,
|
||||||
api.TIFFReadRGBATile(&tif2, 1 * 128, 2 * 128, rgba_buffer.PtrBoth()));
|
api.TIFFReadRGBATile(&tif2, 1 * 128, 2 * 128, rgba_buffer.PtrAfter()));
|
||||||
if (return_value == 0) {
|
if (return_value == 0) {
|
||||||
return absl::InternalError("TIFFReadRGBATile() returned failure code");
|
return absl::InternalError("TIFFReadRGBATile() returned failure code");
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ void TestWriting(const char* mode, int tiled, int height) {
|
||||||
tilebuffer.size());
|
tilebuffer.size());
|
||||||
|
|
||||||
status_or_int = api.TIFFWriteEncodedTile(
|
status_or_int = api.TIFFWriteEncodedTile(
|
||||||
&tif, i, tilebuffer_sapi.PtrBoth(), kTileBufferSize);
|
&tif, i, tilebuffer_sapi.PtrBefore(), kTileBufferSize);
|
||||||
ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteEncodedTile fatal error";
|
ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteEncodedTile fatal error";
|
||||||
EXPECT_THAT(status_or_int.value(), Eq(kTileBufferSize))
|
EXPECT_THAT(status_or_int.value(), Eq(kTileBufferSize))
|
||||||
<< "line " << i << ": expected " << kTileBufferSize << ", got "
|
<< "line " << i << ": expected " << kTileBufferSize << ", got "
|
||||||
|
@ -225,7 +225,7 @@ void TestWriting(const char* mode, int tiled, int height) {
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < height; ++i) {
|
for (int i = 0; i < height; ++i) {
|
||||||
sapi::v::UChar c(i);
|
sapi::v::UChar c(i);
|
||||||
status_or_long = api.TIFFWriteEncodedStrip(&tif, i, c.PtrBoth(), 1);
|
status_or_long = api.TIFFWriteEncodedStrip(&tif, i, c.PtrBefore(), 1);
|
||||||
ASSERT_THAT(status_or_long, IsOk())
|
ASSERT_THAT(status_or_long, IsOk())
|
||||||
<< "TIFFWriteEncodedStrip fatal error";
|
<< "TIFFWriteEncodedStrip fatal error";
|
||||||
EXPECT_THAT(status_or_int.value(), Eq(1))
|
EXPECT_THAT(status_or_int.value(), Eq(1))
|
||||||
|
|
|
@ -106,7 +106,7 @@ TEST(SandboxTest, LongTag) {
|
||||||
std::array<uint8_t, kSamplePerPixel> buffer = {0, 127, 255};
|
std::array<uint8_t, kSamplePerPixel> buffer = {0, 127, 255};
|
||||||
sapi::v::Array<uint8_t> buffer_sapi(buffer.data(), buffer.size());
|
sapi::v::Array<uint8_t> buffer_sapi(buffer.data(), buffer.size());
|
||||||
|
|
||||||
status_or_int = api.TIFFWriteScanline(&tif, buffer_sapi.PtrBoth(), 0, 0);
|
status_or_int = api.TIFFWriteScanline(&tif, buffer_sapi.PtrBefore(), 0, 0);
|
||||||
ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteScanline fatal error";
|
ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteScanline fatal error";
|
||||||
ASSERT_THAT(status_or_int.value(), Ne(-1)) << "Can't write image data";
|
ASSERT_THAT(status_or_int.value(), Ne(-1)) << "Can't write image data";
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ TEST(SandboxTest, RawDecode) {
|
||||||
sapi::v::UShort h;
|
sapi::v::UShort h;
|
||||||
sapi::v::UShort v;
|
sapi::v::UShort v;
|
||||||
absl::StatusOr<int> status_or_int = api.TIFFGetField2(
|
absl::StatusOr<int> status_or_int = api.TIFFGetField2(
|
||||||
&tif, TIFFTAG_YCBCRSUBSAMPLING, h.PtrBoth(), v.PtrBoth());
|
&tif, TIFFTAG_YCBCRSUBSAMPLING, h.PtrAfter(), v.PtrAfter());
|
||||||
ASSERT_THAT(status_or_int, IsOk()) << "TIFFGetField2 fatal error";
|
ASSERT_THAT(status_or_int, IsOk()) << "TIFFGetField2 fatal error";
|
||||||
EXPECT_THAT(
|
EXPECT_THAT(
|
||||||
status_or_int.value() == 0 || h.GetValue() != 2 || v.GetValue() != 2,
|
status_or_int.value() == 0 || h.GetValue() != 2 || v.GetValue() != 2,
|
||||||
|
@ -143,7 +143,7 @@ TEST(SandboxTest, RawDecode) {
|
||||||
sapi::v::Array<uint8_t> buffer(sz);
|
sapi::v::Array<uint8_t> buffer(sz);
|
||||||
// Read a tile in decompressed form, but still YCbCr subsampled
|
// Read a tile in decompressed form, but still YCbCr subsampled
|
||||||
status_or_long =
|
status_or_long =
|
||||||
api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer.PtrBoth(), sz);
|
api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer.PtrAfter(), sz);
|
||||||
ASSERT_THAT(status_or_long, IsOk()) << "TIFFReadEncodedTile fatal error";
|
ASSERT_THAT(status_or_long, IsOk()) << "TIFFReadEncodedTile fatal error";
|
||||||
EXPECT_THAT(status_or_long.value(), Eq(sz))
|
EXPECT_THAT(status_or_long.value(), Eq(sz))
|
||||||
<< "Did not get expected result code from TIFFReadEncodedTile()("
|
<< "Did not get expected result code from TIFFReadEncodedTile()("
|
||||||
|
@ -169,7 +169,7 @@ TEST(SandboxTest, RawDecode) {
|
||||||
|
|
||||||
sapi::v::Array<uint8_t> buffer2(sz);
|
sapi::v::Array<uint8_t> buffer2(sz);
|
||||||
status_or_long =
|
status_or_long =
|
||||||
api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer2.PtrBoth(), sz);
|
api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer2.PtrAfter(), sz);
|
||||||
ASSERT_THAT(status_or_long, IsOk()) << "TIFFReadEncodedTile fatal error";
|
ASSERT_THAT(status_or_long, IsOk()) << "TIFFReadEncodedTile fatal error";
|
||||||
EXPECT_THAT(status_or_long.value(), Eq(sz))
|
EXPECT_THAT(status_or_long.value(), Eq(sz))
|
||||||
<< "Did not get expected result code from TIFFReadEncodedTile()("
|
<< "Did not get expected result code from TIFFReadEncodedTile()("
|
||||||
|
@ -190,7 +190,7 @@ TEST(SandboxTest, RawDecode) {
|
||||||
|
|
||||||
sapi::v::Array<uint32_t> rgba_buffer(kImageSize);
|
sapi::v::Array<uint32_t> rgba_buffer(kImageSize);
|
||||||
status_or_int =
|
status_or_int =
|
||||||
api.TIFFReadRGBATile(&tif2, 1 * 128, 2 * 128, rgba_buffer.PtrBoth());
|
api.TIFFReadRGBATile(&tif2, 1 * 128, 2 * 128, rgba_buffer.PtrAfter());
|
||||||
ASSERT_THAT(status_or_int, IsOk()) << "TIFFReadRGBATile fatal error";
|
ASSERT_THAT(status_or_int, IsOk()) << "TIFFReadRGBATile fatal error";
|
||||||
EXPECT_THAT(status_or_int.value(), IsTrue())
|
EXPECT_THAT(status_or_int.value(), IsTrue())
|
||||||
<< "TIFFReadRGBATile() returned failure code";
|
<< "TIFFReadRGBATile() returned failure code";
|
||||||
|
|
|
@ -135,7 +135,7 @@ TEST(SandboxTest, ShortTag) {
|
||||||
std::array<uint8_t, kSamplePerPixel> buffer = {0, 127, 255};
|
std::array<uint8_t, kSamplePerPixel> buffer = {0, 127, 255};
|
||||||
sapi::v::Array<uint8_t> buffer_sapi(buffer.data(), buffer.size());
|
sapi::v::Array<uint8_t> buffer_sapi(buffer.data(), buffer.size());
|
||||||
|
|
||||||
status_or_int = api.TIFFWriteScanline(&tif, buffer_sapi.PtrBoth(), 0, 0);
|
status_or_int = api.TIFFWriteScanline(&tif, buffer_sapi.PtrBefore(), 0, 0);
|
||||||
ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteScanline fatal error";
|
ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteScanline fatal error";
|
||||||
ASSERT_THAT(status_or_int.value(), Ne(-1)) << "Can't write image data";
|
ASSERT_THAT(status_or_int.value(), Ne(-1)) << "Can't write image data";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user