[PATCH] 1/1 Validate parameters during media creation.

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

 



From 928ab8e3ffc24b6c4d9c5c740f5e9b879c6d7764 Mon Sep 17 00:00:00 2001
From: Mark Harvey <markh794@xxxxxxxxx>
Date: Thu, 25 Jun 2009 18:10:42 +1000
Subject: Prevent tgtimg from core dump.

Check all parameters have been specified when creating new media.

Signed-off-by: Mark Harvey <markh794@xxxxxxxxx>
---
usr/tgtimg.c |   16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/usr/tgtimg.c b/usr/tgtimg.c
index 43b0761..9e11f23 100644
--- a/usr/tgtimg.c
+++ b/usr/tgtimg.c
@@ -343,9 +343,21 @@ static int ssc_new(int op, char *path, char *barcode, char *capacity,
static int ssc_ops(int op, char *path, char *barcode, char *capacity,
		   char *media_type)
{
-	if (op == OP_NEW)
+	if (op == OP_NEW) {
+		if (!media_type) {
+			eprintf("Missing media type: WORM, CLEAN or DATA\n");
+			usage(1);
+		}
+		if (!barcode) {
+			eprintf("Missing the barcode param\n");
+			usage(1);
+		}
+		if (!capacity) {
+			eprintf("Missing the capacity param\n");
+			usage(1);
+		}
		return ssc_new(op, path, barcode, capacity, media_type);
-	else if (op == OP_SHOW)
+	} else if (op == OP_SHOW)
		return ssc_show(path);
	else {
		eprintf("unknown the operation type\n");
--
1.5.4.3

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

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux