|  | 
 
  
    | RSS Feed - WebSphere MQ Support | RSS Feed - Message Broker Support |  
 
  
	|    |  |  
  
	| How to catch Null pointer invocations | « View previous topic :: View next topic » |  
  	| 
		
		
		  | Author | Message |  
		  | ktg | 
			  
				|  Posted: Wed Jul 23, 2008 10:58 pm    Post subject: How to catch Null pointer invocations |   |  |  
		  | Centurion
 
 
 Joined: 09 Jan 2006Posts: 138
 Location: India
 
 | 
			  
				| Hi All, 
 We are writing an API exit to catch all null pointer invocation by applications.
 For example, application should issue MQPUT in the following format (correct way)
 MQPUT(Hcon,                /* connection handle               */
 Hobj,                /* object handle                   */
 &md,                 /* message descriptor              */
 &pmo,                /* default options (datagram)      */
 messlen,             /* message length                  */
 buffer,              /* message buffer                  */
 &CompCode,           /* completion code                 */
 &Reason);            /* reason code                     */
 
 In case, if application passes NULL for any parameter, API exit need to log that error. For example passing pointer to message descriptor as null
 MQPUT(Hcon,                /* connection handle               */
 Hobj,                /* object handle                   */
 NULL,                 /* message descriptor              */
 &pmo,                /* default options (datagram)      */
 messlen,             /* message length                  */
 buffer,              /* message buffer                  */
 &CompCode,           /* completion code                 */
 &Reason);            /* reason code                     */
 
 How can we catch this error.
 In PutBefore entry point, there will be
 void MQENTRY PutBefore   ( PMQAXP    pEP
 , PMQAXC    pEC
 , PMQHCONN  pHconn
 , PMQHOBJ   pHobj
 , PPMQMD    ppMsgDesc
 , PPMQPMO   ppPutMsgOpts
 , PMQLONG   pBufferLength
 , PPMQVOID  ppBuffer
 , PMQLONG   pCompCode
 , PMQLONG   pReason
 )
 
 if (ppMsgDesc == NULL || *ppMsgDesc == NULL)
 is not catching the error.
 
 if (ppMsgDesc == NULL || *ppMsgDesc == NULL || **ppMsgDesc == NULL ) gives compilation error (type mismatch)
 
 What could be done?
 
 Thanks in advance.
 
 Regards,
 Kalpana
 |  |  
		  | Back to top |  |  
		  |  |  
		  | David.Partridge | 
			  
				|  Posted: Wed Jul 23, 2008 11:35 pm    Post subject: |   |  |  
		  |  Master
 
 
 Joined: 28 Jun 2001Posts: 249
 
 
 | 
			  
				| Never mind the C semantics, what are you hoping to achieve? 
 What could you do in an API exit that would "do the right thing" in all (or even a small fraction of) cases - exit code can't be prescient or read the mind of the developer to change the invocation parameters so that the exit acts as a "Do what I meant".
 
 If an application is going to crash and burn because a developer hasn't used tools such as "Lint" or even old fashioned desk checking, then it will crash and burn.   If the developer is passing null pointers to the MQI, there are probably other fundamental errors in the code as well.
 
 No amount of code in an API exit will protect them from that, and IMHO, nor should you attempt it.
 _________________
 Cheers,
 David C. Partridge
 |  |  
		  | Back to top |  |  
		  |  |  
		  | ktg | 
			  
				|  Posted: Thu Jul 24, 2008 12:59 am    Post subject: |   |  |  
		  | Centurion
 
 
 Joined: 09 Jan 2006Posts: 138
 Location: India
 
 | 
			  
				| I was wrong when I said 
   
	| Quote: |  
	| "We are writing an API exit to catch all null pointer invocation by applications" |  Actually, we have an API exit for some other purpose. It was giving wrong results in production site.
 Later it was found that, the wrong results were because of an MQPUT call with MQMD as NULL parameter. That situation was arising because of a bug in MQ. It was the report by team at production site.
 Here, in the development environment we could not simulate the same problem. But, we were asked to make the API exit defensive against NULL pointer invocations.
 Hence.........
 
 Thanks,
 Kalpana
 |  |  
		  | Back to top |  |  
		  |  |  
		  | fjb_saper | 
			  
				|  Posted: Thu Jul 24, 2008 10:39 am    Post subject: |   |  |  
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| You can't fix that. What you can fix is force production to use the right version of MQ... i.e. the one you and QA tested with and did not have the problem. 
 Enjoy
  _________________
 MQ & Broker admin
 |  |  
		  | Back to top |  |  
		  |  |  
		  |  |  |  
  
	|    |  | Page 1 of 1 |  
 
 
  
  	| 
		
		  | 
 
 | You cannot post new topics in this forum You cannot reply to topics in this forum
 You cannot edit your posts in this forum
 You cannot delete your posts in this forum
 You cannot vote in polls in this forum
 
 |  |  |  |