Bug 79239 - bad source code
bad source code
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: pxe (Show other bugs)
8.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Daniel Walsh
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-12-08 05:54 EST by d.binderman
Modified: 2007-04-18 12:48 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-08-01 15:49:22 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description d.binderman 2002-12-08 05:54:56 EST
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 11:47:43 EST
These look bad enough that they may cause the regular daemon crashes (bug 78155).
Comment 2 Daniel Walsh 2002-12-16 11:29:36 EST
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.