Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ int main()
json &manifest = manifest_store["manifests"][active_manifest];

// scan the assertions for the training-mining assertion
string identifer = manifest["thumbnail"]["identifier"];
string identifier = manifest["thumbnail"]["identifier"];
Comment thread
tmathern marked this conversation as resolved.

reader.get_resource(identifer, thumbnail_path);
reader.get_resource(identifier, thumbnail_path);

cout << "thumbnail written to " << thumbnail_path << endl;
}
Expand Down
6 changes: 5 additions & 1 deletion include/c2pa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,11 @@ namespace c2pa

/// @brief Create a signer from a Signer pointer and take ownership of that pointer.
/// @param c_signer The C2paSigner pointer (must be non-null).
Signer(C2paSigner *c_signer) : signer(c_signer) {}
Signer(C2paSigner *c_signer) : signer(c_signer) {
if (!c_signer) {
throw C2paException("Signer can not be null");
}
}

/// @brief Create a Signer from signing credentials.
/// @param alg Signing algorithm name (e.g., "ps256", "es256").
Expand Down
18 changes: 17 additions & 1 deletion src/c2pa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,18 @@ inline std::vector<unsigned char> to_byte_vector(const unsigned char* data, int6
}

auto file = detail::open_file_binary<std::ifstream>(settings_path);

file->seekg(0, std::ios::end);
auto file_size = file->tellg();
file->seekg(0, std::ios::beg);
Comment thread
tmathern marked this conversation as resolved.
if (file_size < 0) {
throw C2paException("Settings file is not readable");
}
constexpr std::streamoff max_settings_size = 1024 * 1024; // 1 MB max, similar to c2pa-rs
if (file_size > max_settings_size) {
throw C2paException("Settings file is too large (>1MB)");
}

std::string json_content((std::istreambuf_iterator<char>(*file)), std::istreambuf_iterator<char>());

return with_json(json_content);
Expand Down Expand Up @@ -862,7 +874,11 @@ inline std::vector<unsigned char> to_byte_vector(const unsigned char* data, int6
/// @brief Get the size to reserve for a signature for this signer.
uintptr_t Signer::reserve_size()
{
return c2pa_signer_reserve_size(signer);
int64_t result = c2pa_signer_reserve_size(signer);
if (result < 0) {
throw C2paException();
Comment thread
tmathern marked this conversation as resolved.
}
return static_cast<uintptr_t>(result);
}

/// @brief Builder class for creating a manifest implementation.
Expand Down