[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
src/usr.bin/tn3270/tools/mkhits/dohits.c scanf()'s
- To: bugs_(_at_)_openbsd_(_dot_)_org
- Subject: src/usr.bin/tn3270/tools/mkhits/dohits.c scanf()'s
- From: Jared Yanovich <jjy2+_(_at_)_pitt_(_dot_)_edu>
- Date: Thu, 13 Nov 2003 14:17:38 -0500
Index: dohits.c
===================================================================
RCS file: /cvs/src/usr.bin/tn3270/tools/mkhits/dohits.c,v
retrieving revision 1.8
diff -u -r1.8 dohits.c
--- dohits.c 2003/06/03 02:56:20 1.8
+++ dohits.c 2003/11/13 19:20:51
@@ -60,6 +60,7 @@
#include <string.h>
#endif /* defined(unix) */
#include <ctype.h>
+#include <err.h>
#include "../general/general.h"
#include "../api/asc_ebc.h"
#include "../api/ebc_disp.h"
@@ -98,7 +99,8 @@
struct thing **item, *this;
item = &firstentry(second);
- this = (struct thing *) malloc(sizeof *this);
+ if ((this = (struct thing *) malloc(sizeof *this)) == NULL)
+ err(1, "malloc");
this->next = *item;
this->hits = NULL;
*item = this;
@@ -117,13 +119,13 @@
char what[100], value[100];
char line[200];
- snprintf(compare, sizeof compare, " %s%%[^,\t \n]", prefix);
+ snprintf(compare, sizeof compare, " %s%%99[^,\t \n]", prefix);
if ((ourfile = fopen(file, "r")) == NULL) {
perror("fopen");
exit(1);
}
while (!feof(ourfile)) {
- if (fscanf(ourfile, compare, what) == 1) {
+ if (fscanf(ourfile, compare, what) == 1) {
add(prefix, what, 0);
}
do {
@@ -148,13 +150,13 @@
char line[200];
int whatitis;
- snprintf(compare, sizeof compare, "#define %s%%s %%s", prefix);
+ snprintf(compare, sizeof compare, "#define %s%%99s %%99s", prefix);
if ((ourfile = fopen(file, "r")) == NULL) {
perror("fopen");
exit(1);
}
while (!feof(ourfile)) {
- if (fscanf(ourfile, compare, what, value) == 2) {
+ if (fscanf(ourfile, compare, what, value) == 2) {
if (value[0] == '0') {
if ((value[1] == 'x') || (value[1] == 'X')) {
sscanf(value, "0x%x", &whatitis);
Visit your host, monkey.org