]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/tty.c
The use of <net/ppp_defs.h> isn't guranteed to exist on Linux (e.g. uclibc, buildroot...
[ppp.git] / pppd / tty.c
index 852cee700ac2d6811a9dfad81665defd1566238d..ad743539ec806c8fcfa2b7cfc9ea95195c063bf8 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
@@ -315,7 +319,7 @@ setdevname(char *cp, char **argv, int doit)
        }
 
        if (doit) {
-               strlcpy(devnam, cp, sizeof(devnam));
+               strlcpy(devnam, cp, MAXPATHLEN);
                devstat = statbuf;
                default_device = 0;
        }
@@ -410,7 +414,7 @@ void tty_process_extra_options(void)
                        option_error("no device specified and stdin is not a tty");
                        exit(EXIT_OPTION_ERROR);
                }
-               strlcpy(devnam, p, sizeof(devnam));
+               strlcpy(devnam, p, MAXPATHLEN);
                if (stat(devnam, &devstat) < 0)
                        fatal("Couldn't stat default device %s: %m", devnam);
        }
@@ -514,7 +518,7 @@ int connect_tty(void)
         * Get a pty master/slave pair if the pty, notty, socket,
         * or record options were specified.
         */
-       strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam));
+       strlcpy(ppp_devnam, devnam, MAXPATHLEN);
        pty_master = -1;
        pty_slave = -1;
        real_ttyfd = -1;
@@ -905,7 +909,7 @@ open_socket(char *dest)
 static int
 start_charshunt(int ifd, int ofd)
 {
-    int cpid;
+    int cpid, ret;
 
     cpid = safe_fork(ifd, ofd, (log_to_fd >= 0? log_to_fd: 2));
     if (cpid == -1) {
@@ -919,10 +923,14 @@ start_charshunt(int ifd, int ofd)
            log_to_fd = -1;
        else if (log_to_fd >= 0)
            log_to_fd = 2;
-       setgid(getgid());
-       setuid(uid);
-       if (getuid() != uid)
-           fatal("setuid failed");
+       ret = setgid(getgid());
+       if (ret != 0) {
+               fatal("setgid failed, %m");
+       }
+       ret = setuid(uid);
+       if (ret != 0 || getuid() != uid) {
+               fatal("setuid failed, %m");
+       }
        charshunt(0, 1, record_file);
        exit(0);
     }