Revision: 45542
http://brlcad.svn.sourceforge.net/brlcad/?rev=45542&view=rev
Author: bhinesley
Date: 2011-07-19 19:22:23 +0000 (Tue, 19 Jul 2011)
Log Message:
-----------
resolved issues regarding fwrite/write return value validation, unveiled by
r45540/r45541 per conversation with Sean
Modified Paths:
--------------
brlcad/trunk/src/libbu/bomb.c
brlcad/trunk/src/libbu/crashreport.c
brlcad/trunk/src/libbu/vlb.c
Modified: brlcad/trunk/src/libbu/bomb.c
===================================================================
--- brlcad/trunk/src/libbu/bomb.c 2011-07-19 17:27:51 UTC (rev 45541)
+++ brlcad/trunk/src/libbu/bomb.c 2011-07-19 19:22:23 UTC (rev 45542)
@@ -108,8 +108,17 @@
fd = open("/dev/tty", 1);
if (LIKELY(fd > 0)) {
if (str && (strlen(str) > 0)) {
- (void)write(fd, str, strlen(str));
- (void)write(fd, "\n", 1);
+ int ret;
+ size_t len;
+
+ len = strlen(str);
+ ret = write(fd, str, len);
+ if (ret < 0 || (size_t)ret != len)
+ perror("write failed");
+
+ ret = write(fd, "\n", 1);
+ if (ret != 1)
+ perror("write failed");
}
close(fd);
}
@@ -154,7 +163,8 @@
fd = open("/dev/tty", 1);
if (LIKELY(fd > 0)) {
- (void)write(fd, "Causing intentional core dump due to debug
flag\n", 48);
+ int ret;
+ ret = write(fd, "Causing intentional core dump due to debug
flag\n", 48);
close(fd);
}
abort(); /* should dump if ulimit is non-zero */
Modified: brlcad/trunk/src/libbu/crashreport.c
===================================================================
--- brlcad/trunk/src/libbu/crashreport.c 2011-07-19 17:27:51 UTC (rev
45541)
+++ brlcad/trunk/src/libbu/crashreport.c 2011-07-19 19:22:23 UTC (rev
45542)
@@ -107,7 +107,13 @@
fprintf(fp, "\nSystem characteristics:\n");
fflush(fp);
while (bu_fgets(buffer, CR_BUFSIZE, popenfp)) {
- (void)fwrite(buffer, 1, strlen(buffer), fp);
+ size_t ret;
+ size_t len;
+
+ len = strlen(buffer);
+ ret = fwrite(buffer, 1, len, fp);
+ if (ret != len)
+ perror("fwrite failed");
}
}
#if defined(HAVE_POPEN) && !defined(STRICT_FLAGS)
@@ -133,10 +139,17 @@
fprintf(fp, "\nSystem information:\n");
fflush(fp);
while (bu_fgets(buffer, CR_BUFSIZE, popenfp)) {
- if ((strlen(buffer) == 0) || ((strlen(buffer) == 1) &&
(buffer[0] == '\n'))) {
+ size_t ret;
+ size_t len;
+
+ len = strlen(buffer);
+ if ((len == 0) || (len == 1) && (buffer[0] == '\n')) {
continue;
}
- (void)fwrite(buffer, 1, strlen(buffer), fp);
+
+ ret = fwrite(buffer, 1, len, fp);
+ if (ret != len)
+ perror("fwrite failed");
}
}
#if defined(HAVE_POPEN) && !defined(STRICT_FLAGS)
Modified: brlcad/trunk/src/libbu/vlb.c
===================================================================
--- brlcad/trunk/src/libbu/vlb.c 2011-07-19 17:27:51 UTC (rev 45541)
+++ brlcad/trunk/src/libbu/vlb.c 2011-07-19 19:22:23 UTC (rev 45542)
@@ -117,8 +117,13 @@
void
bu_vlb_print(struct bu_vlb *vlb, FILE *fd)
{
+ size_t ret;
+
BU_CKMAG(vlb, BU_VLB_MAGIC, "magic for bu_vlb");
- (void)fwrite(vlb->buf, 1, vlb->nextByte, fd);
+
+ ret = fwrite(vlb->buf, 1, vlb->nextByte, fd);
+ if (ret != vlb->nextByte)
+ perror("fwrite failed");
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Magic Quadrant for Content-Aware Data Loss Prevention
Research study explores the data loss prevention market. Includes in-depth
analysis on the changes within the DLP market, and the criteria used to
evaluate the strengths and weaknesses of these DLP solutions.
http://www.accelacomm.com/jaw/sfnl/114/51385063/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits