Do not use signed data types if unsigned arithmetic is expected,
i.e. use size_t if processing sizes and unsigned int for line numbers
due to given API of freadline_wrapped.
This fixes a possible signed integer overflow on 64 bit systems.
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/81
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
*/
char *freadline_wrapped(FILE *fp, unsigned int *linenum)
{
- int size = 256;
- int i = 0, n = 0;
+ size_t i = 0, size = 256;
+ unsigned int n = 0;
_cleanup_free_ char *buf = malloc(size);
if (buf == NULL)