From 94e023fab01a0eb17117ce4ad46384ef78997c61 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Devenyi" Date: Fri, 14 Aug 2026 23:21:23 -0400 Subject: [PATCH] BUG: Bound the aux_file copy by sizeof rather than a repeated 24 strncpy writes no terminator when the source fills the destination, so the copy is safe only because of the line that follows it, which is what -Wstringop-truncation reports. Copying at most sizeof(dest) - 1 makes the call safe on its own and takes the size from the buffer rather than a literal repeated twice. (cherry picked from commit 5c1665c6d974465e87acaff4f3f04126057726de) --- fsliolib/fslio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fsliolib/fslio.c b/fsliolib/fslio.c index 5b775e77..a5564397 100644 --- a/fsliolib/fslio.c +++ b/fsliolib/fslio.c @@ -1355,8 +1355,8 @@ void FslSetAuxFile(FSLIO *fslio,const char *aux_file) { if (fslio==NULL) FSLIOERR("FslSetAuxFile: Null pointer passed for FSLIO"); if (fslio->niftiptr!=NULL) { - strncpy(fslio->niftiptr->aux_file, aux_file, 24); - fslio->niftiptr->aux_file[24-1] = '\0'; + strncpy(fslio->niftiptr->aux_file,aux_file,sizeof(fslio->niftiptr->aux_file)-1); + fslio->niftiptr->aux_file[sizeof(fslio->niftiptr->aux_file)-1] = '\0'; } if (fslio->mincptr!=NULL) { fprintf(stderr,"Warning:: Minc is not yet supported\n");