Skip to content

Commit

Permalink
Fixed (potential) OOBs unveiled by link-time code-optimization (LTO). (
Browse files Browse the repository at this point in the history
…#60)

Fixed (potential) OOBs unveiled by link-time code-optimization (LTO). CPASSERT the length of the destination string prior to assignment.
  • Loading branch information
hfp committed Oct 30, 2018
1 parent 0d23b48 commit 9a24425
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/atom_upf.F
Original file line number Diff line number Diff line change
Expand Up @@ -343,17 +343,18 @@ SUBROUTINE upf_header_option(parser, pot)
CALL parser_get_object(parser, pot%comment)
CASE ("ELEMENT")
CALL parser_get_object(parser, line)
CPASSERT(2 <= LEN(pot%symbol))
pot%symbol = line(2:3)
CASE ("PSEUDO_TYPE")
CALL parser_get_object(parser, line)
line = ADJUSTL(line)
il = LEN_TRIM(line)
pot%pseudo_type = line(2:il-1)
READ (line(2:il-1), *) pot%pseudo_type
CASE ("RELATIVISTIC")
CALL parser_get_object(parser, line)
line = ADJUSTL(line)
il = LEN_TRIM(line)
pot%relativistic = line(2:il-1)
READ (line(2:il-1), *) pot%relativistic
CASE ("IS_ULTRASOFT")
CALL parser_get_object(parser, line)
line = ADJUSTL(line)
Expand Down
1 change: 1 addition & 0 deletions src/input/cp_output_handling.F
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ FUNCTION cp_print_key_generate_filename(logger, print_key, middle_name, extensio

CALL section_vals_val_get(print_key, "FILENAME", c_val=outPath)
IF (outPath(1:1) == '=') THEN
CPASSERT(LEN(outPath)-1 <= LEN(filename))
filename = outPath(2:)
RETURN
END IF
Expand Down

0 comments on commit 9a24425

Please sign in to comment.