[hackers] [sbase] enmasse: check filename length || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Thu, 23 Jun 2011 03:08:49 +0200 (CEST)

changeset: 93:0021d9f2b4e6
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Thu Jun 23 02:08:41 2011 +0100
files: LICENSE util/enmasse.c
description:
enmasse: check filename length

diff -r 60c036a99b20 -r 0021d9f2b4e6 LICENSE
--- a/LICENSE Wed Jun 22 23:45:03 2011 +0100
+++ b/LICENSE Thu Jun 23 02:08:41 2011 +0100
@@ -6,6 +6,7 @@
 © 2011 Rob Pilling <robpilling_AT_gmail.com>
 © 2011 Hiltjo Posthuma <hiltjo_AT_codemadness.org>
 © 2011 pancake <pancake_AT_youterm.com>
+© 2011 Random832 <random832_AT_fastmail.us>
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the "Software"),
diff -r 60c036a99b20 -r 0021d9f2b4e6 util/enmasse.c
--- a/util/enmasse.c Wed Jun 22 23:45:03 2011 +0100
+++ b/util/enmasse.c Thu Jun 23 02:08:41 2011 +0100
@@ -21,17 +21,16 @@
                 fnck(argv[0], argv[1], fn);
                 return;
         }
- else if(argc == 1)
- dir = ".";
         else
- dir = argv[--argc];
+ dir = (argc == 1) ? "." : argv[--argc];
 
         if((size = pathconf(dir, _PC_PATH_MAX)) == -1)
                 size = BUFSIZ;
         if(!(buf = malloc(size)))
                 eprintf("malloc:");
         for(i = 0; i < argc; i++) {
- snprintf(buf, size, "%s/%s", dir, basename(argv[i]));
+ if(snprintf(buf, size, "%s/%s", dir, basename(argv[i])) > size)
+ eprintf("%s/%s: filename too long\n", dir, basename(argv[i]));
                 fnck(argv[i], buf, fn);
         }
         free(buf);
Received on Thu Jun 23 2011 - 03:08:49 CEST

This archive was generated by hypermail 2.2.0 : Thu Jun 23 2011 - 03:12:05 CEST