1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
From: Guido Scholz <gscholz@users.sourceforge.net>
Subject: Fix build failure on GNU/Hurd
Origin: upstream, https://sourceforge.net/p/srcpd/code/1777/
Bug: https://sourceforge.net/p/srcpd/bugs/25/
Index: src/srcp-server.c
===================================================================
--- a/src/srcp-server.c (Revision 1776)
+++ b/src/srcp-server.c (Arbeitskopie)
@@ -19,7 +19,7 @@
#define __server ((SERVER_DATA*)buses[0].driverdata)
-char PIDFILENAME[MAXPATHLEN] = "/var/run/srcpd.pid";
+char PIDFILENAME[255] = "/var/run/srcpd.pid";
/* This variable is accessible by several threads at the same time and
* should be protected by a lock */
@@ -88,9 +88,7 @@
else if (xmlStrcmp(child->name, BAD_CAST "pid-file") == 0) {
txt = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
if (txt != NULL) {
- strncpy((char *) &PIDFILENAME, (char *) txt,
- MAXPATHLEN - 2);
- PIDFILENAME[MAXPATHLEN - 1] = 0x00;
+ snprintf(PIDFILENAME, sizeof(PIDFILENAME), "%s", txt);
xmlFree(txt);
}
}
Index: src/srcpd.c
===================================================================
--- a/src/srcpd.c (Revision 1776)
+++ b/src/srcpd.c (Arbeitskopie)
@@ -39,7 +39,7 @@
/* structures to determine which port needs to be served */
fd_set rfds;
int maxfd;
-char conffile[MAXPATHLEN];
+char conffile[255];
extern char PIDFILENAME;
@@ -292,8 +292,7 @@
while ((c = getopt(argc, argv, "f:hvn")) != EOF) {
switch (c) {
case 'f':
- if (strlen(optarg) < MAXPATHLEN - 1)
- strcpy(conffile, optarg);
+ snprintf(conffile, sizeof(conffile), "%s", optarg);
break;
case 'v':
printf(WELCOME_MSG);
|