Commit 1e7328ef authored by Jonathan Jenkins's avatar Jonathan Jenkins
Browse files

use strcpy in codes_mapping_get_lp_info

strncpy might prevent bad internal state from destroying everything, but it
also writes MAX_NAME_LENGTH bytes unconditionally, clobbering input if it
isn't long enough. Besides, internal state will only be inconsistent if people
are trying to call codes_mapping_get_lp_info without configuring in the first
parent ea1d1013
......@@ -359,7 +359,7 @@ void codes_mapping_get_lp_info(
// we've found the group
tw_lpid rem = gid - id_total;
if (group_name != NULL)
strncpy(group_name, lpg->name.ptr, MAX_NAME_LENGTH);
strcpy(group_name, lpg->name.ptr);
*group_index = g;
// find repetition within group
*rep_id = (int) (rem / num_id_per_rep);
......@@ -370,12 +370,12 @@ void codes_mapping_get_lp_info(
if (rem < num_id_per_rep + lpt->count){
// found the specific LP
if (lp_type_name != NULL)
strncpy(lp_type_name, lpt->name.ptr, MAX_NAME_LENGTH);
strcpy(lp_type_name, lpt->name.ptr);
if (annotation != NULL) {
if (lpt->anno.ptr == NULL)
annotation[0] = '\0';
strncpy(annotation, lpt->anno.ptr, MAX_NAME_LENGTH);
strcpy(annotation, lpt->anno.ptr);
*offset = (int) (rem - num_id_per_rep);
*lp_type_index = l;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment