diff options
author | Tom Gundersen <teg@jklm.no> | 2014-09-18 19:16:54 +0200 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-09-18 18:53:24 -0400 |
commit | b75d8b25e4b2016785edea8989a10e10674ee237 (patch) | |
tree | 216e34107e9f4c60337c03f57356a5f21ce94020 /src/udev | |
parent | 3a9daa4bedde6589e22c0d838e3c3b93f4a99f2d (diff) |
udevadm: hwdb - check return value of fseeko()
Fonud by Coverity. Fixes CID #996255.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/udevadm-hwdb.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index de535de754..4a3f35c2af 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -372,7 +372,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); @@ -385,7 +390,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) |