X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=unmime.c;h=f799ff92f51b5a22836a9135c43f9b4df8878bfb;hb=f3efb867a6c3b539e8ab946584f3ed00e5f31a43;hp=a518da2c0b36d9e7d221a5fbe2bea630432e3a96;hpb=1cdd882de1191a63cc2e9efc061ea1425f7d8904;p=~andy%2Ffetchmail diff --git a/unmime.c b/unmime.c index a518da2c..f799ff92 100644 --- a/unmime.c +++ b/unmime.c @@ -292,7 +292,7 @@ static char *GetBoundary(char *CntType) do { p2 = strchr(p1, ';'); if (p2) - for (p2++; isspace((unsigned char)*p2); p2++); + for (p2++; isspace((unsigned char)*p2); p2++) { } p1 = p2; } while ((p1) && (strncasecmp(p1, "boundary", 8) != 0)); @@ -337,7 +337,7 @@ static int CheckContentType(char *CntType) * be really careful if you change this. */ - static char *DecodedTypes[] = { + static const char *DecodedTypes[] = { "text/", /* Will match ALL content-type's starting with 'text/' */ "message/rfc822", NULL @@ -418,7 +418,7 @@ int MimeBodyType(char *hdrs, int WantDecode) */ /* Skip the "Content-Type:" part and whitespace after it */ - for (NxtHdr += 13; ((*NxtHdr == ' ') || (*NxtHdr == '\t')); NxtHdr++); + for (NxtHdr += 13; ((*NxtHdr == ' ') || (*NxtHdr == '\t')); NxtHdr++) { } /* * Get the full value of the Content-Type header; @@ -434,7 +434,7 @@ int MimeBodyType(char *hdrs, int WantDecode) if (p == NULL) p = NxtHdr + strlen(NxtHdr); xfree(CntType); - CntType = xmalloc(p-NxtHdr+1); + CntType = (char *)xmalloc(p-NxtHdr+1); strlcpy(CntType, NxtHdr, p-NxtHdr+1); HdrsFound++; } @@ -651,13 +651,13 @@ int UnMimeBodyline(char **bufp, flag delimited, flag softline) #include #include -char *program_name = "unmime"; +const char *program_name = "unmime"; int outlevel = 0; #define BUFSIZE_INCREMENT 4096 #ifdef DEBUG -#define DBG_FWRITE(B,L,BS,FD) fwrite(B, L, BS, FD) +#define DBG_FWRITE(B,L,BS,FD) do { if (fwrite((B), (L), (BS), (FD))) { } } while(0) #else #define DBG_FWRITE(B,L,BS,FD) #endif @@ -707,7 +707,7 @@ int main(int argc, char *argv[]) buf_p++; if ((unsigned)(buf_p - buffer) == BufSize) { /* Buffer is full! Get more room. */ - buffer = xrealloc(buffer, BufSize+BUFSIZE_INCREMENT); + buffer = (char *)xrealloc(buffer, BufSize+BUFSIZE_INCREMENT); buf_p = buffer + BufSize; BufSize += BUFSIZE_INCREMENT; } @@ -720,8 +720,11 @@ int main(int argc, char *argv[]) bodytype = MimeBodyType(buffer, 1); i = strlen(buffer); - fwrite(buffer, i, 1, stdout); DBG_FWRITE(buffer, i, 1, fd_conv); + if (fwrite(buffer, i, 1, stdout) < 1) { + perror("fwrite"); + goto barf; + } do { buf_p = (buffer - 1); @@ -738,13 +741,17 @@ int main(int argc, char *argv[]) buf_p = buffer; UnMimeBodyline(&buf_p, 0, 0); } - fwrite(buffer, (buf_p - buffer), 1, stdout); DBG_FWRITE(buffer, (buf_p - buffer), 1, fd_conv); + if (fwrite(buffer, (buf_p - buffer), 1, stdout) < 1) { + perror("fwrite"); + goto barf; + } } } while (buf_p > buffer); +barf: free(buffer); - fflush(stdout); + if (EOF == fflush(stdout)) perror("fflush"); #ifdef DEBUG fclose(fd_orig); @@ -754,4 +761,3 @@ int main(int argc, char *argv[]) return 0; } #endif -