mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-08 12:28:00 -05:00
Check return value of fgets calls
Prevents compiler warnings with -D_FORTIFY_SOURCE=2 Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
686b8c1463
commit
60de8ec932
@ -657,7 +657,9 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
||||
goto error;
|
||||
}
|
||||
while(!feof(fp)) {
|
||||
fgets(line, 255, fp);
|
||||
if(fgets(line, 256, fp) == NULL) {
|
||||
break;
|
||||
}
|
||||
_alpm_strtrim(line);
|
||||
if(strcmp(line, "%DEPENDS%") == 0) {
|
||||
while(fgets(line, sline, fp) && strlen(_alpm_strtrim(line))) {
|
||||
@ -693,7 +695,9 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
||||
snprintf(path, PATH_MAX, "%sdeltas", pkgpath);
|
||||
if((fp = fopen(path, "r"))) {
|
||||
while(!feof(fp)) {
|
||||
fgets(line, 255, fp);
|
||||
if(fgets(line, 256, fp) == NULL) {
|
||||
break;
|
||||
}
|
||||
_alpm_strtrim(line);
|
||||
if(strcmp(line, "%DELTAS%") == 0) {
|
||||
while(fgets(line, sline, fp) && strlen(_alpm_strtrim(line))) {
|
||||
|
@ -324,8 +324,7 @@ static int grep(const char *fn, const char *needle)
|
||||
while(!feof(fp)) {
|
||||
char line[1024];
|
||||
int sline = sizeof(line)-1;
|
||||
fgets(line, sline, fp);
|
||||
if(feof(fp)) {
|
||||
if(fgets(line, sline, fp) == NULL) {
|
||||
continue;
|
||||
}
|
||||
if(strstr(line, needle)) {
|
||||
|
Loading…
Reference in New Issue
Block a user