[Pkg-erlang-devel] Bug#911789: erlang-depends crashes on empty substvars file

Michael Kuhn suraia at ikkoku.de
Wed Oct 24 20:36:31 BST 2018


Package: erlang
Severity: normal
Tags: patch

Dear Maintainer,

erlang-depends crashes when the corresponding substvars file is empty.
This causes crashes on Ubuntu, where dpkg-shlibdeps sometimes creates
empty substvars files:

escript: exception error: no function clause matching string:substr([],1,-1) (string.erl, line 1774)
  in function  erl_eval:do_apply/6 (erl_eval.erl, line 670)
  in call from erl_eval:expr/5 (erl_eval.erl, line 438)
  in call from erl_eval:exprs/5 (erl_eval.erl, line 122)
  in call from erl_eval:local_func/6 (erl_eval.erl, line 557)
  in call from erl_eval:exprs/5 (erl_eval.erl, line 122)
  in call from lists:foreach/2 (lists.erl, line 1338)
dh_rebar: erlang-depends -perlang-p1-zlib returned exit code 127

See: https://launchpadlibrarian.net/379512161/buildlog_ubuntu-cosmic-amd64.erlang-p1-zlib_1.0.4-2_BUILDING.txt.gz

The attached patch fixes the problem.

-- System Information:
Debian Release: buster/sid
  APT prefers cosmic-updates
  APT policy: (500, 'cosmic-updates'), (500, 'cosmic-security'), (500, 'cosmic')
Architecture: amd64 (x86_64)

Kernel: Linux 4.18.0-10-generic (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages erlang depends on:
ii  erlang-asn1           1:20.3.8.5+dfsg-1build1
ii  erlang-base           1:20.3.8.5+dfsg-1build1
pn  erlang-common-test    <none>
pn  erlang-corba          <none>
ii  erlang-crypto         1:20.3.8.5+dfsg-1build1
pn  erlang-debugger       <none>
pn  erlang-dev            <none>
pn  erlang-dialyzer       <none>
pn  erlang-diameter       <none>
ii  erlang-edoc           1:20.3.8.5+dfsg-1build1
pn  erlang-eldap          <none>
pn  erlang-erl-docgen     <none>
pn  erlang-et             <none>
pn  erlang-eunit          <none>
pn  erlang-ic             <none>
ii  erlang-inets          1:20.3.8.5+dfsg-1build1
pn  erlang-megaco         <none>
ii  erlang-mnesia         1:20.3.8.5+dfsg-1build1
pn  erlang-observer       <none>
ii  erlang-odbc           1:20.3.8.5+dfsg-1build1
ii  erlang-os-mon         1:20.3.8.5+dfsg-1build1
pn  erlang-parsetools     <none>
ii  erlang-public-key     1:20.3.8.5+dfsg-1build1
pn  erlang-reltool        <none>
ii  erlang-runtime-tools  1:20.3.8.5+dfsg-1build1
ii  erlang-snmp           1:20.3.8.5+dfsg-1build1
pn  erlang-ssh            <none>
ii  erlang-ssl            1:20.3.8.5+dfsg-1build1
ii  erlang-syntax-tools   1:20.3.8.5+dfsg-1build1
pn  erlang-tools          <none>
pn  erlang-wx             <none>
ii  erlang-xmerl          1:20.3.8.5+dfsg-1build1

Versions of packages erlang recommends:
pn  erlang-examples    <none>
pn  erlang-ic-java     <none>
pn  erlang-jinterface  <none>
pn  erlang-mode        <none>
pn  erlang-src         <none>

Versions of packages erlang suggests:
pn  erlang-doc       <none>
pn  erlang-manpages  <none>
-------------- next part --------------
diff -Nru erlang-20.3.8.5+dfsg/debian/scripts/erlang-depends.in erlang-20.3.8.5+dfsg/debian/scripts/erlang-depends.in
--- erlang-20.3.8.5+dfsg/debian/scripts/erlang-depends.in	2018-08-13 16:56:38.000000000 +0200
+++ erlang-20.3.8.5+dfsg/debian/scripts/erlang-depends.in	2018-10-24 18:05:57.000000000 +0200
@@ -342,8 +342,10 @@
 
 	    Len = string:len(StrData),
 	    StrData2 = case Len - string:rstr(StrData, "\n") of
-			    0 ->
+			    0 when Len > 0 ->
 				string:left(StrData, Len - 1);
+			    0 when Len == 0 ->
+				StrData;
 			    _ ->
 				StrData
 		       end,
@@ -406,8 +408,10 @@
 
 	    Len = string:len(StrData),
 	    StrData2 = case Len - string:rstr(StrData, "\n") of
-			    0 ->
+			    0 when Len > 0 ->
 				string:left(StrData, Len - 1);
+			    0 when Len == 0 ->
+				StrData;
 			    _ ->
 				StrData
 		       end,


More information about the Pkg-erlang-devel mailing list