| View previous topic :: View next topic |
| Author |
Message |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Sat Jun 02, 2012 8:40 pm Post subject: I MAD, IT FUCKING TOOK ME LIKE 9 HOURS TO DO THIS SHIT! |
|
|
| Code: | #include <stdio.h>
#include <string.h>
void read(char* obj,char* count){
FILE * fp;
char buffer[80];
fp = fopen( "carro.DAE", "r" );
if(fp == NULL){
perror("file missing");
}
while(fgets (buffer, sizeof (buffer), fp) != NULL) {
char title[80];
strcpy(title,"<float_array id=\"");
strcat(title,obj);
strcat(title,"-POSITION-array\" count=\"");
strcat(title,count);
strcat(title,"\">");
if(strstr(buffer, title)) {
char* start = strchr(buffer, '>');
start++;
char* end = strchr(buffer, '<');
end = '\0';
printf("%s\n", start); // prints yy
}
}
}
|
|
|
| Back to top |
|
 |
the the the Master Cheater
Reputation: 46
Joined: 15 Jun 2008 Posts: 429
|
Posted: Sat Jun 02, 2012 8:56 pm Post subject: |
|
|
| wat is it
|
|
| Back to top |
|
 |
NotReallySureWhatGoesHere Expert Cheater
Reputation: -1
Joined: 20 Feb 2012 Posts: 110
|
Posted: Sat Jun 02, 2012 9:00 pm Post subject: |
|
|
| asciicat wrote: | | wat is it |
Looks like some console-application that prints some HTML.
|
|
| Back to top |
|
 |
Aviar³ Grandmaster Cheater
Reputation: 50
Joined: 03 Jan 2008 Posts: 655 Location: Canada
|
Posted: Sat Jun 02, 2012 10:41 pm Post subject: |
|
|
Reads from a file and stores into buffer. Particularly, reads 80 characters from a file named carro.DAE and stores them into an array, then apparently overflows the fuck out of everything because he concats what was read from the buffer into another array (filling it) and then concats more shit (making it ouf of bounds). And it doesnt stop there, he stuffs that fucking string like it was thanksgiving.
_________________
This is the inception of deception, checking the depth of your perception.
 |
|
| Back to top |
|
 |
OP. I post too much
Reputation: 0
Joined: 09 Nov 2008 Posts: 2217
|
Posted: Sat Jun 02, 2012 10:41 pm Post subject: |
|
|
does everybody here know a lot about scripting and all this c++ stuff?
_________________
|
|
| Back to top |
|
 |
