Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9874 (closed defect: fixed)

Opened 9 months ago

Last modified 9 months ago

[PATH][TINY] fix oracle numeric password error

Reported by: limlian Assigned to: mschoen
Priority: normal Milestone: 1.2.5
Component: ActiveRecord Version: edge
Severity: normal Keywords: oracle,tiny
Cc: bitsweat

Description

Though password with only digits is not secure, Oracle database does support numeric passwords. Suppose we have Oracle database account named "test" with a legal password "123". Configure development mode as following:

-+-+-+-+-+-+- database.yml +-+-+-+-+-+-

development:
  adapter: oracle
  database: localhost/XE
  username: test
  password: 123

This will lead an error as following when we run "rake db:migrate"

-+-+-+-+-+-+- error message +-+-+-+-+-+-

rake aborted!
wrong argument type Fixnum (expected String)

This error happens because ActiveRecord doesn't convert password "123" from numeric to string when reading account information from database.yml. The Ruby-Oci8 driver checks the account parameters' type before connecting to the server. You can find the corresponding codes at Ruby-Oci8 driver's file env.c. Following is the code snippet.

-+-+-+-+-+-+- ruby-oci8-1.0.0.3-rc3/ext/oci8/env.c +-+-+-+-+-+-

static VALUE oci8_logon(VALUE self, VALUE username, VALUE password, VALUE dbname)
......
  Get_String(username, u);
  Get_String(password, p);
  Get_String(dbname, d);
......

The function "Get_String" checks the data type of username, password and dbname. If those parameters' type isn't string, a type error will be raised.

The attached patch with a very tiny modification fixes the problem and make the numeric password workable with Oracle adapter.

Attachments

fix_oracle_numeric_password_error_patch.diff (0.8 kB) - added by limlian on 10/15/07 08:16:13.

Change History

10/15/07 08:16:13 changed by limlian

  • attachment fix_oracle_numeric_password_error_patch.diff added.

10/15/07 08:56:43 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [7915]) Ensure username, password, and database are strings. Closes #9874 [limlian]