1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
From 1a33ea8ff7736fc63f0c7be2c3a8b488e572694d Mon Sep 17 00:00:00 2001
From: Alexey Gladkov <legion@altlinux.org>
Date: Fri, 13 Oct 2006 22:58:46 +1000
Subject: [PATCH] [SYSTEM] Check return code for getgroups and fwrite
Check getgroups() and fwrite() return code, required to build with
-D_FORTIFY_SOURCE=2.
---
ChangeLog | 8 ++++++++
src/bltin/test.c | 3 ++-
src/mkinit.c | 9 ++++++---
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9970489..a4db7de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-10-13 Alexey Gladkov <legion@altlinux.org>
+
+ * Check return code for getgroups and fwrite.
+
+2006-10-04 Herbert Xu <herbert@gondor.apana.org.au>
+
+ * Fixed inverted char class matching.
+
2006-05-23 Alexey Gladkov <legion@altlinux.org>
* Added --with-libedit option to configure.
diff --git a/src/bltin/test.c b/src/bltin/test.c
index 9b09094..f16c819 100644
--- a/src/bltin/test.c
+++ b/src/bltin/test.c
@@ -489,7 +489,8 @@ bash_group_member(gid_t gid)
ngroups = getgroups(0, NULL);
group_array = stalloc(ngroups * sizeof(gid_t));
- getgroups(ngroups, group_array);
+ if ((getgroups(ngroups, group_array)) != ngroups)
+ return (0);
/* Search through the list looking for GID. */
for (i = 0; i < ngroups; i++)
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");
}
}
--
1.4.3.1
|