X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;ds=sidebyside;f=uip%2Fdistsbr.c;h=e5f7bc55b29921d2ee6a6890b12816f8e4c76c0d;hb=2f689a1cb907a5de04e6d39ffd217a69af3216c7;hp=bda98c8f120b9266c6ddad80c6075673bc5c142c;hpb=6c42153ad9362cc676ea66563bf400d7511b3b68;p=mmh diff --git a/uip/distsbr.c b/uip/distsbr.c index bda98c8..e5f7bc5 100644 --- a/uip/distsbr.c +++ b/uip/distsbr.c @@ -11,6 +11,7 @@ #include #include +#include static int hdrfd = NOTOK; static int txtfd = NOTOK; @@ -29,7 +30,8 @@ int distout (char *drft, char *msgnam, char *backup) { int state; - register char *dp, *resent; + register unsigned char *dp; + register char *resent; char name[NAMESZ], buffer[BUFSIZ]; register FILE *ifp, *ofp; @@ -130,6 +132,7 @@ ready_msg (char *msgnam) int state, out; char name[NAMESZ], buffer[BUFSIZ], tmpfil[BUFSIZ]; register FILE *ifp, *ofp; + char *cp = NULL; if (hdrfd != NOTOK) close (hdrfd), hdrfd = NOTOK; @@ -139,9 +142,12 @@ ready_msg (char *msgnam) if ((ifp = fopen (msgnam, "r")) == NULL) adios (msgnam, "unable to open message"); - strncpy (tmpfil, m_tmpfil ("dist"), sizeof(tmpfil)); - if ((hdrfd = open (tmpfil, O_RDWR | O_CREAT | O_TRUNC, 0600)) == NOTOK) - adios (tmpfil, "unable to re-open temporary file"); + cp = m_mktemp2(NULL, "dist", &hdrfd, NULL); + if (cp == NULL) { + adios("distsbr", "unable to create temporary file"); + } + fchmod(hdrfd, 0600); + strncpy(tmpfil, cp, sizeof(tmpfil)); if ((out = dup (hdrfd)) == NOTOK || (ofp = fdopen (out, "w")) == NULL) adios (NULL, "no file descriptors -- you lose big"); @@ -169,9 +175,12 @@ ready_msg (char *msgnam) case BODYEOF: fclose (ofp); - strncpy (tmpfil, m_tmpfil ("dist"), sizeof(tmpfil)); - if ((txtfd = open (tmpfil, O_RDWR | O_CREAT | O_TRUNC, 0600)) == NOTOK) - adios (tmpfil, "unable to open temporary file"); + cp = m_mktemp2(NULL, "dist", &txtfd, NULL); + if (cp == NULL) { + adios("distsbr", "unable to create temporary file"); + } + fchmod(txtfd, 0600); + strncpy (tmpfil, cp, sizeof(tmpfil)); if ((out = dup (txtfd)) == NOTOK || (ofp = fdopen (out, "w")) == NULL) adios (NULL, "no file descriptors -- you lose big");