Skip to content

Commit

Permalink
mimickying strdup to avoid a -Wstringop-overflow warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Iximiel committed Aug 7, 2024
1 parent bd13216 commit 09423e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/wrapper/Plumed.h
Original file line number Diff line number Diff line change
Expand Up @@ -3831,7 +3831,7 @@ void* plumed_attempt_dlopen(const char*path,int mode) {
__PLUMED_FPRINTF(stderr,"+++ Allocation error +++\n");
__PLUMED_WRAPPER_STD abort();
}
__PLUMED_WRAPPER_STD strncpy(pathcopy,path,strlenpath+1);
__PLUMED_WRAPPER_STD strcpy(pathcopy,path);

Check failure

Code scanning / CodeQL

Unbounded write Critical

This 'call to strcpy' with input from
an environment variable
may overflow the destination.
pc=pathcopy+strlenpath-6;
while(pc>=pathcopy && __PLUMED_WRAPPER_STD memcmp(pc,"Kernel",6)) pc--;
if(pc>=pathcopy) {
Expand Down

0 comments on commit 09423e8

Please sign in to comment.