@@ -79,7 +79,7 @@ int ex_put_field_metadata(int exoid, const ex_field field)
7979 int status = 0 ;
8080 static char * field_template = "Field@%s@%s" ;
8181 char attribute_name [NC_MAX_NAME + 1 ];
82- sprintf (attribute_name , field_template , field .name , "type" );
82+ snprintf (attribute_name , NC_MAX_NAME + 1 , field_template , field .name , "type" );
8383 if ((status = ex_put_integer_attribute (exoid , field .entity_type , field .entity_id , attribute_name ,
8484 field .nesting , field .type )) != EX_NOERR ) {
8585 exi_persist_leavedef (exoid , __func__ );
@@ -89,7 +89,7 @@ int ex_put_field_metadata(int exoid, const ex_field field)
8989
9090 /* Do not write if empty... */
9191 if (field .type_name [0 ] != '\0' ) {
92- sprintf (attribute_name , field_template , field .name , "type_name" );
92+ snprintf (attribute_name , NC_MAX_NAME + 1 , field_template , field .name , "type_name" );
9393 if ((status = ex_put_text_attribute (exoid , field .entity_type , field .entity_id , attribute_name ,
9494 field .type_name )) != EX_NOERR ) {
9595 exi_persist_leavedef (exoid , __func__ );
@@ -100,7 +100,7 @@ int ex_put_field_metadata(int exoid, const ex_field field)
100100
101101 /* Default component_separator is '_'. Avoid writing if that is what it is... */
102102 if (field .component_separator [0 ] != '_' || field .nesting > 1 ) {
103- sprintf (attribute_name , field_template , field .name , "separator" );
103+ snprintf (attribute_name , NC_MAX_NAME + 1 , field_template , field .name , "separator" );
104104 if ((status = ex_put_text_attribute (exoid , field .entity_type , field .entity_id , attribute_name ,
105105 field .component_separator )) != EX_NOERR ) {
106106 exi_persist_leavedef (exoid , __func__ );
@@ -117,7 +117,7 @@ int ex_put_field_metadata(int exoid, const ex_field field)
117117 }
118118 }
119119 if (needs_cardinality ) {
120- sprintf (attribute_name , field_template , field .name , "cardinality" );
120+ snprintf (attribute_name , NC_MAX_NAME + 1 , field_template , field .name , "cardinality" );
121121 if ((status = ex_put_integer_attribute (exoid , field .entity_type , field .entity_id ,
122122 attribute_name , field .nesting , field .cardinality )) !=
123123 EX_NOERR ) {
@@ -138,7 +138,7 @@ int exi_put_type_attribute(int exoid, const char *att_root, const char *name, co
138138 if (entry != NULL ) {
139139 static char * template = "%s@%s@%s" ;
140140 char attribute_name [NC_MAX_NAME + 1 ];
141- sprintf (attribute_name , template , att_root , name , type );
141+ snprintf (attribute_name , NC_MAX_NAME + 1 , template , att_root , name , type );
142142 if (value_type == EX_INTEGER ) {
143143 status = ex_put_integer_attribute (exoid , EX_GLOBAL , 0 , attribute_name , cardinality , entry );
144144 }
@@ -329,7 +329,7 @@ int ex_put_field_suffices(int exoid, const ex_field field, const char *suffices)
329329 return EX_FATAL ;
330330 }
331331
332- sprintf (attribute_name , field_template , field .name , "suffices" );
332+ snprintf (attribute_name , NC_MAX_NAME + 1 , field_template , field .name , "suffices" );
333333 if ((status = ex_put_text_attribute (exoid , field .entity_type , field .entity_id , attribute_name ,
334334 suffices )) != EX_NOERR ) {
335335 snprintf (errmsg , MAX_ERR_LENGTH ,
0 commit comments