summaryrefslogtreecommitdiff
path: root/src/fstab-generator/fstab-generator.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-03-25 18:18:57 +0100
committerLennart Poettering <lennart@poettering.net>2013-03-25 18:20:03 +0100
commitdf3e57f542cf680cd891dfbd85615885b54770dc (patch)
tree13212db730b356529e16c585d88d3f69187a41ac /src/fstab-generator/fstab-generator.c
parent790838e4f16831f2bb06aeb845b9e2fb0f1d28dd (diff)
fstab-generator: add missing OOM check
Diffstat (limited to 'src/fstab-generator/fstab-generator.c')
-rw-r--r--src/fstab-generator/fstab-generator.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index d5f9db49ca..a0a87a15fc 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -389,13 +389,15 @@ static int add_mount(const char *what, const char *where, const char *type, cons
}
static int parse_fstab(const char *prefix, bool initrd) {
- FILE *f;
_cleanup_free_ char *fstab_path = NULL;
+ FILE *f;
int r = 0;
struct mntent *me;
- errno = 0;
- fstab_path = strjoin(prefix, "/etc/fstab", NULL);
+ fstab_path = strjoin(strempty(prefix), "/etc/fstab", NULL);
+ if (!fstab_path)
+ return log_oom();
+
f = setmntent(fstab_path, "r");
if (!f) {
if (errno == ENOENT)
@@ -614,7 +616,7 @@ int main(int argc, char *argv[]) {
if (!arg_enabled)
return (r < 0) ? EXIT_FAILURE : EXIT_SUCCESS;
- k = parse_fstab("", false);
+ k = parse_fstab(NULL, false);
if (in_initrd())
l = parse_fstab("/sysroot", true);