summaryrefslogtreecommitdiffstats
path: root/src/cc4group.c
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2019-04-20 22:04:14 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2019-04-20 22:04:14 +0200
commit70a0ccbcc1a1e029e9d41e10f292ca320a4c3417 (patch)
tree0faa92eab047f193349201c81a333222492ccb0d /src/cc4group.c
parentd1202195a3d94d0333d735fb05ac72214bd6708d (diff)
downloadcc4group-70a0ccbcc1a1e029e9d41e10f292ca320a4c3417.tar.gz
cc4group-70a0ccbcc1a1e029e9d41e10f292ca320a4c3417.zip
Check return value of write in cc4group_extractEntry
Diffstat (limited to 'src/cc4group.c')
-rw-r--r--src/cc4group.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/cc4group.c b/src/cc4group.c
index a9ecb85..85bc48b 100644
--- a/src/cc4group.c
+++ b/src/cc4group.c
@@ -1282,20 +1282,29 @@ static bool cc4group_extractEntry(CC4Group* const this, const C4GroupEntryData*
{
return false;
}
- write(file, data, root->core.Size);
+
+ bool success = true;
+ if(write(file, data, root->core.Size) != root->core.Size)
+ {
+ SET_ERRNO_ERROR("write: Writing to the target file");
+ success = false;
+ }
if(close(file) == -1)
{
fprintf(stderr, "WARNING: close: Closing the extracted file \"%s\" failed: %s\n", targetPath, strerror(errno));
}
- struct utimbuf times = {.actime = root->core.Modified, .modtime = root->core.Modified};
- if(utime(targetPath, &times) == -1)
+ if(success)
{
- fprintf(stderr, "WARNING: utime: Setting modification time for \"%s\" failed: %s\n", targetPath, strerror(errno));
+ struct utimbuf times = {.actime = root->core.Modified, .modtime = root->core.Modified};
+ if(utime(targetPath, &times) == -1)
+ {
+ fprintf(stderr, "WARNING: utime: Setting modification time for \"%s\" failed: %s\n", targetPath, strerror(errno));
+ }
}
- return true;
+ return success;
}
static bool cc4group_extractChildren(CC4Group* const this, const C4GroupEntryData* const root, const char* const targetPath)