netatalk  4.6.1
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
test_convert.c File Reference
#include "config.h"
#include <atalk/adouble.h>
#include <atalk/ea.h>
#include <atalk/logger.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>

Data Structures

struct  adent

Macros

#define PATH_MAX   4096

Enumerations

enum  reject_reason { REASON_NONE = 0 , REASON_ROFF_LOW , REASON_SOURCE }

Functions

const char * tmpdir (void)
 Find a suitable temporary directory for Netatalk.
static void fail (const char *name, const char *what)
static void write_sidecar (const struct adent *ents, size_t nents, const char *tail, size_t taillen)
static void save_sidecar (void)
static int sidecar_unchanged (void)
static int open_rf_write (void)
static int init_meta (void)
static off_t file_size (const char *p)
static ssize_t read_sidecar (unsigned char *buf, size_t buflen)
static void expect_reject (const char *name, enum reject_reason reason, const struct adent *ents, size_t nents, const char *tail, size_t taillen)
static void expect_short_header_after_stat (void)
static int find_entry (const unsigned char *buf, size_t buflen, uint32_t eid, uint32_t *off, uint32_t *len)
static void expect_legit_conversion (void)
static void expect_empty_rfork (void)
static void expect_declared_len_wins (void)
static void expect_null_path_refresh (void)
int main (void)

Variables

static char dfpath [PATH_MAX]
static char scpath [PATH_MAX]
static char bakpath [PATH_MAX]
static int failures

Detailed Description

Crafted ._ sidecars are opened through ad_open() with resource-fork write intent, mirroring the afpd call sequence. Malformed entries must be rejected with errno EIO and leave the sidecar untouched. A well-formed sidecar must be rewritten to the canonical OS X layout with its resource fork payload preserved byte for byte.

Macro Definition Documentation

◆ PATH_MAX

#define PATH_MAX   4096

Enumeration Type Documentation

◆ reject_reason

Enumerator
REASON_NONE 
REASON_ROFF_LOW 
REASON_SOURCE 

Function Documentation

◆ expect_declared_len_wins()

void expect_declared_len_wins ( void )
static

◆ expect_empty_rfork()

void expect_empty_rfork ( void )
static

◆ expect_legit_conversion()

void expect_legit_conversion ( void )
static

◆ expect_null_path_refresh()

void expect_null_path_refresh ( void )
static

◆ expect_reject()

void expect_reject ( const char * name,
enum reject_reason reason,
const struct adent * ents,
size_t nents,
const char * tail,
size_t taillen )
static

◆ expect_short_header_after_stat()

void expect_short_header_after_stat ( void )
static

◆ fail()

void fail ( const char * name,
const char * what )
static

◆ file_size()

off_t file_size ( const char * p)
static

◆ find_entry()

int find_entry ( const unsigned char * buf,
size_t buflen,
uint32_t eid,
uint32_t * off,
uint32_t * len )
static

◆ init_meta()

int init_meta ( void )
static

◆ main()

int main ( void )

◆ open_rf_write()

int open_rf_write ( void )
static

◆ read_sidecar()

ssize_t read_sidecar ( unsigned char * buf,
size_t buflen )
static

◆ save_sidecar()

void save_sidecar ( void )
static

◆ sidecar_unchanged()

int sidecar_unchanged ( void )
static

◆ tmpdir()

const char * tmpdir ( void )
extern

Find a suitable temporary directory for Netatalk.

Creates a subdirectory for current gid if it doesn't exist. The result should be copied immediately as it may be overwritten by a subsequent call.

◆ write_sidecar()

void write_sidecar ( const struct adent * ents,
size_t nents,
const char * tail,
size_t taillen )
static

Variable Documentation

◆ bakpath

char bakpath[PATH_MAX]
static

◆ dfpath

char dfpath[PATH_MAX]
static

◆ failures

int failures
static

◆ scpath

char scpath[PATH_MAX]
static