Check return value on fwrite
authorKevin Harwell <kharwell@digium.com>
Fri, 30 Aug 2013 15:39:09 +0000 (15:39 +0000)
committerKevin Harwell <kharwell@digium.com>
Fri, 30 Aug 2013 15:39:09 +0000 (15:39 +0000)
........

Merged revisions 398000 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 398002 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398003 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/asterisk.c

index df55618..395d0cc 100644 (file)
@@ -2089,7 +2089,7 @@ static int console_log_verbose(const char *s)
 
        char prefix[80];
        const char *c = s;
 
        char prefix[80];
        const char *c = s;
-       int res = 0;
+       int num, res = 0;
 
        do {
                if (VERBOSE_HASMAGIC(s)) {
 
        do {
                if (VERBOSE_HASMAGIC(s)) {
@@ -2127,7 +2127,10 @@ static int console_log_verbose(const char *s)
                        fputs(prefix, stdout);
                }
 
                        fputs(prefix, stdout);
                }
 
-               fwrite(c, sizeof(char), s - c, stdout);
+               num = s - c;
+               if (fwrite(c, sizeof(char), num, stdout) < num) {
+                       break;
+               }
 
                if (!res) {
                        /* if at least some info has been written
 
                if (!res) {
                        /* if at least some info has been written