diff options
author | brian <brian@FreeBSD.org> | 2001-08-20 21:24:38 +0800 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2001-08-20 21:24:38 +0800 |
commit | cb15175a84cc17a68cfb38d0a5087293e6e6c5a3 (patch) | |
tree | dbef3ac49e03525c1bfb080e23f92db17aee515c /sysutils | |
parent | 8fa4572433b359334b924fbe96d6ff4005a4d774 (diff) | |
download | freebsd-ports-gnome-cb15175a84cc17a68cfb38d0a5087293e6e6c5a3.tar.gz freebsd-ports-gnome-cb15175a84cc17a68cfb38d0a5087293e6e6c5a3.tar.zst freebsd-ports-gnome-cb15175a84cc17a68cfb38d0a5087293e6e6c5a3.zip |
Handle snprintf() returning -1.
MFC after: 2 weeks
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/diskcheckd/files/diskcheckd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sysutils/diskcheckd/files/diskcheckd.c b/sysutils/diskcheckd/files/diskcheckd.c index 558b583f6c39..cb79a08944ba 100644 --- a/sysutils/diskcheckd/files/diskcheckd.c +++ b/sysutils/diskcheckd/files/diskcheckd.c @@ -443,8 +443,9 @@ updateproctitle(struct disk *disks) { p += sizeof _PATH_DEV - 1; percent = 100 * (double)dseek(dp, 0, SEEK_CUR) / dp->size; - if ((size_t)(ret = snprintf(bp, size, - "%s %.2f%%, ", p, percent)) >= size) { + if ((ret = snprintf(bp, size, "%s %.2f%%, ", p, percent)) == -1) + ret = 0; + if ((size_t)ret >= size) { inc = ((ret + 1023) >> 10) << 10; size += inc; bufsize += inc; @@ -456,6 +457,8 @@ updateproctitle(struct disk *disks) { } bp = buf + bufsize - size; ret = snprintf(bp, size, "%s %.2f%%, ", p, percent); + if (ret == -1) + ret = 0; } bp += ret; size -= ret; |