xauth-pam: Add workaround for null-terminated passwords
authorTobias Brunner <tobias@strongswan.org>
Mon, 7 Jul 2014 09:12:30 +0000 (11:12 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 7 Jul 2014 09:14:02 +0000 (11:14 +0200)
Fixes #631.

src/libcharon/plugins/xauth_pam/xauth_pam.c

index 1970146..3414d2e 100644 (file)
@@ -153,7 +153,12 @@ METHOD(xauth_method_t, process, status_t,
                                attr2string(user, sizeof(user), chunk);
                                break;
                        case XAUTH_USER_PASSWORD:
-                               attr2string(pass, sizeof(pass), attr->get_chunk(attr));
+                               chunk = attr->get_chunk(attr);
+                               if (chunk.len && chunk.ptr[chunk.len - 1] == 0)
+                               {       /* fix null-terminated passwords (Android etc.) */
+                                       chunk.len -= 1;
+                               }
+                               attr2string(pass, sizeof(pass), chunk);
                                break;
                        default:
                                break;