From eb0925e19ab7b3611310cfb8e557d864e4ce3141 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Sat, 23 Jun 2007 14:20:21 +0000 Subject: [PATCH] Sanitize Name and Location given in the command line. Fix the bug with 8bit chars in the Name & Location in the text output. --- misc/astrolog/Makefile | 2 +- misc/astrolog/files/patch-ac | 36 +++++++++++++++++++++++++---- misc/astrolog/files/patch-charts1.c | 20 ++++++++++++++++ 3 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 misc/astrolog/files/patch-charts1.c diff --git a/misc/astrolog/Makefile b/misc/astrolog/Makefile index 5ba2dc70994d..e0470adedd9d 100644 --- a/misc/astrolog/Makefile +++ b/misc/astrolog/Makefile @@ -10,7 +10,7 @@ PORTNAME= astrolog PORTVERSION= 5.40 -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= misc MASTER_SITES= http://www.astrolog.org/ftp/ephem/:ephem \ http://www.astrolog.org/ftp/:dist diff --git a/misc/astrolog/files/patch-ac b/misc/astrolog/files/patch-ac index e3523ed21ebd..8d7a05dedcfd 100644 --- a/misc/astrolog/files/patch-ac +++ b/misc/astrolog/files/patch-ac @@ -1,6 +1,14 @@ ---- astrolog.c.orig Wed Dec 23 23:29:16 1998 -+++ astrolog.c Fri May 25 21:07:58 2001 -@@ -1146,8 +1146,18 @@ +--- astrolog.c.orig 1998-12-23 23:29:07.000000000 +0300 ++++ astrolog.c 2007-06-23 18:07:49.000000000 +0400 +@@ -35,6 +35,7 @@ + ** Last code change made 12/20/1998. + */ + ++#include + #include "astrolog.h" + + +@@ -1146,8 +1147,18 @@ case 'z': if (ch1 == '0') { if (argc <= 1 || RParseSz(argv[1], pmZon) == rLarge) { @@ -21,7 +29,27 @@ SS = us.dstDef = i ? 1.0 : 0.0; } else { SS = us.dstDef = RParseSz(argv[1], pmZon); -@@ -1236,9 +1246,19 @@ +@@ -1232,13 +1243,39 @@ + return fFalse; + } + ciCore.nam = SzPersist(argv[1]); ++ if (CchSz(ciCore.nam) > 25) /* see xcharts0.c */ ++ ciCore.nam[25] = chNull; ++ for (pch = ciCore.nam; *pch; pch++) { ++ if (*pch == '"') /* see io.c */ ++ *pch = '\''; ++ else if (iscntrl((_char)*pch)) /* see xgeneral.c */ ++ *pch = ' '; ++ } + ciCore.loc = SzPersist(argv[2]); ++ if (CchSz(ciCore.loc) > 25) /* see xcharts0.c */ ++ ciCore.loc[25] = chNull; ++ for (pch = ciCore.loc; *pch; pch++) { ++ if (*pch == '"') /* see io.c */ ++ *pch = '\''; ++ else if (iscntrl((_char)*pch)) /* see xgeneral.c */ ++ *pch = ' '; ++ } argc -= 2; argv += 2; break; } diff --git a/misc/astrolog/files/patch-charts1.c b/misc/astrolog/files/patch-charts1.c new file mode 100644 index 000000000000..707385e7fe03 --- /dev/null +++ b/misc/astrolog/files/patch-charts1.c @@ -0,0 +1,20 @@ +--- charts1.c.bak 1998-12-23 23:29:26.000000000 +0300 ++++ charts1.c 2007-06-23 16:28:33.000000000 +0400 +@@ -53,7 +53,7 @@ + char sz[cchSzDef]; + int day, fNam, fLoc; + +- fNam = *ciMain.nam > chNull; fLoc = *ciMain.loc > chNull; ++ fNam = *ciMain.nam != chNull; fLoc = *ciMain.loc != chNull; + AnsiColor(kWhite); + sprintf(sz, "%s %s chart ", szAppName, szVersionCore); PrintSz(sz); + if (fNoTimeOrSpace) +@@ -83,7 +83,7 @@ + real rT; + + CreateElemTable(&et); +- fNam = *ciMain.nam > chNull; fLoc = *ciMain.loc > chNull; ++ fNam = *ciMain.nam != chNull; fLoc = *ciMain.loc != chNull; + + PrintHeader(); /* Show time and date of the chart being displayed. */ +