From 5f3e19dbbeb851fff5cf7f9869d344feca479413 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Tue, 19 May 2015 18:17:31 -0700 Subject: Fix error handling for negative size in ftruncate. Bug: 21309901 Change-Id: I54692ab8105dd09db6af7a2c0894a17bdd118aa0 (cherry picked from commit c05554ec5c9aff5e0f1e83de9bb62c3569eecca2) --- tests/unistd_test.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp index f54a461..a21578a 100644 --- a/tests/unistd_test.cpp +++ b/tests/unistd_test.cpp @@ -176,6 +176,15 @@ TEST(unistd, ftruncate64) { ASSERT_EQ(123, sb.st_size); } +TEST(unistd, ftruncate_negative) { + TemporaryFile tf; + errno = 0; + int rc = ftruncate(tf.fd, -123); + int err = errno; + ASSERT_EQ(-1, rc); + ASSERT_EQ(EINVAL, err); +} + static bool g_pause_test_flag = false; static void PauseTestSignalHandler(int) { g_pause_test_flag = true; -- cgit v1.1