|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 6c8aaf0c1bf2a04010ae7125a08ceb51e7058712 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Tom Gundersen <teg@jklm.no>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Wed, 17 Sep 2014 19:53:01 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] udev: rules - close empty file
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
If the file is found to be empty, we exit early without closing the file first.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Found by coverity. Fixes CID #1237759.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/udev/udev-rules.c | 3 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 1 insertion(+), 2 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 2a691f6ab7..3bc25f7c26 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/udev/udev-rules.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/udev/udev-rules.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1575,7 +1575,7 @@ invalid:
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static int parse_file(struct udev_rules *rules, const char *filename) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- FILE *f;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ _cleanup_fclose_ FILE *f = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned int first_token;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned int filename_off;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char line[UTIL_LINE_SIZE];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1633,7 +1633,6 @@ static int parse_file(struct udev_rules *rules, const char *filename) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
add_rule(rules, key, filename, filename_off, line_nr);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- fclose(f);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* link GOTOs to LABEL rules in this file to be able to fast-forward */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (i = first_token+1; i < rules->token_cur; i++) {
|