[asterisk-bugs] [Asterisk 0015313]: [patch] incorrect comparation in ast_monitor_change_fname() leads to deletion of recorded files

Asterisk Bug Tracker noreply at bugs.digium.com
Wed Nov 4 18:01:49 CST 2009


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=15313 
====================================================================== 
Reported By:                caspy
Assigned To:                jpeeler
====================================================================== 
Project:                    Asterisk
Issue ID:                   15313
Category:                   Resources/res_monitor
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     closed
Asterisk Version:           SVN 
JIRA:                       SWP-214 
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
Resolution:                 fixed
Fixed in Version:           
====================================================================== 
Date Submitted:             2009-06-11 04:20 CDT
Last Modified:              2009-11-04 18:01 CST
====================================================================== 
Summary:                    [patch] incorrect comparation in
ast_monitor_change_fname() leads to deletion of recorded files
Description: 
In res_monitor.c in ast_monitor_change_fname() is done a comparation of new
monitor's filename with a current one to preserve of setting
chan->monitor->filename_changed in case of file name is not changed.
There is a mistake in filename preparation routines, which makes wrong
comparation of the SAME filename: 'chan->monitor->filename_base' contains
only current name of file and 'tmpstring' contains the SAME filename but
with full path.

In attached patch there is a couple of new debug messages, and a quick
fix.
This fix is working ok for me, but i'm not sure it is correct in idea. So,
please, review it before commiting.

Here is an example of debug output for this issue:
$ grep CASPY /var/log/asterisk/debug | tail -2
[Jun 11 12:39:39] DEBUG[19438] res_monitor.c: CASPY:
ast_monitor_change_fname(): fname_base:
in-20090611-123450-4957874222-1244709290-28095, filename_base:
in-20090611-123450-4957874222-1244709290-28095
[Jun 11 12:39:39] DEBUG[19438] res_monitor.c: CASPY:
ast_monitor_change_fname(): comparing:
/var/spool/asterisk/monitor/in-20090611-123450-4957874222-1244709290-28095
and in-20090611-123450-4957874222-1244709290-28095

Here you can see, that filename is the same, but one of compared with a
full path. This leads to later deletion of recorded files.
======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
has duplicate       0015332 [patch] Recorded files get deleted befo...
====================================================================== 

---------------------------------------------------------------------- 
 (0113168) svnbot (reporter) - 2009-11-04 18:01
 https://issues.asterisk.org/view.php?id=15313#c113168 
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 227948

_U  branches/1.6.1/
U   branches/1.6.1/res/res_monitor.c

------------------------------------------------------------------------
r227948 | jpeeler | 2009-11-04 18:01:47 -0600 (Wed, 04 Nov 2009) | 28
lines

Merged revisions 227945 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r227945 | jpeeler | 2009-11-04 17:50:59 -0600 (Wed, 04 Nov 2009) | 21
lines
  
  Merged revisions 227944 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r227944 | jpeeler | 2009-11-04 17:47:08 -0600 (Wed, 04 Nov 2009) | 14
lines
    
    Fix incorrect filename comparsion after monitor file change
    
    The logic to detect if a requested file is indeed a different file
from the
    current file was incorrect. The main issue being confusion of the use
of
    filename_base which was previously set without pathing information and
then
    compared to another full path. Robust file comparison logic has been
added
    to properly check if two files are the same even if symlinks are used.
    
    (closes issue https://issues.asterisk.org/view.php?id=15313)
    Reported by: caspy
    Patches: 
          20091103__issue15313__1.4.diff.txt uploaded by jpeeler (license
325)
          but mostly tilghman's work
  ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=227948 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-11-04 18:01 svnbot         Checkin                                      
2009-11-04 18:01 svnbot         Note Added: 0113168                          
======================================================================




More information about the asterisk-bugs mailing list