centos 7
obsolete weakness #295

1

Weakness Breakdown


Definition:

An obsolete weakness occurs when someone uses deprecated or obsolete functions when building a system. As a programming language evolves, some functions occasionally become obsolete.

Warning code(s):

This C routine is considered obsolete.

File Name:

gpm-1.20.7/src/prog/mouse-test.c

Context:

The highlighted line of code below is the trigger point of this particular Centos 7 obsolete weakness.

    for (nextitem=&list, cursor=mice; cursor->fun; cursor++) {
      if (cursor->absolute) continue;
      *nextitem=malloc(sizeof(struct item));
      if (!*nextitem) gpm_report(GPM_PR_OOPS,"malloc()");
      (*nextitem)->this=cursor; (*nextitem)->next=NULL;
      printf("\t%s",cursor->name);
      if (cursor->synonyms && cursor->synonyms[0])
         printf(" (%s)",cursor->synonyms);
      printf("\r\n");
      typecount++;
      nextitem=&((*nextitem)->next);
   }

/*====================================== Packet size - first step */

   printf("\r\nNow please press and release your left mouse button,\r\n"
	 "one time only\r\n\r\n");

   i=read(mousefd,buf,1);
   if (i==-1 && errno==EINVAL)
      readamount=3;
   else
      readamount=1;

   usleep(100000);

#define REMOVETYPE(cur,reason) \
   do { \
	 printf("\tRemoving type \"%s\" because of '%s'\r\n", \
		(cur)->this->name,reason); \
	 (*nextitem)=(cur)->next; \
	 free(cur); \
	 typecount--; \
       } while(0)


   for (nextitem=&list; *nextitem; /* nothing */) {
      struct item *cur=*nextitem;
    
      if (readamount!=cur->this->howmany)
         REMOVETYPE(cur,"different read() semantics");
      else
         nextitem=&(cur->next);
   }
   read(mousefd,buf,BUFLEN); /* flush */

/*====================================== Packet size - second step */

   printf("\r\nNow you will be asked to generate different kind of events,\r\n"
		 "in order to understand what protocol is your mouse speaking\r\n"); 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.