Skip to content

Commit e02c613

Browse files
committed
udev/udev-watch: calculate the real buffer sizes needed
1 parent a6eccc3 commit e02c613

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/udev/udev-node.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
337337
void udev_node_add(struct udev_device *dev, bool apply,
338338
mode_t mode, uid_t uid, gid_t gid,
339339
struct udev_list *seclabel_list) {
340-
char filename[UTIL_PATH_SIZE];
340+
char filename[sizeof("/dev/block/:") + 2*DECIMAL_STR_MAX(unsigned)];
341341
struct udev_list_entry *list_entry;
342342

343343
log_debug("handling device node '%s', devnum=%s, mode=%#o, uid="UID_FMT", gid="GID_FMT,
@@ -360,7 +360,7 @@ void udev_node_add(struct udev_device *dev, bool apply,
360360

361361
void udev_node_remove(struct udev_device *dev) {
362362
struct udev_list_entry *list_entry;
363-
char filename[UTIL_PATH_SIZE];
363+
char filename[sizeof("/dev/block/:") + 2*DECIMAL_STR_MAX(unsigned)];
364364

365365
/* remove/update symlinks, remove symlinks from name index */
366366
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(dev))

src/udev/udev-watch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void udev_watch_restore(struct udev *udev) {
8989
}
9090

9191
void udev_watch_begin(struct udev *udev, struct udev_device *dev) {
92-
char filename[UTIL_PATH_SIZE];
92+
char filename[sizeof("/run/udev/watch/") + DECIMAL_STR_MAX(int)];
9393
int wd;
9494
int r;
9595

@@ -116,7 +116,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) {
116116

117117
void udev_watch_end(struct udev *udev, struct udev_device *dev) {
118118
int wd;
119-
char filename[UTIL_PATH_SIZE];
119+
char filename[sizeof("/run/udev/watch/") + DECIMAL_STR_MAX(int)];
120120

121121
if (inotify_fd < 0)
122122
return;
@@ -135,7 +135,7 @@ void udev_watch_end(struct udev *udev, struct udev_device *dev) {
135135
}
136136

137137
struct udev_device *udev_watch_lookup(struct udev *udev, int wd) {
138-
char filename[UTIL_PATH_SIZE];
138+
char filename[sizeof("/run/udev/watch/") + DECIMAL_STR_MAX(int)];
139139
char device[UTIL_NAME_SIZE];
140140
ssize_t len;
141141

0 commit comments

Comments
 (0)