util.pposix: Return error from ftruncate if that fails too (but what would we do...
[prosody.git] / util-src / pposix.c
index d797f0329af95907a5153fff02019b2aab7efc69..5288b08cd03217e8c86db35cfa0c16a20027817c 100644 (file)
@@ -750,7 +750,10 @@ int lc_fallocate(lua_State* L) {
                lua_pushstring(L, strerror(ret));
                /* posix_fallocate() can leave a bunch of NULs at the end, so we cut that
                 * this assumes that offset == length of the file */
-               ftruncate(fileno(f), offset);
+               if(ftruncate(fileno(f), offset) != 0) {
+                       lua_pushstring(L, strerror(errno));
+                       return 3;
+               }
                return 2;
        }
 }