Compare commits

..

1 Commits

Author SHA1 Message Date
OrbisAI Security 25eb54b557
Merge beeb94561e into 724b008b0e 2026-06-24 10:40:57 +05:30
4 changed files with 21 additions and 33 deletions

View File

@ -1,7 +1,4 @@
Version 1.86 2026-06-25
* add function fc_parse_version
Version 1.85 2026-06-23 Version 1.85 2026-06-23
* add functions fc_safe_srand and fc_safe_rand for more security under Linux * add functions fc_safe_srand and fc_safe_rand for more security under Linux
* add function seconds_to_human_str * add function seconds_to_human_str

View File

@ -4691,27 +4691,3 @@ int fc_safe_rand()
return (n & RAND_MAX); return (n & RAND_MAX);
} }
#endif #endif
int fc_parse_version(const char *src, Version *version)
{
const char *p;
int numbers[2];
int i;
numbers[0] = numbers[1] = 0;
p = src;
for (i=0; i<2; i++) {
p = strchr(p, '.');
if (p == NULL) {
break;
}
p++;
numbers[i] = strtol(p, NULL, 10);
}
version->major = strtol(src, NULL, 10);
version->minor = numbers[0];
version->patch = numbers[1];
return FC_VERSION_TO_INT1(*version);
}

View File

@ -1877,8 +1877,6 @@ int fc_safe_rand();
#define fc_safe_rand() rand() #define fc_safe_rand() rand()
#endif #endif
int fc_parse_version(const char *src, Version *version);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -960,16 +960,33 @@ int get_sysinfo(struct fast_sysinfo *info)
int get_kernel_version(Version *version) int get_kernel_version(Version *version)
{ {
struct utsname name; struct utsname name;
char *p;
int numbers[2];
int i;
if (uname(&name) < 0) if (uname(&name) < 0)
{ {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"call uname fail, errno: %d, error info: %s", "call uname fail, errno: %d, error info: %s",
__LINE__, errno, STRERROR(errno)); __LINE__, errno, STRERROR(errno));
return errno != 0 ? errno : EFAULT; return errno != 0 ? errno : EFAULT;
} }
fc_parse_version(name.release, version); numbers[0] = numbers[1] = 0;
p = name.release;
for (i=0; i<2; i++) {
p = strchr(p, '.');
if (p == NULL) {
break;
}
p++;
numbers[i] = strtol(p, NULL, 10);
}
version->major = strtol(name.release, NULL, 10);
version->minor = numbers[0];
version->patch = numbers[1];
return 0; return 0;
} }