From 2844e2834e2e1823389e88ecaea9c6aa752f9e63 Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 4 Sep 2024 21:00:06 +0200 Subject: [PATCH] Check for the return value of prfxpathPos https://github.com/probonopd/go-appimage/issues/300#issuecomment-2328288496 Thanks @kevle --- src/appimagetool/appdirtool.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/appimagetool/appdirtool.go b/src/appimagetool/appdirtool.go index ff4ed54..01c1ef2 100644 --- a/src/appimagetool/appdirtool.go +++ b/src/appimagetool/appdirtool.go @@ -511,7 +511,12 @@ func patchQtPrfxpath(appdir helpers.AppDir, lib string, libraryLocationsInAppDir f.Seek(0, 0) // Search from the beginning of the file search := []byte("qt_prfxpath=") - offset := ScanFile(f, search) + int64(len(search)) + prfxpathPos := ScanFile(f, search) + if prfxpathPos < 0 { + helpers.PrintError("Could not find offset for " + string(search), errors.New("no " + string(search) + " token in binary")) + os.Exit(1) + } + offset := prfxpathPos + int64(len(search)) log.Println("Offset of qt_prfxpath:", offset) /* What does qt_prfxpath=. actually mean on a Linux system? Where is "."?