digiKam
heif_limits.h
Go to the documentation of this file.
1 /*
2  * HEIF codec.
3  * Copyright (c) 2018 struktur AG, Dirk Farin <farin@struktur.de>
4  *
5  * This file is part of libheif.
6  *
7  * libheif is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * libheif is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with libheif. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #ifndef LIBHEIF_HEIF_LIMITS_H
21 #define LIBHEIF_HEIF_LIMITS_H
22 
23 #if defined(HAVE_CONFIG_H)
24 #include "config.h"
25 #endif
26 
27 #include <cinttypes>
28 #include <cstddef>
29 
30 static const size_t MAX_CHILDREN_PER_BOX = 20000;
31 static const int MAX_ILOC_ITEMS = 20000;
32 static const int MAX_ILOC_EXTENTS_PER_ITEM = 32;
33 static const int MAX_MEMORY_BLOCK_SIZE = 512*1024*1024; // 512 MB
34 
35 // Artificial limit to avoid allocating too much memory.
36 // 32768^2 = 1.5 GB as YUV-4:2:0 or 4 GB as RGB32
37 static const int MAX_IMAGE_WIDTH = 32768;
38 static const int MAX_IMAGE_HEIGHT = 32768;
39 
40 // Maximum nesting level of boxes in input files.
41 // We put a limit on this to avoid unlimited stack usage by malicious input files.
42 static const int MAX_BOX_NESTING_LEVEL = 20;
43 
44 static const int MAX_BOX_SIZE = 0x7FFFFFFF; // 2 GB
45 static const int64_t MAX_LARGE_BOX_SIZE = 0x0FFFFFFFFFFFFFFF;
46 static const int64_t MAX_FILE_POS = 0x007FFFFFFFFFFFFFLL; // maximum file position
47 static const int MAX_FRACTION_VALUE = 0x10000;
48 
49 #endif // LIBHEIF_HEIF_LIMITS_H