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
|
From: Svante Signell <svante.signell@gmail.com>
Description: Avoid usage of PATH_MAX
fix the GNU/Hurd build by avoiding using PATH_MAX, since it is not defined.
Forwarded: no
Index: qstat/debug.c
===================================================================
--- qstat.orig/debug.c
+++ qstat/debug.c
@@ -111,12 +111,17 @@ malformed_packet(const struct qserver *s
static void
_dump_packet(const char *tag, const char *buf, int buflen)
{
- char fn[PATH_MAX] = { 0 };
- int fd;
- sprintf(fn, "%03u_%s.pkt", count++, tag);
+ char *fn = NULL;
+ int fd, len;
+ len = 3 + 1 + strlen(tag) + 4 + 1;
+ fn = malloc(len);
+ if(!fn) { perror("malloc"); return; }
+
+ snprintf(fn, len, "%03u_%s.pkt", count++, tag);
fprintf(stderr, "dumping to %s\n", fn);
fd = open(fn, O_WRONLY | O_CREAT | O_EXCL, 0644);
+ free(fn);
if (fd == -1) {
perror("open");
return;
|