aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
...
* Remove trailing whitespaceGravatar Christoph Gysin2017-07-28
|
* Make it more portableGravatar Mykyta Holubakha2017-06-11
|
* Update README.mdGravatar benjiprod2017-05-05
| | | Dead link on AUR.
* Add AUR to READMEGravatar Hummer120072017-02-18
|
* Fix logical errorsGravatar Mykyta Holubakha2017-01-18
| | | | | | | | | | Restore device data only after successful read Do not set curr_brightness to max after an unsuccessful restore Fix ensure_dir Do not ignore ignore value of fread (fixes #6)
* Version bumpGravatar Mykyta Holubakha2017-01-17
|
* Readme hotfixGravatar Hummer120072017-01-17
|
* Readme hotfixGravatar Hummer120072017-01-17
|
* Updated readmeGravatar Mykyta Holubakha2017-01-17
|
* No longer require root privilegesGravatar Mykyta Holubakha2017-01-17
|
* Ensure state files are world-writableGravatar Mykyta Holubakha2017-01-15
|
* Refactor directory accessGravatar Mykyta Holubakha2017-01-15
| | | | Add static specifier to functions
* Updated makefileGravatar Mykyta Holubakha2017-01-15
|
* Fix a null-pointer dereference in read_deviceGravatar Mykyta Holubakha2017-01-15
|
* Merge pull request #5 from Miciah/various-fixesGravatar Hummer120072017-01-15
|\ | | | | Various fixes
| * Print error if run dir is not a directoryGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Print an error message if the run directory or the device-class subdirectory exists but is not a directory. Before: % rm -rf /tmp/brightnessctl % touch /tmp/brightnessctl % brightnessctl -s Device 'intel_backlight' of class 'backlight': Current brightness: 1000 (20%) Max brightness: 4794 % file /tmp/brightnessctl /tmp/brightnessctl: empty % After: % brightnessctl -s Error saving device data: Not a directory Could not save data for device 'intel_backlight'. Device 'intel_backlight' of class 'backlight': Current brightness: 1000 (20%) Max brightness: 4794 %
| * Clean up error handlingGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make several changes to error handling: • Check for negative values from sprintf, and treat them as errors. • Check for errors from fscanf both by comparing its return value against EOF and by checking ferror. • Avoiding calling perror with errno set to -1. Either set a meaningful value, such as EINVAL, or use fprintf if errno cannot be expected to have a meaningful value. • Instead of re-using errno for internal error handling, use a new variable to indicate errors where it makes sense to do so. • In read_device, print more specific error messages if we fail to read a device's current or max brightness, and print an error message immediately if a read fails, instead of only maybe at the end of read_device.
| * Do not write NUL to state fileGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not write a trailing NUL byte to the state file. Before: % brightnessctl -ms intel_backlight,backlight,1000,20%,4794 % od -t x1z /tmp/brightnessctl/backlight/intel_backlight 0000000 31 30 30 30 00 >1000.< 0000005 % After: % brightnessctl -ms intel_backlight,backlight,1000,20%,4794 % od -t x1z /tmp/brightnessctl/backlight/intel_backlight 0000000 31 30 30 30 >1000< 0000004 % Note that restore still works: % brightnessctl -mr intel_backlight,backlight,1000,20%,4794 %
| * Fix logic for directory creation when saving stateGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When creating the /tmp/brightnessctl directory or its subdirectories, clear errno before calling mkdir, and call stat a second time after mkdir. Previously, errno was not cleared, so even if the error was handled (by creating the missing directory with mkdir), subsequent error handling code read the old errno value from the failed stat call and printed an error message. Additionally, because we did not call stat again after calling mkdir, the stat buffer had outdated information, and so S_ISDIR returned a false negative. As a result of these defects, invoking brightnessctl -s when /tmp/brightnessctl did not exist would create /tmp/brightnessctl and fail. Invoking brightnessctl -s a second time would create /tmp/brightnessctl/backlight and fail. Invoking the command a third time would succeed and write the state file under /tmp/brightnessctl/backlight/. After this commit, brightnessctl -s succeeds the first time.
| * -r/--restore requires root, same as setGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | The -r/--restore flag requires root, the same as the set verb does, so print an error message if either the flag or the verb is used without running as root.
| * Set dev_name to default device nameGravatar Miciah Masters2017-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If no device is specified with the --device flag, set dev_name to the id of the first device. Before, if the --device flag is not used to specify the default device, the dev pointer was set to first device found (see commit c9140d1e5070dae2746d3b70c0390075bd5380f6), but the dev_name pointer was left set to NULL. As a result, some error messages did not print the name of the default device: % brightnessctl -s Error saving device data: No such file or directory Could not save data for device '(null)'. Device 'intel_backlight' of class 'backlight': Current brightness: 1000 (20%) Max brightness: 4794 % brightnessctl -s -m Error saving device data: No such file or directory Could not save data for device '(null)'. intel_backlight,backlight,1000,20%,4794 % After this commit, all error messages have the correct name: % brightnessctl -s Error saving device data: No such file or directory Could not save data for device 'intel_backlight'. Device 'intel_backlight' of class 'backlight': Current brightness: 1000 (20%) Max brightness: 4794 % brightnessctl -s -m Error saving device data: No such file or directory Could not save data for device 'intel_backlight'. intel_backlight,backlight,1000,20%,4794 %
| * Fix buffer overflow in cat_withGravatar Miciah Masters2017-01-09
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Account for separators when computing the buffer size in cat_width in order to avoid overflowing the buffer. Previously, cat_width only accounted for the lengths of the strings being catenated, but not the separators, which could result in buffer overflows. For example, trace the execution of the following invocation of cat_with: char s[5] = "xxxx"; cat_with(' ', s, s, s, s, s, s, s, s); cat_with initialises size and length and allocates an initial buffer: size = 32; /* size = 32 */ length = 0; /* length = 0 */ buf = calloc(1, size + 1); /* allocated 33 bytes for buf */ The first iteration of the main loop in cat_with catenates the first string and a separator but fails to account for the separator in length: length += strlen(curr); /* length = 4 */ while (length + 2 > size) /* 4 + 2 > 32 is false */ strcat(buf, curr); /* written 5 bytes to buf */ strcat(buf, split); /* written 6 bytes to buf */ Now we have written the string "xxxx " (6 bytes including NUL) to buf, but length only counts the 4 bytes "xxxx" (excluding NUL). In successive iterations, the discrepancy between the value in length and the actual length of the string in the buffer grows: length += strlen(curr); /* length = 8 */ while (length + 2 > size) /* 8 + 2 > 32 is false */ strcat(buf, curr); /* written 10 bytes to buf */ strcat(buf, split); /* written 11 bytes to buf */ Now we have written "xxxx xxxx " (11 bytes incl. NUL). length += strlen(curr); /* length = 12 */ while (length + 2 > size) /* 12 + 2 > 32 is false */ strcat(buf, curr); /* written 15 bytes to buf */ strcat(buf, split); /* written 16 bytes to buf */ Now we have written "xxxx xxxx xxxx " (16 bytes incl. NUL). length += strlen(curr); /* length = 16 */ while (length + 2 > size) /* 16 + 2 > 32 is false */ strcat(buf, curr); /* written 20 bytes to buf */ strcat(buf, split); /* written 21 bytes to buf */ Now we have written "xxxx xxxx xxxx xxxx " (21 bytes incl. NUL). length += strlen(curr); /* length = 20 */ while (length + 2 > size) /* 20 + 2 > 32 is false */ strcat(buf, curr); /* written 25 bytes to buf */ strcat(buf, split); /* written 26 bytes to buf */ Now we have written "xxxx xxxx xxxx xxxx xxxx " (26 bytes incl. NUL). length += strlen(curr); /* length = 24 */ while (length + 2 > size) /* 24 + 2 > 32 is false */ strcat(buf, curr); /* written 30 bytes to buf */ strcat(buf, split); /* written 31 bytes to buf */ Now we have written "xxxx xxxx xxxx xxxx xxxx xxxx " (31 bytes incl. NUL). Eventually, the string can grow beyond the buffer before length grows large enough to cause a re-allocation: length += strlen(curr); /* length = 28 */ while (length + 2 > size) /* 28 + 2 > 32 is false */ strcat(buf, curr); /* written 35 bytes to buf */ strcat(buf, split); /* written 36 bytes to buf */ Note that we have not increased size or re-allocated the buffer, and so we have written "xxxx xxxx xxxx xxxx xxxx xxxx xxxx" (35 bytes incl. NUL) to a buffer for which we have allocated only 33 bytes.
* Document prefix-sign supportGravatar Mykyta Holubakha2017-01-07
|
* Fix prefix-sign supportGravatar Mykyta Holubakha2017-01-07
|
* Support delta sign in prefixGravatar Hummer120072017-01-07
|
* Merge branch 'pr2' (by @Fale)Gravatar Mykyta Holubakha2016-11-27
|\ | | | | | | Closes: #2
| * Respect CFLAGS and sort it for easier readGravatar Fabio Alessandro Locati2016-11-27
| |
* | Merge pull request #4 from Fale/readmeGravatar Hummer120072016-11-27
|\| | | | | Improve readme and help
| * Improve readme and helpGravatar Fabio Alessandro Locati2016-11-27
|/
* Updated makefileGravatar Mykyta Holubakha2016-07-20
|
* Specify year and name in the licenseGravatar Mykyta Holubakha2016-07-20
|
* Added LICENSE, renamed PREFIX to DESTDIRGravatar Mykyta Holubakha2016-07-20
|
* Update READMEGravatar Mykyta Holubakha2016-07-20
|
* Version bumpGravatar Mykyta Holubakha2016-07-20
|
* do not write NUL to brightness fileGravatar Mykyta Holubakha2016-07-04
|
* refactored cat_withGravatar Mykyta Holubakha2016-07-04
|
* default device is the firstGravatar Mykyta Holubakha2016-06-22
|
* fix warnings, segfaultGravatar Mykyta Holubakha2016-06-22
|
* Code cleanupGravatar Mykyta Holubakha2016-04-26
|
* Close file handlesGravatar Mykyta Holubakha2016-04-07
|
* Updated READMEGravatar Mykyta Holubakha2016-04-07
|
* Addeed support for save/restore functionalityGravatar Mykyta Holubakha2016-04-07
|
* Added readme fileGravatar Mykyta Holubakha2016-03-28
|
* Initial commitGravatar Mykyta Holubakha2016-03-28