diff options
author | nectar <nectar@FreeBSD.org> | 2003-12-17 13:36:05 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2003-12-17 13:36:05 +0000 |
commit | d1c590eca25f8642bc793b42247737d8196f4587 (patch) | |
tree | 8197bcca21c00355d7afaca1c69ade7b7f5fdfd1 | |
parent | 0fa7b537cdd945155a6d54b6cff6d253daddeec1 (diff) | |
download | FreeBSD-src-d1c590eca25f8642bc793b42247737d8196f4587.zip FreeBSD-src-d1c590eca25f8642bc793b42247737d8196f4587.tar.gz |
Correct truncation detection after use of snprintf: The case where
exactly one character was truncated was not detected.
-rw-r--r-- | usr.sbin/pkg_install/add/extract.c | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_install/create/pl.c | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c index f35cce2..e76cede 100644 --- a/usr.sbin/pkg_install/add/extract.c +++ b/usr.sbin/pkg_install/add/extract.c @@ -159,7 +159,7 @@ extract_plist(const char *home, Package *pkg) PUSHOUT(Directory); } add_count = snprintf(&perm_args[perm_count], maxargs - perm_count, "'%s' ", p->name); - if (add_count < 0 || add_count > maxargs - perm_count) { + if (add_count < 0 || add_count >= maxargs - perm_count) { cleanup(0); errx(2, "%s: oops, miscounted strings!", __func__); } @@ -179,7 +179,7 @@ extract_plist(const char *home, Package *pkg) PUSHOUT(Directory); } add_count = snprintf(&where_args[where_count], maxargs - where_count, " '%s'", p->name); - if (add_count < 0 || add_count > maxargs - where_count) { + if (add_count < 0 || add_count >= maxargs - where_count) { cleanup(0); errx(2, "%s: oops, miscounted strings!", __func__); } @@ -187,7 +187,7 @@ extract_plist(const char *home, Package *pkg) add_count = snprintf(&perm_args[perm_count], maxargs - perm_count, "'%s' ", p->name); - if (add_count < 0 || add_count > maxargs - perm_count) { + if (add_count < 0 || add_count >= maxargs - perm_count) { cleanup(0); errx(2, "%s: oops, miscounted strings!", __func__); } diff --git a/usr.sbin/pkg_install/create/pl.c b/usr.sbin/pkg_install/create/pl.c index d8b3d7e..55c721c 100644 --- a/usr.sbin/pkg_install/create/pl.c +++ b/usr.sbin/pkg_install/create/pl.c @@ -204,7 +204,7 @@ copy_plist(const char *home, Package *plist) p->name); last_chdir = home; } - if (add_count < 0 || add_count > maxargs - where_count) { + if (add_count < 0 || add_count >= maxargs - where_count) { cleanup(0); errx(2, "%s: oops, miscounted strings!", __func__); } @@ -242,7 +242,7 @@ copy_plist(const char *home, Package *plist) " -C %s %s", mythere ? mythere : where, p->name); - if (add_count < 0 || add_count > maxargs - where_count) { + if (add_count < 0 || add_count >= maxargs - where_count) { cleanup(0); errx(2, "%s: oops, miscounted strings!", __func__); } |