tor  0.4.2.1-alpha-dev
Functions
qstring.c File Reference
#include "orconfig.h"
#include "lib/encoding/qstring.h"
#include "lib/malloc/malloc.h"
#include "lib/log/util_bug.h"

Go to the source code of this file.

Functions

static int get_qstring_length (const char *start, size_t in_len_max, int *chars_out)
 
const char * decode_qstring (const char *start, size_t in_len_max, char **out, size_t *out_len)
 

Detailed Description

Implement QuotedString parsing.

Note that this is only used for controller authentication; do not create new users for this. Instead, prefer the cstring.c functions.

Definition in file qstring.c.

Function Documentation

◆ decode_qstring()

const char* decode_qstring ( const char *  start,
size_t  in_len_max,
char **  out,
size_t *  out_len 
)

Given a pointer to a string starting at start containing in_len_max characters, decode a string beginning with one double quote, containing any number of non-quote characters or characters escaped with a backslash, and ending with a final double quote. Place the resulting string (unquoted, unescaped) into a newly allocated string in *out; store its length in out_len. On success, return a pointer to the character immediately following the escaped string. On failure, return NULL.

Definition at line 64 of file qstring.c.

References get_qstring_length(), and tor_assert().

◆ get_qstring_length()

static int get_qstring_length ( const char *  start,
size_t  in_len_max,
int *  chars_out 
)
inlinestatic

If the first in_len_max characters in start contain a QuotedString, return the length of that string (as encoded, including quotes). Otherwise return -1.

Definition at line 22 of file qstring.c.

Referenced by decode_qstring().