aboutsummaryrefslogtreecommitdiff
path: root/rfc4251.C
diff options
context:
space:
mode:
authorTimo Weingärtner <timo@tiwe.de>2026-03-07 22:36:10 +0100
committerTimo Weingärtner <timo@tiwe.de>2026-03-07 22:36:10 +0100
commit960aa108a9cd4ff31932653fdc847d492901a37b (patch)
tree905386c7eb0a7d470ff90b8428f2a70f3327743e /rfc4251.C
parentf47546025f34ff4294b7f6b3e672c521c8d2d3f5 (diff)
parent8bd8f61f2ab2978a0a1bf7aa6f19a6352b9769c9 (diff)
downloadssh-agent-filter-960aa108a9cd4ff31932653fdc847d492901a37b.tar.gz
Merge tag '0.5.3' into debian
0.5.3
Diffstat (limited to 'rfc4251.C')
-rw-r--r--rfc4251.C41
1 files changed, 20 insertions, 21 deletions
diff --git a/rfc4251.C b/rfc4251.C
index 5ea0a93..05ef8b8 100644
--- a/rfc4251.C
+++ b/rfc4251.C
@@ -1,10 +1,10 @@
/*
* rfc4251.C -- support for name-list type from RFC 4251, section 5
*
- * These are the conversions between an rfc4251::string containing a name-list
- * and vector<string>.
+ * These are the conversions between an rfc4251::name_list and
+ * std::vector<std::string>.
*
- * Copyright (C) 2013,2015 Timo Weingärtner <timo@tiwe.de>
+ * Copyright (C) 2013,2015,2021 Timo Weingärtner <timo@tiwe.de>
*
* This file is part of ssh-agent-filter.
*
@@ -26,34 +26,33 @@
namespace rfc4251 {
-string::string (std::vector<std::string> const & v) {
+name_list::name_list (std::vector<std::string> const & v) {
for (auto it = v.begin(); it != v.end();) {
if (it->size() == 0)
throw std::length_error{"name of zero length"};
- if (value.size() + it->size() > std::numeric_limits<uint32_t>::max())
- throw std::length_error{"32-bit limit for rfc4251::string exceeded"};
- value.insert(value.end(), it->data(), it->data() + it->size());
+ check_length_against_limit(buf.size() + it->size());
+ buf.insert(buf.end(), it->data(), it->data() + it->size());
++it;
if (it == v.end())
break;
- value.push_back(',');
+ buf.push_back(',');
}
}
-string::operator std::vector<std::string> () const {
- std::vector<std::string> ret;
- auto name_start = value.begin();
- if (name_start != value.end())
- for (auto it = name_start; ; ++it) {
- if (it == value.end() or *it == ',') {
- if (it == name_start)
- throw std::length_error{"name of zero length"};
- ret.emplace_back(name_start, it);
- name_start = it + 1;
- }
- if (it == value.end())
- break;
+name_list::operator std::vector<std::string> () const {
+ std::vector<std::string> ret{};
+ if (buf.empty()) return ret;
+ auto name_start = buf.begin();
+ for (auto it = name_start; ; ++it) {
+ if (it == buf.end() or *it == ',') {
+ if (it == name_start)
+ throw std::length_error{"name of zero length"};
+ ret.emplace_back(name_start, it);
+ name_start = it + 1;
}
+ if (it == buf.end())
+ break;
+ }
return ret;
}