summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@dahyabhai.net>2013-11-19 13:59:12 -0500
committerNalin Dahyabhai <nalin@dahyabhai.net>2013-11-19 13:59:12 -0500
commit57222779f460df0730438535e72a9e20494dbe89 (patch)
treec89ca0817e48117315a4b52a669bb6c00da92847
parentf268e45ef21e7282f2d7ea9d0efcc281a3cad117 (diff)
downloadslapi-nis-57222779f460df0730438535e72a9e20494dbe89.tar.gz
slapi-nis-57222779f460df0730438535e72a9e20494dbe89.tar.xz
slapi-nis-57222779f460df0730438535e72a9e20494dbe89.zip
Remove a possible memmove() of 0 bytes
Don't bother memmove()ing a 0-byte chunk of data. Found by static analysis.
-rw-r--r--src/disp-nis.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/disp-nis.c b/src/disp-nis.c
index 5e0c883..b584765 100644
--- a/src/disp-nis.c
+++ b/src/disp-nis.c
@@ -770,10 +770,12 @@ client_read(struct plugin_state *state, struct dispatch_client *client)
client->client_query = query;
client->client_query_size = nlen;
/* Drop the fragment from the incoming
- * buffer. */
- memmove(client->client_inbuf,
- client->client_inbuf + (len + 4),
- client->client_inbuf_used - (len + 4));
+ * buffer by moving the rest forward. */
+ if ((len + 4) < client->client_inbuf_used) {
+ memmove(client->client_inbuf,
+ client->client_inbuf + (len + 4),
+ client->client_inbuf_used - (len + 4));
+ }
client->client_inbuf_used -= (len + 4);
}
if (last) {