summaryrefslogtreecommitdiff
path: root/src/file.h
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2021-02-05 21:33:49 +0000
committerChristos Zoulas <christos@zoulas.com>2021-02-05 21:33:49 +0000
commitf6dfbb86de9b377f4b8f273d54258b787241e7a2 (patch)
tree17728203f42df61315f1a9c10512dee05d1cfbb9 /src/file.h
parent9c74f7b258cfe17b8c7f6eaaf6bbbf4ed14017d0 (diff)
downloadfile-git-f6dfbb86de9b377f4b8f273d54258b787241e7a2.tar.gz
PR/234: halaei: Add limit to the number of bytes to scan for encoding
file_buffer(3) passed the full size of the buffer to the encoding determination function. If the file was too large, we ended up allocating (2 * size + 4 * size) buffers to scan for encoding. Now we limit size to 64K.
Diffstat (limited to 'src/file.h')
-rw-r--r--src/file.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/file.h b/src/file.h
index 6c390047..86b51ead 100644
--- a/src/file.h
+++ b/src/file.h
@@ -27,7 +27,7 @@
*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.223 2020/12/08 21:26:00 christos Exp $
+ * @(#)$File: file.h,v 1.224 2021/02/05 21:33:49 christos Exp $
*/
#ifndef __file_h__
@@ -462,6 +462,7 @@ struct magic_set {
uint16_t elf_notes_max;
uint16_t regex_max;
size_t bytes_max; /* number of bytes to read from file */
+ size_t encoding_max; /* bytes to look for encoding */
#ifndef FILE_BYTES_MAX
# define FILE_BYTES_MAX (1024 * 1024) /* how much of the file to look at */
#endif
@@ -471,6 +472,7 @@ struct magic_set {
#define FILE_INDIR_MAX 50
#define FILE_NAME_MAX 50
#define FILE_REGEX_MAX 8192
+#define FILE_ENCODING_MAX (64 * 1024)
};
/* Type for Unicode characters */