Hi Michael, > > Yes, you are right, strncmp() will check 30 bytes if use sizeof(buffer). > > But any issue of strcmp() ? This rountin cares about exactly match. I think no > need to convert to strncmp() if it does have other issue. > > > fscanf with fgets would be better too, to make sure we never go over our > buffer size when dealing with /proc/modules. > > If we use fgets, we need additional efforts to get the modname, for > potential overflow issue, we can limit counts of fscanf(). like below: > > fscanf(fd, "%30s %*[^\n]", mod_name); >
As long as it doesn't cause easy buffer overruns, I'm fine with it :-) Thanks, Anatoly