[PATCH 3/3] pg: check numeric user inputs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 text-utils/Makemodule.am | 4 ++--
 text-utils/pg.c          | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/text-utils/Makemodule.am b/text-utils/Makemodule.am
index 23185eaa..f2c10eb 100644
--- a/text-utils/Makemodule.am
+++ b/text-utils/Makemodule.am
@@ -59,11 +59,11 @@ pg_SOURCES = text-utils/pg.c
 
 if HAVE_TINFO
 more_LDADD = $(LDADD) -ltinfo
-pg_LDADD = $(LDADD) -ltinfo @NCURSES_LIBS@
+pg_LDADD = $(LDADD) libcommon.la -ltinfo @NCURSES_LIBS@
 ul_LDADD = $(LDADD) -ltinfo
 else
 more_LDADD = $(LDADD) @NCURSES_LIBS@
-pg_LDADD = $(LDADD) @NCURSES_LIBS@
+pg_LDADD = $(LDADD) libcommon.la @NCURSES_LIBS@
 ul_LDADD = $(LDADD) @NCURSES_LIBS@
 endif
 
diff --git a/text-utils/pg.c b/text-utils/pg.c
index 9ade866..c4a86ca 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -64,6 +64,7 @@
 #include "widechar.h"
 #include "all-io.h"
 #include "closestream.h"
+#include "strutils.h"
 
 #define	READBUF		LINE_MAX	/* size of input buffer */
 #define CMDBUF		255		/* size of command buffer */
@@ -1623,7 +1624,7 @@ main(int argc, char **argv)
 				goto endargs;
 			case '1': case '2': case '3': case '4': case '5':
 			case '6': case '7': case '8': case '9': case '0':
-				pagelen = atoi(argv[arg] + i);
+				pagelen = strtol_or_err(argv[arg] + 1, _("failed to parse argument"));
 				havepagelen = 1;
 				goto nextarg;
 			case 'c':
@@ -1687,7 +1688,7 @@ endargs:
 			/*NOTREACHED*/
 		case '1': case '2': case '3': case '4': case '5':
 		case '6': case '7': case '8': case '9': case '0':
-			startline = atoi(argv[arg] + 1);
+			startline = strtol_or_err(argv[arg] + 1, _("failed to parse argument"));
 			break;
 		case '/':
 			searchfor = argv[arg] + 2;
-- 
1.7.12.2

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux