mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 08:08:10 +00:00
Trim OpenCL device name whitespaces
This commit is contained in:
parent
0eb18b068f
commit
b5f149476d
@ -56,4 +56,7 @@ bool hc_path_create (const char *path);
|
||||
|
||||
bool hc_string_is_digit (const char *s);
|
||||
|
||||
void hc_string_trim_trailing (char *s);
|
||||
void hc_string_trim_leading (char *s);
|
||||
|
||||
#endif // _SHARED_H
|
||||
|
@ -2596,6 +2596,10 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
||||
|
||||
device_param->device_name = device_name;
|
||||
|
||||
hc_string_trim_leading (device_param->device_name);
|
||||
|
||||
hc_string_trim_trailing (device_param->device_name);
|
||||
|
||||
// device_vendor
|
||||
|
||||
CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, 0, NULL, ¶m_value_size);
|
||||
|
46
src/shared.c
46
src/shared.c
@ -421,3 +421,49 @@ u32 get_random_num (const u32 min, const u32 max)
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void hc_string_trim_leading (char *s)
|
||||
{
|
||||
int skip = 0;
|
||||
|
||||
const int len = (int) strlen (s);
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
const int c = (const int) s[i];
|
||||
|
||||
if (isspace (c) == 0) break;
|
||||
|
||||
skip++;
|
||||
}
|
||||
|
||||
if (skip == 0) return;
|
||||
|
||||
const int new_len = len - skip;
|
||||
|
||||
memmove (s, s + skip, new_len);
|
||||
|
||||
s[new_len] = 0;
|
||||
}
|
||||
|
||||
void hc_string_trim_trailing (char *s)
|
||||
{
|
||||
int skip = 0;
|
||||
|
||||
const int len = (int) strlen (s);
|
||||
|
||||
for (int i = len - 1; i >= 0; i--)
|
||||
{
|
||||
const int c = (const int) s[i];
|
||||
|
||||
if (isspace (c) == 0) break;
|
||||
|
||||
skip++;
|
||||
}
|
||||
|
||||
if (skip == 0) return;
|
||||
|
||||
const size_t new_len = len - skip;
|
||||
|
||||
s[new_len] = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user