diff --git a/udev_device.c b/udev_device.c index f312810..e8b0c9b 100644 --- a/udev_device.c +++ b/udev_device.c @@ -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) {