Check entered address range is valid

This is a discussion on Check entered address range is valid within the C Programming forums, part of the General Programming Boards category; Hey I would like to know how to check whether a user specified start address and end address (for data ...

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    27

    Check entered address range is valid

    Hey

    I would like to know how to check whether a user specified start address and end address (for data locations) is valid or not

    Is there a way to check the given address is actually part of the program?

    I have malloc-ed to a variable, so would the correct method be to check whether the user inputted address is within that variable's scope?

    Thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,980
    Err... why would be user be providing an object's address as input?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2012
    Posts
    27
    I want to be able to write the values from a start address to the given end address to a file.

    So the value starting at for example, *(hex+10) can be the first value written, to *(hex+20) when in reality the data starts from *(hex)

    So I just need to either check the address provided is within the program's allocation and that its within the hex malloc

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,980
    Sounds like you should be writing offsets instead, e.g., 10 and 20.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Apr 2012
    Posts
    27
    cheers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Searching for a particular address in a given range
    By Sjvlsdsd in forum C Programming
    Replies: 9
    Last Post: 07-30-2011, 08:22 AM
  2. random number within user entered range
    By me77 in forum C++ Programming
    Replies: 5
    Last Post: 03-10-2010, 07:11 PM
  3. validating memory - minimum address of valid location
    By m37h0d in forum C++ Programming
    Replies: 12
    Last Post: 09-05-2008, 10:50 PM
  4. Minimum valid address value
    By BMintern in forum C Programming
    Replies: 6
    Last Post: 04-12-2008, 08:21 AM
  5. Ignoring data after valid entered
    By wpr101 in forum C++ Programming
    Replies: 2
    Last Post: 01-16-2003, 01:55 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21