|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Oct 2002
Città: San Jose, California
Messaggi: 11794
|
WTF
http://www.thedailywtf.com/forums/53809/ShowPost.aspx
A lot of programmers have lost all hope after seeing this website. After all, most of the code I post here was found out in the wild, on real, live, production systems that some of you actually maintain. But today I'd like to offer a glimmer of hope: there are actually people who are out there who are fighting the good fight, doing their best to makes sure that code like today's never makes it to production. You should all be thanking Kirk L. for being one of those guys. He discovered this in a code review of a colleague. The code also explained why there were hundreds of temp files in the working directory came and a huge leakage of file pointers. If you're not well-versed in C++, suffice it to say that while most people would simply use sprintf, our coder felt it better to format strings by writing temporary files to disk and reading them back ... Codice:
void printf_to_string( int first, char * fomat, ... )
{
va_list marker;
va_start( marker, first );
// this is required, or it will not work for some reason
*(char*)*va_arg( marker, char * );
// string to write to
// ** MUST BE FIRST AFTER FORMAT IN FUNCTION COMAND LINE **
{} /* make the variable */
char * string_write_to = va_arg( marker, char * );
char temporary_file_name[ 19 ];
char * temorary_file_name_name ;
strcpy( temporary_file_name, "thefileXXXX" );
temorary_file_name_name = _mktemp( temporary_file_name );
{}
FILE * FILE1 = fopen( temporary_file_name, "w" );
vfprintf( FILE1, fomat, marker );
fclose( FILE1 );
{} FILE * FILE11 = fopen( temporary_file_name, "r" ); {}
// 2 is to the end ... it took some experamenting
// -1 is so we go back and dont get the blank after it
fseek( FILE11, -1, 2 );
{}
double bignumberjustincase = ftell( FILE11 );
fclose( FILE1 );
FILE * FILE111 = fopen( temporary_file_name, "r" );
read( _fileno( FILE111 ), string_write_to, (short)bignumberjustincase );
int stopHere = (long)string_write_to + (int)0;
stopHere = stopHere + (bignumberjustincase);
if ( stopHere != 0 )
{
((char*)stopHere)[ 0 ] = '\0';
strcpy( string_write_to + int(bignumberjustincase ), "" );
va_end( marker );
}
}
__________________
"We in the game industry are lucky enough to be able to create our visions" @ NVIDIA |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Oct 2001
Messaggi: 11471
|
Oddio il commento sopra alla fseek mi ha ucciso
ciao |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Mar 2002
Città: Italy/Usa
Messaggi: 2817
|
vicius!! ti ringrazio per la segnalazione
che dire! questo sì che è lo stato dell'arte nel rilasciare open source in formato closed ![]() questa poi è una chicca // this is required, or it will not work for some reason
__________________
"Utilizzando atomi pentavalenti drogheremo il silicio di tipo n; Utilizzando atomi trivalenti drogheremo il silicio di tipo p; Utilizzando della cannabis ci drogheremo noi e vedremo il silicio fare cose impossibili" - DSDT-HowTo Ultima modifica di maxithron : 03-01-2006 alle 20:42. |
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Ciao maxithron !!! Partecipa anche tu a Diamonds !!!
Riguardo al codice sopra |
|
|
|
|
|
#5 | |
|
Senior Member
Iscritto dal: Mar 2002
Città: Italy/Usa
Messaggi: 2817
|
Quote:
in merito a diamonds oggi mi sono scaricato tutto l'occorrente e configurato per benino l'ambiente. In questo momento sarei altamente inaffidabile per questioni di tempo
__________________
"Utilizzando atomi pentavalenti drogheremo il silicio di tipo n; Utilizzando atomi trivalenti drogheremo il silicio di tipo p; Utilizzando della cannabis ci drogheremo noi e vedremo il silicio fare cose impossibili" - DSDT-HowTo |
|
|
|
|
|
|
#6 |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
ma che scherzate ragazzi, fek, che non l'hai capito... quello è codice senza bug!!
(ricordi quando ne parlammo tempo fa?) quel codice non serve a fare quello che sembra voler fare, in realtà serve a sfruttare il rootkit della Sony per conquistare il mondo!!!
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 14:15.




















