X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fbitmapvalidator.cpp;h=771b707eca577677011710deeb137206f86541bc;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hp=68482c1a219fd1d3278a08349ade48df3cb8f51b;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af;p=fms.git diff --git a/src/bitmapvalidator.cpp b/src/bitmapvalidator.cpp index 68482c1..771b707 100644 --- a/src/bitmapvalidator.cpp +++ b/src/bitmapvalidator.cpp @@ -1,27 +1,29 @@ #include "../include/bitmapvalidator.h" #include "../include/freenet/captcha/easybmp/EasyBMP.h" +#include + #include +#include const bool BitmapValidator::Validate(const std::vector &data) { bool validated=false; - std::ostringstream tempname; - - tempname << "validatebmp-" << rand() << ".tmp"; - FILE *outfile=fopen(tempname.str().c_str(),"w+b"); + std::string tempname=Poco::TemporaryFile::tempName(); + + FILE *outfile=fopen(tempname.c_str(),"w+b"); if(outfile) { fwrite(&data[0],1,data.size(),outfile); fclose(outfile); BMP temp; - if(temp.ReadFromFile(tempname.str().c_str())) + if(temp.ReadFromFile(tempname.c_str())) { validated=true; } - unlink(tempname.str().c_str()); + unlink(tempname.c_str()); }