gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 65c2b50: CosmicCalculator: check applied in va


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 65c2b50: CosmicCalculator: check applied in values to --obsline option
Date: Fri, 9 Aug 2019 13:32:26 -0400 (EDT)

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

    CosmicCalculator: check applied in values to --obsline option
    
    Until now, if a single value was given to this option, we would get a
    segmentation fault. This is because it wouldn't check if the option is
    given more than one value.
    
    With this commit, if no value is given after the first, CosmicCalculator
    aborts with an informative error.
    
    Since a small change was made in the library, I also incremented the
    library soname version with this commit. Many more changes in the library
    will be made before the next major release.
    
    This fixes bug #56736.
---
 NEWS               | 15 +++++++++++++++
 bin/cosmiccal/ui.c |  8 ++++----
 configure.ac       |  2 +-
 lib/options.c      |  2 +-
 4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index 8e6741f..88a21c8 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,21 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
 Copyright (C) 2015-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
+* Noteworthy changes in release X.X (library X.X.X) (XXXX-XX-XX) [stable]
+
+** New features
+
+** Removed features
+
+** Changed features
+
+** Bugs fixed
+  bug #56736: CosmicCalculator crash when a single value given to --obsline
+
+
+
+
+
 * Noteworthy changes in release 0.10 (library 8.0.0) (2019-08-03) [stable]
 
 ** New features
diff --git a/bin/cosmiccal/ui.c b/bin/cosmiccal/ui.c
index 8e31895..d69e51a 100644
--- a/bin/cosmiccal/ui.c
+++ b/bin/cosmiccal/ui.c
@@ -279,10 +279,10 @@ ui_parse_obsline(struct argp_option *option, char *arg,
       obsline=gal_options_parse_list_of_numbers(arg, filename, lineno);
 
       /* Only one number must be given as second argument. */
-      if(obsline->size!=1)
-        error(EXIT_FAILURE, 0, "too many values (%zu) given to `--obsline'. "
-              "Only two values (line name/wavelengh, and observed wavelengh) "
-              "must be given", obsline->size+1);
+      if(obsline==NULL || obsline->size!=1)
+        error(EXIT_FAILURE, 0, "Wrong format given to `--obsline'. Only "
+              "two values (line name/wavelengh, and observed wavelengh) "
+              "must be given to it");
 
       /* If a wavelength is given directly as a number (not a name), then
          put that number in a second element of the array. */
diff --git a/configure.ac b/configure.ac
index fdb3ed4..d3b48c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,7 +50,7 @@ AC_CONFIG_MACRO_DIRS([bootstrapped/m4])
 
 # Library version, see the GNU Libtool manual ("Library interface versions"
 # section for the exact definition of each) for
-GAL_CURRENT=8
+GAL_CURRENT=9
 GAL_REVISION=0
 GAL_AGE=0
 GAL_LT_VERSION="${GAL_CURRENT}:${GAL_REVISION}:${GAL_AGE}"
diff --git a/lib/options.c b/lib/options.c
index 1103723..06c7c40 100644
--- a/lib/options.c
+++ b/lib/options.c
@@ -582,7 +582,7 @@ gal_options_parse_list_of_numbers(char *string, char 
*filename, size_t lineno)
   size_t minmapsize=-1;
 
   /* If we have an empty string, just return NULL. */
-  if(*string=='\0') return NULL;
+  if(string==NULL || *string=='\0') return NULL;
 
   /* Go through the input character by character. */
   while(string && *c!='\0')



reply via email to

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