mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-31 10:58:49 +00:00
Fix some code in restore.c to make cppcheck happy
This commit is contained in:
parent
c254138c21
commit
733a7385b4
@ -45,18 +45,17 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (rd->pid)
|
if (rd->pid)
|
||||||
{
|
{
|
||||||
|
#if defined (_POSIX)
|
||||||
|
|
||||||
char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin);
|
char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin);
|
||||||
|
|
||||||
int pidbin_len = -1;
|
|
||||||
|
|
||||||
#if defined (_POSIX)
|
|
||||||
snprintf (pidbin, HCBUFSIZ_LARGE - 1, "/proc/%u/cmdline", rd->pid);
|
snprintf (pidbin, HCBUFSIZ_LARGE - 1, "/proc/%u/cmdline", rd->pid);
|
||||||
|
|
||||||
FILE *fd = fopen (pidbin, "rb");
|
FILE *fd = fopen (pidbin, "rb");
|
||||||
|
|
||||||
if (fd)
|
if (fd)
|
||||||
{
|
{
|
||||||
pidbin_len = fread (pidbin, 1, HCBUFSIZ_LARGE, fd);
|
size_t pidbin_len = fread (pidbin, 1, HCBUFSIZ_LARGE, fd);
|
||||||
|
|
||||||
pidbin[pidbin_len] = 0;
|
pidbin[pidbin_len] = 0;
|
||||||
|
|
||||||
@ -78,17 +77,19 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hcfree (pidbin);
|
||||||
|
|
||||||
#elif defined (_WIN)
|
#elif defined (_WIN)
|
||||||
|
|
||||||
HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, rd->pid);
|
HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, rd->pid);
|
||||||
|
|
||||||
|
char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin);
|
||||||
char *pidbin2 = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin2);
|
char *pidbin2 = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin2);
|
||||||
|
|
||||||
int pidbin2_len = -1;
|
int pidbin_len = GetModuleFileName (NULL, pidbin, HCBUFSIZ_LARGE);
|
||||||
|
int pidbin2_len = GetModuleFileNameEx (hProcess, NULL, pidbin2, HCBUFSIZ_LARGE);
|
||||||
|
|
||||||
pidbin_len = GetModuleFileName (NULL, pidbin, HCBUFSIZ_LARGE);
|
pidbin[pidbin_len] = 0;
|
||||||
pidbin2_len = GetModuleFileNameEx (hProcess, NULL, pidbin2, HCBUFSIZ_LARGE);
|
|
||||||
|
|
||||||
pidbin[pidbin_len] = 0;
|
|
||||||
pidbin2[pidbin2_len] = 0;
|
pidbin2[pidbin2_len] = 0;
|
||||||
|
|
||||||
if (pidbin2_len)
|
if (pidbin2_len)
|
||||||
@ -102,10 +103,9 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
hcfree (pidbin2);
|
hcfree (pidbin2);
|
||||||
|
hcfree (pidbin);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hcfree (pidbin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rd->version < RESTORE_VERSION_MIN)
|
if (rd->version < RESTORE_VERSION_MIN)
|
||||||
|
Loading…
Reference in New Issue
Block a user