[evolution-activesync] eas-connection.c: avoid strlen(NULL)
- From: Patrick Ohly <pohly src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-activesync] eas-connection.c: avoid strlen(NULL)
- Date: Tue, 20 Sep 2016 18:33:00 +0000 (UTC)
commit ec22c586564e0841c87361fbc7ddef32e8977038
Author: Patrick Ohly <patrick ohly intel com>
Date: Tue Sep 20 04:49:02 2016 -0700
eas-connection.c: avoid strlen(NULL)
Calling strlen() when the xml pointer is NULL will lead to a crash.
The if(xml) probably was meant to apply to both the XML sanitization
and the calculation of the resulting string length.
Found via static code analysis (clang or cppcheck, not sure anymore).
eas-daemon/libeas/eas-connection.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/eas-daemon/libeas/eas-connection.c b/eas-daemon/libeas/eas-connection.c
index 7a3d973..006cab7 100644
--- a/eas-daemon/libeas/eas-connection.c
+++ b/eas-daemon/libeas/eas-connection.c
@@ -2190,10 +2190,10 @@ handle_server_response (SoupSession *session, SoupMessage *msg, gpointer data)
Anything we get here is going to be passed out to dbus in a string
type, and dbus would end up silently calling exit() if we pass it
non-UTF8 anyway */
- if (xml)
+ if (xml) {
xml = sanitize_utf8 (xml);
-
- xml_len = strlen((char *)xml);
+ xml_len = strlen((char *)xml);
+ }
if (getenv ("EAS_CAPTURE_RESPONSE") && (atoi (g_getenv ("EAS_CAPTURE_RESPONSE")) >=
1)) {
write_response_to_file (xml, xml_len);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]