BSD 4_4_Lite1 release
[unix-history] / usr / src / usr.sbin / lpr / lpd / lpd.c
index 7d8ee13..aaf72b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 1983, 1993
+ * Copyright (c) 1983, 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
  *
  *
  *     The Regents of the University of California.  All rights reserved.
  *
  *
 
 #ifndef lint
 static char copyright[] =
 
 #ifndef lint
 static char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
+"@(#) Copyright (c) 1983, 1993, 1994\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)lpd.c      8.1 (Berkeley) 6/6/93";
+static char sccsid[] = "@(#)lpd.c      8.4 (Berkeley) 4/17/94";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -180,6 +180,7 @@ main(argc, argv)
        signal(SIGINT, mcleanup);
        signal(SIGQUIT, mcleanup);
        signal(SIGTERM, mcleanup);
        signal(SIGINT, mcleanup);
        signal(SIGQUIT, mcleanup);
        signal(SIGTERM, mcleanup);
+       memset(&un, 0, sizeof(un));
        un.sun_family = AF_UNIX;
        strcpy(un.sun_path, _PATH_SOCKETNAME);
 #ifndef SUN_LEN
        un.sun_family = AF_UNIX;
        strcpy(un.sun_path, _PATH_SOCKETNAME);
 #ifndef SUN_LEN
@@ -207,18 +208,21 @@ main(argc, argv)
                        syslog(LOG_ERR, "printer/tcp: unknown service");
                        mcleanup(0);
                }
                        syslog(LOG_ERR, "printer/tcp: unknown service");
                        mcleanup(0);
                }
+               memset(&sin, 0, sizeof(sin));
                sin.sin_family = AF_INET;
                sin.sin_port = sp->s_port;
                if (bind(finet, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
                        syslog(LOG_ERR, "bind: %m");
                        mcleanup(0);
                }
                sin.sin_family = AF_INET;
                sin.sin_port = sp->s_port;
                if (bind(finet, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
                        syslog(LOG_ERR, "bind: %m");
                        mcleanup(0);
                }
-               FD_SET(finet, &defreadfds);     
+               FD_SET(finet, &defreadfds);
                listen(finet, 5);
        }
        /*
         * Main loop: accept, do a request, continue.
         */
                listen(finet, 5);
        }
        /*
         * Main loop: accept, do a request, continue.
         */
+       memset(&frominet, 0, sizeof(frominet));
+       memset(&fromunix, 0, sizeof(fromunix));
        for (;;) {
                int domain, nfds, s;
                fd_set readfds;
        for (;;) {
                int domain, nfds, s;
                fd_set readfds;
@@ -425,7 +429,6 @@ startup()
         * Restart the daemons.
         */
        while (cgetnext(&buf, printcapdb) > 0) {
         * Restart the daemons.
         */
        while (cgetnext(&buf, printcapdb) > 0) {
-               printer = buf;
                for (cp = buf; *cp; cp++)
                        if (*cp == '|' || *cp == ':') {
                                *cp = '\0';
                for (cp = buf; *cp; cp++)
                        if (*cp == '|' || *cp == ':') {
                                *cp = '\0';
@@ -436,6 +439,7 @@ startup()
                        mcleanup(0);
                }
                if (!pid) {
                        mcleanup(0);
                }
                if (!pid) {
+                       printer = buf;
                        cgetclose();
                        printjob();
                }
                        cgetclose();
                        printjob();
                }