Sun, 17 Dec 2023 15:33:50 +0100
fix faulty string to int conversion utilities
Probably it was expected that errno is set to EINVAL when illegal characters are encountered. But this is not standard and does not happen on every system, allowing illegal strings to be parsed as valid integers.
418
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | #!/bin/sh |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | # |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | # |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | # Copyright 2018 Olaf Wintermann. All rights reserved. |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | # |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | # Redistribution and use in source and binary forms, with or without |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | # modification, are permitted provided that the following conditions are met: |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | # |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | # 1. Redistributions of source code must retain the above copyright |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | # notice, this list of conditions and the following disclaimer. |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | # |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | # 2. Redistributions in binary form must reproduce the above copyright |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | # notice, this list of conditions and the following disclaimer in the |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | # documentation and/or other materials provided with the distribution. |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | # |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | # POSSIBILITY OF SUCH DAMAGE. |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | # |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | if [ -z "$DAV_BIN" ]; |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | then |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | echo "DAV_BIN variable not set" |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | exit 1 |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | fi |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | # 1. test |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | OUT=`$DAV_BIN info dav-test-repo` |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | if [ $? -ne 0 ]; |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | then |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | echo "dav info returned" $? |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | exit 2 |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | fi |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | echo $OUT | grep "type: collection" > /dev/null |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | if [ $? -ne 0 ]; |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | then |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | echo "wrong resource type" |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | exit 2 |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | fi |
cfdeeed64ac5
adds shellscript test-suite for binaries
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 |