Guest User

Untitled

a guest
Jan 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. diff --git a/cutef8/utf8.c b/cutef8/utf8.c
  2. index 9adbe81..e30ed07 100644
  3. --- a/cutef8/utf8.c
  4. +++ b/cutef8/utf8.c
  5. @@ -732,8 +732,8 @@ chkutf8:
  6. return CUTEF8_IS_INVALID; // Last byte can't be > 127
  7. }
  8. byt = pnt[-1];
  9. - // Must be between 0xc2 and 0xf4 inclusive to be valid
  10. - if (((uint32_t) byt - 0xc2) > (0xf4 - 0xc2)) {
  11. + // Range check: 0xc2 <= byte < 0xf8
  12. + if (((uint32_t) byt - 0xc2) >= (0xf8 - 0xc2)) {
  13. return CUTEF8_IS_INVALID;
  14. }
  15. if (byt < 0xe0) { // 2-byte sequence
  16. @@ -746,11 +746,11 @@ chkutf8:
  17. return CUTEF8_IS_INVALID;
  18. }
  19. // Check for surrogate chars
  20. - if (byt == 0xed && *pnt > 0x9f) {
  21. + if (byt == 0xed && *pnt >= 0xa0) {
  22. return CUTEF8_IS_INVALID;
  23. }
  24. // Check for overlong encoding
  25. - if (byt == 0xe0 && *pnt < 0xa0) {
  26. + if (byt < 0xe1 && *pnt < 0xa0) {
  27. return CUTEF8_IS_INVALID;
  28. }
  29. pnt += 2;
  30. @@ -759,15 +759,13 @@ chkutf8:
  31. if ((pnt + 2 >= pend) || isutf(*pnt) || isutf(pnt[1]) || isutf(pnt[2])) {
  32. return CUTEF8_IS_INVALID;
  33. }
  34. - // Make sure in correct range (0x10000 - 0x10ffff)
  35. - if (byt == 0xf0) {
  36. + // Make sure in correct range (0x10000 - 0x1fffff)
  37. + if (byt < 0xf1) {
  38. if (*pnt < 0x90) {
  39. return CUTEF8_IS_INVALID;
  40. }
  41. - } else if (byt == 0xf4) {
  42. - if (*pnt > 0x8f) {
  43. - return CUTEF8_IS_INVALID;
  44. - }
  45. + } else if (byt >= 0xf4 && (byt != 0xf4 || *pnt >= 0x90)) {
  46. + return CUTEF8_IS_INVALID;
  47. }
  48. pnt += 3;
  49. }
  50. diff --git a/fbink_cmd.c b/fbink_cmd.c
  51. index 01d8ce2..5bd0d4c 100644
  52. --- a/fbink_cmd.c
  53. +++ b/fbink_cmd.c
  54. @@ -1209,7 +1209,7 @@ int
  55. } else {
  56. while ((nread = getline(&line, &len, stdin)) != -1) {
  57. if ((linecnt = fbink_print(fbfd, line, &fbink_cfg)) < 0) {
  58. - fprintf(stderr, "Failed to print that string!\n");
  59. + fprintf(stderr, "Failed to print that string!\n%s\n", line);
  60. rv = ERRCODE(EXIT_FAILURE);
  61. }
  62. fbink_cfg.row = (short int) (fbink_cfg.row + linecnt);
Add Comment
Please, Sign In to add comment