<commit_before>//
//  src/macho_file_parse_single_lc.c
//  tbd
//
//  Created by inoahdev on 12/10/19.
//  Copyright © 2019 inoahdev. All rights reserved.
//

#include <string.h>
#include "copy.h"

#include "mach-o/loader.h"
#include "macho_file_parse_single_lc.h"
#include "macho_file.h"

#include "swap.h"
#include "tbd.h"
#include "yaml.h"

static bool
call_callback(const macho_file_parse_error_callback callback,
              struct tbd_create_info *__notnull const info_in,
              const enum macho_file_parse_error error,
              void *const cb_info)
{
    if (callback != NULL) {
        if (callback(info_in, error, cb_info)) {
            return true;
        }
    }

    return false;
}

static inline bool
verify_string_offset(const uint8_t *const load_cmd,
                     const uint32_t offset,
                     const uint32_t load_cmd_min_size,
                     const uint32_t load_cmdsize,
                     uint32_t *__notnull const length_out)
{
    /*
     * Ensure the string is fully within the structure, and doesn't overlap the
     * basic structure of the load-command.
     */

    if (offset < load_cmd_min_size || offset >= load_cmdsize) {
        return E_MACHO_FILE_PARSE_INVALID_CLIENT;
    }

    const char *const string = (const char *)load_cmd + offset;

    /*
     * The string extends from its offset to the end of the dylib-command
     * load-commmand.<commit_msg>Return a boolean value from verify_string_offset()<commit_after>//
//  src/macho_file_parse_single_lc.c
//  tbd
//
//  Created by inoahdev on 12/10/19.
//  Copyright © 2019 inoahdev. All rights reserved.
//

#include <string.h>
#include "copy.h"

#include "mach-o/loader.h"
#include "macho_file_parse_single_lc.h"
#include "macho_file.h"

#include "swap.h"
#include "tbd.h"
#include "yaml.h"

static bool
call_callback(const macho_file_parse_error_callback callback,
              struct tbd_create_info *__notnull const info_in,
              const enum macho_file_parse_error error,
              void *const cb_info)
{
    if (callback != NULL) {
        if (callback(info_in, error, cb_info)) {
            return true;
        }
    }

    return false;
}

static inline bool
verify_string_offset(const uint8_t *const load_cmd,
                     const uint32_t offset,
                     const uint32_t load_cmd_min_size,
                     const uint32_t load_cmdsize,
                     uint32_t *__notnull const length_out)
{
    /*
     * Ensure the string is fully within the structure, and doesn't overlap the
     * basic structure of the load-command.
     */

    if (offset < load_cmd_min_size || offset >= load_cmdsize) {
        return false;
    }

    const char *const string = (const char *)load_cmd + offset;

    /*
     * The string extends from its offset to the end of the dylib-command
     * load-commmand.
{'fraction_non_alphanumeric': 0.08898157803267293, 'fraction_numerical': 0.013208202989224887, 'mean_word_length': 2.3858823529411763, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7128249', 'n_tokens_mistral': 966, 'n_tokens_neox': 927, 'n_words': 252}