From: Martin Willi Date: Tue, 19 Mar 2013 12:44:11 +0000 (+0100) Subject: Don't try to mmap() empty ipsec.secret files X-Git-Tag: 5.0.3rc1~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=824864f4e02b70d7a37221070b3eda1a953509da;p=thirdparty%2Fstrongswan.git Don't try to mmap() empty ipsec.secret files --- diff --git a/src/libcharon/plugins/stroke/stroke_cred.c b/src/libcharon/plugins/stroke/stroke_cred.c index c401bc6f1c..e9da477fa2 100644 --- a/src/libcharon/plugins/stroke/stroke_cred.c +++ b/src/libcharon/plugins/stroke/stroke_cred.c @@ -991,6 +991,11 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level, close(fd); return; } + if (sb.st_size == 0) + { /* skip empty files, as mmap() complains */ + close(fd); + return; + } addr = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); if (addr == MAP_FAILED) { @@ -1262,4 +1267,3 @@ stroke_cred_t *stroke_cred_create() return &this->public; } -