@@ -292,35 +292,6 @@ int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, size_t len,
292292 max_send_fragment = ssl_get_max_send_fragment (s );
293293 split_send_fragment = ssl_get_split_send_fragment (s );
294294
295- /*
296- * Ask the record layer how it would like to split the amount of data that
297- * we have, and how many of those records it would like in one go.
298- */
299- maxpipes = s -> rlayer .wrlmethod -> get_max_records (s -> rlayer .wrl , type , n ,
300- max_send_fragment ,
301- & split_send_fragment );
302- /*
303- * If max_pipelines is 0 then this means "undefined" and we default to
304- * whatever the record layer wants to do. Otherwise we use the smallest
305- * value from the number requested by the record layer, and max number
306- * configured by the user.
307- */
308- if (s -> max_pipelines > 0 && maxpipes > s -> max_pipelines )
309- maxpipes = s -> max_pipelines ;
310-
311- if (maxpipes > SSL_MAX_PIPELINES )
312- maxpipes = SSL_MAX_PIPELINES ;
313-
314-
315- #if 0
316- /* TODO(RECLAYER): FIX ME */
317- if (maxpipes == 0
318- || s -> enc_write_ctx == NULL
319- || (EVP_CIPHER_get_flags (EVP_CIPHER_CTX_get0_cipher (s -> enc_write_ctx ))
320- & EVP_CIPH_FLAG_PIPELINE ) == 0
321- || !SSL_USE_EXPLICIT_IV (s ))
322- maxpipes = 1 ;
323- #endif
324295 if (max_send_fragment == 0
325296 || split_send_fragment == 0
326297 || split_send_fragment > max_send_fragment ) {
@@ -346,39 +317,56 @@ int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, size_t len,
346317
347318 for (;;) {
348319 size_t tmppipelen , remain ;
349- size_t numpipes , j , lensofar = 0 ;
320+ size_t j , lensofar = 0 ;
350321
351- if (n == 0 )
352- numpipes = 1 ;
353- else
354- numpipes = ((n - 1 ) / split_send_fragment ) + 1 ;
355- if (numpipes > maxpipes )
356- numpipes = maxpipes ;
322+ /*
323+ * Ask the record layer how it would like to split the amount of data
324+ * that we have, and how many of those records it would like in one go.
325+ */
326+ maxpipes = s -> rlayer .wrlmethod -> get_max_records (s -> rlayer .wrl , type , n ,
327+ max_send_fragment ,
328+ & split_send_fragment );
329+ /*
330+ * If max_pipelines is 0 then this means "undefined" and we default to
331+ * whatever the record layer wants to do. Otherwise we use the smallest
332+ * value from the number requested by the record layer, and max number
333+ * configured by the user.
334+ */
335+ if (s -> max_pipelines > 0 && maxpipes > s -> max_pipelines )
336+ maxpipes = s -> max_pipelines ;
337+
338+ if (maxpipes > SSL_MAX_PIPELINES )
339+ maxpipes = SSL_MAX_PIPELINES ;
340+
341+ if (split_send_fragment > max_send_fragment ) {
342+ SSLfatal (s , SSL_AD_INTERNAL_ERROR , ERR_R_INTERNAL_ERROR );
343+ return -1 ;
344+ }
357345
358- if (n / numpipes >= split_send_fragment ) {
346+ if (n / maxpipes >= split_send_fragment ) {
359347 /*
360348 * We have enough data to completely fill all available
361349 * pipelines
362350 */
363- for (j = 0 ; j < numpipes ; j ++ ) {
351+ for (j = 0 ; j < maxpipes ; j ++ ) {
364352 tmpls [j ].type = type ;
365353 tmpls [j ].version = recversion ;
366354 tmpls [j ].buf = & (buf [tot ]) + (j * split_send_fragment );
367355 tmpls [j ].buflen = split_send_fragment ;
368356 }
369357 /* Remember how much data we are going to be sending */
370- s -> rlayer .wpend_tot = numpipes * split_send_fragment ;
358+ s -> rlayer .wpend_tot = maxpipes * split_send_fragment ;
371359 } else {
372360 /* We can partially fill all available pipelines */
373- tmppipelen = n / numpipes ;
374- remain = n % numpipes ;
361+ tmppipelen = n / maxpipes ;
362+ remain = n % maxpipes ;
375363 /*
376364 * If there is a remainder we add an extra byte to the first few
377365 * pipelines
378366 */
379367 if (remain > 0 )
380368 tmppipelen ++ ;
381- for (j = 0 ; j < numpipes ; j ++ ) {
369+ for (j = 0 ; j < maxpipes ; j ++ ) {
382370 tmpls [j ].type = type ;
383371 tmpls [j ].version = recversion ;
384372 tmpls [j ].buf = & (buf [tot ]) + lensofar ;
@@ -392,7 +380,7 @@ int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, size_t len,
392380 }
393381
394382 i = HANDLE_RLAYER_WRITE_RETURN (s ,
395- s -> rlayer .wrlmethod -> write_records (s -> rlayer .wrl , tmpls , numpipes ));
383+ s -> rlayer .wrlmethod -> write_records (s -> rlayer .wrl , tmpls , maxpipes ));
396384 if (i <= 0 ) {
397385 /* SSLfatal() already called if appropriate */
398386 s -> rlayer .wnum = tot ;
0 commit comments