Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skgb() does not handle reading past end of file gracefully #395

Open
edwardhartnett opened this issue May 16, 2023 · 0 comments
Open

skgb() does not handle reading past end of file gracefully #395

edwardhartnett opened this issue May 16, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@edwardhartnett
Copy link
Contributor

skgb() is supposed to handle attempts to read past end of file, but in fact this causes a memory problem.

See commented out code in test_skgb.F90 to test this.

 Testing skgb()...
           1         202       11183
           2       11591       18917
           3       30714       12644
           4       43564       15067
           5       58836       15042
           6       74084       10362
           7       84652       11326
           8       96184       21168
           9      117557       15123
          10      132886       19821
          11      152913       22210
          12      175331       15849
          13      191386       12631
          14      204222       21895
          15      226323       12785
          16      239313       15053
          17      254572       11342
          18      266120       12957
          19      279283       19567
          20      299055       15006
          21      314265       14962
          22      329433       12467
          23      342106       19677
          24      361989       10438
          25      372633       22082
          26      394921       12497
=================================================================
==69766==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffffffcf32 at pc 0x5555555abaf7 bp 0x7fffffffcaf0 sp 0x7fffffffcae0
READ of size 1 at 0x7fffffffcf32 thread T0
    #0 0x5555555abaf6 in mova2i_ /home/ed/NCEPLIBS-g2/src/mova2i.c:23
    #1 0x55555557d772 in g2_gbytesc_ /home/ed/NCEPLIBS-g2/src/g2_gbytesc.F90:84
    #2 0x55555557db26 in g2_gbytec_ /home/ed/NCEPLIBS-g2/src/g2_gbytesc.F90:25
    #3 0x5555555a7fc6 in skgb_ /home/ed/NCEPLIBS-g2/src/skgb.F90:46
    #4 0x555555565153 in test_skgb /home/ed/NCEPLIBS-g2/tests/test_skgb.F90:51
    #5 0x555555565664 in main /home/ed/NCEPLIBS-g2/tests/test_skgb.F90:7
    #6 0x7ffff6e48082 in __libc_start_main ../csu/libc-start.c:308
    #7 0x55555556473d in _start (/home/ed/NCEPLIBS-g2/b/tests/test_skgb_4+0x1073d)

Address 0x7fffffffcf32 is located in stack of thread T0 at offset 770 in frame
    #0 0x5555555a779c in skgb_ /home/ed/NCEPLIBS-g2/src/skgb.F90:20

@edwardhartnett edwardhartnett added the bug Something isn't working label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant