GIMP Script-fu

sg-select-within-layer
Login

sg-select-within-layer

Command:
Within Layer
Menu:
"<Image>/Select/Within Layer"
PDB Name:
script-fu-sg-select-within-layer
Download:
sg-select-within-layer.scm (after the page appears, click on the "Download" command)
License:
GPLv2+

Description:

Make a selection that falls within the boundaries of the active layer.

If there is no selection when you run the script, it will select the entire layer. If there is a selection present when you run the script, it will reduce the selection to only the portion of it that intersects with the layer.