Update of /cvsroot/netrek/client/netrekxp/src
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26472/src
Modified Files:
parsemeta.c
Log Message:
Changed how metarefresh() handes comment/address field, so it now has a sanity
check on the length of both, not just on comment.
Index: parsemeta.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/parsemeta.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- parsemeta.c 1 Dec 2006 00:43:11 -0000 1.18
+++ parsemeta.c 1 Dec 2006 00:49:56 -0000 1.19
@@ -1182,7 +1182,7 @@
/* Refresh line i in the list */
{
struct servers *sp;
- char comment[LINE];
+ char serverline[LINE];
char buf[LINE + 1];
#ifdef METAPING
@@ -1203,29 +1203,26 @@
if (metablock(sp->address))
return;
+ /* Ensure comment/address field not longer than we want */
#ifdef METAPING
if (metaPing)
{
if (strlen(sp->comment))
- {
- strncpy(comment, sp->comment, 34);
- comment[34] = '\0';
- sprintf(buf, "%-34s ", comment);
- }
+ strncpy(serverline, sp->comment, 34);
else
- sprintf (buf, "%-34s ", sp->address);
+ strncpy(serverline, sp->address, 34);
+ serverline[34] = '\0';
+ sprintf(buf, "%-34s ", serverline);
}
else
{
#endif
if (strlen(sp->comment))
- {
- strncpy(comment, sp->comment, 40);
- comment[40] = '\0';
- sprintf(buf, "%-40s ", comment);
- }
+ strncpy(serverline, sp->comment, 40);
else
- sprintf (buf, "%-40s ", sp->address);
+ strncpy(serverline, sp->address, 40);
+ serverline[40] = '\0';
+ sprintf(buf, "%-40s ", serverline);
#ifdef METAPING
}
#endif