[ekg2-commit] r4127 - in trunk: ekg plugins/jabber: trunk/ekg/plugins.h trunk/ekg/sessions.c trunk/ekg/stuff.c trunk/plugins/jabber/commands.c trunk/plugins/jabber/jabber_handlers.c
SVN commit
svn w toxygen.net
Pią, 18 Lip 2008, 11:45:41 CEST
Author: darkjames
Date: 2008-07-18 11:45:40 +0200 (Fri, 18 Jul 2008)
New Revision: 4127
Modified:
trunk/ekg/plugins.h
trunk/ekg/sessions.c
trunk/ekg/stuff.c
trunk/plugins/jabber/commands.c
trunk/plugins/jabber/jabber_handlers.c
Log:
fix base64_encode()
valgrind will now stop bugging us about 'Use of uninitialised value of size 4/8'
please test, and remove comments.
NOTE:
base64_encode() was using buffer from [0...len]
it's ok if as len we pass strlen(buf) because buf[strlen(buf] is accessible (NUL-byte)
However if we have some buffers (not NUL-terminated) each call can produce different base64-hash.
buf[sizeof(buf)] can be anything.
we should read buffer-data from [0 to len) [as we now do]
NOTE2: peres, can you check jabber_avatar_load() ?
Modified: trunk/ekg/plugins.h
===================================================================
--- trunk/ekg/plugins.h 2008-07-18 09:17:27 UTC (rev 4126)
+++ trunk/ekg/plugins.h 2008-07-18 09:45:40 UTC (rev 4127)
@@ -26,7 +26,7 @@
#include "dynstuff.h"
#include "sessions.h"
-#define EKG_ABI_VER 4118
+#define EKG_ABI_VER 4126
#define EXPORT __attribute__ ((visibility("default")))
Modified: trunk/ekg/sessions.c
===================================================================
--- trunk/ekg/sessions.c 2008-07-18 09:17:27 UTC (rev 4126)
+++ trunk/ekg/sessions.c 2008-07-18 09:45:40 UTC (rev 4127)
@@ -449,7 +449,7 @@
int session_password_set(session_t *s, const char *password)
{
xfree(s->password);
- s->password = (password) ? base64_encode(password, xstrlen(password)) : NULL;
+ s->password = (password) ? base64_encode(password, xstrlen(password)+1) : NULL; /* XXX: +1? */
return 0;
}
Modified: trunk/ekg/stuff.c
===================================================================
--- trunk/ekg/stuff.c 2008-07-18 09:17:27 UTC (rev 4126)
+++ trunk/ekg/stuff.c 2008-07-18 09:45:40 UTC (rev 4127)
@@ -2226,13 +2226,13 @@
res = out = xmalloc((len / 3 + 1) * 4 + 2);
- while (j <= len) {
+ while (j < len) {
switch (i % 4) {
case 0:
k = (buf[j] & 252) >> 2;
break;
case 1:
- if (j < len)
+ if (j+1 < len)
k = ((buf[j] & 3) << 4) | ((buf[j + 1] & 240) >> 4);
else
k = (buf[j] & 3) << 4;
@@ -2240,7 +2240,7 @@
j++;
break;
case 2:
- if (j < len)
+ if (j+1 < len)
k = ((buf[j] & 15) << 2) | ((buf[j + 1] & 192) >> 6);
else
k = (buf[j] & 15) << 2;
Modified: trunk/plugins/jabber/commands.c
===================================================================
--- trunk/plugins/jabber/commands.c 2008-07-18 09:17:27 UTC (rev 4126)
+++ trunk/plugins/jabber/commands.c 2008-07-18 09:45:40 UTC (rev 4127)
@@ -945,7 +945,7 @@
} else if (len >= sizeof(buf))
printq("io_toobig", path, itoa(len), sizeof(buf)-1);
else {
- char *enc = base64_encode(buf, len);
+ char *enc = base64_encode(buf, len); /* XXX base64_encode() CHANGED!! len+1 ? */
char *out;
const char *type = "application/octet-stream";
Modified: trunk/plugins/jabber/jabber_handlers.c
===================================================================
--- trunk/plugins/jabber/jabber_handlers.c 2008-07-18 09:17:27 UTC (rev 4126)
+++ trunk/plugins/jabber/jabber_handlers.c 2008-07-18 09:45:40 UTC (rev 4127)
@@ -426,7 +426,7 @@
string_append_raw(str, "\0", 1);
string_append(str, session_get(s, "password")); /* XXX, haslo rekodowac na UTF-8 */
- encoded = base64_encode(str->str, str->len-1);
+ encoded = base64_encode(str->str, str->len);
watch_write(j->send_watch,
"<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">%s</auth>", encoded);
@@ -577,7 +577,7 @@
string_append(str, ",response="); string_append(str, auth_resp);
string_append(str, ",charset=utf-8");
- encoded = base64_encode(str->str, str->len);
+ encoded = base64_encode(str->str, str->len); /* XXX base64_encoded() CHANGED!! str->len+1 ? */
watch_write(j->send_watch, "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">%s</response>", encoded);
xfree(encoded);
Więcej informacji o liście dyskusyjnej ekg2-commit