Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Chet Ramey Newsgroups: gnu.bash.bug Subject: Bash-5.0 Official Patch 17 Date: Fri, 24 Apr 2020 10:52:23 -0400 Lines: 295 Sender: Chet Ramey Approved: bug-bash@gnu.org Message-ID: References: <200424145223.AA28115.SM@caleb.ins.cwru.edu> Reply-To: chet.ramey@case.edu NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1587740521 7236 209.51.188.17 (24 Apr 2020 15:02:01 GMT) X-Complaints-To: action@cs.stanford.edu Cc: chet.ramey@case.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1587740513; bh=jVx9C23qfDaKkFTZTenXD/sgOrjSccRqTo8SWAvLbw4=; h=Date:From:Sender:To:Subject:Cc:Reply-To:Message-ID:MIME-Version: Content-Type; b=lS9KY/LCHgJXl+rhEdMPQfMr7DOOuUBvotbaFHDRj1XjQsoAGPvIDkQmWRrdJuylwt OnAfwZJErpym3I3Bdq65sRNe4uKm7UvRPZZM6N42ydB3NrknD+Q/jhFE5FmJhIejj66 sfGt8CQzEULbadgNXlGRagbOfS8AuDc8GEkvo2ivkmePngmz2E5bbjl+AbRo42Vkhik 8Fq6UQRRCsuono541xm9IecLapSTEHaYInmsMi+vWtUWTJTgydW+ORarFOl2cxbXfR7 MacXu7cyBpub4g3v2ufkUtZp2ZAGuynKD2reg+jdrKTyajTg2MujXI0d5XBPegPBISw Ll0ii9MQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1587740148; bh=PU5lb/1y6JHlkX2RiwR15zu8xFU3bbswgZXPHEQOIVc=; h=Date:From:Sender:To:Subject:Cc:Reply-To:Message-ID:MIME-Version: Content-Type; b=ZxNseKBOwsCSmS/t7sIa+/d63cunSHO+0aJg0JcMBwUqtnKVY5ZDFE8tLOQEx5oja6 ignXoFfRSVrtjomNH5GAP572MsZfM6PWm/mRnAS+APiaQlVU16Vtwp1DjmrJBzrRlZN Au0Vg2ngTkN2XZypvo1kDMIDVIp+hcMiMsdPxMbR1C+VUC2FiPEzsNtNPoKAzEK/GFn tys/y6iwEnkUXAdNowZ4tis+wI2tfgnpvFhk+YHCGga18mGYgJg1cu5SoxaR+yOMq67 Kq/d7Feq1STVR6lJA9lLVODV4udo/NcIWnF1OUUZsC0VjSRqS+rW2qyfbxge7DywrPR YFo3zEDg== Read-Receipt-To: chet.ramey@case.edu X-Mirapoint-IP-Reputation: reputation=Neutral-1, source=Queried, refid=tid=0001.0A020303.5EA2FDF3.00BE, actions=tag X-Mirapoint-IP-Reputation: reputation=good-1, source=Fixed, refid=n/a, actions=tag X-Junkmail-Status: score=7/80, host=mpv3-2015.case.edu X-Junkmail-PrAS-Raw: score=7/80, refid=2.7.2:2020.4.24.134218:17:7.944, ip=, rules=__RCVD_POSTFIX_UID, DKIM_SIGNATURE, DATE_TZ_NA, __HAS_FROM, FROM_EDU_TLD, __HAS_SENDER, __TO_MALFORMED_2, __TO_NO_NAME, __HAS_CC_HDR, __HAS_REPLYTO, __HAS_MSGID, __SANE_MSGID, __MIME_VERSION, __CT, __CT_TEXT_PLAIN, __REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC1, __REPLYTO_SAMEAS_FROM_DOMAIN, __DKIM_ALIGNS_1, __DKIM_ALIGNS_2, __URI_HAS_HYPHEN_USC, __ANY_URI, __URI_MAILTO, __HTTPS_URI, __URI_WITH_PATH, __URI_ENDS_IN_SLASH, URI_ENDS_IN_HTML, __URI_NO_WWW, __STOCK_PHRASE_24, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __BITCOIN_ADDRESS_OBFU, __MULTIPLE_URI_TEXT, __URI_IN_BODY, __URI_NOT_IMG, __BODY_NO_MAILTO, __NO_HTML_TAG_RAW, BODY_SIZE_6000_6999, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, SXL_IP_TFX_WM[202.103.22.129.fur], HTML_00_01, HTML_00_10, DKIM_ALIGNS, KNOWN_MTA_TFX, __FROM_DOMAIN_IN_RCPT, MULTIPLE_REAL_RCPTS, [TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138 Received-SPF: none client-ip=129.22.103.194; envelope-from=chet@caleb.ins.cwru.edu; helo=mpv3-2015.case.edu X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/24 10:55:48 X-ACL-Warn: Detected OS = Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 129.22.103.194 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <200424145223.AA28115.SM@caleb.ins.cwru.edu> Xref: csiph.com gnu.bash.bug:16237 BASH PATCH REPORT ================= Bash-Release: 5.0 Patch-ID: bash50-017 Bug-Reported-by: Valentin Lab Bug-Reference-ID: Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2020-03/msg00062.html Bug-Description: There were cases where patch 16 reaped process substitution file descriptors (or FIFOs) and processes to early. This is a better fix for the problem that bash50-016 attempted to solve. Patch (apply with `patch -p0'): *** ../bash-5.0-patched/subst.c 2019-08-29 11:16:49.000000000 -0400 --- subst.c 2020-04-02 16:24:19.000000000 -0400 *************** *** 5337,5341 **** } ! char * copy_fifo_list (sizep) int *sizep; --- 5337,5341 ---- } ! void * copy_fifo_list (sizep) int *sizep; *************** *** 5343,5347 **** if (sizep) *sizep = 0; ! return (char *)NULL; } --- 5343,5347 ---- if (sizep) *sizep = 0; ! return (void *)NULL; } *************** *** 5409,5414 **** if (fifo_list[i].file) { ! fifo_list[j].file = fifo_list[i].file; ! fifo_list[j].proc = fifo_list[i].proc; j++; } --- 5409,5419 ---- if (fifo_list[i].file) { ! if (i != j) ! { ! fifo_list[j].file = fifo_list[i].file; ! fifo_list[j].proc = fifo_list[i].proc; ! fifo_list[i].file = (char *)NULL; ! fifo_list[i].proc = 0; ! } j++; } *************** *** 5426,5433 **** void close_new_fifos (list, lsize) ! char *list; int lsize; { int i; if (list == 0) --- 5431,5439 ---- void close_new_fifos (list, lsize) ! void *list; int lsize; { int i; + char *plist; if (list == 0) *************** *** 5437,5442 **** } ! for (i = 0; i < lsize; i++) ! if (list[i] == 0 && i < fifo_list_size && fifo_list[i].proc != -1) unlink_fifo (i); --- 5443,5448 ---- } ! for (plist = (char *)list, i = 0; i < lsize; i++) ! if (plist[i] == 0 && i < fifo_list_size && fifo_list[i].proc != -1) unlink_fifo (i); *************** *** 5560,5568 **** } ! char * copy_fifo_list (sizep) int *sizep; { ! char *ret; if (nfds == 0 || totfds == 0) --- 5566,5574 ---- } ! void * copy_fifo_list (sizep) int *sizep; { ! void *ret; if (nfds == 0 || totfds == 0) *************** *** 5570,5579 **** if (sizep) *sizep = 0; ! return (char *)NULL; } if (sizep) *sizep = totfds; ! ret = (char *)xmalloc (totfds * sizeof (pid_t)); return (memcpy (ret, dev_fd_list, totfds * sizeof (pid_t))); } --- 5576,5585 ---- if (sizep) *sizep = 0; ! return (void *)NULL; } if (sizep) *sizep = totfds; ! ret = xmalloc (totfds * sizeof (pid_t)); return (memcpy (ret, dev_fd_list, totfds * sizeof (pid_t))); } *************** *** 5648,5655 **** void close_new_fifos (list, lsize) ! char *list; int lsize; { int i; if (list == 0) --- 5654,5662 ---- void close_new_fifos (list, lsize) ! void *list; int lsize; { int i; + pid_t *plist; if (list == 0) *************** *** 5659,5664 **** } ! for (i = 0; i < lsize; i++) ! if (list[i] == 0 && i < totfds && dev_fd_list[i]) unlink_fifo (i); --- 5666,5671 ---- } ! for (plist = (pid_t *)list, i = 0; i < lsize; i++) ! if (plist[i] == 0 && i < totfds && dev_fd_list[i]) unlink_fifo (i); *** ../bash-5.0-patched/subst.h 2018-10-21 18:46:09.000000000 -0400 --- subst.h 2020-04-02 16:29:28.000000000 -0400 *************** *** 274,280 **** extern void unlink_fifo __P((int)); ! extern char *copy_fifo_list __P((int *)); ! extern void unlink_new_fifos __P((char *, int)); ! extern void close_new_fifos __P((char *, int)); extern void clear_fifo_list __P((void)); --- 274,279 ---- extern void unlink_fifo __P((int)); ! extern void *copy_fifo_list __P((int *)); ! extern void close_new_fifos __P((void *, int)); extern void clear_fifo_list __P((void)); *** ../bash-5.0-patched/execute_cmd.c 2020-02-06 20:16:48.000000000 -0500 --- execute_cmd.c 2020-04-02 17:00:10.000000000 -0400 *************** *** 565,569 **** #if defined (PROCESS_SUBSTITUTION) volatile int ofifo, nfifo, osize, saved_fifo; ! volatile char *ofifo_list; #endif --- 565,569 ---- #if defined (PROCESS_SUBSTITUTION) volatile int ofifo, nfifo, osize, saved_fifo; ! volatile void *ofifo_list; #endif *************** *** 751,760 **** # endif ! if (variable_context != 0) /* XXX - also if sourcelevel != 0? */ { ofifo = num_fifos (); ofifo_list = copy_fifo_list ((int *)&osize); begin_unwind_frame ("internal_fifos"); ! add_unwind_protect (xfree, ofifo_list); saved_fifo = 1; } --- 751,762 ---- # endif ! /* XXX - also if sourcelevel != 0? */ ! if (variable_context != 0) { ofifo = num_fifos (); ofifo_list = copy_fifo_list ((int *)&osize); begin_unwind_frame ("internal_fifos"); ! if (ofifo_list) ! add_unwind_protect (xfree, ofifo_list); saved_fifo = 1; } *************** *** 1100,1123 **** nfifo = num_fifos (); if (nfifo > ofifo) ! close_new_fifos ((char *)ofifo_list, osize); free ((void *)ofifo_list); discard_unwind_frame ("internal_fifos"); } - # if defined (HAVE_DEV_FD) - /* Reap process substitutions at the end of loops */ - switch (command->type) - { - case cm_while: - case cm_until: - case cm_for: - case cm_group: - # if defined (ARITH_FOR_COMMAND) - case cm_arith_for: - # endif - reap_procsubs (); - default: - break; - } - # endif /* HAVE_DEV_FD */ #endif --- 1102,1109 ---- nfifo = num_fifos (); if (nfifo > ofifo) ! close_new_fifos ((void *)ofifo_list, osize); free ((void *)ofifo_list); discard_unwind_frame ("internal_fifos"); } #endif *** ../bash-5.0/patchlevel.h 2016-06-22 14:51:03.000000000 -0400 --- patchlevel.h 2016-10-01 11:01:28.000000000 -0400 *************** *** 26,30 **** looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 16 #endif /* _PATCHLEVEL_H_ */ --- 26,30 ---- looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 17 #endif /* _PATCHLEVEL_H_ */ -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/