Repository: electron/electron
Pull request: fix: possible crash in `shell.readShortcutLink` (35-x-y)

Manual backport of #46294 to 35-x-y. See that PR for details.

Notes: Fixed a possible crash in `shell.readShortcutLink`.

Changed files:
filename: patches/chromium/.patches
patch: @@ -140,7 +140,7 @@ feat_add_signals_when_embedder_cleanup_callbacks_run_for.patch
 feat_separate_content_settings_callback_for_sync_and_async_clipboard.patch
 cherry-pick-dd8e2822e507.patch
 fix_osr_stutter_in_both_cpu_and_gpu_capture_when_page_has_animation.patch
-ignore_parse_errors_for_pkey_appusermodel_toastactivatorclsid.patch
+ignore_parse_errors_for_resolveshortcutproperties.patch
 fix_win32_synchronous_spellcheck.patch
 fix_drag_and_drop_icons_on_windows.patch
 chore_remove_conflicting_allow_unsafe_libc_calls.patch

filename: patches/chromium/ignore_parse_errors_for_pkey_appusermodel_toastactivatorclsid.patch
patch: @@ -1,40 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?David=20L=C3=B6nnhager?= <dv.lnh.d@gmail.com>
-Date: Fri, 17 Jan 2025 14:30:48 +0100
-Subject: Ignore parse errors for PKEY_AppUserModel_ToastActivatorCLSID
-
-Some shortcuts store this as a string UUID as opposed to VT_CLSID,
-hitting NOTREACHED() and sometimes breaking parsing in Electron.
-Ignore this error instead.
-
-Bug: N/A
-Change-Id: I9fc472212b2d3afac2c8e18a2159bc2d50bbdf98
-
-diff --git a/AUTHORS b/AUTHORS
-index e96a3afdabc731afe355cda83eec4923ea780fec..0b1dc07aad197eab7b79344bc5aee702a2d580ab 100644
---- a/AUTHORS
-+++ b/AUTHORS
-@@ -340,6 +340,7 @@ David Futcher <david.mike.futcher@gmail.com>
- David Jin <davidjin@amazon.com>
- David Lechner <david@pybricks.com>
- David Leen <davileen@amazon.com>
-+David Lönnhager <dv.lnh.d@gmail.com>
- David Manouchehri <david@davidmanouchehri.com>
- David McAllister <mcdavid@amazon.com>
- David Michael Barr <david.barr@samsung.com>
-diff --git a/base/win/shortcut.cc b/base/win/shortcut.cc
-index 967e130e823f41c402411dfadb53b805e8a8c92b..3a9df7f31861ca69168fd24513ee554d0984798d 100644
---- a/base/win/shortcut.cc
-+++ b/base/win/shortcut.cc
-@@ -356,8 +356,9 @@ bool ResolveShortcutProperties(const FilePath& shortcut_path,
-               *(pv_toast_activator_clsid.get().puuid));
-           break;
-         default:
--          NOTREACHED() << "Unexpected variant type: "
--                       << pv_toast_activator_clsid.get().vt;
-+          // Shortcuts may use strings to represent the CLSID. This case is
-+          // ignored.
-+          break;
-       }
-     }
-   }

filename: patches/chromium/ignore_parse_errors_for_resolveshortcutproperties.patch
patch: @@ -0,0 +1,45 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?David=20L=C3=B6nnhager?= <dv.lnh.d@gmail.com>
+Date: Fri, 17 Jan 2025 14:30:48 +0100
+Subject: Ignore parse errors in ResolveShortcutProperties
+
+Some shortcuts store this as a string UUID as opposed to VT_CLSID,
+hitting NOTREACHED() and sometimes breaking parsing in Electron.
+Ignore this error instead.
+
+diff --git a/base/win/shortcut.cc b/base/win/shortcut.cc
+index 967e130e823f41c402411dfadb53b805e8a8c92b..c1cc95fa8993cc5bdab422710934fb6217272b96 100644
+--- a/base/win/shortcut.cc
++++ b/base/win/shortcut.cc
+@@ -317,7 +317,8 @@ bool ResolveShortcutProperties(const FilePath& shortcut_path,
+           break;
+         }
+         default: {
+-          NOTREACHED() << "Unexpected variant type: " << pv_app_id.get().vt;
++          LOG(WARNING) << "Unexpected variant type: " << pv_app_id.get().vt;
++          break;
+         }
+       }
+     }
+@@ -336,7 +337,8 @@ bool ResolveShortcutProperties(const FilePath& shortcut_path,
+           properties->set_dual_mode(pv_dual_mode.get().boolVal == VARIANT_TRUE);
+           break;
+         default:
+-          NOTREACHED() << "Unexpected variant type: " << pv_dual_mode.get().vt;
++          LOG(WARNING) << "Unexpected variant type: " << pv_dual_mode.get().vt;
++          break;
+       }
+     }
+ 
+@@ -356,8 +358,9 @@ bool ResolveShortcutProperties(const FilePath& shortcut_path,
+               *(pv_toast_activator_clsid.get().puuid));
+           break;
+         default:
+-          NOTREACHED() << "Unexpected variant type: "
+-                       << pv_toast_activator_clsid.get().vt;
++          LOG(INFO) << "Unexpected variant type: "
++                    << pv_toast_activator_clsid.get().vt;
++          break;
+       }
+     }
+   }