@@ -174,6 +174,12 @@ static int cwcid_careful_send(struct ast_channel *chan, unsigned char *buf, int
174174 };
175175 int amt ;
176176
177+ if (!len ) {
178+ ast_log (LOG_WARNING , "Send buffer is empty, returning\n" );
179+ return -1 ;
180+ }
181+ ast_debug (2 , "Carefully sending %d bytes\n" , len );
182+
177183 if (remain && * remain ) {
178184 amt = len ;
179185
@@ -210,7 +216,10 @@ static int cwcid_careful_send(struct ast_channel *chan, unsigned char *buf, int
210216
211217 /* Drop any frames that are not voice */
212218 if (inf -> frametype != AST_FRAME_VOICE ) {
219+ char frametype [32 ];
220+ ast_frame_type2str (inf -> frametype , frametype , sizeof (frametype ));
213221 ast_frfree (inf );
222+ ast_debug (1 , "Skipping %s\n" , frametype );
214223 continue ;
215224 }
216225
@@ -237,6 +246,7 @@ static int cwcid_careful_send(struct ast_channel *chan, unsigned char *buf, int
237246 buf += amt ;
238247 len -= amt ;
239248 ast_frfree (inf );
249+ ast_debug (2 , "%d bytes remaining\n" , len );
240250 }
241251 return 0 ;
242252}
@@ -288,21 +298,21 @@ static int cwcid_exec(struct ast_channel *chan, const char *data)
288298 }
289299
290300 tz = args .timezone ;
291- clidnum = ast_strlen_zero (args .number ) ? ast_channel_caller (chan )-> id .number .str : args .number ;
301+ clidnum = ! ast_strlen_zero (args .number ) ? args . number : ast_channel_caller (chan )-> id .number .valid ? ast_channel_caller ( chan ) -> id .number . str : "" ;
292302 if (strlen (clidnum ) > 15 ) {
293303 ast_log (LOG_WARNING , "Caller ID number '%s' is greater than 15 characters and will be truncated\n" , clidnum );
294304 } else if (ast_strlen_zero (clidnum )) {
295305 ast_log (LOG_WARNING , "Caller ID number is empty\n" );
296306 }
297- ast_copy_string (clid , clidnum , 16 );
307+ ast_copy_string (clid , clidnum , sizeof ( clid ) );
298308
299- clidname = ast_strlen_zero (args .name ) ? ast_channel_caller (chan )-> id .name .str : args .name ;
309+ clidname = ! ast_strlen_zero (args .name ) ? args . name : ast_channel_caller (chan )-> id .name .valid ? ast_channel_caller ( chan ) -> id .name . str : "" ;
300310 if (strlen (clidname ) > 15 ) {
301311 ast_log (LOG_WARNING , "Caller ID name '%s' is greater than 15 characters and will be truncated\n" , clidname );
302312 } else if (ast_strlen_zero (clidname )) {
303313 ast_log (LOG_WARNING , "Caller ID name is empty\n" );
304314 }
305- ast_copy_string (cnam , clidname , 16 );
315+ ast_copy_string (cnam , clidname , sizeof ( cnam ) );
306316
307317 if (!ast_strlen_zero (args .presentation )) {
308318 presentation = ast_parse_caller_presentation (args .presentation );
0 commit comments