icu-overflow.patch 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. A combination of issue & patches from...
  2. https://bugs.icu-project.org/trac/ticket/7680
  3. https://bugs.icu-project.org/trac/changeset/28002
  4. https://bugs.icu-project.org/trac/changeset/28124
  5. Enlarged buffers more since include files for pkgdata can grow
  6. significantly when cross-compiling.
  7. This ONLY affects building.
  8. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
  9. diff -Nura icu.orig/source/tools/pkgdata/pkgdata.cpp icu/source/tools/pkgdata/pkgdata.cpp
  10. --- icu.orig/source/tools/pkgdata/pkgdata.cpp 2010-09-29 15:37:28.000000000 -0300
  11. +++ icu/source/tools/pkgdata/pkgdata.cpp 2010-12-21 15:53:30.252554924 -0300
  12. @@ -97,8 +97,9 @@
  13. #define PKGDATA_FILE_SEP_STRING U_FILE_SEP_STRING
  14. #endif
  15. -#define LARGE_BUFFER_MAX_SIZE 2048
  16. -#define SMALL_BUFFER_MAX_SIZE 512
  17. +#define LARGE_BUFFER_MAX_SIZE 8192
  18. +#define MEDIUM_BUFFER_MAX_SIZE 4096
  19. +#define SMALL_BUFFER_MAX_SIZE 2048
  20. static void loadLists(UPKGOptions *o, UErrorCode *status);
  21. @@ -472,29 +473,48 @@
  22. }
  23. static int runCommand(const char* command, UBool specialHandling) {
  24. - char cmd[SMALL_BUFFER_MAX_SIZE];
  25. + char *cmd = NULL;
  26. + char cmdBuffer[SMALL_BUFFER_MAX_SIZE];
  27. + int32_t len = strlen(command);
  28. +
  29. + if (len == 0) {
  30. + return 0;
  31. + }
  32. if (!specialHandling) {
  33. +#if defined(USING_CYGWIN) || defined(OS400)
  34. +#define CMD_PADDING_SIZE 20
  35. + if ((len + CMD_PADDING_SIZE) >= SMALL_BUFFER_MAX_SIZE) {
  36. + cmd = (char *)uprv_malloc(len + CMD_PADDING_SIZE);
  37. + } else {
  38. + cmd = cmdBuffer;
  39. + }
  40. #ifdef USING_CYGWIN
  41. sprintf(cmd, "bash -c \"%s\"", command);
  42. #elif defined(OS400)
  43. sprintf(cmd, "QSH CMD('%s')", command);
  44. +#endif
  45. #else
  46. goto normal_command_mode;
  47. #endif
  48. } else {
  49. normal_command_mode:
  50. - sprintf(cmd, "%s", command);
  51. + cmd = (char *)command;
  52. }
  53. -
  54. +
  55. printf("pkgdata: %s\n", cmd);
  56. int result = system(cmd);
  57. - if (result != 0) {
  58. - printf("-- return status = %d\n", result);
  59. + if (result != 0) {
  60. + printf("-- return status = %d\n", result);
  61. + }
  62. +
  63. + if (cmd != cmdBuffer && cmd != command) {
  64. + uprv_free(cmd);
  65. }
  66. - return result;
  67. -}
  68. +
  69. + return result;
  70. +}
  71. #define LN_CMD "ln -s"
  72. #define RM_CMD "rm -f"
  73. @@ -586,7 +606,7 @@
  74. pkgDataFlags = (char**)uprv_malloc(sizeof(char*) * PKGDATA_FLAGS_SIZE);
  75. if (pkgDataFlags != NULL) {
  76. for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) {
  77. - pkgDataFlags[i] = (char*)uprv_malloc(sizeof(char) * SMALL_BUFFER_MAX_SIZE);
  78. + pkgDataFlags[i] = (char*)uprv_malloc(sizeof(char) * MEDIUM_BUFFER_MAX_SIZE);
  79. if (pkgDataFlags[i] != NULL) {
  80. pkgDataFlags[i][0] = 0;
  81. } else {