Merge branch 'verify-stdio-includes' into 'master'
verify stdio header includes See merge request redox-os/relibc!1433
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
# stddef.h brings in size_t
|
||||
sys_includes = ["stdarg.h", "stddef.h", "stdint.h", "features.h"]
|
||||
# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdio.h.html
|
||||
#
|
||||
# Spec quotations relating to includes:
|
||||
# - "off_t As described in <sys/types.h>."
|
||||
# - "size_t As described in <stddef.h>."
|
||||
# - "ssize_t As described in <sys/types.h>."
|
||||
# - "va_list As described in <stdarg.h>."
|
||||
# - "The <stdio.h> header shall define NULL as described in <stddef.h>."
|
||||
# - "Inclusion of the <stdio.h> header may also make visible all symbols from <stddef.h>."
|
||||
#
|
||||
# stdarg.h brings in va_list (TODO split out)
|
||||
# stddef.h brings in size_t and NULL
|
||||
# features.h required for deprecated annotations
|
||||
sys_includes = ["stdarg.h", "stddef.h", "features.h"]
|
||||
after_includes = """
|
||||
#include <bits/off-t.h> // for off_t from sys/types.h
|
||||
#include <bits/ssize-t.h> // for ssize_t from sys/types.h
|
||||
|
||||
@@ -38,14 +38,18 @@ pub unsafe extern "C" fn getline(
|
||||
/// - `stream` has to be a valid file handle returned by fopen and likes.
|
||||
///
|
||||
/// # Deviation from POSIX
|
||||
/// - **EINVAL is set on stream being NULL or delim not fitting into char** (POSIX allows UB)
|
||||
/// - **`*n` can contain invalid data.** The buffer size `n` is not read, instead realloc is called each time. That is in principle
|
||||
/// inefficent since the buffer is reallocated in memory for every call, but if `n` is by mistake
|
||||
/// bigger than the number of bytes allocated for the buffer, there can be no out-of-bounds write.
|
||||
/// - On non-stream-related errors, the error indicator of the stream is *not* set. Posix states
|
||||
/// "If an error occurs, the error indicator for the stream shall be set, and the function shall
|
||||
/// return -1 and set errno to indicate the error." but in cases that produce EINVAL even glibc
|
||||
/// doesn't seem to set the error indicator, so we also don't.
|
||||
/// - **EINVAL is set on stream being NULL or delim not fitting into char**
|
||||
/// (POSIX allows UB)
|
||||
/// - **`*n` can contain invalid data.** The buffer size `n` is not read,
|
||||
/// instead realloc is called each time. That is in principle inefficent
|
||||
/// since the buffer is reallocated in memory for every call, but if `n` is
|
||||
/// by mistake bigger than the number of bytes allocated for the buffer,
|
||||
/// there can be no out-of-bounds write.
|
||||
/// - On non-stream-related errors, the error indicator of the stream is *not*
|
||||
/// set. Posix states "If an error occurs, the error indicator for the stream
|
||||
/// shall be set, and the function shall return -1 and set errno to indicate
|
||||
/// the error." but in cases that produce EINVAL even glibc doesn't seem to
|
||||
/// set the error indicator, so we also don't.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn getdelim(
|
||||
lineptr: *mut *mut c_char,
|
||||
|
||||
Reference in New Issue
Block a user