sscanf - string buffer overflow
#1

I know what this warning means, but I shouldn't be getting it.

In an /ame command:
pawn Код:
new action[500];
if(sscanf(params, "s[500]", action))
I know it shouldn't be 500, it should be 124 (which I got from 128 - 5 ("/ame ") and + the null terminator) but I changed it to 500 to see if it actually was a problem with the string length being too small.

However, I still get "sscanf warning: String buffer overflow.", I tested how many characters it takes to set off the warning and it's as soon as I type anything above "/ame iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii". So anything over 97 characters.
(ignore the space in the i's, no idea why the forums added that but I can't get rid of it)

Does anyone know why this is?
Reply
#2

You are not even allowed to use sccanf with the s specifier only, its completely wrong as ****** did say that and its so obvious why. Use the isnull function instead to detect if the string is empty and then use params rather than action.
Reply
#3

Are you sure that it is caused by this instance of sscanf? Perhaps your functions calls another function that also uses sscanf? Even though using sscanf for strings is quite redundant (as Ralfie said) it should actually work.
Reply
#4

Yeah that makes complete sense, I should've thought of that, I would imagine what I'm doing would work though. I remember there was a ton of documentation on ******' GitHub I think but obviously that's gone now so I'm just working off of some of the restored topics, but yeah it makes sense that there's no use for sscanf here.

And yeah Vince, I checked for that but the only functions that are getting called after the sscanf check are format, SetPlayerChatBubble and SendClientMessage.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)