fix for bug #578 repl leaks umask; there are several other
authorGlenn Burkhardt <glenn@aoi.ultranet.com>
Thu, 26 Jun 2003 01:30:36 +0000 (01:30 +0000)
committerGlenn Burkhardt <glenn@aoi.ultranet.com>
Thu, 26 Jun 2003 01:30:36 +0000 (01:30 +0000)
places in the code where the umask value is not restored,
so there might be other similar bugs

uip/replsbr.c

index 1ea411c..a7616d3 100644 (file)
@@ -76,14 +76,16 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
     register char **nxtbuf;
     register char **ap;
     register struct comp **savecomp;
     register char **nxtbuf;
     register char **ap;
     register struct comp **savecomp;
-    int        char_read = 0, format_len;
+    int        char_read = 0, format_len, mask;
     char name[NAMESZ], *scanl, *cp;
     FILE *out;
 
     char name[NAMESZ], *scanl, *cp;
     FILE *out;
 
-    umask(~m_gmprot());
+    mask = umask(~m_gmprot());
     if ((out = fopen (drft, "w")) == NULL)
        adios (drft, "unable to create");
 
     if ((out = fopen (drft, "w")) == NULL)
        adios (drft, "unable to create");
 
+    umask(mask);
+
     /* get new format string */
     cp = new_fs (form, NULL, NULL);
     format_len = strlen (cp);
     /* get new format string */
     cp = new_fs (form, NULL, NULL);
     format_len = strlen (cp);