X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Ftty.c;h=ad743539ec806c8fcfa2b7cfc9ea95195c063bf8;hb=509f04959ad891d7f981f035ed461d51bd1f74b0;hp=852cee700ac2d6811a9dfad81665defd1566238d;hpb=2ae35d6c067d198c5e0bb4ac2d480271f3de3540;p=ppp.git diff --git a/pppd/tty.c b/pppd/tty.c index 852cee7..ad74353 100644 --- a/pppd/tty.c +++ b/pppd/tty.c @@ -68,6 +68,10 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -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); }