1 Star 0 Fork 9

caodongxia/procinfo

forked from src-openEuler/procinfo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
procinfo-18-ranges.patch 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
Grooooot 提交于 2020-02-19 10:01 . init the package
--- procinfo-18/procinfo.c.ranges 2005-10-12 12:07:20.000000000 +0200
+++ procinfo-18/procinfo.c 2005-10-12 12:09:17.000000000 +0200
@@ -231,8 +231,8 @@
fseek (loadavgfp, 0L, SEEK_SET);
fgets (line, sizeof (line), loadavgfp);
- strcpy (loadavg, line);
- loadavg[strlen (loadavg) - 1] = '\0';
+ strncpy (loadavg, line, sizeof (loadavg));
+ loadavg[sizeof (loadavg) - 1] = '\0';
fgets (line, sizeof (line), loadavgfp);
printf ("Bootup: %s Load average: %s\n\n", booted, loadavg);
@@ -481,7 +481,7 @@
for (i = 0; i < nr_irqs; i++) {
if (strncmp (&line[4], irq_label[i], foo) == 0) {
- tmplen = sprintf (tmp, " [%ld]",
+ tmplen = snprintf (tmp, sizeof(tmp), " [%ld]",
atol (strtok (line, ":")));
if (strlen (irq_label[i]) > (21 - tmplen)) {
@@ -686,7 +686,7 @@
fs = strchr (line, '\t');
fs = strtok (fs + 1, "\n");
if (line[0] == 'n') {
- sprintf (tmp, "[%s]", fs);
+ snprintf (tmp, sizeof(tmp), "[%s]", fs);
printf ("%-20s", tmp);
} else
printf ("%-20s", fs);
@@ -1003,7 +1003,7 @@
if (strlen (line) > 1) {
tmpsl = atof (line);
sl = (long) (tmpsl * 1000000.0);
- sprintf (line, "delay set to %f", tmpsl);
+ snprintf (line, sizeof(line), "delay set to %f", tmpsl);
message = line;
}
redrawn = 1;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/caodongxia/procinfo.git
git@gitee.com:caodongxia/procinfo.git
caodongxia
procinfo
procinfo
master

搜索帮助