static int marks['z' - 'a'];
In this case c is the character read and index is out of bounds. We
need marks[c - 'a']
While playing around with optimization settings gcc caught caught this.
Also fix one check for c, change from isalpha to islower.
From 2cc36818283e9068576c1042690c016a81b709a3 Mon Sep 17 00:00:00 2001
From: Evan Gates <firstname.lastname@example.org>
Date: Fri, 15 Jul 2016 09:52:39 -0700
Subject: [PATCH] fix marks indexing
This allows users to touch files they have write access to, but aren't the
Also, remove utime.h include (not necessary since
4132561c17), and make sure to check the return
value of localtime (potentially preventing a NULL pointer derefence).
Currently, if the caller has a umask of 002 or 000, the file gets created as 644
Also, add O_WRONLY to the open call, since POSIX says that "Applications shall
specify exactly one of the first five values (file access modes) below in the
value of oflag".
Currently, if you specify -t x, then s is advanced once in the switch statement
to determine the length, and then once again in the for loop, resulting in a
read past the end of the argument.
Also, use sizeof(int) when no length is specified, as specified by POSIX.
I'm not sure if there are other implications of this or not, but
the issue is that columns() uses len to store the allocated buffer
size, but linecmp() compares up to len bytes. If those trailing
bytes do not match, the line is considered not matching, even though
the relevant parts of the buffer do match.
To resolve this, also keep track of column capacity. Additionally,
since there is no reason to keep the existing data when resizing,
just use free and emalloc rather than erealloc.
The simplest case I could reduce it to is this:
if [ "$(printf '%s\n' a a xxb xxc | ./sort -u)" = "$(printf '%s\n' a xxb xxc)" ] ; then
- After first iteration, set first to 0 instead of !first.
- If Hflag || Lflag, then mkent used stat instead of lstat, so the
entity cannot be a symlink.
- Print path prefix along with directory name.
- In the 'if (Rflag)' block, just use 1 instead of Rflag.
Previously, it printed lines that didn't match some pattern. Instead,
it should print lines that don't match *any* pattern.
out=$(echo foo | ./grep -v -e foo -e bar)
if [ "$?" = 1 ] && [ -z "$out" ] ; then
This provides a reliable and portable way to
test whether an environment variable is defined.
(Of course, if you are using glibc you may get
false positives if you include a = in the query.)
Signed-off-by: Mattias Andrée <email@example.com>
In eb9bda8787, a bug was introduced in the
handling of -1 return values from getline. Since the type of the len
field in struct line is unsigned, the break condition was never true.
This caused sort -c to never succeed.
A bug was introduced in the NUL support refactor leading to
the length of the previous line only being saved if the
previous line was shorter than the current line. If triggered
this lead to copying too much data into the previous line buffer.
printf '1234\na\n' | ./uniq
printf '1234\na\n' | ./uniq