![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Hobbyist Programmer
Join Date: Jun 2006
Posts: 137
Rep Power: 0
![]() |
Yup source would be nice...
|
|
|
|
|
|
#22 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
here's the source. I made a few changes to chiba to make it easier to use.
|
|
|
|
|
|
#23 | |
|
Professional Programmer
|
That's not the source, that's the executable. I think you mixed up the files you were uploading. Unless you don't know the difference between source and executable. I don't think that's the problem here though.
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
|
|
#24 |
|
Programmer
|
Awsome, even though i still cant chat, its still great
Can u please post the source files? it would help me a lot |
|
|
|
|
|
#25 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
oops...srry guys, i guess i forgot to attach the source, here it is. It should include chiba.cpp and chiba.h. the code is a bit messy, cuz I was just messing around with it and didnt really expect it to work. Ill post a cleaned up version sometime.
|
|
|
|
|
|
#26 |
|
Hobbyist Programmer
|
You have a whole bunch of flaws in your program that can cause the client to crash (and you can probably make the server crash too, although I haven't really looked into it.)
Here're some places that you need to examine: case IDC_SEND:
{
int len=GetWindowTextLength(GetDlgItem(hwnd,IDC_MAIN_EDIT));
if(len > 0)
{
GetDlgItemText(hwnd,IDC_MAIN_EDIT,new_data,len+1);
SetDlgItemText(hwnd,IDC_MAIN_EDIT,"");GetDlgItemText(hwnd,IDC_MAIN_EDIT,new_data,sizeof(new_data)-3); That way that will ensure that new_data is not overflowed. Next: strcpy(message,username); strcat(message," : "); strcat(message,new_data); Now, you've truncated new_data and because new_data and message have the same length, you'd think that you couldn't overflow the message variable. Wrong, look at this code fragment: case IDC_CHANGENAME:
{
int len=GetWindowTextLength(GetDlgItem(hwnd,IDC_MAIN_EDIT));
if(len > 0)
{
char *new_name;
new_name=(char *)GlobalAlloc(GPTR,len+1);
GetDlgItemText(hwnd,IDC_MAIN_EDIT,new_name,len+1);
strcpy(username,"<");
strcat(username,new_name);
strcat(username,">");
SetDlgItemText(hwnd,IDC_MAIN_EDIT,"");
}
else
{
MessageBox(NULL,"please select a username","msg",NULL);
}
}There's more problems here: you allocate a buffer big enough to hold the name. Good, however, you then copy that onto the username variable which is only supposed to be 50 characters in length, and you copy it without length checking anyway. You can overflow this too, but let's say that you fix the first problem I pointed out (with new_data) and so only 1020 characters of data or so are copied into new_data. Okay, but then you strcat the 'username' variable onto it which can be (legitimately) 50 characters, so you're overflowing a 1070 character-or-so into a 1024 character buffer. My advice to fix these bugs is that you start checking out your program logic a little more and start using functions like this: A) snprintf B) strncpy* Hope this helped. * strncpy is still not entirely safe. It will -not- terminate the destination buffer with a \0 character, so you could have non-null termination issues, here's an example: char dest[256],finaldest[256]; strncpy(dest,user_input,sizeof(dest)); strcpy(finaldest,dest); /*ensures safe null termination on the dest buffer if it is used in subsequent copies*/ #define safer_strncpy(dest,src,size) \ strncpy(dest,src,sizeof(src)); dest[sizeof(dest)-1] = '\0'; |
|
|
|
|
|
#27 | |
|
Professional Programmer
|
I've also been meaning to ask, what's with the name, "chiba"? I don't think that's an... appropriate name for a chat messenger. Maybe it's not the chiba I'm thinking of.
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
|
|
#28 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
thanks for the info
|
|
|
|
|
|
#29 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
idk.....i just randomly thought of a name for it, it just popped into my head.
|
|
|
|
|
|
#30 |
|
Programmer
|
Did anyone ever say if this will or will not work over the Internet? j/w
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|