[systemd-commits] 3 commits - src/udev
Tom Gundersen
tomegun at kemper.freedesktop.org
Thu Sep 18 10:17:19 PDT 2014
src/udev/udevadm-hwdb.c | 14 ++++++++++++--
src/udev/udevd.c | 35 +++++++++++++++++++++++++++--------
2 files changed, 39 insertions(+), 10 deletions(-)
New commits:
commit f901aaadd68050bc575c1c15b84f8f31fd4d494d
Author: Tom Gundersen <teg at jklm.no>
Date: Thu Sep 18 19:16:54 2014 +0200
udevadm: hwdb - check return value of fseeko()
Fonud by Coverity. Fixes CID #996255.
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index 65cbf61..64273fb 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -365,7 +365,12 @@ static int trie_store(struct trie *trie, const char *filename) {
fchmod(fileno(t.f), 0444);
/* write nodes */
- fseeko(t.f, sizeof(struct trie_header_f), SEEK_SET);
+ err = fseeko(t.f, sizeof(struct trie_header_f), SEEK_SET);
+ if (err < 0) {
+ fclose(t.f);
+ unlink_noerrno(filename_tmp);
+ return -errno;
+ }
root_off = trie_store_nodes(&t, trie->root);
h.nodes_root_off = htole64(root_off);
pos = ftello(t.f);
@@ -378,7 +383,12 @@ static int trie_store(struct trie *trie, const char *filename) {
/* write header */
size = ftello(t.f);
h.file_size = htole64(size);
- fseeko(t.f, 0, SEEK_SET);
+ err = fseeko(t.f, 0, SEEK_SET);
+ if (err < 0) {
+ fclose(t.f);
+ unlink_noerrno(filename_tmp);
+ return -errno;
+ }
fwrite(&h, sizeof(struct trie_header_f), 1, t.f);
err = ferror(t.f);
if (err)
commit d457ff8319b1e7c522c146f75e272f1226f4720c
Author: Tom Gundersen <teg at jklm.no>
Date: Thu Sep 18 19:07:02 2014 +0200
udevd: check return of various functions
One reported by Coverity. Fixes CID #996252.
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 95c6468..9210da6 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1139,13 +1139,26 @@ int main(int argc, char *argv[]) {
goto exit;
}
- label_init("/dev");
+ r = label_init("/dev");
+ if (r < 0) {
+ log_error("could not initialize labelling: %s", strerror(-r));
+ goto exit;
+ }
/* set umask before creating any file/directory */
- chdir("/");
+ r = chdir("/");
+ if (r < 0) {
+ log_error("could not change dir to /: %m");
+ goto exit;
+ }
+
umask(022);
- mkdir("/run/udev", 0755);
+ r = mkdir("/run/udev", 0755);
+ if (r < 0) {
+ log_error("could not create /run/udev: %m");
+ goto exit;
+ }
dev_setup(NULL);
commit 6f5cf8a8b1de763383f7382821147e538b7dbd6d
Author: Tom Gundersen <teg at jklm.no>
Date: Thu Sep 18 19:02:03 2014 +0200
udevd: parse_argv - warn if argumens are invalid
Found by Coverity. Fixes CID #1238780.
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index cd51793..95c6468 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1048,17 +1048,23 @@ static int parse_argv(int argc, char *argv[]) {
arg_daemonize = true;
break;
case 'c':
- safe_atoi(optarg, &arg_children_max);
+ r = safe_atoi(optarg, &arg_children_max);
+ if (r < 0)
+ log_warning("Invalid --children-max ignored: %s", optarg);
break;
case 'e':
- safe_atoi(optarg, &arg_exec_delay);
+ r = safe_atoi(optarg, &arg_exec_delay);
+ if (r < 0)
+ log_warning("Invalid --exec-delay ignored: %s", optarg);
break;
case 't':
r = safe_atou64(optarg, &arg_event_timeout_usec);
if (r < 0)
- break;
- arg_event_timeout_usec *= USEC_PER_SEC;
- arg_event_timeout_warn_usec = (arg_event_timeout_usec / 3) ? : 1;
+ log_warning("Invalig --event-timeout ignored: %s", optarg);
+ else {
+ arg_event_timeout_usec *= USEC_PER_SEC;
+ arg_event_timeout_warn_usec = (arg_event_timeout_usec / 3) ? : 1;
+ }
break;
case 'D':
arg_debug = true;
More information about the systemd-commits
mailing list