Index: res/res_features.c =================================================================== --- res/res_features.c (revision 115539) +++ res/res_features.c (working copy) @@ -325,14 +325,26 @@ /* Check for channel variable PARKINGEXTEN */ parkingexten = pbx_builtin_getvar_helper(chan, "PARKINGEXTEN"); if (!ast_strlen_zero(parkingexten)) { - if (ast_exists_extension(NULL, parking_con, parkingexten, 1, NULL)) { + /*!\note The API forces us to specify a numeric parking slot, even + * though the architecture would tend to support non-numeric extensions + * (as are possible with SIP, for example). Hence, we enforce that + * limitation here. If extout was not numeric, we could permit + * arbitrary non-numeric extensions. + */ + if (sscanf(parkingexten, "%d", &x) != 1 || x < 0) { + ast_log(LOG_WARNING, "PARKINGEXTEN does not indicate a valid parking slot: '%s'.\n", parkingexten); ast_mutex_unlock(&parking_lock); free(pu); + return 1; /* Continue execution if possible */ + } + snprintf(pu->parkingexten, sizeof(pu->parkingexten), "%d", x); + + if (ast_exists_extension(NULL, parking_con, pu->parkingexten, 1, NULL)) { + ast_mutex_unlock(&parking_lock); + free(pu); ast_log(LOG_WARNING, "Requested parking extension already exists: %s@%s\n", parkingexten, parking_con); return 1; /* Continue execution if possible */ } - ast_copy_string(pu->parkingexten, parkingexten, sizeof(pu->parkingexten)); - x = atoi(parkingexten); } else { /* Select parking space within range */ parking_range = parking_stop - parking_start+1; @@ -357,6 +369,7 @@ /* Set pointer for next parking */ if (parkfindnext) parking_offset = x - parking_start + 1; + snprintf(pu->parkingexten, sizeof(pu->parkingexten), "%d", x); } chan->appl = "Parked Call"; @@ -397,8 +410,6 @@ if (option_verbose > 1) ast_verbose(VERBOSE_PREFIX_2 "Parked %s on %d@%s. Will timeout back to extension [%s] %s, %d in %d seconds\n", pu->chan->name, pu->parkingnum, parking_con, pu->context, pu->exten, pu->priority, (pu->parkingtime/1000)); - if (pu->parkingnum != -1) - snprintf(pu->parkingexten, sizeof(pu->parkingexten), "%d", x); manager_event(EVENT_FLAG_CALL, "ParkedCall", "Exten: %s\r\n" "Channel: %s\r\n" @@ -423,7 +434,7 @@ if (!con) /* Still no context? Bad */ ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con); /* Tell the peer channel the number of the parking space */ - if (peer && ((pu->parkingnum != -1 && ast_strlen_zero(orig_chan_name)) || !strcasecmp(peer->name, orig_chan_name))) { /* Only say number if it's a number and the channel hasn't been masqueraded away */ + if (peer && (ast_strlen_zero(orig_chan_name) || !strcasecmp(peer->name, orig_chan_name))) { /* Only say number if it's a number and the channel hasn't been masqueraded away */ /* Make sure we don't start saying digits to the channel being parked */ ast_set_flag(peer, AST_FLAG_MASQ_NOSTREAM); ast_say_digits(peer, pu->parkingnum, "", peer->language);