changeset 141:a1aa8ee2da85

read_hex_data_file(): add maxlen argument
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 24 Feb 2021 17:25:28 +0000
parents 13ab44761ea6
children 878d66dce6d3
files libcommon/hexread.c simtool/stktest.c simtool/writecmd.c uicc/writecmd.c
diffstat 4 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libcommon/hexread.c	Wed Feb 24 17:16:04 2021 +0000
+++ b/libcommon/hexread.c	Wed Feb 24 17:25:28 2021 +0000
@@ -10,9 +10,10 @@
 
 extern FILE *open_script_input_file();
 
-read_hex_data_file(filename, databuf)
+read_hex_data_file(filename, databuf, maxlen)
 	char *filename;
 	u_char *databuf;
+	unsigned maxlen;
 {
 	FILE *inf;
 	unsigned count;
@@ -38,7 +39,7 @@
 		c2 = getc(inf);
 		if (!isxdigit(c2))
 			goto inv_input;
-		if (count >= 255) {
+		if (count >= maxlen) {
 			fprintf(stderr, "%s: hex input data is too long\n",
 				filename);
 			fclose(inf);
--- a/simtool/stktest.c	Wed Feb 24 17:16:04 2021 +0000
+++ b/simtool/stktest.c	Wed Feb 24 17:25:28 2021 +0000
@@ -39,7 +39,7 @@
 	int rc;
 	unsigned len;
 
-	rc = read_hex_data_file(argv[1], cmd + 5);
+	rc = read_hex_data_file(argv[1], cmd + 5, 255);
 	if (rc < 0)
 		return(rc);
 	len = rc;
--- a/simtool/writecmd.c	Wed Feb 24 17:16:04 2021 +0000
+++ b/simtool/writecmd.c	Wed Feb 24 17:25:28 2021 +0000
@@ -15,7 +15,7 @@
 		fprintf(stderr, "error: offset argument is out of range\n");
 		return(-1);
 	}
-	rc = read_hex_data_file(argv[2], data);
+	rc = read_hex_data_file(argv[2], data, 255);
 	if (rc < 0)
 		return(rc);
 	len = rc;
@@ -54,7 +54,7 @@
 			"error: record number argument is out of range\n");
 		return(-1);
 	}
-	rc = read_hex_data_file(argv[2], data);
+	rc = read_hex_data_file(argv[2], data, 255);
 	if (rc < 0)
 		return(rc);
 	if (rc != curfile_record_len) {
@@ -70,7 +70,7 @@
 	u_char data[255];
 	int rc;
 
-	rc = read_hex_data_file(argv[1], data);
+	rc = read_hex_data_file(argv[1], data, 255);
 	if (rc < 0)
 		return(rc);
 	if (rc != curfile_record_len) {
--- a/uicc/writecmd.c	Wed Feb 24 17:16:04 2021 +0000
+++ b/uicc/writecmd.c	Wed Feb 24 17:25:28 2021 +0000
@@ -16,7 +16,7 @@
 		fprintf(stderr, "error: offset argument is out of range\n");
 		return(-1);
 	}
-	rc = read_hex_data_file(argv[2], data);
+	rc = read_hex_data_file(argv[2], data, 255);
 	if (rc < 0)
 		return(rc);
 	len = rc;
@@ -59,7 +59,7 @@
 			"error: record number argument is out of range\n");
 		return(-1);
 	}
-	rc = read_hex_data_file(argv[2], data);
+	rc = read_hex_data_file(argv[2], data, 255);
 	if (rc < 0)
 		return(rc);
 	if (rc != last_sel_file_record_len) {