From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id E79C43858D33; Tue, 7 Feb 2023 11:22:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E79C43858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675768921; bh=l9b0yOzBVSTCZjzRsVyupJGqnxPTxEFrLGzZW4CjTDY=; h=To:Subject:Date:From:From; b=B05D1Q+ua9i/FJWFus+CzWITAzXh7vS0ptWWXedM9Z3j+QX0R6m8LbZrbah7lWWDO y1kIHRKUihwnxl6is73AcIke0t18CI7+v5H8x81f3XlqXmDM1K2WwhKvvuUAnhIoLE QoQ/fAiOfnYGsIw4IVcABo+mNcCAsLA0bgsF1mqE= To: cygwin-apps-cvs@sourceware.org Subject: [robots - The game; Fight against maniac robots] branch master, updated. f021172a007888eac5bcb6c6e33eedc030f1dece X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 78a466cd76680353c6107fada34aa4ffb1795b5e X-Git-Newrev: f021172a007888eac5bcb6c6e33eedc030f1dece Message-Id: <20230207112201.E79C43858D33@sourceware.org> Date: Tue, 7 Feb 2023 11:22:01 +0000 (GMT) From: Corinna Vinschen List-Id: https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/robots.git;h=f021172a007888eac5bcb6c6e33eedc030f1dece commit f021172a007888eac5bcb6c6e33eedc030f1dece Author: Corinna Vinschen 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 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; }