Bug 79239 - bad source code
Summary: bad source code
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: pxe
Version: 8.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Daniel Walsh
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-12-08 10:54 UTC by d.binderman
Modified: 2007-04-18 16:48 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2003-08-01 19:49:22 UTC
Embargoed:


Attachments (Terms of Use)

Description d.binderman 2002-12-08 10:54:56 UTC
Description of Problem:

Hello there,

I just tried to compile package pxe-0.1-33 from Redhat 8.0.

Here are some of the compiler messages.

discover.c:168: warning: `n' might be used uninitialized in this function
discover.c:168: warning: `n' might be used uninitialized in this function
discover.c:242: too few arguments to function `unicast_discover'
discover.c:286: too few arguments to function `multicast_discover'
discover.c:299: too few arguments to function `broadcast_discover'
discover.c:310: too few arguments to function `unicast_discover'
misc.c:5: conflicting types for `cksum'
misc.h:61: previous declaration of `cksum'
apstring.cc:437: warning: returning reference to temporary
cproxreg.cc:93: warning: `char*pImageName' might be used uninitialized in this
pxeparser.cc:91: warning: `BYTE*pucDhcpPacket' might be used uninitialized in
pxeparser.cc:391: warning: `int nCredLen' might be used uninitialized in this

It seems that Bruce's c compiler (bcc) doesn't do as much checking as
the GNU C compiler. Here is an untested patch which seems to shut up
the compiler.

*** ./nbp.linux/discover.c.old	2002-11-22 09:24:49.000000000 +0000
--- ./nbp.linux/discover.c	2002-11-22 09:26:49.000000000 +0000
***************
*** 165,171 ****
  unicast_discover(int ipcnt, t_IP *iplist, int type)
  {
  	int timeout;
! 	int n;
  	int r;
  
  	if (ipcnt == 1) {
--- 165,171 ----
  unicast_discover(int ipcnt, t_IP *iplist, int type)
  {
  	int timeout;
! 	int n = 0;
  	int r;
  
  	if (ipcnt == 1) {
***************
*** 239,245 ****
  			return -2;
  		}
  
! 		return unicast_discover(1, iplist);
  	}
  
  	discctrl = find_pxe_tag(&proxy, PXE_DISCOVERY_CONTROL, 0);
--- 239,245 ----
  			return -2;
  		}
  
! 		return unicast_discover(1, iplist, type);
  	}
  
  	discctrl = find_pxe_tag(&proxy, PXE_DISCOVERY_CONTROL, 0);
***************
*** 283,289 ****
  #if 1
  	if (discaddr) {
  		if (!discctrl || !(discctrl->flag & PXE_DISCOVERY_CONTROL_MCAST_DISABLE)) {
! 			switch (multicast_discover(discaddr->ip, ipcnt, iplist)) {
  			case 1: /* found */
  				return 1;
  
--- 283,289 ----
  #if 1
  	if (discaddr) {
  		if (!discctrl || !(discctrl->flag & PXE_DISCOVERY_CONTROL_MCAST_DISABLE)) {
! 			switch (multicast_discover(discaddr->ip, ipcnt, iplist, type)) {
  			case 1: /* found */
  				return 1;
  
***************
*** 296,302 ****
  
  #if 1
  	if (!discctrl || !(discctrl->flag & PXE_DISCOVERY_CONTROL_BCAST_DISABLE)) {
! 		switch (broadcast_discover(ipcnt, iplist)) {
  		case 1: /* found */
  			return 1;
  
--- 296,302 ----
  
  #if 1
  	if (!discctrl || !(discctrl->flag & PXE_DISCOVERY_CONTROL_BCAST_DISABLE)) {
! 		switch (broadcast_discover(ipcnt, iplist, type)) {
  		case 1: /* found */
  			return 1;
  
***************
*** 307,313 ****
  #endif
  
  	if (ipcnt && iplist)
! 		return unicast_discover(ipcnt, iplist);
  
  	return 0;
  }
--- 307,313 ----
  #endif
  
  	if (ipcnt && iplist)
! 		return unicast_discover(ipcnt, iplist, type);
  
  	return 0;
  }
*** ./nbp.linux/misc.c.old	2002-11-20 10:39:50.000000000 +0000
--- ./nbp.linux/misc.c	2002-11-20 10:39:56.000000000 +0000
***************
*** 1,7 ****
  #include "nbp.h"
  
  UINT8
! cksum(UINT8 *b, UINT16 n)
  {
  	UINT8 s = 0;
  
--- 1,7 ----
  #include "nbp.h"
  
  UINT8
! cksum(UINT8 *b, int n)
  {
  	UINT8 s = 0;
  
*** ./server/classes/apstring.cc.old	2002-11-20 11:05:16.000000000 +0000
--- ./server/classes/apstring.cc	2002-11-20 11:10:40.000000000 +0000
***************
*** 433,440 ****
  
  const apstring& myStringArray::operator [] (int k)
  {
! 	if (k >= m_capacity)
! 		return NULL;
  
  	return *m_array[k];
  }
--- 433,440 ----
  
  const apstring& myStringArray::operator [] (int k)
  {
! 	assert( k >= 0);
! 	assert( k < m_capacity);
  
  	return *m_array[k];
  }
*** ./server/classes/cproxreg.cc.old	2002-11-20 11:11:04.000000000 +0000
--- ./server/classes/cproxreg.cc	2002-11-20 11:11:31.000000000 +0000
***************
*** 90,96 ****
  	// Check to see if there are anymore files left to send.
  	int cnt=0;
  	int nStartLayer=0, nEndLayer=0;
! 	char *pImageName;
  	while(cnt < saImageFile.GetSize())
  	{
  		switch(cnt)
--- 90,96 ----
  	// Check to see if there are anymore files left to send.
  	int cnt=0;
  	int nStartLayer=0, nEndLayer=0;
! 	char *pImageName = NULL;
  	while(cnt < saImageFile.GetSize())
  	{
  		switch(cnt)
*** ./server/services/pxeparser/pxeparser.cc.old	2002-11-20 11:11:51.000000000 +0000
--- ./server/services/pxeparser/pxeparser.cc	2002-11-20 11:14:28.000000000 +0000
***************
*** 88,94 ****
  	USHORT usService = 0;
  	USHORT usLayer = 0;
  	CString strBootFile;
! 	BYTE* pucDhcpPacket;
  	BOOL bMcastDiscoveryEnabled = TRUE;
  
  	CProxyRegistry ProxyReg;
--- 88,94 ----
  	USHORT usService = 0;
  	USHORT usLayer = 0;
  	CString strBootFile;
! 	BYTE* pucDhcpPacket = NULL;
  	BOOL bMcastDiscoveryEnabled = TRUE;
  
  	CProxyRegistry ProxyReg;
***************
*** 388,394 ****
  
  		BYTE CredentialTypesList[32];
  		BOOL bCredentialTypeReqd = TRUE; 
! 		int nCredLen;
  		if (usLayer & 0x8000)
  		{
  			nCredLen = ClientPkt.Get43Option(PXE_CREDENTIAL_TYPES, CredentialTypesList, sizeof(CredentialTypesList) );
--- 388,394 ----
  
  		BYTE CredentialTypesList[32];
  		BOOL bCredentialTypeReqd = TRUE; 
! 		int nCredLen = 0;
  		if (usLayer & 0x8000)
  		{
  			nCredLen = ClientPkt.Get43Option(PXE_CREDENTIAL_TYPES, CredentialTypesList, sizeof(CredentialTypesList) );


Version-Release number of selected component (if applicable):


How Reproducible:


Steps to Reproduce:
1. 
2. 
3. 

Actual Results:


Expected Results:


Additional Information:

Comment 1 Joe Orton 2002-12-09 16:47:43 UTC
These look bad enough that they may cause the regular daemon crashes (bug 78155).

Comment 2 Daniel Walsh 2002-12-16 16:29:36 UTC
Applied your patch in pxe-0.1-34.  Thanks, Dan


Note You need to log in before you can comment on or make changes to this bug.