fix-strlcat_strlcpy.patch 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. --- src/apppstatus.cc 2017-07-30 10:59:06.000000000 +0200
  2. +++ src/apppstatus.cc 2017-08-09 09:12:54.332052762 +0200
  3. @@ -366,7 +366,7 @@
  4. sscanf(p, "%s %s %s %s %s", val[0], val[1], val[2], val[3], val[4]);
  5. for (i = 0; i < 4; i++) {
  6. if (strncmp(val[i+1], "?", 1) != 0)
  7. - strlcpy(phoneNumber, val[i+1], sizeof phoneNumber);
  8. + my_strlcpy(phoneNumber, val[i+1], sizeof phoneNumber);
  9. }
  10. }
  11. --- src/base.h 2017-07-30 10:59:06.000000000 +0200
  12. +++ src/base.h 2017-08-09 09:11:13.082025484 +0200
  13. @@ -44,9 +44,9 @@
  14. /*** String Functions *********************************************************/
  15. /* Prefer this as a safer alternative over strcpy. Return strlen(from). */
  16. -size_t strlcpy(char *dest, const char *from, size_t dest_size);
  17. +size_t my_strlcpy(char *dest, const char *from, size_t dest_size);
  18. /* Prefer this over strcat. Return strlen(dest) + strlen(from). */
  19. -size_t strlcat(char *dest, const char *from, size_t dest_size);
  20. +size_t my_strlcat(char *dest, const char *from, size_t dest_size);
  21. char *newstr(char const *str);
  22. char *newstr(char const *str, int len);
  23. --- src/gnome2.cc 2017-07-30 10:59:06.000000000 +0200
  24. +++ src/gnome2.cc 2017-08-09 09:11:21.819027846 +0200
  25. @@ -158,8 +158,8 @@
  26. const int plen = strlen(fPath);
  27. char tmp[256];
  28. - strlcpy(tmp, fPath, sizeof tmp);
  29. - strlcat(tmp, "/.directory", sizeof tmp);
  30. + my_strlcpy(tmp, fPath, sizeof tmp);
  31. + my_strlcat(tmp, "/.directory", sizeof tmp);
  32. if (isDir && !stat(tmp, &sb)) { // looks like kde/gnome1 style
  33. @@ -279,8 +279,8 @@
  34. while ((file = readdir(dir)) != NULL) {
  35. char fullpath[256];
  36. - strlcpy(fullpath, dirname, sizeof fullpath);
  37. - strlcat(fullpath, file->d_name, sizeof fullpath);
  38. + my_strlcpy(fullpath, dirname, sizeof fullpath);
  39. + my_strlcat(fullpath, file->d_name, sizeof fullpath);
  40. GnomeDesktopItem *ditem =
  41. gnome_desktop_item_new_from_file(fullpath,
  42. (GnomeDesktopItemLoadFlags)0,
  43. --- src/icehelp.cc 2017-07-30 10:59:06.000000000 +0200
  44. +++ src/icehelp.cc 2017-08-09 09:11:31.490030459 +0200
  45. @@ -1790,8 +1790,8 @@
  46. const size_t size = 9 + strlen(cfmt) + strlen(cstr) + strlen(crea);
  47. char *cbuf = (char *)malloc(size);
  48. snprintf(cbuf, size, cfmt, cstr);
  49. - strlcat(cbuf, ":\n ", size);
  50. - strlcat(cbuf, crea, size);
  51. + my_strlcat(cbuf, ":\n ", size);
  52. + my_strlcat(cbuf, crea, size);
  53. node *root = new node(node::div);
  54. flist<node> nodes(root);
  55. --- src/icesm.cc 2017-07-30 10:59:06.000000000 +0200
  56. +++ src/icesm.cc 2017-08-09 09:13:12.946057758 +0200
  57. @@ -28,10 +28,10 @@
  58. wordexp_t w;
  59. if (wordexp(trim(buf), &w, 0) != 0 || w.we_wordc == 0)
  60. return false;
  61. - size_t len = strlcpy(buf, trim(w.we_wordv[0]), bufsiz);
  62. + size_t len = my_strlcpy(buf, trim(w.we_wordv[0]), bufsiz);
  63. for (size_t k = 1; k < w.we_wordc && len < bufsiz; ++k) {
  64. - strlcat(buf, " ", bufsiz);
  65. - len = strlcat(buf, trim(w.we_wordv[k]), bufsiz);
  66. + my_strlcat(buf, " ", bufsiz);
  67. + len = my_strlcat(buf, trim(w.we_wordv[k]), bufsiz);
  68. }
  69. wordfree(&w);
  70. if (len >= bufsiz)
  71. @@ -39,7 +39,7 @@
  72. #else
  73. char *str = trim(buf);
  74. if (str > buf)
  75. - strlcpy(buf, str, bufsiz);
  76. + my_strlcpy(buf, str, bufsiz);
  77. #endif
  78. if (buf[0] == '#' || buf[0] == '=')
  79. buf[0] = 0;
  80. --- src/icesound.cc 2017-07-30 10:59:06.000000000 +0200
  81. +++ src/icesound.cc 2017-08-09 09:11:26.686029161 +0200
  82. @@ -145,8 +145,8 @@
  83. char * findSample(int sid) {
  84. char basefname[1024];
  85. - strlcpy(basefname, gui_events[sid].name, sizeof basefname);
  86. - strlcat(basefname, ".wav", sizeof basefname);
  87. + my_strlcpy(basefname, gui_events[sid].name, sizeof basefname);
  88. + my_strlcat(basefname, ".wav", sizeof basefname);
  89. return findSample(basefname);
  90. }
  91. --- src/misc.cc 2017-07-30 10:59:06.000000000 +0200
  92. +++ src/misc.cc 2017-08-09 09:13:39.372064834 +0200
  93. @@ -448,7 +448,7 @@
  94. #endif
  95. /* Prefer this as a safer alternative over strcpy. Return strlen(from). */
  96. -size_t strlcpy(char *dest, const char *from, size_t dest_size)
  97. +size_t my_strlcpy(char *dest, const char *from, size_t dest_size)
  98. {
  99. const char *in = from;
  100. if (dest_size > 0) {
  101. @@ -463,12 +463,12 @@
  102. }
  103. /* Prefer this over strcat. Return strlen(dest) + strlen(from). */
  104. -size_t strlcat(char *dest, const char *from, size_t dest_size)
  105. +size_t my_strlcat(char *dest, const char *from, size_t dest_size)
  106. {
  107. char *to = dest;
  108. char *const stop = to + dest_size - 1;
  109. while (to < stop && *to) ++to;
  110. - return to - dest + strlcpy(to, from, dest_size - (to - dest));
  111. + return to - dest + my_strlcpy(to, from, dest_size - (to - dest));
  112. }
  113. char *newstr(char const *str) {
  114. --- src/strtest.cc 2017-07-30 10:59:06.000000000 +0200
  115. +++ src/strtest.cc 2017-08-09 09:13:24.395060823 +0200
  116. @@ -286,63 +286,63 @@
  117. strtest tester("strlc");
  118. char d[10] = "@";
  119. size_t n;
  120. - n = strlcpy(d, "", 0);
  121. + n = my_strlcpy(d, "", 0);
  122. sequal(d, "@");
  123. assert(d, n == 0);
  124. - n = strlcpy(d, "a", 0);
  125. + n = my_strlcpy(d, "a", 0);
  126. sequal(d, "@");
  127. assert(d, n == 1);
  128. - n = strlcpy(d, "", 1);
  129. + n = my_strlcpy(d, "", 1);
  130. sequal(d, "");
  131. assert(d, n == 0);
  132. - n = strlcpy(d, "a", 1);
  133. + n = my_strlcpy(d, "a", 1);
  134. sequal(d, "");
  135. assert(d, n == 1);
  136. - n = strlcpy(d, "a", 2);
  137. + n = my_strlcpy(d, "a", 2);
  138. sequal(d, "a");
  139. assert(d, n == 1);
  140. - n = strlcpy(d, "ab", 2);
  141. + n = my_strlcpy(d, "ab", 2);
  142. sequal(d, "a");
  143. assert(d, n == 2);
  144. - n = strlcpy(d, "ab", 3);
  145. + n = my_strlcpy(d, "ab", 3);
  146. sequal(d, "ab");
  147. assert(d, n == 2);
  148. - n = strlcpy(d, "abc", sizeof d);
  149. + n = my_strlcpy(d, "abc", sizeof d);
  150. sequal(d, "abc");
  151. assert(d, n == 3);
  152. - n = strlcat(d, "def", 4);
  153. + n = my_strlcat(d, "def", 4);
  154. sequal(d, "abc");
  155. assert(d, n == 6);
  156. - n = strlcat(d, "def", sizeof d);
  157. + n = my_strlcat(d, "def", sizeof d);
  158. sequal(d, "abcdef");
  159. assert(d, n == 6);
  160. - n = strlcat(d, "ghijkl", sizeof d);
  161. + n = my_strlcat(d, "ghijkl", sizeof d);
  162. sequal(d, "abcdefghi");
  163. assert(d, n == 12);
  164. - n = strlcpy(d, "123", sizeof d);
  165. + n = my_strlcpy(d, "123", sizeof d);
  166. sequal(d, "123");
  167. assert(d, n == 3);
  168. - n = strlcpy(d, d + 1, sizeof d);
  169. + n = my_strlcpy(d, d + 1, sizeof d);
  170. sequal(d, "23");
  171. assert(d, n == 2);
  172. - n = strlcpy(d, d + 1, sizeof d);
  173. + n = my_strlcpy(d, d + 1, sizeof d);
  174. sequal(d, "3");
  175. assert(d, n == 1);
  176. - n = strlcpy(d, d + 1, sizeof d);
  177. + n = my_strlcpy(d, d + 1, sizeof d);
  178. sequal(d, "");
  179. assert(d, n == 0);
  180. }
  181. @@ -418,7 +418,7 @@
  182. while (a.next()) {
  183. const char *e = a.entry();
  184. assert(e, strcoll(buf, e) < 0);
  185. - strlcpy(buf, e, sizeof buf);
  186. + my_strlcpy(buf, e, sizeof buf);
  187. }
  188. assert(buf, strcoll(buf, "~~~~~~~~~") < 0);
  189. }
  190. @@ -437,7 +437,7 @@
  191. cstring c(s.entry());
  192. const char *e = c.c_str();
  193. assert(e, strcoll(buf, e) < 0);
  194. - strlcpy(buf, e, sizeof buf);
  195. + my_strlcpy(buf, e, sizeof buf);
  196. }
  197. assert(buf, strcoll(buf, "~~~~~~~~~") < 0);
  198. }
  199. --- src/udir.cc 2017-07-30 10:59:06.000000000 +0200
  200. +++ src/udir.cc 2017-08-09 09:13:28.346061883 +0200
  201. @@ -66,7 +66,7 @@
  202. if (impl) {
  203. DirPtr dirp(impl);
  204. if (dirp.next()) {
  205. - strlcpy(fEntry, dirp.name(), sizeof fEntry);
  206. + my_strlcpy(fEntry, dirp.name(), sizeof fEntry);
  207. return true;
  208. }
  209. }