修复漏洞——文件为空时(敏感词模板下载)

This commit is contained in:
sh
2026-05-26 13:18:51 +08:00
parent 50558fdbc6
commit 6260b5347b

View File

@@ -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);
} catch (FileNotFoundException e1) {
resMsg = "文件未找到";
e1.printStackTrace();
response.getWriter().write(resMsg + ":" + name);
}
OutputStream ou = response.getOutputStream();
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();
}
}
}
}