[asterisk-commits] jrose: branch 1.8 r376389 - /branches/1.8/res/res_monitor.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Nov 16 13:31:54 CST 2012


Author: jrose
Date: Fri Nov 16 13:31:48 2012
New Revision: 376389

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=376389
Log:
monitor: prevent attempts to move/remove recordings skipped with 'i' and 'o'.

The i and o options for monitor skip the input and output sides of a recording
respectively. This patch addresses a problem in those options when monitor is
called without specifying a specific filename where monitor will try to move
the recording that was skipped. Since this usually doesn't exist when these
options are used, it would produce a warning when it does this in most cases,
but it is conceivable that there are use cases where this could result in
moving/removing a file unintentionally.

(closes issue ASTERISK-20641)
Reported by: Jonathan Rose
Review: https://reviewboard.asterisk.org/r/2190/

Modified:
    branches/1.8/res/res_monitor.c

Modified: branches/1.8/res/res_monitor.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_monitor.c?view=diff&rev=376389&r1=376388&r2=376389
==============================================================================
--- branches/1.8/res/res_monitor.c (original)
+++ branches/1.8/res/res_monitor.c Fri Nov 16 13:31:48 2012
@@ -451,24 +451,28 @@
 		}
 
 		if (chan->monitor->filename_changed && !ast_strlen_zero(chan->monitor->filename_base)) {
-			if (ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0) {
-				snprintf(filename, FILENAME_MAX, "%s-in", chan->monitor->filename_base);
-				if (ast_fileexists(filename, NULL, NULL) > 0) {
-					ast_filedelete(filename, NULL);
+			if (chan->monitor->read_stream) {
+				if (ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0) {
+					snprintf(filename, FILENAME_MAX, "%s-in", chan->monitor->filename_base);
+					if (ast_fileexists(filename, NULL, NULL) > 0) {
+						ast_filedelete(filename, NULL);
+					}
+					ast_filerename(chan->monitor->read_filename, filename, chan->monitor->format);
+				} else {
+					ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->read_filename);
 				}
-				ast_filerename(chan->monitor->read_filename, filename, chan->monitor->format);
-			} else {
-				ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->read_filename);
-			}
-
-			if (ast_fileexists(chan->monitor->write_filename,NULL,NULL) > 0) {
-				snprintf(filename, FILENAME_MAX, "%s-out", chan->monitor->filename_base);
-				if (ast_fileexists(filename, NULL, NULL) > 0) {
-					ast_filedelete(filename, NULL);
+			}
+
+			if (chan->monitor->write_stream) {
+				if (ast_fileexists(chan->monitor->write_filename,NULL,NULL) > 0) {
+					snprintf(filename, FILENAME_MAX, "%s-out", chan->monitor->filename_base);
+					if (ast_fileexists(filename, NULL, NULL) > 0) {
+						ast_filedelete(filename, NULL);
+					}
+					ast_filerename(chan->monitor->write_filename, filename, chan->monitor->format);
+				} else {
+					ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->write_filename);
 				}
-				ast_filerename(chan->monitor->write_filename, filename, chan->monitor->format);
-			} else {
-				ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->write_filename);
 			}
 		}
 




More information about the asterisk-commits mailing list