pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pkg/58578: pkgin(1) doesn't handle blanks in /usr/pkg/etc/pkgin/repositories.conf
>Number: 58578
>Category: pkg
>Synopsis: pkgin(1) doesn't handle blanks in /usr/pkg/etc/pkgin/repositories.conf
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Aug 11 05:55:00 +0000 2024
>Originator: RVP
>Release: NetBSD/amd64 10.99.11
>Organization:
>Environment:
NetBSD/amd64 10.99.11
>Description:
pkgin(1) doesn't handle blanks in /usr/pkg/etc/pkgin/repositories.conf
very well. Add leading or trailings blanks to the URL there and pkgin
does silly things.
>How-To-Repeat:
As above; then do `pkgin update'.
>Fix:
Trim blanks from URLs
---START patch---
diff -urN pkgin-22.10.0.orig/fsops.c pkgin-22.10.0/fsops.c
--- pkgin-22.10.0.orig/fsops.c 2022-10-05 17:19:10.000000000 +0000
+++ pkgin-22.10.0/fsops.c 2023-03-24 07:12:52.029452000 +0000
@@ -112,6 +112,12 @@
if (fgets(buf, BUFSIZ, fp) == NULL)
continue;
+ for (tmp = buf; isspace((unsigned char )*tmp); tmp++)
+ /* EMPTY */ ;
+ if (strlen(tmp) == 0)
+ continue;
+ memmove(buf, tmp, strlen(tmp) + 1);
+
if (strncmp(buf, "ftp://", 6) != 0 &&
strncmp(buf, "http://", 7) != 0 &&
strncmp(buf, "https://", 8) != 0 &&
diff -urN pkgin-22.10.0.orig/tools.c pkgin-22.10.0/tools.c
--- pkgin-22.10.0.orig/tools.c 2022-10-05 17:19:10.000000000 +0000
+++ pkgin-22.10.0/tools.c 2023-03-24 07:09:32.862474000 +0000
@@ -46,25 +46,15 @@
}
/*
- * Remove trailing \n or \r\n, returning length of resulting string.
+ * Remove all trailing space chars., returning length of resulting string.
*/
size_t
trimcr(char *str)
{
- size_t len;
-
- if (str == NULL)
- return (0);
-
- len = strlen(str);
-
- if (str[len - 1] == '\n')
- str[--len] = '\0';
-
- if (str[len - 1] == '\r')
- str[--len] = '\0';
-
- return (len);
+ char* p = str + strlen(str);
+ while (p > str && isspace((unsigned char )*(p - 1)))
+ *--p = '\0';
+ return (size_t)(p - str);
}
void
---END patch---
Note, this was made for 22.10.0, but, it still applies cleanly with a
bit of fuzz.
Home |
Main Index |
Thread Index |
Old Index