diff options
author | Toomas Soome <tsoome@me.com> | 2019-01-26 15:45:17 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2019-07-30 21:20:12 +0300 |
commit | 7bc3049f70ccb68ec7cd7ba1bb17a4643fb60f36 (patch) | |
tree | a993b7fcb85651c244c7c7f2563bda2f4a4edb37 | |
parent | 46fbc806d6e97aff59942e61f3f01b8abc70b716 (diff) | |
download | illumos-joyent-7bc3049f70ccb68ec7cd7ba1bb17a4643fb60f36.tar.gz |
11418 refer: NULL pointer errors
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r-- | usr/src/cmd/refer/addbib.c | 25 | ||||
-rw-r--r-- | usr/src/cmd/refer/refer2.c | 4 | ||||
-rw-r--r-- | usr/src/cmd/refer/refer4.c | 12 | ||||
-rw-r--r-- | usr/src/cmd/refer/sortbib.c | 14 |
4 files changed, 24 insertions, 31 deletions
diff --git a/usr/src/cmd/refer/addbib.c b/usr/src/cmd/refer/addbib.c index 99570efce7..8037bfa117 100644 --- a/usr/src/cmd/refer/addbib.c +++ b/usr/src/cmd/refer/addbib.c @@ -4,7 +4,7 @@ */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. @@ -12,9 +12,6 @@ * specifies the terms and conditions for redistribution. */ -#pragma ident "%Z%%M% %I% %E% SMI" - - #include <locale.h> #include <stdio.h> #include <ctype.h> @@ -23,16 +20,16 @@ struct skeleton { char prompt[20]; /* prompt user for entry */ - char keylet[5]; /* key letter for database */ + char keylet[5]; /* key letter for database */ } bibskel[MAXENT] = { " Author:", "%A", " Title:", "%T", " Journal:", "%J", - " Volume:", "%V", + " Volume:", "%V", " Pages:", "%P", "Publisher:", "%I", - " City:", "%C", - " Date:", "%D", + " City:", "%C", + " Date:", "%D", " Other:", "%O", " Keywords:", "%K", }; @@ -134,7 +131,7 @@ addbib(FILE *fp, char *argv) /* add entries to a bibliographic database */ } else if (line[strlen(line)-2] == '\\') { if (line[0] != '\\') { line[strlen(line)-2] = '\n'; - line[strlen(line)-1] = NULL; + line[strlen(line)-1] = '\0'; trim(line); fprintf(fp, "%s %s", bibskel[i].keylet, line); @@ -144,7 +141,7 @@ addbib(FILE *fp, char *argv) /* add entries to a bibliographic database */ fgets(line, BUFSIZ, stdin); if (line[strlen(line)-2] == '\\') { line[strlen(line)-2] = '\n'; - line[strlen(line)-1] = NULL; + line[strlen(line)-1] = '\0'; trim(line); fputs(line, fp); printf("> "); @@ -197,7 +194,7 @@ trim(char line[]) /* trim line of trailing white space */ break; } line[++n] = '\n'; - line[++n] = NULL; + line[++n] = '\0'; } void @@ -208,7 +205,7 @@ bibedit(FILE *fp, char *cmd, char *arg) /* edit database with edit, ex, or vi */ fclose(fp); while (!isspace(cmd[i])) i++; - cmd[i] = NULL; + cmd[i] = '\0'; if (fork() == 0) { if (cmd[0] == 'v' && cmd[1] == 'i') execlp(cmd, cmd, "+$", arg, NULL); @@ -261,7 +258,7 @@ rd_skel(char *arg) /* redo bibskel from user-supplied file */ for (entry = 0; fgets(str, BUFSIZ, pfp); entry++) { for (i = 0; str[i] != '\t' && str[i] != '\n'; i++) bibskel[entry].prompt[i] = str[i]; - bibskel[entry].prompt[i] = NULL; + bibskel[entry].prompt[i] = '\0'; if (str[i] == '\n') { fprintf(stderr, gettext( "No tabs between promptfile fields.\n")); @@ -271,7 +268,7 @@ rd_skel(char *arg) /* redo bibskel from user-supplied file */ } for (i++, j = 0; str[i] != '\n'; i++, j++) bibskel[entry].keylet[j] = str[i]; - bibskel[entry].keylet[j] = NULL; + bibskel[entry].keylet[j] = '\0'; if (entry >= MAXENT) { fprintf(stderr, gettext( diff --git a/usr/src/cmd/refer/refer2.c b/usr/src/cmd/refer/refer2.c index f8605e227b..5d879cf320 100644 --- a/usr/src/cmd/refer/refer2.c +++ b/usr/src/cmd/refer/refer2.c @@ -4,7 +4,7 @@ */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. @@ -47,7 +47,7 @@ doref(char *line1) int stat, nf, nr, query = 0, alph, digs; again: - buff[0] = dbuff[0] = NULL; + buff[0] = dbuff[0] = '\0'; if (biblio && Iline == 1 && line1[0] == '%') strcat(dbuff, line1); while (input(line)) { /* get query */ diff --git a/usr/src/cmd/refer/refer4.c b/usr/src/cmd/refer/refer4.c index e8cd5f22ab..560c4ec627 100644 --- a/usr/src/cmd/refer/refer4.c +++ b/usr/src/cmd/refer/refer4.c @@ -4,7 +4,7 @@ */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. @@ -12,8 +12,6 @@ * specifies the terms and conditions for redistribution. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "refer..c" #include <locale.h> @@ -50,7 +48,7 @@ append(char *s) ; lch = *--p; if (postpunct && punctuat(lch)) - *p = NULL; + *p = '\0'; else /* pre-punctuation */ switch (lch) { case '.': @@ -60,7 +58,7 @@ append(char *s) case ';': case ':': *p++ = lch; - *p = NULL; + *p = '\0'; } strcat(buff, s); if (postpunct) @@ -74,10 +72,10 @@ append(char *s) for (p = buff; *p; p++) ; if (*--p == '\n') - *p = NULL; + *p = '\0'; *p++ = lch; *p++ = '\n'; - *p = NULL; + *p = '\0'; } if (strlen(buff) > BUFSIZ) err(gettext("output buff too long (%d)"), BUFSIZ); diff --git a/usr/src/cmd/refer/sortbib.c b/usr/src/cmd/refer/sortbib.c index b05bf3b96e..fd1a7eeeba 100644 --- a/usr/src/cmd/refer/sortbib.c +++ b/usr/src/cmd/refer/sortbib.c @@ -4,7 +4,7 @@ */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. @@ -12,8 +12,6 @@ * specifies the terms and conditions for redistribution. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <locale.h> #include <stdio.h> #include <signal.h> @@ -136,7 +134,7 @@ sortbib(FILE *fp, FILE *tfp, int i) error(tempfile); } } - *fld[0] = *fld[1] = *fld[2] = *fld[3] = NULL; + *fld[0] = *fld[1] = *fld[2] = *fld[3] = '\0'; oneauth = 0; /* reset number of authors */ lastoffset = offset; /* save for next time */ } @@ -211,7 +209,7 @@ parse(char line[], char fld[][BUF]) int n, i, j; for (i = 0; i < 8; i++) /* zap out old strings */ - *wd[i] = NULL; + *wd[i] = '\0'; n = sscanf(line, "%s %s %s %s %s %s %s %s", wd[0], wd[1], wd[2], wd[3], wd[4], wd[5], wd[6], wd[7]); for (i = 0; i < 4; i++) { @@ -290,11 +288,11 @@ eval(char keystr[]) multauth = 1; i++; } - if (keystr[i] == NULL) + if (keystr[i] == '\0') break; keystr[j] = keystr[i]; } - keystr[j] = NULL; + keystr[j] = '\0'; } /* exit in case of various system errors */ @@ -321,7 +319,7 @@ endcomma(char *str) n = strlen(str) - 1; if (str[n] == ',') { - str[n] = NULL; + str[n] = '\0'; return (1); } return (0); |