util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] swapon: check numeric user inputs
@ 2012-10-02 20:15 Sami Kerola
  2012-10-02 20:15 ` [PATCH 2/3] docs: clarify swapon.8 priority option Sami Kerola
  2012-10-02 20:15 ` [PATCH 3/3] pg: check numeric user inputs Sami Kerola
  0 siblings, 2 replies; 3+ messages in thread
From: Sami Kerola @ 2012-10-02 20:15 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/swapon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index c9cabc1..3fe6592 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -730,7 +730,8 @@ int main(int argc, char *argv[])
 			usage(stdout);
 			break;
 		case 'p':		/* priority */
-			priority = atoi(optarg);
+			priority = strtos16_or_err(optarg,
+					   _("failed to parse argument"));
 			break;
 		case 'L':
 			add_label(optarg);
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] docs: clarify swapon.8 priority option
  2012-10-02 20:15 [PATCH 1/3] swapon: check numeric user inputs Sami Kerola
@ 2012-10-02 20:15 ` Sami Kerola
  2012-10-02 20:15 ` [PATCH 3/3] pg: check numeric user inputs Sami Kerola
  1 sibling, 0 replies; 3+ messages in thread
From: Sami Kerola @ 2012-10-02 20:15 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Value -1 is valid argument for -p, even though it might not make much
sense as the -1 is in use when priority is not specified at all.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/swapon.8 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys-utils/swapon.8 b/sys-utils/swapon.8
index e471d07..69682b4 100644
--- a/sys-utils/swapon.8
+++ b/sys-utils/swapon.8
@@ -150,8 +150,8 @@ is needed.)
 .B "\-p, \-\-priority \fIpriority\fP"
 Specify the priority of the swap device.
 .I priority
-is a value between 0 and 32767. Higher numbers indicate higher
-priority. See
+is a value between \-1 and 32767.  Higher numbers indicate
+higher priority.  See
 .BR swapon (2)
 for a full description of swap priorities. Add
 .BI pri= value
@@ -159,6 +159,7 @@ to the option field of
 .I /etc/fstab
 for use with
 .BR "swapon -a" .
+When priority is not defined it defaults to \-1.
 .TP
 .B "\-s, \-\-summary"
 Display swap usage summary by device. Equivalent to "cat /proc/swaps".
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] pg: check numeric user inputs
  2012-10-02 20:15 [PATCH 1/3] swapon: check numeric user inputs Sami Kerola
  2012-10-02 20:15 ` [PATCH 2/3] docs: clarify swapon.8 priority option Sami Kerola
@ 2012-10-02 20:15 ` Sami Kerola
  1 sibling, 0 replies; 3+ messages in thread
From: Sami Kerola @ 2012-10-02 20:15 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-02 20:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-02 20:15 [PATCH 1/3] swapon: check numeric user inputs Sami Kerola
2012-10-02 20:15 ` [PATCH 2/3] docs: clarify swapon.8 priority option Sami Kerola
2012-10-02 20:15 ` [PATCH 3/3] pg: check numeric user inputs Sami Kerola

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).