]> git.ipfire.org Git - thirdparty/asterisk.git/commit
main/untils: Prevent potential infinite loop in ast_careful_fwrite
authorMatthew Jordan <mjordan@digium.com>
Thu, 3 Jul 2014 11:26:26 +0000 (11:26 +0000)
committerMatthew Jordan <mjordan@digium.com>
Thu, 3 Jul 2014 11:26:26 +0000 (11:26 +0000)
commitf13656e4fc9651de24c552ce4c7c06e945659de6
tree537067a682bf15542c22e80ed1230a8ee70e1b27
parente46eb72fbbf6f62c600e262923445c305081ffad
main/untils: Prevent potential infinite loop in ast_careful_fwrite

A loop in ast_careful_fwrite exists that will continually attempt to write to
a file stream, even in the presence of EAGAIN/EINTR errors. However, if a
connection that uses ast_careful_fwrite closes suddenly, ast_careful_fwrite's
call to fflush may return EAGAIN/EINTER along with EOF. A subsequent call to
fflush will return EOF but not clear errno, resulting in an infinite loop.

This patch clears errno after it is detected and handled the loop, such that
any subsequent call to fflush will not get erroneously stuck.

Review: https://reviewboard.asterisk.org/r/3704

#ASTERISK-23984 #close
Reported by: Steve Davies
patches:
  fflush_loop_fix uploaded by one47 (License 5012)
........

Merged revisions 417797 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@417799 65c4cc65-6c06-0410-ace0-fbb531ad65f3
main/utils.c