Changeset 82279 in vbox for trunk/src/VBox/GuestHost/SharedClipboard
- Timestamp:
- Nov 29, 2019 11:42:20 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 135103
- Location:
- trunk/src/VBox/GuestHost/SharedClipboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp
r81444 r82279 464 464 /** @todo convert the remainder of the Assert stuff to AssertLogRel. */ 465 465 /* We only take little endian Utf16 */ 466 if (pwszSrc[0] == UTF16BEMARKER)467 { 468 LogRel((" vboxClipboardUtf16GetWinSize: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));469 AssertReturn(pwszSrc[0] != UTF16BEMARKER, VERR_INVALID_PARAMETER);466 if (pwszSrc[0] == VBOX_SHCL_UTF16BEMARKER) 467 { 468 LogRel(("Shared Clipboard: vboxClipboardUtf16GetWinSize: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n")); 469 AssertReturn(pwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, VERR_INVALID_PARAMETER); 470 470 } 471 471 cwDest = 0; 472 472 /* Calculate the size of the destination text string. */ 473 473 /* Is this Utf16 or Utf16-LE? */ 474 for (i = (pwszSrc[0] == UTF16LEMARKER ? 1 : 0); i < cwSrc; ++i, ++cwDest)474 for (i = (pwszSrc[0] == VBOX_SHCL_UTF16LEMARKER ? 1 : 0); i < cwSrc; ++i, ++cwDest) 475 475 { 476 476 /* Check for a single line feed */ 477 if (pwszSrc[i] == LINEFEED)477 if (pwszSrc[i] == VBOX_SHCL_LINEFEED) 478 478 ++cwDest; 479 479 #ifdef RT_OS_DARWIN 480 480 /* Check for a single carriage return (MacOS) */ 481 if (pwszSrc[i] == CARRIAGERETURN)481 if (pwszSrc[i] == VBOX_SHCL_CARRIAGERETURN) 482 482 ++cwDest; 483 483 #endif … … 501 501 if (!VALID_PTR(pwszSrc) || !VALID_PTR(pu16Dest)) 502 502 { 503 LogRel((" vboxClipboardUtf16LinToWin: received an invalid pointer, pwszSrc=%p, pu16Dest=%p, returning VERR_INVALID_PARAMETER\n", pwszSrc, pu16Dest));503 LogRel(("Shared Clipboard: vboxClipboardUtf16LinToWin: received an invalid pointer, returning VERR_INVALID_PARAMETER\n")); 504 504 AssertReturn(VALID_PTR(pwszSrc) && VALID_PTR(pu16Dest), VERR_INVALID_PARAMETER); 505 505 } … … 516 516 } 517 517 /* We only take little endian Utf16 */ 518 if (pwszSrc[0] == UTF16BEMARKER)519 { 520 LogRel((" vboxClipboardUtf16LinToWin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));521 AssertReturn(pwszSrc[0] != UTF16BEMARKER, VERR_INVALID_PARAMETER);518 if (pwszSrc[0] == VBOX_SHCL_UTF16BEMARKER) 519 { 520 LogRel(("Shared Clipboard: vboxClipboardUtf16LinToWin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n")); 521 AssertReturn(pwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, VERR_INVALID_PARAMETER); 522 522 } 523 523 /* Don't copy the endian marker. */ 524 for (i = (pwszSrc[0] == UTF16LEMARKER ? 1 : 0), j = 0; i < cwSrc; ++i, ++j)524 for (i = (pwszSrc[0] == VBOX_SHCL_UTF16LEMARKER ? 1 : 0), j = 0; i < cwSrc; ++i, ++j) 525 525 { 526 526 /* Don't copy the null byte, as we add it below. */ … … 532 532 return VERR_BUFFER_OVERFLOW; 533 533 } 534 if (pwszSrc[i] == LINEFEED)535 { 536 pu16Dest[j] = CARRIAGERETURN;534 if (pwszSrc[i] == VBOX_SHCL_LINEFEED) 535 { 536 pu16Dest[j] = VBOX_SHCL_CARRIAGERETURN; 537 537 ++j; 538 538 if (j == cwDest) … … 544 544 #ifdef RT_OS_DARWIN 545 545 /* Check for a single carriage return (MacOS) */ 546 else if (pwszSrc[i] == CARRIAGERETURN)546 else if (pwszSrc[i] == VBOX_SHCL_CARRIAGERETURN) 547 547 { 548 548 /* set cr */ 549 pu16Dest[j] = CARRIAGERETURN;549 pu16Dest[j] = VBOX_SHCL_CARRIAGERETURN; 550 550 ++j; 551 551 if (j == cwDest) … … 555 555 } 556 556 /* add the lf */ 557 pu16Dest[j] = LINEFEED;557 pu16Dest[j] = VBOX_SHCL_LINEFEED; 558 558 continue; 559 559 } … … 579 579 if (!VALID_PTR(pwszSrc)) 580 580 { 581 LogRel((" vboxClipboardUtf16GetLinSize: received an invalid Utf16 string %p. Returning VERR_INVALID_PARAMETER.\n", pwszSrc));581 LogRel(("Shared Clipboard: vboxClipboardUtf16GetLinSize: received an invalid Utf16 string, returning VERR_INVALID_PARAMETER\n")); 582 582 AssertReturn(VALID_PTR(pwszSrc), VERR_INVALID_PARAMETER); 583 583 } … … 589 589 } 590 590 /* We only take little endian Utf16 */ 591 if (pwszSrc[0] == UTF16BEMARKER)592 { 593 LogRel((" vboxClipboardUtf16GetLinSize: received a big endian Utf16 string. Returning VERR_INVALID_PARAMETER.\n"));594 AssertReturn(pwszSrc[0] != UTF16BEMARKER, VERR_INVALID_PARAMETER);591 if (pwszSrc[0] == VBOX_SHCL_UTF16BEMARKER) 592 { 593 LogRel(("Shared Clipboard: vboxClipboardUtf16GetLinSize: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n")); 594 AssertReturn(pwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, VERR_INVALID_PARAMETER); 595 595 } 596 596 /* Calculate the size of the destination text string. */ 597 597 /* Is this Utf16 or Utf16-LE? */ 598 if (pwszSrc[0] == UTF16LEMARKER)598 if (pwszSrc[0] == VBOX_SHCL_UTF16LEMARKER) 599 599 cwDest = 0; 600 600 else … … 603 603 { 604 604 if ( (i + 1 < cwSrc) 605 && (pwszSrc[i] == CARRIAGERETURN)606 && (pwszSrc[i + 1] == LINEFEED))605 && (pwszSrc[i] == VBOX_SHCL_CARRIAGERETURN) 606 && (pwszSrc[i + 1] == VBOX_SHCL_LINEFEED)) 607 607 { 608 608 ++i; … … 630 630 if (!VALID_PTR(pwszSrc) || !VALID_PTR(pu16Dest)) 631 631 { 632 LogRel((" vboxClipboardUtf16WinToLin: received an invalid ptr, pwszSrc=%p, pu16Dest=%p, returning VERR_INVALID_PARAMETER\n", pwszSrc, pu16Dest));632 LogRel(("Shared Clipboard: vboxClipboardUtf16WinToLin: received an invalid pointer, returning VERR_INVALID_PARAMETER\n")); 633 633 AssertReturn(VALID_PTR(pwszSrc) && VALID_PTR(pu16Dest), VERR_INVALID_PARAMETER); 634 634 } 635 635 /* We only take little endian Utf16 */ 636 if (pwszSrc[0] == UTF16BEMARKER)637 { 638 LogRel((" vboxClipboardUtf16WinToLin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));636 if (pwszSrc[0] == VBOX_SHCL_UTF16BEMARKER) 637 { 638 LogRel(("Shared Clipboard: vboxClipboardUtf16WinToLin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n")); 639 639 AssertMsgFailedReturn(("received a big endian string\n"), VERR_INVALID_PARAMETER); 640 640 } … … 651 651 } 652 652 /* Prepend the Utf16 byte order marker if it is missing. */ 653 if (pwszSrc[0] == UTF16LEMARKER)653 if (pwszSrc[0] == VBOX_SHCL_UTF16LEMARKER) 654 654 { 655 655 cwDestPos = 0; … … 657 657 else 658 658 { 659 pu16Dest[0] = UTF16LEMARKER;659 pu16Dest[0] = VBOX_SHCL_UTF16LEMARKER; 660 660 cwDestPos = 1; 661 661 } … … 672 672 } 673 673 if ( (i + 1 < cwSrc) 674 && (pwszSrc[i] == CARRIAGERETURN)675 && (pwszSrc[i + 1] == LINEFEED))674 && (pwszSrc[i] == VBOX_SHCL_CARRIAGERETURN) 675 && (pwszSrc[i + 1] == VBOX_SHCL_LINEFEED)) 676 676 { 677 677 ++i; … … 704 704 /** @todo Support all the many versions of the DIB headers. */ 705 705 if ( cbSrc < sizeof(BMINFOHEADER) 706 || RT_LE2H_U32(pBitmapInfoHeader->u 32Size) < sizeof(BMINFOHEADER)707 || RT_LE2H_U32(pBitmapInfoHeader->u 32Size) != sizeof(BMINFOHEADER))708 { 709 Log(("vboxClipboardDibToBmp: invalid or unsupported bitmap data .\n"));706 || RT_LE2H_U32(pBitmapInfoHeader->uSize) < sizeof(BMINFOHEADER) 707 || RT_LE2H_U32(pBitmapInfoHeader->uSize) != sizeof(BMINFOHEADER)) 708 { 709 Log(("vboxClipboardDibToBmp: invalid or unsupported bitmap data\n")); 710 710 return VERR_INVALID_PARAMETER; 711 711 } 712 712 713 713 offPixel = sizeof(BMFILEHEADER) 714 + RT_LE2H_U32(pBitmapInfoHeader->u 32Size)715 + RT_LE2H_U32(pBitmapInfoHeader->u 32ClrUsed) * sizeof(uint32_t);714 + RT_LE2H_U32(pBitmapInfoHeader->uSize) 715 + RT_LE2H_U32(pBitmapInfoHeader->uClrUsed) * sizeof(uint32_t); 716 716 if (cbSrc < offPixel) 717 717 { 718 Log(("vboxClipboardDibToBmp: invalid bitmap data .\n"));718 Log(("vboxClipboardDibToBmp: invalid bitmap data\n")); 719 719 return VERR_INVALID_PARAMETER; 720 720 } … … 723 723 if (!pvDest) 724 724 { 725 Log(("writeToPasteboard: cannot allocate memory for bitmap .\n"));725 Log(("writeToPasteboard: cannot allocate memory for bitmap\n")); 726 726 return VERR_NO_MEMORY; 727 727 } 728 728 729 729 pFileHeader = (PBMFILEHEADER)pvDest; 730 pFileHeader->u 16Type = BITMAPHEADERMAGIC;731 pFileHeader->u 32Size = (uint32_t)RT_H2LE_U32(cb);732 pFileHeader->u 16Reserved1 = pFileHeader->u16Reserved2 = 0;733 pFileHeader->u 32OffBits = (uint32_t)RT_H2LE_U32(offPixel);730 pFileHeader->uType = BITMAPHEADERMAGIC; 731 pFileHeader->uSize = (uint32_t)RT_H2LE_U32(cb); 732 pFileHeader->uReserved1 = pFileHeader->uReserved2 = 0; 733 pFileHeader->uOffBits = (uint32_t)RT_H2LE_U32(offPixel); 734 734 memcpy((uint8_t *)pvDest + sizeof(BMFILEHEADER), pvSrc, cbSrc); 735 735 *ppvDest = pvDest; … … 746 746 PBMFILEHEADER pFileHeader = (PBMFILEHEADER)pvSrc; 747 747 if ( cbSrc < sizeof(BMFILEHEADER) 748 || pFileHeader->u 16Type != BITMAPHEADERMAGIC749 || RT_LE2H_U32(pFileHeader->u 32Size) != cbSrc)750 { 751 Log(("vboxClipboardBmpGetDib: invalid bitmap data .\n"));748 || pFileHeader->uType != BITMAPHEADERMAGIC 749 || RT_LE2H_U32(pFileHeader->uSize) != cbSrc) 750 { 751 Log(("vboxClipboardBmpGetDib: invalid bitmap data\n")); 752 752 return VERR_INVALID_PARAMETER; 753 753 } … … 787 787 } 788 788 789 void ShClDbgDumpData(const void *pv, size_t cb, SHCLFORMAT u 32Format)790 { 791 if (u 32Format & VBOX_SHCL_FMT_UNICODETEXT)789 void ShClDbgDumpData(const void *pv, size_t cb, SHCLFORMAT uFormat) 790 { 791 if (uFormat & VBOX_SHCL_FMT_UNICODETEXT) 792 792 { 793 793 LogFunc(("VBOX_SHCL_FMT_UNICODETEXT:\n")); … … 797 797 LogFunc(("%p %zu\n", pv, cb)); 798 798 } 799 else if (u 32Format & VBOX_SHCL_FMT_BITMAP)799 else if (uFormat & VBOX_SHCL_FMT_BITMAP) 800 800 LogFunc(("VBOX_SHCL_FMT_BITMAP\n")); 801 else if (u 32Format & VBOX_SHCL_FMT_HTML)801 else if (uFormat & VBOX_SHCL_FMT_HTML) 802 802 { 803 803 LogFunc(("VBOX_SHCL_FMT_HTML:\n")); … … 822 822 } 823 823 else 824 LogFunc(("Invalid format %02X\n", u 32Format));824 LogFunc(("Invalid format %02X\n", uFormat)); 825 825 } 826 826 #endif /* LOG_ENABLED */ -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
r82266 r82279 1854 1854 for (unsigned i = 0; i < cbSrc && pcSrc[i] != '\0'; ++i) 1855 1855 { 1856 if (pcSrc[i] == LINEFEED)1856 if (pcSrc[i] == VBOX_SHCL_LINEFEED) 1857 1857 cwcDest += 2; 1858 1858 else … … 1875 1875 for (unsigned i = 0, j = 0; i < cbSrc; ++i, ++j) 1876 1876 { 1877 if (pcSrc[i] != LINEFEED)1877 if (pcSrc[i] != VBOX_SHCL_LINEFEED) 1878 1878 pwszDest[j] = pcSrc[i]; 1879 1879 else 1880 1880 { 1881 pwszDest[j] = CARRIAGERETURN;1882 pwszDest[j + 1] = LINEFEED;1881 pwszDest[j] = VBOX_SHCL_CARRIAGERETURN; 1882 pwszDest[j + 1] = VBOX_SHCL_LINEFEED; 1883 1883 ++j; 1884 1884 }
Note:
See TracChangeset
for help on using the changeset viewer.