Author: rhuijben
Date: Thu Oct 15 22:27:16 2015
New Revision: 1708900

URL: http://svn.apache.org/viewvc?rev=1708900&view=rev
Log:
Following up on r1708898, make the server side alpn selection code in the mock
server check that the to be returned protocol is actually one of the options
requested by the client.

* test/MockHTTPinC/MockHTTP_server.c
  (alpn_select_callback): Decode client generated list and see if the protocol
    is really in the list.

Modified:
    serf/trunk/test/MockHTTPinC/MockHTTP_server.c

Modified: serf/trunk/test/MockHTTPinC/MockHTTP_server.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/test/MockHTTPinC/MockHTTP_server.c?rev=1708900&r1=1708899&r2=1708900&view=diff
==============================================================================
--- serf/trunk/test/MockHTTPinC/MockHTTP_server.c (original)
+++ serf/trunk/test/MockHTTPinC/MockHTTP_server.c Thu Oct 15 22:27:16 2015
@@ -2522,11 +2522,24 @@ static int alpn_select_callback(SSL *ssl
                                 void *arg)
 {
   const char *select = arg;
+  apr_size_t select_sz = strlen(select);
 
-  *out = select;
-  *outlen = strlen(select);
+  unsigned char *p = in;
 
-  return SSL_TLSEXT_ERR_OK;
+  while ((p + *p) < (in + inlen)) {
+
+      if ((*p == select_sz)
+          && !strncmp(p+1, select, select_sz)) {
+
+          *out = select;
+          *outlen = strlen(select);
+          return SSL_TLSEXT_ERR_OK;
+      }
+
+      p += *p + 1;
+  }
+
+  return SSL_TLSEXT_ERR_ALERT_FATAL;
 }
 
 /**


Reply via email to