forked from gluster/glusterfs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
protocol/client: Initialize list head to prevent NULL de-reference
> Upstream patch: gluster@00761df > fixes: gluster#2443 > Change-Id: I86ef0270d41d6fb924db97fde3196d7c98c8b564 > Signed-off-by: Pranith Kumar K <[email protected]> BUG: 1689375 Change-Id: I86ef0270d41d6fb924db97fde3196d7c98c8b564 Signed-off-by: karthik-us <[email protected]> Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/245613 Tested-by: RHGS Build Bot <[email protected]> Reviewed-by: Ravishankar Narayanankutty <[email protected]> Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <[email protected]>
- Loading branch information
1 parent
adeec3d
commit f114ba2
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include <sys/file.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <errno.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
|
||
int | ||
main(int argc, char *argv[]) | ||
{ | ||
int fd = -1; | ||
char *filename = NULL; | ||
struct flock lock = { | ||
0, | ||
}; | ||
int i = 0; | ||
int ret = -1; | ||
|
||
if (argc != 2) { | ||
fprintf(stderr, "Usage: %s <filename> ", argv[0]); | ||
goto out; | ||
} | ||
|
||
filename = argv[1]; | ||
|
||
fd = open(filename, O_RDWR | O_CREAT, 0); | ||
if (fd < 0) { | ||
fprintf(stderr, "open (%s) failed (%s)\n", filename, strerror(errno)); | ||
goto out; | ||
} | ||
|
||
lock.l_start = 0; | ||
lock.l_type = F_RDLCK; | ||
lock.l_whence = SEEK_SET; | ||
lock.l_len = 2; | ||
|
||
ret = fcntl(fd, F_SETLK, &lock); | ||
if (ret < 0) { | ||
fprintf(stderr, "fcntl setlk failed (%s)\n", strerror(errno)); | ||
goto out; | ||
} | ||
|
||
lock.l_start = 2; | ||
lock.l_type = F_WRLCK; | ||
lock.l_whence = SEEK_SET; | ||
lock.l_len = 2; | ||
|
||
ret = fcntl(fd, F_SETLK, &lock); | ||
if (ret < 0) { | ||
fprintf(stderr, "fcntl setlk failed (%s)\n", strerror(errno)); | ||
goto out; | ||
} | ||
|
||
lock.l_start = 0; | ||
lock.l_type = F_RDLCK; | ||
lock.l_whence = SEEK_SET; | ||
lock.l_len = 4; | ||
|
||
ret = fcntl(fd, F_SETLK, &lock); | ||
if (ret < 0) { | ||
fprintf(stderr, "fcntl setlk failed (%s)\n", strerror(errno)); | ||
goto out; | ||
} | ||
out: | ||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
. $(dirname $0)/../../include.rc | ||
. $(dirname $0)/../../volume.rc | ||
cleanup; | ||
|
||
TEST glusterd | ||
TEST pidof glusterd | ||
TEST $CLI volume create $V0 $H0:$B0/brick0 | ||
TEST $CLI volume start $V0 | ||
TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0; | ||
|
||
build_tester $(dirname $0)/issue-2443-crash.c | ||
TEST mv $(dirname $0)/issue-2443-crash $M0 | ||
cd $M0 | ||
TEST ./issue-2443-crash a | ||
|
||
cd - | ||
cleanup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters