天天看點

更新linux伺服器元件(打更新檔或者更新)

比如打更新檔,一般會有一個更新檔的位址,進去以後可以看到修複的代碼修改記錄,并且說明影響的版本和修複的版本。

nginx 安全漏洞(CVE-2018-16845) 中危 nginx類 nginx是由俄羅斯的程式設計師Igor Sysoev所開發的一款輕量級Web伺服器/反向代理伺服器及電子郵件(IMAP/POP3)代理伺服器。 
Nginx 1.15.5及之前的版本和1.14.1版本中的ngx_http_mp4_module元件存在記憶體洩露漏洞,該漏洞源于程式沒有正确處理MP4檔案。遠端攻擊者可利用該漏洞擷取敏感資訊或造成拒絕服務。
 廠商更新檔: 目前廠商已釋出更新更新檔以修複漏洞,更新檔擷取連結: http://mailman.nginx.org/pipermail/nginx-announce/2018/000221.html      

具體代碼修改如下:

--- src/http/modules/ngx_http_mp4_module.c
+++ src/http/modules/ngx_http_mp4_module.c
@@ -942,6 +942,13 @@ ngx_http_mp4_read_atom(ngx_http_mp4_file
                 atom_size = ngx_mp4_get_64value(atom_header + 8);
                 atom_header_size = sizeof(ngx_mp4_atom_header64_t);
 
+                if (atom_size < sizeof(ngx_mp4_atom_header64_t)) {
+                    ngx_log_error(NGX_LOG_ERR, mp4->file.log, 0,
+                                  "\"%s\" mp4 atom is too small:%uL",
+                                  mp4->file.name.data, atom_size);
+                    return NGX_ERROR;
+                }
+
             } else {
                 ngx_log_error(NGX_LOG_ERR, mp4->file.log, 0,
                               "\"%s\" mp4 atom is too small:%uL",      

這時候我們修複有2種方法:

1、到我們的安裝包源碼目錄,根據更新檔檔案修改安裝包的代碼,然後重新編輯,替換執行檔案。

2、到官網下載下傳已修複的版本,編譯,替換執行檔案。

#檢視原有編譯參數
./sbin/nginx -V

#如果是PHP,執行./php-fpm -i |grep configure

#得到如下
nginx version: nginx/1.11.5 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) built with OpenSSL 1.0.1c 10 May 2012 TLS SNI support enabled configure arguments: --prefix=/app/nginx/nginx --with-pcre=/app/nginx/soft/pcre-8.35 --with-zlib=/app/nginx/soft/zlib-1.2.8 --with-openssl=/app/nginx/soft/openssl-1.0.1c --with-http_ssl_module --with-http_realip_module
#需要用到的内容為configure arguments:後的内容

去nginx源碼目錄編譯
cd nginx-1.11.5 && ./configure --prefix=/app/nginx/nginx --with-pcre=/app/nginx/soft/pcre-8.35 --with-zlib=/app/nginx/soft/zlib-1.2.8 --with-openssl=/app/nginx/soft/openssl-1.0.1c --with-http_ssl_module --with-http_realip_module && make
#注意:不要make install,不然會覆寫現有的
#等待編譯成功後會生成一個objs目錄,進入目錄
cd objs
#複制編譯生成的可執行檔案到原先的nginx的sbin目錄
cp nginx /app/nginx/nginx/sbin
#注意,複制前建議先備份原有的sbin檔案
./nginx -s reload #重新開機