Comments (8)
Github doesn't understand "partially fixes" and keeps closing this, pretty annoying. :/
But in any case, strftime
is still happening on a fixed length buffer. So I don't think this is fully fixed.
from scrot.
I think the only remaining issue now is the strftime
buffer. This would (almost) fix it:
Stream ret = {0};
long hostNameMax = 0;
- char strf[4096];
+ char *strf = NULL;
+ size_t strfSize = 64;
char *tmp;
struct stat st;
- if (strftime(strf, 4095, str, tm) == 0)
- errx(EXIT_FAILURE, "strftime returned 0");
+ do {
+ strfSize *= 2;
+ strf = erealloc(strf, strfSize);
+ } while (strftime(strf, strfSize, str, tm) == 0); /* FIXME: infinite loop */
imlib_context_set_image(im);
But the problem is strftime can validly return 0 and there's no way to distinguish between a valid 0 return vs a 0 return due to small buffer.
from scrot.
Filenames can't be the null string, dirname
and basename
will guarantee that the destination is at least "."
when #226 is fixed.
I've been reading books instead of contributing as of late.
from scrot.
From the strftime
manpage:
Note that the return value 0 does not necessarily indicate an error. For example, in many
locales %p yields an empty string.
So if someone does scrot "%p"
strftime may "validly" return a zero. I don't think the chdir
will fix that.
I've been reading books instead of contributing as of late.
It's voluntary work, do it at your own pace :)
from scrot.
Maybe we can use strptime()
then.
https://pubs.opengroup.org/onlinepubs/007904875/functions/strptime.html
Or, set the first byte to zero, call strftime()
, and if it's still 0 after the call and the size of the buffer is greater than 2 bytes, strftime()
created a null string.
from scrot.
and if it's still 0 after the call and the size of the buffer is greater than 2 bytes
In the case of error 0 return, the contents of buf
is undefined.
If the length of the result string (including the terminating null byte) would exceed max bytes, then strftime() returns 0, and the contents of the array are undefined.
So we can't read the contents of the buffer to make any conclusions.
Maybe we can use strptime() then.
I'll take a look into it.
from scrot.
POSIX says unspecified. It's unlikely an an implementation wouldn't output directly to the buffer anyway.
from scrot.
If the output file is an absolute path (starts with '/'
), then strftime()
can't create a 0-sized string. If the output file isn't an absolute path, prepending "./"
to it is harmless and prevents the creation of a 0-sized string.
from scrot.
Related Issues (20)
- XChangeProperty() errors aren't checked HOT 1
- assert() showing up in OS packages
- Document the minimum version for dependencies HOT 7
- Scrot needs patching to be packaged on Termux HOT 5
- The license in our README is wrong HOT 4
- Support shell completion
- `--enable-libbsd-feature-test` is unsound
- Add Termux to CI HOT 1
- scrot: received DestroyNotify event HOT 1
- Scrot doesn't capture VLC fullscreen HOT 3
- selection edge: detect selection repaint more reliably
- Add additional CI targets HOT 2
- screenshot of a 10bpc screen comes out 8bit HOT 3
- build failure on SmartOS and other Solaris-based systems due to `dprintf` HOT 2
- lack of information when scrot renames the output file because it already exists HOT 3
- image quality issues HOT 2
- Selection via keyboard
- --freeze by default, when using scrot -s HOT 3
- unicode hyphen in man page instead of ASCII hyphen-minus HOT 2
- How to save screenshots to a specific directory HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scrot.