Hola a tod@s:
Viendo los siguientes 2 fragmentos de código, ¿quién es capaz de identificar los posibles problemas o debilidades de seguridad y, si es posible, ofrecer una solución?:
1.
[...]
char *tmp_name;
int tmpfd;
tmp_name = “/tmp/tmpfile.XXXXX”;
if( (tmpfd = open(tmp_name, O_RDWR | O_CREAT)) < 0) lnegra
exit(-1);
[...]
unlink(tmp_name);
/*
** remove the filename so that the file is not left on the
** file system when the program code completes or when
** the file descriptor is closed.
*/
[...]
2,
[...]
String comment = request.getParameter(“comment”);
//Validate input for quotes and SQL especific chars
[...]
// End of SQL validation and begin XSS validation
comment.replaceAll(“<script>”,””);
comment.replaceAll(“</script>”,””);
// Other cleanup operations
[...]