--- freem/src/mref.c 2025/03/09 15:20:18 1.3 +++ freem/src/mref.c 2025/04/10 01:24:38 1.7 @@ -1,23 +1,11 @@ /* - * * - * * * - * * * - * *************** - * * * * * - * * MUMPS * - * * * * * - * *************** - * * * - * * * - * * - * - * mref.c + * $Id: mref.c,v 1.7 2025/04/10 01:24:38 snw Exp $ * supporting functions for handling freem_ref_t structures * * * Author: Serena Willis * Copyright (C) 1998 MUG Deutschland - * Copyright (C) 2020 Coherent Logic Development LLC + * Copyright (C) 2020, 2025 Coherent Logic Development LLC * * * This file is part of FreeM. @@ -35,6 +23,22 @@ * You should have received a copy of the GNU Affero Public License * along with FreeM. If not, see . * + * $Log: mref.c,v $ + * Revision 1.7 2025/04/10 01:24:38 snw + * Remove C++ style comments + * + * Revision 1.6 2025/04/09 15:16:50 snw + * Fix buffer overruns in mref_to_external and ssvn.c + * + * Revision 1.5 2025/03/22 18:43:54 snw + * Make STRLEN 255 chars and add BIGSTR macro for larger buffers + * + * Revision 1.4 2025/03/09 19:50:47 snw + * Second phase of REUSE compliance and header reformat + * + * + * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC + * SPDX-License-Identifier: AGPL-3.0-or-later **/ #include @@ -167,7 +171,7 @@ freem_ref_t *internal_to_mref (freem_ref ref->reftype = MREF_RT_LOCAL; } - strncpy (ref->name, nam, 256); + strncpy (ref->name, nam, STRLEN); /* if no subscripts, return the ref */ if (*(ptr - 1) == EOL) { @@ -270,7 +274,7 @@ void mref_to_external (freem_ref_t *ref, } } - stcnv_m2c (buf); + stncnv_m2c (buf, STRLEN); strcat (buf, ")"); @@ -286,24 +290,16 @@ short mref_is_descendant(freem_ref_t *a, { register int i; - //printf ("checking if %s is a descendant of %s\r\n", b->name, a->name); - //printf ("a: %d b: %d\r\n", a->subscript_count, b->subscript_count); - if (a->subscript_count > b->subscript_count) return FALSE; if ((strcmp (a->name, b->name) == 0) && (a->subscript_count == 0)) return TRUE; for (i = 0; i < a->subscript_count; i++) { - - //printf("\ta[%d] = '%s'\r\n\tb[%d] = '%s'\r\n", i, a->subscripts[i], i, b->subscripts[i]); - if (strcmp (b->subscripts[i], a->subscripts[i]) != 0 ) { - //printf ("not descendant [%d]\r\n", strcmp (b->subscripts[i], a->subscripts[i])); + return FALSE; } } - - //printf ("is descendant\r\n"); return TRUE; }