aboutsummaryrefslogtreecommitdiffstats
path: root/tools/firmware-utils/src/ptgen.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2008-09-23 16:12:40 +0000
committerFelix Fietkau <nbd@openwrt.org>2008-09-23 16:12:40 +0000
commit0524ab859029bcc02e642d6d9ba13cdf464bc499 (patch)
tree09b12c533c55b8a667b08101a98477c33429186a /tools/firmware-utils/src/ptgen.c
parent35fb42beaaaddababe78fe1e97fa730a35aef423 (diff)
downloadupstream-0524ab859029bcc02e642d6d9ba13cdf464bc499.tar.gz
upstream-0524ab859029bcc02e642d6d9ba13cdf464bc499.tar.bz2
upstream-0524ab859029bcc02e642d6d9ba13cdf464bc499.zip
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
Diffstat (limited to 'tools/firmware-utils/src/ptgen.c')
-rw-r--r--tools/firmware-utils/src/ptgen.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c
index 8733e252cb..d94aabb5fc 100644
--- a/tools/firmware-utils/src/ptgen.c
+++ b/tools/firmware-utils/src/ptgen.c
@@ -143,7 +143,7 @@ static int gen_ptable(int nr)
printf("%ld\n", ((long) len * 512));
}
- if ((fd = open(filename, O_WRONLY|O_CREAT, 0644)) < 0) {
+ if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) {
fprintf(stderr, "Can't open output file '%s'\n",filename);
return -1;
}