|
From: Patrick H. <pa...@pa...> - 2001-06-20 12:39:16
|
Hello,
I, too, just subscribed a few days ago, and there doesn't seem to be
much traffic on the list. And it appears that it filters attachments
out, so I'll include code directly.
For Find support, I've added the code listed below after my .sig.
Also, there is a security hole in keyring-0.75 and keyring-1.0.
The snib is not completely destroyed and may be used by a hacked
version of gnukeyring. If you want to try it, either compile 1.0 or
earlier after commenting out the passwd check and run it on a palmos
that has 1.0 or earlier on it. You'll be able to get into all the data.
This is also available at:
http://haller.ws/~hallerp/palm/gKey/keyring-haq0r
Patrick.
+--
Patrick Haller +1 717 249 7270
Network Administrator PAdotNET http://www.pa.net
#include <PalmOS.h>
#include <Password.h>
#include <Encrypt.h>
#include "resource.h"
#include "keyring.h"
#include "keydb.h"
#include "passwd.h"
#include "uiutil.h"
#include "upgrade.h"
#include "keyedit.h"
#include "crypto.h"
#include "search.h"
#include "error.h"
#include "auto.h"
static void DrawMemoTitle (Char * memo, Int16 x, Int16 y, Int16 width)
{
Char * ptr = StrChr (memo, linefeedChr);
Int16 titleLen = (ptr == NULL ? StrLen (memo) : (Int16) (ptr - memo));
if (FntWidthToOffset (memo, titleLen, width, NULL, NULL) == titleLen)
{
WinDrawChars (memo, titleLen, x, y);
}
else
{
Int16 titleWidth;
titleLen = FntWidthToOffset (memo, titleLen,
width - FntCharWidth (chrEllipsis), NULL, &titleWidth);
WinDrawChars (memo, titleLen, x, y);
WinDrawChar (chrEllipsis, x + titleWidth, y);
}
}
void sleep(UInt16 time){
UInt16 i = 0;
time = time * 10000000;
for(i=0;i<time;i++){
time++;
time--;
}
}
void Search(FindParamsPtr findParams){
UInt16 numRecs = 0;
UInt16 idx = 0;
UInt16 cardNo = 0;
UInt16 attr = 0;
MemHandle recHand;
void *recPtr;
Err err;
RectangleType r;
char scrStr[20];
char haystack[20];
char needle[20];
Int16 badoutput = 0;
LocalID appID;
DmSearchStateType state;
err = DmGetNextDatabaseByTypeCreator(true, &state, kKeyDBType,
kKeyringCreatorID, true,
&cardNo,
&appID);
// Open the database to be searched.
if( (gKeyDB = DmOpenDatabase(cardNo, appID,
findParams->dbAccesMode)) != 0 ){
FindDrawHeader(findParams, "GNU Keyring");
StrToLower(needle, findParams->strAsTyped); // for some reason
strToFind yields gibberish.
numRecs = DmNumRecords(gKeyDB);
// Get first record to search.
for (idx = kNumHiddenRecs; idx < numRecs; idx++) {
Boolean done = false;
if(StrLen(needle) < 4){ //give up if we don't have enough
chars.
break;
}
if ((idx & 0x000f) == 0 && EvtSysEventAvail(true)){
// Stop the search process.
findParams->more = false;
break;
}
err = DmRecordInfo(gKeyDB, idx, &attr, NULL, NULL);
ErrFatalDisplayIf(err, "DmRecordInfo");
recHand = DmQueryNextInCategory(gKeyDB, &idx, dmAllCategories);
if (!recHand) {
findParams->more = false;
badoutput++;
continue;
}
recPtr = MemHandleLock(recHand);
if(!recPtr){
StrCopy(scrStr, "<no-ptr>");
continue;
}
StrNCopy(scrStr, recPtr, 19);
scrStr[19] = '\0';
StrToLower(haystack, scrStr);
if( StrStr(haystack, needle) != NULL ){
done = FindSaveMatch (findParams,
idx, 0, 0, 0,
cardNo, gKeyDBID);
// Display the title of the description.
FindGetLineBounds (findParams, &r);
DrawMemoTitle (haystack, r.topLeft.x+1, r.topLeft.y,
r.extent.x-2);
//DrawMemoTitle (haystack, r.topLeft.x+1, r.topLeft.y,
StrLen(haystack));
//DrawCharsToFitWidth(haystack, &r);
//FindDrawHeader(findParams, haystack);
findParams->lineNumber++;
}
MemHandleUnlock(recHand);
if (done) break;
if (badoutput > 10) break;
}
DmCloseDatabase (gKeyDB);
}
}
void GoToItem (GoToParamsPtr goToParams, Boolean isCurrentApp){
UInt16 recordNum = 1;
UInt16 attr;
UInt32 uniqueID;
Err err;
if(isCurrentApp == false){
App_LoadPrefs();
SysRandom(TimGetTicks() ^ SysRandom(0));
Gkr_CheckBeta();
if ((err = Snib_Init()))
ErrDisplay("Snib_Init failed");
if ((err = Keyring_PrepareDB()))
Snib_Close();
recordNum = goToParams->recordNum;
DmRecordInfo (gKeyDB, recordNum, &attr, &uniqueID, NULL);
//gPrefs.category = attr & dmRecAttrCategoryMask;
gPrefs.category = dmAllCategories;
if (Unlock_CheckTimeout() || UnlockForm_Run()) {
KeyEditForm_GotoRecord(recordNum);
FrmGotoForm(KeyEditForm);
//maybe make an event?
}
App_EventLoop();
App_Stop();
}
if(isCurrentApp == true){
ErrDisplay("Sorry. We don't support Finds from within the GNU
Keyring.");
FrmCloseAllForms();
FrmGotoForm(ListForm);
//FrmSetActiveForm(ListForm);
if (Unlock_CheckTimeout() || UnlockForm_Run()) {
KeyEditForm_GotoRecord(recordNum);
FrmGotoForm(KeyEditForm);
//maybe make an event?
}
}
}
|