From 3809a8fdebc7087514443871f875d64c9e24e447 Mon Sep 17 00:00:00 2001 From: hubertf Date: Sat, 17 Jul 1999 19:57:03 +0000 Subject: The patch below improves the security of the game atc(6), by having it open the score file at the start and then drop all setgid privileges while keeping a (close-on-exec) file descriptor open to it. In order to allow this the static data files have to be made world readable. In addition a potential buffer overrun with corrupted score files is avoided by more careful use of scanf (note that SCORE_SCANF_FMT is defined alongside the definition of the relevant structure). Submitted in PR 8015 by Joseph Myers --- atc/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'atc/main.c') diff --git a/atc/main.c b/atc/main.c index 8bc180d5..3b543547 100644 --- a/atc/main.c +++ b/atc/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.8 1998/11/10 13:43:31 hubertf Exp $ */ +/* $NetBSD: main.c,v 1.9 1999/07/17 19:57:03 hubertf Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -55,7 +55,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: main.c,v 1.8 1998/11/10 13:43:31 hubertf Exp $"); +__RCSID("$NetBSD: main.c,v 1.9 1999/07/17 19:57:03 hubertf Exp $"); #endif #endif /* not lint */ @@ -78,6 +78,10 @@ main(ac, av) struct itimerval itv; #endif + /* Open the score file then revoke setgid privileges */ + open_score_file(); + setregid(getgid(), getgid()); + start_time = seed = time(0); name = *av++; -- cgit v1.2.3-56-ge451