歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux命令 >> Linux ls 命令本地 D.o.S

Linux ls 命令本地 D.o.S

日期:2017/2/28 10:05:03   编辑:Linux命令
Linux命令 涉及程序:
Linux RedHat 6.x Slackware 7.0

描述:
Linux ls 命令本地 D.o.S

詳細:
受影響的系統:
- Linux RedHat 6.x
- LInux Slackware 7.0
某些 Linux 系統中的 "ls" 指令包含一個 "-w" 參數,它是用來定義顯示屏幕的寬度。缺省時 ls 定義了一個很大的 INT_MAX 來保證可以制定足夠寬的屏幕,用戶提供的寬度只要小於這個數值都會被允許。如果指定一個很大的寬度數值,會使 ls 占用大量的內存,只要循環執行多次相應的命令,就會耗盡系統內存,嚴重降低系統性能。
如:

bash$ perl -e 'for(;;){fork();`ls -w 9999999`;}'




解決方案:
臨時補丁程序。
注:這個補丁是針對(Slackware 7.0)Fileutils-4.0 src/ls.c文件的。

使用方法:
執行'patch -p1 < ls.patch' 然後重新編譯安裝
--------------- Patch ---------------------------------------

--- old/ls.c Sun May 11 21:48:51 1980
+++ new/ls.c Sun May 11 21:56:17 1980
@@ -74,6 +74,7 @@
#include "quotearg.h"
#include "filemode.h"

+#define WIDTH_MAX 1000
#define obstack_chunk_alloc malloc
#define obstack_chunk_free free

@@ -866,7 +867,7 @@
if ((p = getenv ("COLUMNS")) && *p)
{
if (xstrtol (p, NULL, 0, &tmp_long, NULL) == LONGINT_OK
-&& 0 < tmp_long && tmp_long <= INT_MAX)
+&& 0 < tmp_long && tmp_long <= WIDTH_MAX)
{
line_length = (int) tmp_long;
}
@@ -1012,7 +1013,7 @@

case 'w':
if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
- || tmp_long <= 0 || tmp_long > INT_MAX)
+ || tmp_long <= 0 || tmp_long > WIDTH_MAX)
 error (EXIT_FAILURE, 0, _("invalid line width: %s"),
 quotearg (optarg));
line_length = (int) tmp_long;


附加信息:
Cody Tubbs

Copyright © Linux教程網 All Rights Reserved