gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master d09f2a2: Fixed segfault in breaking filename t


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master d09f2a2: Fixed segfault in breaking filename to FITS keywords
Date: Fri, 28 Oct 2016 16:34:46 +0000 (UTC)

branch: master
commit d09f2a261ab8f4d6359f98e7521044a55dbb132a
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Fixed segfault in breaking filename to FITS keywords
    
    The job of `gal_fits_file_name_in_keywords' is to break the input filename
    into multiple FITS keywords. It doesn't just break up the filename based on
    the available space, it breaks it up based on the directories so it can be
    more safely used and read. Since the last character of a string has to be
    `/0', the largest position where a `/' could be placed is the second last
    byte. However, we were assuming that this is the last byte, so when the `/'
    fell on the last usable byte, we would have a segmentation fault. This is
    fixed now.
---
 lib/fits.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/fits.c b/lib/fits.c
index e543622..494f833 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -1409,7 +1409,7 @@ gal_fits_file_name_in_keywords(char *keynamebase, char 
*filename,
           /* Find the last place in the copied array that contains a
              '/' and put j on the next character (so it can be turned
              into a null character.*/
-          for(j=maxlength-1;j>0;--j)
+          for(j=maxlength-2;j>0;--j)
             if(value[j]=='/')
               {
                 value[j+1]='\0';



reply via email to

[Prev in Thread] Current Thread [Next in Thread]