diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2024-10-07 15:55:44 +0200 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2024-10-07 16:02:06 +0200 |
| commit | d61d86c73104d1aa84fd6ca506c2230e67727b17 (patch) | |
| tree | 50ff4649c75dbccf43ff63a59818d97c3a8b3e0d | |
| parent | 98ad351133592fe8ed8ff0f6aa311005c8c3dad8 (diff) | |
ftparchive: Mystrdup: Add safety check and bump buffer size
Add a safety check to ensure that the block were are allocating
actually fits the string we want to write. If it doesn't, abort
the program.
While we are here, bump the buffer size from 40 KiB to 4 MiB,
because why bother with smaller buffers.
| -rw-r--r-- | ftparchive/contents.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ftparchive/contents.cc b/ftparchive/contents.cc index 4835cc6dd..be75c4706 100644 --- a/ftparchive/contents.cc +++ b/ftparchive/contents.cc @@ -72,7 +72,9 @@ char *GenContents::Mystrdup(const char *From) unsigned int Len = strlen(From) + 1; if (StrLeft <= Len) { - StrLeft = 4096*10; + StrLeft = 4 * 1024 * 1024; + if (unlikely(StrLeft <= Len)) + abort(); StrPool = (char *)malloc(StrLeft); BigBlock *Block = new BigBlock; |
