Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BB0B8200D2D for ; Fri, 27 Oct 2017 22:42:04 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B682F1609DD; Fri, 27 Oct 2017 20:42:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DCF4E160BF4 for ; Fri, 27 Oct 2017 22:42:03 +0200 (CEST) Received: (qmail 22385 invoked by uid 500); 27 Oct 2017 20:42:02 -0000 Mailing-List: contact dev-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list dev@qpid.apache.org Received: (qmail 22215 invoked by uid 99); 27 Oct 2017 20:42:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Oct 2017 20:42:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id E8E9CC492F for ; Fri, 27 Oct 2017 20:42:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id XWlO3qLO_kNN for ; Fri, 27 Oct 2017 20:42:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id DDDC75FB32 for ; Fri, 27 Oct 2017 20:42:00 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6128FE0D50 for ; Fri, 27 Oct 2017 20:42:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 1A160212F9 for ; Fri, 27 Oct 2017 20:42:00 +0000 (UTC) Date: Fri, 27 Oct 2017 20:42:00 +0000 (UTC) From: "Nathan Campbell (JIRA)" To: dev@qpid.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (PROTON-1661) Incomplete name comparision in transport.c pn_find_link() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 27 Oct 2017 20:42:04 -0000 [ https://issues.apache.org/jira/browse/PROTON-1661?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Nathan Campbell updated PROTON-1661: ------------------------------------ Description: Tested in both proton-c version 0.11.1 and 0.17.0 with qpid broker 1.36.0 Problem: Function "pn_find_link()" incorrectly returns a link when argument "name" matches first N characters of existing link. i.e.: 1) QPID client creates receiver with address "amq.topic/fooBar": Broker will call function pn_find_link( ssn, name = "fooBar", true) which returns NULL as expected. Link is initialized and receiver works as expected. 2) Some time later the same QPID client creates second receiver with address "amq.topic/foo": Broker will call function pn_find_link( ssn, name="foo", true) which incorrectly returns pointer to existing link. Expected behavior is to return NULL so that link will (later) be initialized. This is because if() starting on line 1268 of proton-c/src/core/transport.c only uses strncmp(). eg: "strncmp( "foo", "fooBar", 3) == 0" That if() also needs to check +sizes of the names+ and only do "strncmp()" if: "(name.size == strlen(pn_string_get(link->name)))" Symptoms: Qpid client blocks indefinitely on second ConnectionContext::createReceiver() waiting for link to be established. Broker never does PN_LINK_INIT because it incorrectly believes link already exists, client is hung waiting for message back from broker. was: Tested in both proton-c version 0.11.1 and 0.17.0 with qpid broker 1.36.0 Problem: Function "pn_find_link()" incorrectly returns a link when argument "name" matches first N characters of existing link. i.e.: 1) QPID client creates receiver with address "amq.topic/fooBar": Broker will call function pn_find_link( ssn, name = "fooBar", true) which returns NULL as expected. Link is initialized and receiver works as expected. 2) Some time later QPID client creates second receiver with address "amq.topic/foo": Broker will call function pn_find_link( ssn, name="foo", true) which incorrectly returns pointer to existing link. Expected behavior is to return NULL so that link will (later) be initialized. This is because if() starting on line 1268 of proton-c/src/core/transport.c only uses strncmp(). eg: "strncmp( "foo", "fooBar", 3) == 0" That if() also needs to check +sizes of the names+ and only do "strncmp()" if: "(name.size == strlen(pn_string_get(link->name)))" Symptoms: Qpid client blocks indefinitely on second ConnectionContext::createReceiver() waiting for link to be established. Broker never does PN_LINK_INIT because it incorrectly believes link already exists, client is hung waiting for message back from broker. > Incomplete name comparision in transport.c pn_find_link() > --------------------------------------------------------- > > Key: PROTON-1661 > URL: https://issues.apache.org/jira/browse/PROTON-1661 > Project: Qpid Proton > Issue Type: Bug > Components: proton-c > Affects Versions: 0.11.1, proton-c-0.17.0 > Environment: RedHat EL 5 & 7 > Reporter: Nathan Campbell > > Tested in both proton-c version 0.11.1 and 0.17.0 with qpid broker 1.36.0 > Problem: > Function "pn_find_link()" incorrectly returns a link when argument "name" matches first N characters of existing link. > i.e.: > 1) QPID client creates receiver with address "amq.topic/fooBar": > Broker will call function pn_find_link( ssn, name = "fooBar", true) which returns NULL as expected. Link is initialized and receiver works as expected. > 2) Some time later the same QPID client creates second receiver with address "amq.topic/foo": > Broker will call function pn_find_link( ssn, name="foo", true) which incorrectly returns pointer to existing link. Expected behavior is to return NULL so that link will (later) be initialized. > This is because if() starting on line 1268 of proton-c/src/core/transport.c only uses strncmp(). > eg: "strncmp( "foo", "fooBar", 3) == 0" > That if() also needs to check +sizes of the names+ and only do "strncmp()" if: > "(name.size == strlen(pn_string_get(link->name)))" > Symptoms: > Qpid client blocks indefinitely on second ConnectionContext::createReceiver() waiting for link to be established. Broker never does PN_LINK_INIT because it incorrectly believes link already exists, client is hung waiting for message back from broker. -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org For additional commands, e-mail: dev-help@qpid.apache.org