Media Object Insert

KSK

KSK

Well Known Member
HI All,

I am trying to insert data into Media Object file with custom Audit information(UPMJ,USER,UPMT from BSFN DataStructure)but the system is not allowing me to override the Audit information ..During the execution of jdeGT_InsertDataKeyStr API, it is picking the current login user id, time and date (not with the Audit information passed inside the “lpds”)

Please guide me on the solution.




JDBReturn = JDB_InitBhvr(lpBhvrCom, &hUser,(JCHAR *) NULL,
JDEDB_COMMIT_AUTO);
JDBReturn = jdeGT_OpenTable (hUser,NULL,lpDS->szNameObject, &hRequestGT);

jdeStripTrailingBlanks(lpDS->szGenericTextKey);

lpGTData.nSeq = lpDS->nMediaObjectSequenceNumber;
lpGTData.nMOType = OBJ_RTFTEXT;
lpGTData.pData = lpDS->szMessageText;
jdeStrcpy(lpGTData.szItemName, _J("New Text"));

jdeStrncpy(lpGTData.szUser,lpDS->szUserId,sizeof(lpDS->szUserId));
MathCopy(&lpGTData.mnTime,&lpDS->mnTimeLastUpdated );
memcpy((void *)(&lpGTData.jdDate), (const void *)(&lpDS->jdDateUpdated),
sizeof(lpGTData.jdDate));


JDBReturn =jdeGT_InsertDataKeyStr(hRequestGT, lpDS->szNameObject, lpDS->szGenericTextKey,1, szLang, &lpGTData);
 
Just let the system do it using your code above, then just use the same GT key to go and update the audit fields yourself immediately afterwards using table I/O....?
 
HI John,

I have tried in the similar way(Table IO) but once out of every five transaction application is ending with JAS errors .So I am trying for an alternative solution.
 
[ QUOTE ]
jdeStrncpy(lpGTData.szUser,lpDS->szUserId,sizeof(lpDS->szUserId));


[/ QUOTE ]

That line of code is a buffer overflow. The last parm should be DIM(lpDS->szUserId)-1. sizeof will return the number of bytes but jdeStrncpy expects the number of characters and with Unicode characters (JCHAR) are 2 bytes.

Craig
 
Back
Top