--- freem/src/namespace.c 2025/01/19 02:04:04 1.1.1.1 +++ freem/src/namespace.c 2025/04/13 04:22:43 1.6 @@ -1,23 +1,11 @@ /* - * * - * * * - * * * - * *************** - * * * * * - * * MUMPS * - * * * * * - * *************** - * * * - * * * - * * - * - * namespace.c + * $Id: namespace.c,v 1.6 2025/04/13 04:22:43 snw Exp $ * Namespace support * * - * Author: Serena Willis + * 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: namespace.c,v $ + * Revision 1.6 2025/04/13 04:22:43 snw + * Fix snprintf calls + * + * Revision 1.5 2025/04/09 19:52:02 snw + * Eliminate as many warnings as possible while building with -Wall + * + * Revision 1.4 2025/04/02 03:02:42 snw + * Stop requiring users to pass -e to fmadm when -u or -g are passed + * + * Revision 1.3 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 @@ -64,13 +68,12 @@ #endif #define LOCK 'l' -#define ZDEALLOCATE 'D' void ns_error(char *ns, char *e) { char msg_buf[256]; - snprintf(msg_buf, 256, "error switching to namespace '%s': %s (possibly a configuration error?)\r\n\201", ns, e); + snprintf(msg_buf, sizeof (msg_buf) - 1, "error switching to namespace '%s': %s (possibly a configuration error?)\r\n\201", ns, e); write_m(msg_buf); return; @@ -98,7 +101,7 @@ void set_namespace(char *ns, int verbose get_conf (ns, "root", nsroot); if(!file_exists (config_file)) { - snprintf (tmps, 256, "configuration file '%s' does not exist.\n", config_file); + snprintf (tmps, sizeof (tmps) - 1, "configuration file '%s' does not exist.\n", config_file); ns_error (ns, tmps); cleanup (); @@ -110,7 +113,6 @@ void set_namespace(char *ns, int verbose /* turn off all the old so-called "journal" implementation */ ug_buf[HOME][0] = EOL; jour_flag = 0; - jourfile[0] = NUL; /* the real journal file */ jour_file[0] = NUL; @@ -156,7 +158,7 @@ void set_namespace(char *ns, int verbose } else { - snprintf (tmps, 256, "invalid journal_mode '%s'", ns_buf); + snprintf (tmps, sizeof (tmps) - 1, "invalid journal_mode '%s'", ns_buf); ns_error ("SYSTEM", tmps); goto jour_end; @@ -247,11 +249,11 @@ jour_end: /* set up local engine */ for(i = 0; i < 256; i++) ns_buf[i] = NUL; - if(get_conf(ns, "local_engine", ns_buf) == TRUE) { - sprintf(loc_engine, "%s", ns_buf); + if(get_conf (ns, "local_engine", ns_buf) == TRUE) { + snprintf (loc_engine, sizeof (loc_engine), "%s", ns_buf); } else { - sprintf(loc_engine, "BUILTIN"); + sprintf (loc_engine, "BUILTIN"); } @@ -325,7 +327,7 @@ jour_end: strcpy (nsname, ns); if (verbose == TRUE) { - snprintf (notif, 256, "Namespace set to '%s'\r\n\201", ns); + snprintf (notif, sizeof (notif) - 1, "Namespace set to '%s'\r\n\201", ns); write_m (notif); }