Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 icebreaker (1.21-12) unstable; urgency=medium
 .
   * Reintroduction of icebreaker to Debian.
   * Change maintainer to Debian Games Team
   * Merge Ubuntu changes:
     [Alexander Faithfull]
     - Fixed a buffer overflow in options.c that caused a crash on startup.
   * Move to debhelper compat 10, policy 4.1.0, source-format 3.0
   * Remove Debian menu file
   * Compile with hardening CFLAGS
   * Make the build reproducible. Thanks to Reiner Herrmann.
Author: Andreas Gnau <Rondom@Rondom.de>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2017-09-10

--- icebreaker-1.21.orig/Makefile
+++ icebreaker-1.21/Makefile
@@ -1,6 +1,6 @@
-CC=gcc
+CC?=gcc
 
-SDLCONFIG=sdl-config
+SDLCONFIG?=sdl-config
 
 ifndef prefix
   prefix=/usr/local
@@ -24,7 +24,8 @@ ifndef OPTIMIZE
   OPTIMIZE=-O3
 endif
 
-CFLAGS=-Wall $(OPTIMIZE) $(SDL_CFLAGS) -DDATAPREFIX=\"$(datadir)/icebreaker\" -DHISCOREPREFIX=\"$(highscoredir)\"
+CFLAGS?=-Wall $(OPTIMIZE)
+CFLAGS+=$(SDL_CFLAGS) -DDATAPREFIX=\"$(datadir)/icebreaker\" -DHISCOREPREFIX=\"$(highscoredir)\"
 
 SRC=icebreaker.c cursor.c grid.c laundry.c line.c penguin.c sound.c \
     level.c intro.c text.c status.c transition.c hiscore.c dialog.c \
@@ -35,7 +36,7 @@ SDL_LIB=$(SDL_LDFLAGS) $(SDL_MIXER)
 SDL_CFLAGS := $(shell $(SDLCONFIG) --cflags)
 SDL_LDFLAGS := $(shell $(SDLCONFIG) --libs)
 VERSION := $(shell awk '/^\#define VERSION/ { print $$3 }' icebreaker.h)
-VERDATE := $(shell date -r icebreaker.h +"%d %B %Y")
+VERDATE := $(shell LC_ALL=C date -u -r icebreaker.h +"%d %B %Y")
 
 ifneq ($(VERSION),$(shell awk '/^Version:/ { print $$2 }' icebreaker.spec))
   $(error "Version in spec file doesn't match version in icebreaker.h!")
@@ -94,7 +95,7 @@ icebreaker-$(VERSION).zip: icebreaker.ex
            [ -s $@ ] || rm -f $@
 
 icebreaker:	$(SRC:.c=.o)
-	$(CC) $(CFLAGS) $^ -o icebreaker $(SDL_LIB)
+	$(CC) $(CFLAGS) $^ -o icebreaker $(SDL_LIB) $(LDFLAGS)
 
 man: icebreaker.6
 
@@ -103,14 +104,14 @@ man: icebreaker.6
 	   sed 's/\$$VERDATE/$(VERDATE)/' > $@
 
 install: all
-	mkdir -p $(prefix)/bin
-	mkdir -p $(prefix)/share/icebreaker
-	mkdir -p $(highscoredir)
-	mkdir -p $(mandir)/man6
+#	mkdir -p $(prefix)/bin
+#	mkdir -p $(prefix)/share/icebreaker
+#	mkdir -p $(highscoredir)
+#	mkdir -p $(mandir)/man6
 
 	install -m 644 *.wav *.bmp $(prefix)/share/icebreaker
-	install -g games -s -m 2755 icebreaker $(prefix)/bin
-	install -m 644 icebreaker.6 $(mandir)/man6
+	install -g games -m 2755 icebreaker $(prefix)/games
+#	install -m 644 icebreaker.6 $(mandir)/man6
 	touch $(highscoredir)/icebreaker.scores
 	chown games:games $(highscoredir)/icebreaker.scores
 	chmod 664 $(highscoredir)/icebreaker.scores
