Skip to content

Commit

Permalink
remove unnecessary filename length check
Browse files Browse the repository at this point in the history
256 (or NAME_MAX) is not a reliable constant. furthermore, the
"fileName" in this case can be a full path as well, so checking against
NAME_MAX would be wrong regardless.

Closes: resurrecting-open-source-projects#247
  • Loading branch information
N-R-K committed May 6, 2023
1 parent 7ab1b65 commit 00231b1
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "scrot_selection.h"
#include "util.h"

#define STR_LEN_MAX_FILENAME(msg, fileName) do { \
if (strlen((fileName)) > MAX_FILENAME) { \
errx(EXIT_FAILURE, #msg " filename too long, must be " \
"less than %d characters", MAX_FILENAME); \
} \
} while(0)

#define checkMaxInputFileName(fileName) \
STR_LEN_MAX_FILENAME(input, (fileName))

enum {
MAX_FILENAME = 256, // characters
};

struct ScrotOptions opt = {
.quality = 75,
.lineStyle = LineSolid,
Expand Down Expand Up @@ -226,7 +212,6 @@ static void optionsParseSelection(const char *optarg)
if (errmsg)
errx(EXIT_FAILURE, "option --select: '%s' is %s", value, errmsg);
} else { // SELECTION_MODE_HIDE
checkMaxInputFileName(value);
opt.selection.fileName = value;
}
}
Expand Down

0 comments on commit 00231b1

Please sign in to comment.