@@ -227,11 +227,13 @@ rops_handle_POLLIN_h2(struct lws_context_per_thread *pt, struct lws *wsi,
227227 // lwsi_state(wsi) != LRS_H1C_ISSUE_HANDSHAKE2 &&
228228 lwsi_state (wsi ) != LRS_H2_WAITING_TO_SEND_HEADERS ))) {
229229
230+ int scr_ret ;
231+
230232 ebuf .token = pt -> serv_buf ;
231- ebuf . len = lws_ssl_capable_read (wsi ,
233+ scr_ret = lws_ssl_capable_read (wsi ,
232234 ebuf .token ,
233235 wsi -> a .context -> pt_serv_buf_size );
234- switch (ebuf . len ) {
236+ switch (scr_ret ) {
235237 case 0 :
236238 lwsl_info ("%s: zero length read\n" , __func__ );
237239 return LWS_HPI_RET_PLEASE_CLOSE_ME ;
@@ -243,6 +245,19 @@ rops_handle_POLLIN_h2(struct lws_context_per_thread *pt, struct lws *wsi,
243245 return LWS_HPI_RET_PLEASE_CLOSE_ME ;
244246 }
245247
248+ /*
249+ * coverity is confused: it knows lws_ssl_capable_read may
250+ * return < 0 and assigning that to ebuf.len is bad, but it
251+ * doesn't understand this check below on scr_ret < 0
252+ * removes that possibility
253+ */
254+
255+ ebuf .len = scr_ret ;
256+ if (ebuf .len < 0 ) /* ie, not usable data */ {
257+ lwsl_info ("%s: other error\n" , __func__ );
258+ return LWS_HPI_RET_PLEASE_CLOSE_ME ;
259+ }
260+
246261 // lwsl_notice("%s: Actual RX %d\n", __func__, ebuf.len);
247262 // if (ebuf.len > 0)
248263 // lwsl_hexdump_notice(ebuf.token, ebuf.len);
@@ -313,7 +328,8 @@ rops_handle_POLLIN_h2(struct lws_context_per_thread *pt, struct lws *wsi,
313328 lws_dll2_remove (& wsi -> dll_buflist );
314329 }
315330 } else
316- if (n && n < ebuf .len && ebuf .len > 0 ) {
331+ /* cov: both n and ebuf.len are int */
332+ if (n > 0 && n < ebuf .len && ebuf .len > 0 ) {
317333 // lwsl_notice("%s: h2 append seg %d\n", __func__, ebuf.len - n);
318334 m = lws_buflist_append_segment (& wsi -> buflist ,
319335 ebuf .token + n ,
0 commit comments