diff options
author | robert <robert@FreeBSD.org> | 2005-04-28 12:37:15 +0000 |
---|---|---|
committer | robert <robert@FreeBSD.org> | 2005-04-28 12:37:15 +0000 |
commit | 848d1505738e386694e687cceccbc3d3f52fef78 (patch) | |
tree | 78189b0980b24db9e30086e8df0afee8106e5e04 /usr.bin/rs/rs.c | |
parent | cb2545c6526a804b90d024436133d94df2b327b1 (diff) | |
download | FreeBSD-src-848d1505738e386694e687cceccbc3d3f52fef78.zip FreeBSD-src-848d1505738e386694e687cceccbc3d3f52fef78.tar.gz |
- 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
Diffstat (limited to 'usr.bin/rs/rs.c')
-rw-r--r-- | usr.bin/rs/rs.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/rs/rs.c b/usr.bin/rs/rs.c index 98cc3d4..df01c57 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: |