public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-apps-cvs@sourceware.org
Subject: [robots - The game; Fight against maniac robots] branch master, updated. f021172a007888eac5bcb6c6e33eedc030f1dece
Date: Tue,  7 Feb 2023 11:22:01 +0000 (GMT)	[thread overview]
Message-ID: <20230207112201.E79C43858D33@sourceware.org> (raw)




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/robots.git;h=f021172a007888eac5bcb6c6e33eedc030f1dece

commit f021172a007888eac5bcb6c6e33eedc030f1dece
Author: Corinna Vinschen <vinschen@redhat.com>
Date:   Tue Feb 7 12:18:05 2023 +0100

    improve Makefile

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/robots.git;h=c9891437927399d8a14d54ff9f8cf59b4ebb0c46

commit c9891437927399d8a14d54ff9f8cf59b4ebb0c46
Author: Corinna Vinschen <vinschen@redhat.com>
Date:   Tue Feb 7 11:20:39 2023 +0100

    fix gcc warnings


Diff:
---
 Makefile | 7 +++++--
 score.c  | 9 +++++----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 8a9bbf075a85..dda9c3da9d36 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+srcdir	= .
+VPATH	= $(srcdir)
 # just -lcurses for SYS V
 #LIBS	= -lcurses -ltermcap
 LIBS	= -lncurses
@@ -7,7 +9,8 @@ LIBS	= -lncurses
 # -DALLSCORES          don't take a user only once per highscore
 OPTIONS	= -DALLSCORES
 CPPFLAGS= -I/usr/include/ncurses
-CFLAGS  = $(IFDEF) $(OPTIONS) -DSCOREDIR='"$(scoredir)"' -g -O2 -Wall
+CFLAGS  += $(IFDEF) $(OPTIONS) -DSCOREDIR='"$(scoredir)"' -g -O2 -pipe
+CFLAGS	+= -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 
 # Suffix of executables. ".exe" on Windows based systems
 EXEEXT	= .exe
 
@@ -42,7 +45,7 @@ install: robots$(EXEEXT) robots.6
 	-mkdir -p $(DESTDIR)$(mandir)
 	install -c robots.6 $(DESTDIR)$(mandir)
 	-mkdir -p $(DESTDIR)$(postinstalldir)
-	sed -e 's#@SCOREDIR@#$(scoredir)#' < robots.sh > $(DESTDIR)$(postinstalldir)/robots.sh
+	sed -e 's#@SCOREDIR@#$(scoredir)#' < $(srcdir)/robots.sh > $(DESTDIR)$(postinstalldir)/robots.sh
 
 tidy: clean
 clean:
diff --git a/score.c b/score.c
index 0a1b75a76843..3933c9e07131 100644
--- a/score.c
+++ b/score.c
@@ -137,7 +137,7 @@ do_score(bool eaten, int fd, int max_days, char *type_str)
 				}
 			}
 			position->s_score = score;
-			(void) strncpy(position->s_name,whoami,MAXSTR);
+			(void) snprintf(position->s_name, MAXSTR, "%s", whoami);
 			position->s_eaten = eaten;
 			position->s_level = LEVEL;
 			position->s_uid = uid;
@@ -187,14 +187,15 @@ do_score(bool eaten, int fd, int max_days, char *type_str)
 void
 scorer()
 {
-	static char tels[6];
+	static char tels[32]; /* originally 6, but this generates warnings */
 	if(free_teleports != old_free) {
 		if(free_teleports > free_per_level) {
-			(void) sprintf(tels,"%d+%d",
+			(void) snprintf(tels, sizeof(tels), "%d+%d",
 				       free_per_level,
 				       free_teleports-free_per_level);
 		} else {
-			(void) sprintf(tels,"%d",free_teleports);
+			(void) snprintf(tels, sizeof(tels), "%d",
+					free_teleports);
 		}
 		old_free = free_teleports;
 	}


                 reply	other threads:[~2023-02-07 11:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230207112201.E79C43858D33@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-apps-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).