Aviar³ Grandmaster Cheater
Reputation: 50
Joined: 03 Jan 2008 Posts: 655 Location: Canada
|
Posted: Sat Jun 02, 2012 10:44 pm Post subject: |
|
|
Disregard the last thing I said, I suck dicks. He concats obj not buffer. Then again, no one can guarantee that all that concatenation will fit into 80 characters. It probably will work most of the time since I think strstr() scans until it reaches the null character (not the array size), but it can still probably end up crashing depending on how memory is allocated.
sum of characters<buffer size
43+obj+count<80
obj<37-count
count<37-obj
Obviously, that means count or obj cannot be greater than 37 (really 37-1 due to /0) characters in length, and even then, that means the other is 0.
Also, directives in caps and vars start and end with _. I couldn't be assed to either make sure the directives structure is constant or that it even makes fucking sense.
| Code: | ALLOCATE space for _fileHandle_ and _buffer_
READ _file_ from _fileHandle_ carro.DAE
IF error reading file
PRINT error
WHILE characters left to STORE into _buffer_ from _file_
ALLOCATE space for _title_
STORE <float_array id="_obj_-POSITION-array" count="_count_"> into _title_
IF substring in _buffer_ matches _title_
ALLOCATE start and set to
INCREMENT _start_ by one
ALLOCATE end and set to
ADD null terminating character
PRINT start
REPEAT |
_________________
This is the inception of deception, checking the depth of your perception.
 |
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jun 03, 2012 5:59 am Post subject: |
|
|
| OP. wrote: | | does everybody here know a lot about scripting and all this c++ stuff? |
it's not c++. it's c99 or above. +rep to anyone who can tell me how i know that
@aviar: i think you misunderstood (or at least didn't understand past line-by-line analysis) the whole sub-block starting with strstr
|
|
| Back to top |
|
 |
Innovation Grandmaster Cheater
Reputation: 12
Joined: 14 Aug 2008 Posts: 617
|
Posted: Sun Jun 03, 2012 7:05 am Post subject: |
|
|
| Slugsnack wrote: | | OP. wrote: | | does everybody here know a lot about scripting and all this c++ stuff? |
it's not c++. it's c99 or above. +rep to anyone who can tell me how i know that |
"title" is declared in the while loop and not at the beginning of the function.
Last edited by Innovation on Sun Jun 03, 2012 7:32 am; edited 2 times in total |
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jun 03, 2012 7:14 am Post subject: |
|
|
| there's nothing wrong with that. the declaration occurs at the beginning of a scope so it is c89 compliant
|
|
| Back to top |
|
 |
Innovation Grandmaster Cheater
Reputation: 12
Joined: 14 Aug 2008 Posts: 617
|
Posted: Sun Jun 03, 2012 7:55 am Post subject: |
|
|
| Slugsnack wrote: | | there's nothing wrong with that. the declaration occurs at the beginning of a scope so it is c89 compliant |
I thought that you can't declare variables in for and while iteration statements at all? Or is it just that you can't declare a variable in the initializer part of the for loop?
From what I've read, the idea was that you are forced to allocate the variable once outside of the loop instead of allocating the same variable multiple times (even though modern compilers optimize it to shift the stack pointer only once anyway).
It might have been only recommended practice, and I mixed it up with other information (this person believes it too).
Last edited by Innovation on Sun Jun 03, 2012 8:19 am; edited 2 times in total |
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jun 03, 2012 8:14 am Post subject: |
|
|
| Innovation wrote: | | Slugsnack wrote: | | there's nothing wrong with that. the declaration occurs at the beginning of a scope so it is c89 compliant |
I thought that you can't declare variables in for and while iteration statements at all? Or is it just that you can't declare a variable in the initializer part of the for loop?
From what I've read, the idea was that you are forced to allocate the variable once outside of the loop instead of allocating the same variable multiple times (even though modern compilers optimize it to shift the stack pointer only once anyway).
It might have been only recommended practice and was mixed up other with information (this person believes it too). |
yes to the part i quoted
here, i'll give you the solution. just compile with 'gcc -std=c89 -pedantic' and see what happens
the answer is that the '//' is not valid c89. also 'end' is not declared at the beginning of a scope
|
|
| Back to top |
|
 |
Innovation Grandmaster Cheater
Reputation: 12
Joined: 14 Aug 2008 Posts: 617
|
Posted: Sun Jun 03, 2012 8:24 am Post subject: |
|
|
| Slugsnack wrote: | yes to the part i quoted
here, i'll give you the solution. just compile with 'gcc -std=c89 -pedantic' and see what happens
the answer is that the '//' is not valid c89. also 'end' is not declared at the beginning of a scope |
Yeah, I would've mentioned that otherwise.
Are you Ready For C99?
|
|
| Back to top |
|
 |
Cheat Engine User Something epic
Reputation: 60
Joined: 22 Jun 2007 Posts: 2071
|
Posted: Sun Jun 03, 2012 8:25 am Post subject: |
|
|
I hate it when people do brackets like that.
Netbeans does it too. Automatically. It makes me cringe.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jun 03, 2012 8:47 am Post subject: |
|
|
| k&r? although his case is not really strict k&r
|
|
| Back to top |
|
 |
Aniblaze Grandmaster Cheater Supreme
Reputation: 138
Joined: 23 Apr 2006 Posts: 1757 Location: The Netherlands
|
Posted: Sun Jun 03, 2012 9:54 am Post subject: |
|
|
I have no idea what OP is trying to do, and am unwilling to find out what it is. Simply here to see the replies and figure it out from that.
| Holland wrote: | I hate it when people do brackets like that.
Netbeans does it too. Automatically. It makes me cringe. |
Readability doesn't suffer, so I actually prefer it. A class with 20 methods would have 20 extra lines that do absolutely nothing. It makes me cringe.
|
|
| Back to top |
|
 |
|