Uups, I overwrote something



  • (Using Fortran 90/95)

    If you first define a fixed size array,

      INTEGER i_array(i_var_1 * i_var_2 * 8)

    then assign values to it,

      index = 0
      Do i = 1, i_var_3
        If ( some_boolean_expression ) Then
          index = index + 1
          i_array(index) = some_integer_expression
        EndIf
      EndDo

    And only then check for array bounds violations

      If ( index > i_var_1 * i_var_2 * 8 ) Then
        ErrorStatus = 10
        Call Ereport("********", ErrorStatus, "over-writing due to index size")
      EndIf

    Chances are, the program crashes before you even get to that check.



  • @Skywolf said:

    (Using Fortran 90/95)

    A'yep, found yer' problem, mister.

     

    @Skywolf said:

    Chances are, the program crashes before you even get to that check.

    Will it?  I don't know much about Fortran, but usually this just corrupts the heap.  The only way it would crash outright is if it tried to write to a protected page (contingent on OS and architecture, of course).  Still, it's really bad and obviously checking for it after-the-fact is pointless.



  •  "When I point a pistol at my foot and pull the trigger, a hole appears and it hurts."

    The language specification doesn't cover doing stupid things, so the processor may do anything when you do them.  If you want array bounds checking, turn them on with the compiler switch. This will slow processing down, but enables you to catch the problems. When the program works, you can turn off array bounds processing (among other options).

     



  • @4merK0d34 said:

    "When I point a pistol at my foot and pull the trigger, a hole appears and it hurts."
    QFT.

    I think you mixed up your username and password inputs when you registered though.



  • @Zecc said:

    I think you mixed up your username and password inputs when you registered though.
     

     

    Well, at least he has a strong username that can't easily be guessed or bruteforced.



  • @dhromed said:

    @Zecc said:

    I think you mixed up your username and password inputs when you registered though.
     

     

    Well, at least he has a strong username that can't easily be guessed or bruteforced.

     

     

    That password must have been taken...



  • Indeed, that doubles the security, as any wanna-be hacker now has to guess the username too! Just make sure to keep it in a safe place, don't write it on a post-it on your screen, or post it on internet message boards. Oh, wait.



  • @Abdiel said:

    or post it on internet message boards. Oh, wait.
     

    Well, e asn't posted it, as'e?



  • @Abdiel said:

    Indeed, that doubles the security, as any wanna-be hacker now has to guess the username too! Just make sure to keep it in a safe place, don't write it on a post-it on your screen, or post it on internet message boards. Oh, wait.

    Thank you for explaining the joke.  I totally didn't get it on my own.



  • @dhromed said:

    @Abdiel said:
    or post it on internet message boards. Oh, wait.
    Well, e asn't posted it, as'e?
    QFCockney



  • @belgariontheking said:

    QFCockney
     

    I likes the cockney.


Log in to reply