--- icebreaker-1.21.orig/hiscore.c
+++ icebreaker-1.21/hiscore.c
@@ -83,7 +83,7 @@ void readhiscores()
 	// ok, so now, we can copy things over in the proper sorted order
 	for (i=0;i<HISCORENUM;i++)
 	{
-		snprintf(hiscorename[i],50,temphiscorename[arrayindex[i]]);
+		snprintf(hiscorename[i],50,"%s",temphiscorename[arrayindex[i]]);
 		hiscoreval[i]=temphiscoreval[arrayindex[i]];
 	}
 
@@ -109,13 +109,13 @@ void addhiscore(char * username, long sc
 	// make sure the temp array contains the right data
 	for (i=0;i<HISCORENUM;i++)
 	{
-		snprintf(temphiscorename[i],50,hiscorename[i]);
+		snprintf(temphiscorename[i],50,"%s",hiscorename[i]);
 		temphiscoreval[i]=hiscoreval[i];
 	}
 	
 	// and toss in the new data 
 	//(this is why these arrays are size HISCORENUM+1)
-	snprintf(temphiscorename[HISCORENUM],50,username);
+	snprintf(temphiscorename[HISCORENUM],50,"%s",username);
 	temphiscoreval[HISCORENUM]=score;
 
 	// fill the "helper" array. 
@@ -129,7 +129,7 @@ void addhiscore(char * username, long sc
 	// and take the top ones back.
 	for (i=0;i<HISCORENUM;i++)
 	{
-		snprintf(hiscorename[i],50,temphiscorename[arrayindex[i]]); 
+		snprintf(hiscorename[i],50,"%s",temphiscorename[arrayindex[i]]); 
 		hiscoreval[i]=temphiscoreval[arrayindex[i]];
 	}
 
--- icebreaker-1.21.orig/icebreaker.desktop
+++ icebreaker-1.21/icebreaker.desktop
@@ -1,7 +1,10 @@
 [Desktop Entry]
+Version=1.0
 Name=IceBreaker
+GenericName=IceBreaker
 Type=Application
-Comment=%{Summary}
+Comment=Melt an iceberg into small pieces, in order to trap the penguins
 Exec=icebreaker
-Icon=/usr/share/icebreaker/icebreaker_48.bmp
-Terminal=0
+Icon=icebreaker_48
+Terminal=false
+Categories=Game;ArcadeGame;
--- icebreaker-1.21.orig/icebreaker.man.in
+++ icebreaker-1.21/icebreaker.man.in
@@ -33,7 +33,7 @@ None in current version; in the future t
 
 .SH FILES
 .TP 
-.I /var/lib/games/icebreaker.scores
+.I /var/games/icebreaker.scores
 The system-wide list of high scores.
 .TP
 .I ~/.icebreaker
--- icebreaker-1.21.orig/options.c
+++ icebreaker-1.21/options.c
@@ -25,6 +25,8 @@
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
+#include <unistd.h>
+#include <sys/types.h>
 #include "icebreaker.h"
 #include "globals.h"
 #include "icebreaker.h"
@@ -48,14 +50,17 @@ int readoptions(void)
 	FILE * optionfile;
 	char linebuf[50];
 	char filename[255];
-	char optbuf[20];
-	char valbuf[10];
+	char optbuf[21];
+	char valbuf[11];
 	int i;
+	uid_t gid=getegid(), uid=geteuid();
 
 	setdefaultoptions();
 	
 	snprintf(filename,255,"%s/%s",homedir,OPTIONFILE);
 	
+	seteuid(getuid());
+	setegid(getgid());
 	optionfile=fopen(filename,"r");
 	if (optionfile==NULL)
 	{
@@ -110,6 +115,8 @@ int readoptions(void)
 	}
 	
 	fclose(optionfile);
+	setegid(gid);
+	seteuid(uid);
 
 	return false;
 }
@@ -118,8 +125,12 @@ int writeoptions(void)
 {
 	FILE * optionfile;
 	char filename[255];
+	uid_t gid=getegid(), uid=geteuid();
+	
 	snprintf(filename,255,"%s/%s",homedir,OPTIONFILE);
 	
+	seteuid(getuid());
+	setegid(getgid());
 	optionfile=fopen(filename,"w");
 	if (optionfile==NULL)
 	{
@@ -168,6 +179,8 @@ int writeoptions(void)
 
 	
 	fclose(optionfile);
+	setegid(gid);
+	seteuid(uid);
 	
 	return false;
 }
