wordpad: Refuse to load OLE compound storage files like Windows does. Try 2

Dmitry Timoshkov dmitry at codeweavers.com
Tue Oct 16 08:07:31 CDT 2007


Hello,

this version of the patch simply checks the file signature instead of trying
to open it as an OLE storage.

Wordpad from Windows XP pops up a MessageBox stating that Word for Windows
files are not supported when somebody tries to open a .doc file.

This patch should fix the bug 9196.

Changelog:
    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(+), 0 deletions(-)

diff --git a/programs/wordpad/De.rc b/programs/wordpad/De.rc
index 1b333fd..7175fa7 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 e0724fb..a14ec7f 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 dcf80ec..2448c3c 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 feca301..7b72a7f 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 7ec919e..800f2cf 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 d6c5346..04042d8 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 3bebdf9..0c203ed 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 3b05326..3ed7e81 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 17828cc..3eaf438 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 65cb31f..b3463f0 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 2c2cc98..130eb94 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 5e1d0dc..2d24d33 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 char 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;
-- 
1.5.3.4






More information about the wine-patches mailing list