From 6b8ee0e41f0333de11cf837b21fba580a641c0f6 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Tue, 16 Oct 2007 22:07:31 +0900 Subject: [PATCH] wordpad: Refuse to load OLE compound storage files like Windows does. --- programs/wordpad/De.rc | 1 + programs/wordpad/En.rc | 1 + programs/wordpad/Fr.rc | 1 + programs/wordpad/Hu.rc | 1 + programs/wordpad/Ko.rc | 1 + programs/wordpad/Nl.rc | 1 + programs/wordpad/No.rc | 1 + programs/wordpad/Pl.rc | 1 + programs/wordpad/Ru.rc | 1 + programs/wordpad/Tr.rc | 1 + programs/wordpad/resource.h | 1 + programs/wordpad/wordpad.c | 9 +++++++++ 12 files changed, 20 insertions(+) diff --git a/programs/wordpad/De.rc b/programs/wordpad/De.rc index 1b333fd4f4d..7175fa7b3bf 100644 --- a/programs/wordpad/De.rc +++ b/programs/wordpad/De.rc @@ -229,4 +229,5 @@ BEGIN "which will cause all formatting to be lost. " \ "Are you sure that you wish to do this?" STRING_INVALID_NUMBER, "Invalid number format" + STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported" END diff --git a/programs/wordpad/En.rc b/programs/wordpad/En.rc index e0724fb7fcf..a14ec7f6611 100644 --- a/programs/wordpad/En.rc +++ b/programs/wordpad/En.rc @@ -229,4 +229,5 @@ BEGIN "which will cause all formatting to be lost. " \ "Are you sure that you wish to do this?" STRING_INVALID_NUMBER, "Invalid number format" + STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported" END diff --git a/programs/wordpad/Fr.rc b/programs/wordpad/Fr.rc index dcf80ecfeea..2448c3c53d9 100644 --- a/programs/wordpad/Fr.rc +++ b/programs/wordpad/Fr.rc @@ -229,4 +229,5 @@ BEGIN "which will cause all formatting to be lost. " \ "Are you sure that you wish to do this?" STRING_INVALID_NUMBER, "Invalid number format" + STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported" END diff --git a/programs/wordpad/Hu.rc b/programs/wordpad/Hu.rc index feca301d8c9..7b72a7fe549 100644 --- a/programs/wordpad/Hu.rc +++ b/programs/wordpad/Hu.rc @@ -229,4 +229,5 @@ BEGIN "which will cause all formatting to be lost. " \ "Are you sure that you wish to do this?" STRING_INVALID_NUMBER, "Invalid number format" + STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported" END diff --git a/programs/wordpad/Ko.rc b/programs/wordpad/Ko.rc index 7ec919ee3b1..800f2cf466a 100644 --- a/programs/wordpad/Ko.rc +++ b/programs/wordpad/Ko.rc @@ -223,4 +223,5 @@ BEGIN "ÀÌ°ÍÀº Ư¼öÇÑ ²Ù¹ÒÀ» ¾ø¿¤ °ÍÀÔ´Ï´Ù. " \ "´ç½ÅÀº Á¤¸»·Î ÀúÀåÇϱ⸦ ¿øÇմϱî?" STRING_INVALID_NUMBER, "¿Ã¹Ù¸£Áö ¾ÊÀº ¼ö Çü½Ä" + STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported" END diff --git a/programs/wordpad/Nl.rc b/programs/wordpad/Nl.rc index d6c5346b11b..04042d8aa64 100644 --- a/programs/wordpad/Nl.rc +++ b/programs/wordpad/Nl.rc @@ -229,4 +229,5 @@ BEGIN "which will cause all formatting to be lost. " \ "Are you sure that you wish to do this?" STRING_INVALID_NUMBER, "Invalid number format" + STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported" END diff --git a/programs/wordpad/No.rc b/programs/wordpad/No.rc index 3bebdf9e7b0..0c203ed63f3 100644 --- a/programs/wordpad/No.rc +++ b/programs/wordpad/No.rc @@ -229,4 +229,5 @@ BEGIN "vil føre til at all formatering går tapt. Er du " \ "sikker på at du vil fortsette?" STRING_INVALID_NUMBER, "Ugyldig tallformat" + STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported" END diff --git a/programs/wordpad/Pl.rc b/programs/wordpad/Pl.rc index 3b05326748b..3ed7e81ca51 100644 --- a/programs/wordpad/Pl.rc +++ b/programs/wordpad/Pl.rc @@ -230,4 +230,5 @@ BEGIN "which will cause all formatting to be lost. " \ "Are you sure that you wish to do this?" STRING_INVALID_NUMBER, "Invalid number format" + STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported" END diff --git a/programs/wordpad/Ru.rc b/programs/wordpad/Ru.rc index 17828cc3900..3eaf4386397 100644 --- a/programs/wordpad/Ru.rc +++ b/programs/wordpad/Ru.rc @@ -228,4 +228,5 @@ BEGIN "which will cause all formatting to be lost. " \ "Are you sure that you wish to do this?" STRING_INVALID_NUMBER, "Invalid number format" + STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported" END diff --git a/programs/wordpad/Tr.rc b/programs/wordpad/Tr.rc index 65cb31f9b2e..b3463f0c0c8 100644 --- a/programs/wordpad/Tr.rc +++ b/programs/wordpad/Tr.rc @@ -232,4 +232,5 @@ BEGIN "which will cause all formatting to be lost. " \ "Are you sure that you wish to do this?" STRING_INVALID_NUMBER, "Invalid number format" + STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported" END diff --git a/programs/wordpad/resource.h b/programs/wordpad/resource.h index 2c2cc986f06..130eb94b47c 100644 --- a/programs/wordpad/resource.h +++ b/programs/wordpad/resource.h @@ -180,3 +180,4 @@ #define STRING_LOAD_RICHED_FAILED 1703 #define STRING_SAVE_LOSEFORMATTING 1704 #define STRING_INVALID_NUMBER 1705 +#define STRING_OLE_STORAGE_NOT_SUPPORTED 1706 diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c index 5e1d0dc5df6..a117a756f5d 100644 --- a/programs/wordpad/wordpad.c +++ b/programs/wordpad/wordpad.c @@ -1092,8 +1092,17 @@ static void DoOpenFile(LPCWSTR szOpenFileName) } else if(readOut >= 5) { static const char header[] = "{\\rtf"; + static const BYTE STG_magic[] = { 0xd0,0xcf,0x11,0xe0 }; + if(!memcmp(header, fileStart, 5)) format = SF_RTF; + else if (!memcmp(STG_magic, fileStart, sizeof(STG_magic))) + { + CloseHandle(hFile); + MessageBoxW(hMainWnd, MAKEINTRESOURCEW(STRING_OLE_STORAGE_NOT_SUPPORTED), wszAppTitle, + MB_OK | MB_ICONEXCLAMATION); + return; + } } es.dwCookie = (DWORD_PTR)hFile;