diff --git a/apps/app_directed_pickup.c b/apps/app_directed_pickup.c index bcefb0661547d9c073b5dac65dbc4950fdb1526c..3914e0d8ec6eba3bfd38fd8b3fd70e9c8d7b2a6e 100644 --- a/apps/app_directed_pickup.c +++ b/apps/app_directed_pickup.c @@ -179,18 +179,24 @@ static struct ast_channel *my_ast_get_channel_by_name_locked(const char *channam char *chkchan; struct pickup_by_name_args pickup_args; - pickup_args.len = strlen(channame) + 1; - - chkchan = alloca(pickup_args.len + 1); - - /* need to append a '-' for the comparison so we check full channel name, - * i.e SIP/hgc- , use a temporary variable so original stays the same for - * debugging. + /* Check if channel name contains a '-'. + * In this case the channel name will be interpreted as full channel name. */ - strcpy(chkchan, channame); - strcat(chkchan, "-"); - - pickup_args.name = chkchan; + if (strchr(channame, '-')) { + /* check full channel name */ + pickup_args.len = strlen(channame); + pickup_args.name = channame; + } else { + /* need to append a '-' for the comparison so we check full channel name, + * i.e SIP/hgc- , use a temporary variable so original stays the same for + * debugging. + */ + pickup_args.len = strlen(channame) + 1; + chkchan = alloca(pickup_args.len + 1); + strcpy(chkchan, channame); + strcat(chkchan, "-"); + pickup_args.name = chkchan; + } return ast_channel_callback(pickup_by_name_cb, NULL, &pickup_args, 0); }