mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
5.8 KiB

  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 3.2
  4. Patch-ID: bash32-005
  5. Bug-Reported-by: Stuart Shelton <stuart@openobjects.com>
  6. Bug-Reference-ID: <453F7CC8.6030907@openobjects.com>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2006-10/msg00127.html
  8. Bug-Description:
  9. A missing extern declaration for `asprintf' caused `double' arguments to be
  10. passed as `0', leading to incorrect results. Additionally, a bug in the
  11. replacement asprintf/snprintf function caused an infinite loop when passed
  12. 0 arguments to the floating point conversions under some circumstances.
  13. Patch:
  14. *** bash-3.2/builtins/printf.def Mon Sep 18 08:48:42 2006
  15. --- builtins/printf.def Tue Oct 31 08:19:44 2006
  16. ***************
  17. *** 49,54 ****
  18. --- 49,60 ----
  19. # define INT_MIN (-2147483647-1)
  20. #endif
  21. + #if defined (PREFER_STDARG)
  22. + # include <stdarg.h>
  23. + #else
  24. + # include <varargs.h>
  25. + #endif
  26. +
  27. #include <stdio.h>
  28. #include <chartypes.h>
  29. ***************
  30. *** 151,156 ****
  31. --- 157,166 ----
  32. #define SKIP1 "#'-+ 0"
  33. #define LENMODS "hjlLtz"
  34. + #ifndef HAVE_ASPRINTF
  35. + extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
  36. + #endif
  37. +
  38. static void printf_erange __P((char *));
  39. static int printstr __P((char *, char *, int, int, int));
  40. static int tescape __P((char *, char *, int *));
  41. *** bash-3.2/lib/sh/snprintf.c Thu Apr 6 09:48:40 2006
  42. --- lib/sh/snprintf.c Sat Oct 28 00:00:13 2006
  43. ***************
  44. *** 471,476 ****
  45. --- 476,483 ----
  46. 10^x ~= r
  47. * log_10(200) = 2;
  48. * log_10(250) = 2;
  49. + *
  50. + * NOTE: do not call this with r == 0 -- an infinite loop results.
  51. */
  52. static int
  53. log_10(r)
  54. ***************
  55. *** 576,583 ****
  56. {
  57. integral_part[0] = '0';
  58. integral_part[1] = '\0';
  59. ! fraction_part[0] = '0';
  60. ! fraction_part[1] = '\0';
  61. if (fract)
  62. *fract = fraction_part;
  63. return integral_part;
  64. --- 583,593 ----
  65. {
  66. integral_part[0] = '0';
  67. integral_part[1] = '\0';
  68. ! /* The fractional part has to take the precision into account */
  69. ! for (ch = 0; ch < precision-1; ch++)
  70. ! fraction_part[ch] = '0';
  71. ! fraction_part[ch] = '0';
  72. ! fraction_part[ch+1] = '\0';
  73. if (fract)
  74. *fract = fraction_part;
  75. return integral_part;
  76. ***************
  77. *** 805,810 ****
  78. --- 815,821 ----
  79. PUT_CHAR(*tmp, p);
  80. tmp++;
  81. }
  82. +
  83. PAD_LEFT(p);
  84. }
  85. ***************
  86. *** 972,982 ****
  87. if ((p->flags & PF_THOUSANDS) && grouping && (t = groupnum (tmp)))
  88. tmp = t;
  89. /* calculate the padding. 1 for the dot */
  90. p->width = p->width -
  91. ((d > 0. && p->justify == RIGHT) ? 1:0) -
  92. ((p->flags & PF_SPACE) ? 1:0) -
  93. ! strlen(tmp) - p->precision - 1;
  94. PAD_RIGHT(p);
  95. PUT_PLUS(d, p, 0.);
  96. PUT_SPACE(d, p, 0.);
  97. --- 983,1003 ----
  98. if ((p->flags & PF_THOUSANDS) && grouping && (t = groupnum (tmp)))
  99. tmp = t;
  100. + if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
  101. + {
  102. + /* smash the trailing zeros unless altform */
  103. + for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
  104. + tmp2[i] = '\0';
  105. + if (tmp2[0] == '\0')
  106. + p->precision = 0;
  107. + }
  108. +
  109. /* calculate the padding. 1 for the dot */
  110. p->width = p->width -
  111. ((d > 0. && p->justify == RIGHT) ? 1:0) -
  112. ((p->flags & PF_SPACE) ? 1:0) -
  113. ! strlen(tmp) - p->precision -
  114. ! ((p->precision != 0 || (p->flags & PF_ALTFORM)) ? 1 : 0); /* radix char */
  115. PAD_RIGHT(p);
  116. PUT_PLUS(d, p, 0.);
  117. PUT_SPACE(d, p, 0.);
  118. ***************
  119. *** 991,1001 ****
  120. if (p->precision != 0 || (p->flags & PF_ALTFORM))
  121. PUT_CHAR(decpoint, p); /* put the '.' */
  122. - if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
  123. - /* smash the trailing zeros unless altform */
  124. - for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
  125. - tmp2[i] = '\0';
  126. -
  127. for (; *tmp2; tmp2++)
  128. PUT_CHAR(*tmp2, p); /* the fraction */
  129. --- 1012,1017 ----
  130. ***************
  131. *** 1011,1024 ****
  132. char *tmp, *tmp2;
  133. int j, i;
  134. ! if (chkinfnan(p, d, 1) || chkinfnan(p, d, 2))
  135. return; /* already printed nan or inf */
  136. GETLOCALEDATA(decpoint, thoussep, grouping);
  137. DEF_PREC(p);
  138. ! j = log_10(d);
  139. ! d = d / pow_10(j); /* get the Mantissa */
  140. ! d = ROUND(d, p);
  141. tmp = dtoa(d, p->precision, &tmp2);
  142. /* 1 for unit, 1 for the '.', 1 for 'e|E',
  143. --- 1027,1045 ----
  144. char *tmp, *tmp2;
  145. int j, i;
  146. ! if (d != 0 && (chkinfnan(p, d, 1) || chkinfnan(p, d, 2)))
  147. return; /* already printed nan or inf */
  148. GETLOCALEDATA(decpoint, thoussep, grouping);
  149. DEF_PREC(p);
  150. ! if (d == 0.)
  151. ! j = 0;
  152. ! else
  153. ! {
  154. ! j = log_10(d);
  155. ! d = d / pow_10(j); /* get the Mantissa */
  156. ! d = ROUND(d, p);
  157. ! }
  158. tmp = dtoa(d, p->precision, &tmp2);
  159. /* 1 for unit, 1 for the '.', 1 for 'e|E',
  160. ***************
  161. *** 1076,1081 ****
  162. --- 1097,1103 ----
  163. PUT_CHAR(*tmp, p);
  164. tmp++;
  165. }
  166. +
  167. PAD_LEFT(p);
  168. }
  169. #endif
  170. ***************
  171. *** 1358,1364 ****
  172. STAR_ARGS(data);
  173. DEF_PREC(data);
  174. d = GETDOUBLE(data);
  175. ! i = log_10(d);
  176. /*
  177. * for '%g|%G' ANSI: use f if exponent
  178. * is in the range or [-4,p] exclusively
  179. --- 1380,1386 ----
  180. STAR_ARGS(data);
  181. DEF_PREC(data);
  182. d = GETDOUBLE(data);
  183. ! i = (d != 0.) ? log_10(d) : -1;
  184. /*
  185. * for '%g|%G' ANSI: use f if exponent
  186. * is in the range or [-4,p] exclusively
  187. *** bash-3.2/patchlevel.h Thu Apr 13 08:31:04 2006
  188. --- patchlevel.h Mon Oct 16 14:22:54 2006
  189. ***************
  190. *** 26,30 ****
  191. looks for to find the patch level (for the sccs version string). */
  192. ! #define PATCHLEVEL 4
  193. #endif /* _PATCHLEVEL_H_ */
  194. --- 26,30 ----
  195. looks for to find the patch level (for the sccs version string). */
  196. ! #define PATCHLEVEL 5
  197. #endif /* _PATCHLEVEL_H_ */