Skip to content

Commit

Permalink
11392 mail: NULL pointer errors
Browse files Browse the repository at this point in the history
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Approved by: Garrett D'Amore <garrett@damore.org>
  • Loading branch information
tsoome committed Jul 20, 2019
1 parent d5dace5 commit 9e364ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
31 changes: 14 additions & 17 deletions usr/src/cmd/mail/isheader.c
Expand Up @@ -20,14 +20,13 @@
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* All Rights Reserved */


#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1. */
#include "mail.h"
/*
* isheader(lp, ctf) - check if lp is header line and return type
* lp -> pointer to line
* lp -> pointer to line
* ctfp -> continuation flag (should be FALSE the first time
* isheader() is called on a message. isheader() sets
* it for the remaining calls to that message)
Expand All @@ -36,24 +35,22 @@
* H_* -> type of header line found.
*/
int
isheader(lp, ctfp)
char *lp;
int *ctfp;
isheader(char *lp, int *ctfp)
{
register char *p, *q;
register int i;
char *p, *q;
int i;

p = lp;
while((*p) && (*p != '\n') && (isspace(*p))) {
while ((*p) && (*p != '\n') && (isspace(*p))) {
p++;
}
if((*p == NULL) || (*p == '\n')) {
if ((*p == '\0') || (*p == '\n')) {
/* blank line */
return (FALSE);
}

if ((*ctfp) && ((*lp == ' ') || (*lp == '\t'))) {
return(H_CONT);
return (H_CONT);
}

*ctfp = FALSE;
Expand All @@ -78,15 +75,15 @@ int *ctfp;
}
/*
* Check if name: value pair
*/
if ((p = strpbrk(lp, ":")) != NULL ) {
for(q = lp; q < p; q++) {
*/
if ((p = strpbrk(lp, ":")) != NULL) {
for (q = lp; q < p; q++) {
if ((*q == ' ') || (!isprint(*q))) {
return(FALSE);
return (FALSE);
}
}
*ctfp = TRUE;
return(H_NAMEVALUE);
return (H_NAMEVALUE);
}
return(FALSE);
return (FALSE);
}
24 changes: 10 additions & 14 deletions usr/src/cmd/mail/isit.c
Expand Up @@ -25,48 +25,44 @@
*/

/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */

#pragma ident "%Z%%M% %I% %E% SMI"
/* All Rights Reserved */

#include "mail.h"

/*
* isit(lp, type) -- match "name" portion of
* isit(lp, type) -- match "name" portion of
* "name: value" pair
* lp -> pointer to line to check
* type -> type of header line to match
* returns
* TRUE -> lp matches header type (case independent)
* TRUE -> lp matches header type (case independent)
* FALSE -> no match
*
* Execpt for H_FORM type, matching is case insensitive (bug 1173101)
*/
int
isit(lp, type)
register char *lp;
register int type;
isit(char *lp, int type)
{
register char *p;
char *p;

switch (type) {
case H_FROM:
for (p = header[type].tag; *lp && *p; lp++, p++) {
if (*p != *lp) {
return(FALSE);
return (FALSE);
}
}
break;
default:
for (p = header[type].tag; *lp && *p; lp++, p++) {
if (toupper(*p) != toupper(*lp)) {
return(FALSE);
return (FALSE);
}
}
break;
}
if (*p == NULL) {
return(TRUE);
if (*p == '\0') {
return (TRUE);
}
return(FALSE);
return (FALSE);
}

0 comments on commit 9e364ac

Please sign in to comment.