X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/f5a9aef6b97b9f07c8af62b2eb4d67fcbb995fb7..b15948e6710cd1d7cc29b661591ac18c2de4cbd2:/uip/mhbuildsbr.c diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 653c5b3f..d2d033f1 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -62,7 +62,6 @@ void content_error (char *, CT, char *, ...); int find_cache (CT, int, int *, char *, char *, int); /* mhfree.c */ -void free_content (CT); void free_ctinfo (CT); void free_encoding (CT, int); @@ -134,6 +133,7 @@ build_mime (char *infile, int directives) struct part **pp; CT ct; FILE *in; + m_getfld_state_t gstate = 0; directive_init(directives); @@ -161,11 +161,12 @@ build_mime (char *infile, int directives) * draft into the linked list of header fields for * the new MIME message. */ - for (compnum = 1, state = FLD;;) { - switch (state = m_getfld (state, name, buf, sizeof(buf), in)) { + m_getfld_track_filepos (&gstate, in); + for (compnum = 1;;) { + int bufsz = sizeof buf; + switch (state = m_getfld (&gstate, name, buf, &bufsz, in)) { case FLD: case FLDPLUS: - case FLDEOF: compnum++; /* abort if draft has Mime-Version header field */ @@ -178,8 +179,10 @@ build_mime (char *infile, int directives) /* ignore any Content-Type fields in the header */ if (!mh_strcasecmp (name, TYPE_FIELD)) { - while (state == FLDPLUS) - state = m_getfld (state, name, buf, sizeof(buf), in); + while (state == FLDPLUS) { + bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, in); + } goto finish_field; } @@ -189,7 +192,8 @@ build_mime (char *infile, int directives) /* if necessary, get rest of field */ while (state == FLDPLUS) { - state = m_getfld (state, name, buf, sizeof(buf), in); + bufsz = sizeof buf; + state = m_getfld (&gstate, name, buf, &bufsz, in); vp = add (buf, vp); /* add to previous value */ } @@ -198,16 +202,13 @@ build_mime (char *infile, int directives) finish_field: /* if this wasn't the last header field, then continue */ - if (state != FLDEOF) - continue; - /* else fall... */ + continue; case FILEEOF: adios (NULL, "draft has empty body -- no directives!"); /* NOTREACHED */ case BODY: - case BODYEOF: fseek (in, (long) (-strlen (buf)), SEEK_CUR); break; @@ -220,6 +221,7 @@ finish_field: } break; } + m_getfld_state_destroy (&gstate); /* * Now add the MIME-Version header field @@ -400,8 +402,7 @@ static int user_content (FILE *in, char *file, char *buf, CT *ctp) { int extrnal, vrsn; - unsigned char *cp; - char **ap; + char *cp, **ap; char buffer[BUFSIZ]; struct multipart *m; struct part **pp; @@ -674,7 +675,7 @@ use_forw: if (ci->ci_magic) { /* check if specifies command to execute */ if (*ci->ci_magic == '|' || *ci->ci_magic == '!') { - for (cp = ci->ci_magic + 1; isspace (*cp); cp++) + for (cp = ci->ci_magic + 1; isspace ((unsigned char) *cp); cp++) continue; if (!*cp) adios (NULL, "empty pipe command for #%s directive", ci->ci_type); @@ -1093,7 +1094,7 @@ raw: if ((out = fopen (ce->ce_file, "w")) == NULL) adios (ce->ce_file, "unable to open for writing"); - for (i = 0; (child_id = vfork()) == NOTOK && i > 5; i++) + for (i = 0; (child_id = fork()) == NOTOK && i > 5; i++) sleep (5); switch (child_id) { case NOTOK: @@ -1153,7 +1154,7 @@ scan_content (CT ct) int checklinelen = 0, linelen = 0; /* check for long lines */ int checkboundary = 0, boundaryclash = 0; /* check if clashes with multipart boundary */ int checklinespace = 0, linespace = 0; /* check if any line ends with space */ - unsigned char *cp = NULL, buffer[BUFSIZ]; + char *cp = NULL, buffer[BUFSIZ]; struct text *t = NULL; FILE *in = NULL; CE ce = ct->c_cefile; @@ -1248,7 +1249,7 @@ scan_content (CT ct) */ if (check8bit) { for (cp = buffer; *cp; cp++) { - if (!isascii (*cp)) { + if (!isascii ((unsigned char) *cp)) { contains8bit = 1; check8bit = 0; /* no need to keep checking */ } @@ -1266,7 +1267,7 @@ scan_content (CT ct) /* * Check if line ends with a space. */ - if (checklinespace && (cp = buffer + strlen (buffer) - 2) > buffer && isspace (*cp)) { + if (checklinespace && (cp = buffer + strlen (buffer) - 2) > buffer && isspace ((unsigned char) *cp)) { linespace = 1; checklinespace = 0; /* no need to keep checking */ } @@ -1277,10 +1278,10 @@ scan_content (CT ct) */ if (checkboundary && buffer[0] == '-' && buffer[1] == '-') { for (cp = buffer + strlen (buffer) - 1; cp >= buffer; cp--) - if (!isspace (*cp)) + if (!isspace ((unsigned char) *cp)) break; *++cp = '\0'; - if (!strncmp(buffer + 2, prefix, len) && isdigit(buffer[2 + len])) { + if (!strncmp(buffer + 2, prefix, len) && isdigit((unsigned char) buffer[2 + len])) { boundaryclash = 1; checkboundary = 0; /* no need to keep checking */ } @@ -1639,7 +1640,8 @@ calculate_digest (CT ct, int asciiP) } /* encode the digest using base64 */ - for (dp = digest, op = outbuf, cc = sizeof(digest) / sizeof(digest[0]); + for (dp = digest, op = (char *) outbuf, + cc = sizeof(digest) / sizeof(digest[0]); cc > 0; cc -= 3, op += 4) { unsigned long bits; char *bp;