Fix off-by-1 error in vfscanf
Scanf function requires look ahead to function properly, In case of scanning from a buffer that will not be an issue, but in our case we are reading from file, so lookaheads needs to be undone (via lseek) in our case. The only problem here is that if we opened a file that doesn't support lseek such as many of the file /dev/*
This commit is contained in:
@@ -1041,8 +1041,12 @@ pub unsafe extern "C" fn vsprintf(s: *mut c_char, format: *const c_char, ap: va_
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn vfscanf(file: *mut FILE, format: *const c_char, ap: va_list) -> c_int {
|
||||
let mut file = (*file).lock();
|
||||
scanf::scanf(&mut *file, format, ap)
|
||||
let ret = {
|
||||
let mut file = (*file).lock();
|
||||
scanf::scanf(&mut *file, format, ap)
|
||||
};
|
||||
fseeko(file, -1, SEEK_CUR);
|
||||
ret
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user