From ec5920ac2ed11b29135acb834ce6d633259aad75 Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Tue, 15 Apr 2014 20:09:21 +0200 Subject: rfc4251: move remaining non-inline functions to impl file --- rfc4251.C | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 rfc4251.C (limited to 'rfc4251.C') diff --git a/rfc4251.C b/rfc4251.C new file mode 100644 index 0000000..0d59420 --- /dev/null +++ b/rfc4251.C @@ -0,0 +1,32 @@ +#include "rfc4251.h" + +rfc4251string::rfc4251string (std::vector 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::max()) + throw std::length_error{"32-bit limit for rfc4251string exceeded"}; + value.insert(value.end(), it->data(), it->data() + it->size()); + ++it; + if (it == v.end()) + break; + value.push_back(','); + } +} + +rfc4251string::operator std::vector () const { + std::vector 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; + } + return ret; +} -- cgit v1.2.3 From 57f385d44cdc4eec0d0d2de7ea04ade6f4154dbf Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Tue, 27 May 2014 00:16:40 +0200 Subject: update copyright --- rfc4251.C | 24 ++++++++++++++++++++++++ rfc4251.h | 2 +- ssh-agent-filter.C | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'rfc4251.C') diff --git a/rfc4251.C b/rfc4251.C index 0d59420..8ca5f2b 100644 --- a/rfc4251.C +++ b/rfc4251.C @@ -1,3 +1,27 @@ +/* + * rfc4251.C -- support for name-list type from RFC 4251, section 5 + * + * These are the conversions between an rfc4251string containing a name-list + * and vector. + * + * Copyright (C) 2013 Timo Weingärtner + * + * This file is part of ssh-agent-filter. + * + * ssh-agent-filter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ssh-agent-filter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ssh-agent-filter. If not, see . + */ + #include "rfc4251.h" rfc4251string::rfc4251string (std::vector const & v) { diff --git a/rfc4251.h b/rfc4251.h index 35f97fb..d9ac93e 100644 --- a/rfc4251.h +++ b/rfc4251.h @@ -10,7 +10,7 @@ * those structs contain the objects in their RFC 4251 representation, * conversions are provided via constructors and cast operators * - * Copyright (C) 2013 Timo Weingärtner + * Copyright (C) 2013-2014 Timo Weingärtner * * This file is part of ssh-agent-filter. * diff --git a/ssh-agent-filter.C b/ssh-agent-filter.C index 7ac2687..faa31f9 100644 --- a/ssh-agent-filter.C +++ b/ssh-agent-filter.C @@ -1,7 +1,7 @@ /* * ssh-agent-filter.C -- filtering proxy for ssh-agent meant to be forwarded to untrusted servers * - * Copyright (C) 2013 Timo Weingärtner + * Copyright (C) 2013-2014 Timo Weingärtner * * This file is part of ssh-agent-filter. * -- cgit v1.2.3