diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-07-22 21:47:42 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-07-22 21:47:42 +0200 |
commit | 8703a0516f92819ea97d991984540332c061fe17 (patch) | |
tree | 338da09bb4f4f3f280e2ed7cbcc8698b9cb870de | |
parent | 422e7a0319bbb6e8ae87d5d37ed5674b4daf1bcb (diff) | |
download | gnunet-8703a0516f92819ea97d991984540332c061fe17.tar.gz gnunet-8703a0516f92819ea97d991984540332c061fe17.zip |
ensure psql fails hard if there is an error in the SQL (fixes #6437)
m--------- | contrib/build-common | 0 | ||||
-rw-r--r-- | src/pq/pq_connect.c | 4 | ||||
-rw-r--r-- | src/util/disk.c | 14 |
3 files changed, 9 insertions, 9 deletions
diff --git a/contrib/build-common b/contrib/build-common | |||
Subproject d81bbfabc2538932f631d3946bd6a9b95182b4f | Subproject 1915a74bbb4cd2ae9bc541a382dfebc37064a2f | ||
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c index e3a610922..881a158bb 100644 --- a/src/pq/pq_connect.c +++ b/src/pq/pq_connect.c | |||
@@ -172,6 +172,8 @@ apply_patch (struct GNUNET_PQ_Context *db, | |||
172 | "-f", | 172 | "-f", |
173 | buf, | 173 | buf, |
174 | "-q", | 174 | "-q", |
175 | "--set", | ||
176 | "ON_ERROR_STOP=1", | ||
175 | NULL); | 177 | NULL); |
176 | if (NULL == psql) | 178 | if (NULL == psql) |
177 | { | 179 | { |
@@ -415,7 +417,7 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db) | |||
415 | db->load_path)) | 417 | db->load_path)) |
416 | { | 418 | { |
417 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 419 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
418 | "Failed to load SQL statements from `%s'\n", | 420 | "Failed to load SQL statements from `%s*'\n", |
419 | db->load_path); | 421 | db->load_path); |
420 | PQfinish (db->conn); | 422 | PQfinish (db->conn); |
421 | db->conn = NULL; | 423 | db->conn = NULL; |
diff --git a/src/util/disk.c b/src/util/disk.c index 6560726ea..c95e9753c 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -1377,14 +1377,13 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, | |||
1377 | enum GNUNET_DISK_MapType access, | 1377 | enum GNUNET_DISK_MapType access, |
1378 | size_t len) | 1378 | size_t len) |
1379 | { | 1379 | { |
1380 | int prot; | ||
1381 | |||
1380 | if (NULL == h) | 1382 | if (NULL == h) |
1381 | { | 1383 | { |
1382 | errno = EINVAL; | 1384 | errno = EINVAL; |
1383 | return NULL; | 1385 | return NULL; |
1384 | } | 1386 | } |
1385 | |||
1386 | int prot; | ||
1387 | |||
1388 | prot = 0; | 1387 | prot = 0; |
1389 | if (access & GNUNET_DISK_MAP_TYPE_READ) | 1388 | if (access & GNUNET_DISK_MAP_TYPE_READ) |
1390 | prot = PROT_READ; | 1389 | prot = PROT_READ; |
@@ -1405,22 +1404,21 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, | |||
1405 | 1404 | ||
1406 | /** | 1405 | /** |
1407 | * Unmap a file | 1406 | * Unmap a file |
1407 | * | ||
1408 | * @param h mapping handle | 1408 | * @param h mapping handle |
1409 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | 1409 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
1410 | */ | 1410 | */ |
1411 | int | 1411 | int |
1412 | GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h) | 1412 | GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h) |
1413 | { | 1413 | { |
1414 | int ret; | 1414 | int ret; |
1415 | 1415 | ||
1416 | if (h == NULL) | 1416 | if (NULL == h) |
1417 | { | 1417 | { |
1418 | errno = EINVAL; | 1418 | errno = EINVAL; |
1419 | return GNUNET_SYSERR; | 1419 | return GNUNET_SYSERR; |
1420 | } | 1420 | } |
1421 | |||
1422 | ret = munmap (h->addr, h->len) != -1 ? GNUNET_OK : GNUNET_SYSERR; | 1421 | ret = munmap (h->addr, h->len) != -1 ? GNUNET_OK : GNUNET_SYSERR; |
1423 | |||
1424 | GNUNET_free (h); | 1422 | GNUNET_free (h); |
1425 | return ret; | 1423 | return ret; |
1426 | } | 1424 | } |
@@ -1429,7 +1427,7 @@ GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h) | |||
1429 | /** | 1427 | /** |
1430 | * Write file changes to disk | 1428 | * Write file changes to disk |
1431 | * @param h handle to an open file | 1429 | * @param h handle to an open file |
1432 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | 1430 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
1433 | */ | 1431 | */ |
1434 | int | 1432 | int |
1435 | GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h) | 1433 | GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h) |