use snprintf
This commit is contained in:
parent
aa4af2806f
commit
f32e386b19
@ -1516,7 +1516,8 @@ static int create_diskmap_v4(sigar_t *sigar)
|
|||||||
*s = '\0';
|
*s = '\0';
|
||||||
}
|
}
|
||||||
strcpy(disk, ptr);
|
strcpy(disk, ptr);
|
||||||
sprintf(cmd, LSPV_CMD " -l %s", disk);
|
snprintf(cmd, sizeof(cmd),
|
||||||
|
LSPV_CMD " -l %s", disk);
|
||||||
if (!(lfp = popen(cmd, "r"))) {
|
if (!(lfp = popen(cmd, "r"))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1587,7 +1588,8 @@ static int create_diskmap_v5(sigar_t *sigar)
|
|||||||
sigar_cache_entry_t *ent;
|
sigar_cache_entry_t *ent;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
sprintf(query, "parent = '%s'", disk[i].vgname);
|
snprintf(query, sizeof(query),
|
||||||
|
"parent = '%s'", disk[i].vgname);
|
||||||
|
|
||||||
ptr = dv = odm_get_list(CuDv_CLASS, query, &info, 256, 1);
|
ptr = dv = odm_get_list(CuDv_CLASS, query, &info, 256, 1);
|
||||||
if ((int)dv == -1) {
|
if ((int)dv == -1) {
|
||||||
@ -2356,15 +2358,21 @@ int sigar_os_sys_info_get(sigar_t *sigar,
|
|||||||
SIGAR_SSTRCPY(sysinfo->arch, get_cpu_arch());
|
SIGAR_SSTRCPY(sysinfo->arch, get_cpu_arch());
|
||||||
/* utsname.machine is a sequence number */
|
/* utsname.machine is a sequence number */
|
||||||
/* XXX odm might have something better */
|
/* XXX odm might have something better */
|
||||||
sprintf(sysinfo->machine, "%s %s",
|
snprintf(sysinfo->machine,
|
||||||
|
sizeof(sysinfo->machine),
|
||||||
|
"%s %s",
|
||||||
sysinfo->arch, get_cpu_model());
|
sysinfo->arch, get_cpu_model());
|
||||||
|
|
||||||
sprintf(sysinfo->version, "%s.%s",
|
snprintf(sysinfo->version,
|
||||||
|
sizeof(sysinfo->version),
|
||||||
|
"%s.%s",
|
||||||
name.version, name.release);
|
name.version, name.release);
|
||||||
|
|
||||||
SIGAR_SSTRCPY(sysinfo->vendor_version, sysinfo->version);
|
SIGAR_SSTRCPY(sysinfo->vendor_version, sysinfo->version);
|
||||||
|
|
||||||
sprintf(sysinfo->description, "%s %s",
|
snprintf(sysinfo->description,
|
||||||
|
sizeof(sysinfo->description),
|
||||||
|
"%s %s",
|
||||||
sysinfo->name, sysinfo->version);
|
sysinfo->name, sysinfo->version);
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
|
@ -1083,7 +1083,9 @@ int sigar_os_sys_info_get(sigar_t *sigar,
|
|||||||
|
|
||||||
SIGAR_SSTRCPY(sysinfo->vendor_version, vendor_version);
|
SIGAR_SSTRCPY(sysinfo->vendor_version, vendor_version);
|
||||||
|
|
||||||
sprintf(sysinfo->description, "%s %s",
|
snprintf(sysinfo->description,
|
||||||
|
sizeof(sysinfo->description),
|
||||||
|
"%s %s",
|
||||||
sysinfo->vendor_name, sysinfo->vendor_version);
|
sysinfo->vendor_name, sysinfo->vendor_version);
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
|
@ -1247,7 +1247,8 @@ static int get_iostat_sys(sigar_t *sigar,
|
|||||||
partition = strtoul(fsdev, NULL, 0);
|
partition = strtoul(fsdev, NULL, 0);
|
||||||
*fsdev = '\0';
|
*fsdev = '\0';
|
||||||
|
|
||||||
sprintf(stat, SYS_BLOCK "/%s/%s%d/stat", name, name, partition);
|
snprintf(stat, sizeof(stat),
|
||||||
|
SYS_BLOCK "/%s/%s%d/stat", name, name, partition);
|
||||||
|
|
||||||
status = sigar_file2str(stat, dev, sizeof(dev));
|
status = sigar_file2str(stat, dev, sizeof(dev));
|
||||||
if (status != SIGAR_OK) {
|
if (status != SIGAR_OK) {
|
||||||
@ -2157,7 +2158,9 @@ static void redhat_vendor_parse(char *line, sigar_sys_info_t *info)
|
|||||||
#define RHEL_PREFIX "Red Hat Enterprise Linux "
|
#define RHEL_PREFIX "Red Hat Enterprise Linux "
|
||||||
#define CENTOS_VENDOR "CentOS"
|
#define CENTOS_VENDOR "CentOS"
|
||||||
if (strnEQ(line, RHEL_PREFIX, sizeof(RHEL_PREFIX)-1)) {
|
if (strnEQ(line, RHEL_PREFIX, sizeof(RHEL_PREFIX)-1)) {
|
||||||
sprintf(info->vendor_version, "Enterprise Linux %c",
|
snprintf(info->vendor_version,
|
||||||
|
sizeof(info->vendor_version),
|
||||||
|
"Enterprise Linux %c",
|
||||||
info->vendor_version[0]);
|
info->vendor_version[0]);
|
||||||
}
|
}
|
||||||
else if (strnEQ(line, CENTOS_VENDOR, sizeof(CENTOS_VENDOR)-1)) {
|
else if (strnEQ(line, CENTOS_VENDOR, sizeof(CENTOS_VENDOR)-1)) {
|
||||||
@ -2268,7 +2271,9 @@ static int get_linux_vendor_info(sigar_sys_info_t *info)
|
|||||||
generic_vendor_parse(data, info);
|
generic_vendor_parse(data, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(info->description, "%s %s",
|
snprintf(info->description,
|
||||||
|
sizeof(info->description),
|
||||||
|
"%s %s",
|
||||||
info->vendor, info->vendor_version);
|
info->vendor, info->vendor_version);
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
|
@ -801,7 +801,8 @@ static int ucb_ps_args_get(sigar_t *sigar, sigar_pid_t pid,
|
|||||||
args = pargs->args;
|
args = pargs->args;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sprintf(buffer, "/usr/ucb/ps -ww %ld", pid);
|
snprintf(buffer, sizeof(buffer),
|
||||||
|
"/usr/ucb/ps -ww %ld", pid);
|
||||||
|
|
||||||
if (!(fp = popen(buffer, "r"))) {
|
if (!(fp = popen(buffer, "r"))) {
|
||||||
return errno;
|
return errno;
|
||||||
@ -2319,7 +2320,9 @@ int sigar_os_sys_info_get(sigar_t *sigar,
|
|||||||
|
|
||||||
SIGAR_SSTRCPY(sys_info->vendor_version, vendor_version);
|
SIGAR_SSTRCPY(sys_info->vendor_version, vendor_version);
|
||||||
|
|
||||||
sprintf(sys_info->description, "%s %s",
|
snprintf(sys_info->description,
|
||||||
|
sizeof(sys_info->description),
|
||||||
|
"%s %s",
|
||||||
sys_info->name, sys_info->vendor_version);
|
sys_info->name, sys_info->vendor_version);
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user