Raised This Month: $ Target: $400
 0% 

CODERS - Use format() correctly! Or I will beat you!


Post New Thread Reply   
 
Thread Tools Display Modes
VEN
Veteran Member
Join Date: Jan 2005
Old 02-27-2006 , 09:24  
Reply With Quote #21

Quote:
Originally Posted by mysticssjgoku4
what if I had just one extra % in there? Is that ok?

Example: I want this to read as a percent.

Code:
format(string,sizeof(string),"Percent: %i%",number) client_print(id,print_chat,string)
Well, i believe it should be
Code:
format(string,sizeof buffer,"Percent: %i%%",number) client_print(id,print_chat,"%s",string)
VEN is offline
Marticus
Member
Join Date: Nov 2004
Old 02-27-2006 , 11:06  
Reply With Quote #22

So, what is a way to prevent the security risk of passing user supplied strings?
Marticus is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 02-27-2006 , 12:04  
Reply With Quote #23

Do what is said....
Code:
new ClientSaid[46] read_args(ClientSaid , 45) client_print( id , print_chat , "%s" , ClientSaid)
instead of
Code:
new ClientSaid[46] read_args(ClientSaid , 45) client_print( id , print_chat , ClientSaid)
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Marticus
Member
Join Date: Nov 2004
Old 02-27-2006 , 18:17  
Reply With Quote #24

Well, that's how I've been doing it because I didn't know it could be done the other way However, I'll keep this in mind if I am looking at other people's code (OPC), ahh yeah.
Marticus is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode