lopsub-1.0.4 master pu v1.0.4
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 28 Jun 2023 14:45:43 +0000 (16:45 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 2 Jul 2023 14:19:41 +0000 (16:19 +0200)
Makefile
NEWS
debian/changelog
debian/copyright
lopsub-suite.5.m4
lopsub.c

index 548c96ff0e6298e29d8f247940a4f446e6757d35..97d135a069773da221e44ade4915fd194c83602d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,8 @@ INSTALL := install
 GZIP := gzip -fn9
 ZCAT := zcat
 
+CC += -ffile-prefix-map=$(CURDIR)=.
+
 dummy != $(M4) /dev/null || printf 'failed'
 ifeq ($(dummy), failed)
 $(error m4 is required to build this package)
diff --git a/NEWS b/NEWS
index 13a7ed237c809ff18013c7550d2cd5889605ab93..8508f442c72c5ce0d96e2bee05a9be1bc5feacb5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+Noteworthy changes in lopsub-1.0.4 (2023-07-02)
+===============================================
+* make the build reproducible (Chris Lamb, Vagrant Cascadian)
+* improvements to the build system
+* documentation fixes
+* avoid NULL pointer dereference in argument parsing
+
 Noteworthy changes in lopsub-1.0.3 (2019-05-19)
 ===============================================
 * build a shared library instead of a static one
index e9ea70316c5865c1db50f95a361c9708cce3108d..08cd28f6dfaa373f405c1733e5453b6bf8270e01 100644 (file)
@@ -1,3 +1,12 @@
+liblopsub (1.0.4-1) unstable; urgency=low
+
+  * Make the build reproducible (Chris Lamb, Vagrant Cascadian). Closes:
+    #1039617, #1039618
+  * Avoid crash due to a NULL pointer dereference in certain cases
+  * Minor cleanups and fixes, see NEWS for details.
+
+ -- Andre Noll <maan@tuebingen.mpg.de>  Sun, 02 Jul 2023 14:12:13 +0200
+
 liblopsub (1.0.3-2) unstable; urgency=low
 
   * Make the output of lopsubgen reproducible.
index 95fcd00deeab89fcf4b84e4b4d0a18fd92c66122..ee4fb2bfedd5546b27d5052f8a108b5f15411012 100644 (file)
@@ -1,4 +1,4 @@
-Copyright 2016 Andre Noll <maan@tuebingen.mpg.de>
+Copyright 2016-2023 Andre Noll <maan@tuebingen.mpg.de>
 
 This package is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License, version 3
index 0244c38a49f056f086476c3e3238a61241e698a3..cd607a5ec5bb074d3bef44efe09b56f465e74068 100644 (file)
@@ -144,9 +144,7 @@ way with
 and
 .BR [/conclusion] .
 Both texts will become part of the manual page, but are not not part
-of the short or long help. Like for the
-.B section
-directive, arbitrary roff source may be included here.
+of the short or long help.
 .TP
 .B aux_info_prefix
 This text is shown at the bottom of each command before the value of the
index a9e401f259f63422e3db094080cc66ecb808c694..b5017c32db1e45b87d3d765c19862503558421f9 100644 (file)
--- a/lopsub.c
+++ b/lopsub.c
@@ -632,17 +632,23 @@ static int lls_parse_arg(struct lls_arg *la, const struct lls_option *opts,
        bool multiple;
        int idx, ret;
 
-       if (!la->arg)
-               goto success;
-       if (opt->arg_info == LLS_NO_ARGUMENT) {
+       if (la->arg && opt->arg_info == LLS_NO_ARGUMENT) {
                xasprintf(errctx, "arg: %s, option: %s", la->arg, opt->name);
                return -E_LLS_ARG_GIVEN;
        }
        multiple = opt->flags & LLS_MULTIPLE;
+       if (opt->arg_type == LLS_STRING && !opt->values && !multiple) {
+               if (lor->value) { /* discard previous value */
+                       free(lor->value[0].string_val);
+                       free(lor->value);
+                       lor->value = NULL;
+               }
+       }
+       if (!la->arg)
+               goto success;
        idx = multiple? lor->given : 0;
-       if (lor->given == 0 || multiple) {
-               ret = xrealloc(&lor->value,
-                       (lor->given + 1) * sizeof(*lor->value));
+       if (!lor->value || multiple) {
+               ret = xrealloc(&lor->value, (idx + 1) * sizeof(*lor->value));
                if (ret < 0) {
                        xasprintf(errctx, "option value array for --%s",
                                opt->name);
@@ -651,8 +657,6 @@ static int lls_parse_arg(struct lls_arg *la, const struct lls_option *opts,
        }
        switch (opt->arg_type) {
        case LLS_STRING:
-               if (!opt->values && lor->given > 0 && !multiple)
-                       free(lor->value[idx].string_val);
                if (opt->values) {
                        ret = check_enum_arg(la->arg, opt, errctx);
                        if (ret < 0)
@@ -736,10 +740,11 @@ int lls_check_arg_count(const struct lls_parse_result *lpr,
                        xasprintf(errctx, "no non-option args allowed, "
                                "%u given", lpr->num_inputs);
                else
-                       xasprintf(errctx, "%s %u non-option args allowed, "
-                               "%u given", min_argc < max_argc?
-                               "at most" : "exactly",
-                               max_argc, lpr->num_inputs);
+                       xasprintf(errctx, "%s %u non-option args %s, %u given",
+                               min_argc < max_argc? "at most" : "exactly",
+                               max_argc,
+                               min_argc < max_argc? "allowed" : "required",
+                               lpr->num_inputs);
                return -E_LLS_BAD_ARG_COUNT;
        }
        return 1;