From 92bc8d4e8e53221b119e5c652e8343522d649481 Mon Sep 17 00:00:00 2001 From: Robert Drehmel Date: Thu, 28 Apr 2005 12:37:15 +0000 Subject: [PATCH] - Set negative row or column argument values to zero. Negative values would produce undefined behaviour including a possible segmentation fault. - Explicitly initialize the global row and column variables to zero. PR: bin/80348 --- usr.bin/rs/rs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.bin/rs/rs.c b/usr.bin/rs/rs.c index 98cc3d4d16c..df01c57d1b6 100644 --- a/usr.bin/rs/rs.c +++ b/usr.bin/rs/rs.c @@ -86,7 +86,7 @@ char *curline; int allocsize = BUFSIZ; int curlen; int irows, icols; -int orows, ocols; +int orows = 0, ocols = 0; int maxlen; int skip; int propgutter; @@ -482,9 +482,11 @@ getargs(int ac, char *av[]) /*case 3: opages = atoi(av[2]);*/ case 2: - ocols = atoi(av[1]); + if ((ocols = atoi(av[1])) < 0) + ocols = 0; case 1: - orows = atoi(av[0]); + if ((orows = atoi(av[0])) < 0) + orows = 0; case 0: break; default: