diff options
author | Tim Potter <tpot@samba.org> | 2003-01-09 06:58:07 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2003-01-09 06:58:07 +0000 |
commit | c4b4386996c0f759017c74d928b37f62d1f710f4 (patch) | |
tree | d90454e59782083e07bf3edd23da68a798e7fa57 | |
parent | baa1276eb0adfef420b0e9bb4a9365c397ef9d84 (diff) | |
download | samba-c4b4386996c0f759017c74d928b37f62d1f710f4.tar.gz samba-c4b4386996c0f759017c74d928b37f62d1f710f4.tar.bz2 samba-c4b4386996c0f759017c74d928b37f62d1f710f4.zip |
Remove read_with_timeout() and replaced its only caller (the passwd chat
stuff) with a call to read_socket_with_timeout() which does the same thing.
Passwd chat still works but I couldn't figure out the right arguments to
passwd chat to get it to work right but data was definitely getting
through.
(This used to be commit 88eb9e9486bca55a38e40ae53aed35ee338a68d7)
-rw-r--r-- | source3/lib/util_sock.c | 82 | ||||
-rw-r--r-- | source3/smbd/chgpasswd.c | 10 |
2 files changed, 8 insertions, 84 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index e162e5cd77..3a7899df3d 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -186,30 +186,6 @@ ssize_t read_udp_socket(int fd,char *buf,size_t len) return(ret); } -/******************************************************************* - checks if read data is outstanding. - ********************************************************************/ -static int read_data_outstanding(int fd, unsigned int time_out) -{ - int selrtn; - fd_set fds; - struct timeval timeout; - - FD_ZERO(&fds); - FD_SET(fd, &fds); - - timeout.tv_sec = (time_t) (time_out / 1000); - timeout.tv_usec = (long)(1000 * (time_out % 1000)); - - selrtn = sys_select_intr(fd + 1, &fds, NULL, NULL, &timeout); - - if (selrtn <= 0) - { - return selrtn; - } - return FD_ISSET(fd, &fds) ? 1 : 0; -} - /**************************************************************************** Read data from a socket with a timout in msec. mincount = if timeout, minimum to read before returning @@ -217,7 +193,7 @@ static int read_data_outstanding(int fd, unsigned int time_out) time_out = timeout in milliseconds ****************************************************************************/ -static ssize_t read_socket_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out) +ssize_t read_socket_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out) { fd_set fds; int selrtn; @@ -309,62 +285,6 @@ static ssize_t read_socket_with_timeout(int fd,char *buf,size_t mincnt,size_t ma } /**************************************************************************** - Read data from a fd with a timout in msec. - mincount = if timeout, minimum to read before returning - maxcount = number to be read. - time_out = timeout in milliseconds -****************************************************************************/ - -ssize_t read_with_timeout(int fd, char *buf, size_t mincnt, size_t maxcnt, - unsigned int time_out) -{ - ssize_t readret; - size_t nread = 0; - - /* just checking .... */ - if (maxcnt <= 0) - return(0); - - /* Blocking read */ - if (time_out <= 0) { - if (mincnt == 0) mincnt = maxcnt; - - while (nread < mincnt) { - readret = sys_read(fd, buf + nread, maxcnt - nread); - - if (readret <= 0) - return readret; - - nread += readret; - } - return((ssize_t)nread); - } - - /* Most difficult - timeout read */ - /* If this is ever called on a disk file and - mincnt is greater then the filesize then - system performance will suffer severely as - select always returns true on disk files */ - - for (nread=0; nread < mincnt; ) { - int selrtn = read_data_outstanding(fd, time_out); - - if(selrtn <= 0) - return selrtn; - - readret = sys_read(fd, buf+nread, maxcnt-nread); - - if (readret <= 0) - return readret; - - nread += readret; - } - - /* Return the number we got */ - return((ssize_t)nread); -} - -/**************************************************************************** read data from the client, reading exactly N bytes. ****************************************************************************/ diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c index cc130d16c2..fb06ad3ab8 100644 --- a/source3/smbd/chgpasswd.c +++ b/source3/smbd/chgpasswd.c @@ -249,9 +249,9 @@ static int expect(int master, char *issue, char *expected) nread = 0; buffer[nread] = 0; - while ((len = read_with_timeout(master, buffer + nread, 1, - sizeof(buffer) - nread - 1, - timeout)) > 0) { + while ((len = read_socket_with_timeout(master, buffer + nread, 1, + sizeof(buffer) - nread - 1, + timeout)) > 0) { nread += len; buffer[nread] = 0; @@ -863,6 +863,10 @@ static NTSTATUS check_oem_password(const char *user, */ new_pw_len = IVAL(lmdata, 512); + + DEBUG(0, ("** new_pw_len = %d, new_passwd_size = %d\n", + new_pw_len, new_passwd_size)); + if (new_pw_len < 0 || new_pw_len > new_passwd_size - 1) { DEBUG(0,("check_oem_password: incorrect password length (%d).\n", new_pw_len)); pdb_free_sam(&sampass); |