Jan Friesse wrote:
> thanks for pointing bugs. Attached patch should be fine (I hope).

Thanks.  that is much better.
While this is definitely an improvement
(it will no longer write past the end of the buffer),
you might want to write a follow-up patch
that also detects/handles truncation, rather than
proceeding to use the truncated result.

It's not a big deal then it's just a diagnostic that's
been truncated, but when it's a module name or a file name,
that might lead to a subsequent harder-to-diagnose error,
it is worth reporting the problem ASAP, just to avoid that.

However, that will probably involve changing interfaces,
and it will be a larger, more invasive change, so I'd recommend
doing it separately from this small change.

> Jim Meyering wrote:
>> Jan Friesse wrote:
...
> Index: lcr/lcr_ifact.c
> ===================================================================
> --- lcr/lcr_ifact.c   (revision 1987)
> +++ lcr/lcr_ifact.c   (working copy)
> @@ -224,7 +224,7 @@
>       struct dirent **scandir_list;
>       unsigned int scandir_entries;
>
> -     sprintf (filename_cat, "%s/%s", path, filename);
> +     snprintf (filename_cat, sizeof(filename_cat), "%s/%s", path, filename);
>       if (filename[0] == '*') {
>               scandir_entries = scandir (
>                       path,
> @@ -375,7 +375,8 @@
>               /*
>                * Load objects, scan them, unload them if they are not a match
>                */
> -             sprintf (dl_name, "%s/%s", path, 
> scandir_list[libs_to_scan]->d_name);
> +             snprintf (dl_name, sizeof(dl_name), "%s/%s",
> +                     path, scandir_list[libs_to_scan]->d_name);
>               /*
>                * Don't reload already loaded libraries
>                */
...
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to