--- popthelp.c.orig Sat Feb 24 21:05:36 2001 +++ popthelp.c Sat Feb 24 21:52:25 2001 @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef HAVE_ALLOCA_H #include @@ -80,15 +81,25 @@ *left = '\0'; if (opt->longName && opt->shortName) - sprintf(left, "-%c, --%s", opt->shortName, opt->longName); + g_snprintf(left, maxLeftCol, "-%c, --%s", opt->shortName, opt->longName); else if (opt->shortName) - sprintf(left, "-%c", opt->shortName); + g_snprintf(left, maxLeftCol, "-%c", opt->shortName); else if (opt->longName) - sprintf(left, "--%s", opt->longName); + g_snprintf(left, maxLeftCol, "--%s", opt->longName); if (!*left) return ; if (argDescrip) { - strcat(left, "="); - strcat(left, argDescrip); + char *src, *dst; + int rest = maxLeftCol - strlen(left); + if (rest > 0) { + strcat(left, "="); + rest--; + } + src = argDescrip; + dst = left + strlen(left); + while (rest > 0 && (*dst++ = *src++)) + rest--; + if (rest == 0) + *dst = '\0'; } if (help)