Fixed findings

List of Findings

Error: GCC_ANALYZER_WARNING (CWE-401): [#def1]
screen-4.9.1-build/screen-4.9.1/ansi.c: scope_hint: In function ‘MFixLine’
screen-4.9.1-build/screen-4.9.1/ansi.c:2390:10: warning[-Wanalyzer-malloc-leak]: leak of ‘calloc((long unsigned int)(*p.w_layer.l_width + 1), 1)’
screen-4.9.1-build/screen-4.9.1/screen.h:151: included_from: Included from here.
screen-4.9.1-build/screen-4.9.1/ansi.c:36: included_from: Included from here.
screen-4.9.1-build/screen-4.9.1/ansi.c:2390:50: note: in expansion of macro ‘w_width’
# 2388|     if (mc->attr && ml->attr == null)
# 2389|       {
# 2390|->       if ((ml->attr = (unsigned char *)calloc(p->w_width + 1, 1)) == 0)
# 2391|   	{
# 2392|   	  ml->attr = null;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def2]
screen-4.9.1-build/screen-4.9.1/ansi.c:2400:10: warning[-Wanalyzer-malloc-leak]: leak of ‘calloc((long unsigned int)(*p.w_layer.l_width + 1), 1)’
screen-4.9.1-build/screen-4.9.1/ansi.c:2400:50: note: in expansion of macro ‘w_width’
# 2398|     if (mc->font && ml->font == null)
# 2399|       {
# 2400|->       if ((ml->font = (unsigned char *)calloc(p->w_width + 1, 1)) == 0)
# 2401|   	{
# 2402|   	  ml->font = null;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def3]
screen-4.9.1-build/screen-4.9.1/ansi.c:2411:10: warning[-Wanalyzer-malloc-leak]: leak of ‘calloc((long unsigned int)(*p.w_layer.l_width + 1), 1)’
screen-4.9.1-build/screen-4.9.1/ansi.c:2390:50: note: in expansion of macro ‘w_width’
screen-4.9.1-build/screen-4.9.1/ansi.c:2400:50: note: in expansion of macro ‘w_width’
screen-4.9.1-build/screen-4.9.1/ansi.c:2411:51: note: in expansion of macro ‘w_width’
# 2409|     if (mc->fontx && ml->fontx == null)
# 2410|       {
# 2411|->       if ((ml->fontx = (unsigned char *)calloc(p->w_width + 1, 1)) == 0)
# 2412|   	{
# 2413|   	  ml->fontx = null;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def4]
screen-4.9.1-build/screen-4.9.1/ansi.c:2421:10: warning[-Wanalyzer-malloc-leak]: leak of ‘calloc((long unsigned int)(*p.w_layer.l_width + 1), 1)’
screen-4.9.1-build/screen-4.9.1/ansi.c:2390:50: note: in expansion of macro ‘w_width’
screen-4.9.1-build/screen-4.9.1/ansi.c:2411:51: note: in expansion of macro ‘w_width’
screen-4.9.1-build/screen-4.9.1/ansi.c:2421:51: note: in expansion of macro ‘w_width’
# 2419|     if (mc->color && ml->color == null)
# 2420|       {
# 2421|->       if ((ml->color = (unsigned char *)calloc(p->w_width + 1, 1)) == 0)
# 2422|   	{
# 2423|   	  ml->color = null;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def5]
screen-4.9.1-build/screen-4.9.1/ansi.c:2431:10: warning[-Wanalyzer-malloc-leak]: leak of ‘calloc((long unsigned int)(*p.w_layer.l_width + 1), 1)’
screen-4.9.1-build/screen-4.9.1/ansi.c:2390:50: note: in expansion of macro ‘w_width’
screen-4.9.1-build/screen-4.9.1/ansi.c:2411:51: note: in expansion of macro ‘w_width’
screen-4.9.1-build/screen-4.9.1/ansi.c:2431:52: note: in expansion of macro ‘w_width’
# 2429|     if (mc->colorx && ml->colorx == null)
# 2430|       {
# 2431|->       if ((ml->colorx = (unsigned char *)calloc(p->w_width + 1, 1)) == 0)
# 2432|   	{
# 2433|   	  ml->colorx = null;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def6]
screen-4.9.1-build/screen-4.9.1/attacher.c: scope_hint: In function ‘PAM_conv’
screen-4.9.1-build/screen-4.9.1/attacher.c:860:11: warning[-Wanalyzer-malloc-leak]: leak of ‘<unknown>’
#  858|   	default:
#  859|   	  /* unknown or PAM_ERROR_MSG */
#  860|-> 	  free(reply);
#  861|   	  return PAM_CONV_ERR;
#  862|   	}

Error: GCC_ANALYZER_WARNING (CWE-476): [#def7]
screen-4.9.1-build/screen-4.9.1/canvas.c:336:22: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘p’
#  334|   		  break;
#  335|   	      ASSERT(p);
#  336|-> 	      *pp = p->w_next;
#  337|   	      p->w_next = windows;
#  338|   	      windows = p;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def8]
screen-4.9.1-build/screen-4.9.1/canvas.c:885:35: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘calloc(1, 312)’
#  883|   	{
#  884|   	  cvt->c_slperp = (struct canvas *)calloc(1, sizeof(struct canvas));
#  885|-> 	  cvt->c_slperp->c_slback = cvt;
#  886|   	  CanvasInitBlank(cvt->c_slperp);
#  887|   	  DupLayoutCv(cvf->c_slperp, cvt->c_slperp, save);

Error: GCC_ANALYZER_WARNING (CWE-476): [#def9]
screen-4.9.1-build/screen-4.9.1/canvas.c:892:35: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘calloc(1, 312)’
#  890|   	{
#  891|   	  cvt->c_slnext = (struct canvas *)calloc(1, sizeof(struct canvas));
#  892|-> 	  cvt->c_slnext->c_slprev = cvt;
#  893|   	  cvt->c_slnext->c_slback = cvt->c_slback;
#  894|   	  CanvasInitBlank(cvt->c_slnext);

Error: COMPILER_WARNING (CWE-697): [#def10]
screen-4.9.1-build/screen-4.9.1/display.c: scope_hint: In function ‘SetRendition’
screen-4.9.1-build/screen-4.9.1/display.c:1876:13: warning[-Waddress]: the comparison will always evaluate as ‘true’ for the address of ‘attr2color’ will never be NULL
# 1876 |         if (attr2color[i] && (mc->attr & (1 << i)) != 0)
#      |             ^~~~~~~~~~
screen-4.9.1-build/screen-4.9.1/display.c:120:6: note: ‘attr2color’ declared here
#  120 | int  attr2color[8][4];
#      |      ^~~~~~~~~~
# 1874|         mmc = *mc;
# 1875|         for (i = 0; i < 8; i++)
# 1876|-> 	if (attr2color[i] && (mc->attr & (1 << i)) != 0)
# 1877|   	  {
# 1878|   	    if (mc->color == 0 && attr2color[i][3])

Error: COMPILER_WARNING (CWE-252): [#def11]
screen-4.9.1-build/screen-4.9.1/display.c:4044:7: warning[-Wunused-result]: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’
# 4044 |       dup(0);
#      |       ^~~~~~
# 4042|         if (open(m, O_RDWR))
# 4043|   	Panic(errno, "Cannot open %s", m);
# 4044|->       dup(0);
# 4045|         dup(0);
# 4046|         close(D_blankerev.fd);

Error: COMPILER_WARNING (CWE-252): [#def12]
screen-4.9.1-build/screen-4.9.1/display.c:4045:7: warning[-Wunused-result]: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’
# 4045 |       dup(0);
#      |       ^~~~~~
# 4043|   	Panic(errno, "Cannot open %s", m);
# 4044|         dup(0);
# 4045|->       dup(0);
# 4046|         close(D_blankerev.fd);
# 4047|         if (slave != -1)

Error: GCC_ANALYZER_WARNING (CWE-457): [#def13]
screen-4.9.1-build/screen-4.9.1/fileio.c: scope_hint: In function ‘CatExtra’
screen-4.9.1-build/screen-4.9.1/fileio.c:77:17: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘cp’
screen-4.9.1-build/screen-4.9.1/screen.h:150: included_from: Included from here.
screen-4.9.1-build/screen-4.9.1/fileio.c:39: included_from: Included from here.
screen-4.9.1-build/screen-4.9.1/display.h:212:25: note: in expansion of macro ‘DISPLAY’
screen-4.9.1-build/screen-4.9.1/fileio.c:169:34: note: in expansion of macro ‘D_termname’
#   75|   		if ((cp = realloc(str2, (unsigned)len1 + len2 + add_colon + 1)) == NULL)
#   76|   			Panic(0, "%s", strnomem);
#   77|-> 		bcopy(cp, cp + len1 + add_colon, len2 + 1);
#   78|   	} else {
#   79|   		if ((cp = malloc((unsigned)len1 + add_colon + 1)) == NULL)

Error: COMPILER_WARNING (CWE-252): [#def14]
screen-4.9.1-build/screen-4.9.1/fileio.c: scope_hint: In function ‘WriteFile’
screen-4.9.1-build/screen-4.9.1/fileio.c:431:49: warning[-Wunused-result]: ignoring return value of ‘ftruncate’ declared with attribute ‘warn_unused_result’
#  431 |                                                 ftruncate(fd, 0);
#      |                                                 ^~~~~~~~~~~~~~~~
#  429|   				if ((fd = open(fn, O_WRONLY, 0666)) >= 0) {
#  430|   					if (fstat(fd, &stb2) == 0 && stb.st_dev == stb2.st_dev && stb.st_ino == stb2.st_ino)
#  431|-> 						ftruncate(fd, 0);
#  432|   					else {
#  433|   						close(fd);

Error: COMPILER_WARNING (CWE-252): [#def15]
screen-4.9.1-build/screen-4.9.1/fileio.c: scope_hint: In function ‘printpipe’
screen-4.9.1-build/screen-4.9.1/fileio.c:724:17: warning[-Wunused-result]: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’
#  724 |                 dup(pi[0]);
#      |                 ^~~~~~~~~~
#  722|   #endif
#  723|   		close(0);
#  724|-> 		dup(pi[0]);
#  725|   		closeallfiles(0);
#  726|   		if (setgid(real_gid) || setuid(real_uid))

Error: GCC_ANALYZER_WARNING (CWE-688): [#def16]
screen-4.9.1-build/screen-4.9.1/input.c: scope_hint: In function ‘InpProcess’
screen-4.9.1-build/screen-4.9.1/input.c:433:19: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘store’ where non-null expected
<built-in>: note: argument 1 of ‘__builtin_memcpy’ must be non-null
#  431|   		{
#  432|   		  store = malloc(sizeof(struct inpline));
#  433|-> 		  memcpy(store, &inpdata->inp, sizeof(struct inpline));
#  434|   		}
#  435|   	      store->next = &inphist;

Error: COMPILER_WARNING (CWE-252): [#def17]
screen-4.9.1-build/screen-4.9.1/loadav.c: scope_hint: In function ‘GetLoadav’
screen-4.9.1-build/screen-4.9.1/loadav.c:89:3: warning[-Wunused-result]: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’
#   89 |   fgets(buf, sizeof(buf), fp);
#      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
#   87|       return 0;
#   88|     *buf = 0;
#   89|->   fgets(buf, sizeof(buf), fp);
#   90|     fclose(fp);
#   91|     /* can't use fscanf because the decimal point symbol depends on

Error: GCC_ANALYZER_WARNING (CWE-126): [#def18]
screen-4.9.1-build/screen-4.9.1/loadav.c: scope_hint: In function ‘AddLoadav’
screen-4.9.1-build/screen-4.9.1/loadav.c:391:7: warning[-Wanalyzer-out-of-bounds]: buffer over-read
screen-4.9.1-build/screen-4.9.1/loadav.c:391:7: note: read of 1 byte from after the end of ‘" %2.2f"’
screen-4.9.1-build/screen-4.9.1/loadav.c:391:7: note: valid subscripts for ‘" %2.2f"’ are ‘[0]’ to ‘[6]’
screen-4.9.1-build/screen-4.9.1/os.h:30: included_from: Included from here.
screen-4.9.1-build/screen-4.9.1/screen.h:30: included_from: Included from here.
screen-4.9.1-build/screen-4.9.1/loadav.c:51: included_from: Included from here.
/usr/include/stdio.h:365:12: note: parameter 2 of ‘sprintf’ marked as a format string via ‘format’ attribute
/usr/include/stdio.h:365:12: note: argument 2 of ‘sprintf’ must be a pointer to a null-terminated string
#  389|     for (i = 0; i < j; i++)
#  390|       {
#  391|->       sprintf(p, " %2.2f" + !i, FIX_TO_DBL(loadav[i]));
#  392|         p += strlen(p);
#  393|       }

Error: GCC_ANALYZER_WARNING (CWE-457): [#def19]
screen-4.9.1-build/screen-4.9.1/logfile.c: scope_hint: In function ‘changed_logfile’
screen-4.9.1-build/screen-4.9.1/logfile.c:49:20: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘*s.st_size’
#   47|     if (fstat(fileno(l->fp), &o) < 0)  /* get trouble later */
#   48|       return;
#   49|->   if (o.st_size > s->st_size) {      /* aha, appended text */
#   50|       s->st_size = o.st_size;          /* this should have changed */
#   51|       s->st_mtime = o.st_mtime;        /* only size and mtime */

Error: CPPCHECK_WARNING (CWE-401): [#def20]
screen-4.9.1-build/screen-4.9.1/process.c:4215: error[memleakOnRealloc]: Common realloc mistake: 'wtab' nulled but not freed upon failure
# 4213|   	  if (!windows)
# 4214|               {
# 4215|-> 	      wtab = realloc(wtab, n * sizeof(struct win *));
# 4216|                 bzero(wtab, n * sizeof(struct win *));
# 4217|               }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def21]
screen-4.9.1-build/screen-4.9.1/process.c: scope_hint: In function ‘KillWindow’
screen-4.9.1-build/screen-4.9.1/process.c:5432:10: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘p’
screen-4.9.1-build/screen-4.9.1/screen.h:150: included_from: Included from here.
screen-4.9.1-build/screen-4.9.1/process.c:52: included_from: Included from here.
screen-4.9.1-build/screen-4.9.1/display.h:276:25: note: in expansion of macro ‘DISPLAY’
screen-4.9.1-build/screen-4.9.1/process.c:776:34: note: in expansion of macro ‘D_seql’
# 5430|         break;
# 5431|     ASSERT(p);
# 5432|->   *pp = p->w_next;
# 5433|     wi->w_inlen = 0;
# 5434|     wtab[wi->w_number] = 0;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def22]
screen-4.9.1-build/screen-4.9.1/resize.c: scope_hint: In function ‘AllocMline’
screen-4.9.1-build/screen-4.9.1/resize.c:454:13: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘ml’
screen-4.9.1-build/screen-4.9.1/resize.c: scope_hint: In function ‘AllocMline’
screen-4.9.1-build/screen-4.9.1/resize.c:718:20: note: in expansion of macro ‘w_width’
screen-4.9.1-build/screen-4.9.1/resize.c:752:10: note: in expansion of macro ‘w_width’
#  452|   int w;
#  453|   {
#  454|->   ml->image = malloc(w);
#  455|     ml->attr  = null;
#  456|   #ifdef FONT

Error: GCC_ANALYZER_WARNING (CWE-476): [#def23]
screen-4.9.1-build/screen-4.9.1/resize.c:837:18: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘mlt’
screen-4.9.1-build/screen-4.9.1/resize.c: scope_hint: In function ‘ChangeWindowSize’
screen-4.9.1-build/screen-4.9.1/resize.c:718:20: note: in expansion of macro ‘w_width’
screen-4.9.1-build/screen-4.9.1/resize.c:752:10: note: in expansion of macro ‘w_width’
screen-4.9.1-build/screen-4.9.1/resize.c:801:14: note: in expansion of macro ‘w_width’
screen-4.9.1-build/screen-4.9.1/resize.c:817:20: note: in expansion of macro ‘w_y’
#  835|   	{
#  836|   	  lx = lt > lf ? lf : lt;
#  837|-> 	  if (mlt->image == 0)
#  838|   	    {
#  839|   	      if (AllocMline(mlt, wi + 1))

Error: GCC_ANALYZER_WARNING (CWE-476): [#def24]
screen-4.9.1-build/screen-4.9.1/sched.c:74:16: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘timeoutev’
screen-4.9.1-build/screen-4.9.1/sched.c: scope_hint: In function ‘sched’
/usr/include/sys/select.h:30: included_from: Included from here.
/usr/include/sys/types.h:179: included_from: Included from here.
screen-4.9.1-build/screen-4.9.1/sched.c:29: included_from: Included from here.
#   72|   	struct event *evp, **evpp;
#   73|   	debug3("Deq event fd %d type %d queued %d\n", ev -> fd, ev -> type, ev -> queued);
#   74|-> 	if (!ev->queued)
#   75|   		return;
#   76|   	evpp = &evs;

Error: COMPILER_WARNING (CWE-252): [#def25]
screen-4.9.1-build/screen-4.9.1/screen.c:987:5: warning[-Wunused-result]: ignoring return value of ‘setgid’ declared with attribute ‘warn_unused_result’
#  987 |     setgid(real_gid); \
#      |     ^~~~~~~~~~~~~~~~
screen-4.9.1-build/screen-4.9.1/screen.c:1184:5: note: in expansion of macro ‘SET_GUID’
# 1184 |     SET_GUID();
#      |     ^~~~~~~~
#  985|   #define SET_GUID() do \
#  986|     { \
#  987|->     setgid(real_gid); \
#  988|       setuid(real_uid); \
#  989|       eff_uid = real_uid; \

Error: COMPILER_WARNING (CWE-252): [#def26]
screen-4.9.1-build/screen-4.9.1/screen.c:988:5: warning[-Wunused-result]: ignoring return value of ‘setuid’ declared with attribute ‘warn_unused_result’
#  988 |     setuid(real_uid); \
#      |     ^~~~~~~~~~~~~~~~
screen-4.9.1-build/screen-4.9.1/screen.c:1184:5: note: in expansion of macro ‘SET_GUID’
# 1184 |     SET_GUID();
#      |     ^~~~~~~~
#  986|     { \
#  987|       setgid(real_gid); \
#  988|->     setuid(real_uid); \
#  989|       eff_uid = real_uid; \
#  990|       eff_gid = real_gid; \

Error: COMPILER_WARNING (CWE-252): [#def27]
screen-4.9.1-build/screen-4.9.1/screen.c: scope_hint: In function ‘main’
screen-4.9.1-build/screen-4.9.1/screen.c:1124:16: warning[-Wunused-result]: ignoring return value of ‘chown’ declared with attribute ‘warn_unused_result’
# 1124 |         (void) chown(SockPath, real_uid, real_gid);
#      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1122|           if (mkdir(SockPath, 0700) == -1 && errno != EEXIST)
# 1123|             Panic(errno, "Cannot make directory '%s'", SockPath);
# 1124|->         (void) chown(SockPath, real_uid, real_gid);
# 1125|         }
# 1126|       }

Error: COMPILER_WARNING (CWE-252): [#def28]
screen-4.9.1-build/screen-4.9.1/screen.c:1326:3: warning[-Wunused-result]: ignoring return value of ‘freopen’ declared with attribute ‘warn_unused_result’
# 1326 |   freopen("/dev/null", "r", stdin);
#      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1324|     else
# 1325|       n = -1;
# 1326|->   freopen("/dev/null", "r", stdin);
# 1327|     freopen("/dev/null", "w", stdout);
# 1328|   

Error: COMPILER_WARNING (CWE-252): [#def29]
screen-4.9.1-build/screen-4.9.1/screen.c:1327:3: warning[-Wunused-result]: ignoring return value of ‘freopen’ declared with attribute ‘warn_unused_result’
# 1327 |   freopen("/dev/null", "w", stdout);
#      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1325|       n = -1;
# 1326|     freopen("/dev/null", "r", stdin);
# 1327|->   freopen("/dev/null", "w", stdout);
# 1328|   
# 1329|   #ifdef DEBUG

Error: COMPILER_WARNING (CWE-252): [#def30]
screen-4.9.1-build/screen-4.9.1/screen.c:1332:3: warning[-Wunused-result]: ignoring return value of ‘freopen’ declared with attribute ‘warn_unused_result’
# 1332 |   freopen("/dev/null", "w", stderr);
#      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1330|     if (dfp != stderr)
# 1331|   #endif
# 1332|->   freopen("/dev/null", "w", stderr);
# 1333|     debug("-- screen.back debug started\n");
# 1334|   

Error: COMPILER_WARNING (CWE-252): [#def31]
screen-4.9.1-build/screen-4.9.1/screen.c: scope_hint: In function ‘CoreDump’
screen-4.9.1-build/screen-4.9.1/screen.c:1670:3: warning[-Wunused-result]: ignoring return value of ‘setgid’ declared with attribute ‘warn_unused_result’
# 1670 |   setgid(getgid());
#      |   ^~~~~~~~~~~~~~~~
# 1668|     signal(sigsig, SIG_IGN);
# 1669|   #endif
# 1670|->   setgid(getgid());
# 1671|     setuid(getuid());
# 1672|     unlink("core");

Error: COMPILER_WARNING (CWE-252): [#def32]
screen-4.9.1-build/screen-4.9.1/screen.c:1671:3: warning[-Wunused-result]: ignoring return value of ‘setuid’ declared with attribute ‘warn_unused_result’
# 1671 |   setuid(getuid());
#      |   ^~~~~~~~~~~~~~~~
# 1669|   #endif
# 1670|     setgid(getgid());
# 1671|->   setuid(getuid());
# 1672|     unlink("core");
# 1673|   

Error: COMPILER_WARNING (CWE-252): [#def33]
screen-4.9.1-build/screen-4.9.1/screen.c: scope_hint: In function ‘eexit’
screen-4.9.1-build/screen-4.9.1/screen.c:1863:5: warning[-Wunused-result]: ignoring return value of ‘setgid’ declared with attribute ‘warn_unused_result’
# 1863 |     setgid(real_gid);
#      |     ^~~~~~~~~~~~~~~~
# 1861|     if (ServerSocket != -1) {
# 1862|       debug1("we unlink(%s)\n", SockPath);
# 1863|->     setgid(real_gid);
# 1864|       setuid(real_uid);
# 1865|       (void) unlink(SockPath);

Error: COMPILER_WARNING (CWE-252): [#def34]
screen-4.9.1-build/screen-4.9.1/screen.c:1864:5: warning[-Wunused-result]: ignoring return value of ‘setuid’ declared with attribute ‘warn_unused_result’
# 1864 |     setuid(real_uid);
#      |     ^~~~~~~~~~~~~~~~
# 1862|       debug1("we unlink(%s)\n", SockPath);
# 1863|       setgid(real_gid);
# 1864|->     setuid(real_uid);
# 1865|       (void) unlink(SockPath);
# 1866|     }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def35]
screen-4.9.1-build/screen-4.9.1/screen.c: scope_hint: In function ‘runbacktick’
screen-4.9.1-build/screen-4.9.1/screen.c:2411:9: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘bt’
screen-4.9.1-build/screen-4.9.1/screen.c: scope_hint: In function ‘runbacktick’
# 2409|   
# 2410|     debug1("runbacktick called for backtick #%d\n", bt->num);
# 2411|->   if (bt->tick && (!*tickp || bt->tick < *tickp))
# 2412|       *tickp = bt->tick;
# 2413|     if ((bt->lifespan == 0 && bt->tick == 0) || now < bt->bestbefore) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def36]
screen-4.9.1-build/screen-4.9.1/socket.c: scope_hint: In function ‘MakeServerFifo’
screen-4.9.1-build/screen-4.9.1/socket.c:438:6: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&SockPath, 2049)’
#  436|   #endif
#  437|     s = open(SockPath, O_WRONLY | O_NONBLOCK);
#  438|->   if (s >= 0)
#  439|       {
#  440|         debug("huii, my fifo already exists??\n");

Error: COMPILER_WARNING (CWE-252): [#def37]
screen-4.9.1-build/screen-4.9.1/socket.c: scope_hint: In function ‘SendErrorMsg’
screen-4.9.1-build/screen-4.9.1/socket.c:757:10: warning[-Wunused-result]: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’
#  757 |   (void) write(s, (char *) &m, sizeof m);
#      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  755|     m.protocol_revision = MSG_REVISION;
#  756|     debug1("SendErrorMsg(): writing to '%s'\n", SockPath);
#  757|->   (void) write(s, (char *) &m, sizeof m);
#  758|     close(s);
#  759|     return 0;

Error: COMPILER_WARNING (CWE-252): [#def38]
screen-4.9.1-build/screen-4.9.1/socket.c: scope_hint: In function ‘CreateTempDisplay’
screen-4.9.1-build/screen-4.9.1/socket.c:961:11: warning[-Wunused-result]: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’
#  961 |           write(i, "Attaching from inside of screen?\n", 33);
#      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  959|         if (display || wi)
#  960|   	{
#  961|-> 	  write(i, "Attaching from inside of screen?\n", 33);
#  962|   	  close(i);
#  963|   	  Kill(pid, SIG_BYE);

Error: COMPILER_WARNING (CWE-252): [#def39]
screen-4.9.1-build/screen-4.9.1/socket.c:972:15: warning[-Wunused-result]: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’
#  972 |               write(i, "Access to session denied.\n", 26);
#      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  970|   	if (*FindUserPtr(user) == 0)
#  971|   	  {
#  972|-> 	      write(i, "Access to session denied.\n", 26);
#  973|   	      close(i);
#  974|   	      Kill(pid, SIG_BYE);

Error: COMPILER_WARNING (CWE-252): [#def40]
screen-4.9.1-build/screen-4.9.1/socket.c:996:7: warning[-Wunused-result]: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’
#  996 |       write(i, "Could not make display.\n", 24);
#      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  994|     if (MakeDisplay(user, m->m_tty, attach ? m->m.attach.envterm : "", i, pid, &Mode) == 0)
#  995|       {
#  996|->       write(i, "Could not make display.\n", 24);
#  997|         close(i);
#  998|         Msg(0, "Attach: could not make display for user %s", user);

Error: COMPILER_WARNING (CWE-477): [#def41]
screen-4.9.1-build/screen-4.9.1/utmp.c: scope_hint: In function ‘pututslot’
screen-4.9.1-build/screen-4.9.1/utmp.c:582:9: warning[-Wdeprecated-declarations]: ‘addToUtmp’ is deprecated: better use utempter_add_record instead
#  582 |         addToUtmp(wi->w_tty, host, wi->w_ptyfd);
#      |         ^~~~~~~~~
screen-4.9.1-build/screen-4.9.1/utmp.c:38: included_from: Included from here.
/usr/include/utempter.h:44:13: note: declared here
#   44 | extern void addToUtmp(const char *pty, const char *hostname, int master_fd)
#      |             ^~~~~~~~~
#  580|         /* sigh, linux hackers made the helper functions void */
#  581|         if (SLOT_USED(u))
#  582|-> 	addToUtmp(wi->w_tty, host, wi->w_ptyfd);
#  583|         else
#  584|   	removeLineFromUtmp(wi->w_tty, wi->w_ptyfd);

Error: COMPILER_WARNING (CWE-477): [#def42]
screen-4.9.1-build/screen-4.9.1/utmp.c:584:9: warning[-Wdeprecated-declarations]: ‘removeLineFromUtmp’ is deprecated: better use utempter_remove_record instead
#  584 |         removeLineFromUtmp(wi->w_tty, wi->w_ptyfd);
#      |         ^~~~~~~~~~~~~~~~~~
/usr/include/utempter.h:48:13: note: declared here
#   48 | extern void removeLineFromUtmp(const char *pty, int master_fd)
#      |             ^~~~~~~~~~~~~~~~~~
#  582|   	addToUtmp(wi->w_tty, host, wi->w_ptyfd);
#  583|         else
#  584|-> 	removeLineFromUtmp(wi->w_tty, wi->w_ptyfd);
#  585|         /*
#  586|          * As documented in libutempter: "During execution of the privileged

Error: GCC_ANALYZER_WARNING (CWE-476): [#def43]
screen-4.9.1-build/screen-4.9.1/window.c: scope_hint: In function ‘MakeWindow’
screen-4.9.1-build/screen-4.9.1/window.c:596:11: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘pp’
#  594|     do
#  595|       {
#  596|->       if (*pp == 0)
#  597|   	break;
#  598|         if (++pp == wtab + maxwin)

Error: GCC_ANALYZER_WARNING (CWE-476): [#def44]
screen-4.9.1-build/screen-4.9.1/window.c:602:7: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘pp’
#  600|       }
#  601|     while (pp != wtab + startat);
#  602|->   if (*pp)
#  603|       {
#  604|         Msg(0, "No more windows.");

Error: CPPCHECK_WARNING (CWE-457): [#def45]
screen-4.9.1-build/screen-4.9.1/window.c:923: warning[uninitvar]: Uninitialized variable: f
#  921|   
#  922|     strncpy(p->w_tty, *TtyName ? TtyName : p->w_title, MAXSTR - 1);
#  923|->   p->w_ptyfd = f;
#  924|     p->w_readev.fd = f;
#  925|     p->w_writeev.fd = f;

Error: GCC_ANALYZER_WARNING (CWE-457): [#def46]
screen-4.9.1-build/screen-4.9.1/window.c: scope_hint: In function ‘RemakeWindow’
screen-4.9.1-build/screen-4.9.1/window.c:923:14: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘f’
#  921|   
#  922|     strncpy(p->w_tty, *TtyName ? TtyName : p->w_title, MAXSTR - 1);
#  923|->   p->w_ptyfd = f;
#  924|     p->w_readev.fd = f;
#  925|     p->w_writeev.fd = f;

Error: COMPILER_WARNING (CWE-457): [#def47]
screen-4.9.1-build/screen-4.9.1/window.c: scope_hint: In function ‘RemakeWindow’
screen-4.9.1-build/screen-4.9.1/window.c:925:19: warning[-Wmaybe-uninitialized]: ‘f’ may be used uninitialized
#  925 |   p->w_writeev.fd = f;
#      |   ~~~~~~~~~~~~~~~~^~~
screen-4.9.1-build/screen-4.9.1/window.c:907:14: note: ‘f’ was declared here
#  907 |   int lflag, f;
#      |              ^
#  923|     p->w_ptyfd = f;
#  924|     p->w_readev.fd = f;
#  925|->   p->w_writeev.fd = f;
#  926|     evenq(&p->w_readev);
#  927|     evenq(&p->w_writeev);

Error: COMPILER_WARNING (CWE-252): [#def48]
screen-4.9.1-build/screen-4.9.1/window.c: scope_hint: In function ‘CloseDevice’
screen-4.9.1-build/screen-4.9.1/window.c:983:13: warning[-Wunused-result]: ignoring return value of ‘chown’ declared with attribute ‘warn_unused_result’
#  983 |       (void)chown(wp->w_tty, 0, 0);
#      |             ^~~~~~~~~~~~~~~~~~~~~~
#  981|         /* pty 4 SALE */
#  982|         (void)chmod(wp->w_tty, 0666);
#  983|->       (void)chown(wp->w_tty, 0, 0);
#  984|       }
#  985|     close(wp->w_ptyfd);

Error: COMPILER_WARNING (CWE-252): [#def49]
screen-4.9.1-build/screen-4.9.1/window.c: scope_hint: In function ‘ForkWindow’
screen-4.9.1-build/screen-4.9.1/window.c:1297:11: warning[-Wunused-result]: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’
# 1297 |           dup(slave);
#      |           ^~~~~~~~~~
# 1295|   	{
# 1296|   	  close(0);
# 1297|-> 	  dup(slave);
# 1298|   	  close(slave);
# 1299|   	  closeallfiles(win->w_ptyfd);

Error: COMPILER_WARNING (CWE-252): [#def50]
screen-4.9.1-build/screen-4.9.1/window.c:1348:17: warning[-Wunused-result]: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’
# 1348 |                 dup(newfd);
#      |                 ^~~~~~~~~~
# 1346|   		}
# 1347|   	      else
# 1348|-> 		dup(newfd);
# 1349|   	    }
# 1350|   	  else

Error: COMPILER_WARNING (CWE-252): [#def51]
screen-4.9.1-build/screen-4.9.1/window.c:1352:15: warning[-Wunused-result]: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’
# 1352 |               dup(win->w_ptyfd);
#      |               ^~~~~~~~~~~~~~~~~
# 1350|   	  else
# 1351|   	    {
# 1352|-> 	      dup(win->w_ptyfd);
# 1353|   	      wfdused = 1;
# 1354|   	    }

Scan Properties

analyzer-version-clippy1.82.0
analyzer-version-cppcheck2.16.0
analyzer-version-gcc14.2.1
analyzer-version-gcc-analyzer15.0.0
analyzer-version-shellcheck0.10.0
analyzer-version-unicontrol0.0.2
diffbase-analyzer-version-clippy1.82.0
diffbase-analyzer-version-cppcheck2.16.0
diffbase-analyzer-version-gcc14.2.1
diffbase-analyzer-version-gcc-analyzer15.0.0
diffbase-analyzer-version-shellcheck0.10.0
diffbase-analyzer-version-unicontrol0.0.2
diffbase-enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
diffbase-exit-code0
diffbase-hostip-172-16-1-190.us-west-2.compute.internal
diffbase-mock-configfedora-rawhide-gcc-latest-x86_64
diffbase-project-namescreen-5.0.0-1.fc42
diffbase-store-results-to/tmp/tmpjm8p_uwq/screen-5.0.0-1.fc42.tar.xz
diffbase-time-created2024-11-13 03:25:49
diffbase-time-finished2024-11-13 03:28:25
diffbase-toolcsmock
diffbase-tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-gcc-latest-x86_64' '-t' 'clippy,cppcheck,gcc,unicontrol,shellcheck' '-o' '/tmp/tmpjm8p_uwq/screen-5.0.0-1.fc42.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install=gcc-latest' '--gcc-analyzer-bin=/opt/gcc-latest/bin/gcc' '/tmp/tmpjm8p_uwq/screen-5.0.0-1.fc42.src.rpm'
diffbase-tool-versioncsmock-3.7.1.20241107.094801.gb3f0f26.pr_192-1.el9
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-190.us-west-2.compute.internal
mock-configfedora-rawhide-gcc-latest-x86_64
project-namescreen-4.9.1-2.fc41
store-results-to/tmp/tmps0lvoqjq/screen-4.9.1-2.fc41.tar.xz
time-created2024-11-13 03:22:03
time-finished2024-11-13 03:25:22
titleFixed findings
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-gcc-latest-x86_64' '-t' 'clippy,cppcheck,gcc,unicontrol,shellcheck' '-o' '/tmp/tmps0lvoqjq/screen-4.9.1-2.fc41.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install=gcc-latest' '--gcc-analyzer-bin=/opt/gcc-latest/bin/gcc' '/tmp/tmps0lvoqjq/screen-4.9.1-2.fc41.src.rpm'
tool-versioncsmock-3.7.1.20241107.094801.gb3f0f26.pr_192-1.el9