[LTP] [PATCH 11/15] ujson: reader: Support files with zero lseek size

Cyril Hrubis chrubis@suse.cz
Fri Oct 9 17:21:53 CEST 2026


Hi!
> Files in pseudo-filesystems like /proc/sys report a size of 0 with
> lseek(), causing ujson_reader_load() to allocate a 1-byte buffer and
> skip the read loop entirely. seq_file based files such as
> /proc/self/status do not support SEEK_END at all, making the load fail.
> Allocate an initial capacity when the size is unknown and grow the
> buffer with realloc() dynamically until EOF.

I would say that the proper fix here is to err out on lseek() returning
zero. I do not think that it make sense to support loading JSON from a
sysfs until we really need that.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list