Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/cutef8/utf8.c b/cutef8/utf8.c
- index 9adbe81..e30ed07 100644
- --- a/cutef8/utf8.c
- +++ b/cutef8/utf8.c
- @@ -732,8 +732,8 @@ chkutf8:
- return CUTEF8_IS_INVALID; // Last byte can't be > 127
- }
- byt = pnt[-1];
- - // Must be between 0xc2 and 0xf4 inclusive to be valid
- - if (((uint32_t) byt - 0xc2) > (0xf4 - 0xc2)) {
- + // Range check: 0xc2 <= byte < 0xf8
- + if (((uint32_t) byt - 0xc2) >= (0xf8 - 0xc2)) {
- return CUTEF8_IS_INVALID;
- }
- if (byt < 0xe0) { // 2-byte sequence
- @@ -746,11 +746,11 @@ chkutf8:
- return CUTEF8_IS_INVALID;
- }
- // Check for surrogate chars
- - if (byt == 0xed && *pnt > 0x9f) {
- + if (byt == 0xed && *pnt >= 0xa0) {
- return CUTEF8_IS_INVALID;
- }
- // Check for overlong encoding
- - if (byt == 0xe0 && *pnt < 0xa0) {
- + if (byt < 0xe1 && *pnt < 0xa0) {
- return CUTEF8_IS_INVALID;
- }
- pnt += 2;
- @@ -759,15 +759,13 @@ chkutf8:
- if ((pnt + 2 >= pend) || isutf(*pnt) || isutf(pnt[1]) || isutf(pnt[2])) {
- return CUTEF8_IS_INVALID;
- }
- - // Make sure in correct range (0x10000 - 0x10ffff)
- - if (byt == 0xf0) {
- + // Make sure in correct range (0x10000 - 0x1fffff)
- + if (byt < 0xf1) {
- if (*pnt < 0x90) {
- return CUTEF8_IS_INVALID;
- }
- - } else if (byt == 0xf4) {
- - if (*pnt > 0x8f) {
- - return CUTEF8_IS_INVALID;
- - }
- + } else if (byt >= 0xf4 && (byt != 0xf4 || *pnt >= 0x90)) {
- + return CUTEF8_IS_INVALID;
- }
- pnt += 3;
- }
- diff --git a/fbink_cmd.c b/fbink_cmd.c
- index 01d8ce2..5bd0d4c 100644
- --- a/fbink_cmd.c
- +++ b/fbink_cmd.c
- @@ -1209,7 +1209,7 @@ int
- } else {
- while ((nread = getline(&line, &len, stdin)) != -1) {
- if ((linecnt = fbink_print(fbfd, line, &fbink_cfg)) < 0) {
- - fprintf(stderr, "Failed to print that string!\n");
- + fprintf(stderr, "Failed to print that string!\n%s\n", line);
- rv = ERRCODE(EXIT_FAILURE);
- }
- fbink_cfg.row = (short int) (fbink_cfg.row + linecnt);
Add Comment
Please, Sign In to add comment