OpenVAS Scanner  6.0.1
Macros | Typedefs | Functions | Variables
charcnv.c File Reference

Unix SMB/CIFS implementation: Character set conversion Extensions. More...

#include "byteorder.h"
#include "iconv.h"
#include "proto.h"
#include "smb.h"
#include <gvm/base/logging.h>

Macros

#define uint8   uint8_t
 
#define uint16   uint16_t
 
#define _PUBLIC_
 
#define G_LOG_DOMAIN   "lib nasl"
 GLib logging domain. More...
 
#define False   0
 
#define True   1
 

Typedefs

typedef unsigned int bool
 

Functions

size_t convert_string_ntlmssp (charset_t from, charset_t to, void const *src, size_t srclen, void *dest, size_t destlen, bool allow_badcharcnv)
 
static int check_dos_char_slowly_ntlmssp (uint16 c)
 
char lp_failed_convert_char_ntlmssp (void)
 
void init_valid_table_ntlmssp (void)
 
size_t strlen_w_ntlmssp (const uint16 *src)
 
static const char * charset_name_ntlmssp (charset_t ch)
 
void lazy_initialize_conv_ntlmssp (void)
 
void init_iconv_ntlmssp (void)
 
static size_t convert_string_internal_ntlmssp (charset_t from, charset_t to, void const *src, size_t srclen, void *dest, size_t destlen, bool allow_bad_conv)
 

Variables

static uint8valid_table_ntlmssp
 
static bool valid_table_use_unmap_ntlmssp
 
static smb_iconv_t conv_handles_ntlmssp [NUM_CHARSETS][NUM_CHARSETS]
 
static bool conv_silent_ntlmssp
 

Detailed Description

Unix SMB/CIFS implementation: Character set conversion Extensions.

Character-set conversion routines built on our iconv.

MODIFICATIONS: only those functions that are required for OpenVAS are retained, others are removed Modified By Preeti Subramanian spree.nosp@m.ti@s.nosp@m.ecpod.nosp@m..com

  1. init_valid_table taken from samba/<source>/lib/util_unistr.c, using a dynamically created valid table only
  2. valid_table taken from samba/<source>/lib/util_unistr.c
  3. valid_table_use_unmap taken from samba/<source>/lib/util_unistr.c, BOOL is changed to bool
  4. check_dos_char_slowly taken from samba/<source>/lib/util_unistr.c, smb_ucs2_t is changed to uint16
  5. strlen_w taken from samba/<source>/lib/util_unistr.c, smb_ucs2_t is changed to uint16
  6. strupper_m taken from samba/source/lib/util_str.c, and modified for OpenVAS
  7. charset_name function changed for OpenVAS
  8. in lazy_initialize_conv function, loading or generating the case handling tables removed
  9. in init_iconv, init_doschar_table not required(removed)
Note
Samba's internal character set (at least in the 3.0 series) is always the same as the one for the Unix filesystem. It is not necessarily UTF-8 and may be different on machines that need i18n filenames to be compatible with Unix software. It does have to be a superset of ASCII. All multibyte sequences must start with a byte with the high bit set.
See also
lib/iconv.c

Macro Definition Documentation

◆ _PUBLIC_

#define _PUBLIC_

◆ False

#define False   0

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "lib nasl"

GLib logging domain.

◆ True

#define True   1

◆ uint16

#define uint16   uint16_t

◆ uint8

#define uint8   uint8_t

Typedef Documentation

◆ bool

typedef unsigned int bool

Function Documentation

◆ charset_name_ntlmssp()

static const char* charset_name_ntlmssp ( charset_t  ch)
static
  • Return the name of a charset to give to iconv().

◆ check_dos_char_slowly_ntlmssp()

static int check_dos_char_slowly_ntlmssp ( uint16  c)
static

◆ convert_string_internal_ntlmssp()

static size_t convert_string_internal_ntlmssp ( charset_t  from,
charset_t  to,
void const *  src,
size_t  srclen,
void *  dest,
size_t  destlen,
bool  allow_bad_conv 
)
static

Convert string from one encoding to another, making error checking etc Slow path version - uses (slow) iconv.

Parameters
srcpointer to source string (multibyte or singlebyte)
srclenlength of the source string in bytes
destpointer to destination string (multibyte or singlebyte)
destlenmaximal length allowed for string
allow_bad_convdetermines if a "best effort" conversion is acceptable (never returns errors)
Returns
the number of bytes occupied in the destination

Ensure the srclen contains the terminating zero.

◆ convert_string_ntlmssp()

size_t convert_string_ntlmssp ( charset_t  from,
charset_t  to,
void const *  src,
size_t  srclen,
void *  dest,
size_t  destlen,
bool  allow_bad_conv 
)

Convert string from one encoding to another, making error checking etc Fast path version - handles ASCII first.

Parameters
srcpointer to source string (multibyte or singlebyte)
srclenlength of the source string in bytes, or -1 for nul terminated.
destpointer to destination string (multibyte or singlebyte)
destlenmaximal length allowed for string - NEVER -1.
allow_bad_convdetermines if a "best effort" conversion is acceptable (never returns errors)
Returns
the number of bytes occupied in the destination

Ensure the srclen contains the terminating zero.

This function has been hand-tuned to provide a fast path. Don't change unless you really know what you are doing. JRA.

◆ init_iconv_ntlmssp()

void init_iconv_ntlmssp ( void  )

Initialize iconv conversion descriptors.

This is called the first time it is needed, and also called again every time the configuration is reloaded, because the charset or codepage might have changed.

◆ init_valid_table_ntlmssp()

void init_valid_table_ntlmssp ( void  )

◆ lazy_initialize_conv_ntlmssp()

void lazy_initialize_conv_ntlmssp ( void  )

◆ lp_failed_convert_char_ntlmssp()

char lp_failed_convert_char_ntlmssp ( void  )

◆ strlen_w_ntlmssp()

size_t strlen_w_ntlmssp ( const uint16 src)

Variable Documentation

◆ conv_handles_ntlmssp

smb_iconv_t conv_handles_ntlmssp[NUM_CHARSETS][NUM_CHARSETS]
static

◆ conv_silent_ntlmssp

bool conv_silent_ntlmssp
static

◆ valid_table_ntlmssp

uint8* valid_table_ntlmssp
static

◆ valid_table_use_unmap_ntlmssp

bool valid_table_use_unmap_ntlmssp
static