Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

NULL handling in gen_storage_odbc #27

Merged
merged 3 commits into from

3 participants

Brendon Hogger badlop Ben Homnick
Brendon Hogger

Using {auth_storage, odbc}, {auth_password_format, plain}, and Postgres, I noticed that it was trying to insert rows into passwd with the string "undefined" in storedkey, serverkey, salt, and iterationcount.

This tiny commit translates undefined to "NULL" in gen_storage_odbc writes, and conversely null to undefined in reads.

I was also getting a bunch of format crashes in debug prints which I've fixed with iolist_to_binary.

Krzysiek Goj goj referenced this pull request from a commit in goj/ejabberd
Krzysiek Goj goj Binarify ejabberd_s2s:parent_domains/1
Fixes #27 on GitHub
470bbf8
Michał Piotrowski michalwski referenced this pull request from a commit in michalwski/MongooseIM
Krzysiek Goj goj Binarify ejabberd_s2s:parent_domains/1
Fixes #27 on GitHub
3128b51
badlop badlop merged commit 9fe0eff into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +1 −1  src/ejabberd_c2s.erl
  2. +7 −0 src/gen_storage_odbc.erl
2  src/ejabberd_c2s.erl
View
@@ -1645,7 +1645,7 @@ send_text(StateData, Text) when StateData#state.xml_socket ->
(StateData#state.sockmod):send_xml(StateData#state.socket,
{xmlstreamraw, Text1});
send_text(StateData, Text) ->
- ?DEBUG("Send XML on stream = ~s", [Text]),
+ ?DEBUG("Send XML on stream = ~s", [iolist_to_binary(Text)]),
(StateData#state.sockmod):send(StateData#state.socket, Text).
send_element(StateData, #xmlel{ns = ?NS_XMPP, name = 'stream'} = El) ->
7 src/gen_storage_odbc.erl
View
@@ -423,6 +423,9 @@ rows_to_result(#tabdef{record_name = RecordName,
row_to_result(Row, [], Result) ->
{Row, lists:reverse(Result)};
+
+row_to_result([null | Row], [_ | Types], Result) ->
+ row_to_result(Row, Types, [undefined | Result]);
row_to_result([Field | Row], [Type | Types], Result) ->
case Type of
int ->
@@ -649,6 +652,10 @@ format(I) when is_integer(I) ->
%% escaping not needed
integer_to_list(I);
+
+format(undefined) ->
+ "NULL";
+
format(A) when is_atom(A) ->
%% escaping usually not needed, watch atom() usage
"'" ++ atom_to_list(A) ++ "'";
Something went wrong with that request. Please try again.