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