diff options
author | Tom Gundersen <teg@jklm.no> | 2014-09-18 19:16:54 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-09-18 19:16:54 +0200 |
commit | f901aaadd68050bc575c1c15b84f8f31fd4d494d (patch) | |
tree | 68f37dd304f3eb23bfc6e5efa0d47fe7f42f4c97 /src/udev/udevadm-hwdb.c | |
parent | d457ff8319b1e7c522c146f75e272f1226f4720c (diff) |
udevadm: hwdb - check return value of fseeko()
Fonud by Coverity. Fixes CID #996255.
Diffstat (limited to 'src/udev/udevadm-hwdb.c')
-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 65cbf61865..64273fbe8d 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) |