[systemd-commits] 8 commits - Makefile.am src/libudev src/udev
Kay Sievers
kay at kemper.freedesktop.org
Sun Sep 23 05:50:54 PDT 2012
Makefile.am | 8 ++++----
src/libudev/libudev-device-private.c | 5 ++++-
src/udev/accelerometer/accelerometer.c | 4 +++-
src/udev/collect/collect.c | 30 ++++++++++++++++++++++++++----
src/udev/scsi_id/scsi_serial.c | 3 ++-
src/udev/udev-rules.c | 32 ++++++++++++++------------------
src/udev/udev-watch.c | 5 ++++-
7 files changed, 57 insertions(+), 30 deletions(-)
New commits:
commit b8bc868009372deb2f30263322572723e5968842
Author: Kay Sievers <kay at vrfy.org>
Date: Sun Sep 23 14:31:53 2012 +0200
comment out uncommitted test source code
diff --git a/Makefile.am b/Makefile.am
index 3ccd0fc..8265927 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2584,15 +2584,15 @@ noinst_PROGRAMS += \
test-journal-send \
test-journal-match \
test-journal-stream \
- test-journal-verify \
- test-mmap-cache
+ test-journal-verify
+# test-mmap-cache
TESTS += \
test-journal \
test-journal-match \
test-journal-stream \
- test-journal-verify \
- test-mmap-cache
+ test-journal-verify
+# test-mmap-cache
pkginclude_HEADERS += \
src/systemd/sd-journal.h \
commit 9c513fe009968151fe95961dd9d5088c609aed98
Author: Lukas Nykryn <lnykryn at redhat.com>
Date: Fri Sep 21 13:03:00 2012 +0200
udev: free fd before return in accelerometer.c
diff --git a/src/udev/accelerometer/accelerometer.c b/src/udev/accelerometer/accelerometer.c
index b8ed7b8..67fed27 100644
--- a/src/udev/accelerometer/accelerometer.c
+++ b/src/udev/accelerometer/accelerometer.c
@@ -205,8 +205,10 @@ static void test_orientation(struct udev *udev,
r = read(fd, ev, sizeof(struct input_event) * 64);
- if (r < (int) sizeof(struct input_event))
+ if (r < (int) sizeof(struct input_event)) {
+ close(fd);
return;
+ }
for (i = 0; i < r / (int) sizeof(struct input_event); i++) {
if (got_syn == 1) {
commit ab261e1226efac3d47b2dc4a0e0165aeb8bb528e
Author: Lukas Nykryn <lnykryn at redhat.com>
Date: Fri Sep 21 13:01:29 2012 +0200
udev: free fd before return in scsi_serial.c
diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c
index 5ad0c31..3c52dee 100644
--- a/src/udev/scsi_id/scsi_serial.c
+++ b/src/udev/scsi_id/scsi_serial.c
@@ -921,7 +921,8 @@ int scsi_get_serial(struct udev *udev,
}
} else if (page_code != 0x00) {
log_debug("%s: unsupported page code 0x%d\n", dev_scsi->kernel, page_code);
- return 1;
+ retval = 1;
+ goto completed;
}
/*
commit 0820a4f0f6d6c264339a501a4352c22af26c5300
Author: Václav PavlÃn <vpavlin at redhat.com>
Date: Fri Sep 21 14:54:30 2012 +0200
udev: free rule structure on error
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index d86e6bc..0900928 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1728,30 +1728,24 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
/* init token array and string buffer */
rules->tokens = malloc(PREALLOC_TOKEN * sizeof(struct token));
- if (rules->tokens == NULL) {
- free(rules);
- return NULL;
- }
+ if (rules->tokens == NULL)
+ return udev_rules_unref(rules);
+
rules->token_max = PREALLOC_TOKEN;
rules->buf = malloc(PREALLOC_STRBUF);
- if (rules->buf == NULL) {
- free(rules->tokens);
- free(rules);
- return NULL;
- }
+ if (rules->buf == NULL)
+ return udev_rules_unref(rules);
+
rules->buf_max = PREALLOC_STRBUF;
/* offset 0 is always '\0' */
rules->buf[0] = '\0';
rules->buf_cur = 1;
rules->trie_nodes = malloc(PREALLOC_TRIE * sizeof(struct trie_node));
- if (rules->trie_nodes == NULL) {
- free(rules->buf);
- free(rules->tokens);
- free(rules);
- return NULL;
- }
+ if (rules->trie_nodes == NULL)
+ return udev_rules_unref(rules);
+
rules->trie_nodes_max = PREALLOC_TRIE;
/* offset 0 is the trie root, with an empty string */
memset(rules->trie_nodes, 0x00, sizeof(struct trie_node));
@@ -1763,21 +1757,23 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
NULL);
if (!rules->dirs) {
log_error("failed to build config directory array");
- return NULL;
+ return udev_rules_unref(rules);
}
if (!path_strv_canonicalize(rules->dirs)) {
log_error("failed to canonicalize config directories\n");
- return NULL;
+ return udev_rules_unref(rules);
}
strv_uniq(rules->dirs);
rules->dirs_ts_usec = calloc(strv_length(rules->dirs), sizeof(long long));
+ if(!rules->dirs_ts_usec)
+ return udev_rules_unref(rules);
udev_rules_check_timestamp(rules);
r = conf_files_list_strv(&files, ".rules", (const char **)rules->dirs);
if (r < 0) {
log_error("failed to enumerate rules files: %s\n", strerror(-r));
- return NULL;
+ return udev_rules_unref(rules);
}
/*
commit cb32f0141ead382a972f86f144b9500f2414166f
Author: Václav PavlÃn <vpavlin at redhat.com>
Date: Fri Sep 21 13:51:45 2012 +0200
udev: check return value of write
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index 47c2ddd..feae4bb 100644
--- a/src/udev/collect/collect.c
+++ b/src/udev/collect/collect.c
@@ -305,7 +305,10 @@ static int missing(int fd)
buf = tmpbuf;
}
snprintf(buf, strlen(him->name)+2, "%s ", him->name);
- write(fd, buf, strlen(buf));
+ if (write(fd, buf, strlen(buf)) < 0) {
+ free(buf);
+ return -1;
+ }
}
}
commit 6bb2f0a08a321eb165b28de1584884bdfc0c27ee
Author: Václav PavlÃn <vpavlin at redhat.com>
Date: Fri Sep 21 12:52:08 2012 +0200
udev: check return value of symlink
diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c
index c27a280..eebcee6 100644
--- a/src/udev/udev-watch.c
+++ b/src/udev/udev-watch.c
@@ -98,6 +98,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev)
{
char filename[UTIL_PATH_SIZE];
int wd;
+ int r;
if (inotify_fd < 0)
return;
@@ -113,7 +114,9 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev)
snprintf(filename, sizeof(filename), "/run/udev/watch/%d", wd);
mkdir_parents(filename, 0755);
unlink(filename);
- symlink(udev_device_get_id_filename(dev), filename);
+ r = symlink(udev_device_get_id_filename(dev), filename);
+ if (r < 0)
+ log_error("Failed to create symlink: %m");
udev_device_set_watch_handle(dev, wd);
}
commit 029f4f21fc49389ea2e3168b6f424ee94280680a
Author: Václav PavlÃn <vpavlin at redhat.com>
Date: Fri Sep 21 12:40:29 2012 +0200
libudev: check return value of rename
diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c
index 00fa3b8..489bea8 100644
--- a/src/libudev/libudev-device-private.c
+++ b/src/libudev/libudev-device-private.c
@@ -101,6 +101,7 @@ int udev_device_update_db(struct udev_device *udev_device)
char filename[UTIL_PATH_SIZE];
char filename_tmp[UTIL_PATH_SIZE];
FILE *f;
+ int r;
id = udev_device_get_id_filename(udev_device);
if (id == NULL)
@@ -161,7 +162,9 @@ int udev_device_update_db(struct udev_device *udev_device)
}
fclose(f);
- rename(filename_tmp, filename);
+ r = rename(filename_tmp, filename);
+ if (r < 0)
+ return -1;
udev_dbg(udev, "created %s file '%s' for '%s'\n", has_info ? "db" : "empty",
filename, udev_device_get_devpath(udev_device));
return 0;
commit 8dc8ef598de91326cc7cd21bb705efb8b8960d1c
Author: Václav PavlÃn <vpavlin at redhat.com>
Date: Fri Sep 21 12:17:23 2012 +0200
udev: check malloc return in collect/collect.c
Returns from no memory checks updated with log_oom call
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index 4162c43..47c2ddd 100644
--- a/src/udev/collect/collect.c
+++ b/src/udev/collect/collect.c
@@ -142,7 +142,7 @@ static int checkout(int fd)
buf = calloc(1,bufsize + 1);
if (!buf) {
fprintf(stderr, "Out of memory.\n");
- return -1;
+ return log_oom();
}
memset(buf, ' ', bufsize);
ptr = buf + len;
@@ -167,7 +167,16 @@ static int checkout(int fd)
if (debug)
fprintf(stderr, "Found word %s\n", word);
him = malloc(sizeof (struct _mate));
+ if (!him) {
+ free(buf);
+ return log_oom();
+ }
him->name = strdup(word);
+ if (!him->name) {
+ free(buf);
+ free(him);
+ return log_oom();
+ }
him->state = STATE_OLD;
udev_list_node_append(&him->node, &bunch);
word = NULL;
@@ -276,7 +285,7 @@ static int missing(int fd)
buf = malloc(bufsize);
if (!buf)
- return -1;
+ return log_oom();
udev_list_node_foreach(him_node, &bunch) {
struct _mate *him = node_to_mate(him_node);
@@ -291,7 +300,7 @@ static int missing(int fd)
tmpbuf = realloc(buf, bufsize);
if (!tmpbuf) {
free(buf);
- return -1;
+ return log_oom();
}
buf = tmpbuf;
}
@@ -431,7 +440,17 @@ int main(int argc, char **argv)
if (debug)
fprintf(stderr, "ID %s: not in database\n", argv[i]);
him = malloc(sizeof (struct _mate));
+ if (!him) {
+ ret = ENOMEM;
+ goto out;
+ }
+
him->name = malloc(strlen(argv[i]) + 1);
+ if (!him->name) {
+ ret = ENOMEM;
+ goto out;
+ }
+
strcpy(him->name, argv[i]);
him->state = STATE_NONE;
udev_list_node_append(&him->node, &bunch);
More information about the systemd-commits
mailing list