[zaptel-commits] kpfleming: branch 1.4 r4173 - /branches/1.4/kernel/zaptel-base.c

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Thu Apr 17 07:20:27 CDT 2008


Author: kpfleming
Date: Thu Apr 17 07:20:26 2008
New Revision: 4173

URL: http://svn.digium.com/view/zaptel?view=rev&rev=4173
Log:
when processing ZT_SET_DIALPARAMS, don't return an error for out-of-range tone durations, just ignore them (so that applications that don't initialize the entire zt_dialparams structure won't fail to set the ones they do initialize)

(closes issue #12456)
Reported by: fnordian
Tested by: fnordian

Modified:
    branches/1.4/kernel/zaptel-base.c

Modified: branches/1.4/kernel/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/zaptel-base.c?view=diff&rev=4173&r1=4172&r2=4173
==============================================================================
--- branches/1.4/kernel/zaptel-base.c (original)
+++ branches/1.4/kernel/zaptel-base.c Thu Apr 17 07:20:26 2008
@@ -3916,14 +3916,16 @@
 	case ZT_SET_DIALPARAMS:
 		if (copy_from_user(&tdp, (struct zt_dialparams *) data, sizeof(tdp)))
 			return -EFAULT;
-		if ((tdp.dtmf_tonelen > 4000) || (tdp.dtmf_tonelen < 10))
-			return -EINVAL;
-		if ((tdp.mfv1_tonelen > 4000) || (tdp.mfv1_tonelen < 10))
-			return -EINVAL;
-		if ((tdp.mfr2_tonelen > 4000) || (tdp.mfr2_tonelen < 10))
-			return -EINVAL;
-
-		global_dialparams = tdp;
+
+		if ((tdp.dtmf_tonelen <= 4000) || (tdp.dtmf_tonelen >= 10)) {
+			global_dialparams.dtmf_tonelen = tdp.dtmf_tonelen;
+		}
+		if ((tdp.mfv1_tonelen <= 4000) || (tdp.mfv1_tonelen >= 10)) {
+			global_dialparams.mfv1_tonelen = tdp.mfv1_tonelen;
+		}
+		if ((tdp.mfr2_tonelen <= 4000) || (tdp.mfr2_tonelen >= 10)) {
+			global_dialparams.mfr2_tonelen = tdp.mfr2_tonelen;
+		}
 
 		/* update the lengths in all currently loaded zones */
 		write_lock(&zone_lock);
@@ -3934,27 +3936,27 @@
 				continue;
 
 			for (i = 0; i < sizeof(z->dtmf) / sizeof(z->dtmf[0]); i++) {
-				z->dtmf[i].tonesamples = tdp.dtmf_tonelen * ZT_CHUNKSIZE;
+				z->dtmf[i].tonesamples = global_dialparams.dtmf_tonelen * ZT_CHUNKSIZE;
 			}
 
 			/* for MFR1, we only adjust the length of the digits */
 			for (i = ZT_TONE_MFR1_0; i <= ZT_TONE_MFR1_9; i++) {
-				z->mfr1[i - ZT_TONE_MFR1_BASE].tonesamples = tdp.mfv1_tonelen * ZT_CHUNKSIZE;
+				z->mfr1[i - ZT_TONE_MFR1_BASE].tonesamples = global_dialparams.mfv1_tonelen * ZT_CHUNKSIZE;
 			}
 
 			for (i = 0; i < sizeof(z->mfr2_fwd) / sizeof(z->mfr2_fwd[0]); i++) {
-				z->mfr2_fwd[i].tonesamples = tdp.mfr2_tonelen * ZT_CHUNKSIZE;
+				z->mfr2_fwd[i].tonesamples = global_dialparams.mfr2_tonelen * ZT_CHUNKSIZE;
 			}
 
 			for (i = 0; i < sizeof(z->mfr2_rev) / sizeof(z->mfr2_rev[0]); i++) {
-				z->mfr2_rev[i].tonesamples = tdp.mfr2_tonelen * ZT_CHUNKSIZE;
+				z->mfr2_rev[i].tonesamples = global_dialparams.mfr2_tonelen * ZT_CHUNKSIZE;
 			}
 		}
 		write_unlock(&zone_lock);
 
-		dtmf_silence.tonesamples = tdp.dtmf_tonelen * ZT_CHUNKSIZE;
-		mfr1_silence.tonesamples = tdp.mfv1_tonelen * ZT_CHUNKSIZE;
-		mfr2_silence.tonesamples = tdp.mfr2_tonelen * ZT_CHUNKSIZE;
+		dtmf_silence.tonesamples = global_dialparams.dtmf_tonelen * ZT_CHUNKSIZE;
+		mfr1_silence.tonesamples = global_dialparams.mfv1_tonelen * ZT_CHUNKSIZE;
+		mfr2_silence.tonesamples = global_dialparams.mfr2_tonelen * ZT_CHUNKSIZE;
 
 		break;
 	case ZT_GET_DIALPARAMS:




More information about the zaptel-commits mailing list