Fixed usage of uninitialized memory, thax to valgrind
[lcr.git] / callerid.c
index 9b31461..2f12ac1 100644 (file)
@@ -45,20 +45,22 @@ const char *numberrize_callerinfo(const char *string, int ntype, const char *nat
 
                case INFO_NTYPE_INTERNATIONAL:
                strcpy(result, international);
-               strncat(result, string, sizeof(result)-strlen(result)-1);
+               strncat(result, string, sizeof(result)-1);
                result[sizeof(result)-1] = '\0';
                return(result);
                break;
 
                case INFO_NTYPE_NATIONAL:
                strcpy(result, national);
-               strncat(result, string, sizeof(result)-strlen(result)-1);
+               strncat(result, string, sizeof(result)-1);
                result[sizeof(result)-1] = '\0';
                return(result);
                break;
 
                default:
-               return(string);
+               strncpy(result, string, sizeof(result)-1);
+               result[sizeof(result)-1] = '\0';
+               return(result);
        }
 }