X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Fnew_pair.c;h=2c3c2fb82a2d4c01420b5c8ba47372589a50d202;hp=c47e61e7e8d7eeca4acadd9d7b2c78cecc4986f1;hb=eccca377f55c70b12e3e92621d94d1e1c1fcfb7d;hpb=bfe3845eb1a2ff02a740e917b537e939ec4e44cb diff --git a/ncurses/base/new_pair.c b/ncurses/base/new_pair.c index c47e61e7..2c3c2fb8 100644 --- a/ncurses/base/new_pair.c +++ b/ncurses/base/new_pair.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2017,2018 Free Software Foundation, Inc. * + * Copyright (c) 2017-2018,2019 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -60,7 +60,7 @@ #endif -MODULE_ID("$Id: new_pair.c,v 1.17 2018/12/29 21:27:21 tom Exp $") +MODULE_ID("$Id: new_pair.c,v 1.18 2019/01/21 14:54:47 tom Exp $") #if NCURSES_EXT_COLORS @@ -102,13 +102,17 @@ dumpit(SCREEN *sp, int pair, const char *tag) char bigbuf[256 * 20]; char *p = bigbuf; int n; - sprintf(p, "%s", tag); - p += strlen(p); + size_t have = sizeof(bigbuf); + + _nc_STRCPY(p, tag, have); for (n = 0; n < sp->_pair_limit; ++n) { if (list[n].mode != cpFREE) { - sprintf(p, " %d%c(%d,%d)", - n, n == pair ? '@' : ':', list[n].next, list[n].prev); p += strlen(p); + if ((size_t) (p - bigbuf) + 50 > have) + break; + _nc_SPRINTF(p, _nc_SLIMIT(have - (p - bigbuf)) + " %d%c(%d,%d)", + n, n == pair ? '@' : ':', list[n].next, list[n].prev); } } T(("(%d/%d) %ld - %s",