aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/ocda
diff options
context:
space:
mode:
Diffstat (limited to 'src/sisudoc/ocda')
-rw-r--r--src/sisudoc/ocda/io_in/carried_names.d34
-rw-r--r--src/sisudoc/ocda/io_in/read_zip_pod.d6
2 files changed, 39 insertions, 1 deletions
diff --git a/src/sisudoc/ocda/io_in/carried_names.d b/src/sisudoc/ocda/io_in/carried_names.d
index 09e8912..84a4f3c 100644
--- a/src/sisudoc/ocda/io_in/carried_names.d
+++ b/src/sisudoc/ocda/io_in/carried_names.d
@@ -56,6 +56,40 @@
+/
module sisudoc.ocda.io_in.carried_names;
@safe:
+/+ ↓ how many members one pod archive may hold, for both writer and the reader
+ .
+ It was 500 set in the reader alone, determined when a pod held markup and
+ images. A pod that carries translation catalogues has a different
+ calculation, the count is driven by how many *files* a document is made of
+ times the number of languages it has (rather than document size). Here are
+ figures based on the document sample set:
+ .
+ entries ~= languages x (markup_files + po_files + 1)
+ + pot_files + images + 2
+ .
+ the_wealth_of_networks 213,405 words, 1 file per language
+ 12 languages -> 49 entries
+ live-manual 24,724 words, 20 files per language
+ 12 languages -> 506 entries
+ .
+ (the big book is not what runs into this; the modular manual is. At 500
+ live-manual was two languages from producing an archive spine writes and
+ then refuses to read).
+ .
+ 10,000 covers a hundred-insert manual in thirty languages, about 6,200
+ entries, with room. The number is deliberately well clear of any real
+ document rather than snug above the largest one known, because the two
+ errors are not comparable: too low refuses a legitimate document with a
+ message that reads as corruption, while too high defers to a size cap a
+ moment later.
+ .
+ This is the weakest of the three guards and is not what bounds resource
+ use. MAX_ENTRY_SIZE bounds any one member and MAX_TOTAL_SIZE bounds the
+ whole extraction, both checked before a byte is written. A count bounds
+ metadata and per-file syscalls, which at this order of magnitude is
+ nothing beside what the size caps already allow.
++/
+enum size_t MAX_POD_ENTRY_COUNT = 10_000;
/+ ↓ names that arrive from outside, and decide where a file gets written
.
A pod zip and a .ocda.db both carry files by name, and both can arrive
diff --git a/src/sisudoc/ocda/io_in/read_zip_pod.d b/src/sisudoc/ocda/io_in/read_zip_pod.d
index d0eb65a..18a957c 100644
--- a/src/sisudoc/ocda/io_in/read_zip_pod.d
+++ b/src/sisudoc/ocda/io_in/read_zip_pod.d
@@ -64,11 +64,15 @@ template spineExtractZipPod() {
import std.stdio;
import std.string : indexOf;
import sisudoc.ocda.zstd;
+ import sisudoc.ocda.io_in.carried_names : MAX_POD_ENTRY_COUNT;
/+ security limits for zip extraction +/
enum size_t MAX_ENTRY_SIZE = 50 * 1024 * 1024; /+ 50 MB per entry +/
enum size_t MAX_TOTAL_SIZE = 500 * 1024 * 1024; /+ 500 MB total +/
- enum size_t MAX_ENTRY_COUNT = 500; /+ max entries in archive +/
+ /+ ↓ the entry count now comes from carried_names, so that the writer is
+ held to the same number the reader enforces.
+ +/
+ alias MAX_ENTRY_COUNT = MAX_POD_ENTRY_COUNT;
enum size_t MAX_PATH_DEPTH = 10; /+ max path components +/
/+ allowed entry name pattern: alphanumeric, dots, dashes, underscores, forward slashes +/