--- freem/src/locktab.c 2025/02/28 20:51:20 1.2 +++ freem/src/locktab.c 2025/04/13 04:22:43 1.6 @@ -1,23 +1,11 @@ /* - * * - * * * - * * * - * *************** - * * * * * - * * MUMPS * - * * * * * - * *************** - * * * - * * * - * * - * - * locktab.c + * $Id: locktab.c,v 1.6 2025/04/13 04:22:43 snw Exp $ * lock table implementation * * - * Author: Serena Willis + * Author: Serena Willis * Copyright (C) 1998 MUG Deutschland - * Copyright (C) 2021 Coherent Logic Development LLC + * Copyright (C) 2021, 2025 Coherent Logic Development LLC * * * This file is part of FreeM. @@ -35,6 +23,19 @@ * You should have received a copy of the GNU Affero Public License * along with FreeM. If not, see . * + * $Log: locktab.c,v $ + * Revision 1.6 2025/04/13 04:22:43 snw + * Fix snprintf calls + * + * Revision 1.5 2025/03/24 02:57:25 snw + * Shared memory compatibility fixes for OS/2 + * + * Revision 1.4 2025/03/09 19:14:25 snw + * First phase of REUSE compliance and header reformat + * + * + * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC + * SPDX-License-Identifier: AGPL-3.0-or-later **/ #include @@ -49,7 +50,7 @@ #include "mref.h" #include "transact.h" -#if !defined(__OpenBSD__) && !defined(__APPLE__) +#if !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__OS2__) union semun { int val; /* Value for SETVAL */ struct semid_ds *buf; /* Buffer for IPC_STAT, IPC_SET */ @@ -438,10 +439,10 @@ locktab_ent_t *locktab_find(char *key) char chk_ns[255]; if (key[1] == '%') { - snprintf (chk_ns, 255, "SYSTEM"); + snprintf (chk_ns, sizeof (chk_ns) - 1, "SYSTEM"); } else { - snprintf (chk_ns, 255, "%s", nsname); + snprintf (chk_ns, sizeof (chk_ns) - 1, "%s", nsname); } for (lck = shm_config->hdr->locktab_head; lck != NULL; lck = lck->next) { @@ -482,10 +483,10 @@ locktab_ent_t *locktab_insert(char *key) ik = internal_to_mref (ik, key); if (key[1] == '%') { - snprintf (chk_ns, 255, "SYSTEM"); + snprintf (chk_ns, sizeof (chk_ns) - 1, "SYSTEM"); } else { - snprintf (chk_ns, 255, "%s", nsname); + snprintf (chk_ns, sizeof (chk_ns) - 1, "%s", nsname); } for (l = shm_config->hdr->locktab_head; l != NULL; l = l->next) { @@ -537,7 +538,7 @@ new_insert: } stcpy (l->nref, key); - snprintf (l->namespace, 255, "%s", chk_ns); + snprintf (l->namespace, sizeof (l->namespace) - 1, "%s", chk_ns); l->owner_job = pid; l->ct = 1;