2009-11-26 20:02:19 +01:00
|
|
|
Description: String buffer handling fixes.
|
|
|
|
- convert a strncpy() to snprintf() to ensure null-termination;
|
|
|
|
- explicitly pass sizeof(var) as the second argument of snprintf().
|
|
|
|
Forwarded: no
|
|
|
|
Author: Peter Pentchev <roam@FreeBSD.org>
|
|
|
|
Last-Update: 2009-11-26
|
2009-03-16 14:51:24 +01:00
|
|
|
|
|
|
|
--- a/backfill.c
|
|
|
|
+++ b/backfill.c
|
2009-11-26 20:02:19 +01:00
|
|
|
@@ -54,7 +54,7 @@
|
2009-03-16 14:51:24 +01:00
|
|
|
return(-1);
|
|
|
|
#endif
|
|
|
|
/*- format a new string */
|
|
|
|
- snprintf(bak_file, MAX_BUFF, "%s.bak", filename);
|
|
|
|
+ snprintf(bak_file, sizeof(bak_file), "%s.bak", filename);
|
|
|
|
if (rename(filename, bak_file))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "rename %s->%s: %s\n", filename, bak_file, strerror(errno));
|
2009-11-26 20:02:19 +01:00
|
|
|
@@ -153,7 +153,7 @@
|
2009-03-16 14:51:24 +01:00
|
|
|
fprintf(stderr, "%s: No such domain\n", domain);
|
|
|
|
return((char *) 0);
|
|
|
|
}
|
|
|
|
- snprintf(filename, MAX_BUFF, "%s/.dir_control_free", ptr);
|
|
|
|
+ snprintf(filename, sizeof(filename), "%s/.dir_control_free", ptr);
|
|
|
|
if (operation == 1) /*- Delete */
|
|
|
|
{
|
|
|
|
if (!(fp = fopen(filename, "r")))
|
2009-11-26 20:02:19 +01:00
|
|
|
@@ -191,7 +191,7 @@
|
2009-03-16 14:51:24 +01:00
|
|
|
} else
|
|
|
|
if (operation == 2) /*- add */
|
|
|
|
{
|
|
|
|
- (void) strncpy(tmpbuf, path, MAX_BUFF);
|
|
|
|
+ snprintf(tmpbuf, sizeof(tmpbuf), "%s", path);
|
|
|
|
if ((ptr = strstr(tmpbuf, username)))
|
|
|
|
{
|
|
|
|
if (ptr != tmpbuf)
|