firmware-utils: when using open with O_CREAT and O_WRONLY, also use O_TRUNC to ensure that overwritten files have the right size (fixes #3505)

SVN-Revision: 12667
This commit is contained in:
Felix Fietkau
2008-09-23 16:12:40 +00:00
parent c3ae8337f4
commit 216c6cd8a9
3 changed files with 4 additions and 4 deletions

View File

@@ -122,7 +122,7 @@ int main(int argc, char **argv)
memcpy(buf, &header, sizeof(header));
// write the buf
if ((fd = open(argv[3], O_CREAT|O_WRONLY,0644)) < 0
if ((fd = open(argv[3], O_CREAT|O_WRONLY|O_TRUNC,0644)) < 0
|| write(fd, buf, buflen) != buflen
|| close(fd) < 0)
{