--- freem/src/objects.c 2025/04/10 01:24:38 1.5 +++ freem/src/objects.c 2025/04/13 04:22:43 1.6 @@ -1,5 +1,5 @@ /* - * $Id: objects.c,v 1.5 2025/04/10 01:24:38 snw Exp $ + * $Id: objects.c,v 1.6 2025/04/13 04:22:43 snw Exp $ * implementation of OO support * * @@ -24,6 +24,9 @@ * along with FreeM. If not, see . * * $Log: objects.c,v $ + * Revision 1.6 2025/04/13 04:22:43 snw + * Fix snprintf calls + * * Revision 1.5 2025/04/10 01:24:38 snw * Remove C++ style comments * @@ -124,8 +127,8 @@ void obj_set_attribute(char *inst, char char t_key[255]; char t_data[255]; - snprintf (t_key, 254, "^$OBJECT\202%s\202%s\201", inst, attrib); - snprintf (t_data, 254, "%s\201", value); + snprintf (t_key, sizeof (t_key) - 1, "^$OBJECT\202%s\202%s\201", inst, attrib); + snprintf (t_data, sizeof (t_data) - 1, "%s\201", value); symtab_bltin (set_sym, t_key, t_data); } @@ -134,7 +137,7 @@ short obj_get_attribute(char *inst, char { char t_key[255]; - snprintf (t_key, 254, "^$OBJECT\202%s\202%s\201", inst, attrib); + snprintf (t_key, sizeof (t_key) - 1, "^$OBJECT\202%s\202%s\201", inst, attrib); symtab_bltin (get_sym, t_key, buf); @@ -162,19 +165,19 @@ short obj_get_attribute(char *inst, char void obj_destroy(char *inst) { - char t_key[255]; + char t_key[256]; - snprintf (t_key, 254, "^$OBJECT\202\%s\201", inst); + snprintf (t_key, sizeof (t_key) - 1, "^$OBJECT\202\%s\201", inst); symtab_bltin (kill_sym, t_key, " \201"); } void obj_create_symbols(char *objvar, char *class) { - char t_key[255]; - char t_data[255]; + char t_key[256]; + char t_data[256]; - snprintf (t_key, 254, "%s\201", objvar); - snprintf (t_data, 254, " \201"); + snprintf (t_key, sizeof (t_key) - 1, "%s\201", objvar); + snprintf (t_data, sizeof (t_data) - 1, " \201"); symtab_bltin (set_sym, t_key, t_data); @@ -195,7 +198,7 @@ void obj_get_constructor(char *construct strcpy (outref.name, inref.name); outref.subscript_count = inref.subscript_count + 1; - snprintf (outref.subscripts[0], 255, ".%s", instvar); + snprintf (outref.subscripts[0], STRLEN - 1, ".%s", instvar); for (i = 0; i < inref.subscript_count; i++) { strcpy (outref.subscripts[i + 1], inref.subscripts[i]);