Mercurial > hg > early-roguelike
annotate arogue5/acinclude.m4 @ 176:db1c9a21a7c3
srogue: prevent overflowing the score file name.
If SCOREFILE is not defined, roguehome() is called to find a directory
for the score file. It copies up to PATH_MAX-20 bytes from an
environment variable to a static buffer. Later these are strcpy()'d to
scorefile, which is of size LINLEN. Unfortunately LINLEN is 80 and
PATH_MAX is at least 256. On Linux, it happens to be 4096.
I haven't yet managed to crash or exploit it, but there are surely no
beneficial consequences, so roguehome() has been modified to check the
length, and the string it returns is also checked in main().
author | John "Elwin" Edwards |
---|---|
date | Sun, 02 Aug 2015 12:14:47 -0400 |
parents | dfeed24bb616 |
children | 029c1f5c5588 |
rev | line source |
---|---|
99 | 1 AC_DEFUN([MP_WITH_CURSES], |
2 [AC_ARG_WITH(ncurses, [ --with-ncurses Force the use of ncurses over curses],,) | |
3 mp_save_LIBS="$LIBS" | |
4 CURSES_LIB="" | |
5 if test "$with_ncurses" != yes | |
6 then | |
7 AC_CACHE_CHECK([for working curses], mp_cv_curses, | |
8 [LIBS="$LIBS -lcurses" | |
9 AC_TRY_LINK( | |
10 [#include <curses.h>], | |
11 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
12 mp_cv_curses=yes, mp_cv_curses=no)]) | |
13 if test "$mp_cv_curses" = yes | |
14 then | |
15 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
16 #AC_DEFINE(HAVE_CURSES_H) | |
17 CURSES_LIB="-lcurses" | |
18 fi | |
19 fi | |
20 if test ! "$CURSES_LIB" | |
21 then | |
22 AC_CACHE_CHECK([for working ncurses], mp_cv_ncurses, | |
23 [LIBS="$mp_save_LIBS -lncurses" | |
24 AC_TRY_LINK( | |
25 [#include <ncurses.h>], | |
26 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
27 mp_cv_ncurses=yes, mp_cv_ncurses=no)]) | |
28 if test "$mp_cv_ncurses" = yes | |
29 then | |
30 AC_DEFINE(HAVE_NCURSES_H, 1, [Define to 1 if libncurses is requested]) | |
31 CURSES_LIB="-lncurses" | |
32 fi | |
33 fi | |
34 if test ! "$CURSES_LIB" | |
35 then | |
36 AC_CACHE_CHECK([for working pdcurses], mp_cv_pdcurses, | |
37 [LIBS="$mp_save_LIBS -lpdcurses" | |
38 AC_TRY_LINK( | |
39 [#include <curses.h>], | |
40 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
41 mp_cv_pdcurses=yes, mp_cv_pdcurses=no)]) | |
42 if test "$mp_cv_pdcurses" = yes | |
43 then | |
44 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
45 CURSES_LIB="-lpdcurses" | |
46 fi | |
47 fi | |
48 if test ! "$CURSES_LIB" | |
49 then | |
50 AC_CACHE_CHECK([for working pdcur], mp_cv_pdcur, | |
51 [LIBS="$mp_save_LIBS -lpdcur" | |
52 AC_TRY_LINK( | |
53 [#include <curses.h>], | |
54 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
55 mp_cv_pdcur=yes, mp_cv_pdcur=no)]) | |
56 if test "$mp_cv_pdcur" = yes | |
57 then | |
58 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
59 CURSES_LIB="-lpdcur" | |
60 fi | |
61 fi | |
62 if test ! "$CURSES_LIB" | |
63 then | |
64 AC_CACHE_CHECK([for working peer pdcurses], mp_cv_lpdcurses, | |
65 [LIBS="$mp_save_LIBS ../pdcurses/pdcurses.a" | |
66 AC_TRY_LINK( | |
67 [#include "../pdcurses/curses.h"], | |
68 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
69 mp_cv_lpdcurses=yes, mp_cv_lpdcurses=no)]) | |
70 if test "$mp_cv_lpdcurses" = yes | |
71 then | |
72 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
73 CURSES_LIB="../pdcurses/pdcurses.a" | |
74 RF_ADDTO(CPPFLAGS,"-I../pdcurses") | |
75 fi | |
76 fi | |
77 AC_CACHE_CHECK([for ESCDELAY variable], | |
78 [mc_cv_ncurses_escdelay], | |
79 [AC_TRY_LINK([], [ | |
80 extern int ESCDELAY; | |
81 ESCDELAY = 0; | |
82 ], | |
83 [mc_cv_ncurses_escdelay=yes], | |
84 [mc_cv_ncurses_escdelay=no]) | |
85 ]) | |
86 if test "$mc_cv_ncurses_escdelay" = yes; then | |
87 AC_DEFINE(HAVE_ESCDELAY, 1, | |
88 [Define if ncurses has ESCDELAY variable]) | |
89 fi | |
90 if test ! "$CURSES_LIB" ; then | |
91 LIBS="$mp_save_LIBS" | |
92 fi | |
93 ])dnl | |
94 | |
95 dnl | |
dfeed24bb616
arogue5: port to autoconf.
John "Elwin" Edwards |