Issue [1395] NullPointerException raised by ldapsearch when prompt for bind passwd
When "-w -" is passed to a command-line tool such as ldapsearch, the tool requests the bind password from standard input. OpenDS on Java 6 uses java.io.Console.readPassword method. For prior releases a utility method org.opends.server.util.PasswordReader.readPasswordUsingBackspaces is used, and this routine returns a char[] with the user-supplied password, which is used to initialize a String. In the case no password was supplied (i.e., the user just presses return at the prompt), the routine returns null, which results in an exception. This change returns char[0] in the case of an empty password, which mimics the behavior of the Java 6 java.io.Console.readPassword, and eliminates the exception.
| | |
| | | err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH)); |
| | | return 1; |
| | | } |
| | | } else if(bindPasswordValue == null) |
| | | } |
| | | else if(bindPasswordValue == null) |
| | | { |
| | | // Read from file if it exists. |
| | | bindPasswordValue = bindPasswordFile.getValue(); |
| | |
| | | if ((charRead == -1) || (charRead == '\n')) |
| | | { |
| | | // This is the end of the value. |
| | | if (pos == 0) |
| | | pwChars = new char[pos]; |
| | | if (0 < pos) |
| | | { |
| | | return null; |
| | | } |
| | | else |
| | | { |
| | | pwChars = new char[pos]; |
| | | System.arraycopy(pwBuffer, 0, pwChars, 0, pos); |
| | | Arrays.fill(pwBuffer, '\u0000'); |
| | | return pwChars; |
| | | } |
| | | return pwChars; |
| | | } |
| | | else if (charRead == '\r') |
| | | { |