Commit c194fc8d authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Replace use of strcpy from user-provided strings with strncpy.

parent 2df23f99
......@@ -355,7 +355,10 @@ void zaxisDefName(int zaxisID, const char *name)
zaxis_check_ptr(zaxisID, zaxisptr);
if ( name )
strcpy(zaxisptr->name, name);
{
strncpy(zaxisptr->name, name, CDI_MAX_NAME - 1);
zaxisptr->name[CDI_MAX_NAME - 1] = '\0';
}
}
/*
......@@ -387,7 +390,10 @@ void zaxisDefLongname(int zaxisID, const char *longname)
zaxis_check_ptr(zaxisID, zaxisptr);
if ( longname )
strcpy(zaxisptr->longname, longname);
{
strncpy(zaxisptr->longname, longname, CDI_MAX_NAME - 1);
zaxisptr->longname[CDI_MAX_NAME - 1] = '\0';
}
}
/*
......@@ -419,7 +425,10 @@ void zaxisDefUnits(int zaxisID, const char *units)
zaxis_check_ptr(zaxisID, zaxisptr);
if ( units )
strcpy(zaxisptr->units, units);
{
strncpy(zaxisptr->units, units, CDI_MAX_NAME - 1);
zaxisptr->units[CDI_MAX_NAME - 1] = '\0';
}
}
/*
......
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