mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-04-21 12:27:27 +03:00
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)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@12667 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user