Skip to content
Tcl Source Code Attachment Details
Login

Attachment Details

Overview

Artifact ID: b866d5f547b0689824fd30d2fc12234cf7cc756d
Ticket: 719790ffffffffffffffffffffffffffffffffff
Date: 2006-03-14 06:44:27
User: davygrvy
Artifact Attached: 5b3eef43e30b5037f259c89514dfd6a0affff677
Filename:patch.txt
Description:fix for misplaced [eof] check.
Content:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
Index: ftpd.tcl
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/ftpd/ftpd.tcl,v
retrieving revision 1.26
diff -c -r1.26 ftpd.tcl
*** ftpd.tcl	5 Oct 2004 19:15:52 -0000	1.26
--- ftpd.tcl	13 Mar 2006 23:41:11 -0000
***************
*** 527,565 ****
      variable CurrentSocket 
  
      set CurrentSocket $sock
!     if {[eof $sock]} {
! 	Finish $sock
! 	return
!     }
!     switch -exact -- $data(state) {
! 	command {
! 	    gets $sock command
! 	    set parts [split $command]
! 	    set cmd [string toupper [lindex  $parts 0]]
! 	    auto_load ::ftpd::command::$cmd
!             if {($data(access) == 0) && ((![info exists data(user)]) || \
! 	            ($data(user) == "")) && (![string equal $cmd "USER"])} {
!                 if {[string equal $cmd "PASS"]} {
! 		    puts $sock "503 Login with USER first."
!                 } else {
!                     puts $sock "530 Please login with USER and PASS."
  		}
! 	    } elseif {($data(access) == 0) && (![string equal $cmd "PASS"]) \
!                     && (![string equal $cmd "USER"]) \
!                     && (![string equal $cmd "QUIT"])} {
!                 puts $sock "530 Please login with USER and PASS."
! 	    } elseif {[info command ::ftpd::command::$cmd] != ""} {
! 		Log debug $command
! 		::ftpd::command::$cmd $sock [lrange $parts 1 end]
! 		catch {flush $sock}
! 	    } else {
! 		Log error "Unknown command: $cmd"
! 		puts $sock "500 Unknown command $cmd"
  	    }
  	}
! 	default {
! 	    error "Unknown state \"$data(state)\""
! 	}
      }
      return
  }
--- 527,567 ----
      variable CurrentSocket 
  
      set CurrentSocket $sock
!     set caught [catch {gets $sock command} err]
! 
!     if {!$caught && [string length $command]} {
! 	switch -exact -- $data(state) {
! 	    command {
! 		set parts [split $command]
! 		set cmd [string toupper [lindex  $parts 0]]
! 		auto_load ::ftpd::command::$cmd
! 		if {($data(access) == 0) && ((![info exists data(user)]) || \
! 			($data(user) == "")) && (![string equal $cmd "USER"])} {
! 		    if {[string equal $cmd "PASS"]} {
! 			puts $sock "503 Login with USER first."
! 		    } else {
! 			puts $sock "530 Please login with USER and PASS."
! 		    }
! 		} elseif {($data(access) == 0) && (![string equal $cmd "PASS"]) \
! 			&& (![string equal $cmd "USER"]) \
! 			&& (![string equal $cmd "QUIT"])} {
! 		    puts $sock "530 Please login with USER and PASS."
! 		} elseif {[info command ::ftpd::command::$cmd] != ""} {
! 		    Log debug $command
! 		    ::ftpd::command::$cmd $sock [lrange $parts 1 end]
! 		    catch {flush $sock}
! 		} else {
! 		    Log error "Unknown command: $cmd"
! 		    puts $sock "500 Unknown command $cmd"
  		}
! 	    }
! 	    default {
! 		error "Unknown state \"$data(state)\""
  	    }
  	}
!     }
!     if {[eof $sock]} {
! 	Finish $sock
      }
      return
  }