fix EventLogRecord.stringData

This commit is contained in:
Doug MacEachern 2005-09-23 02:31:43 +00:00
parent f0d6eba45d
commit 288bd907f2

View File

@ -43,8 +43,8 @@ static HANDLE win32_get_pointer(JNIEnv *env, jobject obj)
static int get_messagefile_dll(const char *app, char *source, char *dllfile) static int get_messagefile_dll(const char *app, char *source, char *dllfile)
{ {
HKEY hk; HKEY hk;
DWORD type, data;
char buf[MAX_MSG_LENGTH]; char buf[MAX_MSG_LENGTH];
DWORD type, data = sizeof(buf);
LONG rc; LONG rc;
sprintf(buf, "%s%s\\%s", REG_MSGFILE_ROOT, app, source); sprintf(buf, "%s%s\\%s", REG_MSGFILE_ROOT, app, source);
@ -60,7 +60,7 @@ static int get_messagefile_dll(const char *app, char *source, char *dllfile)
return rc; return rc;
} }
strncpy(dllfile, buf, sizeof(dllfile)); strncpy(dllfile, buf, MAX_MSG_LENGTH);
RegCloseKey(hk); RegCloseKey(hk);
@ -99,7 +99,7 @@ static int get_formatted_message(EVENTLOGRECORD *pevlr, char *dllfile,
MAX_MSG_LENGTH, MAX_MSG_LENGTH,
insert_strs); insert_strs);
strncpy(msg, msgbuf, sizeof(msg)); strncpy(msg, msgbuf, MAX_MSG_LENGTH);
FreeLibrary(hlib); FreeLibrary(hlib);
LocalFree((HLOCAL)msgbuf); LocalFree((HLOCAL)msgbuf);
@ -169,7 +169,7 @@ JNIEXPORT jobject SIGAR_JNI(win32_EventLog_readlog)
{ {
EVENTLOGRECORD *pevlr; EVENTLOGRECORD *pevlr;
BYTE buffer[8192]; BYTE buffer[8192];
char dllfile[1024]; char dllfile[MAX_MSG_LENGTH];
char msg[MAX_MSG_LENGTH]; char msg[MAX_MSG_LENGTH];
DWORD dwRead, dwNeeded; DWORD dwRead, dwNeeded;
LPSTR source, machineName; LPSTR source, machineName;