------------------------------------------------------------ revno: 12412 revision-id: squid3@treenet.co.nz-20121124035540-jjnnc65ywk09uew7 parent: squid3@treenet.co.nz-20121124035401-yq2h34f4lvzvnaqo committer: Amos Jeffries branch nick: 3.3 timestamp: Fri 2012-11-23 20:55:40 -0700 message: librfcnb: memory leaks in session setup Detected by Coverity Scan. Issue 740425. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20121124035540-jjnnc65ywk09uew7 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # testament_sha1: 6efc8d15062ad46601fb38f8052eb8f180d14021 # timestamp: 2012-11-24 03:57:54 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # base_revision_id: squid3@treenet.co.nz-20121124035401-\ # yq2h34f4lvzvnaqo # # Begin patch === modified file 'lib/rfcnb/rfcnb-util.c' --- lib/rfcnb/rfcnb-util.c 2012-01-20 18:55:04 +0000 +++ lib/rfcnb/rfcnb-util.c 2012-11-24 03:55:40 +0000 @@ -425,6 +425,7 @@ char resp[16]; int len; struct RFCNB_Pkt *pkt, res_pkt; + int result = 0; /* We build and send the session request, then read the response */ @@ -450,7 +451,7 @@ #endif if ((len = RFCNB_Put_Pkt(con, pkt, RFCNB_Pkt_Sess_Len)) < 0) { - + RFCNB_Free_Pkt(pkt); return (RFCNBE_Bad); /* Should be able to write that lot ... */ } @@ -463,7 +464,7 @@ res_pkt.next = NULL; if ((len = RFCNB_Get_Pkt(con, &res_pkt, sizeof(resp))) < 0) { - + RFCNB_Free_Pkt(pkt); return (RFCNBE_Bad); } @@ -497,12 +498,12 @@ break; } - return (RFCNBE_Bad); + result = (RFCNBE_Bad); break; case RFCNB_SESSION_ACK: /* Got what we wanted ... */ - return (0); + result = (0); break; case RFCNB_SESSION_RETARGET: /* Go elsewhere */ @@ -512,13 +513,16 @@ memcpy(Dest_IP, (resp + RFCNB_Pkt_IP_Offset), sizeof(struct in_addr)); *port = SVAL(resp, RFCNB_Pkt_Port_Offset); - return (0); + result = (0); break; default: /* A protocol error */ RFCNB_errno = RFCNBE_ProtErr; - return (RFCNBE_Bad); + result = (RFCNBE_Bad); break; } + + RFCNB_Free_Pkt(pkt); + return result; }