Commit c29be795c254d3c0b83a042a30092abe65c0d925

Authored by Perry Werneck
1 parent e3e52c8f
Exists in master and in 2 other branches develop, macos

Fixing code scanning alerts.

src/core/ctlr.c
... ... @@ -2364,8 +2364,13 @@ void ctlr_clear(H3270 *session, Boolean can_snap)
2364 2364  
2365 2365 #endif
2366 2366  
2367   - /* Clear the screen. */
2368   - (void) memset((char *)session->ea_buf, 0, session->view.rows * session->view.cols * sizeof(struct lib3270_ea));
  2367 + // Clear the screen.
  2368 + (void) memset(
  2369 + (char *)session->ea_buf,
  2370 + 0,
  2371 + ((size_t)session->view.rows) * ((size_t) session->view.cols) * sizeof(struct lib3270_ea)
  2372 + );
  2373 +
2369 2374 cursor_move(session,0);
2370 2375 session->buffer_addr = 0;
2371 2376  
... ...
src/core/rpq.c
... ... @@ -376,9 +376,7 @@ static Boolean select_rpq_terms(H3270 *hSession)
376 376 return False;
377 377 }
378 378  
379   -/**
380   - * @brief Utility function used by the RPQNAMES query reply.
381   - */
  379 +/// @brief Utility function used by the RPQNAMES query reply.
382 380 static int get_rpq_timezone(H3270 *hSession)
383 381 {
384 382 /*
... ... @@ -394,7 +392,7 @@ static int get_rpq_timezone(H3270 *hSession)
394 392 */
395 393 time_t here;
396 394 struct tm here_tm;
397   - struct tm *utc_tm;
  395 + struct tm utc_tm;
398 396 double delta;
399 397 char *p1, *p2;
400 398 struct rpq_keyword *kw;
... ... @@ -440,22 +438,31 @@ static int get_rpq_timezone(H3270 *hSession)
440 438 }
441 439  
442 440  
443   -// memcpy(&here_tm, localtime(&here), sizeof(struct tm));
444   - localtime_r(&here, &here_tm);
  441 + localtime_r(&here,&here_tm);
  442 +
  443 + if(gmtime_r(&here,&utc_tm) == NULL)
  444 + {
  445 + rpq_warning(hSession, _("RPQ: Unable to determine workstation UTC time"));
  446 + return 2;
  447 + }
  448 +
  449 + /*
  450 + memcpy(&here_tm, localtime(&here), sizeof(struct tm));
445 451  
446 452 if ((utc_tm = gmtime(&here)) == NULL)
447 453 {
448 454 rpq_warning(hSession, _("RPQ: Unable to determine workstation UTC time"));
449 455 return 2;
450 456 }
  457 + */
451 458  
452 459 /*
453 460 * Do not take Daylight Saving Time into account.
454 461 * We just want the "raw" time difference.
455 462 */
456 463 here_tm.tm_isdst = 0;
457   - utc_tm->tm_isdst = 0;
458   - delta = difftime(mktime(&here_tm), mktime(utc_tm)) / 60L;
  464 + utc_tm.tm_isdst = 0;
  465 + delta = difftime(mktime(&here_tm), mktime(&utc_tm)) / 60L;
459 466 }
460 467  
461 468 // sanity check: difference cannot exceed +/- 12 hours
... ...
src/core/telnet.c
... ... @@ -2152,10 +2152,13 @@ void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, in
2152 2152 int offset;
2153 2153 int col = 0;
2154 2154  
2155   - time_t ltime;
  2155 + {
  2156 + time_t ltime;
  2157 + struct tm tm;
  2158 + time(&ltime);
  2159 + strftime(l1, 81, "%x %X", localtime_r(&ltime,&tm));
  2160 + }
2156 2161  
2157   - time(&ltime);
2158   - strftime(l1, 81, "%x %X", localtime(&ltime));
2159 2162 lib3270_write_nettrace(hSession,"%c %s %s data len=%d\n\n",direction,l1,direction == '>' ? "SEND" : "RECV", len);
2160 2163  
2161 2164 for (offset = 0; offset < len; offset++)
... ...
src/core/util.c
... ... @@ -183,7 +183,7 @@ LIB3270_EXPORT void * lib3270_realloc(void *p, int len)
183 183  
184 184 LIB3270_EXPORT void * lib3270_calloc(int elsize, int nelem, void *ptr)
185 185 {
186   - size_t sz = nelem * elsize;
  186 + size_t sz = ((size_t) nelem) * ((size_t) elsize);
187 187  
188 188 if(ptr)
189 189 ptr = realloc(ptr,sz);
... ...