Commit bf563e1
committed
DAG: Validate environment variables better. [skip ci]
Make the environment variables named constants. Add a helper function
to convert strings to integers using a more thorough validation, such
that if it returns a non-negative integer for an input string, the
string definitely represents the number. In dag_activate() reject
integers that are not one of the valid values. In case of a validation
error include the rejected string value in the error message, not the
parsed integer value.
Before:
# ERF_FCS_BITS=invalid tcpdump -ni dag0
(works as if ERF_FCS_BITS=0)
# ERF_DONT_STRIP_FCS=never tcpdump -ni dag0
(works as if ERF_DONT_STRIP_FCS=1)
After:
# ERF_FCS_BITS=invalid tcpdump -ni dag0
tcpdump: dag_activate dag0: invalid ERF_FCS_BITS value (invalid) in
environment
# ERF_DONT_STRIP_FCS=never tcpdump -ni dag0
tcpdump: dag_activate dag0: invalid ERF_DONT_STRIP_FCS value (never) in
environment1 parent e645387 commit bf563e1
3 files changed
+54
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
96 | 120 | | |
97 | 121 | | |
98 | 122 | | |
| |||
829 | 853 | | |
830 | 854 | | |
831 | 855 | | |
832 | | - | |
| 856 | + | |
| 857 | + | |
833 | 858 | | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
847 | 872 | | |
848 | 873 | | |
849 | 874 | | |
850 | 875 | | |
851 | 876 | | |
852 | | - | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
853 | 882 | | |
854 | 883 | | |
855 | 884 | | |
856 | 885 | | |
857 | 886 | | |
858 | 887 | | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
859 | 895 | | |
860 | 896 | | |
861 | 897 | | |
| |||
0 commit comments