diff options
author | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2008-05-12 10:36:44 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2008-05-12 10:42:20 -0700 |
commit | f9fae16456c30479b0cb9317e57200af36795785 (patch) | |
tree | 23ca76805b88b582e76b783ae6498290e06f68ee /hw | |
parent | ac4e33a9cd0ca2f0ec76181d11d5b90b82690c05 (diff) |
XQuartz: Added some version checking protection so we don't trigger an infinite exec loop with new /usr/X11/bin/Xquartz and older X11.app
(cherry picked from commit 78032815aeb10c22ff45b49702e9c9df82ab471c)
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xquartz/bundle/Info.plist | 4 | ||||
-rw-r--r-- | hw/xquartz/mach-startup/stub.c | 44 |
2 files changed, 37 insertions, 11 deletions
diff --git a/hw/xquartz/bundle/Info.plist b/hw/xquartz/bundle/Info.plist index 4b0830f0e..30bb3c891 100644 --- a/hw/xquartz/bundle/Info.plist +++ b/hw/xquartz/bundle/Info.plist @@ -20,6 +20,10 @@ <string>APPL</string> <key>CFBundleShortVersionString</key> <string>2.3.0</string> + <key>CFBundleVersion</key> + <string>2.3.0</string> + <key>CFBundleVersionString</key> + <string>2.3.0</string> <key>CFBundleSignature</key> <string>x11a</string> <key>CSResourcesFileMapped</key> diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c index 70f222c27..3be5f6568 100644 --- a/hw/xquartz/mach-startup/stub.c +++ b/hw/xquartz/mach-startup/stub.c @@ -43,33 +43,55 @@ static char x11_path[PATH_MAX + 1]; static void set_x11_path() { CFURLRef appURL = NULL; + CFBundleRef bundle = NULL; OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, nil, &appURL); - + UInt32 ver; + switch (osstatus) { case noErr: if (appURL == NULL) { - fprintf(stderr, "xinit: Invalid response from LSFindApplicationForInfo(%s)\n", + fprintf(stderr, "Xquartz: Invalid response from LSFindApplicationForInfo(%s)\n", kX11AppBundleId); exit(1); } - + + bundle = CFBundleCreate(NULL, appURL); + if(!bundle) { + fprintf(stderr, "Xquartz: Null value returned from CFBundleCreate().\n"); + exit(2); + } + if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) { - fprintf(stderr, "xinit: Error resolving URL for %s\n", kX11AppBundleId); - exit(2); + fprintf(stderr, "Xquartz: Error resolving URL for %s\n", kX11AppBundleId); + exit(3); } - + + ver = CFBundleGetVersionNumber(bundle); + if(ver < 0x02308000) { + CFStringRef versionStr = CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleVersionKey); + const char * versionCStr = "Unknown"; + + if(versionStr) + versionCStr = CFStringGetCStringPtr(versionStr, kCFStringEncodingMacRoman); + + fprintf(stderr, "Xquartz: Could not find a new enough X11.app LSFindApplicationForInfo() returned\n"); + fprintf(stderr, " X11.app = %s\n", x11_path); + fprintf(stderr, " Version = %s (%x), Expected Version > 2.3.0\n", versionCStr, (unsigned)ver); + exit(9); + } + strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path)); #ifdef DEBUG - fprintf(stderr, "XQuartz: X11.app = %s\n", x11_path); + fprintf(stderr, "Xquartz: X11.app = %s\n", x11_path); #endif break; case kLSApplicationNotFoundErr: - fprintf(stderr, "XQuartz: Unable to find application for %s\n", kX11AppBundleId); - exit(4); + fprintf(stderr, "Xquartz: Unable to find application for %s\n", kX11AppBundleId); + exit(10); default: - fprintf(stderr, "XQuartz: Unable to find application for %s, error code = %d\n", + fprintf(stderr, "Xquartz: Unable to find application for %s, error code = %d\n", kX11AppBundleId, (int)osstatus); - exit(5); + exit(11); } } |