diff options
author | Kristian Høgsberg <krh@redhat.com> | 2004-05-17 22:19:04 +0000 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2004-05-17 22:19:04 +0000 |
commit | d86fc4071ccb8590d922e3456c5c80c0f7bb9d6f (patch) | |
tree | 7ed880494686d9290ad1f9ded6230459e2e7269a /dbus/dbus-keyring.c | |
parent | 91605d6899e8f21a6adf7f2fc87cfe07d399875f (diff) |
2004-05-17 Kristian Høgsberg <krh@redhat.com>
Remove base64 encoding, replace with hex encoding. Original patch
from trow@ximian.com, added error handling.
* dbus/dbus-string.c (_dbus_string_base64_encode)
(_dbus_string_base64_decode): Remove.
(_dbus_string_hex_decode): Add end_return argument so we can
distinguish between OOM and invalid hex encoding.
(_dbus_string_test): Remove base64 tests and add test case for
invalid hex.
* dbus/dbus-keyring.c, dbus/dbus-auth-script.c, dbus/dbus-auth.c:
Replace base64 with hex.
* test/data/auth/invalid-hex-encoding.auth-script: New test case
for invalid hex encoded data in auth protocol.
Diffstat (limited to 'dbus/dbus-keyring.c')
-rw-r--r-- | dbus/dbus-keyring.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 68178b15..92989b8d 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -474,6 +474,7 @@ _dbus_keyring_reload (DBusKeyring *keyring, int id; long timestamp; int len; + int end; DBusKey *new; /* Don't load more than the max. */ @@ -542,13 +543,20 @@ _dbus_keyring_reload (DBusKeyring *keyring, keys[n_keys-1].id = id; keys[n_keys-1].creation_time = timestamp; - if (!_dbus_string_hex_decode (&line, next, - &keys[n_keys-1].secret, - 0)) - { - dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); - goto out; - } + if (!_dbus_string_hex_decode (&line, next, &end, + &keys[n_keys-1].secret, 0)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto out; + } + + if (_dbus_string_get_length (&line) != end) + { + _dbus_verbose ("invalid hex encoding in keyring file\n"); + _dbus_string_free (&keys[n_keys - 1].secret); + n_keys -= 1; + continue; + } } _dbus_verbose ("Successfully loaded %d existing keys\n", |