From 6f45656fa68aab60e38dfdda3ddd34567b33f273 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. --- fsliolib/fslio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fsliolib/fslio.c b/fsliolib/fslio.c index aee7687b..6eb00e06 100644 --- a/fsliolib/fslio.c +++ b/fsliolib/fslio.c @@ -1368,8 +1368,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");