summary refs log tree commit diff
path: root/src/mkinit.c
diff options
context:
space:
mode:
authorAlexey Gladkov <legion@altlinux.org>2006-10-13 22:58:46 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2006-10-13 22:58:46 +1000
commit1a33ea8ff7736fc63f0c7be2c3a8b488e572694d (patch)
treefd93c352efd0de3cdd1e2758e291b378578c404c /src/mkinit.c
parent[EXPAND] Fixed inverted char class matching (diff)
downloaddash-1a33ea8ff7736fc63f0c7be2c3a8b488e572694d.tar.gz
dash-1a33ea8ff7736fc63f0c7be2c3a8b488e572694d.zip
[SYSTEM] Check return code for getgroups and fwrite
Check getgroups() and fwrite() return code, required to build with
-D_FORTIFY_SOURCE=2.
Diffstat (limited to '')
-rw-r--r--src/mkinit.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mkinit.c b/src/mkinit.c
index e803751..9714bee 100644
--- a/src/mkinit.c
+++ b/src/mkinit.c
@@ -427,9 +427,12 @@ writetext(struct text *text, FILE *fp)
 	struct block *bp;
 
 	if (text->start != NULL) {
-		for (bp = text->start ; bp != text->last ; bp = bp->next)
-			fwrite(bp->text, sizeof (char), BLOCKSIZE, fp);
-		fwrite(bp->text, sizeof (char), BLOCKSIZE - text->nleft, fp);
+		for (bp = text->start ; bp != text->last ; bp = bp->next) {
+			if ((fwrite(bp->text, sizeof (char), BLOCKSIZE, fp)) != BLOCKSIZE)
+				error("Can't write data\n");
+		}
+		if ((fwrite(bp->text, sizeof (char), BLOCKSIZE - text->nleft, fp)) != (BLOCKSIZE - text->nleft))
+			error("Can't write data\n");
 	}
 }