check file size

This commit is contained in:
illiliti
2020-08-23 15:31:10 +03:00
parent 894aa48906
commit 14e187f1e2

View File

@@ -560,6 +560,7 @@ struct udev_device *udev_device_new_from_file(struct udev *udev, const char *pat
char line[LINE_MAX], syspath[PATH_MAX], devnode[PATH_MAX];
struct udev_device *udev_device;
char *pos, *sysname;
struct stat st;
FILE *file;
int i;
@@ -569,6 +570,11 @@ struct udev_device *udev_device_new_from_file(struct udev *udev, const char *pat
return NULL;
}
if (stat(path, &st) != 0 || st.st_size > 8192) {
free(udev_device);
return NULL;
}
file = fopen(path, "r");
if (!file) {