The reason for this behavior is when you Malloc space for the Calling Line ID (CLID) and Digital Number Identification Service (DNIS), you Malloc the proper amount (the strlen() plus 1 for a NULL terminator). However, you can switch to use snprintf() in order to populate these fields. This function takes the length of the string and always appends a NULL byte to it.
Since the length of the string (strlen(clid)) does not contain the NULL byte, when snprintf appends this byte, it overwrites the last character of the string. This causes the DNIS and CLID to be incorrect and the last digit to be stripped.
As a workaround, download and upgrade the Cisco IOS software to any one of these Cisco IOS software releases: