File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,8 @@ int git_attr_file__load(
143
143
blobsize = git_blob_rawsize (blob );
144
144
145
145
GIT_ERROR_CHECK_BLOBSIZE (blobsize );
146
+ if (blobsize > GIT_ATTR_MAX_FILE_SIZE ) /* TODO: issue warning when warning API is available */
147
+ goto cleanup ;
146
148
git_str_put (& content , git_blob_rawcontent (blob ), (size_t )blobsize );
147
149
break ;
148
150
}
@@ -155,6 +157,7 @@ int git_attr_file__load(
155
157
if (p_stat (entry -> fullpath , & st ) < 0 ||
156
158
S_ISDIR (st .st_mode ) ||
157
159
(fd = git_futils_open_ro (entry -> fullpath )) < 0 ||
160
+ (st .st_size > GIT_ATTR_MAX_FILE_SIZE ) ||
158
161
(error = git_futils_readbuffer_fd (& content , fd , (size_t )st .st_size )) < 0 )
159
162
nonexistent = true;
160
163
@@ -198,6 +201,8 @@ int git_attr_file__load(
198
201
blobsize = git_blob_rawsize (blob );
199
202
200
203
GIT_ERROR_CHECK_BLOBSIZE (blobsize );
204
+ if (blobsize > GIT_ATTR_MAX_FILE_SIZE ) /* TODO: issue warning when warning API is available */
205
+ goto cleanup ;
201
206
if ((error = git_str_put (& content ,
202
207
git_blob_rawcontent (blob ), (size_t )blobsize )) < 0 )
203
208
goto cleanup ;
Original file line number Diff line number Diff line change 21
21
#define GIT_ATTR_FILE_SYSTEM "gitattributes"
22
22
#define GIT_ATTR_FILE_XDG "attributes"
23
23
24
+ #define GIT_ATTR_MAX_FILE_SIZE 100 * 1024 * 1024
25
+
24
26
#define GIT_ATTR_FNMATCH_NEGATIVE (1U << 0)
25
27
#define GIT_ATTR_FNMATCH_DIRECTORY (1U << 1)
26
28
#define GIT_ATTR_FNMATCH_FULLPATH (1U << 2)
You can’t perform that action at this time.
0 commit comments