diff options
author | Andy Grover <agrover@redhat.com> | 2015-11-17 10:07:19 -0800 |
---|---|---|
committer | Andy Grover <agrover@redhat.com> | 2015-11-17 10:07:19 -0800 |
commit | 7ccca210c7f00176cfcf2aa2f40df3d0ee9c5a30 (patch) | |
tree | 4d042bc0c21d7dde778524d3f1e70c1cb701b6ef | |
parent | 2bcc4cd809409525bca62f09b08e97c2b97b0d43 (diff) | |
download | rtslib-fb-7ccca210c7f00176cfcf2aa2f40df3d0ee9c5a30.tar.gz |
Restrict auth parameters to 255 chars
See https://bugzilla.redhat.com/show_bug.cgi?id=1279942
The kernel will truncate all auth paramaters over 255 characters. Instead
of silently altering what the user entered, throw an exception.
Make exception RTSLibError for consistency with the rest of the library.
Change check for 'NULL' to match.
Signed-off-by: Andy Grover <agrover@redhat.com>
-rw-r--r-- | rtslib/utils.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/rtslib/utils.py b/rtslib/utils.py index 286dbc1..46f10c3 100644 --- a/rtslib/utils.py +++ b/rtslib/utils.py @@ -451,7 +451,9 @@ def _set_auth_attr(self, value, attribute, ignore=False): path = "%s/%s" % (self.path, attribute) value = value.strip() if value == "NULL": - raise ValueError("'NULL' is not a permitted value") + raise RTSLibError("'NULL' is not a permitted value") + if len(value) > 255: + raise RTSLibError("Value longer than maximum length of 255") if value == '': value = "NULL" try: |