~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/appl/libpty/getpty.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2009-05-07 16:16:34 UTC
  • mfrom: (13.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090507161634-xqyk0s9na0le4flj
Tags: 1.7dfsg~beta1-4
When  decrypting the TGS response fails with the subkey, try with the
session key to work around Heimdal bug, Closes: #527353 

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "com_err.h"
24
24
#include "libpty.h"
25
25
#include "pty-int.h"
 
26
#include "k5-platform.h"
26
27
 
27
28
long
28
29
ptyint_getpty_ext(int *fd, char *slave, int slavelength, int do_grantpt)
59
60
        *fd = -1;
60
61
        return PTY_GETPTY_NOPTY;
61
62
    }
62
 
    if (strlen(slaveret) > slavelength - 1) {
 
63
    if (strlcpy(slave, slaveret, slavelength) >= slavelength) {
63
64
        close(*fd);
64
65
        *fd = -1;
65
66
        return PTY_GETPTY_SLAVE_TOOLONG;
66
67
    }
67
 
    else strcpy(slave, slaveret);
68
68
    return 0;
69
69
#else /*HAVE__GETPTY*/
70
70
    
92
92
#endif
93
93
#endif
94
94
        if (p) {
95
 
            if (strlen(p) > slavelength - 1) {
 
95
            if (strlcpy(slave, p, slavelength) >= slavelength) {
96
96
                    close (*fd);
97
97
                    *fd = -1;
98
98
                    return PTY_GETPTY_SLAVE_TOOLONG;
99
99
            }
100
 
            strcpy(slave, p);
101
100
            return 0;
102
101
        }
103
102
 
106
105
            return PTY_GETPTY_FSTAT;
107
106
        }
108
107
        ptynum = (int)(stb.st_rdev&0xFF);
109
 
        sprintf(slavebuf, "/dev/ttyp%x", ptynum);
 
108
        snprintf(slavebuf, sizeof(slavebuf), "/dev/ttyp%x", ptynum);
110
109
        if (strlen(slavebuf) > slavelength - 1) {
111
110
            close(*fd);
112
111
            *fd = -1;
116
115
        return 0;
117
116
    } else {
118
117
        for (cp = "pqrstuvwxyzPQRST";*cp; cp++) {
119
 
            sprintf(slavebuf,"/dev/ptyXX");
 
118
            snprintf(slavebuf,sizeof(slavebuf),"/dev/ptyXX");
120
119
            slavebuf[sizeof("/dev/pty") - 1] = *cp;
121
120
            slavebuf[sizeof("/dev/ptyp") - 1] = '0';
122
121
            if (stat(slavebuf, &stb) < 0)