- if (server)
- {
- /* For ServerHello only send extensions present
- * in ClientHello.
- */
- if (!(meth->ext_flags & SSL_EXT_FLAG_RECEIVED))
- continue;
- /* If callback absent for server skip it */
- if (!meth->add_cb)
- continue;
- }
- if (meth->add_cb)
- {
- int cb_retval = 0;
- cb_retval = meth->add_cb(s, meth->ext_type,
- &out, &outlen, al,
- meth->add_arg);
- if (cb_retval < 0)
- return 0; /* error */
- if (cb_retval == 0)
- continue; /* skip this extension */
- }
- if (4 > limit - ret || outlen > (size_t)(limit - ret - 4))
- return 0;
- s2n(meth->ext_type, ret);
- s2n(outlen, ret);
- if (outlen)
- {
- memcpy(ret, out, outlen);
- ret += outlen;
- }
- /* We can't send duplicates: code logic should prevent this. */
- OPENSSL_assert(!(meth->ext_flags & SSL_EXT_FLAG_SENT));
- /* Indicate extension has been sent: this is both a sanity
- * check to ensure we don't send duplicate extensions
- * and indicates that it is not an error if the extension
- * is present in ServerHello.
- */
- meth->ext_flags |= SSL_EXT_FLAG_SENT;
- if (meth->free_cb)
- meth->free_cb(s, meth->ext_type, out, meth->add_arg);
- }
- *pret = ret;
- return 1;
- }
+ if (server) {
+ /*
+ * For ServerHello only send extensions present in ClientHello.
+ */
+ if (!(meth->ext_flags & SSL_EXT_FLAG_RECEIVED))
+ continue;
+ /* If callback absent for server skip it */
+ if (!meth->add_cb)
+ continue;
+ }
+ if (meth->add_cb) {
+ int cb_retval = 0;
+ cb_retval = meth->add_cb(s, meth->ext_type,
+ &out, &outlen, al, meth->add_arg);
+ if (cb_retval < 0)
+ return 0; /* error */
+ if (cb_retval == 0)
+ continue; /* skip this extension */
+ }
+ if (4 > limit - ret || outlen > (size_t)(limit - ret - 4))
+ return 0;
+ s2n(meth->ext_type, ret);
+ s2n(outlen, ret);
+ if (outlen) {
+ memcpy(ret, out, outlen);
+ ret += outlen;
+ }
+ /*
+ * We can't send duplicates: code logic should prevent this.
+ */
+ OPENSSL_assert(!(meth->ext_flags & SSL_EXT_FLAG_SENT));
+ /*
+ * Indicate extension has been sent: this is both a sanity check to
+ * ensure we don't send duplicate extensions and indicates that it is
+ * not an error if the extension is present in ServerHello.
+ */
+ meth->ext_flags |= SSL_EXT_FLAG_SENT;
+ if (meth->free_cb)
+ meth->free_cb(s, meth->ext_type, out, meth->add_arg);
+ }
+ *pret = ret;
+ return 1;
+}