Fix error handling for negative size in ftruncate.

Bug: 21309901
Change-Id: I54692ab8105dd09db6af7a2c0894a17bdd118aa0
(cherry picked from commit c05554ec5c)
This commit is contained in:
Dan Albert
2015-05-19 18:17:31 -07:00
parent ca10ac6dd4
commit 5f3e19dbbe
7 changed files with 38 additions and 60 deletions

View File

@@ -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;