修复漏洞——文件为空时(敏感词模板下载)
This commit is contained in:
@@ -159,21 +159,27 @@ public class SensitiveWordDataController extends BaseController {
|
||||
response.setHeader("Pragma", "public");
|
||||
response.setHeader("Cache-Control", "max-age=0");
|
||||
InputStream in = null;
|
||||
OutputStream ou =null;
|
||||
try {
|
||||
in = new FileInputStream(url);
|
||||
ou = response.getOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int i = -1;
|
||||
while ((i = in.read(buffer)) != -1) {
|
||||
ou.write(buffer, 0, i);
|
||||
}
|
||||
ou.flush();
|
||||
} catch (FileNotFoundException e1) {
|
||||
resMsg = "文件未找到";
|
||||
e1.printStackTrace();
|
||||
response.getWriter().write(resMsg + ":" + name);
|
||||
}finally {
|
||||
if (ou != null) {
|
||||
ou.close();
|
||||
}
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
OutputStream ou = response.getOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int i = -1;
|
||||
while ((i = in.read(buffer)) != -1) {
|
||||
ou.write(buffer, 0, i);
|
||||
}
|
||||
ou.flush();
|
||||
ou.close();
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user