WPS: Add a workaround for parsing M1 from OS X 10.6
authorJouni Malinen <j@w1.fi>
Mon, 5 Jul 2010 20:04:54 +0000 (13:04 -0700)
committerJouni Malinen <j@w1.fi>
Mon, 5 Jul 2010 20:04:54 +0000 (13:04 -0700)
It looks like Mac OS X adds unexpected 0x00 padding to the end of M1.
Skip that padding to avoid interop issues.

src/wps/wps_attr_parse.c

index b185721..30b0e79 100644 (file)
@@ -17,6 +17,8 @@
 #include "common.h"
 #include "wps_i.h"
 
+#define WPS_WORKAROUNDS
+
 
 static int wps_set_attr(struct wps_parse_attr *attr, u16 type,
                        const u8 *pos, u16 len)
@@ -435,6 +437,25 @@ int wps_parse_msg(const struct wpabuf *msg, struct wps_parse_attr *attr)
                        return -1;
                }
 
+#ifdef WPS_WORKAROUNDS
+               if (type == 0 && len == 0) {
+                       /*
+                        * Mac OS X 10.6 seems to be adding 0x00 padding to the
+                        * end of M1. Skip those to avoid interop issues.
+                        */
+                       int i;
+                       for (i = 0; i < end - pos; i++) {
+                               if (pos[i])
+                                       break;
+                       }
+                       if (i == end - pos) {
+                               wpa_printf(MSG_DEBUG, "WPS: Workaround - skip "
+                                          "unexpected message padding");
+                               break;
+                       }
+               }
+#endif /* WPS_WORKAROUNDS */
+
                if (wps_set_attr(attr, type, pos, len) < 0)
                        return -1;