QuickFIX/J

Badly behaved counterparty sending FIX.5.0 as begin string causes exceptions

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Default Default
  • Resolution: Fixed
  • Affects Version/s: 1.3.3
  • Fix Version/s: 1.5.1
  • Component/s: Engine
  • Labels:
    None

Description

The following context diff shows a patch which cleans up the issue by reducing the possibility of a null pointer.

*** quickfixj/core/src/main/java/quickfix/MessageUtils.java Thu Jan 15 11:47:03 2009
--- quickfixj-svn/core/src/main/java/quickfix/MessageUtils.java Tue Jan 20 15:49:54 2009
***************
*** 104,107 ****
--- 104,116 ----
          String customApplVerID = null;
  
+ MessageFactory messageFactory = session.getMessageFactory();
+ DataDictionaryProvider ddProvider = session.getDataDictionaryProvider();
+ DataDictionary sessionDataDictionary = ddProvider.getSessionDataDictionary(beginString);
+ DataDictionary payloadDataDictionary = null;
+
+ // We check and if it's a Admin message we don't need anything more
+ if (MessageUtils.isAdminMessage(msgType)) {
+ payloadDataDictionary = sessionDataDictionary;
+ } else {
              if (FixVersions.BEGINSTRING_FIXT11.equals(beginString)) {
                  applVerID = getApplVerID(session, messageString);

***************
*** 111,128 ****
          }
          
! MessageFactory messageFactory = session.getMessageFactory();
!
! DataDictionaryProvider ddProvider = session.getDataDictionaryProvider();
! DataDictionary sessionDataDictionary = ddProvider.getSessionDataDictionary(beginString);
! DataDictionary applicationDataDictionary = ddProvider.getApplicationDataDictionary(
! applVerID, customApplVerID);
  
          quickfix.Message message = messageFactory.create(beginString, msgType);
! DataDictionary payloadDictionary = MessageUtils.isAdminMessage(msgType)
! ? sessionDataDictionary
! : applicationDataDictionary;
!
! message.parse(messageString, sessionDataDictionary, payloadDictionary,
! payloadDictionary != null);
          
          return message;

--- 120,130 ----
              }
  
! payloadDataDictionary = ddProvider.getApplicationDataDictionary(applVerID,
! customApplVerID);
! }
  
          quickfix.Message message = messageFactory.create(beginString, msgType);
! message.parse(messageString, sessionDataDictionary, payloadDataDictionary,
! payloadDataDictionary != null);
  
          return message;

Activity

Hide
Jay Walters added a comment - 03/Feb/09 10:30 PM

A little bit more in a separate file to help with the same issue.

      • quickfixj/core/src/main/java/quickfix/DataDictionary.java Thu Jan 15 11:47:03 2009
      • quickfixj-svn/core/src/main/java/quickfix/DataDictionary.java Thu Jan 15 10:33:19 2009
        ***************
      • 256,260 ****
        */
        public boolean isHeaderField(int field) { ! return messageFields.get(HEADER_ID).contains(field); }

— 256,261 ----
*/
public boolean isHeaderField(int field) { ! Set<Integer> hdrFields = messageFields.get(HEADER_ID); ! return (hdrFields == null) ? false : hdrFields.contains(field); }

***************

      • 1092,1096 ****
        addXMLGroup(document, componentFieldNode, msgtype, dd, isRequired);
        }
        !
        if (componentFieldNode.getNodeName().equals("component")) { String required = getAttribute(componentFieldNode, "required"); --- 1093,1097 ---- addXMLGroup(document, componentFieldNode, msgtype, dd, isRequired); }
        ! // Also need to take into account nested components
        if (componentFieldNode.getNodeName().equals("component")) {
        String required = getAttribute(componentFieldNode, "required");
Show
Jay Walters added a comment - 03/Feb/09 10:30 PM A little bit more in a separate file to help with the same issue.
      • quickfixj/core/src/main/java/quickfix/DataDictionary.java Thu Jan 15 11:47:03 2009
      • quickfixj-svn/core/src/main/java/quickfix/DataDictionary.java Thu Jan 15 10:33:19 2009 ***************
      • 256,260 **** */ public boolean isHeaderField(int field) { ! return messageFields.get(HEADER_ID).contains(field); }
— 256,261 ---- */ public boolean isHeaderField(int field) { ! Set<Integer> hdrFields = messageFields.get(HEADER_ID); ! return (hdrFields == null) ? false : hdrFields.contains(field); } ***************
      • 1092,1096 **** addXMLGroup(document, componentFieldNode, msgtype, dd, isRequired); } ! if (componentFieldNode.getNodeName().equals("component")) { String required = getAttribute(componentFieldNode, "required"); --- 1093,1097 ---- addXMLGroup(document, componentFieldNode, msgtype, dd, isRequired); } ! // Also need to take into account nested components if (componentFieldNode.getNodeName().equals("component")) { String required = getAttribute(componentFieldNode, "required");
Hide
Eric Deshayes added a comment - 29/Apr/11 4:03 PM

This issue had already been fixed.
Potential null pointer prevention has been introduced in rev#926.

Show
Eric Deshayes added a comment - 29/Apr/11 4:03 PM This issue had already been fixed. Potential null pointer prevention has been introduced in rev#926.

People

Vote (0)
Watch (0)

Dates

  • Created:
    03/Feb/09 10:28 PM
    Updated:
    29/Apr/11 4:03 PM
    Resolved:
    29/Apr/11 4:03 PM