search : delimiter in ipsec.secrets entries from the rear
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
|
*
|
||||||
|
* RCSID $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -1394,7 +1396,7 @@ static void load_secrets(private_local_credential_store_t *this, bool reload)
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!extract_token(&ids, ':', &line))
|
if (!extract_last_token(&ids, ':', &line))
|
||||||
{
|
{
|
||||||
DBG1(DBG_CFG, "line %d: missing ':' separator", line_nr);
|
DBG1(DBG_CFG, "line %d: missing ':' separator", line_nr);
|
||||||
goto error;
|
goto error;
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
|
*
|
||||||
|
* RCSID $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -45,7 +47,7 @@ bool match(const char *pattern, const chunk_t *ch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extracts a token ending with a given termination symbol
|
* extracts a token ending with the first occurrence of a given termination symbol
|
||||||
*/
|
*/
|
||||||
bool extract_token(chunk_t *token, const char termination, chunk_t *src)
|
bool extract_token(chunk_t *token, const char termination, chunk_t *src)
|
||||||
{
|
{
|
||||||
@@ -70,6 +72,32 @@ bool extract_token(chunk_t *token, const char termination, chunk_t *src)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* extracts a token ending with the last occurrence of a given termination symbol
|
||||||
|
*/
|
||||||
|
bool extract_last_token(chunk_t *token, const char termination, chunk_t *src)
|
||||||
|
{
|
||||||
|
u_char *eot = memrchr(src->ptr, termination, src->len);
|
||||||
|
|
||||||
|
/* initialize empty token */
|
||||||
|
*token = chunk_empty;
|
||||||
|
|
||||||
|
if (eot == NULL) /* termination symbol not found */
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* extract token */
|
||||||
|
token->ptr = src->ptr;
|
||||||
|
token->len = (u_int)(eot - src->ptr);
|
||||||
|
|
||||||
|
/* advance src pointer after termination symbol */
|
||||||
|
src->ptr = eot + 1;
|
||||||
|
src->len -= (token->len + 1);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetches a new line terminated by \n or \r\n
|
* fetches a new line terminated by \n or \r\n
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
|
*
|
||||||
|
* RCSID $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
@@ -32,10 +34,15 @@ bool eat_whitespace(chunk_t *src);
|
|||||||
bool match(const char *pattern, const chunk_t *ch);
|
bool match(const char *pattern, const chunk_t *ch);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Extracts a token ending with a given termination symbol
|
* @brief Extracts a token ending with the first occurence a given termination symbol
|
||||||
*/
|
*/
|
||||||
bool extract_token(chunk_t *token, const char termination, chunk_t *src);
|
bool extract_token(chunk_t *token, const char termination, chunk_t *src);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Extracts a token ending with the last occurence a given termination symbol
|
||||||
|
*/
|
||||||
|
bool extract_last_token(chunk_t *token, const char termination, chunk_t *src);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fetches a new text line terminated by \n or \r\n
|
* @brief Fetches a new text line terminated by \n or \r\n
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user