From 70033702cda3b13150426cd176a31713d48394d9 Mon Sep 17 00:00:00 2001 From: "arnd@arndb.de" Date: Tue, 18 Nov 2003 21:39:30 -0800 Subject: [PATCH] more robust config file parsing in namedev.c After getting a number of different crashes for udev reading broken udev.config files, I decided to try to make the parser a little more robust. The behaviour is changed to stop reading the configuration file and logging the broken entry instead of silently ignoring it (is that good? It's easy to just print and continue). All strcpy()'s to a fixed length string are now implicitly limited to the bounds of the target string. I kept the -ENODEV return code for now, not sure if there should be different ones. --- udev.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'udev.h') diff --git a/udev.h b/udev.h index cdf1af4fc2..904948d67a 100644 --- a/udev.h +++ b/udev.h @@ -70,6 +70,12 @@ struct udevice { mode_t mode; }; +#define strfieldcpy(to, from) \ +do { \ + to[sizeof(to)-1] = '\0'; \ + strncpy(to, from, sizeof(to)-1); \ +} while (0) + extern int udev_add_device(char *path, char *subsystem); extern int udev_remove_device(char *path, char *subsystem); -- cgit v1.2.3-54-g00ecf