Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Graal Stock Market (https://forums.graalonline.com/forums/showthread.php?t=134267716)

ff7chocoboknight 01-03-2013 06:09 PM

Dsider trollin' the nerds. lol

Gunderak 01-03-2013 11:07 PM

Quote:

Originally Posted by BlueMelon (Post 1711462)
PHP Code:

  if(params[0] == "Buy"){
    
temp.rate Stocks.stock_price.(@params[1]);
    
temp.amnt params[2];
    
temp.price amnt*rate;
    if(
clientr.stockcash >= price){
      
clientr.stockcash -= price;
      
clientr.stocks.(@int(random(1,9999999)))= {params[1], rateamnt};
      
clientr.stockcash clientr.stockcash.substring(0clientr.stockcash.pos(".") + 3);
    }
  }
  if(
params[0] == "Sell"){
    
temp.rate Stocks.stock_price.(@params[1]);
    for(
temp.getstringkeys("clientr.stocks.")){
      
temp.amnt clientr.stocks.(@i)[2];
      
temp.price amnt*rate;
      
temp.checkname clientr.stocks.(@i)[0];
      if(
checkname == params[1]){
        
temp.checkrate clientr.stocks.(@i)[1];
        if(
checkrate.pos(params[2]) >= 0){
          
temp.checkquantity clientr.stocks.(@i)[2];
          if(
checkquantity == params[3]){;
            if(
clientr.stocks.(@i) == null) return;
            
clientr.stocks.(@i) = null;
            
clientr.stockcash += price;
            return;
          }
        }
      }
    }
  } 

No validation? Huge security holes... What if params[1] or params[2] was negative?
clientr.stockcash -= -(price);

See where I'm going?

No validation?
It checks with the database NPC.
And I haven't thought about if stocks are that negative.
Generally people don't buy negative stocks..
And it does check if your money is greater than or equal to the stock you're buying.
And the priced is taken from the DB NPC.

BlueMelon 01-03-2013 11:58 PM

Validation as in, are you getting the right input? What if the triggers value (from clientside) was modified to send a negative value in the trigger? (Happened on era, that's why I'm saying this)

DustyPorViva 01-04-2013 12:03 AM

Checking for things like negative input is something you really need to get into a habit of doing. That kind of **** is what will let a player walk away from a bank with a free million dollars/gralats.

smirt362 01-04-2013 12:38 AM

Quote:

Originally Posted by DustyPorViva (Post 1711506)
Checking for things like negative input is something you really need to get into a habit of doing. That kind of **** is what will let a player walk away from a bank with a free million dollars/gralats.

Delteria's banking system was like this

Hezzy002 01-04-2013 01:02 AM

Quote:

Originally Posted by Gunderak (Post 1711500)
No validation?
It checks with the database NPC.
And I haven't thought about if stocks are that negative.
Generally people don't buy negative stocks..
And it does check if your money is greater than or equal to the stock you're buying.
And the priced is taken from the DB NPC.

-rep for being retarded

Gunderak 01-04-2013 03:16 AM

The value can't be negative. As you can't buy - stocks.
I'll add an extra check anyway..

xXziroXx 01-04-2013 03:50 AM

Quote:

Originally Posted by Gunderak (Post 1711515)
The value can't be negative. As you can't buy - stocks.
I'll add an extra check anyway..

You have t o realize that any clientsided code can be altered with various memory editors and whatnot, thus, anyone with the knowledge and enough free time on their hands can modify the trigger and send a negative value with it. ALWAYS make sure things are as they should be on clientside AND serverside.

BlueMelon 01-04-2013 03:51 AM

Quote:

Originally Posted by Gunderak (Post 1711515)
The value can't be negative. As you can't buy - stocks.
I'll add an extra check anyway..

Since you are sending the values FROM client-side, TO server-side, they can be edited before sending the values. The trigger params can be edited by anyone who knows how. Always do serverside validation, making sure you have the correct values...


All times are GMT +2. The time now is 08:52 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.