Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package no-more-secrets for openSUSE:Factory
checked in at 2021-09-27 20:08:47
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/no-more-secrets (Old)
and /work/SRC/openSUSE:Factory/.no-more-secrets.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "no-more-secrets"
Mon Sep 27 20:08:47 2021 rev:4 rq:921534 version:1.0.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/no-more-secrets/no-more-secrets.changes
2018-01-09 14:54:52.003094978 +0100
+++
/work/SRC/openSUSE:Factory/.no-more-secrets.new.1899/no-more-secrets.changes
2021-09-27 20:08:56.642464478 +0200
@@ -1,0 +2,16 @@
+Sun Sep 26 21:03:04 UTC 2021 - Michael Vetter <[email protected]>
+
+- Update to 1.0.1:
+ * Updated output for nms -v to match release version.
+
+-------------------------------------------------------------------
+Sun Sep 26 21:02:39 UTC 2021 - Michael Vetter <[email protected]>
+
+- Update to 1.0.0:
+ * Added cyan for color output.
+ * Fixed issues with the ncurses implementation.
+ * Improved code for getting input and error reporting.
+ * Turned on optimizations for the c compiler.
+ * Various other small code improvements and small bug/typo fixes.
+
+-------------------------------------------------------------------
Old:
----
no-more-secrets-0.3.3.tar.gz
New:
----
no-more-secrets-1.0.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ no-more-secrets.spec ++++++
--- /var/tmp/diff_new_pack.OML3W9/_old 2021-09-27 20:08:57.206465099 +0200
+++ /var/tmp/diff_new_pack.OML3W9/_new 2021-09-27 20:08:57.210465104 +0200
@@ -1,7 +1,7 @@
#
# spec file for package no-more-secrets
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,17 +12,17 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: no-more-secrets
-Version: 0.3.3
+Version: 1.0.1
Release: 0
Summary: A recreation of the "decrypting text" effect from the 1992
movie Sneakers
-License: GPL-3.0+
+License: GPL-3.0-or-later
Group: Amusements/Toys/Other
-Url: https://github.com/bartobri/%{name}
+URL: https://github.com/bartobri/%{name}
Source0:
https://github.com/bartobri/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
BuildRequires: ncurses-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-build
++++++ no-more-secrets-0.3.3.tar.gz -> no-more-secrets-1.0.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/.gitignore
new/no-more-secrets-1.0.1/.gitignore
--- old/no-more-secrets-0.3.3/.gitignore 2017-09-20 15:15:04.000000000
+0200
+++ new/no-more-secrets-1.0.1/.gitignore 2021-09-24 21:02:46.000000000
+0200
@@ -1,2 +1,3 @@
bin/*
obj/*
+.vs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/Makefile
new/no-more-secrets-1.0.1/Makefile
--- old/no-more-secrets-0.3.3/Makefile 2017-09-20 15:15:04.000000000 +0200
+++ new/no-more-secrets-1.0.1/Makefile 2021-09-24 21:02:46.000000000 +0200
@@ -13,11 +13,11 @@
SRC=src
CC ?= gcc
-CFLAGS ?= -Wextra -Wall
+CFLAGS ?= -Wextra -Wall -O2
.PHONY: all install uninstall clean
-nms: $(OBJ)/nmscharset.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o $(OBJ)/nms.o |
$(BIN)
+nms: $(OBJ)/input.o $(OBJ)/error.o $(OBJ)/nmscharset.o $(OBJ)/nmstermio.o
$(OBJ)/nmseffect.o $(OBJ)/nms.o | $(BIN)
$(CC) $(CFLAGS) -o $(BIN)/$@ $^
sneakers: $(OBJ)/nmscharset.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o
$(OBJ)/sneakers.o | $(BIN)
@@ -27,11 +27,11 @@
all-ncurses: nms-ncurses sneakers-ncurses
-nms-ncurses: $(OBJ)/nmscharset.o $(OBJ)/nmstermio_ncurses.o $(OBJ)/nmseffect.o
$(OBJ)/nms.o | $(BIN)
- $(CC) $(CFLAGS) -o $(BIN)/nms $^ -lncurses
+nms-ncurses: $(OBJ)/input.o $(OBJ)/error.o $(OBJ)/nmscharset.o
$(OBJ)/nmstermio_ncurses.o $(OBJ)/nmseffect.o $(OBJ)/nms.o | $(BIN)
+ $(CC) $(CFLAGS) -o $(BIN)/nms $^ -lncursesw
sneakers-ncurses: $(OBJ)/nmscharset.o $(OBJ)/nmstermio_ncurses.o
$(OBJ)/nmseffect.o $(OBJ)/sneakers.o | $(BIN)
- $(CC) $(CFLAGS) -o $(BIN)/sneakers $^ -lncurses
+ $(CC) $(CFLAGS) -o $(BIN)/sneakers $^ -lncursesw
$(OBJ)/%.o: $(SRC)/%.c | $(OBJ)
$(CC) $(CFLAGS) -o $@ -c $<
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/NCURSES.md
new/no-more-secrets-1.0.1/NCURSES.md
--- old/no-more-secrets-0.3.3/NCURSES.md 2017-09-20 15:15:04.000000000
+0200
+++ new/no-more-secrets-1.0.1/NCURSES.md 2021-09-24 21:02:46.000000000
+0200
@@ -8,7 +8,7 @@
```
sudo apt-get update
-sudo apt-get install lib32ncurses5-dev
+sudo apt-get install lib32ncursesw5-dev
```
#### Fedora Linux
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/README.md
new/no-more-secrets-1.0.1/README.md
--- old/no-more-secrets-0.3.3/README.md 2017-09-20 15:15:04.000000000 +0200
+++ new/no-more-secrets-1.0.1/README.md 2021-09-24 21:02:46.000000000 +0200
@@ -8,8 +8,8 @@
For reference, you can see this effect at 0:35 in [this movie
clip](https://www.youtube.com/watch?v=F5bAa6gFvLs&t=35).
This command works on piped data. Pipe any ASCII or UTF-8 text to `nms`,
-and it will apply the hollywood effect, initially showing encrypted data,
-then starting a decryption sequence to reveal the original plaintext
characters.
+and it will apply the Hollywood effect, initially showing encrypted data,
+then starting a decryption sequence to reveal the original plain-text
characters.

@@ -38,9 +38,9 @@
Download and Install
--------------------
-More and more unix/linux platforms are including this project in their
+More and more Unix/Linux platforms are including this project in their
package manager. You may wish to search your package manager to see if it
-is an installation option. If you install form a package manager, please
+is an installation option. If you install from a package manager, please
check that you have the latest version (`nms -v`). If not, I suggest
installing from source by following the instructions below.
@@ -121,7 +121,7 @@
Clear the screen prior to printing any output. Specifically,
it saves the state of the terminal (all current output), and restores it
-once the effect is comlpeted. Note that when using this option, `nms` requires
+once the effect is completed. Note that when using this option, `nms` requires
the user to press a key before restoring the terminal.
`-v`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/nms.6
new/no-more-secrets-1.0.1/nms.6
--- old/no-more-secrets-0.3.3/nms.6 2017-09-20 15:15:04.000000000 +0200
+++ new/no-more-secrets-1.0.1/nms.6 2021-09-24 21:02:46.000000000 +0200
@@ -22,7 +22,7 @@
.TP
.BI -f <COLOR>
set the foreground color of the decrypted text to the color specified.
-Valid options are white, yellow, black, magenta, blue (default), green, or red.
+Valid options are white, black, yellow, magenta, cyan, blue (default), green,
or red.
.SH DESCRIPTION
This command works on piped data. Pipe any ASCII or UTF-8 text to nms,
and it will apply the hollywood effect, seen on screen in the 1992 hacker
movie Sneakers.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/src/error.c
new/no-more-secrets-1.0.1/src/error.c
--- old/no-more-secrets-0.3.3/src/error.c 1970-01-01 01:00:00.000000000
+0100
+++ new/no-more-secrets-1.0.1/src/error.c 2021-09-24 21:02:46.000000000
+0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017 Brian Barto
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GPL License. See LICENSE for more details.
+ */
+
+#include <stdio.h>
+#include <stddef.h>
+#include <stdarg.h>
+
+#define ERROR_LIST_MAX 20
+#define ERROR_LENGTH_MAX 100
+
+static char error_stack[ERROR_LIST_MAX][ERROR_LENGTH_MAX];
+static int N = 0;
+
+void error_log(char *error, ...)
+{
+ va_list argList;
+
+ if (N < ERROR_LIST_MAX)
+ {
+ va_start(argList, error);
+ vsnprintf(error_stack[N++], ERROR_LENGTH_MAX - 1, error,
argList);
+ va_end(argList);
+ }
+}
+
+void error_print(void)
+{
+ int i;
+
+ for (i = N-1; i >= 0; --i)
+ {
+ fprintf(stderr, "%s ", error_stack[i]);
+ }
+ fprintf(stderr, "\n");
+}
+
+char *error_get(void)
+{
+ if (N > 0)
+ {
+ return error_stack[--N];
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+void error_clear(void)
+{
+ N = 0;
+}
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/src/error.h
new/no-more-secrets-1.0.1/src/error.h
--- old/no-more-secrets-0.3.3/src/error.h 1970-01-01 01:00:00.000000000
+0100
+++ new/no-more-secrets-1.0.1/src/error.h 2021-09-24 21:02:46.000000000
+0200
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2017 Brian Barto
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GPL License. See LICENSE for more details.
+ */
+
+#ifndef ERROR_H
+#define ERROR_H 1
+
+void error_log(char *, ...);
+void error_print(void);
+char *error_get(void);
+void error_clear(void);
+
+#endif
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/src/input.c
new/no-more-secrets-1.0.1/src/input.c
--- old/no-more-secrets-0.3.3/src/input.c 1970-01-01 01:00:00.000000000
+0100
+++ new/no-more-secrets-1.0.1/src/input.c 2021-09-24 21:02:46.000000000
+0200
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2017 Brian Barto
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GPL License. See LICENSE for more details.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+#include <time.h>
+#include <errno.h>
+#include "input.h"
+#include "error.h"
+
+int input_get(unsigned char** dest, char *prompt)
+{
+ int r, input_len;
+ fd_set input_stream;
+ struct timeval timeout;
+ void *timeout_p;
+
+ FD_ZERO(&input_stream);
+ input_len = 0;
+
+ timeout.tv_sec = 10;
+ timeout.tv_usec = 0;
+
+ if (isatty(STDIN_FILENO))
+ {
+ timeout_p = NULL;
+ if (prompt != NULL)
+ {
+ printf("%s", prompt);
+ fflush(stdout);
+ }
+ }
+ else
+ {
+ timeout_p = &timeout;
+ }
+
+ FD_SET(STDIN_FILENO, &input_stream);
+ r = select(FD_SETSIZE, &input_stream, NULL, NULL, timeout_p);
+ if (r < 0)
+ {
+ error_log("Error while waiting for input data. Errno: %i",
errno);
+ return -1;
+ }
+ if (r > 0)
+ {
+ r = ioctl(STDIN_FILENO, FIONREAD, &input_len);
+ if (r < 0)
+ {
+ error_log("Could not determine length of input. Errno:
%i", errno);
+ return -1;
+ }
+ if (input_len > 0)
+ {
+ *dest = malloc(input_len);
+ if (*dest == NULL)
+ {
+ error_log("Memory allocation error.");
+ return -1;
+ }
+ r = read(STDIN_FILENO, *dest, input_len);
+ if (r < 0)
+ {
+ error_log("Input read error. Errno: %i", errno);
+ return -1;
+ }
+ }
+ }
+
+ FD_CLR(STDIN_FILENO, &input_stream);
+
+ return input_len;
+}
+
+int input_get_str(char** dest, char *prompt)
+{
+ int r, i, input_len;
+ unsigned char *input;
+
+ r = input_get(&input, prompt);
+ if (r < 0)
+ {
+ error_log("Could not get input.");
+ return -1;
+ }
+
+ if (r > 0)
+ {
+ if (input[r - 1] == '\n')
+ {
+ --r;
+ if (r > 0 && input[r - 1] == '\r')
+ {
+ --r;
+ }
+ }
+ }
+
+ if (r == 0)
+ {
+ error_log("No input provided.");
+ return -1;
+ }
+
+ input_len = r;
+
+ *dest = malloc(input_len + 1);
+ if (*dest == NULL)
+ {
+ error_log("Memory allocation error.");
+ return -1;
+ }
+
+ memset(*dest, 0, input_len + 1);
+
+ for (i = 0; i < input_len; ++i)
+ {
+ if (isascii(input[i]))
+ {
+ (*dest)[i] = input[i];
+ }
+ else
+ {
+ error_log("Input contains non-ascii characters.");
+ return -1;
+ }
+ }
+
+ free(input);
+
+ return input_len;
+}
+
+int input_get_from_pipe(unsigned char** dest)
+{
+ int r;
+
+ if (isatty(STDIN_FILENO))
+ {
+ error_log("Input data from a piped or redirected source is
required.");
+ return -1;
+ }
+
+ r = input_get(dest, NULL);
+ if (r < 0)
+ {
+ error_log("Could not get input.");
+ return -1;
+ }
+ if (r == 0)
+ {
+ error_log("No input provided.");
+ return -1;
+ }
+
+ return r;
+}
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/src/input.h
new/no-more-secrets-1.0.1/src/input.h
--- old/no-more-secrets-0.3.3/src/input.h 1970-01-01 01:00:00.000000000
+0100
+++ new/no-more-secrets-1.0.1/src/input.h 2021-09-24 21:02:46.000000000
+0200
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2017 Brian Barto
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GPL License. See LICENSE for more details.
+ */
+
+#ifndef INPUT_H
+#define INPUT_H 1
+
+int input_get(unsigned char** dest, char *prompt);
+int input_get_str(char** dest, char *prompt);
+int input_get_from_pipe(unsigned char** dest);
+
+#endif
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/src/nms.c
new/no-more-secrets-1.0.1/src/nms.c
--- old/no-more-secrets-0.3.3/src/nms.c 2017-09-20 15:15:04.000000000 +0200
+++ new/no-more-secrets-1.0.1/src/nms.c 2021-09-24 21:02:46.000000000 +0200
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2017 Brian Barto
- *
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GPL License. See LICENSE for more details.
*/
@@ -10,67 +10,68 @@
#include <unistd.h>
#include <ctype.h>
#include "nmseffect.h"
+#include "input.h"
+#include "error.h"
-#define VERSION "0.3.3"
-#define INITIAL_CAPACITY 50
-#define INPUT_GROWTH_FACTOR 2
-
-int main(int argc, char *argv[]) {
- int c, o, i, inCapacity = INITIAL_CAPACITY;
- char *input = NULL;
-
- // Processing command arguments
- while ((o = getopt(argc, argv, "f:ascv")) != -1) {
- switch (o) {
+#define VERSION "1.0.1"
+
+int main(int argc, char *argv[])
+{
+ int r, o;
+ unsigned char *input;
+
+ input = NULL;
+
+ while ((o = getopt(argc, argv, "f:ascv")) != -1)
+ {
+ switch (o)
+ {
case 'f':
nmseffect_set_foregroundcolor(optarg);
break;
case 'a':
nmseffect_set_autodecrypt(1);
break;
- case 's':
- nmseffect_set_maskblank(1);
- break;
+ case 's':
+ nmseffect_set_maskblank(1);
+ break;
case 'c':
nmseffect_set_clearscr(1);
break;
case 'v':
printf("nms version " VERSION "\n");
- return 0;
+ return EXIT_SUCCESS;
case '?':
if (isprint(optopt))
- fprintf (stderr, "Unknown option
'-%c'.\n", optopt);
+ {
+ error_log("Unknown option '-%c'.",
optopt);
+ }
else
- fprintf (stderr, "Unknown option
character '\\x%x'.\n", optopt);
- return 1;
+ {
+ error_log("Unknown option character
'\\x%x'.", optopt);
+ }
+ error_print();
+ return EXIT_FAILURE;
}
}
-
- // Allocate memory for our input buffer
- if ((input = malloc(inCapacity + 1)) == NULL) {
- fprintf (stderr, "Memory Allocation Error! Quitting...\n");
- return 1;
- }
- // Geting input
- for (i = 0; (c = getchar()) != EOF; ++i) {
- if (i >= inCapacity) {
- inCapacity *= INPUT_GROWTH_FACTOR;
- input = realloc(input, inCapacity + 1);
- if (input == NULL) {
- fprintf (stderr, "Memory Allocation Error!
Quitting...\n");
- return 1;
- }
- }
- input[i] = c;
- input[i+1] = '\0';
+ r = input_get(&input, "Enter input: ");
+ if (r < 0)
+ {
+ error_log("Could not get input.");
+ error_print();
+ return EXIT_FAILURE;
+ }
+ else if (r == 0)
+ {
+ error_log("Input is empty.");
+ error_print();
+ return EXIT_FAILURE;
}
- // Execute effect
- c = nmseffect_exec(input);
+ r = nmseffect_exec(input, r);
- // Free allocated memory (not necessary here, but good practice)
free(input);
- return 0;
+ return EXIT_SUCCESS;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/src/nmseffect.c
new/no-more-secrets-1.0.1/src/nmseffect.c
--- old/no-more-secrets-0.3.3/src/nmseffect.c 2017-09-20 15:15:04.000000000
+0200
+++ new/no-more-secrets-1.0.1/src/nmseffect.c 2021-09-24 21:02:46.000000000
+0200
@@ -32,12 +32,9 @@
#define REVEAL_LOOP_SPEED 50 // miliseconds between each reveal loop
// Behavior settings
-static char *returnOpts = NULL; // Return option setting
static int autoDecrypt = 0; // Auto-decrypt flag
static int maskBlank = 0; // Mask blank spaces
static int colorOn = 1; // Terminal color flag
-static int inputPositionX = -1; // X coordinate for input position
-static int inputPositionY = -1; // Y coordinate for input position
// Character attribute structure, linked list. Keeps track of every
// character's attributes required for rendering and decryption effect.
@@ -58,25 +55,13 @@
* string that is provided as an argument. It returns the last character
* pressed by the user.
*/
-char nmseffect_exec(char *string) {
+char nmseffect_exec(unsigned char *string, int string_len) {
struct charAttr *list_pointer = NULL;
struct charAttr *list_head = NULL;
struct charAttr *list_temp = NULL;
- int i, revealed = 0;
+ int i, l, revealed = 0;
int maxRows, maxCols, curRow, curCol, origRow = 0, origCol = 0;
char ret = 0;
-
- // Error if we have an empty string.
- if (string == NULL || string[0] == '\0') {
- fprintf(stderr, "Error. Empty string.\n");
- return 0;
- }
-
- // Reassociate STDIN to the terminal if needed
- if (!isatty(STDIN_FILENO) && !freopen ("/dev/tty", "r", stdin)) {
- fprintf(stderr, "Error. Can't associate STDIN with
terminal.\n");
- return 0;
- }
// Needed for UTF-8 support
setlocale(LC_ALL, "");
@@ -108,8 +93,8 @@
curCol = origCol;
// Processing input
- for (i = 0; string[i] != '\0'; ++i) {
-
+ for (i = 0; i < string_len; ++i) {
+
// Don't go beyond maxRows
if (curRow - origRow >= maxRows - 1) {
break;
@@ -125,11 +110,12 @@
}
// Get character's byte-length and store character.
- if (mblen(&string[i], 4) > 0) {
- list_pointer->source = malloc(mblen(&string[i], 4) + 1);
- strncpy(list_pointer->source, &string[i],
mblen(&string[i], 4));
- list_pointer->source[mblen(&string[i], 4)] = '\0';
- i += (mblen(&string[i], 4) - 1);
+ l = mblen((char *)&string[i], 4);
+ if (l > 0) {
+ list_pointer->source = malloc(l + 1);
+ memcpy(list_pointer->source, &string[i], l);
+ list_pointer->source[l] = '\0';
+ i += (l - 1);
} else {
fprintf(stderr, "Unknown character encountered.
Quitting.\n");
nmstermio_restore_terminal();
@@ -283,29 +269,9 @@
nmseffect_sleep(REVEAL_LOOP_SPEED);
}
- // Flush any input up to this point
nmstermio_clear_input();
-
- // Check if user must select from a set of options
- if (returnOpts != NULL && strlen(returnOpts) > 0) {
-
- // Position cursor if necessary
- if (inputPositionY >= 0 && inputPositionX >= 0) {
- nmstermio_move_cursor(inputPositionY, inputPositionX);
- }
-
- nmstermio_show_cursor();
-
- // Get and validate user selection
- while (strchr(returnOpts, ret = nmstermio_get_char()) == NULL) {
- nmstermio_beep();
- }
-
- }
- // User must press a key to continue when clearSrc is set
- // without returnOpts
- else if (nmstermio_get_clearscr()) {
+ if (nmstermio_get_clearscr()) {
nmstermio_get_char();
}
@@ -335,18 +301,6 @@
}
/*
- * Copy the string argument to the 'returnOpts' variable. This string is
- * used to determine what character the user must choose from before
- * nmseffect_exec() returns execution to the calling function. Normally
- * this is left NULL. Use only when you want to present a menu with
- * selection choices to the user.
- */
-void nmseffect_set_returnopts(char *opts) {
- returnOpts = realloc(returnOpts, strlen(opts) + 1);
- strcpy(returnOpts, opts);
-}
-
-/*
* Set the autoDecrypt flag according to the true/false value of the
* 'setting' argument. When set to true, nmseffect_exec() will not
* require a key press to start the decryption effect.
@@ -394,18 +348,6 @@
}
/*
- * Set the desired coordinates of the cursor in the terminal window when
- * nmseffect_exec() gets the character selection from the user that is set
- * with nmseffect_set_returnopts().
- */
-void nmseffect_set_input_position(int x, int y) {
- if (x >= 0 && y >= 0) {
- inputPositionX = x;
- inputPositionY = y;
- }
-}
-
-/*
* Sleep for the number of milliseconds indicated by argument 't'.
*/
static void nmseffect_sleep(int t) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/src/nmseffect.h
new/no-more-secrets-1.0.1/src/nmseffect.h
--- old/no-more-secrets-0.3.3/src/nmseffect.h 2017-09-20 15:15:04.000000000
+0200
+++ new/no-more-secrets-1.0.1/src/nmseffect.h 2021-09-24 21:02:46.000000000
+0200
@@ -9,7 +9,7 @@
#define NMSEFFECT_H 1
// Function prototypes
-char nmseffect_exec(char *);
+char nmseffect_exec(unsigned char *, int string_len);
void nmseffect_set_foregroundcolor(char *);
void nmseffect_set_returnopts(char *);
void nmseffect_set_autodecrypt(int);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/src/nmstermio.c
new/no-more-secrets-1.0.1/src/nmstermio.c
--- old/no-more-secrets-0.3.3/src/nmstermio.c 2017-09-20 15:15:04.000000000
+0200
+++ new/no-more-secrets-1.0.1/src/nmstermio.c 2021-09-24 21:02:46.000000000
+0200
@@ -257,14 +257,14 @@
* reading/parsing its response.
*/
int nmstermio_get_cursor_row(void) {
- int i, r = 0;
+ int i, r;
int row = 0;
char buf[10];
char *cmd = "\033[6n";
memset(buf, 0, sizeof(buf));
- write(STDOUT_FILENO, cmd, sizeof(cmd));
+ r = write(STDOUT_FILENO, cmd, strlen(cmd));
r = read(STDIN_FILENO, buf, sizeof(buf));
@@ -294,6 +294,10 @@
struct termios tp;
static struct termios save;
static int state = 1;
+
+ if (!isatty(STDIN_FILENO)) {
+ stdin = freopen("/dev/tty", "r", stdin);
+ }
if (s == 0) {
if (tcgetattr(STDIN_FILENO, &tp) == -1) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/src/nmstermio_ncurses.c
new/no-more-secrets-1.0.1/src/nmstermio_ncurses.c
--- old/no-more-secrets-0.3.3/src/nmstermio_ncurses.c 2017-09-20
15:15:04.000000000 +0200
+++ new/no-more-secrets-1.0.1/src/nmstermio_ncurses.c 2021-09-24
21:02:46.000000000 +0200
@@ -11,6 +11,8 @@
* functionality is defined and implemented here.
*/
+#include <stdio.h>
+#include <unistd.h>
#include <string.h>
#include <ncurses.h>
@@ -25,6 +27,9 @@
* otherwise.
*/
void nmstermio_init_terminal(void) {
+ if (!isatty(STDIN_FILENO)) {
+ freopen("/dev/tty", "r", stdin);
+ }
initscr();
cbreak();
noecho();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/no-more-secrets-0.3.3/src/sneakers.c
new/no-more-secrets-1.0.1/src/sneakers.c
--- old/no-more-secrets-0.3.3/src/sneakers.c 2017-09-20 15:15:04.000000000
+0200
+++ new/no-more-secrets-1.0.1/src/sneakers.c 2021-09-24 21:02:46.000000000
+0200
@@ -13,8 +13,8 @@
int main(void) {
int termCols, spaces = 0;
- char input;
- char display[2000];
+ unsigned char *display_uc = NULL;
+ char *display = NULL;
char *head1Left = "DATANET PROC RECORD: 45-3456-W-3452";
char *head1Right = "Transnet on/xc-3";
char *head2Center = "FEDERAL RESERVE TRANSFER NODE";
@@ -32,9 +32,31 @@
// Get terminal dimentions (needed for centering)
struct winsize w;
- ioctl(0, TIOCGWINSZ, &w);
+ // if not an interactive tty, w is not populated, resulting in UB
+ if (ioctl(0, TIOCGWINSZ, &w) == -1) {
+ perror("Input not from an interactive terminal");
+ return 1;
+ }
termCols = w.ws_col;
+ // Allocate space for our display string
+ if ((display = malloc(20 * termCols)) == NULL)
+ {
+ fprintf(stderr, "Memory Allocation Error. Quitting!\n");
+ return 1;
+ }
+
+ // Allocate space for our display string
+ if ((display_uc = malloc(20 * termCols)) == NULL)
+ {
+ free(display);
+ fprintf(stderr, "Memory Allocation Error. Quitting!\n");
+ return 1;
+ }
+
+ memset(display, 0, 20 * termCols);
+ memset(display_uc, 0, 20 * termCols);
+
// Start building the display string
strcpy(display, head1Left);
@@ -158,16 +180,15 @@
}
strcat(display, foot2Center);
- // Settings
- nmseffect_set_input_position(((termCols - strlen(foot2Center)) / 2) +
2, 18);
- nmseffect_set_returnopts("123456");
nmseffect_set_clearscr(1);
- // Execut effect
- input = nmseffect_exec(display);
-
- // Print user choice
- printf("You chose %c\n", input);
+ memcpy(display_uc, display, 20 * termCols);
+
+ // Execute effect
+ nmseffect_exec(display_uc, strlen(display));
+
+ free(display);
+ free(display_uc);
return 0;
}