project
stringclasses
633 values
commit_id
stringlengths
7
81
target
int64
0
1
func
stringlengths
5
484k
cwe
stringclasses
131 values
big_vul_idx
float64
0
189k
idx
int64
0
522k
hash
stringlengths
34
39
size
float64
1
24k
message
stringlengths
0
11.5k
dataset
stringclasses
1 value
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size) { struct acpi_ioremap *map; if (!acpi_gbl_permanent_mmap) { __acpi_unmap_table(virt, size); return; } mutex_lock(&acpi_ioremap_lock); map = acpi_map_lookup_virt(virt, size); if (!map) { mutex_unlock(&acpi_ioremap_lock); WARN(true, PREFIX "%s: bad address %p\n", __func__, virt); return; } acpi_os_drop_map_ref(map); mutex_unlock(&acpi_ioremap_lock); acpi_os_map_cleanup(map); }
CWE-264
null
517,108
150888892732467782137843470202635209978
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
static int __init setup_acpi_rsdp(char *arg) { if (kstrtoul(arg, 16, &acpi_rsdp)) return -EINVAL; return 0; }
CWE-264
null
517,109
232634569299667834624386067122960736966
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_os_signal(u32 function, void *info) { switch (function) { case ACPI_SIGNAL_FATAL: printk(KERN_ERR PREFIX "Fatal opcode executed\n"); break; case ACPI_SIGNAL_BREAKPOINT: /* * AML Breakpoint * ACPI spec. says to treat it as a NOP unless * you are debugging. So if/when we integrate * AML debugger into the kernel debugger its * hook will go here. But until then it is * not useful to print anything on breakpoints. */ break; default: break; } return AE_OK; }
CWE-264
null
517,110
173952793564976590409513179816906972501
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void acpi_os_vprintf(const char *fmt, va_list args) { static char buffer[512]; vsprintf(buffer, fmt, args); #ifdef ENABLE_DEBUGGER if (acpi_in_debugger) { kdb_printf("%s", buffer); } else { printk(KERN_CONT "%s", buffer); } #else if (acpi_debugger_write_log(buffer) < 0) printk(KERN_CONT "%s", buffer); #endif }
CWE-264
null
517,111
232099773962032283661845577436135720929
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_os_notify_command_complete(void) { int ret; ret = acpi_debugger_notify_command_complete(); if (ret < 0) return AE_ERROR; return AE_OK; }
CWE-264
null
517,112
78988368505880805634272726592091972903
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_os_purge_cache(acpi_cache_t * cache) { kmem_cache_shrink(cache); return (AE_OK); }
CWE-264
null
517,113
108527961994942183720948754561421598513
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) { kmem_cache_free(cache, object); return (AE_OK); }
CWE-264
null
517,114
74994890322644810956134468171456120765
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status __init acpi_os_initialize1(void) { kacpid_wq = alloc_workqueue("kacpid", 0, 1); kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1); kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0); BUG_ON(!kacpid_wq); BUG_ON(!kacpi_notify_wq); BUG_ON(!kacpi_hotplug_wq); acpi_install_interface_handler(acpi_osi_handler); acpi_osi_setup_late(); return AE_OK; }
CWE-264
null
517,115
144363890715579691618714510378630428864
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state, u32 val_a, u32 val_b)) { __acpi_os_prepare_extended_sleep = func; }
CWE-264
null
517,116
276495041118625128166490827945001089025
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
int acpi_os_map_generic_address(struct acpi_generic_address *gas) { u64 addr; void __iomem *virt; if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) return 0; /* Handle possible alignment issues */ memcpy(&addr, &gas->address, sizeof(addr)); if (!addr || !gas->bit_width) return -EINVAL; virt = acpi_os_map_iomem(addr, gas->bit_width / 8); if (!virt) return -EIO; return 0; }
CWE-264
null
517,117
48400724463387932829326943031898392436
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_os_execute(acpi_execute_type type, acpi_osd_exec_callback function, void *context) { acpi_status status = AE_OK; struct acpi_os_dpc *dpc; struct workqueue_struct *queue; int ret; ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Scheduling function [%p(%p)] for deferred execution.\n", function, context)); if (type == OSL_DEBUGGER_MAIN_THREAD) { ret = acpi_debugger_create_thread(function, context); if (ret) { pr_err("Call to kthread_create() failed.\n"); status = AE_ERROR; } goto out_thread; } /* * Allocate/initialize DPC structure. Note that this memory will be * freed by the callee. The kernel handles the work_struct list in a * way that allows us to also free its memory inside the callee. * Because we may want to schedule several tasks with different * parameters we can't use the approach some kernel code uses of * having a static work_struct. */ dpc = kzalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC); if (!dpc) return AE_NO_MEMORY; dpc->function = function; dpc->context = context; /* * To prevent lockdep from complaining unnecessarily, make sure that * there is a different static lockdep key for each workqueue by using * INIT_WORK() for each of them separately. */ if (type == OSL_NOTIFY_HANDLER) { queue = kacpi_notify_wq; INIT_WORK(&dpc->work, acpi_os_execute_deferred); } else if (type == OSL_GPE_HANDLER) { queue = kacpid_wq; INIT_WORK(&dpc->work, acpi_os_execute_deferred); } else { pr_err("Unsupported os_execute type %d.\n", type); status = AE_ERROR; } if (ACPI_FAILURE(status)) goto err_workqueue; /* * On some machines, a software-initiated SMI causes corruption unless * the SMI runs on CPU 0. An SMI can be initiated by any AML, but * typically it's done in GPE-related methods that are run via * workqueues, so we can avoid the known corruption cases by always * queueing on CPU 0. */ ret = queue_work_on(0, queue, &dpc->work); if (!ret) { printk(KERN_ERR PREFIX "Call to queue_work() failed.\n"); status = AE_ERROR; } err_workqueue: if (ACPI_FAILURE(status)) kfree(dpc); out_thread: return status; }
CWE-264
null
517,118
155578611008232300520162893706231814754
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
ssize_t acpi_debugger_write_log(const char *msg) { ssize_t ret; ssize_t (*func)(const char *); struct module *owner; if (!acpi_debugger_initialized) return -ENODEV; mutex_lock(&acpi_debugger.lock); if (!acpi_debugger.ops) { ret = -ENODEV; goto err_lock; } if (!try_module_get(acpi_debugger.owner)) { ret = -ENODEV; goto err_lock; } func = acpi_debugger.ops->write_log; owner = acpi_debugger.owner; mutex_unlock(&acpi_debugger.lock); ret = func(msg); mutex_lock(&acpi_debugger.lock); module_put(owner); err_lock: mutex_unlock(&acpi_debugger.lock); return ret; }
CWE-264
null
517,119
39883563326353712127916088606820740462
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void acpi_os_delete_lock(acpi_spinlock handle) { ACPI_FREE(handle); }
CWE-264
null
517,120
158627639581119443440109336388267382520
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp) { acpi_cpu_flags flags; spin_lock_irqsave(lockp, flags); return flags; }
CWE-264
null
517,121
171413310697431634697300613384771492455
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control) { int rc = 0; if (__acpi_os_prepare_sleep) rc = __acpi_os_prepare_sleep(sleep_state, pm1a_control, pm1b_control); if (rc < 0) return AE_ERROR; else if (rc > 0) return AE_CTRL_SKIP; return AE_OK; }
CWE-264
null
517,122
285716473803980640424744767923544725393
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, u32 pm1a_ctrl, u32 pm1b_ctrl)) { __acpi_os_prepare_sleep = func; }
CWE-264
null
517,123
133300138253703268877750506370314818163
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) { acpi_status status = AE_OK; struct semaphore *sem = (struct semaphore *)handle; long jiffies; int ret = 0; if (!acpi_os_initialized) return AE_OK; if (!sem || (units < 1)) return AE_BAD_PARAMETER; if (units > 1) return AE_SUPPORT; ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout)); if (timeout == ACPI_WAIT_FOREVER) jiffies = MAX_SCHEDULE_TIMEOUT; else jiffies = msecs_to_jiffies(timeout); ret = down_timeout(sem, jiffies); if (ret) status = AE_TIME; if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Failed to acquire semaphore[%p|%d|%d], %s", handle, units, timeout, acpi_format_exception(status))); } else { ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Acquired semaphore[%p|%d|%d]", handle, units, timeout)); } return status; }
CWE-264
null
517,124
289287356714165214538313523554476866547
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
static void acpi_os_execute_deferred(struct work_struct *work) { struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); dpc->function(dpc->context); kfree(dpc); }
CWE-264
null
517,125
166234829938899188029120778855215991168
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void acpi_os_printf(const char *fmt, ...) { va_list args; va_start(args, fmt); acpi_os_vprintf(fmt, args); va_end(args); }
CWE-264
null
517,126
281433108392194260010553984338734037297
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
u64 acpi_os_get_timer(void) { u64 time_ns = ktime_to_ns(ktime_get()); do_div(time_ns, 100); return time_ns; }
CWE-264
null
517,127
4342336406875957419851789240034291700
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
int acpi_debugger_notify_command_complete(void) { int ret; int (*func)(void); struct module *owner; if (!acpi_debugger_initialized) return -ENODEV; mutex_lock(&acpi_debugger.lock); if (!acpi_debugger.ops) { ret = -ENODEV; goto err_lock; } if (!try_module_get(acpi_debugger.owner)) { ret = -ENODEV; goto err_lock; } func = acpi_debugger.ops->notify_command_complete; owner = acpi_debugger.owner; mutex_unlock(&acpi_debugger.lock); ret = func(); mutex_lock(&acpi_debugger.lock); module_put(owner); err_lock: mutex_unlock(&acpi_debugger.lock); return ret; }
CWE-264
null
517,128
59103848330842378907699006878362835464
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_map_lookup(acpi_physical_address phys, acpi_size size) { struct acpi_ioremap *map; list_for_each_entry_rcu(map, &acpi_ioremaps, list) if (map->phys <= phys && phys + size <= map->phys + map->size) return map; return NULL; }
CWE-264
null
517,129
285818553693315835350043654487788498732
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void __init acpi_initrd_override(void *data, size_t size) { int sig, no, table_nr = 0, total_offset = 0; long offset = 0; struct acpi_table_header *table; char cpio_path[32] = "kernel/firmware/acpi/"; struct cpio_data file; if (data == NULL || size == 0) return; for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) { file = find_cpio_data(cpio_path, data, size, &offset); if (!file.data) break; data += offset; size -= offset; if (file.size < sizeof(struct acpi_table_header)) { pr_err("ACPI OVERRIDE: Table smaller than ACPI header [%s%s]\n", cpio_path, file.name); continue; } table = file.data; for (sig = 0; table_sigs[sig]; sig++) if (!memcmp(table->signature, table_sigs[sig], 4)) break; if (!table_sigs[sig]) { pr_err("ACPI OVERRIDE: Unknown signature [%s%s]\n", cpio_path, file.name); continue; } if (file.size != table->length) { pr_err("ACPI OVERRIDE: File length does not match table length [%s%s]\n", cpio_path, file.name); continue; } if (acpi_table_checksum(file.data, table->length)) { pr_err("ACPI OVERRIDE: Bad table checksum [%s%s]\n", cpio_path, file.name); continue; } pr_info("%4.4s ACPI table found in initrd [%s%s][0x%x]\n", table->signature, cpio_path, file.name, table->length); all_tables_size += table->length; acpi_initrd_files[table_nr].data = file.data; acpi_initrd_files[table_nr].size = file.size; table_nr++; } if (table_nr == 0) return; if (get_securelevel() > 0) { pr_notice(PREFIX "securelevel enabled, ignoring table override\n"); return; } acpi_tables_addr = memblock_find_in_range(0, max_low_pfn_mapped << PAGE_SHIFT, all_tables_size, PAGE_SIZE); if (!acpi_tables_addr) { WARN_ON(1); return; } /* * Only calling e820_add_reserve does not work and the * tables are invalid (memory got used) later. * memblock_reserve works as expected and the tables won't get modified. * But it's not enough on X86 because ioremap will * complain later (used by acpi_os_map_memory) that the pages * that should get mapped are not marked "reserved". * Both memblock_reserve and e820_add_region (via arch_reserve_mem_area) * works fine. */ memblock_reserve(acpi_tables_addr, all_tables_size); arch_reserve_mem_area(acpi_tables_addr, all_tables_size); /* * early_ioremap only can remap 256k one time. If we map all * tables one time, we will hit the limit. Need to map chunks * one by one during copying the same as that in relocate_initrd(). */ for (no = 0; no < table_nr; no++) { unsigned char *src_p = acpi_initrd_files[no].data; phys_addr_t size = acpi_initrd_files[no].size; phys_addr_t dest_addr = acpi_tables_addr + total_offset; phys_addr_t slop, clen; char *dest_p; total_offset += size; while (size) { slop = dest_addr & ~PAGE_MASK; clen = size; if (clen > MAP_CHUNK_SIZE - slop) clen = MAP_CHUNK_SIZE - slop; dest_p = early_ioremap(dest_addr & PAGE_MASK, clen + slop); memcpy(dest_p + slop, src_p, clen); early_iounmap(dest_p, clen + slop); src_p += clen; dest_addr += clen; size -= clen; } } }
CWE-264
null
517,130
47944988099362208668428695142946406933
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void __init acpi_initrd_initialize_tables(void) { }
CWE-264
null
517,131
277501593444755907045610389464311257076
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d) { printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); if (enable == -1) return; osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */ set_osi_linux(enable); return; }
CWE-264
null
517,132
171263336570540508821758800496763979639
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_os_terminate(void) { if (acpi_irq_handler) { acpi_os_remove_interrupt_handler(acpi_gbl_FADT.sci_interrupt, acpi_irq_handler); } acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe1_block); acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe0_block); acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1b_event_block); acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1a_event_block); if (acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) acpi_os_unmap_generic_address(&acpi_gbl_FADT.reset_register); destroy_workqueue(kacpid_wq); destroy_workqueue(kacpi_notify_wq); destroy_workqueue(kacpi_hotplug_wq); return AE_OK; }
CWE-264
null
517,133
257319052198170330772015452570904316863
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size) { struct acpi_ioremap *map; void __iomem *virt = NULL; mutex_lock(&acpi_ioremap_lock); map = acpi_map_lookup(phys, size); if (map) { virt = map->virt + (phys - map->phys); map->refcount++; } mutex_unlock(&acpi_ioremap_lock); return virt; }
CWE-264
null
517,134
40074687328437347259363450861135277789
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
void __ref acpi_os_unmap_memory(void *virt, acpi_size size) { return acpi_os_unmap_iomem((void __iomem *)virt, size); }
CWE-264
null
517,135
120891951486452564322329440924699302529
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
static void __init acpi_request_region (struct acpi_generic_address *gas, unsigned int length, char *desc) { u64 addr; /* Handle possible alignment issues */ memcpy(&addr, &gas->address, sizeof(addr)); if (!addr || !length) return; /* Resources are never freed */ if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) request_region(addr, length, desc); else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) request_mem_region(addr, length, desc); }
CWE-264
null
517,136
131343735754078987524481863191216666503
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_os_table_override(struct acpi_table_header *existing_table, struct acpi_table_header **new_table) { if (!existing_table || !new_table) return AE_BAD_PARAMETER; *new_table = NULL; #ifdef CONFIG_ACPI_CUSTOM_DSDT if (strncmp(existing_table->signature, "DSDT", 4) == 0) *new_table = (struct acpi_table_header *)AmlCode; #endif if (*new_table != NULL) acpi_table_taint(existing_table); return AE_OK; }
CWE-264
null
517,137
185480767357813505014496928956978117393
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz) { unsigned long pfn; pfn = pg_off >> PAGE_SHIFT; if (should_use_kmap(pfn)) { if (pg_sz > PAGE_SIZE) return NULL; return (void __iomem __force *)kmap(pfn_to_page(pfn)); } else return acpi_os_ioremap(pg_off, pg_sz); }
CWE-264
null
517,138
316525726554104720378826108476970596215
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
static int __init acpi_reserve_resources(void) { acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length, "ACPI PM1a_EVT_BLK"); acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length, "ACPI PM1b_EVT_BLK"); acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length, "ACPI PM1a_CNT_BLK"); acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length, "ACPI PM1b_CNT_BLK"); if (acpi_gbl_FADT.pm_timer_length == 4) acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR"); acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length, "ACPI PM2_CNT_BLK"); /* Length of GPE blocks must be a non-negative multiple of 2 */ if (!(acpi_gbl_FADT.gpe0_block_length & 0x1)) acpi_request_region(&acpi_gbl_FADT.xgpe0_block, acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK"); if (!(acpi_gbl_FADT.gpe1_block_length & 0x1)) acpi_request_region(&acpi_gbl_FADT.xgpe1_block, acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK"); return 0; }
CWE-264
null
517,139
79435381045529991988541051512838491133
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_os_remove_interrupt_handler(u32 gsi, acpi_osd_handler handler) { if (gsi != acpi_gbl_FADT.sci_interrupt || !acpi_sci_irq_valid()) return AE_BAD_PARAMETER; free_irq(acpi_sci_irq, acpi_irq); acpi_irq_handler = NULL; acpi_sci_irq = INVALID_ACPI_IRQ; return AE_OK; }
CWE-264
null
517,140
135816289658162521085846632549884750340
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
bool acpi_queue_hotplug_work(struct work_struct *work) { return queue_work(kacpi_hotplug_wq, work); }
CWE-264
null
517,141
66008632320090088977583790352747460512
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_os_delete_cache(acpi_cache_t * cache) { kmem_cache_destroy(cache); return (AE_OK); }
CWE-264
null
517,142
16580960459665860175605513158731215853
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
int acpi_register_debugger(struct module *owner, const struct acpi_debugger_ops *ops) { int ret = 0; mutex_lock(&acpi_debugger.lock); if (acpi_debugger.ops) { ret = -EBUSY; goto err_lock; } acpi_debugger.owner = owner; acpi_debugger.ops = ops; err_lock: mutex_unlock(&acpi_debugger.lock); return ret; }
CWE-264
null
517,143
112907351680478163751184027831678534698
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
int acpi_debugger_create_thread(acpi_osd_exec_callback function, void *context) { int ret; int (*func)(acpi_osd_exec_callback, void *); struct module *owner; if (!acpi_debugger_initialized) return -ENODEV; mutex_lock(&acpi_debugger.lock); if (!acpi_debugger.ops) { ret = -ENODEV; goto err_lock; } if (!try_module_get(acpi_debugger.owner)) { ret = -ENODEV; goto err_lock; } func = acpi_debugger.ops->create_thread; owner = acpi_debugger.owner; mutex_unlock(&acpi_debugger.lock); ret = func(function, context); mutex_lock(&acpi_debugger.lock); module_put(owner); err_lock: mutex_unlock(&acpi_debugger.lock); return ret; }
CWE-264
null
517,144
173185539910773738094347466238323505294
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
static int __init osi_setup(char *str) { if (str && !strcmp("Linux", str)) acpi_cmdline_osi_linux(1); else if (str && !strcmp("!Linux", str)) acpi_cmdline_osi_linux(0); else acpi_osi_setup(str); return 1; }
CWE-264
null
517,145
337217862167118930175987254215304749082
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
int acpi_check_resource_conflict(const struct resource *res) { acpi_adr_space_type space_id; acpi_size length; u8 warn = 0; int clash = 0; if (acpi_enforce_resources == ENFORCE_RESOURCES_NO) return 0; if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM)) return 0; if (res->flags & IORESOURCE_IO) space_id = ACPI_ADR_SPACE_SYSTEM_IO; else space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY; length = resource_size(res); if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) warn = 1; clash = acpi_check_address_range(space_id, res->start, length, warn); if (clash) { if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) { if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX) printk(KERN_NOTICE "ACPI: This conflict may" " cause random problems and system" " instability\n"); printk(KERN_INFO "ACPI: If an ACPI driver is available" " for this device, you should use it instead of" " the native driver\n"); } if (acpi_enforce_resources == ENFORCE_RESOURCES_STRICT) return -EBUSY; } return 0; }
CWE-264
null
517,146
247261712800010205841622547967557625755
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src) { struct acpi_hp_work *hpw; ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Scheduling hotplug event (%p, %u) for deferred execution.\n", adev, src)); hpw = kmalloc(sizeof(*hpw), GFP_KERNEL); if (!hpw) return AE_NO_MEMORY; INIT_WORK(&hpw->work, acpi_hotplug_work_fn); hpw->adev = adev; hpw->src = src; /* * We can't run hotplug code in kacpid_wq/kacpid_notify_wq etc., because * the hotplug code may call driver .remove() functions, which may * invoke flush_scheduled_work()/acpi_os_wait_events_complete() to flush * these workqueues. */ if (!queue_work(kacpi_hotplug_wq, &hpw->work)) { kfree(hpw); return AE_ERROR; } return AE_OK; }
CWE-264
null
517,147
88076147494609866780167345642110953188
null
null
other
mjg59_linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
0
acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width) { void __iomem *virt_addr; unsigned int size = width / 8; bool unmap = false; u64 dummy; rcu_read_lock(); virt_addr = acpi_map_vaddr_lookup(phys_addr, size); if (!virt_addr) { rcu_read_unlock(); virt_addr = acpi_os_ioremap(phys_addr, size); if (!virt_addr) return AE_BAD_ADDRESS; unmap = true; } if (!value) value = &dummy; switch (width) { case 8: *(u8 *) value = readb(virt_addr); break; case 16: *(u16 *) value = readw(virt_addr); break; case 32: *(u32 *) value = readl(virt_addr); break; case 64: *(u64 *) value = readq(virt_addr); break; default: BUG(); } if (unmap) iounmap(virt_addr); else rcu_read_unlock(); return AE_OK; }
CWE-264
null
517,148
312288111125597343299012771308411746162
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
PAM_EXTERN int pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, CONST char **argv) { CONST char *user; char *password = NULL; char *new_password = NULL; char *check_password = NULL; int ctrl; int retval = PAM_AUTHTOK_ERR; int attempts; char recv_buffer[4096]; char send_buffer[4096]; AUTH_HDR *request = (AUTH_HDR *) send_buffer; AUTH_HDR *response = (AUTH_HDR *) recv_buffer; radius_conf_t config; ctrl = _pam_parse(argc, argv, &config); /* grab the user name */ retval = pam_get_user(pamh, &user, NULL); PAM_FAIL_CHECK; /* check that they've entered something, and not too long, either */ if ((user == NULL) || (strlen(user) > MAXPWNAM)) { return PAM_USER_UNKNOWN; } /* * Get the IP address of the authentication server * Then, open a socket, and bind it to a port */ retval = initialize(&config, FALSE); PAM_FAIL_CHECK; /* * If there's no client id specified, use the service type, to help * keep track of which service is doing the authentication. */ if (!config.client_id) { retval = pam_get_item(pamh, PAM_SERVICE, (CONST void **) &config.client_id); PAM_FAIL_CHECK; } /* now we've got a socket open, so we've got to clean it up on error */ #undef PAM_FAIL_CHECK #define PAM_FAIL_CHECK if (retval != PAM_SUCCESS) {goto error; } /* grab the old password (if any) from the previous password layer */ retval = pam_get_item(pamh, PAM_OLDAUTHTOK, (CONST void **) &password); PAM_FAIL_CHECK; if (password) password = strdup(password); /* grab the new password (if any) from the previous password layer */ retval = pam_get_item(pamh, PAM_AUTHTOK, (CONST void **) &new_password); PAM_FAIL_CHECK; if (new_password) new_password = strdup(new_password); /* preliminary password change checks. */ if (flags & PAM_PRELIM_CHECK) { if (!password) { /* no previous password: ask for one */ retval = rad_converse(pamh, PAM_PROMPT_ECHO_OFF, config.prompt, &password); PAM_FAIL_CHECK; } /* * We now check the password to see if it's the right one. * If it isn't, we let the user try again. * Note that RADIUS doesn't have any concept of 'root'. The only way * that root can change someone's password is to log into the RADIUS * server, and and change it there. */ /* build and initialize the access request RADIUS packet */ request->code = PW_AUTHENTICATION_REQUEST; get_random_vector(request->vector); request->id = request->vector[0]; /* this should be evenly distributed */ build_radius_packet(request, user, password, &config); add_int_attribute(request, PW_USER_SERVICE_TYPE, PW_AUTHENTICATE_ONLY); retval = talk_radius(&config, request, response, password, NULL, 1); PAM_FAIL_CHECK; /* oops! They don't have the right password. Complain and die. */ if (response->code != PW_AUTHENTICATION_ACK) { _pam_forget(password); retval = PAM_PERM_DENIED; goto error; } /* * We're now sure it's the right user. * Ask for their new password, if appropriate */ if (!new_password) { /* not found yet: ask for it */ int new_attempts; attempts = 0; /* loop, trying to get matching new passwords */ while (attempts++ < 3) { /* loop, trying to get a new password */ new_attempts = 0; while (new_attempts++ < 3) { retval = rad_converse(pamh, PAM_PROMPT_ECHO_OFF, "New password: ", &new_password); PAM_FAIL_CHECK; /* the old password may be short. Check it, first. */ if (strcmp(password, new_password) == 0) { /* are they the same? */ rad_converse(pamh, PAM_ERROR_MSG, "You must choose a new password.", NULL); _pam_forget(new_password); continue; } else if (strlen(new_password) < 6) { rad_converse(pamh, PAM_ERROR_MSG, "it's WAY too short", NULL); _pam_forget(new_password); continue; } /* insert crypt password checking here */ break; /* the new password is OK */ } if (new_attempts >= 3) { /* too many new password attempts: die */ retval = PAM_AUTHTOK_ERR; goto error; } /* make sure of the password by asking for verification */ retval = rad_converse(pamh, PAM_PROMPT_ECHO_OFF, "New password (again): ", &check_password); PAM_FAIL_CHECK; retval = strcmp(new_password, check_password); _pam_forget(check_password); /* if they don't match, don't pass them to the next module */ if (retval != 0) { _pam_forget(new_password); rad_converse(pamh, PAM_ERROR_MSG, "You must enter the same password twice.", NULL); retval = PAM_AUTHTOK_ERR; goto error; /* ??? maybe this should be a 'continue' ??? */ } break; /* everything's fine */ } /* loop, trying to get matching new passwords */ if (attempts >= 3) { /* too many new password attempts: die */ retval = PAM_AUTHTOK_ERR; goto error; } } /* now we have a new password which passes all of our tests */ /* * Solaris 2.6 calls pam_sm_chauthtok only ONCE, with PAM_PRELIM_CHECK * set. */ #ifndef sun /* If told to update the authentication token, do so. */ } else if (flags & PAM_UPDATE_AUTHTOK) { #endif if (!password || !new_password) { /* ensure we've got passwords */ retval = PAM_AUTHTOK_ERR; goto error; } /* build and initialize the password change request RADIUS packet */ request->code = PW_PASSWORD_REQUEST; get_random_vector(request->vector); request->id = request->vector[0]; /* this should be evenly distributed */ /* the secret here can not be know to the user, so it's the new password */ _pam_forget(config.server->secret); config.server->secret = strdup(password); /* it's free'd later */ build_radius_packet(request, user, new_password, &config); add_password(request, PW_OLD_PASSWORD, password, password); retval = talk_radius(&config, request, response, new_password, password, 1); PAM_FAIL_CHECK; /* Whew! Done password changing, check for password acknowledge */ if (response->code != PW_PASSWORD_ACK) { retval = PAM_AUTHTOK_ERR; goto error; } } /* * Send the passwords to the next stage if preliminary checks fail, * or if the password change request fails. */ if ((flags & PAM_PRELIM_CHECK) || (retval != PAM_SUCCESS)) { error: /* If there was a password pass it to the next layer */ if (password && *password) { pam_set_item(pamh, PAM_OLDAUTHTOK, password); } if (new_password && *new_password) { pam_set_item(pamh, PAM_AUTHTOK, new_password); } } if (ctrl & PAM_DEBUG_ARG) { _pam_log(LOG_DEBUG, "password change %s", retval==PAM_SUCCESS ? "succeeded" : "failed"); } close(config.sockfd); cleanup(config.server); _pam_forget(password); _pam_forget(new_password); return retval; }
CWE-787
null
517,168
243310002592567977936231587547806547645
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static int _pam_parse(int argc, CONST char **argv, radius_conf_t *conf) { int ctrl=0; memset(conf, 0, sizeof(radius_conf_t)); /* ensure it's initialized */ strcpy(conf_file, CONF_FILE); /* set the default prompt */ snprintf(conf->prompt, MAXPROMPT, "%s: ", DEFAULT_PROMPT); /* * If either is not there, then we can't parse anything. */ if ((argc == 0) || (argv == NULL)) { return ctrl; } /* step through arguments */ for (ctrl=0; argc-- > 0; ++argv) { /* generic options */ if (!strncmp(*argv,"conf=",5)) { /* protect against buffer overflow */ if (strlen(*argv+5) >= sizeof(conf_file)) { _pam_log(LOG_ERR, "conf= argument too long"); conf_file[0] = 0; return 0; } strcpy(conf_file,*argv+5); } else if (!strcmp(*argv, "use_first_pass")) { ctrl |= PAM_USE_FIRST_PASS; } else if (!strcmp(*argv, "try_first_pass")) { ctrl |= PAM_TRY_FIRST_PASS; } else if (!strcmp(*argv, "skip_passwd")) { ctrl |= PAM_SKIP_PASSWD; } else if (!strncmp(*argv, "retry=", 6)) { conf->retries = atoi(*argv+6); } else if (!strcmp(*argv, "localifdown")) { conf->localifdown = 1; } else if (!strncmp(*argv, "client_id=", 10)) { if (conf->client_id) { _pam_log(LOG_WARNING, "ignoring duplicate '%s'", *argv); } else { conf->client_id = (char *) *argv+10; /* point to the client-id */ } } else if (!strcmp(*argv, "accounting_bug")) { conf->accounting_bug = TRUE; } else if (!strcmp(*argv, "ruser")) { ctrl |= PAM_RUSER_ARG; } else if (!strcmp(*argv, "debug")) { ctrl |= PAM_DEBUG_ARG; conf->debug = 1; opt_debug = TRUE; } else if (!strncmp(*argv, "prompt=", 7)) { if (!strncmp(conf->prompt, (char*)*argv+7, MAXPROMPT)) { _pam_log(LOG_WARNING, "ignoring duplicate '%s'", *argv); } else { /* truncate excessive prompts to (MAXPROMPT - 3) length */ if (strlen((char*)*argv+7) >= (MAXPROMPT - 3)) { *((char*)*argv+7 + (MAXPROMPT - 3)) = 0; } /* set the new prompt */ memset(conf->prompt, 0, sizeof(conf->prompt)); snprintf(conf->prompt, MAXPROMPT, "%s: ", (char*)*argv+7); } } else if (!strcmp(*argv, "force_prompt")) { conf->force_prompt= TRUE; } else if (!strncmp(*argv, "max_challenge=", 14)) { conf->max_challenge = atoi(*argv+14); } else { _pam_log(LOG_WARNING, "unrecognized option '%s'", *argv); } } return ctrl; }
CWE-787
null
517,169
109256189171645130423143893486424937277
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static int verify_packet(char *secret, AUTH_HDR *response, AUTH_HDR *request) { MD5_CTX my_md5; unsigned char calculated[AUTH_VECTOR_LEN]; unsigned char reply[AUTH_VECTOR_LEN]; /* * We could dispense with the memcpy, and do MD5's of the packet * + vector piece by piece. This is easier understand, and maybe faster. */ memcpy(reply, response->vector, AUTH_VECTOR_LEN); /* save the reply */ memcpy(response->vector, request->vector, AUTH_VECTOR_LEN); /* sent vector */ /* MD5(response packet header + vector + response packet data + secret) */ MD5Init(&my_md5); MD5Update(&my_md5, (unsigned char *) response, ntohs(response->length)); /* * This next bit is necessary because of a bug in the original Livingston * RADIUS server. The authentication vector is *supposed* to be MD5'd * with the old password (as the secret) for password changes. * However, the old password isn't used. The "authentication" vector * for the server reply packet is simply the MD5 of the reply packet. * Odd, the code is 99% there, but the old password is never copied * to the secret! */ if (*secret) { MD5Update(&my_md5, (unsigned char *) secret, strlen(secret)); } MD5Final(calculated, &my_md5); /* set the final vector */ /* Did he use the same random vector + shared secret? */ if (memcmp(calculated, reply, AUTH_VECTOR_LEN) != 0) { return FALSE; } return TRUE; }
CWE-787
null
517,170
164958510781470066825736713503729088491
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static void cleanup(radius_server_t *server) { radius_server_t *next; while (server) { next = server->next; _pam_drop(server->hostname); _pam_forget(server->secret); _pam_drop(server); server = next; } }
CWE-787
null
517,171
314834696845010646970807134165977094098
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static uint32_t get_ipaddr(char *host) { struct hostent *hp; if (good_ipaddr(host) == 0) { return ipstr2long(host); } else if ((hp = gethostbyname(host)) == (struct hostent *)NULL) { return (uint32_t)0; } return ntohl(*(uint32_t *)hp->h_addr); }
CWE-787
null
517,172
206653653026468307297628755016516719776
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static int rad_converse(pam_handle_t *pamh, int msg_style, char *message, char **password) { CONST struct pam_conv *conv; struct pam_message resp_msg; CONST struct pam_message *msg[1]; struct pam_response *resp = NULL; int retval; resp_msg.msg_style = msg_style; resp_msg.msg = message; msg[0] = &resp_msg; /* grab the password */ retval = pam_get_item(pamh, PAM_CONV, (CONST void **) &conv); PAM_FAIL_CHECK; retval = conv->conv(1, msg, &resp,conv->appdata_ptr); PAM_FAIL_CHECK; if (password) { /* assume msg.type needs a response */ /* I'm not sure if this next bit is necessary on Linux */ #ifdef sun /* NULL response, fail authentication */ if ((resp == NULL) || (resp->resp == NULL)) { return PAM_SYSTEM_ERR; } #endif *password = resp->resp; free(resp); } return PAM_SUCCESS; }
CWE-787
null
517,173
311023592354030827913516550284843526753
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static int good_ipaddr(char *addr) { int dot_count; int digit_count; dot_count = 0; digit_count = 0; while(*addr != '\0' && *addr != ' ') { if (*addr == '.') { dot_count++; digit_count = 0; } else if (!isdigit(*addr)) { dot_count = 5; } else { digit_count++; if (digit_count > 3) { dot_count = 5; } } addr++; } if (dot_count != 3) { return -1; } else { return 0; } }
CWE-787
null
517,174
136948631315018052132506417480187283828
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static void get_random_vector(unsigned char *vector) { #ifdef linux int fd = open("/dev/urandom",O_RDONLY); /* Linux: get *real* random numbers */ int total = 0; if (fd >= 0) { while (total < AUTH_VECTOR_LEN) { int bytes = read(fd, vector + total, AUTH_VECTOR_LEN - total); if (bytes <= 0) break; /* oops! Error */ total += bytes; } close(fd); } if (total != AUTH_VECTOR_LEN) #endif { /* do this *always* on other platforms */ MD5_CTX my_md5; struct timeval tv; struct timezone tz; static unsigned int session = 0; /* make the number harder to guess */ /* Use the time of day with the best resolution the system can give us -- often close to microsecond accuracy. */ gettimeofday(&tv,&tz); if (session == 0) { session = getppid(); /* (possibly) hard to guess information */ } tv.tv_sec ^= getpid() * session++; /* Hash things to get maybe cryptographically strong pseudo-random numbers */ MD5Init(&my_md5); MD5Update(&my_md5, (unsigned char *) &tv, sizeof(tv)); MD5Update(&my_md5, (unsigned char *) &tz, sizeof(tz)); MD5Final(vector, &my_md5); /* set the final vector */ } }
CWE-787
null
517,175
109911949163554023360425889730104104382
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static attribute_t *find_attribute(AUTH_HDR *response, unsigned char type) { attribute_t *attr = (attribute_t *) &response->data; int len = ntohs(response->length) - AUTH_HDR_LEN; while (attr->attribute != type) { if ((len -= attr->length) <= 0) { return NULL; /* not found */ } attr = (attribute_t *) ((char *) attr + attr->length); } return attr; }
CWE-787
null
517,176
67090456482036448020536658551476437509
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static void add_attribute(AUTH_HDR *request, unsigned char type, CONST unsigned char *data, int length) { attribute_t *p; p = (attribute_t *) ((unsigned char *)request + ntohs(request->length)); p->attribute = type; p->length = length + 2; /* the total size of the attribute */ request->length = htons(ntohs(request->length) + p->length); memcpy(p->data, data, length); }
CWE-787
null
517,177
112613993363821047917524995276788908865
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static unsigned char * xor(unsigned char *p, unsigned char *q, int length) { int i; unsigned char *retval = p; for (i = 0; i < length; i++) { *(p++) ^= *(q++); } return retval; }
CWE-787
null
517,178
52572868570030608773771024547884462885
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static int talk_radius(radius_conf_t *conf, AUTH_HDR *request, AUTH_HDR *response, char *password, char *old_password, int tries) { socklen_t salen; int total_length; fd_set set; struct timeval tv; time_t now, end; int rcode; struct sockaddr saremote; struct sockaddr_in *s_in = (struct sockaddr_in *) &saremote; radius_server_t *server = conf->server; int ok; int server_tries; int retval; /* ************************************************************ */ /* Now that we're done building the request, we can send it */ /* Hmm... on password change requests, all of the found server information could be saved with a pam_set_data(), which means even the radius_conf_t information will have to be malloc'd at some point On the other hand, we could just try all of the servers again in sequence, on the off chance that one may have ended up fixing itself. */ /* loop over all available servers */ while (server != NULL) { /* clear the response */ memset(response, 0, sizeof(AUTH_HDR)); /* only look up IP information as necessary */ if ((retval = host2server(server)) != PAM_SUCCESS) { _pam_log(LOG_ERR, "Failed looking up IP address for RADIUS server %s (errcode=%d)", server->hostname, retval); ok = FALSE; goto next; /* skip to the next server */ } /* set up per-server IP && port configuration */ memset ((char *) s_in, '\0', sizeof(struct sockaddr)); s_in->sin_family = AF_INET; s_in->sin_addr.s_addr = htonl(server->ip.s_addr); s_in->sin_port = server->port; total_length = ntohs(request->length); if (!password) { /* make an RFC 2139 p6 request authenticator */ get_accounting_vector(request, server); } server_tries = tries; send: /* send the packet */ if (sendto(conf->sockfd, (char *) request, total_length, 0, &saremote, sizeof(struct sockaddr_in)) < 0) { _pam_log(LOG_ERR, "Error sending RADIUS packet to server %s: %s", server->hostname, strerror(errno)); ok = FALSE; goto next; /* skip to the next server */ } /* ************************************************************ */ /* Wait for the response, and verify it. */ salen = sizeof(struct sockaddr); tv.tv_sec = server->timeout; /* wait for the specified time */ tv.tv_usec = 0; FD_ZERO(&set); /* clear out the set */ FD_SET(conf->sockfd, &set); /* wait only for the RADIUS UDP socket */ time(&now); end = now + tv.tv_sec; /* loop, waiting for the select to return data */ ok = TRUE; while (ok) { rcode = select(conf->sockfd + 1, &set, NULL, NULL, &tv); /* select timed out */ if (rcode == 0) { _pam_log(LOG_ERR, "RADIUS server %s failed to respond", server->hostname); if (--server_tries) { goto send; } ok = FALSE; break; /* exit from the select loop */ } else if (rcode < 0) { /* select had an error */ if (errno == EINTR) { /* we were interrupted */ time(&now); if (now > end) { _pam_log(LOG_ERR, "RADIUS server %s failed to respond", server->hostname); if (--server_tries) goto send; ok = FALSE; break; /* exit from the select loop */ } tv.tv_sec = end - now; if (tv.tv_sec == 0) { /* keep waiting */ tv.tv_sec = 1; } } else { /* not an interrupt, it was a real error */ _pam_log(LOG_ERR, "Error waiting for response from RADIUS server %s: %s", server->hostname, strerror(errno)); ok = FALSE; break; } /* the select returned OK */ } else if (FD_ISSET(conf->sockfd, &set)) { /* try to receive some data */ if ((total_length = recvfrom(conf->sockfd, (void *) response, BUFFER_SIZE, 0, &saremote, &salen)) < 0) { _pam_log(LOG_ERR, "error reading RADIUS packet from server %s: %s", server->hostname, strerror(errno)); ok = FALSE; break; /* there's data, see if it's valid */ } else { char *p = server->secret; if ((ntohs(response->length) != total_length) || (ntohs(response->length) > BUFFER_SIZE)) { _pam_log(LOG_ERR, "RADIUS packet from server %s is corrupted", server->hostname); ok = FALSE; break; } /* Check if we have the data OK. We should also check request->id */ if (password) { if (old_password) { #ifdef LIVINGSTON_PASSWORD_VERIFY_BUG_FIXED p = old_password; /* what it should be */ #else p = ""; /* what it really is */ #endif } /* * RFC 2139 p.6 says not do do this, but the Livingston 1.16 * server disagrees. If the user says he wants the bug, give in. */ } else { /* authentication request */ if (conf->accounting_bug) { p = ""; } } if (!verify_packet(p, response, request)) { _pam_log(LOG_ERR, "packet from RADIUS server %s failed verification: " "The shared secret is probably incorrect.", server->hostname); ok = FALSE; break; } /* * Check that the response ID matches the request ID. */ if (response->id != request->id) { _pam_log(LOG_WARNING, "Response packet ID %d does not match the " "request packet ID %d: verification of packet fails", response->id, request->id); ok = FALSE; break; } } /* * Whew! The select is done. It hasn't timed out, or errored out. * It's our descriptor. We've got some data. It's the right size. * The packet is valid. * NOW, we can skip out of the select loop, and process the packet */ break; } /* otherwise, we've got data on another descriptor, keep select'ing */ } /* go to the next server if this one didn't respond */ next: if (!ok) { radius_server_t *old; /* forget about this server */ old = server; server = server->next; conf->server = server; _pam_forget(old->secret); free(old->hostname); free(old); if (server) { /* if there's more servers to check */ /* get a new authentication vector, and update the passwords */ get_random_vector(request->vector); request->id = request->vector[0]; /* update passwords, as appropriate */ if (password) { get_random_vector(request->vector); if (old_password) { /* password change request */ add_password(request, PW_PASSWORD, password, old_password); add_password(request, PW_OLD_PASSWORD, old_password, old_password); } else { /* authentication request */ add_password(request, PW_PASSWORD, password, server->secret); } } } continue; } else { /* we've found one that does respond, forget about the other servers */ cleanup(server->next); server->next = NULL; live_server = server; /* we've got a live one! */ break; } } if (!server) { _pam_log(LOG_ERR, "All RADIUS servers failed to respond."); if (conf->localifdown) retval = PAM_IGNORE; else retval = PAM_AUTHINFO_UNAVAIL; } else { retval = PAM_SUCCESS; } return retval; }
CWE-787
null
517,179
181871943868913124997180405411725409218
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
PAM_EXTERN int pam_sm_setcred(pam_handle_t *pamh,int flags,int argc,CONST char **argv) { int retval, *pret; retval = PAM_SUCCESS; pret = &retval; pam_get_data(pamh, "rad_setcred_return", (CONST void **) &pret); return *pret; }
CWE-787
null
517,180
106456469518834048246174295736691392622
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static int pam_private_session(pam_handle_t *pamh, int flags, int argc, CONST char **argv, int status) { CONST char *user; int ctrl; int retval = PAM_AUTH_ERR; char recv_buffer[4096]; char send_buffer[4096]; AUTH_HDR *request = (AUTH_HDR *) send_buffer; AUTH_HDR *response = (AUTH_HDR *) recv_buffer; radius_conf_t config; ctrl = _pam_parse(argc, argv, &config); /* grab the user name */ retval = pam_get_user(pamh, &user, NULL); PAM_FAIL_CHECK; /* check that they've entered something, and not too long, either */ if ((user == NULL) || (strlen(user) > MAXPWNAM)) { return PAM_USER_UNKNOWN; } /* * Get the IP address of the authentication server * Then, open a socket, and bind it to a port */ retval = initialize(&config, TRUE); PAM_FAIL_CHECK; /* * If there's no client id specified, use the service type, to help * keep track of which service is doing the authentication. */ if (!config.client_id) { retval = pam_get_item(pamh, PAM_SERVICE, (CONST void **) &config.client_id); PAM_FAIL_CHECK; } /* now we've got a socket open, so we've got to clean it up on error */ #undef PAM_FAIL_CHECK #define PAM_FAIL_CHECK if (retval != PAM_SUCCESS) {goto error; } /* build and initialize the RADIUS packet */ request->code = PW_ACCOUNTING_REQUEST; get_random_vector(request->vector); request->id = request->vector[0]; /* this should be evenly distributed */ build_radius_packet(request, user, NULL, &config); add_int_attribute(request, PW_ACCT_STATUS_TYPE, status); sprintf(recv_buffer, "%08d", (int) getpid()); add_attribute(request, PW_ACCT_SESSION_ID, (unsigned char *) recv_buffer, strlen(recv_buffer)); add_int_attribute(request, PW_ACCT_AUTHENTIC, PW_AUTH_RADIUS); if (status == PW_STATUS_START) { session_time = time(NULL); } else { add_int_attribute(request, PW_ACCT_SESSION_TIME, time(NULL) - session_time); } retval = talk_radius(&config, request, response, NULL, NULL, 1); PAM_FAIL_CHECK; /* oops! They don't have the right password. Complain and die. */ if (response->code != PW_ACCOUNTING_RESPONSE) { retval = PAM_PERM_DENIED; goto error; } retval = PAM_SUCCESS; error: close(config.sockfd); cleanup(config.server); return retval; }
CWE-787
null
517,181
183125966974894193070073044991882145155
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static uint32_t ipstr2long(char *ip_str) { char buf[6]; char *ptr; int i; int count; uint32_t ipaddr; int cur_byte; ipaddr = (uint32_t)0; for(i = 0;i < 4;i++) { ptr = buf; count = 0; *ptr = '\0'; while(*ip_str != '.' && *ip_str != '\0' && count < 4) { if (!isdigit(*ip_str)) { return (uint32_t)0; } *ptr++ = *ip_str++; count++; } if (count >= 4 || count == 0) { return (uint32_t)0; } *ptr = '\0'; cur_byte = atoi(buf); if (cur_byte < 0 || cur_byte > 255) { return (uint32_t)0; } ip_str++; ipaddr = ipaddr << 8 | (uint32_t)cur_byte; } return ipaddr; }
CWE-787
null
517,182
260435370832726884270567521913756659212
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, CONST char **argv) { return pam_private_session(pamh, flags, argc, argv, PW_STATUS_STOP); }
CWE-787
null
517,183
226133045326030904311143226476342110025
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static void _pam_log(int err, CONST char *format, ...) { va_list args; char buffer[BUFFER_SIZE]; va_start(args, format); vsprintf(buffer, format, args); /* don't do openlog or closelog, but put our name in to be friendly */ syslog(err, "%s: %s", pam_module_name, buffer); va_end(args); }
CWE-787
null
517,184
58388957187883160202521992475285154739
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static void get_accounting_vector(AUTH_HDR *request, radius_server_t *server) { MD5_CTX my_md5; int secretlen = strlen(server->secret); int len = ntohs(request->length); memset(request->vector, 0, AUTH_VECTOR_LEN); MD5Init(&my_md5); memcpy(((char *)request) + len, server->secret, secretlen); MD5Update(&my_md5, (unsigned char *)request, len + secretlen); MD5Final(request->vector, &my_md5); /* set the final vector */ }
CWE-787
null
517,185
210042347455732798384002413900025317968
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh,int flags,int argc,CONST char **argv) { CONST char *user; CONST char *userinfo; char *password = NULL; CONST char *rhost; char *resp2challenge = NULL; int ctrl; int retval = PAM_AUTH_ERR; int num_challenge = 0; char recv_buffer[4096]; char send_buffer[4096]; AUTH_HDR *request = (AUTH_HDR *) send_buffer; AUTH_HDR *response = (AUTH_HDR *) recv_buffer; radius_conf_t config; ctrl = _pam_parse(argc, argv, &config); /* grab the user name */ retval = pam_get_user(pamh, &user, NULL); PAM_FAIL_CHECK; /* check that they've entered something, and not too long, either */ if ((user == NULL) || (strlen(user) > MAXPWNAM)) { int *pret = malloc(sizeof(int)); *pret = PAM_USER_UNKNOWN; pam_set_data(pamh, "rad_setcred_return", (void *) pret, _int_free); DPRINT(LOG_DEBUG, "User name was NULL, or too long"); return PAM_USER_UNKNOWN; } DPRINT(LOG_DEBUG, "Got user name %s", user); if (ctrl & PAM_RUSER_ARG) { retval = pam_get_item(pamh, PAM_RUSER, (CONST void **) &userinfo); PAM_FAIL_CHECK; DPRINT(LOG_DEBUG, "Got PAM_RUSER name %s", userinfo); if (!strcmp("root", user)) { user = userinfo; DPRINT(LOG_DEBUG, "Username now %s from ruser", user); } else { DPRINT(LOG_DEBUG, "Skipping ruser for non-root auth"); } } /* * Get the IP address of the authentication server * Then, open a socket, and bind it to a port */ retval = initialize(&config, FALSE); PAM_FAIL_CHECK; /* * If there's no client id specified, use the service type, to help * keep track of which service is doing the authentication. */ if (!config.client_id) { retval = pam_get_item(pamh, PAM_SERVICE, (CONST void **) &config.client_id); PAM_FAIL_CHECK; } /* now we've got a socket open, so we've got to clean it up on error */ #undef PAM_FAIL_CHECK #define PAM_FAIL_CHECK if (retval != PAM_SUCCESS) {goto error; } /* build and initialize the RADIUS packet */ request->code = PW_AUTHENTICATION_REQUEST; get_random_vector(request->vector); request->id = request->vector[0]; /* this should be evenly distributed */ /* grab the password (if any) from the previous authentication layer */ if (!config.force_prompt) { DPRINT(LOG_DEBUG, "ignore last_pass, force_prompt set"); retval = pam_get_item(pamh, PAM_AUTHTOK, (CONST void **) &password); PAM_FAIL_CHECK; } if (password) { password = strdup(password); DPRINT(LOG_DEBUG, "Got password %s", password); } /* no previous password: maybe get one from the user */ if (!password) { if (ctrl & PAM_USE_FIRST_PASS) { retval = PAM_AUTH_ERR; /* use one pass only, stopping if it fails */ goto error; } /* check to see if we send a NULL password the first time around */ if (!(ctrl & PAM_SKIP_PASSWD)) { retval = rad_converse(pamh, PAM_PROMPT_ECHO_OFF, config.prompt, &password); PAM_FAIL_CHECK; } } /* end of password == NULL */ build_radius_packet(request, user, password, &config); /* not all servers understand this service type, but some do */ add_int_attribute(request, PW_USER_SERVICE_TYPE, PW_AUTHENTICATE_ONLY); /* * Tell the server which host the user is coming from. * * Note that this is NOT the IP address of the machine running PAM! * It's the IP address of the client. */ retval = pam_get_item(pamh, PAM_RHOST, (CONST void **) &rhost); PAM_FAIL_CHECK; if (rhost) { add_attribute(request, PW_CALLING_STATION_ID, (unsigned char *) rhost, strlen(rhost)); } DPRINT(LOG_DEBUG, "Sending RADIUS request code %d", request->code); retval = talk_radius(&config, request, response, password, NULL, config.retries + 1); PAM_FAIL_CHECK; DPRINT(LOG_DEBUG, "Got RADIUS response code %d", response->code); /* * If we get an authentication failure, and we sent a NULL password, * ask the user for one and continue. * * If we get an access challenge, then do a response, for as many * challenges as we receive. */ while (response->code == PW_ACCESS_CHALLENGE) { attribute_t *a_state, *a_reply; char challenge[BUFFER_SIZE]; /* Now we do a bit more work: challenge the user, and get a response */ if (((a_state = find_attribute(response, PW_STATE)) == NULL) || ((a_reply = find_attribute(response, PW_REPLY_MESSAGE)) == NULL)) { /* Actually, State isn't required. */ _pam_log(LOG_ERR, "RADIUS Access-Challenge received with State or Reply-Message missing"); retval = PAM_AUTHINFO_UNAVAIL; goto error; } /* * Security fixes. */ if ((a_state->length <= 2) || (a_reply->length <= 2)) { _pam_log(LOG_ERR, "RADIUS Access-Challenge received with invalid State or Reply-Message"); retval = PAM_AUTHINFO_UNAVAIL; goto error; } memcpy(challenge, a_reply->data, a_reply->length - 2); challenge[a_reply->length - 2] = 0; /* It's full challenge-response, we should have echo on */ retval = rad_converse(pamh, PAM_PROMPT_ECHO_ON, challenge, &resp2challenge); PAM_FAIL_CHECK; /* now that we've got a response, build a new radius packet */ build_radius_packet(request, user, resp2challenge, &config); /* request->code is already PW_AUTHENTICATION_REQUEST */ request->id++; /* one up from the request */ if (rhost) { add_attribute(request, PW_CALLING_STATION_ID, (unsigned char *) rhost, strlen(rhost)); } /* copy the state over from the servers response */ add_attribute(request, PW_STATE, a_state->data, a_state->length - 2); retval = talk_radius(&config, request, response, resp2challenge, NULL, 1); PAM_FAIL_CHECK; DPRINT(LOG_DEBUG, "Got response to challenge code %d", response->code); /* * max_challenge limits the # of challenges a server can issue * It's a workaround for buggy servers */ if (config.max_challenge > 0 && response->code == PW_ACCESS_CHALLENGE) { num_challenge++; if (num_challenge >= config.max_challenge) { DPRINT(LOG_DEBUG, "maximum number of challenges (%d) reached, failing", num_challenge); break; } } } /* Whew! Done the pasword checks, look for an authentication acknowledge */ if (response->code == PW_AUTHENTICATION_ACK) { retval = PAM_SUCCESS; } else { retval = PAM_AUTH_ERR; /* authentication failure */ error: /* If there was a password pass it to the next layer */ if (password && *password) { pam_set_item(pamh, PAM_AUTHTOK, password); } } DPRINT(LOG_DEBUG, "authentication %s", retval==PAM_SUCCESS ? "succeeded":"failed"); close(config.sockfd); cleanup(config.server); _pam_forget(password); _pam_forget(resp2challenge); { int *pret = malloc(sizeof(int)); *pret = retval; pam_set_data(pamh, "rad_setcred_return", (void *) pret, _int_free); } return retval; }
CWE-787
null
517,186
225203695545686910882930429303484520979
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, CONST char **argv) { return pam_private_session(pamh, flags, argc, argv, PW_STATUS_START); }
CWE-787
null
517,187
146153055956367515282085418096504646593
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static void add_int_attribute(AUTH_HDR *request, unsigned char type, int data) { int value = htonl(data); add_attribute(request, type, (unsigned char *) &value, sizeof(int)); }
CWE-787
null
517,188
267336696288652043936363458621488480571
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static void add_password(AUTH_HDR *request, unsigned char type, CONST char *password, char *secret) { MD5_CTX md5_secret, my_md5; unsigned char misc[AUTH_VECTOR_LEN]; int i; int length = strlen(password); unsigned char hashed[256 + AUTH_PASS_LEN]; /* can't be longer than this */ unsigned char *vector; attribute_t *attr; if (length > MAXPASS) { /* shorten the password for now */ length = MAXPASS; } if (length == 0) { length = AUTH_PASS_LEN; /* 0 maps to 16 */ } if ((length & (AUTH_PASS_LEN - 1)) != 0) { length += (AUTH_PASS_LEN - 1); /* round it up */ length &= ~(AUTH_PASS_LEN - 1); /* chop it off */ } /* 16*N maps to itself */ memset(hashed, 0, length); memcpy(hashed, password, length); attr = find_attribute(request, PW_PASSWORD); if (type == PW_PASSWORD) { vector = request->vector; } else { vector = attr->data; /* attr CANNOT be NULL here. */ } /* ************************************************************ */ /* encrypt the password */ /* password : e[0] = p[0] ^ MD5(secret + vector) */ MD5Init(&md5_secret); MD5Update(&md5_secret, (unsigned char *) secret, strlen(secret)); my_md5 = md5_secret; /* so we won't re-do the hash later */ MD5Update(&my_md5, vector, AUTH_VECTOR_LEN); MD5Final(misc, &my_md5); /* set the final vector */ xor(hashed, misc, AUTH_PASS_LEN); /* For each step through, e[i] = p[i] ^ MD5(secret + e[i-1]) */ for (i = 1; i < (length >> 4); i++) { my_md5 = md5_secret; /* grab old value of the hash */ MD5Update(&my_md5, &hashed[(i-1) * AUTH_PASS_LEN], AUTH_PASS_LEN); MD5Final(misc, &my_md5); /* set the final vector */ xor(&hashed[i * AUTH_PASS_LEN], misc, AUTH_PASS_LEN); } if (type == PW_OLD_PASSWORD) { attr = find_attribute(request, PW_OLD_PASSWORD); } if (!attr) { add_attribute(request, type, hashed, length); } else { memcpy(attr->data, hashed, length); /* overwrite the packet */ } }
CWE-787
null
517,189
167941960835446777329148180192080310949
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static int host2server(radius_server_t *server) { char *p; if ((p = strchr(server->hostname, ':')) != NULL) { *(p++) = '\0'; /* split the port off from the host name */ } if ((server->ip.s_addr = get_ipaddr(server->hostname)) == ((uint32_t)0)) { DPRINT(LOG_DEBUG, "DEBUG: get_ipaddr(%s) returned 0.\n", server->hostname); return PAM_AUTHINFO_UNAVAIL; } /* * If the server port hasn't already been defined, go get it. */ if (!server->port) { if (p && isdigit(*p)) { /* the port looks like it's a number */ unsigned int i = atoi(p) & 0xffff; if (!server->accounting) { server->port = htons((uint16_t) i); } else { server->port = htons((uint16_t) (i + 1)); } } else { /* the port looks like it's a name */ struct servent *svp; if (p) { /* maybe it's not "radius" */ svp = getservbyname (p, "udp"); /* quotes allow distinction from above, lest p be radius or radacct */ DPRINT(LOG_DEBUG, "DEBUG: getservbyname('%s', udp) returned %p.\n", p, svp); *(--p) = ':'; /* be sure to put the delimiter back */ } else { if (!server->accounting) { svp = getservbyname ("radius", "udp"); DPRINT(LOG_DEBUG, "DEBUG: getservbyname(radius, udp) returned %p.\n", svp); } else { svp = getservbyname ("radacct", "udp"); DPRINT(LOG_DEBUG, "DEBUG: getservbyname(radacct, udp) returned %p.\n", svp); } } if (svp == (struct servent *) 0) { /* debugging above... */ return PAM_AUTHINFO_UNAVAIL; } server->port = svp->s_port; } } return PAM_SUCCESS; }
CWE-787
null
517,190
75640765583910163358160560543461536643
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh,int flags,int argc,CONST char **argv) { int retval; retval = PAM_SUCCESS; return retval; }
CWE-787
null
517,191
235194122659639049254757630780157711006
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static void build_radius_packet(AUTH_HDR *request, CONST char *user, CONST char *password, radius_conf_t *conf) { char hostname[256]; uint32_t ipaddr; hostname[0] = '\0'; gethostname(hostname, sizeof(hostname) - 1); request->length = htons(AUTH_HDR_LEN); if (password) { /* make a random authentication req vector */ get_random_vector(request->vector); } add_attribute(request, PW_USER_NAME, (unsigned char *) user, strlen(user)); /* * Add a password, if given. */ if (password) { add_password(request, PW_PASSWORD, password, conf->server->secret); /* * Add a NULL password to non-accounting requests. */ } else if (request->code != PW_ACCOUNTING_REQUEST) { add_password(request, PW_PASSWORD, "", conf->server->secret); } /* the packet is from localhost if on localhost, to make configs easier */ if ((conf->server->ip.s_addr == ntohl(0x7f000001)) || (!hostname[0])) { ipaddr = 0x7f000001; } else { struct hostent *hp; if ((hp = gethostbyname(hostname)) == (struct hostent *) NULL) { ipaddr = 0x00000000; /* no client IP address */ } else { ipaddr = ntohl(*(uint32_t *) hp->h_addr); /* use the first one available */ } } /* If we can't find an IP address, then don't add one */ if (ipaddr) { add_int_attribute(request, PW_NAS_IP_ADDRESS, ipaddr); } /* There's always a NAS identifier */ if (conf->client_id && *conf->client_id) { add_attribute(request, PW_NAS_IDENTIFIER, (unsigned char *) conf->client_id, strlen(conf->client_id)); } /* * Add in the port (pid) and port type (virtual). * * We might want to give the TTY name here, too. */ add_int_attribute(request, PW_NAS_PORT_ID, getpid()); add_int_attribute(request, PW_NAS_PORT_TYPE, PW_NAS_PORT_TYPE_VIRTUAL); }
CWE-787
null
517,192
41584316919346367611701075128706496963
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
static int initialize(radius_conf_t *conf, int accounting) { struct sockaddr salocal; char hostname[BUFFER_SIZE]; char secret[BUFFER_SIZE]; char buffer[BUFFER_SIZE]; char *p; FILE *fserver; radius_server_t *server = NULL; struct sockaddr_in * s_in; int timeout; int line = 0; /* the first time around, read the configuration file */ if ((fserver = fopen (conf_file, "r")) == (FILE*)NULL) { _pam_log(LOG_ERR, "Could not open configuration file %s: %s\n", conf_file, strerror(errno)); return PAM_ABORT; } while (!feof(fserver) && (fgets (buffer, sizeof(buffer), fserver) != (char*) NULL) && (!ferror(fserver))) { line++; p = buffer; /* * Skip blank lines and whitespace */ while (*p && ((*p == ' ') || (*p == '\t') || (*p == '\r') || (*p == '\n'))) { p++; } /* * Nothing, or just a comment. Ignore the line. */ if ((!*p) || (*p == '#')) { continue; } timeout = 3; if (sscanf(p, "%s %s %d", hostname, secret, &timeout) < 2) { _pam_log(LOG_ERR, "ERROR reading %s, line %d: Could not read hostname or secret\n", conf_file, line); continue; /* invalid line */ } else { /* read it in and save the data */ radius_server_t *tmp; tmp = malloc(sizeof(radius_server_t)); if (server) { server->next = tmp; server = server->next; } else { conf->server = tmp; server= tmp; /* first time */ } /* sometime later do memory checks here */ server->hostname = strdup(hostname); server->secret = strdup(secret); server->accounting = accounting; server->port = 0; if ((timeout < 1) || (timeout > 60)) { server->timeout = 3; } else { server->timeout = timeout; } server->next = NULL; } } fclose(fserver); if (!server) { /* no server found, die a horrible death */ _pam_log(LOG_ERR, "No RADIUS server found in configuration file %s\n", conf_file); return PAM_AUTHINFO_UNAVAIL; } /* open a socket. Dies if it fails */ conf->sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (conf->sockfd < 0) { _pam_log(LOG_ERR, "Failed to open RADIUS socket: %s\n", strerror(errno)); return PAM_AUTHINFO_UNAVAIL; } /* set up the local end of the socket communications */ s_in = (struct sockaddr_in *) &salocal; memset ((char *) s_in, '\0', sizeof(struct sockaddr)); s_in->sin_family = AF_INET; s_in->sin_addr.s_addr = INADDR_ANY; s_in->sin_port = 0; if (bind(conf->sockfd, &salocal, sizeof (struct sockaddr_in)) < 0) { _pam_log(LOG_ERR, "Failed binding to port: %s", strerror(errno)); close(conf->sockfd); return PAM_AUTHINFO_UNAVAIL; } return PAM_SUCCESS; }
CWE-787
null
517,193
151679867504037238267188393030772862545
null
null
other
pam_radius
01173ec2426627dbb1e0d96c06c3ffa0b14d36d0
0
void _int_free(pam_handle_t * pamh, void *x, int error_status) { free(x); }
CWE-787
null
517,194
214942584403093579315360810046381953990
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
option_value2string ( vimoption_T *opp, int opt_flags /* OPT_GLOBAL and/or OPT_LOCAL */ ) { char_u *varp; varp = get_varp_scope(opp, opt_flags); if (opp->flags & P_NUM) { long wc = 0; if (wc_use_keyname(varp, &wc)) { STRLCPY(NameBuff, get_special_key_name((int)wc, 0), sizeof(NameBuff)); } else if (wc != 0) { STRLCPY(NameBuff, transchar((int)wc), sizeof(NameBuff)); } else { snprintf((char *)NameBuff, sizeof(NameBuff), "%" PRId64, (int64_t)*(long *)varp); } } else { // P_STRING varp = *(char_u **)(varp); if (varp == NULL) /* just in case */ NameBuff[0] = NUL; else if (opp->flags & P_EXPAND) home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); /* Translate 'pastetoggle' into special key names */ else if ((char_u **)opp->var == &p_pt) str2specialbuf(p_pt, NameBuff, MAXPATHL); else STRLCPY(NameBuff, varp, MAXPATHL); } }
CWE-20
null
517,195
48209571973142411733491740899585623322
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
void set_init_1(void) { int opt_idx; langmap_init(); /* Be nocompatible */ p_cp = FALSE; /* * Find default value for 'shell' option. * Don't use it if it is empty. */ { const char *shell = os_getenv("SHELL"); if (shell != NULL) { set_string_default("sh", (char *) shell, false); } } /* * Set the default for 'backupskip' to include environment variables for * temp files. */ { # ifdef UNIX static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; # else static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; # endif int len; garray_T ga; ga_init(&ga, 1, 100); for (size_t n = 0; n < ARRAY_SIZE(names); ++n) { bool mustfree = true; char *p; # ifdef UNIX if (*names[n] == NUL) { p = "/tmp"; mustfree = false; } else # endif p = vim_getenv(names[n]); if (p != NULL && *p != NUL) { // First time count the NUL, otherwise count the ','. len = (int)strlen(p) + 3; ga_grow(&ga, len); if (!GA_EMPTY(&ga)) STRCAT(ga.ga_data, ","); STRCAT(ga.ga_data, p); add_pathsep(ga.ga_data); STRCAT(ga.ga_data, "*"); ga.ga_len += len; } if(mustfree) { xfree(p); } } if (ga.ga_data != NULL) { set_string_default("bsk", ga.ga_data, true); } } /* * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory */ opt_idx = findoption((char_u *)"maxmemtot"); if (opt_idx >= 0) { { /* Use half of amount of memory available to Vim. */ /* If too much to fit in uintptr_t, get uintptr_t max */ uint64_t available_kib = os_get_total_mem_kib(); uintptr_t n = available_kib / 2 > UINTPTR_MAX ? UINTPTR_MAX : (uintptr_t)(available_kib /2); options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; opt_idx = findoption((char_u *)"maxmem"); if (opt_idx >= 0) { options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; } } } { char_u *cdpath; char_u *buf; int i; int j; /* Initialize the 'cdpath' option's default value. */ cdpath = (char_u *)vim_getenv("CDPATH"); if (cdpath != NULL) { buf = xmalloc(2 * STRLEN(cdpath) + 2); { buf[0] = ','; /* start with ",", current dir first */ j = 1; for (i = 0; cdpath[i] != NUL; ++i) { if (vim_ispathlistsep(cdpath[i])) buf[j++] = ','; else { if (cdpath[i] == ' ' || cdpath[i] == ',') buf[j++] = '\\'; buf[j++] = cdpath[i]; } } buf[j] = NUL; opt_idx = findoption((char_u *)"cdpath"); if (opt_idx >= 0) { options[opt_idx].def_val[VI_DEFAULT] = buf; options[opt_idx].flags |= P_DEF_ALLOCED; } else xfree(buf); /* cannot happen */ } xfree(cdpath); } } #if defined(MSWIN) || defined(MAC) /* Set print encoding on platforms that don't default to latin1 */ set_string_default("printencoding", "hp-roman8", false); #endif // 'printexpr' must be allocated to be able to evaluate it. set_string_default("printexpr", #ifdef UNIX "system(['lpr'] " "+ (empty(&printdevice)?[]:['-P', &printdevice]) " "+ [v:fname_in])" ". delete(v:fname_in)" "+ v:shell_error", #elif defined(MSWIN) "system(['copy', v:fname_in, " "empty(&printdevice)?'LPT1':&printdevice])" ". delete(v:fname_in)", #else "", #endif false); char *backupdir = stdpaths_user_data_subpath("backup", 0, true); const size_t backupdir_len = strlen(backupdir); backupdir = xrealloc(backupdir, backupdir_len + 3); memmove(backupdir + 2, backupdir, backupdir_len + 1); memmove(backupdir, ".,", 2); set_string_default("viewdir", stdpaths_user_data_subpath("view", 0, true), true); set_string_default("backupdir", backupdir, true); set_string_default("directory", stdpaths_user_data_subpath("swap", 2, true), true); set_string_default("undodir", stdpaths_user_data_subpath("undo", 0, true), true); // Set default for &runtimepath. All necessary expansions are performed in // this function. set_runtimepath_default(); /* * Set all the options (except the terminal options) to their default * value. Also set the global value for local options. */ set_options_default(0); curbuf->b_p_initialized = true; curbuf->b_p_ar = -1; /* no local 'autoread' value */ curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; check_buf_options(curbuf); check_win_options(curwin); check_options(); /* Set all options to their Vim default */ set_options_default(OPT_FREE); // set 'laststatus' last_status(false); /* Must be before option_expand(), because that one needs vim_isIDc() */ didset_options(); // Use the current chartab for the generic chartab. This is not in // didset_options() because it only depends on 'encoding'. init_spell_chartab(); /* * Expand environment variables and things like "~" for the defaults. * If option_expand() returns non-NULL the variable is expanded. This can * only happen for non-indirect options. * Also set the default to the expanded value, so ":set" does not list * them. * Don't set the P_ALLOCED flag, because we don't want to free the * default. */ for (opt_idx = 0; options[opt_idx].fullname; opt_idx++) { if (options[opt_idx].flags & P_NO_DEF_EXP) { continue; } char *p; if ((options[opt_idx].flags & P_GETTEXT) && options[opt_idx].var != NULL) { p = _(*(char **)options[opt_idx].var); } else { p = (char *) option_expand(opt_idx, NULL); } if (p != NULL) { p = xstrdup(p); *(char **)options[opt_idx].var = p; /* VIMEXP * Defaults for all expanded options are currently the same for Vi * and Vim. When this changes, add some code here! Also need to * split P_DEF_ALLOCED in two. */ if (options[opt_idx].flags & P_DEF_ALLOCED) xfree(options[opt_idx].def_val[VI_DEFAULT]); options[opt_idx].def_val[VI_DEFAULT] = (char_u *) p; options[opt_idx].flags |= P_DEF_ALLOCED; } } save_file_ff(curbuf); /* Buffer is unchanged */ /* Detect use of mlterm. * Mlterm is a terminal emulator akin to xterm that has some special * abilities (bidi namely). * NOTE: mlterm's author is being asked to 'set' a variable * instead of an environment variable due to inheritance. */ if (os_env_exists("MLTERM")) set_option_value((char_u *)"tbidi", 1L, NULL, 0); didset_options2(); // enc_locale() will try to find the encoding of the current locale. // This will be used when 'default' is used as encoding specifier // in 'fileencodings' char_u *p = enc_locale(); if (p == NULL) { // use utf-8 as 'default' if locale encoding can't be detected. p = vim_strsave((char_u *)"utf-8"); } fenc_default = p; #ifdef HAVE_WORKING_LIBINTL // GNU gettext 0.10.37 supports this feature: set the codeset used for // translated messages independently from the current locale. (void)bind_textdomain_codeset(PROJECT_NAME, (char *)p_enc); #endif /* Set the default for 'helplang'. */ set_helplang_default(get_mess_lang()); }
CWE-20
null
517,196
306062594362051869906046687525495402393
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
int langmap_adjust_mb(int c) { langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); int a = 0; int b = langmap_mapga.ga_len; while (a != b) { int i = (a + b) / 2; int d = entries[i].from - c; if (d == 0) return entries[i].to; /* found matching entry */ if (d < 0) a = i + 1; else b = i; } return c; /* no entry found, return "c" unmodified */ }
CWE-20
null
517,197
216246437842386260672746122472443289450
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
static void langmap_set(void) { char_u *p; char_u *p2; int from, to; ga_clear(&langmap_mapga); /* clear the previous map first */ langmap_init(); /* back to one-to-one map */ for (p = p_langmap; p[0] != NUL; ) { for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';'; mb_ptr_adv(p2)) { if (p2[0] == '\\' && p2[1] != NUL) ++p2; } if (p2[0] == ';') ++p2; /* abcd;ABCD form, p2 points to A */ else p2 = NULL; /* aAbBcCdD form, p2 is NULL */ while (p[0]) { if (p[0] == ',') { ++p; break; } if (p[0] == '\\' && p[1] != NUL) ++p; from = (*mb_ptr2char)(p); to = NUL; if (p2 == NULL) { mb_ptr_adv(p); if (p[0] != ',') { if (p[0] == '\\') ++p; to = (*mb_ptr2char)(p); } } else { if (p2[0] != ',') { if (p2[0] == '\\') ++p2; to = (*mb_ptr2char)(p2); } } if (to == NUL) { EMSG2(_("E357: 'langmap': Matching character missing for %s"), transchar(from)); return; } if (from >= 256) langmap_set_entry(from, to); else { assert(to <= UCHAR_MAX); langmap_mapchar[from & 255] = (char_u)to; } /* Advance to next pair */ mb_ptr_adv(p); if (p2 != NULL) { mb_ptr_adv(p2); if (*p == ';') { p = p2; if (p[0] != NUL) { if (p[0] != ',') { EMSG2(_( "E358: 'langmap': Extra characters after semicolon: %s"), p); return; } ++p; } break; } } } } }
CWE-20
null
517,198
60220912586512903674669956340267770957
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
bool is_tty_option(char *name) { return (name[0] == 't' && name[1] == '_') || !strcmp((char *)name, "term"); }
CWE-20
null
517,199
190519904334393120858720666298277993214
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
bool set_tty_option(char *name, char *value) { if (!strcmp(name, "t_Co")) { int colors = atoi(value); // Only reinitialize colors if t_Co value has really changed to // avoid expensive reload of colorscheme if t_Co is set to the // same value multiple times if (colors != t_colors) { t_colors = colors; // We now have a different color setup, initialize it again. init_highlight(TRUE, FALSE); } return true; } return is_tty_option(name) || !strcmp(name, "term") || !strcmp(name, "ttytype"); }
CWE-20
null
517,200
7092731370912457693567949666751010908
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
int makefoldset(FILE *fd) { if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE) == FAIL || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE) == FAIL || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE) == FAIL || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL ) return FAIL; return OK; }
CWE-20
null
517,201
26512293805263693512233016142675859431
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
set_bool_option ( int opt_idx, /* index in options[] table */ char_u *varp, /* pointer to the option variable */ int value, /* new value */ int opt_flags /* OPT_LOCAL and/or OPT_GLOBAL */ ) { int old_value = *(int *)varp; /* Disallow changing some options from secure mode */ if ((secure || sandbox != 0) && (options[opt_idx].flags & P_SECURE)) { return e_secure; } *(int *)varp = value; /* set the new value */ /* Remember where the option was set. */ set_option_scriptID_idx(opt_idx, opt_flags, current_SID); /* May set global value for local option. */ if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; // Ensure that options set to p_force_on cannot be disabled. if ((int *)varp == &p_force_on && p_force_on == FALSE) { p_force_on = TRUE; return e_unsupportedoption; } // Ensure that options set to p_force_off cannot be enabled. else if ((int *)varp == &p_force_off && p_force_off == TRUE) { p_force_off = FALSE; return e_unsupportedoption; } /* 'undofile' */ else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) { /* Only take action when the option was set. When reset we do not * delete the undo file, the option may be set again without making * any changes in between. */ if (curbuf->b_p_udf || p_udf) { char_u hash[UNDO_HASH_SIZE]; buf_T *save_curbuf = curbuf; for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next) { /* When 'undofile' is set globally: for every buffer, otherwise * only for the current buffer: Try to read in the undofile, * if one exists, the buffer wasn't changed and the buffer was * loaded */ if ((curbuf == save_curbuf || (opt_flags & OPT_GLOBAL) || opt_flags == 0) && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) { u_compute_hash(hash); u_read_undo(NULL, hash, curbuf->b_fname); } } curbuf = save_curbuf; } } else if ((int *)varp == &curbuf->b_p_ro) { /* when 'readonly' is reset globally, also reset readonlymode */ if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) readonlymode = FALSE; /* when 'readonly' is set may give W10 again */ if (curbuf->b_p_ro) curbuf->b_did_warn = false; redraw_titles(); } /* when 'modifiable' is changed, redraw the window title */ else if ((int *)varp == &curbuf->b_p_ma) { redraw_titles(); } /* when 'endofline' is changed, redraw the window title */ else if ((int *)varp == &curbuf->b_p_eol) { redraw_titles(); } else if ((int *)varp == &curbuf->b_p_fixeol) { // when 'fixeol' is changed, redraw the window title redraw_titles(); } /* when 'bomb' is changed, redraw the window title and tab page text */ else if ((int *)varp == &curbuf->b_p_bomb) { redraw_titles(); } /* when 'bin' is set also set some other options */ else if ((int *)varp == &curbuf->b_p_bin) { set_options_bin(old_value, curbuf->b_p_bin, opt_flags); redraw_titles(); } /* when 'buflisted' changes, trigger autocommands */ else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) { apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, NULL, NULL, TRUE, curbuf); } /* when 'swf' is set, create swapfile, when reset remove swapfile */ else if ((int *)varp == (int *)&curbuf->b_p_swf) { if (curbuf->b_p_swf && p_uc) ml_open_file(curbuf); /* create the swap file */ else /* no need to reset curbuf->b_may_swap, ml_open_file() will check * buf->b_p_swf */ mf_close_file(curbuf, true); /* remove the swap file */ } /* when 'terse' is set change 'shortmess' */ else if ((int *)varp == &p_terse) { char_u *p; p = vim_strchr(p_shm, SHM_SEARCH); /* insert 's' in p_shm */ if (p_terse && p == NULL) { STRCPY(IObuff, p_shm); STRCAT(IObuff, "s"); set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); } /* remove 's' from p_shm */ else if (!p_terse && p != NULL) STRMOVE(p, p + 1); } /* when 'paste' is set or reset also change other options */ else if ((int *)varp == &p_paste) { paste_option_changed(); } /* when 'insertmode' is set from an autocommand need to do work here */ else if ((int *)varp == &p_im) { if (p_im) { if ((State & INSERT) == 0) { need_start_insertmode = true; } stop_insert_mode = false; } else if (old_value) { // only reset if it was set previously need_start_insertmode = false; stop_insert_mode = true; if (restart_edit != 0 && mode_displayed) { clear_cmdline = true; // remove "(insert)" } restart_edit = 0; } } /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */ else if ((int *)varp == &p_ic && p_hls) { redraw_all_later(SOME_VALID); } /* when 'hlsearch' is set or reset: reset no_hlsearch */ else if ((int *)varp == &p_hls) { SET_NO_HLSEARCH(FALSE); } /* when 'scrollbind' is set: snapshot the current position to avoid a jump * at the end of normal_cmd() */ else if ((int *)varp == &curwin->w_p_scb) { if (curwin->w_p_scb) { do_check_scrollbind(FALSE); curwin->w_scbind_pos = curwin->w_topline; } } /* There can be only one window with 'previewwindow' set. */ else if ((int *)varp == &curwin->w_p_pvw) { if (curwin->w_p_pvw) { FOR_ALL_WINDOWS_IN_TAB(win, curtab) { if (win->w_p_pvw && win != curwin) { curwin->w_p_pvw = FALSE; return (char_u *)N_("E590: A preview window already exists"); } } } } else if (varp == (char_u *)&(curbuf->b_p_lisp)) { // When 'lisp' option changes include/exclude '-' in // keyword characters. (void)buf_init_chartab(curbuf, false); // ignore errors } else if ((int *)varp == &p_title) { // when 'title' changed, may need to change the title; same for 'icon' did_set_title(false); } else if ((int *)varp == &p_icon) { did_set_title(true); } else if ((int *)varp == &curbuf->b_changed) { if (!value) { save_file_ff(curbuf); // Buffer is unchanged } redraw_titles(); modified_was_set = value; } #ifdef BACKSLASH_IN_FILENAME else if ((int *)varp == &p_ssl) { if (p_ssl) { psepc = '/'; psepcN = '\\'; pseps[0] = '/'; } else { psepc = '\\'; psepcN = '/'; pseps[0] = '\\'; } /* need to adjust the file name arguments and buffer names. */ buflist_slash_adjust(); alist_slash_adjust(); scriptnames_slash_adjust(); } #endif /* If 'wrap' is set, set w_leftcol to zero. */ else if ((int *)varp == &curwin->w_p_wrap) { if (curwin->w_p_wrap) curwin->w_leftcol = 0; } else if ((int *)varp == &p_ea) { if (p_ea && !old_value) { win_equal(curwin, false, 0); } } else if ((int *)varp == &p_acd) { // Change directories when the 'acd' option is set now. do_autochdir(); } /* 'diff' */ else if ((int *)varp == &curwin->w_p_diff) { /* May add or remove the buffer from the list of diff buffers. */ diff_buf_adjust(curwin); if (foldmethodIsDiff(curwin)) foldUpdateAll(curwin); } /* 'spell' */ else if ((int *)varp == &curwin->w_p_spell) { if (curwin->w_p_spell) { char_u *errmsg = did_set_spelllang(curwin); if (errmsg != NULL) EMSG(_(errmsg)); } } else if ((int *)varp == &p_altkeymap) { if (old_value != p_altkeymap) { if (!p_altkeymap) { p_hkmap = p_fkmap; p_fkmap = 0; } else { p_fkmap = p_hkmap; p_hkmap = 0; } (void)init_chartab(); } } /* * In case some second language keymapping options have changed, check * and correct the setting in a consistent way. */ /* * If hkmap or fkmap are set, reset Arabic keymapping. */ if ((p_hkmap || p_fkmap) && p_altkeymap) { p_altkeymap = p_fkmap; curwin->w_p_arab = FALSE; (void)init_chartab(); } /* * If hkmap set, reset Farsi keymapping. */ if (p_hkmap && p_altkeymap) { p_altkeymap = 0; p_fkmap = 0; curwin->w_p_arab = FALSE; (void)init_chartab(); } /* * If fkmap set, reset Hebrew keymapping. */ if (p_fkmap && !p_altkeymap) { p_altkeymap = 1; p_hkmap = 0; curwin->w_p_arab = FALSE; (void)init_chartab(); } if ((int *)varp == &curwin->w_p_arab) { if (curwin->w_p_arab) { /* * 'arabic' is set, handle various sub-settings. */ if (!p_tbidi) { /* set rightleft mode */ if (!curwin->w_p_rl) { curwin->w_p_rl = TRUE; changed_window_setting(); } /* Enable Arabic shaping (major part of what Arabic requires) */ if (!p_arshape) { p_arshape = TRUE; redraw_later_clear(); } } /* Arabic requires a utf-8 encoding, inform the user if its not * set. */ if (STRCMP(p_enc, "utf-8") != 0) { static char *w_arabic = N_( "W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); msg_source(hl_attr(HLF_W)); MSG_ATTR(_(w_arabic), hl_attr(HLF_W)); set_vim_var_string(VV_WARNINGMSG, _(w_arabic), -1); } /* set 'delcombine' */ p_deco = TRUE; /* Force-set the necessary keymap for arabic */ set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", OPT_LOCAL); p_altkeymap = 0; p_hkmap = 0; p_fkmap = 0; (void)init_chartab(); } else { /* * 'arabic' is reset, handle various sub-settings. */ if (!p_tbidi) { /* reset rightleft mode */ if (curwin->w_p_rl) { curwin->w_p_rl = FALSE; changed_window_setting(); } /* 'arabicshape' isn't reset, it is a global option and * another window may still need it "on". */ } /* 'delcombine' isn't reset, it is a global option and another * window may still want it "on". */ /* Revert to the default keymap */ curbuf->b_p_iminsert = B_IMODE_NONE; curbuf->b_p_imsearch = B_IMODE_USE_INSERT; } } /* * End of handling side effects for bool options. */ // after handling side effects, call autocommand options[opt_idx].flags |= P_WAS_SET; if (!starting) { char buf_old[2]; char buf_new[2]; char buf_type[7]; vim_snprintf(buf_old, ARRAY_SIZE(buf_old), "%d", old_value ? true: false); vim_snprintf(buf_new, ARRAY_SIZE(buf_new), "%d", value ? true: false); vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); set_vim_var_string(VV_OPTION_NEW, buf_new, -1); set_vim_var_string(VV_OPTION_OLD, buf_old, -1); set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, false, NULL); reset_v_option_vars(); } comp_col(); /* in case 'ruler' or 'showcmd' changed */ if (curwin->w_curswant != MAXCOL && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; check_redraw(options[opt_idx].flags); return NULL; }
CWE-20
null
517,202
196595371279622368366574169438558845783
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
static char_u *get_varp(vimoption_T *p) { /* hidden option, always return NULL */ if (p->var == NULL) return NULL; switch ((int)p->indir) { case PV_NONE: return p->var; /* global option with local value: use local value if it's been set */ case PV_EP: return *curbuf->b_p_ep != NUL ? (char_u *)&curbuf->b_p_ep : p->var; case PV_KP: return *curbuf->b_p_kp != NUL ? (char_u *)&curbuf->b_p_kp : p->var; case PV_PATH: return *curbuf->b_p_path != NUL ? (char_u *)&(curbuf->b_p_path) : p->var; case PV_AR: return curbuf->b_p_ar >= 0 ? (char_u *)&(curbuf->b_p_ar) : p->var; case PV_TAGS: return *curbuf->b_p_tags != NUL ? (char_u *)&(curbuf->b_p_tags) : p->var; case PV_TC: return *curbuf->b_p_tc != NUL ? (char_u *)&(curbuf->b_p_tc) : p->var; case PV_BKC: return *curbuf->b_p_bkc != NUL ? (char_u *)&(curbuf->b_p_bkc) : p->var; case PV_DEF: return *curbuf->b_p_def != NUL ? (char_u *)&(curbuf->b_p_def) : p->var; case PV_INC: return *curbuf->b_p_inc != NUL ? (char_u *)&(curbuf->b_p_inc) : p->var; case PV_DICT: return *curbuf->b_p_dict != NUL ? (char_u *)&(curbuf->b_p_dict) : p->var; case PV_TSR: return *curbuf->b_p_tsr != NUL ? (char_u *)&(curbuf->b_p_tsr) : p->var; case PV_EFM: return *curbuf->b_p_efm != NUL ? (char_u *)&(curbuf->b_p_efm) : p->var; case PV_GP: return *curbuf->b_p_gp != NUL ? (char_u *)&(curbuf->b_p_gp) : p->var; case PV_MP: return *curbuf->b_p_mp != NUL ? (char_u *)&(curbuf->b_p_mp) : p->var; case PV_STL: return *curwin->w_p_stl != NUL ? (char_u *)&(curwin->w_p_stl) : p->var; case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL ? (char_u *)&(curbuf->b_p_ul) : p->var; case PV_LW: return *curbuf->b_p_lw != NUL ? (char_u *)&(curbuf->b_p_lw) : p->var; case PV_ARAB: return (char_u *)&(curwin->w_p_arab); case PV_LIST: return (char_u *)&(curwin->w_p_list); case PV_SPELL: return (char_u *)&(curwin->w_p_spell); case PV_CUC: return (char_u *)&(curwin->w_p_cuc); case PV_CUL: return (char_u *)&(curwin->w_p_cul); case PV_CC: return (char_u *)&(curwin->w_p_cc); case PV_DIFF: return (char_u *)&(curwin->w_p_diff); case PV_FDC: return (char_u *)&(curwin->w_p_fdc); case PV_FEN: return (char_u *)&(curwin->w_p_fen); case PV_FDI: return (char_u *)&(curwin->w_p_fdi); case PV_FDL: return (char_u *)&(curwin->w_p_fdl); case PV_FDM: return (char_u *)&(curwin->w_p_fdm); case PV_FML: return (char_u *)&(curwin->w_p_fml); case PV_FDN: return (char_u *)&(curwin->w_p_fdn); case PV_FDE: return (char_u *)&(curwin->w_p_fde); case PV_FDT: return (char_u *)&(curwin->w_p_fdt); case PV_FMR: return (char_u *)&(curwin->w_p_fmr); case PV_NU: return (char_u *)&(curwin->w_p_nu); case PV_RNU: return (char_u *)&(curwin->w_p_rnu); case PV_NUW: return (char_u *)&(curwin->w_p_nuw); case PV_WFH: return (char_u *)&(curwin->w_p_wfh); case PV_WFW: return (char_u *)&(curwin->w_p_wfw); case PV_PVW: return (char_u *)&(curwin->w_p_pvw); case PV_RL: return (char_u *)&(curwin->w_p_rl); case PV_RLC: return (char_u *)&(curwin->w_p_rlc); case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); case PV_LBR: return (char_u *)&(curwin->w_p_lbr); case PV_BRI: return (char_u *)&(curwin->w_p_bri); case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); case PV_SCBIND: return (char_u *)&(curwin->w_p_scb); case PV_CRBIND: return (char_u *)&(curwin->w_p_crb); case PV_COCU: return (char_u *)&(curwin->w_p_cocu); case PV_COLE: return (char_u *)&(curwin->w_p_cole); case PV_AI: return (char_u *)&(curbuf->b_p_ai); case PV_BIN: return (char_u *)&(curbuf->b_p_bin); case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); case PV_BH: return (char_u *)&(curbuf->b_p_bh); case PV_BT: return (char_u *)&(curbuf->b_p_bt); case PV_BL: return (char_u *)&(curbuf->b_p_bl); case PV_CI: return (char_u *)&(curbuf->b_p_ci); case PV_CIN: return (char_u *)&(curbuf->b_p_cin); case PV_CINK: return (char_u *)&(curbuf->b_p_cink); case PV_CINO: return (char_u *)&(curbuf->b_p_cino); case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); case PV_COM: return (char_u *)&(curbuf->b_p_com); case PV_CMS: return (char_u *)&(curbuf->b_p_cms); case PV_CPT: return (char_u *)&(curbuf->b_p_cpt); case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); case PV_EOL: return (char_u *)&(curbuf->b_p_eol); case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); case PV_ET: return (char_u *)&(curbuf->b_p_et); case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); case PV_FF: return (char_u *)&(curbuf->b_p_ff); case PV_FT: return (char_u *)&(curbuf->b_p_ft); case PV_FO: return (char_u *)&(curbuf->b_p_fo); case PV_FLP: return (char_u *)&(curbuf->b_p_flp); case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); case PV_INF: return (char_u *)&(curbuf->b_p_inf); case PV_ISK: return (char_u *)&(curbuf->b_p_isk); case PV_INEX: return (char_u *)&(curbuf->b_p_inex); case PV_INDE: return (char_u *)&(curbuf->b_p_inde); case PV_INDK: return (char_u *)&(curbuf->b_p_indk); case PV_FEX: return (char_u *)&(curbuf->b_p_fex); case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); case PV_ML: return (char_u *)&(curbuf->b_p_ml); case PV_MPS: return (char_u *)&(curbuf->b_p_mps); case PV_MA: return (char_u *)&(curbuf->b_p_ma); case PV_MOD: return (char_u *)&(curbuf->b_changed); case PV_NF: return (char_u *)&(curbuf->b_p_nf); case PV_PI: return (char_u *)&(curbuf->b_p_pi); case PV_QE: return (char_u *)&(curbuf->b_p_qe); case PV_RO: return (char_u *)&(curbuf->b_p_ro); case PV_SI: return (char_u *)&(curbuf->b_p_si); case PV_STS: return (char_u *)&(curbuf->b_p_sts); case PV_SUA: return (char_u *)&(curbuf->b_p_sua); case PV_SWF: return (char_u *)&(curbuf->b_p_swf); case PV_SMC: return (char_u *)&(curbuf->b_p_smc); case PV_SYN: return (char_u *)&(curbuf->b_p_syn); case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc); case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf); case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl); case PV_SW: return (char_u *)&(curbuf->b_p_sw); case PV_TS: return (char_u *)&(curbuf->b_p_ts); case PV_TW: return (char_u *)&(curbuf->b_p_tw); case PV_UDF: return (char_u *)&(curbuf->b_p_udf); case PV_WM: return (char_u *)&(curbuf->b_p_wm); case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); default: EMSG(_("E356: get_varp ERROR")); } /* always return a valid pointer to avoid a crash! */ return (char_u *)&(curbuf->b_p_wm); }
CWE-20
null
517,203
35828702639246747078198040797966923458
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
void find_mps_values(int *initc, int *findc, int *backwards, int switchit) { char_u *ptr; ptr = curbuf->b_p_mps; while (*ptr != NUL) { if (has_mbyte) { char_u *prev; if (mb_ptr2char(ptr) == *initc) { if (switchit) { *findc = *initc; *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); *backwards = TRUE; } else { *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); *backwards = FALSE; } return; } prev = ptr; ptr += mb_ptr2len(ptr) + 1; if (mb_ptr2char(ptr) == *initc) { if (switchit) { *findc = *initc; *initc = mb_ptr2char(prev); *backwards = FALSE; } else { *findc = mb_ptr2char(prev); *backwards = TRUE; } return; } ptr += mb_ptr2len(ptr); } else { if (*ptr == *initc) { if (switchit) { *backwards = TRUE; *findc = *initc; *initc = ptr[2]; } else { *backwards = FALSE; *findc = ptr[2]; } return; } ptr += 2; if (*ptr == *initc) { if (switchit) { *backwards = FALSE; *findc = *initc; *initc = ptr[-2]; } else { *backwards = TRUE; *findc = ptr[-2]; } return; } ++ptr; } if (*ptr == ',') ++ptr; } }
CWE-20
null
517,204
202346193975203188341005670358064634381
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
bool shortmess(int x) { return (p_shm != NULL && (vim_strchr(p_shm, x) != NULL || (vim_strchr(p_shm, 'a') != NULL && vim_strchr((char_u *)SHM_ALL_ABBREVIATIONS, x) != NULL))); }
CWE-20
null
517,205
15376708292250099914984254127879613506
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
static int check_opt_wim(void) { char_u new_wim_flags[4]; char_u *p; int i; int idx = 0; for (i = 0; i < 4; ++i) new_wim_flags[i] = 0; for (p = p_wim; *p; ++p) { for (i = 0; ASCII_ISALPHA(p[i]); ++i) ; if (p[i] != NUL && p[i] != ',' && p[i] != ':') return FAIL; if (i == 7 && STRNCMP(p, "longest", 7) == 0) new_wim_flags[idx] |= WIM_LONGEST; else if (i == 4 && STRNCMP(p, "full", 4) == 0) new_wim_flags[idx] |= WIM_FULL; else if (i == 4 && STRNCMP(p, "list", 4) == 0) new_wim_flags[idx] |= WIM_LIST; else return FAIL; p += i; if (*p == NUL) break; if (*p == ',') { if (idx == 3) return FAIL; ++idx; } } /* fill remaining entries with last flag */ while (idx < 3) { new_wim_flags[idx + 1] = new_wim_flags[idx]; ++idx; } /* only when there are no errors, wim_flags[] is changed */ for (i = 0; i < 4; ++i) wim_flags[i] = new_wim_flags[i]; return OK; }
CWE-20
null
517,206
15997092127407945341487508432838830251
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
int has_format_option(int x) { if (p_paste) return FALSE; return vim_strchr(curbuf->b_p_fo, x) != NULL; }
CWE-20
null
517,207
170987096728154263833989715197599142923
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
static void didset_options(void) { /* initialize the table for 'iskeyword' et.al. */ (void)init_chartab(); (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, true); (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, true); (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, true); (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true); (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, true); (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, true); (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, true); (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, false); (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, true); (void)spell_check_msm(); (void)spell_check_sps(); (void)compile_cap_prog(curwin->w_s); (void)did_set_spell_option(true); // set cedit_key (void)check_cedit(); briopt_check(curwin); // initialize the table for 'breakat'. fill_breakat_flags(); }
CWE-20
null
517,208
132528669574719002727953931674480318339
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
for (size_t i = 0; i < len; i++) { if (src[i] == ',') { dest[i + shift++] = '\\'; } dest[i + shift] = src[i]; }
CWE-20
null
517,209
73328634745830113543539692558938976389
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
if (dir != NULL && dir_len > 0) { ret += ((dir_len + memcnt(dir, ',', dir_len) + common_suf_len + !after_pathsep(dir, dir + dir_len)) * 2 + single_suf_len); }
CWE-20
null
517,210
88724110833143451247828633854748770618
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_WARN_UNUSED_RESULT { if (dir == NULL || dir_len == 0) { return dest; } dest = strcpy_comma_escaped(dest, dir, dir_len); if (append_nvim) { if (!after_pathsep(dest - 1, dest)) { *dest++ = PATHSEP; } memmove(dest, "nvim", NVIM_SIZE); dest += NVIM_SIZE; if (suf1 != NULL) { *dest++ = PATHSEP; memmove(dest, suf1, len1); dest += len1; if (suf2 != NULL) { *dest++ = PATHSEP; memmove(dest, suf2, len2); dest += len2; } } } *dest++ = ','; return dest; }
CWE-20
null
517,211
163032066846496782577459265345649716884
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
char_u *get_highlight_default(void) { int i; i = findoption((char_u *)"hl"); if (i >= 0) return options[i].def_val[VI_DEFAULT]; return (char_u *)NULL; }
CWE-20
null
517,212
125033518669125962659216710109136079100
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
bool get_tty_option(char *name, char **value) { if (!strcmp(name, "t_Co")) { if (value) { if (t_colors <= 1) { *value = xstrdup(""); } else { *value = xmalloc(TCO_BUFFER_SIZE); snprintf(*value, TCO_BUFFER_SIZE, "%d", t_colors); } } return true; } if (!strcmp(name, "term") || !strcmp(name, "ttytype")) { if (value) { *value = xstrdup("nvim"); } return true; } if (is_tty_option(name)) { if (value) { // XXX: All other t_* options were removed in 3baba1e7. *value = xstrdup(""); } return true; } return false; }
CWE-20
null
517,213
273984807422399319494628644985964791902
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
void check_buf_options(buf_T *buf) { check_string_option(&buf->b_p_bh); check_string_option(&buf->b_p_bt); check_string_option(&buf->b_p_fenc); check_string_option(&buf->b_p_ff); check_string_option(&buf->b_p_def); check_string_option(&buf->b_p_inc); check_string_option(&buf->b_p_inex); check_string_option(&buf->b_p_inde); check_string_option(&buf->b_p_indk); check_string_option(&buf->b_p_fex); check_string_option(&buf->b_p_kp); check_string_option(&buf->b_p_mps); check_string_option(&buf->b_p_fo); check_string_option(&buf->b_p_flp); check_string_option(&buf->b_p_isk); check_string_option(&buf->b_p_com); check_string_option(&buf->b_p_cms); check_string_option(&buf->b_p_nf); check_string_option(&buf->b_p_qe); check_string_option(&buf->b_p_syn); check_string_option(&buf->b_s.b_syn_isk); check_string_option(&buf->b_s.b_p_spc); check_string_option(&buf->b_s.b_p_spf); check_string_option(&buf->b_s.b_p_spl); check_string_option(&buf->b_p_sua); check_string_option(&buf->b_p_cink); check_string_option(&buf->b_p_cino); parse_cino(buf); check_string_option(&buf->b_p_ft); check_string_option(&buf->b_p_cinw); check_string_option(&buf->b_p_cpt); check_string_option(&buf->b_p_cfu); check_string_option(&buf->b_p_ofu); check_string_option(&buf->b_p_keymap); check_string_option(&buf->b_p_gp); check_string_option(&buf->b_p_mp); check_string_option(&buf->b_p_efm); check_string_option(&buf->b_p_ep); check_string_option(&buf->b_p_path); check_string_option(&buf->b_p_tags); check_string_option(&buf->b_p_tc); check_string_option(&buf->b_p_dict); check_string_option(&buf->b_p_tsr); check_string_option(&buf->b_p_lw); check_string_option(&buf->b_p_bkc); }
CWE-20
null
517,214
51399074651423064684410913586754627388
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
set_num_option ( int opt_idx, /* index in options[] table */ char_u *varp, /* pointer to the option variable */ long value, /* new value */ char_u *errbuf, /* buffer for error messages */ size_t errbuflen, /* length of "errbuf" */ int opt_flags /* OPT_LOCAL, OPT_GLOBAL and OPT_MODELINE */ ) { char_u *errmsg = NULL; long old_value = *(long *)varp; long old_Rows = Rows; /* remember old Rows */ long old_Columns = Columns; /* remember old Columns */ long *pp = (long *)varp; /* Disallow changing some options from secure mode. */ if ((secure || sandbox != 0) && (options[opt_idx].flags & P_SECURE)) { return e_secure; } *pp = value; /* Remember where the option was set. */ set_option_scriptID_idx(opt_idx, opt_flags, current_SID); if (curbuf->b_p_sw < 0) { errmsg = e_positive; curbuf->b_p_sw = curbuf->b_p_ts; } /* * Number options that need some action when changed */ if (pp == &p_wh || pp == &p_hh) { if (p_wh < 1) { errmsg = e_positive; p_wh = 1; } if (p_wmh > p_wh) { errmsg = e_winheight; p_wh = p_wmh; } if (p_hh < 0) { errmsg = e_positive; p_hh = 0; } /* Change window height NOW */ if (lastwin != firstwin) { if (pp == &p_wh && curwin->w_height < p_wh) win_setheight((int)p_wh); if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) win_setheight((int)p_hh); } } /* 'winminheight' */ else if (pp == &p_wmh) { if (p_wmh < 0) { errmsg = e_positive; p_wmh = 0; } if (p_wmh > p_wh) { errmsg = e_winheight; p_wmh = p_wh; } win_setminheight(); } else if (pp == &p_wiw) { if (p_wiw < 1) { errmsg = e_positive; p_wiw = 1; } if (p_wmw > p_wiw) { errmsg = e_winwidth; p_wiw = p_wmw; } /* Change window width NOW */ if (lastwin != firstwin && curwin->w_width < p_wiw) win_setwidth((int)p_wiw); } /* 'winminwidth' */ else if (pp == &p_wmw) { if (p_wmw < 0) { errmsg = e_positive; p_wmw = 0; } if (p_wmw > p_wiw) { errmsg = e_winwidth; p_wmw = p_wiw; } win_setminheight(); } else if (pp == &p_ls) { /* (re)set last window status line */ last_status(false); } /* (re)set tab page line */ else if (pp == &p_stal) { shell_new_rows(); /* recompute window positions and heights */ } /* 'foldlevel' */ else if (pp == &curwin->w_p_fdl) { if (curwin->w_p_fdl < 0) curwin->w_p_fdl = 0; newFoldLevel(); } /* 'foldminlines' */ else if (pp == &curwin->w_p_fml) { foldUpdateAll(curwin); } /* 'foldnestmax' */ else if (pp == &curwin->w_p_fdn) { if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) foldUpdateAll(curwin); } /* 'foldcolumn' */ else if (pp == &curwin->w_p_fdc) { if (curwin->w_p_fdc < 0) { errmsg = e_positive; curwin->w_p_fdc = 0; } else if (curwin->w_p_fdc > 12) { errmsg = e_invarg; curwin->w_p_fdc = 12; } // 'shiftwidth' or 'tabstop' } else if (pp == &curbuf->b_p_sw || pp == (long *)&curbuf->b_p_ts) { if (foldmethodIsIndent(curwin)) { foldUpdateAll(curwin); } // When 'shiftwidth' changes, or it's zero and 'tabstop' changes: // parse 'cinoptions'. if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) { parse_cino(curbuf); } } /* 'maxcombine' */ else if (pp == &p_mco) { if (p_mco > MAX_MCO) p_mco = MAX_MCO; else if (p_mco < 0) p_mco = 0; screenclear(); /* will re-allocate the screen */ } else if (pp == &curbuf->b_p_iminsert) { if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) { errmsg = e_invarg; curbuf->b_p_iminsert = B_IMODE_NONE; } p_iminsert = curbuf->b_p_iminsert; showmode(); /* Show/unshow value of 'keymap' in status lines. */ status_redraw_curbuf(); } else if (pp == &p_window) { if (p_window < 1) p_window = 1; else if (p_window >= Rows) p_window = Rows - 1; } else if (pp == &curbuf->b_p_imsearch) { if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) { errmsg = e_invarg; curbuf->b_p_imsearch = B_IMODE_NONE; } p_imsearch = curbuf->b_p_imsearch; } /* if 'titlelen' has changed, redraw the title */ else if (pp == &p_titlelen) { if (p_titlelen < 0) { errmsg = e_positive; p_titlelen = 85; } if (starting != NO_SCREEN && old_value != p_titlelen) need_maketitle = TRUE; } /* if p_ch changed value, change the command line height */ else if (pp == &p_ch) { if (p_ch < 1) { errmsg = e_positive; p_ch = 1; } if (p_ch > Rows - min_rows() + 1) p_ch = Rows - min_rows() + 1; /* Only compute the new window layout when startup has been * completed. Otherwise the frame sizes may be wrong. */ if (p_ch != old_value && full_screen ) command_height(); } /* when 'updatecount' changes from zero to non-zero, open swap files */ else if (pp == &p_uc) { if (p_uc < 0) { errmsg = e_positive; p_uc = 100; } if (p_uc && !old_value) ml_open_files(); } else if (pp == &curwin->w_p_cole) { if (curwin->w_p_cole < 0) { errmsg = e_positive; curwin->w_p_cole = 0; } else if (curwin->w_p_cole > 3) { errmsg = e_invarg; curwin->w_p_cole = 3; } } /* sync undo before 'undolevels' changes */ else if (pp == &p_ul) { /* use the old value, otherwise u_sync() may not work properly */ p_ul = old_value; u_sync(TRUE); p_ul = value; } else if (pp == &curbuf->b_p_ul) { /* use the old value, otherwise u_sync() may not work properly */ curbuf->b_p_ul = old_value; u_sync(TRUE); curbuf->b_p_ul = value; } /* 'numberwidth' must be positive */ else if (pp == &curwin->w_p_nuw) { if (curwin->w_p_nuw < 1) { errmsg = e_positive; curwin->w_p_nuw = 1; } if (curwin->w_p_nuw > 10) { errmsg = e_invarg; curwin->w_p_nuw = 10; } curwin->w_nrwidth_line_count = 0; } else if (pp == &curbuf->b_p_tw) { if (curbuf->b_p_tw < 0) { errmsg = e_positive; curbuf->b_p_tw = 0; } FOR_ALL_TAB_WINDOWS(tp, wp) { check_colorcolumn(wp); } } /* * Check the bounds for numeric options here */ if (Rows < min_rows() && full_screen) { if (errbuf != NULL) { vim_snprintf((char *)errbuf, errbuflen, _("E593: Need at least %d lines"), min_rows()); errmsg = errbuf; } Rows = min_rows(); } if (Columns < MIN_COLUMNS && full_screen) { if (errbuf != NULL) { vim_snprintf((char *)errbuf, errbuflen, _("E594: Need at least %d columns"), MIN_COLUMNS); errmsg = errbuf; } Columns = MIN_COLUMNS; } limit_screen_size(); /* * If the screen (shell) height has been changed, assume it is the * physical screenheight. */ if (old_Rows != Rows || old_Columns != Columns) { /* Changing the screen size is not allowed while updating the screen. */ if (updating_screen) { *pp = old_value; } else if (full_screen) { screen_resize((int)Columns, (int)Rows); } else { /* Postpone the resizing; check the size and cmdline position for * messages. */ check_shellsize(); if (cmdline_row > Rows - p_ch && Rows > p_ch) { assert(p_ch >= 0 && Rows - p_ch <= INT_MAX); cmdline_row = (int)(Rows - p_ch); } } if (p_window >= Rows || !option_was_set((char_u *)"window")) p_window = Rows - 1; } if (curbuf->b_p_ts <= 0) { errmsg = e_positive; curbuf->b_p_ts = 8; } if (p_tm < 0) { errmsg = e_positive; p_tm = 0; } if ((curwin->w_p_scr <= 0 || (curwin->w_p_scr > curwin->w_height && curwin->w_height > 0)) && full_screen) { if (pp == &(curwin->w_p_scr)) { if (curwin->w_p_scr != 0) errmsg = e_scroll; win_comp_scroll(curwin); } /* If 'scroll' became invalid because of a side effect silently adjust * it. */ else if (curwin->w_p_scr <= 0) curwin->w_p_scr = 1; else /* curwin->w_p_scr > curwin->w_height */ curwin->w_p_scr = curwin->w_height; } if (p_hi < 0) { errmsg = e_positive; p_hi = 0; } else if (p_hi > 10000) { errmsg = e_invarg; p_hi = 10000; } if (p_re < 0 || p_re > 2) { errmsg = e_invarg; p_re = 0; } if (p_report < 0) { errmsg = e_positive; p_report = 1; } if ((p_sj < -100 || p_sj >= Rows) && full_screen) { if (Rows != old_Rows) /* Rows changed, just adjust p_sj */ p_sj = Rows / 2; else { errmsg = e_scroll; p_sj = 1; } } if (p_so < 0 && full_screen) { errmsg = e_scroll; p_so = 0; } if (p_siso < 0 && full_screen) { errmsg = e_positive; p_siso = 0; } if (p_cwh < 1) { errmsg = e_positive; p_cwh = 1; } if (p_ut < 0) { errmsg = e_positive; p_ut = 2000; } if (p_ss < 0) { errmsg = e_positive; p_ss = 0; } /* May set global value for local option. */ if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; options[opt_idx].flags |= P_WAS_SET; if (!starting && errmsg == NULL) { char buf_old[NUMBUFLEN]; char buf_new[NUMBUFLEN]; char buf_type[7]; vim_snprintf(buf_old, ARRAY_SIZE(buf_old), "%ld", old_value); vim_snprintf(buf_new, ARRAY_SIZE(buf_new), "%ld", value); vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); set_vim_var_string(VV_OPTION_NEW, buf_new, -1); set_vim_var_string(VV_OPTION_OLD, buf_old, -1); set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, false, NULL); reset_v_option_vars(); } comp_col(); /* in case 'columns' or 'ls' changed */ if (curwin->w_curswant != MAXCOL && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) curwin->w_set_curswant = TRUE; check_redraw(options[opt_idx].flags); return errmsg; }
CWE-20
null
517,215
210364008055189834738252837337779465249
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file) { int num_normal = 0; // Nr of matching non-term-code settings int match; int count = 0; char_u *str; int loop; static char *(names[]) = {"all", "termcap"}; int ic = regmatch->rm_ic; /* remember the ignore-case flag */ /* do this loop twice: * loop == 0: count the number of matching options * loop == 1: copy the matching options into allocated memory */ for (loop = 0; loop <= 1; ++loop) { regmatch->rm_ic = ic; if (xp->xp_context != EXPAND_BOOL_SETTINGS) { for (match = 0; match < (int)ARRAY_SIZE(names); ++match) if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) { if (loop == 0) num_normal++; else (*file)[count++] = vim_strsave((char_u *)names[match]); } } for (size_t opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; opt_idx++) { if (options[opt_idx].var == NULL) continue; if (xp->xp_context == EXPAND_BOOL_SETTINGS && !(options[opt_idx].flags & P_BOOL)) continue; match = FALSE; if (vim_regexec(regmatch, str, (colnr_T)0) || (options[opt_idx].shortname != NULL && vim_regexec(regmatch, (char_u *)options[opt_idx].shortname, (colnr_T)0))){ match = TRUE; } if (match) { if (loop == 0) { num_normal++; } else (*file)[count++] = vim_strsave(str); } } if (loop == 0) { if (num_normal > 0) { *num_file = num_normal; } else { return OK; } *file = (char_u **)xmalloc((size_t)(*num_file) * sizeof(char_u *)); } } return OK; }
CWE-20
null
517,216
120395354844959258804781439067035200050
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
set_option_default ( int opt_idx, int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ int compatible /* use Vi default value */ ) { char_u *varp; /* pointer to variable for current option */ int dvi; /* index in def_val[] */ int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); uint32_t flags = options[opt_idx].flags; if (varp != NULL) { /* skip hidden option, nothing to do for it */ dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; if (flags & P_STRING) { /* Use set_string_option_direct() for local options to handle * freeing and allocating the value. */ if (options[opt_idx].indir != PV_NONE) set_string_option_direct(NULL, opt_idx, options[opt_idx].def_val[dvi], opt_flags, 0); else { if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED)) free_string_option(*(char_u **)(varp)); *(char_u **)varp = options[opt_idx].def_val[dvi]; options[opt_idx].flags &= ~P_ALLOCED; } } else if (flags & P_NUM) { if (options[opt_idx].indir == PV_SCROLL) win_comp_scroll(curwin); else { *(long *)varp = (long)options[opt_idx].def_val[dvi]; /* May also set global value for local option. */ if (both) *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *(long *)varp; } } else { /* P_BOOL */ *(int *)varp = (int)(intptr_t)options[opt_idx].def_val[dvi]; #ifdef UNIX /* 'modeline' defaults to off for root */ if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) *(int *)varp = FALSE; #endif /* May also set global value for local option. */ if (both) *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *(int *)varp; } /* The default value is not insecure. */ uint32_t *flagsp = insecure_flag(opt_idx, opt_flags); *flagsp = *flagsp & ~P_INSECURE; } set_option_scriptID_idx(opt_idx, opt_flags, current_SID); }
CWE-20
null
517,217
183680422531199792346551140186594539301
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
void buf_copy_options(buf_T *buf, int flags) { int should_copy = TRUE; char_u *save_p_isk = NULL; /* init for GCC */ int dont_do_help; int did_isk = FALSE; /* * Don't do anything if the buffer is invalid. */ if (buf == NULL || !buf_valid(buf)) return; /* * Skip this when the option defaults have not been set yet. Happens when * main() allocates the first buffer. */ if (p_cpo != NULL) { /* * Always copy when entering and 'cpo' contains 'S'. * Don't copy when already initialized. * Don't copy when 'cpo' contains 's' and not entering. * 'S' BCO_ENTER initialized 's' should_copy * yes yes X X TRUE * yes no yes X FALSE * no X yes X FALSE * X no no yes FALSE * X no no no TRUE * no yes no X TRUE */ if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) && (buf->b_p_initialized || (!(flags & BCO_ENTER) && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) should_copy = FALSE; if (should_copy || (flags & BCO_ALWAYS)) { /* Don't copy the options specific to a help buffer when * BCO_NOHELP is given or the options were initialized already * (jumping back to a help file with CTRL-T or CTRL-O) */ dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) || buf->b_p_initialized; if (dont_do_help) { /* don't free b_p_isk */ save_p_isk = buf->b_p_isk; buf->b_p_isk = NULL; } /* * Always free the allocated strings. * If not already initialized, set 'readonly' and copy 'fileformat'. */ if (!buf->b_p_initialized) { free_buf_options(buf, TRUE); buf->b_p_ro = FALSE; /* don't copy readonly */ buf->b_p_fenc = vim_strsave(p_fenc); buf->b_p_ff = vim_strsave(p_ff); buf->b_p_bh = empty_option; buf->b_p_bt = empty_option; } else free_buf_options(buf, FALSE); buf->b_p_ai = p_ai; buf->b_p_ai_nopaste = p_ai_nopaste; buf->b_p_sw = p_sw; buf->b_p_tw = p_tw; buf->b_p_tw_nopaste = p_tw_nopaste; buf->b_p_tw_nobin = p_tw_nobin; buf->b_p_wm = p_wm; buf->b_p_wm_nopaste = p_wm_nopaste; buf->b_p_wm_nobin = p_wm_nobin; buf->b_p_bin = p_bin; buf->b_p_bomb = p_bomb; buf->b_p_et = p_et; buf->b_p_fixeol = p_fixeol; buf->b_p_et_nobin = p_et_nobin; buf->b_p_et_nopaste = p_et_nopaste; buf->b_p_ml = p_ml; buf->b_p_ml_nobin = p_ml_nobin; buf->b_p_inf = p_inf; buf->b_p_swf = p_swf; buf->b_p_cpt = vim_strsave(p_cpt); buf->b_p_cfu = vim_strsave(p_cfu); buf->b_p_ofu = vim_strsave(p_ofu); buf->b_p_sts = p_sts; buf->b_p_sts_nopaste = p_sts_nopaste; buf->b_p_com = vim_strsave(p_com); buf->b_p_cms = vim_strsave(p_cms); buf->b_p_fo = vim_strsave(p_fo); buf->b_p_flp = vim_strsave(p_flp); buf->b_p_nf = vim_strsave(p_nf); buf->b_p_mps = vim_strsave(p_mps); buf->b_p_si = p_si; buf->b_p_ci = p_ci; buf->b_p_cin = p_cin; buf->b_p_cink = vim_strsave(p_cink); buf->b_p_cino = vim_strsave(p_cino); /* Don't copy 'filetype', it must be detected */ buf->b_p_ft = empty_option; buf->b_p_pi = p_pi; buf->b_p_cinw = vim_strsave(p_cinw); buf->b_p_lisp = p_lisp; /* Don't copy 'syntax', it must be set */ buf->b_p_syn = empty_option; buf->b_p_smc = p_smc; buf->b_s.b_syn_isk = empty_option; buf->b_s.b_p_spc = vim_strsave(p_spc); (void)compile_cap_prog(&buf->b_s); buf->b_s.b_p_spf = vim_strsave(p_spf); buf->b_s.b_p_spl = vim_strsave(p_spl); buf->b_p_inde = vim_strsave(p_inde); buf->b_p_indk = vim_strsave(p_indk); buf->b_p_fex = vim_strsave(p_fex); buf->b_p_sua = vim_strsave(p_sua); buf->b_p_keymap = vim_strsave(p_keymap); buf->b_kmap_state |= KEYMAP_INIT; /* This isn't really an option, but copying the langmap and IME * state from the current buffer is better than resetting it. */ buf->b_p_iminsert = p_iminsert; buf->b_p_imsearch = p_imsearch; /* options that are normally global but also have a local value * are not copied, start using the global value */ buf->b_p_ar = -1; buf->b_p_ul = NO_LOCAL_UNDOLEVEL; buf->b_p_bkc = empty_option; buf->b_bkc_flags = 0; buf->b_p_gp = empty_option; buf->b_p_mp = empty_option; buf->b_p_efm = empty_option; buf->b_p_ep = empty_option; buf->b_p_kp = empty_option; buf->b_p_path = empty_option; buf->b_p_tags = empty_option; buf->b_p_tc = empty_option; buf->b_tc_flags = 0; buf->b_p_def = empty_option; buf->b_p_inc = empty_option; buf->b_p_inex = vim_strsave(p_inex); buf->b_p_dict = empty_option; buf->b_p_tsr = empty_option; buf->b_p_qe = vim_strsave(p_qe); buf->b_p_udf = p_udf; buf->b_p_lw = empty_option; /* * Don't copy the options set by ex_help(), use the saved values, * when going from a help buffer to a non-help buffer. * Don't touch these at all when BCO_NOHELP is used and going from * or to a help buffer. */ if (dont_do_help) buf->b_p_isk = save_p_isk; else { buf->b_p_isk = vim_strsave(p_isk); did_isk = true; buf->b_p_ts = p_ts; buf->b_help = false; if (buf->b_p_bt[0] == 'h') clear_string_option(&buf->b_p_bt); buf->b_p_ma = p_ma; } } /* * When the options should be copied (ignoring BCO_ALWAYS), set the * flag that indicates that the options have been initialized. */ if (should_copy) buf->b_p_initialized = true; } check_buf_options(buf); /* make sure we don't have NULLs */ if (did_isk) (void)buf_init_chartab(buf, FALSE); }
CWE-20
null
517,218
271828755246985117431392419186340444638
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
int check_ff_value(char_u *p) { return check_opt_strings(p, p_ff_values, FALSE); }
CWE-20
null
517,219
91668240380901304334438560127967037838
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
void comp_col(void) { int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin)); sc_col = 0; ru_col = 0; if (p_ru) { ru_col = (ru_wid ? ru_wid : COL_RULER) + 1; /* no last status line, adjust sc_col */ if (!last_has_status) sc_col = ru_col; } if (p_sc) { sc_col += SHOWCMD_COLS; if (!p_ru || last_has_status) /* no need for separating space */ ++sc_col; } assert(sc_col >= 0 && INT_MIN + sc_col <= Columns && Columns - sc_col <= INT_MAX); sc_col = (int)(Columns - sc_col); assert(ru_col >= 0 && INT_MIN + ru_col <= Columns && Columns - ru_col <= INT_MAX); ru_col = (int)(Columns - ru_col); if (sc_col <= 0) /* screen too narrow, will become a mess */ sc_col = 1; if (ru_col <= 0) ru_col = 1; }
CWE-20
null
517,220
210170838659762336451708621490976844027
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
did_set_option ( int opt_idx, int opt_flags, /* possibly with OPT_MODELINE */ int new_value /* value was replaced completely */ ) { options[opt_idx].flags |= P_WAS_SET; /* When an option is set in the sandbox, from a modeline or in secure mode * set the P_INSECURE flag. Otherwise, if a new value is stored reset the * flag. */ uint32_t *p = insecure_flag(opt_idx, opt_flags); if (secure || sandbox != 0 || (opt_flags & OPT_MODELINE)) *p = *p | P_INSECURE; else if (new_value) *p = *p & ~P_INSECURE; }
CWE-20
null
517,221
273711344049870661331515938110608435483
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id) { int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; int indir = (int)options[opt_idx].indir; /* Remember where the option was set. For local options need to do that * in the buffer or window structure. */ if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0) options[opt_idx].scriptID = id; if (both || (opt_flags & OPT_LOCAL)) { if (indir & PV_BUF) curbuf->b_p_scriptID[indir & PV_MASK] = id; else if (indir & PV_WIN) curwin->w_p_scriptID[indir & PV_MASK] = id; } }
CWE-20
null
517,222
46018198855171414877439981282120278072
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
void clear_winopt(winopt_T *wop) { clear_string_option(&wop->wo_fdi); clear_string_option(&wop->wo_fdm); clear_string_option(&wop->wo_fdm_save); clear_string_option(&wop->wo_fde); clear_string_option(&wop->wo_fdt); clear_string_option(&wop->wo_fmr); clear_string_option(&wop->wo_rlc); clear_string_option(&wop->wo_stl); clear_string_option(&wop->wo_cc); clear_string_option(&wop->wo_cocu); clear_string_option(&wop->wo_briopt); }
CWE-20
null
517,223
74657346038381395212855394192437288683
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
void save_file_ff(buf_T *buf) { buf->b_start_ffc = *buf->b_p_ff; buf->b_start_eol = buf->b_p_eol; buf->b_start_bomb = buf->b_p_bomb; /* Only use free/alloc when necessary, they take time. */ if (buf->b_start_fenc == NULL || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) { xfree(buf->b_start_fenc); buf->b_start_fenc = vim_strsave(buf->b_p_fenc); } }
CWE-20
null
517,224
46489346123614468263819256041166367748
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
void set_init_2(void) { int idx; /* * 'scroll' defaults to half the window height. Note that this default is * wrong when the window height changes. */ set_number_default("scroll", Rows / 2); idx = findoption((char_u *)"scroll"); if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) set_option_default(idx, OPT_LOCAL, p_cp); comp_col(); /* * 'window' is only for backwards compatibility with Vi. * Default is Rows - 1. */ if (!option_was_set((char_u *)"window")) p_window = Rows - 1; set_number_default("window", Rows - 1); parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */ (void)parse_printoptions(); /* parse 'printoptions' default value */ }
CWE-20
null
517,225
136714096679115075253903728081285340841
null
null
other
neovim
4fad66fbe637818b6b3d6bc5d21923ba72795040
0
void clear_string_option(char_u **pp) { if (*pp != empty_option) xfree(*pp); *pp = empty_option; }
CWE-20
null
517,226
225205223832358239007163243659362522910
null
null
other