summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dpkg-split/split.c18
-rw-r--r--src/packages.c12
2 files changed, 12 insertions, 18 deletions
diff --git a/dpkg-split/split.c b/dpkg-split/split.c
index c41286f69..b886f2a51 100644
--- a/dpkg-split/split.c
+++ b/dpkg-split/split.c
@@ -41,6 +41,7 @@
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/path.h>
+#include <dpkg/string.h>
#include <dpkg/subproc.h>
#include <dpkg/buffer.h>
#include <dpkg/ar.h>
@@ -255,17 +256,12 @@ do_split(const char *const *argv)
if (prefix && *argv)
badusage(_("--split takes at most a source filename and destination prefix"));
if (!prefix) {
- char *palloc;
- int l;
-
- l = strlen(sourcefile);
- palloc = nfmalloc(l + 1);
- strcpy(palloc, sourcefile);
- if (strcmp(palloc + l - (sizeof(DEBEXT) - 1), DEBEXT) == 0) {
- l -= (sizeof(DEBEXT) - 1);
- palloc[l] = '\0';
- }
- prefix = palloc;
+ size_t sourcefile_len = strlen(sourcefile);
+
+ if (str_match_end(sourcefile, DEBEXT))
+ sourcefile_len -= strlen(DEBEXT);
+
+ prefix = nfstrnsave(sourcefile, sourcefile_len);
}
mksplit(sourcefile, prefix, opt_maxpartsize, opt_msdos);
diff --git a/src/packages.c b/src/packages.c
index 7b4e427c3..c063dcbee 100644
--- a/src/packages.c
+++ b/src/packages.c
@@ -41,6 +41,7 @@
#include <dpkg/pkg-list.h>
#include <dpkg/pkg-queue.h>
#include <dpkg/pkg-spec.h>
+#include <dpkg/string.h>
#include <dpkg/options.h>
#include "filesdb.h"
@@ -114,13 +115,10 @@ enqueue_specified(const char *const *argv)
badusage(_("--%s needs a valid package name but '%.250s' is not: %s"),
cipaction->olong, thisarg, err.str);
- if (pkg->status == stat_notinstalled) {
- size_t l = strlen(pkg->set->name);
- const char *extension = pkg->set->name + l - sizeof(DEBEXT) + 1;
-
- if (l >= sizeof(DEBEXT) && strcmp(extension, DEBEXT) == 0)
- badusage(_("you must specify packages by their own names,"
- " not by quoting the names of the files they come in"));
+ if (pkg->status == stat_notinstalled &&
+ str_match_end(pkg->set->name, DEBEXT)) {
+ badusage(_("you must specify packages by their own names, "
+ "not by quoting the names of the files they come in"));
}
enqueue_package(pkg);
}